![]() |
Routines |
| Prev: 44168 | Up: Map | Next: 44284 |
|
Used by the routine at ChangeRoom.
Moves the player to a new room. Before updating the current room, it moves every scenic-event item from Table_ScenicEventItems that is present into the destination room (so those events follow the player). It then writes the destination to CurrentRoom and, for each set bit in Flags_EventStates, brings the matching byte from Data_PhraseTokens into the new room via Handler_UpdateItemEventCurrentRoom.
|
||||||||
|
Store the destination room ID and prepare to update scenic events.
|
||||||||
| MovePlayerToRoom | 44221 | LD C,A | Copy the destination room ID into C. | |||||
| 44222 | LD A,(48079) | Jump to MovePlayerToRoom_SetRoom if *Count_ScenicEvents is zero. | ||||||
| 44225 | AND A | |||||||
| 44226 | JR Z,MovePlayerToRoom_SetRoom | |||||||
|
Loop through the scenic items at Table_ScenicEventItems and move any that are present into the destination room.
|
||||||||
| 44228 | LD B,A | Copy the scenic-event count from A into B as the loop counter. | ||||||
| 44229 | LD HL,46778 | Point HL at the scenic event items table at Table_ScenicEventItems. | ||||||
| 44232 | JR ScenicItem_Next | Jump to ScenicItem_Next. | ||||||
| ScenicItem_Advance | 44234 | INC HL | Move HL on to the next scenic event item ID. | |||||
| ScenicItem_Next | 44235 | LD A,(HL) | Fetch this scenic event's item ID from Table_ScenicEventItems into A. | |||||
| 44236 | CALL ValidateItemPresent | Call ValidateItemPresent to test whether that item is present. | ||||||
| 44239 | JR NZ,ScenicItem_Count | Jump to ScenicItem_Count if the item is not present. | ||||||
|
This scenic item is present, so move it to the destination room.
|
||||||||
| 44241 | PUSH HL | Stash the scenic table pointer and loop counter on the stack. | ||||||
| 44242 | PUSH BC | |||||||
| 44243 | LD B,(HL) | Copy the scenic item ID into B. | ||||||
| 44244 | CALL Handler_UpdateItemLocation | Call Handler_UpdateItemLocation to place that item in the destination room held in C. | ||||||
| 44247 | POP BC | Restore the loop counter and scenic table pointer from the stack. | ||||||
| 44248 | POP HL | |||||||
| ScenicItem_Count | 44249 | 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 | 44251 | LD A,C | Write the destination room ID from C to CurrentRoom. | |||||
| 44252 | LD (41222),A | |||||||
| 44255 | LD A,(41169) | Fetch *Flags_EventStates into A and return if no event flag is set. | ||||||
| 44258 | AND A | |||||||
| 44259 | RET Z | |||||||
|
For each set bit in Flags_EventStates, bring the corresponding byte from Data_PhraseTokens into the current room.
|
||||||||
| 44260 | LD B,8 | Set a counter in B for 8 bits. | ||||||
| 44262 | LD HL,46836 | Point HL at Data_PhraseTokens. | ||||||
| 44265 | LD C,A | Copy the event flags into C for bit testing. | ||||||
| 44266 | JR EventFlag_Next | Jump to EventFlag_Next. | ||||||
| EventFlag_Advance | 44268 | INC HL | Move HL on to the next event item ID. | |||||
| EventFlag_Next | 44269 | SRL C | Shift the event flags right to test the next bit. | |||||
| 44271 | JR NC,EventFlag_Count | Jump to EventFlag_Count if this bit is not set. | ||||||
|
This event bit is set, so bring its item into the current room.
|
||||||||
| 44273 | LD A,(HL) | Fetch the item ID from Data_PhraseTokens into A. | ||||||
| 44274 | PUSH HL | Stash the table pointer and bit counter on the stack. | ||||||
| 44275 | PUSH BC | |||||||
| 44276 | CALL Handler_UpdateItemEventCurrentRoom | Call Handler_UpdateItemEventCurrentRoom to move that item into the current room. | ||||||
| 44279 | POP BC | Restore the bit counter and table pointer from the stack. | ||||||
| 44280 | POP HL | |||||||
| EventFlag_Count | 44281 | DJNZ EventFlag_Advance | Decrease the bit counter by one and loop back to EventFlag_Advance until all 8 bits have been tested. | |||||
| MovePlayerToRoom_Return | 44283 | RET | Return. | |||||
|
View the equivalent code in;
|
||||||||
| Prev: 44168 | Up: Map | Next: 44284 |