diff --git a/src/vid_mga.c b/src/vid_mga.c index a0820cc..131b30f 100644 --- a/src/vid_mga.c +++ b/src/vid_mga.c @@ -611,6 +611,7 @@ enum #define DMA_MODE_VECTOR 2 #define STATUS_SOFTRAPEN (1 << 0) +#define STATUS_VSYNCPEN (1 << 4) #define STATUS_VLINEPEN (1 << 5) #define STATUS_DWGENGSTS (1 << 16) #define STATUS_ENDPRDMASTS (1 << 17) @@ -711,6 +712,12 @@ void mystique_out(uint16_t addr, uint8_t val, void *p) svga->fullchange = changeframecount; svga_recalctimings(svga); } + if (svga->crtcreg == 0x11) + { + if (!(val & 0x10)) + mystique->status &= ~STATUS_VSYNCPEN; + mystique_update_irqs(mystique); + } } break; @@ -800,6 +807,18 @@ static int mystique_line_compare(svga_t *svga) return 0; } +static void mystique_vsync_callback(svga_t *svga) +{ + mystique_t *mystique = (mystique_t *)svga->p; + + if (svga->crtc[0x11] & 0x10) + { + mystique->status |= STATUS_VSYNCPEN; + mystique_update_irqs(mystique); + } + +} + void mystique_recalctimings(svga_t *svga) { mystique_t *mystique = (mystique_t *)svga->p; @@ -976,10 +995,13 @@ static void mystique_recalc_mapping(mystique_t *mystique) static void mystique_update_irqs(mystique_t *mystique) { + svga_t *svga = &mystique->svga; int irq = 0; if ((mystique->status & mystique->ien) & STATUS_SOFTRAPEN) irq = 1; + if ((mystique->status & STATUS_VSYNCPEN) && (svga->crtc[0x11] & 0x30) == 0x10) + irq = 1; if (irq) pci_set_irq(mystique->card, PCI_INTA); @@ -5298,6 +5320,8 @@ void *mystique_init() mystique->status = STATUS_ENDPRDMASTS; + mystique->svga.vsync_callback = mystique_vsync_callback; + return mystique; } diff --git a/src/vid_svga.c b/src/vid_svga.c index 9c3cd7c..65443de 100644 --- a/src/vid_svga.c +++ b/src/vid_svga.c @@ -697,6 +697,9 @@ void svga_poll(void *p) // if (svga_interlace && oddeven) ma=maback=ma+(svga_rowoffset<<2); // pclog("Addr %08X vson %03X vsoff %01X %02X %02X %02X %i %i\n",ma,svga_vsyncstart,crtc[0x11]&0xF,crtc[0xD],crtc[0xC],crtc[0x33], svga_interlace, oddeven); + + if (svga->vsync_callback) + svga->vsync_callback(svga); } if (svga->vc == svga->vtotal) { diff --git a/src/vid_svga.h b/src/vid_svga.h index 83d9cbc..4b21f3d 100644 --- a/src/vid_svga.h +++ b/src/vid_svga.h @@ -129,6 +129,9 @@ typedef struct svga_t vertical line interrupt*/ int (*line_compare)(struct svga_t *svga); + /*Called at the start of vertical sync*/ + void (*vsync_callback)(struct svga_t *svga); + /*If set then another device is driving the monitor output and the SVGA card should not attempt to display anything */ int override;