![]() |
Routines |
| Prev: 43084 | Up: Map | Next: 43189 |
|
Swaps the active and inactive player data. Exchanges the four player-state bytes at ActivePlayer_Level and InactivePlayer_Level, 1024 bytes of terrain between TerrainData_Active and TerrainData_Inactive, and 288 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 | 43136 | LD HL,24224 | HL=ActivePlayer_Level. | |
| 43139 | LD DE,24228 | DE=InactivePlayer_Level. | ||
| 43142 | LD B,4 | Set a byte counter in B for 4 loops. | ||
|
Exchange the four player-state bytes at ActivePlayer_Level with the inactive copy at InactivePlayer_Level.
|
||||
| ChangePlayer_States | 43144 | LD A,(DE) | A=*DE. | |
| 43145 | LD C,(HL) | C=*HL. | ||
| 43146 | LD (HL),A | Swap the bytes at *HL and *DE. | ||
| 43147 | LD A,C | |||
| 43148 | LD (DE),A | |||
| 43149 | INC HL | Increment HL by one. | ||
| 43150 | INC DE | Increment DE by one. | ||
| 43151 | 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.
|
||||
| 43153 | LD HL,28672 | HL=TerrainData_Active. | ||
| 43156 | LD DE,29696 | DE=TerrainData_Inactive. | ||
| 43159 | LD BC,1024 | Set the byte count in BC to 1024. | ||
| 43162 | CALL ChangePlayer_Loop | Call ChangePlayer_Loop. | ||
|
And this is the active sprites.
|
||||
| 43165 | LD HL,24720 | HL=Rover_Slot. | ||
| 43168 | LD DE,25152 | DE=Actor_List_End. | ||
| 43171 | LD BC,288 | Set the byte count in BC to 288. | ||
|
Exchange the bytes at HL and DE for BC counts.
|
||||
| ChangePlayer_Loop | 43174 | PUSH BC | Stash BC on the stack. | |
| 43175 | LD A,(DE) | A=*DE. | ||
| 43176 | LD C,(HL) | C=*HL. | ||
| 43177 | LD (HL),A | Swap the bytes at *HL and *DE. | ||
| 43178 | LD A,C | |||
| 43179 | LD (DE),A | |||
| 43180 | INC HL | Increment HL by one. | ||
| 43181 | INC DE | Increment DE by one. | ||
| 43182 | POP BC | Restore BC from the stack. | ||
| 43183 | DEC BC | Decrease BC by one. | ||
| 43184 | LD A,B | Jump back to ChangePlayer_Loop until BC is zero. | ||
| 43185 | OR C | |||
| 43186 | JR NZ,ChangePlayer_Loop | |||
| 43188 | RET | Return. | ||
|
View the equivalent code in;
|
||||
| Prev: 43084 | Up: Map | Next: 43189 |