ref: 5b94d54a6c81d7ea09497dfc3d1477a7ed3bd954
parent: 2f14f3a669afd51ab98d9f2dea5857e5b548a8d7
author: PikalaxALT <PikalaxALT@gmail.com>
date: Fri Dec 4 03:46:11 EST 2015
More work on animations
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -5339,7 +5339,7 @@
call Function3d329
jr c, .Cancel
.loop
- callba Function8ea4a
+ callba FreezeMonIcons
call .GetMenu
jr c, .PressedB
call Function1bee
@@ -5674,7 +5674,7 @@
ld [MenuSelection2], a
ld a, $1
ld [wcfaa], a
- ld a, [wd0eb]
+ ld a, [wNumMoves]
inc a
ld [wcfa3], a
ld a, $1
@@ -5812,7 +5812,7 @@
ld a, [MenuSelection2]
and a
jp nz, .menu_loop
- ld a, [wd0eb]
+ ld a, [wNumMoves]
inc a
ld [MenuSelection2], a
jp .menu_loop
@@ -5821,7 +5821,7 @@
.pressed_down ; 3e62e
ld a, [MenuSelection2]
ld b, a
- ld a, [wd0eb]
+ ld a, [wNumMoves]
rept 2
inc a
endr
--- a/constants/sprite_constants.asm
+++ b/constants/sprite_constants.asm
@@ -358,7 +358,7 @@
const SPRITEANIMSTRUCT_XOFFSET
const SPRITEANIMSTRUCT_YOFFSET
const SPRITEANIMSTRUCT_DURATION
- const SPRITEANIMSTRUCT_09
+ const SPRITEANIMSTRUCT_DURATIONOFFSET
const SPRITEANIMSTRUCT_FRAME
const SPRITEANIMSTRUCT_0B
const SPRITEANIMSTRUCT_0C
--- a/data/sprite_engine.asm
+++ b/data/sprite_engine.asm
@@ -67,7 +67,7 @@
dw Unknown_8d948 ; 41
; 8d76a
-Unknown_8d76a: db $00, $20
+Unknown_8d76a: db $00, $20 ; lowest 6 bits of second byte are duration, upper two bits are flags
db -1
Unknown_8d76d: db $00, $08
db $01, $08
@@ -1569,3 +1569,4 @@
dbbw $10, $39, $672a ; 16-tile 2bpp at 39:672a (empty data)
dbbw $10, $24, $672a ; 16-tile 2bpp at 24:672a (inside Function926f7)
dbbw $10, $21, $672a ; 16-tile 2bpp at 21:672a (inside Function8671c)
+; 8e72a (23:672a)
--- a/engine/compose_mail.asm
+++ b/engine/compose_mail.asm
@@ -34,7 +34,7 @@
ld a, BANK(.MailIcon)
call FarCopyBytes
xor a
- ld hl, wc300
+ ld hl, wSpriteAnimDict
ld [hli], a
ld [hl], a
@@ -43,7 +43,7 @@
ld a, SPRITE_ANIM_INDEX_00
call _InitSpriteAnimStruct
- ld hl, $2
+ ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], $0
call .InitCharset
@@ -67,6 +67,7 @@
add hl, de
ld [hl], $4e
ret
+
; 11ef4 (4:5ef4)
.MailIcon: ; 11ef4
@@ -77,6 +78,7 @@
ld a, $21
ld [wc6d3], a
ret
+
; 11f7a (4:5f7a)
.Dummy: ; dummied out
@@ -128,6 +130,7 @@
call DelayFrame
and a
ret
+
.exit_mail
callab ClearSpriteAnims
call ClearSprites
@@ -179,10 +182,10 @@
ld [wc6d5], a
ld a, b
ld [wc6d6], a
- ld hl, $1
+ ld hl, SPRITEANIMSTRUCT_01
add hl, bc
ld a, [hl]
- ld hl, $e
+ ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
ld [hl], a
ld hl, wJumptableIndex
@@ -232,10 +235,10 @@
ld c, [hl]
inc hl
ld b, [hl]
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], $9
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld [hl], $5
ret
@@ -268,44 +271,47 @@
ld de, MailEntry_Uppercase
call .PlaceMailCharset
ret
+
.switch_to_lowercase
ld de, MailEntry_Lowercase
call .PlaceMailCharset
ret
+; called from engine/sprite_anims.asm
Function120c1: ; 120c1 (4:60c1)
call Function1210c
- ld hl, SpriteAnim1Sprite0d - SpriteAnim1
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
ld e, a
swap e
- ld hl, SpriteAnim1YOffset - SpriteAnim1
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], e
cp $5
ld de, Unknown_120f8
- ld a, $0
+ ld a, 0
jr nz, .asm_120df
ld de, Unknown_12102
- ld a, $1
+ ld a, 1
.asm_120df
- ld hl, SpriteAnim1Sprite0e - SpriteAnim1
+ ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
add [hl]
- ld hl, SpriteAnim1Sprite01 - SpriteAnim1
+ ld hl, SPRITEANIMSTRUCT_01
add hl, bc
ld [hl], a
- ld hl, SpriteAnim1Sprite0c - SpriteAnim1
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld l, [hl]
- ld h, SpriteAnim1Index - SpriteAnim1
+ ld h, 0
add hl, de
ld a, [hl]
- ld hl, SpriteAnim1XOffset - SpriteAnim1
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
+
; 120f8 (4:60f8)
Unknown_120f8: ; 120f8
@@ -329,11 +335,12 @@
and D_RIGHT
jr nz, .right
ret
+
.right
call Function1218b
and a
jr nz, .asm_12138
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
cp $9
@@ -340,9 +347,11 @@
jr nc, .asm_12135
inc [hl]
ret
+
.asm_12135
ld [hl], $0
ret
+
.asm_12138
cp $3
jr nz, .asm_1213d
@@ -351,15 +360,16 @@
ld e, a
add a
add e
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], a
ret
+
.left
call Function1218b
and a
jr nz, .asm_12159
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
and a
@@ -366,9 +376,11 @@
jr z, .asm_12156
dec [hl]
ret
+
.asm_12156
ld [hl], $9
ret
+
.asm_12159
cp $1
jr nz, .asm_1215f
@@ -380,12 +392,13 @@
ld e, a
add a
add e
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], a
ret
+
.down
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
cp $5
@@ -392,11 +405,13 @@
jr nc, .asm_12175
inc [hl]
ret
+
.asm_12175
ld [hl], $0
ret
+
.up
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
and a
@@ -403,6 +418,7 @@
jr z, .asm_12182
dec [hl]
ret
+
.asm_12182
ld [hl], $5
ret
@@ -414,12 +430,12 @@
ld b, [hl]
Function1218b: ; 1218b (4:618b)
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
cp $5
jr nz, .asm_121aa
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
cp $3
@@ -428,12 +444,15 @@
jr c, .asm_121a7
ld a, $3
ret
+
.asm_121a4
ld a, $1
ret
+
.asm_121a7
ld a, $2
ret
+
.asm_121aa
xor a
ret
--- a/engine/crystal_intro.asm
+++ b/engine/crystal_intro.asm
@@ -213,7 +213,7 @@
GameFreakLogoJumper: ; e46ed (39:46ed)
- ld hl, $b
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld e, [hl]
ld d, 0
@@ -234,19 +234,19 @@
dw GameFreakLogoScene5
GameFreakLogoScene1: ; e4707 (39:4707)
- ld hl, $b
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
inc [hl]
ret
GameFreakLogoScene2: ; e470d (39:470d)
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
and a
jr z, .asm_e4747
ld d, a
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
and $3f
@@ -256,16 +256,16 @@
.asm_e4723
ld e, a
callba Functionce765
- ld hl, $7
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], e
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
dec [hl]
and $1f
ret nz
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
sub $30
@@ -273,11 +273,12 @@
ld de, SFX_DITTO_BOUNCE
call PlaySFX
ret
+
.asm_e4747
- ld hl, $b
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
inc [hl]
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld [hl], $0
ld de, SFX_DITTO_POP_UP
@@ -285,7 +286,7 @@
ret
GameFreakLogoScene3: ; e4759 (39:4759)
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
cp $20
@@ -292,11 +293,12 @@
jr nc, .asm_e4764
inc [hl]
ret
+
.asm_e4764
- ld hl, $b
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
inc [hl]
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld [hl], $0
ld de, SFX_DITTO_TRANSFORM
@@ -304,7 +306,7 @@
ret
GameFreakLogoScene4: ; e4776 (39:4776)
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
cp $40
@@ -331,12 +333,12 @@
ld a, $1
ld [hCGBPalUpdate], a
ret
+
.asm_e47a3
- ld hl, $b
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
inc [hl]
call PlaceGameFreakPresents_AdvanceIndex
-
GameFreakLogoScene5: ; e47ab (39:47ab)
ret
; e47ac (39:47ac)
@@ -810,7 +812,7 @@
.finish
ld de, SFX_INTRO_SUICUNE_2
call PlaySFX
- callba Function8d03d
+ callba DeinitializeAllSprites
call NextIntroScene
ret
@@ -1101,7 +1103,7 @@
ret
.asm_e4e2c
- callba Function8d03d
+ callba DeinitializeAllSprites
ret
.asm_e4e33
@@ -1313,7 +1315,7 @@
ld a, $90
ld [hWY], a
callba ClearSpriteAnims
- ld hl, wc300
+ ld hl, wSpriteAnimDict
xor a
ld [hli], a
ld [hl], $7f
@@ -1394,7 +1396,7 @@
jr nc, .done
ret
.done
- callba Function8d03d
+ callba DeinitializeAllSprites
call NextIntroScene
ret
--- a/engine/intro_menu.asm
+++ b/engine/intro_menu.asm
@@ -450,9 +450,9 @@
call DelayFrame
call GetJoypad
ld hl, hJoyPressed
- bit 0, [hl]
+ bit A_BUTTON_F, [hl]
jr nz, .PressA
- bit 1, [hl]
+ bit B_BUTTON_F, [hl]
jr z, .loop
scf
ret
@@ -1336,7 +1336,7 @@
and $3
ret nz
ld bc, SpriteAnim10
- ld hl, SpriteAnim10FrameIndex - SpriteAnim10
+ ld hl, SPRITEANIMSTRUCT_FRAME
add hl, bc ; over-the-top compicated way to load wc3ae into hl
ld l, [hl]
ld h, 0
--- a/engine/learn.asm
+++ b/engine/learn.asm
@@ -150,7 +150,7 @@
ld [wcfa1], a
ld a, $6
ld [wcfa2], a
- ld a, [wd0eb]
+ ld a, [wNumMoves]
inc a
ld [wcfa3], a
ld a, $1
--- /dev/null
+++ b/engine/mon_icons.asm
@@ -1,0 +1,450 @@
+LoadOverworldMonIcon: ; 8e82b
+ ld a, e
+ call ReadMonMenuIcon
+ ld l, a
+ ld h, 0
+ add hl, hl
+ ld de, IconPointers
+ add hl, de
+ ld a, [hli]
+ ld e, a
+ ld d, [hl]
+ ld b, BANK(Icons)
+ ld c, 8
+ ret
+; 8e83f
+
+Function8e83f: ; 8e83f
+ push hl
+ push de
+ push bc
+ call Function8e849
+ pop bc
+ pop de
+ pop hl
+ ret
+; 8e849
+
+Function8e849: ; 8e849
+ ld d, 0
+ ld hl, .jumptable
+rept 2
+ add hl, de
+endr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 8e854
+
+
+.jumptable: ; 8e854 (23:6854)
+ dw Function8e8d5 ; init
+ dw Function8e961
+ dw Function8e97d
+ dw Function8e99a
+ dw Function8e898
+ dw Function8e8b1
+ dw Function8e862
+
+
+Function8e862: ; 8e862 (23:6862)
+ call InitPartyMenuIcon
+ call Function8e86c
+ call SetPartyMonIconAnimSpeed
+ ret
+
+Function8e86c: ; 8e86c (23:686c)
+ push bc
+ ld a, [hObjectStructIndexBuffer]
+ ld hl, PartyMon1Item
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ pop bc
+ ld a, [hl]
+ and a
+ jr z, .asm_8e890
+ push hl
+ push bc
+ ld d, a
+ callab ItemIsMail
+ pop bc
+ pop hl
+ jr c, .asm_8e88e
+ ld a, $6
+ jr .asm_8e892
+.asm_8e88e
+ ld a, $5
+ ; jr .asm_8e892
+.asm_8e890
+ ld a, $4
+.asm_8e892
+ ld hl, SPRITEANIMSTRUCT_01
+ add hl, bc
+ ld [hl], a
+ ret
+
+Function8e898: ; 8e898 (23:6898)
+ call Function8e8d5
+ ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
+ add hl, bc
+ ld a, $0
+ ld [hl], a
+ ld hl, SPRITEANIMSTRUCT_XCOORD
+ add hl, bc
+ ld a, 9 * 8
+ ld [hl], a
+ ld hl, SPRITEANIMSTRUCT_YCOORD
+ add hl, bc
+ ld a, 9 * 8
+ ld [hl], a
+ ret
+
+Function8e8b1: ; 8e8b1 (23:68b1)
+ call InitPartyMenuIcon
+ call SetPartyMonIconAnimSpeed
+ ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
+ add hl, bc
+ ld a, $0
+ ld [hl], a
+ ld hl, SPRITEANIMSTRUCT_XCOORD
+ add hl, bc
+ ld a, 3 * 8
+ ld [hl], a
+ ld hl, SPRITEANIMSTRUCT_YCOORD
+ add hl, bc
+ ld a, 12 * 8
+ ld [hl], a
+ ld a, c
+ ld [wc608], a
+ ld a, b
+ ld [wc608 + 1], a
+ ret
+
+Function8e8d5: ; 8e8d5 (23:68d5)
+ call InitPartyMenuIcon
+ call .SpawnItemIcon
+ call SetPartyMonIconAnimSpeed
+ ret
+
+.SpawnItemIcon: ; 8e8df (23:68df)
+ push bc
+ ld a, [hObjectStructIndexBuffer]
+ ld hl, PartyMon1Item
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ pop bc
+ ld a, [hl]
+ and a
+ ret z
+ push hl
+ push bc
+ ld d, a
+ callab ItemIsMail
+ pop bc
+ pop hl
+ jr c, .mail
+ ld a, $3
+ jr .okay
+
+ ld a, $2
+.okay
+ ld hl, SPRITEANIMSTRUCT_01
+ add hl, bc
+ ld [hl], a
+ ret
+
+InitPartyMenuIcon: ; 8e908 (23:6908)
+ ld a, [wCurIconTile]
+ push af
+ ld a, [hObjectStructIndexBuffer]
+ ld hl, PartySpecies
+ ld e, a
+ ld d, $0
+ add hl, de
+ ld a, [hl]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ call GetMemIconGFX
+ ld a, [hObjectStructIndexBuffer]
+; y coord
+rept 4
+ add a
+endr
+ add $1c
+ ld d, a
+; x coord
+ ld e, $10
+; type is partymon icon
+ ld a, SPRITE_ANIM_INDEX_00
+ call InitSpriteAnimStruct
+ pop af
+ ld hl, SPRITEANIMSTRUCT_TILE_ID
+ add hl, bc
+ ld [hl], a
+ ret
+
+SetPartyMonIconAnimSpeed: ; 8e936 (23:6936)
+ push bc
+ ld a, [hObjectStructIndexBuffer]
+ ld b, a
+ call .getspeed
+ ld a, b
+ pop bc
+ ld hl, SPRITEANIMSTRUCT_DURATIONOFFSET
+ add hl, bc
+ ld [hl], a
+ rlca
+ rlca
+ ld hl, SPRITEANIMSTRUCT_0D
+ add hl, bc
+ ld [hl], a
+ ret
+
+.getspeed: ; 8e94c (23:694c)
+ callba PlacePartymonHPBar
+ call GetHPPal
+ ld e, d
+ ld d, 0
+ ld hl, .speeds
+ add hl, de
+ ld b, [hl]
+ ret
+; 8e95e (23:695e)
+
+.speeds: ; 8e95e
+ db $00, $40, $80
+; 8e961
+
+Function8e961: ; 8e961 (23:6961)
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ xor a
+ call GetIconGFX
+ depixel 4, 4, 4, 0
+ ld a, SPRITE_ANIM_INDEX_00
+ call InitSpriteAnimStruct
+ ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
+ add hl, bc
+ ld [hl], $0
+ ret
+
+Function8e97d: ; 8e97d (23:697d)
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ xor a
+ call GetIconGFX
+ ld d, 3 * 8 + 2
+ ld e, 4 * 8 + 4
+ ld a, SPRITE_ANIM_INDEX_00
+ call InitSpriteAnimStruct
+ ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
+ add hl, bc
+ ld [hl], SPRITE_ANIM_SEQ_00
+ ret
+
+Function8e99a: ; 8e99a (23:699a)
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ ld a, $62
+ ld [wCurIconTile], a
+ call GetMemIconGFX
+ ret
+
+GetSpeciesIcon: ; 8e9ac
+; Load species icon into VRAM at tile a
+ push de
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ pop de
+ ld a, e
+ call GetIconGFX
+ ret
+; 8e9bc
+
+
+FlyFunction_GetMonIcon: ; 8e9bc (23:69bc)
+ push de
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ pop de
+ ld a, e
+ call GetIcon_a
+ ret
+; 8e9cc (23:69cc)
+
+GetMonIcon2: ; 8e9cc
+; unreferenced
+ push de
+ ld a, [wd265]
+ call ReadMonMenuIcon
+ ld [CurIcon], a
+ pop de
+ call GetIcon_de
+ ret
+; 8e9db
+
+GetMemIconGFX: ; 8e9db (23:69db)
+ ld a, [wCurIconTile]
+GetIconGFX: ; 8e9de
+ call GetIcon_a
+ ld de, $80 ; 8 tiles
+ add hl, de
+ ld de, HeldItemIcons
+ lb bc, BANK(HeldItemIcons), 2
+ call GetGFXUnlessMobile
+ ld a, [wCurIconTile]
+ add 10
+ ld [wCurIconTile], a
+ ret
+
+HeldItemIcons:
+INCBIN "gfx/icon/mail.2bpp"
+INCBIN "gfx/icon/item.2bpp"
+; 8ea17
+
+GetIcon_de: ; 8ea17
+; Load icon graphics into VRAM starting from tile de.
+ ld l, e
+ ld h, d
+ jr GetIcon
+
+GetIcon_a: ; 8ea1b
+; Load icon graphics into VRAM starting from tile a.
+ ld l, a
+ ld h, 0
+
+GetIcon: ; 8ea1e
+; Load icon graphics into VRAM starting from tile hl.
+
+; One tile is 16 bytes long.
+rept 4
+ add hl, hl
+endr
+
+ ld de, VTiles0
+ add hl, de
+ push hl
+
+; The icons are contiguous, in order and of the same
+; size, so the pointer table is somewhat redundant.
+ ld a, [CurIcon]
+ push hl
+ ld l, a
+ ld h, 0
+ add hl, hl
+ ld de, IconPointers
+ add hl, de
+ ld a, [hli]
+ ld e, a
+ ld d, [hl]
+ pop hl
+
+ lb bc, BANK(Icons), 8
+ call GetGFXUnlessMobile
+
+ pop hl
+ ret
+; 8ea3f
+
+GetGFXUnlessMobile: ; 8ea3f
+ ld a, [wLinkMode]
+ cp LINK_MOBILE
+ jp nz, Request2bpp
+ jp Get2bpp_2
+; 8ea4a
+
+FreezeMonIcons: ; 8ea4a
+ ld hl, wSpriteAnimationStructs
+ ld e, PARTY_LENGTH
+ ld a, [MenuSelection2]
+ ld d, a
+.loop
+ ld a, [hl]
+ and a
+ jr z, .next
+ cp d
+ jr z, .loadwithtwo
+ ld a, SPRITE_ANIM_SEQ_00
+ jr .ok
+
+.loadwithtwo
+ ld a, SPRITE_ANIM_SEQ_02
+
+.ok
+ push hl
+ ld c, l
+ ld b, h
+ ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
+ add hl, bc
+ ld [hl], a
+ pop hl
+
+.next
+ ld bc, $10
+ add hl, bc
+ dec e
+ jr nz, .loop
+ ret
+; 8ea71
+
+UnfreezeMonIcons: ; 8ea71
+ ld hl, wSpriteAnimationStructs
+ ld e, PARTY_LENGTH
+.loop
+ ld a, [hl]
+ and a
+ jr z, .next
+ push hl
+ ld c, l
+ ld b, h
+ ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
+ add hl, bc
+ ld [hl], SPRITE_ANIM_SEQ_01
+ pop hl
+.next
+ ld bc, $10
+ add hl, bc
+ dec e
+ jr nz, .loop
+ ret
+; 8ea8c (23:6a8c)
+
+HoldSwitchmonIcon: ; 8ea8c
+ ld hl, wSpriteAnimationStructs
+ ld e, PARTY_LENGTH
+ ld a, [wSwitchMon]
+ ld d, a
+.loop
+ ld a, [hl]
+ and a
+ jr z, .next
+ cp d
+ jr z, .is_switchmon
+ ld a, SPRITE_ANIM_SEQ_03
+ jr .join_back
+
+.is_switchmon
+ ld a, SPRITE_ANIM_SEQ_02
+.join_back
+ push hl
+ ld c, l
+ ld b, h
+ ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
+ add hl, bc
+ ld [hl], a
+ pop hl
+.next
+ ld bc, $10
+ add hl, bc
+ dec e
+ jr nz, .loop
+ ret
+
+INCLUDE "menu/mon_icons.asm"
--- a/engine/namingscreen.asm
+++ b/engine/namingscreen.asm
@@ -176,7 +176,7 @@
depixel 4, 4, 4, 0
ld a, SPRITE_ANIM_INDEX_0A
call _InitSpriteAnimStruct
- ld hl, $1
+ ld hl, SPRITEANIMSTRUCT_01
add hl, bc
ld [hl], $0
hlcoord 5, 2
@@ -411,10 +411,10 @@
ld [wc6d5], a
ld a, b
ld [wc6d6], a
- ld hl, $1
+ ld hl, SPRITEANIMSTRUCT_01
add hl, bc
ld a, [hl]
- ld hl, $e
+ ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
ld [hl], a
ld hl, wJumptableIndex
@@ -454,10 +454,10 @@
ld c, [hl]
inc hl
ld b, [hl]
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], $8
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld [hl], $4
call Function1189c
@@ -497,7 +497,7 @@
ld b, [hl]
Function11a11: ; 11a11 (4:5a11)
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
push bc
@@ -509,7 +509,7 @@
cp b
pop bc
jr nz, .asm_11a39
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
cp $3
@@ -530,12 +530,12 @@
Function11a3b: ; 11a3b (4:5a3b)
call Function11a8b
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
ld e, a
swap e
- ld hl, $7
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], e
ld d, $4
@@ -550,19 +550,19 @@
ld de, Unknown_11a82
ld a, $1
.asm_11a60
- ld hl, $e
+ ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
add [hl]
- ld hl, $1
+ ld hl, SPRITEANIMSTRUCT_01
add hl, bc
ld [hl], a
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld l, [hl]
ld h, $0
add hl, de
ld a, [hl]
- ld hl, $6
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
@@ -593,7 +593,7 @@
call Function11a11
and a
jr nz, .asm_11ab7
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
cp $8
@@ -611,7 +611,7 @@
ld e, a
add a
add e
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], a
ret
@@ -619,7 +619,7 @@
call Function11a11
and a
jr nz, .asm_11ad8
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
and a
@@ -640,12 +640,12 @@
ld e, a
add a
add e
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], a
ret
.down
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
call Function1189c
@@ -663,7 +663,7 @@
ld [hl], $0
ret
.up
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
and a
@@ -826,10 +826,10 @@
ld c, [hl]
inc hl
ld b, [hl]
- ld hl, $6
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld a, [hl]
- ld hl, $4
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
add [hl]
sub $8
@@ -837,10 +837,10 @@
srl a
srl a
ld e, a
- ld hl, $7
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld a, [hl]
- ld hl, $5
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
add [hl]
sub $10
--- a/engine/overworld.asm
+++ b/engine/overworld.asm
@@ -266,7 +266,7 @@
and a
jr z, .NoBreedmon
- callba Function8e82b
+ callba LoadOverworldMonIcon
ld l, 1
ld h, 0
--- a/engine/pokegear.asm
+++ b/engine/pokegear.asm
@@ -1425,12 +1425,13 @@
_UpdateRadioStation: ; 9163e (24:563e)
jr UpdateRadioStation
-Function91640: ; 91640 (24:5640)
+; called from engine/sprite_anims.asm
+AnimateTuningKnob: ; 91640 (24:5640)
push bc
call .TuningKnob
pop bc
ld a, [wRadioTuningKnob]
- ld hl, $6
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
--- a/engine/predef.asm
+++ b/engine/predef.asm
@@ -65,7 +65,7 @@
add_predef ListMoves ; $20
add_predef PlaceNonFaintStatus
add_predef Function50cdb
- add_predef Function50c50
+ add_predef ListMovePP
add_predef GetGender
add_predef StatsScreenInit
add_predef DrawPlayerHP
--- a/engine/sprite_anims.asm
+++ b/engine/sprite_anims.asm
@@ -35,7 +35,7 @@
dw .seventeen
dw .eighteen
dw .nineteen ; finish egg hatching animation
- dw .twenty
+ dw .twenty ; radio tuning knob
dw .twentyone
dw .twentytwo ; flying sprite
dw .twentythree ; flying leaves
@@ -57,23 +57,27 @@
.one: ; 8d2a2 (23:52a2)
ld a, [MenuSelection2]
- ld hl, 0
+
+ ld hl, SPRITEANIMSTRUCT_INDEX
add hl, bc
cp [hl]
jr z, .two
- ld hl, $4
+
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld [hl], $10
- ld hl, $7
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], $0
ret
.two: ; 8d2b9 (23:52b9)
- ld hl, $4
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld [hl], $18
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
ld d, a
@@ -80,10 +84,12 @@
inc [hl]
and $f
ret nz
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld e, [hl]
- ld hl, $7
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld a, d
and $10 ; bit 4
@@ -97,10 +103,12 @@
xor a
ld [hl], a
ret
+
.asm_8d2e2
ld a, $ff
ld [hl], a
ret
+
.asm_8d2e6
ld a, $fe
ld [hl], a
@@ -108,16 +116,19 @@
.three: ; 8d2ea (23:52ea)
ld a, [MenuSelection2]
- ld hl, 0
+
+ ld hl, SPRITEANIMSTRUCT_INDEX
add hl, bc
cp [hl]
jr z, .asm_8d2fb
- ld hl, $4
+
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld [hl], $10
ret
+
.asm_8d2fb
- ld hl, $4
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld [hl], $18
ret
@@ -133,66 +144,76 @@
; 8d30a
.four_zero: ; 8d30a
- call .asm_8d6d8
- ld hl, 0
+ call .IncrementSpriteAnimStruct0B
+
+ ld hl, SPRITEANIMSTRUCT_INDEX
add hl, bc
ld a, [hl]
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
and $3
ld [hl], a
inc [hl]
swap a
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], a
.four_one: ; 8d321
- ld hl, $4
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld a, [hl]
cp $a4
jr nc, .asm_8d356
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
add $4
- ld hl, $4
+
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld [hl], a
- ld hl, $5
+
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
inc [hl]
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
sla a
sla a
ld d, $2
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
add $3
ld [hl], a
- call .ApplyYOffset
- ld hl, $7
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
ret
.asm_8d356
- call Function8d036
+ call DeinitializeSprite
ret
; 8d35a
.twentyfive: ; 8d35a (23:535a)
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
inc a
ld [hl], a
ld d, $2
- call .ApplyYOffset
- ld hl, $7
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
ret
@@ -210,7 +231,7 @@
ret
.seven: ; 8d381 (23:5381)
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
and a
@@ -221,69 +242,81 @@
ld d, a
and $1f
jr nz, .asm_8d395
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
dec [hl]
.asm_8d395
- ld hl, $b
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld a, [hl]
push af
push de
- call .ApplyYOffset
- ld hl, $7
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
pop de
pop af
- call .ApplyXOffset
- ld hl, $6
+ call .ApplySineWaveX
+
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
- ld hl, $b
+
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
add [hl]
ld [hl], a
ret
+
.asm_8d3ba
ld a, $1
ld [wcf64], a
- call Function8d036
+ call DeinitializeSprite
ret
.eight: ; 8d3c3 (23:53c3)
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hli]
or [hl]
jr z, .asm_8d41e
- ld hl, $f
+
+ ld hl, SPRITEANIMSTRUCT_0F
add hl, bc
ld d, [hl]
- ld hl, $b
+
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld a, [hl]
push af
push de
- call .ApplyYOffset
- ld hl, $7
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
pop de
pop af
- call .ApplyXOffset
- ld hl, $6
+ call .ApplySineWaveX
+
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
- ld hl, $e
+
+ ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
ld a, [hli]
ld h, [hl]
@@ -291,12 +324,14 @@
add hl, de
ld e, l
ld d, h
- ld hl, $e
+
+ ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
ld [hl], e
inc hl
ld [hl], d
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hli]
ld h, [hl]
@@ -305,19 +340,22 @@
add hl, de
ld e, l
ld d, h
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], e
inc hl
ld [hl], d
- ld hl, $b
+
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld a, [hl]
xor $20
ld [hl], a
ret
+
.asm_8d41e
- call Function8d036
+ call DeinitializeSprite
ret
.nine: ; 8d422 (23:5422)
@@ -336,7 +374,7 @@
ret
.eleven: ; 8d43e (23:543e)
- ld hl, $b
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld a, [hl]
dec [hl]
@@ -343,24 +381,27 @@
ld e, a
and $1
jr z, .asm_8d462
- ld hl, $4
+
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld a, [hl]
cp $78
jr c, .asm_8d461
- call Function8d036
+ call DeinitializeSprite
ld a, $4
ld [wcf64], a
ld de, SFX_PLACE_PUZZLE_PIECE_DOWN
call PlaySFX
ret
+
.asm_8d461
inc [hl]
.asm_8d462
ld a, e
ld d, $20
- call .ApplyYOffset
- ld hl, $7
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
ret
@@ -394,10 +435,12 @@
.sixteen_zero: ; 8d493
ld a, $14
call Function8d120
- ld hl, $b
+
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld [hl], $2
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], $20
ret
@@ -404,7 +447,7 @@
; 8d4a5
.sixteen_two: ; 8d4a5
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
and a
@@ -413,13 +456,14 @@
ret
.asm_8d4af
- call .asm_8d6d8
- ld hl, $c
+ call .IncrementSpriteAnimStruct0B
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], $40
.sixteen_three: ; 8d4b8
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
cp $30
@@ -426,8 +470,9 @@
jr c, .asm_8d4cd
dec [hl]
ld d, $28
- call .ApplyYOffset
- ld hl, $7
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
ret
@@ -439,13 +484,15 @@
; 8d4d5
.sixteen_one: ; 8d4d5
- ld hl, $b
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld [hl], $4
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], $30
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld [hl], $24
ret
@@ -452,29 +499,34 @@
; 8d4e8
.sixteen_four: ; 8d4e8
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
and a
jr z, .asm_8d51c
ld d, a
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
- call ApplyYOffset
- ld hl, $7
+ call ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
inc [hl]
ld a, [hl]
and $3f
ret nz
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], $20
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
sub $c
@@ -485,19 +537,20 @@
.asm_8d51c
xor a
- ld hl, $7
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
- call .asm_8d6d8
+ call .IncrementSpriteAnimStruct0B
ret
.sixteen_five: ; 8d526
- call Function8d036
+ call DeinitializeSprite
ret
; 8d52a
.seventeen: ; 8d52a (23:552a)
- ld hl, $4
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld a, [hl]
rept 2
@@ -512,7 +565,7 @@
ret
.asm_8d53f
- call Function8d036
+ call DeinitializeSprite
ret
.eighteen: ; 8d543 (23:5543)
@@ -520,7 +573,7 @@
ret
.nineteen: ; 8d54a (23:554a)
- ld hl, SpriteAnim1Sprite0c - SpriteAnim1
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
cp $80
@@ -528,7 +581,8 @@
ld d, a
add $8
ld [hl], a
- ld hl, SpriteAnim1Sprite0b - SpriteAnim1
+
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld a, [hl]
xor $20
@@ -536,29 +590,31 @@
push af
push de
- call .ApplyYOffset
- ld hl, SpriteAnim1YOffset - SpriteAnim1
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
pop de
pop af
- call .ApplyXOffset
- ld hl, SpriteAnim1XOffset - SpriteAnim1
+ call .ApplySineWaveX
+
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
.finish_nineteen
- call Function8d036
+ call DeinitializeSprite
ret
.twenty: ; 8d578 (23:5578)
- callab Function91640
+ callab AnimateTuningKnob
ret
.twentyone: ; 8d57f (23:557f)
- ld hl, $d
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld e, [hl]
inc hl
@@ -567,12 +623,14 @@
add hl, de
ld e, l
ld d, h
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld [hl], e
inc hl
ld [hl], d
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
rept 3
@@ -580,36 +638,41 @@
endr
push af
push de
- call .ApplyYOffset
- ld hl, $7
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
pop de
pop af
- call .ApplyXOffset
- ld hl, $6
+ call .ApplySineWaveX
+
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
.twentytwo: ; 8d5b0 (23:55b0)
- ld hl, $5
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld a, [hl]
and a
ret z
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
inc [hl]
cp $40
ret c
- ld hl, $5
+
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
rept 2
dec [hl]
endr
- ld hl, $f
+
+ ld hl, SPRITEANIMSTRUCT_0F
add hl, bc
ld a, [hl]
ld d, a
@@ -618,18 +681,19 @@
add $8
ld [hl], a
.asm_8d5d3
- ld hl, $e
+ ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
ld a, [hl]
inc [hl]
- call .ApplyXOffset
- ld hl, $6
+ call .ApplySineWaveX
+
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
.twentythree: ; 8d5e2 (23:55e2)
- ld hl, $4
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld a, [hl]
cp $b8
@@ -637,35 +701,40 @@
rept 2
inc [hl]
endr
- ld hl, $5
+
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
dec [hl]
ld d, $40
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
inc [hl]
- call .ApplyXOffset
- ld hl, $6
+ call .ApplySineWaveX
+
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
.asm_8d603
- call Function8d036
+ call DeinitializeSprite
ret
.twentyfour: ; 8d607 (23:5607)
- ld hl, $5
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld a, [hl]
cp $54
ret z
- ld hl, $5
+
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
rept 2
inc [hl]
endr
- ld hl, $f
+
+ ld hl, SPRITEANIMSTRUCT_0F
add hl, bc
ld a, [hl]
ld d, a
@@ -674,12 +743,13 @@
sub $2
ld [hl], a
.asm_8d621
- ld hl, $e
+ ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
ld a, [hl]
inc [hl]
- call .ApplyXOffset
- ld hl, $6
+ call .ApplySineWaveX
+
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
@@ -698,10 +768,11 @@
jr nz, .asm_8d645
ret
.asm_8d645
- ld hl, $7
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], $0
- ld hl, $d
+
+ ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
add $2
@@ -709,8 +780,9 @@
xor $ff
inc a
ld d, $20
- call .ApplyYOffset
- ld hl, $7
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
ld a, $36
@@ -718,7 +790,7 @@
ret
.thirty: ; 8d666 (23:5666)
- ld hl, $c
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
cp $14
@@ -728,8 +800,9 @@
xor $ff
inc a
ld d, $20
- call .ApplyYOffset
- ld hl, $7
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
.asm_8d67f
@@ -736,25 +809,28 @@
ret
.thirtytwo: ; 8d680 (23:5680)
- ld hl, $b
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld d, [hl]
rept 3
inc [hl]
endr
- ld hl, $c
+
+ ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld a, [hl]
push af
push de
- call .ApplyYOffset
- ld hl, $7
+ call .ApplySineWaveY
+
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], a
pop de
pop af
- call .ApplyXOffset
- ld hl, $6
+ call .ApplySineWaveX
+
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
@@ -768,7 +844,7 @@
ret
.thirtyfour: ; 8d6ae (23:56ae)
- ld hl, $5
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld a, [hl]
add $10
@@ -789,7 +865,8 @@
inc hl
ld d, [hl]
inc de
- ld hl, $b
+
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
ld l, [hl]
ld h, $0
@@ -801,18 +878,18 @@
ret
; 8d6d8 (23:56d8)
-.asm_8d6d8: ; 8d6d8
- ld hl, $b
+.IncrementSpriteAnimStruct0B: ; 8d6d8
+ ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
inc [hl]
ret
; 8d6de
-.ApplyYOffset: ; 8d6de (23:56de)
- call ApplyYOffset
+.ApplySineWaveY: ; 8d6de (23:56de)
+ call ApplySineWaveY
ret
-.ApplyXOffset: ; 8d6e2 (23:56e2)
- call ApplyXOffset
+.ApplySineWaveX: ; 8d6e2 (23:56e2)
+ call ApplySineWaveX
ret
; 8d6e6 (23:56e6)
--- a/engine/sprites.asm
+++ b/engine/sprites.asm
@@ -114,6 +114,7 @@
ret
InitSpriteAnimStruct:: ; 8cfd6
+; Initialize animation a at pixel x=e, y=d
; Find if there's any room in the wSpriteAnimationStructs array, which is 10x16
push de
push af
@@ -159,7 +160,7 @@
ld e, l
ld d, h
; Set hl to the first field (field 0) in the current structure.
- ld hl, 0
+ ld hl, SPRITEANIMSTRUCT_INDEX
add hl, bc
; Load the index.
ld a, [wc3b4]
@@ -174,11 +175,11 @@
; Look up the third field from the table in the wc300 array (10x2).
; Take the value and load it in
ld a, [de]
- call LookUpInwSpriteAnimDict
+ call GetSpriteAnimVTile
ld [hli], a
pop de
-; Set hl to field 4. Kinda pointless, because we're presumably already here.
- ld hl, $4
+; Set hl to field 4 (X coordinate). Kinda pointless, because we're presumably already here.
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
; Load the original value of de into here.
ld a, e
@@ -203,15 +204,15 @@
ld [hli], a
endr
ld [hl], a
-; back up the address of the first field to wc3b8
+; back up the address of the first field to wSpriteAnimAddrBackup
ld a, c
- ld [wc3b8], a
+ ld [wSpriteAnimAddrBackup], a
ld a, b
- ld [wc3b8 + 1], a
+ ld [wSpriteAnimAddrBackup + 1], a
ret
; 8d036
-Function8d036: ; 8d036
+DeinitializeSprite: ; 8d036
; Clear the index field of the struct in bc.
ld hl, SPRITEANIMSTRUCT_INDEX
add hl, bc
@@ -220,7 +221,7 @@
; 8d03d
-Function8d03d: ; 8d03d (23:503d)
+DeinitializeAllSprites: ; 8d03d (23:503d)
; Clear the index field of every struct in the wSpriteAnimationStructs array.
ld hl, wSpriteAnimationStructs
ld bc, $10
@@ -235,7 +236,7 @@
Function8d04c: ; 8d04c
- call Function8d0ec ; init WRAM
+ call InitSpriteAnimBuffer ; init WRAM
call Function8d132 ; read from a memory array
cp -3
jr z, .done
@@ -259,7 +260,7 @@
ld c, a ; number of objects
.loop
; first byte: y (px)
- ; [de] = [wCurrAnimYCoord] + [wCurrAnimYOffset] + [wGlobalAnimYOffset] + Function8d0be([hl])
+ ; [de] = [wCurrAnimYCoord] + [wCurrAnimYOffset] + [wGlobalAnimYOffset] + AddOrSubtractY([hl])
ld a, [wCurrAnimYCoord]
ld b, a
ld a, [wCurrAnimYOffset]
@@ -268,13 +269,13 @@
ld a, [wGlobalAnimYOffset]
add b
ld b, a
- call Function8d0be
+ call AddOrSubtractY
add b
ld [de], a
inc hl
inc de
; second byte: x (px)
- ; [de] = [wCurrAnimXCoord] + [wCurrAnimXOffset] + [wGlobalAnimXOffset] + Function8d0ce([hl])
+ ; [de] = [wCurrAnimXCoord] + [wCurrAnimXOffset] + [wGlobalAnimXOffset] + AddOrSubtractX([hl])
ld a, [wCurrAnimXCoord]
ld b, a
ld a, [wCurrAnimXOffset]
@@ -283,7 +284,7 @@
ld a, [wGlobalAnimXOffset]
add b
ld b, a
- call Function8d0ce
+ call AddOrSubtractX
add b
ld [de], a
inc hl
@@ -311,7 +312,7 @@
jr .done
.delete
- call Function8d036
+ call DeinitializeSprite
.done
and a
@@ -323,12 +324,13 @@
ret
; 8d0be
-Function8d0be: ; 8d0be
+AddOrSubtractY: ; 8d0be
push hl
ld a, [hl]
- ld hl, wc3b8
+ ld hl, wCurrSpriteAddSubFlags
bit 6, [hl]
jr z, .ok
+ ; 8 - a
add $8
xor $ff
inc a
@@ -338,12 +340,13 @@
ret
; 8d0ce
-Function8d0ce: ; 8d0ce
+AddOrSubtractX: ; 8d0ce
push hl
ld a, [hl]
- ld hl, wc3b8
+ ld hl, wCurrSpriteAddSubFlags
bit 5, [hl]
jr z, .ok
+ ; 8 - a
add $8
xor $ff
inc a
@@ -354,7 +357,7 @@
; 8d0de
Function8d0de: ; 8d0de
- ld a, [wc3b8]
+ ld a, [wCurrSpriteAddSubFlags]
ld b, a
ld a, [hl]
xor b
@@ -366,9 +369,9 @@
ret
; 8d0ec
-Function8d0ec: ; 8d0ec
+InitSpriteAnimBuffer: ; 8d0ec
xor a
- ld [wc3b8], a
+ ld [wCurrSpriteAddSubFlags], a
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld a, [hli]
@@ -384,8 +387,9 @@
ret
; 8d109
-LookUpInwSpriteAnimDict: ; 8d109
+GetSpriteAnimVTile: ; 8d109
; a = wSpriteAnimDict[a] if a in wSpriteAnimDict else 0
+; VTiles offset
push hl
push bc
ld hl, wSpriteAnimDict
@@ -452,7 +456,7 @@
ld a, [hl]
push hl
and $3f
- ld hl, SPRITEANIMSTRUCT_09
+ ld hl, SPRITEANIMSTRUCT_DURATIONOFFSET
add hl, bc
add [hl]
ld hl, SPRITEANIMSTRUCT_DURATION
@@ -463,7 +467,7 @@
ld a, [hl]
and $c0
srl a
- ld [wc3b8], a
+ ld [wCurrSpriteAddSubFlags], a
pop af
ret
@@ -552,6 +556,7 @@
; 8d1c4
Unknown_8d1c4: ; 8d1c4
+ ; ??, sequence, tile
db $01, SPRITE_ANIM_SEQ_01, $00 ; 00
db $07, SPRITE_ANIM_SEQ_04, $00 ; 01
db $08, SPRITE_ANIM_SEQ_05, $05 ; 02
@@ -562,7 +567,7 @@
db $0e, SPRITE_ANIM_SEQ_0A, $07 ; 07
db $10, SPRITE_ANIM_SEQ_0B, $07 ; 08
db $08, SPRITE_ANIM_SEQ_0C, $05 ; 09
- db $11, SPRITE_ANIM_SEQ_00, $00 ; 0a
+ db $11, SPRITE_ANIM_SEQ_00, $00 ; 0a flying sprite
db $12, SPRITE_ANIM_SEQ_0D, $08 ; 0b
db $12, SPRITE_ANIM_SEQ_0E, $08 ; 0c
db $12, SPRITE_ANIM_SEQ_0F, $08 ; 0d
@@ -572,11 +577,11 @@
db $17, SPRITE_ANIM_SEQ_12, $00 ; 11
db $18, SPRITE_ANIM_SEQ_12, $00 ; 12
db $19, SPRITE_ANIM_SEQ_13, $00 ; 13
- db $1a, SPRITE_ANIM_SEQ_14, $00 ; 14
+ db $1a, SPRITE_ANIM_SEQ_14, $00 ; 14 radio tuning knob
db $1b, SPRITE_ANIM_SEQ_00, $00 ; 15
db $1d, SPRITE_ANIM_SEQ_15, $00 ; 16
db $1e, SPRITE_ANIM_SEQ_00, $00 ; 17
- db $1d, SPRITE_ANIM_SEQ_17, $00 ; 18
+ db $1d, SPRITE_ANIM_SEQ_17, $00 ; 18 flying leaves
db $1f, SPRITE_ANIM_SEQ_00, $00 ; 19
db $24, SPRITE_ANIM_SEQ_19, $00 ; 1a
db $25, SPRITE_ANIM_SEQ_00, $00 ; 1b
@@ -605,19 +610,19 @@
; Unknown_8d6e6
; Unknown_8d94d
-ApplyXOffset: ; 8e72a
+ApplySineWaveX: ; 8e72a
add $10
-ApplyYOffset: ; 8e72c
+ApplySineWaveY: ; 8e72c
and $3f
cp $20
- jr nc, .xflip
- call Function8e741
+ jr nc, .flip
+ call .ApplyOffset
ld a, h
ret
-.xflip
+.flip
and $1f
- call Function8e741
+ call .ApplyOffset
ld a, h
xor $ff ; cpl
inc a
@@ -624,7 +629,7 @@
ret
; 8e741
-Function8e741: ; 8e741
+.ApplyOffset: ; 8e741
ld e, a
ld a, d
ld d, 0
@@ -696,7 +701,7 @@
push de
push hl
- call ApplyYOffset
+ call ApplySineWaveY
pop hl
pop de
add 13 * 8
@@ -705,7 +710,7 @@
pop af
push de
push hl
- call ApplyXOffset
+ call ApplySineWaveX
pop hl
pop de
add 10 * 8 + 4
@@ -743,451 +748,3 @@
pop hl
ret
; 8e82b
-
-Function8e82b: ; 8e82b
- ld a, e
- call ReadMonMenuIcon
- ld l, a
- ld h, 0
- add hl, hl
- ld de, IconPointers
- add hl, de
- ld a, [hli]
- ld e, a
- ld d, [hl]
- ld b, BANK(Icons)
- ld c, 8
- ret
-; 8e83f
-
-Function8e83f: ; 8e83f
- push hl
- push de
- push bc
- call Function8e849
- pop bc
- pop de
- pop hl
- ret
-; 8e849
-
-Function8e849: ; 8e849
- ld d, 0
- ld hl, Jumptable_8e854
-rept 2
- add hl, de
-endr
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; 8e854
-
-
-Jumptable_8e854: ; 8e854 (23:6854)
- dw Function8e8d5
- dw Function8e961
- dw Function8e97d
- dw Function8e99a
- dw Function8e898
- dw Function8e8b1
- dw Function8e862
-
-
-Function8e862: ; 8e862 (23:6862)
- call Function8e908
- call Function8e86c
- call Function8e936
- ret
-
-Function8e86c: ; 8e86c (23:686c)
- push bc
- ld a, [hObjectStructIndexBuffer]
- ld hl, PartyMon1Item
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- pop bc
- ld a, [hl]
- and a
- jr z, .asm_8e890
- push hl
- push bc
- ld d, a
- callab ItemIsMail
- pop bc
- pop hl
- jr c, .asm_8e88e
- ld a, $6
- jr .asm_8e892
-.asm_8e88e
- ld a, $5
-.asm_8e890
- ld a, $4
-.asm_8e892
- ld hl, $1
- add hl, bc
- ld [hl], a
- ret
-
-Function8e898: ; 8e898 (23:6898)
- call Function8e8d5
- ld hl, $2
- add hl, bc
- ld a, $0
- ld [hl], a
- ld hl, $4
- add hl, bc
- ld a, $48
- ld [hl], a
- ld hl, $5
- add hl, bc
- ld a, $48
- ld [hl], a
- ret
-
-Function8e8b1: ; 8e8b1 (23:68b1)
- call Function8e908
- call Function8e936
- ld hl, $2
- add hl, bc
- ld a, $0
- ld [hl], a
- ld hl, $4
- add hl, bc
- ld a, $18
- ld [hl], a
- ld hl, $5
- add hl, bc
- ld a, $60
- ld [hl], a
- ld a, c
- ld [wc608], a
- ld a, b
- ld [wc608 + 1], a
- ret
-
-Function8e8d5: ; 8e8d5 (23:68d5)
- call Function8e908
- call Function8e8df
- call Function8e936
- ret
-
-Function8e8df: ; 8e8df (23:68df)
- push bc
- ld a, [hObjectStructIndexBuffer]
- ld hl, PartyMon1Item
- ld bc, $30
- call AddNTimes
- pop bc
- ld a, [hl]
- and a
- ret z
- push hl
- push bc
- ld d, a
- callab ItemIsMail
- pop bc
- pop hl
- jr c, .asm_8e900
- ld a, $3
- jr .asm_8e902
-.asm_8e900
- ld a, $2
-.asm_8e902
- ld hl, $1
- add hl, bc
- ld [hl], a
- ret
-
-Function8e908: ; 8e908 (23:6908)
- ld a, [wc3b7]
- push af
- ld a, [hObjectStructIndexBuffer]
- ld hl, PartySpecies
- ld e, a
- ld d, $0
- add hl, de
- ld a, [hl]
- call ReadMonMenuIcon
- ld [CurIcon], a
- call Function8e9db
- ld a, [hObjectStructIndexBuffer]
-; y coord
-rept 4
- add a
-endr
- add $1c
- ld d, a
-; x coord
- ld e, $10
-; type is partymon icon
- ld a, SPRITE_ANIM_INDEX_00
- call InitSpriteAnimStruct
- pop af
- ld hl, $3
- add hl, bc
- ld [hl], a
- ret
-
-Function8e936: ; 8e936 (23:6936)
- push bc
- ld a, [hObjectStructIndexBuffer]
- ld b, a
- call Function8e94c
- ld a, b
- pop bc
- ld hl, $9
- add hl, bc
- ld [hl], a
- rlca
- rlca
- ld hl, $d
- add hl, bc
- ld [hl], a
- ret
-
-Function8e94c: ; 8e94c (23:694c)
- callba PlacePartymonHPBar
- call GetHPPal
- ld e, d
- ld d, 0
- ld hl, Unknown_8e95e
- add hl, de
- ld b, [hl]
- ret
-; 8e95e (23:695e)
-
-Unknown_8e95e: ; 8e95e
- db $00, $40, $80
-; 8e961
-
-Function8e961: ; 8e961 (23:6961)
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- xor a
- call GetIconGFX
- lb de, $24, $20
- ld a, SPRITE_ANIM_INDEX_00
- call InitSpriteAnimStruct
- ld hl, $2
- add hl, bc
- ld [hl], $0
- ret
-
-Function8e97d: ; 8e97d (23:697d)
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- xor a
- call GetIconGFX
- ld d, $1a
- ld e, $24
- ld a, SPRITE_ANIM_INDEX_00
- call InitSpriteAnimStruct
- ld hl, $2
- add hl, bc
- ld [hl], $0
- ret
-
-Function8e99a: ; 8e99a (23:699a)
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- ld a, $62
- ld [wc3b7], a
- call Function8e9db
- ret
-
-GetSpeciesIcon: ; 8e9ac
-; Load species icon into VRAM at tile a
- push de
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- pop de
- ld a, e
- call GetIconGFX
- ret
-; 8e9bc
-
-
-Function8e9bc: ; 8e9bc (23:69bc)
- push de
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- pop de
- ld a, e
- call GetIcon_a
- ret
-; 8e9cc (23:69cc)
-
-Function8e9cc: ; 8e9cc
- push de
- ld a, [wd265]
- call ReadMonMenuIcon
- ld [CurIcon], a
- pop de
- call GetIcon_de
- ret
-; 8e9db
-
-Function8e9db: ; 8e9db (23:69db)
- ld a, [wc3b7]
-
-GetIconGFX: ; 8e9de
- call GetIcon_a
- ld de, $80 ; 8 tiles
- add hl, de
- ld de, HeldItemIcons
- lb bc, BANK(HeldItemIcons), 2
- call GetGFXUnlessMobile
- ld a, [wc3b7]
- add 10
- ld [wc3b7], a
- ret
-
-HeldItemIcons:
-INCBIN "gfx/icon/mail.2bpp"
-INCBIN "gfx/icon/item.2bpp"
-; 8ea17
-
-GetIcon_de: ; 8ea17
-; Load icon graphics into VRAM starting from tile de.
- ld l, e
- ld h, d
- jr GetIcon
-
-GetIcon_a: ; 8ea1b
-; Load icon graphics into VRAM starting from tile a.
- ld l, a
- ld h, 0
-
-GetIcon: ; 8ea1e
-; Load icon graphics into VRAM starting from tile hl.
-
-; One tile is 16 bytes long.
-rept 4
- add hl, hl
-endr
-
- ld de, VTiles0
- add hl, de
- push hl
-
-; The icons are contiguous, in order and of the same
-; size, so the pointer table is somewhat redundant.
- ld a, [CurIcon]
- push hl
- ld l, a
- ld h, 0
- add hl, hl
- ld de, IconPointers
- add hl, de
- ld a, [hli]
- ld e, a
- ld d, [hl]
- pop hl
-
- lb bc, BANK(Icons), 8
- call GetGFXUnlessMobile
-
- pop hl
- ret
-; 8ea3f
-
-GetGFXUnlessMobile: ; 8ea3f
- ld a, [wLinkMode]
- cp LINK_MOBILE
- jp nz, Request2bpp
- jp Get2bpp_2
-; 8ea4a
-
-Function8ea4a: ; 8ea4a
- ld hl, wSpriteAnimationStructs
- ld e, $6
- ld a, [MenuSelection2]
- ld d, a
-.loop
- ld a, [hl]
- and a
- jr z, .next
- cp d
- jr z, .loadwithtwo
- ld a, $0
- jr .ok
-
-.loadwithtwo
- ld a, $2
-
-.ok
- push hl
- ld c, l
- ld b, h
- ld hl, $2
- add hl, bc
- ld [hl], a
- pop hl
-
-.next
- ld bc, $10
- add hl, bc
- dec e
- jr nz, .loop
- ret
-; 8ea71
-
-Function8ea71: ; 8ea71
- ld hl, wSpriteAnimationStructs
- ld e, $6
-.loop
- ld a, [hl]
- and a
- jr z, .zero
- push hl
- ld c, l
- ld b, h
- ld hl, $2
- add hl, bc
- ld [hl], $1
- pop hl
-.zero
- ld bc, $10
- add hl, bc
- dec e
- jr nz, .loop
- ret
-; 8ea8c (23:6a8c)
-
-Function8ea8c: ; 8ea8c
- ld hl, wSpriteAnimationStructs
- ld e, $6
- ld a, [wd0e3]
- ld d, a
-.asm_8ea95
- ld a, [hl]
- and a
- jr z, .asm_8eaab
- cp d
- jr z, .asm_8eaa0
- ld a, $3
- jr .asm_8eaa2
-.asm_8eaa0
- ld a, $2
-.asm_8eaa2
- push hl
- ld c, l
- ld b, h
- ld hl, $2
- add hl, bc
- ld [hl], a
- pop hl
-.asm_8eaab
- ld bc, $10
- add hl, bc
- dec e
- jr nz, .asm_8ea95
- ret
-
-INCLUDE "menu/mon_icons.asm"
--- a/engine/startmenu.asm
+++ b/engine/startmenu.asm
@@ -685,7 +685,7 @@
CancelPokemonAction: ; 12a79
callba InitPartyMenuWithCancel
- callba Function8ea71
+ callba UnfreezeMonIcons
ld a, 1
ret
; 12a88
@@ -748,7 +748,7 @@
inc a
ld [wSwitchMon], a
- callba Function8ea8c
+ callba HoldSwitchmonIcon
callba InitPartyMenuNoCancel
ld a, 4
@@ -1457,13 +1457,13 @@
ret
; 12f5b
-Function12f5b: ; 12f5b
+ChooseMoveToDelete: ; 12f5b
ld hl, Options
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
call LoadFontsBattleExtra
- call Function12f73
+ call .asm_12f73
pop bc
ld a, b
ld [Options], a
@@ -1473,36 +1473,36 @@
ret
; 12f73
-Function12f73: ; 12f73
+.asm_12f73: ; 12f73
call SetUpMoveScreenBG
ld de, Unknown_12fb2
call InitMenu3
- call Function131ef
+ call SetUpMoveList
ld hl, wcfa5
set 6, [hl]
- jr Function12f93
+ jr .asm_12f93
-Function12f86: ; 12f86
+.asm_12f86: ; 12f86
call Function1bd3
bit 1, a
- jp nz, Function12f9f
+ jp nz, .asm_12f9f
bit 0, a
- jp nz, Function12f9c
+ jp nz, .asm_12f9c
-Function12f93: ; 12f93
+.asm_12f93: ; 12f93
call PrepareToPlaceMoveData
call PlaceMoveData
- jp Function12f86
+ jp .asm_12f86
; 12f9c
-Function12f9c: ; 12f9c
+.asm_12f9c: ; 12f9c
and a
- jr Function12fa0
+ jr .asm_12fa0
-Function12f9f: ; 12f9f
+.asm_12f9f: ; 12f9f
scf
-Function12fa0: ; 12fa0
+.asm_12fa0: ; 12fa0
push af
xor a
ld [wSwitchMon], a
@@ -1545,7 +1545,7 @@
ld de, Unknown_13163
call InitMenu3
.loop
- call Function131ef
+ call SetUpMoveList
ld hl, wcfa5
set 6, [hl]
jr .skip_joy
@@ -1802,7 +1802,7 @@
jp ClearBox
; 131ef
-Function131ef: ; 131ef
+SetUpMoveList: ; 131ef
xor a
ld [hBGMapMode], a
ld [wMoveSwapBuffer], a
@@ -1817,10 +1817,10 @@
hlcoord 2, 3
predef ListMoves
hlcoord 10, 4
- predef Function50c50
+ predef ListMovePP
call WaitBGMap
call SetPalettes
- ld a, [wd0eb]
+ ld a, [wNumMoves]
inc a
ld [wcfa3], a
hlcoord 0, 11
--- a/engine/stats_screen.asm
+++ b/engine/stats_screen.asm
@@ -697,7 +697,7 @@
hlcoord 12, 11
ld a, $28
ld [Buffer1], a
- predef Function50c50
+ predef ListMovePP
ret
Function4e189: ; 4e189 (13:6189)
--- a/event/field_moves.asm
+++ b/event/field_moves.asm
@@ -325,7 +325,7 @@
push af
xor a
ld [VramState], a
- call Function8cb9b
+ call FlyFunction_InitGFX
depixel 10, 10, 4, 0
ld a, SPRITE_ANIM_INDEX_0A
call _InitSpriteAnimStruct
@@ -334,7 +334,7 @@
ld [hl], $84
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
- ld [hl], $16
+ ld [hl], SPRITE_ANIM_SEQ_16
ld a, $80
ld [wcf64], a
.loop
@@ -360,7 +360,7 @@
push af
xor a
ld [VramState], a
- call Function8cb9b
+ call FlyFunction_InitGFX
depixel 31, 10, 4, 0
ld a, SPRITE_ANIM_INDEX_0A
call _InitSpriteAnimStruct
@@ -410,7 +410,7 @@
call ByteFill
ret
-Function8cb9b: ; 8cb9b (23:4b9b)
+FlyFunction_InitGFX: ; 8cb9b (23:4b9b)
callab ClearSpriteAnims
ld de, CutGrassGFX
ld hl, VTiles1 tile $00
@@ -424,7 +424,7 @@
ld a, [hl]
ld [wd265], a
ld e, $84
- callba Function8e9bc
+ callba FlyFunction_GetMonIcon
xor a
ld [wJumptableIndex], a
ret
--- a/event/move_deleter.asm
+++ b/event/move_deleter.asm
@@ -20,7 +20,7 @@
ld hl, UnknownText_0x2c5ea
call PrintText
call LoadStandardMenuDataHeader
- callba Function12f5b
+ callba ChooseMoveToDelete
push af
call Function2b74
pop af
--- a/home.asm
+++ b/home.asm
@@ -2019,13 +2019,13 @@
_InitSpriteAnimStruct:: ; 3b2a
- ld [wc3b8], a
+ ld [wSpriteAnimIDBuffer], a
ld a, [hROMBank]
push af
ld a, BANK(InitSpriteAnimStruct)
rst Bankswitch
- ld a, [wc3b8]
+ ld a, [wSpriteAnimIDBuffer]
call InitSpriteAnimStruct
@@ -2038,13 +2038,13 @@
Function3b3c:: ; 3b3c
- ld [wc3b8], a
+ ld [wSpriteAnimIDBuffer], a
ld a, [hROMBank]
push af
ld a, BANK(Function8d120)
rst Bankswitch
- ld a, [wc3b8]
+ ld a, [wSpriteAnimIDBuffer]
call Function8d120
--- a/main.asm
+++ b/main.asm
@@ -10731,7 +10731,7 @@
xor a
ld [hBGMapMode], a
call GetMonSubmenuItems
- callba Function8ea4a
+ callba FreezeMonIcons
ld hl, .MenuDataHeader
call LoadMenuDataHeader
call .GetTopCoord
@@ -15428,13 +15428,13 @@
ld hl, PartyMon1Species
ld bc, PartyMonOT
.asm_4a851
- call Function4a8dc
+ call .CheckMatch
ret c
push bc
ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
pop bc
- call Function4a91e
+ call .CopyName
dec d
jr nz, .asm_4a851
ld a, BANK(sBoxCount)
@@ -15446,7 +15446,7 @@
ld hl, sBoxMon1Species
ld bc, sBoxMonOT
.asm_4a873
- call Function4a8dc
+ call .CheckMatch
jr nc, .asm_4a87c
call CloseSRAM
ret
@@ -15456,7 +15456,7 @@
ld bc, BOXMON_STRUCT_LENGTH
add hl, bc
pop bc
- call Function4a91e
+ call .CopyName
dec d
jr nz, .asm_4a873
@@ -15468,7 +15468,7 @@
and $f
cp c
jr z, .asm_4a8d1
- ld hl, BoxAddressTable2
+ ld hl, .BoxAddrs
ld b, 0
rept 3
add hl, bc
@@ -15496,7 +15496,7 @@
pop hl
ld d, a
.asm_4a8ba
- call Function4a8dc
+ call .CheckMatch
jr nc, .asm_4a8c4
pop bc
call CloseSRAM
@@ -15507,7 +15507,7 @@
ld bc, BOXMON_STRUCT_LENGTH
add hl, bc
pop bc
- call Function4a91e
+ call .CopyName
dec d
jr nz, .asm_4a8ba
pop bc
@@ -15522,7 +15522,7 @@
ret
; 4a8dc
-Function4a8dc: ; 4a8dc
+.CheckMatch: ; 4a8dc
push bc
push hl
push de
@@ -15549,7 +15549,7 @@
ret
; 4a8f4
-BoxAddressTable2: ; 4a8f4
+.BoxAddrs: ; 4a8f4
dba sBox1
dba sBox2
dba sBox3
@@ -15566,7 +15566,7 @@
dba sBox14
; 4a91e
-Function4a91e: ; 4a91e
+.CopyName: ; 4a91e
push hl
ld hl, NAME_LENGTH
add hl, bc
@@ -15600,6 +15600,7 @@
ret
; 4a94e
+; mobile battle selection
Function4a94e: ; 4a94e
call FadeToMenu
ld a, -1
@@ -16102,7 +16103,7 @@
lb bc, 2, 18
hlcoord 1, 15
call ClearBox
- callba Function8ea4a
+ callba FreezeMonIcons
ld hl, MenuDataHeader_0x4aca2
call LoadMenuDataHeader
ld hl, wd019
@@ -16422,7 +16423,7 @@
SwapTextboxPalettes:: ; 4c000
hlcoord 0, 0
decoord 0, 0, AttrMap
- ld b, $12
+ ld b, SCREEN_HEIGHT
.loop
push bc
ld c, SCREEN_WIDTH
@@ -18868,11 +18869,11 @@
ret
; 50c50
-Function50c50: ; 50c50
- ld a, [wd0eb]
+ListMovePP: ; 50c50
+ ld a, [wNumMoves]
inc a
ld c, a
- ld a, $4
+ ld a, NUM_MOVES
sub c
ld b, a
push hl
@@ -18879,16 +18880,16 @@
ld a, [Buffer1]
ld e, a
ld d, $0
- ld a, $3e
- call Function50cc9
+ ld a, $3e ; P
+ call .load_loop
ld a, b
and a
- jr z, .asm_50c6f
+ jr z, .skip
ld c, a
- ld a, $e3
- call Function50cc9
+ ld a, "-"
+ call .load_loop
-.asm_50c6f
+.skip
pop hl
rept 3
inc hl
@@ -18897,10 +18898,10 @@
ld e, l
ld hl, TempMonMoves
ld b, 0
-.asm_50c7a
+.loop
ld a, [hli]
and a
- jr z, .asm_50cc8
+ jr z, .done
push bc
push hl
push de
@@ -18927,7 +18928,7 @@
ld de, StringBuffer1 + 4
lb bc, 1, 2
call PrintNum
- ld a, $f3
+ ld a, "/"
ld [hli], a
ld de, wd265
lb bc, 1, 2
@@ -18944,19 +18945,18 @@
inc b
ld a, b
cp NUM_MOVES
- jr nz, .asm_50c7a
+ jr nz, .loop
-.asm_50cc8
+.done
ret
; 50cc9
-Function50cc9: ; 50cc9
-.asm_50cc9
+.load_loop: ; 50cc9
ld [hli], a
ld [hld], a
add hl, de
dec c
- jr nz, .asm_50cc9
+ jr nz, .load_loop
ret
; 50cd0
@@ -19097,7 +19097,7 @@
call PlaceString
pop bc
ld a, b
- ld [wd0eb], a
+ ld [wNumMoves], a
inc b
pop hl
push bc
@@ -21435,9 +21435,9 @@
ret
; 8cf53
-
INCLUDE "engine/sprites.asm"
+INCLUDE "engine/mon_icons.asm"
SECTION "bank24", ROMX, BANK[$24]
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -1901,7 +1901,7 @@
ld a, [MenuSelection2]
and a
jp nz, .asm_100bcb
- ld a, [wd0eb]
+ ld a, [wNumMoves]
inc a
ld [MenuSelection2], a
jp .asm_100bcb
@@ -1909,7 +1909,7 @@
.asm_100c10
ld a, [MenuSelection2]
ld b, a
- ld a, [wd0eb]
+ ld a, [wNumMoves]
rept 2
inc a
endr
@@ -1989,7 +1989,7 @@
Function100c98: ; 100c98
ld de, Unknown_100cad
call InitMenu3
- ld a, [wd0eb]
+ ld a, [wNumMoves]
inc a
ld [wcfa3], a
ld a, [CurMoveNum]
@@ -2553,10 +2553,10 @@
Function101050: ; 101050
call Function10107d
ld a, [OTPartyCount]
-rept 2
+rept 2 ; ???
ld hl, wc608
endr
- ld bc, $01b3
+ ld bc, wc7bb - wc608
call Function1010de
ld hl, wc7bb
ld [hl], e
@@ -2566,7 +2566,7 @@
call GetSRAMBank
ld hl, wc608
ld de, $a001
- ld bc, $01b5
+ ld bc, wc7bd - wc608
call CopyBytes
call CloseSRAM
ret
@@ -2575,11 +2575,11 @@
Function10107d: ; 10107d
xor a
ld hl, wc608
- ld bc, $01b5
+ ld bc, wc7bd - wc608
call ByteFill
ld hl, wd26b
ld de, wc608
- ld bc, $000b
+ ld bc, NAME_LENGTH
call CopyBytes
ld hl, wd271
ld a, [hli]
@@ -2588,16 +2588,16 @@
ld [wc608 + 12], a
ld hl, OTPartyMonNicknames
ld de, wc608 + 13
- ld bc, $000b
- call Function1010cd
+ ld bc, NAME_LENGTH
+ call .CopyAllFromOT
ld hl, OTPartyMonOT
ld de, wc656 + 1
- ld bc, $000b
- call Function1010cd
+ ld bc, NAME_LENGTH
+ call .CopyAllFromOT
ld hl, OTPartyMon1Species
ld de, wc68a + 15
- ld bc, $0030
- call Function1010cd
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call .CopyAllFromOT
ld a, $50
ld [wc7b9], a
ld a, $33
@@ -2605,7 +2605,7 @@
ret
; 1010cd
-Function1010cd: ; 1010cd
+.CopyAllFromOT: ; 1010cd
push hl
ld hl, 0
ld a, [OTPartyCount]
@@ -2621,7 +2621,7 @@
push hl
push bc
ld de, 0
-.asm_1010e3
+.loop
ld a, [hli]
add e
ld e, a
@@ -2631,7 +2631,7 @@
dec bc
ld a, b
or c
- jr nz, .asm_1010e3
+ jr nz, .loop
pop bc
pop hl
ret
--- a/misc/mobile_42.asm
+++ b/misc/mobile_42.asm
@@ -519,7 +519,7 @@
ld de, VTiles2
call Function108201
call EnableLCD
- callba Function8d03d
+ callba DeinitializeAllSprites
xor a
ld [hSCX], a
ld [hSCY], a
@@ -654,7 +654,7 @@
ld de, VTiles2
call Function108201
call EnableLCD
- callba Function8d03d
+ callba DeinitializeAllSprites
call DelayFrame
ld de, TradeBallGFX
ld hl, VTiles0
@@ -723,7 +723,7 @@
ld de, VTiles2
call Function108201
call EnableLCD
- callba Function8d03d
+ callba DeinitializeAllSprites
call DelayFrame
ld de, TradeBallGFX
ld hl, VTiles0
@@ -780,7 +780,7 @@
; 108638
Function108638: ; 108638
- callba Function8d03d
+ callba DeinitializeAllSprites
call ClearBGPalettes
call ClearSprites
call ClearTileMap
@@ -816,7 +816,7 @@
; 108689
Function108689: ; 108689
- callba Function8d03d
+ callba DeinitializeAllSprites
call ClearBGPalettes
call ClearSprites
call ClearTileMap
@@ -1067,7 +1067,7 @@
jr .asm_108868
.asm_108879
- callba Function8d03d
+ callba DeinitializeAllSprites
depixel 9, 10, 2, 0
ld a, SPRITE_ANIM_INDEX_25
call _InitSpriteAnimStruct
@@ -1161,7 +1161,7 @@
Function108919: ; 108919
ld c, $28
call Function1082cc
- callba Function8d03d
+ callba DeinitializeAllSprites
call ClearBGPalettes
call ClearSprites
call ClearTileMap
@@ -1546,7 +1546,7 @@
; 108bbd
Function108bbd: ; 108bbd
- callba Function8d03d
+ callba DeinitializeAllSprites
call ClearSprites
ret
; 108bc7
@@ -1564,7 +1564,7 @@
ld [hl], a
ret
.asm_108bd9
- callba Function8d036
+ callba DeinitializeSprite
ret
Function108be0: ; 108be0 (42:4be0)
--- a/misc/mobile_46.asm
+++ b/misc/mobile_46.asm
@@ -5965,7 +5965,7 @@
dec a
ld [hObjectStructIndexBuffer], a
ld a, $10
- ld [wc3b7], a
+ ld [wCurIconTile], a
ld hl, Function8e83f
ld a, BANK(Function8e83f)
ld e, $4
@@ -6884,7 +6884,7 @@
ld hl, $0003
add hl, bc
ld e, [hl]
- callba Function8e9bc
+ callba FlyFunction_GetMonIcon
hlcoord 4, 14
push hl
call GetPokemonName
--- a/wram.asm
+++ b/wram.asm
@@ -392,8 +392,10 @@
ds 1
-SECTION "c300", WRAM0 [$c300]
+SECTION "wSpriteAnims", WRAM0 [$c300]
; wc300 - wc313 is a 10x2 dictionary.
+; keys: taken from third column of Unknown_8d1c4
+; values: VTiles
wSpriteAnimDict:: ds 10 * 2
ds wSpriteAnimDict - @
wc300:: ds 1
@@ -469,8 +471,11 @@
ds 1
-wc3b7:: ds 1
-wc3b8:: ds 2
+wCurIconTile:: ds 1
+wSpriteAnimAddrBackup::
+wSpriteAnimIDBuffer::
+wCurrSpriteAddSubFlags::
+ ds 2
wCurrAnimVTile:: ds 1
wCurrAnimXCoord:: ds 1
wCurrAnimYCoord:: ds 1
@@ -1000,10 +1005,10 @@
wc74e:: ds 107
wc7b9:: ds 1
wc7ba:: ds 1
-wc7bb:: ds 15
-wc7ca:: ds 6
+wc7bb:: ds 2
+wc7bd::
+ ds wc6d0 - @
- ds -$100
wPokedexDataStart::
wPokedexOrder:: ds NUM_POKEMON +- 1
wPokedexOrderEnd:: ds 6
@@ -1767,6 +1772,7 @@
wMenuScrollPosition:: ds 4
wQueuedScriptBank:: ds 1
wQueuedScriptAddr:: ds 2
+wNumMoves::
wd0eb:: ds 1
wFieldMoveSucceeded::
wPlayerAction::