Prev: 59859 Up: Map Next: 60016
59873: Change Room
Used by the routines at Handler_ShowNewRoom, MovePlayer, Action_Pour and GameStart.
Commits a move into the destination room held in A. It handles the Hall of the Phoenix and the ruined cottage, calls MovePlayerToRoom to update the current room, then jumps to Handler_ShowNewRoom to describe the new room.
Input
A Destination room ID
Entering the Hall of the Phoenix is fatal. Bit 0 of *Flags_RoomChange, when set, means the firegate does not incinerate the player.
ChangeRoom 59873 CP 55 Jump to ChangeRoom_LeavePhoenix if the destination is not room 55: " The Hall of the Phoenix".
59875 JR NZ,ChangeRoom_LeavePhoenix
59877 LD HL,44662 Jump to ChangeRoom_LeavePhoenix if bit 0 of *Flags_RoomChange is set.
59880 BIT 0,(HL)
59882 JR NZ,ChangeRoom_LeavePhoenix
The player is dead, so do not resume the movement handler.
59884 POP HL Discard the calling address of ChangeRoom.
59885 LD HL,59829 Switch GameOver onto the stack so the next return actions a "game over".
59888 EX (SP),HL
Print "The scorching flames of the firegate have incinerated you.".
59889 LD HL,53324 Point HL at Messaging_TheScorchingFlamesOfTheFiregateHave and print it and start a new line.
59892 CALL PrintStringAndNewline
59895 RET Return.
Leaving the Hall of the Phoenix.
ChangeRoom_LeavePhoenix 59896 LD C,A Copy the destination room ID into C.
59897 LD A,(44749) Fetch *CurrentRoom into A.
59900 CP 55 Jump to ChangeRoom_EnterRoom if the current room is not 55: " The Hall of the Phoenix".
59902 JR NZ,ChangeRoom_EnterRoom
59904 LD HL,44662 Jump to ChangeRoom_EnterRoom if bit 1 of *Flags_RoomChange is set.
59907 BIT 1,(HL)
59909 JR NZ,ChangeRoom_EnterRoom
South into the Hall of Black Magic turns the ashes into a phoenix.
59911 LD A,63 Jump to ChangeRoom_PhoenixToAshes if the destination is not room 63: " The Hall of Black Magic".
59913 CP C
59914 JR NZ,ChangeRoom_PhoenixToAshes
59916 LD BC,33154 Call TransformItem to transform "Some hot ashes." into "A phoenix.".
59919 CALL TransformItem
This action changes the map:
59922 XOR A Write 0 to close southbound access to The Hall of Black Magic from The Hall of the Phoenix.
59923 LD (59697),A
Print "Suddenly,the ashes burst into flames....".
ChangeRoom_AshesBurst 59926 LD HL,53383 Point HL at Messaging_SuddenlyTheAshesBurstIntoFlames and print it and start a new line.
59929 CALL PrintStringAndNewline
Print "A phoenix emerges from the fire and blocks your path.".
ChangeRoom_PhoenixAppears 59932 LD HL,53424 Point HL at Messaging_APhoenixEmergesFromTheFireAndBlocks and pause, print it and scroll.
59935 CALL PausePrintStringAndScroll
59938 RET Return.
Any other exit from the Hall of the Phoenix turns the phoenix back into ashes and opens the south.
ChangeRoom_PhoenixToAshes 59939 LD A,C Copy the destination room ID into A.
59940 PUSH AF Stash the destination room ID on the stack.
59941 LD A,130 Call HandlerDestroyItemEvent with item 130: "A phoenix.".
59943 CALL HandlerDestroyItemEvent
59946 LD A,129 Call HandlerUpdateItemEventForTheCurrentRoom with item 129: "Some hot ashes.".
59948 CALL HandlerUpdateItemEventForTheCurrentRoom
This action changes the map:
59951 LD A,63 Write 63 to open southbound access to The Hall of Black Magic from The Hall of the Phoenix.
59953 LD (59697),A
59956 POP AF Restore the destination room ID from the stack.
59957 LD C,A Copy it into C.
Move into the destination room.
ChangeRoom_EnterRoom 59958 LD A,C Copy the destination room ID into A.
59959 CALL MovePlayerToRoom Call MovePlayerToRoom to move the player into the room.
Winning in the ruined cottage.
59962 LD A,(44749) Fetch *CurrentRoom into A.
59965 CP 2 Jump to Handler_ShowNewRoom if it is not room 2: " Inside the Ruined Cottage".
59967 JR NZ,Handler_ShowNewRoom
59969 LD A,(44689) Fetch *Flag_FollowingHeroes into A.
59972 CP 15 Jump to Handler_ShowNewRoom if it is not 15 (all four heroes following).
59974 JR NZ,Handler_ShowNewRoom
59976 LD HL,60016 Count how many of the five gems at Table_Gems are here.
59979 LD B,5
59981 LD C,0
Count each gem that is here.
Cottage_CountGem 59983 LD A,(HL) Fetch the next gem item ID.
59984 CALL ValidateItemPresent Call ValidateItemPresent to test whether it is here.
59987 JR NZ,Cottage_CountGem_Next Jump to Cottage_CountGem_Next if it is not here.
59989 INC C Count a gem that is here.
Continue the gem count.
Cottage_CountGem_Next 59990 INC HL Advance to the next gem.
59991 DJNZ Cottage_CountGem Decrease the gem counter by one and loop back to Cottage_CountGem until it is zero.
59993 LD A,5 Jump to Handler_ShowNewRoom if fewer than five gems are here.
59995 CP C
59996 JR NZ,Handler_ShowNewRoom
59998 LD HL,58628 Call CheckActiveScenicEvents with the jade-flower group at Data_ItemGroup_Flower.
60001 CALL CheckActiveScenicEvents
60004 JR NZ,Handler_ShowNewRoom Jump to Handler_ShowNewRoom if the jade flower is neither here nor carried.
The game is won, so do not resume the movement handler or the command loop.
60006 POP HL Discard the return address of ChangeRoom and of its caller.
60007 POP HL
60008 LD A,4 Call AddToScore to score four points.
60010 CALL AddToScore
60013 JP GameComplete Jump to GameComplete.
Prev: 59859 Up: Map Next: 60016