From de52e5889e97029eba7a7945ee6ecdd69907fd61 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Mon, 13 Feb 2012 18:58:53 +0200 Subject: [PATCH 1/2] Add header file in order to make it compile with bsnes v086 --- src/core/memorymanip.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/memorymanip.cpp b/src/core/memorymanip.cpp index da792d38..a5c363f5 100644 --- a/src/core/memorymanip.cpp +++ b/src/core/memorymanip.cpp @@ -1,5 +1,6 @@ #include "lsnes.hpp" #include +#include #include #include "core/command.hpp" From d6af918d5bcc2ea4df49eb54736cec1232b35851 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Mon, 13 Feb 2012 19:09:28 +0200 Subject: [PATCH 2/2] Allow compiling against bsnes v086 Add the patches and code changes needed by v086 --- VERSION | 2 +- ...01-Don-t-use-time-in-emulating-chips.patch | 84 +++++++++++++++++++ ...ve-controller-state-when-savestating.patch | 54 ++++++++++++ ...ontend-to-control-random-number-seed.patch | 53 ++++++++++++ manual.lyx | 8 ++ manual.txt | 4 + 6 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 bsnes-patches/v086/0001-Don-t-use-time-in-emulating-chips.patch create mode 100644 bsnes-patches/v086/0002-Save-controller-state-when-savestating.patch create mode 100644 bsnes-patches/v086/0003-Allow-frontend-to-control-random-number-seed.patch diff --git a/VERSION b/VERSION index e1de1ebb..3177b817 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1-Δ2 \ No newline at end of file +1-Δ2ε1 \ No newline at end of file diff --git a/bsnes-patches/v086/0001-Don-t-use-time-in-emulating-chips.patch b/bsnes-patches/v086/0001-Don-t-use-time-in-emulating-chips.patch new file mode 100644 index 00000000..17f7b806 --- /dev/null +++ b/bsnes-patches/v086/0001-Don-t-use-time-in-emulating-chips.patch @@ -0,0 +1,84 @@ +From c6043046e5c742b9800b06b10584e346274d0e55 Mon Sep 17 00:00:00 2001 +From: Ilari Liusvaara +Date: Wed, 9 Nov 2011 00:37:44 +0200 +Subject: [PATCH 1/3] 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 +override the current time bsnes is using. +--- + snes/chip/bsx/satellaview/satellaview.cpp | 2 +- + snes/chip/spc7110/spc7110.cpp | 2 +- + snes/chip/srtc/srtc.cpp | 2 +- + snes/interface/interface.cpp | 5 +++++ + snes/interface/interface.hpp | 1 + + 5 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/snes/chip/bsx/satellaview/satellaview.cpp b/snes/chip/bsx/satellaview/satellaview.cpp +index 386fb62..3c98019 100755 +--- a/snes/chip/bsx/satellaview/satellaview.cpp ++++ b/snes/chip/bsx/satellaview/satellaview.cpp +@@ -38,7 +38,7 @@ uint8 BSXSatellaview::mmio_read(unsigned addr) { + + if(counter == 0) { + time_t rawtime; +- time(&rawtime); ++ rawtime = SNES::interface->currentTime(); + tm *t = localtime(&rawtime); + + regs.r2192_hour = t->tm_hour; +diff --git a/snes/chip/spc7110/spc7110.cpp b/snes/chip/spc7110/spc7110.cpp +index d2dc640..74a817a 100755 +--- a/snes/chip/spc7110/spc7110.cpp ++++ b/snes/chip/spc7110/spc7110.cpp +@@ -101,7 +101,7 @@ void SPC7110::set_data_adjust(unsigned addr) { r4814 = addr; r4815 = addr >> 8; + + void SPC7110::update_time(int offset) { + time_t rtc_time = (rtc[16] << 0) | (rtc[17] << 8) | (rtc[18] << 16) | (rtc[19] << 24); +- time_t current_time = time(0) - offset; ++ time_t current_time = SNES::interface->currentTime() - offset; + + //sizeof(time_t) is platform-dependent; though rtc[] needs to be platform-agnostic. + //yet platforms with 32-bit signed time_t will overflow every ~68 years. handle this by +diff --git a/snes/chip/srtc/srtc.cpp b/snes/chip/srtc/srtc.cpp +index 1b2fd2a..78fc4c1 100755 +--- a/snes/chip/srtc/srtc.cpp ++++ b/snes/chip/srtc/srtc.cpp +@@ -31,7 +31,7 @@ void SRTC::reset() { + + void SRTC::update_time() { + time_t rtc_time = (rtc[16] << 0) | (rtc[17] << 8) | (rtc[18] << 16) | (rtc[19] << 24); +- time_t current_time = time(0); ++ time_t current_time = SNES::interface->currentTime(); + + //sizeof(time_t) is platform-dependent; though rtc[] needs to be platform-agnostic. + //yet platforms with 32-bit signed time_t will overflow every ~68 years. handle this by +diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp +index a0e3a81..b3017c9 100755 +--- a/snes/interface/interface.cpp ++++ b/snes/interface/interface.cpp +@@ -18,4 +18,9 @@ void Interface::message(const string &text) { + print(text, "\n"); + } + ++time_t Interface::currentTime() ++{ ++ return time(0); ++} ++ + } +diff --git a/snes/interface/interface.hpp b/snes/interface/interface.hpp +index f1a48c0..df975e8 100755 +--- a/snes/interface/interface.hpp ++++ b/snes/interface/interface.hpp +@@ -5,6 +5,7 @@ struct Interface { + + virtual string path(Cartridge::Slot slot, const string &hint) = 0; + virtual void message(const string &text); ++ virtual time_t currentTime(); + }; + + extern Interface *interface; +-- +1.7.9.48.g85da4d + diff --git a/bsnes-patches/v086/0002-Save-controller-state-when-savestating.patch b/bsnes-patches/v086/0002-Save-controller-state-when-savestating.patch new file mode 100644 index 00000000..a42cd077 --- /dev/null +++ b/bsnes-patches/v086/0002-Save-controller-state-when-savestating.patch @@ -0,0 +1,54 @@ +From 9fb6acd73f646d82e4b345292ee4c9156dfb49b3 Mon Sep 17 00:00:00 2001 +From: Ilari Liusvaara +Date: Wed, 9 Nov 2011 01:52:08 +0200 +Subject: [PATCH 2/3] Save controller state when savestating + +When savestating, save the controller state and restore it upon loadstate. +Prevents libsnes from mixing up buttons. +--- + snes/system/input.cpp | 16 ++++++++++++++++ + snes/system/input.hpp | 1 + + 2 files changed, 17 insertions(+), 0 deletions(-) + +diff --git a/snes/system/input.cpp b/snes/system/input.cpp +index 9050310..ec5559d 100755 +--- a/snes/system/input.cpp ++++ b/snes/system/input.cpp +@@ -26,6 +26,22 @@ void Input::connect(bool port, Input::Device id) { + } + } + ++void Input::serialize(serializer &s) ++{ ++ int p1, p2; ++ p1 = (int)config.controller_port1; ++ p2 = (int)config.controller_port2; ++ s.integer(p1); ++ s.integer(p2); ++ if(s.mode() == nall::serializer::Load) { ++ connect(Controller::Port1, (Device)p1); ++ connect(Controller::Port2, (Device)p2); ++ } ++ port1->serialize(s); ++ port2->serialize(s); ++} ++ ++ + Input::Input() : port1(nullptr), port2(nullptr) { + connect(Controller::Port1, Input::Device::Joypad); + connect(Controller::Port2, Input::Device::Joypad); +diff --git a/snes/system/input.hpp b/snes/system/input.hpp +index 13ef46e..6832e82 100755 +--- a/snes/system/input.hpp ++++ b/snes/system/input.hpp +@@ -31,6 +31,7 @@ struct Input { + Controller *port1; + Controller *port2; + ++ void serialize(serializer &s); + void connect(bool port, Input::Device id); + Input(); + ~Input(); +-- +1.7.9.48.g85da4d + diff --git a/bsnes-patches/v086/0003-Allow-frontend-to-control-random-number-seed.patch b/bsnes-patches/v086/0003-Allow-frontend-to-control-random-number-seed.patch new file mode 100644 index 00000000..d70b8688 --- /dev/null +++ b/bsnes-patches/v086/0003-Allow-frontend-to-control-random-number-seed.patch @@ -0,0 +1,53 @@ +From 5eb53888f8118d1894730d68fb3863919aaa309f Mon Sep 17 00:00:00 2001 +From: Ilari Liusvaara +Date: Fri, 11 Nov 2011 19:49:46 +0200 +Subject: [PATCH 3/3] Allow frontend to control random number seed + +--- + snes/interface/interface.cpp | 5 +++++ + snes/interface/interface.hpp | 1 + + snes/system/system.cpp | 2 +- + 3 files changed, 7 insertions(+), 1 deletions(-) + +diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp +index b3017c9..0a21a13 100755 +--- a/snes/interface/interface.cpp ++++ b/snes/interface/interface.cpp +@@ -23,4 +23,9 @@ time_t Interface::currentTime() + return time(0); + } + ++time_t Interface::randomSeed() ++{ ++ return time(0); ++} ++ + } +diff --git a/snes/interface/interface.hpp b/snes/interface/interface.hpp +index df975e8..30ee7fd 100755 +--- a/snes/interface/interface.hpp ++++ b/snes/interface/interface.hpp +@@ -6,6 +6,7 @@ struct Interface { + virtual string path(Cartridge::Slot slot, const string &hint) = 0; + virtual void message(const string &text); + virtual time_t currentTime(); ++ virtual time_t randomSeed(); + }; + + extern Interface *interface; +diff --git a/snes/system/system.cpp b/snes/system/system.cpp +index 284e389..99901ff 100755 +--- a/snes/system/system.cpp ++++ b/snes/system/system.cpp +@@ -151,7 +151,7 @@ void System::unload() { + } + + void System::power() { +- random.seed((unsigned)time(0)); ++ random.seed((unsigned)interface->randomSeed()); + + region = config.region; + expansion = config.expansion_port; +-- +1.7.9.48.g85da4d + diff --git a/manual.lyx b/manual.lyx index 80591f11..f0eb7969 100644 --- a/manual.lyx +++ b/manual.lyx @@ -5424,5 +5424,13 @@ Wxwidgets: Fix dumper submodes Set core controller types before loadstate \end_layout +\begin_layout Subsection +rr1-delta2epsilon1 +\end_layout + +\begin_layout Itemize +Fix compiling with bsnes v086. +\end_layout + \end_body \end_document diff --git a/manual.txt b/manual.txt index e2da5c4e..d8376148 100644 --- a/manual.txt +++ b/manual.txt @@ -2655,3 +2655,7 @@ set-axis joystick0axis19 disabled • Set core controller types before loadstate +15.49 rr1-delta2epsilon1 + +• Fix compiling with bsnes v086. +