Update MAME integration to support 0.227
This commit is contained in:
parent
7baf9ffeaf
commit
3d69a3a1f9
|
@ -62,18 +62,19 @@
|
||||||
(self:start-cpu-monitor)
|
(self:start-cpu-monitor)
|
||||||
(self:continue) ; debug mame starts paused
|
(self:continue) ; debug mame starts paused
|
||||||
(self:done-msg))
|
(self:done-msg))
|
||||||
|
|
||||||
(fn Machine.start-cpu-monitor [self ?last-addr]
|
(fn Machine.start-cpu-monitor [self ?last-addr]
|
||||||
(self.monitor:eval-input
|
(self.monitor:eval-input
|
||||||
"(let [?last-addr (tonumber (io.read))]
|
"(let [?last-addr (tonumber (io.read))]
|
||||||
(run-periodic-job :cpu-monitor (fn []
|
(run-periodic-job :cpu-monitor (fn []
|
||||||
(var last-addr ?last-addr)
|
(var last-addr ?last-addr)
|
||||||
(while (let [state (-> (manager:machine) (: :debugger) (. :execution_state))
|
(while (let [state manager.machine.debugger.execution_state
|
||||||
addr (-> (manager:machine) (. :devices ::maincpu :state :PC :value))]
|
addr (. manager.machine.devices ::maincpu :state :PC :value)]
|
||||||
(not (and (= state :stop) (not= addr ?last-addr))))
|
(not (and (= state :stop) (not= addr ?last-addr))))
|
||||||
(when (= :run (-> (manager:machine) (: :debugger) (. :execution_state)))
|
(when (= :run manager.machine.debugger.execution_state)
|
||||||
(set last-addr nil))
|
(set last-addr nil))
|
||||||
(coroutine.yield))))
|
(coroutine.yield))))
|
||||||
(-> (manager:machine) (. :devices ::maincpu :state :PC :value)))"
|
(. manager.machine.devices ::maincpu :state :PC :value))"
|
||||||
(tostring ?last-addr)
|
(tostring ?last-addr)
|
||||||
{:value (fn [nrepl output response]
|
{:value (fn [nrepl output response]
|
||||||
(self:on-cpu-paused (tonumber output))
|
(self:on-cpu-paused (tonumber output))
|
||||||
|
@ -88,20 +89,20 @@
|
||||||
(set self.breakpoints {}))
|
(set self.breakpoints {}))
|
||||||
(fn Machine.write [self addr bytes]
|
(fn Machine.write [self addr bytes]
|
||||||
(if (> (bytes:len) 0x1000)
|
(if (> (bytes:len) 0x1000)
|
||||||
(do (self:write addr (bytes:sub 1 0x1000))
|
(do (self:write addr (bytes:sub 1 0x1000))
|
||||||
(self:write (+ addr 0x1000) (bytes:sub 0x1001)))
|
(self:write (+ addr 0x1000) (bytes:sub 0x1001)))
|
||||||
(self:eval-input
|
(self:eval-input
|
||||||
"(let [bencode (require :bencode)
|
"(let [bencode (require :bencode)
|
||||||
{: addr : bytes} (bencode.decode (io.read))
|
{: addr : bytes} (bencode.decode (io.read))
|
||||||
mem (-> (manager:machine) (. :devices ::maincpu :spaces :program))]
|
mem (. manager.machine.devices ::maincpu :spaces :program)]
|
||||||
(print :writing (bytes:len) :to addr)
|
(print :writing (bytes:len) :to addr)
|
||||||
(for [i 1 (bytes:len)]
|
(for [i 1 (bytes:len)]
|
||||||
(mem:write_u8 (+ addr i -1) (string.byte (bytes:sub i i)))))"
|
(mem:write_u8 (+ addr i -1) (string.byte (bytes:sub i i)))))"
|
||||||
(bencode.encode {: addr : bytes}))))
|
(bencode.encode {: addr : bytes}))))
|
||||||
(fn Machine.launch [self prg]
|
(fn Machine.launch [self prg]
|
||||||
(self:eval "(: (manager:machine) :soft_reset)")
|
(self:eval "(manager.machine:soft_reset)")
|
||||||
(self:eval (string.format "(emu.keypost \"CALL-151\\n %xG\\n\")" (prg:lookup-addr prg.start-symbol))))
|
(self:eval (string.format "(emu.keypost \"CALL-151\\n %xG\\n\")" (prg:lookup-addr prg.start-symbol))))
|
||||||
(fn Machine.reboot [self] (self:eval "(: (manager:machine) :hard_reset)"))
|
(fn Machine.reboot [self] (self:eval "(manager.machine:hard_reset)"))
|
||||||
(fn Machine.coro-eval [self code]
|
(fn Machine.coro-eval [self code]
|
||||||
(var result nil)
|
(var result nil)
|
||||||
(local append-to-result #(set result (.. (or result "") $2)))
|
(local append-to-result #(set result (.. (or result "") $2)))
|
||||||
|
@ -110,20 +111,21 @@
|
||||||
(coroutine.yield)
|
(coroutine.yield)
|
||||||
(or result "<no result>"))
|
(or result "<no result>"))
|
||||||
(fn Machine.dbgcmd [self cmd ?handlers]
|
(fn Machine.dbgcmd [self cmd ?handlers]
|
||||||
(self:eval (.. "(-> (manager:machine) (: :debugger) (: :command \"" cmd "\"))")) ?handlers)
|
(print "dbgcmd??" cmd)
|
||||||
|
(self:eval (.. "(manager.machine.debugger:command \"" cmd "\")")) ?handlers)
|
||||||
(fn Machine.continue [self] (self:dbgcmd :go))
|
(fn Machine.continue [self] (self:dbgcmd :go))
|
||||||
(fn Machine.step [self] (self:dbgcmd :s))
|
(fn Machine.step [self] (self:dbgcmd :s))
|
||||||
(fn Machine.set-bp [self addr ?action]
|
(fn Machine.set-bp [self addr ?action]
|
||||||
; todo: handle setting the same breakpoint more than once?
|
; todo: handle setting the same breakpoint more than once?
|
||||||
(tset self.breakpoints addr {:action ?action})
|
(tset self.breakpoints addr {:action ?action})
|
||||||
(self:eval (.. "(-> (manager:machine) (. :devices ::maincpu) (: :debug) (: :bpset " (tostring addr) "))")
|
(self:eval (.. "(-> (. manager.machine.devices ::maincpu) (: :debug) (: :bpset " (tostring addr) "))")
|
||||||
{:value #(tset (. self.breakpoints addr) :id (tonumber $2))}))
|
{:value #(tset (. self.breakpoints addr) :id (tonumber $2))}))
|
||||||
(fn Machine.clear-bp [self addr]
|
(fn Machine.clear-bp [self addr]
|
||||||
(local bpid (-?> self.breakpoints (. addr) (. :id)))
|
(local bpid (-?> self.breakpoints (. addr) (. :id)))
|
||||||
(when bpid (self:dbgcmd (.. "bpclear " (string.format "%x" bpid))))
|
(when bpid (self:dbgcmd (.. "bpclear " (string.format "%x" bpid))))
|
||||||
(tset self.breakpoints addr nil))
|
(tset self.breakpoints addr nil))
|
||||||
(fn Machine.jump [self addr]
|
(fn Machine.jump [self addr]
|
||||||
(self:eval (.. "(tset (-> (manager:machine) (. :devices ::maincpu :state :PC)) :value " (tostring addr) ")")))
|
(self:eval (.. "(tset (. manager.machine.devices ::maincpu :state :PC) :value " (tostring addr) ")")))
|
||||||
(fn Machine.stub [self org post-check-jump ...]
|
(fn Machine.stub [self org post-check-jump ...]
|
||||||
(org:append :debug-stub [:jmp post-check-jump] :on-hotswap ...))
|
(org:append :debug-stub [:jmp post-check-jump] :on-hotswap ...))
|
||||||
(fn Machine.hotswap [self prg-old prg-new]
|
(fn Machine.hotswap [self prg-old prg-new]
|
||||||
|
|
Loading…
Reference in a new issue