Apply CGA_CRTC enum to Plantronics Colorplus

This commit is contained in:
starfrost013
2025-06-09 17:03:21 +01:00
parent b4b1a599ba
commit 860a9b0163

View File

@@ -147,7 +147,7 @@ colorplus_poll(void *priv)
colorplus->cga.cgastat |= 1;
colorplus->cga.linepos = 1;
oldsc = colorplus->cga.sc;
if ((colorplus->cga.crtc[8] & 3) == 3)
if ((colorplus->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3)
colorplus->cga.sc = ((colorplus->cga.sc << 1) + colorplus->cga.oddeven) & 7;
if (colorplus->cga.cgadispon) {
if (colorplus->cga.displine < colorplus->cga.firstline) {
@@ -157,10 +157,10 @@ colorplus_poll(void *priv)
colorplus->cga.lastline = colorplus->cga.displine;
/* Left / right border */
for (c = 0; c < 8; c++) {
buffer32->line[colorplus->cga.displine][c] = buffer32->line[colorplus->cga.displine][c + (colorplus->cga.crtc[1] << 4) + 8] = (colorplus->cga.cgacol & 15) + 16;
buffer32->line[colorplus->cga.displine][c] = buffer32->line[colorplus->cga.displine][c + (colorplus->cga.crtc[CGA_CRTC_HDISP] << 4) + 8] = (colorplus->cga.cgacol & 15) + 16;
}
if (colorplus->control & COLORPLUS_320x200_MODE) {
for (x = 0; x < colorplus->cga.crtc[1]; x++) {
for (x = 0; x < colorplus->cga.crtc[CGA_CRTC_HDISP]; x++) {
dat0 = (plane0[((colorplus->cga.ma << 1) & 0x1fff) + ((colorplus->cga.sc & 1) * 0x2000)] << 8) | plane0[((colorplus->cga.ma << 1) & 0x1fff) + ((colorplus->cga.sc & 1) * 0x2000) + 1];
dat1 = (plane1[((colorplus->cga.ma << 1) & 0x1fff) + ((colorplus->cga.sc & 1) * 0x2000)] << 8) | plane1[((colorplus->cga.ma << 1) & 0x1fff) + ((colorplus->cga.sc & 1) * 0x2000) + 1];
colorplus->cga.ma++;
@@ -186,7 +186,7 @@ colorplus_poll(void *priv)
cols[2] = col | 4;
cols[3] = col | 6;
}
for (x = 0; x < colorplus->cga.crtc[1]; x++) {
for (x = 0; x < colorplus->cga.crtc[CGA_CRTC_HDISP]; x++) {
dat0 = (plane0[((colorplus->cga.ma << 1) & 0x1fff) + ((colorplus->cga.sc & 1) * 0x2000)] << 8) | plane0[((colorplus->cga.ma << 1) & 0x1fff) + ((colorplus->cga.sc & 1) * 0x2000) + 1];
dat1 = (plane1[((colorplus->cga.ma << 1) & 0x1fff) + ((colorplus->cga.sc & 1) * 0x2000)] << 8) | plane1[((colorplus->cga.ma << 1) & 0x1fff) + ((colorplus->cga.sc & 1) * 0x2000) + 1];
colorplus->cga.ma++;
@@ -200,10 +200,10 @@ colorplus_poll(void *priv)
} else /* Top / bottom border */
{
cols[0] = (colorplus->cga.cgacol & 15) + 16;
hline(buffer32, 0, colorplus->cga.displine, (colorplus->cga.crtc[1] << 4) + 16, cols[0]);
hline(buffer32, 0, colorplus->cga.displine, (colorplus->cga.crtc[CGA_CRTC_HDISP] << 4) + 16, cols[0]);
}
x = (colorplus->cga.crtc[1] << 4) + 16;
x = (colorplus->cga.crtc[CGA_CRTC_HDISP] << 4) + 16;
if (colorplus->cga.composite)
Composite_Process(colorplus->cga.cgamode, 0, x >> 2, buffer32->line[colorplus->cga.displine]);
@@ -211,7 +211,7 @@ colorplus_poll(void *priv)
video_process_8(x, colorplus->cga.displine);
colorplus->cga.sc = oldsc;
if (colorplus->cga.vc == colorplus->cga.crtc[7] && !colorplus->cga.sc)
if (colorplus->cga.vc == colorplus->cga.crtc[CGA_CRTC_VSYNC] && !colorplus->cga.sc)
colorplus->cga.cgastat |= 8;
colorplus->cga.displine++;
if (colorplus->cga.displine >= 360)
@@ -224,10 +224,11 @@ colorplus_poll(void *priv)
if (!colorplus->cga.vsynctime)
colorplus->cga.cgastat &= ~8;
}
if (colorplus->cga.sc == (colorplus->cga.crtc[11] & 31) || ((colorplus->cga.crtc[8] & 3) == 3 && colorplus->cga.sc == ((colorplus->cga.crtc[11] & 31) >> 1))) {
if (colorplus->cga.sc == (colorplus->cga.crtc[CGA_CRTC_CURSOR_END] & 31)
|| ((colorplus->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && colorplus->cga.sc == ((colorplus->cga.crtc[CGA_CRTC_CURSOR_END] & 31) >> 1))) {
colorplus->cga.con = 0;
}
if ((colorplus->cga.crtc[8] & 3) == 3 && colorplus->cga.sc == (colorplus->cga.crtc[9] >> 1))
if ((colorplus->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && colorplus->cga.sc == (colorplus->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] >> 1))
colorplus->cga.maback = colorplus->cga.ma;
if (colorplus->cga.vadj) {
colorplus->cga.sc++;
@@ -236,41 +237,41 @@ colorplus_poll(void *priv)
colorplus->cga.vadj--;
if (!colorplus->cga.vadj) {
colorplus->cga.cgadispon = 1;
colorplus->cga.ma = colorplus->cga.maback = (colorplus->cga.crtc[13] | (colorplus->cga.crtc[12] << 8)) & 0x3fff;
colorplus->cga.ma = colorplus->cga.maback = (colorplus->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (colorplus->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff;
colorplus->cga.sc = 0;
}
} else if (colorplus->cga.sc == colorplus->cga.crtc[9]) {
} else if (colorplus->cga.sc == colorplus->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR]) {
colorplus->cga.maback = colorplus->cga.ma;
colorplus->cga.sc = 0;
oldvc = colorplus->cga.vc;
colorplus->cga.vc++;
colorplus->cga.vc &= 127;
if (colorplus->cga.vc == colorplus->cga.crtc[6])
if (colorplus->cga.vc == colorplus->cga.crtc[CGA_CRTC_VDISP])
colorplus->cga.cgadispon = 0;
if (oldvc == colorplus->cga.crtc[4]) {
if (oldvc == colorplus->cga.crtc[CGA_CRTC_VTOTAL]) {
colorplus->cga.vc = 0;
colorplus->cga.vadj = colorplus->cga.crtc[5];
colorplus->cga.vadj = colorplus->cga.crtc[CGA_CRTC_VTOTAL_ADJUST];
if (!colorplus->cga.vadj)
colorplus->cga.cgadispon = 1;
if (!colorplus->cga.vadj)
colorplus->cga.ma = colorplus->cga.maback = (colorplus->cga.crtc[13] | (colorplus->cga.crtc[12] << 8)) & 0x3fff;
if ((colorplus->cga.crtc[10] & 0x60) == 0x20)
colorplus->cga.ma = colorplus->cga.maback = (colorplus->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (colorplus->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff;
if ((colorplus->cga.crtc[CGA_CRTC_CURSOR_START] & 0x60) == 0x20)
colorplus->cga.cursoron = 0;
else
colorplus->cga.cursoron = colorplus->cga.cgablink & 8;
}
if (colorplus->cga.vc == colorplus->cga.crtc[7]) {
if (colorplus->cga.vc == colorplus->cga.crtc[CGA_CRTC_VSYNC]) {
colorplus->cga.cgadispon = 0;
colorplus->cga.displine = 0;
colorplus->cga.vsynctime = 16;
if (colorplus->cga.crtc[7]) {
if (colorplus->cga.crtc[CGA_CRTC_VSYNC]) {
if (colorplus->cga.cgamode & 1)
x = (colorplus->cga.crtc[1] << 3) + 16;
x = (colorplus->cga.crtc[CGA_CRTC_HDISP] << 3) + 16;
else
x = (colorplus->cga.crtc[1] << 4) + 16;
x = (colorplus->cga.crtc[CGA_CRTC_HDISP] << 4) + 16;
colorplus->cga.lastline++;
if (x != xsize || (colorplus->cga.lastline - colorplus->cga.firstline) != ysize) {
xsize = x;
@@ -289,11 +290,11 @@ colorplus_poll(void *priv)
video_res_y = ysize;
if (colorplus->cga.cgamode & 1) {
video_res_x /= 8;
video_res_y /= colorplus->cga.crtc[9] + 1;
video_res_y /= colorplus->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1;
video_bpp = 0;
} else if (!(colorplus->cga.cgamode & 2)) {
video_res_x /= 16;
video_res_y /= colorplus->cga.crtc[9] + 1;
video_res_y /= colorplus->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1;
video_bpp = 0;
} else if (!(colorplus->cga.cgamode & 16)) {
video_res_x /= 2;
@@ -314,10 +315,10 @@ colorplus_poll(void *priv)
}
if (colorplus->cga.cgadispon)
colorplus->cga.cgastat &= ~1;
if (colorplus->cga.sc == (colorplus->cga.crtc[10] & 31) || ((colorplus->cga.crtc[8] & 3) == 3 && colorplus->cga.sc == ((colorplus->cga.crtc[10] & 31) >> 1)))
if (colorplus->cga.sc == (colorplus->cga.crtc[CGA_CRTC_CURSOR_START] & 31) || ((colorplus->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && colorplus->cga.sc == ((colorplus->cga.crtc[CGA_CRTC_CURSOR_START] & 31) >> 1)))
colorplus->cga.con = 1;
if (colorplus->cga.cgadispon && (colorplus->cga.cgamode & 1)) {
for (x = 0; x < (colorplus->cga.crtc[1] << 1); x++)
for (x = 0; x < (colorplus->cga.crtc[CGA_CRTC_HDISP] << 1); x++)
colorplus->cga.charbuffer[x] = colorplus->cga.vram[((colorplus->cga.ma << 1) + x) & 0x3fff];
}
}