Prev: 6557 Up: Map Next: 65D2
658A: Handler: Scenic Events
For each armed scenic event, walk its room list from Table_ScenicEventRooms and move the event to a chosen room unless the player is already there.
Handler_ScenicEvents 658A LD A,($6222) Fetch the scenic-event flags.
658D OR A No scenic event is running.
658E JR Z,Handler_ScenicEvents_Step2
6590 LD C,A Keep the scenic flags and test all eight bits.
6591 LD B,$08
Each set bit is a scenic event that can move to a new room.
Handler_ScenicEvents_Loop1 6593 SRL C Take the next scenic-event bit.
6595 JR NC,Handler_ScenicEvents_Step1 This scenic event is not running.
6597 LD DE,$0000 Index this scenic event's room list.
659A LD A,$08
659C SUB B
659D LD E,A
659E SLA E
65A0 PUSH BC Remember which scenic bits are still to be checked.
65A1 LD A,($5C78) Let the frame counter choose how far to walk the room list.
65A4 LD B,A
65A5 LD IX,$62B2 Find the rooms for this scenic event.
65A9 ADD IX,DE Point at this event's rooms and prepare the end marker.
65AB LD A,$FF
Handler_ScenicEvents_Loop2 65AD LD L,(IX+$00) Read the address of this event's room list.
65B0 LD H,(IX+$01)
Handler_ScenicEvents_Loop3 65B3 CP (HL) Walk the list for as many frames as have passed.
65B4 INC HL
65B5 JR Z,Handler_ScenicEvents_Loop2
65B7 DJNZ Handler_ScenicEvents_Loop3
65B9 DEC HL Step back to the room those frames selected.
65BA SRA E Recover the event number from the list index.
65BC LD IX,$6224 Find the room this scenic event belongs to.
65C0 ADD IX,DE Point at this event's room.
65C2 POP BC Restore the scenic flags still to be checked.
65C3 LD A,($6223) Fetch the current room.
65C6 CP (IX+$00) Leave the event alone when the player is already in its room.
65C9 JR Z,Handler_ScenicEvents_Step1
65CB LD A,(HL) Move this scenic event to the chosen room.
65CC LD (IX+$00),A
Handler_ScenicEvents_Step1 65CF DJNZ Handler_ScenicEvents_Loop1 Repeat for the remaining scenic events.
Handler_ScenicEvents_Step2 65D1 RET Return.
Prev: 6557 Up: Map Next: 65D2