Prev: B21E Up: Map Next: B26B
B235: 1UP/ 2UP Swapper
Used by the routines at B1D4 and B205.
This routine "swaps" the data between DE and HL.
ChangePlayer B235 LD A,($969E) A=Flag_ActivePlayer.
B238 CPL Flip the bits.
B239 LD ($969E),A Write this back to Flag_ActivePlayer.
These are all the player states.
B23C LD HL,$96BC HL=96BC
B23F LD DE,$96DF DE=96DF.
B242 LD BC,$0023 BC=23 (counter).
B245 CALL ChangePlayer_Loop Call ChangePlayer_Loop.
This is the current "map".
B248 LD HL,$DDEC HL=DDEC.
B24B LD DE,$DFEC DE=DFEC.
B24E LD BC,$0200 BC=0200 (counter).
B251 CALL ChangePlayer_Loop Call ChangePlayer_Loop.
And this is the active sprites.
B254 LD HL,$9702 HL=ImmortalData.
B257 LD DE,$982E DE=982E.
B25A LD BC,$012C BC=012C (counter).
This looks complicated but it's just grabbing the data from DE, grabbing the data from HL, and writing the others data to each one.
ChangePlayer_Loop B25D LD A,(DE) Fetch a byte from DE and store it in A.
B25E EX AF,AF' Switch to the shadow AF register.
B25F LD A,(HL) Copy a byte from HL and write it to DE.
B260 LD (DE),A
B261 EX AF,AF' Switch back to the normal AF register.
B262 LD (HL),A Write the byte held in A (orginally from DE) into HL.
B263 INC DE Increment DE by one.
B264 INC HL Increment HL by one.
B265 DEC BC Decrease C by one.
B266 LD A,B Loop back to ChangePlayer_Loop until the counter in BC is zero.
B267 OR C
B268 JR NZ,ChangePlayer_Loop
B26A RET Return.
View the equivalent code in;
Prev: B21E Up: Map Next: B26B