Prev: CE41 Up: Map Next: D05B
CFF6: Goldfish Game: Collision
Used by the routine at GoldfishGame.
The player has hit a sprite; test whether it is a fish or a creature.
GoldfishGame_Collision CFF6 LD A,($DC0E) C=*GoldfishGame_PlayerAttributes.
CFF9 LD C,A
CFFA LD A,(IX+$00) A=the other sprite's horizontal co-ordinate.
CFFD SUB (IX+$07) Subtract the player's width at *GoldfishGame_PlayerWidth.
D000 INC A Increment A by one.
D001 SUB C Subtract the player column.
D002 CP $02 Jump to GoldfishGame_NextCreature if the sprites do not overlap.
D004 JR NC,GoldfishGame_NextCreature
D006 PUSH IX Stash the other sprite on the stack.
D008 LD HL,$0064 HL=0064.
D00B LD DE,$0064 DE=0064.
D00E CALL $03B5 Call BEEPER.
D011 POP IX Restore the other sprite from the stack.
D013 LD A,(IX+$08) Jump to GoldfishGame_HitCreature if this sprite is not a collectable fish.
D016 CP $01
D018 JR NZ,GoldfishGame_HitCreature
The player has caught a fish; add it to the count and remove it from the screen.
GoldfishGame_CaughtFish D01A LD A,($DB42) Increment *GoldfishGame_FishCaught by one.
D01D INC A
D01E LD ($DB42),A
D021 LD C,(IX+$00) C=the fish horizontal co-ordinate.
D024 LD B,(IX+$01) B=the fish vertical co-ordinate.
D027 LD E,(IX+$07) E=the fish width.
D02A LD D,(IX+$08) D=the fish height.
D02D LD A,(IX+$02) Jump to GoldfishGame_Collision_BlankSprite if the horizontal offset is 03.
D030 CP $03
D032 JR Z,GoldfishGame_Collision_BlankSprite
D034 INC E Widen the erase by one column.
GoldfishGame_Collision_BlankSprite D035 LD HL,$9F6C Write 9F6C to *CHARS.
D038 LD ($5C36),HL
D03B LD A,$20 A=a blank character.
D03D CALL GoldfishGame_PrintSprite Erase the fish.
D040 LD (IX+$0A),$00 Mark this fish slot inactive.
D044 JP GoldfishGame_NextCreature Jump to GoldfishGame_NextCreature.
A sea creature steals all collected fish.
GoldfishGame_HitCreature D047 XOR A Clear *GoldfishGame_FishCaught.
D048 LD ($DB42),A
D04B PUSH IX Stash IX on the stack.
D04D LD HL,$00C8 HL=00C8.
D050 LD DE,$0032 DE=0032.
D053 CALL $03B5 Call BEEPER.
D056 POP IX Restore IX from the stack.
D058 JP GoldfishGame_NextCreature Jump to GoldfishGame_NextCreature.
Prev: CE41 Up: Map Next: D05B