diff options
Diffstat (limited to 'engine/overworld/sprite_collisions.asm')
-rw-r--r-- | engine/overworld/sprite_collisions.asm | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm index dc57d5b9..db81977b 100644 --- a/engine/overworld/sprite_collisions.asm +++ b/engine/overworld/sprite_collisions.asm @@ -1,5 +1,5 @@ _UpdateSprites:: - ld h, $c1 + ld h, wSpriteStateData1 / $100 inc h ld a, SPRITESTATEDATA2_IMAGEBASEOFFSET .spriteLoop @@ -24,9 +24,12 @@ _UpdateSprites:: jr nz, .spriteLoop ret .updateCurrentSprite - cp $1 - jp nz, UpdateNonPlayerSprite - jp UpdatePlayerSprite + ldh a, [hCurrentSpriteOffset] + and a + jp z, UpdatePlayerSprite + cp $f0 ; pikachu + jp z, SpawnPikachu + ld a, [hl] UpdateNonPlayerSprite: dec a @@ -52,11 +55,10 @@ UpdateNonPlayerSprite: ; The reason that 4 is added below to the coordinate is to make it align with a ; multiple of $10 to make comparisons easier. DetectCollisionBetweenSprites: - nop + ; nop ld h, HIGH(wSpriteStateData1) ldh a, [hCurrentSpriteOffset] - add LOW(wSpriteStateData1) ld l, a ld a, [hl] ; a = [i#SPRITESTATEDATA1_PICTUREID] (0 if slot is unused) @@ -271,6 +273,17 @@ DetectCollisionBetweenSprites: jr nc, .next ; go to next sprite if distance is still positive after both adjustments .collision + ld a, l + and $f0 ; collision with pikachu? + jr nz, .asm_4cd9 + xor a + ld [wd434], a + ldh a, [hFF8F] + cp $f + jr nz, .asm_4cd9 + call Func_4d0a + jr .asm_4cef +.asm_4cd9 ldh a, [hFF91] ; a = 7 or 9 depending on sprite i's delta X ld b, a ldh a, [hFF90] ; a = 7 or 9 depending on sprite i's delta Y @@ -296,6 +309,7 @@ DetectCollisionBetweenSprites: ; to indicate which sprite the collision occurred with inc l inc l +.asm_4cef ldh a, [hFF8F] ; a = loop counter ld de, SpriteCollisionBitTable add a @@ -324,6 +338,26 @@ DetectCollisionBetweenSprites: ; c = 0 if delta X/Y is 0 ; c = 7 if delta X/Y is 1 ; c = 9 if delta X/Y is -1 +Func_4d0a: + ldh a, [hFF91] + ld b, a + ldh a, [hFF90] + inc l + cp b + jr c, .asm_4d17 + ld b, %1100 + jr .asm_4d19 +.asm_4d17 + ld b, %11 +.asm_4d19 + ld a, c + and b + ld [wd434], a + ld a, c + inc l + inc l + ret + SetSpriteCollisionValues: and a ld b, 0 |