![]() |
Routines |
Prev: C4C7 | Up: Map | Next: C520 |
Used by the routine at GameLoop.
Handles checking if a scenic event should occur ... and also, handles jumping to the correct related scenic event routine to action it.
|
||||
Handler_ScenicEvents | C4EB | LD HL,$BC78 | HL=Table_ScenicEventLocations. | |
C4EE | LD BC,($BD30) | Set a counter in BC for *Count_ScenicEvents. | ||
Handler_ScenicEvents_Loop | C4F2 | LD A,($BCCB) | Load *CurrentRoom into A. | |
C4F5 | CPIR | Search for the matching room. | ||
C4F7 | JR NZ,ScenicEvents_Return | Jump to ScenicEvents_Return if no events at all were found in the table. | ||
An event was found to be processed!
First though, stash away the current pointer and index in the search, so this can be resumed later.
|
||||
C4F9 | LD ($BD7D),HL | Write the table position to *TempStore_TablePointer. | ||
C4FC | LD ($BD7F),BC | Write the counter to *TempStore_TableIndex. | ||
Calculate the event index and get the event handler.
|
||||
C500 | INC BC | Adjust the counter for the sum. | ||
C501 | LD HL,($BD30) | HL=*Count_ScenicEvents. | ||
C504 | AND A | Calculate the index. | ||
C505 | SBC HL,BC | |||
C507 | EX DE,HL | Move the index into DE (as GetTableEntry uses E). | ||
C508 | LD IX,($BD24) | Load IX with *Pointer_JumpTable_ScenicEvents which contains a pointer to the scenic event rountines jump table. | ||
C50C | CALL GetTableEntry | Call GetTableEntry. | ||
C50F | LD DE,$C514 | Push ScenicEvents_PostProcessing onto the stack (as the return address). | ||
C512 | PUSH DE | |||
C513 | JP (HL) | Jump to the event handler held by HL. | ||
This is the return point after the handler has finished executing.
|
||||
ScenicEvents_PostProcessing | C514 | LD HL,($BD7D) | Restore *TempStore_TablePointer to HL. | |
C517 | LD BC,($BD7F) | Restore *TempStore_TableIndex to BC. | ||
C51B | XOR A | Jump to Handler_ScenicEvents_Loop if there are any further events to process. | ||
C51C | OR C | |||
C51D | JR NZ,Handler_ScenicEvents_Loop | |||
ScenicEvents_Return | C51F | RET | Return. |
Prev: C4C7 | Up: Map | Next: C520 |