diff --git a/vacation.p8 b/vacation.p8 index 6179abf..f095baf 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -650,17 +650,29 @@ function breather:draw() 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() return self.f + self.speed < self.sep * #self.colors end +function breather:starting_forward() + return self.f < self.sep * #self.colors +end + def_z_pal = { [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_15_fade = split"0,128,129,133,141,13,13,6,6,15,15,136,135,7" -def_13_fade = split"0,128,129,133,141,140,140,13,13,12" -def_shd_fade = split"0,128,130,141,2" +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,0,0,0,0,0,128,129,133,141,13,13,6,6,15,15,7" +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,0,0,0,0,128,130,141,2" -- frames per character to wait -- during zonk text display. @@ -677,7 +689,15 @@ zonk_mode = { txd=10, --text spring-in frames txf=20, + --exit frames + exf=60, + --character wait multiplier + cmul=1, p=def_z_pal, + fd13 = def_13_fade, + fd14 = def_14_fade, + fd15 = def_15_fade, + fd12 = def_shd_fade, twt=60, expect_cfg_line=true, @@ -689,8 +709,6 @@ zonk_mode = { mknew(zonk_mode, function(self) self.stripes=fuzzy_stripey.new{} self.brth=breather.new{} - -- test renderer - self.brth.on = true end) function zonk_mode:set(_, field,value) @@ -703,13 +721,13 @@ function zonk_mode:at(_, x, y) self.txt_frame=scootbox.new{ x=x, from=y, + frames=self.exf, } end function zonk_mode:activate() clear_alt_pal_bits() pal() - pal(self.p, 1) if (type(self.file) == "string") self.file = split(self.file, "\n") if (not self.file) self:next_file() assert(self.file) @@ -764,6 +782,15 @@ function zonk_mode:next_item() return #token,ret 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() if self.playing_text then self.twt -= 1 @@ -775,7 +802,7 @@ function zonk_mode:update() elseif cn < 0 then self.twt = -cn else - self.twt = cn*fchr + self.twt = cn*fchr*self.cmul end if item then self.txt_frame:push(item) @@ -783,17 +810,65 @@ function zonk_mode:update() self.playing_text=false 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 self.stripes:update() self.brth:update() self.txt_frame:update() + if (self.d and self.d:update()) seq:next() end function zonk_mode:draw() cls(0) + pal(self.p, 1) self.stripes: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 -->8