Prev: 46862 Up: Map Next: 46931
46868: Handler: Set Current Room
Used by the routine at Handler_ChangeRoom.
Move the player into the room held in A and update events there.
Handler_SetCurrentRoom 46868 LD C,A Remember the destination room.
46869 LD A,(44792) Read the scenic-event count into A.
46872 AND A Skip scenic events when the game defines none.
46873 JR Z,Handler_SetCurrentRoom_Next
46875 LD B,A Take the scenic-event count.
46876 LD HL,(44780) Load the word at *Pointer_Spare into HL.
46879 JR Handler_SetCurrentRoom_Scenic Read the first scenic item at Handler_SetCurrentRoom_Scenic.
Handler_SetCurrentRoom_Loop 46881 INC HL Advance HL to the next byte.
Handler_SetCurrentRoom_Scenic 46882 LD A,(HL) Read this scenic item.
46883 CALL Get_ObjectLocation Call Get_ObjectLocation to find where the object is.
46886 JR NZ,Handler_SetCurrentRoom_ScenicNext Leave a scenic item that is not here.
46888 PUSH HL Keep this scenic item while it is moved.
46889 PUSH BC
46890 LD B,(HL) Read the buffer byte into B.
46891 CALL SetItemRoom Call SetItemRoom to store the item's room.
46894 POP BC Restore the scenic item count and this scenic item from the stack.
46895 POP HL
Handler_SetCurrentRoom_ScenicNext 46896 DJNZ Handler_SetCurrentRoom_Loop Count down B and repeat from Handler_SetCurrentRoom_Loop until the count is exhausted.
Handler_SetCurrentRoom_Next 46898 LD A,C Restore the destination room.
46899 LD (44749),A Store A in the current room.
46902 LD A,(44689) Read the event-state flags into A.
46905 AND A Leave the turn-based events alone when none are armed.
46906 RET Z
46907 LD B,8 Use 8 as the count in B.
46909 LD HL,44690 Point HL at the turn-based event items.
46912 LD C,A Hold the event flags while each one is tested.
46913 JR Handler_SetCurrentRoom_Event Test the first turn-based event at Handler_SetCurrentRoom_Event.
Handler_SetCurrentRoom_EventLoop 46915 INC HL Advance HL to the next byte.
Handler_SetCurrentRoom_Event 46916 SRL C Test the next turn-based event flag.
46918 JR NC,Handler_SetCurrentRoom_EventNext Branch to Handler_SetCurrentRoom_EventNext when the carry flag is clear.
46920 LD A,(HL) Read the item this event places in the room.
46921 PUSH HL Keep this turn-based event while its item is placed.
46922 PUSH BC
46923 CALL HandlerUpdateItemEventForTheCurrentRoom Call HandlerUpdateItemEventForTheCurrentRoom to update the item for this room.
46926 POP BC Restore the event count and flags, and this turn-based event from the stack.
46927 POP HL
Handler_SetCurrentRoom_EventNext 46928 DJNZ Handler_SetCurrentRoom_EventLoop Count down B and repeat from Handler_SetCurrentRoom_EventLoop until the count is exhausted.
46930 RET Return.
View the equivalent code in;
Prev: 46862 Up: Map Next: 46931