From f2978247c1adca61758d2e61cc879cfa5c2407be Mon Sep 17 00:00:00 2001 From: byuu <2107894+byuu@users.noreply.github.com> Date: Sun, 27 Oct 2019 13:13:59 +0900 Subject: [PATCH] v112.4 Reverted Kishin Douji Zenki fix, as it seems to have been incorrect. Disabled supersampling when EXTBG mode is active. Fixed MSU1 and SGB audio when using run-ahead and overclocking. macOS: fixed a serious issue with the IOKit joypad driver [kode54] --- bsnes/emulator/emulator.hpp | 2 +- bsnes/processor/spc700/instructions.cpp | 6 +++--- bsnes/sfc/coprocessor/icd/interface.cpp | 2 +- bsnes/sfc/coprocessor/msu1/msu1.cpp | 2 +- bsnes/sfc/cpu/timing.cpp | 5 +++++ bsnes/sfc/ppu-fast/ppu.cpp | 5 +++-- bsnes/sfc/smp/memory.cpp | 2 +- ruby/input/joypad/iokit.cpp | 2 ++ 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/bsnes/emulator/emulator.hpp b/bsnes/emulator/emulator.hpp index e1af66c9..474c761e 100644 --- a/bsnes/emulator/emulator.hpp +++ b/bsnes/emulator/emulator.hpp @@ -29,7 +29,7 @@ using namespace nall; namespace Emulator { static const string Name = "bsnes"; - static const string Version = "112.3"; + static const string Version = "112.4"; static const string Author = "byuu"; static const string License = "GPLv3"; static const string Website = "https://byuu.org"; diff --git a/bsnes/processor/spc700/instructions.cpp b/bsnes/processor/spc700/instructions.cpp index fd43462f..d7844893 100644 --- a/bsnes/processor/spc700/instructions.cpp +++ b/bsnes/processor/spc700/instructions.cpp @@ -250,7 +250,7 @@ auto SPC700::instructionDirectDirectCompare(fpb op) -> void { uint8 target = fetch(); uint8 lhs = load(target); lhs = alu(lhs, rhs); - load(target); + idle(); } auto SPC700::instructionDirectDirectModify(fpb op) -> void { @@ -274,7 +274,7 @@ auto SPC700::instructionDirectImmediateCompare(fpb op) -> void { uint8 address = fetch(); uint8 data = load(address); data = alu(data, immediate); - load(address); + idle(); } auto SPC700::instructionDirectImmediateModify(fpb op) -> void { @@ -469,7 +469,7 @@ auto SPC700::instructionIndirectXCompareIndirectY(fpb op) -> void { uint8 rhs = load(Y); uint8 lhs = load(X); lhs = alu(lhs, rhs); - load(X); + idle(); } auto SPC700::instructionIndirectXWriteIndirectY(fpb op) -> void { diff --git a/bsnes/sfc/coprocessor/icd/interface.cpp b/bsnes/sfc/coprocessor/icd/interface.cpp index aaf405fb..3615e32d 100644 --- a/bsnes/sfc/coprocessor/icd/interface.cpp +++ b/bsnes/sfc/coprocessor/icd/interface.cpp @@ -21,7 +21,7 @@ auto ICD::ppuWrite(uint2 color) -> void { auto ICD::apuWrite(float left, float right) -> void { float samples[] = {left, right}; - stream->write(samples); + if(!system.runAhead) stream->write(samples); } auto ICD::joypWrite(bool p14, bool p15) -> void { diff --git a/bsnes/sfc/coprocessor/msu1/msu1.cpp b/bsnes/sfc/coprocessor/msu1/msu1.cpp index 046e7101..2caf4e2e 100644 --- a/bsnes/sfc/coprocessor/msu1/msu1.cpp +++ b/bsnes/sfc/coprocessor/msu1/msu1.cpp @@ -42,7 +42,7 @@ auto MSU1::main() -> void { } } - stream->sample(float(left), float(right)); + if(!system.runAhead) stream->sample(float(left), float(right)); step(1); synchronizeCPU(); } diff --git a/bsnes/sfc/cpu/timing.cpp b/bsnes/sfc/cpu/timing.cpp index 0c9cfe0f..d53c7b0d 100644 --- a/bsnes/sfc/cpu/timing.cpp +++ b/bsnes/sfc/cpu/timing.cpp @@ -20,6 +20,7 @@ auto CPU::step() -> void { static_assert(Clocks == 2 || Clocks == 4 || Clocks == 6 || Clocks == 8 || Clocks == 10 || Clocks == 12); for(auto coprocessor : coprocessors) { + if(coprocessor == &icd || coprocessor == &msu1) continue; coprocessor->clock -= Clocks * (uint64)coprocessor->frequency; } @@ -43,6 +44,10 @@ auto CPU::step() -> void { smp.clock -= Clocks * (uint64)smp.frequency; ppu.clock -= Clocks; + for(auto coprocessor : coprocessors) { + if(coprocessor != &icd && coprocessor != &msu1) continue; + coprocessor->clock -= Clocks * (uint64)coprocessor->frequency; + } if(!status.dramRefresh && hcounter() >= status.dramRefreshPosition) { //note: pattern should technically be 5-3, 5-3, 5-3, 5-3, 5-3 per logic analyzer diff --git a/bsnes/sfc/ppu-fast/ppu.cpp b/bsnes/sfc/ppu-fast/ppu.cpp index 49cae4d9..474d63e4 100644 --- a/bsnes/sfc/ppu-fast/ppu.cpp +++ b/bsnes/sfc/ppu-fast/ppu.cpp @@ -106,8 +106,9 @@ auto PPU::scanline() -> void { if(vcounter() > 0 && vcounter() < vdisp()) { latch.hires |= io.pseudoHires || io.bgMode == 5 || io.bgMode == 6; - latch.hd |= io.bgMode == 7 && hdScale() > 1 && hdSupersample() == 0; - latch.ss |= io.bgMode == 7 && hdScale() > 1 && hdSupersample() == 1; + //supersampling and EXTBG mode are not compatible, so disable supersampling in EXTBG mode + latch.hd |= io.bgMode == 7 && hdScale() > 1 && (hdSupersample() == 0 || io.extbg == 1); + latch.ss |= io.bgMode == 7 && hdScale() > 1 && (hdSupersample() == 1 && io.extbg == 0); } if(vcounter() == vdisp()) { diff --git a/bsnes/sfc/smp/memory.cpp b/bsnes/sfc/smp/memory.cpp index 522b80ea..1ed03bb1 100644 --- a/bsnes/sfc/smp/memory.cpp +++ b/bsnes/sfc/smp/memory.cpp @@ -14,9 +14,9 @@ auto SMP::idle() -> void { } auto SMP::read(uint16 address) -> uint8 { + wait(address); uint8 data = readRAM(address); if((address & 0xfff0) == 0x00f0) data = readIO(address); - wait(address); return data; } diff --git a/ruby/input/joypad/iokit.cpp b/ruby/input/joypad/iokit.cpp index 9a016c2d..04fcc17b 100644 --- a/ruby/input/joypad/iokit.cpp +++ b/ruby/input/joypad/iokit.cpp @@ -14,6 +14,7 @@ struct InputJoypadIOKit { for(uint n : range(CFArrayGetCount(elements))) { IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, n); IOHIDElementType type = IOHIDElementGetType(element); + uint32_t page = IOHIDElementGetUsagePage(element); uint32_t usage = IOHIDElementGetUsage(element); switch(type) { case kIOHIDElementTypeInput_Button: @@ -21,6 +22,7 @@ struct InputJoypadIOKit { break; case kIOHIDElementTypeInput_Axis: case kIOHIDElementTypeInput_Misc: + if(page != kHIDPage_GenericDesktop && page != kHIDPage_Simulation) break; if(usage == kHIDUsage_Sim_Accelerator || usage == kHIDUsage_Sim_Brake || usage == kHIDUsage_Sim_Rudder || usage == kHIDUsage_Sim_Throttle || usage == kHIDUsage_GD_X || usage == kHIDUsage_GD_Y || usage == kHIDUsage_GD_Z