![]() |
Routines |
| Prev: 49965 | Up: Map | Next: 50218 |
|
Used by the routine at 49965.
|
||||||||||||||||
|
Follows previous routine if a door is found in one of the room item data sets.
This routine:
|
||||||||||||||||
| 49993 | LD HL,(60282) | Pointer to the current data byte for the room (from the room data set at 25001) | ||||||||||||||
| 49996 | LD A,(HL) | Get byte from room data | ||||||||||||||
| 49997 | INC HL | Increment pointer | ||||||||||||||
| 49998 | LD (60282),HL | ...and re-store | ||||||||||||||
| 50001 | LD C,A | Temp store of connecting door set number (26512) in C register | ||||||||||||||
| 50002 | LD A,(60230) | Flag indicating where this door appears in the room: 0 = Back wall door 1 = Right wall door 2 = Left wall door |
||||||||||||||
| 50005 | LD (60287),A | Copy this byte to working data buffer | ||||||||||||||
| 50008 | LD A,C | Retrieve connecting door set number | ||||||||||||||
| 50009 | LD (60230),A | ...and store (replace) in room element data buffer | ||||||||||||||
| 50012 | LD A,(60084) | Current/existing connecting door set | ||||||||||||||
| 50015 | CP C | Compare with the set for this door - is this the door that Maroc has entered from? | ||||||||||||||
| 50016 | JR NZ,50062 | If not, jump over the next two sets of instructions (which set Maroc's room position based on this door) | ||||||||||||||
|
Maroc entered the room through this door, so set his new room position accordingly.
|
||||||||||||||||
| 50018 | LD A,(60232) | Horizontal position of door within current room, in half character (4 pixel) steps. | ||||||||||||||
| 50021 | LD (60277),A | Copy to Maroc's horizontal room entry position store | ||||||||||||||
| 50024 | LD A,(60234) | Vertical position within current room, in pixels, from top of room playing area | ||||||||||||||
| 50027 | SUB 12 | Slight height adjustment for the new room height entry point, so that Maroc enters through the lower part of right/left doors, or near the top of the room for vertical room entry | ||||||||||||||
| 50029 | LD (60278),A | Copy to Maroc's vertical room entry position store | ||||||||||||||
|
Next, set his vertical/horizontal facing direction
|
||||||||||||||||
| 50032 | LD A,(60287) | |||||||||||||||
| 50035 | CP 0 | |||||||||||||||
| 50037 | JR Z,50057 | |||||||||||||||
| 50039 | CP 1 | |||||||||||||||
| 50041 | JR Z,50050 | |||||||||||||||
| 50043 | LD A,254 | |||||||||||||||
| 50045 | LD (60075),A | Maroc is entering the room through a door on the left wall | ||||||||||||||
| 50048 | JR 50062 | |||||||||||||||
| 50050 | LD A,2 | |||||||||||||||
| 50052 | LD (60075),A | Maroc is entering the room through a door on the right wall | ||||||||||||||
| 50055 | JR 50062 | |||||||||||||||
| 50057 | LD A,254 | |||||||||||||||
| 50059 | LD (60076),A | Maroc is entering the room through a door on the back wall | ||||||||||||||
|
Calculate the address pointer to this door's connecting door set (at 26512), using the set number x 4 (as each set contains 4 bytes)
|
||||||||||||||||
| 50062 | LD HL,(56053) | Address pointer to the start of the connecting door sets - 26512 | ||||||||||||||
| 50065 | LD A,C | Retrieve the connecting door data set number | ||||||||||||||
| 50066 | LD D,0 | The offset will be calculated in the DE register pair, so set the high byte (D) to zero | ||||||||||||||
| 50068 | RLA | x2 | ||||||||||||||
| 50069 | RL D | |||||||||||||||
| 50071 | RLA | x4 | ||||||||||||||
| 50072 | RL D | If this causes a carry, rotate it into the D register | ||||||||||||||
| 50074 | AND 252 | Offset will be a multiple of 4, so filter out bits 0 & 1 as not needed | ||||||||||||||
| 50076 | LD E,A | |||||||||||||||
| 50077 | ADD HL,DE | Add the offset, so HL now points to the connecting door set for this door in the tables at 26512 | ||||||||||||||
| 50078 | LD (60228),HL | Store this address pointer in the door data buffer | ||||||||||||||
| 50081 | INC HL | Move along to byte 3 of 4 in the set (door properties) | ||||||||||||||
| 50082 | INC HL | |||||||||||||||
| 50083 | LD A,(HL) | |||||||||||||||
| 50084 | OR 5 | Set bits 0 (item visible on-screen) and 2 (item will need erasing before re-drawing) | ||||||||||||||
| 50086 | AND 253 | Filter out bit 1 (2) - (assume door is not hidden) | ||||||||||||||
| 50088 | LD (60238),A | ...and re-store | ||||||||||||||
|
The byte at 60287 is now used to determine which door graphic need to be set up/mirrored when Maroc enters a room.
For each door identified, the following routine sets the following registers:
|
||||||||||||||||
| 50091 | LD C,A | Store filtered byte in C register | ||||||||||||||
| 50092 | LD D,17 | Default frame offset value | ||||||||||||||
| 50094 | LD E,5 | Default value - total number of animation frames needed for door opening/closing. Back wall doors have 4 animation frames, side wall doors 5. | ||||||||||||||
| 50096 | LD L,0 | Height position offset of door (in pixels) | ||||||||||||||
| 50098 | LD A,(60287) | 0 = Back wall door 1 = Right wall door 2 = Left wall door |
||||||||||||||
| 50101 | CP 1 | |||||||||||||||
| 50103 | JR Z,50128 | |||||||||||||||
| 50105 | CP 0 | |||||||||||||||
| 50107 | JR Z,50145 | |||||||||||||||
|
Door on LEFT wall - set graphic address offset and door position offset
|
||||||||||||||||
| 50109 | LD B,2 | Horizontal position offset (in half-characters/4-pixel increments) | ||||||||||||||
| 50111 | LD L,246 | Height pixel position offset of door (-10) | ||||||||||||||
| 50113 | LD H,5 | Door 5 - closed door on left wall. Mirrored version of Door 2. | ||||||||||||||
| 50115 | LD D,245 | |||||||||||||||
| 50117 | LD A,C | Check bit 3 (open/closed) | ||||||||||||||
| 50118 | AND 8 | |||||||||||||||
| 50120 | JR Z,50162 | |||||||||||||||
| 50122 | LD D,17 | |||||||||||||||
| 50124 | LD H,1 | Door 1 - open door on left wall. | ||||||||||||||
| 50126 | JR 50162 | |||||||||||||||
|
Door on RIGHT wall - set graphic address offset and door position offset
|
||||||||||||||||
| 50128 | LD B,254 | Horizontal position offset (in half-characters/4-pixel increments) | ||||||||||||||
| 50130 | LD L,246 | Height pixel position offset of door (-10) | ||||||||||||||
| 50132 | LD H,2 | Door 2 - closed door on right wall. | ||||||||||||||
| 50134 | LD A,C | Check bit 3 (open/closed) | ||||||||||||||
| 50135 | AND 8 | |||||||||||||||
| 50137 | JR Z,50162 | |||||||||||||||
| 50139 | LD D,245 | |||||||||||||||
| 50141 | LD H,6 | Door 6 - open door on right wall. Mirrored version of Door 1. | ||||||||||||||
| 50143 | JR 50162 | |||||||||||||||
|
Door on BACK wall - set graphic address offset and door position offset
|
||||||||||||||||
| 50145 | LD B,253 | Horizontal position offset (in half-characters/4-pixel increments) | ||||||||||||||
| 50147 | LD E,4 | Number of animation frames needed for door opening/closing. Back wall doors have 4, side wall doors 5. | ||||||||||||||
| 50149 | LD H,4 | Door 4 - open door on back wall. Mirrored version of Door 3. | ||||||||||||||
| 50151 | LD D,244 | |||||||||||||||
| 50153 | LD A,C | Check bit 3 (open/closed) | ||||||||||||||
| 50154 | AND 8 | |||||||||||||||
| 50156 | JR NZ,50162 | |||||||||||||||
| 50158 | LD D,17 | |||||||||||||||
| 50160 | LD H,1 | Door 1 - closed door on back wall. | ||||||||||||||
|
Store door graphic address and position offsets
|
||||||||||||||||
| 50162 | LD A,(60232) | Horizontal (X) position of door in room (half-character/4 pixel increments) | ||||||||||||||
| 50165 | ADD A,B | Add calculated horizontal offset | ||||||||||||||
| 50166 | LD (60232),A | ...and store | ||||||||||||||
| 50169 | LD A,(60234) | Vertical (Y) position of door in room (in pixels) | ||||||||||||||
| 50172 | ADD A,L | Add calculated vertical offset | ||||||||||||||
| 50173 | LD (60234),A | ...and store | ||||||||||||||
| 50176 | LD A,D | Door frame byte for particular door - indicates graphic offset and open/close direction, i.e. which way to advance through the graphic pointers | ||||||||||||||
| 50177 | LD (60288),A | |||||||||||||||
| 50180 | LD A,E | Number of animation frames needed for door. Back wall doors have 4, side wall doors 5. | ||||||||||||||
| 50181 | LD (60289),A | |||||||||||||||
| 50184 | LD A,H | Offset for the calculated door graphic frame number (1-6) | ||||||||||||||
| 50185 | LD (60240),A | |||||||||||||||
| 50188 | LD A,9 | Offset for base door graphics address (38851) [offset = (17-1)*2]. Door graphic addresses start from 38867. | ||||||||||||||
| 50190 | CALL 57538 | Prep/mirror door graphics | ||||||||||||||
|
Update pre-graphic byte with the number of (animation) frames for this door (4 for back wall doors, 5 for side doors)
|
||||||||||||||||
| 50193 | LD A,(60239) | Get pre-graphics data byte | ||||||||||||||
| 50196 | AND 240 | Filter out bits 0-3 (the default number of frames in the byte) | ||||||||||||||
| 50198 | LD C,A | |||||||||||||||
| 50199 | LD A,(60289) | Add the number of animation frames needed for the door | ||||||||||||||
| 50202 | OR C | |||||||||||||||
| 50203 | LD (60239),A | Re-store amended pre-graphics byte | ||||||||||||||
| 50206 | LD A,(60288) | Copy graphic frame address offset into working data buffer | ||||||||||||||
| 50209 | LD (60240),A | |||||||||||||||
| 50212 | CALL 57520 | Copy the 16 bytes of door data from 60227 into a room item data set at 31744. | ||||||||||||||
| 50215 | JP 49965 | Keep checking if there are any more doors to set up in this room | ||||||||||||||
| Prev: 49965 | Up: Map | Next: 50218 |