![]() |
Routines |
| Prev: 6127 | Up: Map | Next: 6163 |
|
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 | 613B | LD HL,$5E37 | HL=ActivePlayer_Level. | |
| 613E | LD DE,$5E39 | DE=InactivePlayer_Level. | ||
| 6141 | LD B,$02 | Set the byte counter to 02 (the level and the lives). | ||
| 6143 | CALL ChangePlayer_Loop | Swap the data using ChangePlayer_Loop. | ||
|
Swap the cubby holes.
|
||||
| 6146 | LD HL,$5E23 | HL=CubbyHoles. | ||
| 6149 | LD DE,$5E2D | DE=InactivePlayer_CubbyHoles. | ||
| 614C | LD B,$0A | Set the byte counter to 0A (the ten cubby holes). | ||
| 614E | CALL ChangePlayer_Loop | Swap the data using ChangePlayer_Loop. | ||
|
Swap the flower and leaves.
|
||||
| 6151 | LD HL,$5E44 | HL=InactivePlayer_Flower. | ||
| 6154 | LD DE,$5E8C | DE=State_Flower. | ||
| 6157 | LD B,$28 | Set the byte counter to 28 (the flower and the four leaves). | ||
|
Swap the bytes at HL and DE, then move onto the next pair of bytes.
|
||||
| ChangePlayer_Loop | 6159 | LD A,(DE) | Fetch the byte of the inactive player. | |
| 615A | LD C,(HL) | Fetch the byte of the active player. | ||
| 615B | LD (HL),A | Write the inactive player's byte over the active player's. | ||
| 615C | LD A,C | A=the active player's byte. | ||
| 615D | LD (DE),A | Write the active player's byte over the inactive player's. | ||
| 615E | INC HL | Move both pointers onto the next byte. | ||
| 615F | INC DE | |||
| 6160 | DJNZ ChangePlayer_Loop | Decrease the byte counter by one and loop back to ChangePlayer_Loop until all of the bytes have been swapped. | ||
| 6162 | RET | Return. | ||
|
View the equivalent code in;
|
||||
| Prev: 6127 | Up: Map | Next: 6163 |