Prev: 7208 Up: Map Next: 723F
720F: Room Handler Dispatch
Used by the routine at Run_Main_Loop_Body.
This is a self-modified instruction so the immediate value is patched at runtime. If it is non-zero, store it in *CurrentLevel.
RoomHandlerDispatch 720F LD A,$00 A=00.
7211 OR A Jump to RoomHandlerDispatch_TestSpriteAttributes if A is zero.
7212 JR Z,RoomHandlerDispatch_TestSpriteAttributes
7214 LD ($5FB1),A Write A to *CurrentLevel.
If *RespawnFlag is non-zero, clear 07FF bytes of the sprite attribute buffer at E800.
RoomHandlerDispatch_TestSpriteAttributes 7217 LD A,($5FBB) A=*RespawnFlag.
721A OR A Jump to RoomHandlerDispatch_Lookup if A is zero.
721B JR Z,RoomHandlerDispatch_Lookup
721D LD HL,$E800 Clear 07FF bytes from E800 onwards.
7220 LD DE,$E801
7223 LD (HL),$00
7225 LD BC,$07FF
7228 LDIR
Look up the handler address for the current room from the jump table at JumpTable_RoomHandler. Each entry is a two-byte address; the room number (one-indexed) is decremented to form a zero-based index.
RoomHandlerDispatch_Lookup 722A LD A,($5FB1) B=*CurrentLevel.
722D LD B,A
722E LD A,($5FC5) A=*CurrentRoom.
7231 DEC A Decrement to make the room ID zero-indexed.
7232 LD DE,$7B2E DE=JumpTable_RoomHandler.
7235 LD L,A Transfer the room index to HL.
7236 LD H,$00
7238 ADD HL,HL Multiply by 02 (two bytes per table entry).
7239 ADD HL,DE Add the jump table base address.
723A LD E,(HL) Read the two-byte handler address from the table into DE.
723B INC HL
723C LD D,(HL)
723D EX DE,HL Transfer the handler address to HL.
723E JP (HL) Jump to the room handler.
Prev: 7208 Up: Map Next: 723F