Apply CGA_CRTC and CGA_MODE_FLAGS to the rest of the Super CGA crew.

This commit is contained in:
starfrost013
2025-06-09 19:26:40 +01:00
parent d32a06d305
commit b7e6248db9
14 changed files with 280 additions and 279 deletions

View File

@@ -75,7 +75,7 @@ cga_update_latch(cga_t *cga)
{
uint32_t lp_latch = cga->displine * cga->crtc[CGA_CRTC_HDISP];
cga->crtc[0x10] = (lp_latch >> 8) & 0x3f;
cga->crtc[CGA_CRTC_LIGHT_PEN_ADDR_HIGH] = (lp_latch >> 8) & 0x3f;
cga->crtc[CGA_CRTC_LIGHT_PEN_ADDR_LOW] = lp_latch & 0xff;
}

View File

@@ -135,7 +135,7 @@ update_cga16_color(uint8_t cgamode)
int left = (x >> 6) & 15;
int rc = right;
int lc = left;
if ((cgamode & 4) != 0) {
if ((cgamode & CGA_MODE_FLAG_BW) != 0) {
rc = (right & 8) | ((right & 7) != 0 ? 7 : 0);
lc = (left & 8) | ((left & 7) != 0 ? 7 : 0);
}
@@ -240,7 +240,7 @@ Composite_Process(uint8_t cgamode, uint8_t border, uint32_t blocks /*, bool doub
for (uint8_t x = 0; x < 5; ++x)
OUT(b[x & 3]);
if ((cgamode & 4) != 0) {
if ((cgamode & CGA_MODE_FLAG_BW) != 0) {
/* Decode */
i = temp + 5;
srgb = TempLine;

View File

@@ -173,7 +173,7 @@ colorplus_poll(void *priv)
} else if (colorplus->control & COLORPLUS_640x200_MODE) {
cols[0] = (colorplus->cga.cgacol & 15) | 16;
col = (colorplus->cga.cgacol & 16) ? 24 : 16;
if (colorplus->cga.cgamode & 4) {
if (colorplus->cga.cgamode & CGA_MODE_FLAG_BW) {
cols[1] = col | 3;
cols[2] = col | 4;
cols[3] = col | 7;
@@ -268,7 +268,7 @@ colorplus_poll(void *priv)
colorplus->cga.displine = 0;
colorplus->cga.vsynctime = 16;
if (colorplus->cga.crtc[CGA_CRTC_VSYNC]) {
if (colorplus->cga.cgamode & 1)
if (colorplus->cga.cgamode & CGA_MODE_FLAG_HIGHRES)
x = (colorplus->cga.crtc[CGA_CRTC_HDISP] << 3) + 16;
else
x = (colorplus->cga.crtc[CGA_CRTC_HDISP] << 4) + 16;
@@ -288,15 +288,15 @@ colorplus_poll(void *priv)
video_res_x = xsize - 16;
video_res_y = ysize;
if (colorplus->cga.cgamode & 1) {
if (colorplus->cga.cgamode & CGA_MODE_FLAG_HIGHRES) {
video_res_x /= 8;
video_res_y /= colorplus->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1;
video_bpp = 0;
} else if (!(colorplus->cga.cgamode & 2)) {
} else if (!(colorplus->cga.cgamode & CGA_MODE_FLAG_GRAPHICS)) {
video_res_x /= 16;
video_res_y /= colorplus->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1;
video_bpp = 0;
} else if (!(colorplus->cga.cgamode & 16)) {
} else if (!(colorplus->cga.cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)) {
video_res_x /= 2;
video_bpp = 2;
} else {
@@ -317,7 +317,7 @@ colorplus_poll(void *priv)
colorplus->cga.cgastat &= ~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.cursorvisible = 1;
if (colorplus->cga.cgadispon && (colorplus->cga.cgamode & 1)) {
if (colorplus->cga.cgadispon && (colorplus->cga.cgamode & CGA_MODE_FLAG_HIGHRES)) {
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];
}

View File

@@ -72,9 +72,9 @@ compaq_cga_recalctimings(compaq_cga_t *self)
double _dispontime;
double _dispofftime;
double disptime;
disptime = self->cga.crtc[0] + 1;
disptime = self->cga.crtc[CGA_CRTC_HTOTAL] + 1;
_dispontime = self->cga.crtc[1];
_dispontime = self->cga.crtc[CGA_CRTC_HDISP];
_dispofftime = disptime - _dispontime;
_dispontime *= MDACONST;
_dispofftime *= MDACONST;
@@ -86,7 +86,7 @@ void
compaq_cga_poll(void *priv)
{
compaq_cga_t *self = (compaq_cga_t *) priv;
uint16_t ca = (self->cga.crtc[15] | (self->cga.crtc[14] << 8)) & 0x3fff;
uint16_t ca = (self->cga.crtc[CGA_CRTC_CURSOR_ADDR_LOW] | (self->cga.crtc[CGA_CRTC_CURSOR_ADDR_HIGH] << 8)) & 0x3fff;
int drawcursor;
int x;
int c;
@@ -102,7 +102,7 @@ compaq_cga_poll(void *priv)
int blink = 0;
/* If in graphics mode or character height is not 13, behave as CGA */
if ((self->cga.cgamode & 0x12) || (self->cga.crtc[9] != 13)) {
if ((self->cga.cgamode & 0x12) || (self->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] != 13)) {
overscan_x = overscan_y = 16;
cga_poll(&self->cga);
return;
@@ -115,7 +115,7 @@ compaq_cga_poll(void *priv)
self->cga.cgastat |= 1;
self->cga.linepos = 1;
oldsc = self->cga.sc;
if ((self->cga.crtc[8] & 3) == 3)
if ((self->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3)
self->cga.sc = ((self->cga.sc << 1) + self->cga.oddeven) & 7;
if (self->cga.cgadispon) {
if (self->cga.displine < self->cga.firstline) {
@@ -129,21 +129,21 @@ compaq_cga_poll(void *priv)
for (c = 0; c < 8; c++) {
buffer32->line[self->cga.displine][c] = cols[0];
if (self->cga.cgamode & 1)
buffer32->line[self->cga.displine][c + (self->cga.crtc[1] << 3) + 8] = cols[0];
if (self->cga.cgamode & CGA_MODE_FLAG_HIGHRES)
buffer32->line[self->cga.displine][c + (self->cga.crtc[CGA_CRTC_HDISP] << 3) + 8] = cols[0];
else
buffer32->line[self->cga.displine][c + (self->cga.crtc[1] << 4) + 8] = cols[0];
buffer32->line[self->cga.displine][c + (self->cga.crtc[CGA_CRTC_HDISP] << 4) + 8] = cols[0];
}
if (self->cga.cgamode & 1) {
for (x = 0; x < self->cga.crtc[1]; x++) {
if (self->cga.cgamode & CGA_MODE_FLAG_HIGHRES) {
for (x = 0; x < self->cga.crtc[CGA_CRTC_HDISP]; x++) {
chr = self->cga.charbuffer[x << 1];
attr = self->cga.charbuffer[(x << 1) + 1];
drawcursor = ((self->cga.ma == ca) && self->cga.cursorvisible && self->cga.cursoron);
if (vflags) {
underline = 0;
blink = ((self->cga.cgablink & 8) && (self->cga.cgamode & 0x20) && (attr & 0x80) && !drawcursor);
blink = ((self->cga.cgablink & 8) && (self->cga.cgamode & CGA_MODE_FLAG_BLINK) && (attr & 0x80) && !drawcursor);
}
if (vflags && (self->cga.cgamode & 0x80)) {
@@ -152,7 +152,7 @@ compaq_cga_poll(void *priv)
if ((self->cga.sc == 12) && ((attr & 7) == 1))
underline = 1;
} else if (self->cga.cgamode & 0x20) {
} else if (self->cga.cgamode & CGA_MODE_FLAG_BLINK) {
cols[1] = (attr & 15) + 16;
cols[0] = ((attr >> 4) & 7) + 16;
@@ -181,14 +181,14 @@ compaq_cga_poll(void *priv)
self->cga.ma++;
}
} else {
for (x = 0; x < self->cga.crtc[1]; x++) {
for (x = 0; x < self->cga.crtc[CGA_CRTC_HDISP]; x++) {
chr = self->cga.vram[(self->cga.ma << 1) & 0x3fff];
attr = self->cga.vram[((self->cga.ma << 1) + 1) & 0x3fff];
drawcursor = ((self->cga.ma == ca) && self->cga.cursorvisible && self->cga.cursoron);
if (vflags) {
underline = 0;
blink = ((self->cga.cgablink & 8) && (self->cga.cgamode & 0x20) && (attr & 0x80) && !drawcursor);
blink = ((self->cga.cgablink & 8) && (self->cga.cgamode & CGA_MODE_FLAG_BLINK) && (attr & 0x80) && !drawcursor);
}
if (vflags && (self->cga.cgamode & 0x80)) {
@@ -196,7 +196,7 @@ compaq_cga_poll(void *priv)
cols[1] = mdaattr[attr][blink][1];
if (self->cga.sc == 12 && (attr & 7) == 1)
underline = 1;
} else if (self->cga.cgamode & 0x20) {
} else if (self->cga.cgamode & CGA_MODE_FLAG_BLINK) {
cols[1] = (attr & 15) + 16;
cols[0] = ((attr >> 4) & 7) + 16;
@@ -228,19 +228,19 @@ compaq_cga_poll(void *priv)
} else {
cols[0] = (self->cga.cgacol & 15) + 16;
if (self->cga.cgamode & 1)
hline(buffer32, 0, self->cga.displine, (self->cga.crtc[1] << 3) + 16, cols[0]);
if (self->cga.cgamode & CGA_MODE_FLAG_HIGHRES)
hline(buffer32, 0, self->cga.displine, (self->cga.crtc[CGA_CRTC_HDISP] << 3) + 16, cols[0]);
else
hline(buffer32, 0, self->cga.displine, (self->cga.crtc[1] << 4) + 16, cols[0]);
hline(buffer32, 0, self->cga.displine, (self->cga.crtc[CGA_CRTC_HDISP] << 4) + 16, cols[0]);
}
if (self->cga.cgamode & 1)
x = (self->cga.crtc[1] << 3) + 16;
if (self->cga.cgamode & CGA_MODE_FLAG_HIGHRES)
x = (self->cga.crtc[CGA_CRTC_HDISP] << 3) + 16;
else
x = (self->cga.crtc[1] << 4) + 16;
x = (self->cga.crtc[CGA_CRTC_HDISP] << 4) + 16;
if (self->cga.composite) {
if (self->cga.cgamode & 0x10)
if (self->cga.cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)
border = 0x00;
else
border = self->cga.cgacol & 0x0f;
@@ -253,7 +253,7 @@ compaq_cga_poll(void *priv)
video_process_8(x, self->cga.displine);
self->cga.sc = oldsc;
if (self->cga.vc == self->cga.crtc[7] && !self->cga.sc)
if (self->cga.vc == self->cga.crtc[CGA_CRTC_VSYNC] && !self->cga.sc)
self->cga.cgastat |= 8;
self->cga.displine++;
if (self->cga.displine >= 500)
@@ -267,10 +267,10 @@ compaq_cga_poll(void *priv)
self->cga.cgastat &= ~8;
}
if (self->cga.sc == (self->cga.crtc[11] & 31) || ((self->cga.crtc[8] & 3) == 3 && self->cga.sc == ((self->cga.crtc[11] & 31) >> 1))) {
if (self->cga.sc == (self->cga.crtc[CGA_CRTC_CURSOR_END] & 31) || ((self->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && self->cga.sc == ((self->cga.crtc[CGA_CRTC_CURSOR_END] & 31) >> 1))) {
self->cga.cursorvisible = 0;
}
if ((self->cga.crtc[8] & 3) == 3 && self->cga.sc == (self->cga.crtc[9] >> 1))
if ((self->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && self->cga.sc == (self->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] >> 1))
self->cga.maback = self->cga.ma;
if (self->cga.vadj) {
self->cga.sc++;
@@ -279,48 +279,48 @@ compaq_cga_poll(void *priv)
self->cga.vadj--;
if (!self->cga.vadj) {
self->cga.cgadispon = 1;
self->cga.ma = self->cga.maback = (self->cga.crtc[13] | (self->cga.crtc[12] << 8)) & 0x3fff;
self->cga.ma = self->cga.maback = (self->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (self->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff;
self->cga.sc = 0;
}
} else if (self->cga.sc == self->cga.crtc[9]) {
} else if (self->cga.sc == self->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR]) {
self->cga.maback = self->cga.ma;
self->cga.sc = 0;
oldvc = self->cga.vc;
self->cga.vc++;
self->cga.vc &= 127;
if (self->cga.vc == self->cga.crtc[6])
if (self->cga.vc == self->cga.crtc[CGA_CRTC_VDISP])
self->cga.cgadispon = 0;
if (oldvc == self->cga.crtc[4]) {
if (oldvc == self->cga.crtc[CGA_CRTC_VTOTAL]) {
self->cga.vc = 0;
self->cga.vadj = self->cga.crtc[5];
self->cga.vadj = self->cga.crtc[CGA_CRTC_VTOTAL_ADJUST];
if (!self->cga.vadj)
self->cga.cgadispon = 1;
if (!self->cga.vadj)
self->cga.ma = self->cga.maback = (self->cga.crtc[13] | (self->cga.crtc[12] << 8)) & 0x3fff;
self->cga.ma = self->cga.maback = (self->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (self->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff;
if ((self->cga.crtc[10] & 0x60) == 0x20)
if ((self->cga.crtc[CGA_CRTC_CURSOR_START] & 0x60) == 0x20)
self->cga.cursoron = 0;
else
self->cga.cursoron = self->cga.cgablink & 8;
}
if (self->cga.vc == self->cga.crtc[7]) {
if (self->cga.vc == self->cga.crtc[CGA_CRTC_VSYNC]) {
self->cga.cgadispon = 0;
self->cga.displine = 0;
self->cga.vsynctime = 16;
if (self->cga.crtc[7]) {
if (self->cga.crtc[CGA_CRTC_VSYNC]) {
compaq_cga_log("Lastline %i Firstline %i %i\n", self->cga.lastline,
self->cga.firstline, self->cga.lastline - self->cga.firstline);
if (self->cga.cgamode & 1)
x = (self->cga.crtc[1] << 3) + 16;
if (self->cga.cgamode & CGA_MODE_FLAG_HIGHRES)
x = (self->cga.crtc[CGA_CRTC_HDISP] << 3) + 16;
else
x = (self->cga.crtc[1] << 4) + 16;
x = (self->cga.crtc[CGA_CRTC_HDISP] << 4) + 16;
self->cga.lastline++;
@@ -335,7 +335,7 @@ compaq_cga_poll(void *priv)
if (!enable_overscan)
xs_temp -= 16;
if ((self->cga.cgamode & 8) && ((xs_temp != xsize) || (ys_temp != ysize) || video_force_resize_get())) {
if ((self->cga.cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) && ((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));
@@ -356,15 +356,15 @@ compaq_cga_poll(void *priv)
if (enable_overscan)
xsize -= 16;
video_res_y = ysize;
if (self->cga.cgamode & 1) {
if (self->cga.cgamode & CGA_MODE_FLAG_HIGHRES) {
video_res_x /= 8;
video_res_y /= self->cga.crtc[9] + 1;
video_res_y /= self->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1;
video_bpp = 0;
} else if (!(self->cga.cgamode & 2)) {
} else if (!(self->cga.cgamode & CGA_MODE_FLAG_GRAPHICS)) {
video_res_x /= 16;
video_res_y /= self->cga.crtc[9] + 1;
video_res_y /= self->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1;
video_bpp = 0;
} else if (!(self->cga.cgamode & 16)) {
} else if (!(self->cga.cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)) {
video_res_x /= 2;
video_bpp = 2;
} else
@@ -385,11 +385,11 @@ compaq_cga_poll(void *priv)
if (self->cga.cgadispon)
self->cga.cgastat &= ~1;
if (self->cga.sc == (self->cga.crtc[10] & 31) || ((self->cga.crtc[8] & 3) == 3 && self->cga.sc == ((self->cga.crtc[10] & 31) >> 1)))
if (self->cga.sc == (self->cga.crtc[CGA_CRTC_CURSOR_START] & 31) || ((self->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && self->cga.sc == ((self->cga.crtc[CGA_CRTC_CURSOR_START] & 31) >> 1)))
self->cga.cursorvisible = 1;
if (self->cga.cgadispon && (self->cga.cgamode & 1)) {
for (x = 0; x < (self->cga.crtc[1] << 1); x++)
if (self->cga.cgadispon && (self->cga.cgamode & CGA_MODE_FLAG_HIGHRES)) {
for (x = 0; x < (self->cga.crtc[CGA_CRTC_HDISP] << 1); x++)
self->cga.charbuffer[x] = self->cga.vram[((self->cga.ma << 1) + x) & 0x3fff];
}
}
@@ -445,7 +445,7 @@ compaq_cga_init(const device_t *info)
cga_palette = (self->cga.rgb_type << 1);
cgapal_rebuild();
self->cga.crtc[9] = 13;
self->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] = 13;
return self;
}
@@ -464,7 +464,7 @@ compaq_cga_speed_changed(void *priv)
{
compaq_cga_t *self = (compaq_cga_t *) priv;
if (self->cga.crtc[9] == 13) /* Character height */
if (self->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] == 13) /* Character height */
compaq_cga_recalctimings(self);
else
cga_recalctimings(&self->cga);

View File

@@ -362,27 +362,27 @@ f82c425_text_row(f82c425_t *f82c425)
int blink;
uint16_t addr;
uint8_t sc;
uint16_t ma = (f82c425->cga.crtc[0x0d] | (f82c425->cga.crtc[0x0c] << 8)) & 0x3fff;
uint16_t ma = (f82c425->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (f82c425->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff;
uint16_t ca = (f82c425->cga.crtc[0x0f] | (f82c425->cga.crtc[0x0e] << 8)) & 0x3fff;
uint8_t sl = f82c425->cga.crtc[9] + 1;
int columns = f82c425->cga.crtc[1];
uint8_t sl = f82c425->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1;
int columns = f82c425->cga.crtc[CGA_CRTC_HDISP];
sc = (f82c425->displine) & 7;
addr = ((ma & ~1) + (f82c425->displine >> 3) * columns) * 2;
ma += (f82c425->displine >> 3) * columns;
if ((f82c425->cga.crtc[0x0a] & 0x60) == 0x20) {
if ((f82c425->cga.crtc[CGA_CRTC_CURSOR_START] & 0x60) == 0x20) {
cursorline = 0;
} else {
cursorline = ((f82c425->cga.crtc[0x0a] & 0x0F) <= sc) && ((f82c425->cga.crtc[0x0b] & 0x0F) >= sc);
cursorline = ((f82c425->cga.crtc[CGA_CRTC_CURSOR_START] & 0x0F) <= sc) && ((f82c425->cga.crtc[CGA_CRTC_CURSOR_END] & 0x0F) >= sc);
}
for (int x = 0; x < columns; x++) {
chr = f82c425->vram[(addr + 2 * x) & 0x3FFF];
attr = f82c425->vram[(addr + 2 * x + 1) & 0x3FFF];
drawcursor = ((ma == ca) && cursorline && (f82c425->cga.cgamode & 0x8) && (f82c425->cga.cgablink & 0x10));
drawcursor = ((ma == ca) && cursorline && (f82c425->cga.cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) && (f82c425->cga.cgablink & 0x10));
blink = ((f82c425->cga.cgablink & 0x10) && (f82c425->cga.cgamode & 0x20) && (attr & 0x80) && !drawcursor);
blink = ((f82c425->cga.cgablink & 0x10) && (f82c425->cga.cgamode & CGA_MODE_FLAG_BLINK) && (attr & 0x80) && !drawcursor);
if (drawcursor) {
colors[0] = smartmap[~attr & 0xff][0];
@@ -418,7 +418,7 @@ f82c425_cgaline6(f82c425_t *f82c425)
uint8_t dat;
uint16_t addr;
uint16_t ma = (f82c425->cga.crtc[0x0d] | (f82c425->cga.crtc[0x0c] << 8)) & 0x3fff;
uint16_t ma = (f82c425->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (f82c425->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff;
addr = ((f82c425->displine) & 1) * 0x2000 + (f82c425->displine >> 1) * 80 + ((ma & ~1) << 1);
@@ -442,7 +442,7 @@ f82c425_cgaline4(f82c425_t *f82c425)
uint8_t pattern;
uint16_t addr;
uint16_t ma = (f82c425->cga.crtc[0x0d] | (f82c425->cga.crtc[0x0c] << 8)) & 0x3fff;
uint16_t ma = (f82c425->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (f82c425->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff;
addr = ((f82c425->displine) & 1) * 0x2000 + (f82c425->displine >> 1) * 80 + ((ma & ~1) << 1);
for (uint8_t x = 0; x < 80; x++) {
@@ -526,7 +526,7 @@ f82c425_poll(void *priv)
f82c425->displine = 0;
f82c425->cga.cgastat &= ~8;
f82c425->dispon = 1;
} else if (f82c425->displine == (f82c425->cga.crtc[9] + 1) * f82c425->cga.crtc[6]) {
} else if (f82c425->displine == (f82c425->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1) * f82c425->cga.crtc[CGA_CRTC_VDISP]) {
/* Start of VSYNC */
f82c425->cga.cgastat |= 8;
f82c425->dispon = 0;

View File

@@ -56,12 +56,12 @@ nga_recalctimings(nga_t *nga)
double _dispofftime;
double disptime;
if (nga->cga.cgamode & 1) {
disptime = nga->cga.crtc[0] + 1;
_dispontime = nga->cga.crtc[1];
if (nga->cga.cgamode & CGA_MODE_FLAG_HIGHRES) {
disptime = nga->cga.crtc[CGA_CRTC_HTOTAL] + 1;
_dispontime = nga->cga.crtc[CGA_CRTC_HDISP];
} else {
disptime = (nga->cga.crtc[0] + 1) << 1;
_dispontime = nga->cga.crtc[1] << 1;
disptime = (nga->cga.crtc[CGA_CRTC_HTOTAL] + 1) << 1;
_dispontime = nga->cga.crtc[CGA_CRTC_HDISP] << 1;
}
_dispofftime = disptime - _dispontime;
@@ -148,7 +148,7 @@ nga_poll(void *priv)
{
nga_t *nga = (nga_t *) priv;
/* set cursor position in memory */
uint16_t ca = (nga->cga.crtc[15] | (nga->cga.crtc[14] << 8)) & 0x3fff;
uint16_t ca = (nga->cga.crtc[CGA_CRTC_CURSOR_ADDR_LOW] | (nga->cga.crtc[CGA_CRTC_CURSOR_ADDR_HIGH] << 8)) & 0x3fff;
int drawcursor;
int x;
int c;
@@ -164,7 +164,7 @@ nga_poll(void *priv)
int oldsc;
/* graphic mode and not high-res modes */
if ((nga->cga.cgamode & 2) && !(nga->cga.cgamode & 0x40)) {
if ((nga->cga.cgamode & CGA_MODE_FLAG_GRAPHICS) && !(nga->cga.cgamode & 0x40)) {
/* standard cga mode */
cga_poll(&nga->cga);
return;
@@ -176,7 +176,7 @@ nga_poll(void *priv)
nga->cga.linepos = 1;
oldsc = nga->cga.sc;
/* if interlaced */
if ((nga->cga.crtc[8] & 3) == 3)
if ((nga->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3)
nga->cga.sc = ((nga->cga.sc << 1) + nga->cga.oddeven) & 7;
if (nga->cga.cgadispon) {
if (nga->cga.displine < nga->cga.firstline) {
@@ -185,11 +185,11 @@ nga_poll(void *priv)
}
nga->cga.lastline = nga->cga.displine;
/* 80-col */
if ((nga->cga.cgamode & 1) && !(nga->cga.cgamode & 2)) {
if ((nga->cga.cgamode & CGA_MODE_FLAG_HIGHRES) && !(nga->cga.cgamode & CGA_MODE_FLAG_GRAPHICS)) {
/* for each text column */
for (x = 0; x < nga->cga.crtc[1]; x++) {
for (x = 0; x < nga->cga.crtc[CGA_CRTC_HDISP]; x++) {
/* video output enabled */
if (nga->cga.cgamode & 8) {
if (nga->cga.cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) {
/* character */
chr = nga->cga.charbuffer[x << 1];
/* text attributes */
@@ -201,7 +201,7 @@ nga_poll(void *priv)
/* set foreground */
cols[1] = (attr & 15) + 16;
/* blink active */
if (nga->cga.cgamode & 0x20) {
if (nga->cga.cgamode & CGA_MODE_FLAG_BLINK) {
cols[0] = ((attr >> 4) & 7) + 16;
/* attribute 7 active and not cursor */
if ((nga->cga.cgablink & 8) && (attr & 0x80) && !nga->cga.drawcursor) {
@@ -224,10 +224,10 @@ nga_poll(void *priv)
}
}
/* 40-col */
else if (!(nga->cga.cgamode & 2)) {
else if (!(nga->cga.cgamode & CGA_MODE_FLAG_GRAPHICS)) {
/* for each text column */
for (x = 0; x < nga->cga.crtc[1]; x++) {
if (nga->cga.cgamode & 8) {
for (x = 0; x < nga->cga.crtc[CGA_CRTC_HDISP]; x++) {
if (nga->cga.cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) {
chr = nga->cga.vram[((nga->cga.ma << 1) & 0x3fff) + nga->base];
attr = nga->cga.vram[(((nga->cga.ma << 1) + 1) & 0x3fff) + nga->base];
} else {
@@ -237,7 +237,7 @@ nga_poll(void *priv)
/* set foreground */
cols[1] = (attr & 15) + 16;
/* blink active */
if (nga->cga.cgamode & 0x20) {
if (nga->cga.cgamode & CGA_MODE_FLAG_BLINK) {
cols[0] = ((attr >> 4) & 7) + 16;
if ((nga->cga.cgablink & 8) && (attr & 0x80) && !nga->cga.drawcursor) {
/* set blinking */
@@ -262,7 +262,7 @@ nga_poll(void *priv)
/* high res modes */
if (nga->cga.cgamode & 0x40) {
/* 640x400x2 mode */
if (nga->cga.cgamode & 0x4 || nga->cga.cgamode & 0x10) {
if (nga->cga.cgamode & 0x4 || nga->cga.cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS) {
/*
* Scanlines are read in the following order:
* 0b8000-0b9f3f even scans (0,4,...)
@@ -277,7 +277,7 @@ nga_poll(void *priv)
} else {
cols[0] = (nga->cga.cgacol & 15) | 16;
col = (nga->cga.cgacol & 16) ? 24 : 16;
if (nga->cga.cgamode & 4) {
if (nga->cga.cgamode & CGA_MODE_FLAG_BW) {
cols[1] = col | 3; /* Cyan */
cols[2] = col | 4; /* Red */
cols[3] = col | 7; /* White */
@@ -306,11 +306,11 @@ nga_poll(void *priv)
}
/* for each text column */
for (x = 0; x < nga->cga.crtc[1]; x++) {
for (x = 0; x < nga->cga.crtc[CGA_CRTC_HDISP]; x++) {
/* video out */
if (nga->cga.cgamode & 8) {
if (nga->cga.cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) {
/* 640x400x2 */
if (nga->cga.cgamode & 0x4 || nga->cga.cgamode & 0x10) {
if (nga->cga.cgamode & 0x4 || nga->cga.cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS) {
/* read two bytes at a time */
dat = (nga->cga.vram[((nga->cga.ma << 1) & 0x1fff) + dat2] << 8) | nga->cga.vram[((nga->cga.ma << 1) & 0x1fff) + dat2 + 1];
/* each pixel is represented by one bit, so draw 16 pixels at a time */
@@ -347,26 +347,26 @@ nga_poll(void *priv)
/* nga specific */
cols[0] = ((nga->cga.cgamode & 0x12) == 0x12) ? 0 : (nga->cga.cgacol & 15) + 16;
/* 80-col */
if (nga->cga.cgamode & 1) {
hline(buffer32, 0, (nga->cga.displine << 1), ((nga->cga.crtc[1] << 3) + 16) << 2, cols[0]);
hline(buffer32, 0, (nga->cga.displine << 1) + 1, ((nga->cga.crtc[1] << 3) + 16) << 2, cols[0]);
if (nga->cga.cgamode & CGA_MODE_FLAG_HIGHRES) {
hline(buffer32, 0, (nga->cga.displine << 1), ((nga->cga.crtc[CGA_CRTC_HDISP] << 3) + 16) << 2, cols[0]);
hline(buffer32, 0, (nga->cga.displine << 1) + 1, ((nga->cga.crtc[CGA_CRTC_HDISP] << 3) + 16) << 2, cols[0]);
} else {
hline(buffer32, 0, (nga->cga.displine << 1), ((nga->cga.crtc[1] << 4) + 16) << 2, cols[0]);
hline(buffer32, 0, (nga->cga.displine << 1) + 1, ((nga->cga.crtc[1] << 4) + 16) << 2, cols[0]);
hline(buffer32, 0, (nga->cga.displine << 1), ((nga->cga.crtc[CGA_CRTC_HDISP] << 4) + 16) << 2, cols[0]);
hline(buffer32, 0, (nga->cga.displine << 1) + 1, ((nga->cga.crtc[CGA_CRTC_HDISP] << 4) + 16) << 2, cols[0]);
}
}
if (nga->cga.cgamode & 1)
if (nga->cga.cgamode & CGA_MODE_FLAG_HIGHRES)
/* set screen width */
x = (nga->cga.crtc[1] << 3) + 16;
x = (nga->cga.crtc[CGA_CRTC_HDISP] << 3) + 16;
else
x = (nga->cga.crtc[1] << 4) + 16;
x = (nga->cga.crtc[CGA_CRTC_HDISP] << 4) + 16;
video_process_8(x, nga->cga.displine);
nga->cga.sc = oldsc;
/* vertical sync */
if (nga->cga.vc == nga->cga.crtc[7] && !nga->cga.sc)
if (nga->cga.vc == nga->cga.crtc[CGA_CRTC_VSYNC] && !nga->cga.sc)
nga->cga.cgastat |= 8;
nga->cga.displine++;
if (nga->cga.displine >= 720)
@@ -380,7 +380,7 @@ nga_poll(void *priv)
nga->lineff ^= 1;
/* text mode or 640x400x2 */
if (nga->lineff && !((nga->cga.cgamode & 1) && (nga->cga.cgamode & 0x40))) {
if (nga->lineff && !((nga->cga.cgamode & CGA_MODE_FLAG_HIGHRES) && (nga->cga.cgamode & 0x40))) {
nga->cga.ma = nga->cga.maback;
/* 640x400x4 */
} else {
@@ -390,11 +390,11 @@ nga_poll(void *priv)
nga->cga.cgastat &= ~8;
}
/* cursor stop scanline */
if (nga->cga.sc == (nga->cga.crtc[11] & 31) || ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == ((nga->cga.crtc[11] & 31) >> 1))) {
if (nga->cga.sc == (nga->cga.crtc[CGA_CRTC_CURSOR_END] & 31) || ((nga->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && nga->cga.sc == ((nga->cga.crtc[CGA_CRTC_CURSOR_END] & 31) >> 1))) {
nga->cga.cursorvisible = 0;
}
/* interlaced and max scanline per char reached */
if ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == (nga->cga.crtc[9] >> 1))
if ((nga->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && nga->cga.sc == (nga->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] >> 1))
nga->cga.maback = nga->cga.ma;
if (nga->cga.vadj) {
@@ -405,12 +405,12 @@ nga_poll(void *priv)
if (!nga->cga.vadj) {
nga->cga.cgadispon = 1;
/* change start of displayed page (crtc 12-13) */
nga->cga.ma = nga->cga.maback = (nga->cga.crtc[13] | (nga->cga.crtc[12] << 8)) & 0x7fff;
nga->cga.ma = nga->cga.maback = (nga->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (nga->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x7fff;
nga->cga.sc = 0;
}
/* nga specific */
/* end of character line reached */
} else if (nga->cga.sc == nga->cga.crtc[9] || ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == (nga->cga.crtc[9] >> 1))) {
} else if (nga->cga.sc == nga->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] || ((nga->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && nga->cga.sc == (nga->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] >> 1))) {
nga->cga.maback = nga->cga.ma;
nga->cga.sc = 0;
oldvc = nga->cga.vc;
@@ -418,21 +418,21 @@ nga_poll(void *priv)
nga->cga.vc &= 127;
/* lines of character displayed */
if (nga->cga.vc == nga->cga.crtc[6])
if (nga->cga.vc == nga->cga.crtc[CGA_CRTC_VDISP])
nga->cga.cgadispon = 0;
/* total vertical lines */
if (oldvc == nga->cga.crtc[4]) {
if (oldvc == nga->cga.crtc[CGA_CRTC_VTOTAL]) {
nga->cga.vc = 0;
/* adjust vertical lines */
nga->cga.vadj = nga->cga.crtc[5];
nga->cga.vadj = nga->cga.crtc[CGA_CRTC_VTOTAL_ADJUST];
if (!nga->cga.vadj) {
nga->cga.cgadispon = 1;
/* change start of displayed page (crtc 12-13) */
nga->cga.ma = nga->cga.maback = (nga->cga.crtc[13] | (nga->cga.crtc[12] << 8)) & 0x7fff;
nga->cga.ma = nga->cga.maback = (nga->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (nga->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x7fff;
}
/* cursor start */
switch (nga->cga.crtc[10] & 0x60) {
switch (nga->cga.crtc[CGA_CRTC_CURSOR_START] & 0x60) {
case 0x20:
nga->cga.cursoron = 0;
break;
@@ -445,18 +445,18 @@ nga_poll(void *priv)
}
}
/* vertical line position */
if (nga->cga.vc == nga->cga.crtc[7]) {
if (nga->cga.vc == nga->cga.crtc[CGA_CRTC_VSYNC]) {
nga->cga.cgadispon = 0;
nga->cga.displine = 0;
/* nga specific */
nga->cga.vsynctime = 16;
/* vsync pos */
if (nga->cga.crtc[7]) {
if (nga->cga.cgamode & 1)
if (nga->cga.crtc[CGA_CRTC_VSYNC]) {
if (nga->cga.cgamode & CGA_MODE_FLAG_HIGHRES)
/* set screen width */
x = (nga->cga.crtc[1] << 3) + 16;
x = (nga->cga.crtc[CGA_CRTC_HDISP] << 3) + 16;
else
x = (nga->cga.crtc[1] << 4) + 16;
x = (nga->cga.crtc[CGA_CRTC_HDISP] << 4) + 16;
nga->cga.lastline++;
xs_temp = x;
@@ -471,7 +471,7 @@ nga_poll(void *priv)
if (!enable_overscan)
xs_temp -= 16;
if ((nga->cga.cgamode & 8) && ((xs_temp != xsize) || (ys_temp != ysize) || video_force_resize_get())) {
if ((nga->cga.cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) && ((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));
@@ -493,14 +493,14 @@ nga_poll(void *priv)
video_res_x = xsize;
video_res_y = ysize;
/* 80-col */
if ((nga->cga.cgamode & 1) && !(nga->cga.cgamode & 0x40)) {
if ((nga->cga.cgamode & CGA_MODE_FLAG_HIGHRES) && !(nga->cga.cgamode & 0x40)) {
video_res_x /= 8;
video_res_y /= (nga->cga.crtc[9] + 1) * 2;
video_res_y /= (nga->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1) * 2;
video_bpp = 0;
/* 40-col */
} else if (!(nga->cga.cgamode & 2)) {
} else if (!(nga->cga.cgamode & CGA_MODE_FLAG_GRAPHICS)) {
video_res_x /= 16;
video_res_y /= (nga->cga.crtc[9] + 1) * 2;
video_res_y /= (nga->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1) * 2;
video_bpp = 0;
} else if (nga->cga.cgamode & 0x40) {
video_res_x /= 8;
@@ -523,13 +523,13 @@ nga_poll(void *priv)
nga->cga.cgastat &= ~1;
/* enable cursor if its scanline was reached */
if (nga->cga.sc == (nga->cga.crtc[10] & 31) || ((nga->cga.crtc[8] & 3) == 3 && nga->cga.sc == ((nga->cga.crtc[10] & 31) >> 1)))
if (nga->cga.sc == (nga->cga.crtc[CGA_CRTC_CURSOR_START] & 31) || ((nga->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && nga->cga.sc == ((nga->cga.crtc[CGA_CRTC_CURSOR_START] & 31) >> 1)))
nga->cga.cursorvisible = 1;
}
/* 80-columns */
if (nga->cga.cgadispon && (nga->cga.cgamode & 1)) {
if (nga->cga.cgadispon && (nga->cga.cgamode & CGA_MODE_FLAG_HIGHRES)) {
/* for each character per line */
for (x = 0; x < (nga->cga.crtc[1] << 1); x++)
for (x = 0; x < (nga->cga.crtc[CGA_CRTC_HDISP] << 1); x++)
nga->cga.charbuffer[x] = nga->cga.vram[(((nga->cga.ma << 1) + x) & 0x3fff) + nga->base];
}
}

View File

@@ -65,12 +65,12 @@ ogc_recalctimings(ogc_t *ogc)
double _dispofftime;
double disptime;
if (ogc->cga.cgamode & 1) {
disptime = ogc->cga.crtc[0] + 1;
_dispontime = ogc->cga.crtc[1];
if (ogc->cga.cgamode & CGA_MODE_FLAG_HIGHRES) {
disptime = ogc->cga.crtc[CGA_CRTC_HTOTAL] + 1;
_dispontime = ogc->cga.crtc[CGA_CRTC_HDISP];
} else {
disptime = (ogc->cga.crtc[0] + 1) << 1;
_dispontime = ogc->cga.crtc[1] << 1;
disptime = (ogc->cga.crtc[CGA_CRTC_HTOTAL] + 1) << 1;
_dispontime = ogc->cga.crtc[CGA_CRTC_HDISP] << 1;
}
_dispofftime = disptime - _dispontime;
@@ -201,7 +201,7 @@ void
ogc_poll(void *priv)
{
ogc_t *ogc = (ogc_t *) priv;
uint16_t ca = (ogc->cga.crtc[15] | (ogc->cga.crtc[14] << 8)) & 0x3fff;
uint16_t ca = (ogc->cga.crtc[CGA_CRTC_CURSOR_ADDR_LOW] | (ogc->cga.crtc[CGA_CRTC_CURSOR_ADDR_HIGH] << 8)) & 0x3fff;
int drawcursor;
int x;
int c;
@@ -220,7 +220,7 @@ ogc_poll(void *priv)
// composito colore appare blu scuro
/* graphic mode and not mode 40h */
if (!(ogc->ctrl_3de & 0x1 || !(ogc->cga.cgamode & 2))) {
if (!(ogc->ctrl_3de & 0x1 || !(ogc->cga.cgamode & CGA_MODE_FLAG_GRAPHICS))) {
/* standard cga mode */
cga_poll(&ogc->cga);
return;
@@ -231,7 +231,7 @@ ogc_poll(void *priv)
ogc->cga.cgastat |= 1;
ogc->cga.linepos = 1;
oldsc = ogc->cga.sc;
if ((ogc->cga.crtc[8] & 3) == 3)
if ((ogc->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3)
ogc->cga.sc = ((ogc->cga.sc << 1) + ogc->cga.oddeven) & 7;
if (ogc->cga.cgadispon) {
if (ogc->cga.displine < ogc->cga.firstline) {
@@ -240,11 +240,11 @@ ogc_poll(void *priv)
}
ogc->cga.lastline = ogc->cga.displine;
/* 80-col */
if (ogc->cga.cgamode & 1) {
if (ogc->cga.cgamode & CGA_MODE_FLAG_HIGHRES) {
/* for each text column */
for (x = 0; x < ogc->cga.crtc[1]; x++) {
for (x = 0; x < ogc->cga.crtc[CGA_CRTC_HDISP]; x++) {
/* video output enabled */
if (ogc->cga.cgamode & 8) {
if (ogc->cga.cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) {
/* character */
chr = ogc->cga.charbuffer[x << 1];
/* text attributes */
@@ -263,7 +263,7 @@ ogc_poll(void *priv)
/* set foreground */
cols[1] = (attr & 15) + 16;
/* blink active */
if (ogc->cga.cgamode & 0x20) {
if (ogc->cga.cgamode & CGA_MODE_FLAG_BLINK) {
cols[0] = ((attr >> 4) & 7) + 16;
/* attribute 7 active and not cursor */
if ((ogc->cga.cgablink & 8) && (attr & 0x80) && !ogc->cga.drawcursor) {
@@ -293,9 +293,9 @@ ogc_poll(void *priv)
}
}
/* 40-col */
else if (!(ogc->cga.cgamode & 2)) {
for (x = 0; x < ogc->cga.crtc[1]; x++) {
if (ogc->cga.cgamode & 8) {
else if (!(ogc->cga.cgamode & CGA_MODE_FLAG_GRAPHICS)) {
for (x = 0; x < ogc->cga.crtc[CGA_CRTC_HDISP]; x++) {
if (ogc->cga.cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) {
chr = ogc->cga.vram[((ogc->cga.ma << 1) & 0x3fff) + ogc->base];
attr = ogc->cga.vram[(((ogc->cga.ma << 1) + 1) & 0x3fff) + ogc->base];
} else {
@@ -312,7 +312,7 @@ ogc_poll(void *priv)
/* set foreground */
cols[1] = (attr & 15) + 16;
/* blink active */
if (ogc->cga.cgamode & 0x20) {
if (ogc->cga.cgamode & CGA_MODE_FLAG_BLINK) {
cols[0] = ((attr >> 4) & 7) + 16;
if ((ogc->cga.cgablink & 8) && (attr & 0x80) && !ogc->cga.drawcursor) {
/* set blinking */
@@ -352,9 +352,9 @@ ogc_poll(void *priv)
cols[1] = (ogc->cga.cgacol & 15) + 16;
}
for (x = 0; x < ogc->cga.crtc[1]; x++) {
for (x = 0; x < ogc->cga.crtc[CGA_CRTC_HDISP]; x++) {
/* video out */
if (ogc->cga.cgamode & 8) {
if (ogc->cga.cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) {
dat = (ogc->cga.vram[((ogc->cga.ma << 1) & 0x1fff) + dat2] << 8) | ogc->cga.vram[((ogc->cga.ma << 1) & 0x1fff) + dat2 + 1];
} else {
dat = 0;
@@ -370,22 +370,22 @@ ogc_poll(void *priv)
} else {
/* ogc specific */
cols[0] = ((ogc->cga.cgamode & 0x12) == 0x12) ? 0 : (ogc->cga.cgacol & 15) + 16;
if (ogc->cga.cgamode & 1)
hline(buffer32, 0, ogc->cga.displine, ((ogc->cga.crtc[1] << 3) + 16) << 2, cols[0]);
if (ogc->cga.cgamode & CGA_MODE_FLAG_HIGHRES)
hline(buffer32, 0, ogc->cga.displine, ((ogc->cga.crtc[CGA_CRTC_HDISP] << 3) + 16) << 2, cols[0]);
else
hline(buffer32, 0, ogc->cga.displine, ((ogc->cga.crtc[1] << 4) + 16) << 2, cols[0]);
hline(buffer32, 0, ogc->cga.displine, ((ogc->cga.crtc[CGA_CRTC_HDISP] << 4) + 16) << 2, cols[0]);
}
/* 80 columns */
if (ogc->cga.cgamode & 1)
x = (ogc->cga.crtc[1] << 3) + 16;
if (ogc->cga.cgamode & CGA_MODE_FLAG_HIGHRES)
x = (ogc->cga.crtc[CGA_CRTC_HDISP] << 3) + 16;
else
x = (ogc->cga.crtc[1] << 4) + 16;
x = (ogc->cga.crtc[CGA_CRTC_HDISP] << 4) + 16;
video_process_8(x, ogc->cga.displine);
ogc->cga.sc = oldsc;
if (ogc->cga.vc == ogc->cga.crtc[7] && !ogc->cga.sc)
if (ogc->cga.vc == ogc->cga.crtc[CGA_CRTC_VSYNC] && !ogc->cga.sc)
ogc->cga.cgastat |= 8;
ogc->cga.displine++;
if (ogc->cga.displine >= 720)
@@ -405,10 +405,10 @@ ogc_poll(void *priv)
if (!ogc->cga.vsynctime)
ogc->cga.cgastat &= ~8;
}
if (ogc->cga.sc == (ogc->cga.crtc[11] & 31) || ((ogc->cga.crtc[8] & 3) == 3 && ogc->cga.sc == ((ogc->cga.crtc[11] & 31) >> 1))) {
if (ogc->cga.sc == (ogc->cga.crtc[CGA_CRTC_CURSOR_END] & 31) || ((ogc->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && ogc->cga.sc == ((ogc->cga.crtc[CGA_CRTC_CURSOR_END] & 31) >> 1))) {
ogc->cga.cursorvisible = 0;
}
if ((ogc->cga.crtc[8] & 3) == 3 && ogc->cga.sc == (ogc->cga.crtc[9] >> 1))
if ((ogc->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && ogc->cga.sc == (ogc->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] >> 1))
ogc->cga.maback = ogc->cga.ma;
if (ogc->cga.vadj) {
ogc->cga.sc++;
@@ -417,28 +417,28 @@ ogc_poll(void *priv)
ogc->cga.vadj--;
if (!ogc->cga.vadj) {
ogc->cga.cgadispon = 1;
ogc->cga.ma = ogc->cga.maback = (ogc->cga.crtc[13] | (ogc->cga.crtc[12] << 8)) & 0x3fff;
ogc->cga.ma = ogc->cga.maback = (ogc->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (ogc->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff;
ogc->cga.sc = 0;
}
// potrebbe dare problemi con composito
} else if (ogc->cga.sc == ogc->cga.crtc[9] || ((ogc->cga.crtc[8] & 3) == 3 && ogc->cga.sc == (ogc->cga.crtc[9] >> 1))) {
} else if (ogc->cga.sc == ogc->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] || ((ogc->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && ogc->cga.sc == (ogc->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] >> 1))) {
ogc->cga.maback = ogc->cga.ma;
ogc->cga.sc = 0;
oldvc = ogc->cga.vc;
ogc->cga.vc++;
ogc->cga.vc &= 127;
if (ogc->cga.vc == ogc->cga.crtc[6])
if (ogc->cga.vc == ogc->cga.crtc[CGA_CRTC_VDISP])
ogc->cga.cgadispon = 0;
if (oldvc == ogc->cga.crtc[4]) {
if (oldvc == ogc->cga.crtc[CGA_CRTC_VTOTAL]) {
ogc->cga.vc = 0;
ogc->cga.vadj = ogc->cga.crtc[5];
ogc->cga.vadj = ogc->cga.crtc[CGA_CRTC_VTOTAL_ADJUST];
if (!ogc->cga.vadj) {
ogc->cga.cgadispon = 1;
ogc->cga.ma = ogc->cga.maback = (ogc->cga.crtc[13] | (ogc->cga.crtc[12] << 8)) & 0x3fff;
ogc->cga.ma = ogc->cga.maback = (ogc->cga.crtc[CGA_CRTC_START_ADDR_LOW] | (ogc->cga.crtc[CGA_CRTC_START_ADDR_HIGH] << 8)) & 0x3fff;
}
switch (ogc->cga.crtc[10] & 0x60) {
switch (ogc->cga.crtc[CGA_CRTC_CURSOR_START] & 0x60) {
case 0x20:
ogc->cga.cursoron = 0;
break;
@@ -450,16 +450,16 @@ ogc_poll(void *priv)
break;
}
}
if (ogc->cga.vc == ogc->cga.crtc[7]) {
if (ogc->cga.vc == ogc->cga.crtc[CGA_CRTC_VSYNC]) {
ogc->cga.cgadispon = 0;
ogc->cga.displine = 0;
/* ogc specific */
ogc->cga.vsynctime = (ogc->cga.crtc[3] >> 4) + 1;
if (ogc->cga.crtc[7]) {
if (ogc->cga.cgamode & 1)
x = (ogc->cga.crtc[1] << 3) + 16;
ogc->cga.vsynctime = (ogc->cga.crtc[CGA_CRTC_HSYNC_WIDTH] >> 4) + 1;
if (ogc->cga.crtc[CGA_CRTC_VSYNC]) {
if (ogc->cga.cgamode & CGA_MODE_FLAG_HIGHRES)
x = (ogc->cga.crtc[CGA_CRTC_HDISP] << 3) + 16;
else
x = (ogc->cga.crtc[1] << 4) + 16;
x = (ogc->cga.crtc[CGA_CRTC_HDISP] << 4) + 16;
ogc->cga.lastline++;
xs_temp = x;
@@ -474,7 +474,7 @@ ogc_poll(void *priv)
if (!enable_overscan)
xs_temp -= 16;
if ((ogc->cga.cgamode & 8) && ((xs_temp != xsize) || (ys_temp != ysize) || video_force_resize_get())) {
if ((ogc->cga.cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) && ((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));
@@ -496,14 +496,14 @@ ogc_poll(void *priv)
video_res_x = xsize;
video_res_y = ysize;
/* 80-col */
if (ogc->cga.cgamode & 1) {
if (ogc->cga.cgamode & CGA_MODE_FLAG_HIGHRES) {
video_res_x /= 8;
video_res_y /= (ogc->cga.crtc[9] + 1) * 2;
video_res_y /= (ogc->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1) * 2;
video_bpp = 0;
/* 40-col */
} else if (!(ogc->cga.cgamode & 2)) {
} else if (!(ogc->cga.cgamode & CGA_MODE_FLAG_GRAPHICS)) {
video_res_x /= 16;
video_res_y /= (ogc->cga.crtc[9] + 1) * 2;
video_res_y /= (ogc->cga.crtc[CGA_CRTC_MAX_SCANLINE_ADDR] + 1) * 2;
video_bpp = 0;
} else if (!(ogc->ctrl_3de & 1)) {
video_res_y /= 2;
@@ -524,12 +524,12 @@ ogc_poll(void *priv)
if (ogc->cga.cgadispon)
ogc->cga.cgastat &= ~1;
if (ogc->cga.sc == (ogc->cga.crtc[10] & 31) || ((ogc->cga.crtc[8] & 3) == 3 && ogc->cga.sc == ((ogc->cga.crtc[10] & 31) >> 1)))
if (ogc->cga.sc == (ogc->cga.crtc[CGA_CRTC_CURSOR_START] & 31) || ((ogc->cga.crtc[CGA_CRTC_INTERLACE] & 3) == 3 && ogc->cga.sc == ((ogc->cga.crtc[CGA_CRTC_CURSOR_START] & 31) >> 1)))
ogc->cga.cursorvisible = 1;
}
/* 80-columns */
if (ogc->cga.cgadispon && (ogc->cga.cgamode & 1)) {
for (x = 0; x < (ogc->cga.crtc[1] << 1); x++)
if (ogc->cga.cgadispon && (ogc->cga.cgamode & CGA_MODE_FLAG_HIGHRES)) {
for (x = 0; x < (ogc->cga.crtc[CGA_CRTC_HDISP] << 1); x++)
ogc->cga.charbuffer[x] = ogc->cga.vram[(((ogc->cga.ma << 1) + x) & 0x3fff) + ogc->base];
}
}