Skip to content

Commit

Permalink
DEBUG: Do not clear cycle count when entering the debugger, doing so …
Browse files Browse the repository at this point in the history
…jumps emulator time forward up to 1ms. Add VRT command for programmers who wish to see the output of their program while debugging [#4980]
  • Loading branch information
joncampbell123 committed Jun 23, 2024
1 parent ba1c930 commit 1631099
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
Next:
- Fixed debugger mapper shortcut bug where entering the debugger

This comment has been minimized.

Copy link
@joncampbell123

joncampbell123 Jun 23, 2024

Author Owner

Forgot to mention, this bug, where CPU_Cycles and CPU_CyclesLeft are zeroed, is in DOSBox SVN and almost every other DOSBox fork. Just so you know, if you are attempting to debug anything.

completes the 1 ms "tick" early, effectively jumping emulator time
up to start of the next ms. This might explain the mysterious cases
where a program always fails to work unless you are debugging it.
(joncampbell123).
- Added debugger command "VRT" which resumes running the guest until
vertical retrace. Added for programmers who wish to write something
to screen and then see it show up. (joncampbell123).
- Fix IMGMOUNT, when mounting FAT disk images, to provide the DPB the
actual media id byte instead of assuming 0xF8 or 0xF0. INT AH=1Ch
should now report the proper media id byte for any floppy format,
Expand Down
13 changes: 11 additions & 2 deletions src/debug/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ char *FormatDate(uint16_t year, uint8_t month, uint8_t day);
void GFX_SetTitle(int32_t cycles, int frameskip, Bits timing, bool paused);
bool pc98_pegc_linear_framebuffer_enabled(void);

bool DEBUG_HaltOnRetrace = false;

extern bool dos_kernel_disabled;
extern bool is_paused;
extern bool pc98_crt_mode;
Expand Down Expand Up @@ -2228,6 +2230,11 @@ bool ParseCommand(char* str) {
return true;
}

if (command == "VRT") {
DEBUG_HaltOnRetrace = true;
command = "RUN";
}

if (command == "RUN") {
DrawRegistersUpdateOld();
debug_running = false;
Expand Down Expand Up @@ -3610,7 +3617,7 @@ bool ParseCommand(char* str) {
DEBUG_ShowMsg("SR [reg] [value] - Set register value. Multiple pairs allowed.\n");
DEBUG_ShowMsg("SM [seg]:[off] [val] [.]..- Set memory with following values.\n");
DEBUG_ShowMsg("SMV [addr] [val] [.].. - Set memory with following values at linear (virtual) address.\n");
DEBUG_ShowMsg("FM [seg]:[off] - Freeze memory value at address.\n");
DEBUG_ShowMsg("FM [seg]:[off] - Freeze memory value at address.\n");
DEBUG_ShowMsg("EV [value [value] ...] - Show register value(s).\n");
DEBUG_ShowMsg("IV [seg]:[off] [name] - Create var name for memory address.\n");
DEBUG_ShowMsg("SV [filename] - Save var list in file.\n");
Expand Down Expand Up @@ -3641,6 +3648,7 @@ bool ParseCommand(char* str) {
DEBUG_ShowMsg("TIMERIRQ - Run the system timer.\n");
DEBUG_ShowMsg("TIME [time] - Display or change the internal time.\n");
DEBUG_ShowMsg("DATE [date] - Display or change the internal date.\n");
DEBUG_ShowMsg("VRT - Run, then enter debugger at next vertical retrace.\n");

DEBUG_ShowMsg("IN[P|W|D] [port] - I/O port read byte/word/dword.\n");
DEBUG_ShowMsg("OUT[P|W|D] [port] [data] - I/O port write byte/word/dword.\n");
Expand Down Expand Up @@ -5157,7 +5165,8 @@ Bitu DEBUG_EnableDebugger(void)
if (!debugging || (debugging && debug_running))
DEBUG_Enable_Handler(true);

CPU_Cycles=CPU_CycleLeft=0;
CPU_CycleLeft += CPU_Cycles;
CPU_Cycles = 0;
return 0;
}

Expand Down
12 changes: 12 additions & 0 deletions src/hardware/vga_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5654,9 +5654,21 @@ pic_tickindex_t VGA_PITSync_delay(void) {
return et;
}

#if C_DEBUG
extern bool DEBUG_HaltOnRetrace;
Bitu DEBUG_EnableDebugger(void);
#endif

static void VGA_VerticalTimer(Bitu /*val*/) {
double current_time = PIC_GetCurrentEventTime();

#if C_DEBUG
if (DEBUG_HaltOnRetrace) {
DEBUG_EnableDebugger();
DEBUG_HaltOnRetrace = false;
}
#endif

dbg_event_maxscan = false;
dbg_event_scanstep = false;
dbg_event_hretrace = false;
Expand Down

0 comments on commit 1631099

Please sign in to comment.