video/pc_vga.cpp: implement RAMDAC palette_update fn;

video/pc_vga_matrox.cpp: implement 8-bit palette DAC writes using palette_update fn;
This commit is contained in:
angelosa 2023-09-16 13:53:33 +02:00
parent 1ea6071031
commit a5b632f8ba
4 changed files with 60 additions and 16 deletions

View File

@ -37,6 +37,8 @@
manufacturers put together and which eventually became the VESA consortium.
It has incidentally a couple points in common across families but it's otherwise mostly a
commercial naming rather than a real physical change over the bus slot.
In the end we may not even need this extra device but rather move "SVGA mode"
responsibility to RAMDACs.
References:
- http://www.osdever.net/FreeVGA/vga/vga.htm
@ -1459,19 +1461,27 @@ void vga_device::vga_vh_mono(bitmap_rgb32 &bitmap, const rectangle &cliprect)
}
}
void vga_device::palette_update()
{
for (int i = 0; i < 256; i++)
{
set_pen_color(
i,
pal6bit(vga.dac.color[3*(i & vga.dac.mask) + 0] & 0x3f),
pal6bit(vga.dac.color[3*(i & vga.dac.mask) + 1] & 0x3f),
pal6bit(vga.dac.color[3*(i & vga.dac.mask) + 2] & 0x3f)
);
}
}
uint8_t vga_device::pc_vga_choosevideomode()
{
if (vga.crtc.sync_en)
{
if (vga.dac.dirty)
{
for (int i=0; i<256;i++)
{
/* TODO: color shifters? */
set_pen_color(i, (vga.dac.color[3*(i & vga.dac.mask)] & 0x3f) << 2,
(vga.dac.color[3*(i & vga.dac.mask) + 1] & 0x3f) << 2,
(vga.dac.color[3*(i & vga.dac.mask) + 2] & 0x3f) << 2);
}
palette_update();
vga.dac.dirty = 0;
}
@ -1991,13 +2001,7 @@ uint8_t svga_device::pc_vga_choosevideomode()
{
if (vga.dac.dirty)
{
for (int i=0; i<256;i++)
{
/* TODO: color shifters? */
set_pen_color(i, (vga.dac.color[3*(i & vga.dac.mask)] & 0x3f) << 2,
(vga.dac.color[3*(i & vga.dac.mask) + 1] & 0x3f) << 2,
(vga.dac.color[3*(i & vga.dac.mask) + 2] & 0x3f) << 2);
}
palette_update();
vga.dac.dirty = 0;
}

View File

@ -152,6 +152,7 @@ protected:
return res;
}
virtual bool get_interlace_mode() { return false; }
virtual void palette_update();
struct vga_t
{

View File

@ -38,6 +38,10 @@ void matrox_vga_device::device_start()
save_item(NAME(m_cursor_dcc));
save_pointer(NAME(m_cursor_color), 12);
save_pointer(NAME(m_cursor_ram), 0x400);
save_item(NAME(m_msc));
save_item(NAME(m_truecolor_ctrl));
save_item(NAME(m_multiplex_ctrl));
}
void matrox_vga_device::device_reset()
@ -57,6 +61,7 @@ void matrox_vga_device::device_reset()
m_cursor_x = 0;
m_cursor_y = 0;
m_msc = 0;
m_truecolor_ctrl = 0x80;
m_multiplex_ctrl = 0x98;
}
@ -377,8 +382,19 @@ void matrox_vga_device::ramdac_indexed_map(address_map &map)
// map(0x1a, 0x1a) CSR clock selection
// map(0x1c, 0x1c) palette page
// map(0x1d, 0x1d) GCR general control
// map(0x1e, 0x1e) MSC misc control
// MSC misc control
map(0x1e, 0x1e).lrw8(
NAME([this] (offs_t offset) {
logerror("$1e MSC R\n");
return m_msc;
}),
NAME([this] (offs_t offset, u8 data) {
logerror("$1e MSC W %02x\n", data);
if ((m_msc & 0xc) != (data & 0xc))
vga.dac.dirty = 1;
m_msc = data;
})
);
// map(0x2a, 0x2a) IOC GPIO control (bits 4-0, 1 = data bit as output, 0 = data bit as input)
// map(0x2b, 0x2b) GPIO data (bits 4-0)
// map(0x2d, 0x2d) pixel clock PLL
@ -515,6 +531,26 @@ void matrox_vga_device::flush_true_color_mode()
recompute_params();
}
void matrox_vga_device::palette_update()
{
// TODO: terminal pin handling
if ((m_msc & 0xc) != 0xc)
vga_device::palette_update();
else
{
for (int i = 0; i < 256; i++)
{
set_pen_color(
i,
vga.dac.color[3*(i & vga.dac.mask) + 0],
vga.dac.color[3*(i & vga.dac.mask) + 1],
vga.dac.color[3*(i & vga.dac.mask) + 2]
);
}
}
}
uint8_t matrox_vga_device::mem_r(offs_t offset)
{
if (m_mgamode)

View File

@ -45,6 +45,7 @@ protected:
virtual uint16_t offset() override;
virtual uint32_t start_addr() override;
virtual void recompute_params() override;
virtual void palette_update() override;
void crtcext_map(address_map &map);
void ramdac_indexed_map(address_map &map);
@ -100,6 +101,8 @@ private:
u8 m_multiplex_ctrl = 0;
u8 m_truecolor_ctrl = 0;
u8 m_msc = 0;
};
DECLARE_DEVICE_TYPE(MATROX_VGA, matrox_vga_device)