![]() |
Routines |
| Prev: 24871 | Up: Map | Next: 24931 |
|
Used by the routines at PlayerTurnEnds and ResetPlayerData.
Swaps the data of the active player with that of the inactive player: the level and lives, the cubby holes, and the flower and leaf objects.
|
||||
|
This routine "swaps" the data between DE and HL.
Swap the levels and lives.
|
||||
| ChangePlayer | 24891 | LD HL,24119 | HL=ActivePlayer_Level. | |
| 24894 | LD DE,24121 | DE=InactivePlayer_Level. | ||
| 24897 | LD B,2 | Set the byte counter to 2 (the level and the lives). | ||
| 24899 | CALL ChangePlayer_Loop | Swap the data using ChangePlayer_Loop. | ||
|
Swap the cubby holes.
|
||||
| 24902 | LD HL,24099 | HL=CubbyHoles. | ||
| 24905 | LD DE,24109 | DE=InactivePlayer_CubbyHoles. | ||
| 24908 | LD B,10 | Set the byte counter to 10 (the ten cubby holes). | ||
| 24910 | CALL ChangePlayer_Loop | Swap the data using ChangePlayer_Loop. | ||
|
Swap the flower and leaves.
|
||||
| 24913 | LD HL,24132 | HL=InactivePlayer_Flower. | ||
| 24916 | LD DE,24204 | DE=State_Flower. | ||
| 24919 | LD B,40 | Set the byte counter to 40 (the flower and the four leaves). | ||
|
Swap the bytes at HL and DE, then move onto the next pair of bytes.
|
||||
| ChangePlayer_Loop | 24921 | LD A,(DE) | Fetch the byte of the inactive player. | |
| 24922 | LD C,(HL) | Fetch the byte of the active player. | ||
| 24923 | LD (HL),A | Write the inactive player's byte over the active player's. | ||
| 24924 | LD A,C | A=the active player's byte. | ||
| 24925 | LD (DE),A | Write the active player's byte over the inactive player's. | ||
| 24926 | INC HL | Move both pointers onto the next byte. | ||
| 24927 | INC DE | |||
| 24928 | DJNZ ChangePlayer_Loop | Decrease the byte counter by one and loop back to ChangePlayer_Loop until all of the bytes have been swapped. | ||
| 24930 | RET | Return. | ||
|
View the equivalent code in;
|
||||
| Prev: 24871 | Up: Map | Next: 24931 |