Prev: C1C0 Up: Map Next: C20F
C1E0: Set up room background scenery - part 1
Used by the routine at C2C2.
Identify and set up (mirroring if required, and storing address pointers) for each room element. Includes fixed scenery items such as wall/floor connectors and door frames.
See Trivia: Setting the scene(ry) for information about how the room scenery is stored.
C1E0 LD A,($EB7D) Room setup counter (to be compared with room size data byte at C2C2)
C1E3 DEC A The counter was pre-incremented in the earlier routine, so check its original value
C1E4 AND $03
C1E6 CP $00
C1E8 JR NZ,$C1F5 Door and brickwork data that make up the room are stored in pairs of bits, so 4 to a byte.
After evaluating 4 pairs, the data byte is dealt with, so can be advanced to the next byte in the room data set (at 61A9).
So skip the next instructions (that advance the pointer to the next room data byte) if original counter byte (before INC) is 1,2,3 - 5,6,7 - 9,10,11 etc. (not a multiple of 4)
Get room data byte from 61A9 and advance room data address pointer, as we've dealt with the current byte
C1EA LD HL,($EB7A) Get room data address pointer
C1ED LD A,(HL) Get next room data byte
C1EE INC HL Increment address pointer to next byte
C1EF LD ($EB7A),HL ...and re-store address pointer
C1F2 LD ($EB7E),A Store room data byte
The next series of routines handle the graphics set-up for the door frames and doors in the room.
The following routine determines whether the items (doors and frames) being dealt with are on the back, right or left wall, and sets the A register (shortly to be stored at EB7F) to 0, 1 or 2 respectively.
The incremental counter (EB7D) is checked against the first room data byte, which indicates the room size .
  • If the counter's value is 1 or 2, we're dealing with frames and doors on the left wall.
  • If its value is one of its final two checks (room size - counter <= 2) it's on the right wall.
  • Anywhere in between these two options, we're dealing with the back wall.
C1F5 LD A,($EB7D) Incremental counter, which is checked against with 1st byte from the room data set (in the table at 61A9) which indicates the room size
C1F8 CP $03
C1FA JR NC,$C200
C1FC LD A,$02 If the counter byte is < 3, we're looking at LEFT wall items - set A to 2, for storing at EB7F shortly
C1FE JR $C20F
C200 LD C,A If the counter byte is >=3 it could be the back or right wall
C201 LD A,($EB7C) ...Subtract it from the room data byte
C204 SUB C
C205 CP $02
C207 JR NC,$C20D
C209 LD A,$01 If it's 0 or 1, the counter byte is on one of its last two values, so we're looking at the RIGHT wall - Set A to 1, for storing at EB7F shortly
C20B JR $C20F
C20D LD A,$00 If it's 2 or more, the counter byte is in between, so we're looking at the BACK wall - set A to 0, for storing at EB7F shortly
Prev: C1C0 Up: Map Next: C20F