mirror of
https://github.com/g012/l65.git
synced 2024-12-29 16:29:15 +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)
|
||||
end
|
||||
|
||||
if #arg ~= 2 then
|
||||
print("Invalid arguments, usage:\nl65 source destination")
|
||||
return
|
||||
local l65searcher = function(name)
|
||||
local dirsep = package.config:sub(1,1)
|
||||
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
|
||||
table.insert(package.searchers, 2, l65searcher)
|
||||
|
||||
local inf = io.open(arg[1], 'r')
|
||||
if not inf then
|
||||
print("Failed to open '"..arg[1].."' for reading")
|
||||
if #arg ~= 1 then
|
||||
print("Invalid arguments, usage:\nl65 <filename>")
|
||||
return
|
||||
end
|
||||
local outf = io.open(arg[2], 'w')
|
||||
if not outf then
|
||||
print("Failed to open '"..arg[2].."' for writing")
|
||||
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()
|
||||
local inf,dirsep = arg[1],package.config:sub(1,1)
|
||||
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
|
||||
require(arg[1])
|
||||
|
@ -27,7 +27,6 @@ local wait = function() local l=label() lda INTIM bne l end
|
||||
lda#TIM_KERNEL sta T1024T kernel() wait()
|
||||
jmp main
|
||||
|
||||
local filename=string.match(arg[0], ".-([^\\/]-)%.?[^%.\\/]*$")
|
||||
writebin(filename..'.bin')
|
||||
writesym(filename..'.sym')
|
||||
print(stats)
|
||||
|
@ -84,8 +84,6 @@ do
|
||||
for k,v in pairs(vcs) do symbols[k] = v end
|
||||
end
|
||||
|
||||
--[[ TODO enable this when lua load() is changed
|
||||
|
||||
mappers = {}
|
||||
|
||||
mappers['2K'] = function()
|
||||
@ -178,7 +176,7 @@ mappers.F0 = function()
|
||||
end
|
||||
end
|
||||
|
||||
local function bank_stubs2 = function(hotspot0, hotspot1)
|
||||
local bank_stubs2 = function(hotspot0, hotspot1)
|
||||
function switchrom(i)
|
||||
if i==0 then bit hotspot0
|
||||
elseif i==1 then bit hotspot1
|
||||
@ -193,11 +191,9 @@ local function bank_stubs2 = function(hotspot0, hotspot1)
|
||||
end
|
||||
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['3F'](rom_count)
|
||||
function switchram(i) assert(i>=0 and i<ram_count-1) lda#i sta 0x3E end
|
||||
end
|
||||
|
||||
]]
|
Loading…
Reference in New Issue
Block a user