2018-01-14 16:43:35 -08:00
|
|
|
SPECIALCELEBIEVENT_CELEBI EQU $84
|
|
|
|
|
2020-02-26 12:41:22 -08:00
|
|
|
UnusedForestTreeFrames:
|
2020-06-11 07:55:32 -07:00
|
|
|
INCBIN "gfx/tilesets/forest-tree/1.2bpp"
|
|
|
|
INCBIN "gfx/tilesets/forest-tree/2.2bpp"
|
|
|
|
INCBIN "gfx/tilesets/forest-tree/3.2bpp"
|
|
|
|
INCBIN "gfx/tilesets/forest-tree/4.2bpp"
|
2020-02-26 12:41:22 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CelebiShrineEvent:
|
2015-11-16 19:29:54 -08:00
|
|
|
call DelayFrame
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wVramState]
|
2015-11-16 19:29:54 -08:00
|
|
|
push af
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wVramState], a
|
2015-11-16 19:29:54 -08:00
|
|
|
call LoadCelebiGFX
|
2015-11-18 10:01:55 -08:00
|
|
|
depixel 0, 10, 7, 0
|
2017-12-08 21:50:59 -08:00
|
|
|
ld a, SPRITE_ANIM_INDEX_CELEBI
|
2020-02-11 04:42:36 -08:00
|
|
|
call InitSpriteAnimStruct
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_TILE_ID
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
2018-01-14 16:43:35 -08:00
|
|
|
ld [hl], SPECIALCELEBIEVENT_CELEBI
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
2017-12-08 21:50:59 -08:00
|
|
|
ld [hl], SPRITE_ANIM_SEQ_CELEBI
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_0F
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, $80
|
|
|
|
ld [hl], a
|
2015-12-05 12:38:25 -08:00
|
|
|
ld a, 160 ; frame count
|
2018-01-11 12:36:11 -08:00
|
|
|
ld [wFrameCounter], a
|
2015-11-16 19:29:54 -08:00
|
|
|
ld d, $0
|
|
|
|
.loop
|
|
|
|
ld a, [wJumptableIndex]
|
|
|
|
bit 7, a
|
|
|
|
jr nz, .done
|
|
|
|
push bc
|
2015-12-05 12:38:25 -08:00
|
|
|
call GetCelebiSpriteTile
|
2015-11-16 19:29:54 -08:00
|
|
|
inc d
|
|
|
|
push de
|
2018-07-15 08:58:01 -07:00
|
|
|
ld a, 36 * SPRITEOAMSTRUCT_LENGTH
|
2018-09-09 12:09:51 -07:00
|
|
|
ld [wCurSpriteOAMAddr], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DoNextFrameForAllSprites
|
2015-12-05 12:38:25 -08:00
|
|
|
call CelebiEvent_CountDown
|
2015-11-16 19:29:54 -08:00
|
|
|
ld c, 2
|
|
|
|
call DelayFrames
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wVramState], a
|
2018-01-10 10:47:57 -08:00
|
|
|
call .RestorePlayerSprite_DespawnLeaves
|
2015-12-05 12:38:25 -08:00
|
|
|
call CelebiEvent_SetBattleType
|
2015-11-16 19:29:54 -08:00
|
|
|
ret
|
2015-12-05 12:38:25 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.RestorePlayerSprite_DespawnLeaves:
|
2018-01-30 11:52:46 -08:00
|
|
|
ld hl, wVirtualOAMSprite00TileID
|
2015-11-16 19:29:54 -08:00
|
|
|
xor a
|
2018-01-10 10:47:57 -08:00
|
|
|
ld c, 4
|
2016-04-10 11:42:14 -07:00
|
|
|
.OAMloop:
|
2018-01-10 10:47:57 -08:00
|
|
|
ld [hli], a ; tile id
|
2020-03-21 11:01:05 -07:00
|
|
|
rept SPRITEOAMSTRUCT_LENGTH - 1
|
2016-05-10 09:31:49 -07:00
|
|
|
inc hl
|
2018-01-10 10:47:57 -08:00
|
|
|
endr
|
2015-11-16 19:29:54 -08:00
|
|
|
inc a
|
|
|
|
dec c
|
2015-12-05 12:38:25 -08:00
|
|
|
jr nz, .OAMloop
|
2018-01-30 11:52:46 -08:00
|
|
|
ld hl, wVirtualOAMSprite04
|
2018-01-30 11:55:20 -08:00
|
|
|
ld bc, wVirtualOAMEnd - wVirtualOAMSprite04
|
2015-11-16 19:29:54 -08:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
ret
|
2015-12-05 12:38:25 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadCelebiGFX:
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall ClearSpriteAnims
|
2015-11-16 19:29:54 -08:00
|
|
|
ld de, SpecialCelebiLeafGFX
|
2017-12-28 04:32:33 -08:00
|
|
|
ld hl, vTiles1
|
2015-11-16 19:29:54 -08:00
|
|
|
lb bc, BANK(SpecialCelebiLeafGFX), 4
|
|
|
|
call Request2bpp
|
|
|
|
ld de, SpecialCelebiGFX
|
2018-01-14 16:43:35 -08:00
|
|
|
ld hl, vTiles0 tile SPECIALCELEBIEVENT_CELEBI
|
|
|
|
lb bc, BANK(SpecialCelebiGFX), 4 * 4
|
2015-11-16 19:29:54 -08:00
|
|
|
call Request2bpp
|
|
|
|
xor a
|
|
|
|
ld [wJumptableIndex], a
|
|
|
|
ret
|
2015-12-05 12:38:25 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CelebiEvent_CountDown:
|
2018-01-11 12:36:11 -08:00
|
|
|
ld hl, wFrameCounter
|
2015-11-16 19:29:54 -08:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-12-05 12:38:25 -08:00
|
|
|
jr z, .done
|
2015-11-16 19:29:54 -08:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2015-12-05 12:38:25 -08:00
|
|
|
.done
|
2015-11-16 19:29:54 -08:00
|
|
|
ld hl, wJumptableIndex
|
|
|
|
set 7, [hl]
|
|
|
|
ret
|
2015-12-05 12:38:25 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CelebiEvent_SpawnLeaf:
|
2015-12-05 12:38:25 -08:00
|
|
|
; unused
|
2015-11-16 19:29:54 -08: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-18 17:07:09 -08:00
|
|
|
ld a, SPRITE_ANIM_INDEX_FLY_LEAF ; fly land
|
2020-02-11 04:42:36 -08:00
|
|
|
call InitSpriteAnimStruct
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_TILE_ID
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], $80
|
|
|
|
ret
|
2015-12-05 12:38:25 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpecialCelebiLeafGFX:
|
2017-12-16 09:09:16 -08:00
|
|
|
INCBIN "gfx/overworld/cut_grass.2bpp"
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SpecialCelebiGFX:
|
2020-03-16 05:58:28 -07:00
|
|
|
INCBIN "gfx/overworld/celebi.2bpp"
|
2015-11-16 19:29:54 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdateCelebiPosition:
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_XOFFSET
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_YCOORD
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2015-12-05 12:38:25 -08:00
|
|
|
cp 8 * 10 + 2
|
|
|
|
jp nc, .FreezeCelebiPosition
|
|
|
|
ld hl, SPRITEANIMSTRUCT_YCOORD
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
inc [hl]
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_0F
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld d, a
|
|
|
|
cp $3a
|
2015-12-05 12:38:25 -08:00
|
|
|
jr c, .skip
|
|
|
|
jr z, .skip
|
2015-11-16 19:29:54 -08:00
|
|
|
sub $3
|
|
|
|
ld [hl], a
|
2015-12-05 12:38:25 -08:00
|
|
|
.skip
|
|
|
|
ld hl, SPRITEANIMSTRUCT_0E
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
inc [hl]
|
2015-12-04 11:33:29 -08:00
|
|
|
call CelebiEvent_Cosine
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_XOFFSET
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
|
|
|
ld d, a
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_XCOORD
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2015-12-05 12:38:25 -08:00
|
|
|
cp 8 * 11 + 4
|
|
|
|
jr nc, .ShiftY
|
|
|
|
cp 8 * 8 + 4
|
|
|
|
jr nc, .ReinitSpriteAnimFrame
|
2016-04-10 11:42:14 -07:00
|
|
|
.ShiftY:
|
2015-11-16 19:29:54 -08:00
|
|
|
pop af
|
|
|
|
push af
|
|
|
|
cp d
|
2015-12-05 12:38:25 -08:00
|
|
|
jr nc, .moving_left
|
|
|
|
ld hl, SPRITEANIMSTRUCT_XCOORD
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2015-12-05 12:38:25 -08:00
|
|
|
cp 8 * 10
|
|
|
|
jr c, .float_up
|
|
|
|
jr .float_down
|
|
|
|
|
|
|
|
.moving_left
|
|
|
|
ld hl, SPRITEANIMSTRUCT_XCOORD
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2015-12-05 12:38:25 -08:00
|
|
|
cp 8 * 10
|
|
|
|
jr nc, .float_up
|
|
|
|
.float_down
|
|
|
|
ld hl, SPRITEANIMSTRUCT_YCOORD
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
sub $2
|
|
|
|
ld [hl], a
|
2015-12-05 12:38:25 -08:00
|
|
|
jr .ReinitSpriteAnimFrame
|
|
|
|
|
|
|
|
.float_up
|
|
|
|
ld hl, SPRITEANIMSTRUCT_YCOORD
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
add $1
|
|
|
|
ld [hl], a
|
2016-04-10 11:42:14 -07:00
|
|
|
.ReinitSpriteAnimFrame:
|
2015-11-16 19:29:54 -08:00
|
|
|
pop af
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_XCOORD
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
add [hl]
|
2015-12-05 12:38:25 -08:00
|
|
|
cp 8 * 10
|
|
|
|
jr c, .left
|
|
|
|
cp -(8 * 3 + 2)
|
|
|
|
jr nc, .left
|
|
|
|
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
2017-11-29 11:24:19 -08:00
|
|
|
ld a, SPRITE_ANIM_FRAMESET_CELEBI_RIGHT
|
2015-12-05 12:38:25 -08:00
|
|
|
call ReinitSpriteAnimFrame
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.left
|
|
|
|
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
2017-11-29 11:24:19 -08:00
|
|
|
ld a, SPRITE_ANIM_FRAMESET_CELEBI_LEFT
|
2015-12-05 12:38:25 -08:00
|
|
|
call ReinitSpriteAnimFrame
|
|
|
|
.done
|
2015-11-16 19:29:54 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.FreezeCelebiPosition:
|
2015-11-16 19:29:54 -08:00
|
|
|
pop af
|
2015-12-05 12:38:25 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
2017-11-29 11:24:19 -08:00
|
|
|
ld a, SPRITE_ANIM_FRAMESET_CELEBI_LEFT
|
2015-12-05 12:38:25 -08:00
|
|
|
call ReinitSpriteAnimFrame
|
2015-11-16 19:29:54 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CelebiEvent_Cosine:
|
2018-01-09 13:39:36 -08:00
|
|
|
; a = d * cos(a * pi/32)
|
2018-02-03 18:11:55 -08:00
|
|
|
add %010000 ; cos(x) = sin(x + pi/2)
|
|
|
|
calc_sine_wave
|
2015-11-16 19:29:54 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetCelebiSpriteTile:
|
2015-11-16 19:29:54 -08:00
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
ld a, d
|
|
|
|
ld d, $3
|
|
|
|
ld e, d
|
|
|
|
cp $0
|
2015-12-05 12:38:25 -08:00
|
|
|
jr z, .Frame1
|
2015-11-16 19:29:54 -08:00
|
|
|
cp d
|
2015-12-05 12:38:25 -08:00
|
|
|
jr z, .Frame2
|
|
|
|
call .AddE
|
2015-11-16 19:29:54 -08:00
|
|
|
cp d
|
2015-12-05 12:38:25 -08:00
|
|
|
jr z, .Frame3
|
|
|
|
call .AddE
|
2015-11-16 19:29:54 -08:00
|
|
|
cp d
|
2015-12-05 12:38:25 -08:00
|
|
|
jr z, .Frame4
|
|
|
|
call .AddE
|
2015-11-16 19:29:54 -08:00
|
|
|
cp d
|
2015-12-05 12:38:25 -08:00
|
|
|
jr c, .done
|
|
|
|
jr .restart
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Frame1:
|
2018-01-14 16:43:35 -08:00
|
|
|
ld a, SPECIALCELEBIEVENT_CELEBI
|
2015-12-05 12:38:25 -08:00
|
|
|
jr .load_tile
|
2015-11-16 19:29:54 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Frame2:
|
2018-01-14 16:43:35 -08:00
|
|
|
ld a, SPECIALCELEBIEVENT_CELEBI + 4
|
2015-12-05 12:38:25 -08:00
|
|
|
jr .load_tile
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Frame3:
|
2018-01-14 16:43:35 -08:00
|
|
|
ld a, SPECIALCELEBIEVENT_CELEBI + 8
|
2015-12-05 12:38:25 -08:00
|
|
|
jr .load_tile
|
2015-11-16 19:29:54 -08:00
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Frame4:
|
2018-01-14 16:43:35 -08:00
|
|
|
ld a, SPECIALCELEBIEVENT_CELEBI + 12
|
2015-11-16 19:29:54 -08:00
|
|
|
|
2015-12-05 12:38:25 -08:00
|
|
|
.load_tile
|
|
|
|
ld hl, SPRITEANIMSTRUCT_TILE_ID
|
2015-11-16 19:29:54 -08:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], a
|
2015-12-05 12:38:25 -08:00
|
|
|
jr .done
|
2015-11-16 19:29:54 -08:00
|
|
|
|
2015-12-05 12:38:25 -08:00
|
|
|
.restart
|
2015-11-16 19:29:54 -08:00
|
|
|
pop de
|
|
|
|
ld d, $ff
|
|
|
|
push de
|
|
|
|
|
2015-12-05 12:38:25 -08:00
|
|
|
.done
|
2015-11-16 19:29:54 -08:00
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
2015-12-05 12:38:25 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.AddE:
|
2015-11-16 19:29:54 -08:00
|
|
|
push af
|
|
|
|
ld a, d
|
|
|
|
add e
|
|
|
|
ld d, a
|
|
|
|
pop af
|
|
|
|
ret
|
2015-12-05 12:38:25 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CelebiEvent_SetBattleType:
|
2015-11-16 19:29:54 -08:00
|
|
|
ld a, BATTLETYPE_CELEBI
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wBattleType], a
|
2015-11-16 19:29:54 -08:00
|
|
|
ret
|
2015-12-05 12:38:25 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckCaughtCelebi:
|
2015-11-16 19:29:54 -08:00
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
bit BATTLERESULT_CAUGHT_CELEBI, a
|
2015-11-17 09:29:37 -08:00
|
|
|
jr z, .false
|
2018-04-05 08:44:02 -07:00
|
|
|
ld a, TRUE
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptVar], a
|
2015-11-17 09:29:37 -08:00
|
|
|
jr .done
|
2015-11-16 19:29:54 -08:00
|
|
|
|
2015-11-17 09:29:37 -08:00
|
|
|
.false
|
2018-04-05 08:44:02 -07:00
|
|
|
xor a ; FALSE
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wScriptVar], a
|
2015-11-16 19:29:54 -08:00
|
|
|
|
2015-11-17 09:29:37 -08:00
|
|
|
.done
|
2015-11-16 19:29:54 -08:00
|
|
|
ret
|