Prev: AC86 Up: Map Next: ACBD
AC88: Handler: Scenic Events
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 AC88 LD A,($BBCF) A=*Count_ScenicEvents.
AC8B AND A Return if *Count_ScenicEvents is zero.
AC8C RET Z
AC8D LD B,A B=A.
AC8E LD HL,$B6BA HL=Table_ScenicEventLocations2.
AC91 JR ScenicEvents_Process Jump to ScenicEvents_Process.
Handler_ScenicEvents_Loop AC93 INC HL Increment HL by one.
ScenicEvents_Process AC94 LD A,(HL) A=*HL.
AC95 CALL ValidateItemPresent Call ValidateItemPresent.
AC98 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.
AC9A LD ($AC84),HL Write HL to *TempStore_TablePointer.
AC9D LD ($AC86),BC Write BC to *TempStore_TableIndex.
Calculate the event index and get the event handler.
ACA1 LD A,($BBCF) E=*Count_ScenicEvents-B.
ACA4 SUB B
ACA5 LD E,A
ACA6 LD IX,$BBBD Load IX with JumpTable_ScenicEvents which contains a pointer to the scenic event rountines jump table.
ACAA CALL GetTableEntry Call GetTableEntry.
ACAD PUSH HL IX=HL (using the stack).
ACAE POP IX
ACB0 CALL $A6FF Call A6FF.
This is the return point after the handler has finished executing.
ScenicEvents_PostProcessing ACB3 LD HL,($AC84) Restore *TempStore_TablePointer to HL.
ACB6 LD BC,($AC86) Restore *TempStore_TableIndex to BC.
ScenicEvents_Next ACBA DJNZ Handler_ScenicEvents_Loop Decrease the event counter by one and loop back to Handler_ScenicEvents_Loop until all events have been processed.
ACBC RET Return.
View the equivalent code in;
Prev: AC86 Up: Map Next: ACBD