![]()  | 
Routines | 
| Prev: 44166 | Up: Map | Next: 44221 | 
| 
 
Used by the routine at GameStart.
 
Handles checking if a scenic event should occur ... and also, handles jumping to the correct related scenic event routine to action it.
 
 | 
||||
| Handler_ScenicEvents | 44168 | LD A,(48079) | A=*Count_ScenicEvents. | |
| 44171 | AND A | Return if *Count_ScenicEvents is zero. | ||
| 44172 | RET Z | |||
| 44173 | LD B,A | B=A. | ||
| 44174 | LD HL,46778 | HL=Table_ScenicEventLocations2. | ||
| 44177 | JR ScenicEvents_Process | Jump to ScenicEvents_Process. | ||
| Handler_ScenicEvents_Loop | 44179 | INC HL | Increment HL by one. | |
| ScenicEvents_Process | 44180 | LD A,(HL) | A=*HL. | |
| 44181 | CALL ValidateItemPresent | Call ValidateItemPresent. | ||
| 44184 | 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.
 
 | 
||||
| 44186 | LD (44164),HL | Write HL to *TempStore_TablePointer. | ||
| 44189 | LD (44166),BC | Write BC to *TempStore_TableIndex. | ||
| 
 
Calculate the event index and get the event handler.
 
 | 
||||
| 44193 | LD A,(48079) | E=*Count_ScenicEvents-B. | ||
| 44196 | SUB B | |||
| 44197 | LD E,A | |||
| 44198 | LD IX,48061 | Load IX with JumpTable_ScenicEvents which contains a pointer to the scenic event rountines jump table. | ||
| 44202 | CALL GetTableEntry | Call GetTableEntry. | ||
| 44205 | PUSH HL | IX=HL (using the stack). | ||
| 44206 | POP IX | |||
| 44208 | CALL 42751 | Call 42751. | ||
| 
 
This is the return point after the handler has finished executing.
 
 | 
||||
| ScenicEvents_PostProcessing | 44211 | LD HL,(44164) | Restore *TempStore_TablePointer to HL. | |
| 44214 | LD BC,(44166) | Restore *TempStore_TableIndex to BC. | ||
| ScenicEvents_Next | 44218 | DJNZ Handler_ScenicEvents_Loop | Decrease the event counter by one and loop back to Handler_ScenicEvents_Loop until all events have been processed. | |
| 44220 | RET | Return. | ||
| 
 
View the equivalent code in; 
 
 | 
||||
| Prev: 44166 | Up: Map | Next: 44221 |