summaryrefslogtreecommitdiff
path: root/VP-textwork.lua
diff options
context:
space:
mode:
Diffstat (limited to 'VP-textwork.lua')
-rw-r--r--VP-textwork.lua65
1 files changed, 56 insertions, 9 deletions
diff --git a/VP-textwork.lua b/VP-textwork.lua
index 2d3f56c..c3312f7 100644
--- a/VP-textwork.lua
+++ b/VP-textwork.lua
@@ -1,3 +1,9 @@
+function get_next_char(script)
+ local c = script:readU8()
+ if c >= 0x80 then c = (c - 0x80) + (script:readU8() * 128) end
+ return c
+end
+
function get_next_utf8(str)
local ret = ""
local n
@@ -34,6 +40,8 @@ function dump_special(script, code)
return "\n", "\n"
elseif code == 1 then
return "\n<new/>\n", "\n"
+ elseif code == 2 then
+ return "<pause>", ""
elseif code == 3 then
local speed = script:readU8()
if speed == 255 then
@@ -41,6 +49,8 @@ function dump_special(script, code)
else
return '<st spd="' .. speed .. '"/>', ""
end
+ elseif code == 4 then
+ return '<st clr="' .. script:readU8() .. '"/>', ""
elseif code == 5 then
return '<start/>', ""
elseif code == 7 then
@@ -57,6 +67,21 @@ function dump_special(script, code)
else
return '<st siz="' .. siz ..'"/>', ""
end
+ elseif code == 14 then
+ return '<var n="' .. script:readU8() .. '"/>', ""
+ elseif code == 17 then
+ local t, u
+ t = script:readU8()
+ u = script:readU8()
+ if u == 0 then
+ return '<delay0 t="' .. t .. '"/>', ""
+ elseif u == 1 then
+ return '<delay1 t="' .. t .. '"/>', ""
+ else
+ return '<delay t="' .. t .. '" u="' .. u .. '"/>', ""
+ end
+ elseif code == 18 then
+ return "<ssync/>", ""
elseif code == 19 then
local arg1, arg2
arg1 = script:readU8()
@@ -66,16 +91,35 @@ function dump_special(script, code)
else
return '<port a1="' .. arg1 .. '" a2="' .. arg2 .. '"/>', ""
end
- elseif code == 14 then
- return '<var n="' .. script:readU8() .. '"/>', ""
- elseif code == 4 then
- return '<st clr="' .. script:readU8() .. '"/>', ""
else
local a1, a2
if code == 3 or code == 4 or code == 7 or code == 8 or code == 14 then
a1 = script:readU8()
return '<u1 c="' .. code .. '" a="' .. a1 .. '"/>', ""
- elseif code == 6 or code == 12 or code == 17 or code == 19 then
+ elseif code == 6 or code == 12 or code == 19 then
+ a1 = script:readU8()
+ a2 = script:readU8()
+ return '<u2 c="' .. code .. '" a1="' .. a1 .. '" a2="' .. a2 .. '"/>', ""
+ else
+ return '<uk c="' .. code .. '"/>', ""
+ end
+ end
+ error "Should not end up there"
+end
+
+function dump_special2(script, code)
+ if code == 0 then
+ return "\n", "\n"
+ elseif code == 1 then
+ return "\n<new/>\n", "\n"
+ elseif code == 2 then
+ return "<pause>", ""
+ else
+ local a1, a2
+ if code == 3 or code == 5 or code == 7 or code == 8 or code == 9 or code == 12 or code == 13 or code == 14 or code == 15 or code == 21 then
+ a1 = script:readU8()
+ return '<u1 c="' .. code .. '" a="' .. a1 .. '"/>', ""
+ elseif code == 20 then
a1 = script:readU8()
a2 = script:readU8()
return '<u2 c="' .. code .. '" a1="' .. a1 .. '" a2="' .. a2 .. '"/>', ""
@@ -87,13 +131,16 @@ function dump_special(script, code)
end
function extract_char(script, lookup)
- local
- c = script:readU8()
+ local c = get_next_char(script)
if c == 0 then return nil end
- if c >= 0x80 then c = (c - 0x80) + (script:readU8() * 128) end
if c >= 0x4000 then
- return dump_special(script, c - 0x4000)
+ local code = c - 0x4000
+ if second_style_script then
+ return dump_special2(script, code)
+ else
+ return dump_special(script, code)
+ end
else
local l = lookup[c]
if not l and not sloppy_extract then error("Lookup failed for character " .. c) end