joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.53k stars 371 forks source link

Immediate screen update when using debugger and single stepping - can this be enabled? #4980

Closed migry closed 5 days ago

migry commented 2 months ago

Question

I am running DOSBOX-X in a Ubuntu VM. I compiled the binary from sources (v 083.5). I added my own code to model the ISA card and behaviour of an EPROM programmer. I have been reverse engineering the DOS EXE software (from c. 1988 and compiled from C source code, with a Microsoft C compiler) using Ghidra and IDA-Pro(free) in order to understand some programming algorithms.

I am currently trying to understand code related to the user front end, which is character based, with menus and windows, as was common in the 80's (and TBH is implemented remarkably well!). The code writes directly to video memory, writing both textual characters and changing the attributes (for colour). I am setting breakpoints in known places, then using commands to view registers and memory.

I have put a breakpoint immediately after code which draws a specific box (I am 100% certain of which one), however when the breakpoint is hit, the screen does not show the expected character box.

My best guess is that DOSBOX-X only updates the emulated screen sixty times per second, to mimic the refresh of a CRT monitor. This is a guess, but might explain why screen video memory writes are not reflected on the emulated screen. If I continue to single step, the screen does eventually update, which supports this theory of mine.

I confirmed that at the breakpoint the video memory did contain the expected "data", by viewing video memory in the debugger (D b800:0000) but this was not shown on the emulated screen.

Is there a way to get the emulated screen to either refresh from video memory when stopped in the debugger?

Is there a way (a conf setting) to get the emulated video to immediately update after every video memory write.

I would like to single step through the code in the debugger and see each character appear on the screen as soon as the instruction to write to video memory has taken place.

Please advise as to whether this is possible, or simply not possible due to the way in which video emulation works.

Have you checked that no similar question(s) exist?

Code of Conduct & Contributing Guidelines

joncampbell123 commented 6 days ago

The box will not appear until the video hardware gets around to drawing it. The video raster follows emulator time, and it stops along with everything else when you break into the debugger.

If you want to see the box, draw the box and then add a loop to poll port 3DAh to wait for vertical retrace.

joncampbell123 commented 5 days ago

There is also the VRD command which forces the vertical retrace to end early to redraw the VGA display, though of course, that messes with vertical retrace and it does not fully draw the frame anyway.