Add bsnes alternate poll timings patch
This commit is contained in:
parent
cae6687242
commit
a81e59a1f7
14 changed files with 164 additions and 26 deletions
|
@ -1,7 +1,7 @@
|
|||
From b19b3b2d1d7a522af695f4482abb28e52804326b Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From bb2fed04fbfe62a89e4bcfe90f44b4738f7c7c1a Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From 7379b4570e5755a5a1da25181ba4f5d1ca461a98 Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From efe1b5884c316ce070953edd87c6c9aeffffaa94 Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From cdf2f46490f128308eb7f399d03530936ebeda0a Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From 4dc46334ec175e26277632fee4aea80768749af9 Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From eeaf6dc52d39ca9c150ff61864c11297d200d968 Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From 7018377c93553071fc404db872b2746d40ac3bce Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From 6e0364c9a86caa71623a188a720b2d68b304b89b Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From e397bd46f17d6ea00c8c96d5a8e0c5f5b4a6f642 Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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 <nall/string/convert.hpp>
|
||||
#include <nall/string/cstring.hpp>
|
||||
--
|
||||
1.8.4.4
|
||||
1.8.5.1
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From e047aa8eb9883f60e4141effba8128a4a555d8be Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From a5b380757b086e3a00b47fe14e2a63c74683e8da Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
From 8bc6bb381e680616dcc843c99889799aedd43163 Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
From 40c456dadd79cb2c94379fda8b41a4d0ba051ad1 Mon Sep 17 00:00:00 2001
|
||||
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
|
||||
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
|
||||
|
Loading…
Add table
Reference in a new issue