Prev: E9D3 Up: Map Next: EA70
E9E1: Handler: Change Room
Used by the routines at Handler_ShowNewRoom, Action_Down, Action_Pour and GameStart.
Change room, with the special cases for the gates and the cottage.
Handler_ChangeRoom E9E1 CP $37 See whether the player is moving into the Hall of the Phoenix.
E9E3 JR NZ,Handler_ChangeRoom_0
E9E5 LD HL,$AE76 Point HL at the room-change flags.
E9E8 BIT 0,(HL) See whether the Hall of the Phoenix is safe to enter.
E9EA JR NZ,Handler_ChangeRoom_0 Jump to Handler_ChangeRoom_0 if the zero flag is clear.
E9EC POP HL Return via the "You are dead." message.
E9ED LD HL,$E9B5
E9F0 EX (SP),HL
E9F1 LD HL,$D04C Print "The scorching flames of the firegate have incinerated you." and start a new line.
E9F4 CALL PrintStringAndANewline
E9F7 RET Return.
Handler_ChangeRoom_0 E9F8 LD C,A Remember the room being moved to.
E9F9 LD A,($AECD) Read the current room into A.
E9FC CP $37 See whether the player is leaving the Hall of the Phoenix.
E9FE JR NZ,Handler_ChangeRoom_2
EA00 LD HL,$AE76 Point HL at the room-change flags.
EA03 BIT 1,(HL) See whether the ashes have already become a phoenix.
EA05 JR NZ,Handler_ChangeRoom_2 Jump to Handler_ChangeRoom_2 if the zero flag is clear.
EA07 LD A,$3F See whether the move is into the Hall of Black Magic.
EA09 CP C
EA0A JR NZ,Handler_ChangeRoom_1
EA0C LD BC,$8182 Turn the hot ashes into a phoenix.
EA0F CALL TransformItem
EA12 XOR A Close the south exit from the Hall of the Phoenix.
EA13 LD ($E931),A
Handler_ChangeRoom_AshesBurst EA16 LD HL,$D087 Print "Suddenly,the ashes burst into flames...." and start a new line.
EA19 CALL PrintStringAndANewline
Handler_ChangeRoom_PhoenixAppears EA1C LD HL,$D0B0 Pause, print "A phoenix emerges from the fire and blocks your path." and scroll.
EA1F CALL PausePrintStringAndScroll
EA22 RET Return.
Handler_ChangeRoom_1 EA23 LD A,C Take the destination room.
EA24 PUSH AF Remember the destination room.
EA25 LD A,$82 Remove the phoenix.
EA27 CALL HandlerDestroyItemEvent
EA2A LD A,$81 Leave the hot ashes in this room.
EA2C CALL HandlerUpdateItemEventForTheCurrentRoom
EA2F LD A,$3F Open the south exit from the Hall of the Phoenix into the Hall of Black Magic.
EA31 LD ($E931),A
EA34 POP AF Restore the destination room from the stack.
EA35 LD C,A Put the destination room back.
Handler_ChangeRoom_2 EA36 LD A,C Hand the destination room to the move.
EA37 CALL Handler_SetCurrentRoom Call Handler_SetCurrentRoom to move the player into the room.
EA3A LD A,($AECD) Read the current room into A.
EA3D CP $02 See whether the player is inside the ruined cottage.
EA3F JR NZ,Handler_ShowNewRoom
EA41 LD A,($AE91) Read the event-state flags into A.
EA44 CP $0F See whether the cottage tasks are finished.
EA46 JR NZ,Handler_ShowNewRoom
EA48 LD HL,$EA70 Count how many of the five gems are here.
EA4B LD B,$05
EA4D LD C,$00
Cottage_CountGem EA4F LD A,(HL) Read the next gem.
EA50 CALL Get_ObjectLocation Call Get_ObjectLocation to find where the object is.
EA53 JR NZ,Handler_ChangeRoom_3 Jump to Handler_ChangeRoom_3 if the zero flag is clear.
EA55 INC C Count a gem that is here.
Handler_ChangeRoom_3 EA56 INC HL Move on to the next gem.
EA57 DJNZ Cottage_CountGem Step down B by one and jump to Cottage_CountGem until it is zero.
EA59 LD A,$05 See whether all five gems are here.
EA5B CP C
EA5C JR NZ,Handler_ShowNewRoom
EA5E LD HL,$E504 Check the list of treasures at E504.
EA61 CALL CheckActiveScenicEvents
EA64 JR NZ,Handler_ShowNewRoom Jump to Handler_ShowNewRoom if none of the items listed at E504 is here or carried.
EA66 POP HL Restore HL, HL from the stack.
EA67 POP HL
EA68 LD A,$04 Score four points and finish the game.
EA6A CALL AddToScore
EA6D JP GameComplete
Prev: E9D3 Up: Map Next: EA70