This commit is contained in:
OBattler
2025-06-09 17:17:09 +02:00
17 changed files with 138 additions and 108 deletions

View File

@@ -15,16 +15,65 @@
*
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
* Copyright 2025 starfrost (refactoring)
*/
#ifndef VIDEO_CGA_H
#define VIDEO_CGA_H
// Mode flags for the CGA.
// Set by writing to 3D8
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
CGA_MODE_FLAG_VIDEO_ENABLE = 1 << 3, // 0 = no video (as if the video was 0)
CGA_MODE_FLAG_HIGHRES_GRAPHICS = 1 << 4, // 640*200 mode. Corrupts text mode if CGA_MODE_FLAG_GRAPHICS not set.
CGA_MODE_FLAG_BLINK = 1 << 5, // If this is set, bit 5 of textmode characters blinks. Otherwise it is a high-intensity bg mode.
} cga_mode_flags;
// Motorola MC6845 CRTC registers
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
CGA_CRTC_HSYNC_WIDTH = 0x3, // Width of horizontal sync
CGA_CRTC_VTOTAL = 0x4, // Vertical total (total number of scanlines incl. vsync)
CGA_CRTC_VTOTAL_ADJUST = 0x5, // Vertical total adjust value
CGA_CRTC_VDISP = 0x6, // Vertical display (total number of displayed scanline)
CGA_CRTC_VSYNC = 0x7, // Vertical sync scanline number
CGA_CRTC_INTERLACE = 0x8, // Interlacing mode
CGA_CRTC_MAX_SCANLINE_ADDR = 0x9, // Maximum scanline address
CGA_CRTC_CURSOR_START = 0xA, // Cursor start scanline
CGA_CRTC_CURSOR_END = 0xB, // Cursor end scanline
CGA_CRTC_START_ADDR_HIGH = 0xC, // Screen start address high 8 bits
CGA_CRTC_START_ADDR_LOW = 0xD, // Screen start address low 8 bits
CGA_CRTC_CURSOR_ADDR_HIGH = 0xE, // Cursor address high 8 bits
CGA_CRTC_CURSOR_ADDR_LOW = 0xF, // Cursor address low 8 bits
CGA_CRTC_LIGHT_PEN_ADDR_HIGH = 0x10, // Light pen address high 8 bits (not currently supported)
CGA_CRTC_LIGHT_PEN_ADDR_LOW = 0x11, // Light pen address low 8 bits (not currently supported)
} cga_crtc_registers;
typedef enum cga_registers_e
{
CGA_REGISTER_CRTC_INDEX = 0x3D4,
CGA_REGISTER_CRTC_DATA = 0x3D5,
CGA_REGISTER_MODE_CONTROL = 0x3D8,
CGA_REGISTER_COLOR_SELECT = 0x3D9,
CGA_REGISTER_STATUS = 0x3DA,
CGA_REGISTER_CLEAR_LIGHT_PEN_LATCH = 0x3DB,
CGA_REGISTER_SET_LIGHT_PEN_LATCH = 0x3DC,
} cga_registers;
#define CGA_NUM_CRTC_REGS 32
typedef struct cga_t {
mem_mapping_t mapping;
int crtcreg;
uint8_t crtc[32];
uint8_t crtc[CGA_NUM_CRTC_REGS];
uint8_t cgastat;
@@ -40,7 +89,6 @@ typedef struct cga_t {
int vc;
int cgadispon;
int con;
int coff;
int cursoron;
int cgablink;
int vsynctime;

View File

@@ -47,7 +47,6 @@ typedef struct {
uint16_t ma;
uint16_t maback;
int con;
int coff;
int cursoron;
int dispon;
int blink;

View File

@@ -29,7 +29,6 @@ typedef struct mda_t {
uint16_t ma;
uint16_t maback;
int con;
int coff;
int cursoron;
int dispon;
int blink;

View File

@@ -116,7 +116,6 @@ typedef struct pgc {
int vc;
int cgadispon;
int con;
int coff;
int cursoron;
int cgablink;
int vsynctime;