From 10fed39261e9d13913d54ad156dfbf03374daaf4 Mon Sep 17 00:00:00 2001 From: angelosa Date: Sun, 18 Feb 2024 14:22:50 +0100 Subject: video/pc_vga: CRTC logmacro, fix a bunch of masks towards SVGA --- src/devices/bus/pci/vt6306.cpp | 1 + src/devices/video/pc_vga.cpp | 76 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/devices/bus/pci/vt6306.cpp b/src/devices/bus/pci/vt6306.cpp index 55db5398420..a68bace280d 100644 --- a/src/devices/bus/pci/vt6306.cpp +++ b/src/devices/bus/pci/vt6306.cpp @@ -7,6 +7,7 @@ VIA VT6306 generic FireWire IEEE 1394a card - paired with USB 2.0 controller on a Sunix UFC3212V 4x USB 3x Firewire card (as multifunction, at .3 while USB takes .0/.1/.2) - midway/midzeus.cpp crusnexo/thegrid uses regular IEEE 1394 ports. +- skeleton/pegasos2.cpp uses an on-board version of this. - PHY has default vendor ID=0x004063, device ID=306000, Compliance Level=1 **************************************************************************************************/ diff --git a/src/devices/video/pc_vga.cpp b/src/devices/video/pc_vga.cpp index d9dd075621d..aebada89fa9 100644 --- a/src/devices/video/pc_vga.cpp +++ b/src/devices/video/pc_vga.cpp @@ -58,6 +58,7 @@ #define LOG_WARN (1U << 1) #define LOG_REGS (1U << 2) // deprecated #define LOG_DSW (1U << 3) // Input sense at $3c2 +#define LOG_CRTC (1U << 4) // CRTC setups with monitor geometry #define VERBOSE (LOG_GENERAL | LOG_WARN | LOG_DSW) //#define LOG_OUTPUT_FUNC osd_printf_info @@ -66,6 +67,7 @@ #define LOGWARN(...) LOGMASKED(LOG_WARN, __VA_ARGS__) #define LOGREGS(...) LOGMASKED(LOG_REGS, __VA_ARGS__) #define LOGDSW(...) LOGMASKED(LOG_DSW, __VA_ARGS__) +#define LOGCRTC(...) LOGMASKED(LOG_CRTC, __VA_ARGS__) /*************************************************************************** @@ -665,9 +667,11 @@ void vga_device::crtc_map(address_map &map) }), NAME([this](offs_t offset, u8 data) { // doom (DOS) tries to write to protected regs + LOGCRTC("CR00 H total %02x %s", data, vga.crtc.protect_enable ? "P?\n" : "-> "); if(vga.crtc.protect_enable) return; vga.crtc.horz_total = (vga.crtc.horz_total & ~0xff) | (data & 0xff); + LOGCRTC("%04d\n", vga.crtc.horz_total); recompute_params(); }) ); @@ -676,9 +680,11 @@ void vga_device::crtc_map(address_map &map) return vga.crtc.horz_disp_end & 0xff; }), NAME([this](offs_t offset, u8 data) { + LOGCRTC("CR01 H display end %02x %s", data, vga.crtc.protect_enable ? "P?\n" : "-> "); if(vga.crtc.protect_enable) return; - vga.crtc.horz_disp_end = (data & 0xff); + vga.crtc.horz_disp_end = (vga.crtc.horz_disp_end & ~0xff) | (data & 0xff); + LOGCRTC("%04d\n", vga.crtc.horz_disp_end); recompute_params(); }) ); @@ -687,9 +693,11 @@ void vga_device::crtc_map(address_map &map) return vga.crtc.horz_blank_start & 0xff; }), NAME([this](offs_t offset, u8 data) { + LOGCRTC("CR02 H start blank %02x %s", data, vga.crtc.protect_enable ? "P?\n" : "-> "); if(vga.crtc.protect_enable) return; - vga.crtc.horz_blank_start = (data & 0xff); + vga.crtc.horz_blank_start = (vga.crtc.horz_blank_start & ~0xff) | (data & 0xff); + LOGCRTC("%04d\n", vga.crtc.horz_blank_start); }) ); map(0x03, 0x03).lrw8( @@ -700,12 +708,14 @@ void vga_device::crtc_map(address_map &map) return res; }), NAME([this](offs_t offset, u8 data) { + LOGCRTC("CR03 H blank end %02x %s", data, vga.crtc.protect_enable ? "P?\n" : "-> "); if(vga.crtc.protect_enable) return; vga.crtc.horz_blank_end &= ~0x1f; vga.crtc.horz_blank_end |= data & 0x1f; vga.crtc.disp_enable_skew = (data & 0x60) >> 5; vga.crtc.evra = BIT(data, 7); + LOGCRTC("%04d evra %d display enable skew %01x\n", vga.crtc.horz_blank_end, vga.crtc.evra, vga.crtc.disp_enable_skew); }) ); map(0x04, 0x04).lrw8( @@ -713,9 +723,11 @@ void vga_device::crtc_map(address_map &map) return vga.crtc.horz_retrace_start & 0xff; }), NAME([this](offs_t offset, u8 data) { + LOGCRTC("CR04 H retrace start %02x %s", data, vga.crtc.protect_enable ? "P?\n" : "-> "); if(vga.crtc.protect_enable) return; - vga.crtc.horz_retrace_start = data & 0xff; + vga.crtc.horz_retrace_start = (vga.crtc.horz_retrace_start & ~0xff) | (data & 0xff); + LOGCRTC("%04d\n", vga.crtc.horz_retrace_start); }) ); map(0x05, 0x05).lrw8( @@ -726,12 +738,18 @@ void vga_device::crtc_map(address_map &map) return res; }), NAME([this](offs_t offset, u8 data) { + LOGCRTC("CR05 H blank end %02x %s", data, vga.crtc.protect_enable ? "P?\n" : "-> "); if(vga.crtc.protect_enable) return; vga.crtc.horz_blank_end &= ~0x20; vga.crtc.horz_blank_end |= ((data & 0x80) >> 2); vga.crtc.horz_retrace_skew = ((data & 0x60) >> 5); - vga.crtc.horz_retrace_end = data & 0x1f; + vga.crtc.horz_retrace_end = (vga.crtc.horz_retrace_end & ~0x1f) | (data & 0x1f); + LOGCRTC("%04d retrace skew %01d retrace end %02d\n" + , vga.crtc.horz_blank_end + , vga.crtc.horz_retrace_skew + , vga.crtc.horz_retrace_end + ); }) ); map(0x06, 0x06).lrw8( @@ -739,10 +757,12 @@ void vga_device::crtc_map(address_map &map) return vga.crtc.vert_total & 0xff; }), NAME([this](offs_t offset, u8 data) { + LOGCRTC("CR06 V total %02x %s", data, vga.crtc.protect_enable ? "P?\n" : "-> "); if(vga.crtc.protect_enable) return; vga.crtc.vert_total &= ~0xff; vga.crtc.vert_total |= data & 0xff; + LOGCRTC("%04d\n", vga.crtc.vert_total); recompute_params(); }) ); @@ -762,6 +782,7 @@ void vga_device::crtc_map(address_map &map) NAME([this](offs_t offset, u8 data) { vga.crtc.line_compare &= ~0x100; vga.crtc.line_compare |= ((data & 0x10) << (8-4)); + LOGCRTC("CR07 Overflow %02x -> line compare %04d %s", data, vga.crtc.line_compare, vga.crtc.protect_enable ? "P?\n" : ""); if(vga.crtc.protect_enable) return; vga.crtc.vert_total &= ~0x300; @@ -775,6 +796,12 @@ void vga_device::crtc_map(address_map &map) vga.crtc.vert_retrace_start |= ((data & 0x04) << (8-2)); vga.crtc.vert_disp_end |= ((data & 0x02) << (8-1)); vga.crtc.vert_total |= ((data & 0x01) << (8-0)); + LOGCRTC("V total %04d V retrace start %04d V display end %04d V blank start %04d\n" + , vga.crtc.vert_total + , vga.crtc.vert_retrace_start + , vga.crtc.vert_disp_end + , vga.crtc.vert_blank_start + ); recompute_params(); }) ); @@ -788,6 +815,11 @@ void vga_device::crtc_map(address_map &map) NAME([this](offs_t offset, u8 data) { vga.crtc.byte_panning = (data & 0x60) >> 5; vga.crtc.preset_row_scan = (data & 0x1f); + LOGCRTC("CR08 Preset Row Scan %02x -> %02d byte panning %d\n" + , data + , vga.crtc.preset_row_scan + , vga.crtc.byte_panning + ); }) ); // Maximum Scan Line Register @@ -806,6 +838,13 @@ void vga_device::crtc_map(address_map &map) vga.crtc.line_compare |= ((data & 0x40) << (9-6)); vga.crtc.vert_blank_start |= ((data & 0x20) << (9-5)); vga.crtc.maximum_scan_line = (data & 0x1f) + 1; + LOGCRTC("CR09 Maximum Scan Line %02x -> %02d V blank start %04d line compare %04d scan doubling %d\n" + , data + , vga.crtc.maximum_scan_line + , vga.crtc.vert_blank_start + , vga.crtc.line_compare + , vga.crtc.scan_doubling + ); }) ); map(0x0a, 0x0a).lrw8( @@ -855,6 +894,7 @@ void vga_device::crtc_map(address_map &map) NAME([this](offs_t offset, u8 data) { vga.crtc.vert_retrace_start &= ~0xff; vga.crtc.vert_retrace_start |= data & 0xff; + LOGCRTC("CR10 V retrace start %02x -> %04d\n", data, vga.crtc.vert_retrace_start); }) ); map(0x11, 0x11).lrw8( @@ -869,9 +909,17 @@ void vga_device::crtc_map(address_map &map) NAME([this](offs_t offset, u8 data) { vga.crtc.protect_enable = (data & 0x80) >> 7; vga.crtc.bandwidth = (data & 0x40) >> 6; - vga.crtc.vert_retrace_end = data & 0x0f; + vga.crtc.vert_retrace_end = (vga.crtc.vert_retrace_end & ~0xf) | (data & 0x0f); + // TODO: these two doesn't seem part of the spec vga.crtc.irq_clear = (data & 0x10) >> 4; vga.crtc.irq_disable = (data & 0x20) >> 5; + LOGCRTC("CR11 V retrace end %02x -> %02d protect enable %d bandwidth %d irq %02x\n" + , data + , vga.crtc.vert_retrace_end + , vga.crtc.protect_enable + , vga.crtc.bandwidth + , data & 0x30 + ); }) ); map(0x12, 0x12).lrw8( @@ -881,6 +929,7 @@ void vga_device::crtc_map(address_map &map) NAME([this](offs_t offset, u8 data) { vga.crtc.vert_disp_end &= ~0xff; vga.crtc.vert_disp_end |= data & 0xff; + LOGCRTC("CR12 V display end %02x -> %04d\n", data, vga.crtc.vert_disp_end); recompute_params(); }) ); @@ -913,6 +962,7 @@ void vga_device::crtc_map(address_map &map) NAME([this](offs_t offset, u8 data) { vga.crtc.vert_blank_start &= ~0xff; vga.crtc.vert_blank_start |= data & 0xff; + LOGCRTC("CR15 V blank start %02x -> %04d\n", data, vga.crtc.vert_blank_start); }) ); map(0x16, 0x16).lrw8( @@ -920,7 +970,8 @@ void vga_device::crtc_map(address_map &map) return vga.crtc.vert_blank_end & 0x7f; }), NAME([this](offs_t offset, u8 data) { - vga.crtc.vert_blank_end = data & 0x7f; + vga.crtc.vert_blank_end = (vga.crtc.vert_blank_end & ~0x7f) | (data & 0x7f); + LOGCRTC("CR16 V blank end %02x -> %04d\n", data, vga.crtc.vert_blank_end); }) ); map(0x17, 0x17).lrw8( @@ -942,6 +993,18 @@ void vga_device::crtc_map(address_map &map) vga.crtc.sldiv = BIT(data, 2); vga.crtc.map14 = BIT(data, 1); vga.crtc.map13 = BIT(data, 0); + LOGCRTC("CR17 Mode control %02x -> Sync Enable %d Word/Byte %d Address Wrap select %d\n" + , data + , vga.crtc.sync_en + , vga.crtc.word_mode + , vga.crtc.aw + ); + LOGCRTC("\tDIV2 %d Scan Line Divide %d MAP14 %d MAP13 %d\n" + , vga.crtc.div2 + , vga.crtc.sldiv + , vga.crtc.map14 + , vga.crtc.map13 + ); }) ); map(0x18, 0x18).lrw8( @@ -951,6 +1014,7 @@ void vga_device::crtc_map(address_map &map) NAME([this](offs_t offset, u8 data) { vga.crtc.line_compare &= ~0xff; vga.crtc.line_compare |= data & 0xff; + LOGCRTC("CR18 Line Compare %02x -> %04d\n", data, vga.crtc.line_compare); }) ); // TODO: (undocumented) CR22 Memory Data Latch Register (read only) -- cgit v1.2.3