Voodoo vertical retrace fixes

- vertical retrace bit in status register must be inverted
- implemented registers vRetrace and hvRetrace (vSyncOff only)
This commit is contained in:
Volker Ruppert 2014-01-15 17:29:28 +00:00
parent 63cb7f93bf
commit dfae4b45de
3 changed files with 15 additions and 7 deletions

View File

@ -468,7 +468,8 @@ bx_bool bx_voodoo_c::update_timing(void)
} }
double vfreq = hfreq / (double)vtotal; double vfreq = hfreq / (double)vtotal;
BX_VOODOO_THIS s.vdraw.vtotal_usec = (unsigned)(1000000.0 / vfreq); 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) || if ((BX_VOODOO_THIS s.vdraw.width != v->fbi.width) ||
(BX_VOODOO_THIS s.vdraw.height != v->fbi.height)) { (BX_VOODOO_THIS s.vdraw.height != v->fbi.height)) {
BX_VOODOO_THIS s.vdraw.width = v->fbi.width; 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; 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; 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; if (time_in_frame > BX_VOODOO_THIS s.vdraw.vsync_usec) {
else return 0; 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) void bx_voodoo_c::output_enable(bx_bool enabled)

View File

@ -28,6 +28,7 @@ typedef struct {
struct { struct {
Bit32u width; Bit32u width;
Bit32u height; Bit32u height;
Bit64u htotal_usec;
Bit64u vtotal_usec; Bit64u vtotal_usec;
Bit64u vsync_usec; Bit64u vsync_usec;
Bit64u frame_start; Bit64u frame_start;
@ -58,7 +59,7 @@ public:
virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len); virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len);
virtual void pci_write_handler(Bit8u address, Bit32u value, 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 output_enable(bx_bool enabled);
static void update_screen_start(void); static void update_screen_start(void);
static bx_bool update_timing(void); static bx_bool update_timing(void);

View File

@ -2601,8 +2601,7 @@ Bit32u register_r(Bit32u offset)
} }
/* bit 6 is the vertical retrace */ /* bit 6 is the vertical retrace */
//result |= v->fbi.vblank << 6; result |= (Voodoo_get_retrace() > 0) << 6;
result |= Voodoo_get_retrace() << 6;
/* bit 7 is FBI graphics engine busy */ /* bit 7 is FBI graphics engine busy */
if (v->pci.op_pending) if (v->pci.op_pending)
@ -2664,6 +2663,10 @@ Bit32u register_r(Bit32u offset)
result = v->dac.read_result; result = v->dac.read_result;
break; break;
case vRetrace:
case hvRetrace:
result = Voodoo_get_retrace() & 0x1fff;
break;
} }
return result; return result;