Prev: 24829 Up: Map Next: 24931
24891: 1UP/ 2UP Swapper
Used by the routines at Message_Eaten and ResetPlayerData.
This routine "swaps" the data between DE and HL.
ChangePlayer 24891 LD HL,24119 HL=ActivePlayer_Level.
24894 LD DE,24121 DE=InactivePlayer_Level.
24897 LD B,2 B=2 (counter).
24899 CALL ChangePlayer_Loop Call ChangePlayer_Loop.
24902 LD HL,24099 HL=24099.
24905 LD DE,24109 DE=24109.
24908 LD B,10 B=10 (counter).
24910 CALL ChangePlayer_Loop Call ChangePlayer_Loop.
24913 LD HL,24132 HL=24132.
24916 LD DE,24204 DE=State_Flower.
24919 LD B,40 B=40 (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 24921 LD A,(DE) A=DE.
24922 LD C,(HL) C=HL.
24923 LD (HL),A Store A at HL.
24924 LD A,C Store C at DE.
24925 LD (DE),A
24926 INC HL Increase both HL and DE by one.
24927 INC DE
24928 DJNZ ChangePlayer_Loop Decrease counter by one and loop back to ChangePlayer_Loop until counter is zero.
24930 RET Return.
View the equivalent code in;
Prev: 24829 Up: Map Next: 24931