Prev: 49632 Up: Map Next: 49765
49679: Set up room background scenery - part 2
Used by the routine at 49632.
Input
A Byte calculated in the previous routine at 49653, either 0, 1 or 2, indicating whether to deal with objects on the back, right or left wall respectively
C The incremental counter byte stored at 60285 and used to count room elements
Follows the previous routine. When Maroc enters a room this routine calculates doors and brickwork patterns based on the room's data set at 25001.
See Trivia: Setting the scene(ry) for an explanation of how this routine evaluates the DOORS and BRICKWORK from the room data set.
49679 LD (60287),A Store the above byte (in the A register calculated in the previous routine at 49653)
49682 LD A,(60286) Get the current room data byte (from the current room data banks at 25001)
49685 RLA Shift bits (6 & 7) left x 2
49686 RL C ...Shifting them into bits 0 & 1 of the C register
49688 RLA
49689 RL C
49691 LD (60286),A First two bits moved - now re-store the data byte for further shifts of the next ones later
49694 LD A,C We're only interested in bits 0 and 1 of the C register
49695 AND 3 So filter any others out
49697 LD C,A
49698 AND 1 Check bit 0. If set, this indicates that there's a DOOR here.
49700 JR Z,49765 ...If it's NOT set, skip over the next routine to check for BRICKWORK patterns
DOOR identified from room data set. Check where in the room it is:
49702 LD A,(60281) Item's vertical position within current room, in pixels, from top of room area.
49705 LD (60234),A ...Copy byte into store
49708 LD A,(60280) Horizontal position within current room, in half-character (4 pixel) steps.
49711 LD (60232),A ...Copy byte into store
49714 LD A,(60287) 0 = back wall, 1 = right wall, 2 = left wall
49717 LD (60230),A ...Copy byte into store
49720 LD A,2 Graphic type = 2 (Door)
49722 LD (60227),A
49725 CALL 57520 Copy the 16 bytes in the item's working data buffer at 60227 into a room item data set at 31744.
DOOR FRAMES - set up/mirror graphics
Each door has a door frame, which is a separate graphic to be handled
49728 LD A,1 Graphics type = 1 (fixed room scenery item, in this case a door frame)
49730 LD (60227),A
The byte calculated earlier (0, 1 or 2) indicates whether the item is on the back wall, right wall or left wall, so the following instructions use this information to work out the graphics address offset (in C register).
49733 LD C,20 Redundant instruction as C value (offset) is set either at 49742 (20) or 49748 (21)
49735 LD A,(60287) 0 = Back wall door, 1 = Right wall door or 2 = Left wall door
49738 CP 0
49740 JR NZ,49748
49742 LD C,20 Back wall - Graphics offset = (20-1)*2 + 38851 = 38889 (Door frame - back wall)
49744 LD A,1 Frame offset (= no offset needed)
49746 JR 49750
49748 LD C,21 Side wall - Graphics offset = (21-1)*2 + 38851 = 38891 (Door frame - side wall)
Set up and mirror graphics for door frame
49750 LD (60240),A Store calculated frame offset
49753 LD A,(60279) Get level style offset (for to graphic pointers at 38851).
This is 12 if room number >=84 (cavern levels), otherwise 0 (brick levels).
49756 ADD A,C Add the offset (20 or 21) to graphics offset addresses depending on whether the door frame is on the back or side wall
49757 CALL 57538 Call setup graphics routine (copy graphics address pointers), mirror any relevant graphic data
49760 CALL 57520 Copy the 16 bytes of calculated graphics data from the working buffer at 60227 into one of the the room item data sets at 31744.
49763 JR 49858
Prev: 49632 Up: Map Next: 49765