mirror of
https://github.com/g012/l65.git
synced 2025-01-01 06:30:16 +00:00
Added package searcher for l65 (without module support, not needed).
This commit is contained in:
parent
f0dcdfeaa7
commit
6eeeb656bc
40
l65.lua
40
l65.lua
@ -2462,29 +2462,25 @@ local function Format65(ast)
|
|||||||
return table.concat(out.rope)
|
return table.concat(out.rope)
|
||||||
end
|
end
|
||||||
|
|
||||||
if #arg ~= 2 then
|
local l65searcher = function(name)
|
||||||
print("Invalid arguments, usage:\nl65 source destination")
|
local dirsep = package.config:sub(1,1)
|
||||||
return
|
local filename,err = package.searchpath(name, string.format(".%s?;.%s?.l65", dirsep, dirsep), '.', '.')
|
||||||
|
if not filename then return end
|
||||||
|
local file = io.open(filename, 'rb')
|
||||||
|
if not file then return "failed to open " .. filename .. " for reading" end
|
||||||
|
local src = file:read('*all')
|
||||||
|
file:close()
|
||||||
|
local st, ast = ParseLua(src)
|
||||||
|
if not st then print(ast) return end
|
||||||
|
local bc = assert(load(Format65(ast), filename))
|
||||||
|
return bc, filename
|
||||||
end
|
end
|
||||||
|
table.insert(package.searchers, 2, l65searcher)
|
||||||
|
|
||||||
local inf = io.open(arg[1], 'r')
|
if #arg ~= 1 then
|
||||||
if not inf then
|
print("Invalid arguments, usage:\nl65 <filename>")
|
||||||
print("Failed to open '"..arg[1].."' for reading")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local outf = io.open(arg[2], 'w')
|
local inf,dirsep = arg[1],package.config:sub(1,1)
|
||||||
if not outf then
|
local fn='' for i=#inf,1,-1 do local c=inf:sub(i,i) if c==dirsep or c=='/' then break end fn=c..fn if c=='.' then fn='' end end filename=fn
|
||||||
print("Failed to open '"..arg[2].."' for writing")
|
require(arg[1])
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local sourceText = inf:read('*all')
|
|
||||||
inf:close()
|
|
||||||
local st, ast = ParseLua(sourceText)
|
|
||||||
if not st then
|
|
||||||
print(ast)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
outf:write(Format65(ast))
|
|
||||||
outf:close()
|
|
||||||
|
@ -27,7 +27,6 @@ local wait = function() local l=label() lda INTIM bne l end
|
|||||||
lda#TIM_KERNEL sta T1024T kernel() wait()
|
lda#TIM_KERNEL sta T1024T kernel() wait()
|
||||||
jmp main
|
jmp main
|
||||||
|
|
||||||
local filename=string.match(arg[0], ".-([^\\/]-)%.?[^%.\\/]*$")
|
|
||||||
writebin(filename..'.bin')
|
writebin(filename..'.bin')
|
||||||
writesym(filename..'.sym')
|
writesym(filename..'.sym')
|
||||||
print(stats)
|
print(stats)
|
||||||
|
@ -84,8 +84,6 @@ do
|
|||||||
for k,v in pairs(vcs) do symbols[k] = v end
|
for k,v in pairs(vcs) do symbols[k] = v end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ TODO enable this when lua load() is changed
|
|
||||||
|
|
||||||
mappers = {}
|
mappers = {}
|
||||||
|
|
||||||
mappers['2K'] = function()
|
mappers['2K'] = function()
|
||||||
@ -178,7 +176,7 @@ mappers.F0 = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function bank_stubs2 = function(hotspot0, hotspot1)
|
local bank_stubs2 = function(hotspot0, hotspot1)
|
||||||
function switchrom(i)
|
function switchrom(i)
|
||||||
if i==0 then bit hotspot0
|
if i==0 then bit hotspot0
|
||||||
elseif i==1 then bit hotspot1
|
elseif i==1 then bit hotspot1
|
||||||
@ -193,11 +191,9 @@ local function bank_stubs2 = function(hotspot0, hotspot1)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
mappers.UA = function() bank_stubs2(0x220, 0x240) end
|
mappers.UA = function() bank_stubs2(0x220, 0x240) end
|
||||||
mappers.['0840'] = function() bank_stubs2(0x800, 0x840) end
|
mappers['0840'] = function() bank_stubs2(0x800, 0x840) end
|
||||||
|
|
||||||
mappers['3E'] = function(rom_count, ram_count)
|
mappers['3E'] = function(rom_count, ram_count)
|
||||||
mappers['3F'](rom_count)
|
mappers['3F'](rom_count)
|
||||||
function switchram(i) assert(i>=0 and i<ram_count-1) lda#i sta 0x3E end
|
function switchram(i) assert(i>=0 and i<ram_count-1) lda#i sta 0x3E end
|
||||||
end
|
end
|
||||||
|
|
||||||
]]
|
|
Loading…
Reference in New Issue
Block a user