From c7c92bb62b7eb097b369d726ea54f465d099a113 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Wed, 31 Dec 2014 12:27:32 +0000 Subject: [PATCH] Fixed OPL chip detection. - Increment timer counter before checking for overflow. - Implemented ISA bus delay in the pc_system code and use it for the SB16. This makes OPL chip detection work at ips values > 4 Mips. TODO: OPL chip should use wave output instead of MIDI (maybe port from DOSBox). TODO: Use isa_bus_delay() for other legacy devices if required. --- bochs/iodev/sound/sb16.cc | 12 +++++++----- bochs/pc_system.cc | 8 ++++++++ bochs/pc_system.h | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bochs/iodev/sound/sb16.cc b/bochs/iodev/sound/sb16.cc index b86ceae3d..244b72379 100644 --- a/bochs/iodev/sound/sb16.cc +++ b/bochs/iodev/sound/sb16.cc @@ -2428,7 +2428,7 @@ void bx_sb16_c::opl_timerevent() } else { mask = 0x3ff; } - if (((OPL.timer[i]++) & mask) == 0) { // overflow occured, set flags accordingly + if (((++OPL.timer[i]) & mask) == 0) { // overflow occured, set flags accordingly OPL.timer[i] = OPL.timerinit[i]; // reset the counter if ((OPL.tmask[i/2] >> (6 - (i % 2))) == 0) { // set flags only if unmasked writelog(MIDILOG(5), "OPL Timer Interrupt: Chip %d, Timer %d", i/2, 1 << (i % 2)); @@ -3372,8 +3372,9 @@ Bit32u bx_sb16_c::read(Bit32u address, unsigned io_len) UNUSED(this_ptr); #endif // !BX_USE_SB16_SMF - switch (address) - { + bx_pc_system.isa_bus_delay(); + + switch (address) { // 2x0: FM Music Status Port // 2x8 and 388 are aliases case BX_SB16_IO + 0x00: @@ -3488,8 +3489,9 @@ void bx_sb16_c::write(Bit32u address, Bit32u value, unsigned io_len) UNUSED(this_ptr); #endif // !BX_USE_SB16_SMF - switch (address) - { + bx_pc_system.isa_bus_delay(); + + switch (address) { // 2x0: FM Music Register Port // 2x8 and 388 are aliases case BX_SB16_IO + 0x00: diff --git a/bochs/pc_system.cc b/bochs/pc_system.cc index cadbca391..548b982d3 100644 --- a/bochs/pc_system.cc +++ b/bochs/pc_system.cc @@ -582,3 +582,11 @@ void bx_pc_system_c::setTimerParam(unsigned timerIndex, Bit32u param) #endif timer[timerIndex].param = param; } + +void bx_pc_system_c::isa_bus_delay(void) +{ + // Emulate 8 MHz ISA bus speed + if (m_ips > 4.0) { + tickn((Bit32u)(m_ips * 2.0)); + } +} diff --git a/bochs/pc_system.h b/bochs/pc_system.h index 7b649a585..164774e72 100644 --- a/bochs/pc_system.h +++ b/bochs/pc_system.h @@ -140,6 +140,7 @@ public: #if BX_ENABLE_STATISTICS static void dumpStatsTimer(void* this_ptr); #endif + void isa_bus_delay(void); // =========================== // Non-timer oriented features