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 Set the loop counter in B to the number of scenic events at Count_ScenicEvents.
AC8E LD HL,$B6BA Point HL at the scenic event items table at Table_ScenicEventItems.
AC91 JR ScenicEvents_Process Jump to ScenicEvents_Process.
Handler_ScenicEvents_Loop AC93 INC HL Move HL on to the next scenic event room ID.
ScenicEvents_Process AC94 LD A,(HL) Fetch this scenic event's item ID from Table_ScenicEventItems into A.
AC95 CALL ValidateItemPresent Call ValidateItemPresent to test whether that item is present.
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 Copy the scenic-event script address from HL into IX (using the stack).
ACAE POP IX
ACB0 CALL Handler_RunScript Call Handler_RunScript.
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.
Prev: AC86 Up: Map Next: ACBD