From 78bc52cd8ed1c31560a38b74e64a8dd63140c6cb Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Mon, 28 May 2018 18:24:11 -0500 Subject: [PATCH] Add some debugging info. Don't reset timer when reading $4211. --- cpuexec.cpp | 3 +++ debug.cpp | 7 ++++--- ppu.cpp | 15 +++++++++------ unix/unix.cpp | 19 +++++++++++++++++++ unix/x11.cpp | 1 + 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/cpuexec.cpp b/cpuexec.cpp index 631f6a51..e3cf5a1a 100644 --- a/cpuexec.cpp +++ b/cpuexec.cpp @@ -257,6 +257,9 @@ void S9xMainLoop (void) CPU.IRQPending--; else { + #ifdef DEBUGGER + S9xTraceMessage ("Timer triggered\n"); + #endif CPU.IRQTransition = TRUE; } } diff --git a/debug.cpp b/debug.cpp index 2825cdbf..972c873e 100644 --- a/debug.cpp +++ b/debug.cpp @@ -889,7 +889,7 @@ static uint8 debug_cpu_op_print (char *Line, uint8 Bank, uint16 Address) break; } - sprintf(Line, "%-44s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%04ld VC:%03ld FC:%02d %03x %c %c%c", + sprintf(Line, "%-44s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%04ld VC:%03ld FC:%02d %c%c%c %c %c%c HT:%d VT:%d C:%d", Line, Registers.A.W, Registers.X.W, Registers.Y.W, Registers.D.W, Registers.DB, Registers.S.W, CheckEmulation() ? 'E' : 'e', @@ -904,10 +904,11 @@ static uint8 debug_cpu_op_print (char *Line, uint8 Bank, uint16 Address) (long) CPU.Cycles, (long) CPU.V_Counter, IPPU.FrameCount, - (CPU.IRQExternal ? 0x100 : 0) | (PPU.HTimerEnabled ? 0x10 : 0) | (PPU.VTimerEnabled ? 0x01 : 0), + CPU.IRQExternal ? 'E' : ' ', PPU.HTimerEnabled ? 'H' : ' ', PPU.VTimerEnabled ? 'V' : ' ', CPU.NMIPending ? 'N' : '.', CPU.IRQTransition ? 'T' : ' ', - CPU.IRQLine ? 'L' : ' '); + CPU.IRQLine ? 'L' : ' ', + PPU.HTimerPosition, PPU.VTimerPosition, Timings.NextIRQTimer); return (Size); } diff --git a/ppu.cpp b/ppu.cpp index ccf610a7..c2cf76d0 100644 --- a/ppu.cpp +++ b/ppu.cpp @@ -333,7 +333,7 @@ void S9xUpdateIRQPositions (bool initial) else if (PPU.HTimerEnabled && !PPU.VTimerEnabled) { Timings.NextIRQTimer = PPU.HTimerPosition; - if (CPU.Cycles > Timings.NextIRQTimer) + if (CPU.Cycles > Timings.NextIRQTimer - Timings.IRQTriggerCycles) Timings.NextIRQTimer += Timings.H_Max; } else if (!PPU.HTimerEnabled && PPU.VTimerEnabled) @@ -349,7 +349,7 @@ void S9xUpdateIRQPositions (bool initial) } #ifdef DEBUGGER - S9xTraceFormattedMessage("--- IRQ Timer set %d cycles HTimer:%d Pos:%04d->%04d VTimer:%d Pos:%03d->%03d", + S9xTraceFormattedMessage("--- IRQ Timer HC:%d VC:%d %s %d cycles HTimer:%d Pos:%04d->%04d VTimer:%d Pos:%03d->%03d", CPU.Cycles, CPU.V_Counter, initial ? "set" : "recur", Timings.NextIRQTimer, PPU.HTimerEnabled, PPU.IRQHBeamPos, PPU.HTimerPosition, PPU.VTimerEnabled, PPU.IRQVBeamPos, PPU.VTimerPosition); #endif } @@ -1848,10 +1848,13 @@ uint8 S9xGetCPU (uint16 Address) return ((byte & 0x80) | (OpenBus & 0x70) | Model->_5A22); case 0x4211: // TIMEUP - byte = CPU.IRQLine ? 0x80 : 0; - CPU.IRQLine = FALSE; - CPU.IRQTransition = FALSE; - S9xUpdateIRQPositions(false); + byte = 0; + if (CPU.IRQLine) + { + byte = 0x80; + CPU.IRQLine = FALSE; + CPU.IRQTransition = FALSE; + } return (byte | (OpenBus & 0x7f)); diff --git a/unix/unix.cpp b/unix/unix.cpp index 8b8ee430..5ac14cb4 100644 --- a/unix/unix.cpp +++ b/unix/unix.cpp @@ -306,6 +306,8 @@ struct SoundStatus int32 play_position; }; + +static int frame_advance = 0; static SUnixSettings unixSettings; static SoundStatus so; @@ -1188,6 +1190,12 @@ s9xcommand_t S9xGetPortCommandT (const char *n) return (cmd); } + else if (!strcmp(n, "Advance")) + { + cmd.type = S9xButtonPort; + cmd.port[1] = 3; + return (cmd); + } return (S9xGetDisplayCommandT(n)); } @@ -1220,6 +1228,9 @@ char * S9xGetPortCommandName (s9xcommand_t cmd) case 2: return (strdup("Rewind")); + + case 3: + return (strdup("Advance")); } break; @@ -1260,6 +1271,9 @@ void S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2) case 2: rewinding = (bool8) data1; break; + + case 3: + frame_advance = (bool8) data1; } break; @@ -1945,6 +1959,11 @@ int main (int argc, char **argv) S9xMainLoop(); } + if (Settings.Paused && frame_advance) + { + S9xMainLoop(); + frame_advance = 0; + } #ifdef NETPLAY_SUPPORT if (NP_Activated) diff --git a/unix/x11.cpp b/unix/x11.cpp index 0e51ddc8..cf4d8d03 100644 --- a/unix/x11.cpp +++ b/unix/x11.cpp @@ -567,6 +567,7 @@ const char * S9xParseDisplayConfig (ConfigFile &conf, int pass) keymaps.push_back(strpair_t("K00:slash", "Superscope Pause")); keymaps.push_back(strpair_t("K00:r", "Rewind")); + keymaps.push_back(strpair_t("K00:l", "Advance")); } GUI.no_repeat = !conf.GetBool("Unix/X11::SetKeyRepeat", TRUE);