XGA: Revert to the rom_init routine to load the XGA-1/XGA-2 bios, this fixes intermittent hangs on the XGA-2 end (MCA only, ISA version is intact).

This commit is contained in:
TC1995
2022-09-01 17:52:51 +02:00
parent 874333e0ba
commit c3f6a46142

View File

@@ -46,7 +46,7 @@ xga_updatemapping(svga_t *svga)
{
xga_t *xga = &svga->xga;
// pclog("OpMode = %x, linear base = %08x, aperture cntl = %d, opmodereset1 = %d, access mode = %x, map = %x.\n", xga->op_mode, xga->linear_base, xga->aperture_cntl, xga->op_mode_reset, xga->access_mode, svga->gdcreg[6] & 0x0c);
//pclog("OpMode = %x, linear base = %08x, aperture cntl = %d, opmodereset1 = %d, access mode = %x, map = %x.\n", xga->op_mode, xga->linear_base, xga->aperture_cntl, xga->op_mode_reset, xga->access_mode, svga->gdcreg[6] & 0x0c);
if ((xga->op_mode & 7) >= 4) {
if (xga->aperture_cntl == 1) {
mem_mapping_disable(&svga->mapping);
@@ -135,16 +135,16 @@ xga_recalctimings(svga_t *svga)
switch (xga->clk_sel_1 & 0x0c) {
case 0:
if (xga->clk_sel_2 & 0x80) {
svga->clock = (cpuclock * (double) (1ull << 32)) / 41539000.0;
svga->clock = (cpuclock * (double)(1ull << 32)) / 41539000.0;
} else {
svga->clock = (cpuclock * (double) (1ull << 32)) / 25175000.0;
svga->clock = (cpuclock * (double)(1ull << 32)) / 25175000.0;
}
break;
case 4:
svga->clock = (cpuclock * (double) (1ull << 32)) / 28322000.0;
svga->clock = (cpuclock * (double)(1ull << 32)) / 28322000.0;
break;
case 0x0c:
svga->clock = (cpuclock * (double) (1ull << 32)) / 44900000.0;
svga->clock = (cpuclock * (double)(1ull << 32)) / 44900000.0;
break;
}
} else {
@@ -333,7 +333,7 @@ xga_ext_out_reg(xga_t *xga, svga_t *svga, uint8_t idx, uint8_t val)
xga->cursor_data_on = 0;
}
}
// pclog("Sprite POS = %d, data on = %d, idx = %d, apcntl = %d\n", xga->sprite_pos, xga->cursor_data_on, xga->sprite_pal_addr_idx, xga->aperture_cntl);
//pclog("Sprite POS = %d, data on = %d, idx = %d, apcntl = %d\n", xga->sprite_pos, xga->cursor_data_on, xga->sprite_pal_addr_idx, xga->aperture_cntl);
break;
case 0x62:
@@ -403,10 +403,10 @@ xga_ext_out_reg(xga_t *xga, svga_t *svga, uint8_t idx, uint8_t val)
static void
xga_ext_outb(uint16_t addr, uint8_t val, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
// pclog("[%04X:%08X]: EXT OUTB = %02x, val = %02x\n", CS, cpu_state.pc, addr, val);
//pclog("[%04X:%08X]: EXT OUTB = %02x, val = %02x\n", CS, cpu_state.pc, addr, val);
switch (addr & 0x0f) {
case 0:
xga->op_mode = val;
@@ -426,7 +426,7 @@ xga_ext_outb(uint16_t addr, uint8_t val, void *p)
break;
case 8:
xga->ap_idx = val;
// pclog("Aperture CNTL = %d, val = %02x, up to bit6 = %02x\n", xga->aperture_cntl, val, val & 0x3f);
//pclog("Aperture CNTL = %d, val = %02x, up to bit6 = %02x\n", xga->aperture_cntl, val, val & 0x3f);
if ((xga->op_mode & 7) < 4) {
xga->write_bank = xga->read_bank = 0;
} else {
@@ -454,7 +454,7 @@ xga_ext_outb(uint16_t addr, uint8_t val, void *p)
static uint8_t
xga_ext_inb(uint16_t addr, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
uint8_t ret, index;
@@ -651,7 +651,7 @@ xga_ext_inb(uint16_t addr, void *p)
break;
case 0x6a:
// pclog("Sprite POS Read = %d, addr idx = %04x\n", xga->sprite_pos, xga->sprite_pal_addr_idx_prefetch);
//pclog("Sprite POS Read = %d, addr idx = %04x\n", xga->sprite_pos, xga->sprite_pal_addr_idx_prefetch);
ret = xga->sprite_data[xga->sprite_pos_prefetch];
xga->sprite_pos_prefetch = (xga->sprite_pos_prefetch + 1) & 0x3ff;
break;
@@ -667,10 +667,11 @@ xga_ext_inb(uint16_t addr, void *p)
break;
}
// pclog("[%04X:%08X]: EXT INB = %02x, ret = %02x\n", CS, cpu_state.pc, addr, ret);
//pclog("[%04X:%08X]: EXT INB = %02x, ret = %02x\n", CS, cpu_state.pc, addr, ret);
return ret;
}
#define READ(addr, dat) \
dat = xga->vram[(addr) & (xga->vram_mask)];
@@ -679,14 +680,14 @@ xga_ext_inb(uint16_t addr, void *p)
xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = changeframecount;
#define READW(addr, dat) \
dat = *(uint16_t *) &xga->vram[(addr) & (xga->vram_mask)];
dat = *(uint16_t *)&xga->vram[(addr) & (xga->vram_mask)];
#define READW_REVERSE(addr, dat) \
dat = xga->vram[(addr + 1) & (xga->vram_mask - 1)] & 0xff; \
dat |= (xga->vram[(addr) & (xga->vram_mask - 1)] << 8);
#define WRITEW(addr, dat) \
*(uint16_t *) &xga->vram[((addr)) & (xga->vram_mask)] = dat; \
*(uint16_t *)&xga->vram[((addr)) & (xga->vram_mask)] = dat; \
xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = changeframecount;
#define WRITEW_REVERSE(addr, dat) \
@@ -694,75 +695,30 @@ xga_ext_inb(uint16_t addr, void *p)
xga->vram[((addr)) & (xga->vram_mask - 1)] = dat >> 8; \
xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = changeframecount;
#define ROP(mix, d, s) \
{ \
#define ROP(mix, d, s) { \
switch ((mix) ? (xga->accel.frgd_mix & 0x1f) : (xga->accel.bkgd_mix & 0x1f)) { \
case 0x00: \
d = 0; \
break; \
case 0x01: \
d = s & d; \
break; \
case 0x02: \
d = s & ~d; \
break; \
case 0x03: \
d = s; \
break; \
case 0x04: \
d = ~s & d; \
break; \
case 0x05: \
d = d; \
break; \
case 0x06: \
d = s ^ d; \
break; \
case 0x07: \
d = s | d; \
break; \
case 0x08: \
d = ~s & ~d; \
break; \
case 0x09: \
d = s ^ ~d; \
break; \
case 0x0a: \
d = ~d; \
break; \
case 0x0b: \
d = s | ~d; \
break; \
case 0x0c: \
d = ~s; \
break; \
case 0x0d: \
d = ~s | d; \
break; \
case 0x0e: \
d = ~s | ~d; \
break; \
case 0x0f: \
d = ~0; \
break; \
case 0x10: \
d = MAX(s, d); \
break; \
case 0x11: \
d = MIN(s, d); \
break; \
case 0x12: \
d = MIN(0xff, s + d); \
break; \
case 0x13: \
d = MAX(0, d - s); \
break; \
case 0x14: \
d = MAX(0, s - d); \
break; \
case 0x15: \
d = (s + d) >> 1; \
break; \
case 0x00: d = 0; break; \
case 0x01: d = s & d; break; \
case 0x02: d = s & ~d; break; \
case 0x03: d = s; break; \
case 0x04: d = ~s & d; break; \
case 0x05: d = d; break; \
case 0x06: d = s ^ d; break; \
case 0x07: d = s | d; break; \
case 0x08: d = ~s & ~d; break; \
case 0x09: d = s ^ ~d; break; \
case 0x0a: d = ~d; break; \
case 0x0b: d = s | ~d; break; \
case 0x0c: d = ~s; break; \
case 0x0d: d = ~s | d; break; \
case 0x0e: d = ~s | ~d; break; \
case 0x0f: d = ~0; break; \
case 0x10: d = MAX(s, d); break; \
case 0x11: d = MIN(s, d); break; \
case 0x12: d = MIN(0xff, s + d); break; \
case 0x13: d = MAX(0, d - s); break; \
case 0x14: d = MAX(0, s - d); break; \
case 0x15: d = (s + d) >> 1; break; \
} \
}
@@ -803,6 +759,7 @@ xga_accel_read_pattern_map_pixel(svga_t *svga, int x, int y, int map, uint32_t b
return px;
}
static uint32_t
xga_accel_read_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, int width)
{
@@ -1004,11 +961,18 @@ xga_short_stroke(svga_t *svga, uint8_t ssv)
if (xga->accel.pat_src == 8) {
while (y >= 0) {
if (xga->accel.command & 0xc0) {
if ((dx >= xga->accel.mask_map_origin_x_off) && (dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) && (dy >= xga->accel.mask_map_origin_y_off) && (dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) {
if ((dx >= xga->accel.mask_map_origin_x_off) && (dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) &&
(dy >= xga->accel.mask_map_origin_y_off) && (dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) {
src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color;
dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1);
if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
if ((xga->accel.cc_cond == 4) ||
((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) ||
((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) ||
((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) ||
((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) ||
((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) ||
((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
old_dest_dat = dest_dat;
ROP(1, dest_dat, src_dat);
dest_dat = (dest_dat & plane_mask) | (old_dest_dat & ~plane_mask);
@@ -1028,7 +992,13 @@ xga_short_stroke(svga_t *svga, uint8_t ssv)
src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color;
dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1);
if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
if ((xga->accel.cc_cond == 4) ||
((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) ||
((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) ||
((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) ||
((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) ||
((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) ||
((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
old_dest_dat = dest_dat;
ROP(1, dest_dat, src_dat);
dest_dat = (dest_dat & plane_mask) | (old_dest_dat & ~plane_mask);
@@ -1061,10 +1031,7 @@ xga_short_stroke(svga_t *svga, uint8_t ssv)
xga->accel.dst_map_y = dy;
}
#define SWAP(a, b) \
tmpswap = a; \
a = b; \
b = tmpswap;
#define SWAP(a,b) tmpswap = a; a = b; b = tmpswap;
static void
xga_line_draw_write(svga_t *svga)
@@ -1082,18 +1049,18 @@ xga_line_draw_write(svga_t *svga)
int x = 0;
int dx, dy;
dminor = ((int16_t) xga->accel.bres_k1);
dminor = ((int16_t)xga->accel.bres_k1);
if (xga->accel.bres_k1 & 0x2000)
dminor |= ~0x1fff;
dminor >>= 1;
destxtmp = ((int16_t) xga->accel.bres_k2);
destxtmp = ((int16_t)xga->accel.bres_k2);
if (xga->accel.bres_k2 & 0x2000)
destxtmp |= ~0x1fff;
dmajor = -(destxtmp - (dminor << 1)) >> 1;
err = ((int16_t) xga->accel.bres_err_term);
err = ((int16_t)xga->accel.bres_err_term);
if (xga->accel.bres_err_term & 0x2000)
destxtmp |= ~0x1fff;
@@ -1127,11 +1094,18 @@ xga_line_draw_write(svga_t *svga)
while (y >= 0) {
if (xga->accel.command & 0xc0) {
if (steep) {
if ((dx >= xga->accel.mask_map_origin_x_off) && (dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) && (dy >= xga->accel.mask_map_origin_y_off) && (dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) {
if ((dx >= xga->accel.mask_map_origin_x_off) && (dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) &&
(dy >= xga->accel.mask_map_origin_y_off) && (dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) {
src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color;
dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1);
if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
if ((xga->accel.cc_cond == 4) ||
((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) ||
((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) ||
((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) ||
((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) ||
((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) ||
((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
old_dest_dat = dest_dat;
ROP(1, dest_dat, src_dat);
dest_dat = (dest_dat & plane_mask) | (old_dest_dat & ~plane_mask);
@@ -1144,11 +1118,18 @@ xga_line_draw_write(svga_t *svga)
}
}
} else {
if ((dy >= xga->accel.mask_map_origin_x_off) && (dy <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) && (dx >= xga->accel.mask_map_origin_y_off) && (dx <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) {
if ((dy >= xga->accel.mask_map_origin_x_off) && (dy <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) &&
(dx >= xga->accel.mask_map_origin_y_off) && (dx <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) {
src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color;
dest_dat = xga_accel_read_map_pixel(svga, dy, dx, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1);
if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
if ((xga->accel.cc_cond == 4) ||
((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) ||
((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) ||
((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) ||
((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) ||
((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) ||
((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
old_dest_dat = dest_dat;
ROP(1, dest_dat, src_dat);
dest_dat = (dest_dat & plane_mask) | (old_dest_dat & ~plane_mask);
@@ -1166,7 +1147,13 @@ xga_line_draw_write(svga_t *svga)
src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color;
dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1);
if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
if ((xga->accel.cc_cond == 4) ||
((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) ||
((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) ||
((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) ||
((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) ||
((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) ||
((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
old_dest_dat = dest_dat;
ROP(1, dest_dat, src_dat);
dest_dat = (dest_dat & plane_mask) | (old_dest_dat & ~plane_mask);
@@ -1181,7 +1168,13 @@ xga_line_draw_write(svga_t *svga)
src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color;
dest_dat = xga_accel_read_map_pixel(svga, dy, dx, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1);
if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
if ((xga->accel.cc_cond == 4) ||
((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) ||
((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) ||
((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) ||
((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) ||
((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) ||
((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
old_dest_dat = dest_dat;
ROP(1, dest_dat, src_dat);
dest_dat = (dest_dat & plane_mask) | (old_dest_dat & ~plane_mask);
@@ -1221,6 +1214,7 @@ xga_line_draw_write(svga_t *svga)
}
}
static int16_t
xga_dst_wrap(int16_t addr)
{
@@ -1283,15 +1277,22 @@ xga_bitblt(svga_t *svga)
}
}
// pclog("Pattern Map = 8: CMD = %08x: SRCBase = %08x, DSTBase = %08x, from/to vram dir = %d, cmd dir = %06x\n", xga->accel.command, srcbase, dstbase, xga->from_to_vram, xga->accel.dir_cmd);
// pclog("CMD = %08x: Y = %d, X = %d, patsrc = %02x, srcmap = %d, dstmap = %d, py = %d, sy = %d, dy = %d, width0 = %d, width1 = %d, width2 = %d, width3 = %d\n", xga->accel.command, xga->accel.y, xga->accel.x, xga->accel.pat_src, xga->accel.src_map, xga->accel.dst_map, xga->accel.py, xga->accel.sy, xga->accel.dy, xga->accel.px_map_width[0], xga->accel.px_map_width[1], xga->accel.px_map_width[2], xga->accel.px_map_width[3]);
//pclog("Pattern Map = 8: CMD = %08x: SRCBase = %08x, DSTBase = %08x, from/to vram dir = %d, cmd dir = %06x\n", xga->accel.command, srcbase, dstbase, xga->from_to_vram, xga->accel.dir_cmd);
//pclog("CMD = %08x: Y = %d, X = %d, patsrc = %02x, srcmap = %d, dstmap = %d, py = %d, sy = %d, dy = %d, width0 = %d, width1 = %d, width2 = %d, width3 = %d\n", xga->accel.command, xga->accel.y, xga->accel.x, xga->accel.pat_src, xga->accel.src_map, xga->accel.dst_map, xga->accel.py, xga->accel.sy, xga->accel.dy, xga->accel.px_map_width[0], xga->accel.px_map_width[1], xga->accel.px_map_width[2], xga->accel.px_map_width[3]);
while (xga->accel.y >= 0) {
if (xga->accel.command & 0xc0) {
if ((xga->accel.dx >= xga->accel.mask_map_origin_x_off) && (xga->accel.dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) && (xga->accel.dy >= xga->accel.mask_map_origin_y_off) && (xga->accel.dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) {
if ((xga->accel.dx >= xga->accel.mask_map_origin_x_off) && (xga->accel.dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) &&
(xga->accel.dy >= xga->accel.mask_map_origin_y_off) && (xga->accel.dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) {
src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1) : xga->accel.frgd_color;
dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1);
if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
if ((xga->accel.cc_cond == 4) ||
((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) ||
((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) ||
((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) ||
((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) ||
((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) ||
((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
old_dest_dat = dest_dat;
ROP(1, dest_dat, src_dat);
dest_dat = (dest_dat & plane_mask) | (old_dest_dat & ~plane_mask);
@@ -1302,7 +1303,13 @@ xga_bitblt(svga_t *svga)
src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1) : xga->accel.frgd_color;
dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1);
if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
if ((xga->accel.cc_cond == 4) ||
((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) ||
((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) ||
((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) ||
((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) ||
((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) ||
((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
old_dest_dat = dest_dat;
ROP(1, dest_dat, src_dat);
dest_dat = (dest_dat & plane_mask) | (old_dest_dat & ~plane_mask);
@@ -1361,13 +1368,14 @@ xga_bitblt(svga_t *svga)
}
}
// pclog("Pattern Map = %d: CMD = %08x: PATBase = %08x, SRCBase = %08x, DSTBase = %08x\n", xga->accel.pat_src, xga->accel.command, patbase, srcbase, dstbase);
// pclog("CMD = %08x: Y = %d, X = %d, patsrc = %02x, srcmap = %d, dstmap = %d, py = %d, sy = %d, dy = %d, width0 = %d, width1 = %d, width2 = %d, width3 = %d\n", xga->accel.command, xga->accel.y, xga->accel.x, xga->accel.pat_src, xga->accel.src_map, xga->accel.dst_map, xga->accel.py, xga->accel.sy, xga->accel.dy, xga->accel.px_map_width[0], xga->accel.px_map_width[1], xga->accel.px_map_width[2], xga->accel.px_map_width[3]);
//pclog("Pattern Map = %d: CMD = %08x: PATBase = %08x, SRCBase = %08x, DSTBase = %08x\n", xga->accel.pat_src, xga->accel.command, patbase, srcbase, dstbase);
//pclog("CMD = %08x: Y = %d, X = %d, patsrc = %02x, srcmap = %d, dstmap = %d, py = %d, sy = %d, dy = %d, width0 = %d, width1 = %d, width2 = %d, width3 = %d\n", xga->accel.command, xga->accel.y, xga->accel.x, xga->accel.pat_src, xga->accel.src_map, xga->accel.dst_map, xga->accel.py, xga->accel.sy, xga->accel.dy, xga->accel.px_map_width[0], xga->accel.px_map_width[1], xga->accel.px_map_width[2], xga->accel.px_map_width[3]);
while (xga->accel.y >= 0) {
mix = xga_accel_read_pattern_map_pixel(svga, xga->accel.px, xga->accel.py, xga->accel.pat_src, patbase, patwidth + 1);
if (xga->accel.command & 0xc0) {
if ((xga->accel.dx >= xga->accel.mask_map_origin_x_off) && (xga->accel.dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) && (xga->accel.dy >= xga->accel.mask_map_origin_y_off) && (xga->accel.dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) {
if ((xga->accel.dx >= xga->accel.mask_map_origin_x_off) && (xga->accel.dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) &&
(xga->accel.dy >= xga->accel.mask_map_origin_y_off) && (xga->accel.dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) {
if (mix)
src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1) : xga->accel.frgd_color;
else
@@ -1375,7 +1383,13 @@ xga_bitblt(svga_t *svga)
dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1);
if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
if ((xga->accel.cc_cond == 4) ||
((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) ||
((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) ||
((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) ||
((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) ||
((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) ||
((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
old_dest_dat = dest_dat;
ROP(mix, dest_dat, src_dat);
dest_dat = (dest_dat & plane_mask) | (old_dest_dat & ~plane_mask);
@@ -1390,7 +1404,13 @@ xga_bitblt(svga_t *svga)
dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1);
if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
if ((xga->accel.cc_cond == 4) ||
((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) ||
((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) ||
((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) ||
((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) ||
((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) ||
((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) {
old_dest_dat = dest_dat;
ROP(mix, dest_dat, src_dat);
dest_dat = (dest_dat & plane_mask) | (old_dest_dat & ~plane_mask);
@@ -1398,6 +1418,7 @@ xga_bitblt(svga_t *svga)
}
}
xga->accel.sx += xdir;
if (xga->accel.pattern)
xga->accel.px = ((xga->accel.px + xdir) & patwidth) | (xga->accel.px & ~patwidth);
@@ -1549,7 +1570,7 @@ xga_mem_write(uint32_t addr, uint32_t val, xga_t *xga, svga_t *svga, int len)
xga->accel.short_stroke_vector3 = (xga->accel.short_stroke >> 16) & 0xff;
xga->accel.short_stroke_vector4 = (xga->accel.short_stroke >> 24) & 0xff;
// pclog("1Vector = %02x, 2Vector = %02x, 3Vector = %02x, 4Vector = %02x\n", xga->accel.short_stroke_vector1, xga->accel.short_stroke_vector2, xga->accel.short_stroke_vector3, xga->accel.short_stroke_vector4);
//pclog("1Vector = %02x, 2Vector = %02x, 3Vector = %02x, 4Vector = %02x\n", xga->accel.short_stroke_vector1, xga->accel.short_stroke_vector2, xga->accel.short_stroke_vector3, xga->accel.short_stroke_vector4);
xga_short_stroke(svga, xga->accel.short_stroke_vector1);
xga_short_stroke(svga, xga->accel.short_stroke_vector2);
xga_short_stroke(svga, xga->accel.short_stroke_vector3);
@@ -1821,7 +1842,7 @@ exec_command:
xga->accel.dst_map = ((xga->accel.command >> 16) & 0x0f);
xga->accel.src_map = ((xga->accel.command >> 20) & 0x0f);
// if (xga->accel.pat_src) {
//if (xga->accel.pat_src) {
// pclog("[%04X:%08X]: Accel Command = %02x, full = %08x, patwidth = %d, dstwidth = %d, srcwidth = %d, patheight = %d, dstheight = %d, srcheight = %d, px = %d, py = %d, dx = %d, dy = %d, sx = %d, sy = %d, patsrc = %d, dstmap = %d, srcmap = %d, dstbase = %08x, srcbase = %08x, patbase = %08x, dstformat = %x, srcformat = %x, planemask = %08x\n",
// CS, cpu_state.pc, ((xga->accel.command >> 24) & 0x0f), xga->accel.command, xga->accel.px_map_width[xga->accel.pat_src],
// xga->accel.px_map_width[xga->accel.dst_map], xga->accel.px_map_width[xga->accel.src_map],
@@ -1834,10 +1855,10 @@ exec_command:
// xga->accel.px_map_base[xga->accel.dst_map], xga->accel.px_map_base[xga->accel.src_map], xga->accel.px_map_base[xga->accel.pat_src],
// xga->accel.px_map_format[xga->accel.dst_map] & 0x0f, xga->accel.px_map_format[xga->accel.src_map] & 0x0f, xga->accel.plane_mask);
// //pclog("\n");
// }
//}
switch ((xga->accel.command >> 24) & 0x0f) {
case 3: /*Bresenham Line Draw Read*/
// pclog("Line Draw Read\n");
//pclog("Line Draw Read\n");
break;
case 4: /*Short Stroke Vectors*/
break;
@@ -1848,7 +1869,7 @@ exec_command:
xga_bitblt(svga);
break;
case 9: /*Inverting BitBLT*/
// pclog("Inverting BitBLT\n");
//pclog("Inverting BitBLT\n");
break;
}
} else if (len == 2) {
@@ -1880,31 +1901,31 @@ exec_command:
static void
xga_memio_writeb(uint32_t addr, uint8_t val, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
xga_mem_write(addr, val, xga, svga, 1);
// pclog("Write MEMIOB = %04x, val = %02x\n", addr & 0x7f, val);
//pclog("Write MEMIOB = %04x, val = %02x\n", addr & 0x7f, val);
}
static void
xga_memio_writew(uint32_t addr, uint16_t val, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
xga_mem_write(addr, val, xga, svga, 2);
// pclog("Write MEMIOW = %04x, val = %04x\n", addr & 0x7f, val);
//pclog("Write MEMIOW = %04x, val = %04x\n", addr & 0x7f, val);
}
static void
xga_memio_writel(uint32_t addr, uint32_t val, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
xga_mem_write(addr, val, xga, svga, 4);
// pclog("Write MEMIOL = %04x, val = %08x\n", addr & 0x7f, val);
//pclog("Write MEMIOL = %04x, val = %08x\n", addr & 0x7f, val);
}
static uint8_t
@@ -1981,34 +2002,34 @@ xga_mem_read(uint32_t addr, xga_t *xga, svga_t *svga)
static uint8_t
xga_memio_readb(uint32_t addr, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
uint8_t temp;
temp = xga_mem_read(addr, xga, svga);
// pclog("[%04X:%08X]: Read MEMIOB = %04x, temp = %02x\n", CS, cpu_state.pc, addr, temp);
//pclog("[%04X:%08X]: Read MEMIOB = %04x, temp = %02x\n", CS, cpu_state.pc, addr, temp);
return temp;
}
static uint16_t
xga_memio_readw(uint32_t addr, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
uint16_t temp;
temp = xga_mem_read(addr, xga, svga);
temp |= (xga_mem_read(addr + 1, xga, svga) << 8);
// pclog("[%04X:%08X]: Read MEMIOW = %04x, temp = %04x\n", CS, cpu_state.pc, addr, temp);
//pclog("[%04X:%08X]: Read MEMIOW = %04x, temp = %04x\n", CS, cpu_state.pc, addr, temp);
return temp;
}
static uint32_t
xga_memio_readl(uint32_t addr, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
uint32_t temp;
@@ -2017,7 +2038,7 @@ xga_memio_readl(uint32_t addr, void *p)
temp |= (xga_mem_read(addr + 2, xga, svga) << 16);
temp |= (xga_mem_read(addr + 3, xga, svga) << 24);
// pclog("Read MEMIOL = %04x, temp = %08x\n", addr, temp);
//pclog("Read MEMIOL = %04x, temp = %08x\n", addr, temp);
return temp;
}
@@ -2121,13 +2142,13 @@ xga_render_8bpp(xga_t *xga, svga_t *svga)
xga->lastline_draw = xga->displine;
for (x = 0; x <= xga->h_disp; x += 8) {
dat = *(uint32_t *) (&xga->vram[xga->ma & xga->vram_mask]);
dat = *(uint32_t *)(&xga->vram[xga->ma & xga->vram_mask]);
p[0] = svga->pallook[dat & 0xff];
p[1] = svga->pallook[(dat >> 8) & 0xff];
p[2] = svga->pallook[(dat >> 16) & 0xff];
p[3] = svga->pallook[(dat >> 24) & 0xff];
dat = *(uint32_t *) (&xga->vram[(xga->ma + 4) & xga->vram_mask]);
dat = *(uint32_t *)(&xga->vram[(xga->ma + 4) & xga->vram_mask]);
p[4] = svga->pallook[dat & 0xff];
p[5] = svga->pallook[(dat >> 8) & 0xff];
p[6] = svga->pallook[(dat >> 16) & 0xff];
@@ -2158,19 +2179,19 @@ xga_render_16bpp(xga_t *xga, svga_t *svga)
xga->lastline_draw = xga->displine;
for (x = 0; x <= (xga->h_disp); x += 8) {
dat = *(uint32_t *) (&xga->vram[(xga->ma + (x << 1)) & xga->vram_mask]);
dat = *(uint32_t *)(&xga->vram[(xga->ma + (x << 1)) & xga->vram_mask]);
p[x] = video_16to32[dat & 0xffff];
p[x + 1] = video_16to32[dat >> 16];
dat = *(uint32_t *) (&xga->vram[(xga->ma + (x << 1) + 4) & xga->vram_mask]);
dat = *(uint32_t *)(&xga->vram[(xga->ma + (x << 1) + 4) & xga->vram_mask]);
p[x + 2] = video_16to32[dat & 0xffff];
p[x + 3] = video_16to32[dat >> 16];
dat = *(uint32_t *) (&xga->vram[(xga->ma + (x << 1) + 8) & xga->vram_mask]);
dat = *(uint32_t *)(&xga->vram[(xga->ma + (x << 1) + 8) & xga->vram_mask]);
p[x + 4] = video_16to32[dat & 0xffff];
p[x + 5] = video_16to32[dat >> 16];
dat = *(uint32_t *) (&xga->vram[(xga->ma + (x << 1) + 12) & xga->vram_mask]);
dat = *(uint32_t *)(&xga->vram[(xga->ma + (x << 1) + 12) & xga->vram_mask]);
p[x + 6] = video_16to32[dat & 0xffff];
p[x + 7] = video_16to32[dat >> 16];
}
@@ -2182,7 +2203,7 @@ xga_render_16bpp(xga_t *xga, svga_t *svga)
static void
xga_write(uint32_t addr, uint8_t val, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
if (!xga->on) {
@@ -2205,14 +2226,14 @@ xga_write(uint32_t addr, uint8_t val, void *p)
static void
xga_writeb(uint32_t addr, uint8_t val, void *p)
{
// pclog("[%04X:%08X]: WriteB\n", CS, cpu_state.pc);
//pclog("[%04X:%08X]: WriteB\n", CS, cpu_state.pc);
xga_write(addr, val, p);
}
static void
xga_writew(uint32_t addr, uint16_t val, void *p)
{
// pclog("[%04X:%08X]: WriteW\n", CS, cpu_state.pc);
//pclog("[%04X:%08X]: WriteW\n", CS, cpu_state.pc);
xga_write(addr, val, p);
xga_write(addr + 1, val >> 8, p);
}
@@ -2220,7 +2241,7 @@ xga_writew(uint32_t addr, uint16_t val, void *p)
static void
xga_writel(uint32_t addr, uint32_t val, void *p)
{
// pclog("[%04X:%08X]: WriteL\n", CS, cpu_state.pc);
//pclog("[%04X:%08X]: WriteL\n", CS, cpu_state.pc);
xga_write(addr, val, p);
xga_write(addr + 1, val >> 8, p);
xga_write(addr + 2, val >> 16, p);
@@ -2230,7 +2251,7 @@ xga_writel(uint32_t addr, uint32_t val, void *p)
static void
xga_write_linear(uint32_t addr, uint8_t val, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
if (!xga->on) {
@@ -2252,7 +2273,7 @@ xga_write_linear(uint32_t addr, uint8_t val, void *p)
static void
xga_writew_linear(uint32_t addr, uint16_t val, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
if (!xga->on) {
@@ -2288,7 +2309,7 @@ xga_writew_linear(uint32_t addr, uint16_t val, void *p)
static void
xga_writel_linear(uint32_t addr, uint32_t val, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
if (!xga->on) {
@@ -2305,7 +2326,7 @@ xga_writel_linear(uint32_t addr, uint32_t val, void *p)
static uint8_t
xga_read(uint32_t addr, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
if (!xga->on)
@@ -2359,7 +2380,7 @@ xga_readl(uint32_t addr, void *p)
static uint8_t
xga_read_linear(uint32_t addr, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
if (!xga->on)
@@ -2378,7 +2399,7 @@ xga_read_linear(uint32_t addr, void *p)
static uint16_t
xga_readw_linear(uint32_t addr, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
uint16_t ret;
@@ -2406,13 +2427,14 @@ xga_readw_linear(uint32_t addr, void *p)
static uint32_t
xga_readl_linear(uint32_t addr, void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
if (!xga->on)
return svga_readl_linear(addr, svga);
return xga_read_linear(addr, p) | (xga_read_linear(addr + 1, p) << 8) | (xga_read_linear(addr + 2, p) << 16) | (xga_read_linear(addr + 3, p) << 24);
return xga_read_linear(addr, p) | (xga_read_linear(addr + 1, p) << 8) |
(xga_read_linear(addr + 2, p) << 16) | (xga_read_linear(addr + 3, p) << 24);
}
static void
@@ -2454,7 +2476,8 @@ xga_poll(xga_t *xga, svga_t *svga)
xga->hwcursor_oddeven = 0;
}
if (xga->displine == (xga->hwcursor_latch.y + 1) && xga->hwcursor_latch.ena && xga->interlace) {
if (xga->displine == (xga->hwcursor_latch.y + 1) && xga->hwcursor_latch.ena &&
xga->interlace) {
xga->hwcursor_on = xga->hwcursor_latch.cur_ysize - (xga->cursor_data_on ? 33 : 1);
xga->hwcursor_oddeven = 1;
}
@@ -2473,7 +2496,8 @@ xga_poll(xga_t *xga, svga_t *svga)
}
if (xga->hwcursor_on) {
xga->changedvram[xga->ma >> 12] = xga->changedvram[(xga->ma >> 12) + 1] = xga->interlace ? 3 : 2;
xga->changedvram[xga->ma >> 12] = xga->changedvram[(xga->ma >> 12) + 1] =
xga->interlace ? 3 : 2;
}
xga_do_render(svga);
@@ -2586,17 +2610,17 @@ xga_poll(xga_t *xga, svga_t *svga)
static uint8_t
xga_mca_read(int port, void *priv)
{
svga_t *svga = (svga_t *) priv;
svga_t *svga = (svga_t *)priv;
xga_t *xga = &svga->xga;
// pclog("[%04X:%08X]: POS Read Port = %x, val = %02x\n", CS, cpu_state.pc, port & 7, xga->pos_regs[port & 7]);
//pclog("[%04X:%08X]: POS Read Port = %x, val = %02x\n", CS, cpu_state.pc, port & 7, xga->pos_regs[port & 7]);
return (xga->pos_regs[port & 7]);
}
static void
xga_mca_write(int port, uint8_t val, void *priv)
{
svga_t *svga = (svga_t *) priv;
svga_t *svga = (svga_t *)priv;
xga_t *xga = &svga->xga;
/* MCA does not write registers below 0x0100. */
@@ -2614,7 +2638,7 @@ xga_mca_write(int port, uint8_t val, void *priv)
if (!(xga->pos_regs[4] & 1)) /*MCA 4MB addressing on systems with more than 16MB of memory*/
xga->pos_regs[4] |= 1;
// pclog("[%04X:%08X]: POS Write Port = %x, val = %02x, linear base = %08x, instance = %d, rom addr = %05x\n", CS, cpu_state.pc, port & 7, val, xga->linear_base, xga->instance, xga->rom_addr);
//pclog("[%04X:%08X]: POS Write Port = %x, val = %02x, linear base = %08x, instance = %d, rom addr = %05x\n", CS, cpu_state.pc, port & 7, val, xga->linear_base, xga->instance, xga->rom_addr);
if (xga->pos_regs[2] & 1) {
xga->instance = (xga->pos_regs[2] & 0x0e) >> 1;
xga->base_addr_1mb = (xga->pos_regs[5] & 0x0f) << 20;
@@ -2622,6 +2646,7 @@ xga_mca_write(int port, uint8_t val, void *priv)
xga->rom_addr = 0xc0000 + (((xga->pos_regs[2] & 0xf0) >> 4) * 0x2000);
io_sethandler(0x2100 + (xga->instance << 4), 0x0010, xga_ext_inb, NULL, NULL, xga_ext_outb, NULL, NULL, svga);
if ((port & 7) == 2)
mem_mapping_set_addr(&xga->bios_rom.mapping, xga->rom_addr, 0x2000);
mem_mapping_set_addr(&xga->memio_mapping, xga->rom_addr + 0x1c00 + (xga->instance * 0x80), 0x80);
}
@@ -2630,7 +2655,7 @@ xga_mca_write(int port, uint8_t val, void *priv)
static uint8_t
xga_mca_feedb(void *priv)
{
svga_t *svga = (svga_t *) priv;
svga_t *svga = (svga_t *)priv;
xga_t *xga = &svga->xga;
return xga->pos_regs[2] & 1;
@@ -2639,7 +2664,7 @@ xga_mca_feedb(void *priv)
static void
xga_mca_reset(void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_mca_write(0x102, 0, svga);
}
@@ -2647,14 +2672,13 @@ xga_mca_reset(void *p)
static uint8_t
xga_pos_in(uint16_t addr, void *priv)
{
svga_t *svga = (svga_t *) priv;
svga_t *svga = (svga_t *)priv;
return (xga_mca_read(addr, svga));
}
static void
*
xga_init(const device_t *info)
*xga_init(const device_t *info)
{
svga_t *svga = svga_get_pri();
xga_t *xga = &svga->xga;
@@ -2678,15 +2702,15 @@ static void
xga->a5_test = 0;
f = rom_fopen(xga->type ? XGA2_BIOS_PATH : XGA_BIOS_PATH, "rb");
(void) fseek(f, 0L, SEEK_END);
(void)fseek(f, 0L, SEEK_END);
temp = ftell(f);
(void) fseek(f, 0L, SEEK_SET);
(void)fseek(f, 0L, SEEK_SET);
rom = malloc(xga->bios_rom.sz);
memset(rom, 0xff, xga->bios_rom.sz);
(void) !fread(rom, xga->bios_rom.sz, 1, f);
(void)fread(rom, xga->bios_rom.sz, 1, f);
temp -= xga->bios_rom.sz;
(void) fclose(f);
(void)fclose(f);
xga->bios_rom.rom = rom;
xga->bios_rom.mask = xga->bios_rom.sz - 1;
@@ -2699,11 +2723,7 @@ static void
xga->linear_base = 0;
xga->instance = 0;
xga->rom_addr = 0;
mem_mapping_add(&xga->bios_rom.mapping,
initial_bios_addr, xga->bios_rom.sz,
rom_read, rom_readw, rom_readl,
NULL, NULL, NULL,
xga->bios_rom.rom, MEM_MAPPING_EXTERNAL, &xga->bios_rom);
rom_init(&xga->bios_rom, xga->type ? XGA2_BIOS_PATH : XGA_BIOS_PATH, initial_bios_addr, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL);
} else {
xga->pos_regs[2] = 1 | 0x0c | 0xf0;
xga->instance = (xga->pos_regs[2] & 0x0e) >> 1;
@@ -2743,7 +2763,7 @@ static void
static void
xga_close(void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
xga_t *xga = &svga->xga;
if (svga) {
@@ -2761,7 +2781,7 @@ xga_available(void)
static void
xga_speed_changed(void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
svga_recalctimings(svga);
}
@@ -2769,7 +2789,7 @@ xga_speed_changed(void *p)
static void
xga_force_redraw(void *p)
{
svga_t *svga = (svga_t *) p;
svga_t *svga = (svga_t *)p;
svga->fullchange = changeframecount;
}
@@ -2816,7 +2836,7 @@ static const device_config_t xga_configuration[] = {
}
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
// clang-format on
};
const device_t xga_device = {