
: "justentered"
set "spr250_refx" to 20
set "spr250_refy" to 0
set "spr250_overlay" to 1
set "spr250_static" to 1
set "spr250_vlayer" to 0
end
: "event"
set "textbox" to 1
set "$t" to ""
if "p0" = 1 then "#add_a"
if "p1" = 1 then "#add_b"
if "p2" = 1 then "#add_c"
set "&$event&_&$t&.txt" to "fread_open"
if "fread_pos" = -1 then "fail_1"
goto "continue"
: "continue"
set "$narr" to "fread(512*1024)"
set "" to "fread_open"
loop start
goto "#arep('$narr.&loopcount&')"
loop "('$narr.length'-1)"
goto "play"
: "#arep35"
: "#arep36"
: "#arep37"
: "#arep38"
: "#arep40"
: "#arep41"
: "#arep42"
: "#arep43"
: "#arep60"
: "#arep61"
: "#arep62"
: "#arep64"
: "#arep91"
: "#arep92"
: "#arep93"
: "#arep95"
: "#arep96"
: "#arep123"
: "#arep124"
: "#arep125"
: "#arep126"
: "#arep127"
set "$narr.&loopcount&" 45
goto "#return"

: "fail_1"
set "&$event&_abc.txt" to "fread_open"
if "fread_pos" = -1 then "fail_2"
goto "continue"
: "fail_2"
goto "narrdone"

: "#add_a"
inc "$t" by "a"
goto "#return"
: "#add_b"
inc "$t" by "b"
goto "#return"
: "#add_c"
inc "$t" by "c"
goto "#return"

: "play"
if "$narr.length" = 0 then "narrdone"
loop start
if "$narr.&loopcount&" = 10 then "fff"
if "$narr.&loopcount&" = 13 then "fff"
loop for "('$narr.length'-1)"
: "fff"
set "$txt" to "$narr#&loopcount&"
set "$narr" to "$narr+&loopcount&"
if "$narr.0" = 10 then "#decna"
if "$narr.0" = 13 then "#decna"
if "$narr.0" = 10 then "#decna"
if "$narr.0" = 13 then "#decna"

if "$txt#7" = "Avelia:" then "t_p0"
if "$txt#6" = "Basil:" then "t_p1"
if "$txt#6" = "Celia:" then "t_p2"

set "textbox_r" to 10
set "textbox_g" to 11
set "textbox_b" to 48
set "textbox_font" to 15
goto "tbox"
: "t_p0"
if "p0" = 0 then "play"
set "textbox_r" to 34
set "textbox_g" to 8
set "textbox_b" to 8
set "textbox_font" to 9
goto "tbox"
: "t_p1"
if "p1" = 0 then "play"
set "textbox_r" to 8
set "textbox_g" to 32
set "textbox_b" to 8
set "textbox_font" to 10
goto "tbox"
: "t_p2"
if "p2" = 0 then "play"
set "textbox_r" to 34
set "textbox_g" to 8
set "textbox_b" to 36
set "textbox_font" to 11
goto "tbox"


: "#decna"
if "$narr.length" = 0 then "#return"
if "$narr.length" = 1 then "elim"
set "$narr" to "$narr+1"
goto "#return"
: "#elim"
set "$narr" to ""
goto "#return"
: "narrdone"
set "textbox" to 0
end

: "tbox"
set "local2" to "$txt.length"
set "txtl" to "local2"
if "$txt.length" < 40 then "oneliner"
set "local5" to 30
set "local6" to 1000
set "local8" to 0
: "wrl"
set "lines" to 0
set "local4" to 0
: "wr"
set "local3" to -1
loop start
if "('local4'+'loopcount')" >= "$txt.length" then "fin"
if "$txt.('local4'+'loopcount')" = 32 then "#s"
loop for "local5"
set "$tb&lines&" to "$txt+('local4')#('local3')"
inc "lines" by 1
inc "local4" by "('local3'+1)"
goto "wr"
: "fin"
set "$tb&lines&" to "$txt+('local4')"
inc "lines" by 1

if "(('lines'>6)a('local8'=0))" = 1 then "nvm"
if "lines" > 7 then "nvm"
if "local8" != 0 then "wrd"
set "waste" to 0
loop start
inc "waste" by "('local5'-'$tb&loopcount&.length')"
loop for "('lines'-1)"
inc "$w" by "&waste&"
if "waste" < "local6" then "#leastwaste"

: "nvm"
inc "local5" by 1
if "local5" <= 45 then "wrl"
if "local6" = 1000 then "err"

set "local8" to 1
set "local5" to "local7"
goto "wrl"
: "oneliner"
set "local7" to "$txt.length"
set "$tb0" to "$txt"
set "lines" to 1
goto "wrd"

: "wrd"
set "width" to "local7"
put c0e CustomBlock p26 at 20 0
put c0e CustomBlock p28 at 21 0
put c0e CustomBlock p29 at "(21+'width'+1)" 0
put c0e CustomBlock p2a at "(21+'width'+2)" 0
put c0e CustomBlock p3d at 20 "(1+'lines')"
put c0e CustomBlock p3e at 21 "(1+'lines')"
put c0e CustomBlock p7b at "(21+'width'+1)" "(1+'lines')"
put c0e CustomBlock p7c at "(21+'width'+2)" "(1+'lines')"
loop start
put c0e CustomBlock p7e at "(22+'loopcount')" 0
put c0e CustomBlock p7d at "(22+'loopcount')" "(1+'lines')"
loop for "('width'-1)"
loop start
put c0e CustomBlock p3c at 20 "(1+'loopcount')"
put c0e CustomBlock p60 at 21 "(1+'loopcount')"
put c0e CustomBlock p7f at "(21+'width'+1)" "(1+'loopcount')"
put c0e CustomBlock p2b at "(21+'width'+2)" "(1+'loopcount')"
loop for "('lines'-1)"
loop start
put cee CustomBlock pff at "('loopcount'%'width'+22)" "('loopcount'/'width'+1)"
loop for "('width'*'lines'-1)"
goto "#spr"
set color 14 to "('textbox_r'*2/4)" "('textbox_g'*2/4)" "('textbox_b'*2/4)"
goto "#1"
wait for "(2-'key29')"
set color 14 to "('textbox_r'*3/4)" "('textbox_g'*3/4)" "('textbox_b'*3/4)"
goto "#2"
wait for "(2-'key29')"
set color 14 to "('textbox_r'*4/4)" "('textbox_g'*4/4)" "('textbox_b'*4/4)"
goto "#3"
wait for "(2-'key29')"
loop start
goto "#writeline"
loop for "('lines'-1)"
: "l1"
wait for 1
if "key29" = 1 "l3"
if spacepressed then "l1"
: "l2"
wait for 1
if "key29" = 1 "l3"
if not spacepressed then "l2"
: "l3"
loop start
put cee CustomBlock pff at "('loopcount'%'width'+22)" "('loopcount'/'width'+1)"
loop for "('width'*'lines'-1)"
wait for "(2-'key29')"
set color 14 to "('textbox_r'*3/4)" "('textbox_g'*3/4)" "('textbox_b'*3/4)"
goto "#2"
wait for "(2-'key29')"
set color 14 to "('textbox_r'*2/4)" "('textbox_g'*2/4)" "('textbox_b'*2/4)"
goto "#1"
wait for "(2-'key29')"
set "spr250_off" to 1
goto "play"
end
: "#spr"
set "spr250_width" to "('width'+4)"
set "spr250_height" to "('lines'+2)"
if "tb_centre" = 1 then "tb_centre"
put c?? Sprite "(250)" at "(80-('width'+4)/2)" "(22-'lines')"
goto "#return"
: "tb_centre"
put c?? Sprite "(250)" at "(80-('width'+4)/2)" "(25-('lines'+2)/2)"
goto "#return"


: "#writeline"
set "local2" to "loopcount"
loop start
if "$tb&local2&.&loopcount&" != 32 then "#drawch"
loop for "('$tb&local2&.length'-1)"
set "loopcount" to "local2"
goto "#return"
: "#drawch"
put "('textbox_font'o224)" CustomBlock "$tb&local2&.&loopcount&" at "(22+'loopcount')" "('local2'+1)"
goto "#return"


: "err"
if "local8" = 1 then "WTF"
. "[ \"ERR: LINE TOO LONG\""
set "local8" to 1
set "local5" to "('$txt.length'*2/13)"
. "set \"local5\" to \"('$txt.length'*2/9)\""
set "___C" to "local5"
. "end"
set "local7" to "local5"
goto "wrl"
: "WTF"
[ "WTF"
end

: "#s"
set "local3" to "loopcount"
goto "#return"
: "#leastwaste"
set "local6" to "waste"
set "local7" to "local5"
goto "#return"
: "#1"
char edit '&' to 0 0 0 0 0 0 0 0 0 0 0 0 0 0
char edit '(' to 0 0 0 0 0 0 0 0 0 1 7 15 15 31
char edit ')' to 0 0 0 0 0 0 0 0 0 128 224 240 240 248
char edit '*' to 0 0 0 0 0 0 0 0 0 0 0 0 0 0
char edit '=' to 0 0 0 0 0 0 0 0 0 0 0 0 0 0
char edit '>' to 31 15 15 7 1 0 0 0 0 0 0 0 0 0
char edit '{' to 248 240 240 224 128 0 0 0 0 0 0 0 0 0
char edit '|' to 0 0 0 0 0 0 0 0 0 0 0 0 0 0
char edit '' to 248 248 248 248 248 248 248 248 248 248 248 248 248 248
char edit '+' to 0 0 0 0 0 0 0 0 0 0 0 0 0 0
char edit '<' to 0 0 0 0 0 0 0 0 0 0 0 0 0 0
char edit '`' to 31 31 31 31 31 31 31 31 31 31 31 31 31 31
char edit '~' to 0 0 0 0 0 0 0 0 0 255 255 255 255 255
char edit '}' to 255 255 255 255 255 0 0 0 0 0 0 0 0 0
goto "#return"
: "#2"
char edit '&' to 0 0 0 0 0 0 1 3 3 7 7 7 7 7
char edit '(' to 0 0 0 0 0 127 255 255 255 255 255 255 255 255
char edit ')' to 0 0 0 0 0 254 255 255 255 255 255 255 255 255
char edit '*' to 0 0 0 0 0 0 128 192 192 224 224 224 224 224
char edit '=' to 7 7 7 7 7 3 3 1 0 0 0 0 0 0
char edit '>' to 255 255 255 255 255 255 255 255 127 0 0 0 0 0
char edit '{' to 255 255 255 255 255 255 255 255 254 0 0 0 0 0
char edit '|' to 224 224 224 224 224 192 192 128 0 0 0 0 0 0
char edit '' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit '+' to 224 224 224 224 224 224 224 224 224 224 224 224 224 224
char edit '<' to 7 7 7 7 7 7 7 7 7 7 7 7 7 7
char edit '`' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit '~' to 0 0 0 0 0 255 255 255 255 255 255 255 255 255
char edit '}' to 255 255 255 255 255 255 255 255 255 0 0 0 0 0
goto "#return"
: "#3"
char edit '&' to 15 63 127 127 255 255 255 255 255 255 255 255 255 255
char edit '(' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit ')' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit '*' to 240 252 254 254 255 255 255 255 255 255 255 255 255 255
char edit '=' to 255 255 255 255 255 255 255 255 255 255 127 127 63 15
char edit '>' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit '{' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit '|' to 255 255 255 255 255 255 255 255 255 255 254 254 252 240
char edit '' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit '+' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit '<' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit '`' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit '~' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
char edit '}' to 255 255 255 255 255 255 255 255 255 255 255 255 255 255
goto "#return"
