![]() |
Routines |
Prev: 50375 | Up: Map | Next: 50464 |
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 | 50411 | LD HL,48248 | HL=Table_ScenicEventLocations. | |
50414 | LD BC,(48432) | Set a counter in BC for *Count_ScenicEvents. | ||
Handler_ScenicEvents_Loop | 50418 | LD A,(48331) | Load *CurrentRoom into A. | |
50421 | CPIR | Search for the matching room. | ||
50423 | 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.
|
||||
50425 | LD (48509),HL | Write the table position to *TempStore_TablePointer. | ||
50428 | LD (48511),BC | Write the counter to *TempStore_TableIndex. | ||
Calculate the event index and get the event handler.
|
||||
50432 | INC BC | Adjust the counter for the sum. | ||
50433 | LD HL,(48432) | HL=*Count_ScenicEvents. | ||
50436 | AND A | Calculate the index. | ||
50437 | SBC HL,BC | |||
50439 | EX DE,HL | Move the index into DE (as GetTableEntry uses E). | ||
50440 | LD IX,(48420) | Load IX with *Pointer_JumpTable_ScenicEvents which contains a pointer to the scenic event rountines jump table. | ||
50444 | CALL GetTableEntry | Call GetTableEntry. | ||
50447 | LD DE,50452 | Push ScenicEvents_PostProcessing onto the stack (as the return address). | ||
50450 | PUSH DE | |||
50451 | JP (HL) | Jump to the event handler held by HL. | ||
This is the return point after the handler has finished executing.
|
||||
ScenicEvents_PostProcessing | 50452 | LD HL,(48509) | Restore *TempStore_TablePointer to HL. | |
50455 | LD BC,(48511) | Restore *TempStore_TableIndex to BC. | ||
50459 | XOR A | Jump to Handler_ScenicEvents_Loop if there are any further events to process. | ||
50460 | OR C | |||
50461 | JR NZ,Handler_ScenicEvents_Loop | |||
ScenicEvents_Return | 50463 | RET | Return. |
Prev: 50375 | Up: Map | Next: 50464 |