Routines |
Prev: B1D4 | Up: Map | Next: B252 |
This checks for and actions door transitions.
Used by the routine at touch.
|
||||||||
door_handling | B1F5 | LD A,($68A0) | Get the global current room index | |||||
Interior doors are handled by another routine.
|
||||||||
B1F8 | AND A | Is it indoors? | ||||||
B1F9 | JP NZ,door_handling_interior | Exit via the interior door handling routine if so | ||||||
Select a start position in doors[] based on the direction the hero is facing.
|
||||||||
B1FC | LD HL,$78D6 | Point HL at the first entry in doors[] | ||||||
B1FF | LD E,(IY+$0E) | Fetch current vischar's direction field | ||||||
B202 | LD A,E | Is it direction_BOTTOM_RIGHT or direction_BOTTOM_LEFT? | ||||||
B203 | CP $02 | |||||||
B205 | JR C,door_handling_0 | Jump if not | ||||||
B207 | LD HL,$78DA | Point HL at the second entry in doors[] | ||||||
door_handling_0 | B20A | LD D,$03 | Preload door_FLAGS_MASK_DIRECTION mask ($03) into D | |||||
The first 16 (pairs of) entries in doors[] are the only ones with outdoors as a destination, so only consider those.
|
||||||||
B20C | LD B,$10 | 16 iterations / 16 pairs of entries | ||||||
Start loop
|
||||||||
door_handling_1 | B20E | LD A,(HL) | Load the door entry's room_and_direction field | |||||
B20F | AND D | Extract the direction field | ||||||
B210 | CP E | Does it match the vischar's direction? | ||||||
B211 | JR NZ,door_handling_next | Jump forward if not | ||||||
A match
|
||||||||
B213 | PUSH BC | Preserve loop counter | ||||||
B214 | PUSH HL | Preserve door entry pointer | ||||||
B215 | PUSH DE | Preserve direction mask | ||||||
B216 | CALL door_in_range | Call door_in_range -- returns C clear if in range | ||||||
B219 | POP DE | Restore the registers stored prior to call | ||||||
B21A | POP HL | |||||||
B21B | POP BC | |||||||
B21C | JR NC,door_handling_found | If not in range, jump to door_handling_found | ||||||
door_handling_next | B21E | LD A,$08 | Step forward two entries | |||||
B220 | ADD A,L | |||||||
B221 | LD L,A | |||||||
B222 | JR NC,door_handling_2 | |||||||
B224 | INC H | |||||||
door_handling_2 | B225 | DJNZ door_handling_1 | ...loop | |||||
Commentary: This seems to exist to set Z, but this routine doesn't return anything!
|
||||||||
B227 | AND B | Set Z (B is zero here) | ||||||
B228 | RET | Return | ||||||
door_handling_found | B229 | LD A,$10 | current door = 16 - iterations | |||||
B22B | SUB B | |||||||
B22C | LD ($68A1),A | |||||||
B22F | EXX | Switch register banks over the call | ||||||
B230 | CALL is_door_locked | Call is_door_locked -- returns Z clear if locked | ||||||
B233 | RET NZ | Return if the door was locked | ||||||
B234 | EXX | Switch registers back | ||||||
B235 | LD A,(HL) | Fetch door entry's room_and_direction | ||||||
B236 | RRA | Rotate it by two bits | ||||||
B237 | RRA | |||||||
B238 | AND $3F | Clear the top two bits rotated in | ||||||
B23A | LD (IY+$1C),A | Store in vischar->room | ||||||
B23D | LD A,(HL) | Fetch door entry's room_and_direction again | ||||||
B23E | AND $03 | Extract the direction field | ||||||
B240 | CP $02 | Is it direction_BOTTOM_RIGHT or direction_BOTTOM_LEFT? | ||||||
B242 | JR NC,door_handling_3 | Jump if either of those | ||||||
Point to the next door entry's pos
|
||||||||
B244 | INC HL | Step forward five bytes to the next door entry | ||||||
B245 | INC HL | |||||||
B246 | INC HL | |||||||
B247 | INC HL | |||||||
B248 | INC HL | |||||||
B249 | JP transition | Jump to transition -- never returns | ||||||
Point to the previous door entry's pos
|
||||||||
door_handling_3 | B24C | DEC HL | Step back three bytes to the previous door entry | |||||
B24D | DEC HL | |||||||
B24E | DEC HL | |||||||
B24F | JP transition | Jump to transition -- never returns |
Prev: B1D4 | Up: Map | Next: B252 |