2017-05-30 03:38:38 +02:00
|
|
|
/*
|
2023-01-06 15:36:05 -05:00
|
|
|
* 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.
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* This file is part of the 86Box distribution.
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Emulation of the old and new IBM CGA graphics cards.
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
2020-03-25 00:46:02 +02:00
|
|
|
*
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
2023-01-06 15:36:29 -05:00
|
|
|
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
|
2023-01-06 15:36:05 -05:00
|
|
|
* Miran Grca, <mgrca8@gmail.com>
|
2017-10-11 05:40:44 -04:00
|
|
|
*
|
2023-01-06 15:36:05 -05:00
|
|
|
* Copyright 2008-2019 Sarah Walker.
|
|
|
|
|
* Copyright 2016-2019 Miran Grca.
|
2017-05-30 03:38:38 +02:00
|
|
|
*/
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <string.h>
|
2016-06-26 00:34:39 +02:00
|
|
|
#include <stdlib.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <wchar.h>
|
2016-06-26 00:34:39 +02:00
|
|
|
#include <math.h>
|
2020-03-29 14:24:42 +02:00
|
|
|
#include <86box/86box.h>
|
2020-02-29 19:12:23 +01:00
|
|
|
#include "cpu.h"
|
2020-03-29 14:24:42 +02:00
|
|
|
#include <86box/io.h>
|
|
|
|
|
#include <86box/timer.h>
|
|
|
|
|
#include <86box/pit.h>
|
|
|
|
|
#include <86box/mem.h>
|
|
|
|
|
#include <86box/rom.h>
|
|
|
|
|
#include <86box/device.h>
|
|
|
|
|
#include <86box/video.h>
|
|
|
|
|
#include <86box/vid_cga.h>
|
|
|
|
|
#include <86box/vid_cga_comp.h>
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2022-08-31 19:19:29 -04:00
|
|
|
#define CGA_RGB 0
|
2016-07-09 02:18:45 +02:00
|
|
|
#define CGA_COMPOSITE 1
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2016-07-09 02:18:45 +02:00
|
|
|
#define COMPOSITE_OLD 0
|
|
|
|
|
#define COMPOSITE_NEW 1
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2022-08-31 19:19:29 -04:00
|
|
|
static uint8_t crtcmask[32] = {
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x7f, 0x7f, 0xf3, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff,
|
|
|
|
|
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
2016-06-26 00:34:39 +02:00
|
|
|
};
|
|
|
|
|
|
2022-08-31 19:19:29 -04:00
|
|
|
static video_timings_t timing_cga = { .type = VIDEO_ISA, .write_b = 8, .write_w = 16, .write_l = 32, .read_b = 8, .read_w = 16, .read_l = 32 };
|
2018-09-19 20:13:32 +02:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
void cga_recalctimings(cga_t *cga);
|
|
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
void
|
|
|
|
|
cga_out(uint16_t addr, uint8_t val, void *p)
|
|
|
|
|
{
|
2022-08-31 19:19:29 -04:00
|
|
|
cga_t *cga = (cga_t *) p;
|
2019-02-06 03:34:39 +01:00
|
|
|
uint8_t old;
|
|
|
|
|
|
2021-05-22 03:16:02 +02:00
|
|
|
if ((addr >= 0x3d0) && (addr <= 0x3d7))
|
2022-08-31 19:19:29 -04:00
|
|
|
addr = (addr & 0xff9) | 0x004;
|
2021-05-22 03:16:02 +02:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
switch (addr) {
|
2022-08-31 19:19:29 -04:00
|
|
|
case 0x3D4:
|
|
|
|
|
cga->crtcreg = val & 31;
|
|
|
|
|
return;
|
|
|
|
|
case 0x3D5:
|
|
|
|
|
old = cga->crtc[cga->crtcreg];
|
|
|
|
|
cga->crtc[cga->crtcreg] = val & crtcmask[cga->crtcreg];
|
|
|
|
|
if (old != val) {
|
|
|
|
|
if ((cga->crtcreg < 0xe) || (cga->crtcreg > 0x10)) {
|
|
|
|
|
cga->fullchange = changeframecount;
|
|
|
|
|
cga_recalctimings(cga);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
case 0x3D8:
|
|
|
|
|
old = cga->cgamode;
|
|
|
|
|
cga->cgamode = val;
|
|
|
|
|
|
|
|
|
|
if (old ^ val) {
|
|
|
|
|
if ((old ^ val) & 0x05)
|
|
|
|
|
update_cga16_color(val);
|
|
|
|
|
|
|
|
|
|
cga_recalctimings(cga);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
case 0x3D9:
|
|
|
|
|
old = cga->cgacol;
|
|
|
|
|
cga->cgacol = val;
|
|
|
|
|
if (old ^ val)
|
|
|
|
|
cga_recalctimings(cga);
|
|
|
|
|
return;
|
2019-02-06 03:34:39 +01:00
|
|
|
}
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
uint8_t
|
|
|
|
|
cga_in(uint16_t addr, void *p)
|
|
|
|
|
{
|
|
|
|
|
cga_t *cga = (cga_t *) p;
|
|
|
|
|
|
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
|
|
|
uint8_t ret = 0xff;
|
|
|
|
|
|
2021-05-22 03:16:02 +02:00
|
|
|
if ((addr >= 0x3d0) && (addr <= 0x3d7))
|
2022-08-31 19:19:29 -04:00
|
|
|
addr = (addr & 0xff9) | 0x004;
|
2021-05-22 03:16:02 +02:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
switch (addr) {
|
2022-08-31 19:19:29 -04:00
|
|
|
case 0x3D4:
|
|
|
|
|
ret = cga->crtcreg;
|
|
|
|
|
break;
|
|
|
|
|
case 0x3D5:
|
|
|
|
|
ret = cga->crtc[cga->crtcreg];
|
|
|
|
|
break;
|
|
|
|
|
case 0x3DA:
|
|
|
|
|
ret = cga->cgastat;
|
|
|
|
|
break;
|
2019-02-06 03:34:39 +01:00
|
|
|
}
|
|
|
|
|
|
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
|
|
|
return ret;
|
2018-03-10 09:45:24 -06:00
|
|
|
}
|
|
|
|
|
|
2022-10-20 00:33:30 +02:00
|
|
|
void
|
|
|
|
|
cga_pravetz_out(uint16_t addr, uint8_t val, void *p)
|
|
|
|
|
{
|
2022-11-19 08:49:04 -05:00
|
|
|
cga_t *cga = (cga_t *) p;
|
2022-10-20 00:33:30 +02:00
|
|
|
|
|
|
|
|
cga->fontbase = (((unsigned int) val) << 8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t
|
|
|
|
|
cga_pravetz_in(uint16_t addr, void *p)
|
|
|
|
|
{
|
|
|
|
|
cga_t *cga = (cga_t *) p;
|
|
|
|
|
|
|
|
|
|
return (cga->fontbase >> 8);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
void
|
|
|
|
|
cga_waitstates(void *p)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2022-08-31 19:19:29 -04:00
|
|
|
int ws_array[16] = { 3, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8 };
|
2019-02-06 03:34:39 +01:00
|
|
|
int ws;
|
2017-02-20 06:05:11 +01:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
ws = ws_array[cycles & 0xf];
|
2020-11-26 18:20:24 +01:00
|
|
|
cycles -= ws;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
void
|
|
|
|
|
cga_write(uint32_t addr, uint8_t val, void *p)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2019-02-06 03:34:39 +01:00
|
|
|
cga_t *cga = (cga_t *) p;
|
|
|
|
|
|
|
|
|
|
cga->vram[addr & 0x3fff] = val;
|
|
|
|
|
if (cga->snow_enabled) {
|
2022-08-31 19:19:29 -04:00
|
|
|
int offset = ((timer_get_remaining_u64(&cga->timer) / CGACONST) * 2) & 0xfc;
|
|
|
|
|
cga->charbuffer[offset] = cga->vram[addr & 0x3fff];
|
|
|
|
|
cga->charbuffer[offset | 1] = cga->vram[addr & 0x3fff];
|
2019-02-06 03:34:39 +01:00
|
|
|
}
|
|
|
|
|
cga_waitstates(cga);
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
uint8_t
|
|
|
|
|
cga_read(uint32_t addr, void *p)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2019-02-06 03:34:39 +01:00
|
|
|
cga_t *cga = (cga_t *) p;
|
|
|
|
|
|
|
|
|
|
cga_waitstates(cga);
|
|
|
|
|
if (cga->snow_enabled) {
|
2022-08-31 19:19:29 -04:00
|
|
|
int offset = ((timer_get_remaining_u64(&cga->timer) / CGACONST) * 2) & 0xfc;
|
|
|
|
|
cga->charbuffer[offset] = cga->vram[addr & 0x3fff];
|
|
|
|
|
cga->charbuffer[offset | 1] = cga->vram[addr & 0x3fff];
|
2019-02-06 03:34:39 +01:00
|
|
|
}
|
|
|
|
|
return cga->vram[addr & 0x3fff];
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
void
|
|
|
|
|
cga_recalctimings(cga_t *cga)
|
|
|
|
|
{
|
|
|
|
|
double disptime;
|
|
|
|
|
double _dispontime, _dispofftime;
|
|
|
|
|
|
|
|
|
|
if (cga->cgamode & 1) {
|
2022-08-31 19:19:29 -04:00
|
|
|
disptime = (double) (cga->crtc[0] + 1);
|
|
|
|
|
_dispontime = (double) cga->crtc[1];
|
2019-02-06 03:34:39 +01:00
|
|
|
} else {
|
2022-08-31 19:19:29 -04:00
|
|
|
disptime = (double) ((cga->crtc[0] + 1) << 1);
|
|
|
|
|
_dispontime = (double) (cga->crtc[1] << 1);
|
2019-02-06 03:34:39 +01:00
|
|
|
}
|
2022-08-31 19:19:29 -04:00
|
|
|
_dispofftime = disptime - _dispontime;
|
|
|
|
|
_dispontime = _dispontime * CGACONST;
|
|
|
|
|
_dispofftime = _dispofftime * CGACONST;
|
|
|
|
|
cga->dispontime = (uint64_t) (_dispontime);
|
|
|
|
|
cga->dispofftime = (uint64_t) (_dispofftime);
|
2019-02-06 03:34:39 +01:00
|
|
|
}
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
void
|
|
|
|
|
cga_poll(void *p)
|
|
|
|
|
{
|
2022-08-31 19:19:29 -04:00
|
|
|
cga_t *cga = (cga_t *) p;
|
|
|
|
|
uint16_t ca = (cga->crtc[15] | (cga->crtc[14] << 8)) & 0x3fff;
|
|
|
|
|
int drawcursor;
|
|
|
|
|
int x, c, xs_temp, ys_temp;
|
|
|
|
|
int oldvc;
|
|
|
|
|
uint8_t chr, attr;
|
|
|
|
|
uint8_t border;
|
2019-02-06 03:34:39 +01:00
|
|
|
uint16_t dat;
|
2022-08-31 19:19:29 -04:00
|
|
|
int cols[4];
|
|
|
|
|
int col;
|
|
|
|
|
int oldsc;
|
2019-02-06 03:34:39 +01:00
|
|
|
|
|
|
|
|
if (!cga->linepos) {
|
2022-08-31 19:19:29 -04:00
|
|
|
timer_advance_u64(&cga->timer, cga->dispofftime);
|
|
|
|
|
cga->cgastat |= 1;
|
|
|
|
|
cga->linepos = 1;
|
|
|
|
|
oldsc = cga->sc;
|
|
|
|
|
if ((cga->crtc[8] & 3) == 3)
|
|
|
|
|
cga->sc = ((cga->sc << 1) + cga->oddeven) & 7;
|
|
|
|
|
if (cga->cgadispon) {
|
|
|
|
|
if (cga->displine < cga->firstline) {
|
|
|
|
|
cga->firstline = cga->displine;
|
|
|
|
|
video_wait_for_buffer();
|
|
|
|
|
}
|
|
|
|
|
cga->lastline = cga->displine;
|
|
|
|
|
for (c = 0; c < 8; c++) {
|
|
|
|
|
if ((cga->cgamode & 0x12) == 0x12) {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][c] = buffer32->line[(cga->displine << 1) + 1][c] = 0;
|
|
|
|
|
if (cga->cgamode & 1) {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][c + (cga->crtc[1] << 3) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 3) + 8] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][c + (cga->crtc[1] << 4) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 4) + 8] = 0;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][c] = buffer32->line[(cga->displine << 1) + 1][c] = (cga->cgacol & 15) + 16;
|
|
|
|
|
if (cga->cgamode & 1) {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][c + (cga->crtc[1] << 3) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 3) + 8] = (cga->cgacol & 15) + 16;
|
|
|
|
|
} else {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][c + (cga->crtc[1] << 4) + 8] = buffer32->line[(cga->displine << 1) + 1][c + (cga->crtc[1] << 4) + 8] = (cga->cgacol & 15) + 16;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (cga->cgamode & 1) {
|
|
|
|
|
for (x = 0; x < cga->crtc[1]; x++) {
|
|
|
|
|
if (cga->cgamode & 8) {
|
|
|
|
|
chr = cga->charbuffer[x << 1];
|
|
|
|
|
attr = cga->charbuffer[(x << 1) + 1];
|
|
|
|
|
} else
|
|
|
|
|
chr = attr = 0;
|
|
|
|
|
drawcursor = ((cga->ma == ca) && cga->con && cga->cursoron);
|
|
|
|
|
cols[1] = (attr & 15) + 16;
|
|
|
|
|
if (cga->cgamode & 0x20) {
|
|
|
|
|
cols[0] = ((attr >> 4) & 7) + 16;
|
|
|
|
|
if ((cga->cgablink & 8) && (attr & 0x80) && !cga->drawcursor)
|
|
|
|
|
cols[1] = cols[0];
|
|
|
|
|
} else
|
|
|
|
|
cols[0] = (attr >> 4) + 16;
|
|
|
|
|
if (drawcursor) {
|
|
|
|
|
for (c = 0; c < 8; c++) {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][(x << 3) + c + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 3) + c + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (c = 0; c < 8; c++) {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][(x << 3) + c + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 3) + c + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cga->ma++;
|
|
|
|
|
}
|
|
|
|
|
} else if (!(cga->cgamode & 2)) {
|
|
|
|
|
for (x = 0; x < cga->crtc[1]; x++) {
|
|
|
|
|
if (cga->cgamode & 8) {
|
|
|
|
|
chr = cga->vram[((cga->ma << 1) & 0x3fff)];
|
|
|
|
|
attr = cga->vram[(((cga->ma << 1) + 1) & 0x3fff)];
|
|
|
|
|
} else
|
|
|
|
|
chr = attr = 0;
|
|
|
|
|
drawcursor = ((cga->ma == ca) && cga->con && cga->cursoron);
|
|
|
|
|
cols[1] = (attr & 15) + 16;
|
|
|
|
|
if (cga->cgamode & 0x20) {
|
|
|
|
|
cols[0] = ((attr >> 4) & 7) + 16;
|
|
|
|
|
if ((cga->cgablink & 8) && (attr & 0x80))
|
|
|
|
|
cols[1] = cols[0];
|
|
|
|
|
} else
|
|
|
|
|
cols[0] = (attr >> 4) + 16;
|
|
|
|
|
cga->ma++;
|
|
|
|
|
if (drawcursor) {
|
|
|
|
|
for (c = 0; c < 8; c++) {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (c = 0; c < 8; c++) {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr + cga->fontbase][cga->sc & 7] & (1 << (c ^ 7))) ? 1 : 0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (!(cga->cgamode & 16)) {
|
|
|
|
|
cols[0] = (cga->cgacol & 15) | 16;
|
|
|
|
|
col = (cga->cgacol & 16) ? 24 : 16;
|
|
|
|
|
if (cga->cgamode & 4) {
|
|
|
|
|
cols[1] = col | 3; /* Cyan */
|
|
|
|
|
cols[2] = col | 4; /* Red */
|
|
|
|
|
cols[3] = col | 7; /* White */
|
|
|
|
|
} else if (cga->cgacol & 32) {
|
|
|
|
|
cols[1] = col | 3; /* Cyan */
|
|
|
|
|
cols[2] = col | 5; /* Magenta */
|
|
|
|
|
cols[3] = col | 7; /* White */
|
|
|
|
|
} else {
|
|
|
|
|
cols[1] = col | 2; /* Green */
|
|
|
|
|
cols[2] = col | 4; /* Red */
|
|
|
|
|
cols[3] = col | 6; /* Yellow */
|
|
|
|
|
}
|
|
|
|
|
for (x = 0; x < cga->crtc[1]; x++) {
|
|
|
|
|
if (cga->cgamode & 8)
|
|
|
|
|
dat = (cga->vram[((cga->ma << 1) & 0x1fff) + ((cga->sc & 1) * 0x2000)] << 8) | cga->vram[((cga->ma << 1) & 0x1fff) + ((cga->sc & 1) * 0x2000) + 1];
|
|
|
|
|
else
|
|
|
|
|
dat = 0;
|
|
|
|
|
cga->ma++;
|
|
|
|
|
for (c = 0; c < 8; c++) {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14];
|
|
|
|
|
dat <<= 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
cols[0] = 0;
|
|
|
|
|
cols[1] = (cga->cgacol & 15) + 16;
|
|
|
|
|
for (x = 0; x < cga->crtc[1]; x++) {
|
|
|
|
|
if (cga->cgamode & 8)
|
|
|
|
|
dat = (cga->vram[((cga->ma << 1) & 0x1fff) + ((cga->sc & 1) * 0x2000)] << 8) | cga->vram[((cga->ma << 1) & 0x1fff) + ((cga->sc & 1) * 0x2000) + 1];
|
|
|
|
|
else
|
|
|
|
|
dat = 0;
|
|
|
|
|
cga->ma++;
|
|
|
|
|
for (c = 0; c < 16; c++) {
|
|
|
|
|
buffer32->line[(cga->displine << 1)][(x << 4) + c + 8] = buffer32->line[(cga->displine << 1) + 1][(x << 4) + c + 8] = cols[dat >> 15];
|
|
|
|
|
dat <<= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
cols[0] = ((cga->cgamode & 0x12) == 0x12) ? 0 : (cga->cgacol & 15) + 16;
|
|
|
|
|
if (cga->cgamode & 1) {
|
|
|
|
|
hline(buffer32, 0, (cga->displine << 1), ((cga->crtc[1] << 3) + 16) << 2, cols[0]);
|
|
|
|
|
hline(buffer32, 0, (cga->displine << 1) + 1, ((cga->crtc[1] << 3) + 16) << 2, cols[0]);
|
|
|
|
|
} else {
|
|
|
|
|
hline(buffer32, 0, (cga->displine << 1), ((cga->crtc[1] << 4) + 16) << 2, cols[0]);
|
|
|
|
|
hline(buffer32, 0, (cga->displine << 1) + 1, ((cga->crtc[1] << 4) + 16) << 2, cols[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cga->cgamode & 1)
|
|
|
|
|
x = (cga->crtc[1] << 3) + 16;
|
|
|
|
|
else
|
|
|
|
|
x = (cga->crtc[1] << 4) + 16;
|
|
|
|
|
|
|
|
|
|
if (cga->composite) {
|
|
|
|
|
if (cga->cgamode & 0x10)
|
|
|
|
|
border = 0x00;
|
|
|
|
|
else
|
|
|
|
|
border = cga->cgacol & 0x0f;
|
|
|
|
|
|
|
|
|
|
Composite_Process(cga->cgamode, border, x >> 2, buffer32->line[(cga->displine << 1)]);
|
|
|
|
|
Composite_Process(cga->cgamode, border, x >> 2, buffer32->line[(cga->displine << 1) + 1]);
|
2022-10-30 16:49:38 +01:00
|
|
|
} else {
|
|
|
|
|
video_process_8(x, cga->displine << 1);
|
|
|
|
|
video_process_8(x, (cga->displine << 1) + 1);
|
2022-08-31 19:19:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cga->sc = oldsc;
|
|
|
|
|
if (cga->vc == cga->crtc[7] && !cga->sc)
|
|
|
|
|
cga->cgastat |= 8;
|
|
|
|
|
cga->displine++;
|
|
|
|
|
if (cga->displine >= 360)
|
|
|
|
|
cga->displine = 0;
|
2019-02-06 03:34:39 +01:00
|
|
|
} else {
|
2022-08-31 19:19:29 -04:00
|
|
|
timer_advance_u64(&cga->timer, cga->dispontime);
|
|
|
|
|
cga->linepos = 0;
|
|
|
|
|
if (cga->vsynctime) {
|
|
|
|
|
cga->vsynctime--;
|
|
|
|
|
if (!cga->vsynctime)
|
|
|
|
|
cga->cgastat &= ~8;
|
|
|
|
|
}
|
|
|
|
|
if (cga->sc == (cga->crtc[11] & 31) || ((cga->crtc[8] & 3) == 3 && cga->sc == ((cga->crtc[11] & 31) >> 1))) {
|
|
|
|
|
cga->con = 0;
|
|
|
|
|
cga->coff = 1;
|
|
|
|
|
}
|
|
|
|
|
if ((cga->crtc[8] & 3) == 3 && cga->sc == (cga->crtc[9] >> 1))
|
|
|
|
|
cga->maback = cga->ma;
|
|
|
|
|
if (cga->vadj) {
|
|
|
|
|
cga->sc++;
|
|
|
|
|
cga->sc &= 31;
|
|
|
|
|
cga->ma = cga->maback;
|
|
|
|
|
cga->vadj--;
|
|
|
|
|
if (!cga->vadj) {
|
|
|
|
|
cga->cgadispon = 1;
|
|
|
|
|
cga->ma = cga->maback = (cga->crtc[13] | (cga->crtc[12] << 8)) & 0x3fff;
|
|
|
|
|
cga->sc = 0;
|
|
|
|
|
}
|
|
|
|
|
} else if (cga->sc == cga->crtc[9]) {
|
|
|
|
|
cga->maback = cga->ma;
|
|
|
|
|
cga->sc = 0;
|
|
|
|
|
oldvc = cga->vc;
|
|
|
|
|
cga->vc++;
|
|
|
|
|
cga->vc &= 127;
|
|
|
|
|
|
|
|
|
|
if (cga->vc == cga->crtc[6])
|
|
|
|
|
cga->cgadispon = 0;
|
|
|
|
|
|
|
|
|
|
if (oldvc == cga->crtc[4]) {
|
|
|
|
|
cga->vc = 0;
|
|
|
|
|
cga->vadj = cga->crtc[5];
|
|
|
|
|
if (!cga->vadj) {
|
|
|
|
|
cga->cgadispon = 1;
|
|
|
|
|
cga->ma = cga->maback = (cga->crtc[13] | (cga->crtc[12] << 8)) & 0x3fff;
|
|
|
|
|
}
|
|
|
|
|
switch (cga->crtc[10] & 0x60) {
|
|
|
|
|
case 0x20:
|
|
|
|
|
cga->cursoron = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 0x60:
|
|
|
|
|
cga->cursoron = cga->cgablink & 0x10;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
cga->cursoron = cga->cgablink & 0x08;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cga->vc == cga->crtc[7]) {
|
|
|
|
|
cga->cgadispon = 0;
|
|
|
|
|
cga->displine = 0;
|
|
|
|
|
cga->vsynctime = 16;
|
|
|
|
|
if (cga->crtc[7]) {
|
|
|
|
|
if (cga->cgamode & 1)
|
|
|
|
|
x = (cga->crtc[1] << 3) + 16;
|
|
|
|
|
else
|
|
|
|
|
x = (cga->crtc[1] << 4) + 16;
|
|
|
|
|
cga->lastline++;
|
|
|
|
|
|
|
|
|
|
xs_temp = x;
|
|
|
|
|
ys_temp = (cga->lastline - cga->firstline) << 1;
|
|
|
|
|
|
|
|
|
|
if ((xs_temp > 0) && (ys_temp > 0)) {
|
|
|
|
|
if (xs_temp < 64)
|
|
|
|
|
xs_temp = 656;
|
|
|
|
|
if (ys_temp < 32)
|
|
|
|
|
ys_temp = 400;
|
|
|
|
|
if (!enable_overscan)
|
|
|
|
|
xs_temp -= 16;
|
|
|
|
|
|
|
|
|
|
if ((cga->cgamode & 8) && ((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));
|
|
|
|
|
|
|
|
|
|
if (video_force_resize_get())
|
|
|
|
|
video_force_resize_set(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enable_overscan) {
|
2022-10-30 16:49:38 +01:00
|
|
|
video_blit_memtoscreen(0, (cga->firstline - 4) << 1,
|
|
|
|
|
xsize, ((cga->lastline - cga->firstline) + 8) << 1);
|
2022-08-31 19:19:29 -04:00
|
|
|
} else {
|
2022-10-30 16:49:38 +01:00
|
|
|
video_blit_memtoscreen(8, cga->firstline << 1,
|
|
|
|
|
xsize, (cga->lastline - cga->firstline) << 1);
|
2022-08-31 19:19:29 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frames++;
|
|
|
|
|
|
|
|
|
|
video_res_x = xsize;
|
|
|
|
|
video_res_y = ysize;
|
|
|
|
|
if (cga->cgamode & 1) {
|
|
|
|
|
video_res_x /= 8;
|
|
|
|
|
video_res_y /= cga->crtc[9] + 1;
|
|
|
|
|
video_bpp = 0;
|
|
|
|
|
} else if (!(cga->cgamode & 2)) {
|
|
|
|
|
video_res_x /= 16;
|
|
|
|
|
video_res_y /= cga->crtc[9] + 1;
|
|
|
|
|
video_bpp = 0;
|
|
|
|
|
} else if (!(cga->cgamode & 16)) {
|
|
|
|
|
video_res_x /= 2;
|
|
|
|
|
video_bpp = 2;
|
|
|
|
|
} else
|
|
|
|
|
video_bpp = 1;
|
|
|
|
|
}
|
|
|
|
|
cga->firstline = 1000;
|
|
|
|
|
cga->lastline = 0;
|
|
|
|
|
cga->cgablink++;
|
|
|
|
|
cga->oddeven ^= 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
cga->sc++;
|
|
|
|
|
cga->sc &= 31;
|
|
|
|
|
cga->ma = cga->maback;
|
|
|
|
|
}
|
|
|
|
|
if (cga->cgadispon)
|
|
|
|
|
cga->cgastat &= ~1;
|
|
|
|
|
if ((cga->sc == (cga->crtc[10] & 31) || ((cga->crtc[8] & 3) == 3 && cga->sc == ((cga->crtc[10] & 31) >> 1))))
|
|
|
|
|
cga->con = 1;
|
|
|
|
|
if (cga->cgadispon && (cga->cgamode & 1)) {
|
|
|
|
|
for (x = 0; x < (cga->crtc[1] << 1); x++)
|
|
|
|
|
cga->charbuffer[x] = cga->vram[(((cga->ma << 1) + x) & 0x3fff)];
|
|
|
|
|
}
|
2019-02-06 03:34:39 +01:00
|
|
|
}
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
void
|
|
|
|
|
cga_init(cga_t *cga)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
|
|
|
timer_add(&cga->timer, cga_poll, cga, 1);
|
2019-02-06 03:34:39 +01:00
|
|
|
cga->composite = 0;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
void *
|
|
|
|
|
cga_standalone_init(const device_t *info)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2022-08-31 19:19:29 -04:00
|
|
|
int display_type;
|
2019-02-06 03:34:39 +01:00
|
|
|
cga_t *cga = malloc(sizeof(cga_t));
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
memset(cga, 0, sizeof(cga_t));
|
|
|
|
|
video_inform(VIDEO_FLAG_TYPE_CGA, &timing_cga);
|
2016-07-09 02:18:45 +02:00
|
|
|
|
2022-08-31 19:19:29 -04:00
|
|
|
display_type = device_get_config_int("display_type");
|
|
|
|
|
cga->composite = (display_type != CGA_RGB);
|
|
|
|
|
cga->revision = device_get_config_int("composite_type");
|
2019-02-06 03:34:39 +01:00
|
|
|
cga->snow_enabled = device_get_config_int("snow_enabled");
|
2017-10-14 13:38:05 -04:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
cga->vram = malloc(0x4000);
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
cga_comp_init(cga->revision);
|
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
|
|
|
timer_add(&cga->timer, cga_poll, cga, 1);
|
2019-02-06 03:34:39 +01:00
|
|
|
mem_mapping_add(&cga->mapping, 0xb8000, 0x08000, cga_read, NULL, NULL, cga_write, NULL, NULL, NULL /*cga->vram*/, MEM_MAPPING_EXTERNAL, cga);
|
|
|
|
|
io_sethandler(0x03d0, 0x0010, cga_in, NULL, NULL, cga_out, NULL, NULL, cga);
|
2017-02-19 16:36:43 +01:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
overscan_x = overscan_y = 16;
|
2017-10-14 13:38:05 -04:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
cga->rgb_type = device_get_config_int("rgb_type");
|
2022-08-31 19:19:29 -04:00
|
|
|
cga_palette = (cga->rgb_type << 1);
|
2019-02-06 03:34:39 +01:00
|
|
|
cgapal_rebuild();
|
|
|
|
|
|
|
|
|
|
return cga;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2022-10-20 00:33:30 +02:00
|
|
|
void *
|
|
|
|
|
cga_pravetz_init(const device_t *info)
|
|
|
|
|
{
|
|
|
|
|
cga_t *cga = cga_standalone_init(info);
|
|
|
|
|
|
2022-11-05 00:53:50 +01:00
|
|
|
loadfont("roms/video/cga/PRAVETZ-VDC2.BIN", 10);
|
2022-10-20 00:33:30 +02:00
|
|
|
|
|
|
|
|
io_removehandler(0x03dd, 0x0001, cga_in, NULL, NULL, cga_out, NULL, NULL, cga);
|
|
|
|
|
io_sethandler(0x03dd, 0x0001, cga_pravetz_in, NULL, NULL, cga_pravetz_out, NULL, NULL, cga);
|
|
|
|
|
|
|
|
|
|
cga->fontbase = 0x0300;
|
|
|
|
|
|
|
|
|
|
return cga;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
void
|
|
|
|
|
cga_close(void *p)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2019-02-06 03:34:39 +01:00
|
|
|
cga_t *cga = (cga_t *) p;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
free(cga->vram);
|
|
|
|
|
free(cga);
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
void
|
|
|
|
|
cga_speed_changed(void *p)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2019-02-06 03:34:39 +01:00
|
|
|
cga_t *cga = (cga_t *) p;
|
2017-10-14 13:38:05 -04:00
|
|
|
|
2019-02-06 03:34:39 +01:00
|
|
|
cga_recalctimings(cga);
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2022-02-26 23:31:28 -05:00
|
|
|
// clang-format off
|
|
|
|
|
const device_config_t cga_config[] = {
|
|
|
|
|
{
|
2022-04-09 20:09:14 -04:00
|
|
|
.name = "display_type",
|
|
|
|
|
.description = "Display type",
|
|
|
|
|
.type = CONFIG_SELECTION,
|
|
|
|
|
.default_int = CGA_RGB,
|
|
|
|
|
.selection = {
|
|
|
|
|
{
|
|
|
|
|
.description = "RGB",
|
|
|
|
|
.value = CGA_RGB
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.description = "Composite",
|
|
|
|
|
.value = CGA_COMPOSITE
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.description = ""
|
|
|
|
|
}
|
2022-02-26 23:31:28 -05:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2022-04-09 20:09:14 -04:00
|
|
|
.name = "composite_type",
|
|
|
|
|
.description = "Composite type",
|
|
|
|
|
.type = CONFIG_SELECTION,
|
|
|
|
|
.default_int = COMPOSITE_OLD,
|
|
|
|
|
.selection = {
|
|
|
|
|
{
|
|
|
|
|
.description = "Old",
|
|
|
|
|
.value = COMPOSITE_OLD
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.description = "New",
|
|
|
|
|
.value = COMPOSITE_NEW
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.description = ""
|
|
|
|
|
}
|
2022-02-26 23:31:28 -05:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2022-04-09 20:09:14 -04:00
|
|
|
.name = "rgb_type",
|
|
|
|
|
.description = "RGB type",
|
|
|
|
|
.type = CONFIG_SELECTION,
|
|
|
|
|
.default_int = 0,
|
|
|
|
|
.selection = {
|
|
|
|
|
{
|
|
|
|
|
.description = "Color",
|
|
|
|
|
.value = 0
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.description = "Green Monochrome",
|
|
|
|
|
.value = 1
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.description = "Amber Monochrome",
|
|
|
|
|
.value = 2
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.description = "Gray Monochrome",
|
|
|
|
|
.value = 3
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.description = "Color (no brown)",
|
|
|
|
|
.value = 4
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
.description = ""
|
|
|
|
|
}
|
2016-07-09 02:18:45 +02:00
|
|
|
}
|
2022-02-26 23:31:28 -05:00
|
|
|
},
|
|
|
|
|
{
|
2022-04-09 20:09:14 -04:00
|
|
|
.name = "snow_enabled",
|
|
|
|
|
.description = "Snow emulation",
|
|
|
|
|
.type = CONFIG_BINARY,
|
|
|
|
|
.default_int = 1
|
2022-02-26 23:31:28 -05:00
|
|
|
},
|
|
|
|
|
{
|
2022-04-09 20:09:14 -04:00
|
|
|
.type = CONFIG_END
|
2022-02-26 23:31:28 -05:00
|
|
|
}
|
2016-06-26 00:34:39 +02:00
|
|
|
};
|
2022-02-26 23:31:28 -05:00
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
|
|
const device_t cga_device = {
|
2022-08-31 19:19:29 -04:00
|
|
|
.name = "CGA",
|
2022-03-13 21:43:45 -04:00
|
|
|
.internal_name = "cga",
|
2022-08-31 19:19:29 -04:00
|
|
|
.flags = DEVICE_ISA,
|
|
|
|
|
.local = 0,
|
|
|
|
|
.init = cga_standalone_init,
|
|
|
|
|
.close = cga_close,
|
|
|
|
|
.reset = NULL,
|
2022-03-13 21:43:45 -04:00
|
|
|
{ .available = NULL },
|
|
|
|
|
.speed_changed = cga_speed_changed,
|
2022-08-31 19:19:29 -04:00
|
|
|
.force_redraw = NULL,
|
|
|
|
|
.config = cga_config
|
2016-06-26 00:34:39 +02:00
|
|
|
};
|
2022-10-20 00:33:30 +02:00
|
|
|
|
|
|
|
|
const device_t cga_pravetz_device = {
|
|
|
|
|
.name = "Pravetz VDC-2",
|
|
|
|
|
.internal_name = "cga_pravetz",
|
|
|
|
|
.flags = DEVICE_ISA,
|
|
|
|
|
.local = 0,
|
|
|
|
|
.init = cga_pravetz_init,
|
|
|
|
|
.close = cga_close,
|
|
|
|
|
.reset = NULL,
|
|
|
|
|
{ .available = NULL },
|
|
|
|
|
.speed_changed = cga_speed_changed,
|
|
|
|
|
.force_redraw = NULL,
|
|
|
|
|
.config = cga_config
|
|
|
|
|
};
|