mirror of
https://github.com/g012/l65.git
synced 2025-01-01 06:30:16 +00:00
Added dir of l65 to require search paths.
This commit is contained in:
parent
d320960194
commit
ece6974ba6
185
asm.l65
185
asm.l65
@ -1,185 +0,0 @@
|
||||
dofile "vcs.lua"
|
||||
|
||||
TIM_OVERSCAN = 50 -- TIM64T, 3200 cycles = ~ 42 scanlines
|
||||
TIM_VBLANK = 61 -- TIM64T, 3904 cycles = ~ 51 scanlines
|
||||
TIM_KERNEL = 17 -- T1024T, 17408 cycles = ~229 scanlines
|
||||
|
||||
function switchbank(i) bit 0x1ff4+i end
|
||||
-- create bank stubs
|
||||
for bi=0,7,1 do
|
||||
local o=(bi<<12)
|
||||
_ENV['bank' .. bi] = location{0x8000+o, 0x8fff+o, rorg=0xf000}
|
||||
local start=section{"entry"..bi, org=0x8fee+o} switchbank(0) if bi==0 then jmp main end
|
||||
section{"switchtab"..bi, org=0x8ff4+o} byte(0,0,0,0,0,0,0,0)
|
||||
section{"vectors"..bi, org=0x8ffc+o} word(start,start)
|
||||
end
|
||||
|
||||
bank0.name = 'core'
|
||||
location(bank0)
|
||||
|
||||
--location(0x1000)
|
||||
|
||||
--location(0xf000, 0xffff)
|
||||
|
||||
if toto ~= 15 then end
|
||||
|
||||
abc = 13 ~ 0x7
|
||||
xyz = 1 << 2
|
||||
|
||||
x={ f=function() end }
|
||||
x:f()
|
||||
::lualabel::
|
||||
|
||||
#pragma syntax6502 off
|
||||
lda = 5 if lda < 6 then sta=7 end
|
||||
#pragma syntax6502 on
|
||||
|
||||
local function ptr_table(label, ...)
|
||||
local vals = {...}
|
||||
section{label .. "_lo", align=16} byte_lo(vals)
|
||||
section{label .. "_hi", align=16} byte_hi(vals)
|
||||
end
|
||||
|
||||
charset(" abcdefghijklmnopqrstuvwxyz-")
|
||||
@@message2 byte(4, "test", 0)
|
||||
charset()
|
||||
@@message byte(4, "test", 0)
|
||||
|
||||
@@data
|
||||
crosspage
|
||||
byte(1, 2) byte(3, 4)
|
||||
end
|
||||
word(0xf080) byte(16, 3, 4, 5, 6,
|
||||
24, 32)
|
||||
word(message2)
|
||||
byte_lo(message) byte_hi(message)
|
||||
byte(\(message&0xff), \(message>>8))
|
||||
|
||||
ptr_table("ptrs", message, data, 0)
|
||||
|
||||
@@main
|
||||
lda #0
|
||||
|
||||
--section{ "toto", align = 256, offset = 16 }
|
||||
--section{ "toto", org = 0xf100 }
|
||||
--section "waitForIntim"
|
||||
@@waitForIntim --alt short syntax when no other option
|
||||
-- n_{ a=INTIM } ?
|
||||
--lda(INTIM) -- or a=INTIM
|
||||
--bne "waitForIntim"
|
||||
ldx #0xf0
|
||||
ldx #0b1101
|
||||
ldy #0xAB - 16 + 0b11011 & 3 | 6 ~ 0xf >> ~3 << 1 // 5
|
||||
ldx #15,3
|
||||
ldx#0
|
||||
|
||||
local kernel_cycles,kernel_size
|
||||
table.insert(section_current.instructions, { asbin=function() kernel_cycles=cycles kernel_size=size end })
|
||||
|
||||
lda data
|
||||
lda data,5
|
||||
lda data,5,x
|
||||
lda data,5,y
|
||||
lda data+3,12
|
||||
lda data+3,12,x
|
||||
lda data+3,12,y
|
||||
lda (VBLANK,5,x)
|
||||
lda (\a(a+2),VBLANK,x)
|
||||
lda (VBLANK,5),y
|
||||
lda (\a(a&3),VBLANK),y
|
||||
jmp (VBLANK)
|
||||
jmp (VBLANK,12)
|
||||
jmp (VBLANK-4)
|
||||
|
||||
-- cycles are counted without taking any branch
|
||||
table.insert(section_current.instructions, { asbin=function() print('kernel cycles: ', cycles-kernel_cycles, 'kernel size: ', size-kernel_size) end })
|
||||
|
||||
v=7
|
||||
lda function(c) return 0xffff&(data * c) end, v
|
||||
lda \c((data*c)&0xffff), v
|
||||
local f = \c((data*c)&0xffff) v=5 lda !f,v v=3 lda !f,v
|
||||
local g = function() return function(c) return (data * c)&0xffff end end
|
||||
|
||||
lda !g(),v
|
||||
#pragma encapsulate off
|
||||
lda f,v
|
||||
lda !_toto+15,16,x
|
||||
lda #15
|
||||
#pragma encapsulate on
|
||||
|
||||
samepage
|
||||
lda #0xac
|
||||
lda #VBLANK
|
||||
lda 0xbeef
|
||||
lda VBLANK
|
||||
lda.w VBLANK
|
||||
lda VBLANK,x
|
||||
lda VBLANK,y
|
||||
lda (VBLANK,x)
|
||||
lda (VBLANK),y
|
||||
end
|
||||
|
||||
beq _toto
|
||||
asl
|
||||
asl VBLANK
|
||||
asl
|
||||
@_toto
|
||||
bne "_toto"
|
||||
bne waitForIntim
|
||||
f=\("_toto") bne f()
|
||||
bne _toto
|
||||
|
||||
jam asl lsr ldx #16 ldy 0xf0f0
|
||||
rts
|
||||
|
||||
local filename=string.match(arg[0], ".-([^\\/]-)%.?[^%.\\/]*$")
|
||||
writebin(filename..'.bin')
|
||||
writesym(filename..'.sym')
|
||||
print(stats)
|
||||
|
||||
--[[
|
||||
section "doOverscan"
|
||||
sta{WSYNC} -- WSYNC=a
|
||||
lda(2) sta{VBLANK} -- a=2 VBLANK=a
|
||||
lda(TIM_OVERSCAN) sta{TIM64T} -- a=TIM_OVERSCAN TIM64T=a
|
||||
jsr "waitForIntim"
|
||||
|
||||
section "doVBlank"
|
||||
lda(0x0e)
|
||||
label ".vsyncLoop"
|
||||
sta{WSYNC}
|
||||
sta{VSYNC}
|
||||
lsr()
|
||||
bne ".vsyncLoop"
|
||||
lda(2)
|
||||
sta{VBLANK}
|
||||
lda(TIM_VBLANK)
|
||||
sta{TIM64T}
|
||||
jsr "waitForIntim"
|
||||
|
||||
section "doKernel"
|
||||
lda(TIM_KERNEL)
|
||||
sta{T1024T}
|
||||
jsr "waitForIntim"
|
||||
|
||||
section "start"
|
||||
-- clear zeropage
|
||||
cld()
|
||||
ldx(0)
|
||||
txa()
|
||||
label ".clearLoop"
|
||||
dex()
|
||||
tsx()
|
||||
pha()
|
||||
bne ".clearLoop"
|
||||
-- main
|
||||
label "mainLoop"
|
||||
jsr "doOverscan"
|
||||
jsr "doVBlank"
|
||||
jsr "doKernel"
|
||||
jmp "mainLoop"
|
||||
|
||||
section{ name="vectors", org=0xfffc }
|
||||
word{ "start", "start" }
|
||||
|
||||
]]
|
183
asm.lua
183
asm.lua
@ -1,183 +0,0 @@
|
||||
dofile "vcs.lua"
|
||||
|
||||
TIM_OVERSCAN = 50 -- TIM64T, 3200 cycles = ~ 42 scanlines
|
||||
TIM_VBLANK = 61 -- TIM64T, 3904 cycles = ~ 51 scanlines
|
||||
TIM_KERNEL = 17 -- T1024T, 17408 cycles = ~229 scanlines
|
||||
|
||||
function switchbank(i) bitzab(function(_o) return _o+( 0x1ff4+i) end) end
|
||||
-- create bank stubs
|
||||
for bi=0,7,1 do
|
||||
local o=(bi<<12)
|
||||
_ENV['bank' .. bi] = location{0x8000+o, 0x8fff+o, rorg=0xf000}
|
||||
local start=section{"entry"..bi, org=0x8fee+o} switchbank(0) if bi==0 then jmpabs(function(_o) return _o+( main) end) end
|
||||
section{"switchtab"..bi, org=0x8ff4+o} byte(0,0,0,0,0,0,0,0)
|
||||
section{"vectors"..bi, org=0x8ffc+o} word(start,start)
|
||||
end
|
||||
|
||||
bank0.name = 'core'
|
||||
location(bank0)
|
||||
|
||||
--location(0x1000)
|
||||
|
||||
--location(0xf000, 0xffff)
|
||||
|
||||
if toto ~= 15 then end
|
||||
|
||||
abc = 13 ~ 0x7
|
||||
xyz = 1 << 2
|
||||
|
||||
x={ f=function() end }
|
||||
x:f()
|
||||
::lualabel::
|
||||
|
||||
;
|
||||
lda = 5 if lda < 6 then sta=7 end
|
||||
;
|
||||
|
||||
local function ptr_table(label, ...)
|
||||
local vals = {...}
|
||||
section{label .. "_lo", align=16} byte_lo(vals)
|
||||
section{label .. "_hi", align=16} byte_hi(vals)
|
||||
end
|
||||
|
||||
charset(" abcdefghijklmnopqrstuvwxyz-")
|
||||
section("message2") byte(4, "test", 0)
|
||||
charset()
|
||||
section("message") byte(4, "test", 0)
|
||||
|
||||
section("data")
|
||||
do crosspage()
|
||||
byte(1, 2) byte(3, 4) endpage()
|
||||
end
|
||||
word(0xf080) byte(16, 3, 4, 5, 6,
|
||||
24, 32)
|
||||
word(message2)
|
||||
byte_lo(message) byte_hi(message)
|
||||
byte(function() return message&0xff end, function() return message>>8 end)
|
||||
|
||||
ptr_table("ptrs", message, data, 0)
|
||||
|
||||
section("main")
|
||||
ldaimm (function(_o) return _o+(0) end)
|
||||
|
||||
--section{ "toto", align = 256, offset = 16 }
|
||||
--section{ "toto", org = 0xf100 }
|
||||
--section "waitForIntim"
|
||||
section("waitForIntim") --alt short syntax when no other option
|
||||
-- n_{ a=INTIM } ?
|
||||
--lda(INTIM) -- or a=INTIM
|
||||
--bne "waitForIntim"
|
||||
ldximm (function(_o) return _o+(0xf0) end)
|
||||
ldximm (function(_o) return _o+(13) end)
|
||||
ldyimm (function(_o) return _o+(0xAB - 16 + 27 & 3 | 6 ~ 0xf >> ~3 << 1 // 5) end)
|
||||
ldximm (function(_o) return _o+(15) end,3)
|
||||
ldximm(function(_o) return _o+(0) end)
|
||||
|
||||
local kernel_cycles,kernel_size
|
||||
table.insert(section_current.instructions, { asbin=function() kernel_cycles=cycles kernel_size=size end })
|
||||
|
||||
ldazab(function(_o) return _o+( data) end)
|
||||
ldazab(function(_o) return _o+( data) end,5)
|
||||
ldazax(function(_o) return _o+( data) end,5)
|
||||
ldaaby(function(_o) return _o+( data) end,5)
|
||||
ldazab(function(_o) return _o+( data+3) end,12)
|
||||
ldazax(function(_o) return _o+( data+3) end,12)
|
||||
ldaaby(function(_o) return _o+( data+3) end,12)
|
||||
ldainx (function(_o) return _o+(VBLANK) end,5)
|
||||
ldainx (function(a) return a+2 end,VBLANK)
|
||||
ldainy (function(_o) return _o+(VBLANK) end,5)
|
||||
ldainy (function(a) return a&3 end,VBLANK)
|
||||
jmpind (function(_o) return _o+(VBLANK) end)
|
||||
jmpind (function(_o) return _o+(VBLANK) end,12)
|
||||
jmpind (function(_o) return _o+(VBLANK-4) end)
|
||||
|
||||
-- cycles are counted without taking any branch
|
||||
table.insert(section_current.instructions, { asbin=function() print('kernel cycles: ', cycles-kernel_cycles, 'kernel size: ', size-kernel_size) end })
|
||||
|
||||
v=7
|
||||
ldazab( function(c) return 0xffff&(data * c) end, v)
|
||||
ldazab( function(c) return (data*c)&0xffff end, v)
|
||||
local f = function(c) return (data*c)&0xffff end v=5 ldazab(f,v) v=3 ldazab(f,v)
|
||||
local g = function() return function(c) return (data * c)&0xffff end end
|
||||
|
||||
ldazab(g(),v)
|
||||
ldazab( f,v)
|
||||
ldazax (function(_o) return _o+(_toto+15) end,16)
|
||||
ldaimm (15)
|
||||
|
||||
do samepage()
|
||||
ldaimm (function(_o) return _o+(0xac) end)
|
||||
ldaimm (function(_o) return _o+(VBLANK) end)
|
||||
ldazab(function(_o) return _o+( 0xbeef) end)
|
||||
ldazab(function(_o) return _o+( VBLANK) end)
|
||||
ldaabs(function(_o) return _o+( VBLANK) end)
|
||||
ldazax(function(_o) return _o+( VBLANK) end)
|
||||
ldaaby(function(_o) return _o+( VBLANK) end)
|
||||
ldainx (function(_o) return _o+(VBLANK) end)
|
||||
ldainy (function(_o) return _o+(VBLANK) end) endpage()
|
||||
end
|
||||
|
||||
beqrel( "_toto")
|
||||
aslimp()
|
||||
aslzab(function(_o) return _o+( VBLANK) end)
|
||||
aslimp()
|
||||
label("_toto")
|
||||
bnerel( "_toto")
|
||||
bnerel( "waitForIntim")
|
||||
f=function() return "_toto" end bnerel( f())
|
||||
bnerel( "_toto")
|
||||
|
||||
jamimp() aslimp() lsrimp() ldximm (function(_o) return _o+(16) end) ldyzab(function(_o) return _o+( 0xf0f0) end)
|
||||
rtsimp()
|
||||
|
||||
local filename=string.match(arg[0], ".-([^\\/]-)%.?[^%.\\/]*$")
|
||||
writebin(filename..'.bin')
|
||||
writesym(filename..'.sym')
|
||||
print(stats)
|
||||
|
||||
--[[
|
||||
section "doOverscan"
|
||||
sta{WSYNC} -- WSYNC=a
|
||||
lda(2) sta{VBLANK} -- a=2 VBLANK=a
|
||||
lda(TIM_OVERSCAN) sta{TIM64T} -- a=TIM_OVERSCAN TIM64T=a
|
||||
jsr "waitForIntim"
|
||||
|
||||
section "doVBlank"
|
||||
lda(0x0e)
|
||||
label ".vsyncLoop"
|
||||
sta{WSYNC}
|
||||
sta{VSYNC}
|
||||
lsr()
|
||||
bne ".vsyncLoop"
|
||||
lda(2)
|
||||
sta{VBLANK}
|
||||
lda(TIM_VBLANK)
|
||||
sta{TIM64T}
|
||||
jsr "waitForIntim"
|
||||
|
||||
section "doKernel"
|
||||
lda(TIM_KERNEL)
|
||||
sta{T1024T}
|
||||
jsr "waitForIntim"
|
||||
|
||||
section "start"
|
||||
-- clear zeropage
|
||||
cld()
|
||||
ldx(0)
|
||||
txa()
|
||||
label ".clearLoop"
|
||||
dex()
|
||||
tsx()
|
||||
pha()
|
||||
bne ".clearLoop"
|
||||
-- main
|
||||
label "mainLoop"
|
||||
jsr "doOverscan"
|
||||
jsr "doVBlank"
|
||||
jsr "doKernel"
|
||||
jmp "mainLoop"
|
||||
|
||||
section{ name="vectors", org=0xfffc }
|
||||
word{ "start", "start" }
|
||||
|
||||
]]
|
13
l65.lua
13
l65.lua
@ -2462,17 +2462,24 @@ local function Format65(ast)
|
||||
return table.concat(out.rope)
|
||||
end
|
||||
|
||||
local dirsep = package.config:sub(1,1)
|
||||
local dirl65 = (string.match(arg[0], "(.*[\\/]).*") or ''):gsub('/',dirsep)
|
||||
local searchl65 = ''
|
||||
if #dirl65 > 0 then
|
||||
searchl65 = string.format(";%s?;%s?.l65", dirl65, dirl65)
|
||||
package.path = package.path .. string.format(";%s?.lua", dirl65)
|
||||
end
|
||||
l65 = {
|
||||
parse = ParseLua,
|
||||
format = Format65,
|
||||
searcher_index = 2,
|
||||
search_path = string.format(".%s?;.%s?.l65%s", dirsep, dirsep, searchl65),
|
||||
load_org = load,
|
||||
loadfile_org = loadfile,
|
||||
dofile_org = dofile,
|
||||
}
|
||||
l65.searcher = function(name)
|
||||
local dirsep = package.config:sub(1,1)
|
||||
local filename,err = package.searchpath(name, string.format(".%s?;.%s?.l65", dirsep, dirsep), '.', '.')
|
||||
local filename,err = package.searchpath(name, l65.search_path, '.', '.')
|
||||
if not filename then return err end
|
||||
local file = io.open(filename, 'rb')
|
||||
if not file then return "failed to open " .. filename .. " for reading" end
|
||||
@ -2542,6 +2549,6 @@ if #arg ~= 1 then
|
||||
print("Invalid arguments, usage:\nl65 <filename>")
|
||||
return
|
||||
end
|
||||
local inf,dirsep = arg[1],package.config:sub(1,1)
|
||||
local inf = arg[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
|
||||
dofile(arg[1])
|
||||
|
Loading…
Reference in New Issue
Block a user