More tweaks to bsnes script

This commit is contained in:
Empathic Qubit 2021-04-30 02:21:08 -04:00
parent 7fed47983d
commit c7bd873452
3 changed files with 18 additions and 9 deletions

1
.gitignore vendored
View file

@ -6,6 +6,7 @@ crashsave*
*.pool* *.pool*
*.lsvs *.lsvs
config.lua config.lua
*.srm
*.sfc *.sfc
watchexec* watchexec*
.VSCodeCounter/ .VSCodeCounter/

BIN
rom.srm

Binary file not shown.

View file

@ -51,7 +51,7 @@ local function bpSwitch(switchName, source, startAddress, arg, valWidth, addrWid
valWidth = 2 valWidth = 2
end end
if arg:sub(1, #switchName+2) == '--'..switchName then if arg:sub(1, #switchName+2) == '--'..switchName then
local op, valHex, rwx = arg:sub(#switchName+3):match('([><=]*)([0-9a-fA-F]*):?([rwxRWX]*)$') local op, valHex, rwx = arg:sub(#switchName+3):match('^([><=]*)([0-9a-fA-F]*):?([rwxRWX]*)$')
local valPad = '' local valPad = ''
if valHex ~= '' then if valHex ~= '' then
local val = tonumber(valHex, 16) local val = tonumber(valHex, 16)
@ -62,13 +62,16 @@ local function bpSwitch(switchName, source, startAddress, arg, valWidth, addrWid
-- SNES is LE! -- SNES is LE!
local valLeast = valPad:sub(3, 4) local valLeast = valPad:sub(3, 4)
local valMost = valPad:sub(1, 2) local valMost = valPad:sub(1, 2)
local opLeast = '=' local opLeast = ''
local opMost = '=' local opMost = ''
-- FIXME This is surely wrong but better than nothing? -- FIXME This is surely wrong but better than nothing?
if op == '>' then if op == '>' then
opLeast = '>' opLeast = '>'
opMost = '>=' opMost = '>='
elseif op == '=' then
opLeast = '='
opMost = '='
elseif op == '<' then elseif op == '<' then
opLeast = '<' opLeast = '<'
opMost = '<=' opMost = '<='
@ -79,8 +82,6 @@ local function bpSwitch(switchName, source, startAddress, arg, valWidth, addrWid
opLeast = '>=' opLeast = '>='
opMost = '>=' opMost = '>='
else else
opLeast = ''
opMost = ''
valLeast = '' valLeast = ''
valMost = '' valMost = ''
end end
@ -103,12 +104,14 @@ for arg in os.getenv('BSNES_LAUNCHER_ARGS'):gmatch('[^ ]+') do
end end
end end
local cmdFmt = 'bsnes %s--show-debugger "%s"'
local bpArgs = '' local bpArgs = ''
local withoutBps = string.format(cmdFmt, bpArgs, config.ROM)
if #bps > 0 then if #bps > 0 then
bpArgs = '-b "'..table.concat(bps, '" -b "')..'" ' bpArgs = '-b "'..table.concat(bps, '" -b "')..'" '
end end
local withBps = string.format(cmdFmt, bpArgs, config.ROM)
local cmd = 'bsnes '..bpArgs..'--show-debugger --break-immediately "'..config.ROM..'"'
if count == 0 then if count == 0 then
text('====================') text('====================')
@ -119,7 +122,12 @@ text('====================')
text('Note that you will need to turn off breakpoint saving for this app to work correctly.') text('Note that you will need to turn off breakpoint saving for this app to work correctly.')
text('') text('')
text(cmd) text(withBps)
text('====================') text('====================')
util.doCmd(cmd) while true do
text('Starting without breakpoints first. Save your state where you want with F2, then quit to load with breakpoints enabled')
util.doCmd(withoutBps)
text('Starting with breakpoints enabled. Load your state with F4')
util.doCmd(withBps)
end