2018-01-15 00:43:35 +00:00
|
|
|
SPECIALCELEBIEVENT_CELEBI EQU $84
|
|
|
|
|
2020-10-26 19:45:57 +00:00
|
|
|
UnusedForestTreeFrames: ; unreferenced
|
2020-06-11 14:55:32 +00: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 20:41:22 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CelebiShrineEvent:
|
2015-11-17 03:29:54 +00:00
|
|
|
call DelayFrame
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wVramState]
|
2015-11-17 03:29:54 +00:00
|
|
|
push af
|
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wVramState], a
|
2015-11-17 03:29:54 +00:00
|
|
|
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
|
2020-02-11 12:42:36 +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
|
2018-01-15 00:43:35 +00:00
|
|
|
ld [hl], SPECIALCELEBIEVENT_CELEBI
|
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
|
2020-08-22 14:22:37 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_VAR4
|
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
|
2018-01-11 20:36:11 +00:00
|
|
|
ld [wFrameCounter], a
|
2015-11-17 03:29:54 +00:00
|
|
|
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
|
2018-07-15 15:58:01 +00:00
|
|
|
ld a, 36 * SPRITEOAMSTRUCT_LENGTH
|
2018-09-09 19:09:51 +00:00
|
|
|
ld [wCurSpriteOAMAddr], 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
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop af
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wVramState], a
|
2018-01-10 18:47:57 +00:00
|
|
|
call .RestorePlayerSprite_DespawnLeaves
|
2015-12-05 20:38:25 +00:00
|
|
|
call CelebiEvent_SetBattleType
|
2015-11-17 03:29:54 +00:00
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.RestorePlayerSprite_DespawnLeaves:
|
2018-01-30 19:52:46 +00:00
|
|
|
ld hl, wVirtualOAMSprite00TileID
|
2015-11-17 03:29:54 +00:00
|
|
|
xor a
|
2018-01-10 18:47:57 +00:00
|
|
|
ld c, 4
|
2016-04-10 18:42:14 +00:00
|
|
|
.OAMloop:
|
2018-01-10 18:47:57 +00:00
|
|
|
ld [hli], a ; tile id
|
2020-03-21 18:01:05 +00:00
|
|
|
rept SPRITEOAMSTRUCT_LENGTH - 1
|
2016-05-10 16:31:49 +00:00
|
|
|
inc hl
|
2018-01-10 18:47:57 +00:00
|
|
|
endr
|
2015-11-17 03:29:54 +00:00
|
|
|
inc a
|
|
|
|
dec c
|
2015-12-05 20:38:25 +00:00
|
|
|
jr nz, .OAMloop
|
2018-01-30 19:52:46 +00:00
|
|
|
ld hl, wVirtualOAMSprite04
|
2018-01-30 19:55:20 +00:00
|
|
|
ld bc, wVirtualOAMEnd - wVirtualOAMSprite04
|
2015-11-17 03:29:54 +00:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
LoadCelebiGFX:
|
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
|
2018-01-15 00:43:35 +00:00
|
|
|
ld hl, vTiles0 tile SPECIALCELEBIEVENT_CELEBI
|
|
|
|
lb bc, BANK(SpecialCelebiGFX), 4 * 4
|
2015-11-17 03:29:54 +00:00
|
|
|
call Request2bpp
|
|
|
|
xor a
|
|
|
|
ld [wJumptableIndex], a
|
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CelebiEvent_CountDown:
|
2018-01-11 20:36:11 +00:00
|
|
|
ld hl, wFrameCounter
|
2015-11-17 03:29:54 +00:00
|
|
|
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
|
|
|
|
2020-10-26 19:45:57 +00:00
|
|
|
CelebiEvent_SpawnLeaf: ; unreferenced
|
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
|
2020-02-11 12:42:36 +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
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
SpecialCelebiLeafGFX:
|
2017-12-16 17:09:16 +00:00
|
|
|
INCBIN "gfx/overworld/cut_grass.2bpp"
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
SpecialCelebiGFX:
|
2020-03-16 12:58:28 +00:00
|
|
|
INCBIN "gfx/overworld/celebi.2bpp"
|
2015-11-17 03:29:54 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
UpdateCelebiPosition:
|
2015-12-05 20:38:25 +00:00
|
|
|
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]
|
2020-08-22 14:22:37 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_VAR4
|
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
|
2020-08-22 14:22:37 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_VAR3
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.FreezeCelebiPosition:
|
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
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CelebiEvent_Cosine:
|
2018-01-09 21:39:36 +00:00
|
|
|
; a = d * cos(a * pi/32)
|
2018-02-04 02:11:55 +00:00
|
|
|
add %010000 ; cos(x) = sin(x + pi/2)
|
|
|
|
calc_sine_wave
|
2015-11-17 03:29:54 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
GetCelebiSpriteTile:
|
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
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.Frame1:
|
2018-01-15 00:43:35 +00:00
|
|
|
ld a, SPECIALCELEBIEVENT_CELEBI
|
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
|
|
|
.Frame2:
|
2018-01-15 00:43:35 +00:00
|
|
|
ld a, SPECIALCELEBIEVENT_CELEBI + 4
|
2015-12-05 20:38:25 +00:00
|
|
|
jr .load_tile
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.Frame3:
|
2018-01-15 00:43:35 +00:00
|
|
|
ld a, SPECIALCELEBIEVENT_CELEBI + 8
|
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
|
|
|
.Frame4:
|
2018-01-15 00:43:35 +00:00
|
|
|
ld a, SPECIALCELEBIEVENT_CELEBI + 12
|
2015-11-17 03:29:54 +00:00
|
|
|
|
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
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.AddE:
|
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
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CelebiEvent_SetBattleType:
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, BATTLETYPE_CELEBI
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wBattleType], a
|
2015-11-17 03:29:54 +00:00
|
|
|
ret
|
2015-12-05 20:38:25 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckCaughtCelebi:
|
2015-11-17 03:29:54 +00:00
|
|
|
ld a, [wBattleResult]
|
2018-04-05 15:44:02 +00:00
|
|
|
bit BATTLERESULT_CAUGHT_CELEBI, a
|
2015-11-17 17:29:37 +00:00
|
|
|
jr z, .false
|
2018-04-05 15:44:02 +00:00
|
|
|
ld a, TRUE
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-17 17:29:37 +00:00
|
|
|
jr .done
|
2015-11-17 03:29:54 +00:00
|
|
|
|
2015-11-17 17:29:37 +00:00
|
|
|
.false
|
2018-04-05 15:44:02 +00:00
|
|
|
xor a ; FALSE
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2015-11-17 03:29:54 +00:00
|
|
|
|
2015-11-17 17:29:37 +00:00
|
|
|
.done
|
2015-11-17 03:29:54 +00:00
|
|
|
ret
|