mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-10 10:15:26 -04:00
CLOSES #2025, CLOSES #2029, CLOSES #2030, CLOSES #2031, CLOSES #2033, CLOSES #2034, CLOSES #2035, CLOSES #2038, CLOSES #2040, CLOSES #2041, CLOSES #2042, CLOSES #2043, CLOSES #2044, CLOSES #2045, CLOSES #2046, CLOSES #2048, CLOSES #2049, CLOSES #2050, CLOSES #2051, CLOSES #2052, CLOSES #2053, CLOSES #2054
This commit is contained in:
+86
-44
@@ -18,6 +18,12 @@ local romText = require("src.core.RomText")
|
||||
local EvolutionState = {}
|
||||
EvolutionState.__index = EvolutionState
|
||||
|
||||
local PIC_LOAD_FRAMES = 84
|
||||
-- evolution.asm EvolveMon delays 80 frames before .animLoop, polling nothing (#968, #1031)
|
||||
local CANCEL_GRACE_FRAMES = 80
|
||||
local ANIM_LOOP_FRAMES = 288
|
||||
local FLASH_FRAMES = CANCEL_GRACE_FRAMES + ANIM_LOOP_FRAMES
|
||||
|
||||
-- SGB: SetPal_PokemonWholeScreen for the mon on display
|
||||
function EvolutionState:sgbPalettes(game)
|
||||
local P = require("src.render.PaletteFX")
|
||||
@@ -33,7 +39,8 @@ function EvolutionState:sgbPalettes(game)
|
||||
-- every COLORS mode honest for free: OG RED short-circuits every name to the
|
||||
-- one global boot-ROM palette (a Game Boy Color ignores the SGB packets, so
|
||||
-- it never blacks out) and the mono modes replace it in effectiveColors.
|
||||
if not self.done then
|
||||
-- ../pokered/engine/movie/evolution.asm:23-26, :49-50
|
||||
if not self.done and self.t >= CANCEL_GRACE_FRAMES then
|
||||
local black = P.pal(game.data, "BLACK")
|
||||
if black then return { P.whole(black) } end
|
||||
end
|
||||
@@ -46,15 +53,6 @@ function EvolutionState:sgbPalettes(game)
|
||||
return P.wholeNamed(game.data, "MEWMON")
|
||||
end
|
||||
|
||||
-- evolution.asm EvolveMon delays 80 frames before .animLoop, polling nothing (#968, #1031)
|
||||
local CANCEL_GRACE_FRAMES = 80
|
||||
-- .animLoop starts at `lb bc, $1, $10` and runs 8 iterations: iteration k holds
|
||||
-- the old pic for c = 18-2k frames inside Evolution_CheckForCancel (72 in all),
|
||||
-- then Evolution_BackAndForthAnim swaps b = k times, each swap a pair of
|
||||
-- Evolution_ChangeMonPic that end in Delay3 (6 frames a swap, 216 in all).
|
||||
local ANIM_LOOP_FRAMES = 288
|
||||
local FLASH_FRAMES = CANCEL_GRACE_FRAMES + ANIM_LOOP_FRAMES
|
||||
|
||||
-- which pic is on screen t frames into .animLoop
|
||||
local function evoShowsNew(t)
|
||||
for b = 1, 8 do
|
||||
@@ -95,18 +93,74 @@ function EvolutionState.new(game, mon, newSpecies, onDone, via)
|
||||
self.t = 0
|
||||
self.done = false
|
||||
self.canceled = false
|
||||
-- engine/movie/evolution.asm:41-46
|
||||
-- engine/movie/evolution.asm:12-19
|
||||
Music.stop()
|
||||
self.crySrc = require("src.core.Sound").playCry(game.data, mon.species)
|
||||
require("src.core.Sound").play(game.data, "Tink")
|
||||
self.loading = PIC_LOAD_FRAMES
|
||||
self.crySrc = nil
|
||||
self.cryT = 0
|
||||
self.cryWait = self.crySrc ~= nil
|
||||
if not self.cryWait then
|
||||
Music.play(game.data, Music.special(game.data, "evolution"))
|
||||
end
|
||||
self.cryWait = false
|
||||
return self
|
||||
end
|
||||
|
||||
-- engine/movie/evolution.asm:39-46
|
||||
function EvolutionState:beginCry()
|
||||
self.crySrc = require("src.core.Sound").playCry(self.game.data, self.mon.species)
|
||||
self.cryT = 0
|
||||
self.cryWait = self.crySrc ~= nil
|
||||
if not self.cryWait then
|
||||
Music.play(self.game.data, Music.special(self.game.data, "evolution"))
|
||||
end
|
||||
end
|
||||
|
||||
-- engine/movie/evolution.asm:68-74
|
||||
function EvolutionState:beginDoneCry(species)
|
||||
Music.stop()
|
||||
self.endCrySrc = require("src.core.Sound").playCry(self.game.data, species)
|
||||
self.endCryT = 0
|
||||
self.endCryWait = self.endCrySrc ~= nil
|
||||
if not self.endCryWait then self:pushDoneText() end
|
||||
end
|
||||
|
||||
-- engine/pokemon/evos_moves.asm:136-153, :293
|
||||
function EvolutionState:pushDoneText()
|
||||
local game = self.game
|
||||
local TextBox = require("src.render.TextBox")
|
||||
if self.canceled then
|
||||
game.stack:push(TextBox.new(game,
|
||||
romText(game.data, "_StoppedEvolvingText",
|
||||
"Huh? %s\nstopped evolving!", self.oldName),
|
||||
function()
|
||||
Music.restoreMap(game.data)
|
||||
game.stack:pop()
|
||||
if self.onDone then self.onDone() end
|
||||
end))
|
||||
return
|
||||
end
|
||||
local Evolution = require("src.pokemon.Evolution")
|
||||
local newName = game.data.pokemon[self.newSpecies].name
|
||||
-- engine/pokemon/evos_moves.asm:136-153
|
||||
local msg = romText(game.data, "_EvolvedText", "%s evolved", self.oldName)
|
||||
.. romText(game.data, "_IntoText", "\ninto %s!", newName)
|
||||
game.stack:push(TextBox.new(game, msg,
|
||||
function()
|
||||
Music.restoreMap(game.data)
|
||||
game.stack:pop()
|
||||
-- engine/pokemon/evos_moves.asm:212 (#12)
|
||||
Evolution.learnEvolutionMoves(game, self.mon, self.onDone)
|
||||
end,
|
||||
TextBox.soundOpts(game, "Get_Item2")))
|
||||
end
|
||||
|
||||
function EvolutionState:update(dt)
|
||||
-- engine/movie/evolution.asm:20-40
|
||||
if self.loading then
|
||||
self.loading = self.loading - 1
|
||||
if self.loading > 0 then return end
|
||||
self.loading = nil
|
||||
self:beginCry()
|
||||
return
|
||||
end
|
||||
if self.cryWait then
|
||||
self.cryT = self.cryT + 1
|
||||
local src = self.crySrc
|
||||
@@ -117,6 +171,17 @@ function EvolutionState:update(dt)
|
||||
end
|
||||
return
|
||||
end
|
||||
-- home/pokemon.asm:145-149
|
||||
if self.endCryWait then
|
||||
self.endCryT = self.endCryT + 1
|
||||
local src = self.endCrySrc
|
||||
local playing = src and src.isPlaying and src:isPlaying()
|
||||
if self.endCryT >= 3 and (not playing or self.endCryT > 180) then
|
||||
self.endCryWait, self.endCrySrc = false, nil
|
||||
self:pushDoneText()
|
||||
end
|
||||
return
|
||||
end
|
||||
self.t = self.t + 1
|
||||
if self.done then return end
|
||||
local game = self.game
|
||||
@@ -126,40 +191,15 @@ function EvolutionState:update(dt)
|
||||
and game.input:wasPressed("b") then
|
||||
self.done = true
|
||||
self.canceled = true
|
||||
local TextBox = require("src.render.TextBox")
|
||||
game.stack:push(TextBox.new(game,
|
||||
romText(game.data, "_StoppedEvolvingText",
|
||||
"Huh? %s\nstopped evolving!", self.oldName),
|
||||
function()
|
||||
Music.restoreMap(game.data)
|
||||
game.stack:pop() -- the evolution screen itself
|
||||
if self.onDone then self.onDone() end
|
||||
end))
|
||||
-- evolution.asm:89-94
|
||||
self:beginDoneCry(self.mon.species)
|
||||
return
|
||||
end
|
||||
if self.t >= FLASH_FRAMES then
|
||||
self.done = true
|
||||
local Evolution = require("src.pokemon.Evolution")
|
||||
Evolution.apply(game, self.mon, self.newSpecies, self.via)
|
||||
require("src.core.Sound").playCry(game.data, self.newSpecies)
|
||||
local TextBox = require("src.render.TextBox")
|
||||
local newName = game.data.pokemon[self.newSpecies].name
|
||||
-- EvolvedText then IntoText in the same box (PrintText_NoCreatingTextBox),
|
||||
-- then SFX_GET_ITEM_2 (engine/pokemon/evos_moves.asm:136-153)
|
||||
local msg = romText(game.data, "_EvolvedText", "%s evolved", self.oldName)
|
||||
.. romText(game.data, "_IntoText", "\ninto %s!", newName)
|
||||
game.stack:push(TextBox.new(game, msg,
|
||||
function()
|
||||
Music.restoreMap(game.data)
|
||||
game.stack:pop() -- the evolution screen itself
|
||||
-- Gen1 re-runs the level-up learn check on the evolved species
|
||||
-- after the "evolved into" text (evos_moves.asm EvolveMon ->
|
||||
-- learn_move.asm LearnMoveFromLevelUp, #12). Pop the evo screen
|
||||
-- first so the "learned MOVE!" text / forget prompt push onto the
|
||||
-- overworld / battle-return, not this state.
|
||||
Evolution.learnEvolutionMoves(game, self.mon, self.onDone)
|
||||
end,
|
||||
TextBox.soundOpts(game, "Get_Item2")))
|
||||
self:beginDoneCry(self.newSpecies)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -167,6 +207,8 @@ function EvolutionState:draw()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
-- rows 0-11 only (hlcoord 0,0 / lb bc, 12, 20, evos_moves.asm:126-128)
|
||||
love.graphics.rectangle("fill", 0, 0, 160, 96)
|
||||
-- engine/movie/evolution.asm:20-40
|
||||
if self.loading then return end
|
||||
|
||||
-- accelerating flash between the two forms
|
||||
local sprite, spriteTrueColor
|
||||
|
||||
Reference in New Issue
Block a user