many abbreviations

saves 80 bytes
This commit is contained in:
Kistaro Windrider 2024-02-18 20:11:50 -08:00
parent 15d2ede2f6
commit d1d937e411
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -54,7 +54,7 @@ mknew(event_list, function(x)
x.tail=x x.tail=x
end) end)
function event_list:push_back(x) function event_list:pb(x)
self.tail.next = x self.tail.next = x
self.tail = x self.tail = x
end end
@ -235,7 +235,7 @@ function _update60()
awakener_hold_frames=0 awakener_hold_frames=0
awakener_armed=false awakener_armed=false
mainview = fast_awakener() mainview = fast_awakener()
mainview:activate() mainview:av()
end end
mainview:u() mainview:u()
end end
@ -312,7 +312,7 @@ function txtbox:draw()
print(self.text, self.x, self.y, self.col) print(self.text, self.x, self.y, self.col)
end end
function txtbox:xmax() function txtbox:xm()
return print(self.text, self.x, -9999) return print(self.text, self.x, -9999)
end end
@ -450,7 +450,7 @@ function zonk_txt(s, x, y, p, md, amt, frms)
frames=frms, frames=frms,
v=v, v=v,
} }
itv.eff_w=t1:xmax()-1 itv.eff_w=t1:xm()-1
return itv return itv
end end
@ -639,11 +639,11 @@ function breather:draw()
end end
end end
function breather:matches(x, alwaysmatched) function breather:mt(x, awm)
if (not self.on) return true if (not self.on) return true
if (x==1) return not alwaysmatched and self:starting_reverse() if (x==1) return not awm and self:starting_reverse()
if (x==2) return not alwaysmatched and self:starting_forward() if (x==2) return not awm and self:starting_forward()
if (x==3) return not alwaysmatched and self:starting_reverse() or self:starting_forward() if (x==3) return not awm and self:starting_reverse() or self:starting_forward()
return true return true
end end
@ -693,7 +693,7 @@ zonk_mode = {
twt=60, twt=60,
expect_cfg_line=true, expect_cfg_line=true,
txt_frame=blank, txt_frame=blank,
playing_text=true, px=true,
cx=0, cx=0,
cy=0, cy=0,
} }
@ -708,7 +708,7 @@ mknew(zonk_mode, function(self)
sep=self.br_sep, sep=self.br_sep,
speed=self.br_spd, speed=self.br_spd,
} }
self.alwaysmatched=true self.awm=true
end) end)
function zonk_mode:set(_, field,value) function zonk_mode:set(_, field,value)
@ -752,15 +752,15 @@ function zonk_mode:bgwt(_, w)
self.stripes.weight = w self.stripes.weight = w
end end
function zonk_mode:activate() function zonk_mode:av()
clear_alt_pal_bits() clear_alt_pal_bits()
pal() pal()
font_monogram() font_monogram()
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:nf()
assert(self.file) assert(self.file)
end end
function zonk_mode:next_file() function zonk_mode:nf()
if #self.files > 0 then if #self.files > 0 then
self.file=split(deli(self.files,1), "\n") self.file=split(deli(self.files,1), "\n")
self.expect_cfg_line=true self.expect_cfg_line=true
@ -772,7 +772,7 @@ end
-- return char count, item -- return char count, item
-- or 0, nil: end of page -- or 0, nil: end of page
-- or nil (, nil): end of file -- or nil (, nil): end of file
function zonk_mode:next_item() function zonk_mode:ni()
if not self.line then if not self.line then
if (not self.file or #self.file == 0) return if (not self.file or #self.file == 0) return
local line = deli(self.file, 1) local line = deli(self.file, 1)
@ -785,7 +785,7 @@ function zonk_mode:next_item()
self[frags[1]](self, unpack(frags)) self[frags[1]](self, unpack(frags))
end end
end end
return self:next_item() return self:ni()
end end
if line == "-----" then if line == "-----" then
self.line = nil self.line = nil
@ -800,7 +800,7 @@ function zonk_mode:next_item()
self.line = nil self.line = nil
self.cx = 0 self.cx = 0
self.cy += self.lnh self.cy += self.lnh
return self:next_item() return self:ni()
end end
-- parse token -- parse token
local token = tostr(deli(self.line, 1)) local token = tostr(deli(self.line, 1))
@ -825,7 +825,7 @@ function twmul(s)
return 1 return 1
end end
function zonk_mode:empty() function zonk_mode:ey()
if (self.file and #self.file > 0) return false if (self.file and #self.file > 0) return false
return #self.files == 0 return #self.files == 0
end end
@ -835,16 +835,16 @@ function fadetbl(col, tbl, frac)
end end
function zonk_mode:u() function zonk_mode:u()
if (not self.brth:matches(self.bwt)) self.alwaysmatched=false if (not self.brth:mt(self.bwt)) self.awm=false
if self.playing_text then if self.px then
self.twt -= 1 self.twt -= 1
if self.twt <= 0 then if self.twt <= 0 then
local item, wt = self:next_item() local item, wt = self:ni()
self.confirmed = self.confirmed or self.ac self.cf = self.cf or self.ac
if not item then if not item then
if (not self.file or #self.file == 0) self:next_file() if (not self.file or #self.file == 0) self:nf()
self.playing_text=false self.px=false
if (not self.confirmed) psound(8,8,2) if (not self.cf) psound(8,8,2)
else else
self.txt_frame:push(item) self.txt_frame:push(item)
self.twt = wt*self.cmul self.twt = wt*self.cmul
@ -853,36 +853,32 @@ function zonk_mode:u()
end end
else else
--waiting to advance or exit --waiting to advance or exit
if self.wtmr then
self.twt += self.wait_more
self.wtmr = nil
end
if self.twt <= 0 then if self.twt <= 0 then
local justc=false local justc=false
if (btnp(1) and not self.confirmed) self.confirmed,justc=true,true if (btnp(1) and not self.cf) self.cf,justc=true,true
if not self.nextpage and self.confirmed and self.brth:matches(self.bwt, self.alwaysmatched) then if not self.nxp and self.cf and self.brth:mt(self.bwt, self.awm) then
self.nextpage = true self.nxp = true
self.txt_frame.go = true self.txt_frame.go = true
self.fpfrm = self.exf self.fpfrm = self.exf
self.alwaysmatched=true self.awm=true
if (not self.ac) psound(8, justc and 16 or 18, 8, true) if (not self.ac) psound(8, justc and 16 or 18, 8, true)
end end
if (justc and not self.nextpage) psound(8,16,2, true) if (justc and not self.nxp) psound(8,16,2, true)
else else
self.twt -= 1 self.twt -= 1
end end
end end
if self.nextpage and not self.d then if self.nxp and not self.d then
if self.fpfrm > 0 then if self.fpfrm > 0 then
self.fpfrm -= 1 self.fpfrm -= 1
elseif self:empty() then elseif self:ey() then
self.txt_frame=blank self.txt_frame=blank
self.d = ditherer.new{di=0.5} self.d = ditherer.new{di=0.5}
else else
self.nextpage = false self.nxp = false
self.confirmed=false self.cf=false
self.txt_frame=blank self.txt_frame=blank
self.playing_text=true self.px=true
self.fpfrm=nil self.fpfrm=nil
end end
end end
@ -905,10 +901,10 @@ function zonk_mode:draw()
fadetbl(15, self.fd15, ffrac) fadetbl(15, self.fd15, ffrac)
end end
self.txt_frame:draw() self.txt_frame:draw()
if not self.playing_text and not self.confirmed and self.twt <= 0 then if not self.px and not self.cf and self.twt <= 0 then
font_default() font_default()
print("➡️",121,121,12) print("➡️",121,121,12)
print("➡️",120,120,self.brth:matches(self.bwt) and (hz(2) and 7 or 6) or 5) print("➡️",120,120,self.brth:mt(self.bwt) and (hz(2) and 7 or 6) or 5)
end end
if(self.d) self.d:draw() if(self.d) self.d:draw()
end end
@ -1031,7 +1027,7 @@ function awakener_lock()
arm_awakener() arm_awakener()
return { return {
u=nop, u=nop,
activate=nop, av=nop,
draw=function() draw=function()
pal() pal()
font_default() font_default()
@ -1143,7 +1139,7 @@ end
-- whatever view I want to debug -- whatever view I want to debug
function newtitle() function newtitle()
local ret = title_screen.new() local ret = title_screen.new()
ret:activate() ret:av()
return ret return ret
end end
@ -1155,7 +1151,7 @@ mknew(title_screen, function(t)
wordwait=9999, wordwait=9999,
extra_layer={ extra_layer={
draw=function() draw=function()
t:draw_menu() t:m()
end, end,
u=nop, u=nop,
}, },
@ -1163,8 +1159,8 @@ mknew(title_screen, function(t)
} }
end) end)
function title_screen:activate() function title_screen:av()
self.a:activate() self.a:av()
font_monogram() font_monogram()
end end
@ -1172,7 +1168,7 @@ function title_screen:draw()
self.a:draw() self.a:draw()
end end
function title_screen:draw_menu() function title_screen:m()
font_special() font_special()
print("\^w\^tvACATION", 18, 24, 0) print("\^w\^tvACATION", 18, 24, 0)
print("\^w\^tvACATION", 17, 23, 3) print("\^w\^tvACATION", 17, 23, 3)
@ -1534,7 +1530,7 @@ mknew(arcade_level, function(x)
} }
end) end)
function arcade_level:activate() function arcade_level:av()
-- TODO: fade in level music -- TODO: fade in level music
font_compact() font_compact()
end end
@ -1577,7 +1573,7 @@ function arcade_level:spawn_word()
self.next_break -= 1 self.next_break -= 1
local row = self.pattern[i] local row = self.pattern[i]
self.words:push_back(wordtarget.new{ self.words:pb(wordtarget.new{
y=32*row+irnd(13)-6, y=32*row+irnd(13)-6,
phin=self.phin, phin=self.phin,
on_hit = function(word) on_hit = function(word)
@ -1608,8 +1604,8 @@ end
function arcade_level:word_hit(word) function arcade_level:word_hit(word)
self.score += 1 self.score += 1
-- TODO: sfx -- TODO: sfx
self.bg:push_back(spark.new{x=word.x-1, y=word.y-1, dx=-2}) self.bg:pb(spark.new{x=word.x-1, y=word.y-1, dx=-2})
self.bg:push_back(spark.new{x=word.x+word.w, y=word.y-1, dx=1}) self.bg:pb(spark.new{x=word.x+word.w, y=word.y-1, dx=1})
end end
function arcade_level:draw() function arcade_level:draw()
@ -1624,9 +1620,9 @@ function arcade_level:draw_splash(x, force)
for i=0,n do for i=0,n do
local d = droplet.new{x=x, force=force, y=72+wave(), f=i/n-0.5} local d = droplet.new{x=x, force=force, y=72+wave(), f=i/n-0.5}
if rnd() < 0.5 then if rnd() < 0.5 then
self.bg:push_back(d) self.bg:pb(d)
else else
self.fg:push_back(d) self.fg:pb(d)
end end
end end
end end
@ -1682,7 +1678,7 @@ ggwp = {
} }
mknew(ggwp) mknew(ggwp)
function ggwp:activate() function ggwp:av()
font_monogram() font_monogram()
local score_pct = 100 local score_pct = 100
if seq.max_score ~= 0 then if seq.max_score ~= 0 then
@ -1798,7 +1794,7 @@ function sequencer:next()
else else
mainview = rec.f() mainview = rec.f()
end end
mainview:activate() mainview:av()
mainview:u() mainview:u()
end end