mirror of
https://github.com/g012/l65.git
synced 2024-11-15 19:09:19 +00:00
9c576ef774
Added asserts in 6502.lua.
119 lines
4.4 KiB
Plaintext
119 lines
4.4 KiB
Plaintext
require'nes'
|
|
|
|
-- 2 32kB PRG roms
|
|
mappers.GxROM{ prgsize=(32*2)*1024 }
|
|
|
|
location(chrrom0)
|
|
|
|
local font = section("font")
|
|
dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 -- <SPC>
|
|
dc.b 0x38,0x38,0x2c,0x64,0x7e,0x46,0xce,0x00,0x38,0x38,0x2c,0x64,0x7e,0x46,0xce,0x00 -- A
|
|
dc.b 0xfc,0x62,0x66,0x7c,0x62,0x66,0xfc,0x00,0xfc,0x62,0x66,0x7c,0x62,0x66,0xfc,0x00 -- B
|
|
dc.b 0x7c,0xe6,0xc2,0xc0,0xc0,0xe6,0x7c,0x00,0x7c,0xe6,0xc2,0xc0,0xc0,0xe6,0x7c,0x00 -- C
|
|
dc.b 0xfc,0x4e,0x46,0x46,0x46,0xce,0xfc,0x00,0xfc,0x4e,0x46,0x46,0x46,0xce,0xfc,0x00 -- D
|
|
dc.b 0xfe,0x66,0x60,0x7c,0x60,0x66,0xfe,0x00,0xfe,0x66,0x60,0x7c,0x60,0x66,0xfe,0x00 -- E
|
|
dc.b 0xfe,0x66,0x60,0x7c,0x60,0x60,0xf0,0x00,0xfe,0x66,0x60,0x7c,0x60,0x60,0xf0,0x00 -- F
|
|
dc.b 0x7c,0xe6,0xc0,0xce,0xc6,0xe6,0x7c,0x00,0x7c,0xe6,0xc0,0xce,0xc6,0xe6,0x7c,0x00 -- G
|
|
dc.b 0xee,0x66,0x66,0x7e,0x66,0x66,0xee,0x00,0xee,0x66,0x66,0x7e,0x66,0x66,0xee,0x00 -- H
|
|
dc.b 0x3c,0x18,0x18,0x18,0x18,0x18,0x3c,0x00,0x3c,0x18,0x18,0x18,0x18,0x18,0x3c,0x00 -- I
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0xc2,0xe6,0x7c,0x00 -- U
|
|
dc.b 0xc6,0xc6,0xc6,0x6c,0x6c,0x38,0x38,0x00,0xc6,0xc6,0xc6,0x6c,0x6c,0x38,0x38,0x00 -- V
|
|
dc.b 0xc6,0xc6,0xd6,0xfe,0xee,0xc6,0x82,0x00,0xc6,0xc6,0xd6,0xfe,0xee,0xc6,0x82,0x00 -- W
|
|
dc.b 0x86,0xcc,0x78,0x30,0x78,0xcc,0x86,0x00,0x86,0xcc,0x78,0x30,0x78,0xcc,0x86,0x00 -- X
|
|
dc.b 0xc6,0xc6,0x6c,0x38,0x18,0x18,0x38,0x00,0xc6,0xc6,0x6c,0x38,0x18,0x18,0x38,0x00 -- Y
|
|
dc.b 0x7e,0xce,0x98,0x30,0x62,0xe6,0xfc,0x00,0x7e,0xce,0x98,0x30,0x62,0xe6,0xfc,0x00 -- Z
|
|
charset(" abcdefghijklmnopqrstuvwxyz", \x(x+(font.org - font.location.start) // 16))
|
|
|
|
local copytext = function(sec_text, text)
|
|
-- load screen text in PPU RAM 0x21CA
|
|
ppu_addr(0x21ca)
|
|
ldy #0 @_loadtxt lda sec_text,y sta PPUDATA iny cpy ##text bne _loadtxt
|
|
-- reset scroll position
|
|
ppu_addr(0) sta BGSCROL sta BGSCROL
|
|
end
|
|
|
|
-- RAM
|
|
joya = 0
|
|
|
|
--[[
|
|
BANK 0 - startup bank
|
|
]]
|
|
location(prgrom0)
|
|
|
|
local text0 = "bank one"
|
|
@@text0s byte(text0)
|
|
|
|
@@nmi0 @irq0 rti
|
|
|
|
local toprg1s = section("toprg1")
|
|
switchroms(1,0)
|
|
local fromprg1s = section("fromprg1")
|
|
jmp mainloop
|
|
|
|
@@main
|
|
init()
|
|
--lda#0x80 sta PPUSTAT -- enable VBlank IRQ on NMI vector
|
|
vblank_waitbegin()
|
|
-- load BG palette in PPU RAM
|
|
ppu_addr(BGPAL)
|
|
for _,v in ipairs{ 0x1f, 0x00, 0x10, 0x20 } do lda #v sta PPUDATA end
|
|
-- turn screen on
|
|
lda #0x0a sta PPUMASK -- show BG
|
|
-- idle
|
|
@mainloop
|
|
vblank_waitbegin()
|
|
copytext(text0s, text0)
|
|
read_joy_a(1) bcc _noswitch
|
|
lda joya bne _switch
|
|
lda #1 sta joya jmp toprg1
|
|
@_noswitch
|
|
lda #0 sta joya
|
|
@_switch
|
|
jmp mainloop
|
|
|
|
|
|
--[[
|
|
BANK 1
|
|
]]
|
|
location(prgrom1)
|
|
|
|
local text1 = "bank two"
|
|
@@text1s byte(text1)
|
|
|
|
@@nmi1 @irq1 rti
|
|
|
|
local toprg0s = section("toprg0")
|
|
relate(toprg0s, fromprg1s, 7) -- switchprgrom(immediate) takes 7 bytes
|
|
switchroms(0,0)
|
|
|
|
local fromprg0s = section("fromprg0")
|
|
relate(toprg1s, fromprg0s, 7)
|
|
jmp mainloop1
|
|
|
|
@mainloop1
|
|
vblank_waitbegin()
|
|
copytext(text1s, text1)
|
|
read_joy_a(1) bcc _noswitch
|
|
lda joya bne _switch
|
|
lda #1 sta joya jmp toprg0
|
|
@_noswitch
|
|
lda #0 sta joya
|
|
@_switch
|
|
jmp mainloop1
|
|
|
|
writebin(filename..'.nes')
|
|
writesym(filename..'.mlb', 'mesen')
|
|
writesym(filename..'.nes', 'fceux')
|
|
print(stats)
|