wait for advancement and advance

This commit is contained in:
Kistaro Windrider 2024-02-10 21:35:34 -08:00
parent e97cfc0fec
commit f37476f148
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -650,17 +650,29 @@ function breather:draw()
end end
end end
function breather:matches(x)
if (not x or not self.on) return true
if (x==1) return self:starting_reverse()
if (x==2) return self:starting_forward()
if (x==3) return self:starting_reverse() or self:starting_forward()
return true
end
function breather:starting_reverse() function breather:starting_reverse()
return self.f + self.speed < self.sep * #self.colors return self.f + self.speed < self.sep * #self.colors
end end
function breather:starting_forward()
return self.f < self.sep * #self.colors
end
def_z_pal = { def_z_pal = {
[0]=0,129,1,2,4,5,6,7,1,5,6,140,2,13,7,7 [0]=0,129,1,2,4,5,6,7,1,5,6,140,2,13,7,7
} }
def_14_fade = split"0,128,129,133,141,13,6,15,135,7" def_14_fade = split"0,0,0,0,0,0,0,0,0,128,129,133,141,13,6,15,7"
def_15_fade = split"0,128,129,133,141,13,13,6,6,15,15,136,135,7" def_15_fade = split"0,0,0,0,0,0,128,129,133,141,13,13,6,6,15,15,7"
def_13_fade = split"0,128,129,133,141,140,140,13,13,12" def_13_fade = split"0,0,0,0,0,0,0,0,0,128,129,133,141,140,140,13,12"
def_shd_fade = split"0,128,130,141,2" def_shd_fade = split"0,0,0,0,0,128,130,141,2"
-- frames per character to wait -- frames per character to wait
-- during zonk text display. -- during zonk text display.
@ -677,7 +689,15 @@ zonk_mode = {
txd=10, txd=10,
--text spring-in frames --text spring-in frames
txf=20, txf=20,
--exit frames
exf=60,
--character wait multiplier
cmul=1,
p=def_z_pal, p=def_z_pal,
fd13 = def_13_fade,
fd14 = def_14_fade,
fd15 = def_15_fade,
fd12 = def_shd_fade,
twt=60, twt=60,
expect_cfg_line=true, expect_cfg_line=true,
@ -689,8 +709,6 @@ zonk_mode = {
mknew(zonk_mode, function(self) mknew(zonk_mode, function(self)
self.stripes=fuzzy_stripey.new{} self.stripes=fuzzy_stripey.new{}
self.brth=breather.new{} self.brth=breather.new{}
-- test renderer
self.brth.on = true
end) end)
function zonk_mode:set(_, field,value) function zonk_mode:set(_, field,value)
@ -703,13 +721,13 @@ function zonk_mode:at(_, x, y)
self.txt_frame=scootbox.new{ self.txt_frame=scootbox.new{
x=x, x=x,
from=y, from=y,
frames=self.exf,
} }
end end
function zonk_mode:activate() function zonk_mode:activate()
clear_alt_pal_bits() clear_alt_pal_bits()
pal() pal()
pal(self.p, 1)
if (type(self.file) == "string") self.file = split(self.file, "\n") if (type(self.file) == "string") self.file = split(self.file, "\n")
if (not self.file) self:next_file() if (not self.file) self:next_file()
assert(self.file) assert(self.file)
@ -764,6 +782,15 @@ function zonk_mode:next_item()
return #token,ret return #token,ret
end end
function zonk_mode:empty()
if (self.file and #self.file > 0) return false
return #self.files == 0
end
function fadetbl(col, tbl, frac)
pal(col,tbl[1+(frac*#tbl)&0x7fff],1)
end
function zonk_mode:update() function zonk_mode:update()
if self.playing_text then if self.playing_text then
self.twt -= 1 self.twt -= 1
@ -775,7 +802,7 @@ function zonk_mode:update()
elseif cn < 0 then elseif cn < 0 then
self.twt = -cn self.twt = -cn
else else
self.twt = cn*fchr self.twt = cn*fchr*self.cmul
end end
if item then if item then
self.txt_frame:push(item) self.txt_frame:push(item)
@ -783,17 +810,65 @@ function zonk_mode:update()
self.playing_text=false self.playing_text=false
end end
end end
else
--waiting to advance or exit
if self.wtmr then
self.twt += self.wait_more
self.wtmr = nil
end
if self.twt <= 0 then
if (btnp(1)) self.confirmed=true
if not self.nextpage and self.confirmed and self.brth:matches(self.bwt) then
self.nextpage = true
self.txt_frame.go = true
self.fpfrm = self.exf
end
else
self.twt -= 1
end
end
if self.nextpage and not self.d then
if self.fpfrm > 0 then
self.fpfrm -= 1
elseif self:empty() then
self.d = ditherer.new{di=0.5}
else
self.nextpage = false
self.confirmed=false
self.txt_frame=blank
self.playing_text=true
end
end end
self.stripes:update() self.stripes:update()
self.brth:update() self.brth:update()
self.txt_frame:update() self.txt_frame:update()
if (self.d and self.d:update()) seq:next()
end end
function zonk_mode:draw() function zonk_mode:draw()
cls(0) cls(0)
pal(self.p, 1)
self.stripes:draw() self.stripes:draw()
self.brth:draw() self.brth:draw()
self.txt_frame:draw() if self.fpfrm then
local ffrac = self.fpfrm/self.exf
fadetbl(12, self.fd12, ffrac)
fadetbl(13, self.fd13, ffrac)
fadetbl(14, self.fd14, ffrac)
fadetbl(15, self.fd15, ffrac)
end
self.txt_frame:draw()
-- TODO: draw throbber
if not self.playing_text and not self.confirmed and self.twt <= 0 then
print("➡️",121,121,12)
print("➡️",120,120,self:throbber_color())
end
if(self.d) self.d:draw()
end
function zonk_mode:throbber_color()
if (not self.bwt) return ((t()<<1)&0x1 < 1) and 7 or 6
return self.brth:matches(self.bwt) and 7 or 6
end end
-->8 -->8