Routines |
Prev: C1E0 | Up: Map | Next: C265 |
Used by the routine at C1E0.
|
||||||||||
Follows the previous routine. When Maroc enters a room this routine calculates doors and brickwork patterns based on the room's data set at 61A9.
See Trivia: Setting the scene(ry) for an explanation of how this routine evaluates the DOORS and BRICKWORK from the room data set.
|
||||||||||
C20F | LD ($EB7F),A | Store the above byte (in the A register calculated in the previous routine at C1F5) | ||||||||
C212 | LD A,($EB7E) | Get the current room data byte (from the current room data banks at 61A9) | ||||||||
C215 | RLA | Shift bits (6 & 7) left x 2 | ||||||||
C216 | RL C | ...Shifting them into bits 0 & 1 of the C register | ||||||||
C218 | RLA | |||||||||
C219 | RL C | |||||||||
C21B | LD ($EB7E),A | First two bits moved - now re-store the data byte for further shifts of the next ones later | ||||||||
C21E | LD A,C | We're only interested in bits 0 and 1 of the C register | ||||||||
C21F | AND $03 | So filter any others out | ||||||||
C221 | LD C,A | |||||||||
C222 | AND $01 | Check bit 0. If set, this indicates that there's a DOOR here. | ||||||||
C224 | JR Z,$C265 | ...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:
|
||||||||||
C226 | LD A,($EB79) | Item's vertical position within current room, in pixels, from top of room area. | ||||||||
C229 | LD ($EB4A),A | ...Copy byte into store | ||||||||
C22C | LD A,($EB78) | Horizontal position within current room, in half-character (4 pixel) steps. | ||||||||
C22F | LD ($EB48),A | ...Copy byte into store | ||||||||
C232 | LD A,($EB7F) | 0 = back wall, 1 = right wall, 2 = left wall | ||||||||
C235 | LD ($EB46),A | ...Copy byte into store | ||||||||
C238 | LD A,$02 | Graphic type = 2 (Door) | ||||||||
C23A | LD ($EB43),A | |||||||||
C23D | CALL $E0B0 | Copy the 16 bytes in the item's working data buffer at EB43 into a room item data set at 7C00. | ||||||||
DOOR FRAMES - set up/mirror graphics
Each door has a door frame, which is a separate graphic to be handled
|
||||||||||
C240 | LD A,$01 | Graphics type = 1 (fixed room scenery item, in this case a door frame) | ||||||||
C242 | LD ($EB43),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).
|
||||||||||
C245 | LD C,$14 | Redundant instruction as C value (offset) is set either at C24E (20) or C254 (21) | ||||||||
C247 | LD A,($EB7F) | 0 = Back wall door, 1 = Right wall door or 2 = Left wall door | ||||||||
C24A | CP $00 | |||||||||
C24C | JR NZ,$C254 | |||||||||
C24E | LD C,$14 | Back wall - Graphics offset = (20-1)*2 + 38851 = 97E9 (Door frame - back wall) | ||||||||
C250 | LD A,$01 | Frame offset (= no offset needed) | ||||||||
C252 | JR $C256 | |||||||||
C254 | LD C,$15 | Side wall - Graphics offset = (21-1)*2 + 38851 = 97EB (Door frame - side wall) | ||||||||
Set up and mirror graphics for door frame
|
||||||||||
C256 | LD ($EB50),A | Store calculated frame offset | ||||||||
C259 | LD A,($EB77) | Get level style offset (for to graphic pointers at 97C3). This is 12 if room number >=84 (cavern levels), otherwise 0 (brick levels). |
||||||||
C25C | 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 | ||||||||
C25D | CALL $E0C2 | Call setup graphics routine (copy graphics address pointers), mirror any relevant graphic data | ||||||||
C260 | CALL $E0B0 | Copy the 16 bytes of calculated graphics data from the working buffer at EB43 into one of the the room item data sets at 7C00. | ||||||||
C263 | JR $C2C2 |
Prev: C1E0 | Up: Map | Next: C265 |