Allowed free positioning of referenced-by-string using charset of CHR data, by delaying evaluation of charset value.

This commit is contained in:
g012 2017-12-23 23:58:42 +01:00
parent 08d1dd99ad
commit 22a89970f8
2 changed files with 3 additions and 4 deletions

View File

@ -658,7 +658,7 @@ M.charset = function(s, f)
if not f then f = function(v) return v end
elseif type(f) == 'number' then f = function(v) return v + f end end
local t,i={},0
for c in s:gmatch'.' do t[c]=f(i) i=i+1 end
for c in s:gmatch'.' do local v=i t[c]=function() return f(v) end i=i+1 end
M.cs=t
return t
end

View File

@ -4,7 +4,7 @@ mappers.NROM()
location(chrrom0)
local font = section{"font", org=chrrom0.start}
local font = section("font")
dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 -- <SPC>
dc.b 0x38,0x38,0x2c,0x64,0x7e,0x46,0xce,0x00,0x38,0x38,0x2c,0x64,0x7e,0x46,0xce,0x00 -- A
dc.b 0xfc,0x62,0x66,0x7c,0x62,0x66,0xfc,0x00,0xfc,0x62,0x66,0x7c,0x62,0x66,0xfc,0x00 -- B
@ -37,8 +37,7 @@ location(prgrom)
@@nmi rti
@@irq rti
local font_start = (font.org - chrrom0.start) // 16
charset(" abcdefghijklmnopqrstuvwxyz", \x(x+font_start))
charset(" abcdefghijklmnopqrstuvwxyz", \x(x + (font.org - font.location.start) // 16))
local hello = "hello world"
@@text byte(hello)