CGACompq merge

This commit is contained in:
starfrost013
2025-06-09 23:18:59 +01:00
parent bf07fbf417
commit 40f8affdda

View File

@@ -68,9 +68,9 @@ compaq_cga_recalctimings(cga_t *dev)
double _dispontime; double _dispontime;
double _dispofftime; double _dispofftime;
double disptime; double disptime;
disptime = dev.crtc[0] + 1; disptime = dev->crtc[CGA_CRTC_HTOTAL] + 1;
_dispontime = dev.crtc[CGA_CRTC_HDISP]; _dispontime = dev->crtc[CGA_CRTC_HDISP];
_dispofftime = disptime - _dispontime; _dispofftime = disptime - _dispontime;
_dispontime *= MDACONST; _dispontime *= MDACONST;
_dispofftime *= MDACONST; _dispofftime *= MDACONST;
@@ -81,8 +81,8 @@ compaq_cga_recalctimings(cga_t *dev)
static void static void
compaq_cga_poll(void *priv) compaq_cga_poll(void *priv)
{ {
cga_t *dev = (cga_t *) priv; cga_t *dev = (cga_t *) priv;
uint16_t ca = (dev.crtc[CGA_CRTC_CURSOR_ADDR_LOW] | (dev.crtc[CGA_CRTC_CURSOR_ADDR_HIGH] << 8)) & 0x3fff; uint16_t ca = (dev->crtc[CGA_CRTC_CURSOR_ADDR_LOW] | (dev->crtc[CGA_CRTC_CURSOR_ADDR_HIGH] << 8)) & 0x3fff;
int drawcursor; int drawcursor;
int x; int x;
int c; int c;
@@ -97,8 +97,10 @@ compaq_cga_poll(void *priv)
int underline = 0; int underline = 0;
int blink = 0; int blink = 0;
int32_t highres_graphics_flag = (CGA_MODE_FLAG_HIGHRES_GRAPHICS | CGA_MODE_FLAG_GRAPHICS);
/* If in graphics mode or character height is not 13, behave as CGA */ /* If in graphics mode or character height is not 13, behave as CGA */
if ((dev.cgamode & 0x12) || (dev.crtc[9] != 13)) { if ((dev->cgamode & highres_graphics_flag) || (dev->crtc[CGA_CRTC_MAX_SCANLINE_ADDR] != 13)) {
overscan_x = overscan_y = 16; overscan_x = overscan_y = 16;
cga_poll(dev); cga_poll(dev);
return; return;
@@ -124,22 +126,22 @@ compaq_cga_poll(void *priv)
cols[0] = (dev->cgacol & 15) + 16; cols[0] = (dev->cgacol & 15) + 16;
for (c = 0; c < 8; c++) { for (c = 0; c < 8; c++) {
buffer32->line[dev.displine][c] = cols[0]; buffer32->line[dev->displine][c] = cols[0];
if (dev.cgamode & CGA_MODE_FLAG_HIGHRES) if (dev->cgamode & CGA_MODE_FLAG_HIGHRES)
buffer32->line[dev.displine][c + (dev.crtc[CGA_CRTC_HDISP] << 3) + 8] = cols[0]; buffer32->line[dev->displine][c + (dev->crtc[CGA_CRTC_HDISP] << 3) + 8] = cols[0];
else else
buffer32->line[dev.displine][c + (dev.crtc[CGA_CRTC_HDISP] << 4) + 8] = cols[0]; buffer32->line[dev->displine][c + (dev->crtc[CGA_CRTC_HDISP] << 4) + 8] = cols[0];
} }
if (dev.cgamode & CGA_MODE_FLAG_HIGHRES) { if (dev->cgamode & CGA_MODE_FLAG_HIGHRES) {
for (x = 0; x < dev.crtc[CGA_CRTC_HDISP]; x++) { for (x = 0; x < dev->crtc[CGA_CRTC_HDISP]; x++) {
chr = dev.charbuffer[x << 1]; chr = dev->charbuffer[x << 1];
attr = dev.charbuffer[(x << 1) + 1]; attr = dev->charbuffer[(x << 1) + 1];
drawcursor = ((dev.ma == ca) && dev.con && dev.cursoron); drawcursor = ((dev->ma == ca) && dev->cursorvisible && dev->cursoron);
if (vflags) { if (vflags) {
underline = 0; underline = 0;
blink = ((dev.cgablink & 8) && (dev.cgamode & 0x20) && (attr & 0x80) && !drawcursor); blink = ((dev->cgablink & 8) && (dev->cgamode & CGA_MODE_FLAG_BLINK) && (attr & 0x80) && !drawcursor);
} }
if (vflags && (dev->cgamode & 0x80)) { if (vflags && (dev->cgamode & 0x80)) {
@@ -148,7 +150,7 @@ compaq_cga_poll(void *priv)
if ((dev->sc == 12) && ((attr & 7) == 1)) if ((dev->sc == 12) && ((attr & 7) == 1))
underline = 1; underline = 1;
} else if (dev.cgamode & 0x20) { } else if (dev->cgamode & CGA_MODE_FLAG_BLINK) {
cols[1] = (attr & 15) + 16; cols[1] = (attr & 15) + 16;
cols[0] = ((attr >> 4) & 7) + 16; cols[0] = ((attr >> 4) & 7) + 16;
@@ -179,14 +181,14 @@ compaq_cga_poll(void *priv)
dev->ma++; dev->ma++;
} }
} else { } else {
for (x = 0; x < dev.crtc[CGA_CRTC_HDISP]; x++) { for (x = 0; x < dev->crtc[CGA_CRTC_HDISP]; x++) {
chr = dev.vram[(dev.ma << 1) & 0x3fff]; chr = dev->vram[(dev->ma << 1) & 0x3fff];
attr = dev.vram[((dev.ma << 1) + 1) & 0x3fff]; attr = dev->vram[((dev->ma << 1) + 1) & 0x3fff];
drawcursor = ((dev.ma == ca) && dev.con && dev.cursoron); drawcursor = ((dev->ma == ca) && dev->cursorvisible && dev->cursoron);
if (vflags) { if (vflags) {
underline = 0; underline = 0;
blink = ((dev.cgablink & 8) && (dev.cgamode & CGA_MODE_FLAG_BLINK) && (attr & 0x80) && !drawcursor); blink = ((dev->cgablink & 8) && (dev->cgamode & CGA_MODE_FLAG_BLINK) && (attr & 0x80) && !drawcursor);
} }
if (vflags && (dev->cgamode & 0x80)) { if (vflags && (dev->cgamode & 0x80)) {
@@ -194,7 +196,7 @@ compaq_cga_poll(void *priv)
cols[1] = mdaattr[attr][blink][1]; cols[1] = mdaattr[attr][blink][1];
if (dev->sc == 12 && (attr & 7) == 1) if (dev->sc == 12 && (attr & 7) == 1)
underline = 1; underline = 1;
} else if (dev.cgamode & CGA_MODE_FLAG_BLINK)) { } else if (dev->cgamode & CGA_MODE_FLAG_BLINK)) {
cols[1] = (attr & 15) + 16; cols[1] = (attr & 15) + 16;
cols[0] = ((attr >> 4) & 7) + 16; cols[0] = ((attr >> 4) & 7) + 16;
@@ -232,9 +234,9 @@ compaq_cga_poll(void *priv)
cols[0] = (dev->cgacol & 15) + 16; cols[0] = (dev->cgacol & 15) + 16;
if (dev->cgamode & CGA_MODE_FLAG_HIGHRES) if (dev->cgamode & CGA_MODE_FLAG_HIGHRES)
hline(buffer32, 0, dev.displine, (dev.crtc[CGA_CRTC_HDISP] << 3) + 16, cols[0]); hline(buffer32, 0, dev->displine, (dev->crtc[CGA_CRTC_HDISP] << 3) + 16, cols[0]);
else else
hline(buffer32, 0, dev.displine, (dev.crtc[CGA_CRTC_HDISP] << 4) + 16, cols[0]); hline(buffer32, 0, dev->displine, (dev->crtc[CGA_CRTC_HDISP] << 4) + 16, cols[0]);
} }
if (dev->cgamode & CGA_MODE_FLAG_HIGHRES) if (dev->cgamode & CGA_MODE_FLAG_HIGHRES)
@@ -242,8 +244,8 @@ compaq_cga_poll(void *priv)
else else
x = (dev->crtc[CGA_CRTC_HDISP] << 4) + 16; x = (dev->crtc[CGA_CRTC_HDISP] << 4) + 16;
if (dev.composite) { if (dev->composite) {
if (dev.cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS) if (dev->cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)
border = 0x00; border = 0x00;
else else
border = dev->cgacol & 0x0f; border = dev->cgacol & 0x0f;
@@ -255,12 +257,12 @@ compaq_cga_poll(void *priv)
} else } else
video_process_8(x, dev->displine); video_process_8(x, dev->displine);
dev.sc = oldsc; dev->sc = oldsc;
if (dev.vc == dev.crtc[CGA_CRTC_VSYNC] && !dev.sc) if (dev->vc == dev->crtc[CGA_CRTC_VSYNC] && !dev->sc)
dev.cgastat |= 8; dev->cgastat |= 8;
dev.displine++; dev->displine++;
if (dev.displine >= 500) if (dev->displine >= 500)
dev.displine = 0; dev->displine = 0;
} else { } else {
timer_advance_u64(&dev->timer, dev->dispontime); timer_advance_u64(&dev->timer, dev->dispontime);
dev->linepos = 0; dev->linepos = 0;
@@ -270,60 +272,60 @@ compaq_cga_poll(void *priv)
dev->cgastat &= ~8; dev->cgastat &= ~8;
} }
if (dev.sc == (dev.crtc[11] & 31) || ((dev.crtc[8] & 3) == 3 && dev.sc == ((dev.crtc[11] & 31) >> 1))) { if (dev->sc == (dev->crtc[11] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[11] & 31) >> 1))) {
dev.con = 0; dev->cursorvisible = 0;
} }
if ((dev.crtc[8] & 3) == 3 && dev.sc == (dev.crtc[9] >> 1)) if ((dev->crtc[8] & 3) == 3 && dev->sc == (dev->crtc[9] >> 1))
dev.maback = dev.ma; dev->maback = dev->ma;
if (dev.vadj) { if (dev->vadj) {
dev.sc++; dev->sc++;
dev.sc &= 31; dev->sc &= 31;
dev.ma = dev.maback; dev->ma = dev->maback;
dev.vadj--; dev->vadj--;
if (!dev.vadj) { if (!dev->vadj) {
dev.cgadispon = 1; dev->cgadispon = 1;
dev.ma = dev.maback = (dev.crtc[13] | (dev.crtc[12] << 8)) & 0x3fff; dev->ma = dev->maback = (dev->crtc[13] | (dev->crtc[12] << 8)) & 0x3fff;
dev.sc = 0; dev->sc = 0;
} }
} else if (dev.sc == dev.crtc[9]) { } else if (dev->sc == dev->crtc[9]) {
dev.maback = dev.ma; dev->maback = dev->ma;
dev.sc = 0; dev->sc = 0;
oldvc = dev.vc; oldvc = dev->vc;
dev.vc++; dev->vc++;
dev.vc &= 127; dev->vc &= 127;
if (dev.vc == dev.crtc[6]) if (dev->vc == dev->crtc[6])
dev.cgadispon = 0; dev->cgadispon = 0;
if (oldvc == dev.crtc[4]) { if (oldvc == dev->crtc[4]) {
dev.vc = 0; dev->vc = 0;
dev.vadj = dev.crtc[5]; dev->vadj = dev->crtc[5];
if (!dev->vadj) if (!dev->vadj)
dev->cgadispon = 1; dev->cgadispon = 1;
if (!dev.vadj) if (!dev->vadj)
dev.ma = dev.maback = (dev.crtc[13] | (dev.crtc[12] << 8)) & 0x3fff; dev->ma = dev->maback = (dev->crtc[13] | (dev->crtc[12] << 8)) & 0x3fff;
if ((dev.crtc[10] & 0x60) == 0x20) if ((dev->crtc[10] & 0x60) == 0x20)
dev.cursoron = 0; dev->cursoron = 0;
else else
dev->cursoron = dev->cgablink & 8; dev->cursoron = dev->cgablink & 8;
} }
if (dev.vc == dev.crtc[7]) { if (dev->vc == dev->crtc[7]) {
dev.cgadispon = 0; dev->cgadispon = 0;
dev.displine = 0; dev->displine = 0;
dev.vsynctime = 16; dev->vsynctime = 16;
if (dev.crtc[7]) { if (dev->crtc[7]) {
compaq_cga_log("Lastline %i Firstline %i %i\n", dev.lastline, compaq_cga_log("Lastline %i Firstline %i %i\n", dev->lastline,
dev.firstline, dev.lastline - dev.firstline); dev->firstline, dev->lastline - dev->firstline);
if (dev.cgamode & CGA_MODE_FLAG_HIGHRES) if (dev->cgamode & CGA_MODE_FLAG_HIGHRES)
x = (dev.crtc[CGA_CRTC_HDISP] << 3) + 16; x = (dev->crtc[CGA_CRTC_HDISP] << 3) + 16;
else else
x = (dev.crtc[CGA_CRTC_HDISP] << 4) + 16; x = (dev->crtc[CGA_CRTC_HDISP] << 4) + 16;
dev->lastline++; dev->lastline++;
@@ -338,7 +340,7 @@ compaq_cga_poll(void *priv)
if (!enable_overscan) if (!enable_overscan)
xs_temp -= 16; xs_temp -= 16;
if ((dev.cgamode & 8) && ((xs_temp != xsize) || (ys_temp != ysize) || video_force_resize_get())) { if ((dev->cgamode & 8) && ((xs_temp != xsize) || (ys_temp != ysize) || video_force_resize_get())) {
xsize = xs_temp; xsize = xs_temp;
ysize = ys_temp; ysize = ys_temp;
set_screen_size(xsize, ysize + (enable_overscan ? 16 : 0)); set_screen_size(xsize, ysize + (enable_overscan ? 16 : 0));
@@ -359,15 +361,15 @@ compaq_cga_poll(void *priv)
if (enable_overscan) if (enable_overscan)
xsize -= 16; xsize -= 16;
video_res_y = ysize; video_res_y = ysize;
if (dev.cgamode & CGA_MODE_FLAG_HIGHRES) { if (dev->cgamode & CGA_MODE_FLAG_HIGHRES) {
video_res_x /= 8; video_res_x /= 8;
video_res_y /= dev.crtc[9] + 1; video_res_y /= dev->crtc[9] + 1;
video_bpp = 0; video_bpp = 0;
} else if (!(dev.cgamode & 2)) { } else if (!(dev->cgamode & 2)) {
video_res_x /= 16; video_res_x /= 16;
video_res_y /= dev.crtc[9] + 1; video_res_y /= dev->crtc[9] + 1;
video_bpp = 0; video_bpp = 0;
} else if (!(dev.cgamode & 16)) { } else if (!(dev->cgamode & 16)) {
video_res_x /= 2; video_res_x /= 2;
video_bpp = 2; video_bpp = 2;
} else } else
@@ -388,12 +390,12 @@ compaq_cga_poll(void *priv)
if (dev->cgadispon) if (dev->cgadispon)
dev->cgastat &= ~1; dev->cgastat &= ~1;
if (dev.sc == (dev.crtc[10] & 31) || ((dev.crtc[8] & 3) == 3 && dev.sc == ((dev.crtc[10] & 31) >> 1))) if (dev->sc == (dev->crtc[10] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[10] & 31) >> 1)))
dev.con = 1; dev->cursorvisible = 1;
if (dev.cgadispon && (dev.cgamode & CGA_MODE_FLAG_HIGHRES)) { if (dev->cgadispon && (dev->cgamode & CGA_MODE_FLAG_HIGHRES)) {
for (x = 0; x < (dev.crtc[CGA_CRTC_HDISP] << 1); x++) for (x = 0; x < (dev->crtc[CGA_CRTC_HDISP] << 1); x++)
dev.charbuffer[x] = dev.vram[((dev.ma << 1) + x) & 0x3fff]; dev->charbuffer[x] = dev->vram[((dev->ma << 1) + x) & 0x3fff];
} }
} }
} }
@@ -453,7 +455,7 @@ compaq_cga_init(const device_t *info)
cga_palette = (dev->rgb_type << 1); cga_palette = (dev->rgb_type << 1);
cgapal_rebuild(); cgapal_rebuild();
dev.crtc[9] = 13; dev->crtc[9] = 13;
return dev; return dev;
} }
@@ -472,7 +474,7 @@ compaq_cga_speed_changed(void *priv)
{ {
cga_t *dev = (cga_t *) priv; cga_t *dev = (cga_t *) priv;
if (dev.crtc[9] == 13) /* Character height */ if (dev->crtc[9] == 13) /* Character height */
compaq_cga_recalctimings(self); compaq_cga_recalctimings(self);
else else
cga_recalctimings(dev); cga_recalctimings(dev);