From d2f42198fdbe26e2684cc48ab44b21e6be2ee8b9 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Wed, 26 Jul 2023 10:57:01 -0400 Subject: [PATCH 1/8] Fix clang build failure --- src/cdrom/cdrom_image_backend.c | 2 +- src/cdrom/cdrom_mitsumi.c | 2 +- src/chipset/ali1621.c | 5 +++-- src/chipset/ali6117.c | 3 ++- src/chipset/opti283.c | 3 ++- src/chipset/via_pipc.c | 3 ++- src/device/kbc_at.c | 5 +++-- src/device/kbc_at_dev.c | 3 ++- src/device/mouse_serial.c | 5 +++-- src/device/smbus_ali7101.c | 3 ++- src/device/smbus_piix4.c | 7 ++++--- src/disk/hdc_esdi_at.c | 4 ++-- src/disk/hdc_ide.c | 4 ++-- src/disk/hdc_st506_xt.c | 4 ++-- src/disk/hdc_xta.c | 6 +++--- src/disk/mo.c | 4 ++-- src/disk/zip.c | 6 +++--- src/floppy/fdc.c | 7 ++++--- src/floppy/fdd_86f.c | 6 +++--- src/include/86box/plat.h | 4 ++++ src/include/86box/plat_fallthrough.h | 25 +++++++++++++++++++++++++ src/machine/m_elt.c | 3 ++- src/machine/m_ps1_hdc.c | 2 +- src/network/net_ne2000.c | 3 ++- src/network/net_wd8003.c | 3 ++- src/pci_dummy.c | 3 ++- src/printer/prt_escp.c | 2 +- src/printer/prt_text.c | 2 +- src/scsi/scsi_buslogic.c | 4 ++-- src/scsi/scsi_cdrom.c | 6 +++--- src/scsi/scsi_disk.c | 2 +- src/scsi/scsi_pcscsi.c | 2 +- src/scsi/scsi_x54x.c | 2 +- src/sound/snd_ac97_codec.c | 3 ++- src/sound/snd_ad1848.c | 3 ++- src/sound/snd_cmi8x38.c | 3 ++- src/sound/snd_cs423x.c | 3 ++- src/sound/snd_gus.c | 3 ++- src/sound/snd_sb_dsp.c | 3 ++- src/video/vid_8514a.c | 2 +- src/video/vid_ati_eeprom.c | 3 ++- src/video/vid_ati_mach64.c | 6 +++--- src/video/vid_ati_mach8.c | 2 +- src/video/vid_et4000.c | 3 ++- src/video/vid_ht216.c | 3 ++- src/video/vid_mga.c | 2 +- src/video/vid_s3_virge.c | 3 +-- 47 files changed, 119 insertions(+), 68 deletions(-) create mode 100644 src/include/86box/plat_fallthrough.h diff --git a/src/cdrom/cdrom_image_backend.c b/src/cdrom/cdrom_image_backend.c index d40c25d27..e94668d75 100644 --- a/src/cdrom/cdrom_image_backend.c +++ b/src/cdrom/cdrom_image_backend.c @@ -652,7 +652,7 @@ cdi_cue_get_buffer(char *str, char **line, int up) done = 1; break; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/cdrom/cdrom_mitsumi.c b/src/cdrom/cdrom_mitsumi.c index 11ff14be2..6c015fa9d 100644 --- a/src/cdrom/cdrom_mitsumi.c +++ b/src/cdrom/cdrom_mitsumi.c @@ -324,7 +324,7 @@ mitsumi_cdrom_out(uint16_t port, uint8_t val, void *priv) break; case 5: dev->readmsf = 0; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 4: diff --git a/src/chipset/ali1621.c b/src/chipset/ali1621.c index 4e19dc6cd..b927d3e34 100644 --- a/src/chipset/ali1621.c +++ b/src/chipset/ali1621.c @@ -28,6 +28,7 @@ #include <86box/io.h> #include <86box/mem.h> #include <86box/pci.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> #include <86box/smram.h> #include <86box/spd.h> @@ -108,7 +109,7 @@ ali1621_smram_recalc(uint8_t val, ali1621_t *dev) switch (val & 0x30) { case 0x10: /* Open. */ access_normal = ACCESS_SMRAM_RX; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x30: /* Protect. */ @@ -123,7 +124,7 @@ ali1621_smram_recalc(uint8_t val, ali1621_t *dev) switch (val & 0x30) { case 0x10: /* Open. */ access_normal |= ACCESS_SMRAM_W; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x30: /* Protect. */ diff --git a/src/chipset/ali6117.c b/src/chipset/ali6117.c index c4b8b818a..78705ee26 100644 --- a/src/chipset/ali6117.c +++ b/src/chipset/ali6117.c @@ -33,6 +33,7 @@ #include <86box/hdc.h> #include <86box/hdc_ide.h> #include <86box/chipset.h> +#include <86box/plat_fallthrough.h> typedef struct ali6117_t { uint32_t local; @@ -233,7 +234,7 @@ ali6117_reg_write(uint16_t addr, uint8_t val, void *priv) case 0x12: val &= 0xf7; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/chipset/opti283.c b/src/chipset/opti283.c index 544302b28..865ec6ff5 100644 --- a/src/chipset/opti283.c +++ b/src/chipset/opti283.c @@ -29,6 +29,7 @@ #include <86box/io.h> #include <86box/device.h> #include <86box/mem.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> #include <86box/chipset.h> @@ -228,7 +229,7 @@ opti283_write(uint16_t addr, uint8_t val, void *priv) case 0x14: reset_on_hlt = !!(val & 0x40); -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x11: diff --git a/src/chipset/via_pipc.c b/src/chipset/via_pipc.c index ab109ef4b..04bcd5576 100644 --- a/src/chipset/via_pipc.c +++ b/src/chipset/via_pipc.c @@ -41,6 +41,7 @@ #include <86box/ddma.h> #include <86box/pci.h> #include <86box/pic.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> #include <86box/port_92.h> #include <86box/hdc.h> @@ -1474,7 +1475,7 @@ pipc_write(int func, int addr, uint8_t val, void *priv) case 0xd2: if (dev->local == VIA_PIPC_686B) smbus_piix4_setclock(dev->smbus, (val & 0x04) ? 65536 : 16384); -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/device/kbc_at.c b/src/device/kbc_at.c index 60b4a2b3f..39398f996 100644 --- a/src/device/kbc_at.c +++ b/src/device/kbc_at.c @@ -29,6 +29,7 @@ #include <86box/io.h> #include <86box/pic.h> #include <86box/pit.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> #include <86box/ppi.h> #include <86box/mem.h> @@ -463,7 +464,7 @@ kbc_at_poll_at(atkbc_t *dev) case STATE_KBC_AMI_OUT: if (dev->status & STAT_OFULL) break; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case STATE_MAIN_IBF: @@ -588,7 +589,7 @@ kbc_at_poll_ps2(atkbc_t *dev) case STATE_KBC_AMI_OUT: if (dev->status & STAT_OFULL) break; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case STATE_MAIN_IBF: diff --git a/src/device/kbc_at_dev.c b/src/device/kbc_at_dev.c index c37ddda9d..894b5f08a 100644 --- a/src/device/kbc_at_dev.c +++ b/src/device/kbc_at_dev.c @@ -38,6 +38,7 @@ #include <86box/snd_speaker.h> #include <86box/video.h> #include <86box/keyboard.h> +#include <86box/plat_fallthrough.h> #ifdef ENABLE_KBC_AT_DEV_LOG int kbc_at_dev_do_log = ENABLE_KBC_AT_DEV_LOG; @@ -135,7 +136,7 @@ kbc_at_dev_poll(void *priv) dev->port->wantcmd = 0; break; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case DEV_STATE_MAIN_WANT_IN: diff --git a/src/device/mouse_serial.c b/src/device/mouse_serial.c index ad3b8f7cb..c74e5216b 100644 --- a/src/device/mouse_serial.c +++ b/src/device/mouse_serial.c @@ -26,6 +26,7 @@ #include <86box/timer.h> #include <86box/serial.h> #include <86box/mouse.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> #define SERMOUSE_PORT 0 /* attach to Serial0 */ @@ -507,7 +508,7 @@ sermouse_command_timer(void *priv) break; case PHASE_ACK: serial_write_fifo(dev->serial, 0x06); -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case PHASE_BAUD_RATE: @@ -647,7 +648,7 @@ ltsermouse_write(UNUSED(struct serial_s *serial), void *priv, uint8_t data) switch (data) { default: mouse_serial_log("Serial mouse: Invalid period %02X, using 1200 bps\n", data); -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x6E: diff --git a/src/device/smbus_ali7101.c b/src/device/smbus_ali7101.c index 1e1e61c52..855f0c270 100644 --- a/src/device/smbus_ali7101.c +++ b/src/device/smbus_ali7101.c @@ -28,6 +28,7 @@ #include <86box/timer.h> #include <86box/i2c.h> #include <86box/smbus.h> +#include <86box/plat_fallthrough.h> #ifdef ENABLE_SMBUS_ALI7101_LOG int smbus_ali7101_do_log = ENABLE_SMBUS_ALI7101_LOG; @@ -193,7 +194,7 @@ smbus_ali7101_write(uint16_t addr, uint8_t val, void *priv) case 0x4: /* block R/W */ timer_bytes++; /* count the SMBus length byte now */ -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/device/smbus_piix4.c b/src/device/smbus_piix4.c index 03a465f1c..bad49b957 100644 --- a/src/device/smbus_piix4.c +++ b/src/device/smbus_piix4.c @@ -27,6 +27,7 @@ #include <86box/timer.h> #include <86box/i2c.h> #include <86box/smbus.h> +#include <86box/plat_fallthrough.h> #ifdef ENABLE_SMBUS_PIIX4_LOG int smbus_piix4_do_log = ENABLE_SMBUS_PIIX4_LOG; @@ -195,7 +196,7 @@ smbus_piix4_write(uint16_t addr, uint8_t val, void *priv) timer_bytes++; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -216,7 +217,7 @@ smbus_piix4_write(uint16_t addr, uint8_t val, void *priv) case 0x5: /* block R/W */ timer_bytes++; /* count the SMBus length byte now */ -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -251,7 +252,7 @@ smbus_piix4_write(uint16_t addr, uint8_t val, void *priv) i2c_write(i2c_smbus, smbus_addr, dev->cmd); timer_bytes++; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/disk/hdc_esdi_at.c b/src/disk/hdc_esdi_at.c index 1aa18bd62..258ea9d0f 100644 --- a/src/disk/hdc_esdi_at.c +++ b/src/disk/hdc_esdi_at.c @@ -338,7 +338,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) esdi->command &= ~0x03; if (val & 0x02) fatal("Read with ECC\n"); -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -399,7 +399,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) default: esdi_at_log("WD1007: bad command %02X\n", val); -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0xe8: /*???*/ diff --git a/src/disk/hdc_ide.c b/src/disk/hdc_ide.c index dfc308590..ace646328 100644 --- a/src/disk/hdc_ide.c +++ b/src/disk/hdc_ide.c @@ -1655,7 +1655,7 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv) disabled, the Read Multiple operation is rejected with an Aborted Com- mand error. */ ide->blockcount = 0; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -1706,7 +1706,7 @@ ide_writeb(uint16_t addr, uint8_t val, void *priv) /* Turn on the activity indicator *here* so that it gets turned on less times. */ ui_sb_update_icon(SB_HDD | hdd[ide->hdd_num].bus, 1); -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/disk/hdc_st506_xt.c b/src/disk/hdc_st506_xt.c index 0843a35ee..766d70145 100644 --- a/src/disk/hdc_st506_xt.c +++ b/src/disk/hdc_st506_xt.c @@ -623,7 +623,7 @@ st506_callback(void *priv) st506_complete(dev); break; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -1608,7 +1608,7 @@ st506_init(const device_t *info) case ST506_XT_TYPE_ST11R: /* Seagate ST-11R (RLL) */ dev->spt = RLL_SECTORS; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/disk/hdc_xta.c b/src/disk/hdc_xta.c index d5cf829ba..b27648eca 100644 --- a/src/disk/hdc_xta.c +++ b/src/disk/hdc_xta.c @@ -509,7 +509,7 @@ hdc_callback(void *priv) case CMD_READ_VERIFY: no_data = 1; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -536,7 +536,7 @@ hdc_callback(void *priv) dev->buf_len = 512; dev->state = STATE_SEND; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -646,7 +646,7 @@ do_send: dev->buf_len = 512; dev->state = STATE_RECV; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/disk/mo.c b/src/disk/mo.c index 02ef29d39..eef83ec3a 100644 --- a/src/disk/mo.c +++ b/src/disk/mo.c @@ -655,7 +655,7 @@ mo_update_request_length(mo_t *dev, int len, int block_len) break; } } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif default: @@ -1344,7 +1344,7 @@ mo_command(scsi_common_t *sc, uint8_t *cdb) mo_invalid_field(dev); return; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case GPCMD_SCSI_RESERVE: diff --git a/src/disk/zip.c b/src/disk/zip.c index 6eb60bd6d..cd7359c05 100644 --- a/src/disk/zip.c +++ b/src/disk/zip.c @@ -821,7 +821,7 @@ zip_update_request_length(zip_t *dev, int len, int block_len) break; } } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -1411,7 +1411,7 @@ zip_command(scsi_common_t *sc, uint8_t *cdb) zip_invalid_field(dev); return; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case GPCMD_SCSI_RESERVE: @@ -1576,7 +1576,7 @@ zip_command(scsi_common_t *sc, uint8_t *cdb) zip_command_complete(dev); break; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case GPCMD_WRITE_6: diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index bbe4c05db..37e078b76 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -36,6 +36,7 @@ #include <86box/fdd.h> #include <86box/fdc.h> #include <86box/fdc_ext.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> extern uint64_t motoron[FDD_NUM]; @@ -916,7 +917,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc_bad_command(fdc); break; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x07: /*Recalibrate*/ @@ -961,7 +962,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc_bad_command(fdc); break; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x10: /*Get version*/ @@ -1085,7 +1086,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) case 0x16: /* Verify */ if (fdc->params[0] & 0x80) fdc->sc = fdc->params[7]; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x06: /* Read data */ diff --git a/src/floppy/fdd_86f.c b/src/floppy/fdd_86f.c index 023296358..0e8085a71 100644 --- a/src/floppy/fdd_86f.c +++ b/src/floppy/fdd_86f.c @@ -1951,7 +1951,7 @@ d86f_format_track(int drive, int side, int do_write) if (dev->datac == 3) fdc_stop_id_request(d86f_fdc); } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -2296,7 +2296,7 @@ d86f_turbo_poll(int drive, int side) case STATE_0D_SPIN_TO_INDEX: dev->sector_count = 0; dev->datac = 5; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -2343,7 +2343,7 @@ d86f_turbo_poll(int drive, int side) dev->last_sector.id.r = dev->req_sector.id.r; dev->last_sector.id.n = dev->req_sector.id.n; d86f_handler[drive].set_sector(drive, side, dev->last_sector.id.c, dev->last_sector.id.h, dev->last_sector.id.r, dev->last_sector.id.n); -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index 932dfe87b..02e5def3b 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -55,6 +55,10 @@ extern int strnicmp(const char *s1, const char *s2, size_t n); # define off64_t off_t #endif +#if !defined (__APPLE__) || !defined(__clang__) +# define FALLTHROUGH_ANNOTATION +#endif + #ifdef _MSC_VER # define UNUSED(arg) arg #else diff --git a/src/include/86box/plat_fallthrough.h b/src/include/86box/plat_fallthrough.h new file mode 100644 index 000000000..c256295ac --- /dev/null +++ b/src/include/86box/plat_fallthrough.h @@ -0,0 +1,25 @@ +/* + * 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. + * + * Define the various platform support functions. + * + * + * + * Authors: Miran Grca, + * + * Copyright 2023 Jasmine Iwanek + */ + +#ifndef EMU_PLAT_FALLTHROUGH_H +#define EMU_PLAT_FALLTHROUGH_H + +#if !defined (__APPLE__) || !defined(__clang__) +# define FALLTHROUGH_ANNOTATION +#endif + +#endif /*EMU_PLAT_FALLTHROUGH_H*/ diff --git a/src/machine/m_elt.c b/src/machine/m_elt.c index c1aa6396b..573095223 100644 --- a/src/machine/m_elt.c +++ b/src/machine/m_elt.c @@ -50,6 +50,7 @@ #include <86box/rom.h> #include <86box/video.h> #include <86box/vid_cga.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> static void @@ -123,7 +124,7 @@ elt_vid_out(uint16_t addr, uint8_t val, void *priv) case 0x3d1: if (cga->crtcreg >= 32) return; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/machine/m_ps1_hdc.c b/src/machine/m_ps1_hdc.c index 07969f1c8..225ae04a5 100644 --- a/src/machine/m_ps1_hdc.c +++ b/src/machine/m_ps1_hdc.c @@ -699,7 +699,7 @@ do_fmt: /* Done with this track. */ dev->state = STATE_FDONE; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case STATE_FDONE: diff --git a/src/network/net_ne2000.c b/src/network/net_ne2000.c index 231b7d481..80dc4ec27 100644 --- a/src/network/net_ne2000.c +++ b/src/network/net_ne2000.c @@ -68,6 +68,7 @@ #include <86box/net_ne2000.h> #include <86box/bswap.h> #include <86box/isapnp.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> /* ROM BIOS file paths. */ @@ -749,7 +750,7 @@ nic_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv) case 0x10: /* PCI_BAR */ val &= 0xe0; /* 0xe0 acc to RTL DS */ val |= 0x01; /* re-enable IOIN bit */ -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/network/net_wd8003.c b/src/network/net_wd8003.c index 44df03e6e..61c35986d 100644 --- a/src/network/net_wd8003.c +++ b/src/network/net_wd8003.c @@ -64,6 +64,7 @@ #include <86box/net_dp8390.h> #include <86box/net_wd8003.h> #include <86box/bswap.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> #include "cpu.h" @@ -734,7 +735,7 @@ wd_init(const device_t *info) /* Ethernet, MCA, 5x3 interface chip, RAM 16k */ case WD8003EA: dev->board_chip = WE_ID_SOFT_CONFIG; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif /* Ethernet, MCA, no interface chip, RAM 16k */ diff --git a/src/pci_dummy.c b/src/pci_dummy.c index 2046251ac..8ed6f9f30 100644 --- a/src/pci_dummy.c +++ b/src/pci_dummy.c @@ -9,6 +9,7 @@ #include <86box/io.h> #include <86box/pci.h> #include <86box/pci_dummy.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> typedef struct pci_dummy_t { @@ -210,7 +211,7 @@ pci_dummy_pci_write(int func, int addr, uint8_t val, void *priv) case 0x10: /* PCI_BAR */ val &= 0xe0; /* 0xe0 acc to RTL DS */ -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/printer/prt_escp.c b/src/printer/prt_escp.c index 012e8b686..612a07cac 100644 --- a/src/printer/prt_escp.c +++ b/src/printer/prt_escp.c @@ -1462,7 +1462,7 @@ process_char(escp_t *dev, uint8_t ch) dev->curr_x = dev->left_margin; if (!dev->autofeed) return 1; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/printer/prt_text.c b/src/printer/prt_text.c index d2a6797cd..e1183f0c0 100644 --- a/src/printer/prt_text.c +++ b/src/printer/prt_text.c @@ -283,7 +283,7 @@ process_char(prnt_t *dev, uint8_t ch) dev->curr_x = 0; if (!dev->autofeed) return 1; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/scsi/scsi_buslogic.c b/src/scsi/scsi_buslogic.c index 72c02ba1c..d38a967bd 100644 --- a/src/scsi/scsi_buslogic.c +++ b/src/scsi/scsi_buslogic.c @@ -1232,7 +1232,7 @@ BuslogicPCIWrite(UNUSED(int func), int addr, uint8_t val, void *priv) case 0x10: val &= 0xe0; val |= 1; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -1258,7 +1258,7 @@ BuslogicPCIWrite(UNUSED(int func), int addr, uint8_t val, void *priv) case 0x14: val &= 0xe0; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/scsi/scsi_cdrom.c b/src/scsi/scsi_cdrom.c index 721e75c64..d192aec53 100644 --- a/src/scsi/scsi_cdrom.c +++ b/src/scsi/scsi_cdrom.c @@ -883,7 +883,7 @@ scsi_cdrom_update_request_length(scsi_cdrom_t *dev, int len, int block_len) break; } } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif @@ -961,7 +961,7 @@ scsi_cdrom_command_common(scsi_cdrom_t *dev) scsi_cdrom_log("CD-ROM %i: Seek period: %" PRIu64 " us\n", dev->id, (uint64_t) period); dev->callback += period; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x25: @@ -1940,7 +1940,7 @@ begin: /* IMPORTANT: Convert the command to new read CD for pass through purposes. */ dev->current_cdb[0] = GPCMD_READ_CD; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index 600d9f6e3..2bd61313b 100644 --- a/src/scsi/scsi_disk.c +++ b/src/scsi/scsi_disk.c @@ -597,7 +597,7 @@ scsi_disk_command(scsi_common_t *sc, uint8_t *cdb) scsi_disk_invalid_field(dev); return; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case GPCMD_SCSI_RESERVE: diff --git a/src/scsi/scsi_pcscsi.c b/src/scsi/scsi_pcscsi.c index 3f30fdafc..7fa359396 100644 --- a/src/scsi/scsi_pcscsi.c +++ b/src/scsi/scsi_pcscsi.c @@ -1029,7 +1029,7 @@ esp_reg_write(esp_t *dev, uint32_t saddr, uint32_t val) switch (saddr) { case ESP_TCHI: dev->tchi_written = 1; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case ESP_TCLO: diff --git a/src/scsi/scsi_x54x.c b/src/scsi/scsi_x54x.c index 0b9cb0281..7a6923def 100644 --- a/src/scsi/scsi_x54x.c +++ b/src/scsi/scsi_x54x.c @@ -486,7 +486,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba) default: x54x_log("BIOS: Unimplemented command: %02X\n", cmd->command); -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x05: /* Format Track, invalid since SCSI has no tracks */ diff --git a/src/sound/snd_ac97_codec.c b/src/sound/snd_ac97_codec.c index 6e9f93f1d..929574dce 100644 --- a/src/sound/snd_ac97_codec.c +++ b/src/sound/snd_ac97_codec.c @@ -25,6 +25,7 @@ #include <86box/device.h> #include <86box/io.h> #include <86box/snd_ac97.h> +#include <86box/plat_fallthrough.h> static const struct { const device_t *device; @@ -417,7 +418,7 @@ rate: /* Writable only if VRA/VRM is set. */ /* Get actual previous value. */ prev = dev->vendor_reg_pages[(i << 3) | ((reg & 0x0e) >> 1)]; } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/sound/snd_ad1848.c b/src/sound/snd_ad1848.c index 33379289d..acc143636 100644 --- a/src/sound/snd_ad1848.c +++ b/src/sound/snd_ad1848.c @@ -30,6 +30,7 @@ #include <86box/timer.h> #include <86box/sound.h> #include <86box/snd_ad1848.h> +#include <86box/plat_fallthrough.h> #define CS4231 0x80 #define CS4236 0x03 @@ -241,7 +242,7 @@ ad1848_write(uint16_t addr, uint8_t val, void *priv) case 10: if (ad1848->type < AD1848_TYPE_CS4235) break; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/sound/snd_cmi8x38.c b/src/sound/snd_cmi8x38.c index c3d93aee9..ea81230a9 100644 --- a/src/sound/snd_cmi8x38.c +++ b/src/sound/snd_cmi8x38.c @@ -34,6 +34,7 @@ #include <86box/gameport.h> #include <86box/nmi.h> #include <86box/ui.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> enum { @@ -467,7 +468,7 @@ cmi8x38_sb_mixer_write(uint16_t addr, uint8_t val, void *priv) case 0xf8 ... 0xff: if (dev->type == CMEDIA_CMI8338) mixer->regs[mixer->index] = val; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/sound/snd_cs423x.c b/src/sound/snd_cs423x.c index 8be3b6b33..fff716e28 100644 --- a/src/sound/snd_cs423x.c +++ b/src/sound/snd_cs423x.c @@ -36,6 +36,7 @@ #include <86box/snd_ad1848.h> #include <86box/snd_opl.h> #include <86box/snd_sb.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> #define CRYSTAL_NOEEPROM 0x100 @@ -299,7 +300,7 @@ cs423x_write(uint16_t addr, uint8_t val, void *priv) switch (val) { case 0x55: /* Disable PnP Key */ dev->pnp_enable = 0; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif diff --git a/src/sound/snd_gus.c b/src/sound/snd_gus.c index 1a4265c4c..c7e6d39f9 100644 --- a/src/sound/snd_gus.c +++ b/src/sound/snd_gus.c @@ -17,6 +17,7 @@ #include <86box/sound.h> #include <86box/timer.h> #include <86box/snd_ad1848.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> enum { @@ -626,7 +627,7 @@ writegus(uint16_t addr, uint8_t val, void *priv) else if (gus->irq != -1) picint(1 << gus->irq); } -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x20d: diff --git a/src/sound/snd_sb_dsp.c b/src/sound/snd_sb_dsp.c index 8c6d4146d..d4dcd5a79 100644 --- a/src/sound/snd_sb_dsp.c +++ b/src/sound/snd_sb_dsp.c @@ -25,6 +25,7 @@ #include <86box/sound.h> #include <86box/timer.h> #include <86box/snd_sb.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> #define ADPCM_4 1 @@ -600,7 +601,7 @@ sb_exec_command(sb_dsp_t *dsp) case 0x75: /* 4-bit ADPCM output with reference */ dsp->sbref = dsp->dma_readb(dsp->dma_priv); dsp->sbstep = 0; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x74: /* 4-bit ADPCM output */ diff --git a/src/video/vid_8514a.c b/src/video/vid_8514a.c index ccc530e3b..a9d0a3f5d 100644 --- a/src/video/vid_8514a.c +++ b/src/video/vid_8514a.c @@ -536,7 +536,7 @@ ibm8514_accel_out_fifo(svga_t *svga, uint16_t port, uint32_t val, int len) case 0x92e8: if (len != 1) dev->test = val; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0xd2e8: diff --git a/src/video/vid_ati_eeprom.c b/src/video/vid_ati_eeprom.c index a3479c20a..4992fff40 100644 --- a/src/video/vid_ati_eeprom.c +++ b/src/video/vid_ati_eeprom.c @@ -26,6 +26,7 @@ #include <86box/timer.h> #include <86box/nvr.h> #include <86box/vid_ati_eeprom.h> +#include <86box/plat_fallthrough.h> void ati_eeprom_load(ati_eeprom_t *eeprom, char *fn, int type) @@ -93,7 +94,7 @@ ati_eeprom_write(ati_eeprom_t *eeprom, int ena, int clk, int dat) if (!dat) break; eeprom->state = EEPROM_OPCODE; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case EEPROM_OPCODE: diff --git a/src/video/vid_ati_mach64.c b/src/video/vid_ati_mach64.c index d5e721aef..7140e0276 100644 --- a/src/video/vid_ati_mach64.c +++ b/src/video/vid_ati_mach64.c @@ -748,7 +748,7 @@ mach64_accel_write_fifo(mach64_t *mach64, uint32_t addr, uint8_t val) case 0x11e: case 0x11f: WRITE8(addr, mach64->dst_height_width, val); -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x113: @@ -973,7 +973,7 @@ mach64_accel_write_fifo(mach64_t *mach64, uint32_t addr, uint8_t val) case 0x2a4: case 0x2a5: addr += 2; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x2aa: @@ -990,7 +990,7 @@ mach64_accel_write_fifo(mach64_t *mach64, uint32_t addr, uint8_t val) case 0x2b0: case 0x2b1: addr += 2; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x2b6: diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index 797ae3f19..e2b312c47 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -2838,7 +2838,7 @@ mach_accel_out_fifo(mach_t *mach, svga_t *svga, ibm8514_t *dev, uint16_t port, u case 0x92e8: if (len != 1) dev->test = val; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0xd2e8: diff --git a/src/video/vid_et4000.c b/src/video/vid_et4000.c index b06283a1c..a97d65cdb 100644 --- a/src/video/vid_et4000.c +++ b/src/video/vid_et4000.c @@ -52,6 +52,7 @@ #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_svga_render.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> #define ET4000_TYPE_ISA 1 /* ISA ET4000AX */ @@ -432,7 +433,7 @@ et4000_kasan_out(uint16_t addr, uint8_t val, void *priv) case 5: et4000->kasan_cfg_regs[5] = val; et4000->svga.ksc5601_english_font_type = 0x100 | val; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 6: diff --git a/src/video/vid_ht216.c b/src/video/vid_ht216.c index 2c44c8b28..bd09a9ede 100644 --- a/src/video/vid_ht216.c +++ b/src/video/vid_ht216.c @@ -35,6 +35,7 @@ #include <86box/video.h> #include <86box/vid_svga.h> #include <86box/vid_svga_render.h> +#include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> typedef struct ht216_t { @@ -320,7 +321,7 @@ ht216_out(uint16_t addr, uint8_t val, void *priv) svga->adv_flags &= ~FLAG_RAMDAC_SHIFT; if (val & 0x04) svga->adv_flags |= FLAG_RAMDAC_SHIFT; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif /*Bank registers*/ diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index f9387987b..67f8d5751 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -664,7 +664,7 @@ mystique_out(uint16_t addr, uint8_t val, void *priv) switch (addr) { case 0x3c8: mystique->xreg_idx = val; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif case 0x3c6: diff --git a/src/video/vid_s3_virge.c b/src/video/vid_s3_virge.c index e52322426..4b51daa33 100644 --- a/src/video/vid_s3_virge.c +++ b/src/video/vid_s3_virge.c @@ -39,7 +39,6 @@ #include <86box/vid_ddc.h> #include <86box/vid_svga.h> #include <86box/vid_svga_render.h> -#include <86box/plat_unused.h> static int dither[4][4] = { {0, 4, 1, 5}, @@ -4305,7 +4304,7 @@ s3_virge_init(const device_t *info) case S3_VIRGE_GX: virge->virge_rev = 0x01; -#ifndef __APPLE__ +#ifdef FALLTHROUGH_ANNOTATION [[fallthrough]]; #endif From f16f63e9ee53d8bef74b99b37ae5bef96beac367 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Wed, 26 Jul 2023 11:31:38 -0400 Subject: [PATCH 2/8] Dont run sonar on macos or windows for now --- .github/workflows/cmake.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 5f703a65f..12d278e8f 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -263,7 +263,7 @@ jobs: build-wrapper-win-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build - name: Run sonar-scanner -# if: 0 + if: 0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} @@ -445,7 +445,7 @@ jobs: build-wrapper-macosx-x86 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build - name: Run sonar-scanner -# if: 0 + if: 0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From a61ebf2feaa8e8b619b045b9a7b312710beec8c6 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Wed, 26 Jul 2023 13:14:21 -0400 Subject: [PATCH 3/8] Fix mistake --- src/include/86box/plat_fallthrough.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/86box/plat_fallthrough.h b/src/include/86box/plat_fallthrough.h index c256295ac..702321344 100644 --- a/src/include/86box/plat_fallthrough.h +++ b/src/include/86box/plat_fallthrough.h @@ -10,7 +10,7 @@ * * * - * Authors: Miran Grca, + * Authors: Jasmine Iwanek, * * Copyright 2023 Jasmine Iwanek */ From 0c3db4da438b88f3cfe223b201afb11df912d316 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 27 Jul 2023 01:26:24 +0200 Subject: [PATCH 4/8] Saved coordinates are no longer changed when the emulator is in full screen, fixes #3485. --- src/qt/qt_mainwindow.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index ae6ff955e..ef39765dd 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -1709,18 +1709,20 @@ void MainWindow::on_actionRemember_size_and_position_triggered() { window_remember ^= 1; - window_w = ui->stackedWidget->width(); - window_h = ui->stackedWidget->height(); - if (!QApplication::platformName().contains("wayland")) { - window_x = geometry().x(); - window_y = geometry().y(); - } - for (int i = 1; i < MONITORS_NUM; i++) { - if (window_remember && renderers[i]) { - monitor_settings[i].mon_window_w = renderers[i]->geometry().width(); - monitor_settings[i].mon_window_h = renderers[i]->geometry().height(); - monitor_settings[i].mon_window_x = renderers[i]->geometry().x(); - monitor_settings[i].mon_window_y = renderers[i]->geometry().y(); + if (!video_fullscreen) { + window_w = ui->stackedWidget->width(); + window_h = ui->stackedWidget->height(); + if (!QApplication::platformName().contains("wayland")) { + window_x = geometry().x(); + window_y = geometry().y(); + } + for (int i = 1; i < MONITORS_NUM; i++) { + if (window_remember && renderers[i]) { + monitor_settings[i].mon_window_w = renderers[i]->geometry().width(); + monitor_settings[i].mon_window_h = renderers[i]->geometry().height(); + monitor_settings[i].mon_window_x = renderers[i]->geometry().x(); + monitor_settings[i].mon_window_y = renderers[i]->geometry().y(); + } } } ui->actionRemember_size_and_position->setChecked(window_remember); From bee11bcbba405659c8c5204e0d5eb0ce659d612b Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Wed, 26 Jul 2023 19:54:39 -0400 Subject: [PATCH 5/8] Fix my clang fix --- src/include/86box/plat.h | 2 +- src/include/86box/plat_fallthrough.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index 02e5def3b..2b0809c2e 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -55,7 +55,7 @@ extern int strnicmp(const char *s1, const char *s2, size_t n); # define off64_t off_t #endif -#if !defined (__APPLE__) || !defined(__clang__) +#if !defined (__APPLE__) && !defined(__clang__) # define FALLTHROUGH_ANNOTATION #endif diff --git a/src/include/86box/plat_fallthrough.h b/src/include/86box/plat_fallthrough.h index 702321344..212d662fe 100644 --- a/src/include/86box/plat_fallthrough.h +++ b/src/include/86box/plat_fallthrough.h @@ -18,7 +18,7 @@ #ifndef EMU_PLAT_FALLTHROUGH_H #define EMU_PLAT_FALLTHROUGH_H -#if !defined (__APPLE__) || !defined(__clang__) +#if !defined (__APPLE__) && !defined(__clang__) # define FALLTHROUGH_ANNOTATION #endif From d03399c1a5cbcafd882d3aa7442a984e0c98a791 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 27 Jul 2023 02:33:40 +0200 Subject: [PATCH 6/8] Some fixes for Clang compilation. --- src/win/Makefile.mingw | 43 ++++++++++++++++++++++++++++++++++------ src/win/win_media_menu.c | 9 +++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 806f2b45b..a947dfb62 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -269,8 +269,8 @@ else endif ifeq ($(CLANG), y) - CPP := ${TOOL_PREFIX}clang++ - CC := ${TOOL_PREFIX}clang + CPP := clang++ + CC := clang else CPP := ${TOOL_PREFIX}g++ CC := ${TOOL_PREFIX}gcc @@ -304,17 +304,38 @@ ifeq ($(DEBUG), y) ifndef COPTIM COPTIM := -Og endif + ifndef CXXOPTIM + ifeq ($(CLANG), y) + CXXOPTIM := -Os + else + CXXOPTIM := -Og + endif + endif else DFLAGS += -g0 ifeq ($(OPTIM), y) AOPTIM := -mtune=native ifndef COPTIM - COPTIM := -O3 -ffp-contract=fast -flto + CXXOPTIM := -O3 -ffp-contract=fast -flto + endif + ifndef CXXOPTIM + ifeq ($(CLANG), y) + CXXOPTIM := -Os -ffp-contract=fast -flto + else + CXXOPTIM := -O3 -ffp-contract=fast -flto + endif endif else ifndef COPTIM COPTIM := -O3 endif + ifndef CXXOPTIM + ifeq ($(CLANG), y) + CXXOPTIM := -Os + else + CXXOPTIM := -O3 + endif + endif endif endif ifeq ($(AVX), y) @@ -531,7 +552,9 @@ CFLAGS := $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) \ # Add freetyp2 references through pkgconfig CFLAGS := $(CFLAGS) `pkg-config --cflags freetype2` -CXXFLAGS := $(CFLAGS) +CXXFLAGS := $(OPTS) $(DFLAGS) $(CXXOPTIM) $(AOPTIM) \ + $(AFLAGS) -fomit-frame-pointer -mstackrealign -Wall \ + -fno-strict-aliasing CFLAGS += -Werror=implicit-int -Werror=implicit-function-declaration \ -Werror=int-conversion -Werror=strict-prototypes -Werror=old-style-definition @@ -811,13 +834,21 @@ else endif ifeq ($(RTMIDI), y) - LIBS += -lrtmidi -lwinmm + ifeq ($(CLANG), y) + LIBS += -lrtmidi.dll -lwinmm + else + LIBS += -lrtmidi -lwinmm + endif endif ifeq ($(VNC), y) LIBS += $(VNCLIB) -lws2_32 endif -LIBS += -lpng -lz -lwsock32 -liphlpapi -lpsapi -lhid -lsetupapi -luxtheme -static -lstdc++ +ifeq ($(CLANG), y) + LIBS += -lpng -lz -lwsock32 -liphlpapi -lpsapi -lhid -lsetupapi -luxtheme -static -lstdc++.dll +else + LIBS += -lpng -lz -lwsock32 -liphlpapi -lpsapi -lhid -lsetupapi -luxtheme -static -lstdc++ +endif ifneq ($(X64), y) ifneq ($(ARM64), y) LIBS += -Wl,--large-address-aware diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index 93d7396ae..9e5603442 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -544,6 +544,10 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) int ret = 0; int wp = 0; +#ifdef __clang__ + BROWSEINFO bi; +#endif + id = LOWORD(wParam) & 0x00ff; switch (LOWORD(wParam) & 0xff00) { @@ -651,10 +655,15 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_CDROM_DIR: +#ifndef __clang__ BROWSEINFO bi = { .hwndOwner = hwnd, .ulFlags = BIF_EDITBOX }; +#else + bi.hwndOwner = hwnd; + bi.ulFlags = BIF_EDITBOX; +#endif OleInitialize(NULL); int old_dopause = dopause; plat_pause(1); From 4d5fb6e7cc4fd6b27800578956b00887e34dc830 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 27 Jul 2023 02:43:15 +0200 Subject: [PATCH 7/8] Include cpu/softfloat/softfloat-specialize.h from cpu/x87_ops.h, should hopefully fix compilaton with LLVM. --- src/cpu/x87_ops.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpu/x87_ops.h b/src/cpu/x87_ops.h index e321df959..b01547314 100644 --- a/src/cpu/x87_ops.h +++ b/src/cpu/x87_ops.h @@ -481,6 +481,8 @@ typedef union { # define FP_TAG_VALID_N cpu_state.tag[(cpu_state.TOP + 1) & 7] &= ~TAG_UINT64 #endif +#include "softfloat/softfloat-specialize.h" + #include "x87_ops_sf_arith.h" #include "x87_ops_sf_compare.h" #include "x87_ops_sf_const.h" From d2b0d0c3c20ec859e7bca3c68d93984558518f7a Mon Sep 17 00:00:00 2001 From: TC1995 Date: Thu, 27 Jul 2023 16:01:20 +0200 Subject: [PATCH 8/8] XGA: 16bpp mode in accelerated mode no longer shows inverted colors in various parts of some stuff (e.g.: Win3.1x, OS/2). --- src/include/86box/vid_xga.h | 137 +++----- src/video/vid_xga.c | 620 +++++++++++++++++------------------- 2 files changed, 340 insertions(+), 417 deletions(-) diff --git a/src/include/86box/vid_xga.h b/src/include/86box/vid_xga.h index af5191a81..4401c507d 100644 --- a/src/include/86box/vid_xga.h +++ b/src/include/86box/vid_xga.h @@ -20,7 +20,7 @@ #include <86box/rom.h> -typedef struct xga_hwcursor_t { +typedef struct { int ena; int x; int y; @@ -37,14 +37,11 @@ typedef struct xga_t { mem_mapping_t video_mapping; rom_t bios_rom; rom_t vga_bios_rom; - xga_hwcursor_t hwcursor; - xga_hwcursor_t hwcursor_latch; + xga_hwcursor_t hwcursor, hwcursor_latch; PALETTE extpal; - uint8_t test; - uint8_t atest[2]; - uint8_t testpixel; - + uint8_t test, atest[2], testpixel; + ; uint8_t pos_regs[8]; uint8_t disp_addr; uint8_t cfg_reg; @@ -57,43 +54,34 @@ typedef struct xga_t { uint8_t regs_idx; uint8_t hwc_hotspot_x; uint8_t hwc_hotspot_y; - uint8_t disp_cntl_1; - uint8_t disp_cntl_2; - uint8_t clk_sel_1; - uint8_t clk_sel_2; + uint8_t disp_cntl_1, disp_cntl_2; + uint8_t clk_sel_1, clk_sel_2; uint8_t hwc_control; uint8_t bus_arb; uint8_t isa_pos_enable; uint8_t hwcursor_oddeven; uint8_t cfg_reg_instance; uint8_t rowcount; - uint8_t pal_idx; - uint8_t pal_idx_prefetch; + uint8_t pal_idx, pal_idx_prefetch; uint8_t pal_seq; uint8_t pal_mask; - uint8_t pal_r; - uint8_t pal_r_prefetch; - uint8_t pal_g; - uint8_t pal_g_prefetch; - uint8_t pal_b; - uint8_t pal_b_prefetch; + uint8_t pal_r, pal_r_prefetch; + uint8_t pal_g, pal_g_prefetch; + uint8_t pal_b, pal_b_prefetch; uint8_t sprite_data[1024]; uint8_t scrollcache; + uint8_t border_color; uint8_t direct_color; uint8_t dma_channel; - uint8_t instance_isa; - uint8_t instance_num; - uint8_t ext_mem_addr; - uint8_t *vram; - uint8_t *changedvram; + uint8_t instance_isa, instance_num, ext_mem_addr; + uint8_t *vram, *changedvram; int16_t hwc_pos_x; int16_t hwc_pos_y; uint16_t pos_idx; uint16_t htotal; - uint16_t sprite_idx; - uint16_t sprite_idx_prefetch; + uint16_t sprite_idx, sprite_idx_prefetch; uint16_t hdisp; uint16_t vtotal; uint16_t vdispend; @@ -101,74 +89,41 @@ typedef struct xga_t { uint16_t vsyncstart; uint16_t linecmp; uint16_t pix_map_width; - uint16_t sprite_pal_addr_idx; - uint16_t old_pal_addr_idx; + uint16_t sprite_pal_addr_idx, old_pal_addr_idx; uint16_t sprite_pal_addr_idx_prefetch; - int v_total; - int dispend; - int v_syncstart; - int split; - int v_blankstart; - int h_disp; - int h_disp_old; - int h_total; - int h_disp_time; - int rowoffset; - int dispon; - int h_disp_on; - int vc; - int sc; - int linepos; - int oddeven; - int firstline; - int lastline; - int firstline_draw; - int lastline_draw; - int displine; - int fullchange; - int interlace; - int char_width; - int hwcursor_on; - int pal_pos; - int pal_pos_prefetch; + int v_total, dispend, v_syncstart, split, v_blankstart, + h_disp, h_disp_old, h_total, h_disp_time, rowoffset, + dispon, h_disp_on, vc, sc, linepos, oddeven, firstline, lastline, + firstline_draw, lastline_draw, displine, fullchange, interlace, + char_width, hwcursor_on; + int pal_pos, pal_pos_prefetch; int on; - int op_mode_reset; - int linear_endian_reverse; - int sprite_pos; - int sprite_pos_prefetch; - int cursor_data_on; - int pal_test; - int a5_test; - int type; - int bus; + int op_mode_reset, linear_endian_reverse; + int sprite_pos, sprite_pos_prefetch, cursor_data_on; + int pal_test, a5_test; + int type, bus; - uint32_t linear_base; - uint32_t linear_size; - uint32_t banked_mask; + uint32_t linear_base, linear_size, banked_mask; uint32_t base_addr_1mb; - uint32_t hwc_color0; - uint32_t hwc_color1; + uint32_t hwc_color0, hwc_color1; uint32_t disp_start_addr; uint32_t ma_latch; uint32_t vram_size; uint32_t vram_mask; uint32_t rom_addr; - uint32_t ma; - uint32_t maback; + uint32_t ma, maback; uint32_t extpallook[256]; - uint32_t read_bank; - uint32_t write_bank; + uint32_t read_bank, write_bank; uint32_t px_map_base; - uint64_t dispontime; - uint64_t dispofftime; + uint64_t dispontime, dispofftime; - struct { + struct + { uint8_t control; uint8_t px_map_idx; - uint8_t frgd_mix; - uint8_t bkgd_mix; + uint8_t frgd_mix, bkgd_mix; uint8_t cc_cond; uint8_t octant; uint8_t draw_mode; @@ -179,19 +134,15 @@ typedef struct xga_t { uint8_t short_stroke_vector4; int16_t bres_err_term; - int16_t bres_k1; - int16_t bres_k2; + int16_t bres_k1, bres_k2; uint16_t blt_width; uint16_t blt_height; uint16_t mask_map_origin_x_off; uint16_t mask_map_origin_y_off; - uint16_t src_map_x; - uint16_t src_map_y; - uint16_t dst_map_x; - uint16_t dst_map_y; - uint16_t pat_map_x; - uint16_t pat_map_y; + uint16_t src_map_x, src_map_y; + uint16_t dst_map_x, dst_map_y; + uint16_t pat_map_x, pat_map_y; int ssv_state; int pat_src; @@ -199,14 +150,7 @@ typedef struct xga_t { int dst_map; int bkgd_src; int fore_src; - int x; - int y; - int sx; - int sy; - int dx; - int dy; - int px; - int py; + int x, y, sx, sy, dx, dy, px, py; int pattern; int command_len; @@ -214,8 +158,7 @@ typedef struct xga_t { uint32_t color_cmp; uint32_t carry_chain; uint32_t plane_mask; - uint32_t frgd_color; - uint32_t bkgd_color; + uint32_t frgd_color, bkgd_color; uint32_t command; uint32_t dir_cmd; @@ -225,6 +168,6 @@ typedef struct xga_t { uint32_t px_map_base[4]; } accel; - volatile int force_busy; + int big_endian_linear; } xga_t; #endif /*VIDEO_XGA_H*/ diff --git a/src/video/vid_xga.c b/src/video/vid_xga.c index 50cfcb90a..7afa3e41a 100644 --- a/src/video/vid_xga.c +++ b/src/video/vid_xga.c @@ -42,15 +42,18 @@ static video_timings_t timing_xga_isa = { .type = VIDEO_ISA, .write_b = 3, .write_w = 3, .write_l = 6, .read_b = 5, .read_w = 5, .read_l = 10 }; static video_timings_t timing_xga_mca = { .type = VIDEO_MCA, .write_b = 4, .write_w = 5, .write_l = 10, .read_b = 5, .read_w = 5, .read_l = 10 }; -static void xga_ext_outb(uint16_t addr, uint8_t val, void *priv); -static uint8_t xga_ext_inb(uint16_t addr, void *priv); +static void xga_ext_outb(uint16_t addr, uint8_t val, void *p); +static uint8_t xga_ext_inb(uint16_t addr, void *p); + +static void xga_writew(uint32_t addr, uint16_t val, void *p); +static uint16_t xga_readw(uint32_t addr, void *p); int xga_has_vga = 0; void -svga_xga_out(uint16_t addr, uint8_t val, void *priv) +svga_xga_out(uint16_t addr, uint8_t val, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *)p; uint8_t old; if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) @@ -86,9 +89,9 @@ svga_xga_out(uint16_t addr, uint8_t val, void *priv) } uint8_t -svga_xga_in(uint16_t addr, void *priv) +svga_xga_in(uint16_t addr, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *)p; uint8_t temp; if (((addr & 0xfff0) == 0x3d0 || (addr & 0xfff0) == 0x3b0) && !(svga->miscout & 1)) @@ -350,6 +353,10 @@ xga_ext_out_reg(xga_t *xga, svga_t *svga, uint8_t idx, uint8_t val) svga_recalctimings(svga); break; + case 0x55: + xga->border_color = val; + break; + case 0x59: xga->direct_color = val; break; @@ -451,9 +458,9 @@ xga_ext_out_reg(xga_t *xga, svga_t *svga, uint8_t idx, uint8_t val) } static void -xga_ext_outb(uint16_t addr, uint8_t val, void *priv) +xga_ext_outb(uint16_t addr, uint8_t val, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; //pclog("[%04X:%08X]: EXT OUTB = %02x, val = %02x\n", CS, cpu_state.pc, addr, val); @@ -470,8 +477,6 @@ xga_ext_outb(uint16_t addr, uint8_t val, void *priv) if ((xga->disp_cntl_2 & 7) == 4) xga->aperture_cntl = 0; break; - case 6: - break; case 8: xga->ap_idx = val; //pclog("Aperture CNTL = %d, val = %02x, up to bit6 = %02x\n", xga->aperture_cntl, val, val & 0x3f); @@ -500,11 +505,11 @@ xga_ext_outb(uint16_t addr, uint8_t val, void *priv) } static uint8_t -xga_ext_inb(uint16_t addr, void *priv) +xga_ext_inb(uint16_t addr, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; - uint8_t ret = 0xff; + uint8_t ret; uint8_t index; switch (addr & 0x0f) { @@ -646,6 +651,9 @@ xga_ext_inb(uint16_t addr, void *priv) case 0x54: ret = xga->clk_sel_1; break; + case 0x55: + ret = xga->border_color; + break; case 0x59: ret = xga->direct_color; @@ -743,37 +751,17 @@ xga_ext_inb(uint16_t addr, void *priv) #define READW(addr, dat) \ dat = *(uint16_t *) &xga->vram[(addr) & (xga->vram_mask)]; -#define READW_REVERSE(addr, dat) \ - dat = xga->vram[(addr + 1) & (xga->vram_mask - 1)] & 0xff; \ - dat |= (xga->vram[(addr) & (xga->vram_mask - 1)] << 8); - -#define READL(addr, dat) \ - dat = *(uint32_t *) &xga->vram[(addr) & (xga->vram_mask)]; - -#define READL_REVERSE(addr, dat) \ - dat = xga->vram[(addr + 3) & (xga->vram_mask - 3)] & 0xff; \ - dat |= (xga->vram[(addr + 2) & (xga->vram_mask - 3)] << 8); \ - dat |= (xga->vram[(addr + 1) & (xga->vram_mask - 3)] << 16); \ - dat |= (xga->vram[(addr) & (xga->vram_mask - 3)] << 24); +#define READW_INV(addr, dat) \ + dat = xga->vram[(addr + 1) & (xga->vram_mask)]; \ + dat |= (xga->vram[(addr) & (xga->vram_mask)] << 8); #define WRITEW(addr, dat) \ *(uint16_t *) &xga->vram[((addr)) & (xga->vram_mask)] = dat; \ xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; -#define WRITEL(addr, dat) \ - *(uint32_t *) &xga->vram[((addr)) & (xga->vram_mask)] = dat; \ - xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; - -#define WRITEW_REVERSE(addr, dat) \ - xga->vram[((addr + 1)) & (xga->vram_mask - 1)] = dat & 0xff; \ - xga->vram[((addr)) & (xga->vram_mask - 1)] = dat >> 8; \ - xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; - -#define WRITEL_REVERSE(addr, dat) \ - xga->vram[((addr + 3)) & (xga->vram_mask - 3)] = dat & 0xff; \ - xga->vram[((addr + 2)) & (xga->vram_mask - 3)] = dat >> 8; \ - xga->vram[((addr + 1)) & (xga->vram_mask - 3)] = dat >> 16; \ - xga->vram[((addr)) & (xga->vram_mask - 3)] = dat >> 24; \ +#define WRITEW_INV(addr, dat) \ + xga->vram[((addr + 1)) & (xga->vram_mask)] = dat & 0xff; \ + xga->vram[((addr)) & (xga->vram_mask)] = dat >> 8; \ xga->changedvram[(((addr)) & (xga->vram_mask)) >> 12] = svga->monitor->mon_changeframecount; #define ROP(mix, d, s) \ @@ -873,20 +861,21 @@ xga_accel_read_pattern_map_pixel(svga_t *svga, int x, int y, int map, uint32_t b } else { byte = mem_readb_phys(addr); } - if ((xga->accel.px_map_format[map] & 8) && !(xga->access_mode & 8)) - if (xga->linear_endian_reverse) - bits = 7 - (x & 7); - else - bits = (x & 7); - else { + if (xga->linear_endian_reverse) { bits = 7 - (x & 7); + } else { + if ((xga->accel.px_map_format[map] & 8) && !(xga->access_mode & 8)) + bits = (x & 7); + else { + bits = 7 - (x & 7); + } } px = (byte >> bits) & 1; return px; } static uint32_t -xga_accel_read_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, int width) +xga_accel_read_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, int width, int usesrc) { xga_t *xga = &svga->xga; uint32_t addr = base; @@ -912,13 +901,14 @@ xga_accel_read_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, int } else { byte = mem_readb_phys(addr); } - if ((xga->accel.px_map_format[map] & 8) && !(xga->access_mode & 8)) - if (xga->linear_endian_reverse) - bits = 7 - (x & 7); - else - bits = (x & 7); - else { + if (xga->linear_endian_reverse) { bits = 7 - (x & 7); + } else { + if ((xga->accel.px_map_format[map] & 8) && !(xga->access_mode & 8)) + bits = (x & 7); + else { + bits = 7 - (x & 7); + } } px = (byte >> bits) & 1; return px; @@ -934,39 +924,21 @@ xga_accel_read_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, int case 4: /*16-bit*/ addr += (y * (width << 1)); addr += (x << 1); - if (!skip) { - if (xga->accel.px_map_format[map] & 8) { - if (xga->linear_endian_reverse) { - READW(addr, byte); - } else { - READW_REVERSE(addr, byte); - } - } else { - READW(addr, byte); - } - } else { + if (xga->linear_endian_reverse) { byte = mem_readw_phys(addr); - } - return byte; - case 5: /*24-bit*/ - addr += (y * (width << 2)); - addr += (x << 2); - if (!skip) { - if ((xga->accel.px_map_format[map] & 8)) { - if (xga->linear_endian_reverse) { - READL(addr, byte); - } else { - READL_REVERSE(addr, byte); - } - } else { - READL(addr, byte); - } + if ((xga->access_mode & 7) == 4) + byte = ((byte & 0xff00) >> 8) | ((byte & 0x00ff) << 8); + else if (xga->access_mode & 8) + byte = ((byte & 0xff00) >> 8) | ((byte & 0x00ff) << 8); } else { - byte = mem_readl_phys(addr); + if (!skip) { + READW(addr, byte); + } else { + byte = mem_readb_phys(addr) | (mem_readb_phys(addr + 1) << 8); + } } return byte; } - return 0; } @@ -996,13 +968,14 @@ xga_accel_write_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, ui } else { byte = mem_readb_phys(addr); } - if ((xga->accel.px_map_format[map] & 8) && !(xga->access_mode & 8)) { - if (xga->linear_endian_reverse) - mask = 1 << (7 - (x & 7)); - else - mask = 1 << (x & 7); - } else { + if (xga->linear_endian_reverse) { mask = 1 << (7 - (x & 7)); + } else { + if ((xga->accel.px_map_format[map] & 8) && !(xga->access_mode & 8)) { + mask = 1 << (x & 7); + } else { + mask = 1 << (7 - (x & 7)); + } } byte = (byte & ~mask) | ((pixel ? 0xff : 0) & mask); if (pixel & 1) { @@ -1029,34 +1002,19 @@ xga_accel_write_map_pixel(svga_t *svga, int x, int y, int map, uint32_t base, ui case 4: /*16-bit*/ addr += (y * width << 1); addr += (x << 1); - if (!skip) { - if (xga->accel.px_map_format[map] & 8) { - if (xga->linear_endian_reverse) { - WRITEW(addr, pixel); - } else { - WRITEW_REVERSE(addr, pixel); - } - } else { + if (xga->linear_endian_reverse) { + if ((xga->access_mode & 7) == 4) + pixel = ((pixel & 0xff00) >> 8) | ((pixel & 0x00ff) << 8); + else if (xga->access_mode & 8) + pixel = ((pixel & 0xff00) >> 8) | ((pixel & 0x00ff) << 8); + + mem_writew_phys(addr, pixel); + } else { + if (!skip) { WRITEW(addr, pixel); } + mem_writew_phys(addr, pixel); } - mem_writew_phys(addr, pixel); - break; - case 5: /*24-bit*/ - addr += (y * (width) << 2); - addr += (x << 2); - if (!skip) { - if ((xga->accel.px_map_format[map] & 8)) { - if (xga->linear_endian_reverse) { - WRITEL(addr, pixel); - } else { - WRITEL_REVERSE(addr, pixel); - } - } else { - WRITEL(addr, pixel); - } - } - mem_writel_phys(addr, pixel); break; } } @@ -1080,11 +1038,11 @@ xga_short_stroke(svga_t *svga, uint8_t ssv) int diry = 0; dx = xga->accel.dst_map_x & 0x1fff; - if (xga->accel.dst_map_x & 0x1800) + if (xga->accel.dst_map_x >= 0x1800) dx |= ~0x17ff; dy = xga->accel.dst_map_y & 0x1fff; - if (xga->accel.dst_map_y & 0x1800) + if (xga->accel.dst_map_y >= 0x1800) dy |= ~0x17ff; switch ((ssv >> 5) & 7) { @@ -1126,8 +1084,8 @@ xga_short_stroke(svga_t *svga, uint8_t ssv) while (y >= 0) { if (xga->accel.command & 0xc0) { if ((dx >= xga->accel.mask_map_origin_x_off) && (dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) && (dy >= xga->accel.mask_map_origin_y_off) && (dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) { - src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color; - dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1); + src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1, 1) : xga->accel.frgd_color; + dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1, 0); if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) { old_dest_dat = dest_dat; @@ -1146,8 +1104,8 @@ xga_short_stroke(svga_t *svga, uint8_t ssv) } } } else { - src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color; - dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1); + src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1, 1) : xga->accel.frgd_color; + dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1, 0); if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) { old_dest_dat = dest_dat; @@ -1239,11 +1197,11 @@ xga_line_draw_write(svga_t *svga) } dx = xga->accel.dst_map_x & 0x1fff; - if (xga->accel.dst_map_x & 0x1800) + if (xga->accel.dst_map_x >= 0x1800) dx |= ~0x17ff; dy = xga->accel.dst_map_y & 0x1fff; - if (xga->accel.dst_map_y & 0x1800) + if (xga->accel.dst_map_y >= 0x1800) dy |= ~0x17ff; if (xga->accel.octant & 0x01) { @@ -1257,8 +1215,8 @@ xga_line_draw_write(svga_t *svga) if (xga->accel.command & 0xc0) { if (steep) { if ((dx >= xga->accel.mask_map_origin_x_off) && (dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) && (dy >= xga->accel.mask_map_origin_y_off) && (dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) { - src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color; - dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1); + src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1, 1) : xga->accel.frgd_color; + dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1, 0); if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) { old_dest_dat = dest_dat; @@ -1274,8 +1232,8 @@ xga_line_draw_write(svga_t *svga) } } else { if ((dy >= xga->accel.mask_map_origin_x_off) && (dy <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) && (dx >= xga->accel.mask_map_origin_y_off) && (dx <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) { - src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color; - dest_dat = xga_accel_read_map_pixel(svga, dy, dx, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1); + src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1, 1) : xga->accel.frgd_color; + dest_dat = xga_accel_read_map_pixel(svga, dy, dx, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1, 0); if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) { old_dest_dat = dest_dat; @@ -1292,8 +1250,8 @@ xga_line_draw_write(svga_t *svga) } } else { if (steep) { - src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color; - dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1); + src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1, 1) : xga->accel.frgd_color; + dest_dat = xga_accel_read_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1, 0); if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) { old_dest_dat = dest_dat; @@ -1307,8 +1265,8 @@ xga_line_draw_write(svga_t *svga) xga_accel_write_map_pixel(svga, dx, dy, xga->accel.dst_map, dstbase, dest_dat, xga->accel.px_map_width[xga->accel.dst_map] + 1); } } else { - src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1) : xga->accel.frgd_color; - dest_dat = xga_accel_read_map_pixel(svga, dy, dx, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1); + src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.src_map_x & 0xfff, xga->accel.src_map_y & 0xfff, xga->accel.src_map, srcbase, xga->accel.px_map_width[xga->accel.src_map] + 1, 1) : xga->accel.frgd_color; + dest_dat = xga_accel_read_map_pixel(svga, dy, dx, xga->accel.dst_map, dstbase, xga->accel.px_map_width[xga->accel.dst_map] + 1, 0); if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) { old_dest_dat = dest_dat; @@ -1350,13 +1308,6 @@ xga_line_draw_write(svga_t *svga) } } -static int16_t -xga_dst_wrap(int16_t addr) -{ - addr &= 0x1fff; - return (addr & 0x1800) == 0x1800 ? (addr | 0xf800) : addr; -} - static void xga_bitblt(svga_t *svga) { @@ -1374,6 +1325,9 @@ xga_bitblt(svga_t *svga) uint32_t srcwidth = xga->accel.px_map_width[xga->accel.src_map]; uint32_t patheight = xga->accel.px_map_height[xga->accel.pat_src]; uint32_t srcheight = xga->accel.px_map_height[xga->accel.src_map]; + uint32_t dstheight = xga->accel.px_map_height[xga->accel.dst_map]; + uint32_t frgdcol = xga->accel.frgd_color; + uint32_t bkgdcol = xga->accel.bkgd_color; int mix = 0; int xdir; int ydir; @@ -1397,11 +1351,18 @@ xga_bitblt(svga_t *svga) xga->accel.sy = xga->accel.src_map_y & 0xfff; xga->accel.px = xga->accel.pat_map_x & 0xfff; xga->accel.py = xga->accel.pat_map_y & 0xfff; - xga->accel.dx = xga_dst_wrap(xga->accel.dst_map_x); - xga->accel.dy = xga_dst_wrap(xga->accel.dst_map_y); + xga->accel.dx = xga->accel.dst_map_x & 0x1fff; + if (xga->accel.dst_map_x >= 0x1800) + xga->accel.dx |= ~0x17ff; + xga->accel.dy = xga->accel.dst_map_y & 0x1fff; + if (xga->accel.dst_map_y >= 0x1800) + xga->accel.dy |= ~0x17ff; xga->accel.pattern = 0; + //pclog("XGA bitblt linear endian reverse=%d, access_mode=%x, octanty=%d, src command = %08x, pxsrcmap=%x, pxpatmap=%x, pxdstmap=%x, srcmap=%d, patmap=%d, dstmap=%d, usesrcvramfr=%d, usevrambk=%d.\n", + // xga->linear_endian_reverse, xga->access_mode & 0x0f, ydir, xga->accel.command, xga->accel.px_map_format[xga->accel.src_map] & 0x0f, xga->accel.px_map_format[xga->accel.pat_src] & 0x0f, xga->accel.px_map_format[xga->accel.dst_map] & 0x0f, xga->accel.src_map, xga->accel.pat_src, xga->accel.dst_map, ((xga->accel.command >> 28) & 3), ((xga->accel.command >> 30) & 3)); + if (xga->accel.pat_src == 8) { if (srcheight == 7) xga->accel.pattern = 1; @@ -1414,15 +1375,13 @@ xga_bitblt(svga_t *svga) } } } - // pclog("Pattern Map = 8: CMD = %08x: SRCBase = %08x, DSTBase = %08x, from/to vram dir = %d, cmd dir = %06x\n", xga->accel.command, srcbase, dstbase, xga->from_to_vram, xga->accel.dir_cmd); // pclog("CMD = %08x: Y = %d, X = %d, patsrc = %02x, srcmap = %d, dstmap = %d, py = %d, sy = %d, dy = %d, width0 = %d, width1 = %d, width2 = %d, width3 = %d\n", xga->accel.command, xga->accel.y, xga->accel.x, xga->accel.pat_src, xga->accel.src_map, xga->accel.dst_map, xga->accel.py, xga->accel.sy, xga->accel.dy, xga->accel.px_map_width[0], xga->accel.px_map_width[1], xga->accel.px_map_width[2], xga->accel.px_map_width[3]); while (xga->accel.y >= 0) { if (xga->accel.command & 0xc0) { if ((xga->accel.dx >= xga->accel.mask_map_origin_x_off) && (xga->accel.dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) && (xga->accel.dy >= xga->accel.mask_map_origin_y_off) && (xga->accel.dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) { - src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1) : xga->accel.frgd_color; - dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1); - + src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1, 1) : frgdcol; + dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1, 0); if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) { old_dest_dat = dest_dat; ROP(1, dest_dat, src_dat); @@ -1431,9 +1390,8 @@ xga_bitblt(svga_t *svga) } } } else { - src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1) : xga->accel.frgd_color; - dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1); - + src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1, 1) : frgdcol; + dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1, 0); if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) { old_dest_dat = dest_dat; ROP(1, dest_dat, src_dat); @@ -1446,15 +1404,17 @@ xga_bitblt(svga_t *svga) xga->accel.sx = ((xga->accel.sx + xdir) & srcwidth) | (xga->accel.sx & ~srcwidth); else xga->accel.sx += xdir; - xga->accel.dx = xga_dst_wrap(xga->accel.dx + xdir); + xga->accel.dx += xdir; xga->accel.x--; if (xga->accel.x < 0) { xga->accel.x = (xga->accel.blt_width & 0xfff); - xga->accel.dx = xga_dst_wrap(xga->accel.dst_map_x); + xga->accel.dx = xga->accel.dst_map_x & 0x1fff; + if (xga->accel.dst_map_x >= 0x1800) + xga->accel.dx |= ~0x17ff; xga->accel.sx = xga->accel.src_map_x & 0xfff; - xga->accel.dy = xga_dst_wrap(xga->accel.dy + ydir); + xga->accel.dy += ydir; if (xga->accel.pattern) xga->accel.sy = ((xga->accel.sy + ydir) & srcheight) | (xga->accel.sy & ~srcheight); else @@ -1493,6 +1453,7 @@ xga_bitblt(svga_t *svga) } } + // pclog("XGA bitblt linear endian reverse=%d, octanty=%d, src command = %08x, pxsrcmap=%x, pxdstmap=%x, srcmap=%d, patmap=%d, dstmap=%d, dstwidth=%d, dstheight=%d, srcwidth=%d, srcheight=%d, dstbase=%08x, srcbase=%08x.\n", xga->linear_endian_reverse, ydir, xga->accel.command, xga->accel.px_map_format[xga->accel.src_map] & 0x0f, xga->accel.px_map_format[xga->accel.dst_map] & 0x0f, xga->accel.src_map, xga->accel.pat_src, xga->accel.dst_map, dstwidth, dstheight, srcwidth, srcheight, dstbase, srcbase); // pclog("Pattern Map = %d: CMD = %08x: PATBase = %08x, SRCBase = %08x, DSTBase = %08x\n", xga->accel.pat_src, xga->accel.command, patbase, srcbase, dstbase); // pclog("CMD = %08x: Y = %d, X = %d, patsrc = %02x, srcmap = %d, dstmap = %d, py = %d, sy = %d, dy = %d, width0 = %d, width1 = %d, width2 = %d, width3 = %d\n", xga->accel.command, xga->accel.y, xga->accel.x, xga->accel.pat_src, xga->accel.src_map, xga->accel.dst_map, xga->accel.py, xga->accel.sy, xga->accel.dy, xga->accel.px_map_width[0], xga->accel.px_map_width[1], xga->accel.px_map_width[2], xga->accel.px_map_width[3]); while (xga->accel.y >= 0) { @@ -1500,13 +1461,12 @@ xga_bitblt(svga_t *svga) if (xga->accel.command & 0xc0) { if ((xga->accel.dx >= xga->accel.mask_map_origin_x_off) && (xga->accel.dx <= ((xga->accel.px_map_width[0] & 0xfff) + xga->accel.mask_map_origin_x_off)) && (xga->accel.dy >= xga->accel.mask_map_origin_y_off) && (xga->accel.dy <= ((xga->accel.px_map_height[0] & 0xfff) + xga->accel.mask_map_origin_y_off))) { - if (mix) - src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1) : xga->accel.frgd_color; - else - src_dat = (((xga->accel.command >> 30) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1) : xga->accel.bkgd_color; - - dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1); - + if (mix) { + src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1, 1) : frgdcol; + } else { + src_dat = (((xga->accel.command >> 30) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1, 1) : bkgdcol; + } + dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1, 0); if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) { old_dest_dat = dest_dat; ROP(mix, dest_dat, src_dat); @@ -1515,13 +1475,12 @@ xga_bitblt(svga_t *svga) } } } else { - if (mix) - src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1) : xga->accel.frgd_color; - else - src_dat = (((xga->accel.command >> 30) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1) : xga->accel.bkgd_color; - - dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1); - + if (mix) { + src_dat = (((xga->accel.command >> 28) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1, 1) : frgdcol; + } else { + src_dat = (((xga->accel.command >> 30) & 3) == 2) ? xga_accel_read_map_pixel(svga, xga->accel.sx, xga->accel.sy, xga->accel.src_map, srcbase, srcwidth + 1, 1) : bkgdcol; + } + dest_dat = xga_accel_read_map_pixel(svga, xga->accel.dx, xga->accel.dy, xga->accel.dst_map, dstbase, dstwidth + 1, 0); if ((xga->accel.cc_cond == 4) || ((xga->accel.cc_cond == 1) && (dest_dat > color_cmp)) || ((xga->accel.cc_cond == 2) && (dest_dat == color_cmp)) || ((xga->accel.cc_cond == 3) && (dest_dat < color_cmp)) || ((xga->accel.cc_cond == 5) && (dest_dat >= color_cmp)) || ((xga->accel.cc_cond == 6) && (dest_dat != color_cmp)) || ((xga->accel.cc_cond == 7) && (dest_dat <= color_cmp))) { old_dest_dat = dest_dat; ROP(mix, dest_dat, src_dat); @@ -1535,13 +1494,15 @@ xga_bitblt(svga_t *svga) xga->accel.px = ((xga->accel.px + xdir) & patwidth) | (xga->accel.px & ~patwidth); else xga->accel.px += xdir; - xga->accel.dx = xga_dst_wrap(xga->accel.dx + xdir); + xga->accel.dx += xdir; xga->accel.x--; if (xga->accel.x < 0) { xga->accel.y--; xga->accel.x = (xga->accel.blt_width & 0xfff); - xga->accel.dx = xga_dst_wrap(xga->accel.dst_map_x); + xga->accel.dx = xga->accel.dst_map_x & 0x1fff; + if (xga->accel.dst_map_x >= 0x1800) + xga->accel.dx |= ~0x17ff; xga->accel.sx = xga->accel.src_map_x & 0xfff; xga->accel.px = xga->accel.pat_map_x & 0xfff; @@ -1550,7 +1511,7 @@ xga_bitblt(svga_t *svga) xga->accel.py = ((xga->accel.py + ydir) & patheight) | (xga->accel.py & ~patheight); else xga->accel.py += ydir; - xga->accel.dy = xga_dst_wrap(xga->accel.dy + ydir); + xga->accel.dy += ydir; if (xga->accel.y < 0) { xga->accel.dst_map_x = xga->accel.dx; @@ -1952,7 +1913,6 @@ xga_mem_write(uint32_t addr, uint32_t val, xga_t *xga, svga_t *svga, int len) exec_command: xga->accel.octant = xga->accel.command & 0x07; xga->accel.draw_mode = xga->accel.command & 0x30; - xga->accel.mask_mode = xga->accel.command & 0xc0; xga->accel.pat_src = ((xga->accel.command >> 12) & 0x0f); xga->accel.dst_map = ((xga->accel.command >> 16) & 0x0f); xga->accel.src_map = ((xga->accel.command >> 20) & 0x0f); @@ -1973,18 +1933,23 @@ exec_command: // } switch ((xga->accel.command >> 24) & 0x0f) { case 3: /*Bresenham Line Draw Read*/ - // pclog("Line Draw Read\n"); + //pclog("Line Draw Read\n"); break; case 4: /*Short Stroke Vectors*/ + //pclog("Short Stroke Vectors.\n"); break; case 5: /*Bresenham Line Draw Write*/ + //pclog("Line Draw Write.\n"); xga_line_draw_write(svga); break; case 8: /*BitBLT*/ xga_bitblt(svga); break; case 9: /*Inverting BitBLT*/ - // pclog("Inverting BitBLT\n"); + //pclog("Inverting BitBLT\n"); + break; + case 0x0a: /*Area Fill*/ + //pclog("Area Fill.\n"); break; } } else if (len == 2) { @@ -2014,9 +1979,9 @@ exec_command: } static void -xga_memio_writeb(uint32_t addr, uint8_t val, void *priv) +xga_memio_writeb(uint32_t addr, uint8_t val, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; xga_mem_write(addr, val, xga, svga, 1); @@ -2024,9 +1989,9 @@ xga_memio_writeb(uint32_t addr, uint8_t val, void *priv) } static void -xga_memio_writew(uint32_t addr, uint16_t val, void *priv) +xga_memio_writew(uint32_t addr, uint16_t val, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; xga_mem_write(addr, val, xga, svga, 2); @@ -2034,9 +1999,9 @@ xga_memio_writew(uint32_t addr, uint16_t val, void *priv) } static void -xga_memio_writel(uint32_t addr, uint32_t val, void *priv) +xga_memio_writel(uint32_t addr, uint32_t val, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; xga_mem_write(addr, val, xga, svga, 4); @@ -2125,9 +2090,9 @@ xga_mem_read(uint32_t addr, xga_t *xga, svga_t *svga) } static uint8_t -xga_memio_readb(uint32_t addr, void *priv) +xga_memio_readb(uint32_t addr, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; uint8_t temp; @@ -2138,9 +2103,9 @@ xga_memio_readb(uint32_t addr, void *priv) } static uint16_t -xga_memio_readw(uint32_t addr, void *priv) +xga_memio_readw(uint32_t addr, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; uint16_t temp; @@ -2152,9 +2117,9 @@ xga_memio_readw(uint32_t addr, void *priv) } static uint32_t -xga_memio_readl(uint32_t addr, void *priv) +xga_memio_readl(uint32_t addr, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; uint32_t temp; @@ -2326,9 +2291,9 @@ xga_render_16bpp(xga_t *xga, svga_t *svga) } static void -xga_write(uint32_t addr, uint8_t val, void *priv) +xga_write(uint32_t addr, uint8_t val, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; if (!xga->on) { @@ -2344,39 +2309,114 @@ xga_write(uint32_t addr, uint8_t val, void *priv) cycles -= video_timing_write_b; + if (xga->access_mode & 8) { + if ((xga->access_mode & 7) == 4) + addr ^= 1; + } + xga->changedvram[(addr & xga->vram_mask) >> 12] = svga->monitor->mon_changeframecount; - xga->vram[addr & xga->vram_mask] = val; + xga->vram[addr & xga->vram_mask] = val; } static void -xga_writeb(uint32_t addr, uint8_t val, void *priv) +xga_writew(uint32_t addr, uint16_t val, void *p) { - // pclog("[%04X:%08X]: WriteB\n", CS, cpu_state.pc); - xga_write(addr, val, priv); + svga_t *svga = (svga_t *) p; + xga_t *xga = &svga->xga; + + if (!xga->on) { + svga_writew(addr, val, svga); + return; + } + + xga_write(addr, val & 0xff, svga); + xga_write(addr + 1, val >> 8, svga); } static void -xga_writew(uint32_t addr, uint16_t val, void *priv) +xga_writel(uint32_t addr, uint32_t val, void *p) { - // pclog("[%04X:%08X]: WriteW\n", CS, cpu_state.pc); - xga_write(addr, val, priv); - xga_write(addr + 1, val >> 8, priv); + svga_t *svga = (svga_t *) p; + xga_t *xga = &svga->xga; + + if (!xga->on) { + svga_writel(addr, val, svga); + return; + } + + xga_write(addr, val & 0xff, svga); + xga_write(addr + 1, (val >> 8) & 0xff, svga); + xga_write(addr + 2, (val >> 16) & 0xff, svga); + xga_write(addr + 3, (val >> 24) & 0xff, svga); +} + + +static uint8_t +xga_read(uint32_t addr, void *p) +{ + svga_t *svga = (svga_t *) p; + xga_t *xga = &svga->xga; + uint8_t ret = 0xff; + + if (!xga->on) + return svga_read(addr, svga); + + addr &= xga->banked_mask; + addr += xga->read_bank; + + if (addr >= xga->vram_size) + return ret; + + cycles -= video_timing_read_b; + + if (xga->access_mode & 8) { + if ((xga->access_mode & 7) == 4) + addr ^= 1; + } + + ret = xga->vram[addr & xga->vram_mask]; + + return ret; +} + +static uint16_t +xga_readw(uint32_t addr, void *p) +{ + svga_t *svga = (svga_t *) p; + xga_t *xga = &svga->xga; + uint16_t ret = 0xffff; + + if (!xga->on) + return svga_readw(addr, svga); + + ret = xga_read(addr, svga); + ret |= (xga_read(addr + 1, svga) << 8); + + return ret; +} + +static uint32_t +xga_readl(uint32_t addr, void *p) +{ + svga_t *svga = (svga_t *) p; + xga_t *xga = &svga->xga; + uint32_t ret = 0xffffffff; + + if (!xga->on) + return svga_readl(addr, svga); + + ret = xga_read(addr, svga); + ret |= (xga_read(addr + 1, svga) << 8); + ret |= (xga_read(addr + 2, svga) << 16); + ret |= (xga_read(addr + 3, svga) << 24); + + return ret; } static void -xga_writel(uint32_t addr, uint32_t val, void *priv) +xga_write_linear(uint32_t addr, uint8_t val, void *p) { - // pclog("[%04X:%08X]: WriteL\n", CS, cpu_state.pc); - xga_write(addr, val, priv); - xga_write(addr + 1, val >> 8, priv); - xga_write(addr + 2, val >> 16, priv); - xga_write(addr + 3, val >> 24, priv); -} - -static void -xga_write_linear(uint32_t addr, uint8_t val, void *priv) -{ - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; if (!xga->on) { @@ -2391,14 +2431,24 @@ xga_write_linear(uint32_t addr, uint8_t val, void *priv) cycles -= video_timing_write_b; + if (xga->linear_endian_reverse) { + if ((xga->access_mode & 7) == 4) { + if ((xga->accel.px_map_format[xga->accel.dst_map] & 7) == 4) + addr ^= 1; + } else if (xga->access_mode & 8) { + if ((xga->accel.px_map_format[xga->accel.dst_map] & 7) == 4) + addr ^= 1; + } + } + xga->changedvram[(addr & xga->vram_mask) >> 12] = svga->monitor->mon_changeframecount; xga->vram[addr & xga->vram_mask] = val; } static void -xga_writew_linear(uint32_t addr, uint16_t val, void *priv) +xga_writew_linear(uint32_t addr, uint16_t val, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; if (!xga->on) { @@ -2406,35 +2456,14 @@ xga_writew_linear(uint32_t addr, uint16_t val, void *priv) return; } - if (xga->linear_endian_reverse) { - if (xga->accel.px_map_format[xga->accel.dst_map] == 0x0c) { - xga_write_linear(addr, val, priv); - xga_write_linear(addr + 1, val >> 8, priv); - } else if (xga->accel.px_map_format[xga->accel.dst_map] == 4) { - xga_write_linear(addr + 1, val, priv); - xga_write_linear(addr, val >> 8, priv); - } else { - xga_write_linear(addr, val, priv); - xga_write_linear(addr + 1, val >> 8, priv); - } - } else { - if (xga->accel.px_map_format[xga->accel.dst_map] == 0x0c) { - xga_write_linear(addr + 1, val, priv); - xga_write_linear(addr, val >> 8, priv); - } else if (xga->accel.px_map_format[xga->accel.dst_map] == 4) { - xga_write_linear(addr, val, priv); - xga_write_linear(addr + 1, val >> 8, priv); - } else { - xga_write_linear(addr, val, priv); - xga_write_linear(addr + 1, val >> 8, priv); - } - } + xga_write_linear(addr, val, p); + xga_write_linear(addr + 1, val >> 8, p); } static void -xga_writel_linear(uint32_t addr, uint32_t val, void *priv) +xga_writel_linear(uint32_t addr, uint32_t val, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; if (!xga->on) { @@ -2442,71 +2471,18 @@ xga_writel_linear(uint32_t addr, uint32_t val, void *priv) return; } - xga_write_linear(addr, val, priv); - xga_write_linear(addr + 1, val >> 8, priv); - xga_write_linear(addr + 2, val >> 16, priv); - xga_write_linear(addr + 3, val >> 24, priv); + xga_write_linear(addr, val, p); + xga_write_linear(addr + 1, val >> 8, p); + xga_write_linear(addr + 2, val >> 16, p); + xga_write_linear(addr + 3, val >> 24, p); } static uint8_t -xga_read(uint32_t addr, void *priv) +xga_read_linear(uint32_t addr, void *p) { - svga_t *svga = (svga_t *) priv; - xga_t *xga = &svga->xga; - - if (!xga->on) - return svga_read(addr, svga); - - addr &= xga->banked_mask; - addr += xga->read_bank; - - if (addr >= xga->vram_size) - return 0xff; - - cycles -= video_timing_read_b; - - return xga->vram[addr & xga->vram_mask]; -} - -static uint8_t -xga_readb(uint32_t addr, void *priv) -{ - uint8_t ret; - - ret = xga_read(addr, priv); - - return ret; -} - -static uint16_t -xga_readw(uint32_t addr, void *priv) -{ - uint16_t ret; - - ret = xga_read(addr, priv); - ret |= (xga_read(addr + 1, priv) << 8); - - return ret; -} - -static uint32_t -xga_readl(uint32_t addr, void *priv) -{ - uint32_t ret; - - ret = xga_read(addr, priv); - ret |= (xga_read(addr + 1, priv) << 8); - ret |= (xga_read(addr + 2, priv) << 16); - ret |= (xga_read(addr + 3, priv) << 24); - - return ret; -} - -static uint8_t -xga_read_linear(uint32_t addr, void *priv) -{ - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; + uint8_t ret = 0xff; if (!xga->on) return svga_read_linear(addr, svga); @@ -2514,51 +2490,55 @@ xga_read_linear(uint32_t addr, void *priv) addr &= svga->decode_mask; if (addr >= xga->vram_size) - return 0xff; + return ret; cycles -= video_timing_read_b; + if (xga->linear_endian_reverse) { + if ((xga->access_mode & 7) == 4) { + if ((xga->accel.px_map_format[xga->accel.dst_map] & 7) == 4) + addr ^= 1; + } else if (xga->access_mode & 8) { + if ((xga->accel.px_map_format[xga->accel.dst_map] & 7) == 4) + addr ^= 1; + } + } + return xga->vram[addr & xga->vram_mask]; } static uint16_t -xga_readw_linear(uint32_t addr, void *priv) +xga_readw_linear(uint32_t addr, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; uint16_t ret; if (!xga->on) return svga_readw_linear(addr, svga); - if (xga->linear_endian_reverse) { - if (xga->accel.px_map_format[xga->accel.src_map] == 0x0c) { - ret = xga_read_linear(addr, priv) | (xga_read_linear(addr + 1, priv) << 8); - } else if (xga->accel.px_map_format[xga->accel.src_map] == 4) { - ret = xga_read_linear(addr + 1, priv) | (xga_read_linear(addr, priv) << 8); - } else - ret = xga_read_linear(addr, priv) | (xga_read_linear(addr + 1, priv) << 8); - } else { - if (xga->accel.px_map_format[xga->accel.src_map] == 0x0c) { - ret = xga_read_linear(addr + 1, priv) | (xga_read_linear(addr, priv) << 8); - } else if (xga->accel.px_map_format[xga->accel.src_map] == 4) { - ret = xga_read_linear(addr, priv) | (xga_read_linear(addr + 1, priv) << 8); - } else - ret = xga_read_linear(addr, priv) | (xga_read_linear(addr + 1, priv) << 8); - } + ret = xga_read_linear(addr, svga); + ret |= (xga_read_linear(addr + 1, svga) << 8); + return ret; } static uint32_t -xga_readl_linear(uint32_t addr, void *priv) +xga_readl_linear(uint32_t addr, void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; + uint32_t ret; if (!xga->on) return svga_readl_linear(addr, svga); - return xga_read_linear(addr, priv) | (xga_read_linear(addr + 1, priv) << 8) | (xga_read_linear(addr + 2, priv) << 16) | (xga_read_linear(addr + 3, priv) << 24); + ret = xga_read_linear(addr, svga); + ret |= (xga_read_linear(addr + 1, svga) << 8); + ret |= (xga_read_linear(addr + 2, svga) << 16); + ret |= (xga_read_linear(addr + 3, svga) << 24); + + return ret; } static void @@ -2793,9 +2773,9 @@ xga_mca_feedb(void *priv) } static void -xga_mca_reset(void *priv) +xga_mca_reset(void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; xga->on = 0; @@ -2804,9 +2784,9 @@ xga_mca_reset(void *priv) } static void -xga_reset(void *priv) +xga_reset(void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; mem_mapping_disable(&xga->bios_rom.mapping); @@ -3033,8 +3013,8 @@ static void xga->rom_addr = 0xc0000 + (((xga->pos_regs[2] & 0xf0) >> 4) * 0x2000); } - mem_mapping_add(&xga->video_mapping, 0, 0, xga_readb, xga_readw, xga_readl, - xga_writeb, xga_writew, xga_writel, + mem_mapping_add(&xga->video_mapping, 0, 0, xga_read, xga_readw, xga_readl, + xga_write, xga_writew, xga_writel, NULL, MEM_MAPPING_EXTERNAL, svga); mem_mapping_add(&xga->linear_mapping, 0, 0, xga_read_linear, xga_readw_linear, xga_readl_linear, xga_write_linear, xga_writew_linear, xga_writel_linear, @@ -3090,9 +3070,9 @@ static void } static void -xga_close(void *priv) +xga_close(void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; xga_t *xga = &svga->xga; if (svga) { @@ -3114,17 +3094,17 @@ inmos_xga_available(void) } static void -xga_speed_changed(void *priv) +xga_speed_changed(void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; svga_recalctimings(svga); } static void -xga_force_redraw(void *priv) +xga_force_redraw(void *p) { - svga_t *svga = (svga_t *) priv; + svga_t *svga = (svga_t *) p; svga->fullchange = svga->monitor->mon_changeframecount; }