Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function love.load()
- -- Set window title, resolution, and filter
- love.window.setTitle("Clover")
- love.window.setMode(1280, 720)
- love.graphics.setDefaultFilter("linear", "linear")
- -- Set up debug cart
- cart =
- {
- [0x4019] = 0xA9,
- [0x401A] = 0xFF
- }
- -- Set up ram
- ram = {}
- for i = 0, 2047 do
- ram[i] = tonumber(0x00)
- end
- -- Set up cpu
- cpu =
- {
- reg =
- {
- a = 0x00,
- x = 0x00,
- y = 0x00,
- p = {c = 0, z = 0, i = 1, d = 0, v = 0, n = 0},
- s = 0x0000,
- pc = 0x4019,
- },
- cyl = 0,
- }
- -- Set up opcode functions
- fnc = {}
- function fnc.LDA()
- cpu.reg.a = rd_mem(cpu.reg.pc + 1)
- end
- -- Set up opcode mappings
- op =
- {
- [0xA9] = {"LDA", fnc.LDA},
- }
- end
- function love.update(dt)
- -- Run cpu cycles
- while cpu.cyl ~= 29781 do
- crn_op = rd_mem(cpu.reg.pc)
- op[crn_op][2]()
- cpu.cyl = cpu.cyl + 1
- end
- cpu.cyl = 0
- end
- function love.draw()
- -- Draw debug information
- love.graphics.print(cpu.reg.a)
- end
- -- Set up function to read memory
- function rd_mem(adr)
- if tonumber(adr) <= tonumber("0x1FFF") then
- return ram[adr]
- elseif tonumber(adr) > tonumber("0x4018") then
- return cart[adr]
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement