Merge remote-tracking branch 'upstream/master' into version/4.1

This commit is contained in:
Jasmine Iwanek
2023-08-14 07:20:29 -04:00
52 changed files with 1565 additions and 508 deletions

View File

@@ -9,5 +9,6 @@ zlib
libpng
rtmidi
libslirp
fluidsynth
qt5-static
qt5-translations

View File

@@ -331,7 +331,7 @@ viso_fill_fn_short(char *data, const viso_entry_t *entry, viso_entry_t **entries
}
/* Check if this filename is unique, and add a tail if required, while also adding the extension. */
char tail[8];
char tail[16];
for (int i = force_tail; i <= 999999; i++) {
/* Add tail to the filename if this is not the first run. */
int tail_len = -1;

View File

@@ -13,13 +13,14 @@
# Copyright 2020-2021 David Hrdlička.
#
add_library(chipset OBJECT 82c100.c acc2168.c cs8230.c ali1429.c ali1435.c ali1489.c ali1531.c ali1541.c ali1543.c
ali1621.c ali6117.c headland.c ims8848.c intel_82335.c contaq_82c59x.c cs4031.c intel_420ex.c
intel_4x0.c intel_i450kx.c intel_sio.c intel_piix.c ../ioapic.c neat.c opti283.c opti291.c opti391.c
opti495.c opti822.c opti895.c opti5x7.c scamp.c scat.c sis_85c310.c sis_85c4xx.c
sis_85c496.c sis_85c50x.c sis_5511.c sis_5571.c via_vt82c49x.c via_vt82c505.c sis_85c310.c
sis_85c4xx.c sis_85c496.c sis_85c50x.c gc100.c stpc.c umc_8886.c umc_hb4.c via_apollo.c
via_pipc.c vl82c480.c wd76c10.c)
add_library(chipset OBJECT 82c100.c acc2168.c cs8230.c ali1429.c ali1435.c ali1489.c
ali1531.c ali1541.c ali1543.c ali1621.c ali6117.c headland.c ims8848.c intel_82335.c
compaq_386.c contaq_82c59x.c cs4031.c intel_420ex.c intel_4x0.c intel_i450kx.c
intel_sio.c intel_piix.c ../ioapic.c neat.c opti283.c opti291.c opti391.c opti495.c
opti822.c opti895.c opti5x7.c scamp.c scat.c sis_85c310.c sis_85c4xx.c sis_85c496.c
sis_85c50x.c sis_5511.c sis_5571.c via_vt82c49x.c via_vt82c505.c sis_85c310.c
sis_85c4xx.c sis_85c496.c sis_85c50x.c gc100.c stpc.c umc_8886.c umc_hb4.c
via_apollo.c via_pipc.c vl82c480.c wd76c10.c)
if(OLIVETTI)
target_sources(chipset PRIVATE olivetti_eva.c)

767
src/chipset/compaq_386.c Normal file
View File

@@ -0,0 +1,767 @@
/*
* 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.
*
* Emulation of the Compaq 386 memory controller.
*
* Authors: Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2023 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include <math.h>
#include <86box/86box.h>
#include "cpu.h"
#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/keyboard.h>
#include <86box/fdd.h>
#include <86box/fdc.h>
#include <86box/fdc_ext.h>
#include <86box/hdc.h>
#include <86box/hdc_ide.h>
#include <86box/machine.h>
#include <86box/video.h>
#include <86box/vid_cga.h>
#include <86box/vid_cga_comp.h>
#include <86box/plat_unused.h>
#define RAM_DIAG_L_BASE_MEM_640KB 0x00
#define RAM_DIAG_L_BASE_MEM_INV 0x10
#define RAM_DIAG_L_BASE_MEM_512KB 0x20
#define RAM_DIAG_L_BASE_MEM_256KB 0x30
#define RAM_DIAG_L_BASE_MEM_MASK 0x30
#define RAM_DIAG_L_PERMA_BITS 0x80
#define RAM_DIAG_H_SYS_RAM_4MB 0x01
#define RAM_DIAG_H_SYS_RAM_1MB 0x02
#define RAM_DIAG_H_SYS_RAM_NONE 0x03
#define RAM_DIAG_H_SYS_RAM_MASK 0x03
#define RAM_DIAG_H_MOD_A_RAM_4MB 0x04
#define RAM_DIAG_H_MOD_A_RAM_1MB 0x08
#define RAM_DIAG_H_MOD_A_RAM_NONE 0x0c
#define RAM_DIAG_H_MOD_A_RAM_MASK 0x0c
#define RAM_DIAG_H_MOD_B_RAM_4MB 0x10
#define RAM_DIAG_H_MOD_B_RAM_1MB 0x20
#define RAM_DIAG_H_MOD_B_RAM_NONE 0x30
#define RAM_DIAG_H_MOD_B_RAM_MASK 0x30
#define RAM_DIAG_H_MOD_C_RAM_4MB 0x40
#define RAM_DIAG_H_MOD_C_RAM_1MB 0x80
#define RAM_DIAG_H_MOD_C_RAM_NONE 0xc0
#define RAM_DIAG_H_MOD_C_RAM_MASK 0xc0
#define MEM_STATE_BUS 0x00
#define MEM_STATE_SYS 0x01
#define MEM_STATE_SYS_RELOC 0x02
#define MEM_STATE_MOD_A 0x04
#define MEM_STATE_MOD_B 0x08
#define MEM_STATE_MOD_C 0x10
#define MEM_STATE_MASK (MEM_STATE_SYS | MEM_STATE_MOD_A | MEM_STATE_MOD_B | MEM_STATE_MOD_C)
#define MEM_STATE_WP 0x20
typedef struct cpq_ram_t {
uint8_t wp;
uint32_t phys_base;
uint32_t virt_base;
mem_mapping_t mapping;
} cpq_ram_t;
typedef struct cpq_386_t {
uint8_t regs[8];
uint8_t old_state[256];
uint8_t mem_state[256];
uint32_t ram_bases[4];
uint32_t ram_sizes[4];
uint32_t ram_map_sizes[4];
cpq_ram_t ram[4][64];
cpq_ram_t high_ram[16];
mem_mapping_t regs_mapping;
} cpq_386_t;
static uint8_t
cpq_read_ram(uint32_t addr, void *priv)
{
cpq_ram_t *dev = (cpq_ram_t *) priv;
uint8_t ret = 0xff;
uint32_t old = addr;
addr = (addr - dev->virt_base) + dev->phys_base;
if (addr < (mem_size << 10))
ret = mem_read_ram(addr, priv);
return ret;
}
static uint16_t
cpq_read_ramw(uint32_t addr, void *priv)
{
cpq_ram_t *dev = (cpq_ram_t *) priv;
uint16_t ret = 0xffff;
uint32_t old = addr;
addr = (addr - dev->virt_base) + dev->phys_base;
if (addr < (mem_size << 10))
ret = mem_read_ramw(addr, priv);
return ret;
}
static uint32_t
cpq_read_raml(uint32_t addr, void *priv)
{
cpq_ram_t *dev = (cpq_ram_t *) priv;
uint32_t ret = 0xffffffff;
uint32_t old = addr;
addr = (addr - dev->virt_base) + dev->phys_base;
if (addr < (mem_size << 10))
ret = mem_read_raml(addr, priv);
return ret;
}
static void
cpq_write_ram(uint32_t addr, uint8_t val, void *priv)
{
cpq_ram_t *dev = (cpq_ram_t *) priv;
uint32_t old = addr;
addr = (addr - dev->virt_base) + dev->phys_base;
if (!dev->wp && (addr < (mem_size << 10)))
mem_write_ram(addr, val, priv);
}
static void
cpq_write_ramw(uint32_t addr, uint16_t val, void *priv)
{
cpq_ram_t *dev = (cpq_ram_t *) priv;
uint32_t old = addr;
addr = (addr - dev->virt_base) + dev->phys_base;
if (!dev->wp && (addr < (mem_size << 10)))
mem_write_ramw(addr, val, priv);
}
static void
cpq_write_raml(uint32_t addr, uint32_t val, void *priv)
{
cpq_ram_t *dev = (cpq_ram_t *) priv;
uint32_t old = addr;
addr = (addr - dev->virt_base) + dev->phys_base;
if (!dev->wp && (addr < (mem_size << 10)))
mem_write_raml(addr, val, priv);
}
static uint8_t
cpq_read_regs(uint32_t addr, void *priv)
{
cpq_386_t *dev = (cpq_386_t *) priv;
uint8_t ret = 0xff;
addr &= 0x00000fff;
switch (addr) {
case 0x00000000:
case 0x00000001:
/* RAM Diagnostics (Read Only) */
case 0x00000002:
case 0x00000003:
/* RAM Setup Port (Read/Write) */
ret = dev->regs[addr];
break;
}
return ret;
}
static uint16_t
cpq_read_regsw(uint32_t addr, void *priv)
{
cpq_386_t *dev = (cpq_386_t *) priv;
uint16_t ret = 0xffff;
ret = cpq_read_regs(addr, priv);
ret |= (((uint16_t) cpq_read_regs(addr + 1, priv)) << 8);
return ret;
}
static uint32_t
cpq_read_regsl(uint32_t addr, void *priv)
{
cpq_386_t *dev = (cpq_386_t *) priv;
uint32_t ret = 0xffffffff;
ret = cpq_read_regsw(addr, priv);
ret |= (((uint32_t) cpq_read_regsw(addr + 2, priv)) << 16);
return ret;
}
static void
cpq_recalc_state(cpq_386_t *dev, uint8_t i)
{
uint32_t addr;
addr = ((uint32_t) i) << 16;
if (dev->mem_state[i] == 0x00)
mem_set_mem_state(addr, 0x00010000, MEM_READ_EXTANY | MEM_WRITE_EXTANY);
else if (dev->mem_state[i] == MEM_STATE_WP)
mem_set_mem_state(addr, 0x00010000, MEM_READ_EXTANY | MEM_WRITE_DISABLED);
else if (dev->mem_state[i] & MEM_STATE_WP)
mem_set_mem_state(addr, 0x00010000, MEM_READ_INTERNAL | MEM_WRITE_DISABLED);
else
mem_set_mem_state(addr, 0x00010000, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL);
dev->old_state[i] = dev->mem_state[i];
}
static void
cpq_recalc_states(cpq_386_t *dev)
{
/* Recalculate the entire 16 MB space. */
for (uint16_t i = 0; i < 256; i++) {
if (dev->mem_state[i] != dev->old_state[i])
cpq_recalc_state(dev, i);
}
flushmmucache_nopc();
}
static void
cpq_recalc_cache(cpq_386_t *dev)
{
cpu_cache_ext_enabled = (dev->regs[0x00000002] & 0x40);
cpu_update_waitstates();
}
static void
cpq_recalc_ram(cpq_386_t *dev)
{
uint8_t sys_ram = (dev->regs[0x00000001] & RAM_DIAG_H_SYS_RAM_MASK) & 0x01;
uint8_t setup_port = dev->regs[0x00000002] & 0x0f;
uint8_t sys_min_high = sys_ram ? 0xfa : 0xf4;
uint8_t ram_states[4] = { MEM_STATE_SYS, MEM_STATE_MOD_A,
MEM_STATE_MOD_B, MEM_STATE_MOD_C };
uint8_t ram_bases[4][2][16] = { { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 } },
{ { 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00 },
{ 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 } },
{ { 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, 0x20, 0x20,
0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00 },
{ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50,
0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 } },
{ { 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x60,
0x00, 0x00, 0x90, 0x90, 0x90, 0x90, 0x00, 0x00 },
{ 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
0x00, 0x00, 0x90, 0x00, 0x00, 0xc0, 0xc0, 0xc0 } } };
uint8_t ram_sizes[4][2][16] = { { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x30, 0x00, 0x10, 0x20, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30 } },
{ { 0x00, 0x00, 0x10, 0x10, 0x10, 0x40, 0x10, 0x10,
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00 },
{ 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10,
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 } },
{ { 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x40,
0x30, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00 },
{ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,
0x00, 0x10, 0x10, 0x30, 0x40, 0x40, 0x40, 0x40 } },
{ { 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10,
0x00, 0x00, 0x10, 0x20, 0x30, 0x40, 0x00, 0x00 },
{ 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x20, 0x30 } } };
uint8_t size;
uint8_t start;
uint8_t end;
uint8_t k;
uint32_t virt_base;
uint32_t virt_addr;
uint32_t phys_addr;
cpq_ram_t *cram;
for (uint16_t i = 0x10; i < sys_min_high; i++)
dev->mem_state[i] &= ~MEM_STATE_MASK;
for (uint8_t i = 0; i < 4; i++) {
for (uint8_t j = 0; j <= 64; j++) {
if ((i >= 1) || (j >= 0x10))
mem_mapping_disable(&dev->ram[i][j].mapping);
}
}
for (uint8_t i = 0; i < 4; i++) {
size = ram_sizes[i][sys_ram][setup_port];
if (size > 0x00) {
start = ram_bases[i][sys_ram][setup_port];
end = start + (size - 1);
virt_base = ((uint32_t) start) << 16;
for (uint16_t j = start; j <= end; j++) {
k = j - start;
if (i == 0)
k += 0x10;
cram = &(dev->ram[i][k]);
dev->mem_state[j] |= ram_states[i];
cram->virt_base = ((uint32_t) j) << 16;
cram->phys_base = cram->virt_base - virt_base + dev->ram_bases[i];
mem_mapping_set_addr(&cram->mapping, cram->virt_base, 0x00010000);
mem_mapping_set_exec(&cram->mapping, &(ram[cram->phys_base]));
}
}
}
/* Recalculate the entire 16 MB space. */
cpq_recalc_states(dev);
}
static void
cpq_write_regs(uint32_t addr, uint8_t val, void *priv)
{
cpq_386_t *dev = (cpq_386_t *) priv;
addr &= 0x00000fff;
switch (addr) {
case 0x00000000:
case 0x00000001:
/* RAM Relocation (Write Only) */
dev->regs[addr + 4] = val;
if (addr == 0x00000000) {
dev->mem_state[0x0e] &= ~(MEM_STATE_SYS | MEM_STATE_WP);
dev->mem_state[0x0f] &= ~(MEM_STATE_SYS | MEM_STATE_WP);
dev->mem_state[0xfe] &= ~MEM_STATE_WP;
dev->mem_state[0xff] &= ~MEM_STATE_WP;
if (!(val & 0x01)) {
dev->mem_state[0x0e] |= MEM_STATE_SYS;
dev->mem_state[0x0f] |= MEM_STATE_SYS;
}
if (!(val & 0x02)) {
dev->mem_state[0x0e] |= MEM_STATE_WP;
dev->mem_state[0x0f] |= MEM_STATE_WP;
dev->mem_state[0xfe] |= MEM_STATE_WP;
dev->mem_state[0xff] |= MEM_STATE_WP;
}
cpq_recalc_state(dev, 0x0e);
cpq_recalc_state(dev, 0x0f);
cpq_recalc_state(dev, 0xfe);
cpq_recalc_state(dev, 0xff);
flushmmucache_nopc();
}
break;
case 0x00000002:
case 0x00000003:
/* RAM Setup Port (Read/Write) */
dev->regs[addr] = val;
if (addr == 0x00000002) {
cpq_recalc_ram(dev);
cpq_recalc_cache(dev);
}
break;
}
}
static void
cpq_write_regsw(uint32_t addr, uint16_t val, void *priv)
{
cpq_386_t *dev = (cpq_386_t *) priv;
cpq_write_regs(addr, val & 0xff, priv);
cpq_write_regs(addr + 1, (val >> 8) & 0xff, priv);
}
static void
cpq_write_regsl(uint32_t addr, uint32_t val, void *priv)
{
cpq_386_t *dev = (cpq_386_t *) priv;
cpq_write_regsw(addr, val & 0xff, priv);
cpq_write_regsw(addr + 2, (val >> 16) & 0xff, priv);
}
static void
compaq_ram_init(cpq_ram_t *dev)
{
mem_mapping_add(&dev->mapping,
0x00000000,
0x00010000,
cpq_read_ram,
cpq_read_ramw,
cpq_read_raml,
cpq_write_ram,
cpq_write_ramw,
cpq_write_raml,
NULL,
MEM_MAPPING_INTERNAL,
dev);
mem_mapping_disable(&dev->mapping);
}
static void
compaq_ram_diags_parse(cpq_386_t *dev)
{
uint8_t val = dev->regs[0x00000001];
uint32_t accum = 0x00100000;
val;
for (uint8_t i = 0; i < 4; i++) {
dev->ram_bases[i] = accum;
switch (val & 0x03) {
case RAM_DIAG_H_SYS_RAM_1MB:
dev->ram_sizes[i] = 0x00100000;
break;
case RAM_DIAG_H_SYS_RAM_4MB:
dev->ram_sizes[i] = 0x00400000;
break;
}
if (i == 0)
dev->ram_sizes[i] -= 0x00100000;
dev->ram_map_sizes[i] = dev->ram_sizes[i];
accum += dev->ram_sizes[i];
if (accum >= (mem_size << 10)) {
dev->ram_sizes[i] = (mem_size << 10) - dev->ram_bases[i];
break;
}
val >>= 2;
}
}
static void
compaq_recalc_base_ram(cpq_386_t *dev)
{
uint8_t base_mem = dev->regs[0x00000000] & RAM_DIAG_L_BASE_MEM_MASK;
uint8_t sys_ram = dev->regs[0x00000001] & RAM_DIAG_H_SYS_RAM_MASK;
uint8_t low_start = 0x00;
uint8_t low_end = 0x00;
uint8_t high_start = 0x00;
uint8_t high_end = 0x00;
uint32_t phys_addr = 0x00000000;
uint32_t virt_addr = 0x00000000;
cpq_ram_t *cram;
switch (base_mem) {
case RAM_DIAG_L_BASE_MEM_256KB:
switch (sys_ram) {
case RAM_DIAG_H_SYS_RAM_1MB:
low_start = 0x00;
low_end = 0x03;
high_start = 0xf4;
high_end = 0xff;
break;
case RAM_DIAG_H_SYS_RAM_4MB:
low_start = 0x00;
low_end = 0x03;
high_start = 0xfa;
high_end = 0xff;
break;
default:
fatal("Compaq 386 - Invalid configuation: %02X %02X\n", base_mem, sys_ram);
return;
}
break;
case RAM_DIAG_L_BASE_MEM_512KB:
switch (sys_ram) {
case RAM_DIAG_H_SYS_RAM_1MB:
low_start = 0x00;
low_end = 0x07;
high_start = 0xf8;
high_end = 0xff;
break;
case RAM_DIAG_H_SYS_RAM_4MB:
low_start = 0x00;
low_end = 0x07;
high_start = 0xfa;
high_end = 0xff;
break;
default:
fatal("Compaq 386 - Invalid configuation: %02X %02X\n", base_mem, sys_ram);
return;
}
break;
case RAM_DIAG_L_BASE_MEM_640KB:
switch (sys_ram) {
case RAM_DIAG_H_SYS_RAM_1MB:
low_start = 0x00;
low_end = 0x09;
high_start = 0xfa;
high_end = 0xff;
break;
case RAM_DIAG_H_SYS_RAM_4MB:
low_start = 0x00;
low_end = 0x09;
high_start = 0xfa;
high_end = 0xff;
break;
default:
fatal("Compaq 386 - Invalid configuation: %02X %02X\n", base_mem, sys_ram);
return;
}
break;
default:
fatal("Compaq 386 - Invalid configuation: %02X %02X\n", base_mem, sys_ram);
return;
}
switch (sys_ram) {
case RAM_DIAG_H_SYS_RAM_1MB:
if (mem_size < 1024)
dev->regs[0x00000002] = 0x01;
else if (mem_size == 8192)
dev->regs[0x00000002] = 0x09;
else if (mem_size >= 11264)
dev->regs[0x00000002] = 0x0d;
else
dev->regs[0x00000002] = (mem_size >> 10);
break;
case RAM_DIAG_H_SYS_RAM_4MB:
if (mem_size < 4096)
dev->regs[0x00000002] = 0x04;
else if (mem_size == 11264)
dev->regs[0x00000002] = 0x0c;
else if (mem_size >= 16384)
dev->regs[0x00000002] = 0x00;
else if (mem_size > 13312)
dev->regs[0x00000002] = 0x0d;
else
dev->regs[0x00000002] = (mem_size >> 10);
break;
default:
fatal("Compaq 386 - Invalid configuation: %02X\n", sys_ram);
return;
}
/* The base 640 kB. */
for (uint8_t i = low_start; i <= low_end; i++) {
cram = &(dev->ram[0][i]);
cram->phys_base = cram->virt_base = ((uint32_t) i) << 16;
dev->mem_state[i] |= MEM_STATE_SYS;
mem_mapping_set_addr(&cram->mapping, cram->virt_base, 0x00010000);
mem_mapping_set_exec(&cram->mapping, &(ram[cram->phys_base]));
cpq_recalc_state(dev, i);
}
/* The relocated 128 kB. */
for (uint8_t i = 0x0e; i <= 0x0f; i++) {
cram = &(dev->ram[0][i]);
cram->phys_base = cram->virt_base = ((uint32_t) i) << 16;
mem_mapping_set_addr(&cram->mapping, cram->virt_base, 0x00010000);
mem_mapping_set_exec(&cram->mapping, &(ram[cram->phys_base]));
}
/* Blocks FA-FF. */
for (uint16_t i = high_start; i <= high_end; i++) {
cram = &(dev->high_ram[i & 0x0f]);
cram->phys_base = ((uint32_t) (i & 0x0f)) << 16;
cram->virt_base = ((uint32_t) i) << 16;
dev->mem_state[i] |= MEM_STATE_SYS;
mem_mapping_set_addr(&cram->mapping, cram->virt_base, 0x00010000);
mem_mapping_set_exec(&cram->mapping, &(ram[cram->phys_base]));
cpq_recalc_state(dev, i);
}
}
static void
compaq_386_close(void *priv)
{
cpq_386_t *dev = (cpq_386_t *) priv;
free(dev);
}
static void *
compaq_386_init(const device_t *info)
{
cpq_386_t *dev = (cpq_386_t *) calloc(1, sizeof(cpq_386_t));
mem_mapping_add(&dev->regs_mapping,
0x80c00000,
0x00001000,
cpq_read_regs,
cpq_read_regsw,
cpq_read_regsl,
cpq_write_regs,
cpq_write_regsw,
cpq_write_regsl,
NULL,
MEM_MAPPING_INTERNAL,
dev);
mem_set_mem_state(0x80c00000, 0x00001000, MEM_READ_INTERNAL | MEM_WRITE_INTERNAL);
dev->regs[0x00000000] = RAM_DIAG_L_PERMA_BITS;
if (mem_size >= 640)
dev->regs[0x00000000] |= RAM_DIAG_L_BASE_MEM_640KB;
else if (mem_size >= 512)
dev->regs[0x00000000] |= RAM_DIAG_L_BASE_MEM_512KB;
else if (mem_size >= 256)
dev->regs[0x00000000] |= RAM_DIAG_L_BASE_MEM_256KB;
else
dev->regs[0x00000000] |= RAM_DIAG_L_BASE_MEM_INV;
/* Indicate no parity error. */
dev->regs[0x00000000] |= 0x0f;
if (mem_size >= 1024) {
switch (mem_size) {
case 1024:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_NONE |
RAM_DIAG_H_MOD_B_RAM_NONE | RAM_DIAG_H_MOD_C_RAM_NONE;
break;
case 2048:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_NONE |
RAM_DIAG_H_MOD_B_RAM_NONE | RAM_DIAG_H_MOD_C_RAM_NONE;
break;
case 3072:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_NONE |
RAM_DIAG_H_MOD_B_RAM_NONE | RAM_DIAG_H_MOD_C_RAM_NONE;
break;
case 4096:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_NONE |
RAM_DIAG_H_MOD_B_RAM_NONE | RAM_DIAG_H_MOD_C_RAM_NONE;
break;
case 5120:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_1MB |
RAM_DIAG_H_MOD_B_RAM_NONE | RAM_DIAG_H_MOD_C_RAM_NONE;
break;
case 6144:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_1MB |
RAM_DIAG_H_MOD_B_RAM_1MB | RAM_DIAG_H_MOD_C_RAM_NONE;
break;
case 7168:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_1MB |
RAM_DIAG_H_MOD_B_RAM_1MB | RAM_DIAG_H_MOD_C_RAM_1MB;
break;
case 8192:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_4MB |
RAM_DIAG_H_MOD_B_RAM_NONE | RAM_DIAG_H_MOD_C_RAM_NONE;
break;
case 9216:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_4MB |
RAM_DIAG_H_MOD_B_RAM_1MB | RAM_DIAG_H_MOD_C_RAM_NONE;
break;
case 10240:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_4MB |
RAM_DIAG_H_MOD_B_RAM_1MB | RAM_DIAG_H_MOD_C_RAM_1MB;
break;
case 11264:
case 12288:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_4MB |
RAM_DIAG_H_MOD_B_RAM_4MB | RAM_DIAG_H_MOD_C_RAM_NONE;
break;
case 13312:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_4MB |
RAM_DIAG_H_MOD_B_RAM_4MB | RAM_DIAG_H_MOD_C_RAM_1MB;
break;
case 14336:
case 15360:
case 16384:
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_4MB | RAM_DIAG_H_MOD_A_RAM_4MB |
RAM_DIAG_H_MOD_B_RAM_4MB | RAM_DIAG_H_MOD_C_RAM_4MB;
break;
}
} else
dev->regs[0x00000001] = RAM_DIAG_H_SYS_RAM_1MB | RAM_DIAG_H_MOD_A_RAM_NONE |
RAM_DIAG_H_MOD_B_RAM_NONE | RAM_DIAG_H_MOD_C_RAM_NONE;
dev->regs[0x00000003] = 0xfc;
dev->regs[0x00000004] = dev->regs[0x00000005] = 0xff;
compaq_ram_diags_parse(dev);
mem_mapping_disable(&ram_low_mapping);
mem_mapping_disable(&ram_mid_mapping);
mem_mapping_disable(&ram_high_mapping);
#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64))
/* Should never be the case, but you never know what a user may set. */
if (mem_size > 1048576)
mem_mapping_disable(&ram_2gb_mapping);
#endif
/* Initialize in reverse order for memory mapping precedence
reasons. */
for (int8_t i = 3; i >= 0; i--) {
for (uint8_t j = 0; j < 64; j++)
compaq_ram_init(&(dev->ram[i][j]));
}
for (uint8_t i = 0; i < 16; i++)
compaq_ram_init(&(dev->high_ram[i]));
/* First, set the entire 256 MB of space to invalid states. */
for (uint16_t i = 0; i < 256; i++)
dev->old_state[i] = 0xff;
/* Then, recalculate the base RAM mappings. */
compaq_recalc_base_ram(dev);
/* Enable the external cache. */
dev->regs[0x00000002] |= 0x40;
cpq_recalc_cache(dev);
/* Recalculate the rest of the RAM mapping. */
cpq_recalc_ram(dev);
return dev;
}
const device_t compaq_386_device = {
.name = "Compaq 386 Memory Control",
.internal_name = "opti391",
.flags = 0,
.local = 0,
.init = compaq_386_init,
.close = compaq_386_close,
.reset = NULL,
{ .available = NULL },
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};

View File

@@ -341,7 +341,7 @@ host_arm64_ADDX_IMM(codeblock_t *block, int dst_reg, int src_n_reg, uint64_t imm
} else if (imm_data & 0xfff000)
codegen_addlong(block, OPCODE_ADDX_IMM | Rd(dst_reg) | Rn(src_n_reg) | IMM12((imm_data >> 12) & 0xfff) | DATPROC_IMM_SHIFT(1));
} else
fatal("ADD_IMM_X %016llx\n", imm_data);
fatal("ADD_IMM_X %016" PRIu64 "\n", imm_data);
}
void
host_arm64_ADD_REG(codeblock_t *block, int dst_reg, int src_n_reg, int src_m_reg, int shift)
@@ -684,7 +684,7 @@ host_arm64_CMPX_IMM(codeblock_t *block, int src_n_reg, uint64_t imm_data)
} else if (!(imm_data & 0xfffffffffffff000ull)) {
codegen_addlong(block, OPCODE_CMPX_IMM | Rd(REG_XZR) | Rn(src_n_reg) | IMM12(imm_data & 0xfff) | DATPROC_IMM_SHIFT(0));
} else
fatal("CMPX_IMM %08llx\n", imm_data);
fatal("CMPX_IMM %08" PRIu64 "\n", imm_data);
}
void

View File

@@ -462,6 +462,9 @@ cycles_biu(int bus, int init)
cycles_idle(5 - BUS_CYCLE); /* Leftover BIU cycles + 2 idle cycles. */
BUS_CYCLE_T1; /* Abort the prefetch. */
break;
default:
break;
}
schedule_fetch = 0;
@@ -1035,6 +1038,9 @@ do_mod_rm(void)
case 2:
wait(3, 0);
break;
default:
break;
}
cpu_state.eaaddr = (*mod1add[0][cpu_rm]) + (*mod1add[1][cpu_rm]);
easeg = ovr_seg ? *ovr_seg : *mod1seg[cpu_rm];
@@ -1049,6 +1055,8 @@ do_mod_rm(void)
cpu_state.eaaddr += pfq_fetchw();
wait(1, 0);
break;
default:
break;
}
cpu_state.eaaddr &= 0xffff;
wait(2, 0);
@@ -1591,6 +1599,9 @@ alu_op(int bits)
case 6:
bitwise(bits, (cpu_dest ^ cpu_src));
break;
default:
break;
}
}
@@ -2274,6 +2285,9 @@ execx86(int cycs)
set_af(0);
set_pzs(bits);
break;
default:
break;
}
if ((opcode & 2) != 0)
wait(4, 0);
@@ -2288,6 +2302,9 @@ execx86(int cycs)
BP = pop();
handled = 1;
break;
default:
break;
}
}
if (!handled) {
@@ -3433,6 +3450,9 @@ execx86(int cycs)
set_af(0);
set_pzs(bits);
break;
default:
break;
}
if ((opcode & 2) != 0)
wait(4, 0);
@@ -3517,6 +3537,9 @@ execx86(int cycs)
case 0xDF:
ops_sf_fpu_8087_df[rmdat & 0xff](rmdat);
break;
default:
break;
}
} else {
switch (opcode) {
@@ -3544,6 +3567,9 @@ execx86(int cycs)
case 0xDF:
ops_fpu_8087_df[rmdat & 0xff](rmdat);
break;
default:
break;
}
}
}
@@ -3572,6 +3598,9 @@ execx86(int cycs)
if (!(cpu_state.flags & Z_FLAG))
oldc = 0;
break;
default:
break;
}
} else
oldc = (CX == 0);
@@ -3744,6 +3773,9 @@ execx86(int cycs)
if (x86_div(AL, AH))
wait(1, 0);
break;
default:
break;
}
break;
@@ -3843,6 +3875,9 @@ execx86(int cycs)
wait(4, 0);
push((uint16_t *) &cpu_data);
break;
default:
break;
}
break;

View File

@@ -17,6 +17,7 @@
#include "cpu.h"
#include <86box/mem.h>
#include <86box/plat_unused.h>
#include <inttypes.h>
#include "x86.h"
#include "x86_ops.h"
@@ -850,7 +851,7 @@ COUNT(uint64_t timings, uint64_t deps, int op_32)
return cpu_has_feature(CPU_FEATURE_MMX) ? 1 : 2;
}
fatal("Illegal COUNT %016llx\n", timings);
fatal("Illegal COUNT %016" PRIu64 "\n", timings);
return timings;
}

View File

@@ -22,7 +22,7 @@ x87_from80(x87_conv_t *test)
blah = ((exp64 > 0) ? exp64 : -exp64) & 0x3ff;
exp64final = ((exp64 > 0) ? blah : -blah) + BIAS64;
mant64 = (test->eind.ll >> 11) & (0xfffffffffffffll);
mant64 = (test->eind.ll >> 11) & (0xfffffffffffffLL);
sign = (test->begin & 0x8000) ? 1 : 0;
if ((test->begin & 0x7fff) == 0x7fff)
@@ -48,19 +48,19 @@ x87_to80(double d, x87_conv_t *test)
test->eind.d = d;
sign80 = (test->eind.ll & (0x8000000000000000ll)) ? 1 : 0;
exp80 = test->eind.ll & (0x7ff0000000000000ll);
sign80 = (test->eind.ll & (0x8000000000000000LL)) ? 1 : 0;
exp80 = test->eind.ll & (0x7ff0000000000000LL);
exp80final = (exp80 >> 52);
mant80 = test->eind.ll & (0x000fffffffffffffll);
mant80 = test->eind.ll & (0x000fffffffffffffLL);
mant80final = (mant80 << 11);
if (exp80final == 0x7ff) /*Infinity / Nan*/
{
exp80final = 0x7fff;
mant80final |= (0x8000000000000000ll);
mant80final |= (0x8000000000000000LL);
} else if (d != 0) { /* Zero is a special case */
/* Elvira wants the 8 and tcalc doesn't */
mant80final |= (0x8000000000000000ll);
mant80final |= (0x8000000000000000LL);
/* Ca-cyber doesn't like this when result is zero. */
exp80final += (BIAS80 - BIAS64);
}

View File

@@ -193,7 +193,7 @@ FSTOR(void)
something like this is needed*/
p = (uint64_t *) cpu_state.tag;
#ifdef USE_NEW_DYNAREC
if (cpu_state.MM_w4[0] == 0xffff && cpu_state.MM_w4[1] == 0xffff && cpu_state.MM_w4[2] == 0xffff && cpu_state.MM_w4[3] == 0xffff && cpu_state.MM_w4[4] == 0xffff && cpu_state.MM_w4[5] == 0xffff && cpu_state.MM_w4[6] == 0xffff && cpu_state.MM_w4[7] == 0xffff && !cpu_state.TOP && (*p == 0x0101010101010101ull))
if (cpu_state.MM_w4[0] == 0xffff && cpu_state.MM_w4[1] == 0xffff && cpu_state.MM_w4[2] == 0xffff && cpu_state.MM_w4[3] == 0xffff && cpu_state.MM_w4[4] == 0xffff && cpu_state.MM_w4[5] == 0xffff && cpu_state.MM_w4[6] == 0xffff && cpu_state.MM_w4[7] == 0xffff && !cpu_state.TOP && (*p == 0x0101010101010101ULL))
#else
if (cpu_state.MM_w4[0] == 0xffff && cpu_state.MM_w4[1] == 0xffff && cpu_state.MM_w4[2] == 0xffff && cpu_state.MM_w4[3] == 0xffff && cpu_state.MM_w4[4] == 0xffff && cpu_state.MM_w4[5] == 0xffff && cpu_state.MM_w4[6] == 0xffff && cpu_state.MM_w4[7] == 0xffff && !cpu_state.TOP && !(*p))
#endif

View File

@@ -35,7 +35,7 @@
}
#define CHECK_CURRENT_CARD() \
do { \
if (1) { \
card = dev->first_card; \
while (card) { \
if (card->enable && (card->state == PNP_STATE_CONFIG)) \
@@ -46,7 +46,7 @@
isapnp_log("ISAPnP: No card in CONFIG state\n"); \
break; \
} \
} while (0);
}
static const uint8_t pnp_init_key[32] = { 0x6A, 0xB5, 0xDA, 0xED, 0xF6, 0xFB, 0x7D, 0xBE,
0xDF, 0x6F, 0x37, 0x1B, 0x0D, 0x86, 0xC3, 0x61,

View File

@@ -921,7 +921,7 @@ write64_generic(void *priv, uint8_t val)
Bit 6: Mostly, display: 0 = CGA, 1 = MDA, inverted on Xi8088 and Acer KBC's;
Intel AMI MegaKey KB-5: Used for green features, SMM handler expects it to be set;
IBM PS/1 Model 2011: 0 = current FDD is 3.5", 1 = current FDD is 5.25";
Comapq: 0 = Compaq dual-scan display, 1 = non-Compaq display.
Compaq: 0 = Compaq dual-scan display, 1 = non-Compaq display.
Bit 5: Mostly, manufacturing jumper: 0 = installed (infinite loop at POST), 1 = not installed;
NCR: power-on default speed: 0 = high, 1 = low;
Compaq: System board DIP switch 5: 0 = ON, 1 = OFF.

View File

@@ -156,7 +156,7 @@ mouse_clear_coords(void)
mouse_z = 0;
}
static void
void
mouse_clear_buttons(void)
{
mouse_buttons = 0x00;
@@ -165,6 +165,38 @@ mouse_clear_buttons(void)
mouse_delta_b = 0x00;
}
static double
mouse_scale_coord_x(double x, int mul)
{
double ratio = 1.0;
if (!mouse_raw)
ratio = ((double) monitors[0].mon_unscaled_size_x) / monitors[0].mon_res_x;
if (mul)
x *= ratio;
else
x /= ratio;
return x;
}
static double
mouse_scale_coord_y(double y, int mul)
{
double ratio = 1.0;
if (!mouse_raw)
ratio = ((double) monitors[0].mon_efscrnsz_y) / monitors[0].mon_res_y;
if (mul)
y *= ratio;
else
y /= ratio;
return y;
}
void
mouse_subtract_x(int *delta_x, int *o_x, int min, int max, int abs)
{
@@ -172,31 +204,53 @@ mouse_subtract_x(int *delta_x, int *o_x, int min, int max, int abs)
double smax_x;
double rsmin_x;
double smin_x;
int ds_x;
int scaled_x;
rsmin_x = (double) min;
rsmin_x = mouse_scale_coord_x(min, 0);
if (abs) {
smax_x = (double) max + ABS(rsmin_x);
max += ABS(min);
smax_x = mouse_scale_coord_x(max, 0) + ABS(rsmin_x);
max += ABSD(min);
real_x += rsmin_x;
smin_x = 0;
} else {
smax_x = (double) max;
smax_x = mouse_scale_coord_x(max, 0);
smin_x = rsmin_x;
}
/* Default the X and Y overflows to 1. */
smax_x = floor(smax_x);
smin_x = ceil(smin_x);
/* Default the X overflow to 1. */
if (o_x != NULL)
*o_x = 1;
ds_x = mouse_scale_coord_x(real_x, 1);
if (ds_x >= 0.0)
scaled_x = (int) floor(mouse_scale_coord_x(real_x, 1));
else
scaled_x = (int) ceil(mouse_scale_coord_x(real_x, 1));
if (real_x > smax_x) {
*delta_x = abs ? (int) real_x : max;
real_x -= smax_x;
if (abs) {
*delta_x = scaled_x;
real_x -= mouse_scale_coord_x((double) scaled_x, 0);
} else {
*delta_x = max;
real_x -= smax_x;
}
} else if (real_x < smin_x) {
*delta_x = abs ? (int) real_x : min;
real_x += ABS(smin_x);
if (abs) {
*delta_x = scaled_x;
real_x -= mouse_scale_coord_x((double) scaled_x, 0);
} else {
*delta_x = min;
real_x += ABSD(smin_x);
}
} else {
*delta_x = (int) real_x;
real_x = 0.0;
*delta_x = scaled_x;
real_x -= mouse_scale_coord_x((double) scaled_x, 0);
if (o_x != NULL)
*o_x = 0;
}
@@ -217,34 +271,56 @@ mouse_subtract_y(int *delta_y, int *o_y, int min, int max, int invert, int abs)
double smax_y;
double rsmin_y;
double smin_y;
int ds_y;
int scaled_y;
if (invert)
real_y = -real_y;
rsmin_y = (double) min;
rsmin_y = mouse_scale_coord_y(min, 0);
if (abs) {
smax_y = (double) max + ABS(rsmin_y);
max += ABS(min);
smax_y = mouse_scale_coord_y(max, 0) + ABS(rsmin_y);
max += ABSD(min);
real_y += rsmin_y;
smin_y = 0;
} else {
smax_y = (double) max;
smax_y = mouse_scale_coord_y(max, 0);
smin_y = rsmin_y;
}
/* Default the X and Y overflows to 1. */
smax_y = floor(smax_y);
smin_y = ceil(smin_y);
/* Default Y overflow to 1. */
if (o_y != NULL)
*o_y = 1;
ds_y = mouse_scale_coord_x(real_y, 1);
if (ds_y >= 0.0)
scaled_y = (int) floor(mouse_scale_coord_x(real_y, 1));
else
scaled_y = (int) ceil(mouse_scale_coord_x(real_y, 1));
if (real_y > smax_y) {
*delta_y = abs ? (int) real_y : max;
real_y -= smax_y;
if (abs) {
*delta_y = scaled_y;
real_y -= mouse_scale_coord_y((double) scaled_y, 0);
} else {
*delta_y = max;
real_y -= smax_y;
}
} else if (real_y < smin_y) {
*delta_y = abs ? (int) real_y : min;
real_y += ABS(smin_y);
if (abs) {
*delta_y = scaled_y;
real_y -= mouse_scale_coord_y((double) scaled_y, 0);
} else {
*delta_y = min;
real_y += ABSD(smin_y);
}
} else {
*delta_y = (int) real_y;
real_y = 0.0;
*delta_y = scaled_y;
real_y -= mouse_scale_coord_y((double) scaled_y, 0);
if (o_y != NULL)
*o_y = 0;
}
@@ -272,9 +348,11 @@ mouse_subtract_coords(int *delta_x, int *delta_y, int *o_x, int *o_y,
int
mouse_moved(void)
{
int moved_x = !!((int) floor(ABSD(mouse_scale_coord_x(atomic_load(&mouse_x), 1))));
int moved_y = !!((int) floor(ABSD(mouse_scale_coord_y(atomic_load(&mouse_y), 1))));
/* Convert them to integer so we treat < 1.0 and > -1.0 as 0. */
int ret = (((int) floor(atomic_load(&mouse_x)) != 0) ||
((int) floor(atomic_load(&mouse_y)) != 0));
int ret = (moved_x || moved_y);
return ret;
}
@@ -328,26 +406,35 @@ atomic_double_add(_Atomic double *var, double val)
atomic_store(var, temp);
}
void
mouse_scale_fx(double x)
{
atomic_double_add(&mouse_x, ((double) x) * mouse_sensitivity);
}
void
mouse_scale_fy(double y)
{
atomic_double_add(&mouse_y, ((double) y) * mouse_sensitivity);
}
void
mouse_scale_x(int x)
{
double ratio_x = ((double) monitors[0].mon_unscaled_size_x) / monitors[0].mon_res_x;
if (mouse_raw)
ratio_x /= plat_get_dpi();
atomic_double_add(&mouse_x, (((double) x) * mouse_sensitivity * ratio_x));
atomic_double_add(&mouse_x, ((double) x) * mouse_sensitivity);
}
void
mouse_scale_y(int y)
{
double ratio_y = ((double) monitors[0].mon_efscrnsz_y) / monitors[0].mon_res_y;
atomic_double_add(&mouse_y, ((double) y) * mouse_sensitivity);
}
if (mouse_raw)
ratio_y /= plat_get_dpi();
atomic_double_add(&mouse_y, (((double) y) * mouse_sensitivity * ratio_y));
void
mouse_scalef(double x, double y)
{
mouse_scale_fx(x);
mouse_scale_fy(y);
}
void

View File

@@ -84,9 +84,9 @@ ps2_report_coordinates(atkbc_dev_t *dev, int main)
mouse_subtract_coords(&delta_x, &delta_y, &overflow_x, &overflow_y,
-256, 255, 1, 0);
mouse_subtract_z(&delta_z, -8, 7, 1);
mouse_subtract_z(&delta_z, -8, 7, 0);
buff[0] = (overflow_y << 7) | (overflow_x << 6) |
buff[0] |= (overflow_y << 7) | (overflow_x << 6) |
((delta_y & 0x0100) >> 3) | ((delta_x & 0x0100) >> 4) |
(b & ((dev->flags & FLAG_INTELLI) ? 0x07 : 0x03));
buff[1] = (delta_x & 0x00ff);

View File

@@ -279,7 +279,7 @@ sermouse_report_ms(mouse_t *dev)
int b = mouse_get_buttons_ex();
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 0, 0);
mouse_subtract_z(&delta_z, -8, 7, 1);
mouse_subtract_z(&delta_z, -8, 7, 0);
dev->buf[0] = 0x40;
dev->buf[0] |= (((delta_y >> 6) & 0x03) << 2);

View File

@@ -37,7 +37,7 @@ static uint8_t postcard_written[POSTCARDS_NUM];
static uint8_t postcard_ports_num = 1;
static uint8_t postcard_codes[POSTCARDS_NUM];
static uint8_t postcard_prev_codes[POSTCARDS_NUM];
#define UISTR_LEN 13
#define UISTR_LEN 32
static char postcard_str[UISTR_LEN]; /* UI output string */
extern void ui_sb_bugui(char *__str);
@@ -66,44 +66,44 @@ static void
postcard_setui(void)
{
if (postcard_ports_num > 1) {
char ps[2][POSTCARDS_NUM][64] = { { 0 },
char ps[2][POSTCARDS_NUM][3] = { { 0 },
{ 0 } };
for (uint8_t i = 0; i < POSTCARDS_NUM; i++) {
if (!postcard_written[i]) {
sprintf(ps[0][i], "--");
sprintf(ps[1][i], "--");
snprintf(ps[0][i], sizeof(ps[0][i]), "--");
snprintf(ps[1][i], sizeof(ps[1][i]), "--");
} else if (postcard_written[i] == 1) {
sprintf(ps[0][i], "%02X", postcard_codes[i]);
sprintf(ps[1][i], "--");
snprintf(ps[0][i], sizeof(ps[0][i]), "%02X", postcard_codes[i]);
snprintf(ps[1][i], sizeof(ps[1][i]), "--");
} else {
sprintf(ps[0][i], "%02X", postcard_codes[i]);
sprintf(ps[1][i], "%02X", postcard_prev_codes[i]);
snprintf(ps[0][i], sizeof(ps[0][i]), "%02X", postcard_codes[i]);
snprintf(ps[1][i], sizeof(ps[1][i]), "%02X", postcard_prev_codes[i]);
}
}
switch (postcard_ports_num) {
default:
case 2:
sprintf(postcard_str, "POST: %s%s %s%s",
snprintf(postcard_str, sizeof(postcard_str), "POST: %s%s %s%s",
ps[0][0], ps[0][1], ps[1][0], ps[1][1]);
break;
case 3:
sprintf(postcard_str, "POST: %s/%s%s %s/%s%s",
snprintf(postcard_str, sizeof(postcard_str), "POST: %s/%s%s %s/%s%s",
ps[0][0], ps[0][1], ps[0][2], ps[1][0], ps[1][1], ps[1][2]);
break;
case 4:
sprintf(postcard_str, "POST: %s%s/%s%s %s%s/%s%s",
snprintf(postcard_str, sizeof(postcard_str), "POST: %s%s/%s%s %s%s/%s%s",
ps[0][0], ps[0][1], ps[0][2], ps[0][3],
ps[1][0], ps[1][1], ps[1][2], ps[1][3]);
break;
}
} else {
if (!postcard_written[0])
sprintf(postcard_str, "POST: -- --");
snprintf(postcard_str, sizeof(postcard_str), "POST: -- --");
else if (postcard_written[0] == 1)
sprintf(postcard_str, "POST: %02X --", postcard_codes[0]);
snprintf(postcard_str, sizeof(postcard_str), "POST: %02X --", postcard_codes[0]);
else
sprintf(postcard_str, "POST: %02X %02X", postcard_codes[0], postcard_prev_codes[0]);
snprintf(postcard_str, sizeof(postcard_str), "POST: %02X %02X", postcard_codes[0], postcard_prev_codes[0]);
}
ui_sb_bugui(postcard_str);

View File

@@ -109,8 +109,12 @@ serial_transmit_period(serial_t *dev)
void
serial_do_irq(serial_t *dev, int set)
{
if (dev->irq != 0xff)
picint_common(1 << dev->irq, !!(dev->type >= SERIAL_16450), set, &dev->irq_state);
if (dev->irq != 0xff) {
if (set || (dev->irq_state != !!set))
picint_common(1 << dev->irq, !!(dev->type >= SERIAL_16450), set, &dev->irq_state);
if (dev->type >= SERIAL_16450)
dev->irq_state = !!set;
}
}
void

View File

@@ -439,13 +439,14 @@ MVHDAPI int
mvhd_file_is_vhd(FILE* f)
{
uint8_t con_str[8];
size_t res;
if (f == NULL) {
return 0;
}
mvhd_fseeko64(f, -MVHD_FOOTER_SIZE, SEEK_END);
fread(con_str, sizeof con_str, 1, f);
res = fread(con_str, sizeof con_str, 1, f);
if (mvhd_is_conectix_str(con_str)) {
return 1;
}

View File

@@ -47,10 +47,14 @@
#ifdef ABS
# undef ABS
#endif
#ifdef ABSD
# undef ABSD
#endif
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define ABSD(x) ((x) > 0.0 ? (x) : -(x))
#define BCD8(x) ((((x) / 10) << 4) | ((x) % 10))
#define BCD16(x) ((((x) / 1000) << 12) | (((x) / 100) << 8) | BCD8(x))
#define BCD32(x) ((((x) / 10000000) << 28) | (((x) / 1000000) << 24) | (((x) / 100000) << 20) | (((x) / 10000) << 16) | BCD16(x))

View File

@@ -36,6 +36,9 @@ extern const device_t ali6117d_device;
/* AMD */
extern const device_t amd640_device;
/* Compaq */
extern const device_t compaq_386_device;
/* Contaq/Cypress */
extern const device_t contaq_82c596a_device;
extern const device_t contaq_82c597_device;

View File

@@ -78,6 +78,7 @@ extern const device_t mouse_wacom_artpad_device;
extern void mouse_clear_x(void);
extern void mouse_clear_y(void);
extern void mouse_clear_coords(void);
extern void mouse_clear_buttons(void);
extern void mouse_subtract_x(int *delta_x, int *o_x, int min, int max, int abs);
extern void mouse_subtract_y(int *delta_y, int *o_y, int min, int max, int invert, int abs);
extern void mouse_subtract_coords(int *delta_x, int *delta_y, int *o_x, int *o_y,
@@ -85,8 +86,11 @@ extern void mouse_subtract_coords(int *delta_x, int *delta_y, int *o_
extern int mouse_moved(void);
extern int mouse_state_changed(void);
extern int mouse_mbut_changed(void);
extern void mouse_scale_fx(double x);
extern void mouse_scale_fy(double y);
extern void mouse_scale_x(int x);
extern void mouse_scale_y(int y);
extern void mouse_scalef(double x, double y);
extern void mouse_scale(int x, int y);
extern void mouse_set_z(int z);
extern void mouse_clear_z(void);

View File

@@ -19,17 +19,24 @@
#ifndef VIDEO_8514A_H
#define VIDEO_8514A_H
typedef struct {
int ena,
x, y, xoff, yoff, cur_xsize, cur_ysize,
v_acc, h_acc;
uint32_t addr, pitch;
typedef struct hwcursor8514_t {
int ena;
int x;
int y;
int xoff;
int yoff;
int cur_xsize;
int cur_ysize;
int v_acc;
int h_acc;
uint32_t addr;
uint32_t pitch;
} hwcursor8514_t;
typedef struct ibm8514_t {
hwcursor8514_t hwcursor;
hwcursor8514_t hwcursor_latch;
uint8_t pos_regs[8];
hwcursor8514_t hwcursor;
hwcursor8514_t hwcursor_latch;
uint8_t pos_regs[8];
int force_old_addr;
int type;
@@ -49,9 +56,9 @@ typedef struct ibm8514_t {
int dac_pos;
int dac_r;
int dac_g;
int dac_b;
int dac_b;
int internal_pitch;
int hwcursor_on;
int hwcursor_on;
struct {
uint16_t subsys_cntl;

View File

@@ -45,8 +45,8 @@ typedef struct ega_t {
uint8_t scrblank;
uint8_t plane_mask;
uint8_t ctl_mode;
uint8_t pad;
uint8_t pad0;
uint8_t color_mux;
uint8_t dot;
uint8_t crtc[32];
uint8_t gdcreg[16];
uint8_t attrregs[32];
@@ -108,6 +108,7 @@ typedef struct ega_t {
int res_y;
int bpp;
int index;
int remap_required;
uint32_t charseta;
uint32_t charsetb;
@@ -117,21 +118,24 @@ typedef struct ega_t {
uint32_t ca;
uint32_t vram_limit;
uint32_t overscan_color;
uint32_t cca;
uint32_t *pallook;
uint64_t dispontime;
uint64_t dispofftime;
uint64_t dot_time;
pc_timer_t timer;
pc_timer_t dot_timer;
double clock;
double dot_clock;
int remap_required;
uint32_t (*remap_func)(struct ega_t *ega, uint32_t in_addr);
void * eeprom;
void (*render)(struct ega_t *svga);
void *eeprom;
uint32_t (*remap_func)(struct ega_t *ega, uint32_t in_addr);
void (*render)(struct ega_t *svga);
} ega_t;
#endif

View File

@@ -31,6 +31,7 @@
#include <86box/mem.h>
#include <86box/rom.h>
#include <86box/device.h>
#include <86box/chipset.h>
#include <86box/keyboard.h>
#include <86box/fdd.h>
#include <86box/fdc.h>
@@ -795,34 +796,28 @@ machine_at_compaq_init(const machine_t *model, int type)
{
compaq_machine_type = type;
if ((type != COMPAQ_DESKPRO386) && (type != COMPAQ_DESKPRO386_01_1988))
mem_remap_top(384);
if (fdc_type == FDC_INTERNAL)
device_add(&fdc_at_device);
if ((type == COMPAQ_DESKPRO386) || (type == COMPAQ_DESKPRO386_01_1988) || (type == COMPAQ_PORTABLEIII386))
mem_mapping_add(&ram_mapping, 0xfa0000, 0x60000,
read_ram, read_ramw, read_raml,
write_ram, write_ramw, write_raml,
0xa0000 + ram, MEM_MAPPING_EXTERNAL, NULL);
else
if (type < COMPAQ_PORTABLEIII386) {
mem_remap_top(384);
mem_mapping_add(&ram_mapping, 0xfa0000, 0x60000,
read_ram, read_ramw, read_raml,
write_ram, write_ramw, write_raml,
0xa0000 + ram, MEM_MAPPING_INTERNAL, NULL);
}
video_reset(gfxcard[0]);
switch (type) {
case COMPAQ_PORTABLEII:
machine_at_init(model);
machine_at_init(model);
break;
case COMPAQ_PORTABLEIII:
if (gfxcard[0] == VID_INTERNAL)
device_add(&compaq_plasma_device);
machine_at_init(model);
machine_at_init(model);
break;
case COMPAQ_PORTABLEIII386:
@@ -830,13 +825,14 @@ machine_at_compaq_init(const machine_t *model, int type)
device_add(&ide_isa_device);
if (gfxcard[0] == VID_INTERNAL)
device_add(&compaq_plasma_device);
machine_at_init(model);
machine_at_init(model);
break;
case COMPAQ_DESKPRO386:
case COMPAQ_DESKPRO386_01_1988:
if (hdc_current == 1)
device_add(&ide_isa_device);
device_add(&compaq_386_device);
machine_at_common_init(model);
device_add(&keyboard_at_compaq_device);
break;

View File

@@ -4694,9 +4694,9 @@ const machine_t machines[] = {
.bus_flags = MACHINE_AT,
.flags = MACHINE_IDE,
.ram = {
.min = 640,
.min = 1024,
.max = 16384,
.step = 128
.step = 1024
},
.nvrmask = 63,
.kbc_device = NULL,
@@ -4732,9 +4732,9 @@ const machine_t machines[] = {
.bus_flags = MACHINE_AT,
.flags = MACHINE_IDE,
.ram = {
.min = 640,
.min = 1024,
.max = 16384,
.step = 128
.step = 1024
},
.nvrmask = 63,
.kbc_device = NULL,

View File

@@ -440,12 +440,14 @@ timer_update_irq(nvr_t *nvr)
local_t *local = (local_t *) nvr->data;
uint8_t irq = (nvr->regs[RTC_REGB] & nvr->regs[RTC_REGC]) & (REGB_UIE | REGB_AIE | REGB_PIE);
if (irq) {
nvr->regs[RTC_REGC] |= REGC_IRQF;
picintlevel(1 << nvr->irq, &local->irq_state);
} else {
nvr->regs[RTC_REGC] &= ~REGC_IRQF;
picintclevel(1 << nvr->irq, &local->irq_state);
if (irq || (local->irq_state != !!irq)) {
if (irq) {
nvr->regs[RTC_REGC] |= REGC_IRQF;
picintlevel(1 << nvr->irq, &local->irq_state);
} else {
nvr->regs[RTC_REGC] &= ~REGC_IRQF;
picintclevel(1 << nvr->irq, &local->irq_state);
}
}
}

View File

@@ -33,7 +33,7 @@ CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
|| [event type] == NSEventTypeLeftMouseDragged
|| [event type] == NSEventTypeRightMouseDragged
|| [event type] == NSEventTypeOtherMouseDragged) {
mouse_scale([event deltaX], [event deltaY]);
mouse_scalef((double) [event deltaX], (double) [event deltaY]);
return true;
}
if ([event type] == NSEventTypeScrollWheel) {

View File

@@ -98,8 +98,6 @@ joystick_add_button(raw_joystick_t *rawjoy, plat_joystick_t *joy, USAGE usage)
void
joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS prop)
{
LONG center;
if (joy->nr_axes >= 8)
return;
@@ -139,14 +137,11 @@ joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS
* Some joysticks will send -1 in LogicalMax, like Xbox Controllers
* so we need to mask that to appropriate value (instead of 0xFFFFFFFF)
*/
rawjoy->axis[joy->nr_axes].max = prop->LogicalMax & ((1 << prop->BitSize) - 1);
rawjoy->axis[joy->nr_axes].max = prop->LogicalMax & ((1ULL << prop->BitSize) - 1);
}
rawjoy->axis[joy->nr_axes].min = prop->LogicalMin;
center = (rawjoy->axis[joy->nr_axes].max - rawjoy->axis[joy->nr_axes].min + 1) / 2;
if (center != 0x00)
joy->nr_axes++;
joy->nr_axes++;
}
void
@@ -450,7 +445,7 @@ joystick_process(void)
{
int d;
if (joystick_type == 7)
if (joystick_type == 0)
return;
for (int c = 0; c < joystick_get_max_joysticks(joystick_type); c++) {

View File

@@ -692,7 +692,7 @@ adgold_timer_poll(void *priv)
{
adgold_t *adgold = (adgold_t *) priv;
/*A small timer period will result in hangs.*/
/*A small timer period will result in hangs.*/
timer_on_auto(&adgold->adgold_mma_timer_count, 4.88964);
if (adgold->adgold_midi_ctrl & 0x3f) {

View File

@@ -94,6 +94,7 @@ plat_serpt_write_vcon(serial_passthrough_t *dev, uint8_t data)
fd_set wrfds;
int res;
#endif
size_t res;
/* We cannot use select here, this would block the hypervisor! */
#if 0
@@ -109,12 +110,11 @@ plat_serpt_write_vcon(serial_passthrough_t *dev, uint8_t data)
/* just write it out */
if (dev->mode == SERPT_MODE_HOSTSER) {
int res = 0;
do {
res = write(dev->master_fd, &data, 1);
} while (res == 0 || (res == -1 && (errno == EAGAIN || res == EWOULDBLOCK)));
} else
write(dev->master_fd, &data, 1);
res = write(dev->master_fd, &data, 1);
}
void

View File

@@ -193,7 +193,7 @@ int ibm8514_has_vga = 0;
int
ibm8514_cpu_src(svga_t *svga)
{
ibm8514_t *dev = &svga->dev8514;
const ibm8514_t *dev = &svga->dev8514;
if (!(dev->accel.cmd & 0x100))
return 0;
@@ -207,7 +207,7 @@ ibm8514_cpu_src(svga_t *svga)
int
ibm8514_cpu_dest(svga_t *svga)
{
ibm8514_t *dev = &svga->dev8514;
const ibm8514_t *dev = &svga->dev8514;
if (!(dev->accel.cmd & 0x100))
return 0;
@@ -962,8 +962,8 @@ ibm8514_accel_out(uint16_t port, uint32_t val, svga_t *svga, int len)
if (!val)
break;
dev->accel.advfunc_cntl = val & 0x0f;
ibm8514_on = val & 0x01;
vga_on = !ibm8514_on;
ibm8514_on = val & 0x01;
vga_on = !ibm8514_on;
ibm8514_log("IBM 8514/A: VGA ON = %i, val = %02x\n", vga_on, val);
svga_recalctimings(svga);
break;
@@ -978,6 +978,7 @@ static void
ibm8514_accel_outb(uint16_t port, uint8_t val, void *priv)
{
svga_t *svga = (svga_t *) priv;
ibm8514_accel_out(port, val, svga, 1);
}
@@ -985,6 +986,7 @@ static void
ibm8514_accel_outw(uint16_t port, uint16_t val, void *priv)
{
svga_t *svga = (svga_t *) priv;
ibm8514_accel_out(port, val, svga, 2);
}
@@ -3742,7 +3744,6 @@ void
ibm8514_render_8bpp(svga_t *svga)
{
ibm8514_t *dev = &svga->dev8514;
int x;
uint32_t *p;
uint32_t dat;
@@ -3757,7 +3758,7 @@ ibm8514_render_8bpp(svga_t *svga)
dev->firstline_draw = dev->displine;
dev->lastline_draw = dev->displine;
for (x = 0; x <= dev->h_disp; x += 8) {
for (int x = 0; x <= dev->h_disp; x += 8) {
dat = *(uint32_t *) (&dev->vram[dev->ma & dev->vram_mask]);
p[0] = dev->pallook[dat & 0xff];
p[1] = dev->pallook[(dat >> 8) & 0xff];
@@ -3781,7 +3782,7 @@ void
ibm8514_render_15bpp(svga_t *svga)
{
ibm8514_t *dev = &svga->dev8514;
int x;
int x;
uint32_t *p;
uint32_t dat;
@@ -3822,7 +3823,7 @@ void
ibm8514_render_16bpp(svga_t *svga)
{
ibm8514_t *dev = &svga->dev8514;
int x;
int x;
uint32_t *p;
uint32_t dat;
@@ -3863,7 +3864,6 @@ void
ibm8514_render_24bpp(svga_t *svga)
{
ibm8514_t *dev = &svga->dev8514;
int x;
uint32_t *p;
uint32_t dat;
@@ -3877,7 +3877,7 @@ ibm8514_render_24bpp(svga_t *svga)
dev->firstline_draw = dev->displine;
dev->lastline_draw = dev->displine;
for (x = 0; x <= dev->h_disp; x += 4) {
for (int x = 0; x <= dev->h_disp; x += 4) {
dat = *(uint32_t *) (&dev->vram[dev->ma & dev->vram_mask]);
p[x] = dat & 0xffffff;
@@ -3900,9 +3900,8 @@ void
ibm8514_render_BGR(svga_t *svga)
{
ibm8514_t *dev = &svga->dev8514;
int x;
uint32_t *p;
uint32_t dat;
uint32_t *p;
uint32_t dat;
if ((dev->displine + svga->y_add) < 0)
return;
@@ -3914,7 +3913,7 @@ ibm8514_render_BGR(svga_t *svga)
dev->firstline_draw = dev->displine;
dev->lastline_draw = dev->displine;
for (x = 0; x <= dev->h_disp; x += 4) {
for (int x = 0; x <= dev->h_disp; x += 4) {
dat = *(uint32_t *) (&dev->vram[dev->ma & dev->vram_mask]);
p[x] = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16);
@@ -3937,9 +3936,9 @@ void
ibm8514_render_ABGR8888(svga_t *svga)
{
ibm8514_t *dev = &svga->dev8514;
int x;
uint32_t *p;
uint32_t dat;
int x;
uint32_t *p;
uint32_t dat;
if ((dev->displine + svga->y_add) < 0)
return;
@@ -3964,9 +3963,9 @@ void
ibm8514_render_RGBA8888(svga_t *svga)
{
ibm8514_t *dev = &svga->dev8514;
int x;
uint32_t *p;
uint32_t dat;
int x;
uint32_t *p;
uint32_t dat;
if ((dev->displine + svga->y_add) < 0)
return;

View File

@@ -65,9 +65,9 @@ typedef struct ati68860_ramdac_t {
} ati68860_ramdac_t;
void
ati68860_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga)
ati68860_ramdac_out(uint16_t addr, uint8_t val, void *priv, svga_t *svga)
{
ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) p;
ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) priv;
switch (addr) {
case 0:
@@ -168,10 +168,10 @@ ati68860_ramdac_out(uint16_t addr, uint8_t val, void *p, svga_t *svga)
}
uint8_t
ati68860_ramdac_in(uint16_t addr, void *p, svga_t *svga)
ati68860_ramdac_in(uint16_t addr, void *priv, svga_t *svga)
{
ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) p;
uint8_t temp = 0;
const ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) priv;
uint8_t temp = 0;
switch (addr) {
case 0:
@@ -207,9 +207,9 @@ ati68860_ramdac_in(uint16_t addr, void *p, svga_t *svga)
}
void
ati68860_set_ramdac_type(void *p, int type)
ati68860_set_ramdac_type(void *priv, int type)
{
ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) p;
ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) priv;
if (ramdac->ramdac_type != type) {
ramdac->ramdac_type = type;
@@ -237,17 +237,17 @@ ati68860_ramdac_init(UNUSED(const device_t *info))
}
void
ati68860_ramdac_set_render(void *p, svga_t *svga)
ati68860_ramdac_set_render(void *priv, svga_t *svga)
{
ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) p;
ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) priv;
svga->render = ramdac->render;
}
void
ati68860_ramdac_set_pallook(void *p, int i, uint32_t col)
ati68860_ramdac_set_pallook(void *priv, int i, uint32_t col)
{
ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) p;
ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) priv;
ramdac->pallook[i] = col;
}
@@ -255,11 +255,11 @@ ati68860_ramdac_set_pallook(void *p, int i, uint32_t col)
void
ati68860_hwcursor_draw(svga_t *svga, int displine)
{
ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) svga->ramdac;
int offset;
uint8_t dat;
uint32_t col0 = ramdac->pallook[0];
uint32_t col1 = ramdac->pallook[1];
const ati68860_ramdac_t *ramdac = (ati68860_ramdac_t *) svga->ramdac;
int offset;
uint8_t dat;
uint32_t col0 = ramdac->pallook[0];
uint32_t col1 = ramdac->pallook[1];
offset = svga->dac_hwcursor_latch.xoff;
for (uint32_t x = 0; x < 64 - svga->dac_hwcursor_latch.xoff; x += 4) {

View File

@@ -40,18 +40,18 @@
#include <86box/vid_svga_render.h>
#include <86box/vid_ati_eeprom.h>
#define BIOS_MACH8_ROM_PATH "roms/video/mach8/BIOS.BIN"
#define BIOS_MACH32_ISA_ROM_PATH "roms/video/mach32/ATi Mach32 Graphics Pro ISA.BIN"
#define BIOS_MACH32_VLB_ROM_PATH "roms/video/mach32/MACH32VLB.VBI"
#define BIOS_MACH32_MCA_ROM_PATH "roms/video/mach32/MACH32MCA_Olivetti.BIN"
#define BIOS_MACH32_PCI_ROM_PATH "roms/video/mach32/intelopt_00000.rom"
#define BIOS_MACH8_ROM_PATH "roms/video/mach8/BIOS.BIN"
#define BIOS_MACH32_ISA_ROM_PATH "roms/video/mach32/ATi Mach32 Graphics Pro ISA.BIN"
#define BIOS_MACH32_VLB_ROM_PATH "roms/video/mach32/MACH32VLB.VBI"
#define BIOS_MACH32_MCA_ROM_PATH "roms/video/mach32/MACH32MCA_Olivetti.BIN"
#define BIOS_MACH32_PCI_ROM_PATH "roms/video/mach32/intelopt_00000.rom"
typedef struct mach_t {
ati_eeprom_t eeprom;
svga_t svga;
rom_t bios_rom;
rom_t bios_rom2;
rom_t bios_rom2;
mem_mapping_t mmio_linear_mapping;
int mca_bus;
@@ -65,9 +65,9 @@ typedef struct mach_t {
uint8_t pci_slot;
uint8_t irq_state;
int index;
int ramdac_type;
int old_mode;
int index;
int ramdac_type;
int old_mode;
uint32_t memory;
@@ -408,27 +408,27 @@ mach_pixel_read(mach_t *mach)
static void
mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint32_t cpu_dat, mach_t *mach, ibm8514_t *dev)
{
svga_t *svga = &mach->svga;
int compare_mode;
int poly_src = 0;
uint16_t rd_mask = dev->accel.rd_mask;
uint16_t wrt_mask = dev->accel.wrt_mask;
uint16_t dest_cmp_clr = dev->accel.color_cmp;
int frgd_sel;
int bkgd_sel;
int mono_src;
int compare = 0;
uint16_t src_dat = 0;
uint16_t dest_dat = 0;
uint16_t old_dest_dat;
uint16_t *vram_w = (uint16_t *) dev->vram;
uint16_t mix = 0;
int16_t clip_l = dev->accel.clip_left & 0x7ff;
int16_t clip_t = dev->accel.clip_top & 0x7ff;
int16_t clip_r = dev->accel.multifunc[4] & 0x7ff;
int16_t clip_b = dev->accel.multifunc[3] & 0x7ff;
uint32_t mono_dat0 = 0;
uint32_t mono_dat1 = 0;
const svga_t *svga = &mach->svga;
int compare_mode;
int poly_src = 0;
uint16_t rd_mask = dev->accel.rd_mask;
uint16_t wrt_mask = dev->accel.wrt_mask;
uint16_t dest_cmp_clr = dev->accel.color_cmp;
int frgd_sel;
int bkgd_sel;
int mono_src;
int compare = 0;
uint16_t src_dat = 0;
uint16_t dest_dat = 0;
uint16_t old_dest_dat;
uint16_t *vram_w = (uint16_t *) dev->vram;
uint16_t mix = 0;
int16_t clip_l = dev->accel.clip_left & 0x7ff;
int16_t clip_t = dev->accel.clip_top & 0x7ff;
int16_t clip_r = dev->accel.multifunc[4] & 0x7ff;
int16_t clip_b = dev->accel.multifunc[3] & 0x7ff;
uint32_t mono_dat0 = 0;
uint32_t mono_dat1 = 0;
if (!dev->bpp) {
rd_mask &= 0xff;
@@ -2249,7 +2249,7 @@ mach_accel_start(int cmd_type, int cpu_input, int count, uint32_t mix_dat, uint3
}
static void
mach_accel_out_pixtrans(mach_t *mach, ibm8514_t *dev, UNUSED(uint16_t port), uint16_t val, uint16_t len)
mach_accel_out_pixtrans(mach_t *mach, ibm8514_t *dev, UNUSED(uint16_t port), uint16_t val, UNUSED(uint16_t len))
{
int frgd_sel;
int bkgd_sel;
@@ -2299,7 +2299,7 @@ mach_out(uint16_t addr, uint8_t val, void *priv)
{
mach_t *mach = (mach_t *) priv;
svga_t *svga = &mach->svga;
ibm8514_t *dev = &svga->dev8514;
const ibm8514_t *dev = &svga->dev8514;
uint8_t old;
uint8_t rs2;
uint8_t rs3;
@@ -2483,7 +2483,7 @@ mach_in(uint16_t addr, void *priv)
{
mach_t *mach = (mach_t *) priv;
svga_t *svga = &mach->svga;
ibm8514_t *dev = &svga->dev8514;
const ibm8514_t *dev = &svga->dev8514;
uint8_t temp = 0xff;
uint8_t rs2;
uint8_t rs3;
@@ -2575,7 +2575,7 @@ mach_in(uint16_t addr, void *priv)
static void
mach_recalctimings(svga_t *svga)
{
mach_t *mach = (mach_t *) svga->priv;
const mach_t *mach = (mach_t *) svga->priv;
ibm8514_t *dev = &svga->dev8514;
int clock_sel;
@@ -2595,9 +2595,6 @@ mach_recalctimings(svga_t *svga)
if (mach->regs[0xb0] & 0x40)
svga->ma_latch |= 0x20000;
if (mach->regs[0xa7] & 0x80)
svga->clock *= 3;
if (mach->regs[0xb6] & 0x10) {
svga->hdisp <<= 1;
svga->htotal <<= 1;
@@ -2611,8 +2608,12 @@ mach_recalctimings(svga_t *svga)
if (!svga->scrblank && (svga->crtc[0x17] & 0x80) && svga->attr_palette_enable) {
if (((svga->gdcreg[6] & 1) || (svga->attrregs[0x10] & 1))) {
mach_log("VGA ON.\n");
svga->clock = (uint64_t)((cpuclock * svga->getclock(clock_sel, svga->clock_gen)) / (double) (1ull << 32));
if (!ibm8514_on) {
mach_log("VGA ON.\n");
svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock(clock_sel, svga->clock_gen);
if (mach->regs[0xa7] & 0x80)
svga->clock *= 3;
}
switch (svga->gdcreg[5] & 0x60) {
case 0x00:
if (svga->seqregs[1] & 8) /*Low res (320)*/
@@ -2640,15 +2641,20 @@ mach_recalctimings(svga_t *svga)
}
break;
default:
break;
}
break;
default:
break;
}
}
}
if (dev->local >= 2) {
if (ibm8514_on) {
svga->clock = (uint64_t)((cpuclock * svga->getclock((mach->accel.clock_sel >> 2) & 0x0f, svga->clock_gen)) / (double) (1ull << 32));
svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock((mach->accel.clock_sel >> 2) & 0x0f, svga->clock_gen);
dev->h_disp = (dev->hdisp + 1) << 3;
dev->h_total = (dev->htotal + 1);
dev->v_total = (dev->vtotal + 1);
@@ -2691,7 +2697,7 @@ mach_recalctimings(svga_t *svga)
}
dev->pitch = dev->ext_pitch;
dev->rowoffset = dev->ext_crt_pitch;
if ((mach->accel.ext_ge_config & 0x800) || ((!(mach->accel.ext_ge_config & 0x8000) && !(mach->accel.ext_ge_config & 0x800)))) {
if ((mach->accel.ext_ge_config & 0x800) || (!(mach->accel.ext_ge_config & 0x8000) && !(mach->accel.ext_ge_config & 0x800))) {
if ((mach->accel.ext_ge_config & 0x30) == 0x20) {
if ((mach->accel.ext_ge_config & 0xc0) == 0x40)
svga->bpp = 16;
@@ -2728,6 +2734,9 @@ mach_recalctimings(svga_t *svga)
else
svga->render = ibm8514_render_RGBA8888;
break;
default:
break;
}
}
switch (mach->regs[0xb8] & 0xc0) {
@@ -2740,17 +2749,20 @@ mach_recalctimings(svga_t *svga)
case 0xc0:
svga->clock *= 4;
break;
default:
break;
}
}
} else {
if (ibm8514_on) {
svga->clock = (uint64_t)((cpuclock * svga->getclock((mach->accel.clock_sel >> 2) & 0x0f, svga->clock_gen)) / (double) (1ull << 32));
dev->h_disp = (dev->hdisp + 1) << 3;
dev->h_total = (dev->htotal + 1);
dev->v_total = (dev->vtotal + 1);
dev->v_syncstart = (dev->vsyncstart + 1);
dev->rowcount = !!(dev->disp_cntl & 0x08);
dev->dispend = ((dev->vdisp >> 1) + 1);
svga->clock = (cpuclock * (double) (1ULL << 32)) / svga->getclock((mach->accel.clock_sel >> 2) & 0x0f, svga->clock_gen);
dev->h_disp = (dev->hdisp + 1) << 3;
dev->h_total = (dev->htotal + 1);
dev->v_total = (dev->vtotal + 1);
dev->v_syncstart = (dev->vsyncstart + 1);
dev->rowcount = !!(dev->disp_cntl & 0x08);
dev->dispend = ((dev->vdisp >> 1) + 1);
if (dev->dispend == 766)
dev->dispend += 2;
@@ -3237,7 +3249,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u
}
mach_log("CLIPBOTTOM=%d, CLIPRIGHT=%d, bpp=%d, pitch=%d.\n", dev->accel.multifunc[3], dev->accel.multifunc[4], svga->bpp, dev->pitch);
if ((dev->accel.multifunc_cntl >> 12) == 5) {
if (!dev->ext_crt_pitch || ((dev->local < 2)))
if (!dev->ext_crt_pitch || (dev->local < 2))
dev->ext_crt_pitch = 128;
svga_recalctimings(svga);
}
@@ -3259,7 +3271,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u
dev->accel.clip_left = dev->accel.multifunc_cntl & 0x7ff;
}
if ((dev->accel.multifunc_cntl >> 12) == 5) {
if (!dev->ext_crt_pitch || ((dev->local < 2)))
if (!dev->ext_crt_pitch || (dev->local < 2))
dev->ext_crt_pitch = 128;
svga_recalctimings(svga);
}
@@ -3681,7 +3693,7 @@ mach_accel_out(uint16_t port, uint8_t val, mach_t *mach)
case 0x4ae8:
if (!val)
break;
if (!dev->ext_crt_pitch || ((dev->local < 2)))
if (!dev->ext_crt_pitch || (dev->local < 2))
dev->ext_crt_pitch = 128;
dev->accel.advfunc_cntl = val & 0x0f;
@@ -3719,7 +3731,7 @@ mach_accel_out(uint16_t port, uint8_t val, mach_t *mach)
case 0xeef:
WRITE8(port, mach->cursor_offset_hi_reg, val);
mach->cursor_offset_hi = mach->cursor_offset_hi_reg & 0x0f;
dev->hwcursor.addr = ((mach->cursor_offset_lo | (mach->cursor_offset_hi << 16))) << 2;
dev->hwcursor.addr = (mach->cursor_offset_lo | (mach->cursor_offset_hi << 16)) << 2;
dev->hwcursor.ena = !!(mach->cursor_offset_hi_reg & 0x8000);
break;
@@ -3819,7 +3831,7 @@ mach_accel_out(uint16_t port, uint8_t val, mach_t *mach)
case 0x4aee:
case 0x4aef:
if (!(port & 1))
if (!(port & 1))
mach->old_mode = mach->accel.clock_sel & 0x01;
WRITE8(port, mach->accel.clock_sel, val);
@@ -3914,6 +3926,9 @@ mach_accel_out(uint16_t port, uint8_t val, mach_t *mach)
else
dev->ext_crt_pitch *= 3;
break;
default:
break;
}
svga_set_ramdac_type(svga, !!(mach->accel.ext_ge_config & 0x4000));
mach_log("Passthrough override = %04x.\n", val & 0x1000);
@@ -3930,17 +3945,17 @@ mach_accel_out(uint16_t port, uint8_t val, mach_t *mach)
svga_recalctimings(svga);
break;
default:
break;
default:
break;
}
}
static uint16_t
mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, int len)
{
uint16_t *vram_w = (uint16_t *) dev->vram;
uint16_t temp = 0;
int cmd;
const uint16_t *vram_w = (uint16_t *) dev->vram;
uint16_t temp = 0;
int cmd;
int frgd_sel;
int bkgd_sel;
int mono_src;
@@ -4106,6 +4121,9 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in
} else
mach_accel_start(mach->accel.cmd_type, 1, 2, -1, mach->accel.pix_trans[0] | (mach->accel.pix_trans[1] << 8), mach, dev);
break;
default:
break;
}
}
}
@@ -4144,6 +4162,9 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in
case 0x0a:
temp = dev->accel.multifunc[0x0a];
break;
default:
break;
}
}
break;
@@ -4316,6 +4337,9 @@ mach_accel_in_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, in
temp = 0x22;
}
break;
default:
break;
}
mach_log("Port FIFO IN=%04x, temp=%04x, len=%d.\n", port, temp, len);
@@ -4365,7 +4389,7 @@ mach_accel_in(uint16_t port, mach_t *mach)
break;
case 0x42e8:
case 0x42e9:
case 0x42e9:
vpos = dev->vc & 0x7ff;
if (vblankend > dev->v_total) {
vblankend -= dev->v_total;
@@ -4419,9 +4443,9 @@ mach_accel_in(uint16_t port, mach_t *mach)
if (!(port & 1)) {
switch (mach->memory) {
case 512:
temp &= ~0x0c;
break;
case 512:
temp &= ~0x0c;
break;
case 1024:
temp |= 0x04;
break;
@@ -4431,6 +4455,9 @@ mach_accel_in(uint16_t port, mach_t *mach)
case 4096:
temp |= 0x0c;
break;
default:
break;
}
}
break;
@@ -4513,8 +4540,8 @@ mach_accel_in(uint16_t port, mach_t *mach)
READ8(port, dev->accel.multifunc[3]);
break;
default:
break;
default:
break;
}
mach_log("Port accel in = %04x, temp = %04x.\n", port, temp);
return temp;
@@ -4797,8 +4824,8 @@ mach32_updatemapping(mach_t *mach)
static void
mach32_hwcursor_draw(svga_t *svga, int displine)
{
mach_t *mach = (mach_t *) svga->priv;
ibm8514_t *dev = &svga->dev8514;
const mach_t *mach = (mach_t *) svga->priv;
ibm8514_t *dev = &svga->dev8514;
uint16_t dat;
int comb;
int offset = dev->hwcursor_latch.x - dev->hwcursor_latch.xoff;
@@ -5079,9 +5106,10 @@ mach_io_set(mach_t *mach)
}
static uint8_t
mach_mca_read(int port, void *p)
mach_mca_read(int port, void *priv)
{
mach_t *mach = (mach_t *) p;
const mach_t *mach = (mach_t *) priv;
mach_log("[%04X]: MCA read port = %x, val = %02x.\n", CS, port & 7, mach->pos_regs[port & 7]);
return mach->pos_regs[port & 7];
}
@@ -5089,8 +5117,7 @@ mach_mca_read(int port, void *p)
static void
mach_mca_write(int port, uint8_t val, void *priv)
{
mach_t *mach = (mach_t *) priv;
svga_t *svga = &mach->svga;
mach_t *mach = (mach_t *) priv;
if (port < 0x102)
return;
@@ -5106,17 +5133,18 @@ mach_mca_write(int port, uint8_t val, void *priv)
}
static uint8_t
mach_mca_feedb(void *p)
mach_mca_feedb(void *priv)
{
mach_t *mach = (mach_t *) p;
const mach_t *mach = (mach_t *) priv;
mach_log("FeedB = %x.\n", mach->pos_regs[2] & 0x01);
return mach->pos_regs[2] & 0x01;
}
static void
mach_mca_reset(void *p)
mach_mca_reset(void *priv)
{
mach_t *mach = (mach_t *) p;
mach_t *mach = (mach_t *) priv;
mem_mapping_disable(&mach->bios_rom.mapping);
mem_mapping_disable(&mach->bios_rom2.mapping);
@@ -5411,10 +5439,10 @@ mach8_init(const device_t *info)
mca_add(mach_mca_read, mach_mca_write, mach_mca_feedb, mach_mca_reset, mach);
} else if (mach->pci_bus) {
ati_eeprom_load(&mach->eeprom, "mach32_pci.nvr", 1);
if (mach->has_bios) {
mem_mapping_disable(&mach->bios_rom.mapping);
if (mach->has_bios) {
mem_mapping_disable(&mach->bios_rom.mapping);
pci_add_card(PCI_ADD_NORMAL, mach32_pci_read, mach32_pci_write, mach, &mach->pci_slot);
} else
} else
pci_add_card(PCI_ADD_VIDEO, mach32_pci_read, mach32_pci_write, mach, &mach->pci_slot);
mach->pci_regs[PCI_REG_COMMAND] = 0x83;
mach->pci_regs[0x30] = 0x00;

View File

@@ -44,22 +44,22 @@ static const double tau = 6.28318531; /* == 2*pi */
static unsigned char chroma_multiplexer[256] = {
// clang-format off
2, 2, 2, 2, 114,174, 4, 3, 2, 1,133,135, 2,113,150, 4,
133, 2, 1, 99, 151,152, 2, 1, 3, 2, 96,136, 151,152,151,152,
2, 56, 62, 4, 111,250,118, 4, 0, 51,207,137, 1,171,209, 5,
140, 50, 54,100, 133,202, 57, 4, 2, 50,153,149, 128,198,198,135,
32, 1, 36, 81, 147,158, 1, 42, 33, 1,210,254, 34,109,169, 77,
177, 2, 0,165, 189,154, 3, 44, 33, 0, 91,197, 178,142,144,192,
4, 2, 61, 67, 117,151,112, 83, 4, 0,249,255, 3,107,249,117,
147, 1, 50,162, 143,141, 52, 54, 3, 0,145,206, 124,123,192,193,
72, 78, 2, 0, 159,208, 4, 0, 53, 58,164,159, 37,159,171, 1,
248,117, 4, 98, 212,218, 5, 2, 54, 59, 93,121, 176,181,134,130,
1, 61, 31, 0, 160,255, 34, 1, 1, 58,197,166, 0,177,194, 2,
162,111, 34, 96, 205,253, 32, 1, 1, 57,123,125, 119,188,150,112,
78, 4, 0, 75, 166,180, 20, 38, 78, 1,143,246, 42,113,156, 37,
252, 4, 1,188, 175,129, 1, 37, 118, 4, 88,249, 202,150,145,200,
61, 59, 60, 60, 228,252,117, 77, 60, 58,248,251, 81,212,254,107,
198, 59, 58,169, 250,251, 81, 80, 100, 58,154,250, 251,252,252,252
2, 2, 2, 2, 114,174, 4, 3, 2, 1,133,135, 2,113,150, 4,
133, 2, 1, 99, 151,152, 2, 1, 3, 2, 96,136, 151,152,151,152,
2, 56, 62, 4, 111,250,118, 4, 0, 51,207,137, 1,171,209, 5,
140, 50, 54,100, 133,202, 57, 4, 2, 50,153,149, 128,198,198,135,
32, 1, 36, 81, 147,158, 1, 42, 33, 1,210,254, 34,109,169, 77,
177, 2, 0,165, 189,154, 3, 44, 33, 0, 91,197, 178,142,144,192,
4, 2, 61, 67, 117,151,112, 83, 4, 0,249,255, 3,107,249,117,
147, 1, 50,162, 143,141, 52, 54, 3, 0,145,206, 124,123,192,193,
72, 78, 2, 0, 159,208, 4, 0, 53, 58,164,159, 37,159,171, 1,
248,117, 4, 98, 212,218, 5, 2, 54, 59, 93,121, 176,181,134,130,
1, 61, 31, 0, 160,255, 34, 1, 1, 58,197,166, 0,177,194, 2,
162,111, 34, 96, 205,253, 32, 1, 1, 57,123,125, 119,188,150,112,
78, 4, 0, 75, 166,180, 20, 38, 78, 1,143,246, 42,113,156, 37,
252, 4, 1,188, 175,129, 1, 37, 118, 4, 88,249, 202,150,145,200,
61, 59, 60, 60, 228,252,117, 77, 60, 58,248,251, 81,212,254,107,
198, 59, 58,169, 250,251, 81, 80, 100, 58,154,250, 251,252,252,252
// clang-format on
};

View File

@@ -3353,13 +3353,13 @@ gd54xx_pattern_copy(gd54xx_t *gd54xx)
/* The vertical offset is in the three low-order bits of the Source Address register. */
pattern_y = gd54xx->blt.src_addr & 0x07;
/* Mode Pattern bytes Pattern line bytes
/* Mode Pattern bytes Pattern line bytes
---------------------------------------------------
Color Expansion 8 1
8-bpp 64 8
16-bpp 128 16
24-bpp 256 32
32-bpp 256 32
Color Expansion 8 1
8-bpp 64 8
16-bpp 128 16
24-bpp 256 32
32-bpp 256 32
*/
/* The boundary has to be equal to the size of the pattern. */

View File

@@ -17,6 +17,7 @@
* Copyright 2008-2019 Sarah Walker.
* Copyright 2016-2019 Miran Grca.
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
@@ -26,6 +27,7 @@
#include "cpu.h"
#include <86box/io.h>
#include <86box/timer.h>
#include <86box/pic.h>
#include <86box/pit.h>
#include <86box/mem.h>
#include <86box/rom.h>
@@ -92,11 +94,11 @@ ega_out(uint16_t addr, uint8_t val, void *priv)
case 0xb2:
case 0xbe:
#if 0
if (ega->regs[0xbe] & 8) { /*Read/write bank mode*/
svga->read_bank = ((ega->regs[0xb2] >> 5) & 7) * 0x10000;
svga->write_bank = ((ega->regs[0xb2] >> 1) & 7) * 0x10000;
} else /*Single bank mode*/
svga->read_bank = svga->write_bank = ((ega->regs[0xb2] >> 1) & 7) * 0x10000;
if (ega->regs[0xbe] & 8) { /*Read/write bank mode*/
svga->read_bank = ((ega->regs[0xb2] >> 5) & 7) * 0x10000;
svga->write_bank = ((ega->regs[0xb2] >> 1) & 7) * 0x10000;
} else /*Single bank mode*/
svga->read_bank = svga->write_bank = ((ega->regs[0xb2] >> 1) & 7) * 0x10000;
#endif
break;
case 0xb3:
@@ -302,8 +304,8 @@ ega_in(uint16_t addr, void *priv)
ret = ega->attrregs[ega->attraddr];
break;
case 0x3c2:
ret = (egaswitches & (8 >> egaswitchread)) ? 0x10 : 0x00;
break;
ret = (egaswitches & (8 >> egaswitchread)) ? 0x10 : 0x00;
break;
case 0x3c4:
if (ega_type)
ret = ega->seqaddr;
@@ -361,8 +363,31 @@ ega_in(uint16_t addr, void *priv)
break;
case 0x3da:
ega->attrff = 0;
ega->stat ^= 0x30; /* Fools IBM EGA video BIOS self-test. */
ret = ega->stat;
if (ega_type == 2) {
ret = ega->stat & 0xcf;
switch ((ega->attrregs[0x12] >> 4) & 0x03) {
case 0x00:
/* 00 = Pri. Red (5), Pri. Blue (4) */
ret |= (ega->color_mux & 0x04) ? 0x20 : 0x00;
ret |= (ega->color_mux & 0x01) ? 0x10 : 0x00;
break;
case 0x01:
case 0x03:
/* 01 = Sec. Red (5), Sec. Green (4) */
/* 11 = Sec. Red (5), Sec. Green (4) */
ret |= (ega->color_mux & 0x20) ? 0x20 : 0x00;
ret |= (ega->color_mux & 0x10) ? 0x10 : 0x00;
break;
case 0x02:
/* 10 = Sec. Blue (5), Pri. Green (4) */
ret |= (ega->color_mux & 0x08) ? 0x20 : 0x00;
ret |= (ega->color_mux & 0x02) ? 0x10 : 0x00;
break;
}
} else {
ega->stat ^= 0x30; /* Fools IBM EGA video BIOS self-test. */
ret = ega->stat;
}
break;
case 0x7c6:
ret = 0xfd; /* EGA mode supported. */
@@ -371,7 +396,7 @@ ega_in(uint16_t addr, void *priv)
/* 0000 = None;
0001 = Compaq Dual-Mode (DM) Monitor;
0010 = RGBI Color Monitor;
0011 = COMAPQ Color Monitor (RrGgBb) or Compatible;
0011 = COMPAQ Color Monitor (RrGgBb) or Compatible;
0100 - 1111 = Reserved. */
ret = 0x01;
break;
@@ -436,15 +461,15 @@ ega_recalctimings(ega_t *ega)
if (ega_type == 2) {
color = (ega->miscout & 1);
clksel = ((ega->miscout & 0xc) >> 2) | ((ega->regs[0xbe] & 0x10) ? 4 : 0);
clksel = ((ega->miscout & 0xc) >> 2);
if (color) {
if (clksel)
if (ega->vidclock)
crtcconst = (cpuclock / 16257000.0 * (double) (1ULL << 32));
else
crtcconst = (cpuclock / (157500000.0 / 11.0) * (double) (1ULL << 32));
} else {
if (clksel)
if (ega->vidclock)
crtcconst = (cpuclock / 18981000.0 * (double) (1ULL << 32));
else
crtcconst = (cpuclock / 16872000.0 * (double) (1ULL << 32));
@@ -484,6 +509,10 @@ ega_recalctimings(ega_t *ega)
else
crtcconst = (ega->seqregs[1] & 1) ? CGACONST : (CGACONST * (9.0 / 8.0));
}
if (!(ega->seqregs[1] & 1))
ega->dot_clock = crtcconst / 9.0;
else
ega->dot_clock = crtcconst / 8.0;
ega->interlace = 0;
@@ -538,9 +567,110 @@ ega_recalctimings(ega_t *ega)
if (ega->dispofftime < TIMER_USEC)
ega->dispofftime = TIMER_USEC;
ega->dot_time = (uint64_t) (ega->dot_clock);
if (ega->dot_time < TIMER_USEC)
ega->dot_time = TIMER_USEC;
ega_recalc_remap_func(ega);
}
/* This is needed for the Compaq EGA so that it can pass the 3DA
palette mux part of the self-test. */
void
ega_dot_poll(void *priv)
{
ega_t *ega = (ega_t *) priv;
static uint8_t chr;
static uint8_t attr;
const bool doublewidth = ((ega->seqregs[1] & 8) != 0);
const bool attrblink = ((ega->attrregs[0x10] & 8) != 0);
const bool attrlinechars = (ega->attrregs[0x10] & 4);
const bool crtcreset = ((ega->crtc[0x17] & 0x80) == 0);
const bool seq9dot = ((ega->seqregs[1] & 1) == 0);
const bool blinked = ega->blink & 0x10;
const int dwshift = doublewidth ? 1 : 0;
const int dotwidth = 1 << dwshift;
const int charwidth = dotwidth * (seq9dot ? 9 : 8);
const int cursoron = (ega->sc == (ega->crtc[10] & 31));
const int cursoraddr = (ega->crtc[0xe] << 8) | ega->crtc[0xf];
uint32_t addr;
int drawcursor;
uint32_t charaddr;
static int fg;
static int bg;
static uint32_t dat;
static int disptime;
static int _dispontime;
static int _dispofftime;
static int cclock = 0;
static int active = 0;
if (ega->seqregs[1] & 8) {
disptime = ((ega->crtc[0] + 2) << 1);
_dispontime = ((ega->crtc[1] + 1) << 1);
} else {
disptime = (ega->crtc[0] + 2);
_dispontime = (ega->crtc[1] + 1);
}
_dispofftime = disptime - _dispontime;
timer_advance_u64(&ega->dot_timer, ega->dot_time);
if (ega->render == ega_render_text)
ega->color_mux = (dat & (0x100 >> (ega->dot >> dwshift))) ? fg : bg;
else
ega->color_mux = 0x00;
addr = ega->remap_func(ega, ega->cca) & ega->vrammask;
if (!crtcreset) {
chr = ega->vram[addr];
attr = ega->vram[addr + 1];
} else
chr = attr = 0;
drawcursor = ((ega->cca == cursoraddr) && cursoron && ega->cursoron);
if (attr & 8)
charaddr = ega->charsetb + (chr * 0x80);
else
charaddr = ega->charseta + (chr * 0x80);
dat = ega->vram[charaddr + (ega->sc << 2)];
dat <<= 1;
if ((chr & ~0x1F) == 0xC0 && attrlinechars)
dat |= (dat >> 1) & 1;
if (!active)
dat = 0x200;
if (drawcursor) {
bg = ega->egapal[attr & 0x0f];
fg = ega->egapal[attr >> 4];
} else {
fg = ega->egapal[attr & 0x0f];
bg = ega->egapal[attr >> 4];
if ((attr & 0x80) && attrblink) {
bg = ega->egapal[(attr >> 4) & 7];
if (blinked)
fg = bg;
}
}
ega->dot = (ega->dot + 1) % charwidth;
if (ega->dot == 0) {
ega->cca = (ega->cca + 4) & 0x3ffff;
cclock++;
if (active && (cclock == _dispofftime))
active = 0;
else if (!active && (cclock == _dispontime))
active = 1;
}
}
void
ega_poll(void *priv)
{
@@ -623,6 +753,7 @@ ega_poll(void *priv)
if (ega->linedbl && !ega->linecountff) {
ega->linecountff = 1;
ega->ma = ega->maback;
ega->cca = ega->maback;
}
if (ega->sc == (ega->crtc[9] & 31)) {
ega->linecountff = 0;
@@ -633,11 +764,13 @@ ega_poll(void *priv)
ega->maback += (ega->rowoffset << 3);
ega->maback &= ega->vrammask;
ega->ma = ega->maback;
ega->cca = ega->maback;
} else {
ega->linecountff = 0;
ega->sc++;
ega->sc &= 31;
ega->ma = ega->maback;
ega->cca = ega->maback;
}
}
ega->vc++;
@@ -649,6 +782,7 @@ ega_poll(void *priv)
else
ega->ma = ega->maback = 0;
ega->ma <<= 2;
ega->cca = ega->ma;
ega->maback <<= 2;
ega->sc = 0;
if (ega->attrregs[0x10] & 0x20) {
@@ -676,6 +810,7 @@ ega_poll(void *priv)
if (ega->vc == ega->vsyncstart) {
ega->dispon = 0;
ega->stat |= 8;
// picint(1 << 2);
x = ega->hdisp;
if (ega->interlace && !ega->oddeven)
@@ -715,6 +850,7 @@ ega_poll(void *priv)
ega->ma <<= 2;
ega->maback <<= 2;
ega->ca <<= 2;
ega->cca = ega->ma;
}
if (ega->vc == ega->vtotal) {
ega->vc = 0;
@@ -1263,6 +1399,8 @@ ega_init(ega_t *ega, int monitor_type, int is_mono)
ega->crtc[6] = 255;
timer_add(&ega->timer, ega_poll, ega, 1);
if (ega_type == 2)
timer_add(&ega->dot_timer, ega_dot_poll, ega, 1);
}
static void *
@@ -1339,6 +1477,7 @@ ega_standalone_init(const device_t *info)
memset(ega->eeprom, 0, sizeof(ati_eeprom_t));
ati_eeprom_load((ati_eeprom_t *) ega->eeprom, "egawonder800.nvr", 0);
} else if (info->local == EGA_COMPAQ) {
io_sethandler(0x0084, 0x0001, ega_in, NULL, NULL, ega_out, NULL, NULL, ega);
io_sethandler(0x07c6, 0x0001, ega_in, NULL, NULL, ega_out, NULL, NULL, ega);
io_sethandler(0x0bc6, 0x0001, ega_in, NULL, NULL, ega_out, NULL, NULL, ega);
io_sethandler(0x0fc6, 0x0001, ega_in, NULL, NULL, ega_out, NULL, NULL, ega);
@@ -1403,11 +1542,11 @@ ega_speed_changed(void *priv)
}
/* SW1 SW2 SW3 SW4
OFF OFF ON OFF Monochrome (5151) 1011 0x0B
ON OFF OFF ON Color 40x25 (5153) 0110 0x06
OFF OFF OFF ON Color 80x25 (5153) 0111 0x07
ON ON ON OFF Enhanced Color - Normal Mode (5154) 1000 0x08
OFF ON ON OFF Enhanced Color - Enhanced Mode (5154) 1001 0x09
OFF OFF ON OFF Monochrome (5151) 1011 0x0B
ON OFF OFF ON Color 40x25 (5153) 0110 0x06
OFF OFF OFF ON Color 80x25 (5153) 0111 0x07
ON ON ON OFF Enhanced Color - Normal Mode (5154) 1000 0x08
OFF ON ON OFF Enhanced Color - Enhanced Mode (5154) 1001 0x09
0 = Switch closed (ON);
1 = Switch open (OFF). */

View File

@@ -39,7 +39,7 @@
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License

View File

@@ -74,7 +74,7 @@ static video_timings_t timing_genius = { .type = VIDEO_ISA, .write_b = 8, .write
* Two card-specific registers control text and graphics display:
*
* 03B0: Control register.
* Bit 0: Map all graphics framebuffer into memory.
* Bit 0: Map all graphics framebuffer into memory.
* Bit 2: Unknown. Set by GMC /M; cleared by mode set or GMC /T.
* Bit 4: Set for CGA-compatible graphics, clear for native graphics.
* Bit 5: Set for black on white, clear for white on black.
@@ -404,13 +404,13 @@ genius_textline(genius_t *genius, uint8_t background, int mda, int cols80)
charh = 15 - (genius->genius_charh & 3);
#if 0
if (genius->genius_charh & 0x10) {
row = ((dl >> 1) / charh);
sc = ((dl >> 1) % charh);
} else {
row = (dl / charh);
sc = (dl % charh);
}
if (genius->genius_charh & 0x10) {
row = ((dl >> 1) / charh);
sc = ((dl >> 1) % charh);
} else {
row = (dl / charh);
sc = (dl % charh);
}
#else
row = (dl / charh);
sc = (dl % charh);
@@ -449,10 +449,10 @@ genius_textline(genius_t *genius, uint8_t background, int mda, int cols80)
for (int x = 0; x < w; x++) {
#if 0
if ((genius->genius_charh & 0x10) && ((addr + 2 * x) > 0x0FFF))
chr = 0x00;
if ((genius->genius_charh & 0x10) && ((addr + 2 * x + 1) > 0x0FFF))
attr = 0x00;
if ((genius->genius_charh & 0x10) && ((addr + 2 * x) > 0x0FFF))
chr = 0x00;
if ((genius->genius_charh & 0x10) && ((addr + 2 * x + 1) > 0x0FFF))
attr = 0x00;
#endif
chr = framebuf[(addr + 2 * x) & 0x3FFF];
attr = framebuf[(addr + 2 * x + 1) & 0x3FFF];

View File

@@ -49,9 +49,9 @@ ics2494_log(const char *fmt, ...)
#endif
float
ics2494_getclock(int clock, void *p)
ics2494_getclock(int clock, void *priv)
{
ics2494_t *ics2494 = (ics2494_t *) p;
const ics2494_t *ics2494 = (ics2494_t *) priv;
if (clock > 15)
clock = 15;
@@ -142,6 +142,9 @@ ics2494_init(const device_t *info)
ics2494->freq[0xe] = 75000000.0;
ics2494->freq[0xf] = 94500000.0;
break;
default:
break;
}
return ics2494;

View File

@@ -84,8 +84,8 @@ ogc_out(uint16_t addr, uint8_t val, void *priv)
{
ogc_t *ogc = (ogc_t *) priv;
// if (addr >= 0x3c0 && addr <= 0x3cf){
// addr = addr + 16;
// if (addr >= 0x3c0 && addr <= 0x3cf) {
// addr = addr + 16;
// }
switch (addr) {
@@ -110,8 +110,8 @@ ogc_in(uint16_t addr, void *priv)
{
ogc_t *ogc = (ogc_t *) priv;
// if (addr >= 0x3c0 && addr <= 0x3cf){
// addr = addr + 16;
// if (addr >= 0x3c0 && addr <= 0x3cf) {
// addr = addr + 16;
// }
uint8_t ret = 0xff;

View File

@@ -747,7 +747,7 @@ pgc_plot(pgc_t *dev, uint16_t x, uint16_t y)
* Draw a line (using raster coordinates).
*
* Bresenham's Algorithm from:
* <https://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#C>
* <https://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#C>
*
* The line pattern mask to use is passed in. Return value is the
* line pattern mask, rotated by the number of points drawn.
@@ -1384,11 +1384,11 @@ hndl_window(pgc_t *dev)
* core commands (listed below) and subclass commands (listed in the clone).
*
* Each row has five parameters:
* ASCII-mode command
* Hex-mode command
* Function that executes this command
* Function that parses this command when building a command list
* Parameter for the parse function
* ASCII-mode command
* Hex-mode command
* Function that executes this command
* Function that parses this command when building a command list
* Parameter for the parse function
*
* TODO: This list omits numerous commands present in a genuine PGC
* (ARC, AREA, AREABC, BUFFER, CIRCLE etc etc).

View File

@@ -109,8 +109,8 @@
* 0x2DC: On write: Resets the NMI.
* 0x2DD: Memory paging. The memory from 0xC1800 to 0xC1FFF can be either:
*
* > ROM: A 128 character 8x16 font for use in graphics modes
* > RAM: Use by the video BIOS to hold its settings.
* > ROM: A 128 character 8x16 font for use in graphics modes
* > RAM: Use by the video BIOS to hold its settings.
*
* Reading port 2DD switches to ROM. Bit 7 of the value read gives the
* previous paging state: bit 7 set if ROM was paged, clear if RAM was

View File

@@ -110,11 +110,11 @@ svga_set_override(svga_t *svga, int val)
void
svga_out(uint16_t addr, uint8_t val, void *priv)
{
svga_t *svga = (svga_t *) priv;
svga_t *svga = (svga_t *) priv;
ibm8514_t *dev = &svga->dev8514;
xga_t *xga = &svga->xga;
uint8_t o;
uint8_t index;
xga_t *xga = &svga->xga;
uint8_t o;
uint8_t index;
switch (addr) {
case 0x2ea:
@@ -150,6 +150,9 @@ svga_out(uint16_t addr, uint8_t val, void *priv)
dev->dac_pos = 0;
dev->dac_addr = (dev->dac_addr + 1) & 0xff;
break;
default:
break;
}
break;
@@ -274,7 +277,7 @@ svga_out(uint16_t addr, uint8_t val, void *priv)
break;
case 2:
index = svga->dac_addr & 255;
svga->dac_b = val;
svga->dac_b = val;
svga->vgapal[index].r = svga->dac_r;
svga->vgapal[index].g = svga->dac_g;
svga->vgapal[index].b = svga->dac_b;
@@ -353,10 +356,10 @@ svga_out(uint16_t addr, uint8_t val, void *priv)
uint8_t
svga_in(uint16_t addr, void *priv)
{
svga_t *svga = (svga_t *) priv;
svga_t *svga = (svga_t *) priv;
ibm8514_t *dev = &svga->dev8514;
uint8_t index;
uint8_t ret = 0xff;
uint8_t index;
uint8_t ret = 0xff;
switch (addr) {
case 0x2ea:
@@ -394,8 +397,8 @@ svga_in(uint16_t addr, void *priv)
ret = svga->vgapal[index].b & 0x3f;
break;
default:
break;
default:
break;
}
break;
@@ -537,12 +540,11 @@ svga_set_ramdac_type(svga_t *svga, int type)
void
svga_recalctimings(svga_t *svga)
{
ibm8514_t *dev = &svga->dev8514;
xga_t *xga = &svga->xga;
double crtcconst;
double _dispontime;
double _dispofftime;
double disptime;
const ibm8514_t *dev = &svga->dev8514;
double crtcconst;
double _dispontime;
double _dispofftime;
double disptime;
svga->vtotal = svga->crtc[6];
svga->dispend = svga->crtc[0x12];
@@ -812,7 +814,7 @@ svga_poll(void *priv)
{
svga_t *svga = (svga_t *) priv;
ibm8514_t *dev = &svga->dev8514;
xga_t *xga = &svga->xga;
xga_t *xga = &svga->xga;
uint32_t x;
uint32_t blink_delay;
int wx;
@@ -919,7 +921,7 @@ svga_poll(void *priv)
svga->con = 0;
if (svga->dispon) {
if (svga->linedbl && !svga->linecountff) {
svga->linecountff = 1;
svga->linecountff = 1;
svga->ma = svga->maback;
} else if (svga->sc == svga->rowcount) {
svga->linecountff = 0;
@@ -1220,12 +1222,12 @@ svga_decode_addr(svga_t *svga, uint32_t addr, int write)
static __inline void
svga_write_common(uint32_t addr, uint8_t val, uint8_t linear, void *priv)
{
svga_t *svga = (svga_t *) priv;
xga_t *xga = &svga->xga;
svga_t *svga = (svga_t *) priv;
xga_t *xga = &svga->xga;
int writemask2 = svga->writemask;
int reset_wm = 0;
latch_t vall;
uint8_t wm = svga->writemask;
uint8_t wm = svga->writemask;
uint8_t count;
uint8_t i;
@@ -1437,7 +1439,7 @@ static __inline uint8_t
svga_read_common(uint32_t addr, uint8_t linear, void *priv)
{
svga_t *svga = (svga_t *) priv;
xga_t *xga = &svga->xga;
xga_t *xga = &svga->xga;
uint32_t latch_addr = 0;
int readplane = svga->readplane;
uint8_t count;

View File

@@ -81,7 +81,7 @@ video_cards[] = {
{ &vid_internal_device },
{ &atiega_device },
{ &mach8_isa_device, VIDEO_FLAG_TYPE_8514 },
{ &mach32_isa_device, VIDEO_FLAG_TYPE_8514 },
{ &mach32_isa_device, VIDEO_FLAG_TYPE_8514 },
{ &mach64gx_isa_device },
{ &ati28800k_device },
{ &ati18800_vga88_device },
@@ -159,7 +159,7 @@ video_cards[] = {
{ &gd5428_mca_device },
{ &et4000_mca_device },
{ &radius_svga_multiview_mca_device },
{ &mach32_pci_device, VIDEO_FLAG_TYPE_8514 },
{ &mach32_pci_device, VIDEO_FLAG_TYPE_8514 },
{ &mach64gx_pci_device },
{ &mach64vt2_device },
{ &et4000w32p_videomagic_revb_pci_device },
@@ -217,7 +217,7 @@ video_cards[] = {
{ &voodoo_3_1000_device },
{ &voodoo_3_2000_device },
{ &voodoo_3_3000_device },
{ &mach32_vlb_device, VIDEO_FLAG_TYPE_8514 },
{ &mach32_vlb_device, VIDEO_FLAG_TYPE_8514 },
{ &mach64gx_vlb_device },
{ &et4000w32i_vlb_device },
{ &et4000w32p_videomagic_revb_vlb_device },

View File

@@ -1102,8 +1102,8 @@ tgui_ext_linear_write(uint32_t addr, uint8_t val, void *priv)
{
svga_t *svga = (svga_t *) priv;
tgui_t *tgui = (tgui_t *) svga->priv;
int c;
int bpp = (tgui->ext_gdc_regs[0] & EXT_CTRL_16BIT);
int c;
int bpp = (tgui->ext_gdc_regs[0] & EXT_CTRL_16BIT);
uint8_t fg[2] = { tgui->ext_gdc_regs[4], tgui->ext_gdc_regs[5] };
uint8_t bg[2] = { tgui->ext_gdc_regs[1], tgui->ext_gdc_regs[2] };
uint8_t mask = tgui->ext_gdc_regs[7];
@@ -1168,8 +1168,8 @@ tgui_ext_linear_writew(uint32_t addr, uint16_t val, void *priv)
{
svga_t *svga = (svga_t *) priv;
tgui_t *tgui = (tgui_t *) svga->priv;
int c;
int bpp = (tgui->ext_gdc_regs[0] & EXT_CTRL_16BIT);
int c;
int bpp = (tgui->ext_gdc_regs[0] & EXT_CTRL_16BIT);
uint8_t fg[2] = { tgui->ext_gdc_regs[4], tgui->ext_gdc_regs[5] };
uint8_t bg[2] = { tgui->ext_gdc_regs[1], tgui->ext_gdc_regs[2] };
uint16_t mask = (tgui->ext_gdc_regs[7] << 8) | tgui->ext_gdc_regs[8];

View File

@@ -91,7 +91,7 @@ vid_out(uint16_t addr, uint8_t val, void *priv)
#if 0
if (((addr & 0xfff0) == 0x03d0 || (addr & 0xfff0) == 0x03b0) &&
!(svga->miscout & 1)) addr ^= 0x60;
!(svga->miscout & 1)) addr ^= 0x60;
#endif
switch (addr) {
@@ -151,7 +151,7 @@ vid_in(uint16_t addr, void *priv)
#if 0
if (((addr & 0xfff0) == 0x03d0 || (addr & 0xfff0) == 0x03b0) &&
!(svga->miscout & 1)) addr ^= 0x60;
!(svga->miscout & 1)) addr ^= 0x60;
#endif
switch (addr) {

View File

@@ -1,18 +1,18 @@
/*
* 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.
* 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.
* This file is part of the 86Box distribution.
*
* IBM XGA emulation.
* IBM XGA emulation.
*
*
*
* Authors: TheCollector1995.
* Authors: TheCollector1995.
*
* Copyright 2022 TheCollector1995.
* Copyright 2022 TheCollector1995.
*/
#include <stdio.h>
#include <stdint.h>
@@ -3079,6 +3079,7 @@ xga_init(const device_t *info)
xga_t *xga = &svga->xga;
FILE *f;
uint8_t *rom = NULL;
size_t res;
xga->ext_mem_addr = device_get_config_hex16("ext_mem_addr");
xga->instance_isa = device_get_config_int("instance");
@@ -3103,7 +3104,7 @@ xga_init(const device_t *info)
rom = malloc(xga->bios_rom.sz);
memset(rom, 0xff, xga->bios_rom.sz);
(void) fread(rom, xga->bios_rom.sz, 1, f);
res = fread(rom, xga->bios_rom.sz, 1, f);
(void) fclose(f);
xga->bios_rom.rom = rom;

View File

@@ -106,7 +106,7 @@ void *__cdecl (*video_copy)(void *_Dst, const void *_Src, size_t _Size) = memcpy
void *(*video_copy)(void *__restrict, const void *__restrict, size_t);
#endif
PALETTE cgapal = {
PALETTE cgapal = {
{0,0,0}, {0,42,0}, {42,0,0}, {42,21,0},
{0,0,0}, {0,42,42}, {42,0,42}, {42,42,42},
{0,0,0}, {21,63,21}, {63,21,21}, {63,63,21},
@@ -127,109 +127,108 @@ PALETTE cgapal = {
{0,0,0}, {0,63,63}, {63,0,0}, {63,63,63},
{0,0,0}, {0,63,63}, {63,0,0}, {63,63,63},
};
PALETTE cgapal_mono[6] = {
{ /* 0 - green, 4-color-optimized contrast. */
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x17,0x05},
{0x01,0x1a,0x06},{0x02,0x28,0x09},{0x02,0x2c,0x0a},
{0x03,0x39,0x0d},{0x03,0x3c,0x0e},{0x00,0x07,0x01},
{0x01,0x13,0x04},{0x01,0x1f,0x07},{0x01,0x23,0x08},
{0x02,0x31,0x0b},{0x02,0x35,0x0c},{0x05,0x3f,0x11},{0x0d,0x3f,0x17},
PALETTE cgapal_mono[6] = {
{ /* 0 - green, 4-color-optimized contrast. */
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x17,0x05},
{0x01,0x1a,0x06},{0x02,0x28,0x09},{0x02,0x2c,0x0a},
{0x03,0x39,0x0d},{0x03,0x3c,0x0e},{0x00,0x07,0x01},
{0x01,0x13,0x04},{0x01,0x1f,0x07},{0x01,0x23,0x08},
{0x02,0x31,0x0b},{0x02,0x35,0x0c},{0x05,0x3f,0x11},{0x0d,0x3f,0x17},
},
{ /* 1 - green, 16-color-optimized contrast. */
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x15,0x05},
{0x01,0x17,0x05},{0x01,0x21,0x08},{0x01,0x24,0x08},
{0x02,0x2e,0x0b},{0x02,0x31,0x0b},{0x01,0x22,0x08},
{0x02,0x28,0x09},{0x02,0x30,0x0b},{0x02,0x32,0x0c},
{0x03,0x39,0x0d},{0x03,0x3b,0x0e},{0x09,0x3f,0x14},{0x0d,0x3f,0x17},
{ /* 1 - green, 16-color-optimized contrast. */
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x15,0x05},
{0x01,0x17,0x05},{0x01,0x21,0x08},{0x01,0x24,0x08},
{0x02,0x2e,0x0b},{0x02,0x31,0x0b},{0x01,0x22,0x08},
{0x02,0x28,0x09},{0x02,0x30,0x0b},{0x02,0x32,0x0c},
{0x03,0x39,0x0d},{0x03,0x3b,0x0e},{0x09,0x3f,0x14},{0x0d,0x3f,0x17},
},
{ /* 2 - amber, 4-color-optimized contrast. */
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x20,0x0b,0x00},
{0x24,0x0d,0x00},{0x33,0x18,0x00},{0x37,0x1b,0x00},
{0x3f,0x26,0x01},{0x3f,0x2b,0x06},{0x0b,0x02,0x00},
{0x1b,0x08,0x00},{0x29,0x11,0x00},{0x2e,0x14,0x00},
{0x3b,0x1e,0x00},{0x3e,0x21,0x00},{0x3f,0x32,0x0a},{0x3f,0x38,0x0d},
{ /* 2 - amber, 4-color-optimized contrast. */
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x20,0x0b,0x00},
{0x24,0x0d,0x00},{0x33,0x18,0x00},{0x37,0x1b,0x00},
{0x3f,0x26,0x01},{0x3f,0x2b,0x06},{0x0b,0x02,0x00},
{0x1b,0x08,0x00},{0x29,0x11,0x00},{0x2e,0x14,0x00},
{0x3b,0x1e,0x00},{0x3e,0x21,0x00},{0x3f,0x32,0x0a},{0x3f,0x38,0x0d},
},
{ /* 3 - amber, 16-color-optimized contrast. */
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x1e,0x09,0x00},
{0x21,0x0b,0x00},{0x2b,0x12,0x00},{0x2f,0x15,0x00},
{0x38,0x1c,0x00},{0x3b,0x1e,0x00},{0x2c,0x13,0x00},
{0x32,0x17,0x00},{0x3a,0x1e,0x00},{0x3c,0x1f,0x00},
{0x3f,0x27,0x01},{0x3f,0x2a,0x04},{0x3f,0x36,0x0c},{0x3f,0x38,0x0d},
{ /* 3 - amber, 16-color-optimized contrast. */
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x1e,0x09,0x00},
{0x21,0x0b,0x00},{0x2b,0x12,0x00},{0x2f,0x15,0x00},
{0x38,0x1c,0x00},{0x3b,0x1e,0x00},{0x2c,0x13,0x00},
{0x32,0x17,0x00},{0x3a,0x1e,0x00},{0x3c,0x1f,0x00},
{0x3f,0x27,0x01},{0x3f,0x2a,0x04},{0x3f,0x36,0x0c},{0x3f,0x38,0x0d},
},
{ /* 4 - grey, 4-color-optimized contrast. */
{0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x15,0x17,0x18},
{0x18,0x1a,0x1b},{0x24,0x25,0x25},{0x27,0x28,0x28},
{0x33,0x34,0x32},{0x37,0x38,0x35},{0x09,0x0a,0x0b},
{0x11,0x12,0x13},{0x1c,0x1e,0x1e},{0x20,0x22,0x22},
{0x2c,0x2d,0x2c},{0x2f,0x30,0x2f},{0x3c,0x3c,0x38},{0x3f,0x3f,0x3b},
{ /* 4 - grey, 4-color-optimized contrast. */
{0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x15,0x17,0x18},
{0x18,0x1a,0x1b},{0x24,0x25,0x25},{0x27,0x28,0x28},
{0x33,0x34,0x32},{0x37,0x38,0x35},{0x09,0x0a,0x0b},
{0x11,0x12,0x13},{0x1c,0x1e,0x1e},{0x20,0x22,0x22},
{0x2c,0x2d,0x2c},{0x2f,0x30,0x2f},{0x3c,0x3c,0x38},{0x3f,0x3f,0x3b},
},
{ /* 5 - grey, 16-color-optimized contrast. */
{0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x13,0x14,0x15},
{0x15,0x17,0x18},{0x1e,0x20,0x20},{0x20,0x22,0x22},
{0x29,0x2a,0x2a},{0x2c,0x2d,0x2c},{0x1f,0x21,0x21},
{0x23,0x25,0x25},{0x2b,0x2c,0x2b},{0x2d,0x2e,0x2d},
{0x34,0x35,0x33},{0x37,0x37,0x34},{0x3e,0x3e,0x3a},{0x3f,0x3f,0x3b},
{ /* 5 - grey, 16-color-optimized contrast. */
{0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x13,0x14,0x15},
{0x15,0x17,0x18},{0x1e,0x20,0x20},{0x20,0x22,0x22},
{0x29,0x2a,0x2a},{0x2c,0x2d,0x2c},{0x1f,0x21,0x21},
{0x23,0x25,0x25},{0x2b,0x2c,0x2b},{0x2d,0x2e,0x2d},
{0x34,0x35,0x33},{0x37,0x37,0x34},{0x3e,0x3e,0x3a},{0x3f,0x3f,0x3b},
}
};
const uint32_t shade[5][256] =
{
{0}, // RGB Color (unused)
{0}, // RGB Grayscale (unused)
{ // Amber monitor
0x000000, 0x060000, 0x090000, 0x0d0000, 0x100000, 0x120100, 0x150100, 0x170100, 0x1a0100, 0x1c0100, 0x1e0200, 0x210200, 0x230200, 0x250300, 0x270300, 0x290300,
0x2b0400, 0x2d0400, 0x2f0400, 0x300500, 0x320500, 0x340500, 0x360600, 0x380600, 0x390700, 0x3b0700, 0x3d0700, 0x3f0800, 0x400800, 0x420900, 0x440900, 0x450a00,
0x470a00, 0x480b00, 0x4a0b00, 0x4c0c00, 0x4d0c00, 0x4f0d00, 0x500d00, 0x520e00, 0x530e00, 0x550f00, 0x560f00, 0x581000, 0x591000, 0x5b1100, 0x5c1200, 0x5e1200,
0x5f1300, 0x601300, 0x621400, 0x631500, 0x651500, 0x661600, 0x671600, 0x691700, 0x6a1800, 0x6c1800, 0x6d1900, 0x6e1a00, 0x701a00, 0x711b00, 0x721c00, 0x741c00,
0x751d00, 0x761e00, 0x781e00, 0x791f00, 0x7a2000, 0x7c2000, 0x7d2100, 0x7e2200, 0x7f2300, 0x812300, 0x822400, 0x832500, 0x842600, 0x862600, 0x872700, 0x882800,
0x8a2900, 0x8b2900, 0x8c2a00, 0x8d2b00, 0x8e2c00, 0x902c00, 0x912d00, 0x922e00, 0x932f00, 0x953000, 0x963000, 0x973100, 0x983200, 0x993300, 0x9b3400, 0x9c3400,
0x9d3500, 0x9e3600, 0x9f3700, 0xa03800, 0xa23900, 0xa33a00, 0xa43a00, 0xa53b00, 0xa63c00, 0xa73d00, 0xa93e00, 0xaa3f00, 0xab4000, 0xac4000, 0xad4100, 0xae4200,
0xaf4300, 0xb14400, 0xb24500, 0xb34600, 0xb44700, 0xb54800, 0xb64900, 0xb74a00, 0xb94a00, 0xba4b00, 0xbb4c00, 0xbc4d00, 0xbd4e00, 0xbe4f00, 0xbf5000, 0xc05100,
0xc15200, 0xc25300, 0xc45400, 0xc55500, 0xc65600, 0xc75700, 0xc85800, 0xc95900, 0xca5a00, 0xcb5b00, 0xcc5c00, 0xcd5d00, 0xce5e00, 0xcf5f00, 0xd06000, 0xd26101,
0xd36201, 0xd46301, 0xd56401, 0xd66501, 0xd76601, 0xd86701, 0xd96801, 0xda6901, 0xdb6a01, 0xdc6b01, 0xdd6c01, 0xde6d01, 0xdf6e01, 0xe06f01, 0xe17001, 0xe27201,
0xe37301, 0xe47401, 0xe57501, 0xe67602, 0xe77702, 0xe87802, 0xe97902, 0xeb7a02, 0xec7b02, 0xed7c02, 0xee7e02, 0xef7f02, 0xf08002, 0xf18103, 0xf28203, 0xf38303,
0xf48403, 0xf58503, 0xf68703, 0xf78803, 0xf88903, 0xf98a04, 0xfa8b04, 0xfb8c04, 0xfc8d04, 0xfd8f04, 0xfe9005, 0xff9105, 0xff9205, 0xff9305, 0xff9405, 0xff9606,
0xff9706, 0xff9806, 0xff9906, 0xff9a07, 0xff9b07, 0xff9d07, 0xff9e08, 0xff9f08, 0xffa008, 0xffa109, 0xffa309, 0xffa409, 0xffa50a, 0xffa60a, 0xffa80a, 0xffa90b,
0xffaa0b, 0xffab0c, 0xffac0c, 0xffae0d, 0xffaf0d, 0xffb00e, 0xffb10e, 0xffb30f, 0xffb40f, 0xffb510, 0xffb610, 0xffb811, 0xffb912, 0xffba12, 0xffbb13, 0xffbd14,
0xffbe14, 0xffbf15, 0xffc016, 0xffc217, 0xffc317, 0xffc418, 0xffc619, 0xffc71a, 0xffc81b, 0xffca1c, 0xffcb1d, 0xffcc1e, 0xffcd1f, 0xffcf20, 0xffd021, 0xffd122,
0xffd323, 0xffd424, 0xffd526, 0xffd727, 0xffd828, 0xffd92a, 0xffdb2b, 0xffdc2c, 0xffdd2e, 0xffdf2f, 0xffe031, 0xffe133, 0xffe334, 0xffe436, 0xffe538, 0xffe739
},
{ // Green monitor
0x000000, 0x000400, 0x000700, 0x000900, 0x000b00, 0x000d00, 0x000f00, 0x001100, 0x001300, 0x001500, 0x001600, 0x001800, 0x001a00, 0x001b00, 0x001d00, 0x001e00,
0x002000, 0x002100, 0x002300, 0x002400, 0x002601, 0x002701, 0x002901, 0x002a01, 0x002b01, 0x002d01, 0x002e01, 0x002f01, 0x003101, 0x003201, 0x003301, 0x003401,
0x003601, 0x003702, 0x003802, 0x003902, 0x003b02, 0x003c02, 0x003d02, 0x003e02, 0x004002, 0x004102, 0x004203, 0x004303, 0x004403, 0x004503, 0x004703, 0x004803,
0x004903, 0x004a03, 0x004b04, 0x004c04, 0x004d04, 0x004e04, 0x005004, 0x005104, 0x005205, 0x005305, 0x005405, 0x005505, 0x005605, 0x005705, 0x005806, 0x005906,
0x005a06, 0x005b06, 0x005d06, 0x005e07, 0x005f07, 0x006007, 0x006107, 0x006207, 0x006308, 0x006408, 0x006508, 0x006608, 0x006708, 0x006809, 0x006909, 0x006a09,
0x006b09, 0x016c0a, 0x016d0a, 0x016e0a, 0x016f0a, 0x01700b, 0x01710b, 0x01720b, 0x01730b, 0x01740c, 0x01750c, 0x01760c, 0x01770c, 0x01780d, 0x01790d, 0x017a0d,
0x017b0d, 0x017b0e, 0x017c0e, 0x017d0e, 0x017e0f, 0x017f0f, 0x01800f, 0x018110, 0x028210, 0x028310, 0x028410, 0x028511, 0x028611, 0x028711, 0x028812, 0x028912,
0x028a12, 0x028a13, 0x028b13, 0x028c13, 0x028d14, 0x028e14, 0x038f14, 0x039015, 0x039115, 0x039215, 0x039316, 0x039416, 0x039417, 0x039517, 0x039617, 0x039718,
0x049818, 0x049918, 0x049a19, 0x049b19, 0x049c19, 0x049c1a, 0x049d1a, 0x049e1b, 0x059f1b, 0x05a01b, 0x05a11c, 0x05a21c, 0x05a31c, 0x05a31d, 0x05a41d, 0x06a51e,
0x06a61e, 0x06a71f, 0x06a81f, 0x06a920, 0x06aa20, 0x07aa21, 0x07ab21, 0x07ac21, 0x07ad22, 0x07ae22, 0x08af23, 0x08b023, 0x08b024, 0x08b124, 0x08b225, 0x09b325,
0x09b426, 0x09b526, 0x09b527, 0x0ab627, 0x0ab728, 0x0ab828, 0x0ab929, 0x0bba29, 0x0bba2a, 0x0bbb2a, 0x0bbc2b, 0x0cbd2b, 0x0cbe2c, 0x0cbf2c, 0x0dbf2d, 0x0dc02d,
0x0dc12e, 0x0ec22e, 0x0ec32f, 0x0ec42f, 0x0fc430, 0x0fc530, 0x0fc631, 0x10c731, 0x10c832, 0x10c932, 0x11c933, 0x11ca33, 0x11cb34, 0x12cc35, 0x12cd35, 0x12cd36,
0x13ce36, 0x13cf37, 0x13d037, 0x14d138, 0x14d139, 0x14d239, 0x15d33a, 0x15d43a, 0x16d43b, 0x16d53b, 0x17d63c, 0x17d73d, 0x17d83d, 0x18d83e, 0x18d93e, 0x19da3f,
0x19db40, 0x1adc40, 0x1adc41, 0x1bdd41, 0x1bde42, 0x1cdf43, 0x1ce043, 0x1de044, 0x1ee145, 0x1ee245, 0x1fe346, 0x1fe446, 0x20e447, 0x20e548, 0x21e648, 0x22e749,
0x22e74a, 0x23e84a, 0x23e94b, 0x24ea4c, 0x25ea4c, 0x25eb4d, 0x26ec4e, 0x27ed4e, 0x27ee4f, 0x28ee50, 0x29ef50, 0x29f051, 0x2af152, 0x2bf153, 0x2cf253, 0x2cf354,
0x2df455, 0x2ef455, 0x2ff556, 0x2ff657, 0x30f758, 0x31f758, 0x32f859, 0x32f95a, 0x33fa5a, 0x34fa5b, 0x35fb5c, 0x36fc5d, 0x37fd5d, 0x38fd5e, 0x38fe5f, 0x39ff60
},
{ // White monitor
0x000000, 0x010102, 0x020203, 0x020304, 0x030406, 0x040507, 0x050608, 0x060709, 0x07080a, 0x08090c, 0x080a0d, 0x090b0e, 0x0a0c0f, 0x0b0d10, 0x0c0e11, 0x0d0f12,
0x0e1013, 0x0f1115, 0x101216, 0x111317, 0x121418, 0x121519, 0x13161a, 0x14171b, 0x15181c, 0x16191d, 0x171a1e, 0x181b1f, 0x191c20, 0x1a1d21, 0x1b1e22, 0x1c1f23,
0x1d2024, 0x1e2125, 0x1f2226, 0x202327, 0x212428, 0x222529, 0x22262b, 0x23272c, 0x24282d, 0x25292e, 0x262a2f, 0x272b30, 0x282c30, 0x292d31, 0x2a2e32, 0x2b2f33,
0x2c3034, 0x2d3035, 0x2e3136, 0x2f3237, 0x303338, 0x313439, 0x32353a, 0x33363b, 0x34373c, 0x35383d, 0x36393e, 0x373a3f, 0x383b40, 0x393c41, 0x3a3d42, 0x3b3e43,
0x3c3f44, 0x3d4045, 0x3e4146, 0x3f4247, 0x404348, 0x414449, 0x42454a, 0x43464b, 0x44474c, 0x45484d, 0x46494d, 0x474a4e, 0x484b4f, 0x484c50, 0x494d51, 0x4a4e52,
0x4b4f53, 0x4c5054, 0x4d5155, 0x4e5256, 0x4f5357, 0x505458, 0x515559, 0x52565a, 0x53575b, 0x54585b, 0x55595c, 0x565a5d, 0x575b5e, 0x585c5f, 0x595d60, 0x5a5e61,
0x5b5f62, 0x5c6063, 0x5d6164, 0x5e6265, 0x5f6366, 0x606466, 0x616567, 0x626668, 0x636769, 0x64686a, 0x65696b, 0x666a6c, 0x676b6d, 0x686c6e, 0x696d6f, 0x6a6e70,
0x6b6f70, 0x6c7071, 0x6d7172, 0x6f7273, 0x707374, 0x707475, 0x717576, 0x727677, 0x747778, 0x757879, 0x767979, 0x777a7a, 0x787b7b, 0x797c7c, 0x7a7d7d, 0x7b7e7e,
0x7c7f7f, 0x7d8080, 0x7e8181, 0x7f8281, 0x808382, 0x818483, 0x828584, 0x838685, 0x848786, 0x858887, 0x868988, 0x878a89, 0x888b89, 0x898c8a, 0x8a8d8b, 0x8b8e8c,
0x8c8f8d, 0x8d8f8e, 0x8e908f, 0x8f9190, 0x909290, 0x919391, 0x929492, 0x939593, 0x949694, 0x959795, 0x969896, 0x979997, 0x989a98, 0x999b98, 0x9a9c99, 0x9b9d9a,
0x9c9e9b, 0x9d9f9c, 0x9ea09d, 0x9fa19e, 0xa0a29f, 0xa1a39f, 0xa2a4a0, 0xa3a5a1, 0xa4a6a2, 0xa6a7a3, 0xa7a8a4, 0xa8a9a5, 0xa9aaa5, 0xaaaba6, 0xabaca7, 0xacada8,
0xadaea9, 0xaeafaa, 0xafb0ab, 0xb0b1ac, 0xb1b2ac, 0xb2b3ad, 0xb3b4ae, 0xb4b5af, 0xb5b6b0, 0xb6b7b1, 0xb7b8b2, 0xb8b9b2, 0xb9bab3, 0xbabbb4, 0xbbbcb5, 0xbcbdb6,
0xbdbeb7, 0xbebfb8, 0xbfc0b8, 0xc0c1b9, 0xc1c2ba, 0xc2c3bb, 0xc3c4bc, 0xc5c5bd, 0xc6c6be, 0xc7c7be, 0xc8c8bf, 0xc9c9c0, 0xcacac1, 0xcbcbc2, 0xccccc3, 0xcdcdc3,
0xcecec4, 0xcfcfc5, 0xd0d0c6, 0xd1d1c7, 0xd2d2c8, 0xd3d3c9, 0xd4d4c9, 0xd5d5ca, 0xd6d6cb, 0xd7d7cc, 0xd8d8cd, 0xd9d9ce, 0xdadacf, 0xdbdbcf, 0xdcdcd0, 0xdeddd1,
0xdfded2, 0xe0dfd3, 0xe1e0d4, 0xe2e1d4, 0xe3e2d5, 0xe4e3d6, 0xe5e4d7, 0xe6e5d8, 0xe7e6d9, 0xe8e7d9, 0xe9e8da, 0xeae9db, 0xebeadc, 0xecebdd, 0xedecde, 0xeeeddf,
0xefeedf, 0xf0efe0, 0xf1f0e1, 0xf2f1e2, 0xf3f2e3, 0xf4f3e3, 0xf6f3e4, 0xf7f4e5, 0xf8f5e6, 0xf9f6e7, 0xfaf7e8, 0xfbf8e9, 0xfcf9e9, 0xfdfaea, 0xfefbeb, 0xfffcec
}
const uint32_t shade[5][256] = {
{0}, // RGB Color (unused)
{0}, // RGB Grayscale (unused)
{ // Amber monitor
0x000000, 0x060000, 0x090000, 0x0d0000, 0x100000, 0x120100, 0x150100, 0x170100, 0x1a0100, 0x1c0100, 0x1e0200, 0x210200, 0x230200, 0x250300, 0x270300, 0x290300,
0x2b0400, 0x2d0400, 0x2f0400, 0x300500, 0x320500, 0x340500, 0x360600, 0x380600, 0x390700, 0x3b0700, 0x3d0700, 0x3f0800, 0x400800, 0x420900, 0x440900, 0x450a00,
0x470a00, 0x480b00, 0x4a0b00, 0x4c0c00, 0x4d0c00, 0x4f0d00, 0x500d00, 0x520e00, 0x530e00, 0x550f00, 0x560f00, 0x581000, 0x591000, 0x5b1100, 0x5c1200, 0x5e1200,
0x5f1300, 0x601300, 0x621400, 0x631500, 0x651500, 0x661600, 0x671600, 0x691700, 0x6a1800, 0x6c1800, 0x6d1900, 0x6e1a00, 0x701a00, 0x711b00, 0x721c00, 0x741c00,
0x751d00, 0x761e00, 0x781e00, 0x791f00, 0x7a2000, 0x7c2000, 0x7d2100, 0x7e2200, 0x7f2300, 0x812300, 0x822400, 0x832500, 0x842600, 0x862600, 0x872700, 0x882800,
0x8a2900, 0x8b2900, 0x8c2a00, 0x8d2b00, 0x8e2c00, 0x902c00, 0x912d00, 0x922e00, 0x932f00, 0x953000, 0x963000, 0x973100, 0x983200, 0x993300, 0x9b3400, 0x9c3400,
0x9d3500, 0x9e3600, 0x9f3700, 0xa03800, 0xa23900, 0xa33a00, 0xa43a00, 0xa53b00, 0xa63c00, 0xa73d00, 0xa93e00, 0xaa3f00, 0xab4000, 0xac4000, 0xad4100, 0xae4200,
0xaf4300, 0xb14400, 0xb24500, 0xb34600, 0xb44700, 0xb54800, 0xb64900, 0xb74a00, 0xb94a00, 0xba4b00, 0xbb4c00, 0xbc4d00, 0xbd4e00, 0xbe4f00, 0xbf5000, 0xc05100,
0xc15200, 0xc25300, 0xc45400, 0xc55500, 0xc65600, 0xc75700, 0xc85800, 0xc95900, 0xca5a00, 0xcb5b00, 0xcc5c00, 0xcd5d00, 0xce5e00, 0xcf5f00, 0xd06000, 0xd26101,
0xd36201, 0xd46301, 0xd56401, 0xd66501, 0xd76601, 0xd86701, 0xd96801, 0xda6901, 0xdb6a01, 0xdc6b01, 0xdd6c01, 0xde6d01, 0xdf6e01, 0xe06f01, 0xe17001, 0xe27201,
0xe37301, 0xe47401, 0xe57501, 0xe67602, 0xe77702, 0xe87802, 0xe97902, 0xeb7a02, 0xec7b02, 0xed7c02, 0xee7e02, 0xef7f02, 0xf08002, 0xf18103, 0xf28203, 0xf38303,
0xf48403, 0xf58503, 0xf68703, 0xf78803, 0xf88903, 0xf98a04, 0xfa8b04, 0xfb8c04, 0xfc8d04, 0xfd8f04, 0xfe9005, 0xff9105, 0xff9205, 0xff9305, 0xff9405, 0xff9606,
0xff9706, 0xff9806, 0xff9906, 0xff9a07, 0xff9b07, 0xff9d07, 0xff9e08, 0xff9f08, 0xffa008, 0xffa109, 0xffa309, 0xffa409, 0xffa50a, 0xffa60a, 0xffa80a, 0xffa90b,
0xffaa0b, 0xffab0c, 0xffac0c, 0xffae0d, 0xffaf0d, 0xffb00e, 0xffb10e, 0xffb30f, 0xffb40f, 0xffb510, 0xffb610, 0xffb811, 0xffb912, 0xffba12, 0xffbb13, 0xffbd14,
0xffbe14, 0xffbf15, 0xffc016, 0xffc217, 0xffc317, 0xffc418, 0xffc619, 0xffc71a, 0xffc81b, 0xffca1c, 0xffcb1d, 0xffcc1e, 0xffcd1f, 0xffcf20, 0xffd021, 0xffd122,
0xffd323, 0xffd424, 0xffd526, 0xffd727, 0xffd828, 0xffd92a, 0xffdb2b, 0xffdc2c, 0xffdd2e, 0xffdf2f, 0xffe031, 0xffe133, 0xffe334, 0xffe436, 0xffe538, 0xffe739
},
{ // Green monitor
0x000000, 0x000400, 0x000700, 0x000900, 0x000b00, 0x000d00, 0x000f00, 0x001100, 0x001300, 0x001500, 0x001600, 0x001800, 0x001a00, 0x001b00, 0x001d00, 0x001e00,
0x002000, 0x002100, 0x002300, 0x002400, 0x002601, 0x002701, 0x002901, 0x002a01, 0x002b01, 0x002d01, 0x002e01, 0x002f01, 0x003101, 0x003201, 0x003301, 0x003401,
0x003601, 0x003702, 0x003802, 0x003902, 0x003b02, 0x003c02, 0x003d02, 0x003e02, 0x004002, 0x004102, 0x004203, 0x004303, 0x004403, 0x004503, 0x004703, 0x004803,
0x004903, 0x004a03, 0x004b04, 0x004c04, 0x004d04, 0x004e04, 0x005004, 0x005104, 0x005205, 0x005305, 0x005405, 0x005505, 0x005605, 0x005705, 0x005806, 0x005906,
0x005a06, 0x005b06, 0x005d06, 0x005e07, 0x005f07, 0x006007, 0x006107, 0x006207, 0x006308, 0x006408, 0x006508, 0x006608, 0x006708, 0x006809, 0x006909, 0x006a09,
0x006b09, 0x016c0a, 0x016d0a, 0x016e0a, 0x016f0a, 0x01700b, 0x01710b, 0x01720b, 0x01730b, 0x01740c, 0x01750c, 0x01760c, 0x01770c, 0x01780d, 0x01790d, 0x017a0d,
0x017b0d, 0x017b0e, 0x017c0e, 0x017d0e, 0x017e0f, 0x017f0f, 0x01800f, 0x018110, 0x028210, 0x028310, 0x028410, 0x028511, 0x028611, 0x028711, 0x028812, 0x028912,
0x028a12, 0x028a13, 0x028b13, 0x028c13, 0x028d14, 0x028e14, 0x038f14, 0x039015, 0x039115, 0x039215, 0x039316, 0x039416, 0x039417, 0x039517, 0x039617, 0x039718,
0x049818, 0x049918, 0x049a19, 0x049b19, 0x049c19, 0x049c1a, 0x049d1a, 0x049e1b, 0x059f1b, 0x05a01b, 0x05a11c, 0x05a21c, 0x05a31c, 0x05a31d, 0x05a41d, 0x06a51e,
0x06a61e, 0x06a71f, 0x06a81f, 0x06a920, 0x06aa20, 0x07aa21, 0x07ab21, 0x07ac21, 0x07ad22, 0x07ae22, 0x08af23, 0x08b023, 0x08b024, 0x08b124, 0x08b225, 0x09b325,
0x09b426, 0x09b526, 0x09b527, 0x0ab627, 0x0ab728, 0x0ab828, 0x0ab929, 0x0bba29, 0x0bba2a, 0x0bbb2a, 0x0bbc2b, 0x0cbd2b, 0x0cbe2c, 0x0cbf2c, 0x0dbf2d, 0x0dc02d,
0x0dc12e, 0x0ec22e, 0x0ec32f, 0x0ec42f, 0x0fc430, 0x0fc530, 0x0fc631, 0x10c731, 0x10c832, 0x10c932, 0x11c933, 0x11ca33, 0x11cb34, 0x12cc35, 0x12cd35, 0x12cd36,
0x13ce36, 0x13cf37, 0x13d037, 0x14d138, 0x14d139, 0x14d239, 0x15d33a, 0x15d43a, 0x16d43b, 0x16d53b, 0x17d63c, 0x17d73d, 0x17d83d, 0x18d83e, 0x18d93e, 0x19da3f,
0x19db40, 0x1adc40, 0x1adc41, 0x1bdd41, 0x1bde42, 0x1cdf43, 0x1ce043, 0x1de044, 0x1ee145, 0x1ee245, 0x1fe346, 0x1fe446, 0x20e447, 0x20e548, 0x21e648, 0x22e749,
0x22e74a, 0x23e84a, 0x23e94b, 0x24ea4c, 0x25ea4c, 0x25eb4d, 0x26ec4e, 0x27ed4e, 0x27ee4f, 0x28ee50, 0x29ef50, 0x29f051, 0x2af152, 0x2bf153, 0x2cf253, 0x2cf354,
0x2df455, 0x2ef455, 0x2ff556, 0x2ff657, 0x30f758, 0x31f758, 0x32f859, 0x32f95a, 0x33fa5a, 0x34fa5b, 0x35fb5c, 0x36fc5d, 0x37fd5d, 0x38fd5e, 0x38fe5f, 0x39ff60
},
{ // White monitor
0x000000, 0x010102, 0x020203, 0x020304, 0x030406, 0x040507, 0x050608, 0x060709, 0x07080a, 0x08090c, 0x080a0d, 0x090b0e, 0x0a0c0f, 0x0b0d10, 0x0c0e11, 0x0d0f12,
0x0e1013, 0x0f1115, 0x101216, 0x111317, 0x121418, 0x121519, 0x13161a, 0x14171b, 0x15181c, 0x16191d, 0x171a1e, 0x181b1f, 0x191c20, 0x1a1d21, 0x1b1e22, 0x1c1f23,
0x1d2024, 0x1e2125, 0x1f2226, 0x202327, 0x212428, 0x222529, 0x22262b, 0x23272c, 0x24282d, 0x25292e, 0x262a2f, 0x272b30, 0x282c30, 0x292d31, 0x2a2e32, 0x2b2f33,
0x2c3034, 0x2d3035, 0x2e3136, 0x2f3237, 0x303338, 0x313439, 0x32353a, 0x33363b, 0x34373c, 0x35383d, 0x36393e, 0x373a3f, 0x383b40, 0x393c41, 0x3a3d42, 0x3b3e43,
0x3c3f44, 0x3d4045, 0x3e4146, 0x3f4247, 0x404348, 0x414449, 0x42454a, 0x43464b, 0x44474c, 0x45484d, 0x46494d, 0x474a4e, 0x484b4f, 0x484c50, 0x494d51, 0x4a4e52,
0x4b4f53, 0x4c5054, 0x4d5155, 0x4e5256, 0x4f5357, 0x505458, 0x515559, 0x52565a, 0x53575b, 0x54585b, 0x55595c, 0x565a5d, 0x575b5e, 0x585c5f, 0x595d60, 0x5a5e61,
0x5b5f62, 0x5c6063, 0x5d6164, 0x5e6265, 0x5f6366, 0x606466, 0x616567, 0x626668, 0x636769, 0x64686a, 0x65696b, 0x666a6c, 0x676b6d, 0x686c6e, 0x696d6f, 0x6a6e70,
0x6b6f70, 0x6c7071, 0x6d7172, 0x6f7273, 0x707374, 0x707475, 0x717576, 0x727677, 0x747778, 0x757879, 0x767979, 0x777a7a, 0x787b7b, 0x797c7c, 0x7a7d7d, 0x7b7e7e,
0x7c7f7f, 0x7d8080, 0x7e8181, 0x7f8281, 0x808382, 0x818483, 0x828584, 0x838685, 0x848786, 0x858887, 0x868988, 0x878a89, 0x888b89, 0x898c8a, 0x8a8d8b, 0x8b8e8c,
0x8c8f8d, 0x8d8f8e, 0x8e908f, 0x8f9190, 0x909290, 0x919391, 0x929492, 0x939593, 0x949694, 0x959795, 0x969896, 0x979997, 0x989a98, 0x999b98, 0x9a9c99, 0x9b9d9a,
0x9c9e9b, 0x9d9f9c, 0x9ea09d, 0x9fa19e, 0xa0a29f, 0xa1a39f, 0xa2a4a0, 0xa3a5a1, 0xa4a6a2, 0xa6a7a3, 0xa7a8a4, 0xa8a9a5, 0xa9aaa5, 0xaaaba6, 0xabaca7, 0xacada8,
0xadaea9, 0xaeafaa, 0xafb0ab, 0xb0b1ac, 0xb1b2ac, 0xb2b3ad, 0xb3b4ae, 0xb4b5af, 0xb5b6b0, 0xb6b7b1, 0xb7b8b2, 0xb8b9b2, 0xb9bab3, 0xbabbb4, 0xbbbcb5, 0xbcbdb6,
0xbdbeb7, 0xbebfb8, 0xbfc0b8, 0xc0c1b9, 0xc1c2ba, 0xc2c3bb, 0xc3c4bc, 0xc5c5bd, 0xc6c6be, 0xc7c7be, 0xc8c8bf, 0xc9c9c0, 0xcacac1, 0xcbcbc2, 0xccccc3, 0xcdcdc3,
0xcecec4, 0xcfcfc5, 0xd0d0c6, 0xd1d1c7, 0xd2d2c8, 0xd3d3c9, 0xd4d4c9, 0xd5d5ca, 0xd6d6cb, 0xd7d7cc, 0xd8d8cd, 0xd9d9ce, 0xdadacf, 0xdbdbcf, 0xdcdcd0, 0xdeddd1,
0xdfded2, 0xe0dfd3, 0xe1e0d4, 0xe2e1d4, 0xe3e2d5, 0xe4e3d6, 0xe5e4d7, 0xe6e5d8, 0xe7e6d9, 0xe8e7d9, 0xe9e8da, 0xeae9db, 0xebeadc, 0xecebdd, 0xedecde, 0xeeeddf,
0xefeedf, 0xf0efe0, 0xf1f0e1, 0xf2f1e2, 0xf3f2e3, 0xf4f3e3, 0xf6f3e4, 0xf7f4e5, 0xf8f5e6, 0xf9f6e7, 0xfaf7e8, 0xfbf8e9, 0xfcf9e9, 0xfdfaea, 0xfefbeb, 0xfffcec
}
};
typedef struct blit_data_struct {

View File

@@ -46,15 +46,6 @@ static int ptr_x;
static int ptr_y;
static int ptr_but;
typedef struct {
int buttons;
int dx;
int dy;
int dwheel;
} MOUSESTATE;
static MOUSESTATE ms;
#ifdef ENABLE_VNC_LOG
int vnc_do_log = ENABLE_VNC_LOG;
@@ -82,26 +73,31 @@ vnc_kbdevent(rfbBool down, rfbKeySym k, rfbClientPtr cl)
vnc_kbinput(down ? 1 : 0, (int) k);
}
void
vnc_mouse_poll(void)
static void
vnc_ptrevent(int but, int x, int y, rfbClientPtr cl)
{
static int b = 0;
if (ms.dx != 0 || ms.dy != 0) {
mouse_x += ms.dx;
mouse_y += ms.dy;
int dx;
int dy;
int b;
ms.dx = 0;
ms.dy = 0;
b = 0x00;
if (but & 0x01)
b |= 0x01;
if (but & 0x02)
b |= 0x04;
if (but & 0x04)
b |= 0x02;
mouse_set_buttons_ex(b);
ptr_but = but;
#if 0
pclog("dx=%d, dy=%d, dwheel=%d\n", mouse_x, mouse_y, mouse_z);
#endif
}
dx = (x - ptr_x) / 0.96; /* TODO: Figure out the correct scale factor for X and Y. */
dy = (y - ptr_y) / 0.96;
if (b != ms.buttons) {
mouse_buttons = ms.buttons;
b = ms.buttons;
}
/* VNC uses absolute positions within the window, no deltas. */
mouse_scale_x(dx, dy);
ptr_x = x;
ptr_y = y;
mouse_x_abs = (double)ptr_x / (double)allowedX;
mouse_y_abs = (double)ptr_y / (double)allowedY;
@@ -110,25 +106,6 @@ vnc_mouse_poll(void)
if (mouse_y_abs > 1.0) mouse_y_abs = 1.0;
if (mouse_x_abs < 0.0) mouse_x_abs = 0.0;
if (mouse_y_abs < 0.0) mouse_y_abs = 0.0;
}
static void
vnc_ptrevent(int but, int x, int y, rfbClientPtr cl)
{
ms.buttons = 0;
if (but & 0x01)
ms.buttons |= 0x01;
if (but & 0x02)
ms.buttons |= 0x04;
if (but & 0x04)
ms.buttons |= 0x02;
ptr_but = but;
/* VNC uses absolute positions within the window, no deltas. */
ms.dx += (x - ptr_x) / 0.96; /* TODO: Figure out the correct scale factor for X and Y. */
ms.dy += (y - ptr_y) / 0.96;
ptr_x = x;
ptr_y = y;
rfbDefaultPtrAddEvent(but, x, y, cl);
}
@@ -165,9 +142,8 @@ vnc_newclient(rfbClientPtr cl)
/* Reset the mouse. */
ptr_x = allowedX / 2;
ptr_y = allowedY / 2;
mouse_x = mouse_y = mouse_z = 0;
mouse_buttons = 0x00;
memset(&ms, 0, sizeof(MOUSESTATE));
mouse_clear_coords();
mouse_clear_buttons();
/* We now have clients, un-pause the emulator if needed. */
vnc_log("VNC: unpausing..\n");

View File

@@ -582,6 +582,7 @@ CPUOBJ := $(DYNARECOBJ) \
softfloat-muladd.o softfloat-round-pack.o softfloat-specialize.o softfloatx80.o
CHIPSETOBJ := 82c100.o acc2168.o \
compaq_386.o \
contaq_82c59x.o \
cs4031.o cs8230.o \
ali1429.o ali1435.o ali1489.o ali1531.o ali1541.o ali1543.o ali1621.o ali6117.o \

View File

@@ -1286,3 +1286,11 @@ endblit(void)
{
ReleaseMutex(ghMutex);
}
double
plat_get_dpi(void)
{
UINT dpi = win_get_dpi(hwndRender);
return ((double) dpi) / 96.0;
}

View File

@@ -32,15 +32,6 @@
int mouse_capture;
typedef struct {
int buttons;
int dx;
int dy;
int dwheel;
} MOUSESTATE;
MOUSESTATE mousestate;
void
win_mouse_init(void)
{
@@ -56,8 +47,6 @@ win_mouse_init(void)
ridev.usUsage = 0x02;
if (!RegisterRawInputDevices(&ridev, 1, sizeof(ridev)))
fatal("plat_mouse_init: RegisterRawInputDevices failed\n");
memset(&mousestate, 0, sizeof(MOUSESTATE));
}
void

View File

@@ -50,8 +50,8 @@ in vec2 VertexCoord;\n\
in vec2 TexCoord;\n\
out vec2 tex;\n\
void main(){\n\
gl_Position = vec4(VertexCoord, 0.0, 1.0);\n\
tex = TexCoord;\n\
gl_Position = vec4(VertexCoord, 0.0, 1.0);\n\
tex = TexCoord;\n\
}\n";
/**
@@ -62,7 +62,7 @@ in vec2 tex;\n\
uniform sampler2D texsampler;\n\
out vec4 color;\n\
void main() {\n\
color = texture(texsampler, tex);\n\
color = texture(texsampler, tex);\n\
}\n";
/**
@@ -179,7 +179,7 @@ load_custom_shaders(const char *path)
/* Check if the shader program defines version directive */
char *version_start = strstr(shader, "#version");
/* If the shader program contains a version directive,
/* If the shader program contains a version directive,
it must be captured and placed as the first statement. */
if (version_start != NULL) {
/* Version directive found, search the line end */
@@ -197,7 +197,7 @@ load_custom_shaders(const char *path)
fragment_sources[0] = version;
}
/* Comment out the original version directive
/* Comment out the original version directive
as only one is allowed. */
memset(version_start, '/', 2);
}