mirror of
https://github.com/g012/l65.git
synced 2024-12-29 16:29:15 +00:00
Added helpers for implementing cross bank calls using tjoppen's method of encoding the bank number into the 3 MSB.
This commit is contained in:
parent
117730c8e1
commit
def316e982
2
6502.lua
2
6502.lua
@ -572,7 +572,7 @@ local op_resolve = function(v)
|
|||||||
if type(v) == 'string' then v = symbols[v] end
|
if type(v) == 'string' then v = symbols[v] end
|
||||||
if type(v) ~= 'number' then error("unresolved symbol: " .. tostring(v)) end
|
if type(v) ~= 'number' then error("unresolved symbol: " .. tostring(v)) end
|
||||||
return v
|
return v
|
||||||
end
|
end M.op_resolve = op_resolve
|
||||||
|
|
||||||
local size_ref = function(v)
|
local size_ref = function(v)
|
||||||
if type(v) == 'string' then v=symbols[v] end
|
if type(v) == 'string' then v=symbols[v] end
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
require'vcs'
|
require'vcs'
|
||||||
#pragma encapsulate far farcall
|
#pragma encapsulate far farcall
|
||||||
|
#pragma encapsulate xsr xcall
|
||||||
|
#pragma add_opcode rtx imp
|
||||||
|
|
||||||
|
mappers.jmpfar=true
|
||||||
mappers.F4()
|
mappers.F4()
|
||||||
local bank_core,bank_fx = rom0,rom1
|
local bank_core,bank_fx = rom0,rom1
|
||||||
|
|
||||||
@ -8,11 +11,19 @@ location(bank_core)
|
|||||||
@@main
|
@@main
|
||||||
init()
|
init()
|
||||||
@_frame
|
@_frame
|
||||||
overscan() vblank() screen_begin() far kernel screen_end() jmp _frame
|
overscan() vblank() screen_begin()
|
||||||
|
far kernel
|
||||||
|
sta WSYNC lda#0xaa sta COLUBK for i=1,10 do sta WSYNC end
|
||||||
|
xsr kernel2
|
||||||
|
--lda#kernel2&0xff sta 0x8a lda#kernel2>>8 sta 0x8b jsr jmpfar
|
||||||
|
screen_end()
|
||||||
|
jmp _frame
|
||||||
|
|
||||||
location(bank_fx)
|
location(bank_fx)
|
||||||
@@kernel
|
@@kernel
|
||||||
ldx#0xd0 @_loop sta WSYNC stx COLUBK dex bne _loop rts
|
ldx#0x50 @_loop sta WSYNC stx COLUBK dex bne _loop rts
|
||||||
|
@@kernel2
|
||||||
|
ldx#0x50 @_loop sta WSYNC stx COLUBK dex bne _loop rtx --jmp rtsfar
|
||||||
|
|
||||||
;
|
;
|
||||||
writebin(filename..'.bin')
|
writebin(filename..'.bin')
|
||||||
|
23
vcs.l65
23
vcs.l65
@ -182,6 +182,10 @@ screen_begin = function() lda#TV.TIM_KERNEL sta T1024T end
|
|||||||
screen_end = wait
|
screen_end = wait
|
||||||
screen = function(f) screen_begin() if f then f() end screen_end() end
|
screen = function(f) screen_begin() if f then f() end screen_end() end
|
||||||
|
|
||||||
|
setptr = function(f) lda#op_resolve(f)&0xff sta mappers.tmp lda#op_resolve(f)>>8 sta mappers.tmp+1 end
|
||||||
|
xcall = function(f) setptr(f) jsr jmpfar end
|
||||||
|
rtximp = function() jmp rtsfar end
|
||||||
|
|
||||||
-- for mappers that swap banks in place
|
-- for mappers that swap banks in place
|
||||||
-- call an asm function into another bank and generate the stubs if needed
|
-- call an asm function into another bank and generate the stubs if needed
|
||||||
local far_stubs = {} _ENV.far_stubs=far_stubs
|
local far_stubs = {} _ENV.far_stubs=far_stubs
|
||||||
@ -205,7 +209,7 @@ farcall = function(dst)
|
|||||||
jsr far_stubs[dst][loc_src]
|
jsr far_stubs[dst][loc_src]
|
||||||
end
|
end
|
||||||
|
|
||||||
mappers = {}
|
mappers = { tmp=0x8a }
|
||||||
|
|
||||||
mappers['2K'] = function()
|
mappers['2K'] = function()
|
||||||
rom0 = location(0xf800, 0xffff)
|
rom0 = location(0xf800, 0xffff)
|
||||||
@ -221,12 +225,25 @@ end
|
|||||||
local bank_stubs = function(count, hotspot, entry)
|
local bank_stubs = function(count, hotspot, entry)
|
||||||
function switchrom(i) assert(i>=0 and i<count) if mappers.noillegal then bit 0x1000+hotspot+i else nop 0x1000+hotspot+i end end
|
function switchrom(i) assert(i>=0 and i<count) if mappers.noillegal then bit 0x1000+hotspot+i else nop 0x1000+hotspot+i end end
|
||||||
local base = 0x10000 - (count << 12)
|
local base = 0x10000 - (count << 12)
|
||||||
|
local jmpfar0,rtsfar0
|
||||||
for bi=0,count-1 do
|
for bi=0,count-1 do
|
||||||
local o = base+(bi<<12)
|
local o,ro = base+(bi<<12), mappers.jmpfar and 0x1000+(bi<<13) or 0xf000 -- stella doesn't honor breakpoints in banks with jmpfar method
|
||||||
_ENV['rom' .. bi] = location{o, o+0xfff, rorg=0xf000, rom=bi}
|
_ENV['rom' .. bi] = location{o, o+0xfff, rorg=ro, rom=bi}
|
||||||
local start=section{"entry"..bi, org=o+(entry or hotspot-6)} switchrom(0) if bi==0 then jmp main end
|
local start=section{"entry"..bi, org=o+(entry or hotspot-6)} switchrom(0) if bi==0 then jmp main end
|
||||||
section{"switchtab"..bi, org=o+hotspot} for i=1,count do byte(0) end
|
section{"switchtab"..bi, org=o+hotspot} for i=1,count do byte(0) end
|
||||||
section{"vectors"..bi, org=o+0xffc} dc.w start if mappers.irq then dc.w start end
|
section{"vectors"..bi, org=o+0xffc} dc.w start if mappers.irq then dc.w start end
|
||||||
|
if mappers.jmpfar then
|
||||||
|
local jmpfar = section("jmpfar"..(bi>0 and bi or ''))
|
||||||
|
lda mappers.tmp+1 lsr lsr lsr lsr lsr tax
|
||||||
|
if mappers.noillegal then and 0x1000+hotspot,x else nop 0x1000+hotspot,x end
|
||||||
|
jmp (mappers.tmp)
|
||||||
|
local rtsfar = section("rtsfar"..(bi>0 and bi or ''))
|
||||||
|
tsx lda 2,x lsr lsr lsr lsr lsr tax
|
||||||
|
if mappers.noillegal then and 0x1000+hotspot,x else nop 0x1000+hotspot,x end
|
||||||
|
rts
|
||||||
|
if bi==0 then jmpfar0=jmpfar rtsfar0=rtsfar
|
||||||
|
else relate(jmpfar0, jmpfar) relate(rtsfar0, rtsfar) end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mappers.FA = function() bank_stubs(3, 0xff8) end
|
mappers.FA = function() bank_stubs(3, 0xff8) end
|
||||||
|
Loading…
Reference in New Issue
Block a user