pokecrystal-board/engine/events/celebi.asm

381 lines
5.0 KiB
NASM
Raw Normal View History

2015-11-16 19:29:54 -08:00
Special_CelebiShrineEvent: ; 4989a
call DelayFrame
ld a, [VramState]
push af
xor a
ld [VramState], a
call LoadCelebiGFX
2015-11-18 10:01:55 -08:00
depixel 0, 10, 7, 0
ld a, SPRITE_ANIM_INDEX_CELEBI
2015-11-16 19:29:54 -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], $84
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
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
2015-11-16 19:29:54 -08:00
ld [wcf64], a
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
ld a, $90
2015-12-05 12:38:25 -08:00
ld [wCurrSpriteOAMAddr], 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
2015-12-05 12:38:25 -08:00
2015-11-16 19:29:54 -08:00
.done
pop af
ld [VramState], a
2015-12-05 12:38:25 -08:00
call .RefreshPlayerSprite_ClearAllOthers
call CelebiEvent_SetBattleType
2015-11-16 19:29:54 -08:00
ret
2015-12-05 12:38:25 -08:00
2015-11-16 19:29:54 -08:00
; 498f9
2015-12-05 12:38:25 -08:00
.RefreshPlayerSprite_ClearAllOthers: ; 498f9
2015-11-16 19:29:54 -08:00
ld hl, Sprites + 2
xor a
ld c, $4
.OAMloop:
2015-11-16 19:29:54 -08:00
ld [hli], a
inc hl
inc hl
inc hl
2015-11-16 19:29:54 -08:00
inc a
dec c
2015-12-05 12:38:25 -08:00
jr nz, .OAMloop
2016-01-10 14:44:09 -08:00
ld hl, Sprites + 4 * 4
ld bc, 36 * 4
2015-11-16 19:29:54 -08:00
xor a
call ByteFill
ret
2015-12-05 12:38:25 -08:00
2015-11-16 19:29:54 -08:00
; 49912
LoadCelebiGFX: ; 49912
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
2017-12-28 04:32:33 -08:00
ld hl, vTiles0 tile $84
2015-11-16 19:29:54 -08:00
lb bc, BANK(SpecialCelebiGFX), $10
call Request2bpp
xor a
ld [wJumptableIndex], a
ret
2015-12-05 12:38:25 -08:00
2015-11-16 19:29:54 -08:00
; 49935
2015-12-05 12:38:25 -08:00
CelebiEvent_CountDown: ; 49935
2015-11-16 19:29:54 -08:00
ld hl, wcf64
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
2015-11-16 19:29:54 -08:00
; 49944
2015-12-05 12:38:25 -08:00
CelebiEvent_SpawnLeaf: ; 49944
; 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
2015-11-16 19:29:54 -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
2015-11-16 19:29:54 -08:00
; 49962
SpecialCelebiLeafGFX: ; 49962
2017-12-16 09:09:16 -08:00
INCBIN "gfx/overworld/cut_grass.2bpp"
2015-11-16 19:29:54 -08:00
SpecialCelebiGFX: ; 499a2
2017-12-16 09:09:16 -08: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-16 19:29:54 -08:00
2015-12-05 12:38:25 -08:00
UpdateCelebiPosition: ; 49aa2 (12:5aa2)
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]
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
.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
.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
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
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
2015-12-05 12:38:25 -08:00
.FreezeCelebiPosition: ; 49b30 (12:5b30)
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
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
2015-12-05 12:38:25 -08:00
CelebiEvent_Cosine: ; 49b3b (12:5b3b)
2015-11-16 19:29:54 -08:00
add $10
and $3f
cp $20
2015-12-06 19:36:09 -08:00
jr nc, .negative
call .SineFunction
2015-11-16 19:29:54 -08:00
ld a, h
ret
2015-12-05 12:38:25 -08:00
2015-12-06 19:36:09 -08:00
.negative
2015-11-16 19:29:54 -08:00
and $1f
call .SineFunction
2015-11-16 19:29:54 -08:00
ld a, h
xor $ff
inc a
ret
2015-12-05 12:38:25 -08:00
.SineFunction: ; 49b52 (12:5b52)
2015-11-16 19:29:54 -08:00
ld e, a
ld a, d
ld d, $0
ld hl, .sinewave
2015-11-16 19:29:54 -08:00
add hl, de
add hl, de
2015-11-16 19:29:54 -08:00
ld e, [hl]
inc hl
ld d, [hl]
ld hl, 0
.multiply
2015-11-16 19:29:54 -08:00
srl a
jr nc, .even
2015-11-16 19:29:54 -08:00
add hl, de
.even
2015-11-16 19:29:54 -08:00
sla e
rl d
and a
jr nz, .multiply
2015-11-16 19:29:54 -08:00
ret
2015-12-05 12:38:25 -08:00
2015-11-16 19:29:54 -08:00
; 49b6e (12:5b6e)
.sinewave ; 49b6e
2015-11-16 19:29:54 -08:00
sine_wave $100
; 49bae
2015-12-05 12:38:25 -08:00
GetCelebiSpriteTile: ; 49bae
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
2015-11-16 19:29:54 -08:00
.Frame1:
2015-11-16 19:29:54 -08:00
ld a, $84
2015-12-05 12:38:25 -08:00
jr .load_tile
2015-11-16 19:29:54 -08:00
2015-12-05 12:38:25 -08:00
.Frame2:
2015-11-16 19:29:54 -08:00
ld a, $88
2015-12-05 12:38:25 -08:00
jr .load_tile
2015-11-16 19:29:54 -08:00
.Frame3:
2015-11-16 19:29:54 -08:00
ld a, $8c
2015-12-05 12:38:25 -08:00
jr .load_tile
2015-11-16 19:29:54 -08:00
2015-12-05 12:38:25 -08:00
.Frame4:
2015-11-16 19:29:54 -08:00
ld a, $90
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
2015-11-16 19:29:54 -08:00
; 49bed
2015-12-05 12:38:25 -08:00
.AddE: ; 49bed
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
2015-11-16 19:29:54 -08:00
; 49bf3
2015-12-05 12:38:25 -08:00
CelebiEvent_SetBattleType: ; 49bf3
2015-11-16 19:29:54 -08:00
ld a, BATTLETYPE_CELEBI
ld [BattleType], a
ret
2015-12-05 12:38:25 -08:00
2015-11-16 19:29:54 -08:00
; 49bf9
2015-11-17 09:29:37 -08:00
CheckCaughtCelebi: ; 49bf9
2015-11-16 19:29:54 -08:00
ld a, [wBattleResult]
bit 6, a
2015-11-17 09:29:37 -08:00
jr z, .false
2015-11-16 19:29:54 -08:00
ld a, $1
ld [ScriptVar], a
2015-11-17 09:29:37 -08:00
jr .done
2015-11-16 19:29:54 -08:00
2015-12-05 12:38:25 -08:00
2015-11-17 09:29:37 -08:00
.false
2015-11-16 19:29:54 -08:00
xor a
ld [ScriptVar], a
2015-11-17 09:29:37 -08:00
.done
2015-11-16 19:29:54 -08:00
ret
2015-12-05 12:38:25 -08:00
2015-11-16 19:29:54 -08:00
; 49c0c