summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-06-17 17:02:45 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-06-17 17:02:45 -0400
commit451f529b0d6311fc0b6c507d8ccb5336e2984889 (patch)
treeb2c5643d6973e79c02f3e7aba7d9e86702c51870
parent993f87a852974b000a0ec770cfd53afb392136ce (diff)
Harmonize engine/{movie, pokemon} with pokecrystal
To do: engine/{menus, overworld}
-rw-r--r--engine/gfx/sprite_anims.asm2
-rw-r--r--engine/link/mystery_gift.asm4
-rw-r--r--engine/menus/intro_menu.asm2
-rw-r--r--engine/movie/credits.asm4
-rw-r--r--engine/movie/evolution_animation.asm285
-rw-r--r--engine/movie/intro.asm90
-rw-r--r--engine/overworld/scripting.asm2
-rw-r--r--engine/phone/phone.asm4
-rw-r--r--engine/pokemon/bills_pc.asm2
-rw-r--r--engine/pokemon/bills_pc_top.asm4
-rw-r--r--engine/pokemon/caught_nickname.asm6
-rw-r--r--engine/pokemon/evolve.asm287
-rw-r--r--engine/pokemon/mon_stats.asm4
-rw-r--r--engine/pokemon/stats_screen.asm23
-rw-r--r--engine/pokemon/types.asm2
15 files changed, 362 insertions, 359 deletions
diff --git a/engine/gfx/sprite_anims.asm b/engine/gfx/sprite_anims.asm
index 0cb4f67f..cced6ae6 100644
--- a/engine/gfx/sprite_anims.asm
+++ b/engine/gfx/sprite_anims.asm
@@ -948,7 +948,7 @@ ENDC
ret
.GameFreakLogo:
- callfar GFPresents_UpdateLogoPal
+ callfar GameFreakPresents_UpdateLogoPal
ret
.GSIntroStar
diff --git a/engine/link/mystery_gift.asm b/engine/link/mystery_gift.asm
index 92f67093..7fcb10a9 100644
--- a/engine/link/mystery_gift.asm
+++ b/engine/link/mystery_gift.asm
@@ -294,7 +294,7 @@ Function29fc9:
Function2a037:
call Function2a073
jp nz, Function2a103
-; fall through
+; fallthrough
Function2a03d:
call Function2a166
jp nz, Function2a103
@@ -322,7 +322,7 @@ Function2a073:
ld b, $1
call Function2a184
ret nz
-; fall through
+; fallthrough
Function2a07c:
call Function2a461
ldh a, [hMGStatusFlags]
diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm
index b7456f95..bdd456ac 100644
--- a/engine/menus/intro_menu.asm
+++ b/engine/menus/intro_menu.asm
@@ -836,7 +836,7 @@ Intro_PlaceChrisSprite:
db 10 * 8 + 4, 10 * 8, 3
IntroSequence:
- callfar Copyright_GFPresents
+ callfar Copyright_GameFreakPresents
jr c, StartTitleScreen
callfar GoldSilverIntro
diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm
index 533c3d79..0dd51c76 100644
--- a/engine/movie/credits.asm
+++ b/engine/movie/credits.asm
@@ -74,9 +74,9 @@ Credits::
call SetPalettes
ldh a, [hVBlank]
push af
- ld a, 5
+ ld a, $5
ldh [hVBlank], a
- ld a, 1
+ ld a, TRUE
ldh [hInMenu], a
xor a
ldh [hBGMapMode], a
diff --git a/engine/movie/evolution_animation.asm b/engine/movie/evolution_animation.asm
new file mode 100644
index 00000000..c8a6b370
--- /dev/null
+++ b/engine/movie/evolution_animation.asm
@@ -0,0 +1,285 @@
+EvolutionAnimation:
+ push hl
+ push de
+ push bc
+ ld a, [wCurSpecies]
+ push af
+ ldh a, [rOBP0]
+ push af
+ ld a, %11100100
+ ldh [rOBP0], a
+
+ ld de, MUSIC_NONE
+ call PlayMusic
+
+ callfar ClearSpriteAnims
+
+ ld de, .GFX
+ ld hl, vTiles0
+ lb bc, BANK(.GFX), 8
+ call Request2bpp
+
+ xor a
+ ld [wLowHealthAlarm], a
+
+ ld a, 1
+ ldh [hBGMapMode], a
+
+ call WaitBGMap
+ xor a
+ ldh [hBGMapMode], a
+
+ ld a, [wEvolutionOldSpecies]
+ ld [wPlayerHPPal], a
+
+ ld c, FALSE
+ call .GetSGBLayout
+
+ ld a, [wEvolutionNewSpecies]
+ ld [wCurPartySpecies], a
+ ld [wCurSpecies], a
+ call .PlaceFrontpic
+
+ ld de, vTiles2
+ ld hl, vTiles2 tile $31
+ ld bc, 7 * 7
+ call Request2bpp
+
+ ld a, [wEvolutionOldSpecies]
+ ld [wCurPartySpecies], a
+ ld [wCurSpecies], a
+ call .PlaceFrontpic
+
+ ld a, 1
+ ldh [hBGMapMode], a
+
+ ld a, [wEvolutionOldSpecies]
+ call PlayMonCry
+
+ ld de, MUSIC_EVOLUTION
+ call PlayMusic
+
+ ld c, 80
+ call DelayFrames
+
+ ld c, TRUE
+ call .GetSGBLayout
+
+.AnimationSequence:
+ call ClearJoypad
+ lb bc, 1, 16 ; flash b times, wait c frames in between
+.loop
+ push bc
+ call .WaitFrames_CheckPressedB
+ jr c, .cancel_evo
+ call .Flash
+ pop bc
+ inc b
+ dec c
+ dec c
+ jr nz, .loop
+
+ xor a
+ ld [wEvolutionCanceled], a
+
+ ld a, 7 * 7
+ ld [wEvolutionPicOffset], a
+ call .ReplaceFrontpic
+
+ ld a, [wEvolutionNewSpecies]
+.return
+ ld [wPlayerHPPal], a
+
+ ld c, FALSE
+ call .GetSGBLayout
+
+ call .PlayEvolvedSFX
+
+ callfar ClearSpriteAnims
+
+ ld a, [wPlayerHPPal]
+ call PlayMonCry
+
+ pop af
+ ldh [rOBP0], a
+ pop af
+ ld [wCurSpecies], a
+ pop bc
+ pop de
+ pop hl
+
+ ld a, [wEvolutionCanceled]
+ and a
+ ret z
+
+ scf
+ ret
+
+.cancel_evo
+ pop bc
+ ld a, TRUE
+ ld [wEvolutionCanceled], a
+
+ ld a, [wEvolutionOldSpecies]
+ jr .return
+
+.GetSGBLayout:
+ ld b, SCGB_EVOLUTION
+ jp GetSGBLayout
+
+.PlaceFrontpic:
+ call GetBaseData
+ hlcoord 7, 2
+ jp PrepMonFrontpic
+
+.Flash:
+ ld a, 7 * 7 ; previous stage
+ ld [wEvolutionPicOffset], a
+ call .ReplaceFrontpic
+ ld a, -7 * 7 ; new stage
+ ld [wEvolutionPicOffset], a
+ call .ReplaceFrontpic
+ dec b
+ jr nz, .Flash
+ ret
+
+.ReplaceFrontpic:
+ push bc
+ xor a
+ ldh [hBGMapMode], a
+ hlcoord 7, 2
+ lb bc, 7, 7
+ ld de, SCREEN_WIDTH - 7
+.loop1
+ push bc
+.loop2
+ ld a, [wEvolutionPicOffset]
+ add [hl]
+ ld [hli], a
+ dec c
+ jr nz, .loop2
+ pop bc
+ add hl, de
+ dec b
+ jr nz, .loop1
+ ld a, $1
+ ldh [hBGMapMode], a
+ call WaitBGMap
+ pop bc
+ ret
+
+.WaitFrames_CheckPressedB:
+ call DelayFrame
+ push bc
+ call JoyTextDelay
+ ldh a, [hJoyDown]
+ pop bc
+ and B_BUTTON
+ jr nz, .pressed_b
+.loop3
+ dec c
+ jr nz, .WaitFrames_CheckPressedB
+ and a
+ ret
+
+.pressed_b
+ ld a, [wForceEvolution]
+ and a
+ jr nz, .loop3
+ scf
+ ret
+
+.PlayEvolvedSFX:
+ ld a, [wEvolutionCanceled]
+ and a
+ ret nz
+ ld de, SFX_EVOLVED
+ call PlaySFX
+ ld hl, wJumptableIndex
+ ld a, [hl]
+ push af
+ ld [hl], $0
+.loop4
+ call .balls_of_light
+ jr nc, .done
+ call .AnimateBallsOfLight
+ jr .loop4
+
+.done
+ ld c, 32
+.loop5
+ call .AnimateBallsOfLight
+ dec c
+ jr nz, .loop5
+ pop af
+ ld [wJumptableIndex], a
+ ret
+
+.balls_of_light
+ ld hl, wJumptableIndex
+ ld a, [hl]
+ cp 32
+ ret nc
+ ld d, a
+ inc [hl]
+ and $1
+ jr nz, .done_balls
+ ld e, $0
+ call .GenerateBallOfLight
+ ld e, $10
+ call .GenerateBallOfLight
+
+.done_balls
+ scf
+ ret
+
+.GenerateBallOfLight:
+ push de
+ depixel 9, 11
+ ld a, SPRITE_ANIM_INDEX_EVOLUTION_BALL_OF_LIGHT
+ call InitSpriteAnimStruct
+ ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
+ add hl, bc
+ ld a, [wJumptableIndex]
+ and %1110
+ sla a
+ pop de
+ add e
+ ld [hl], a
+ ld hl, SPRITEANIMSTRUCT_TILE_ID
+ add hl, bc
+ ld [hl], $0
+ ld hl, SPRITEANIMSTRUCT_0C
+ add hl, bc
+ ld [hl], $10
+ ret
+
+.AnimateBallsOfLight:
+ push bc
+ callfar PlaySpriteAnimations
+ ; a = (([hVBlankCounter] + 4) / 2) % NUM_PALETTES
+ ldh a, [hVBlankCounter]
+ and %1110
+ srl a
+ inc a
+ inc a
+ and $7
+ ld b, a
+ ld hl, wVirtualOAMSprite00Attributes
+ ld c, NUM_SPRITE_OAM_STRUCTS
+.loop6
+ ld a, [hl]
+ or b
+ ld [hli], a ; attributes
+rept SPRITEOAMSTRUCT_LENGTH - 1
+ inc hl
+endr
+ dec c
+ jr nz, .loop6
+ pop bc
+ call DelayFrame
+ ret
+
+.GFX:
+INCBIN "gfx/evo/bubble_large.2bpp"
+INCBIN "gfx/evo/bubble.2bpp"
diff --git a/engine/movie/intro.asm b/engine/movie/intro.asm
index 1f3630ee..5e6af7a8 100644
--- a/engine/movie/intro.asm
+++ b/engine/movie/intro.asm
@@ -1,4 +1,4 @@
-Copyright_GFPresents:
+Copyright_GameFreakPresents:
; Play the copyright screen and GameFreak Presents sequence.
; Return carry if user cancels animation by pressing a button.
@@ -36,7 +36,7 @@ Copyright_GFPresents:
bit 6, a
jr nz, .canceled
-; clear carry flag from GFPresents_PlayFrame
+; clear carry flag from GameFreakPresents_PlayFrame
and a
ret
@@ -47,14 +47,14 @@ Copyright_GFPresents:
.GetGFLogoGFX:
; Load gfx and initialize variables
- ld de, GFPresentsGFX1
+ ld de, GameFreakPresentsGFX1
ld hl, vTiles1
- lb bc, BANK(GFPresentsGFX1), 28
+ lb bc, BANK(GameFreakPresentsGFX1), 28
call Get1bpp
- ld de, GFPresentsGFX2
+ ld de, GameFreakPresentsGFX2
ld hl, vTiles1 tile 28
- lb bc, BANK(GFPresentsGFX2), 5
+ lb bc, BANK(GameFreakPresentsGFX2), 5
call Request2bpp
farcall ClearSpriteAnims
@@ -79,7 +79,7 @@ Copyright_GFPresents:
ret
.PlayFrame:
-; Play one frame of GFPresents sequence.
+; Play one frame of GameFreakPresents sequence.
; Return carry when the sequence completes or is canceled.
call JoyTextDelay
@@ -95,7 +95,7 @@ Copyright_GFPresents:
farcall PlaySpriteAnimations
- call GFPresentsJumper
+ call PlaceGameFreakPresents
call DelayFrame
; ensure carry is cleared
@@ -118,18 +118,18 @@ Copyright_GFPresents:
scf
ret
-GFPresentsJumper:
+PlaceGameFreakPresents:
jumptable .scenes, wJumptableIndex
.scenes
- dw GFPresents_Star
- dw GFPresents_PlaceLogo
- dw GFPresents_LogoSparkles
- dw GFPresents_PlacePresents
- dw GFPresents_WaitForTimer
- dw GFPresents_SetDoneFlag
-
-GFPresents_NextScene:
+ dw GameFreakPresents_Star
+ dw GameFreakPresents_PlaceLogo
+ dw GameFreakPresents_LogoSparkles
+ dw GameFreakPresents_PlacePresents
+ dw GameFreakPresents_WaitForTimer
+ dw GameFreakPresents_SetDoneFlag
+
+GameFreakPresents_NextScene:
ld hl, wJumptableIndex
inc [hl]
ret
@@ -137,11 +137,11 @@ GFPresents_NextScene:
Unreferenced_Functione4a8d:
ld c, 64
call DelayFrames
- call GFPresents_NextScene
+ call GameFreakPresents_NextScene
ret
-GFPresents_Star:
-; tell GFPresents_PlaceLogo we haven't finished yet
+GameFreakPresents_Star:
+; tell GameFreakPresents_PlaceLogo we haven't finished yet
xor a
ld [wIntroSceneFrameCounter], a
@@ -156,10 +156,10 @@ GFPresents_Star:
ld de, SFX_GAME_FREAK_LOGO_GS
call PlaySFX
- call GFPresents_NextScene
+ call GameFreakPresents_NextScene
ret
-GFPresents_PlaceLogo:
+GameFreakPresents_PlaceLogo:
; Draw the Game Freak logo (may be initially invisible due to palette)
; wait until the star animation completed
@@ -172,14 +172,14 @@ GFPresents_PlaceLogo:
ld a, SPRITE_ANIM_INDEX_GAMEFREAK_LOGO
call InitSpriteAnimStruct
- call GFPresents_NextScene
+ call GameFreakPresents_NextScene
-; set timer for GFPresents_LogoSparkles
+; set timer for GameFreakPresents_LogoSparkles
ld a, $80
ld [wIntroSceneTimer], a
ret
-GFPresents_LogoSparkles:
+GameFreakPresents_LogoSparkles:
ld hl, wIntroSceneTimer
ld a, [hl]
and a
@@ -188,19 +188,19 @@ GFPresents_LogoSparkles:
; add first text when timer passes half
cp $3f
- call z, GFPresents_PlaceGameFreak
+ call z, GameFreakPresents_PlaceGameFreak
; add sparkles continuously
- call GFPresents_Sparkle
+ call GameFreakPresents_Sparkle
ret
.done
-; set timer for GFPresents_PlacePresents
+; set timer for GameFreakPresents_PlacePresents
ld [hl], $80
- call GFPresents_NextScene
+ call GameFreakPresents_NextScene
ret
-GFPresents_PlaceGameFreak:
+GameFreakPresents_PlaceGameFreak:
hlcoord 5, 12
ld de, .game_freak
call PlaceString
@@ -210,14 +210,14 @@ GFPresents_PlaceGameFreak:
db $80, $81, $82, $83, $8d, $84, $85, $83, $81, $86
db "@"
-GFPresents_PlacePresents:
+GameFreakPresents_PlacePresents:
hlcoord 7, 13
ld de, .presents
call PlaceString
- call GFPresents_NextScene
+ call GameFreakPresents_NextScene
-; set timer for GFPresents_WaitForTimer
+; set timer for GameFreakPresents_WaitForTimer
ld a, $80
ld [wIntroSceneTimer], a
ret
@@ -226,14 +226,14 @@ GFPresents_PlacePresents:
db $87, $88, $89, $8a, $8b, $8c
db "@"
-GFPresents_SetDoneFlag:
-; Tell GFPresents_PlayFrame and TitleScreenFrame that we're finished.
+GameFreakPresents_SetDoneFlag:
+; Tell GameFreakPresents_PlayFrame and TitleScreenFrame that we're finished.
ld hl, wJumptableIndex
set 7, [hl]
ret
-GFPresents_WaitForTimer:
+GameFreakPresents_WaitForTimer:
ld hl, wIntroSceneTimer
ld a, [hl]
and a
@@ -241,12 +241,12 @@ GFPresents_WaitForTimer:
dec [hl]
ret
.done
- call GFPresents_NextScene
+ call GameFreakPresents_NextScene
ret
-GFPresents_UpdateLogoPal:
+GameFreakPresents_UpdateLogoPal:
; called from DoAnimFrame.GameFreakLogo
-; OBP1 was initialized at end of GFPresents_Init
+; OBP1 was initialized at end of GameFreakPresents_Init
; once we reached the final state, leave it alone
ldh a, [rOBP1]
@@ -267,7 +267,7 @@ GFPresents_UpdateLogoPal:
call DmgToCgbObjPal1
ret
-GFPresents_Sparkle:
+GameFreakPresents_Sparkle:
; Initialize and configure a sparkle sprite.
; run only every second frame
@@ -333,11 +333,11 @@ GFPresents_Sparkle:
db $34, $02
db $3c, $04
-GFPresentsGFX1:
+GameFreakPresentsGFX1:
INCBIN "gfx/intro/gamefreak_presents.1bpp"
INCBIN "gfx/intro/gamefreak_logo.1bpp"
-GFPresentsGFX2:
+GameFreakPresentsGFX2:
INCBIN "gfx/intro/logo_star.2bpp"
INCBIN "gfx/intro/logo_sparkle.2bpp"
@@ -641,7 +641,7 @@ Functione4ec1:
call Intro_InitLapras
depixel 28, 28, 4, 4
call DmgToCgbObjPals
-; fall through
+; fallthrough
Functione4eca:
call Functione4fde
@@ -1174,7 +1174,7 @@ IntroScene11:
inc [hl]
xor a
ld [wIntroFrameCounter1], a
-; fall through
+; fallthrough
IntroScene12:
; load Charizard palettes
@@ -1245,7 +1245,7 @@ IntroScene14:
ld [wIntroFrameCounter2], a
ld de, SFX_GS_INTRO_CHARIZARD_FIREBALL
call PlaySFX
-; fall through
+; fallthrough
IntroScene15:
; Charizard mouth wide open / fireball starts
diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm
index 7e7750a9..e52ceac0 100644
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -2318,7 +2318,7 @@ Script_warpfacing:
set PLAYERSPRITESETUP_CUSTOM_FACING_F, a
or c
ld [wPlayerSpriteSetupFlags], a
-; fall through
+; fallthrough
Script_warp:
; script command 0x3c
diff --git a/engine/phone/phone.asm b/engine/phone/phone.asm
index 67f1fe0f..7b41f4d3 100644
--- a/engine/phone/phone.asm
+++ b/engine/phone/phone.asm
@@ -455,7 +455,7 @@ LoadElmCallScript:
RingTwice_StartCall:
call .Ring
-; fall through (rings a second time)
+; fallthrough (rings a second time)
.Ring:
call Phone_StartRinging
call Phone_Wait20Frames
@@ -480,7 +480,7 @@ PhoneCall::
ld a, d
ld [wPhoneCaller + 1], a
call Phone_Ring
-; fall through (rings a second time)
+; fallthrough (rings a second time)
Phone_Ring:
call Phone_StartRinging
call Phone_Wait20Frames
diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm
index fa610df1..8be4e96c 100644
--- a/engine/pokemon/bills_pc.asm
+++ b/engine/pokemon/bills_pc.asm
@@ -1633,7 +1633,7 @@ BillsPC_IsMonAnEgg:
BillsPC_StatsScreen:
call LowVolume
call BillsPC_CopyMon
- ld a, 3
+ ld a, TEMPMON
ld [wMonType], a
predef StatsScreenInit
call BillsPC_InitGFX
diff --git a/engine/pokemon/bills_pc_top.asm b/engine/pokemon/bills_pc_top.asm
index 0975c750..64b328cb 100644
--- a/engine/pokemon/bills_pc_top.asm
+++ b/engine/pokemon/bills_pc_top.asm
@@ -209,11 +209,11 @@ BillsPC_WithdrawMenu:
Unreferenced_Functione548:
ld a, [wPartyCount]
cp PARTY_LENGTH
- jr nc, .asm_e551
+ jr nc, .party_full
and a
ret
-.asm_e551
+.party_full
ld hl, PCCantTakeText
call MenuTextboxBackup
scf
diff --git a/engine/pokemon/caught_nickname.asm b/engine/pokemon/caught_nickname.asm
index 408e284a..562702c9 100644
--- a/engine/pokemon/caught_nickname.asm
+++ b/engine/pokemon/caught_nickname.asm
@@ -1,5 +1,5 @@
CheckPartyFullAfterContest:
- ld a, [wContestMon]
+ ld a, [wContestMonSpecies]
and a
jp z, .DidntCatchAnything
ld [wCurPartySpecies], a
@@ -14,7 +14,7 @@ CheckPartyFullAfterContest:
ld c, a
ld b, 0
add hl, bc
- ld a, [wContestMon]
+ ld a, [wContestMonSpecies]
ld [hli], a
ld [wCurSpecies], a
ld a, -1
@@ -65,7 +65,7 @@ CheckPartyFullAfterContest:
call CopyBytes
xor a
ld [wContestMonSpecies], a
- and a
+ and a ; BUGCONTEST_CAUGHT_MON
ld [wScriptVar], a
ret
diff --git a/engine/pokemon/evolve.asm b/engine/pokemon/evolve.asm
index 5c6d68b0..e538a040 100644
--- a/engine/pokemon/evolve.asm
+++ b/engine/pokemon/evolve.asm
@@ -241,15 +241,15 @@ EvolveAfterBattle_MasterLoop:
push hl
ld hl, EvolvedIntoText
call PrintTextboxText
- push de
+ push de
ld de, MUSIC_NONE
call PlayMusic
ld de, SFX_CAUGHT_MON
call PlaySFX
call WaitSFX
-
pop de
+
ld c, 40
call DelayFrames
@@ -601,288 +601,7 @@ EvoFlagAction:
pop de
ret
-EvolutionAnimation:
- push hl
- push de
- push bc
- ld a, [wCurSpecies]
- push af
- ldh a, [rOBP0]
- push af
- ld a, %11100100
- ldh [rOBP0], a
-
- ld de, MUSIC_NONE
- call PlayMusic
-
- callfar ClearSpriteAnims
-
- ld de, .GFX
- ld hl, vTiles0
- lb bc, BANK(.GFX), 8
- call Request2bpp
- xor a
- ld [wLowHealthAlarm], a
-
- ld a, 1
- ldh [hBGMapMode], a
-
- call WaitBGMap
- xor a
- ldh [hBGMapMode], a
-
- ld a, [wEvolutionOldSpecies]
- ld [wPlayerHPPal], a
- ld c, 0
- call .GetSGBLayout
-
- ld a, [wEvolutionNewSpecies]
- ld [wCurPartySpecies], a
- ld [wCurSpecies], a
- call .PlaceFrontpic
-
- ld de, vTiles2
- ld hl, vTiles2 tile $31
- ld bc, 7 * 7
- call Request2bpp
-
- ld a, [wEvolutionOldSpecies]
- ld [wCurPartySpecies], a
- ld [wCurSpecies], a
- call .PlaceFrontpic
-
- ld a, 1
- ldh [hBGMapMode], a
-
- ld a, [wEvolutionOldSpecies]
- call PlayMonCry
-
- ld de, MUSIC_EVOLUTION
- call PlayMusic
-
- ld c, 80
- call DelayFrames
-
- ld c, 1
- call .GetSGBLayout
-
-.AnimationSequence:
- call ClearJoypad
- lb bc, 1, 16 ; flash b times, wait c frames in between
-.loop
- push bc
- call .WaitFrames_CheckPressedB
- jr c, .cancel
- call .Flash
- pop bc
- inc b
- dec c
- dec c
- jr nz, .loop
-
- xor a
- ld [wEvolutionCanceled], a
-
- ld a, 49
- ld [wEvolutionPicOffset], a
- call .ReplaceFrontpic
-
- ld a, [wEvolutionNewSpecies]
-.return:
- ld [wPlayerHPPal], a
-
- ld c, 0
- call .GetSGBLayout
- call .PlayEvolvedSFX
-
- callfar ClearSpriteAnims
-
- ld a, [wPlayerHPPal]
- call PlayMonCry
-
- pop af
- ldh [rOBP0], a
- pop af
- ld [wCurSpecies], a
- pop bc
- pop de
- pop hl
-
- ld a, [wEvolutionCanceled]
- and a
- ret z
-
- scf
- ret
-
-.cancel:
- pop bc
- ld a, 1
- ld [wEvolutionCanceled], a
-
- ld a, [wEvolutionOldSpecies]
- jr .return
-
-.GetSGBLayout:
- ld b, SCGB_EVOLUTION
- jp GetSGBLayout
-
-.PlaceFrontpic:
- call GetBaseData
- hlcoord 7, 2
- jp PrepMonFrontpic
-
-.Flash:
- ld a, 7 * 7 ; previous stage
- ld [wEvolutionPicOffset], a
- call .ReplaceFrontpic
- ld a, -7 * 7 ; new stage
- ld [wEvolutionPicOffset], a
- call .ReplaceFrontpic
- dec b
- jr nz, .Flash
- ret
-
-.ReplaceFrontpic:
- push bc
- xor a
- ldh [hBGMapMode], a
- hlcoord 7, 2
- lb bc, 7, 7
- ld de, SCREEN_WIDTH - 7
-.loop1
- push bc
-.loop2
- ld a, [wEvolutionPicOffset]
- add [hl]
- ld [hli], a
- dec c
- jr nz, .loop2
- pop bc
- add hl, de
- dec b
- jr nz, .loop1
- ld a, $1
- ldh [hBGMapMode], a
- call WaitBGMap
- pop bc
- ret
-
-.WaitFrames_CheckPressedB:
- call DelayFrame
- push bc
- call JoyTextDelay
- ldh a, [hJoyDown]
- pop bc
- and B_BUTTON
- jr nz, .pressed_b
-.loop3
- dec c
- jr nz, .WaitFrames_CheckPressedB
- and a
- ret
-
-.pressed_b
- ld a, [wForceEvolution]
- and a
- jr nz, .loop3
- scf
- ret
-
-.PlayEvolvedSFX:
- ld a, [wEvolutionCanceled]
- and a
- ret nz
- ld de, SFX_EVOLVED
- call PlaySFX
- ld hl, wJumptableIndex
- ld a, [hl]
- push af
- ld [hl], $0
-.loop4
- call .balls_of_light
- jr nc, .done
- call .AnimateBallsOfLight
- jr .loop4
-
-.done
- ld c, 32
-.loop5
- call .AnimateBallsOfLight
- dec c
- jr nz, .loop5
- pop af
- ld [wJumptableIndex], a
- ret
-
-.balls_of_light
- ld hl, wJumptableIndex
- ld a, [hl]
- cp 32
- ret nc
- ld d, a
- inc [hl]
- and $1
- jr nz, .done_balls
- ld e, $0
- call .GenerateBallOfLight
- ld e, $10
- call .GenerateBallOfLight
-
-.done_balls
- scf
- ret
-
-.GenerateBallOfLight:
- push de
- depixel 9, 11
- ld a, SPRITE_ANIM_INDEX_EVOLUTION_BALL_OF_LIGHT
- call InitSpriteAnimStruct
- ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
- add hl, bc
- ld a, [wJumptableIndex]
- and %1110
- sla a
- pop de
- add e
- ld [hl], a
- ld hl, SPRITEANIMSTRUCT_TILE_ID
- add hl, bc
- ld [hl], $0
- ld hl, SPRITEANIMSTRUCT_0C
- add hl, bc
- ld [hl], $10
- ret
-
-.AnimateBallsOfLight:
- push bc
- callfar PlaySpriteAnimations
- ; a = (([hVBlankCounter] + 4) / 2) % NUM_PALETTES
- ldh a, [hVBlankCounter]
- and %1110
- srl a
- inc a
- inc a
- and $7
- ld b, a
- ld hl, wVirtualOAMSprite00Attributes
- ld c, NUM_SPRITE_OAM_STRUCTS
-.loop6
- ld a, [hl]
- or b
- ld [hli], a ; attributes
-rept SPRITEOAMSTRUCT_LENGTH - 1
- inc hl
-endr
- dec c
- jr nz, .loop6
- pop bc
- call DelayFrame
- ret
-
-.GFX:
-INCBIN "gfx/evo/bubble_large.2bpp"
-INCBIN "gfx/evo/bubble.2bpp"
+INCLUDE "engine/movie/evolution_animation.asm"
GetPreEvolution:
; Find the first mon to evolve into wCurPartySpecies.
diff --git a/engine/pokemon/mon_stats.asm b/engine/pokemon/mon_stats.asm
index 04285f87..3ed26a2d 100644
--- a/engine/pokemon/mon_stats.asm
+++ b/engine/pokemon/mon_stats.asm
@@ -1,9 +1,9 @@
DrawPlayerHP:
- ld a, 1
+ ld a, $1
jr DrawHP
DrawEnemyHP:
- ld a, 2
+ ld a, $2
DrawHP:
ld [wWhichHPBar], a
diff --git a/engine/pokemon/stats_screen.asm b/engine/pokemon/stats_screen.asm
index a2345f37..457d43fc 100644
--- a/engine/pokemon/stats_screen.asm
+++ b/engine/pokemon/stats_screen.asm
@@ -2,6 +2,9 @@
const PINK_PAGE ; 1
const GREEN_PAGE ; 2
const BLUE_PAGE ; 3
+NUM_STAT_PAGES EQU const_value - 1
+
+STAT_PAGE_MASK EQU %00000011
StatsScreenInit:
ldh a, [hMapAnims]
@@ -9,7 +12,7 @@ StatsScreenInit:
xor a
ldh [hMapAnims], a ; disable overworld tile animations
- ld c, 1
+ ld c, PINK_PAGE ; first_page
call StatsScreenMain
; restore old values
@@ -59,10 +62,8 @@ StatsScreen_LoadPage:
push bc
ld de, .done_loading
push de
-; first jump to LoadPage function in jumptable
jp hl
-; return here after LoadPage function finishes
.done_loading
pop bc
ld b, 1
@@ -102,7 +103,7 @@ StatsScreen_LoadPage:
bit D_UP_F, a
jr nz, .d_up
-; .d_down
+; down
ld a, [wMonType]
cp BOXMON
jr nc, .joypad_loop
@@ -139,7 +140,6 @@ StatsScreen_LoadPage:
ld a, b
inc a
ld [wPartyMenuCursor], a
-; fall through
.load_mon
jp StatsScreenMain
@@ -160,7 +160,7 @@ StatsScreen_LoadPage:
dec c
jr nz, StatsScreen_JumpToLoadPageFunction
ld c, BLUE_PAGE ; last page
-; fall through
+; fallthrough
StatsScreen_JumpToLoadPageFunction:
ld hl, StatsScreen_LoadPageJumptable
@@ -179,14 +179,13 @@ EggStatsInit:
push bc
call EggStatsScreen
pop bc
-; fall through
+; fallthrough
EggStats_JoypadLoop:
call GetJoypad
ld a, [wMonType]
cp TEMPMON
jr nz, .not_tempmon
-; .tempmon
push hl
push de
push bc
@@ -256,7 +255,7 @@ EggStats_UpAction:
ld a, b
inc a
ld [wPartyMenuCursor], a
-; fall through
+; fallthrough
EggStats_ScrollToLoadMon:
jp StatsScreenMain
@@ -357,7 +356,7 @@ LoadPinkPage:
lb bc, 10, 20
call ClearBox
hlcoord 0, 9
- ld b, 0
+ ld b, $0
call DrawPlayerHP
hlcoord 8, 9
ld [hl], $41 ; right HP/exp bar end cap
@@ -694,10 +693,10 @@ LoadBluePage:
; remove left padding if name was 8-10 chars (somehow?)
ld a, NAME_LENGTH - 1
sub c
- cp 3 ; NAME_LENGTH - PLAYER_NAME_LENGTH
+ cp NAME_LENGTH - PLAYER_NAME_LENGTH
; otherwise, use 2 spaces of left padding
jr c, .ok
- ld a, 2 ; NAME_LENGTH - PLAYER_NAME_LENGTH - 1
+ ld a, NAME_LENGTH - PLAYER_NAME_LENGTH - 1
.ok
ld c, a
hlcoord 0, 13
diff --git a/engine/pokemon/types.asm b/engine/pokemon/types.asm
index 3c9d28cd..d546dbca 100644
--- a/engine/pokemon/types.asm
+++ b/engine/pokemon/types.asm
@@ -19,7 +19,7 @@ PrintMonTypes:
pop hl
jr z, .hide_type_2
- ld bc, $28
+ ld bc, SCREEN_WIDTH * 2
add hl, bc
.Print: