mirror of
https://github.com/g012/l65.git
synced 2025-01-03 03:32:53 +00:00
Bankswitching defaults to using illegal nop instead of bit.
This commit is contained in:
parent
462c4a3b8d
commit
117730c8e1
90
vcs.l65
90
vcs.l65
@ -207,58 +207,58 @@ end
|
||||
|
||||
mappers = {}
|
||||
|
||||
mappers['2K'] = function(irq)
|
||||
mappers['2K'] = function()
|
||||
rom0 = location(0xf800, 0xffff)
|
||||
section{"vectors", org=0xfffc} dc.w main if irq then dc.w main end
|
||||
section{"vectors", org=0xfffc} dc.w main if mappers.irq then dc.w main end
|
||||
end
|
||||
mappers.CV = mappers['2K']
|
||||
|
||||
mappers['4K'] = function(irq)
|
||||
mappers['4K'] = function()
|
||||
rom0 = location(0xf000, 0xffff)
|
||||
section{"vectors", org=0xfffc} dc.w main if irq then dc.w main end
|
||||
section{"vectors", org=0xfffc} dc.w main if mappers.irq then dc.w main end
|
||||
end
|
||||
|
||||
local bank_stubs = function(irq, count, hotspot, entry)
|
||||
function switchrom(i) assert(i>=0 and i<count) bit 0x1000+hotspot+i end
|
||||
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
|
||||
local base = 0x10000 - (count << 12)
|
||||
for bi=0,count-1 do
|
||||
local o = base+(bi<<12)
|
||||
_ENV['rom' .. bi] = location{o, o+0xfff, rorg=0xf000, rom=bi}
|
||||
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{"vectors"..bi, org=o+0xffc} dc.w start if irq then dc.w start end
|
||||
section{"vectors"..bi, org=o+0xffc} dc.w start if mappers.irq then dc.w start end
|
||||
end
|
||||
end
|
||||
mappers.FA = function(irq) bank_stubs(irq, 3, 0xff8) end
|
||||
mappers.F8 = function(irq) bank_stubs(irq, 2, 0xff8) end
|
||||
mappers.F6 = function(irq) bank_stubs(irq, 4, 0xff6) end
|
||||
mappers.F4 = function(irq) bank_stubs(irq, 8, 0xff4) end
|
||||
mappers.EF = function(irq) bank_stubs(irq, 16, 0xfe0, 0xffc-6) end
|
||||
mappers.FA = function() bank_stubs(3, 0xff8) end
|
||||
mappers.F8 = function() bank_stubs(2, 0xff8) end
|
||||
mappers.F6 = function() bank_stubs(4, 0xff6) end
|
||||
mappers.F4 = function() bank_stubs(8, 0xff4) end
|
||||
mappers.EF = function() bank_stubs(16, 0xfe0, 0xffc-6) end
|
||||
|
||||
mappers.FE = function(irq)
|
||||
mappers.FE = function()
|
||||
rom1 = location(0xd000, 0xdfff)
|
||||
section{"vectors1", org=0xdffc} dc.w main if irq then dc.w main end
|
||||
section{"vectors1", org=0xdffc} dc.w main if mappers.irq then dc.w main end
|
||||
location{0xe000, 0xefff, nofill=true}
|
||||
rom0 = location(0xf000, 0xffff)
|
||||
section{"vectors0", org=0xfffc} dc.w main if irq then dc.w main end
|
||||
section{"vectors0", org=0xfffc} dc.w main if mappers.irq then dc.w main end
|
||||
end
|
||||
|
||||
mappers.E0 = function(map, irq)
|
||||
function switchrom0(i) assert(map[i]==0) bit 0x1fe0+i end
|
||||
function switchrom1(i) assert(map[i]==1) bit 0x1fe8+i end
|
||||
function switchrom2(i) assert(map[i]==2) bit 0x1ff0+i end
|
||||
mappers.E0 = function(map)
|
||||
function switchrom0(i) assert(map[i]==0) if mappers.noillegal then bit 0x1fe0+i else nop 0x1fe0+i end end
|
||||
function switchrom1(i) assert(map[i]==1) if mappers.noillegal then bit 0x1fe8+i else nop 0x1fe8+i end end
|
||||
function switchrom2(i) assert(map[i]==2) if mappers.noillegal then bit 0x1ff0+i else nop 0x1ff0+i end end
|
||||
map[7]=3
|
||||
for bi=0,7 do
|
||||
local o = bi*0x400
|
||||
_ENV["rom"..bi] = location{0xe000+o, 0xe3ff+o, rorg=0xf000+map[bi]*0x400}
|
||||
end
|
||||
section{"switchtab", org=0xffe0} for i=1,8*3 do byte(0) end
|
||||
section{"vectors", org=0xfffc} dc.w main if irq then dc.w main end
|
||||
section{"vectors", org=0xfffc} dc.w main if mappers.irq then dc.w main end
|
||||
end
|
||||
|
||||
-- rom0 refers to the last one in ROM, ie the one always mapped to 0xF800-0xFFFF,
|
||||
-- such that changing the rom count does not change its index
|
||||
mappers['3F'] = function(count, irq)
|
||||
mappers['3F'] = function(count)
|
||||
function switchrom(i) assert(i>=0 and i<count-1) lda#i sta 0x3f end
|
||||
local symbols=cpu.symbols for k,v in pairs(vcs) do -- remap TIA to 0x40-0x7F
|
||||
if v<0x40 then v=v+0x40 vcs[k]=v symbols[k]=v end
|
||||
@ -269,23 +269,23 @@ mappers['3F'] = function(count, irq)
|
||||
end
|
||||
local o = 0x800 * (count-1) + 0x10000
|
||||
rom0 = location{o, 0x7ff+o, rorg=0xf800}
|
||||
section{"vectors", org=0xfffc} dc.w main if irq then dc.w main end
|
||||
section{"vectors", org=0xfffc} dc.w main if mappers.irq then dc.w main end
|
||||
end
|
||||
|
||||
mappers.E7 = function(irq)
|
||||
function switchrom(i) assert(i>=0 and i<7) bit 0x1fe0+i end
|
||||
function enableram() bit 0x1fe7 end
|
||||
function switchram(i) assert(i>=0 and i<4) bit 0x1fe8+i end
|
||||
mappers.E7 = function()
|
||||
function switchrom(i) assert(i>=0 and i<7) if mappers.noillegal then bit 0x1fe0+i else nop 0x1fe0+i end end
|
||||
function enableram() if mappers.noillegal then bit 0x1fe7 else nop 0x1fe7 end end
|
||||
function switchram(i) assert(i>=0 and i<4) if mappers.noillegal then bit 0x1fe8+i else nop 0x1fe8+i end end
|
||||
for bi=0,6 do
|
||||
local o = bi*0x800
|
||||
_ENV['rom' .. bi] = location{o+0xc000, o+0xc7ff, rorg=0xf000}
|
||||
end
|
||||
rom7 = location{0xf800, 0xffff, rorg=0xf800}
|
||||
section{"switchtab", org=0xffe0} for i=1,12 do byte(0) end
|
||||
section{"vectors", org=0xfffc} dc.w main if irq then dc.w main end
|
||||
section{"vectors", org=0xfffc} dc.w main if mappers.irq then dc.w main end
|
||||
end
|
||||
|
||||
mappers.F0 = function(irq)
|
||||
mappers.F0 = function()
|
||||
function switchrom() lda 0x1ff0 end
|
||||
for bi=0,15 do
|
||||
local o = bi*0x1000 + 0x1000
|
||||
@ -294,14 +294,14 @@ mappers.F0 = function(irq)
|
||||
local l=label() switchrom() bne l
|
||||
if bi==0 then jmp main end
|
||||
section{"switchtab"..bi, org=o+0xff0} byte(bi)
|
||||
section{"vectors"..bi, org=o+0xffc} dc.w start if irq then dc.w start end
|
||||
section{"vectors"..bi, org=o+0xffc} dc.w start if mappers.irq then dc.w start end
|
||||
end
|
||||
end
|
||||
|
||||
local bank_stubs2 = function(irq, hotspot0, hotspot1)
|
||||
local bank_stubs2 = function(hotspot0, hotspot1)
|
||||
function switchrom(i)
|
||||
if i==0 then bit hotspot0
|
||||
elseif i==1 then bit hotspot1
|
||||
if i==0 then if mappers.noillegal then bit hotspot0 else nop hotspot0 end
|
||||
elseif i==1 then if mappers.noillegal then bit hotspot1 else nop hotspot1 end
|
||||
else error("invalid rom index: " .. i) end
|
||||
end
|
||||
local base = 0xe000
|
||||
@ -309,29 +309,29 @@ local bank_stubs2 = function(irq, hotspot0, hotspot1)
|
||||
local o = base+(bi<<12)
|
||||
_ENV['rom' .. bi] = location{o, o+0xfff, rorg=0xf000}
|
||||
local start=section{"entry"..bi, org=o+0xffc-6} switchrom(0) if bi==0 then jmp main end
|
||||
section{"vectors"..bi, org=o+0xffc} dc.w start if irq then dc.w start end
|
||||
section{"vectors"..bi, org=o+0xffc} dc.w start if mappers.irq then dc.w start end
|
||||
end
|
||||
end
|
||||
mappers.UA = function(irq) bank_stubs2(irq, 0x220, 0x240) end
|
||||
mappers['0840'] = function(irq) bank_stubs2(irq, 0x800, 0x840) end
|
||||
mappers.SB = function(count, irq)
|
||||
function switchrom(i) assert(i>=0 and i<count) bit 0x800+i end
|
||||
mappers.UA = function() bank_stubs2(0x220, 0x240) end
|
||||
mappers['0840'] = function() bank_stubs2(0x800, 0x840) end
|
||||
mappers.SB = function(count)
|
||||
function switchrom(i) assert(i>=0 and i<count) if mappers.noillegal then bit 0x800+i else nop 0x800+i end end
|
||||
for bi=0,count-1 do
|
||||
local o = bi*0x1000 + 0x1000
|
||||
_ENV['rom' .. bi] = location{o, o+0xfff, rorg=0xf000}
|
||||
local start=section{"entry"..bi, org=o+0xffc-6} switchrom(0) if bi==0 then jmp main end
|
||||
section{"vectors"..bi, org=o+0xffc} dc.w start if irq then dc.w start end
|
||||
section{"vectors"..bi, org=o+0xffc} dc.w start if mappers.irq then dc.w start end
|
||||
end
|
||||
end
|
||||
|
||||
mappers['3E'] = function(rom_count, ram_count, irq)
|
||||
mappers['3F'](rom_count, irq)
|
||||
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
|
||||
|
||||
-- rom0 refers to the last 1k in ROM, which is mapped automatically on reset,
|
||||
-- such that changing the rom count does not change its index
|
||||
mappers.MC = function(rom_count, ram_count, irq)
|
||||
mappers.MC = function(rom_count, ram_count)
|
||||
for i=0,3 do
|
||||
_ENV['switchrom'..i] = function(i) assert(i>=0 and i<128) lda#i sta 0x3c+i end
|
||||
_ENV['switchram'..i] = function(i) assert(i>=0 and i<128) lda#i+0x80 sta 0x3c+i end
|
||||
@ -341,17 +341,17 @@ mappers.MC = function(rom_count, ram_count, irq)
|
||||
_ENV["rom"..(count-1-bi)] = location{o, 0x3ff+o, rorg=0xf000+(o&0xfff)}
|
||||
end
|
||||
local start=section("entry") switchrom3(0) jmp main
|
||||
section{"vectors", org=0xfffc} dc.w start if irq then dc.w start end
|
||||
section{"vectors", org=0xfffc} dc.w start if mappers.irq then dc.w start end
|
||||
end
|
||||
|
||||
mappers.X07 = function(irq)
|
||||
function switchrom(i) assert(i>=0 and i<16) bit 0x80b+(i<<4) end
|
||||
mappers.X07 = function()
|
||||
function switchrom(i) assert(i>=0 and i<16) if mappers.noillegal then bit 0x80b+(i<<4) else nop 0x80b+(i<<4) end end
|
||||
-- map TIA also to 0x40-0x7F: use VSYNC for bank 14, and VSYNC2 for bank 15
|
||||
vcs.VSYNC2=0x40 cpu.symbols.VSYNC2=0x40
|
||||
for bi=0,count-1 do
|
||||
local o = bi*0x1000 + 0x1000
|
||||
_ENV['rom' .. bi] = location{o, o+0xfff, rorg=0xf000}
|
||||
local start=section{"entry"..bi, org=o+0xffc-6} switchrom(0) if bi==0 then jmp main end
|
||||
section{"vectors"..bi, org=o+0xffc} dc.w start if irq then dc.w start end
|
||||
section{"vectors"..bi, org=o+0xffc} dc.w start if mappers.irq then dc.w start end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user