diff --git a/bochs/iodev/display/voodoo.cc b/bochs/iodev/display/voodoo.cc index 858a0a02f..adbff25fd 100644 --- a/bochs/iodev/display/voodoo.cc +++ b/bochs/iodev/display/voodoo.cc @@ -468,7 +468,8 @@ bx_bool bx_voodoo_c::update_timing(void) } double vfreq = hfreq / (double)vtotal; BX_VOODOO_THIS s.vdraw.vtotal_usec = (unsigned)(1000000.0 / vfreq); - BX_VOODOO_THIS s.vdraw.vsync_usec = vsync * (unsigned)(1000000.0 / hfreq); + BX_VOODOO_THIS s.vdraw.htotal_usec = (unsigned)(1000000.0 / hfreq); + BX_VOODOO_THIS s.vdraw.vsync_usec = vsync * BX_VOODOO_THIS s.vdraw.htotal_usec; if ((BX_VOODOO_THIS s.vdraw.width != v->fbi.width) || (BX_VOODOO_THIS s.vdraw.height != v->fbi.height)) { BX_VOODOO_THIS s.vdraw.width = v->fbi.width; @@ -581,11 +582,14 @@ void bx_voodoo_c::redraw_area(unsigned x0, unsigned y0, unsigned width, v->fbi.video_changed = 1; } -bx_bool bx_voodoo_c::get_retrace(void) +Bit16u bx_voodoo_c::get_retrace(void) { Bit64u time_in_frame = bx_pc_system.time_usec() - BX_VOODOO_THIS s.vdraw.frame_start; - if (time_in_frame > BX_VOODOO_THIS s.vdraw.vsync_usec) return 1; - else return 0; + if (time_in_frame > BX_VOODOO_THIS s.vdraw.vsync_usec) { + return 0; + } else { + return (BX_VOODOO_THIS s.vdraw.vsync_usec - time_in_frame) / BX_VOODOO_THIS s.vdraw.htotal_usec; + } } void bx_voodoo_c::output_enable(bx_bool enabled) diff --git a/bochs/iodev/display/voodoo.h b/bochs/iodev/display/voodoo.h index fa89bab7d..375ad0085 100644 --- a/bochs/iodev/display/voodoo.h +++ b/bochs/iodev/display/voodoo.h @@ -28,6 +28,7 @@ typedef struct { struct { Bit32u width; Bit32u height; + Bit64u htotal_usec; Bit64u vtotal_usec; Bit64u vsync_usec; Bit64u frame_start; @@ -58,7 +59,7 @@ public: virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len); virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len); - static bx_bool get_retrace(void); + static Bit16u get_retrace(void); static void output_enable(bx_bool enabled); static void update_screen_start(void); static bx_bool update_timing(void); diff --git a/bochs/iodev/display/voodoo_func.h b/bochs/iodev/display/voodoo_func.h index 9736663b0..00d436fa9 100644 --- a/bochs/iodev/display/voodoo_func.h +++ b/bochs/iodev/display/voodoo_func.h @@ -2601,8 +2601,7 @@ Bit32u register_r(Bit32u offset) } /* bit 6 is the vertical retrace */ - //result |= v->fbi.vblank << 6; - result |= Voodoo_get_retrace() << 6; + result |= (Voodoo_get_retrace() > 0) << 6; /* bit 7 is FBI graphics engine busy */ if (v->pci.op_pending) @@ -2664,6 +2663,10 @@ Bit32u register_r(Bit32u offset) result = v->dac.read_result; break; + case vRetrace: + case hvRetrace: + result = Voodoo_get_retrace() & 0x1fff; + break; } return result;