Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. function love.load()
  2.  
  3. -- Set window title, resolution, and filter
  4. love.window.setTitle("Clover")
  5. love.window.setMode(1280, 720)
  6. love.graphics.setDefaultFilter("linear", "linear")
  7.  
  8. -- Set up debug cart
  9. cart =
  10. {
  11. [0x4019] = 0xA9,
  12. [0x401A] = 0xFF
  13. }
  14.  
  15. -- Set up ram
  16. ram = {}
  17. for i = 0, 2047 do
  18. ram[i] = tonumber(0x00)
  19. end
  20.  
  21. -- Set up cpu
  22. cpu =
  23. {
  24. reg =
  25. {
  26. a = 0x00,
  27. x = 0x00,
  28. y = 0x00,
  29. p = {c = 0, z = 0, i = 1, d = 0, v = 0, n = 0},
  30. s = 0x0000,
  31. pc = 0x4019,
  32. },
  33. cyl = 0,
  34. }
  35.  
  36. -- Set up opcode functions
  37. fnc = {}
  38. function fnc.LDA()
  39. cpu.reg.a = rd_mem(cpu.reg.pc + 1)
  40. end
  41.  
  42. -- Set up opcode mappings
  43. op =
  44. {
  45. [0xA9] = {"LDA", fnc.LDA},
  46. }
  47.  
  48. end
  49.  
  50. function love.update(dt)
  51.  
  52. -- Run cpu cycles
  53. while cpu.cyl ~= 29781 do
  54. crn_op = rd_mem(cpu.reg.pc)
  55. op[crn_op][2]()
  56. cpu.cyl = cpu.cyl + 1
  57. end
  58. cpu.cyl = 0
  59.  
  60. end
  61.  
  62. function love.draw()
  63.  
  64. -- Draw debug information
  65. love.graphics.print(cpu.reg.a)
  66.  
  67. end
  68.  
  69. -- Set up function to read memory
  70. function rd_mem(adr)
  71. if tonumber(adr) <= tonumber("0x1FFF") then
  72. return ram[adr]
  73. elseif tonumber(adr) > tonumber("0x4018") then
  74. return cart[adr]
  75. end
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement