summaryrefslogtreecommitdiff
path: root/engine/overworld/map_sprite_functions1.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/overworld/map_sprite_functions1.asm')
-rw-r--r--engine/overworld/map_sprite_functions1.asm48
1 files changed, 41 insertions, 7 deletions
diff --git a/engine/overworld/map_sprite_functions1.asm b/engine/overworld/map_sprite_functions1.asm
index d1a411fa..2ad923fb 100644
--- a/engine/overworld/map_sprite_functions1.asm
+++ b/engine/overworld/map_sprite_functions1.asm
@@ -1,7 +1,7 @@
_UpdateSprites:
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
inc h
- ld a, $e ; wSpriteStateData2 + $0e
+ ld a, $e ; (wSpriteStateData2 + $0e) & $ff
.spriteLoop
ld l, a
sub $e
@@ -24,9 +24,12 @@ _UpdateSprites:
jr nz, .spriteLoop
ret
.updateCurrentSprite
- cp $1
- jp nz, UpdateNonPlayerSprite
- jp UpdatePlayerSprite
+ ld a, [H_CURRENTSPRITEOFFSET]
+ and a
+ jp z, UpdatePlayerSprite
+ cp $f0 ; pikachu
+ jp z, SpawnPikachu
+ ld a, [hl]
UpdateNonPlayerSprite:
dec a
@@ -51,11 +54,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, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
- add wSpriteStateData1 % $100
ld l, a
ld a, [hl] ; a = [$c1i0] (picture) (0 if slot is unused)
@@ -270,6 +272,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
+ ld a, [$ff8f]
+ cp $f
+ jr nz, .asm_4cd9
+ call Func_4d0a
+ jr .asm_4cef
+.asm_4cd9
ld a, [$ff91] ; a = 7 or 9 depending on sprite i's delta X
ld b, a
ld a, [$ff90] ; a = 7 or 9 depending on sprite i's delta Y
@@ -294,6 +307,7 @@ DetectCollisionBetweenSprites:
; set bit in [$c1ie] or [$c1if] to indicate which sprite the collision occurred with
inc l
inc l
+.asm_4cef
ld a, [$ff8f] ; a = loop counter
ld de, SpriteCollisionBitTable
add a
@@ -322,6 +336,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:
+ ld a, [$ff91]
+ ld b, a
+ ld a, [$ff90]
+ 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