singe/testScripts/scene50.singe
2026-09-13 22:06:39 -05:00

77 lines
4 KiB
Text

-- Hypseus parity, stage 6: subtitles, the banner and the disc picture controls. The disc is
-- searched to a known frame before each subtitle shot, so a cue's timing is read off the disc's
-- own frame number and not off the wall clock; the .srt's timestamps become disc frames at the
-- disc's frame rate when it is loaded.
dofile("Singe/Framework.singe")
local font = fontLoad("Singe/FreeSansBold.ttf", 14)
local frames = 0
local step = 0
local note = "start"
local broken = srtLoad("testScripts/broken.srt") -- No cues in it: false, and nothing loaded.
local good = srtLoad("testScripts/subtitles.srt") -- Four cues over the first twelve seconds.
-- Each step: a name, what to do when it is reached, and the frame to leave the disc on.
local steps = {
{ "cue 1 (frames 0 to 45)", 15, function() srtEnable(true) end },
{ "cue 2, two lines", 90, function() end },
{ "cue 2 at srtPosition(15)", 90, function() srtPosition(15) end },
{ "cue 2 at srtPosition(80)", 90, function() srtPosition(80) end },
{ "cue 3, escaped < and &", 210, function() end },
{ "the gap: no cue", 150, function() end },
{ "cue 4, the last", 300, function() end },
{ "overlayBanner over the cue", 300, function() overlayBanner("A banner, sixty characters or fewer, over the picture.", 30) end },
{ "the banner has timed out", 300, function() end },
{ "srtEnable(false)", 300, function() srtEnable(false) end },
{ "srtEnable(true) again", 300, function() srtEnable(true) end },
{ "srtClear()", 300, function() srtClear() end },
{ "vldpSetLuma(true, 0): half", 300, function() srtEnable(false) vldpSetLuma(true, 0) end },
{ "vldpSetLuma(true, 8): brighter", 300, function() vldpSetLuma(true, 8) end },
{ "vldpSetLuma(true, 4): neutral", 300, function() vldpSetLuma(true, 4) end },
{ "vldpSetLuma(false)", 300, function() vldpSetLuma(false) end },
{ "vldpSetBlend(true)", 300, function() vldpSetBlend(true) end },
{ "vldpSetBlend(false)", 300, function() vldpSetBlend(false) end },
{ "vldpSetLuma(true, 1) and blend", 300, function() vldpSetBlend(true) vldpSetLuma(true, 1) end },
{ "back to the plain picture", 300, function() vldpSetBlend(false) vldpSetLuma(false) end },
-- The blend is a one row smoothing, so it is easiest to see magnified: the same sliver of the
-- picture through vldpFocusArea, without it and then with it.
{ "a magnified sliver, no blend", 300, function() vldpFocusArea(discGetWidth() * 0.42, discGetHeight() * 0.42, 96, 64) end },
{ "the same sliver, blended", 300, function() vldpSetBlend(true) end },
{ "the sliver, blend off again", 300, function() vldpSetBlend(false) end },
{ "vldpResetFocus()", 300, function() vldpResetFocus() end },
}
fontSelect(font)
discSearch(1)
function onOverlayUpdate()
frames = frames + 1
if frames == ((#steps + 1) * 20) + 1 then
note = "vldpFlash()"
vldpFlash()
singeScreenshot()
end
overlayClear()
overlayBox(1, 1, overlayGetWidth() - 2, overlayGetHeight() - 2)
fontPrint(8, 6, string.format("srtLoad broken=%s good=%s disc frame %d", tostring(broken), tostring(good), discGetFrame()))
fontPrint(8, 24, string.format("step %d/%d %s", step, #steps, note))
-- One step every twenty script frames: act on the first, shoot on the tenth, so a banner
-- (thirty drawn frames) is up for one shot and gone by the next.
if (frames % 20) == 1 and step < #steps then
step = step + 1
note = steps[step][1]
discSearch(steps[step][2])
steps[step][3]()
elseif (frames % 20) == 11 then
singeScreenshot()
end
-- The flash lasts one drawn frame, so it is asked for and shot in the same tick. The note is
-- set before the text is drawn, so the shot names what it is showing.
if frames == ((#steps + 1) * 20) + 3 then
note = "the frame after vldpFlash()"
singeScreenshot()
end
if frames == ((#steps + 1) * 20) + 20 then
singeQuit()
end
return OVERLAY_UPDATED
end