Skip to content

Commit c2ebab9

Browse files
committed
video/pc_vga: retire vblank_timer_cb override, add a latch_start_addr fn in place
1 parent 3eea926 commit c2ebab9

12 files changed

+47
-34
lines changed

src/devices/bus/pci/clgd546x_laguna.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
DEFINE_DEVICE_TYPE(CIRRUS_GD5465_LAGUNA3D, cirrus_gd5465_laguna3d_device, "clgd5465_laguna", "Cirrus Logic GD-5465 \"Laguna 3D\"")
2020

2121
cirrus_gd5465_laguna3d_device::cirrus_gd5465_laguna3d_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
22-
: pci_device(mconfig, CIRRUS_GD5465_LAGUNA3D, tag, owner, clock)
23-
, m_vga(*this, "svga")
22+
: pci_card_device(mconfig, CIRRUS_GD5465_LAGUNA3D, tag, owner, clock)
23+
, m_vga(*this, "vga")
2424
, m_vga_rom(*this, "vga_rom")
2525
{
2626
// device ID 0x1013 Cirrus Logic

src/devices/bus/pci/clgd546x_laguna.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
#pragma once
77

8-
#include "machine/pci.h"
8+
#include "pci_slot.h"
99
#include "video/pc_vga_cirrus.h"
1010

11-
class cirrus_gd5465_laguna3d_device : public pci_device
11+
class cirrus_gd5465_laguna3d_device : public pci_card_device
1212
{
1313
public:
1414
cirrus_gd5465_laguna3d_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

src/devices/video/pc_vga.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,9 @@
8383
#define GRAPHIC_MODE (vga.gc.alpha_dis) /* else text mode */
8484

8585
#define EGA_COLUMNS (vga.crtc.horz_disp_end+1)
86-
#define EGA_START_ADDRESS (vga.crtc.start_addr)
8786
#define EGA_LINE_LENGTH (vga.crtc.offset<<1)
8887

8988
#define VGA_COLUMNS (vga.crtc.horz_disp_end+1)
90-
#define VGA_START_ADDRESS (vga.crtc.start_addr)
9189
#define VGA_LINE_LENGTH (vga.crtc.offset<<3)
9290

9391
#define VGA_CH_WIDTH ((vga.sequencer.data[1]&1)?8:9)
@@ -101,7 +99,6 @@
10199
// Special values for SVGA Trident - Mode Vesa 110h
102100
#define TLINES (LINES)
103101
#define TGA_COLUMNS (EGA_COLUMNS)
104-
#define TGA_START_ADDRESS (vga.crtc.start_addr<<2)
105102
#define TGA_LINE_LENGTH (vga.crtc.offset<<3)
106103

107104

@@ -1356,7 +1353,7 @@ void vga_device::vga_vh_ega(bitmap_rgb32 &bitmap, const rectangle &cliprect)
13561353
int height = vga.crtc.maximum_scan_line * (vga.crtc.scan_doubling + 1);
13571354
int pel_shift = (vga.attribute.pel_shift & 7);
13581355

1359-
for (int addr=EGA_START_ADDRESS, line=0; line<LINES; line += height, addr += offset())
1356+
for (int addr = vga.crtc.start_addr, line = 0; line < LINES; line += height, addr += offset())
13601357
{
13611358
for (int yi=0;yi<height;yi++)
13621359
{
@@ -1839,7 +1836,7 @@ void vga_device::mem_linear_w(offs_t offset, uint8_t data)
18391836
/* VBLANK callback, start address definitely updates AT vblank, not before. */
18401837
TIMER_CALLBACK_MEMBER(vga_device::vblank_timer_cb)
18411838
{
1842-
vga.crtc.start_addr = vga.crtc.start_addr_latch;
1839+
vga.crtc.start_addr = latch_start_addr();
18431840
vga.attribute.pel_shift = vga.attribute.pel_shift_latch;
18441841
m_vblank_timer->adjust( screen().time_until_pos(vga.crtc.vert_blank_start + vga.crtc.vert_blank_end) );
18451842
}
@@ -1896,7 +1893,7 @@ void svga_device::svga_vh_rgb8(bitmap_rgb32 &bitmap, const rectangle &cliprect)
18961893
// }
18971894

18981895
uint8_t start_shift = (!(vga.sequencer.data[4] & 0x08) || svga.ignore_chain4) ? 2 : 0;
1899-
for (int addr = VGA_START_ADDRESS << start_shift, line=0; line<LINES; line+=height, addr+=offset(), curr_addr+=offset())
1896+
for (int addr = vga.crtc.start_addr << start_shift, line=0; line<LINES; line+=height, addr += offset(), curr_addr+=offset())
19001897
{
19011898
for (int yi = 0;yi < height; yi++)
19021899
{
@@ -1932,7 +1929,7 @@ void svga_device::svga_vh_rgb15(bitmap_rgb32 &bitmap, const rectangle &cliprect)
19321929
// uint16_t mask_comp = 0xff | (TLINES & 0x300);
19331930
int curr_addr = 0;
19341931
int yi=0;
1935-
for (int addr = TGA_START_ADDRESS, line=0; line<TLINES; line+=height, addr+=offset(), curr_addr+=offset())
1932+
for (int addr = vga.crtc.start_addr << 2, line=0; line<TLINES; line+=height, addr+=offset(), curr_addr+=offset())
19361933
{
19371934
uint32_t *const bitmapline = &bitmap.pix(line);
19381935
addr %= vga.svga_intf.vram_size;
@@ -1967,7 +1964,7 @@ void svga_device::svga_vh_rgb16(bitmap_rgb32 &bitmap, const rectangle &cliprect)
19671964
// uint16_t mask_comp = 0xff | (TLINES & 0x300);
19681965
int curr_addr = 0;
19691966
int yi=0;
1970-
for (int addr = TGA_START_ADDRESS, line=0; line<TLINES; line+=height, addr+=offset(), curr_addr+=offset())
1967+
for (int addr = vga.crtc.start_addr << 2, line=0; line<TLINES; line+=height, addr+=offset(), curr_addr+=offset())
19711968
{
19721969
uint32_t *const bitmapline = &bitmap.pix(line);
19731970
addr %= vga.svga_intf.vram_size;
@@ -2002,7 +1999,7 @@ void svga_device::svga_vh_rgb24(bitmap_rgb32 &bitmap, const rectangle &cliprect)
20021999
// uint16_t mask_comp = 0xff | (TLINES & 0x300);
20032000
int curr_addr = 0;
20042001
int yi=0;
2005-
for (int addr = TGA_START_ADDRESS<<1, line=0; line<TLINES; line+=height, addr+=offset(), curr_addr+=offset())
2002+
for (int addr = vga.crtc.start_addr << 3, line=0; line<TLINES; line+=height, addr+=offset(), curr_addr+=offset())
20062003
{
20072004
uint32_t *const bitmapline = &bitmap.pix(line);
20082005
addr %= vga.svga_intf.vram_size;
@@ -2036,7 +2033,7 @@ void svga_device::svga_vh_rgb32(bitmap_rgb32 &bitmap, const rectangle &cliprect)
20362033
// mask_comp = 0xff | (TLINES & 0x300);
20372034
int curr_addr = 0;
20382035
int yi=0;
2039-
for (int addr = TGA_START_ADDRESS, line=0; line<TLINES; line+=height, addr+=(offset()), curr_addr+=(offset()))
2036+
for (int addr = vga.crtc.start_addr << 2, line=0; line<TLINES; line+=height, addr+=(offset()), curr_addr+=(offset()))
20402037
{
20412038
uint32_t *const bitmapline = &bitmap.pix(line);
20422039
addr %= vga.svga_intf.vram_size;

src/devices/video/pc_vga.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class vga_device : public device_t
4040
virtual void mem_w(offs_t offset, uint8_t data);
4141
virtual uint8_t mem_linear_r(offs_t offset);
4242
virtual void mem_linear_w(offs_t offset,uint8_t data);
43-
virtual TIMER_CALLBACK_MEMBER(vblank_timer_cb);
4443

4544
void set_offset(uint16_t val) { vga.crtc.offset = val; }
4645
void set_vram_size(size_t vram_size) { vga.svga_intf.vram_size = vram_size; }
@@ -65,6 +64,8 @@ class vga_device : public device_t
6564

6665
vga_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
6766

67+
TIMER_CALLBACK_MEMBER(vblank_timer_cb);
68+
6869
// device-level overrides
6970
virtual void device_start() override;
7071
virtual void device_reset() override;
@@ -128,7 +129,7 @@ class vga_device : public device_t
128129
// NOTE: do not use the subclassed result when determining pitch in SVGA modes.
129130
// dw & word mode should apply to normal VGA modes only.
130131
virtual uint16_t offset();
131-
virtual uint32_t start_addr();
132+
virtual uint32_t latch_start_addr() { return vga.crtc.start_addr_latch; }
132133
virtual uint8_t vga_latch_write(int offs, uint8_t data);
133134
inline uint8_t rotate_right(uint8_t val) { return (val >> vga.gc.rotate_count) | (val << (8 - vga.gc.rotate_count)); }
134135
inline uint8_t vga_logical_op(uint8_t data, uint8_t plane, uint8_t mask)
@@ -298,6 +299,8 @@ class vga_device : public device_t
298299
address_space_config m_atc_space_config;
299300

300301
bool m_ioas = false;
302+
private:
303+
uint32_t start_addr();
301304
};
302305

303306

src/devices/video/pc_vga_cirrus.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ void cirrus_gd5428_vga_device::device_start()
643643
save_item(NAME(m_hidden_dac_mode));
644644
save_pointer(NAME(gc_bank), 2);
645645

646-
m_vblank_timer = timer_alloc(FUNC(vga_device::vblank_timer_cb), this);
646+
m_vblank_timer = timer_alloc(FUNC(cirrus_gd5428_vga_device::vblank_timer_cb), this);
647647

648648
m_chip_id = 0x98; // GD5428 - Rev 0
649649
}
@@ -848,6 +848,20 @@ uint16_t cirrus_gd5428_vga_device::offset()
848848
return svga_device::offset();
849849
}
850850

851+
uint32_t cirrus_gd5428_vga_device::latch_start_addr()
852+
{
853+
if (svga.rgb24_en || svga.rgb32_en)
854+
return vga.crtc.start_addr_latch >> 1;
855+
856+
// FIXME: need to explicitly return earlier because rgb8_en is '1' in tandem with these
857+
if (svga.rgb15_en || svga.rgb16_en)
858+
return vga.crtc.start_addr_latch;
859+
860+
if (svga.rgb8_en)
861+
return vga.crtc.start_addr_latch << 2;
862+
return vga.crtc.start_addr_latch;
863+
}
864+
851865
void cirrus_gd5428_vga_device::start_bitblt()
852866
{
853867
uint32_t x,y;

src/devices/video/pc_vga_cirrus.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class cirrus_gd5428_vga_device : public svga_device
3030
virtual void device_start() override;
3131
virtual void device_reset() override;
3232
virtual uint16_t offset() override;
33+
virtual uint32_t latch_start_addr() override;
3334

3435
virtual void io_3cx_map(address_map &map) override;
3536

src/devices/video/pc_vga_matrox.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,15 @@ uint16_t matrox_vga_device::offset()
673673
return svga_device::offset();
674674
}
675675

676-
uint32_t matrox_vga_device::start_addr()
676+
uint32_t matrox_vga_device::latch_start_addr()
677677
{
678-
// TODO: fails VBEtest scrolling tests
679-
// if (m_mgamode)
680-
// return (vga.crtc.start_addr << 4);
678+
// TODO: fails SDD scrolling tests
679+
// Looks like it can latch per byte in SVGA modes, which contradicts what's in pc_vga
680+
// drawing functions.
681+
//if (m_mgamode)
682+
// return (vga.crtc.start_addr << 4);
681683

682-
return svga_device::start_addr();
684+
return vga.crtc.start_addr_latch;
683685
}
684686

685687
u16 matrox_vga_device::line_compare_mask()

src/devices/video/pc_vga_matrox.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class matrox_vga_device : public svga_device
4343
virtual void device_reset() override;
4444

4545
virtual uint16_t offset() override;
46-
virtual uint32_t start_addr() override;
46+
virtual uint32_t latch_start_addr() override;
4747
virtual void recompute_params() override;
4848
virtual void palette_update() override;
4949

src/devices/video/pc_vga_s3.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,16 @@ void s3vision864_vga_device::device_add_mconfig(machine_config &config)
4343
IBM8514A(config, "8514a", 0).set_vga_owner();
4444
}
4545

46-
TIMER_CALLBACK_MEMBER(s3vision864_vga_device::vblank_timer_cb)
46+
uint32_t s3vision864_vga_device::latch_start_addr()
4747
{
4848
if(s3.memory_config & 0x08)
4949
{
5050
// - SDD scrolling test expects a << 2 for 8bpp and no shift for anything else
5151
// - Slackware 3.x XF86_S3 expect a << 2 shift (to be confirmed)
5252
// - przonegd expect no shift (RGB16)
53-
vga.crtc.start_addr = vga.crtc.start_addr_latch << (svga.rgb8_en ? 2 : 0);
53+
return vga.crtc.start_addr_latch << (svga.rgb8_en ? 2 : 0);
5454
}
55-
else
56-
vga.crtc.start_addr = vga.crtc.start_addr_latch;
57-
vga.attribute.pel_shift = vga.attribute.pel_shift_latch;
58-
m_vblank_timer->adjust( screen().time_until_pos(vga.crtc.vert_blank_start + vga.crtc.vert_blank_end) );
55+
return vga.crtc.start_addr_latch;
5956
}
6057

6158
void s3vision864_vga_device::device_start()

src/devices/video/pc_vga_s3.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ class s3vision864_vga_device : public svga_device
2121

2222
virtual uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) override;
2323

24-
virtual TIMER_CALLBACK_MEMBER(vblank_timer_cb) override;
25-
2624
ibm8514a_device* get_8514() { return m_8514; }
2725

2826
protected:
@@ -35,6 +33,7 @@ class s3vision864_vga_device : public svga_device
3533

3634
virtual void crtc_map(address_map &map) override;
3735
virtual void sequencer_map(address_map &map) override;
36+
virtual uint32_t latch_start_addr() override;
3837

3938
virtual u16 line_compare_mask() override;
4039

src/devices/video/pc_vga_trident.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ void trident_vga_device::device_start()
574574
save_pointer(tri.accel_pattern,"Pattern Data", 0x80);
575575
save_pointer(tri.lutdac_reg,"LUTDAC registers", 0x100);
576576

577-
m_vblank_timer = timer_alloc(FUNC(vga_device::vblank_timer_cb), this);
577+
m_vblank_timer = timer_alloc(FUNC(trident_vga_device::vblank_timer_cb), this);
578578
svga.ignore_chain4 = true;
579579
memset(&tri, 0, sizeof(tri));
580580
}

src/devices/video/s3virge.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void s3virge_vga_device::device_start()
102102
save_item(vga.sequencer.data,"Sequencer Registers");
103103
save_item(vga.attribute.data,"Attribute Registers");
104104

105-
m_vblank_timer = timer_alloc(FUNC(vga_device::vblank_timer_cb), this);
105+
m_vblank_timer = timer_alloc(FUNC(s3virge_vga_device::vblank_timer_cb), this);
106106
m_draw_timer = timer_alloc(FUNC(s3virge_vga_device::draw_step_tick), this);
107107

108108
memset(&s3, 0, sizeof(s3));
@@ -188,7 +188,7 @@ void s3virgedx_rev1_vga_device::device_reset()
188188
uint16_t s3virge_vga_device::offset()
189189
{
190190
// win98se expects 24bpp packed mode with x6 boundaries
191-
// this breaks VBETest, which detects these VESA modes as 32bpp.
191+
// this breaks SDD, which detects these VESA modes as 32bpp.
192192
if(svga.rgb24_en)
193193
return vga.crtc.offset * 6;
194194
return s3trio64_vga_device::offset();

0 commit comments

Comments
 (0)