ref: 6eac26732a7d19e08374e7e8e6f122da38b4a395
parent: e83a5bae87d565eae14716470397df211a1fee94
author: PikalaxALT <[email protected]>
date: Sat Dec 5 10:38:25 EST 2015
Celebi Event
--- a/constants/sprite_constants.asm
+++ b/constants/sprite_constants.asm
@@ -350,7 +350,7 @@
const_def
const SPRITEANIMSTRUCT_INDEX
- const SPRITEANIMSTRUCT_01
+ const SPRITEANIMSTRUCT_FRAMESET_ID
const SPRITEANIMSTRUCT_ANIM_SEQ_ID
const SPRITEANIMSTRUCT_TILE_ID
const SPRITEANIMSTRUCT_XCOORD
--- a/data/sprite_engine.asm
+++ b/data/sprite_engine.asm
@@ -1,4 +1,4 @@
-Unknown_8d6e6: ; 8d6e6
+SpriteAnimFrameData: ; 8d6e6
dw Unknown_8d76a ; 00
dw Unknown_8d76d ; 01
dw Unknown_8d772 ; 02
@@ -63,54 +63,54 @@
dw Unknown_8d932 ; 3d
dw Unknown_8d93d ; 3e
dw Unknown_8d940 ; 3f
- dw Unknown_8d943 ; 40
- dw Unknown_8d948 ; 41
+ dw Unknown_8d943 ; 40 celebi on the left
+ dw Unknown_8d948 ; 41 celebi on the right
; 8d76a
-
-Unknown_8d76a: db $00, $20 ; lowest 6 bits of second byte are duration, upper two bits are flags
- db -1
+ ; OAM idx (see SpriteAnimOAMData), flip flags/duration
+Unknown_8d76a: db $00, $20
+ db -1
Unknown_8d76d: db $00, $08
db $01, $08
- db -2
+ db -2
Unknown_8d772: db $3d, $08
db $3e, $08
- db -2
+ db -2
Unknown_8d777: db $3f, $08
db $40, $08
- db -2
+ db -2
Unknown_8d77c: db $00, $04
db $01, $04
- db -2
+ db -2
Unknown_8d781: db $3d, $04
db $3e, $04
- db -2
+ db -2
Unknown_8d786: db $3f, $04
db $40, $04
- db -2
+ db -2
Unknown_8d78b: db $00, $08
db $01, $08
db $00, $08
db $01, $48
- db -2
+ db -2
Unknown_8d794: db $63, $08
db $64, $08
db $63, $08
db $64, $48
- db -2
+ db -2
Unknown_8d79d: db $65, $08
db $66, $08
db $65, $08
db $66, $48
- db -2
+ db -2
Unknown_8d7a6: db $1e, $01
db $1f, $01
- db -2
+ db -2
Unknown_8d7ab: db $20, $01
- db $fd, $01
- db -2
+ db -3, $01
+ db -2
Unknown_8d7b0: db $21, $01
- db $fd, $01
- db -2
+ db -3, $01
+ db -2
Unknown_8d7b5: db $81, $0c
db $82, $01
db $83, $01
@@ -126,111 +126,111 @@
db $89, $04
db $8a, $0a
db $8b, $07
- db -1
+ db -1
Unknown_8d7d4: db $23, $03
db $23, $83
- db -2
+ db -2
Unknown_8d7d9: db $24, $02
db $25, $02
db $26, $02
db $25, $02
- db -2
+ db -2
Unknown_8d7e2: db $27, $07
db $28, $07
db $27, $87
db $28, $47
- db -2
+ db -2
Unknown_8d7eb: db $29, $07
db $2a, $07
db $29, $07
db $2b, $07
- db -2
+ db -2
Unknown_8d7f4: db $29, $07
db $2c, $07
db $2d, $07
db $2c, $07
db $29, $07
- db -1
+ db -1
Unknown_8d7ff: db $2e, $14
- db -1
+ db -1
Unknown_8d802: db $2f, $20
- db -1
+ db -1
Unknown_8d805: db $30, $20
- db -1
+ db -1
Unknown_8d808: db $30, $03
db $31, $03
db $30, $03
db $31, $43
- db -2
+ db -2
Unknown_8d811: db $32, $04
db $33, $04
db $34, $04
- db -4
+ db -4
Unknown_8d818: db $35, $03
db $36, $03
- db -2
+ db -2
Unknown_8d81d: db $37, $07
db $38, $07
- db -2
+ db -2
Unknown_8d822: db $39, $20
- db -1
+ db -1
Unknown_8d825: db $3b, $02
db $3a, $02
db $3b, $02
- db -1
+ db -1
Unknown_8d82c: db $3c, $20
- db -1
+ db -1
Unknown_8d82f: db $41, $08
db $42, $08
db $41, $08
db $42, $48
- db -2
+ db -2
db $43, $08
db $44, $08
- db -2
+ db -2
db $45, $08
db $46, $08
- db -2
+ db -2
db $47, $08
db $48, $08
- db -2
+ db -2
db $49, $01
db $49, $41
db $49, $c1
db $49, $81
- db -2
+ db -2
db $4a, $20
- db -1
+ db -1
db $4b, $20
- db -1
+ db -1
db $4c, $20
- db -1
+ db -1
db $4d, $20
- db -1
+ db -1
db $4e, $03
- db $fd, $03
- db -2
-Unknown_8d861: db $fd, $20
- db -1
+ db -3, $03
+ db -2
+Unknown_8d861: db -3, $20
+ db -1
Unknown_8d864: db $4f, $20
- db -1
+ db -1
Unknown_8d867: db $50, $02
db $51, $10
- db $fd, $01
+ db -3, $01
db $52, $01
- db $fd, $01
+ db -3, $01
db $53, $01
- db -4
+ db -4
Unknown_8d874: db $54, $20
- db -1
+ db -1
Unknown_8d877: db $55, $20
- db -1
+ db -1
Unknown_8d87a: db $55, $60
- db -1
+ db -1
Unknown_8d87d: db $55, $a0
- db -1
+ db -1
Unknown_8d880: db $55, $e0
- db -1
+ db -1
Unknown_8d883: db $56, $0a
db $57, $09
db $58, $0a
@@ -237,26 +237,26 @@
db $59, $0a
db $58, $09
db $5a, $0a
- db -2
+ db -2
Unknown_8d890: db $50, $02
db $5b, $02
db $50, $02
db $5b, $42
- db -2
+ db -2
Unknown_8d899: db $5c, $02
- db -1
+ db -1
Unknown_8d89c: db $5d, $02
- db -1
+ db -1
Unknown_8d89f: db $5e, $02
- db -1
+ db -1
Unknown_8d8a2: db $5f, $02
- db -1
+ db -1
Unknown_8d8a5: db $60, $02
- db -1
+ db -1
Unknown_8d8a8: db $61, $02
- db -1
+ db -1
Unknown_8d8ab: db $62, $02
- db -1
+ db -1
Unknown_8d8ae: db $32, $03
db $33, $03
db $34, $03
@@ -272,7 +272,7 @@
db $31, $03
db $30, $03
db $31, $43
- db -1
+ db -1
Unknown_8d8cd: db $30, $03
db $31, $03
db $30, $03
@@ -288,67 +288,67 @@
db $32, $03
db $33, $03
db $34, $03
- db -4
+ db -4
Unknown_8d8ec: db $67, $03
db $68, $03
- db -2
+ db -2
Unknown_8d8f1: db $6c, $03
- db -1
+ db -1
Unknown_8d8f4: db $6d, $03
- db -1
+ db -1
Unknown_8d8f7: db $69, $02
db $6a, $02
db $6b, $02
- db -4
+ db -4
Unknown_8d8fe: db $6e, $03
db $6f, $03
db $70, $03
db $71, $03
- db -2
+ db -2
Unknown_8d907: db $71, $03
db $6e, $07
- db -1
+ db -1
Unknown_8d90c: db $72, $20
db $73, $07
db $74, $07
- db -1
+ db -1
Unknown_8d913: db $75, $03
- db -1
+ db -1
Unknown_8d916: db $76, $03
db $77, $03
db $78, $07
- db -4
+ db -4
Unknown_8d91d: db $76, $43
db $77, $43
db $78, $47
- db -4
+ db -4
Unknown_8d924: db $76, $83
db $77, $83
db $78, $87
- db -4
+ db -4
Unknown_8d92b: db $76, $c3
db $77, $c3
db $78, $c7
- db -4
+ db -4
Unknown_8d932: db $79, $03
db $7a, $03
db $7b, $03
db $7c, $07
db $7d, $07
- db -1
+ db -1
Unknown_8d93d: db $7e, $03
- db -1
-Unknown_8d940: db $fd, $00
- db -1
+ db -1
+Unknown_8d940: db -3, $00
+ db -1
Unknown_8d943: db $7f, $08
db $80, $08
- db -1
+ db -1
Unknown_8d948: db $7f, $48
db $80, $48
- db -1
+ db -1
; 8d94d
-Unknown_8d94d: ; 8d94d
+SpriteAnimOAMData: ; 8d94d
; vtile offset, pointer
dbw $00, Unknown_8dd8a ; 00
dbw $04, Unknown_8dd8a ; 01
--- a/engine/breeding/egg.asm
+++ b/engine/breeding/egg.asm
@@ -829,7 +829,7 @@
ld [hl], $0
pop de
ld a, e
- ld hl, SPRITEANIMSTRUCT_01
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
add [hl]
ld [hl], a
--- a/engine/compose_mail.asm
+++ b/engine/compose_mail.asm
@@ -182,7 +182,7 @@
ld [wc6d5], a
ld a, b
ld [wc6d6], a
- ld hl, SPRITEANIMSTRUCT_01
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld a, [hl]
ld hl, SPRITEANIMSTRUCT_0E
@@ -298,7 +298,7 @@
ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
add [hl]
- ld hl, SPRITEANIMSTRUCT_01
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
ld hl, SPRITEANIMSTRUCT_0C
--- a/engine/crystal_intro.asm
+++ b/engine/crystal_intro.asm
@@ -1627,7 +1627,7 @@
add hl, bc
ld [hl], $8
ld a, $3c
- call Function3b3c
+ call ReinitSpriteAnimFrame
pop de
push de
@@ -1637,7 +1637,7 @@
add hl, bc
ld [hl], $18
ld a, $3b
- call Function3b3c
+ call ReinitSpriteAnimFrame
pop de
push de
@@ -1647,7 +1647,7 @@
add hl, bc
ld [hl], $28
ld a, $39
- call Function3b3c
+ call ReinitSpriteAnimFrame
pop de
ld a, SPRITE_ANIM_INDEX_29
@@ -1656,7 +1656,7 @@
add hl, bc
ld [hl], $38
ld a, $3a
- call Function3b3c
+ call ReinitSpriteAnimFrame
ret
CrystalIntro_UnownFade: ; e5223 (39:5223)
--- a/engine/mon_icons.asm
+++ b/engine/mon_icons.asm
@@ -79,7 +79,7 @@
.asm_8e890
ld a, $4
.asm_8e892
- ld hl, SPRITEANIMSTRUCT_01
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
ret
@@ -150,7 +150,7 @@
ld a, $2
.okay
- ld hl, SPRITEANIMSTRUCT_01
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
ret
--- 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, SPRITEANIMSTRUCT_01
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], $0
hlcoord 5, 2
@@ -411,7 +411,7 @@
ld [wc6d5], a
ld a, b
ld [wc6d6], a
- ld hl, SPRITEANIMSTRUCT_01
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld a, [hl]
ld hl, SPRITEANIMSTRUCT_0E
@@ -553,7 +553,7 @@
ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
add [hl]
- ld hl, SPRITEANIMSTRUCT_01
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
ld hl, SPRITEANIMSTRUCT_0C
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -100,7 +100,7 @@
call Function92844
call Function92b0f
xor a
- ld [wOAMRetentionSize], a
+ ld [wCurrSpriteOAMAddr], a
callab DoNextFrameForFirst16Sprites
call Function927f8
call Function927d3
--- a/engine/sprite_anims.asm
+++ b/engine/sprite_anims.asm
@@ -36,7 +36,7 @@
dw .eighteen
dw .nineteen ; finish egg hatching animation
dw .twenty ; radio tuning knob
- dw .twentyone
+ dw .twentyone ; cut grass leaves
dw .twentytwo ; flying sprite
dw .twentythree ; flying leaves
dw .twentyfour
@@ -370,7 +370,7 @@
ret nz
ld [hl], $3
ld a, $f
- call Function8d120
+ call _ReinitSpriteAnimFrame
ret
.eleven: ; 8d43e (23:543e)
@@ -434,7 +434,7 @@
.sixteen_zero: ; 8d493
ld a, $14
- call Function8d120
+ call _ReinitSpriteAnimFrame
ld hl, SPRITEANIMSTRUCT_0B
add hl, bc
@@ -786,7 +786,7 @@
add hl, bc
ld [hl], a
ld a, $36
- call Function8d120
+ call _ReinitSpriteAnimFrame
ret
.thirty: ; 8d666 (23:5666)
@@ -840,7 +840,7 @@
cp $40
ret nz
ld a, $3d
- call Function8d120
+ call _ReinitSpriteAnimFrame
ret
.thirtyfour: ; 8d6ae (23:56ae)
@@ -856,7 +856,7 @@
ret
.thirtyone: ; 8d6be (23:56be)
- callba Function49aa2
+ callba UpdateCelebiPosition
ret
.anonymous_jumptable: ; 8d6c5 (23:56c5)
--- a/engine/sprites.asm
+++ b/engine/sprites.asm
@@ -24,7 +24,7 @@
push af
ld a, 0 * 4
- ld [wOAMRetentionSize], a
+ ld [wCurrSpriteOAMAddr], a
call DoNextFrameForAllSprites
pop af
@@ -47,7 +47,7 @@
push hl
push de
call DoAnimFrame ; Uses a massive jumptable
- call Function8d04c
+ call UpdateAnimFrame
pop de
pop hl
jr c, .done
@@ -58,11 +58,11 @@
dec e
jr nz, .loop
- ld a, [wOAMRetentionSize]
+ ld a, [wCurrSpriteOAMAddr]
ld l, a
ld h, Sprites / $0100
-.loop2 ; Clear (Sprites + [wOAMRetentionSize] --> SpritesEnd)
+.loop2 ; Clear (Sprites + [wCurrSpriteOAMAddr] --> SpritesEnd)
ld a, l
cp SpritesEnd % $100
jr nc, .done
@@ -87,7 +87,7 @@
push hl
push de
call DoAnimFrame ; Uses a massive jumptable
- call Function8d04c
+ call UpdateAnimFrame
pop de
pop hl
jr c, .done
@@ -98,11 +98,11 @@
dec e
jr nz, .loop
- ld a, [wOAMRetentionSize]
+ ld a, [wCurrSpriteOAMAddr]
ld l, a
ld h, (Sprites + $40) / $100
-.loop2 ; Clear (Sprites + [wOAMRetentionSize] --> Sprites + $40)
+.loop2 ; Clear (Sprites + [wCurrSpriteOAMAddr] --> Sprites + $40)
ld a, l
cp (Sprites + 16 * 4) % $100
jr nc, .done
@@ -149,11 +149,11 @@
inc [hl]
.initialized
-; Get row a of Unknown_8d1c4, copy the pointer into de
+; Get row a of SpriteAnimSeqData, copy the pointer into de
pop af
ld e, a
ld d, 0
- ld hl, Unknown_8d1c4
+ ld hl, SpriteAnimSeqData
rept 3
add hl, de
endr
@@ -235,14 +235,14 @@
ret
-Function8d04c: ; 8d04c
+UpdateAnimFrame: ; 8d04c
call InitSpriteAnimBuffer ; init WRAM
- call Function8d132 ; read from a memory array
+ call GetSpriteAnimFrame ; read from a memory array
cp -3
jr z, .done
cp -4
jr z, .delete
- call Function8d1a2 ; OAM?
+ call GetFrameOAMPointer
; add byte to [wCurrAnimVTile]
ld a, [wCurrAnimVTile]
add [hl]
@@ -253,7 +253,7 @@
ld h, [hl]
ld l, a
push bc
- ld a, [wOAMRetentionSize]
+ ld a, [wCurrSpriteOAMAddr]
ld e, a
ld d, Sprites / $100
ld a, [hli]
@@ -297,13 +297,13 @@
inc hl
inc de
; fourth byte: attributes
- ; [de] = Function8d0de([hl])
- call Function8d0de
+ ; [de] = GetSpriteOAMAttr([hl])
+ call GetSpriteOAMAttr
ld [de], a
inc hl
inc de
ld a, e
- ld [wOAMRetentionSize], a
+ ld [wCurrSpriteOAMAddr], a
cp SpritesEnd % $100
jr nc, .reached_the_end
dec c
@@ -356,7 +356,7 @@
ret
; 8d0de
-Function8d0de: ; 8d0de
+GetSpriteOAMAttr: ; 8d0de
ld a, [wCurrSpriteAddSubFlags]
ld b, a
ld a, [hl]
@@ -414,8 +414,8 @@
ret
; 8d120
-Function8d120:: ; 8d120
- ld hl, SPRITEANIMSTRUCT_01
+_ReinitSpriteAnimFrame:: ; 8d120
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
ld hl, SPRITEANIMSTRUCT_DURATION
@@ -428,7 +428,7 @@
; 8d132
-Function8d132: ; 8d132
+GetSpriteAnimFrame: ; 8d132
.loop
ld hl, SPRITEANIMSTRUCT_DURATION
add hl, bc
@@ -436,7 +436,7 @@
and a
jr z, .next_frame ; finished the current sequence
dec [hl]
- call Function8d189 ; load pointer from Unknown_8d6e6
+ call GetSpriteFrameDataPointer ; load pointer from SpriteAnimFrameData
ld a, [hli]
push af
jr .okay
@@ -445,12 +445,12 @@
ld hl, SPRITEANIMSTRUCT_FRAME
add hl, bc
inc [hl]
- call Function8d189 ; load pointer from Unknown_8d6e6
+ call GetSpriteFrameDataPointer ; load pointer from SpriteAnimFrameData
ld a, [hli]
cp -2
- jr z, .minus_2
+ jr z, .restart
cp -1
- jr z, .minus_1
+ jr z, .repeat_last
push af
ld a, [hl]
@@ -471,7 +471,7 @@
pop af
ret
-.minus_1
+.repeat_last
xor a
ld hl, SPRITEANIMSTRUCT_DURATION
add hl, bc
@@ -484,7 +484,7 @@
endr
jr .loop
-.minus_2
+.restart
xor a
ld hl, SPRITEANIMSTRUCT_DURATION
add hl, bc
@@ -497,15 +497,15 @@
jr .loop
; 8d189
-Function8d189: ; 8d189
+GetSpriteFrameDataPointer: ; 8d189
; Get the data for the current frame for the current animation sequence
- ; Unknown_8d6e6[SpriteAnim[SPRITEANIMSTRUCT_01]][SpriteAnim[SPRITEANIMSTRUCT_FRAME]]
- ld hl, SPRITEANIMSTRUCT_01
+ ; SpriteAnimFrameData[SpriteAnim[SPRITEANIMSTRUCT_FRAMESET_ID]][SpriteAnim[SPRITEANIMSTRUCT_FRAME]]
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld e, [hl]
ld d, 0
- ld hl, Unknown_8d6e6
+ ld hl, SpriteAnimFrameData
rept 2
add hl, de
endr
@@ -521,11 +521,11 @@
ret
; 8d1a2
-Function8d1a2: ; 8d1a2
+GetFrameOAMPointer: ; 8d1a2
; Load OAM data pointer
ld e, a
ld d, 0
- ld hl, Unknown_8d94d
+ ld hl, SpriteAnimOAMData
rept 3
add hl, de
endr
@@ -555,7 +555,7 @@
ret
; 8d1c4
-Unknown_8d1c4: ; 8d1c4
+SpriteAnimSeqData: ; 8d1c4
; ??, sequence, tile
db $01, SPRITE_ANIM_SEQ_01, $00 ; 00
db $07, SPRITE_ANIM_SEQ_04, $00 ; 01
@@ -579,7 +579,7 @@
db $19, SPRITE_ANIM_SEQ_13, $00 ; 13
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 $1d, SPRITE_ANIM_SEQ_15, $00 ; 16 leaves when cutting down a tree
db $1e, SPRITE_ANIM_SEQ_00, $00 ; 17
db $1d, SPRITE_ANIM_SEQ_17, $00 ; 18 flying leaves
db $1f, SPRITE_ANIM_SEQ_00, $00 ; 19
@@ -607,12 +607,13 @@
INCLUDE "engine/sprite_anims.asm" ; DoAnimFrame
INCLUDE "data/sprite_engine.asm"
-; Unknown_8d6e6
-; Unknown_8d94d
+; SpriteAnimFrameData
+; SpriteAnimOAMData
Sprites_Cosine: ; 8e72a
add $10
Sprites_Sine: ; 8e72c
+; floor(d * sin(a * pi/32))
and $3f
cp $20
jr nc, .negative
@@ -669,8 +670,8 @@
ld hl, VTiles0 tile $00
lb bc, BANK(EndOfExpBarGFX), 1
call Request2bpp
- ld c, $8
- ld d, $0
+ ld c, 8
+ ld d, 0
.loop
push bc
call .AnimateFrame
@@ -694,6 +695,7 @@
ret z
dec c
ld a, c
+; multiply by 8
sla a
sla a
sla a
--- a/event/celebi.asm
+++ b/event/celebi.asm
@@ -8,17 +8,17 @@
depixel 0, 10, 7, 0
ld a, SPRITE_ANIM_INDEX_2C
call _InitSpriteAnimStruct
- ld hl, $3
+ ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $84
- ld hl, $2
+ ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
- ld [hl], $1f
- ld hl, $f
+ ld [hl], SPRITE_ANIM_SEQ_1F
+ ld hl, SPRITEANIMSTRUCT_0F
add hl, bc
ld a, $80
ld [hl], a
- ld a, $a0
+ ld a, 160 ; frame count
ld [wcf64], a
ld d, $0
.loop
@@ -26,13 +26,13 @@
bit 7, a
jr nz, .done
push bc
- call Function49bae
+ call GetCelebiSpriteTile
inc d
push de
ld a, $90
- ld [wOAMRetentionSize], a
+ ld [wCurrSpriteOAMAddr], a
callba DoNextFrameForAllSprites
- call Function49935
+ call CelebiEvent_CountDown
ld c, 2
call DelayFrames
pop de
@@ -39,19 +39,21 @@
pop bc
jr .loop
+
.done
pop af
ld [VramState], a
- call Function498f9
- call Function49bf3
+ call .RefreshPlayerSprite_ClearAllOthers
+ call CelebiEvent_SetBattleType
ret
+
; 498f9
-Function498f9: ; 498f9
+.RefreshPlayerSprite_ClearAllOthers: ; 498f9
ld hl, Sprites + 2
xor a
ld c, $4
-.loop
+.OAMloop
ld [hli], a
rept 3
inc hl
@@ -58,12 +60,13 @@
endr
inc a
dec c
- jr nz, .loop
+ jr nz, .OAMloop
ld hl, Sprites + $10
ld bc, $90
xor a
call ByteFill
ret
+
; 49912
LoadCelebiGFX: ; 49912
@@ -79,23 +82,27 @@
xor a
ld [wJumptableIndex], a
ret
+
; 49935
-Function49935: ; 49935
+CelebiEvent_CountDown: ; 49935
ld hl, wcf64
ld a, [hl]
and a
- jr z, .asm_4993e
+ jr z, .done
dec [hl]
ret
-.asm_4993e
+
+.done
ld hl, wJumptableIndex
set 7, [hl]
ret
+
; 49944
-Function49944: ; 49944
+CelebiEvent_SpawnLeaf: ; 49944
+; unused
ld hl, wcf65
ld a, [hl]
inc [hl]
@@ -109,10 +116,11 @@
ld e, $0
ld a, SPRITE_ANIM_INDEX_18 ; fly land
call _InitSpriteAnimStruct
- ld hl, $3
+ ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $80
ret
+
; 49962
SpecialCelebiLeafGFX: ; 49962
@@ -124,105 +132,110 @@
INCBIN "gfx/special/celebi/4.2bpp"
-Function49aa2: ; 49aa2 (12:5aa2)
- ld hl, $6
+UpdateCelebiPosition: ; 49aa2 (12:5aa2)
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld a, [hl]
push af
- ld hl, $5
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld a, [hl]
- cp $52
- jp nc, Function49b30
- ld hl, $5
+ cp 8 * 10 + 2
+ jp nc, .FreezeCelebiPosition
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
inc [hl]
- ld hl, $f
+ ld hl, SPRITEANIMSTRUCT_0F
add hl, bc
ld a, [hl]
ld d, a
cp $3a
- jr c, .asm_49ac6
- jr z, .asm_49ac6
+ jr c, .skip
+ jr z, .skip
sub $3
ld [hl], a
-.asm_49ac6
- ld hl, $e
+.skip
+ ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
ld a, [hl]
inc [hl]
call CelebiEvent_Cosine
- ld hl, $6
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ld d, a
- ld hl, $4
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
add [hl]
- cp $5c
- jr nc, .asm_49ae2
- cp $44
- jr nc, .asm_49b0d
-.asm_49ae2
+ cp 8 * 11 + 4
+ jr nc, .ShiftY
+ cp 8 * 8 + 4
+ jr nc, .ReinitSpriteAnimFrame
+.ShiftY
pop af
push af
cp d
- jr nc, .asm_49af2
- ld hl, $4
+ jr nc, .moving_left
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
add [hl]
- cp $50
- jr c, .asm_49b05
- jr .asm_49afb
-.asm_49af2
- ld hl, $4
+ cp 8 * 10
+ jr c, .float_up
+ jr .float_down
+
+.moving_left
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
add [hl]
- cp $50
- jr nc, .asm_49b05
-.asm_49afb
- ld hl, $5
+ cp 8 * 10
+ jr nc, .float_up
+.float_down
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld a, [hl]
sub $2
ld [hl], a
- jr .asm_49b0d
-.asm_49b05
- ld hl, $5
+ jr .ReinitSpriteAnimFrame
+
+.float_up
+ ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld a, [hl]
add $1
ld [hl], a
-.asm_49b0d
+.ReinitSpriteAnimFrame
pop af
- ld hl, $4
+ ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
add [hl]
- cp $50
- jr c, .asm_49b26
- cp $e6
- jr nc, .asm_49b26
- ld hl, $1
+ cp 8 * 10
+ jr c, .left
+ cp -(8 * 3 + 2)
+ jr nc, .left
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld a, $41
- call Function3b3c
- jr .asm_49b2f
-.asm_49b26
- ld hl, $1
+ call ReinitSpriteAnimFrame
+ jr .done
+
+.left
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld a, $40
- call Function3b3c
-.asm_49b2f
+ call ReinitSpriteAnimFrame
+.done
ret
-Function49b30: ; 49b30 (12:5b30)
+
+.FreezeCelebiPosition: ; 49b30 (12:5b30)
pop af
- ld hl, $1
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld a, $40
- call Function3b3c
+ call ReinitSpriteAnimFrame
ret
+
CelebiEvent_Cosine: ; 49b3b (12:5b3b)
add $10
and $3f
@@ -231,6 +244,7 @@
call .SineFunction
ld a, h
ret
+
.asm_49b48
and $1f
call .SineFunction
@@ -239,6 +253,7 @@
inc a
ret
+
.SineFunction: ; 49b52 (12:5b52)
ld e, a
ld a, d
@@ -261,6 +276,7 @@
and a
jr nz, .multiply
ret
+
; 49b6e (12:5b6e)
.sinewave: ; 49b6e
@@ -267,7 +283,7 @@
sine_wave $100
; 49bae
-Function49bae: ; 49bae
+GetCelebiSpriteTile: ; 49bae
push hl
push bc
push de
@@ -275,54 +291,60 @@
ld d, $3
ld e, d
cp $0
- jr z, .asm_49bd0
+ jr z, .Frame1
cp d
- jr z, .asm_49bd4
- call Function49bed
+ jr z, .Frame2
+ call .AddE
cp d
- jr z, .asm_49bd8
- call Function49bed
+ jr z, .Frame3
+ call .AddE
cp d
- jr z, .asm_49bdc
- call Function49bed
+ jr z, .Frame4
+ call .AddE
cp d
- jr c, .asm_49be9
- jr .asm_49be5
+ jr c, .done
+ jr .restart
-.asm_49bd0
+
+.Frame1
ld a, $84
- jr .asm_49bde
+ jr .load_tile
-.asm_49bd4
+
+.Frame2
ld a, $88
- jr .asm_49bde
+ jr .load_tile
-.asm_49bd8
+
+.Frame3
ld a, $8c
- jr .asm_49bde
+ jr .load_tile
-.asm_49bdc
+
+.Frame4
ld a, $90
-.asm_49bde
- ld hl, $3
+.load_tile
+ ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], a
- jr .asm_49be9
+ jr .done
-.asm_49be5
+
+.restart
pop de
ld d, $ff
push de
-.asm_49be9
+.done
pop de
pop bc
pop hl
ret
+
; 49bed
-Function49bed: ; 49bed
+.AddE: ; 49bed
push af
ld a, d
add e
@@ -329,12 +351,14 @@
ld d, a
pop af
ret
+
; 49bf3
-Function49bf3: ; 49bf3
+CelebiEvent_SetBattleType: ; 49bf3
ld a, BATTLETYPE_CELEBI
ld [BattleType], a
ret
+
; 49bf9
CheckCaughtCelebi: ; 49bf9
@@ -345,6 +369,7 @@
ld [ScriptVar], a
jr .done
+
.false
xor a
ld [ScriptVar], a
@@ -351,4 +376,5 @@
.done
ret
+
; 49c0c
--- a/event/field_moves.asm
+++ b/event/field_moves.asm
@@ -36,7 +36,7 @@
add hl, bc
ld [hl], $84
ld a, 36 * 4
- ld [wOAMRetentionSize], a
+ ld [wCurrSpriteOAMAddr], a
callba DoNextFrameForAllSprites
call GetHeadbuttTreeRelativeLocation
ld a, $20
@@ -51,7 +51,7 @@
jr z, .done
dec [hl]
ld a, 36 * 4
- ld [wOAMRetentionSize], a
+ ld [wCurrSpriteOAMAddr], a
callba DoNextFrameForAllSprites
call DelayFrame
jr .loop
@@ -125,7 +125,7 @@
bit 7, a
jr nz, .finish
ld a, 36 * 4
- ld [wOAMRetentionSize], a
+ ld [wCurrSpriteOAMAddr], a
callab DoNextFrameForAllSprites
call OWCutJumptable
call DelayFrame
@@ -342,7 +342,7 @@
bit 7, a
jr nz, .exit
ld a, 0 * 4
- ld [wOAMRetentionSize], a
+ ld [wCurrSpriteOAMAddr], a
callab DoNextFrameForAllSprites
call Function8cbc8
call DelayFrame
@@ -380,7 +380,7 @@
bit 7, a
jr nz, .exit
ld a, 0 * 4
- ld [wOAMRetentionSize], a
+ ld [wCurrSpriteOAMAddr], a
callab DoNextFrameForAllSprites
call Function8cbc8
call DelayFrame
--- a/home.asm
+++ b/home.asm
@@ -2036,17 +2036,17 @@
; 3b3c
-Function3b3c:: ; 3b3c
+ReinitSpriteAnimFrame:: ; 3b3c
ld [wSpriteAnimIDBuffer], a
ld a, [hROMBank]
push af
- ld a, BANK(Function8d120)
+ ld a, BANK(_ReinitSpriteAnimFrame)
rst Bankswitch
ld a, [wSpriteAnimIDBuffer]
- call Function8d120
+ call _ReinitSpriteAnimFrame
pop af
rst Bankswitch
--- a/misc/fixed_words.asm
+++ b/misc/fixed_words.asm
@@ -2478,7 +2478,7 @@
ld d, $0
add hl, de
ld a, [hl]
- call Function3b3c
+ call ReinitSpriteAnimFrame
ld a, [CreditsTimer]
sla a
ld hl, Unknown_11d23e
@@ -2487,7 +2487,7 @@
Function11d10f: ; 11d10f (47:510f)
ld a, $27
- call Function3b3c
+ call ReinitSpriteAnimFrame
ld a, [wcd25]
sla a
ld hl, Unknown_11d29e
@@ -2514,7 +2514,7 @@
Function11d134: ; 11d134 (47:5134)
ld a, $27
- call Function3b3c
+ call ReinitSpriteAnimFrame
ld a, [wcd2a]
sla a
ld hl, Unknown_11d2b6
@@ -2523,7 +2523,7 @@
Function11d145: ; 11d145 (47:5145)
ld a, $27
- call Function3b3c
+ call ReinitSpriteAnimFrame
ld a, [wcd2c]
sla a
ld hl, Unknown_11d2ba
@@ -2532,7 +2532,7 @@
Function11d156: ; 11d156 (47:5156)
ld a, $2a
- call Function3b3c
+ call ReinitSpriteAnimFrame
ld a, [wcd4a]
sla a
sla a
@@ -2557,7 +2557,7 @@
.asm_11d180
ld a, $26
.asm_11d182
- call Function3b3c
+ call ReinitSpriteAnimFrame
ld a, [wcd4d]
cp $4
jr z, .asm_11d1b1
@@ -2611,7 +2611,7 @@
asm_11d1db: ; 11d1db (47:51db)
push de
- call Function3b3c
+ call ReinitSpriteAnimFrame
ld a, [wcd4a]
sla a
sla a
@@ -2632,7 +2632,7 @@
Function11d1fc: ; 11d1fc (47:51fc)
ld a, $26
- call Function3b3c
+ call ReinitSpriteAnimFrame
ld a, $8
ld e, a
call Function11d2ee
--- a/misc/mobile_46.asm
+++ b/misc/mobile_46.asm
@@ -5885,7 +5885,7 @@
call Function11acb7
call Function11ad6e
ld a, 30 * 4
- ld [wOAMRetentionSize], a
+ ld [wCurrSpriteOAMAddr], a
callba DoNextFrameForAllSprites
callba ReloadMapPart
jr .asm_11ac82
--- a/wram.asm
+++ b/wram.asm
@@ -395,7 +395,7 @@
SECTION "wSpriteAnims", WRAM0 [$c300]
; wc300 - wc313 is a 10x2 dictionary.
-; keys: taken from third column of Unknown_8d1c4
+; keys: taken from third column of SpriteAnimSeqData
; values: VTiles
wSpriteAnimDict:: ds 10 * 2
ds wSpriteAnimDict - @
@@ -429,8 +429,8 @@
\1YCoord:: ds 1 ; 5
\1XOffset:: ds 1 ; 6
\1YOffset:: ds 1 ; 7
-\1FrameTimer:: ds 1 ; 8
-\1Sprite09:: ds 1 ; 9
+\1Duration:: ds 1 ; 8
+\1DurationOffset:: ds 1 ; 9
\1FrameIndex:: ds 1 ; a
\1Sprite0b:: ds 1
\1Sprite0c:: ds 1
@@ -440,7 +440,7 @@
ENDM
; Field 0: Index
-; Fields 1-3: Loaded from Unknown_8d1c4
+; Fields 1-3: Loaded from SpriteAnimSeqData
wc314::
SpriteAnim1:: sprite_anim_struct SpriteAnim1
wc324::
@@ -466,7 +466,7 @@
wc3ac:: ds 8 ; c3ac
wSpriteAnimCount::
wc3b4:: ds 1
-wOAMRetentionSize:: ds 1
+wCurrSpriteOAMAddr:: ds 1
CurIcon:: ; c3b6
ds 1