Prev: A84C Up: Map Next: A8B5
A880: 1UP/ 2UP Swapper
Swaps the active and inactive player data. Exchanges the four player-state bytes at ActivePlayer_Level and InactivePlayer_Level, 0400 bytes of terrain between TerrainData_Active and TerrainData_Inactive, and 0120 bytes of actor slots between Rover_Slot and Actor_List_End.
This routine "swaps" the data between DE and HL.
These are all the player states.
ChangePlayer A880 LD HL,$5EA0 HL=ActivePlayer_Level.
A883 LD DE,$5EA4 DE=InactivePlayer_Level.
A886 LD B,$04 Set a byte counter in B for 04 loops.
Exchange the four player-state bytes at ActivePlayer_Level with the inactive copy at InactivePlayer_Level.
ChangePlayer_States A888 LD A,(DE) A=*DE.
A889 LD C,(HL) C=*HL.
A88A LD (HL),A Swap the bytes at *HL and *DE.
A88B LD A,C
A88C LD (DE),A
A88D INC HL Increment HL by one.
A88E INC DE Increment DE by one.
A88F DJNZ ChangePlayer_States Decrease the counter by one and jump back to ChangePlayer_States until it is zero.
This is the current terrain buffer data.
A891 LD HL,$7000 HL=TerrainData_Active.
A894 LD DE,$7400 DE=TerrainData_Inactive.
A897 LD BC,$0400 Set the byte count in BC to 0400.
A89A CALL ChangePlayer_Loop Call ChangePlayer_Loop.
And this is the active sprites.
A89D LD HL,$6090 HL=Rover_Slot.
A8A0 LD DE,$6240 DE=Actor_List_End.
A8A3 LD BC,$0120 Set the byte count in BC to 0120.
Exchange the bytes at HL and DE for BC counts.
ChangePlayer_Loop A8A6 PUSH BC Stash BC on the stack.
A8A7 LD A,(DE) A=*DE.
A8A8 LD C,(HL) C=*HL.
A8A9 LD (HL),A Swap the bytes at *HL and *DE.
A8AA LD A,C
A8AB LD (DE),A
A8AC INC HL Increment HL by one.
A8AD INC DE Increment DE by one.
A8AE POP BC Restore BC from the stack.
A8AF DEC BC Decrease BC by one.
A8B0 LD A,B Jump back to ChangePlayer_Loop until BC is zero.
A8B1 OR C
A8B2 JR NZ,ChangePlayer_Loop
A8B4 RET Return.
View the equivalent code in;
Prev: A84C Up: Map Next: A8B5