From 4335c3e085c248147a4843546f0b9e183859e860 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Fri, 1 Mar 2024 19:27:46 +0500 Subject: [PATCH 1/6] Fix ACPI poweroffs disabling exit confirmations Use confirm_exit_cmdl to skip the confirmation prompt without saving it in the config --- src/qt/qt_platform.cpp | 2 +- src/unix/unix.c | 2 +- src/win/win_ui.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index 356334bac..46d50672e 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -413,7 +413,7 @@ void plat_power_off(void) { plat_mouse_capture(0); - confirm_exit = 0; + confirm_exit_cmdl = 0; nvr_save(); config_save(); diff --git a/src/unix/unix.c b/src/unix/unix.c index 6c21bfa45..2a9324307 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -697,7 +697,7 @@ plat_get_exe_name(char *s, int size) void plat_power_off(void) { - confirm_exit = 0; + confirm_exit_cmdl = 0; nvr_save(); config_save(); diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 207158b29..ec4a785ab 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -383,7 +383,7 @@ win_notify_dlg_closed(void) void plat_power_off(void) { - confirm_exit = 0; + confirm_exit_cmdl = 0; nvr_save(); config_save(); From f9ae162e5d7bc6cbf62dd95cddd0d4564bf6312d Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Fri, 1 Mar 2024 19:29:09 +0500 Subject: [PATCH 2/6] Move the EMU8000 ROM path to a macro --- src/include/86box/snd_emu8k.h | 2 ++ src/sound/snd_emu8k.c | 2 +- src/sound/snd_sb.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/include/86box/snd_emu8k.h b/src/include/86box/snd_emu8k.h index 090ab662a..d226ed8db 100644 --- a/src/include/86box/snd_emu8k.h +++ b/src/include/86box/snd_emu8k.h @@ -406,6 +406,8 @@ void emu8k_close(emu8k_t *emu8k); void emu8k_update(emu8k_t *emu8k); +#define EMU8K_ROM_PATH "roms/sound/creative/awe32.raw" + /* Section E - Introduction to the EMU8000 Chip diff --git a/src/sound/snd_emu8k.c b/src/sound/snd_emu8k.c index 22435c065..793f8bcb7 100644 --- a/src/sound/snd_emu8k.c +++ b/src/sound/snd_emu8k.c @@ -2172,7 +2172,7 @@ emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram) int c; double out; - fp = rom_fopen("roms/sound/creative/awe32.raw", "rb"); + fp = rom_fopen(EMU8K_ROM_PATH, "rb"); if (!fp) fatal("AWE32.RAW not found\n"); diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index fb9157dfd..2e63e99c0 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -2509,7 +2509,7 @@ sb_16_compat_init(const device_t *info) static int sb_awe32_available(void) { - return rom_present("roms/sound/creative/awe32.raw"); + return rom_present(EMU8K_ROM_PATH); } static int From 9a67f05a8f494ace6c5303ec09ad0740bc696157 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Fri, 1 Mar 2024 19:31:34 +0500 Subject: [PATCH 3/6] Move the Sound Blaster PnP ROM paths to macros --- src/sound/snd_sb.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 2e63e99c0..5d59d2577 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -43,6 +43,14 @@ #include <86box/snd_sb.h> #include <86box/plat_unused.h> +#define PNP_ROM_SB_VIBRA16XV "roms/sound/creative/CT4170 PnP.BIN" +#define PNP_ROM_SB_VIBRA16C "roms/sound/creative/CT4180 PnP.BIN" +#define PNP_ROM_SB_32_PNP "roms/sound/creative/CT3600 PnP.BIN" +#define PNP_ROM_SB_AWE32_PNP "roms/sound/creative/CT3980 PnP.BIN" +#define PNP_ROM_SB_AWE64_VALUE "roms/sound/creative/CT4520 PnP.BIN" +#define PNP_ROM_SB_AWE64 PNP_ROM_SB_AWE64_VALUE +#define PNP_ROM_SB_AWE64_GOLD "roms/sound/creative/CT4540 PnP.BIN" + /* 0 to 7 -> -14dB to 0dB i 2dB steps. 8 to 15 -> 0 to +14dB in 2dB steps. Note that for positive dB values, this is not amplitude, it is amplitude - 1. */ static const double sb_bass_treble_4bits[] = { @@ -2382,13 +2390,13 @@ sb_16_pnp_init(UNUSED(const device_t *info)) static int sb_vibra16xv_available(void) { - return rom_present("roms/sound/creative/CT4170 PnP.BIN"); + return rom_present(PNP_ROM_SB_VIBRA16XV); } static int sb_vibra16c_available(void) { - return rom_present("roms/sound/creative/CT4180 PnP.BIN"); + return rom_present(PNP_ROM_SB_VIBRA16C); } static void * @@ -2430,11 +2438,11 @@ sb_vibra16_pnp_init(UNUSED(const device_t *info)) const char *pnp_rom_file = NULL; switch (info->local) { case 0: - pnp_rom_file = "roms/sound/creative/CT4170 PnP.BIN"; + pnp_rom_file = PNP_ROM_SB_VIBRA16XV; break; case 1: - pnp_rom_file = "roms/sound/creative/CT4180 PnP.BIN"; + pnp_rom_file = PNP_ROM_SB_VIBRA16C; break; default: @@ -2515,31 +2523,31 @@ sb_awe32_available(void) static int sb_32_pnp_available(void) { - return sb_awe32_available() && rom_present("roms/sound/creative/CT3600 PnP.BIN"); + return sb_awe32_available() && rom_present(PNP_ROM_SB_32_PNP); } static int sb_awe32_pnp_available(void) { - return sb_awe32_available() && rom_present("roms/sound/creative/CT3980 PnP.BIN"); + return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE32_PNP); } static int sb_awe64_value_available(void) { - return sb_awe32_available() && rom_present("roms/sound/creative/CT4520 PnP.BIN"); + return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE64_VALUE); } static int sb_awe64_available(void) { - return sb_awe32_available() && rom_present("roms/sound/creative/CT4520 PnP.BIN"); + return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE64); } static int sb_awe64_gold_available(void) { - return sb_awe32_available() && rom_present("roms/sound/creative/CT4540 PnP.BIN"); + return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE64_GOLD); } static void * @@ -2659,20 +2667,23 @@ sb_awe32_pnp_init(const device_t *info) const char *pnp_rom_file = NULL; switch (info->local) { case 0: - pnp_rom_file = "roms/sound/creative/CT3600 PnP.BIN"; + pnp_rom_file = PNP_ROM_SB_32_PNP; break; case 1: - pnp_rom_file = "roms/sound/creative/CT3980 PnP.BIN"; + pnp_rom_file = PNP_ROM_SB_AWE32_PNP; break; case 2: + pnp_rom_file = PNP_ROM_SB_AWE64_VALUE; + break; + case 3: - pnp_rom_file = "roms/sound/creative/CT4520 PnP.BIN"; + pnp_rom_file = PNP_ROM_SB_AWE64; break; case 4: - pnp_rom_file = "roms/sound/creative/CT4540 PnP.BIN"; + pnp_rom_file = PNP_ROM_SB_AWE64_GOLD; break; default: From 938fa5bde59616701d881437a0a70fde9e9026d7 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Fri, 1 Mar 2024 19:34:59 +0500 Subject: [PATCH 4/6] Add a correct PnP ROM for the CT4380 SB AWE64 Add a correct PnP ROM for the CT4380 "regular" Sound Blaster AWE64 and add quarternary IDE to it to match the new ROM --- src/sound/snd_sb.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 5d59d2577..a82ee21d3 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -48,7 +48,7 @@ #define PNP_ROM_SB_32_PNP "roms/sound/creative/CT3600 PnP.BIN" #define PNP_ROM_SB_AWE32_PNP "roms/sound/creative/CT3980 PnP.BIN" #define PNP_ROM_SB_AWE64_VALUE "roms/sound/creative/CT4520 PnP.BIN" -#define PNP_ROM_SB_AWE64 PNP_ROM_SB_AWE64_VALUE +#define PNP_ROM_SB_AWE64 "roms/sound/creative/CTL009DA.BIN" #define PNP_ROM_SB_AWE64_GOLD "roms/sound/creative/CT4540 PnP.BIN" /* 0 to 7 -> -14dB to 0dB i 2dB steps. 8 to 15 -> 0 to +14dB in 2dB steps. @@ -1782,6 +1782,27 @@ sb_awe32_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *pr } } +static void +sb_awe64_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv) +{ + sb_t *sb = (sb_t *) priv; + + switch (ld) { + case 0: /* Audio */ + case 2: /* WaveTable */ + sb_16_pnp_config_changed(ld, config, sb); + break; + + case 1: /* Game */ + case 3: /* IDE */ + sb_16_pnp_config_changed(ld ^ 2, config, sb); + break; + + default: + break; + } +} + static void sb_awe64_gold_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv) { @@ -2661,7 +2682,7 @@ sb_awe32_pnp_init(const device_t *info) sb->gameport = gameport_add(&gameport_pnp_device); - if ((info->local != 2) && (info->local != 3) && (info->local != 4)) + if ((info->local != 2) && (info->local != 4)) device_add(&ide_qua_pnp_device); const char *pnp_rom_file = NULL; @@ -2709,8 +2730,11 @@ sb_awe32_pnp_init(const device_t *info) isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe32_pnp_config_changed, NULL, NULL, NULL, sb); break; - case 2: case 3: + isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_pnp_config_changed, NULL, NULL, NULL, sb); + break; + + case 2: case 4: isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_gold_pnp_config_changed, NULL, NULL, NULL, sb); break; @@ -2725,7 +2749,7 @@ sb_awe32_pnp_init(const device_t *info) sb_dsp_setdma16(&sb->dsp, ISAPNP_DMA_DISABLED); mpu401_change_addr(sb->mpu, 0); - if ((info->local != 2) && (info->local != 3) && (info->local != 4)) + if ((info->local != 2) && (info->local != 4)) ide_remove_handlers(3); emu8k_change_addr(&sb->emu8k, 0); From ff6964f73d2b65915866560ba0cf179aa5546d73 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Fri, 1 Mar 2024 19:26:32 +0100 Subject: [PATCH 5/6] ESDI/MFM AT changes: Make sure they IRQ activations are more IDE-like and correct. --- src/disk/hdc_esdi_at.c | 26 ++++++++++++++------------ src/disk/hdc_st506_at.c | 32 +++++++++++++++++--------------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/disk/hdc_esdi_at.c b/src/disk/hdc_esdi_at.c index 65184094a..042a6020a 100644 --- a/src/disk/hdc_esdi_at.c +++ b/src/disk/hdc_esdi_at.c @@ -129,23 +129,24 @@ esdi_at_log(const char *fmt, ...) static __inline void irq_raise(esdi_t *esdi) { - if (!(esdi->fdisk & 2)) - picint(1 << 14); - esdi->irqstat = 1; + if (!(esdi->fdisk & 2)) + picint_common(1 << 14, PIC_IRQ_EDGE, 1, NULL); } static __inline void -irq_lower(UNUSED(esdi_t *esdi)) +irq_lower(esdi_t *esdi) { - picintc(1 << 14); + esdi->irqstat = 0; + if (!(esdi->fdisk & 2)) + picint_common(1 << 14, PIC_IRQ_EDGE, 0, NULL); } static __inline void -irq_update(UNUSED(esdi_t *esdi)) +irq_update(esdi_t *esdi) { - if (esdi->irqstat && !((pic2.irr | pic2.isr) & 0x40) && !(esdi->fdisk & 2)) - picint(1 << 14); + uint8_t set = !(esdi->fdisk & 2) && esdi->irqstat; + picint_common(1 << 14, PIC_IRQ_EDGE, set, NULL); } static void @@ -263,6 +264,7 @@ esdi_write(uint16_t port, uint8_t val, void *priv) double seek_time; double xfer_time; off64_t addr; + uint8_t old; esdi_at_log("WD1007 write(%04x, %02x)\n", port, val); @@ -411,15 +413,15 @@ esdi_write(uint16_t port, uint8_t val, void *priv) esdi_set_callback(esdi, 500 * HDC_TIME); esdi->reset = 1; esdi->status = STAT_BUSY; - } - - if (val & 0x04) { + } else if (!(esdi->fdisk & 0x04) && (val & 0x04)) { /* Drive held in reset. */ esdi_set_callback(esdi, 0); esdi->status = STAT_BUSY; } + old = esdi->fdisk; esdi->fdisk = val; - irq_update(esdi); + if (!(val & 0x02) && (old & 0x02)) + irq_update(esdi); break; default: diff --git a/src/disk/hdc_st506_at.c b/src/disk/hdc_st506_at.c index 41499591d..c8c35d7d5 100644 --- a/src/disk/hdc_st506_at.c +++ b/src/disk/hdc_st506_at.c @@ -134,26 +134,27 @@ st506_at_log(const char *fmt, ...) # define st506_at_log(fmt, ...) #endif -static inline void +static __inline void irq_raise(mfm_t *mfm) { - if (!(mfm->fdisk & 2)) - picint(1 << 14); - mfm->irqstat = 1; + if (!(mfm->fdisk & 2)) + picint_common(1 << 14, PIC_IRQ_EDGE, 1, NULL); } -static inline void -irq_lower(UNUSED(mfm_t *mfm)) +static __inline void +irq_lower(mfm_t *mfm) { - picintc(1 << 14); + mfm->irqstat = 0; + if (!(mfm->fdisk & 2)) + picint_common(1 << 14, PIC_IRQ_EDGE, 0, NULL); } -static void +static __inline void irq_update(mfm_t *mfm) { - if (mfm->irqstat && !((pic2.irr | pic2.isr) & 0x40) && !(mfm->fdisk & 2)) - picint(1 << 14); + uint8_t set = !(mfm->fdisk & 2) && mfm->irqstat; + picint_common(1 << 14, PIC_IRQ_EDGE, set, NULL); } /* @@ -378,6 +379,7 @@ static void mfm_write(uint16_t port, uint8_t val, void *priv) { mfm_t *mfm = (mfm_t *) priv; + uint8_t old; st506_at_log("WD1003 write(%04x, %02x)\n", port, val); @@ -408,7 +410,7 @@ mfm_write(uint16_t port, uint8_t val, void *priv) case 0x01f6: /* drive/head */ mfm->head = val & 0xF; - mfm->drvsel = (val & 0x10) ? 1 : 0; + mfm->drvsel = !!(val & 0x10); if (mfm->drives[mfm->drvsel].present) mfm->status = STAT_READY | STAT_DSC; else @@ -425,15 +427,15 @@ mfm_write(uint16_t port, uint8_t val, void *priv) timer_set_delay_u64(&mfm->callback_timer, 500 * MFM_TIME); mfm->reset = 1; mfm->status = STAT_BUSY; - } - - if (val & 0x04) { + } else if (!(mfm->fdisk & 0x04) && (val & 0x04)) { /* Drive held in reset. */ timer_disable(&mfm->callback_timer); mfm->status = STAT_BUSY; } + old = mfm->fdisk; mfm->fdisk = val; - irq_update(mfm); + if (!(val & 0x02) && (old & 0x02)) + irq_update(mfm); break; default: From 929fa7328d59d1085787c71e91f29cc6461617d9 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Fri, 1 Mar 2024 19:50:23 +0100 Subject: [PATCH 6/6] Mach8/32 horizontal display changes. Make sure for the 9001st time to display correctly the horizontal side of the display (looking at you, ATI 1992 set for win3.1x and Mach8/32 drivers for OS/2 1.2x). --- src/video/vid_ati_mach8.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/video/vid_ati_mach8.c b/src/video/vid_ati_mach8.c index 3888e9c26..2613de767 100644 --- a/src/video/vid_ati_mach8.c +++ b/src/video/vid_ati_mach8.c @@ -2596,15 +2596,16 @@ mach_recalctimings(svga_t *svga) mach_log("ON[0]=%d, ON[1]=%d, exton[0]=%d, exton[1]=%d, vendormode0=%d, vendormode1=%d.\n", dev->on[0], dev->on[1], mach->ext_on[0], mach->ext_on[1], dev->vendor_mode[0], dev->vendor_mode[1]); if (dev->on[0] || dev->on[1]) { mach_log("8514/A ON.\n"); - dev->h_disp = dev->hdisp; dev->h_total = dev->htotal + 1; dev->h_blankstart = dev->hblankstart; dev->h_blank_end_val = dev->hblank_end_val; dev->v_total = dev->vtotal; dev->v_syncstart = dev->vsyncstart; - dev->dispend = dev->vdisp; dev->rowcount = !!(dev->disp_cntl & 0x08); + dev->h_disp = dev->hdisp; + dev->dispend = dev->vdisp; + if (dev->dispend == 766) dev->dispend += 2; @@ -2636,6 +2637,7 @@ mach_recalctimings(svga_t *svga) dev->v_total >>= 1; } + mach_log("HDISP=%d.\n", dev->h_disp); dev->pitch = dev->ext_pitch; dev->rowoffset = dev->ext_crt_pitch; if ((mach->accel.ext_ge_config & 0x800) || (!(mach->accel.ext_ge_config & 0x8000) && !(mach->accel.ext_ge_config & 0x800))) { @@ -3626,9 +3628,21 @@ mach_accel_out_call(uint16_t port, uint8_t val, mach_t *mach, svga_t *svga, ibm8 if (((dev->disp_cntl & 0x60) == 0x20) || (((dev->disp_cntl & 0x60) == 0x40) && !(dev->accel.advfunc_cntl & 0x04)) || (mach->accel.clock_sel & 0x01)) { dev->hdisped = val; dev->hdisp = (dev->hdisped + 1) << 3; + if ((dev->hdisp == 640) && ((mach->shadow_set & 0x03) == 0x02) && (((dev->disp_cntl & 0x60) == 0x40) && !(dev->accel.advfunc_cntl & 0x04))) + svga_recalctimings(svga); + else if ((dev->hdisp == 1024) && !(mach->accel.clock_sel & 0x01) && ((dev->disp_cntl & 0x60) == 0x40)) { + if (dev->accel.advfunc_cntl & 0x04) { + dev->hdisp = 1024; + dev->vdisp = 768; + } else { + dev->hdisp = 640; + dev->vdisp = 480; + } + svga_recalctimings(svga); + } } } - mach_log("[%04X:%08X]: ATI 8514/A: H_DISP write 06E8 = %d, actual val=%d, set lock=%x, shadow set=%x, advfunc=%x, dispcntl=%02x.\n", CS, cpu_state.pc, dev->hdisp, ((val + 1) << 3), mach->shadow_cntl, mach->shadow_set, dev->accel.advfunc_cntl & 4, dev->disp_cntl & 0x60); + mach_log("[%04X:%08X]: ATI 8514/A: H_DISP write 06E8 = %d, actual val=%d, set lock=%x, shadow set=%x, advfunc bit 2=%x, dispcntl=%02x, clocksel bit 0=%x.\n", CS, cpu_state.pc, dev->hdisp, ((val + 1) << 3), mach->shadow_cntl, mach->shadow_set, dev->accel.advfunc_cntl & 0x04, dev->disp_cntl & 0x60, mach->accel.clock_sel & 0x01); break; case 0xae8: @@ -3733,7 +3747,7 @@ mach_accel_out_call(uint16_t port, uint8_t val, mach_t *mach, svga_t *svga, ibm8 mach->ext_on[port & 1] = dev->on[port & 1]; mach32_updatemapping(mach, svga); dev->vendor_mode[port & 1] = 0; - mach_log("ATI 8514/A: (0x%04x): ON=%d, shadow crt=%x.\n", port, dev->on[port & 1], dev->accel.advfunc_cntl & 4); + mach_log("ATI 8514/A: (0x%04x): ON=%d, shadow crt=%x, hdisp=%d.\n", port, dev->on[port & 1], dev->accel.advfunc_cntl & 4, dev->hdisp); svga_recalctimings(svga); break;