Merge pull request #2393 from 86Box/tc1995

Added initial (and a bit buggy on OS/2, so use 8514/A on it instead) emulation of XGA
This commit is contained in:
Miran Grča
2022-06-18 00:04:02 +02:00
committed by GitHub
11 changed files with 3257 additions and 5 deletions

View File

@@ -172,6 +172,7 @@ int GUS = 0; /* (C) sound option */
int SSI2001 = 0; /* (C) sound option */
int voodoo_enabled = 0; /* (C) video option */
int ibm8514_enabled = 0; /* (C) video option */
int xga_enabled = 0; /* (C) video option */
uint32_t mem_size = 0; /* (C) memory size (Installed on system board)*/
uint32_t isa_mem_size = 0; /* (C) memory size (ISA Memory Cards) */
int cpu_use_dynarec = 0; /* (C) cpu uses/needs Dyna */

View File

@@ -931,6 +931,7 @@ load_video(void)
voodoo_enabled = !!config_get_int(cat, "voodoo", 0);
ibm8514_enabled = !!config_get_int(cat, "8514a", 0);
xga_enabled = !!config_get_int(cat, "xga", 0);
}
@@ -2474,6 +2475,11 @@ save_video(void)
else
config_set_int(cat, "8514a", ibm8514_enabled);
if (xga_enabled == 0)
config_delete_var(cat, "xga");
else
config_set_int(cat, "xga", xga_enabled);
delete_section_if_empty(cat);
}

View File

@@ -112,7 +112,8 @@ extern int sound_is_float, /* (C) sound uses FP values */
GUS, GUSMAX, /* (C) sound option */
SSI2001, /* (C) sound option */
voodoo_enabled, /* (C) video option */
ibm8514_enabled; /* (C) video option */
ibm8514_enabled, /* (C) video option */
xga_enabled; /* (C) video option */
extern uint32_t mem_size; /* (C) memory size (Installed on system board) */
extern uint32_t isa_mem_size; /* (C) memory size (ISA Memory Cards) */
extern int cpu, /* (C) cpu type */

View File

@@ -19,6 +19,7 @@
#include <86box/thread.h>
#include <86box/vid_8514a.h>
#include <86box/vid_xga.h>
#ifndef VIDEO_SVGA_H
# define VIDEO_SVGA_H
@@ -49,6 +50,7 @@ typedef union {
typedef struct svga_t
{
ibm8514_t dev8514;
xga_t xga;
mem_mapping_t mapping;
uint8_t fast, chain4, chain2_write, chain2_read,
@@ -176,6 +178,9 @@ extern int vga_on, ibm8514_on;
extern void ibm8514_poll(ibm8514_t *dev, svga_t *svga);
extern void ibm8514_recalctimings(svga_t *svga);
extern void xga_poll(xga_t *xga, svga_t *svga);
extern void xga_recalctimings(svga_t *svga);
extern int svga_init(const device_t *info, svga_t *svga, void *p, int memsize,
void (*recalctimings_ex)(struct svga_t *svga),
uint8_t (*video_in) (uint16_t addr, void *p),

162
src/include/86box/vid_xga.h Normal file
View File

@@ -0,0 +1,162 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* IBM XGA emulation.
*
*
*
* Authors: TheCollector1995.
*
* Copyright 2022 TheCollector1995.
*/
#ifndef VIDEO_XGA_H
# define VIDEO_XGA_H
#include <86box/rom.h>
typedef struct {
int ena;
int x, y, xoff, yoff, xsize, ysize;
uint32_t addr;
} xga_hwcursor_t;
typedef struct xga_t
{
mem_mapping_t memio_mapping;
mem_mapping_t linear_mapping;
mem_mapping_t video_mapping;
rom_t bios_rom;
xga_hwcursor_t hwcursor, hwcursor_latch;
PALETTE extpal;
uint8_t test, atest[2], testpixel;;
uint8_t pos_regs[8];
uint8_t disp_addr;
uint8_t cfg_reg;
uint8_t instance;
uint8_t op_mode;
uint8_t aperture_cntl;
uint8_t ap_idx;
uint8_t access_mode;
uint8_t regs[0x100];
uint8_t regs_idx;
uint8_t hwc_hotspot_x;
uint8_t hwc_hotspot_y;
uint8_t disp_cntl_1, disp_cntl_2;
uint8_t clk_sel_1, clk_sel_2;
uint8_t hwc_control;
uint8_t bus_arb;
uint8_t select_pos_isa;
uint8_t hwcursor_oddeven;
uint8_t cfg_reg_instance;
uint8_t rowcount;
uint8_t pal_idx, pal_idx_prefetch;
uint8_t pal_seq;
uint8_t pal_mask;
uint8_t pal_r, pal_r_prefetch;
uint8_t pal_g, pal_g_prefetch;
uint8_t pal_b, pal_b_prefetch;
uint8_t sprite_data[1024];
uint8_t *vram, *changedvram;
int16_t hwc_pos_x;
int16_t hwc_pos_y;
uint16_t pos_idx;
uint16_t htotal;
uint16_t sprite_idx, sprite_idx_prefetch;
uint16_t hdisp;
uint16_t vtotal;
uint16_t vdispend;
uint16_t vblankstart;
uint16_t vsyncstart;
uint16_t linecmp;
uint16_t pix_map_width;
uint16_t sprite_pal_addr_idx, old_pal_addr_idx;
uint16_t sprite_pal_addr_idx_prefetch;
int v_total, dispend, v_syncstart, split, v_blankstart,
h_disp, h_disp_old, h_total, h_disp_time, rowoffset,
dispon, h_disp_on, vc, sc, linepos, oddeven, firstline, lastline,
firstline_draw, lastline_draw, displine, fullchange, interlace,
char_width, hwcursor_on;
int pal_pos, pal_pos_prefetch;
int on;
int op_mode_reset;
int sprite_pos, sprite_pos_prefetch, cursor_data_on;
int pal_test;
int from_to_vram;
uint32_t linear_base, linear_size;
uint32_t base_addr_1mb;
uint32_t hwc_color0, hwc_color1;
uint32_t disp_start_addr;
uint32_t ma_latch;
uint32_t vram_size;
uint32_t vram_mask;
uint32_t rom_addr;
uint32_t ma, maback;
uint32_t extpallook[256];
uint32_t read_bank, write_bank;
uint32_t px_map_base;
uint64_t dispontime, dispofftime;
struct
{
uint8_t control;
uint8_t px_map_idx;
uint8_t frgd_mix, bkgd_mix;
uint8_t cc_cond;
uint8_t octant;
uint8_t draw_mode;
uint8_t mask_mode;
uint8_t short_stroke_vector1;
uint8_t short_stroke_vector2;
uint8_t short_stroke_vector3;
uint8_t short_stroke_vector4;
int16_t bres_err_term;
int16_t bres_k1, bres_k2;
uint16_t blt_width;
uint16_t blt_height;
uint16_t mask_map_origin_x_off;
uint16_t mask_map_origin_y_off;
uint16_t src_map_x, src_map_y;
uint16_t dst_map_x, dst_map_y;
uint16_t pat_map_x, pat_map_y;
int ssv_state;
int pat_src;
int src_map;
int dst_map;
int bkgd_src;
int fore_src;
int x, y, sx, sy, dx, dy, px, py;
int pattern;
int command_len;
uint32_t short_stroke;
uint32_t color_cmp;
uint32_t carry_chain;
uint32_t plane_mask;
uint32_t frgd_color, bkgd_color;
uint32_t command;
uint32_t dir_cmd;
uint8_t px_map_format[4];
uint16_t px_map_width[4];
uint16_t px_map_height[4];
uint32_t px_map_base[4];
} accel;
volatile int force_busy;
} xga_t;
#endif /*VIDEO_XGA_H*/

View File

@@ -47,6 +47,7 @@ void SettingsDisplay::save() {
gfxcard = ui->comboBoxVideo->currentData().toInt();
voodoo_enabled = ui->checkBoxVoodoo->isChecked() ? 1 : 0;
ibm8514_enabled = ui->checkBox8514->isChecked() ? 1 : 0;
xga_enabled = ui->checkBoxXga->isChecked() ? 1 : 0;
}
void SettingsDisplay::onCurrentMachineChanged(int machineId) {
@@ -119,8 +120,12 @@ void SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index) {
bool has_MCA = machine_has_bus(machineId, MACHINE_BUS_MCA) > 0;
ui->checkBox8514->setEnabled(hasIsa16 || has_MCA);
if (hasIsa16 || has_MCA) {
ui->checkBox8514->setChecked(ibm8514_enabled > 0);
ui->checkBox8514->setChecked(ibm8514_enabled);
}
ui->checkBoxXga->setEnabled(hasIsa16 || has_MCA);
if (hasIsa16 || has_MCA)
ui->checkBoxXga->setChecked(xga_enabled);
}
void SettingsDisplay::on_checkBoxVoodoo_stateChanged(int state) {

View File

@@ -70,7 +70,14 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxXga">
<property name="text">
<string>XGA</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>

View File

@@ -24,7 +24,8 @@ add_library(vid OBJECT agpgart.c video.c vid_table.c vid_cga.c vid_cga_comp.c
vid_stg_ramdac.c vid_ht216.c vid_oak_oti.c vid_paradise.c vid_rtg310x.c
vid_f82c425.c vid_ti_cf62011.c vid_tvga.c vid_tgui9440.c vid_tkd8001_ramdac.c
vid_att20c49x_ramdac.c vid_s3.c vid_s3_virge.c vid_ibm_rgb528_ramdac.c
vid_sdac_ramdac.c vid_ogc.c vid_nga.c vid_tvp3026_ramdac.c vid_att2xc498_ramdac.c)
vid_sdac_ramdac.c vid_ogc.c vid_nga.c vid_tvp3026_ramdac.c vid_att2xc498_ramdac.c
vid_xga.c)
if(MGA)
target_compile_definitions(vid PRIVATE USE_MGA)

View File

@@ -560,6 +560,8 @@ svga_recalctimings(svga_t *svga)
} else {
if (ibm8514_on && ibm8514_enabled)
ibm8514_recalctimings(svga);
if (xga_enabled)
xga_recalctimings(svga);
}
svga->y_add = (overscan_y >> 1) - (svga->crtc[8] & 0x1f);
@@ -660,6 +662,9 @@ svga_poll(void *p)
if (!vga_on && ibm8514_enabled && ibm8514_on) {
ibm8514_poll(&svga->dev8514, svga);
return;
} else if (!vga_on && xga_enabled && svga->xga.on) {
xga_poll(&svga->xga, svga);
return;
}
if (!svga->linepos) {
@@ -1070,6 +1075,23 @@ svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *p)
cycles -= video_timing_write_b;
if (!linear) {
if (xga_enabled) {
if (((svga->xga.op_mode & 7) == 4) && (svga->xga.aperture_cntl == 1)) {
if (val == 0xa5) { /*Memory size test of XGA*/
svga->xga.test = val;
return;
} else if (val == 0x5a) {
svga->xga.test = val;
return;
} else if (val == 0x12 || val == 0x34) {
addr += svga->xga.write_bank;
svga->xga.vram[addr & svga->xga.vram_mask] = val;
svga->xga.op_mode_reset = 1;
return;
}
} else
svga->xga.on = 0;
}
addr = svga_decode_addr(svga, addr, 1);
if (addr == 0xffffffff)
@@ -1254,6 +1276,21 @@ svga_read_common(uint32_t addr, uint8_t linear, void *p)
cycles -= video_timing_read_b;
if (!linear) {
if (xga_enabled) {
if (((svga->xga.op_mode & 7) == 4) && (svga->xga.aperture_cntl == 1)) {
if (svga->xga.test == 0xa5) { /*Memory size test of XGA*/
svga->xga.on = 1;
return svga->xga.test;
} else if (svga->xga.test == 0x5a) {
svga->xga.on = 1;
return svga->xga.test;
} else if (addr == 0xa0000 || addr == 0xa0010) {
addr += svga->xga.read_bank;
return svga->xga.vram[addr & svga->xga.vram_mask];
}
} else
svga->xga.on = 0;
}
addr = svga_decode_addr(svga, addr, 0);
if (addr == 0xffffffff)

3026
src/video/vid_xga.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -715,7 +715,8 @@ VIDOBJ := agpgart.o video.o \
vid_ibm_rgb528_ramdac.o vid_sdac_ramdac.o \
vid_ogc.o \
vid_nga.o \
vid_tvp3026_ramdac.o
vid_tvp3026_ramdac.o \
vid_xga.o
VOODOOOBJ := vid_voodoo.o vid_voodoo_banshee.o \
vid_voodoo_banshee_blitter.o \