diff --git a/bsnes-patches/v085/0001-Make-libsnes-compile.patch b/bsnes-patches/v085/0001-Make-libsnes-compile.patch index ea197c78..4587d16d 100644 --- a/bsnes-patches/v085/0001-Make-libsnes-compile.patch +++ b/bsnes-patches/v085/0001-Make-libsnes-compile.patch @@ -1,7 +1,7 @@ From b19b3b2d1d7a522af695f4482abb28e52804326b Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 9 Nov 2011 00:30:36 +0200 -Subject: [PATCH 01/13] Make libsnes compile +Subject: [PATCH 01/14] Make libsnes compile Changes between v083 and v084 had broken libsnes. Fix it so it at least compiles. @@ -78,5 +78,5 @@ index fbb4482..5f5ded6 100755 } SNES::cartridge.load(SNES::Cartridge::Mode::SuperGameBoy, xmlrom); -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0002-Fix-bsnes-version-number-in-libsnes-to-be-v085-not-v.patch b/bsnes-patches/v085/0002-Fix-bsnes-version-number-in-libsnes-to-be-v085-not-v.patch index 83c5b66f..ec94882c 100644 --- a/bsnes-patches/v085/0002-Fix-bsnes-version-number-in-libsnes-to-be-v085-not-v.patch +++ b/bsnes-patches/v085/0002-Fix-bsnes-version-number-in-libsnes-to-be-v085-not-v.patch @@ -1,7 +1,7 @@ From bb2fed04fbfe62a89e4bcfe90f44b4738f7c7c1a Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 9 Nov 2011 00:31:59 +0200 -Subject: [PATCH 02/13] Fix bsnes version number in libsnes to be v085, not +Subject: [PATCH 02/14] Fix bsnes version number in libsnes to be v085, not v083 --- @@ -22,5 +22,5 @@ index 5f5ded6..0e63075 100755 unsigned snes_library_revision_major(void) { -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0003-Don-t-use-time-in-emulating-chips.patch b/bsnes-patches/v085/0003-Don-t-use-time-in-emulating-chips.patch index 9cbb756a..15242e39 100644 --- a/bsnes-patches/v085/0003-Don-t-use-time-in-emulating-chips.patch +++ b/bsnes-patches/v085/0003-Don-t-use-time-in-emulating-chips.patch @@ -1,7 +1,7 @@ From 7379b4570e5755a5a1da25181ba4f5d1ca461a98 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 9 Nov 2011 00:37:44 +0200 -Subject: [PATCH 03/13] Don't use time() in emulating chips +Subject: [PATCH 03/14] Don't use time() in emulating chips Instead of using time() in chip emulation, create new interface method currentTime(), defaulting to time(0). This way frontend can cleanly @@ -80,5 +80,5 @@ index f1a48c0..df975e8 100755 extern Interface *interface; -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0004-Save-controller-state-when-savestating.patch b/bsnes-patches/v085/0004-Save-controller-state-when-savestating.patch index 56234f4e..3a2b2d3f 100644 --- a/bsnes-patches/v085/0004-Save-controller-state-when-savestating.patch +++ b/bsnes-patches/v085/0004-Save-controller-state-when-savestating.patch @@ -1,7 +1,7 @@ From efe1b5884c316ce070953edd87c6c9aeffffaa94 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 9 Nov 2011 01:52:08 +0200 -Subject: [PATCH 04/13] Save controller state when savestating +Subject: [PATCH 04/14] Save controller state when savestating When savestating, save the controller state and restore it upon loadstate. Prevents libsnes from mixing up buttons. @@ -342,5 +342,5 @@ index f7d6f3b..08e7051 100755 if(cartridge.mode() == Cartridge::Mode::SufamiTurbo) sufamiturbo.serialize(s); if(cartridge.mode() == Cartridge::Mode::SuperGameBoy) icd2.serialize(s); -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0005-Fix-unserialization-of-64-bit-signed-integers.patch b/bsnes-patches/v085/0005-Fix-unserialization-of-64-bit-signed-integers.patch index 675ded88..628390e9 100644 --- a/bsnes-patches/v085/0005-Fix-unserialization-of-64-bit-signed-integers.patch +++ b/bsnes-patches/v085/0005-Fix-unserialization-of-64-bit-signed-integers.patch @@ -1,7 +1,7 @@ From cdf2f46490f128308eb7f399d03530936ebeda0a Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Fri, 11 Nov 2011 03:05:48 +0200 -Subject: [PATCH 05/13] Fix unserialization of 64-bit signed integers +Subject: [PATCH 05/14] Fix unserialization of 64-bit signed integers --- nall/serializer.hpp | 2 +- @@ -21,5 +21,5 @@ index ff2337a..e6bc8fa 100755 isize += size; } -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0006-Allow-frontend-to-control-random-number-seed.patch b/bsnes-patches/v085/0006-Allow-frontend-to-control-random-number-seed.patch index 41b6a21a..e751b5ee 100644 --- a/bsnes-patches/v085/0006-Allow-frontend-to-control-random-number-seed.patch +++ b/bsnes-patches/v085/0006-Allow-frontend-to-control-random-number-seed.patch @@ -1,7 +1,7 @@ From 4dc46334ec175e26277632fee4aea80768749af9 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Fri, 11 Nov 2011 19:49:46 +0200 -Subject: [PATCH 06/13] Allow frontend to control random number seed +Subject: [PATCH 06/14] Allow frontend to control random number seed --- snes/interface/interface.cpp | 5 +++++ @@ -49,5 +49,5 @@ index c19a7c5..dbd912d 100755 region = config.region; expansion = config.expansion_port; -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0007-Fix-mouse-polling.patch b/bsnes-patches/v085/0007-Fix-mouse-polling.patch index f9cd3c72..1e58c96a 100644 --- a/bsnes-patches/v085/0007-Fix-mouse-polling.patch +++ b/bsnes-patches/v085/0007-Fix-mouse-polling.patch @@ -1,7 +1,7 @@ From eeaf6dc52d39ca9c150ff61864c11297d200d968 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 7 Mar 2012 16:57:18 +0200 -Subject: [PATCH 07/13] Fix mouse polling +Subject: [PATCH 07/14] Fix mouse polling Don't poll for mouse motion excessive number of times (no need to poll it for each bit!) @@ -59,5 +59,5 @@ index b66ea51..b07c8ab 100755 + int _position_y; }; -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0008-Fix-uninitialized-variables.patch b/bsnes-patches/v085/0008-Fix-uninitialized-variables.patch index c2ecf2cb..a2db16b2 100644 --- a/bsnes-patches/v085/0008-Fix-uninitialized-variables.patch +++ b/bsnes-patches/v085/0008-Fix-uninitialized-variables.patch @@ -1,7 +1,7 @@ From 7018377c93553071fc404db872b2746d40ac3bce Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sat, 1 Sep 2012 11:23:34 +0300 -Subject: [PATCH 08/13] Fix uninitialized variables +Subject: [PATCH 08/14] Fix uninitialized variables These uninitialized variables cause a lot of desyncs in Shadowrun. --- @@ -138,5 +138,5 @@ index 9080624..d4ccf42 100755 void SMP::reset() { -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0009-Add-needed-support-for-detecting-true-polls-as-oppos.patch b/bsnes-patches/v085/0009-Add-needed-support-for-detecting-true-polls-as-oppos.patch index 321fac21..5a20b430 100644 --- a/bsnes-patches/v085/0009-Add-needed-support-for-detecting-true-polls-as-oppos.patch +++ b/bsnes-patches/v085/0009-Add-needed-support-for-detecting-true-polls-as-oppos.patch @@ -1,7 +1,7 @@ From 6e0364c9a86caa71623a188a720b2d68b304b89b Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Mon, 24 Sep 2012 21:46:09 +0300 -Subject: [PATCH 09/13] Add needed support for detecting true polls as opposed +Subject: [PATCH 09/14] Add needed support for detecting true polls as opposed to just autopolling --- @@ -65,5 +65,5 @@ index 8b6aaa6..c5ee930 100755 //DMAPx uint8 CPU::mmio_r43x0(uint8 i) { -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0010-Fix-compiling-on-GCC-4.7.patch b/bsnes-patches/v085/0010-Fix-compiling-on-GCC-4.7.patch index 95468cb9..c8e97ce5 100644 --- a/bsnes-patches/v085/0010-Fix-compiling-on-GCC-4.7.patch +++ b/bsnes-patches/v085/0010-Fix-compiling-on-GCC-4.7.patch @@ -1,7 +1,7 @@ From e397bd46f17d6ea00c8c96d5a8e0c5f5b4a6f642 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sun, 14 Oct 2012 23:31:36 +0300 -Subject: [PATCH 10/13] Fix compiling on GCC 4.7 +Subject: [PATCH 10/14] Fix compiling on GCC 4.7 --- nall/string.hpp | 2 +- @@ -22,5 +22,5 @@ index 1b255ce..07a64df 100755 #include #include -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0011-Support-notifying-latches.patch b/bsnes-patches/v085/0011-Support-notifying-latches.patch index befcdde2..a5b6cde6 100644 --- a/bsnes-patches/v085/0011-Support-notifying-latches.patch +++ b/bsnes-patches/v085/0011-Support-notifying-latches.patch @@ -1,7 +1,7 @@ From e047aa8eb9883f60e4141effba8128a4a555d8be Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sun, 27 Oct 2013 10:52:45 +0200 -Subject: [PATCH 11/13] Support notifying latches +Subject: [PATCH 11/14] Support notifying latches --- snes/cpu/mmio/mmio.cpp | 1 + @@ -61,5 +61,5 @@ index 30ee7fd..203f7b0 100755 extern Interface *interface; -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0012-Support-unlimited-number-of-breakpoints.patch b/bsnes-patches/v085/0012-Support-unlimited-number-of-breakpoints.patch index 216affc5..fe308fea 100644 --- a/bsnes-patches/v085/0012-Support-unlimited-number-of-breakpoints.patch +++ b/bsnes-patches/v085/0012-Support-unlimited-number-of-breakpoints.patch @@ -1,7 +1,7 @@ From a5b380757b086e3a00b47fe14e2a63c74683e8da Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Thu, 28 Nov 2013 22:36:29 +0200 -Subject: [PATCH 12/13] Support unlimited number of breakpoints +Subject: [PATCH 12/14] Support unlimited number of breakpoints --- snes/alt/cpu/cpu.cpp | 22 +++++++------- @@ -795,5 +795,5 @@ index dffeeee..37ed1fe 100755 namespace SNES { namespace Info { -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0013-Support-auto-detecting-bsnes-version.patch b/bsnes-patches/v085/0013-Support-auto-detecting-bsnes-version.patch index 32f706c3..82af5539 100644 --- a/bsnes-patches/v085/0013-Support-auto-detecting-bsnes-version.patch +++ b/bsnes-patches/v085/0013-Support-auto-detecting-bsnes-version.patch @@ -1,7 +1,7 @@ From 8bc6bb381e680616dcc843c99889799aedd43163 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sat, 30 Nov 2013 10:27:37 +0200 -Subject: [PATCH 13/13] Support auto-detecting bsnes version +Subject: [PATCH 13/14] Support auto-detecting bsnes version --- bsnes.mk | 3 +++ @@ -18,5 +18,5 @@ index 0000000..20f22f6 +LIBSNES_DIR=ui-libsnes +BSNES_VERSION=085 -- -1.8.4.4 +1.8.5.1 diff --git a/bsnes-patches/v085/0014-Support-alternate-more-accurate-poll-timings.patch b/bsnes-patches/v085/0014-Support-alternate-more-accurate-poll-timings.patch new file mode 100644 index 00000000..2a01b169 --- /dev/null +++ b/bsnes-patches/v085/0014-Support-alternate-more-accurate-poll-timings.patch @@ -0,0 +1,138 @@ +From 40c456dadd79cb2c94379fda8b41a4d0ba051ad1 Mon Sep 17 00:00:00 2001 +From: Ilari Liusvaara +Date: Sat, 7 Dec 2013 23:32:44 +0200 +Subject: [PATCH 14/14] Support alternate (more accurate) poll timings + +--- + snes/config/config.cpp | 1 + + snes/config/config.hpp | 1 + + snes/cpu/timing/joypad.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ + snes/cpu/timing/timing.cpp | 16 ++++++++++++---- + snes/cpu/timing/timing.hpp | 1 + + snes/snes.hpp | 1 + + 6 files changed, 56 insertions(+), 4 deletions(-) + +diff --git a/snes/config/config.cpp b/snes/config/config.cpp +index 701af94..206daae 100755 +--- a/snes/config/config.cpp ++++ b/snes/config/config.cpp +@@ -13,6 +13,7 @@ Configuration::Configuration() { + cpu.ntsc_frequency = 21477272; //315 / 88 * 6000000 + cpu.pal_frequency = 21281370; + cpu.wram_init_value = 0x55; ++ cpu.alt_poll_timings = false; + + smp.ntsc_frequency = 24607104; //32040.5 * 768 + smp.pal_frequency = 24607104; +diff --git a/snes/config/config.hpp b/snes/config/config.hpp +index 1f4d037..dabde59 100755 +--- a/snes/config/config.hpp ++++ b/snes/config/config.hpp +@@ -10,6 +10,7 @@ struct Configuration { + unsigned ntsc_frequency; + unsigned pal_frequency; + unsigned wram_init_value; ++ bool alt_poll_timings; + } cpu; + + struct SMP { +diff --git a/snes/cpu/timing/joypad.cpp b/snes/cpu/timing/joypad.cpp +index 6a98de0..ae8e94f 100755 +--- a/snes/cpu/timing/joypad.cpp ++++ b/snes/cpu/timing/joypad.cpp +@@ -29,4 +29,44 @@ void CPU::step_auto_joypad_poll() { + } + } + ++//called every 128 clocks; see CPU::add_clocks() ++void CPU::step_auto_joypad_poll_NEW(bool polarity) { ++ if(status.auto_joypad_counter > 0 && status.auto_joypad_counter <= 34) { ++ if(!status.auto_joypad_latch) { ++ //FIXME: Is this right, busy flag goes on even if not enabled??? ++ if(status.auto_joypad_counter == 1) ++ status.auto_joypad_active = true; ++ if(status.auto_joypad_counter == 34) ++ status.auto_joypad_active = false; ++ } else { ++ if(status.auto_joypad_counter == 1) { ++ status.auto_joypad_active = true; ++ input.port1->latch(1); ++ input.port2->latch(1); ++ } ++ if(status.auto_joypad_counter == 3) { ++ input.port1->latch(0); ++ input.port2->latch(0); ++ } ++ if((status.auto_joypad_counter & 1) != 0 && status.auto_joypad_counter != 1) { ++ uint2 port0 = input.port1->data(); ++ uint2 port1 = input.port2->data(); ++ ++ status.joy1 = (status.joy1 << 1) | (bool)(port0 & 1); ++ status.joy2 = (status.joy2 << 1) | (bool)(port1 & 1); ++ status.joy3 = (status.joy3 << 1) | (bool)(port0 & 2); ++ status.joy4 = (status.joy4 << 1) | (bool)(port1 & 2); ++ } ++ if(status.auto_joypad_counter == 34) ++ status.auto_joypad_active = false; ++ } ++ status.auto_joypad_counter++; ++ } ++ if(vcounter() >= (ppu.overscan() == false ? 225 : 240) && status.auto_joypad_counter == 0 && !polarity) { ++ status.auto_joypad_latch = status.auto_joypad_poll; ++ status.auto_joypad_counter = 1; ++ } ++} ++ ++ + #endif +diff --git a/snes/cpu/timing/timing.cpp b/snes/cpu/timing/timing.cpp +index f1378f0..d7cf24f 100755 +--- a/snes/cpu/timing/timing.cpp ++++ b/snes/cpu/timing/timing.cpp +@@ -17,10 +17,18 @@ void CPU::add_clocks(unsigned clocks) { + + step(clocks); + +- status.auto_joypad_clock += clocks; +- if(status.auto_joypad_clock >= 256) { +- status.auto_joypad_clock -= 256; +- step_auto_joypad_poll(); ++ if(config.cpu.alt_poll_timings) { ++ bool opolarity = (status.auto_joypad_clock & 128); ++ status.auto_joypad_clock = (status.auto_joypad_clock + clocks) & 0xFF; ++ bool npolarity = (status.auto_joypad_clock & 128); ++ if(opolarity != npolarity) ++ step_auto_joypad_poll_NEW(opolarity); ++ } else { ++ status.auto_joypad_clock += clocks; ++ if(status.auto_joypad_clock >= 256) { ++ status.auto_joypad_clock -= 256; ++ step_auto_joypad_poll(); ++ } + } + + if(status.dram_refreshed == false && hcounter() >= status.dram_refresh_position) { +diff --git a/snes/cpu/timing/timing.hpp b/snes/cpu/timing/timing.hpp +index 6c225da..bf15a72 100755 +--- a/snes/cpu/timing/timing.hpp ++++ b/snes/cpu/timing/timing.hpp +@@ -22,3 +22,4 @@ alwaysinline bool irq_test(); + + //joypad.cpp + void step_auto_joypad_poll(); ++void step_auto_joypad_poll_NEW(bool polarity); +diff --git a/snes/snes.hpp b/snes/snes.hpp +index 37ed1fe..4e3ba64 100755 +--- a/snes/snes.hpp ++++ b/snes/snes.hpp +@@ -1,6 +1,7 @@ + #ifndef SNES_HPP + #define SNES_HPP + #define BSNES_SUPPORTS_ADV_BREAKPOINTS ++#define BSNES_SUPPORTS_ALT_TIMINGS + + namespace SNES { + namespace Info { +-- +1.8.5.1 +