Skip to content

Commit 865e156

Browse files
author
Juan Segura
committed
Added MAME-Plugin
1 parent 84b7ec3 commit 865e156

5 files changed

Lines changed: 106 additions & 0 deletions

File tree

MAME-plugin/Version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1-beta1

MAME-plugin/init.lua

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
local exports = {}
2+
3+
local cpu = nil
4+
local paused = false
5+
6+
local breakpointaddr = nil --0x8000
7+
local breakpoint_hit = false
8+
9+
function exports.startplugin()
10+
print("Plugin ZXBS loaded!")
11+
12+
--emu.register_start(function()
13+
emu.add_machine_reset_notifier(function()
14+
cpu = manager.machine.devices[":maincpu"]
15+
print("")
16+
print("CPU detected")
17+
18+
if breakpointaddr then
19+
if cpu.debug then
20+
local id=cpu.debug:bpset(breakpointaddr, "", "")
21+
print("Breakpoint set " .. id)
22+
else
23+
print("DEBUG NO AVAILABLE")
24+
end
25+
end
26+
27+
emu.register_periodic(timer)
28+
end)
29+
end
30+
31+
32+
function timer()
33+
if not cpu or not cpu.debug then
34+
return
35+
end
36+
37+
local current_pc = cpu.state["PC"].value
38+
if current_pc == breakpointaddr and breakpoint_hit == false then
39+
emu.pause()
40+
breakpoint_hit = true
41+
show_registers()
42+
end
43+
44+
--if breakpoint_hit == true and current_pc != breakpointaddr then
45+
-- breakpoint_hit = false
46+
--end
47+
end
48+
49+
50+
function timer2()
51+
local cmd = get_command()
52+
53+
if cmd == "PAUSE" then
54+
emu.pause()
55+
show_registers()
56+
else
57+
if cmd == nil then
58+
return
59+
end
60+
print("UNKNOW COMMAD")
61+
print(cmd)
62+
end
63+
end
64+
65+
66+
function get_command()
67+
local f = io.open("zxbs.tmp","r")
68+
if not f then
69+
return nil
70+
end
71+
local content = f:read("*a")
72+
f:close()
73+
os.remove("zxbs.tmp")
74+
return content
75+
end
76+
77+
78+
function show_registers()
79+
local pc = cpu.state["PC"].value
80+
local af = cpu.state["AF"].value
81+
local bc = cpu.state["BC"].value
82+
local de = cpu.state["DE"].value
83+
local hl = cpu.state["HL"].value
84+
print(string.format("BREAKPOINT PC:%04X AF:%04X BC:%04X DE:%04X HL:%04X",pc, af, bc, de, hl))
85+
end
86+
87+
return exports

MAME-plugin/plugin.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"plugin": {
3+
"name": "zxbs",
4+
"description": "ZX Basic Studio debugger plugin",
5+
"version": "0.1",
6+
"author": "DuefectuCorp",
7+
"type": "plugin",
8+
"start": "start"
9+
}
10+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Have fun!
2424
- AbenZaX
2525
- Pedro Tomás (Pere)
2626
- Jose Daniel Fernandez Santos (Fenix)
27+
- Super@ado
2728

2829
## Credits
2930
- Icons from [SVG REPO](https://www.svgrepo.com/):

ZXBasicStudio.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Installer", "Installer", "{
4242
EndProject
4343
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Emulator", "Emulator", "{6AB4C5D0-AB60-49F0-A349-E46971736749}"
4444
EndProject
45+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MAME-plugin", "MAME-plugin", "{1EFA610B-30F8-41E7-AED5-39CAB54C39A6}"
46+
ProjectSection(SolutionItems) = preProject
47+
MAME-plugin\init.lua = MAME-plugin\init.lua
48+
MAME-plugin\plugin.json = MAME-plugin\plugin.json
49+
MAME-plugin\Version.txt = MAME-plugin\Version.txt
50+
EndProjectSection
51+
EndProject
4552
Global
4653
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4754
Debug|Any CPU = Debug|Any CPU

0 commit comments

Comments
 (0)