2015-11-17 03:29:54 +00:00
|
|
|
Special_CelebiShrineEvent: ; 4989a
|
|
|
|
call DelayFrame
|
|
|
|
ld a, [VramState]
|
|
|
|
push af
|
|
|
|
xor a
|
|
|
|
ld [VramState], a
|
|
|
|
call LoadCelebiGFX
|
2015-11-18 18:01:55 +00:00
|
|
|
depixel 0, 10, 7, 0
|
2017-12-09 05:50:59 +00:00
|
|
|
ld a, SPRITE_ANIM_INDEX_CELEBI
|
2015-11-17 03:29:54 +00:00
|
|
|
call _InitSpriteAnimStruct
|
2015-12-05 20:38:25 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_TILE_ID
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], $84
|
2015-12-05 20:38:25 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
2017-12-09 05:50:59 +00:00
|
|
|
ld [hl], SPRITE_ANIM_SEQ_CELEBI
|
2015-12-05 20:38:25 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_0F
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, $80
|
|
|
|
ld [hl], a
|
2015-12-05 20:38:25 +00:00
|
|
|
ld a, 160 ; frame count
|
2015-11-17 03:29:54 +00:00
|
|
|
ld [wcf64], a
|
|
|
|
ld d, $0
|
|
|
|
.loop
|
|
|
|
ld a, [wJumptableIndex]
|
|
|
|
bit 7, a
|
|
|
|
jr nz, .done
|
|
|
|
push bc
|
2015-12-05 20:38:25 +00:00
|
|
|
call GetCelebiSpriteTile
|
2015-11-17 03:29:54 +00:00
|
|
|
inc d
|
|
|
|
push de
|
|
|
|
ld a, $90
|
2015-12-05 20:38:25 +00:00
|
|
|
ld [wCurrSpriteOAMAddr], a
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall DoNextFrameForAllSprites
|
2015-12-05 20:38:25 +00:00
|
|
|
call CelebiEvent_CountDown
|
2015-11-17 03:29:54 +00:00
|
|
|
ld c, 2
|
|
|
|
call DelayFrames
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
jr .loop
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
.done
|
|
|
|
pop af
|
|
|
|
ld [VramState], a
|
2015-12-05 20:38:25 +00:00
|
|
|
call .RefreshPlayerSprite_ClearAllOthers
|
|
|
|
call CelebiEvent_SetBattleType
|
2015-11-17 03:29:54 +00:00
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
; 498f9
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
.RefreshPlayerSprite_ClearAllOthers: ; 498f9
|
2015-11-17 03:29:54 +00:00
|
|
|
ld hl, Sprites + 2
|
|
|
|
xor a
|
|
|
|
ld c, $4
|
2016-04-10 18:42:14 +00:00
|
|
|
.OAMloop:
|
2015-11-17 03:29:54 +00:00
|
|
|
ld [hli], a
|
|
|
|
inc hl
|
2016-05-10 16:31:49 +00:00
|
|
|
inc hl
|
|
|
|
inc hl
|
2015-11-17 03:29:54 +00:00
|
|
|
inc a
|
|
|
|
dec c
|
2015-12-05 20:38:25 +00:00
|
|
|
jr nz, .OAMloop
|
2016-01-10 22:44:09 +00:00
|
|
|
ld hl, Sprites + 4 * 4
|
|
|
|
ld bc, 36 * 4
|
2015-11-17 03:29:54 +00:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
; 49912
|
|
|
|
|
|
|
|
LoadCelebiGFX: ; 49912
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall ClearSpriteAnims
|
2015-11-17 03:29:54 +00:00
|
|
|
ld de, SpecialCelebiLeafGFX
|
2017-12-28 12:32:33 +00:00
|
|
|
ld hl, vTiles1
|
2015-11-17 03:29:54 +00:00
|
|
|
lb bc, BANK(SpecialCelebiLeafGFX), 4
|
|
|
|
call Request2bpp
|
|
|
|
ld de, SpecialCelebiGFX
|
2017-12-28 12:32:33 +00:00
|
|
|
ld hl, vTiles0 tile $84
|
2015-11-17 03:29:54 +00:00
|
|
|
lb bc, BANK(SpecialCelebiGFX), $10
|
|
|
|
call Request2bpp
|
|
|
|
xor a
|
|
|
|
ld [wJumptableIndex], a
|
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
; 49935
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
CelebiEvent_CountDown: ; 49935
|
2015-11-17 03:29:54 +00:00
|
|
|
ld hl, wcf64
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-12-05 20:38:25 +00:00
|
|
|
jr z, .done
|
2015-11-17 03:29:54 +00:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
|
|
|
|
.done
|
2015-11-17 03:29:54 +00:00
|
|
|
ld hl, wJumptableIndex
|
|
|
|
set 7, [hl]
|
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
; 49944
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
CelebiEvent_SpawnLeaf: ; 49944
|
|
|
|
; unused
|
2015-11-17 03:29:54 +00:00
|
|
|
ld hl, wcf65
|
|
|
|
ld a, [hl]
|
|
|
|
inc [hl]
|
|
|
|
and $7
|
|
|
|
ret nz
|
|
|
|
ld a, [hl]
|
|
|
|
and $18
|
|
|
|
sla a
|
|
|
|
add $40
|
|
|
|
ld d, a
|
|
|
|
ld e, $0
|
2015-12-19 01:07:09 +00:00
|
|
|
ld a, SPRITE_ANIM_INDEX_FLY_LEAF ; fly land
|
2015-11-17 03:29:54 +00:00
|
|
|
call _InitSpriteAnimStruct
|
2015-12-05 20:38:25 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_TILE_ID
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], $80
|
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
; 49962
|
|
|
|
|
|
|
|
SpecialCelebiLeafGFX: ; 49962
|
2017-12-16 17:09:16 +00:00
|
|
|
INCBIN "gfx/overworld/cut_grass.2bpp"
|
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
SpecialCelebiGFX: ; 499a2
|
2017-12-16 17:09:16 +00:00
|
|
|
INCBIN "gfx/overworld/celebi/1.2bpp"
|
|
|
|
INCBIN "gfx/overworld/celebi/2.2bpp"
|
|
|
|
INCBIN "gfx/overworld/celebi/3.2bpp"
|
|
|
|
INCBIN "gfx/overworld/celebi/4.2bpp"
|
2015-11-17 03:29:54 +00:00
|
|
|
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
UpdateCelebiPosition: ; 49aa2 (12:5aa2)
|
|
|
|
ld hl, SPRITEANIMSTRUCT_XOFFSET
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
2015-12-05 20:38:25 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_YCOORD
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-12-05 20:38:25 +00:00
|
|
|
cp 8 * 10 + 2
|
|
|
|
jp nc, .FreezeCelebiPosition
|
|
|
|
ld hl, SPRITEANIMSTRUCT_YCOORD
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
2015-12-05 20:38:25 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_0F
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld d, a
|
|
|
|
cp $3a
|
2015-12-05 20:38:25 +00:00
|
|
|
jr c, .skip
|
|
|
|
jr z, .skip
|
2015-11-17 03:29:54 +00:00
|
|
|
sub $3
|
|
|
|
ld [hl], a
|
2015-12-05 20:38:25 +00:00
|
|
|
.skip
|
|
|
|
ld hl, SPRITEANIMSTRUCT_0E
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
inc [hl]
|
2015-12-04 19:33:29 +00:00
|
|
|
call CelebiEvent_Cosine
|
2015-12-05 20:38:25 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_XOFFSET
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld d, a
|
2015-12-05 20:38:25 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_XCOORD
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2015-12-05 20:38:25 +00:00
|
|
|
cp 8 * 11 + 4
|
|
|
|
jr nc, .ShiftY
|
|
|
|
cp 8 * 8 + 4
|
|
|
|
jr nc, .ReinitSpriteAnimFrame
|
2016-04-10 18:42:14 +00:00
|
|
|
.ShiftY:
|
2015-11-17 03:29:54 +00:00
|
|
|
pop af
|
|
|
|
push af
|
|
|
|
cp d
|
2015-12-05 20:38:25 +00:00
|
|
|
jr nc, .moving_left
|
|
|
|
ld hl, SPRITEANIMSTRUCT_XCOORD
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2015-12-05 20:38:25 +00:00
|
|
|
cp 8 * 10
|
|
|
|
jr c, .float_up
|
|
|
|
jr .float_down
|
|
|
|
|
|
|
|
.moving_left
|
|
|
|
ld hl, SPRITEANIMSTRUCT_XCOORD
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2015-12-05 20:38:25 +00:00
|
|
|
cp 8 * 10
|
|
|
|
jr nc, .float_up
|
|
|
|
.float_down
|
|
|
|
ld hl, SPRITEANIMSTRUCT_YCOORD
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
sub $2
|
|
|
|
ld [hl], a
|
2015-12-05 20:38:25 +00:00
|
|
|
jr .ReinitSpriteAnimFrame
|
|
|
|
|
|
|
|
.float_up
|
|
|
|
ld hl, SPRITEANIMSTRUCT_YCOORD
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
add $1
|
|
|
|
ld [hl], a
|
2016-04-10 18:42:14 +00:00
|
|
|
.ReinitSpriteAnimFrame:
|
2015-11-17 03:29:54 +00:00
|
|
|
pop af
|
2015-12-05 20:38:25 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_XCOORD
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2015-12-05 20:38:25 +00:00
|
|
|
cp 8 * 10
|
|
|
|
jr c, .left
|
|
|
|
cp -(8 * 3 + 2)
|
|
|
|
jr nc, .left
|
|
|
|
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
2017-11-29 19:24:19 +00:00
|
|
|
ld a, SPRITE_ANIM_FRAMESET_CELEBI_RIGHT
|
2015-12-05 20:38:25 +00:00
|
|
|
call ReinitSpriteAnimFrame
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.left
|
|
|
|
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
2017-11-29 19:24:19 +00:00
|
|
|
ld a, SPRITE_ANIM_FRAMESET_CELEBI_LEFT
|
2015-12-05 20:38:25 +00:00
|
|
|
call ReinitSpriteAnimFrame
|
|
|
|
.done
|
2015-11-17 03:29:54 +00:00
|
|
|
ret
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
|
|
|
|
.FreezeCelebiPosition: ; 49b30 (12:5b30)
|
2015-11-17 03:29:54 +00:00
|
|
|
pop af
|
2015-12-05 20:38:25 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
2017-11-29 19:24:19 +00:00
|
|
|
ld a, SPRITE_ANIM_FRAMESET_CELEBI_LEFT
|
2015-12-05 20:38:25 +00:00
|
|
|
call ReinitSpriteAnimFrame
|
2015-11-17 03:29:54 +00:00
|
|
|
ret
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-12-04 19:33:29 +00:00
|
|
|
CelebiEvent_Cosine: ; 49b3b (12:5b3b)
|
2015-11-17 03:29:54 +00:00
|
|
|
add $10
|
|
|
|
and $3f
|
|
|
|
cp $20
|
2015-12-07 03:36:09 +00:00
|
|
|
jr nc, .negative
|
2015-12-04 19:33:29 +00:00
|
|
|
call .SineFunction
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, h
|
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-12-07 03:36:09 +00:00
|
|
|
.negative
|
2015-11-17 03:29:54 +00:00
|
|
|
and $1f
|
2015-12-04 19:33:29 +00:00
|
|
|
call .SineFunction
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, h
|
|
|
|
xor $ff
|
|
|
|
inc a
|
|
|
|
ret
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-12-04 19:33:29 +00:00
|
|
|
.SineFunction: ; 49b52 (12:5b52)
|
2015-11-17 03:29:54 +00:00
|
|
|
ld e, a
|
|
|
|
ld a, d
|
|
|
|
ld d, $0
|
2015-12-04 19:33:29 +00:00
|
|
|
ld hl, .sinewave
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, de
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, de
|
2015-11-17 03:29:54 +00:00
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
ld hl, 0
|
2015-12-04 19:33:29 +00:00
|
|
|
.multiply
|
2015-11-17 03:29:54 +00:00
|
|
|
srl a
|
2015-12-04 19:33:29 +00:00
|
|
|
jr nc, .even
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, de
|
2015-12-04 19:33:29 +00:00
|
|
|
.even
|
2015-11-17 03:29:54 +00:00
|
|
|
sla e
|
|
|
|
rl d
|
|
|
|
and a
|
2015-12-04 19:33:29 +00:00
|
|
|
jr nz, .multiply
|
2015-11-17 03:29:54 +00:00
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
; 49b6e (12:5b6e)
|
|
|
|
|
2016-04-10 19:01:49 +00:00
|
|
|
.sinewave ; 49b6e
|
2015-11-17 03:29:54 +00:00
|
|
|
sine_wave $100
|
|
|
|
; 49bae
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
GetCelebiSpriteTile: ; 49bae
|
2015-11-17 03:29:54 +00:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld a, d
|
|
|
|
ld d, $3
|
|
|
|
ld e, d
|
|
|
|
cp $0
|
2015-12-05 20:38:25 +00:00
|
|
|
jr z, .Frame1
|
2015-11-17 03:29:54 +00:00
|
|
|
cp d
|
2015-12-05 20:38:25 +00:00
|
|
|
jr z, .Frame2
|
|
|
|
call .AddE
|
2015-11-17 03:29:54 +00:00
|
|
|
cp d
|
2015-12-05 20:38:25 +00:00
|
|
|
jr z, .Frame3
|
|
|
|
call .AddE
|
2015-11-17 03:29:54 +00:00
|
|
|
cp d
|
2015-12-05 20:38:25 +00:00
|
|
|
jr z, .Frame4
|
|
|
|
call .AddE
|
2015-11-17 03:29:54 +00:00
|
|
|
cp d
|
2015-12-05 20:38:25 +00:00
|
|
|
jr c, .done
|
|
|
|
jr .restart
|
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.Frame1:
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, $84
|
2015-12-05 20:38:25 +00:00
|
|
|
jr .load_tile
|
2015-11-17 03:29:54 +00:00
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.Frame2:
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, $88
|
2015-12-05 20:38:25 +00:00
|
|
|
jr .load_tile
|
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.Frame3:
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, $8c
|
2015-12-05 20:38:25 +00:00
|
|
|
jr .load_tile
|
2015-11-17 03:29:54 +00:00
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.Frame4:
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, $90
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
.load_tile
|
|
|
|
ld hl, SPRITEANIMSTRUCT_TILE_ID
|
2015-11-17 03:29:54 +00:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-12-05 20:38:25 +00:00
|
|
|
jr .done
|
2015-11-17 03:29:54 +00:00
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
|
|
|
|
.restart
|
2015-11-17 03:29:54 +00:00
|
|
|
pop de
|
|
|
|
ld d, $ff
|
|
|
|
push de
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
.done
|
2015-11-17 03:29:54 +00:00
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
; 49bed
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
.AddE: ; 49bed
|
2015-11-17 03:29:54 +00:00
|
|
|
push af
|
|
|
|
ld a, d
|
|
|
|
add e
|
|
|
|
ld d, a
|
|
|
|
pop af
|
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
; 49bf3
|
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
CelebiEvent_SetBattleType: ; 49bf3
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, BATTLETYPE_CELEBI
|
|
|
|
ld [BattleType], a
|
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
; 49bf9
|
|
|
|
|
2015-11-17 17:29:37 +00:00
|
|
|
CheckCaughtCelebi: ; 49bf9
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, [wBattleResult]
|
|
|
|
bit 6, a
|
2015-11-17 17:29:37 +00:00
|
|
|
jr z, .false
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, $1
|
|
|
|
ld [ScriptVar], a
|
2015-11-17 17:29:37 +00:00
|
|
|
jr .done
|
2015-11-17 03:29:54 +00:00
|
|
|
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 17:29:37 +00:00
|
|
|
.false
|
2015-11-17 03:29:54 +00:00
|
|
|
xor a
|
|
|
|
ld [ScriptVar], a
|
|
|
|
|
2015-11-17 17:29:37 +00:00
|
|
|
.done
|
2015-11-17 03:29:54 +00:00
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2015-11-17 03:29:54 +00:00
|
|
|
; 49c0c
|