![]()  | 
Routines | 
| Prev: AFC7 | Up: Map | Next: B01F | 
| 
 
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 | AFEB | LD A,($A7EE) | A=*Count_ScenicEvents. | |
| AFEE | AND A | Return if *Count_ScenicEvents is zero. | ||
| AFEF | RET Z | |||
| AFF0 | LD B,A | B=A. | ||
| AFF1 | LD HL,($A7E2) | HL=*Pointer_ScenicEventLocations. | ||
| AFF4 | JR ScenicEvents_Process | Jump to ScenicEvents_Process. | ||
| Handler_ScenicEvents_Loop | AFF6 | INC HL | Increment HL by one. | |
| ScenicEvents_Process | AFF7 | LD A,(HL) | A=*HL. | |
| AFF8 | CALL ValidateItemPresent | Call ValidateItemPresent. | ||
| AFFB | JR NZ,ScenicEvents_Next | Jump to ScenicEvents_Next if HL is not equal to A. | ||
| 
 
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.
 
 | 
||||
| AFFD | LD ($A83B),HL | Write HL to *TempStore_TablePointer. | ||
| B000 | LD ($A83D),BC | Write BC to *TempStore_TableIndex. | ||
| 
 
Calculate the event index and get the event handler.
 
 | 
||||
| B004 | LD A,($A7EE) | E=*Count_ScenicEvents-B. | ||
| B007 | SUB B | |||
| B008 | LD E,A | |||
| B009 | LD IX,($A7DE) | Load IX with *Pointer_JumpTable_ScenicEvents which contains a pointer to the scenic event rountines jump table. | ||
| B00D | CALL GetTableEntry | Call GetTableEntry. | ||
| B010 | LD DE,$B015 | Push ScenicEvents_PostProcessing onto the stack (as the return address). | ||
| B013 | PUSH DE | |||
| B014 | JP (HL) | Jump to the event handler held by HL. | ||
| 
 
This is the return point after the handler has finished executing.
 
 | 
||||
| ScenicEvents_PostProcessing | B015 | LD HL,($A83B) | Restore *TempStore_TablePointer to HL. | |
| B018 | LD BC,($A83D) | Restore *TempStore_TableIndex to BC. | ||
| ScenicEvents_Next | B01C | DJNZ Handler_ScenicEvents_Loop | Decrease the event counter by one and loop back to Handler_ScenicEvents_Loop until all events have been processed. | |
| B01E | RET | Return. | ||
| 
 
View the equivalent code in The Jewels Of Babylon.
 
 | 
||||
| Prev: AFC7 | Up: Map | Next: B01F |