Add BSNES patches for v085
This commit is contained in:
parent
251b2c860a
commit
c6eb5ac4cc
15 changed files with 336 additions and 1 deletions
82
bsnes-patches/v085/0001-Make-libsnes-compile.patch
Normal file
82
bsnes-patches/v085/0001-Make-libsnes-compile.patch
Normal file
|
@ -0,0 +1,82 @@
|
|||
From 2bd1d4a577c8ac57f742635f3a139e9c192687fe 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 1/6] Make libsnes compile
|
||||
|
||||
Changes between v083 and v084 had broken libsnes. Fix it so it at least
|
||||
compiles.
|
||||
---
|
||||
ui-libsnes/libsnes.cpp | 37 +++++++++++++++++++++++++++++++++++--
|
||||
1 files changed, 35 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/ui-libsnes/libsnes.cpp b/ui-libsnes/libsnes.cpp
|
||||
index fbb4482..5f5ded6 100755
|
||||
--- a/ui-libsnes/libsnes.cpp
|
||||
+++ b/ui-libsnes/libsnes.cpp
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "libsnes.hpp"
|
||||
#include <snes/snes.hpp>
|
||||
+#include <gameboy/gameboy.hpp>
|
||||
|
||||
#include <nall/snes/cartridge.hpp>
|
||||
#include <nall/gameboy/cartridge.hpp>
|
||||
@@ -46,6 +47,38 @@ struct Interface : public SNES::Interface {
|
||||
print(text, "\n");
|
||||
}
|
||||
|
||||
+ void setCheats(const lstring &list = lstring{}) {
|
||||
+ if(SNES::cartridge.mode() == SNES::Cartridge::Mode::SuperGameBoy) {
|
||||
+ GameBoy::cheat.reset();
|
||||
+ for(auto &code : list) {
|
||||
+ lstring codelist;
|
||||
+ codelist.split("+", code);
|
||||
+ for(auto &part : codelist) {
|
||||
+ unsigned addr, data, comp;
|
||||
+ if(GameBoy::Cheat::decode(part, addr, data, comp)) {
|
||||
+ GameBoy::cheat.append({ addr, data, comp });
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ GameBoy::cheat.synchronize();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ SNES::cheat.reset();
|
||||
+ for(auto &code : list) {
|
||||
+ lstring codelist;
|
||||
+ codelist.split("+", code);
|
||||
+ for(auto &part : codelist) {
|
||||
+ unsigned addr, data;
|
||||
+ if(SNES::Cheat::decode(part, addr, data)) {
|
||||
+ SNES::cheat.append({ addr, data });
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ SNES::cheat.synchronize();
|
||||
+ }
|
||||
+
|
||||
+
|
||||
string path(SNES::Cartridge::Slot slot, const string &hint) {
|
||||
return { basename, hint };
|
||||
}
|
||||
@@ -115,7 +148,7 @@ void snes_set_cartridge_basename(const char *basename) {
|
||||
}
|
||||
|
||||
void snes_init(void) {
|
||||
- interface.initialize(&interface);
|
||||
+ SNES::system.init();
|
||||
SNES::input.connect(SNES::Controller::Port1, SNES::Input::Device::Joypad);
|
||||
SNES::input.connect(SNES::Controller::Port2, SNES::Input::Device::Joypad);
|
||||
}
|
||||
@@ -244,7 +277,7 @@ bool snes_load_cartridge_super_game_boy(
|
||||
uint8_t *data = new uint8_t[dmg_size];
|
||||
memcpy(data, dmg_data, dmg_size);
|
||||
string xmldmg = (dmg_xml && *dmg_xml) ? string(dmg_xml) : GameBoyCartridge(data, dmg_size).markup;
|
||||
- GameBoy::cartridge.load(xmldmg, data, dmg_size);
|
||||
+ GameBoy::cartridge.load(GameBoy::System::Revision::SuperGameBoy, xmldmg, data, dmg_size);
|
||||
delete[] data;
|
||||
}
|
||||
SNES::cartridge.load(SNES::Cartridge::Mode::SuperGameBoy, xmlrom);
|
||||
--
|
||||
1.7.8.3.g027b7
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
From 1dd7c73ba21009ec68e5129072a14c6704497a32 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 2/6] Fix bsnes version number in libsnes to be v085, not v083
|
||||
|
||||
---
|
||||
ui-libsnes/libsnes.cpp | 2 +-
|
||||
1 files changed, 1 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/ui-libsnes/libsnes.cpp b/ui-libsnes/libsnes.cpp
|
||||
index 5f5ded6..0e63075 100755
|
||||
--- a/ui-libsnes/libsnes.cpp
|
||||
+++ b/ui-libsnes/libsnes.cpp
|
||||
@@ -112,7 +112,7 @@ struct Interface : public SNES::Interface {
|
||||
static Interface interface;
|
||||
|
||||
const char* snes_library_id(void) {
|
||||
- return "bsnes v083";
|
||||
+ return "bsnes v085";
|
||||
}
|
||||
|
||||
unsigned snes_library_revision_major(void) {
|
||||
--
|
||||
1.7.8.3.g027b7
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
From 3c73ac6afaf0a581b5aa75ab958b27b4c976a74f 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 3/6] 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.8.3.g027b7
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
From a76bc71b5dff6f1a9bbd458f0519c6d59d8f47d4 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 4/6] 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.8.3.g027b7
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
From eeeb659d03e9613906ebe07354b195afd98c9c66 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 5/6] Fix unserialization of 64-bit signed integers
|
||||
|
||||
---
|
||||
nall/serializer.hpp | 2 +-
|
||||
1 files changed, 1 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/nall/serializer.hpp b/nall/serializer.hpp
|
||||
index ff2337a..e6bc8fa 100755
|
||||
--- a/nall/serializer.hpp
|
||||
+++ b/nall/serializer.hpp
|
||||
@@ -58,7 +58,7 @@ namespace nall {
|
||||
for(unsigned n = 0; n < size; n++) idata[isize++] = value >> (n << 3);
|
||||
} else if(imode == Load) {
|
||||
value = 0;
|
||||
- for(unsigned n = 0; n < size; n++) value |= idata[isize++] << (n << 3);
|
||||
+ for(unsigned n = 0; n < size; n++) value |= (unsigned long long)idata[isize++] << (n << 3);
|
||||
} else if(imode == Size) {
|
||||
isize += size;
|
||||
}
|
||||
--
|
||||
1.7.8.3.g027b7
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
From 9912e6cc68f8ef1d509b76bf4384482d87deeef4 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 6/6] 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 c19a7c5..dbd912d 100755
|
||||
--- a/snes/system/system.cpp
|
||||
+++ b/snes/system/system.cpp
|
||||
@@ -146,7 +146,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.8.3.g027b7
|
||||
|
|
@ -4846,5 +4846,13 @@ Reliably pause after skip poll
|
|||
Fix controller logical numbers
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
rr0-delta1epsilon1
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
Add BSNES patches for v085.
|
||||
\end_layout
|
||||
|
||||
\end_body
|
||||
\end_document
|
||||
|
|
|
@ -2352,3 +2352,7 @@ set-axis joystick0axis19 disabled
|
|||
|
||||
• Fix controller logical numbers
|
||||
|
||||
13.30 rr0-delta1epsilon1
|
||||
|
||||
• Add BSNES patches for v085.
|
||||
|
||||
|
|
|
@ -299,4 +299,4 @@ uint32_t gcd(uint32_t a, uint32_t b) throw()
|
|||
}
|
||||
|
||||
std::string bsnes_core_version;
|
||||
std::string lsnes_version = "0-Δ1";
|
||||
std::string lsnes_version = "0-Δ1ε1";
|
||||
|
|
Loading…
Add table
Reference in a new issue