![]() |
Routines |
| Prev: 46816 | Up: Map | Next: 46931 |
|
Used by the routine at Handler_ChangeRoom.
Moves the player to a new room. Before updating the current room, it brings every scenic-event item that is here or carried along to the destination. It then moves each item whose bit is set in Flag_FollowingHeroes into the new room (see Table_FollowingItems).
|
||||||||
|
Store the destination room ID and prepare to update scenic events.
|
||||||||
| MovePlayerToRoom | 46868 | LD C,A | Copy the destination room ID into C. | |||||
| 46869 | LD A,(44792) | Load *Count_ScenicEvents into A. | ||||||
| 46872 | AND A | Jump to MovePlayerToRoom_SetRoom if no scenic events are defined. | ||||||
| 46873 | JR Z,MovePlayerToRoom_SetRoom | |||||||
| 46875 | LD B,A | Load *Count_ScenicEvents into B for the loop counter. | ||||||
| 46876 | LD HL,(44780) | Set a pointer to *Pointer_Spare in HL. | ||||||
| 46879 | JR ScenicItem_Next | Jump to ScenicItem_Next. | ||||||
|
Loop through all scenic event items and move any that are here or carried to the destination room (so they follow the player).
|
||||||||
| ScenicItem_Advance | 46881 | INC HL | Move to the next scenic event item ID. | |||||
| ScenicItem_Next | 46882 | LD A,(HL) | Load this scenic event item ID into A. | |||||
| 46883 | CALL ValidateItemPresent | Call ValidateItemPresent to test whether it is here or carried. | ||||||
| 46886 | JR NZ,ScenicItem_Count | Jump to ScenicItem_Count if it is neither here nor carried. | ||||||
|
This scenic event item is here or carried, so move it with the player.
|
||||||||
| 46888 | PUSH HL | Stash the table pointer and counter on the stack. | ||||||
| 46889 | PUSH BC | |||||||
| 46890 | LD B,(HL) | Load the scenic event item ID into B. | ||||||
| 46891 | CALL SetItemRoom | Call SetItemRoom to update the item's location to the destination room. | ||||||
| 46894 | POP BC | Restore the table pointer and counter from the stack. | ||||||
| 46895 | POP HL | |||||||
| ScenicItem_Count | 46896 | DJNZ ScenicItem_Advance | Decrease the scenic event counter by one and loop back to ScenicItem_Advance until all scenic events have been checked. | |||||
|
Update the current room ID to the destination room.
|
||||||||
| MovePlayerToRoom_SetRoom | 46898 | LD A,C | Copy the destination room ID into A. | |||||
| 46899 | LD (44749),A | Write the destination room ID to CurrentRoom. | ||||||
| 46902 | LD A,(44689) | Load *Flag_FollowingHeroes into A. | ||||||
| 46905 | AND A | Return if no following item is active. | ||||||
| 46906 | RET Z | |||||||
|
For each set bit, move the item at that position in Table_FollowingItems into the current room.
|
||||||||
| 46907 | LD B,8 | Set a counter in B for 8 bits. | ||||||
| 46909 | LD HL,44690 | Set a pointer to Table_FollowingItems in HL. | ||||||
| 46912 | LD C,A | Copy the following flags into C for bit testing. | ||||||
| 46913 | JR EventFlag_Next | Jump to EventFlag_Next. | ||||||
| EventFlag_Advance | 46915 | INC HL | Move to the next item ID. | |||||
| EventFlag_Next | 46916 | SRL C | Shift the following flags right to check the next bit. | |||||
| 46918 | JR NC,EventFlag_Count | Jump to EventFlag_Count if this bit is not set. | ||||||
|
This item is following, so move it to the current room.
|
||||||||
| 46920 | LD A,(HL) | Get the item ID from the table. | ||||||
| 46921 | PUSH HL | Stash the table pointer and counter on the stack. | ||||||
| 46922 | PUSH BC | |||||||
| 46923 | CALL HandlerUpdateItemEventForTheCurrentRoom | Call HandlerUpdateItemEventForTheCurrentRoom to update the item's location to the current room. | ||||||
| 46926 | POP BC | Restore the table pointer and counter from the stack. | ||||||
| 46927 | POP HL | |||||||
| EventFlag_Count | 46928 | DJNZ EventFlag_Advance | Decrease the bit counter by one and loop back to EventFlag_Advance until all 8 bits have been tested. | |||||
| MovePlayerToRoom_Return | 46930 | RET | Return. | |||||
|
View the equivalent code in;
|
||||||||
| Prev: 46816 | Up: Map | Next: 46931 |