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 _dispofftime;
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;
_dispontime *= MDACONST;
_dispofftime *= MDACONST;
@@ -81,8 +81,8 @@ compaq_cga_recalctimings(cga_t *dev)
static void
compaq_cga_poll(void *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;
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;
int drawcursor;
int x;
int c;
@@ -97,8 +97,10 @@ compaq_cga_poll(void *priv)
int underline = 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 ((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;
cga_poll(dev);
return;
@@ -124,22 +126,22 @@ compaq_cga_poll(void *priv)
cols[0] = (dev->cgacol & 15) + 16;
for (c = 0; c < 8; c++) {
buffer32->line[dev.displine][c] = cols[0];
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] = cols[0];
if (dev->cgamode & CGA_MODE_FLAG_HIGHRES)
buffer32->line[dev->displine][c + (dev->crtc[CGA_CRTC_HDISP] << 3) + 8] = cols[0];
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) {
for (x = 0; x < dev.crtc[CGA_CRTC_HDISP]; x++) {
chr = dev.charbuffer[x << 1];
attr = dev.charbuffer[(x << 1) + 1];
drawcursor = ((dev.ma == ca) && dev.con && dev.cursoron);
if (dev->cgamode & CGA_MODE_FLAG_HIGHRES) {
for (x = 0; x < dev->crtc[CGA_CRTC_HDISP]; x++) {
chr = dev->charbuffer[x << 1];
attr = dev->charbuffer[(x << 1) + 1];
drawcursor = ((dev->ma == ca) && dev->cursorvisible && dev->cursoron);
if (vflags) {
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)) {
@@ -148,7 +150,7 @@ compaq_cga_poll(void *priv)
if ((dev->sc == 12) && ((attr & 7) == 1))
underline = 1;
} else if (dev.cgamode & 0x20) {
} else if (dev->cgamode & CGA_MODE_FLAG_BLINK) {
cols[1] = (attr & 15) + 16;
cols[0] = ((attr >> 4) & 7) + 16;
@@ -179,14 +181,14 @@ compaq_cga_poll(void *priv)
dev->ma++;
}
} else {
for (x = 0; x < dev.crtc[CGA_CRTC_HDISP]; x++) {
chr = dev.vram[(dev.ma << 1) & 0x3fff];
attr = dev.vram[((dev.ma << 1) + 1) & 0x3fff];
drawcursor = ((dev.ma == ca) && dev.con && dev.cursoron);
for (x = 0; x < dev->crtc[CGA_CRTC_HDISP]; x++) {
chr = dev->vram[(dev->ma << 1) & 0x3fff];
attr = dev->vram[((dev->ma << 1) + 1) & 0x3fff];
drawcursor = ((dev->ma == ca) && dev->cursorvisible && dev->cursoron);
if (vflags) {
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)) {
@@ -194,7 +196,7 @@ compaq_cga_poll(void *priv)
cols[1] = mdaattr[attr][blink][1];
if (dev->sc == 12 && (attr & 7) == 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[0] = ((attr >> 4) & 7) + 16;
@@ -232,9 +234,9 @@ compaq_cga_poll(void *priv)
cols[0] = (dev->cgacol & 15) + 16;
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
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)
@@ -242,8 +244,8 @@ compaq_cga_poll(void *priv)
else
x = (dev->crtc[CGA_CRTC_HDISP] << 4) + 16;
if (dev.composite) {
if (dev.cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)
if (dev->composite) {
if (dev->cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)
border = 0x00;
else
border = dev->cgacol & 0x0f;
@@ -255,12 +257,12 @@ compaq_cga_poll(void *priv)
} else
video_process_8(x, dev->displine);
dev.sc = oldsc;
if (dev.vc == dev.crtc[CGA_CRTC_VSYNC] && !dev.sc)
dev.cgastat |= 8;
dev.displine++;
if (dev.displine >= 500)
dev.displine = 0;
dev->sc = oldsc;
if (dev->vc == dev->crtc[CGA_CRTC_VSYNC] && !dev->sc)
dev->cgastat |= 8;
dev->displine++;
if (dev->displine >= 500)
dev->displine = 0;
} else {
timer_advance_u64(&dev->timer, dev->dispontime);
dev->linepos = 0;
@@ -270,60 +272,60 @@ compaq_cga_poll(void *priv)
dev->cgastat &= ~8;
}
if (dev.sc == (dev.crtc[11] & 31) || ((dev.crtc[8] & 3) == 3 && dev.sc == ((dev.crtc[11] & 31) >> 1))) {
dev.con = 0;
if (dev->sc == (dev->crtc[11] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[11] & 31) >> 1))) {
dev->cursorvisible = 0;
}
if ((dev.crtc[8] & 3) == 3 && dev.sc == (dev.crtc[9] >> 1))
dev.maback = dev.ma;
if (dev.vadj) {
dev.sc++;
dev.sc &= 31;
dev.ma = dev.maback;
dev.vadj--;
if (!dev.vadj) {
dev.cgadispon = 1;
dev.ma = dev.maback = (dev.crtc[13] | (dev.crtc[12] << 8)) & 0x3fff;
dev.sc = 0;
if ((dev->crtc[8] & 3) == 3 && dev->sc == (dev->crtc[9] >> 1))
dev->maback = dev->ma;
if (dev->vadj) {
dev->sc++;
dev->sc &= 31;
dev->ma = dev->maback;
dev->vadj--;
if (!dev->vadj) {
dev->cgadispon = 1;
dev->ma = dev->maback = (dev->crtc[13] | (dev->crtc[12] << 8)) & 0x3fff;
dev->sc = 0;
}
} else if (dev.sc == dev.crtc[9]) {
dev.maback = dev.ma;
dev.sc = 0;
oldvc = dev.vc;
dev.vc++;
dev.vc &= 127;
} else if (dev->sc == dev->crtc[9]) {
dev->maback = dev->ma;
dev->sc = 0;
oldvc = dev->vc;
dev->vc++;
dev->vc &= 127;
if (dev.vc == dev.crtc[6])
dev.cgadispon = 0;
if (dev->vc == dev->crtc[6])
dev->cgadispon = 0;
if (oldvc == dev.crtc[4]) {
dev.vc = 0;
dev.vadj = dev.crtc[5];
if (oldvc == dev->crtc[4]) {
dev->vc = 0;
dev->vadj = dev->crtc[5];
if (!dev->vadj)
dev->cgadispon = 1;
if (!dev.vadj)
dev.ma = dev.maback = (dev.crtc[13] | (dev.crtc[12] << 8)) & 0x3fff;
if (!dev->vadj)
dev->ma = dev->maback = (dev->crtc[13] | (dev->crtc[12] << 8)) & 0x3fff;
if ((dev.crtc[10] & 0x60) == 0x20)
dev.cursoron = 0;
if ((dev->crtc[10] & 0x60) == 0x20)
dev->cursoron = 0;
else
dev->cursoron = dev->cgablink & 8;
}
if (dev.vc == dev.crtc[7]) {
dev.cgadispon = 0;
dev.displine = 0;
dev.vsynctime = 16;
if (dev->vc == dev->crtc[7]) {
dev->cgadispon = 0;
dev->displine = 0;
dev->vsynctime = 16;
if (dev.crtc[7]) {
compaq_cga_log("Lastline %i Firstline %i %i\n", dev.lastline,
dev.firstline, dev.lastline - dev.firstline);
if (dev->crtc[7]) {
compaq_cga_log("Lastline %i Firstline %i %i\n", dev->lastline,
dev->firstline, dev->lastline - dev->firstline);
if (dev.cgamode & CGA_MODE_FLAG_HIGHRES)
x = (dev.crtc[CGA_CRTC_HDISP] << 3) + 16;
if (dev->cgamode & CGA_MODE_FLAG_HIGHRES)
x = (dev->crtc[CGA_CRTC_HDISP] << 3) + 16;
else
x = (dev.crtc[CGA_CRTC_HDISP] << 4) + 16;
x = (dev->crtc[CGA_CRTC_HDISP] << 4) + 16;
dev->lastline++;
@@ -338,7 +340,7 @@ compaq_cga_poll(void *priv)
if (!enable_overscan)
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;
ysize = ys_temp;
set_screen_size(xsize, ysize + (enable_overscan ? 16 : 0));
@@ -359,15 +361,15 @@ compaq_cga_poll(void *priv)
if (enable_overscan)
xsize -= 16;
video_res_y = ysize;
if (dev.cgamode & CGA_MODE_FLAG_HIGHRES) {
if (dev->cgamode & CGA_MODE_FLAG_HIGHRES) {
video_res_x /= 8;
video_res_y /= dev.crtc[9] + 1;
video_res_y /= dev->crtc[9] + 1;
video_bpp = 0;
} else if (!(dev.cgamode & 2)) {
} else if (!(dev->cgamode & 2)) {
video_res_x /= 16;
video_res_y /= dev.crtc[9] + 1;
video_res_y /= dev->crtc[9] + 1;
video_bpp = 0;
} else if (!(dev.cgamode & 16)) {
} else if (!(dev->cgamode & 16)) {
video_res_x /= 2;
video_bpp = 2;
} else
@@ -388,12 +390,12 @@ compaq_cga_poll(void *priv)
if (dev->cgadispon)
dev->cgastat &= ~1;
if (dev.sc == (dev.crtc[10] & 31) || ((dev.crtc[8] & 3) == 3 && dev.sc == ((dev.crtc[10] & 31) >> 1)))
dev.con = 1;
if (dev->sc == (dev->crtc[10] & 31) || ((dev->crtc[8] & 3) == 3 && dev->sc == ((dev->crtc[10] & 31) >> 1)))
dev->cursorvisible = 1;
if (dev.cgadispon && (dev.cgamode & CGA_MODE_FLAG_HIGHRES)) {
for (x = 0; x < (dev.crtc[CGA_CRTC_HDISP] << 1); x++)
dev.charbuffer[x] = dev.vram[((dev.ma << 1) + x) & 0x3fff];
if (dev->cgadispon && (dev->cgamode & CGA_MODE_FLAG_HIGHRES)) {
for (x = 0; x < (dev->crtc[CGA_CRTC_HDISP] << 1); x++)
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);
cgapal_rebuild();
dev.crtc[9] = 13;
dev->crtc[9] = 13;
return dev;
}
@@ -472,7 +474,7 @@ compaq_cga_speed_changed(void *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);
else
cga_recalctimings(dev);