diff --git a/src/include/86box/vid_cga.h b/src/include/86box/vid_cga.h
index 04616431e..2198154ed 100644
--- a/src/include/86box/vid_cga.h
+++ b/src/include/86box/vid_cga.h
@@ -8,15 +8,13 @@
*
* Emulation of the old and new IBM CGA graphics cards.
*
- *
- *
* Authors: Sarah Walker,
- * Miran Grca, ,
+ * Miran Grca,
* Connor Hyde / starfrost,
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
- * Copyright 2025 starfrost (refactoring)
+ * Copyright 2025 starfrost (refactoring).
*/
#ifndef VIDEO_CGA_H
@@ -24,8 +22,7 @@
// Mode flags for the CGA.
// Set by writing to 3D8
-typedef enum cga_mode_flags_e
-{
+typedef enum cga_mode_flags_e {
CGA_MODE_FLAG_HIGHRES = 1 << 0, // 80-column text mode
CGA_MODE_FLAG_GRAPHICS = 1 << 1, // Graphics mode
CGA_MODE_FLAG_BW = 1 << 2, // Black and white
@@ -35,8 +32,7 @@ typedef enum cga_mode_flags_e
} cga_mode_flags;
// Motorola MC6845 CRTC registers
-typedef enum cga_crtc_registers_e
-{
+typedef enum cga_crtc_registers_e {
CGA_CRTC_HTOTAL = 0x0, // Horizontal total (total number of characters incl. hsync)
CGA_CRTC_HDISP = 0x1, // Horizontal display
CGA_CRTC_HSYNC_POS = 0x2, // Horizontal position of horizontal ysnc
@@ -58,8 +54,7 @@ typedef enum cga_crtc_registers_e
} cga_crtc_registers;
// Registers for the CGA
-typedef enum cga_registers_e
-{
+typedef enum cga_registers_e {
CGA_REGISTER_CRTC_INDEX = 0x3D4,
CGA_REGISTER_CRTC_DATA = 0x3D5,
CGA_REGISTER_MODE_CONTROL = 0x3D8,
@@ -129,11 +124,11 @@ uint8_t cga_read(uint32_t addr, void *priv);
void cga_recalctimings(cga_t *cga);
void cga_poll(void *priv);
-#ifdef EMU_DEVICE_H
-extern const device_config_t cga_config[];
-
-extern const device_t cga_device;
-extern const device_t cga_pravetz_device;
-#endif
-
+//#ifdef EMU_DEVICE_H
+//extern const device_config_t cga_config[];
+//
+//extern const device_t cga_device;
+//extern const device_t cga_pravetz_device;
+//#endif
+//
#endif /*VIDEO_CGA_H*/
diff --git a/src/include/86box/video.h b/src/include/86box/video.h
index 70d031a4f..62fea0b9a 100644
--- a/src/include/86box/video.h
+++ b/src/include/86box/video.h
@@ -399,6 +399,13 @@ extern const device_t gd5446_pci_device;
extern const device_t gd5446_stb_pci_device;
extern const device_t gd5480_pci_device;
+
+/* IBM CGA*/
+extern const device_t cga_device;
+
+/* pravetz CGA */
+extern const device_t cga_pravetz_device;
+
/* Compaq CGA */
extern const device_t compaq_cga_device;
extern const device_t compaq_cga_2_device;
diff --git a/src/machine/m_xt_zenith.c b/src/machine/m_xt_zenith.c
index 62c6496d1..2159c18e5 100644
--- a/src/machine/m_xt_zenith.c
+++ b/src/machine/m_xt_zenith.c
@@ -45,7 +45,7 @@
#include <86box/serial.h>
#include <86box/machine.h>
#include <86box/io.h>
-#include <86box/vid_cga.h>
+#include <86box/video.h>
#include <86box/plat_unused.h>
typedef struct {
diff --git a/src/video/vid_cga.c b/src/video/vid_cga.c
index 2abfe6a5c..1ca742890 100644
--- a/src/video/vid_cga.c
+++ b/src/video/vid_cga.c
@@ -8,15 +8,13 @@
*
* Emulation of the old and new IBM CGA graphics cards.
*
- *
- *
* Authors: Sarah Walker,
* Miran Grca,
* W. M. Martinez,
*
* Copyright 2008-2019 Sarah Walker.
* Copyright 2016-2019 Miran Grca.
- * Copyright 2023 W. M. Martinez
+ * Copyright 2023 W. M. Martinez
*/
#include
#include
@@ -284,7 +282,7 @@ cga_render(cga_t *cga, int line)
buffer32->line[line][column + (cga->crtc[CGA_CRTC_HDISP] << 4) + 8] = (cga->cgacol & 15) + 16;
}
}
- if (cga->cgamode & CGA_MODE_FLAG_HIGHRES) {
+ if (cga->cgamode & CGA_MODE_FLAG_HIGHRES) { /* 80-column text */
for (x = 0; x < cga->crtc[CGA_CRTC_HDISP]; x++) {
if (cga->cgamode & CGA_MODE_FLAG_VIDEO_ENABLE) {
chr = cga->charbuffer[x << 1];
@@ -342,7 +340,7 @@ cga_render(cga_t *cga, int line)
}
}
}
- } else if (!(cga->cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)) {
+ } else if (!(cga->cgamode & CGA_MODE_FLAG_HIGHRES_GRAPHICS)) { /* not hi-res (but graphics) => 4-color mode */
cols[0] = (cga->cgacol & 15) | 16;
col = (cga->cgacol & 16) ? 24 : 16;
if (cga->cgamode & CGA_MODE_FLAG_BW) {
@@ -372,7 +370,7 @@ cga_render(cga_t *cga, int line)
dat <<= 2;
}
}
- } else {
+ } else { /* 2-color hi-res graphics mode */
cols[0] = 0;
cols[1] = (cga->cgacol & 15) + 16;
for (x = 0; x < cga->crtc[CGA_CRTC_HDISP]; x++) {
@@ -500,7 +498,7 @@ cga_interpolate(cga_t *cga, int x, int y, int w, int h)
interim_1 = cga_interpolate_lookup(cga, prev_color, black, quotient);
interim_2 = cga_interpolate_lookup(cga, black, next_color, quotient);
- final = cga_interpolate_lookup(cga, interim_1, interim_2, quotient);
+ final = cga_interpolate_lookup(cga, interim_1, interim_2, quotient);
buffer32->line[i][j] = final.color;
}
@@ -746,9 +744,8 @@ void *
cga_standalone_init(UNUSED(const device_t *info))
{
int display_type;
- cga_t *cga = malloc(sizeof(cga_t));
+ cga_t *cga = calloc(1, sizeof(cga_t));
- memset(cga, 0, sizeof(cga_t));
video_inform(VIDEO_FLAG_TYPE_CGA, &timing_cga);
display_type = device_get_config_int("display_type");
diff --git a/src/video/vid_cga_olivetti.c b/src/video/vid_cga_olivetti.c
index 8be40ee2e..147529f6e 100644
--- a/src/video/vid_cga_olivetti.c
+++ b/src/video/vid_cga_olivetti.c
@@ -38,6 +38,7 @@
#include <86box/rom.h>
#include <86box/device.h>
#include <86box/vid_cga.h>
+extern const device_config_t cga_config[]; /* defined in vid_cga.c */
#include <86box/vid_ogc.h>
#include <86box/vid_cga_comp.h>
#include <86box/plat_unused.h>