sonarlint vid_svga.c

This commit is contained in:
Jasmine Iwanek
2023-07-30 19:22:43 -04:00
parent bc7cc2c14a
commit 478aa11172
2 changed files with 163 additions and 133 deletions

View File

@@ -31,7 +31,7 @@
# define FLAG_NOSKEW 16 # define FLAG_NOSKEW 16
# define FLAG_ADDR_BY16 32 # define FLAG_ADDR_BY16 32
# define FLAG_RAMDAC_SHIFT 64 # define FLAG_RAMDAC_SHIFT 64
# define FLAG_ATI 128 # define FLAG_ATI 128
# define FLAG_S3_911_16BIT 256 # define FLAG_S3_911_16BIT 256
# define FLAG_512K_MASK 512 # define FLAG_512K_MASK 512
struct monitor_t; struct monitor_t;
@@ -144,24 +144,24 @@ typedef struct svga_t {
For the example memory map, decode_mask would be 4MB-1 (4MB address space), vram_max would be 2MB For the example memory map, decode_mask would be 4MB-1 (4MB address space), vram_max would be 2MB
(present video memory only responds to first 2MB), vram_mask would be 1MB-1 (video memory wraps at 1MB) (present video memory only responds to first 2MB), vram_mask would be 1MB-1 (video memory wraps at 1MB)
*/ */
uint32_t decode_mask; uint32_t decode_mask;
uint32_t vram_max; uint32_t vram_max;
uint32_t vram_mask; uint32_t vram_mask;
uint32_t charseta; uint32_t charseta;
uint32_t charsetb; uint32_t charsetb;
uint32_t adv_flags; uint32_t adv_flags;
uint32_t ma_latch; uint32_t ma_latch;
uint32_t ca_adj; uint32_t ca_adj;
uint32_t ma; uint32_t ma;
uint32_t maback; uint32_t maback;
uint32_t write_bank; uint32_t write_bank;
uint32_t read_bank; uint32_t read_bank;
uint32_t extra_banks[2]; uint32_t extra_banks[2];
uint32_t banked_mask; uint32_t banked_mask;
uint32_t ca; uint32_t ca;
uint32_t overscan_color; uint32_t overscan_color;
uint32_t *map8; uint32_t *map8;
uint32_t pallook[512]; uint32_t pallook[512];
PALETTE vgapal; PALETTE vgapal;
@@ -183,8 +183,8 @@ typedef struct svga_t {
void (*render)(struct svga_t *svga); void (*render)(struct svga_t *svga);
void (*recalctimings_ex)(struct svga_t *svga); void (*recalctimings_ex)(struct svga_t *svga);
void (*video_out)(uint16_t addr, uint8_t val, void *p); void (*video_out)(uint16_t addr, uint8_t val, void *priv);
uint8_t (*video_in)(uint16_t addr, void *p); uint8_t (*video_in)(uint16_t addr, void *priv);
void (*hwcursor_draw)(struct svga_t *svga, int displine); void (*hwcursor_draw)(struct svga_t *svga, int displine);
@@ -195,7 +195,7 @@ typedef struct svga_t {
void (*vblank_start)(struct svga_t *svga); void (*vblank_start)(struct svga_t *svga);
void (*ven_write)(struct svga_t *svga, uint8_t val, uint32_t addr); void (*ven_write)(struct svga_t *svga, uint8_t val, uint32_t addr);
float (*getclock)(int clock, void *p); float (*getclock)(int clock, void *priv);
/* Called when VC=R18 and friends. If this returns zero then MA resetting /* Called when VC=R18 and friends. If this returns zero then MA resetting
is skipped. Matrox Mystique in Power mode reuses this counter for is skipped. Matrox Mystique in Power mode reuses this counter for
@@ -205,17 +205,17 @@ typedef struct svga_t {
/*Called at the start of vertical sync*/ /*Called at the start of vertical sync*/
void (*vsync_callback)(struct svga_t *svga); void (*vsync_callback)(struct svga_t *svga);
uint32_t (*translate_address)(uint32_t addr, void *p); uint32_t (*translate_address)(uint32_t addr, void *priv);
/*If set then another device is driving the monitor output and the SVGA /*If set then another device is driving the monitor output and the SVGA
card should not attempt to display anything */ card should not attempt to display anything */
int override; int override;
void *priv; void *priv;
uint8_t crtc[256]; uint8_t crtc[256];
uint8_t gdcreg[256]; uint8_t gdcreg[256];
uint8_t attrregs[32]; uint8_t attrregs[32];
uint8_t seqregs[256]; uint8_t seqregs[256];
uint8_t egapal[16]; uint8_t egapal[16];
uint8_t *vram; uint8_t *vram;
uint8_t *changedvram; uint8_t *changedvram;
@@ -266,55 +266,55 @@ typedef struct svga_t {
uint8_t monitor_index; uint8_t monitor_index;
/* Pointer to monitor */ /* Pointer to monitor */
monitor_t* monitor; monitor_t *monitor;
} svga_t; } svga_t;
extern int vga_on; extern int vga_on;
extern int ibm8514_on; extern int ibm8514_on;
extern void ibm8514_poll(ibm8514_t *dev, svga_t *svga); extern void ibm8514_poll(ibm8514_t *dev, svga_t *svga);
extern void ibm8514_recalctimings(svga_t *svga); extern void ibm8514_recalctimings(svga_t *svga);
extern uint8_t ibm8514_ramdac_in(uint16_t port, void *p); extern uint8_t ibm8514_ramdac_in(uint16_t port, void *priv);
extern void ibm8514_ramdac_out(uint16_t port, uint8_t val, void *p); extern void ibm8514_ramdac_out(uint16_t port, uint8_t val, void *priv);
extern int ibm8514_cpu_src(svga_t *svga); extern int ibm8514_cpu_src(svga_t *svga);
extern int ibm8514_cpu_dest(svga_t *svga); extern int ibm8514_cpu_dest(svga_t *svga);
extern void ibm8514_accel_out_pixtrans(svga_t *svga, uint16_t port, uint16_t val, int len); extern void ibm8514_accel_out_pixtrans(svga_t *svga, uint16_t port, uint16_t val, int len);
extern void ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, uint8_t ssv, int len); extern void ibm8514_short_stroke_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, uint8_t ssv, int len);
extern void ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, int len); extern void ibm8514_accel_start(int count, int cpu_input, uint32_t mix_dat, uint32_t cpu_dat, svga_t *svga, int len);
extern void xga_poll(xga_t *xga, svga_t *svga); extern void xga_poll(xga_t *xga, svga_t *svga);
extern void xga_recalctimings(svga_t *svga); extern void xga_recalctimings(svga_t *svga);
extern int svga_init(const device_t *info, svga_t *svga, void *p, int memsize, extern int svga_init(const device_t *info, svga_t *svga, void *priv, int memsize,
void (*recalctimings_ex)(struct svga_t *svga), void (*recalctimings_ex)(struct svga_t *svga),
uint8_t (*video_in)(uint16_t addr, void *p), uint8_t (*video_in)(uint16_t addr, void *priv),
void (*video_out)(uint16_t addr, uint8_t val, void *p), void (*video_out)(uint16_t addr, uint8_t val, void *priv),
void (*hwcursor_draw)(struct svga_t *svga, int displine), void (*hwcursor_draw)(struct svga_t *svga, int displine),
void (*overlay_draw)(struct svga_t *svga, int displine)); void (*overlay_draw)(struct svga_t *svga, int displine));
extern void svga_recalctimings(svga_t *svga); extern void svga_recalctimings(svga_t *svga);
extern void svga_close(svga_t *svga); extern void svga_close(svga_t *svga);
uint8_t svga_read(uint32_t addr, void *p); uint8_t svga_read(uint32_t addr, void *priv);
uint16_t svga_readw(uint32_t addr, void *p); uint16_t svga_readw(uint32_t addr, void *priv);
uint32_t svga_readl(uint32_t addr, void *p); uint32_t svga_readl(uint32_t addr, void *priv);
void svga_write(uint32_t addr, uint8_t val, void *p); void svga_write(uint32_t addr, uint8_t val, void *priv);
void svga_writew(uint32_t addr, uint16_t val, void *p); void svga_writew(uint32_t addr, uint16_t val, void *priv);
void svga_writel(uint32_t addr, uint32_t val, void *p); void svga_writel(uint32_t addr, uint32_t val, void *priv);
uint8_t svga_read_linear(uint32_t addr, void *p); uint8_t svga_read_linear(uint32_t addr, void *priv);
uint8_t svga_readb_linear(uint32_t addr, void *p); uint8_t svga_readb_linear(uint32_t addr, void *priv);
uint16_t svga_readw_linear(uint32_t addr, void *p); uint16_t svga_readw_linear(uint32_t addr, void *priv);
uint32_t svga_readl_linear(uint32_t addr, void *p); uint32_t svga_readl_linear(uint32_t addr, void *priv);
void svga_write_linear(uint32_t addr, uint8_t val, void *p); void svga_write_linear(uint32_t addr, uint8_t val, void *priv);
void svga_writeb_linear(uint32_t addr, uint8_t val, void *p); void svga_writeb_linear(uint32_t addr, uint8_t val, void *priv);
void svga_writew_linear(uint32_t addr, uint16_t val, void *p); void svga_writew_linear(uint32_t addr, uint16_t val, void *priv);
void svga_writel_linear(uint32_t addr, uint32_t val, void *p); void svga_writel_linear(uint32_t addr, uint32_t val, void *priv);
void svga_add_status_info(char *s, int max_len, void *p); void svga_add_status_info(char *s, int max_len, void *priv);
extern uint8_t svga_rotate[8][256]; extern uint8_t svga_rotate[8][256];
void svga_out(uint16_t addr, uint8_t val, void *p); void svga_out(uint16_t addr, uint8_t val, void *priv);
uint8_t svga_in(uint16_t addr, void *p); uint8_t svga_in(uint16_t addr, void *priv);
svga_t *svga_get_pri(void); svga_t *svga_get_pri(void);
void svga_set_override(svga_t *svga, int val); void svga_set_override(svga_t *svga, int val);
@@ -334,65 +334,65 @@ enum {
/* We need a way to add a device with a pointer to a parent device so it can attach itself to it, and /* We need a way to add a device with a pointer to a parent device so it can attach itself to it, and
possibly also a second ATi 68860 RAM DAC type that auto-sets SVGA render on RAM DAC render change. */ possibly also a second ATi 68860 RAM DAC type that auto-sets SVGA render on RAM DAC render change. */
extern void ati68860_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga); extern void ati68860_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga);
extern uint8_t ati68860_ramdac_in(uint16_t addr, void *p, svga_t *svga); extern uint8_t ati68860_ramdac_in(uint16_t addr, void *priv, svga_t *svga);
extern void ati68860_set_ramdac_type(void *p, int type); extern void ati68860_set_ramdac_type(void *priv, int type);
extern void ati68860_ramdac_set_render(void *p, svga_t *svga); extern void ati68860_ramdac_set_render(void *priv, svga_t *svga);
extern void ati68860_ramdac_set_pallook(void *p, int i, uint32_t col); extern void ati68860_ramdac_set_pallook(void *priv, int i, uint32_t col);
extern void ati68860_hwcursor_draw(svga_t *svga, int displine); extern void ati68860_hwcursor_draw(svga_t *svga, int displine);
extern void att49x_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *p, svga_t *svga); extern void att49x_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *svga);
extern uint8_t att49x_ramdac_in(uint16_t addr, int rs2, void *p, svga_t *svga); extern uint8_t att49x_ramdac_in(uint16_t addr, int rs2, void *priv, svga_t *svga);
extern void att498_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *p, svga_t *svga); extern void att498_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *svga);
extern uint8_t att498_ramdac_in(uint16_t addr, int rs2, void *p, svga_t *svga); extern uint8_t att498_ramdac_in(uint16_t addr, int rs2, void *priv, svga_t *svga);
extern float av9194_getclock(int clock, void *p); extern float av9194_getclock(int clock, void *priv);
extern void bt48x_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *p, svga_t *svga); extern void bt48x_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, svga_t *svga);
extern uint8_t bt48x_ramdac_in(uint16_t addr, int rs2, int rs3, void *p, svga_t *svga); extern uint8_t bt48x_ramdac_in(uint16_t addr, int rs2, int rs3, void *priv, svga_t *svga);
extern void bt48x_recalctimings(void *p, svga_t *svga); extern void bt48x_recalctimings(void *priv, svga_t *svga);
extern void bt48x_hwcursor_draw(svga_t *svga, int displine); extern void bt48x_hwcursor_draw(svga_t *svga, int displine);
extern void ibm_rgb528_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *p, svga_t *svga); extern void ibm_rgb528_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *svga);
extern uint8_t ibm_rgb528_ramdac_in(uint16_t addr, int rs2, void *p, svga_t *svga); extern uint8_t ibm_rgb528_ramdac_in(uint16_t addr, int rs2, void *priv, svga_t *svga);
extern void ibm_rgb528_recalctimings(void *p, svga_t *svga); extern void ibm_rgb528_recalctimings(void *priv, svga_t *svga);
extern void ibm_rgb528_hwcursor_draw(svga_t *svga, int displine); extern void ibm_rgb528_hwcursor_draw(svga_t *svga, int displine);
extern void icd2061_write(void *p, int val); extern void icd2061_write(void *priv, int val);
extern float icd2061_getclock(int clock, void *p); extern float icd2061_getclock(int clock, void *priv);
/* The code is the same, the #define's are so that the correct name can be used. */ /* The code is the same, the #define's are so that the correct name can be used. */
# define ics9161_write icd2061_write # define ics9161_write icd2061_write
# define ics9161_getclock icd2061_getclock # define ics9161_getclock icd2061_getclock
extern float ics2494_getclock(int clock, void *p); extern float ics2494_getclock(int clock, void *priv);
extern void ics2595_write(void *p, int strobe, int dat); extern void ics2595_write(void *priv, int strobe, int dat);
extern double ics2595_getclock(void *p); extern double ics2595_getclock(void *priv);
extern void ics2595_setclock(void *p, double clock); extern void ics2595_setclock(void *priv, double clock);
extern void sc1148x_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *p, svga_t *svga); extern void sc1148x_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *svga);
extern uint8_t sc1148x_ramdac_in(uint16_t addr, int rs2, void *p, svga_t *svga); extern uint8_t sc1148x_ramdac_in(uint16_t addr, int rs2, void *priv, svga_t *svga);
extern void sc1502x_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga); extern void sc1502x_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga);
extern uint8_t sc1502x_ramdac_in(uint16_t addr, void *p, svga_t *svga); extern uint8_t sc1502x_ramdac_in(uint16_t addr, void *priv, svga_t *svga);
extern void sdac_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *p, svga_t *svga); extern void sdac_ramdac_out(uint16_t addr, int rs2, uint8_t val, void *priv, svga_t *svga);
extern uint8_t sdac_ramdac_in(uint16_t addr, int rs2, void *p, svga_t *svga); extern uint8_t sdac_ramdac_in(uint16_t addr, int rs2, void *priv, svga_t *svga);
extern float sdac_getclock(int clock, void *p); extern float sdac_getclock(int clock, void *priv);
extern void stg_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga); extern void stg_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga);
extern uint8_t stg_ramdac_in(uint16_t addr, void *p, svga_t *svga); extern uint8_t stg_ramdac_in(uint16_t addr, void *priv, svga_t *svga);
extern float stg_getclock(int clock, void *p); extern float stg_getclock(int clock, void *priv);
extern void tkd8001_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga); extern void tkd8001_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga);
extern uint8_t tkd8001_ramdac_in(uint16_t addr, void *p, svga_t *svga); extern uint8_t tkd8001_ramdac_in(uint16_t addr, void *priv, svga_t *svga);
extern void tvp3026_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *p, svga_t *svga); extern void tvp3026_ramdac_out(uint16_t addr, int rs2, int rs3, uint8_t val, void *priv, svga_t *svga);
extern uint8_t tvp3026_ramdac_in(uint16_t addr, int rs2, int rs3, void *p, svga_t *svga); extern uint8_t tvp3026_ramdac_in(uint16_t addr, int rs2, int rs3, void *priv, svga_t *svga);
extern void tvp3026_recalctimings(void *p, svga_t *svga); extern void tvp3026_recalctimings(void *priv, svga_t *svga);
extern void tvp3026_hwcursor_draw(svga_t *svga, int displine); extern void tvp3026_hwcursor_draw(svga_t *svga, int displine);
extern float tvp3026_getclock(int clock, void *p); extern float tvp3026_getclock(int clock, void *priv);
# ifdef EMU_DEVICE_H # ifdef EMU_DEVICE_H
extern const device_t ati68860_ramdac_device; extern const device_t ati68860_ramdac_device;

View File

@@ -169,7 +169,7 @@ svga_out(uint16_t addr, uint8_t val, void *priv)
case 0x3c3: case 0x3c3:
if (xga_enabled) { if (xga_enabled) {
svga->xga.on = (val & 0x01) ? 0 : 1; svga->xga.on = (val & 0x01) ? 0 : 1;
vga_on = !svga->xga.on; vga_on = !svga->xga.on;
} }
break; break;
case 0x3c4: case 0x3c4:
@@ -205,6 +205,9 @@ svga_out(uint16_t addr, uint8_t val, void *priv)
svga->chain4 = val & 8; svga->chain4 = val & 8;
svga->fast = (svga->gdcreg[8] == 0xff && !(svga->gdcreg[3] & 0x18) && !svga->gdcreg[1]) && ((svga->chain4 && (svga->packed_chain4 || svga->force_old_addr)) || svga->fb_only) && !(svga->adv_flags & FLAG_ADDR_BY8); svga->fast = (svga->gdcreg[8] == 0xff && !(svga->gdcreg[3] & 0x18) && !svga->gdcreg[1]) && ((svga->chain4 && (svga->packed_chain4 || svga->force_old_addr)) || svga->fb_only) && !(svga->adv_flags & FLAG_ADDR_BY8);
break; break;
default:
break;
} }
break; break;
case 0x2ea: case 0x2ea:
@@ -245,6 +248,9 @@ svga_out(uint16_t addr, uint8_t val, void *priv)
svga->dac_pos = 0; svga->dac_pos = 0;
svga->dac_addr = (svga->dac_addr + 1) & 255; svga->dac_addr = (svga->dac_addr + 1) & 255;
break; break;
default:
break;
} }
break; break;
case 0x3ce: case 0x3ce:
@@ -283,18 +289,27 @@ svga_out(uint16_t addr, uint8_t val, void *priv)
mem_mapping_set_addr(&svga->mapping, 0xb8000, 0x08000); mem_mapping_set_addr(&svga->mapping, 0xb8000, 0x08000);
svga->banked_mask = 0x7fff; svga->banked_mask = 0x7fff;
break; break;
default:
break;
} }
} }
break; break;
case 7: case 7:
svga->colournocare = val; svga->colournocare = val;
break; break;
default:
break;
} }
svga->gdcreg[svga->gdcaddr & 15] = val; svga->gdcreg[svga->gdcaddr & 15] = val;
svga->fast = (svga->gdcreg[8] == 0xff && !(svga->gdcreg[3] & 0x18) && !svga->gdcreg[1]) && ((svga->chain4 && (svga->packed_chain4 || svga->force_old_addr)) || svga->fb_only); svga->fast = (svga->gdcreg[8] == 0xff && !(svga->gdcreg[3] & 0x18) && !svga->gdcreg[1]) && ((svga->chain4 && (svga->packed_chain4 || svga->force_old_addr)) || svga->fb_only);
if (((svga->gdcaddr & 15) == 5 && (val ^ o) & 0x70) || ((svga->gdcaddr & 15) == 6 && (val ^ o) & 1)) if (((svga->gdcaddr & 15) == 5 && (val ^ o) & 0x70) || ((svga->gdcaddr & 15) == 6 && (val ^ o) & 1))
svga_recalctimings(svga); svga_recalctimings(svga);
break; break;
default:
break;
} }
} }
@@ -362,6 +377,9 @@ svga_in(uint16_t addr, void *priv)
else else
ret = svga->vgapal[index].b & 0x3f; ret = svga->vgapal[index].b & 0x3f;
break; break;
default:
break;
} }
if (svga->adv_flags & FLAG_RAMDAC_SHIFT) if (svga->adv_flags & FLAG_RAMDAC_SHIFT)
ret >>= 2; ret >>= 2;
@@ -403,6 +421,9 @@ svga_in(uint16_t addr, void *priv)
ret = svga->cgastat; ret = svga->cgastat;
break; break;
default:
break;
} }
return ret; return ret;
@@ -561,8 +582,14 @@ svga_recalctimings(svga_t *svga)
else else
svga->render = svga_render_32bpp_highres; svga->render = svga_render_32bpp_highres;
break; break;
default:
break;
} }
break; break;
default:
break;
} }
} }
} }
@@ -698,15 +725,15 @@ svga_do_render(svga_t *svga)
void void
svga_poll(void *priv) svga_poll(void *priv)
{ {
svga_t *svga = (svga_t *) priv; svga_t *svga = (svga_t *) priv;
ibm8514_t *dev = &svga->dev8514; ibm8514_t *dev = &svga->dev8514;
uint32_t x; uint32_t x;
uint32_t blink_delay; uint32_t blink_delay;
int wx; int wx;
int wy; int wy;
int ret; int ret;
int old_ma; int old_ma;
int linecountff = 0; int linecountff = 0;
if (!vga_on && ibm8514_enabled && ibm8514_on) { if (!vga_on && ibm8514_enabled && ibm8514_on) {
if (!dev->local) { if (!dev->local) {
@@ -808,14 +835,14 @@ svga_poll(void *priv)
if ((svga->sc == (svga->crtc[11] & 31)) || (svga->sc == svga->rowcount)) if ((svga->sc == (svga->crtc[11] & 31)) || (svga->sc == svga->rowcount))
svga->con = 0; svga->con = 0;
if (svga->dispon) { if (svga->dispon) {
/*Real IBM 8514/A or compatibility mode doesn't have linedbl, so skip those.*/ /*Real IBM 8514/A or compatibility mode doesn't have linedbl, so skip those.*/
if (dev->local && ibm8514_on) { if (dev->local && ibm8514_on) {
svga->linedbl = 0; svga->linedbl = 0;
svga->linecountff = 0; svga->linecountff = 0;
linecountff = 1; linecountff = 1;
} }
if (svga->linedbl && !svga->linecountff && !linecountff) { if (svga->linedbl && !svga->linecountff && !linecountff) {
svga->linecountff = 1; svga->linecountff = 1;
svga->ma = svga->maback; svga->ma = svga->maback;
} else if (svga->sc == svga->rowcount) { } else if (svga->sc == svga->rowcount) {
svga->linecountff = 0; svga->linecountff = 0;
@@ -920,7 +947,7 @@ svga_poll(void *priv)
svga->oddeven ^= 1; svga->oddeven ^= 1;
svga->monitor->mon_changeframecount = svga->interlace ? 3 : 2; svga->monitor->mon_changeframecount = svga->interlace ? 3 : 2;
svga->vslines = 0; svga->vslines = 0;
if ((dev->local && vga_on) || !dev->local) { if ((dev->local && vga_on) || !dev->local) {
if (svga->interlace && svga->oddeven) if (svga->interlace && svga->oddeven)
@@ -933,7 +960,7 @@ svga_poll(void *priv)
else else
svga->ma = svga->maback = svga->ma_latch; svga->ma = svga->maback = svga->ma_latch;
} }
svga->ca = ((svga->crtc[0xe] << 8) | svga->crtc[0xf]) + ((svga->crtc[0xb] & 0x60) >> 5) + svga->ca_adj; svga->ca = ((svga->crtc[0xe] << 8) | svga->crtc[0xf]) + ((svga->crtc[0xb] & 0x60) >> 5) + svga->ca_adj;
svga->ma = (svga->ma << 2); svga->ma = (svga->ma << 2);
svga->maback = (svga->maback << 2); svga->maback = (svga->maback << 2);
svga->ca = (svga->ca << 2); svga->ca = (svga->ca << 2);
@@ -994,9 +1021,9 @@ svga_init(const device_t *info, svga_t *svga, void *priv, int memsize,
{ {
int e; int e;
svga->priv = priv; svga->priv = priv;
svga->monitor_index = monitor_index_global; svga->monitor_index = monitor_index_global;
svga->monitor = &monitors[svga->monitor_index]; svga->monitor = &monitors[svga->monitor_index];
for (int c = 0; c < 256; c++) { for (int c = 0; c < 256; c++) {
e = c; e = c;
@@ -1010,10 +1037,10 @@ svga_init(const device_t *info, svga_t *svga, void *priv, int memsize,
svga->attrregs[0x11] = 0; svga->attrregs[0x11] = 0;
svga->overscan_color = 0x000000; svga->overscan_color = 0x000000;
svga->monitor->mon_overscan_x = 16; svga->monitor->mon_overscan_x = 16;
svga->monitor->mon_overscan_y = 32; svga->monitor->mon_overscan_y = 32;
svga->x_add = 8; svga->x_add = 8;
svga->y_add = 16; svga->y_add = 16;
svga->crtc[0] = 63; svga->crtc[0] = 63;
svga->crtc[6] = 255; svga->crtc[6] = 255;
@@ -1127,7 +1154,7 @@ svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *priv)
svga_t *svga = (svga_t *) priv; svga_t *svga = (svga_t *) priv;
int writemask2 = svga->writemask; int writemask2 = svga->writemask;
int reset_wm = 0; int reset_wm = 0;
latch_t vall; latch_t vall;
uint8_t wm = svga->writemask; uint8_t wm = svga->writemask;
uint8_t count; uint8_t count;
@@ -1156,7 +1183,7 @@ svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *priv)
} }
} else { } else {
svga->xga.on = 0; svga->xga.on = 0;
vga_on = !svga->xga.on; vga_on = !svga->xga.on;
} }
} }
addr = svga_decode_addr(svga, addr, 1); addr = svga_decode_addr(svga, addr, 1);
@@ -1328,6 +1355,9 @@ svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *priv)
} }
} }
break; break;
default:
break;
} }
if (reset_wm) if (reset_wm)
@@ -1354,11 +1384,11 @@ svga_read_common(uint32_t addr, uint8_t linear, void *priv)
if (((svga->xga.op_mode & 7) >= 4) && (svga->xga.aperture_cntl >= 1)) { if (((svga->xga.op_mode & 7) >= 4) && (svga->xga.aperture_cntl >= 1)) {
if (svga->xga.test == 0xa5) { /*Memory size test of XGA*/ if (svga->xga.test == 0xa5) { /*Memory size test of XGA*/
svga->xga.on = 1; svga->xga.on = 1;
vga_on = !svga->xga.on; vga_on = !svga->xga.on;
return svga->xga.test; return svga->xga.test;
} else if (svga->xga.test == 0x5a) { } else if (svga->xga.test == 0x5a) {
svga->xga.on = 1; svga->xga.on = 1;
vga_on = !svga->xga.on; vga_on = !svga->xga.on;
return svga->xga.test; return svga->xga.test;
} else if ((addr == 0xa0000) || (addr == 0xa0010)) { } else if ((addr == 0xa0000) || (addr == 0xa0010)) {
addr += svga->xga.read_bank; addr += svga->xga.read_bank;
@@ -1366,7 +1396,7 @@ svga_read_common(uint32_t addr, uint8_t linear, void *priv)
} }
} else { } else {
svga->xga.on = 0; svga->xga.on = 0;
vga_on = !svga->xga.on; vga_on = !svga->xga.on;
} }
} }
addr = svga_decode_addr(svga, addr, 0); addr = svga_decode_addr(svga, addr, 0);
@@ -1404,7 +1434,7 @@ svga_read_common(uint32_t addr, uint8_t linear, void *priv)
addr &= ~1; addr &= ~1;
if (linear && ibm8514_on && (svga->adv_flags & FLAG_ATI)) if (linear && ibm8514_on && (svga->adv_flags & FLAG_ATI))
addr &= svga->vram_mask; addr &= svga->vram_mask;
else else
addr <<= 2; addr <<= 2;
} else { } else {
if (linear && ibm8514_on && (svga->adv_flags & FLAG_ATI)) { if (linear && ibm8514_on && (svga->adv_flags & FLAG_ATI)) {
@@ -1586,8 +1616,8 @@ svga_writeb_linear(uint32_t addr, uint8_t val, void *priv)
if (addr >= svga->vram_max) if (addr >= svga->vram_max)
return; return;
addr &= svga->vram_mask; addr &= svga->vram_mask;
svga->changedvram[addr >> 12] = svga->monitor->mon_changeframecount; svga->changedvram[addr >> 12] = svga->monitor->mon_changeframecount;
*(uint8_t *) &svga->vram[addr] = val; *&svga->vram[addr] = val;
} }
void void
@@ -1713,7 +1743,7 @@ svga_writel_linear(uint32_t addr, uint32_t val, void *priv)
uint8_t uint8_t
svga_readb_linear(uint32_t addr, void *priv) svga_readb_linear(uint32_t addr, void *priv)
{ {
svga_t *svga = (svga_t *) priv; const svga_t *svga = (svga_t *) priv;
if (!svga->fast) if (!svga->fast)
return svga_read_linear(addr, priv); return svga_read_linear(addr, priv);
@@ -1722,7 +1752,7 @@ svga_readb_linear(uint32_t addr, void *priv)
if (addr >= svga->vram_max) if (addr >= svga->vram_max)
return 0xff; return 0xff;
return *(uint8_t *) &svga->vram[addr & svga->vram_mask]; return *&svga->vram[addr & svga->vram_mask];
} }
uint16_t uint16_t
@@ -1744,8 +1774,8 @@ svga_readw_common(uint32_t addr, uint8_t linear, void *priv)
addr &= svga->decode_mask; addr &= svga->decode_mask;
if (svga->translate_address) { if (svga->translate_address) {
uint8_t val1 = 0xff; uint8_t val1 = 0xff;
uint8_t val2 = 0xff; uint8_t val2 = 0xff;
uint32_t addr2 = svga->translate_address(addr, priv); uint32_t addr2 = svga->translate_address(addr, priv);
if (addr2 < svga->vram_max) if (addr2 < svga->vram_max)
val1 = svga->vram[addr2 & svga->vram_mask]; val1 = svga->vram[addr2 & svga->vram_mask];
@@ -1792,10 +1822,10 @@ svga_readl_common(uint32_t addr, uint8_t linear, void *priv)
addr &= svga->decode_mask; addr &= svga->decode_mask;
if (svga->translate_address) { if (svga->translate_address) {
uint8_t val1 = 0xff; uint8_t val1 = 0xff;
uint8_t val2 = 0xff; uint8_t val2 = 0xff;
uint8_t val3 = 0xff; uint8_t val3 = 0xff;
uint8_t val4 = 0xff; uint8_t val4 = 0xff;
uint32_t addr2 = svga->translate_address(addr, priv); uint32_t addr2 = svga->translate_address(addr, priv);
if (addr2 < svga->vram_max) if (addr2 < svga->vram_max)
val1 = svga->vram[addr2 & svga->vram_mask]; val1 = svga->vram[addr2 & svga->vram_mask];