Prev: 49600 Up: Map Next: 49679
49632: Set up room background scenery - part 1
Used by the routine at 49858.
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.
49632 LD A,(60285) Room setup counter (to be compared with room size data byte at 49858)
49635 DEC A The counter was pre-incremented in the earlier routine, so check its original value
49636 AND 3
49638 CP 0
49640 JR NZ,49653 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 25001).
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 25001 and advance room data address pointer, as we've dealt with the current byte
49642 LD HL,(60282) Get room data address pointer
49645 LD A,(HL) Get next room data byte
49646 INC HL Increment address pointer to next byte
49647 LD (60282),HL ...and re-store address pointer
49650 LD (60286),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 60287) to 0, 1 or 2 respectively.
The incremental counter (60285) 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.
49653 LD A,(60285) Incremental counter, which is checked against with 1st byte from the room data set (in the table at 25001) which indicates the room size
49656 CP 3
49658 JR NC,49664
49660 LD A,2 If the counter byte is < 3, we're looking at LEFT wall items - set A to 2, for storing at 60287 shortly
49662 JR 49679
49664 LD C,A If the counter byte is >=3 it could be the back or right wall
49665 LD A,(60284) ...Subtract it from the room data byte
49668 SUB C
49669 CP 2
49671 JR NC,49677
49673 LD A,1 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 60287 shortly
49675 JR 49679
49677 LD A,0 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 60287 shortly
Prev: 49600 Up: Map Next: 49679