Prev: 625C Up: Map Next: 6318
62DA: Collision: Cups
Used by the routine at 625C.
CollisionCup 62DA LD HL,($5E05) HL=PlayerMapPosition.
62DD SLA L
62DF RL H
62E1 CALL $6253 Call 6253.
62E4 LD C,H
62E5 LD HL,$721F HL=pointer to CupTable.
62E8 LD B,$08 B=08 (set a counter for the 08 cups).
Fetch the address of the cup from CupTable.
CollisionCup_Loop 62EA LD E,(HL) E=LSB of the cup map address.
62EB INC HL Increment HL by one.
62EC LD D,(HL) D=MSB of the cup map address.
62ED INC HL Increment HL by one, ready to process the next cup.
Check this is still a valid cup (that it hasn't been collected already).
62EE INC DE Increment DE by two (point to the sprite ID).
62EF INC DE
62F0 LD A,(DE) If this is not a cup (the sprite ID is not 20), then jump to CollisionCup_Next.
62F1 CP $20
62F3 JR NZ,CollisionCup_Next
This is still a valid cup, so process it.
62F5 DEC DE Decrease DE by two (go back to the start of the map record).
62F6 DEC DE
62F7 LD A,(DE) Fetch the cup X position.
62F8 SUB C
62F9 JR NC,CollisionCup_Test_X Make sure we have a positive byte.
62FB NEG
CollisionCup_Test_X 62FD CP $0C If 0C is jump to CollisionCup_Test_Y.
62FF JR C,CollisionCup_Test_Y
CollisionCup_Next 6301 DJNZ CollisionCup_Loop Decrease counter by one and loop back to CollisionCup_Loop until counter is zero.
6303 JP $624D Jump to 624D.
CollisionCup_Test_Y 6306 LD A,(DE) Fetch the cup X position.
6307 INC DE Increment DE by one.
6308 LD H,A H=cup X position.
6309 LD A,(DE) Fetch the cup Y position.
630A LD D,A D=cup Y position.
630B CALL $6B30 Call 6B30.
630E EX DE,HL Swap the DE and HL registers.
630F CALL $6B2B Call 6B2B.
6312 EX DE,HL Swap the DE and HL registers.
6313 LD B,H B=H.
6314 LD C,L C=L.
6315 JP $6212 Jump to 6212.
View the equivalent code in;
Prev: 625C Up: Map Next: 6318