From 8bc667b5e02f3c7acf23798e3978dcfe57e8c2ff Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 12 Dec 2024 14:23:11 -0500 Subject: [PATCH 1/9] Remove some obsolete code in the SID --- src/sound/snd_resid.cpp | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/sound/snd_resid.cpp b/src/sound/snd_resid.cpp index dce89eb2e..746b5f971 100644 --- a/src/sound/snd_resid.cpp +++ b/src/sound/snd_resid.cpp @@ -22,16 +22,10 @@ psid_t *psid; void * sid_init(void) { -#if 0 - psid_t *psid; -#endif reSIDfp::SamplingMethod method = reSIDfp::RESAMPLE; float cycles_per_sec = 14318180.0 / 16.0; - psid = new psid_t; -#if 0 - psid = (psid_t *) malloc(sizeof(sound_t)); -#endif + psid = new psid_t; psid->sid = new SID; psid->sid->setChipModel(reSIDfp::MOS6581); @@ -57,9 +51,6 @@ sid_init(void) void sid_close(UNUSED(void *priv)) { -#if 0 - psid_t *psid = (psid_t *) priv; -#endif delete psid->sid; #if 0 free(psid); @@ -69,10 +60,6 @@ sid_close(UNUSED(void *priv)) void sid_reset(UNUSED(void *priv)) { -#if 0 - psid_t *psid = (psid_t *) priv; -#endif - psid->sid->reset(); for (uint8_t c = 0; c < 32; c++) @@ -82,23 +69,12 @@ sid_reset(UNUSED(void *priv)) uint8_t sid_read(uint16_t addr, UNUSED(void *priv)) { -#if 0 - psid_t *psid = (psid_t *) priv; -#endif - return psid->sid->read(addr & 0x1f); -#if 0 - return 0xFF; -#endif } void sid_write(uint16_t addr, uint8_t val, UNUSED(void *priv)) { -#if 0 - psid_t *psid = (psid_t *) priv; -#endif - psid->sid->write(addr & 0x1f, val); } @@ -116,9 +92,6 @@ fillbuf2(int &count, int16_t *buf, int len) void sid_fillbuf(int16_t *buf, int len, UNUSED(void *priv)) { -#if 0 - psid_t *psid = (psid_t *) priv; -#endif int x = CLOCK_DELTA(len); fillbuf2(x, buf, len); From 5a6b5b3692a3e2718f1efe75d07eeea3a566c031 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 12 Dec 2024 14:29:41 -0500 Subject: [PATCH 2/9] Some SSI-2001 formatting --- src/sound/snd_ssi2001.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sound/snd_ssi2001.c b/src/sound/snd_ssi2001.c index 9afb5c6ea..36bce543f 100644 --- a/src/sound/snd_ssi2001.c +++ b/src/sound/snd_ssi2001.c @@ -126,15 +126,15 @@ static const device_config_t ssi2001_config[] = { }; const device_t ssi2001_device = { - .name = "Innovation SSI-2001", + .name = "Innovation SSI-2001", .internal_name = "ssi2001", - .flags = DEVICE_ISA, - .local = 0, - .init = ssi2001_init, - .close = ssi2001_close, - .reset = NULL, - { .available = NULL }, + .flags = DEVICE_ISA, + .local = 0, + .init = ssi2001_init, + .close = ssi2001_close, + .reset = NULL, + { .available = NULL }, .speed_changed = NULL, - .force_redraw = NULL, - .config = ssi2001_config + .force_redraw = NULL, + .config = ssi2001_config }; From 461e59f4a539f308a13721fc8d073efbd914d37e Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 12 Dec 2024 14:29:51 -0500 Subject: [PATCH 3/9] Initial Flexibility to set SID type --- src/include/86box/snd_resid.h | 2 +- src/sound/snd_resid.cpp | 10 ++++++++-- src/sound/snd_ssi2001.c | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/include/86box/snd_resid.h b/src/include/86box/snd_resid.h index 4ddaf9b91..c7e97ac0f 100644 --- a/src/include/86box/snd_resid.h +++ b/src/include/86box/snd_resid.h @@ -4,7 +4,7 @@ #ifdef __cplusplus extern "C" { #endif -void *sid_init(void); +void *sid_init(uint8_t type); void sid_close(void *priv); void sid_reset(void *priv); uint8_t sid_read(uint16_t addr, void *priv); diff --git a/src/sound/snd_resid.cpp b/src/sound/snd_resid.cpp index 746b5f971..b9895cf7e 100644 --- a/src/sound/snd_resid.cpp +++ b/src/sound/snd_resid.cpp @@ -20,7 +20,7 @@ typedef struct psid_t { psid_t *psid; void * -sid_init(void) +sid_init(uint8_t type) { reSIDfp::SamplingMethod method = reSIDfp::RESAMPLE; float cycles_per_sec = 14318180.0 / 16.0; @@ -28,7 +28,13 @@ sid_init(void) psid = new psid_t; psid->sid = new SID; - psid->sid->setChipModel(reSIDfp::MOS6581); + switch (type) { + default: + case 0: + psid->sid->setChipModel(reSIDfp::MOS6581); + case 1: + psid->sid->setChipModel(reSIDfp::MOS8580); + } psid->sid->reset(); diff --git a/src/sound/snd_ssi2001.c b/src/sound/snd_ssi2001.c index 36bce543f..e7f053ea8 100644 --- a/src/sound/snd_ssi2001.c +++ b/src/sound/snd_ssi2001.c @@ -69,7 +69,7 @@ ssi2001_init(UNUSED(const device_t *info)) ssi2001_t *ssi2001 = malloc(sizeof(ssi2001_t)); memset(ssi2001, 0, sizeof(ssi2001_t)); - ssi2001->psid = sid_init(); + ssi2001->psid = sid_init(0); sid_reset(ssi2001->psid); uint16_t addr = device_get_config_hex16("base"); ssi2001->gameport_enabled = device_get_config_int("gameport"); From 04d777506c30292597a7911f81912f627430e24b Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Wed, 27 Nov 2024 03:58:47 -0500 Subject: [PATCH 4/9] Add "The Entertainer" sound device --- src/include/86box/sound.h | 1 + src/sound/snd_ssi2001.c | 67 +++++++++++++++++++++++++++++++++++++++ src/sound/sound.c | 1 + 3 files changed, 69 insertions(+) diff --git a/src/include/86box/sound.h b/src/include/86box/sound.h index bcf7f2ae5..2a41b98f8 100644 --- a/src/include/86box/sound.h +++ b/src/include/86box/sound.h @@ -192,6 +192,7 @@ extern const device_t ps1snd_device; /* Innovation SSI-2001 */ extern const device_t ssi2001_device; +extern const device_t entertainer_device; /* Pro Audio Spectrum Plus, 16, and 16D */ extern const device_t pasplus_device; diff --git a/src/sound/snd_ssi2001.c b/src/sound/snd_ssi2001.c index e7f053ea8..11a10473c 100644 --- a/src/sound/snd_ssi2001.c +++ b/src/sound/snd_ssi2001.c @@ -21,6 +21,10 @@ typedef struct ssi2001_t { int gameport_enabled; } ssi2001_t; +typedef struct entertainer_t { + uint8_t regs; +} entertainer_t; + static void ssi2001_update(ssi2001_t *ssi2001) { @@ -90,6 +94,48 @@ ssi2001_close(void *priv) free(ssi2001); } +static uint8_t +entertainer_read(uint16_t addr, void *priv) +{ + return 0xa5; +} + +static void +entertainer_write(uint16_t addr, uint8_t val, void *priv) +{ + entertainer_t *entertainer = (entertainer_t *) priv; + entertainer->regs = val; +} + +void * +entertainer_init(UNUSED(const device_t *info)) +{ + ssi2001_t *ssi2001 = malloc(sizeof(ssi2001_t)); + entertainer_t *entertainer = malloc(sizeof(entertainer_t)); + memset(ssi2001, 0, sizeof(ssi2001_t)); + memset(entertainer, 0, sizeof(entertainer_t)); + + ssi2001->psid = sid_init(0); + sid_reset(ssi2001->psid); + ssi2001->gameport_enabled = device_get_config_int("gameport"); + io_sethandler(0x200, 0x0001, entertainer_read, NULL, NULL, entertainer_write, NULL, NULL, entertainer); + io_sethandler(0x280, 0x0020, ssi2001_read, NULL, NULL, ssi2001_write, NULL, NULL, ssi2001); + if (ssi2001->gameport_enabled) + gameport_remap(gameport_add(&gameport_201_device), 0x201); + sound_add_handler(ssi2001_get_buffer, ssi2001); + return ssi2001; +} + +void +entertainer_close(void *priv) +{ + ssi2001_t *ssi2001 = (ssi2001_t *) priv; + + sid_close(ssi2001->psid); + + free(ssi2001); +} + static const device_config_t ssi2001_config[] = { // clang-format off { @@ -125,6 +171,13 @@ static const device_config_t ssi2001_config[] = { // clang-format off }; +static const device_config_t entertainer_config[] = { + // clang-format off + { "gameport", "Enable Game port", CONFIG_BINARY, "", 1 }, + { "", "", -1 } +// clang-format off +}; + const device_t ssi2001_device = { .name = "Innovation SSI-2001", .internal_name = "ssi2001", @@ -138,3 +191,17 @@ const device_t ssi2001_device = { .force_redraw = NULL, .config = ssi2001_config }; + +const device_t entertainer_device = { + .name = "The Entertainer", + .internal_name = "Entertainer", + .flags = DEVICE_ISA, + .local = 1, + .init = entertainer_init, + .close = entertainer_close, + .reset = NULL, + { .available = NULL }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = entertainer_config +}; diff --git a/src/sound/sound.c b/src/sound/sound.c index 7e6a1ac1c..d2d3dc313 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -132,6 +132,7 @@ static const SOUND_CARD sound_cards[] = { { &sb_vibra16s_device }, { &sb_vibra16xv_device }, { &ssi2001_device }, + { &entertainer_device }, { &pasplus_device }, { &pas16_device }, { &pas16d_device }, From 3434d7d86834d741e4ed72f5e243342e63531c07 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 13 Dec 2024 04:22:02 +0100 Subject: [PATCH 5/9] A few serial port fixes, now passes Norton Diagnostics tests as well. --- src/device/serial.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/device/serial.c b/src/device/serial.c index 2b832f750..dcaff0f7f 100644 --- a/src/device/serial.c +++ b/src/device/serial.c @@ -197,6 +197,8 @@ serial_receive_timer(void *priv) /* Raise Data Ready interrupt. */ dev->lsr |= 0x01; dev->int_status |= SERIAL_INT_RECEIVE; + if (dev->lsr & 0x02) + dev->int_status |= SERIAL_INT_LSR; serial_update_ints(dev); } @@ -266,10 +268,6 @@ serial_move_to_txsr(serial_t *dev) /* Update interrupts to signal THRE and that TXSR is no longer empty. */ serial_update_ints(dev); } - if (dev->transmit_enabled & 2) - dev->baud_cycles++; - else - dev->baud_cycles = 0; /* If not moving while transmitting, reset BAUDOUT cycle count. */ if (!dev->fifo_enabled || (fifo_get_count(dev->xmit_fifo) == 0x0)) dev->transmit_enabled &= ~1; /* Stop moving. */ dev->transmit_enabled |= 2; /* Start transmitting. */ @@ -303,16 +301,26 @@ static void serial_transmit_timer(void *priv) { serial_t *dev = (serial_t *) priv; - int delay = 8; /* STOP to THRE delay is 8 BAUDOUT cycles. */ + /* + Norton Diagnostics waits for up to 2 bit periods, this is + confirmed by the NS16550A timings graph, which shows operation + as follows after write: 1 bit of delay, then start bit, and at + the end of the start bit, move from THR to TXSR. + */ + int delay = 1; if (dev->transmit_enabled & 3) { + /* + If already transmitting, move from THR to TXSR at the end of + the last data bit. + */ if ((dev->transmit_enabled & 1) && (dev->transmit_enabled & 2)) - delay = dev->data_bits; /* Delay by less if already transmitting. */ + delay = dev->data_bits + 1; dev->baud_cycles++; - /* We have processed (total bits) BAUDOUT cycles, transmit the byte. */ - if ((dev->baud_cycles == dev->bits) && (dev->transmit_enabled & 2)) + /* We have processed (delay + total bits) BAUDOUT cycles, transmit the byte. */ + if ((dev->baud_cycles == (dev->bits + 1)) && (dev->transmit_enabled & 2)) serial_process_txsr(dev); /* We have processed (data bits) BAUDOUT cycles. */ @@ -614,6 +622,11 @@ serial_write(uint16_t addr, uint8_t val, void *priv) dev->msr = new_msr; + if (dev->msr & 0x0f) { + dev->int_status |= SERIAL_INT_MSR; + serial_update_ints(dev); + } + /* TODO: Why reset the FIFO's here?! */ fifo_reset(dev->xmit_fifo); fifo_reset(dev->rcvr_fifo); From 89942fac75087e91926bfea74b561bcc477c467f Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 13 Dec 2024 05:56:57 +0100 Subject: [PATCH 6/9] Some clean-ups and corrections for the OPL2 board, fixes warning in snd_opl.c. --- src/include/86box/snd_opl.h | 14 +++++++------- src/sound/snd_opl2board.c | 35 +++++++++++++---------------------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/include/86box/snd_opl.h b/src/include/86box/snd_opl.h index 8a6a7d6ef..fe0112b47 100644 --- a/src/include/86box/snd_opl.h +++ b/src/include/86box/snd_opl.h @@ -18,13 +18,13 @@ #define SOUND_OPL_H enum fm_type { - FM_YM3812 = 0, /* OPL2 */ - FM_YMF262 = 1, /* OPL3 */ - FM_YMF289B = 2, /* OPL3-L */ - FM_YMF278B = 3, /* OPL 4 */ - FM_ESFM = 4, /* ESFM */ - FM_MAX = 5, - FM_OPL2BOARD = 6 /* OPL2BOARD (External Device)*/ + FM_YM3812 = 0, /* OPL2 */ + FM_YMF262 = 1, /* OPL3 */ + FM_YMF289B = 2, /* OPL3-L */ + FM_YMF278B = 3, /* OPL 4 */ + FM_ESFM = 4, /* ESFM */ + FM_OPL2BOARD = 5, /* OPL2BOARD (External Device)*/ + FM_MAX = 6 }; enum fm_driver { diff --git a/src/sound/snd_opl2board.c b/src/sound/snd_opl2board.c index 57fafbae7..efd408b97 100644 --- a/src/sound/snd_opl2board.c +++ b/src/sound/snd_opl2board.c @@ -56,15 +56,9 @@ opl2board_device_log(const char *fmt, ...) typedef struct opl2board_device_t { fm_drv_t opl; - - uint8_t pos_regs[8]; - - + uint8_t pos_regs[8]; } opl2board_device_t; - - - static void opl2board_device_get_buffer(int32_t *buffer, int len, void *priv) { @@ -115,6 +109,7 @@ opl2board_device_mca_write(int port, uint8_t val, void *priv) default: break; } + serial->pos_regs[port & 7] = val; } @@ -131,8 +126,7 @@ opl2board_device_init(UNUSED(const device_t *info)) { opl2board_device_t *serial = malloc(sizeof(opl2board_device_t)); memset(serial, 0, sizeof(opl2board_device_t)); - - + opl2board_device_log("opl2board_device_init\n"); fm_driver_get(FM_OPL2BOARD, &serial->opl); io_sethandler(0x0388, 0x0002, @@ -141,9 +135,7 @@ opl2board_device_init(UNUSED(const device_t *info)) serial->opl.priv); music_add_handler(opl2board_device_get_buffer, serial); - return serial; - } void * @@ -175,19 +167,18 @@ opl2board_device_close(void *priv) static const device_config_t opl2board_config[] = { - - { - .name = "host_serial_path", - .description = "Host Serial Device", - .type = CONFIG_SERPORT, - .default_string = "", - .file_filter = NULL, - .spinner = {}, - .selection = {} +{ + .name = "host_serial_path", + .description = "Host Serial Device", + .type = CONFIG_SERPORT, + .default_string = "", + .file_filter = NULL, + .spinner = {}, + .selection = {} }, - { .name = "", .description = "", .type = CONFIG_END } + { .name = "", .description = "", .type = CONFIG_END } +}; - }; const device_t opl2board_device = { .name = "OPL2Board (External Device)", .internal_name = "opl2board_device", From 6710b968c093cbe27bef66518c14779fbfcc2875 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 13 Dec 2024 06:06:49 +0100 Subject: [PATCH 7/9] Fixed the warnings in config.c. --- src/config.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/config.c b/src/config.c index 5a3f507c1..2f1561f18 100644 --- a/src/config.c +++ b/src/config.c @@ -895,9 +895,9 @@ load_storage_controllers(void) fatal("load_storage_controllers(): strlen(p) > 2047 " "(cassette_image_history[%i])\n", i); else - snprintf(cassette_image_history[i], (MAX_IMAGE_PATH_LEN - 1), "%s", p); + snprintf(cassette_image_history[i], MAX_IMAGE_PATH_LEN, "%s", p); } else - snprintf(cassette_image_history[i], (MAX_IMAGE_PATH_LEN - 1), "%s%s%s", usr_path, + snprintf(cassette_image_history[i], MAX_IMAGE_PATH_LEN, "%s%s%s", usr_path, path_get_slash(usr_path), p); path_normalize(cassette_image_history[i]); } @@ -960,9 +960,9 @@ load_storage_controllers(void) fatal("load_storage_controllers(): strlen(p) > 2047 " "(cart_image_history[%i][%i])\n", c, i); else - snprintf(cart_image_history[c][i], (MAX_IMAGE_PATH_LEN - 1), "%s", p); + snprintf(cart_image_history[c][i], MAX_IMAGE_PATH_LEN, "%s", p); } else - snprintf(cart_image_history[c][i], (MAX_IMAGE_PATH_LEN - 1), "%s%s%s", usr_path, + snprintf(cart_image_history[c][i], MAX_IMAGE_PATH_LEN, "%s%s%s", usr_path, path_get_slash(usr_path), p); path_normalize(cart_image_history[c][i]); } @@ -1259,9 +1259,9 @@ load_floppy_and_cdrom_drives(void) fatal("load_floppy_and_cdrom_drives(): strlen(p) > 2047 " "(fdd_image_history[%i][%i])\n", c, i); else - snprintf(fdd_image_history[c][i], (MAX_IMAGE_PATH_LEN - 1), "%s", p); + snprintf(fdd_image_history[c][i], MAX_IMAGE_PATH_LEN, "%s", p); } else - snprintf(fdd_image_history[c][i], (MAX_IMAGE_PATH_LEN - 1), "%s%s%s", usr_path, + snprintf(fdd_image_history[c][i], MAX_IMAGE_PATH_LEN, "%s%s%s", usr_path, path_get_slash(usr_path), p); path_normalize(fdd_image_history[c][i]); } @@ -1370,9 +1370,9 @@ load_floppy_and_cdrom_drives(void) fatal("load_floppy_and_cdrom_drives(): strlen(p) > 2047 " "(cdrom[%i].image_history[%i])\n", c, i); else - snprintf(cdrom[c].image_history[i], (MAX_IMAGE_PATH_LEN - 1), "%s", p); + snprintf(cdrom[c].image_history[i], MAX_IMAGE_PATH_LEN, "%s", p); } else - snprintf(cdrom[c].image_history[i], (MAX_IMAGE_PATH_LEN - 1), "%s%s%s", usr_path, + snprintf(cdrom[c].image_history[i], MAX_IMAGE_PATH_LEN, "%s%s%s", usr_path, path_get_slash(usr_path), p); path_normalize(cdrom[c].image_history[i]); } @@ -1500,9 +1500,9 @@ load_other_removable_devices(void) fatal("load_other_removable_devices(): strlen(p) > 2047 " "(zip_drives[%i].image_history[%i])\n", c, i); else - snprintf(zip_drives[c].image_history[i], (MAX_IMAGE_PATH_LEN - 1), "%s", p); + snprintf(zip_drives[c].image_history[i], MAX_IMAGE_PATH_LEN, "%s", p); } else - snprintf(zip_drives[c].image_history[i], (MAX_IMAGE_PATH_LEN - 1), "%s%s%s", usr_path, + snprintf(zip_drives[c].image_history[i], MAX_IMAGE_PATH_LEN, "%s%s%s", usr_path, path_get_slash(usr_path), p); path_normalize(zip_drives[c].image_history[i]); } @@ -1613,9 +1613,9 @@ load_other_removable_devices(void) fatal("load_other_removable_devices(): strlen(p) > 2047 " "(mo_drives[%i].image_history[%i])\n", c, i); else - snprintf(mo_drives[c].image_history[i], (MAX_IMAGE_PATH_LEN - 1), "%s", p); + snprintf(mo_drives[c].image_history[i], MAX_IMAGE_PATH_LEN, "%s", p); } else - snprintf(mo_drives[c].image_history[i], (MAX_IMAGE_PATH_LEN - 1), "%s%s%s", usr_path, + snprintf(mo_drives[c].image_history[i], MAX_IMAGE_PATH_LEN, "%s%s%s", usr_path, path_get_slash(usr_path), p); path_normalize(mo_drives[c].image_history[i]); } From fd396f7d5b22813fdae47d6de58cfca71af69ef3 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Fri, 13 Dec 2024 21:26:35 +0100 Subject: [PATCH 8/9] Make YMFM work again on 86box using OPL2/3. --- src/sound/ymfm/ymfm_fm.ipp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/sound/ymfm/ymfm_fm.ipp b/src/sound/ymfm/ymfm_fm.ipp index 2aa0a216b..f2ec83945 100644 --- a/src/sound/ymfm/ymfm_fm.ipp +++ b/src/sound/ymfm/ymfm_fm.ipp @@ -1473,11 +1473,14 @@ void fm_engine_base::assign_operators() template void fm_engine_base::update_timer(uint32_t tnum, uint32_t enable, int32_t delta_clocks) { + uint32_t subtract = !!(tnum >> 15); + tnum &= 0x7fff; + // if the timer is live, but not currently enabled, set the timer if (enable && !m_timer_running[tnum]) { // period comes from the registers, and is different for each - uint32_t period = (tnum == 0) ? (1024 - m_regs.timer_a_value()) : 16 * (256 - m_regs.timer_b_value()); + uint32_t period = (tnum == 0) ? (1024 - subtract - m_regs.timer_a_value()) : 16 * (256 - subtract - m_regs.timer_b_value()); // caller can also specify a delta to account for other effects period += delta_clocks; @@ -1504,8 +1507,6 @@ void fm_engine_base::update_timer(uint32_t tnum, uint32_t enable, template void fm_engine_base::engine_timer_expired(uint32_t tnum) { - assert(tnum == 0 || tnum == 1); - // update status if (tnum == 0 && m_regs.enable_timer_a()) set_reset_status(STATUS_TIMERA, 0); @@ -1521,8 +1522,11 @@ void fm_engine_base::engine_timer_expired(uint32_t tnum) m_modified_channels |= 1 << chnum; } - // reset - m_timer_running[tnum] = false; + // Make sure the array does not go out of bounds to keep gcc happy + if ((tnum < 2) || (sizeof(m_timer_running) > (2 * sizeof(uint8_t)))) { + // reset + m_timer_running[tnum] = false; + } update_timer(tnum, 1, 0); } From 11b588c6bb5e20d66cab19233676d6888ae3e6a7 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 14 Dec 2024 00:59:52 +0100 Subject: [PATCH 9/9] Fix FPU reporting, fixes #5033. --- src/cpu/x86_ops_fpu.h | 18 ++++-------------- src/cpu/x86_ops_fpu_2386.h | 9 ++------- src/cpu/x87.c | 5 ++++- src/cpu/x87.h | 8 +++----- src/cpu/x87_ops.h | 5 ++++- 5 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/cpu/x86_ops_fpu.h b/src/cpu/x86_ops_fpu.h index 9ea04b447..11f603c19 100644 --- a/src/cpu/x86_ops_fpu.h +++ b/src/cpu/x86_ops_fpu.h @@ -4,7 +4,6 @@ static int opESCAPE_d8_a16(uint32_t fetchdat) { - //pclog("D8 A16: fetchdat=%02x.\n", (fetchdat >> 3) & 0x1f); return x86_opcodes_d8_a16[(fetchdat >> 3) & 0x1f](fetchdat); } static int @@ -16,7 +15,6 @@ opESCAPE_d8_a32(uint32_t fetchdat) static int opESCAPE_d9_a16(uint32_t fetchdat) { - //pclog("D9 A16: fetchdat=%02x.\n", fetchdat & 0xff); return x86_opcodes_d9_a16[fetchdat & 0xff](fetchdat); } static int @@ -28,7 +26,6 @@ opESCAPE_d9_a32(uint32_t fetchdat) static int opESCAPE_da_a16(uint32_t fetchdat) { - //pclog("DA A16: fetchdat=%02x.\n", fetchdat & 0xff); return x86_opcodes_da_a16[fetchdat & 0xff](fetchdat); } static int @@ -40,7 +37,6 @@ opESCAPE_da_a32(uint32_t fetchdat) static int opESCAPE_db_a16(uint32_t fetchdat) { - //pclog("DB A16: fetchdat=%02x.\n", fetchdat & 0xff); return x86_opcodes_db_a16[fetchdat & 0xff](fetchdat); } static int @@ -52,7 +48,6 @@ opESCAPE_db_a32(uint32_t fetchdat) static int opESCAPE_dc_a16(uint32_t fetchdat) { - //pclog("DC A16: fetchdat=%02x.\n", (fetchdat >> 3) & 0x1f); return x86_opcodes_dc_a16[(fetchdat >> 3) & 0x1f](fetchdat); } static int @@ -64,7 +59,6 @@ opESCAPE_dc_a32(uint32_t fetchdat) static int opESCAPE_dd_a16(uint32_t fetchdat) { - //pclog("DD A16: fetchdat=%02x.\n", fetchdat & 0xff); return x86_opcodes_dd_a16[fetchdat & 0xff](fetchdat); } static int @@ -76,7 +70,6 @@ opESCAPE_dd_a32(uint32_t fetchdat) static int opESCAPE_de_a16(uint32_t fetchdat) { - //pclog("DE A16: fetchdat=%02x.\n", fetchdat & 0xff); return x86_opcodes_de_a16[fetchdat & 0xff](fetchdat); } static int @@ -88,7 +81,6 @@ opESCAPE_de_a32(uint32_t fetchdat) static int opESCAPE_df_a16(uint32_t fetchdat) { - //pclog("DF A16: fetchdat=%02x.\n", fetchdat & 0xff); return x86_opcodes_df_a16[fetchdat & 0xff](fetchdat); } static int @@ -105,15 +97,13 @@ opWAIT(uint32_t fetchdat) return 1; } -#if 0 - if (!cpu_use_dynarec && fpu_softfloat) { -#endif if (fpu_softfloat) { if (fpu_state.swd & FPU_SW_Summary) { - if (cr0 & 0x20) { + if (is486 && (cr0 & 0x20)) x86_int(16); - return 1; - } + else + picint(1 << 13); + return 1; } } CLOCK_CYCLES(4); diff --git a/src/cpu/x86_ops_fpu_2386.h b/src/cpu/x86_ops_fpu_2386.h index 52c24d995..d8996d2e1 100644 --- a/src/cpu/x86_ops_fpu_2386.h +++ b/src/cpu/x86_ops_fpu_2386.h @@ -97,15 +97,10 @@ opWAIT(uint32_t fetchdat) return 1; } -#if 0 - if (!cpu_use_dynarec && fpu_softfloat) { -#endif if (fpu_softfloat) { if (fpu_state.swd & FPU_SW_Summary) { - if (cr0 & 0x20) { - x86_int(16); - return 1; - } + picint(1 << 13); + return 1; } } CLOCK_CYCLES(4); diff --git a/src/cpu/x87.c b/src/cpu/x87.c index 390c06dc2..577fa1a40 100644 --- a/src/cpu/x87.c +++ b/src/cpu/x87.c @@ -355,7 +355,10 @@ FPU_exception(uint32_t fetchdat, uint16_t exceptions, int store) nmi = 1; } #else - picint(1 << 13); + if (is486 && (cr0 & 0x20)) + x86_int(16); + else + picint(1 << 13); #endif // FPU_8087 } return unmasked; diff --git a/src/cpu/x87.h b/src/cpu/x87.h index 060f2fe27..2ad0c7b10 100644 --- a/src/cpu/x87.h +++ b/src/cpu/x87.h @@ -228,12 +228,10 @@ FPU_save_regi_tag(extFloat80_t reg, int tag, int stnr) #define FPU_check_pending_exceptions() \ do { \ if (fpu_state.swd & FPU_SW_Summary) { \ - if (cr0 & 0x20) { \ + if (is486 && (cr0 & 0x20)) \ x86_int(16); \ - return 1; \ - } else { \ + else \ picint(1 << 13); \ - return 1; \ - } \ + return 1; \ } \ } while (0) diff --git a/src/cpu/x87_ops.h b/src/cpu/x87_ops.h index 6be9d7648..e1bc5858a 100644 --- a/src/cpu/x87_ops.h +++ b/src/cpu/x87_ops.h @@ -99,7 +99,10 @@ typedef union { dst = src1 / (double) src2; \ else { \ fpu_log("FPU : divide by zero\n"); \ - picint(1 << 13); \ + if (is486 && (cr0 & 0x20)) \ + x86_int(16); \ + else \ + picint(1 << 13); \ return 1; \ } \ } else \