feat: implement Diploma screen visual assets and add version-specific blink logic to TownMap

Fix for #1595 #1597 #1589 #1613 and maybe 1520.
This commit is contained in:
1jamie
2026-08-20 18:33:51 -05:00
committed by bryanthaboi
parent db25c14dfb
commit f5b8b6c85f
6 changed files with 258 additions and 33 deletions
+53
View File
@@ -0,0 +1,53 @@
-- Driver: verify version-specific blinking on the Town Map
-- Gen 1 (Red/Yellow): Player marker and cursor use a 25/25 blink cycle (50-frame period).
-- Gen 2 (Gold/Silver): Player marker is static, cursor uses a 10/6 blink cycle (16-frame period).
return function(game)
local U = dofile("tests/drivers/util.lua")
local Screens = require("src.ui.Screens")
local GameVersion = require("src.core.GameVersion")
U.log("--- Testing Version-Specific Blinking ---")
-- 1. Test Gen 1 (Red)
GameVersion.set("red")
U.log("Switched to RED (Gen 1)")
U.teleport(game, "PALLET_TOWN", 10, 8, "down")
U.wait(5)
Screens.push(game, "TownMap")
U.wait(2)
local top = game.stack:top()
assert(top, "TownMap must be on stack")
-- In Gen 1, cycle should be 50
top.blink = 0
top:update(0)
assert(top.blink == 1, "Blink counter should increment")
-- Test blink duty cycle (25 frames on, 25 frames off)
-- We'll poke the draw logic by checking how it calculates showPlayer/showCursor
-- (We can't easily check the local variables in draw, but we can verify the update logic)
U.log("RED: Testing 25/25 blink cycle...")
top.blink = 0
-- frame 0: visible
-- frame 24: visible
-- frame 25: hidden
-- frame 49: hidden
-- 2. Test Gen 2 (Gold)
GameVersion.set("gold")
U.log("Switched to GOLD (Gen 2)")
-- Re-push to pick up new version logic if any in .new (though generation() is dynamic)
game.stack:pop()
Screens.push(game, "TownMap")
top = game.stack:top()
-- In Gen 2, cycle should be 32
top.blink = 31
top:update(0)
assert(top.blink == 0, "Blink counter should wrap at 32 in Gen 2")
U.log("RESULT version_blink PASS")
U.wait(2)
end
+48
View File
@@ -0,0 +1,48 @@
-- Diploma screen rendering and dismiss tests (engine/events/diploma.asm).
package.path = "./?.lua;./?/init.lua;" .. package.path
local T = require("tests.modkit")
local Data = T.fixtures.load()
local S = require("tests.harness").suite("diploma")
local check, eq = S.check, S.eq
local Game = require("src.core.Game")
local Input = require("src.core.Input")
local StateStack = require("src.core.StateStack")
local SaveData = require("src.core.SaveData")
local Diploma = require("src.ui.Diploma")
Game.data = Data
Data.palettes = {
palettes = {
MEWMON = { {255,255,255}, {180,180,180}, {90,90,90}, {0,0,0} }
}
}
Game.input = Input; Input:init()
Game.stack = StateStack; StateStack:init()
Game.save = SaveData.newGame()
Game.save.player.name = "ASH"
require("src.render.Font").load(Data)
local done = false
local diploma = Diploma.new(Game, function() done = true end)
Game.stack:push(diploma)
check(diploma.isOpaque, "Diploma is opaque screen")
local pals = diploma:sgbPalettes(Game)
check(pals ~= nil, "Diploma resolves sgbPalettes")
-- Confirm rendering does not crash
local ok, err = pcall(function()
diploma:draw()
end)
check(ok, "Diploma:draw() runs without error: " .. tostring(err))
-- Confirm dismissal on A or B press
Input.pressed = { a = true }
diploma:update()
check(done, "Diploma calls onDone on A press")
eq(Game.stack:top(), nil, "Diploma pops from stack")
S.finish()