singe/testScripts/scene99.singe
2026-09-22 18:32:07 -05:00

63 lines
2.2 KiB
Text

-- Formats the build reads but no scene had exercised: a JPEG XL picture beside the PNG it was
-- made from (cjxl -d 0, lossless, so the two must match pixel for pixel), and the chiptune and
-- tracker decoders -- game-music-emu's NSF, libxmp's XM, IT and S3M -- each played as music for
-- a while, the NSF as a sound effect as well. The log says what played; the screenshot shows
-- the two crates.
dofile("Singe/Framework.singe")
local font = fontLoad("Singe/FreeSansBold.ttf", 14)
local png = spriteLoad("testScripts/crate.png")
local jxl = spriteLoad("testScripts/crate.jxl")
local tunes = { "testScripts/chip.nsf", "testScripts/tracker.xm", "testScripts/tracker.it", "testScripts/tracker.s3m" }
local effect = soundLoad("testScripts/chip.nsf")
local frames = 0
local at = 0
local music = nil
local said = "none yet"
local TUNE_FRAMES = 60
local pngBig = spriteLoad("testScripts/crate.png")
local jxlBig = spriteLoad("testScripts/crate.jxl")
fontSelect(font)
overlaySetResolution(1024, 576) -- The picture's own size on the offscreen desktop (16:9 in 1024x768), so a screenshot is the overlay pixel for pixel, 96 rows down.
spriteScale(pngBig, 4)
spriteScale(jxlBig, 4)
discPlay()
function onOverlayUpdate()
frames = frames + 1
overlayClear()
spriteDraw(png, 40, 60)
spriteDraw(jxl, 260, 60)
spriteDraw(pngBig, 40, 140)
spriteDraw(jxlBig, 260, 140)
fontPrint(8, 6, "crate.png (left) and crate.jxl (right), lossless: the same picture twice, as loaded and at four times")
fontPrint(8, 24, string.format("music %s playing %s", said, tostring(musicIsPlaying())))
if frames == 10 then
singeScreenshot("formats")
end
if frames == 30 then
soundPlay(effect)
debugPrint("FORMATS sound chip.nsf played")
end
if (frames % TUNE_FRAMES) == 40 then
if music ~= nil then
debugPrint(string.format("FORMATS music %s was playing %s", said, tostring(musicIsPlaying())))
musicStop()
musicUnload(music)
music = nil
end
at = at + 1
if tunes[at] ~= nil then
music = musicLoad(tunes[at])
musicPlay(music, -1)
said = tunes[at]
debugPrint("FORMATS music " .. said .. " loaded and started")
else
singeQuit()
end
end
return OVERLAY_UPDATED
end