![]() |
Routines |
| Prev: B6BC | Up: Map | Next: B714 |
|
Handles checking if a scenic event should occur ... and also, handles jumping to the correct related scenic event routine to action it.
|
||||
| Handler_ScenicEvents | B6E0 | LD A,($AEF8) | A=*Count_ScenicEvents. | |
| B6E3 | AND A | Return if *Count_ScenicEvents is zero. | ||
| B6E4 | RET Z | |||
| B6E5 | LD B,A | B=A. | ||
| B6E6 | LD HL,($AEEC) | HL=*Pointer_Spare. | ||
| B6E9 | JR ScenicEvents_Process | Jump to ScenicEvents_Process. | ||
| Handler_ScenicEvents_Loop | B6EB | INC HL | Increment HL by one. | |
| ScenicEvents_Process | B6EC | LD A,(HL) | Load the scenic event item ID into A. | |
| B6ED | CALL ValidateItemPresent | Call ValidateItemPresent. | ||
| B6F0 | JR NZ,ScenicEvents_Next | Jump to ScenicEvents_Next if the scenic event item is neither here nor carried. | ||
|
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.
|
||||
| B6F2 | LD ($AF45),HL | Write HL to *TempStore_TablePointer. | ||
| B6F5 | LD ($AF47),BC | Write BC to *TempStore_TableIndex. | ||
|
Calculate the event index and get the event handler.
|
||||
| B6F9 | LD A,($AEF8) | E=*Count_ScenicEvents-B. | ||
| B6FC | SUB B | |||
| B6FD | LD E,A | |||
| B6FE | LD IX,($AEE8) | Load IX with *Pointer_JumpTable_ScenicEvents which contains a pointer to the scenic event rountines jump table. | ||
| B702 | CALL GetTableEntry | Call GetTableEntry. | ||
| B705 | LD DE,$B70A | Push ScenicEvents_PostProcessing onto the stack (as the return address). | ||
| B708 | PUSH DE | |||
| B709 | JP (HL) | Jump to the event handler held by HL. | ||
|
This is the return point after the handler has finished executing.
|
||||
| ScenicEvents_PostProcessing | B70A | LD HL,($AF45) | Restore *TempStore_TablePointer to HL. | |
| B70D | LD BC,($AF47) | Restore *TempStore_TableIndex to BC. | ||
| ScenicEvents_Next | B711 | DJNZ Handler_ScenicEvents_Loop | Decrease the event counter by one and loop back to Handler_ScenicEvents_Loop until all events have been processed. | |
| B713 | RET | Return. | ||
|
View the equivalent code in;
|
||||
| Prev: B6BC | Up: Map | Next: B714 |