Backport bsnes/gambatte patches and make emu at least run

This commit is contained in:
Ilari Liusvaara 2013-12-06 07:51:15 +02:00
parent 8de45f693e
commit 56c1282e48
48 changed files with 8338 additions and 297 deletions

View file

@ -1,13 +1,13 @@
From 53dc2ba4aa6f590d15d9bc65cefb11f74c2448e8 Mon Sep 17 00:00:00 2001
From 831e9614a7babbacf59935960fbaa6cfc8d49c08 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/8] Make libsnes compile
Subject: [PATCH 01/10] 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(-)
ui-libsnes/libsnes.cpp | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/ui-libsnes/libsnes.cpp b/ui-libsnes/libsnes.cpp
index fbb4482..5f5ded6 100755
@ -78,5 +78,5 @@ index fbb4482..5f5ded6 100755
}
SNES::cartridge.load(SNES::Cartridge::Mode::SuperGameBoy, xmlrom);
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,11 +1,12 @@
From d5898559fdf6bb52bbe38c509e3d80ea46107ced Mon Sep 17 00:00:00 2001
From df7851648e41ae6b6efd1a54cdcd32ac55a90131 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/8] Fix bsnes version number in libsnes to be v084, not v083
Subject: [PATCH 02/10] Fix bsnes version number in libsnes to be v084, not
v083
---
ui-libsnes/libsnes.cpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
ui-libsnes/libsnes.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui-libsnes/libsnes.cpp b/ui-libsnes/libsnes.cpp
index 5f5ded6..6b4ef12 100755
@ -21,5 +22,5 @@ index 5f5ded6..6b4ef12 100755
unsigned snes_library_revision_major(void) {
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,17 +1,17 @@
From a9a884ed827d5e61bbf5f3346001bd96cf4e80d2 Mon Sep 17 00:00:00 2001
From b481e3d161d924cc5a4449329393c8d9f23b27ec 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/8] Don't use time() in emulating chips
Subject: [PATCH 03/10] 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 +
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
@ -80,5 +80,5 @@ index f1a48c0..df975e8 100755
extern Interface *interface;
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,26 +1,26 @@
From 0e21eb89711c7254bdcbf7054b4bcd3abe815c6f Mon Sep 17 00:00:00 2001
From af7fdd9f73a3eb5e9266c59bfb4dd676679b2f7d 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/8] Save controller state when savestating
Subject: [PATCH 04/10] Save controller state when savestating
When savestating, save the controller state and restore it upon loadstate.
Prevents libsnes from mixing up buttons.
---
snes/controller/controller.cpp | 8 ++++++
snes/controller/controller.hpp | 2 +
snes/controller/gamepad/gamepad.cpp | 13 ++++++++++
snes/controller/gamepad/gamepad.hpp | 2 +-
snes/controller/justifier/justifier.cpp | 36 +++++++++++++++++++++++++++++
snes/controller/justifier/justifier.hpp | 1 +
snes/controller/mouse/mouse.cpp | 13 ++++++++++
snes/controller/mouse/mouse.hpp | 2 +-
snes/controller/multitap/multitap.cpp | 16 +++++++++++++
snes/controller/multitap/multitap.hpp | 2 +-
snes/controller/superscope/superscope.cpp | 31 +++++++++++++++++++++++++
snes/controller/superscope/superscope.hpp | 1 +
snes/input/input.cpp | 15 ++++++++++++
snes/input/input.hpp | 1 +
snes/system/serialization.cpp | 1 +
snes/controller/controller.cpp | 8 +++++++
snes/controller/controller.hpp | 2 ++
snes/controller/gamepad/gamepad.cpp | 13 +++++++++++
snes/controller/gamepad/gamepad.hpp | 2 +-
snes/controller/justifier/justifier.cpp | 36 +++++++++++++++++++++++++++++++
snes/controller/justifier/justifier.hpp | 1 +
snes/controller/mouse/mouse.cpp | 13 +++++++++++
snes/controller/mouse/mouse.hpp | 2 +-
snes/controller/multitap/multitap.cpp | 16 ++++++++++++++
snes/controller/multitap/multitap.hpp | 2 +-
snes/controller/superscope/superscope.cpp | 31 ++++++++++++++++++++++++++
snes/controller/superscope/superscope.hpp | 1 +
snes/input/input.cpp | 15 +++++++++++++
snes/input/input.hpp | 1 +
snes/system/serialization.cpp | 1 +
15 files changed, 141 insertions(+), 3 deletions(-)
diff --git a/snes/controller/controller.cpp b/snes/controller/controller.cpp
@ -341,5 +341,5 @@ index f7d6f3b..08e7051 100755
if(cartridge.mode() == Cartridge::Mode::SufamiTurbo) sufamiturbo.serialize(s);
if(cartridge.mode() == Cartridge::Mode::SuperGameBoy) icd2.serialize(s);
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,11 +1,11 @@
From c8007a40719d62b6863f6f1fb452b747ade52dea Mon Sep 17 00:00:00 2001
From aa1352516e38ff64f304d8831b357841c4795e43 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/8] Fix unserialization of 64-bit signed integers
Subject: [PATCH 05/10] Fix unserialization of 64-bit signed integers
---
nall/serializer.hpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
nall/serializer.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nall/serializer.hpp b/nall/serializer.hpp
index ff2337a..e6bc8fa 100755
@ -21,5 +21,5 @@ index ff2337a..e6bc8fa 100755
isize += size;
}
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,13 +1,13 @@
From b9697a3b68617afee7fbfcd33af2bfea4034380b Mon Sep 17 00:00:00 2001
From 794d83cb28a93d9ae1e613598d3c7cf09090d6a3 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/8] Allow frontend to control random number seed
Subject: [PATCH 06/10] 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(-)
snes/interface/interface.cpp | 5 +++++
snes/interface/interface.hpp | 1 +
snes/system/system.cpp | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp
index b3017c9..0a21a13 100755
@ -49,5 +49,5 @@ index 6881810..8583595 100755
region = config.region;
expansion = config.expansion_port;
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,13 +1,13 @@
From 33bb874115cbb28d567bfbeee682aa4e82319fb4 Mon Sep 17 00:00:00 2001
From 4f6981592e29038ad9f818399c0d5a48750cf28a 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 7/8] Fix mouse polling
Subject: [PATCH 07/10] Fix mouse polling
Don't poll for mouse motion excessive number of times (no need to poll it for
each bit!)
---
snes/controller/mouse/mouse.cpp | 14 ++++++++++++--
snes/controller/mouse/mouse.hpp | 2 ++
snes/controller/mouse/mouse.cpp | 14 ++++++++++++--
snes/controller/mouse/mouse.hpp | 2 ++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/snes/controller/mouse/mouse.cpp b/snes/controller/mouse/mouse.cpp
@ -59,5 +59,5 @@ index b66ea51..b07c8ab 100755
+ int _position_y;
};
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,12 +1,12 @@
From 0ab605a604efec1b4ae32b31e8ae8ecb62e6e1db Mon Sep 17 00:00:00 2001
From 7b09063fbcaf50c56b476a744f9f3d9634777740 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 8/8] Add needed support for detecting true polls as opposed
Subject: [PATCH 08/10] Add needed support for detecting true polls as opposed
to just autopolling
---
snes/cpu/cpu.hpp | 1 +
snes/cpu/mmio/mmio.cpp | 18 ++++++++++--------
snes/cpu/cpu.hpp | 1 +
snes/cpu/mmio/mmio.cpp | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/snes/cpu/cpu.hpp b/snes/cpu/cpu.hpp
@ -65,5 +65,5 @@ index 8b6aaa6..c5ee930 100755
//DMAPx
uint8 CPU::mmio_r43x0(uint8 i) {
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -0,0 +1,65 @@
From 62f8a07104b57b75071318098145d99012dbc908 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 09/10] Support notifying latches
---
snes/cpu/mmio/mmio.cpp | 1 +
snes/cpu/timing/joypad.cpp | 1 +
snes/interface/interface.cpp | 5 +++++
snes/interface/interface.hpp | 1 +
4 files changed, 8 insertions(+)
diff --git a/snes/cpu/mmio/mmio.cpp b/snes/cpu/mmio/mmio.cpp
index c5ee930..b7afff0 100755
--- a/snes/cpu/mmio/mmio.cpp
+++ b/snes/cpu/mmio/mmio.cpp
@@ -33,6 +33,7 @@ void CPU::mmio_w2183(uint8 data) {
//strobing $4016.d0 affects both controller port latches.
//$4017 bit 0 writes are ignored.
void CPU::mmio_w4016(uint8 data) {
+ if(data&1) interface->notifyLatched();
input.port1->latch(data & 1);
input.port2->latch(data & 1);
}
diff --git a/snes/cpu/timing/joypad.cpp b/snes/cpu/timing/joypad.cpp
index 6e15346..c69b708 100755
--- a/snes/cpu/timing/joypad.cpp
+++ b/snes/cpu/timing/joypad.cpp
@@ -7,6 +7,7 @@ void CPU::step_auto_joypad_poll() {
if(status.auto_joypad_active && status.auto_joypad_poll) {
if(status.auto_joypad_counter == 0) {
+ interface->notifyLatched();
input.port1->latch(1);
input.port2->latch(1);
input.port1->latch(0);
diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp
index 0a21a13..6685556 100755
--- a/snes/interface/interface.cpp
+++ b/snes/interface/interface.cpp
@@ -28,4 +28,9 @@ time_t Interface::randomSeed()
return time(0);
}
+void Interface::notifyLatched()
+{
+ //Nothing.
+}
+
}
diff --git a/snes/interface/interface.hpp b/snes/interface/interface.hpp
index 30ee7fd..203f7b0 100755
--- a/snes/interface/interface.hpp
+++ b/snes/interface/interface.hpp
@@ -7,6 +7,7 @@ struct Interface {
virtual void message(const string &text);
virtual time_t currentTime();
virtual time_t randomSeed();
+ virtual void notifyLatched();
};
extern Interface *interface;
--
1.8.4.4

View file

@ -0,0 +1,22 @@
From 242efcc9cf10fa58c8e06f154c41db21e6aa2688 Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Sat, 30 Nov 2013 10:26:59 +0200
Subject: [PATCH 10/10] Add support for auto-detecting bsnes version
---
bsnes.mk | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 bsnes.mk
diff --git a/bsnes.mk b/bsnes.mk
new file mode 100644
index 0000000..11300e2
--- /dev/null
+++ b/bsnes.mk
@@ -0,0 +1,3 @@
+BSNES_SUPPORTS_DEBUGGER=yes
+LIBSNES_DIR=ui-libsnes
+BSNES_VERSION=084
--
1.8.4.4

View file

@ -1,13 +1,13 @@
From b87f839552118e8a0f198509e995d21a14ea752f Mon Sep 17 00:00:00 2001
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/10] Make libsnes compile
Subject: [PATCH 01/13] 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(-)
ui-libsnes/libsnes.cpp | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/ui-libsnes/libsnes.cpp b/ui-libsnes/libsnes.cpp
index fbb4482..5f5ded6 100755
@ -78,5 +78,5 @@ index fbb4482..5f5ded6 100755
}
SNES::cartridge.load(SNES::Cartridge::Mode::SuperGameBoy, xmlrom);
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,12 +1,12 @@
From 98470a361dacf9e8948528cccf5cd3b79af233a9 Mon Sep 17 00:00:00 2001
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/10] Fix bsnes version number in libsnes to be v085, not
Subject: [PATCH 02/13] Fix bsnes version number in libsnes to be v085, not
v083
---
ui-libsnes/libsnes.cpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
ui-libsnes/libsnes.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui-libsnes/libsnes.cpp b/ui-libsnes/libsnes.cpp
index 5f5ded6..0e63075 100755
@ -22,5 +22,5 @@ index 5f5ded6..0e63075 100755
unsigned snes_library_revision_major(void) {
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,17 +1,17 @@
From 6c6818de834be6664de6bb8a439c54997e43b33f Mon Sep 17 00:00:00 2001
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/10] Don't use time() in emulating chips
Subject: [PATCH 03/13] 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 +
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
@ -80,5 +80,5 @@ index f1a48c0..df975e8 100755
extern Interface *interface;
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,26 +1,26 @@
From 3e9d5d306fb7f7c2e366e3eb84c0415673715d43 Mon Sep 17 00:00:00 2001
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/10] Save controller state when savestating
Subject: [PATCH 04/13] Save controller state when savestating
When savestating, save the controller state and restore it upon loadstate.
Prevents libsnes from mixing up buttons.
---
snes/controller/controller.cpp | 8 ++++++
snes/controller/controller.hpp | 2 +
snes/controller/gamepad/gamepad.cpp | 13 ++++++++++
snes/controller/gamepad/gamepad.hpp | 2 +-
snes/controller/justifier/justifier.cpp | 36 +++++++++++++++++++++++++++++
snes/controller/justifier/justifier.hpp | 1 +
snes/controller/mouse/mouse.cpp | 13 ++++++++++
snes/controller/mouse/mouse.hpp | 2 +-
snes/controller/multitap/multitap.cpp | 16 +++++++++++++
snes/controller/multitap/multitap.hpp | 2 +-
snes/controller/superscope/superscope.cpp | 31 +++++++++++++++++++++++++
snes/controller/superscope/superscope.hpp | 1 +
snes/system/input.cpp | 16 +++++++++++++
snes/system/input.hpp | 1 +
snes/system/serialization.cpp | 1 +
snes/controller/controller.cpp | 8 +++++++
snes/controller/controller.hpp | 2 ++
snes/controller/gamepad/gamepad.cpp | 13 +++++++++++
snes/controller/gamepad/gamepad.hpp | 2 +-
snes/controller/justifier/justifier.cpp | 36 +++++++++++++++++++++++++++++++
snes/controller/justifier/justifier.hpp | 1 +
snes/controller/mouse/mouse.cpp | 13 +++++++++++
snes/controller/mouse/mouse.hpp | 2 +-
snes/controller/multitap/multitap.cpp | 16 ++++++++++++++
snes/controller/multitap/multitap.hpp | 2 +-
snes/controller/superscope/superscope.cpp | 31 ++++++++++++++++++++++++++
snes/controller/superscope/superscope.hpp | 1 +
snes/system/input.cpp | 16 ++++++++++++++
snes/system/input.hpp | 1 +
snes/system/serialization.cpp | 1 +
15 files changed, 142 insertions(+), 3 deletions(-)
diff --git a/snes/controller/controller.cpp b/snes/controller/controller.cpp
@ -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.7.9.48.g85da4d
1.8.4.4

View file

@ -1,11 +1,11 @@
From 160ee6cc6a1907058870dd0ee1f4918885739c66 Mon Sep 17 00:00:00 2001
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/10] Fix unserialization of 64-bit signed integers
Subject: [PATCH 05/13] Fix unserialization of 64-bit signed integers
---
nall/serializer.hpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
nall/serializer.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nall/serializer.hpp b/nall/serializer.hpp
index ff2337a..e6bc8fa 100755
@ -21,5 +21,5 @@ index ff2337a..e6bc8fa 100755
isize += size;
}
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,13 +1,13 @@
From 8e8917baa6aba22c3be013fbc7e57b9184be3ab9 Mon Sep 17 00:00:00 2001
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/10] Allow frontend to control random number seed
Subject: [PATCH 06/13] 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(-)
snes/interface/interface.cpp | 5 +++++
snes/interface/interface.hpp | 1 +
snes/system/system.cpp | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp
index b3017c9..0a21a13 100755
@ -49,5 +49,5 @@ index c19a7c5..dbd912d 100755
region = config.region;
expansion = config.expansion_port;
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,13 +1,13 @@
From f13cc0de2ff39aaaf3b1bb32a28339f87c6a9c83 Mon Sep 17 00:00:00 2001
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/10] Fix mouse polling
Subject: [PATCH 07/13] Fix mouse polling
Don't poll for mouse motion excessive number of times (no need to poll it for
each bit!)
---
snes/controller/mouse/mouse.cpp | 14 ++++++++++++--
snes/controller/mouse/mouse.hpp | 2 ++
snes/controller/mouse/mouse.cpp | 14 ++++++++++++--
snes/controller/mouse/mouse.hpp | 2 ++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/snes/controller/mouse/mouse.cpp b/snes/controller/mouse/mouse.cpp
@ -59,5 +59,5 @@ index b66ea51..b07c8ab 100755
+ int _position_y;
};
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,19 +1,19 @@
From 14aaecac2238a00d51f295d29e1ebc283ca9ec79 Mon Sep 17 00:00:00 2001
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/10] Fix uninitialized variables
Subject: [PATCH 08/13] Fix uninitialized variables
These uninitialized variables cause a lot of desyncs in Shadowrun.
---
snes/alt/dsp/dsp.cpp | 2 ++
snes/alt/ppu-compatibility/ppu.cpp | 11 +++++++++++
snes/cpu/core/core.cpp | 8 ++++++++
snes/cpu/core/core.hpp | 2 ++
snes/cpu/cpu.cpp | 1 +
snes/smp/core/core.cpp | 11 +++++++++++
snes/smp/core/core.hpp | 2 ++
snes/smp/smp.cpp | 1 +
8 files changed, 38 insertions(+), 0 deletions(-)
snes/alt/dsp/dsp.cpp | 2 ++
snes/alt/ppu-compatibility/ppu.cpp | 11 +++++++++++
snes/cpu/core/core.cpp | 8 ++++++++
snes/cpu/core/core.hpp | 2 ++
snes/cpu/cpu.cpp | 1 +
snes/smp/core/core.cpp | 11 +++++++++++
snes/smp/core/core.hpp | 2 ++
snes/smp/smp.cpp | 1 +
8 files changed, 38 insertions(+)
diff --git a/snes/alt/dsp/dsp.cpp b/snes/alt/dsp/dsp.cpp
index d0c9e07..c6809f7 100755
@ -138,5 +138,5 @@ index 9080624..d4ccf42 100755
void SMP::reset() {
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,12 +1,12 @@
From de9503d93bcb202684bbadcabba2a0192483a825 Mon Sep 17 00:00:00 2001
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/10] Add needed support for detecting true polls as opposed
Subject: [PATCH 09/13] Add needed support for detecting true polls as opposed
to just autopolling
---
snes/cpu/cpu.hpp | 1 +
snes/cpu/mmio/mmio.cpp | 18 ++++++++++--------
snes/cpu/cpu.hpp | 1 +
snes/cpu/mmio/mmio.cpp | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/snes/cpu/cpu.hpp b/snes/cpu/cpu.hpp
@ -65,5 +65,5 @@ index 8b6aaa6..c5ee930 100755
//DMAPx
uint8 CPU::mmio_r43x0(uint8 i) {
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,11 +1,11 @@
From fde47ff185a4f6dadd69f7afb47b5351dacbcb96 Mon Sep 17 00:00:00 2001
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/10] Fix compiling on GCC 4.7
Subject: [PATCH 10/13] Fix compiling on GCC 4.7
---
nall/string.hpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
nall/string.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nall/string.hpp b/nall/string.hpp
index 1b255ce..07a64df 100755
@ -22,5 +22,5 @@ index 1b255ce..07a64df 100755
#include <nall/string/convert.hpp>
#include <nall/string/cstring.hpp>
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -0,0 +1,65 @@
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
---
snes/cpu/mmio/mmio.cpp | 1 +
snes/cpu/timing/joypad.cpp | 1 +
snes/interface/interface.cpp | 5 +++++
snes/interface/interface.hpp | 1 +
4 files changed, 8 insertions(+)
diff --git a/snes/cpu/mmio/mmio.cpp b/snes/cpu/mmio/mmio.cpp
index c5ee930..b7afff0 100755
--- a/snes/cpu/mmio/mmio.cpp
+++ b/snes/cpu/mmio/mmio.cpp
@@ -33,6 +33,7 @@ void CPU::mmio_w2183(uint8 data) {
//strobing $4016.d0 affects both controller port latches.
//$4017 bit 0 writes are ignored.
void CPU::mmio_w4016(uint8 data) {
+ if(data&1) interface->notifyLatched();
input.port1->latch(data & 1);
input.port2->latch(data & 1);
}
diff --git a/snes/cpu/timing/joypad.cpp b/snes/cpu/timing/joypad.cpp
index 179df27..6a98de0 100755
--- a/snes/cpu/timing/joypad.cpp
+++ b/snes/cpu/timing/joypad.cpp
@@ -9,6 +9,7 @@ void CPU::step_auto_joypad_poll() {
if(status.auto_joypad_active && status.auto_joypad_latch) {
if(status.auto_joypad_counter == 0) {
+ interface->notifyLatched();
input.port1->latch(1);
input.port2->latch(1);
input.port1->latch(0);
diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp
index 0a21a13..6685556 100755
--- a/snes/interface/interface.cpp
+++ b/snes/interface/interface.cpp
@@ -28,4 +28,9 @@ time_t Interface::randomSeed()
return time(0);
}
+void Interface::notifyLatched()
+{
+ //Nothing.
+}
+
}
diff --git a/snes/interface/interface.hpp b/snes/interface/interface.hpp
index 30ee7fd..203f7b0 100755
--- a/snes/interface/interface.hpp
+++ b/snes/interface/interface.hpp
@@ -7,6 +7,7 @@ struct Interface {
virtual void message(const string &text);
virtual time_t currentTime();
virtual time_t randomSeed();
+ virtual void notifyLatched();
};
extern Interface *interface;
--
1.8.4.4

View file

@ -0,0 +1,799 @@
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
---
snes/alt/cpu/cpu.cpp | 22 +++++++-------
snes/alt/ppu-compatibility/ppu.cpp | 4 +--
snes/alt/ppu-parallel/ppu.cpp | 4 +--
snes/alt/ppu-performance/ppu.cpp | 4 +--
snes/cartridge/cartridge.hpp | 17 +++++++++++
snes/cartridge/markup.cpp | 11 +++++++
snes/cheat/cheat.cpp | 11 ++++---
snes/cheat/cheat.hpp | 1 +
snes/chip/bsx/satellaview/satellaview.cpp | 4 +--
snes/chip/hitachidsp/hitachidsp.cpp | 2 +-
snes/chip/hitachidsp/memory.cpp | 2 +-
snes/chip/nss/nss.cpp | 4 +--
snes/chip/sa1/memory/memory.cpp | 2 +-
snes/chip/sa1/memory/memory.hpp | 2 +-
snes/chip/sa1/sa1.cpp | 2 +-
snes/chip/sdd1/sdd1.cpp | 4 +--
snes/cpu/core/core.hpp | 2 +-
snes/cpu/core/disassembler/disassembler.cpp | 2 +-
snes/cpu/core/memory.hpp | 2 +-
snes/cpu/cpu.cpp | 26 ++++++++--------
snes/cpu/debugger/debugger.cpp | 4 +--
snes/cpu/debugger/debugger.hpp | 2 +-
snes/cpu/dma/dma.cpp | 4 +--
snes/cpu/memory/memory.cpp | 4 +--
snes/cpu/memory/memory.hpp | 2 +-
snes/cpu/mmio/mmio.cpp | 2 +-
snes/debugger/debugger.cpp | 2 +-
snes/memory/memory-inline.hpp | 21 +++++++++++--
snes/memory/memory.cpp | 47 ++++++++++++++++++++++++++---
snes/memory/memory.hpp | 13 +++++++-
snes/ppu/ppu.cpp | 4 +--
snes/smp/core/core.hpp | 2 +-
snes/snes.hpp | 1 +
33 files changed, 166 insertions(+), 70 deletions(-)
diff --git a/snes/alt/cpu/cpu.cpp b/snes/alt/cpu/cpu.cpp
index 814908d..dcbb92d 100755
--- a/snes/alt/cpu/cpu.cpp
+++ b/snes/alt/cpu/cpu.cpp
@@ -89,24 +89,24 @@ void CPU::enable() {
function<uint8 (unsigned)> read = { &CPU::mmio_read, (CPU*)&cpu };
function<void (unsigned, uint8)> write = { &CPU::mmio_write, (CPU*)&cpu };
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2140, 0x2183, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2140, 0x2183, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2140, 0x2183, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2140, 0x2183, 0, read, write);
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4016, 0x4017, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4016, 0x4017, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4016, 0x4017, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4016, 0x4017, 0, read, write);
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4200, 0x421f, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4200, 0x421f, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4200, 0x421f, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4200, 0x421f, 0, read, write);
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4300, 0x437f, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4300, 0x437f, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4300, 0x437f, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4300, 0x437f, 0, read, write);
read = [](unsigned addr) { return cpu.wram[addr]; };
write = [](unsigned addr, uint8 data) { cpu.wram[addr] = data; };
- bus.map(Bus::MapMode::Linear, 0x00, 0x3f, 0x0000, 0x1fff, read, write, 0x000000, 0x002000);
- bus.map(Bus::MapMode::Linear, 0x80, 0xbf, 0x0000, 0x1fff, read, write, 0x000000, 0x002000);
- bus.map(Bus::MapMode::Linear, 0x7e, 0x7f, 0x0000, 0xffff, read, write);
+ bus.map(Bus::MapMode::Linear, 0x00, 0x3f, 0x0000, 0x1fff, 3, read, write, 0x000000, 0x002000);
+ bus.map(Bus::MapMode::Linear, 0x80, 0xbf, 0x0000, 0x1fff, 3, read, write, 0x000000, 0x002000);
+ bus.map(Bus::MapMode::Linear, 0x7e, 0x7f, 0x0000, 0xffff, 3, read, write);
}
void CPU::power() {
diff --git a/snes/alt/ppu-compatibility/ppu.cpp b/snes/alt/ppu-compatibility/ppu.cpp
index a21e5e3..122b143 100755
--- a/snes/alt/ppu-compatibility/ppu.cpp
+++ b/snes/alt/ppu-compatibility/ppu.cpp
@@ -126,8 +126,8 @@ void PPU::enable() {
function<uint8 (unsigned)> read = { &PPU::mmio_read, (PPU*)&ppu };
function<void (unsigned, uint8)> write = { &PPU::mmio_write, (PPU*)&ppu };
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2100, 0x213f, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2100, 0x213f, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2100, 0x213f, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2100, 0x213f, 0, read, write);
}
void PPU::power() {
diff --git a/snes/alt/ppu-parallel/ppu.cpp b/snes/alt/ppu-parallel/ppu.cpp
index 1c3dcb7..8dd118b 100755
--- a/snes/alt/ppu-parallel/ppu.cpp
+++ b/snes/alt/ppu-parallel/ppu.cpp
@@ -36,8 +36,8 @@ void PPU::frame() {
}
void PPU::enable() {
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2100, 0x213f, { &PPU::mmio_read, this }, { &PPU::mmio_write, this });
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2100, 0x213f, { &PPU::mmio_read, this }, { &PPU::mmio_write, this });
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2100, 0x213f, 0, { &PPU::mmio_read, this }, { &PPU::mmio_write, this });
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2100, 0x213f, 0, { &PPU::mmio_read, this }, { &PPU::mmio_write, this });
}
void PPU::power() {
diff --git a/snes/alt/ppu-performance/ppu.cpp b/snes/alt/ppu-performance/ppu.cpp
index 7c231bc..4b2b294 100755
--- a/snes/alt/ppu-performance/ppu.cpp
+++ b/snes/alt/ppu-performance/ppu.cpp
@@ -90,8 +90,8 @@ void PPU::enable() {
function<uint8 (unsigned)> read = { &PPU::mmio_read, (PPU*)&ppu };
function<void (unsigned, uint8)> write = { &PPU::mmio_write, (PPU*)&ppu };
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2100, 0x213f, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2100, 0x213f, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2100, 0x213f, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2100, 0x213f, 0, read, write);
}
void PPU::power() {
diff --git a/snes/cartridge/cartridge.hpp b/snes/cartridge/cartridge.hpp
index 37555bc..82e73c4 100755
--- a/snes/cartridge/cartridge.hpp
+++ b/snes/cartridge/cartridge.hpp
@@ -12,6 +12,22 @@ struct Cartridge : property<Cartridge> {
PAL,
};
+ enum class MemoryClass : unsigned {
+ MISC = 0,
+ ROM = 1,
+ SRAM = 2,
+ WRAM = 3,
+ SUPERFXROM = 4,
+ SUPERFXRAM = 5,
+ SA1IRAM = 6,
+ SA1BWRAM = 7,
+ SUFAMITURBO_ROMA = 8,
+ SUFAMITURBO_ROMB = 9,
+ SUFAMITURBO_RAMA = 10,
+ SUFAMITURBO_RAMB = 11,
+ BSXFLASH = 12,
+ };
+
enum class Slot : unsigned {
Base,
Bsx,
@@ -68,6 +84,7 @@ struct Cartridge : property<Cartridge> {
unsigned addrhi;
unsigned offset;
unsigned size;
+ MemoryClass clazz;
Mapping();
Mapping(const function<uint8 (unsigned)>&, const function<void (unsigned, uint8)>&);
diff --git a/snes/cartridge/markup.cpp b/snes/cartridge/markup.cpp
index e639fe5..2dd0d64 100755
--- a/snes/cartridge/markup.cpp
+++ b/snes/cartridge/markup.cpp
@@ -74,6 +74,7 @@ void Cartridge::parse_markup_rom(XML::Node &root) {
for(auto &node : root) {
if(node.name != "map") continue;
Mapping m(rom);
+ m.clazz = MemoryClass::ROM;
parse_markup_map(m, node);
if(m.size == 0) m.size = rom.size();
mapping.append(m);
@@ -85,6 +86,7 @@ void Cartridge::parse_markup_ram(XML::Node &root) {
ram_size = parse_markup_integer(root["size"].data);
for(auto &node : root) {
Mapping m(ram);
+ m.clazz = MemoryClass::SRAM;
parse_markup_map(m, node);
if(m.size == 0) m.size = ram_size;
mapping.append(m);
@@ -133,6 +135,7 @@ void Cartridge::parse_markup_superfx(XML::Node &root) {
for(auto &leaf : node) {
if(leaf.name != "map") continue;
Mapping m(superfx.rom);
+ //m.clazz = MemoryClass::SUPERFXROM; -- Aliases ROM.
parse_markup_map(m, leaf);
mapping.append(m);
}
@@ -145,6 +148,7 @@ void Cartridge::parse_markup_superfx(XML::Node &root) {
}
if(leaf.name != "map") continue;
Mapping m(superfx.ram);
+ //m.clazz = MemoryClass::SUPERFXRAM; -- Aliases SRAM.
parse_markup_map(m, leaf);
if(m.size == 0) m.size = ram_size;
mapping.append(m);
@@ -188,6 +192,7 @@ void Cartridge::parse_markup_sa1(XML::Node &root) {
for(auto &node : iram) {
if(node.name != "map") continue;
Mapping m(sa1.cpuiram);
+ m.clazz = MemoryClass::SA1IRAM;
parse_markup_map(m, node);
if(m.size == 0) m.size = 2048;
mapping.append(m);
@@ -197,6 +202,7 @@ void Cartridge::parse_markup_sa1(XML::Node &root) {
for(auto &node : bwram) {
if(node.name != "map") continue;
Mapping m(sa1.cpubwram);
+ //m.clazz = MemoryClass::SA1BWRAM; -- Aliases SRAM
parse_markup_map(m, node);
if(m.size == 0) m.size = ram_size;
mapping.append(m);
@@ -341,6 +347,7 @@ void Cartridge::parse_markup_bsx(XML::Node &root) {
for(auto &node : root["slot"]) {
if(node.name != "map") continue;
Mapping m(bsxflash.memory);
+ m.clazz = MemoryClass::BSXFLASH;
parse_markup_map(m, node);
mapping.append(m);
}
@@ -373,6 +380,7 @@ void Cartridge::parse_markup_sufamiturbo(XML::Node &root) {
if(leaf.name != "map") continue;
Memory &memory = slotid == 0 ? sufamiturbo.slotA.rom : sufamiturbo.slotB.rom;
Mapping m(memory);
+ m.clazz = slotid ? MemoryClass::SUFAMITURBO_ROMB : MemoryClass::SUFAMITURBO_ROMA;
parse_markup_map(m, leaf);
if(m.size == 0) m.size = memory.size();
if(m.size) mapping.append(m);
@@ -384,6 +392,7 @@ void Cartridge::parse_markup_sufamiturbo(XML::Node &root) {
if(leaf.name != "map") continue;
Memory &memory = slotid == 0 ? sufamiturbo.slotA.ram : sufamiturbo.slotB.ram;
Mapping m(memory);
+ m.clazz = slotid ? MemoryClass::SUFAMITURBO_RAMB : MemoryClass::SUFAMITURBO_RAMA;
parse_markup_map(m, leaf);
if(m.size == 0) m.size = ram_size;
if(m.size) mapping.append(m);
@@ -536,11 +545,13 @@ void Cartridge::parse_markup_link(XML::Node &root) {
}
Cartridge::Mapping::Mapping() {
+ clazz = MemoryClass::MISC;
mode = Bus::MapMode::Direct;
banklo = bankhi = addrlo = addrhi = offset = size = 0;
}
Cartridge::Mapping::Mapping(Memory &memory) {
+ clazz = MemoryClass::MISC;
read = { &Memory::read, &memory };
write = { &Memory::write, &memory };
mode = Bus::MapMode::Direct;
diff --git a/snes/cheat/cheat.cpp b/snes/cheat/cheat.cpp
index 46c42d1..3a269cc 100755
--- a/snes/cheat/cheat.cpp
+++ b/snes/cheat/cheat.cpp
@@ -21,9 +21,9 @@ void Cheat::synchronize() {
for(unsigned i = 0; i < size(); i++) {
const CheatCode &code = operator[](i);
- unsigned addr = mirror(code.addr);
+ unsigned addr = code.nomirror ? code.addr : mirror(code.addr);
override[addr] = true;
- if((addr & 0xffe000) == 0x7e0000) {
+ if(!code.nomirror && (addr & 0xffe000) == 0x7e0000) {
//mirror $7e:0000-1fff to $00-3f|80-bf:0000-1fff
unsigned mirroraddr;
for(unsigned x = 0; x <= 0x3f; x++) {
@@ -40,11 +40,14 @@ void Cheat::synchronize() {
}
uint8 Cheat::read(unsigned addr) const {
- addr = mirror(addr);
+ unsigned raddr = mirror(addr);
for(unsigned i = 0; i < size(); i++) {
const CheatCode &code = operator[](i);
- if(addr == mirror(code.addr)) {
+ if(!code.nomirror && addr == mirror(code.addr)) {
+ return code.data;
+ }
+ if(code.nomirror && raddr == code.addr) {
return code.data;
}
}
diff --git a/snes/cheat/cheat.hpp b/snes/cheat/cheat.hpp
index 306b99b..b4d2a42 100755
--- a/snes/cheat/cheat.hpp
+++ b/snes/cheat/cheat.hpp
@@ -1,6 +1,7 @@
struct CheatCode {
unsigned addr;
unsigned data;
+ bool nomirror;
};
struct Cheat : public linear_vector<CheatCode> {
diff --git a/snes/chip/bsx/satellaview/satellaview.cpp b/snes/chip/bsx/satellaview/satellaview.cpp
index 3c98019..25af8e5 100755
--- a/snes/chip/bsx/satellaview/satellaview.cpp
+++ b/snes/chip/bsx/satellaview/satellaview.cpp
@@ -6,8 +6,8 @@ void BSXSatellaview::init() {
}
void BSXSatellaview::load() {
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2188, 0x219f, { &BSXSatellaview::mmio_read, &bsxsatellaview }, { &BSXSatellaview::mmio_write, &bsxsatellaview });
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2188, 0x219f, { &BSXSatellaview::mmio_read, &bsxsatellaview }, { &BSXSatellaview::mmio_write, &bsxsatellaview });
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2188, 0x219f, 0, { &BSXSatellaview::mmio_read, &bsxsatellaview }, { &BSXSatellaview::mmio_write, &bsxsatellaview });
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2188, 0x219f, 0, { &BSXSatellaview::mmio_read, &bsxsatellaview }, { &BSXSatellaview::mmio_write, &bsxsatellaview });
}
void BSXSatellaview::unload() {
diff --git a/snes/chip/hitachidsp/hitachidsp.cpp b/snes/chip/hitachidsp/hitachidsp.cpp
index 1042267..3e5c5bd 100755
--- a/snes/chip/hitachidsp/hitachidsp.cpp
+++ b/snes/chip/hitachidsp/hitachidsp.cpp
@@ -23,7 +23,7 @@ void HitachiDSP::enter() {
break;
case State::DMA:
for(unsigned n = 0; n < regs.dma_length; n++) {
- bus.write(regs.dma_target + n, bus.read(regs.dma_source + n));
+ bus.write(regs.dma_target + n, bus.read(regs.dma_source + n, false));
step(2);
}
state = State::Idle;
diff --git a/snes/chip/hitachidsp/memory.cpp b/snes/chip/hitachidsp/memory.cpp
index 3c9c3af..36868e8 100755
--- a/snes/chip/hitachidsp/memory.cpp
+++ b/snes/chip/hitachidsp/memory.cpp
@@ -1,7 +1,7 @@
#ifdef HITACHIDSP_CPP
uint8 HitachiDSP::bus_read(unsigned addr) {
- if((addr & 0x408000) == 0x008000) return bus.read(addr);
+ if((addr & 0x408000) == 0x008000) return bus.read(addr, false);
return 0x00;
}
diff --git a/snes/chip/nss/nss.cpp b/snes/chip/nss/nss.cpp
index 964973d..5946af3 100755
--- a/snes/chip/nss/nss.cpp
+++ b/snes/chip/nss/nss.cpp
@@ -10,8 +10,8 @@ void NSS::init() {
void NSS::load() {
dip = 0x0000;
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4100, 0x4101, { &NSS::read, this }, { &NSS::write, this });
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4100, 0x4101, { &NSS::read, this }, { &NSS::write, this });
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4100, 0x4101, 0, { &NSS::read, this }, { &NSS::write, this });
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4100, 0x4101, 0, { &NSS::read, this }, { &NSS::write, this });
}
void NSS::unload() {
diff --git a/snes/chip/sa1/memory/memory.cpp b/snes/chip/sa1/memory/memory.cpp
index d13ac92..9bb4ff2 100755
--- a/snes/chip/sa1/memory/memory.cpp
+++ b/snes/chip/sa1/memory/memory.cpp
@@ -107,7 +107,7 @@ void SA1::op_io() {
tick();
}
-uint8 SA1::op_read(unsigned addr) {
+uint8 SA1::op_read(unsigned addr, bool exec) {
tick();
if(((addr & 0x40e000) == 0x006000) || ((addr & 0xd00000) == 0x400000)) tick();
return bus_read(addr);
diff --git a/snes/chip/sa1/memory/memory.hpp b/snes/chip/sa1/memory/memory.hpp
index ffb9e9f..ab8e1ed 100755
--- a/snes/chip/sa1/memory/memory.hpp
+++ b/snes/chip/sa1/memory/memory.hpp
@@ -3,7 +3,7 @@ void bus_write(unsigned addr, uint8 data);
uint8 vbr_read(unsigned addr);
alwaysinline void op_io();
-alwaysinline uint8 op_read(unsigned addr);
+alwaysinline uint8 op_read(unsigned addr, bool exec);
alwaysinline void op_write(unsigned addr, uint8 data);
uint8 mmc_read(unsigned addr);
diff --git a/snes/chip/sa1/sa1.cpp b/snes/chip/sa1/sa1.cpp
index 71c6310..30e0080 100755
--- a/snes/chip/sa1/sa1.cpp
+++ b/snes/chip/sa1/sa1.cpp
@@ -37,7 +37,7 @@ void SA1::enter() {
}
void SA1::op_irq() {
- op_read(regs.pc.d);
+ op_read(regs.pc.d, false);
op_io();
if(!regs.e) op_writestack(regs.pc.b);
op_writestack(regs.pc.h);
diff --git a/snes/chip/sdd1/sdd1.cpp b/snes/chip/sdd1/sdd1.cpp
index c9b8b1c..5d6cc55 100755
--- a/snes/chip/sdd1/sdd1.cpp
+++ b/snes/chip/sdd1/sdd1.cpp
@@ -14,8 +14,8 @@ void SDD1::init() {
void SDD1::load() {
//hook S-CPU DMA MMIO registers to gather information for struct dma[];
//buffer address and transfer size information for use in SDD1::mcu_read()
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4300, 0x437f, { &SDD1::mmio_read, &sdd1 }, { &SDD1::mmio_write, &sdd1 });
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4300, 0x437f, { &SDD1::mmio_read, &sdd1 }, { &SDD1::mmio_write, &sdd1 });
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4300, 0x437f, 0, { &SDD1::mmio_read, &sdd1 }, { &SDD1::mmio_write, &sdd1 });
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4300, 0x437f, 0, { &SDD1::mmio_read, &sdd1 }, { &SDD1::mmio_write, &sdd1 });
}
void SDD1::unload() {
diff --git a/snes/cpu/core/core.hpp b/snes/cpu/core/core.hpp
index 7a685a8..9d77f3c 100755
--- a/snes/cpu/core/core.hpp
+++ b/snes/cpu/core/core.hpp
@@ -10,7 +10,7 @@ struct CPUcore {
void powercycle();
virtual void op_io() = 0;
- virtual uint8_t op_read(uint32_t addr) = 0;
+ virtual uint8_t op_read(uint32_t addr, bool exec = false) = 0;
virtual void op_write(uint32_t addr, uint8_t data) = 0;
virtual void last_cycle() = 0;
virtual bool interrupt_pending() = 0;
diff --git a/snes/cpu/core/disassembler/disassembler.cpp b/snes/cpu/core/disassembler/disassembler.cpp
index 030b3ab..ab8dde2 100755
--- a/snes/cpu/core/disassembler/disassembler.cpp
+++ b/snes/cpu/core/disassembler/disassembler.cpp
@@ -6,7 +6,7 @@ uint8 CPUcore::dreadb(uint32 addr) {
//do not read MMIO registers within debugger
return 0x00;
}
- return bus.read(addr);
+ return bus.read(addr, false);
}
uint16 CPUcore::dreadw(uint32 addr) {
diff --git a/snes/cpu/core/memory.hpp b/snes/cpu/core/memory.hpp
index 4992657..132501c 100755
--- a/snes/cpu/core/memory.hpp
+++ b/snes/cpu/core/memory.hpp
@@ -1,5 +1,5 @@
alwaysinline uint8_t op_readpc() {
- return op_read((regs.pc.b << 16) + regs.pc.w++);
+ return op_read((regs.pc.b << 16) + regs.pc.w++, true);
}
alwaysinline uint8_t op_readstack() {
diff --git a/snes/cpu/cpu.cpp b/snes/cpu/cpu.cpp
index 2d7d343..39da6b1 100755
--- a/snes/cpu/cpu.cpp
+++ b/snes/cpu/cpu.cpp
@@ -78,8 +78,8 @@ void CPU::enter() {
} else if(status.reset_pending) {
status.reset_pending = false;
add_clocks(186);
- regs.pc.l = bus.read(0xfffc);
- regs.pc.h = bus.read(0xfffd);
+ regs.pc.l = bus.read(0xfffc, false);
+ regs.pc.h = bus.read(0xfffd, false);
}
}
@@ -95,24 +95,24 @@ void CPU::enable() {
function<uint8 (unsigned)> read = { &CPU::mmio_read, (CPU*)&cpu };
function<void (unsigned, uint8)> write = { &CPU::mmio_write, (CPU*)&cpu };
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2140, 0x2183, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2140, 0x2183, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2140, 0x2183, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2140, 0x2183, 0, read, write);
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4016, 0x4017, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4016, 0x4017, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4016, 0x4017, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4016, 0x4017, 0, read, write);
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4200, 0x421f, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4200, 0x421f, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4200, 0x421f, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4200, 0x421f, 0, read, write);
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4300, 0x437f, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4300, 0x437f, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x4300, 0x437f, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x4300, 0x437f, 0, read, write);
read = [](unsigned addr) { return cpu.wram[addr]; };
write = [](unsigned addr, uint8 data) { cpu.wram[addr] = data; };
- bus.map(Bus::MapMode::Linear, 0x00, 0x3f, 0x0000, 0x1fff, read, write, 0x000000, 0x002000);
- bus.map(Bus::MapMode::Linear, 0x80, 0xbf, 0x0000, 0x1fff, read, write, 0x000000, 0x002000);
- bus.map(Bus::MapMode::Linear, 0x7e, 0x7f, 0x0000, 0xffff, read, write);
+ bus.map(Bus::MapMode::Linear, 0x00, 0x3f, 0x0000, 0x1fff, 3, read, write, 0x000000, 0x002000);
+ bus.map(Bus::MapMode::Linear, 0x80, 0xbf, 0x0000, 0x1fff, 3, read, write, 0x000000, 0x002000);
+ bus.map(Bus::MapMode::Linear, 0x7e, 0x7f, 0x0000, 0xffff, 3, read, write);
}
void CPU::power() {
diff --git a/snes/cpu/debugger/debugger.cpp b/snes/cpu/debugger/debugger.cpp
index a33518e..8301bdb 100755
--- a/snes/cpu/debugger/debugger.cpp
+++ b/snes/cpu/debugger/debugger.cpp
@@ -19,8 +19,8 @@ void CPUDebugger::op_step() {
synchronize_smp();
}
-uint8 CPUDebugger::op_read(uint32 addr) {
- uint8 data = CPU::op_read(addr);
+uint8 CPUDebugger::op_read(uint32 addr, bool exec) {
+ uint8 data = CPU::op_read(addr, exec);
usage[addr] |= UsageRead;
debugger.breakpoint_test(Debugger::Breakpoint::Source::CPUBus, Debugger::Breakpoint::Mode::Read, addr, data);
return data;
diff --git a/snes/cpu/debugger/debugger.hpp b/snes/cpu/debugger/debugger.hpp
index 579f6f0..c3d66db 100755
--- a/snes/cpu/debugger/debugger.hpp
+++ b/snes/cpu/debugger/debugger.hpp
@@ -16,7 +16,7 @@ public:
bool opcode_edge; //true right before an opcode execues, used to skip over opcodes
void op_step();
- uint8 op_read(uint32 addr);
+ uint8 op_read(uint32 addr, bool exec = false);
void op_write(uint32 addr, uint8 data);
CPUDebugger();
diff --git a/snes/cpu/dma/dma.cpp b/snes/cpu/dma/dma.cpp
index e8cdb3e..0a00bfe 100755
--- a/snes/cpu/dma/dma.cpp
+++ b/snes/cpu/dma/dma.cpp
@@ -26,7 +26,7 @@ bool CPU::dma_addr_valid(uint32 abus) {
uint8 CPU::dma_read(uint32 abus) {
if(dma_addr_valid(abus) == false) return 0x00;
- return bus.read(abus);
+ return bus.read(abus, false);
}
//simulate two-stage pipeline for DMA transfers; example:
@@ -49,7 +49,7 @@ void CPU::dma_transfer(bool direction, uint8 bbus, uint32 abus) {
dma_write(dma_transfer_valid(bbus, abus), 0x2100 | bbus, regs.mdr);
} else {
dma_add_clocks(4);
- regs.mdr = dma_transfer_valid(bbus, abus) ? bus.read(0x2100 | bbus) : 0x00;
+ regs.mdr = dma_transfer_valid(bbus, abus) ? bus.read(0x2100 | bbus, false) : 0x00;
dma_add_clocks(4);
dma_write(dma_addr_valid(abus), abus, regs.mdr);
}
diff --git a/snes/cpu/memory/memory.cpp b/snes/cpu/memory/memory.cpp
index c2c8f1f..31f82c3 100755
--- a/snes/cpu/memory/memory.cpp
+++ b/snes/cpu/memory/memory.cpp
@@ -10,11 +10,11 @@ void CPU::op_io() {
alu_edge();
}
-uint8 CPU::op_read(uint32 addr) {
+uint8 CPU::op_read(uint32 addr, bool exec) {
status.clock_count = speed(addr);
dma_edge();
add_clocks(status.clock_count - 4);
- regs.mdr = bus.read(addr);
+ regs.mdr = bus.read(addr, exec);
add_clocks(4);
alu_edge();
return regs.mdr;
diff --git a/snes/cpu/memory/memory.hpp b/snes/cpu/memory/memory.hpp
index d33861d..fd64ba8 100755
--- a/snes/cpu/memory/memory.hpp
+++ b/snes/cpu/memory/memory.hpp
@@ -1,4 +1,4 @@
void op_io();
-debugvirtual uint8 op_read(uint32 addr);
+debugvirtual uint8 op_read(uint32 addr, bool exec);
debugvirtual void op_write(uint32 addr, uint8 data);
alwaysinline unsigned speed(unsigned addr) const;
diff --git a/snes/cpu/mmio/mmio.cpp b/snes/cpu/mmio/mmio.cpp
index b7afff0..30048c1 100755
--- a/snes/cpu/mmio/mmio.cpp
+++ b/snes/cpu/mmio/mmio.cpp
@@ -5,7 +5,7 @@ bool CPU::joylatch() { return status.joypad_strobe_latch; }
//WMDATA
uint8 CPU::mmio_r2180() {
- return bus.read(0x7e0000 | status.wram_addr++);
+ return bus.read(0x7e0000 | status.wram_addr++, false);
}
//WMDATA
diff --git a/snes/debugger/debugger.cpp b/snes/debugger/debugger.cpp
index b131233..e8d0f5a 100755
--- a/snes/debugger/debugger.cpp
+++ b/snes/debugger/debugger.cpp
@@ -33,7 +33,7 @@ uint8 Debugger::read(Debugger::MemorySource source, unsigned addr) {
case MemorySource::CPUBus: {
//do not read from memory-mapped registers that could affect program behavior
if(((addr - 0x2000) & 0x40c000) == 0x000000) break; //$00-3f:2000-5fff MMIO
- return bus.read(addr & 0xffffff);
+ return bus.read(addr & 0xffffff, false);
} break;
case MemorySource::APUBus: {
diff --git a/snes/memory/memory-inline.hpp b/snes/memory/memory-inline.hpp
index 70503be..45f150c 100755
--- a/snes/memory/memory-inline.hpp
+++ b/snes/memory/memory-inline.hpp
@@ -51,11 +51,26 @@ MappedRAM::MappedRAM() : data_(0), size_(0), write_protect_(false) {}
//Bus
-uint8 Bus::read(unsigned addr) {
- if(cheat.override[addr]) return cheat.read(addr);
- return reader[lookup[addr]](target[addr]);
+uint8 Bus::read(unsigned addr, bool exec) {
+ uint8 emask = exec ? 0x24 : 0x09;
+ uint8 val;
+ if(__builtin_expect(cheat.override[addr], 0))
+ val = cheat.read(addr);
+ else
+ val = reader[lookup[addr]](target[addr]);
+ if(__builtin_expect((u_debugflags | debugflags[addr]) & emask, 0)) {
+ unsigned daddr = target[addr];
+ uint8 mclass = classmap[addr];
+ debug_read(mclass, daddr, addr, val, exec);
+ }
+ return val;
}
void Bus::write(unsigned addr, uint8 data) {
+ if(__builtin_expect((u_debugflags | debugflags[addr]) & 0x12, 0)) {
+ unsigned daddr = target[addr];
+ uint8 mclass = classmap[addr];
+ debug_write(mclass, daddr, addr, data);
+ }
return writer[lookup[addr]](target[addr], data);
}
diff --git a/snes/memory/memory.cpp b/snes/memory/memory.cpp
index ede9cbd..a9a484a 100755
--- a/snes/memory/memory.cpp
+++ b/snes/memory/memory.cpp
@@ -27,6 +27,7 @@ void Bus::map(
MapMode mode,
unsigned bank_lo, unsigned bank_hi,
unsigned addr_lo, unsigned addr_hi,
+ unsigned mclass,
const function<uint8 (unsigned)> &rd,
const function<void (unsigned, uint8)> &wr,
unsigned base, unsigned length
@@ -48,6 +49,7 @@ void Bus::map(
if(mode == MapMode::Shadow) destaddr = mirror(base + destaddr, length);
lookup[(bank << 16) | addr] = id;
target[(bank << 16) | addr] = destaddr;
+ if(mclass) classmap[(bank << 16) | addr] = mclass;
}
}
}
@@ -57,23 +59,58 @@ void Bus::map_reset() {
function<void (unsigned, uint8)> writer = [](unsigned, uint8) {};
idcount = 0;
- map(MapMode::Direct, 0x00, 0xff, 0x0000, 0xffff, reader, writer);
+ map(MapMode::Direct, 0x00, 0xff, 0x0000, 0xffff, 0xFF, reader, writer);
}
void Bus::map_xml() {
for(auto &m : cartridge.mapping) {
- map(m.mode, m.banklo, m.bankhi, m.addrlo, m.addrhi, m.read, m.write, m.offset, m.size);
+ map(m.mode, m.banklo, m.bankhi, m.addrlo, m.addrhi, (unsigned)m.clazz, m.read, m.write, m.offset, m.size);
}
}
+unsigned Bus::enumerateMirrors(uint8 clazz, uint32 offset, unsigned start)
+{
+ unsigned i;
+ for(i = start; i < 0x1000000; i++)
+ if((classmap[i] == clazz && target[i] == offset) || (i == offset && clazz == 255))
+ return i;
+ return i;
+}
+
+void Bus::clearDebugFlags()
+{
+ u_debugflags = 0;
+ memset(debugflags, 0, 0x1000000);
+}
+
+void Bus::debugFlags(uint8 setf, uint8 clrf)
+{
+ u_debugflags = (u_debugflags | setf) & ~clrf;
+}
+
+void Bus::debugFlags(uint8 setf, uint8 clrf, uint8 clazz, uint32 offset)
+{
+ if(clazz == 255) {
+ setf <<= 3;
+ clrf <<= 3;
+ debugflags[offset] = (debugflags[offset] | setf) & ~clrf;
+ } else
+ for(unsigned i = 0; i < 0x1000000; i++)
+ if(classmap[i] == clazz && target[i] == offset)
+ debugflags[i] = (debugflags[i] | setf) & ~clrf;
+}
+
Bus::Bus() {
- lookup = new uint8 [16 * 1024 * 1024];
- target = new uint32[16 * 1024 * 1024];
+ u_debugflags = 0;
+ lookup = new uint8 [112 * 1024 * 1024];
+ target = (uint32*)(lookup + 0x3000000);
+ classmap = lookup + 0x1000000;
+ debugflags = lookup + 0x2000000;
+ memset(debugflags, 0, 0x1000000);
}
Bus::~Bus() {
delete[] lookup;
- delete[] target;
}
}
diff --git a/snes/memory/memory.hpp b/snes/memory/memory.hpp
index 634e071..c20e14d 100755
--- a/snes/memory/memory.hpp
+++ b/snes/memory/memory.hpp
@@ -44,10 +44,13 @@ private:
struct Bus {
unsigned mirror(unsigned addr, unsigned size);
- alwaysinline uint8 read(unsigned addr);
+ alwaysinline uint8 read(unsigned addr, bool exec);
alwaysinline void write(unsigned addr, uint8 data);
uint8 *lookup;
+ uint8 *classmap;
+ uint8 *debugflags;
+ uint8 u_debugflags;
uint32 *target;
unsigned idcount;
@@ -59,6 +62,7 @@ struct Bus {
MapMode mode,
unsigned bank_lo, unsigned bank_hi,
unsigned addr_lo, unsigned addr_hi,
+ unsigned mclass,
const function<uint8 (unsigned)> &read,
const function<void (unsigned, uint8)> &write,
unsigned base = 0, unsigned length = 0
@@ -67,6 +71,13 @@ struct Bus {
void map_reset();
void map_xml();
+ void clearDebugFlags();
+ void debugFlags(uint8 setf, uint8 clrf);
+ void debugFlags(uint8 setf, uint8 clrf, uint8 clazz, uint32 offset);
+ unsigned enumerateMirrors(uint8 clazz, uint32 offset, unsigned start);
+ function<void (uint8, unsigned, unsigned, uint8, bool)> debug_read;
+ function<void (uint8, unsigned, unsigned, uint8)> debug_write;
+
Bus();
~Bus();
};
diff --git a/snes/ppu/ppu.cpp b/snes/ppu/ppu.cpp
index 8545175..13e231c 100755
--- a/snes/ppu/ppu.cpp
+++ b/snes/ppu/ppu.cpp
@@ -87,8 +87,8 @@ void PPU::enable() {
function<uint8 (unsigned)> read = { &PPU::mmio_read, (PPU*)&ppu };
function<void (unsigned, uint8)> write = { &PPU::mmio_write, (PPU*)&ppu };
- bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2100, 0x213f, read, write);
- bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2100, 0x213f, read, write);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x2100, 0x213f, 0, read, write);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x2100, 0x213f, 0, read, write);
}
void PPU::power() {
diff --git a/snes/smp/core/core.hpp b/snes/smp/core/core.hpp
index 1489fce..13d6936 100755
--- a/snes/smp/core/core.hpp
+++ b/snes/smp/core/core.hpp
@@ -2,7 +2,7 @@ struct SMPcore {
virtual void op_io() = 0;
virtual uint8 op_read(uint16 addr) = 0;
virtual void op_write(uint16 addr, uint8 data) = 0;
- void op_step();
+ virtual void op_step();
#include "registers.hpp"
#include "memory.hpp"
diff --git a/snes/snes.hpp b/snes/snes.hpp
index dffeeee..37ed1fe 100755
--- a/snes/snes.hpp
+++ b/snes/snes.hpp
@@ -1,5 +1,6 @@
#ifndef SNES_HPP
#define SNES_HPP
+#define BSNES_SUPPORTS_ADV_BREAKPOINTS
namespace SNES {
namespace Info {
--
1.8.4.4

View file

@ -0,0 +1,22 @@
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
---
bsnes.mk | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 bsnes.mk
diff --git a/bsnes.mk b/bsnes.mk
new file mode 100644
index 0000000..20f22f6
--- /dev/null
+++ b/bsnes.mk
@@ -0,0 +1,3 @@
+BSNES_SUPPORTS_DEBUGGER=yes
+LIBSNES_DIR=ui-libsnes
+BSNES_VERSION=085
--
1.8.4.4

View file

@ -1,17 +1,17 @@
From 11817638cce47203329f3d45486a936fdfcf36c7 Mon Sep 17 00:00:00 2001
From 6c3da8eb6516d25e97b46d97fb0d3d24ca9ecfd0 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 1/6] Don't use time() in emulating chips
Subject: [PATCH 1/8] 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 +
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
@ -80,5 +80,5 @@ index f1a48c0..df975e8 100755
extern Interface *interface;
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,26 +1,26 @@
From 20ca58ee581dce5f147b7f8f004ed360543c78fe Mon Sep 17 00:00:00 2001
From c87e7d9288a91db3b32b5ba4b2b74e52c0d3c11d 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 2/6] Save controller state when savestating
Subject: [PATCH 2/8] Save controller state when savestating
When savestating, save the controller state and restore it upon loadstate.
Prevents libsnes from mixing up buttons.
---
snes/controller/controller.cpp | 8 ++++++
snes/controller/controller.hpp | 2 +
snes/controller/gamepad/gamepad.cpp | 13 ++++++++++
snes/controller/gamepad/gamepad.hpp | 2 +-
snes/controller/justifier/justifier.cpp | 36 +++++++++++++++++++++++++++++
snes/controller/justifier/justifier.hpp | 1 +
snes/controller/mouse/mouse.cpp | 13 ++++++++++
snes/controller/mouse/mouse.hpp | 2 +-
snes/controller/multitap/multitap.cpp | 16 +++++++++++++
snes/controller/multitap/multitap.hpp | 2 +-
snes/controller/superscope/superscope.cpp | 31 +++++++++++++++++++++++++
snes/controller/superscope/superscope.hpp | 1 +
snes/system/input.cpp | 16 +++++++++++++
snes/system/input.hpp | 1 +
snes/system/serialization.cpp | 1 +
snes/controller/controller.cpp | 8 +++++++
snes/controller/controller.hpp | 2 ++
snes/controller/gamepad/gamepad.cpp | 13 +++++++++++
snes/controller/gamepad/gamepad.hpp | 2 +-
snes/controller/justifier/justifier.cpp | 36 +++++++++++++++++++++++++++++++
snes/controller/justifier/justifier.hpp | 1 +
snes/controller/mouse/mouse.cpp | 13 +++++++++++
snes/controller/mouse/mouse.hpp | 2 +-
snes/controller/multitap/multitap.cpp | 16 ++++++++++++++
snes/controller/multitap/multitap.hpp | 2 +-
snes/controller/superscope/superscope.cpp | 31 ++++++++++++++++++++++++++
snes/controller/superscope/superscope.hpp | 1 +
snes/system/input.cpp | 16 ++++++++++++++
snes/system/input.hpp | 1 +
snes/system/serialization.cpp | 1 +
15 files changed, 142 insertions(+), 3 deletions(-)
diff --git a/snes/controller/controller.cpp b/snes/controller/controller.cpp
@ -342,5 +342,5 @@ index 9f5273d..005e731 100755
if(cartridge.mode() == Cartridge::Mode::SufamiTurbo) sufamiturbo.serialize(s);
#if defined(GAMEBOY)
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,13 +1,13 @@
From f5c4df87246e2216abb8563f2ddad811eaf59520 Mon Sep 17 00:00:00 2001
From a62794b0bfa1d2bfc8907a1e4d4e5aa6fe3ee426 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 3/6] Allow frontend to control random number seed
Subject: [PATCH 3/8] 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(-)
snes/interface/interface.cpp | 5 +++++
snes/interface/interface.hpp | 1 +
snes/system/system.cpp | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp
index b3017c9..0a21a13 100755
@ -49,5 +49,5 @@ index 284e389..99901ff 100755
region = config.region;
expansion = config.expansion_port;
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,13 +1,13 @@
From 22a4b8a4f4e84540702b34381ef7ba3860d1d0b5 Mon Sep 17 00:00:00 2001
From 33ecd422954b7e15d9e83b7035b07ffb52f4e1e8 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 4/6] Fix mouse polling
Subject: [PATCH 4/8] Fix mouse polling
Don't poll for mouse motion excessive number of times (no need to poll it for
each bit!)
---
snes/controller/mouse/mouse.cpp | 14 ++++++++++++--
snes/controller/mouse/mouse.hpp | 2 ++
snes/controller/mouse/mouse.cpp | 14 ++++++++++++--
snes/controller/mouse/mouse.hpp | 2 ++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/snes/controller/mouse/mouse.cpp b/snes/controller/mouse/mouse.cpp
@ -59,5 +59,5 @@ index b66ea51..b07c8ab 100755
+ int _position_y;
};
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,12 +1,12 @@
From efa6b433e4f0123dca8bbc1bfd27c5762220a524 Mon Sep 17 00:00:00 2001
From 52a1a595f4473b4de0cdedcb018aef68108a2c73 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 5/6] Add needed support for detecting true polls as opposed
to just autopolling
Subject: [PATCH 5/8] Add needed support for detecting true polls as opposed to
just autopolling
---
snes/cpu/cpu.hpp | 1 +
snes/cpu/mmio/mmio.cpp | 18 ++++++++++--------
snes/cpu/cpu.hpp | 1 +
snes/cpu/mmio/mmio.cpp | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/snes/cpu/cpu.hpp b/snes/cpu/cpu.hpp
@ -65,5 +65,5 @@ index 8b6aaa6..c5ee930 100755
//DMAPx
uint8 CPU::mmio_r43x0(uint8 i) {
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,12 +1,12 @@
From f3e7cdb3815a3e0cc5beca79c78726d8f5f9b3ae Mon Sep 17 00:00:00 2001
From 74b67f36961839fcbc1caa23930151bd9b3e9d7e Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Sun, 14 Oct 2012 23:29:40 +0300
Subject: [PATCH 6/6] Fix compiling on GCC 4.7
Subject: [PATCH 6/8] Fix compiling on GCC 4.7
---
nall/string.hpp | 2 +-
ui-libsnes/libsnes.cpp | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)
nall/string.hpp | 2 +-
ui-libsnes/libsnes.cpp | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/nall/string.hpp b/nall/string.hpp
index 996cd68..4747e4c 100755
@ -34,5 +34,5 @@ index 3b2be7a..ca90762 100755
#include <nall/snes/cartridge.hpp>
#include <nall/gameboy/cartridge.hpp>
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -0,0 +1,65 @@
From 5dc532e67245f1e83504be4a21fef1ab15b08af2 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 7/8] Support notifying latches
---
snes/cpu/mmio/mmio.cpp | 1 +
snes/cpu/timing/joypad.cpp | 1 +
snes/interface/interface.cpp | 5 +++++
snes/interface/interface.hpp | 1 +
4 files changed, 8 insertions(+)
diff --git a/snes/cpu/mmio/mmio.cpp b/snes/cpu/mmio/mmio.cpp
index c5ee930..b7afff0 100755
--- a/snes/cpu/mmio/mmio.cpp
+++ b/snes/cpu/mmio/mmio.cpp
@@ -33,6 +33,7 @@ void CPU::mmio_w2183(uint8 data) {
//strobing $4016.d0 affects both controller port latches.
//$4017 bit 0 writes are ignored.
void CPU::mmio_w4016(uint8 data) {
+ if(data&1) interface->notifyLatched();
input.port1->latch(data & 1);
input.port2->latch(data & 1);
}
diff --git a/snes/cpu/timing/joypad.cpp b/snes/cpu/timing/joypad.cpp
index 179df27..6a98de0 100755
--- a/snes/cpu/timing/joypad.cpp
+++ b/snes/cpu/timing/joypad.cpp
@@ -9,6 +9,7 @@ void CPU::step_auto_joypad_poll() {
if(status.auto_joypad_active && status.auto_joypad_latch) {
if(status.auto_joypad_counter == 0) {
+ interface->notifyLatched();
input.port1->latch(1);
input.port2->latch(1);
input.port1->latch(0);
diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp
index 0a21a13..6685556 100755
--- a/snes/interface/interface.cpp
+++ b/snes/interface/interface.cpp
@@ -28,4 +28,9 @@ time_t Interface::randomSeed()
return time(0);
}
+void Interface::notifyLatched()
+{
+ //Nothing.
+}
+
}
diff --git a/snes/interface/interface.hpp b/snes/interface/interface.hpp
index 30ee7fd..203f7b0 100755
--- a/snes/interface/interface.hpp
+++ b/snes/interface/interface.hpp
@@ -7,6 +7,7 @@ struct Interface {
virtual void message(const string &text);
virtual time_t currentTime();
virtual time_t randomSeed();
+ virtual void notifyLatched();
};
extern Interface *interface;
--
1.8.4.4

View file

@ -0,0 +1,22 @@
From ce0634fe5a8dea973ca9c357ec788740fbcfcf09 Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Sat, 30 Nov 2013 10:28:05 +0200
Subject: [PATCH 8/8] Support auto-detecting bsnes version
---
bsnes.mk | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 bsnes.mk
diff --git a/bsnes.mk b/bsnes.mk
new file mode 100644
index 0000000..2248b71
--- /dev/null
+++ b/bsnes.mk
@@ -0,0 +1,3 @@
+BSNES_SUPPORTS_DEBUGGER=
+LIBSNES_DIR=ui-libsnes
+BSNES_VERSION=086
--
1.8.4.4

View file

@ -1,17 +1,17 @@
From d179ef70e8cfdecc92b58d8cbec013071140bcf5 Mon Sep 17 00:00:00 2001
From a8018b3c90314bd0c112842fe81b27e978b891eb 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 1/6] Don't use time() in emulating chips
Subject: [PATCH 1/8] 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 +
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
@ -80,5 +80,5 @@ index f1a48c0..df975e8 100755
extern Interface *interface;
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,26 +1,26 @@
From 686e73181ce3b49d0dcbf94db564030bef350cbc Mon Sep 17 00:00:00 2001
From de423d6ec33a20f33652c6b9c8ce703b867b51bd 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 2/6] Save controller state when savestating
Subject: [PATCH 2/8] Save controller state when savestating
When savestating, save the controller state and restore it upon loadstate.
Prevents libsnes from mixing up buttons.
---
snes/controller/controller.cpp | 8 ++++++
snes/controller/controller.hpp | 2 +
snes/controller/gamepad/gamepad.cpp | 13 ++++++++++
snes/controller/gamepad/gamepad.hpp | 2 +-
snes/controller/justifier/justifier.cpp | 36 +++++++++++++++++++++++++++++
snes/controller/justifier/justifier.hpp | 1 +
snes/controller/mouse/mouse.cpp | 13 ++++++++++
snes/controller/mouse/mouse.hpp | 2 +-
snes/controller/multitap/multitap.cpp | 16 +++++++++++++
snes/controller/multitap/multitap.hpp | 2 +-
snes/controller/superscope/superscope.cpp | 31 +++++++++++++++++++++++++
snes/controller/superscope/superscope.hpp | 1 +
snes/system/input.cpp | 16 +++++++++++++
snes/system/input.hpp | 1 +
snes/system/serialization.cpp | 1 +
snes/controller/controller.cpp | 8 +++++++
snes/controller/controller.hpp | 2 ++
snes/controller/gamepad/gamepad.cpp | 13 +++++++++++
snes/controller/gamepad/gamepad.hpp | 2 +-
snes/controller/justifier/justifier.cpp | 36 +++++++++++++++++++++++++++++++
snes/controller/justifier/justifier.hpp | 1 +
snes/controller/mouse/mouse.cpp | 13 +++++++++++
snes/controller/mouse/mouse.hpp | 2 +-
snes/controller/multitap/multitap.cpp | 16 ++++++++++++++
snes/controller/multitap/multitap.hpp | 2 +-
snes/controller/superscope/superscope.cpp | 31 ++++++++++++++++++++++++++
snes/controller/superscope/superscope.hpp | 1 +
snes/system/input.cpp | 16 ++++++++++++++
snes/system/input.hpp | 1 +
snes/system/serialization.cpp | 1 +
15 files changed, 142 insertions(+), 3 deletions(-)
diff --git a/snes/controller/controller.cpp b/snes/controller/controller.cpp
@ -342,5 +342,5 @@ index f746c3a..67e08a2 100755
if(cartridge.mode() == Cartridge::Mode::SufamiTurbo) sufamiturbo.serialize(s);
#if defined(GAMEBOY)
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,13 +1,13 @@
From f760a5a5981c811a4aeb878893fbad3fcaef3f5c Mon Sep 17 00:00:00 2001
From e1fce124df0a1ea43324df65b9d0ee7262eda988 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 3/6] Allow frontend to control random number seed
Subject: [PATCH 3/8] 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(-)
snes/interface/interface.cpp | 5 +++++
snes/interface/interface.hpp | 1 +
snes/system/system.cpp | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp
index b3017c9..0a21a13 100755
@ -49,5 +49,5 @@ index 9b70bbf..cbd096c 100755
region = config.region;
expansion = config.expansion_port;
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,13 +1,13 @@
From e6ec3c0d382f57e2c447b1a5dbfc4f58fc0ecfef Mon Sep 17 00:00:00 2001
From 21e21c3b953f499bb3e309ff6a04b38763e7910a 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 4/6] Fix mouse polling
Subject: [PATCH 4/8] Fix mouse polling
Don't poll for mouse motion excessive number of times (no need to poll it for
each bit!)
---
snes/controller/mouse/mouse.cpp | 14 ++++++++++++--
snes/controller/mouse/mouse.hpp | 2 ++
snes/controller/mouse/mouse.cpp | 14 ++++++++++++--
snes/controller/mouse/mouse.hpp | 2 ++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/snes/controller/mouse/mouse.cpp b/snes/controller/mouse/mouse.cpp
@ -59,5 +59,5 @@ index b66ea51..b07c8ab 100755
+ int _position_y;
};
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,12 +1,12 @@
From e9a9d78c5ec20aadd42bc7433af236e413eea787 Mon Sep 17 00:00:00 2001
From 9b14075f51587694015f8507f1c7cb565fee8225 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 5/6] Add needed support for detecting true polls as opposed
to just autopolling
Subject: [PATCH 5/8] Add needed support for detecting true polls as opposed to
just autopolling
---
snes/cpu/cpu.hpp | 1 +
snes/cpu/mmio/mmio.cpp | 18 ++++++++++--------
snes/cpu/cpu.hpp | 1 +
snes/cpu/mmio/mmio.cpp | 18 ++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/snes/cpu/cpu.hpp b/snes/cpu/cpu.hpp
@ -65,5 +65,5 @@ index 8b6aaa6..c5ee930 100755
//DMAPx
uint8 CPU::mmio_r43x0(uint8 i) {
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -1,11 +1,11 @@
From cb537c426d507164f6853f8e6cf82739a1bfb732 Mon Sep 17 00:00:00 2001
From 8c41bf9b792c08ecbf22a87d4e85f3e4801e62d2 Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Sun, 14 Oct 2012 23:25:33 +0300
Subject: [PATCH 6/6] Add missing include to libsnes.cpp
Subject: [PATCH 6/8] Add missing include to libsnes.cpp
---
target-libsnes/libsnes.cpp | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
target-libsnes/libsnes.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/target-libsnes/libsnes.cpp b/target-libsnes/libsnes.cpp
index 3b2be7a..ca90762 100755
@ -19,5 +19,5 @@ index 3b2be7a..ca90762 100755
#include <nall/snes/cartridge.hpp>
#include <nall/gameboy/cartridge.hpp>
--
1.7.9.48.g85da4d
1.8.4.4

View file

@ -0,0 +1,65 @@
From 13643c86bfff3871968cf6e8b4f991465d4e81e7 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 7/8] Support notifying latches
---
snes/cpu/mmio/mmio.cpp | 1 +
snes/cpu/timing/joypad.cpp | 1 +
snes/interface/interface.cpp | 5 +++++
snes/interface/interface.hpp | 1 +
4 files changed, 8 insertions(+)
diff --git a/snes/cpu/mmio/mmio.cpp b/snes/cpu/mmio/mmio.cpp
index c5ee930..b7afff0 100755
--- a/snes/cpu/mmio/mmio.cpp
+++ b/snes/cpu/mmio/mmio.cpp
@@ -33,6 +33,7 @@ void CPU::mmio_w2183(uint8 data) {
//strobing $4016.d0 affects both controller port latches.
//$4017 bit 0 writes are ignored.
void CPU::mmio_w4016(uint8 data) {
+ if(data&1) interface->notifyLatched();
input.port1->latch(data & 1);
input.port2->latch(data & 1);
}
diff --git a/snes/cpu/timing/joypad.cpp b/snes/cpu/timing/joypad.cpp
index 179df27..6a98de0 100755
--- a/snes/cpu/timing/joypad.cpp
+++ b/snes/cpu/timing/joypad.cpp
@@ -9,6 +9,7 @@ void CPU::step_auto_joypad_poll() {
if(status.auto_joypad_active && status.auto_joypad_latch) {
if(status.auto_joypad_counter == 0) {
+ interface->notifyLatched();
input.port1->latch(1);
input.port2->latch(1);
input.port1->latch(0);
diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp
index 0a21a13..6685556 100755
--- a/snes/interface/interface.cpp
+++ b/snes/interface/interface.cpp
@@ -28,4 +28,9 @@ time_t Interface::randomSeed()
return time(0);
}
+void Interface::notifyLatched()
+{
+ //Nothing.
+}
+
}
diff --git a/snes/interface/interface.hpp b/snes/interface/interface.hpp
index 30ee7fd..203f7b0 100755
--- a/snes/interface/interface.hpp
+++ b/snes/interface/interface.hpp
@@ -7,6 +7,7 @@ struct Interface {
virtual void message(const string &text);
virtual time_t currentTime();
virtual time_t randomSeed();
+ virtual void notifyLatched();
};
extern Interface *interface;
--
1.8.4.4

View file

@ -0,0 +1,22 @@
From e74f6d6ce7b369d82abf1eed6d7c3e99af0d8f64 Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Sat, 30 Nov 2013 10:28:40 +0200
Subject: [PATCH 8/8] Support auto-dectecting bsnes version
---
bsnes.mk | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 bsnes.mk
diff --git a/bsnes.mk b/bsnes.mk
new file mode 100644
index 0000000..c31911f
--- /dev/null
+++ b/bsnes.mk
@@ -0,0 +1,3 @@
+BSNES_SUPPORTS_DEBUGGER=
+LIBSNES_DIR=target-libsnes
+BSNES_VERSION=087
--
1.8.4.4

View file

@ -1,71 +1,71 @@
From 45ef88799c500b6932f6f2e90377bb4aece25523 Mon Sep 17 00:00:00 2001
From f4fcace8e1261f4e0e01c7db174dc148eab1180f Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Fri, 18 Jan 2013 21:06:30 +0200
Subject: [PATCH] Changes to make libgambatte rerecording friendly
Subject: [PATCH 1/3] Changes to make libgambatte rerecording friendly
---
Makefile | 10 +
libgambatte/Makefile | 18 ++
libgambatte/include/gambatte.h | 72 +++++++-
libgambatte/src/bitmap_font.cpp | 10 +-
libgambatte/src/bitmap_font.h | 6 +-
libgambatte/src/cpu.cpp | 45 ++++-
libgambatte/src/cpu.h | 31 +++-
libgambatte/src/file/file.cpp | 34 ++++
libgambatte/src/file/file.h | 10 +
libgambatte/src/gambatte.cpp | 124 ++++++++++--
libgambatte/src/initstate.cpp | 8 +-
libgambatte/src/initstate.h | 8 +-
libgambatte/src/interrupter.cpp | 17 ++-
libgambatte/src/interrupter.h | 18 ++-
libgambatte/src/interruptrequester.cpp | 23 ++-
libgambatte/src/interruptrequester.h | 27 ++-
libgambatte/src/loadsave.cpp | 266 ++++++++++++++++++++++++++
libgambatte/src/loadsave.h | 160 ++++++++++++++++
libgambatte/src/mem/cartridge.cpp | 160 ++++++++++++++--
libgambatte/src/mem/cartridge.h | 37 ++++-
libgambatte/src/mem/memptrs.cpp | 32 +++-
libgambatte/src/mem/memptrs.h | 17 ++-
libgambatte/src/mem/rtc.cpp | 57 +++++-
libgambatte/src/mem/rtc.h | 11 +-
libgambatte/src/memory.cpp | 108 +++++++----
libgambatte/src/memory.h | 80 +++++---
libgambatte/src/minkeeper.h | 30 ++-
libgambatte/src/savestate.h | 54 +++---
libgambatte/src/sound.cpp | 36 +++-
libgambatte/src/sound.h | 17 ++-
libgambatte/src/sound/channel1.cpp | 44 ++++-
libgambatte/src/sound/channel1.h | 25 ++-
libgambatte/src/sound/channel2.cpp | 41 +++-
libgambatte/src/sound/channel2.h | 17 ++-
libgambatte/src/sound/channel3.cpp | 41 +++-
libgambatte/src/sound/channel3.h | 27 ++-
libgambatte/src/sound/channel4.cpp | 59 ++++--
libgambatte/src/sound/channel4.h | 40 +++--
libgambatte/src/sound/duty_unit.cpp | 34 +++-
libgambatte/src/sound/duty_unit.h | 29 ++-
libgambatte/src/sound/envelope_unit.cpp | 19 ++-
libgambatte/src/sound/envelope_unit.h | 12 +-
libgambatte/src/sound/length_counter.cpp | 19 ++-
libgambatte/src/sound/length_counter.h | 13 +-
libgambatte/src/sound/sound_unit.h | 15 ++-
libgambatte/src/sound/static_output_tester.h | 8 +-
libgambatte/src/state_osd_elements.cpp | 8 +-
libgambatte/src/statesaver.cpp | 6 +-
libgambatte/src/statesaver.h | 7 +
libgambatte/src/tima.cpp | 35 +++-
libgambatte/src/tima.h | 28 ++-
libgambatte/src/video.cpp | 120 +++++++-----
libgambatte/src/video.h | 118 +++++++-----
libgambatte/src/video/ly_counter.cpp | 14 +-
libgambatte/src/video/ly_counter.h | 26 ++-
libgambatte/src/video/lyc_irq.cpp | 14 +-
libgambatte/src/video/lyc_irq.h | 27 ++-
libgambatte/src/video/next_m0_time.h | 10 +
libgambatte/src/video/ppu.cpp | 125 ++++++++++---
libgambatte/src/video/ppu.h | 93 ++++++---
libgambatte/src/video/sprite_mapper.cpp | 17 +-
libgambatte/src/video/sprite_mapper.h | 53 ++++--
Makefile | 10 +
libgambatte/Makefile | 18 ++
libgambatte/include/gambatte.h | 72 +++++++-
libgambatte/src/bitmap_font.cpp | 10 +-
libgambatte/src/bitmap_font.h | 6 +-
libgambatte/src/cpu.cpp | 45 ++++-
libgambatte/src/cpu.h | 31 +++-
libgambatte/src/file/file.cpp | 34 ++++
libgambatte/src/file/file.h | 10 +
libgambatte/src/gambatte.cpp | 124 +++++++++++--
libgambatte/src/initstate.cpp | 8 +-
libgambatte/src/initstate.h | 8 +-
libgambatte/src/interrupter.cpp | 17 +-
libgambatte/src/interrupter.h | 18 +-
libgambatte/src/interruptrequester.cpp | 23 ++-
libgambatte/src/interruptrequester.h | 27 ++-
libgambatte/src/loadsave.cpp | 266 +++++++++++++++++++++++++++
libgambatte/src/loadsave.h | 160 ++++++++++++++++
libgambatte/src/mem/cartridge.cpp | 160 +++++++++++++---
libgambatte/src/mem/cartridge.h | 37 +++-
libgambatte/src/mem/memptrs.cpp | 32 +++-
libgambatte/src/mem/memptrs.h | 17 +-
libgambatte/src/mem/rtc.cpp | 57 +++++-
libgambatte/src/mem/rtc.h | 11 +-
libgambatte/src/memory.cpp | 108 +++++++----
libgambatte/src/memory.h | 80 +++++---
libgambatte/src/minkeeper.h | 30 ++-
libgambatte/src/savestate.h | 54 +++---
libgambatte/src/sound.cpp | 36 +++-
libgambatte/src/sound.h | 17 +-
libgambatte/src/sound/channel1.cpp | 44 ++++-
libgambatte/src/sound/channel1.h | 25 ++-
libgambatte/src/sound/channel2.cpp | 41 ++++-
libgambatte/src/sound/channel2.h | 17 +-
libgambatte/src/sound/channel3.cpp | 41 ++++-
libgambatte/src/sound/channel3.h | 27 ++-
libgambatte/src/sound/channel4.cpp | 59 ++++--
libgambatte/src/sound/channel4.h | 40 ++--
libgambatte/src/sound/duty_unit.cpp | 34 +++-
libgambatte/src/sound/duty_unit.h | 29 +--
libgambatte/src/sound/envelope_unit.cpp | 19 +-
libgambatte/src/sound/envelope_unit.h | 12 +-
libgambatte/src/sound/length_counter.cpp | 19 +-
libgambatte/src/sound/length_counter.h | 13 +-
libgambatte/src/sound/sound_unit.h | 15 +-
libgambatte/src/sound/static_output_tester.h | 8 +-
libgambatte/src/state_osd_elements.cpp | 8 +-
libgambatte/src/statesaver.cpp | 6 +-
libgambatte/src/statesaver.h | 7 +
libgambatte/src/tima.cpp | 35 ++--
libgambatte/src/tima.h | 28 +--
libgambatte/src/video.cpp | 120 ++++++------
libgambatte/src/video.h | 118 +++++++-----
libgambatte/src/video/ly_counter.cpp | 14 +-
libgambatte/src/video/ly_counter.h | 26 ++-
libgambatte/src/video/lyc_irq.cpp | 14 +-
libgambatte/src/video/lyc_irq.h | 27 ++-
libgambatte/src/video/next_m0_time.h | 10 +
libgambatte/src/video/ppu.cpp | 125 ++++++++++---
libgambatte/src/video/ppu.h | 93 +++++++---
libgambatte/src/video/sprite_mapper.cpp | 17 +-
libgambatte/src/video/sprite_mapper.h | 53 ++++--
62 files changed, 2098 insertions(+), 572 deletions(-)
create mode 100644 Makefile
create mode 100644 libgambatte/Makefile
@ -5793,5 +5793,5 @@ index 22bf619..2358d2d 100644
}
--
1.7.9.48.g85da4d
1.8.5

View file

@ -0,0 +1,134 @@
From 0ba9fa35b68d63c4adcf0bd7e19eef52bdc3ecd4 Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Mon, 18 Nov 2013 01:53:58 +0200
Subject: [PATCH 2/3] Expose CPU registers
---
libgambatte/include/gambatte.h | 22 +++++++++++++++++++
libgambatte/src/cpu.h | 12 +++++------
libgambatte/src/gambatte.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/libgambatte/include/gambatte.h b/libgambatte/include/gambatte.h
index 11a54a9..98bd129 100644
--- a/libgambatte/include/gambatte.h
+++ b/libgambatte/include/gambatte.h
@@ -203,6 +203,28 @@ public:
/** Get version. */
static std::string version();
+
+ /** CPU registers. */
+ enum cpu_register
+ {
+ REG_CYCLECOUNTER,
+ REG_PC,
+ REG_SP,
+ REG_HF1,
+ REG_HF2,
+ REG_ZF,
+ REG_CF,
+ REG_A,
+ REG_B,
+ REG_C,
+ REG_D,
+ REG_E,
+ REG_F,
+ REG_H,
+ REG_L
+ };
+ uint32_t get_cpureg(enum cpu_register reg);
+ void set_cpureg(enum cpu_register reg, uint32_t val);
private:
void preload_common();
void postload_common(const unsigned flags);
diff --git a/libgambatte/src/cpu.h b/libgambatte/src/cpu.h
index fd4bd64..08bcf80 100644
--- a/libgambatte/src/cpu.h
+++ b/libgambatte/src/cpu.h
@@ -31,6 +31,12 @@ namespace gambatte {
class CPU {
Memory memory;
+
+ bool skip;
+
+ void process(unsigned cycles);
+
+public:
unsigned cycleCounter_;
unsigned short PC_;
@@ -39,12 +45,6 @@ class CPU {
unsigned HF1, HF2, ZF, CF;
unsigned char A_, B, C, D, E, /*F,*/ H, L;
-
- bool skip;
-
- void process(unsigned cycles);
-
-public:
CPU(time_t (**_getCurrentTime)());
// void halt();
diff --git a/libgambatte/src/gambatte.cpp b/libgambatte/src/gambatte.cpp
index 9c4fcdc..380ab42 100644
--- a/libgambatte/src/gambatte.cpp
+++ b/libgambatte/src/gambatte.cpp
@@ -290,4 +290,52 @@ std::string GB::version()
return "SVN364";
}
+uint32_t GB::get_cpureg(enum cpu_register reg)
+{
+ switch(reg) {
+ case REG_CYCLECOUNTER: return p_->cpu.cycleCounter_;
+ case REG_PC: return p_->cpu.PC_;
+ case REG_SP: return p_->cpu.SP;
+ case REG_HF1: return p_->cpu.HF1;
+ case REG_HF2: return p_->cpu.HF2;
+ case REG_ZF: return p_->cpu.ZF;
+ case REG_CF: return p_->cpu.CF;
+ case REG_A: return p_->cpu.A_;
+ case REG_B: return p_->cpu.B;
+ case REG_C: return p_->cpu.C;
+ case REG_D: return p_->cpu.D;
+ case REG_E: return p_->cpu.E;
+ case REG_F:
+ return ((p_->cpu.HF2 & 0x600 | (p_->cpu.CF & 0x100)) >> 4)
+ | (p_->cpu.ZF & 0xFF ? 0 : 0x80);
+ case REG_H: return p_->cpu.H;
+ case REG_L: return p_->cpu.L;
+ default: return 0;
+ }
+}
+
+void GB::set_cpureg(enum cpu_register reg, uint32_t val)
+{
+ switch(reg) {
+ case REG_PC: p_->cpu.PC_ = val; break;
+ case REG_SP: p_->cpu.SP = val; break;
+ case REG_HF1: p_->cpu.HF1 = val; break;
+ case REG_HF2: p_->cpu.HF2 = val; break;
+ case REG_ZF: p_->cpu.ZF = val; break;
+ case REG_CF: p_->cpu.CF = val; break;
+ case REG_A: p_->cpu.A_ = val; break;
+ case REG_B: p_->cpu.B = val; break;
+ case REG_C: p_->cpu.C = val; break;
+ case REG_D: p_->cpu.D = val; break;
+ case REG_E: p_->cpu.E = val; break;
+ case REG_F:
+ p_->cpu.HF2 = (val << 4) & 0x600;
+ p_->cpu.CF = (val << 4) & 0x100;
+ p_->cpu.ZF = val & 0x80;
+ break;
+ case REG_H: p_->cpu.H = val; break;
+ case REG_L: p_->cpu.L = val; break;
+ default: break;
+ }
+}
}
--
1.8.5

View file

@ -0,0 +1,107 @@
From 8dac6800be952bb48afec48ec2e5c597f7aefae3 Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Thu, 5 Dec 2013 08:46:03 +0200
Subject: [PATCH 3/3] Fix sound DC levels
This was causing popping in Mega Man (I)
---
libgambatte/src/sound/channel1.cpp | 5 ++---
libgambatte/src/sound/channel2.cpp | 4 ++--
libgambatte/src/sound/channel3.cpp | 6 +++---
libgambatte/src/sound/channel4.cpp | 5 ++---
4 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/libgambatte/src/sound/channel1.cpp b/libgambatte/src/sound/channel1.cpp
index 6b9ccf1..915ab1a 100644
--- a/libgambatte/src/sound/channel1.cpp
+++ b/libgambatte/src/sound/channel1.cpp
@@ -220,14 +220,13 @@ void Channel1::loadState(const SaveState &state) {
void Channel1::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cycles) {
const unsigned outBase = envelopeUnit.dacIsOn() ? soBaseVol & soMask : 0;
- const unsigned outLow = outBase * (0 - 15ul);
const unsigned endCycles = cycleCounter + cycles;
for (;;) {
- const unsigned outHigh = master ? outBase * (envelopeUnit.getVolume() * 2 - 15ul) : outLow;
+ const unsigned outHigh = master ? outBase * (envelopeUnit.getVolume()) : 0;
+ const unsigned outLow = -outHigh;
const unsigned nextMajorEvent = nextEventUnit->getCounter() < endCycles ? nextEventUnit->getCounter() : endCycles;
unsigned out = dutyUnit.isHighState() ? outHigh : outLow;
-
while (dutyUnit.getCounter() <= nextMajorEvent) {
*buf = out - prevOut;
prevOut = out;
diff --git a/libgambatte/src/sound/channel2.cpp b/libgambatte/src/sound/channel2.cpp
index 6bd5b04..dc74d7c 100644
--- a/libgambatte/src/sound/channel2.cpp
+++ b/libgambatte/src/sound/channel2.cpp
@@ -125,11 +125,11 @@ void Channel2::loadState(const SaveState &state) {
void Channel2::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cycles) {
const unsigned outBase = envelopeUnit.dacIsOn() ? soBaseVol & soMask : 0;
- const unsigned outLow = outBase * (0 - 15ul);
const unsigned endCycles = cycleCounter + cycles;
for (;;) {
- const unsigned outHigh = master ? outBase * (envelopeUnit.getVolume() * 2 - 15ul) : outLow;
+ const unsigned outHigh = master ? outBase * (envelopeUnit.getVolume()) : 0;
+ const unsigned outLow = -outHigh;
const unsigned nextMajorEvent = nextEventUnit->getCounter() < endCycles ? nextEventUnit->getCounter() : endCycles;
unsigned out = dutyUnit.isHighState() ? outHigh : outLow;
while (dutyUnit.getCounter() <= nextMajorEvent) {
diff --git a/libgambatte/src/sound/channel3.cpp b/libgambatte/src/sound/channel3.cpp
index ec2c8ed..758f3d5 100644
--- a/libgambatte/src/sound/channel3.cpp
+++ b/libgambatte/src/sound/channel3.cpp
@@ -155,7 +155,7 @@ void Channel3::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cy
for (;;) {
const unsigned nextMajorEvent = lengthCounter.getCounter() < endCycles ? lengthCounter.getCounter() : endCycles;
- unsigned out = outBase * (master ? ((sampleBuf >> (~wavePos << 2 & 4) & 0xF) >> rShift) * 2 - 15ul : 0 - 15ul);
+ unsigned out = outBase * (master ? ((sampleBuf >> (~wavePos << 2 & 4) & 0xF) >> rShift) * 2 - (15 >> rShift) : 0);
while (waveCounter <= nextMajorEvent) {
*buf += out - prevOut;
@@ -168,7 +168,7 @@ void Channel3::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cy
++wavePos;
wavePos &= 0x1F;
sampleBuf = waveRam[wavePos >> 1];
- out = outBase * (/*master ? */((sampleBuf >> (~wavePos << 2 & 4) & 0xF) >> rShift) * 2 - 15ul/* : 0 - 15ul*/);
+ out = outBase * (/*master ? */((sampleBuf >> (~wavePos << 2 & 4) & 0xF) >> rShift) * 2 - (15 >> rShift)/* : 0 - 15ul*/);
}
if (cycleCounter < nextMajorEvent) {
@@ -184,7 +184,7 @@ void Channel3::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cy
break;
}
} else {
- unsigned const out = outBase * (0 - 15ul);
+ unsigned const out = outBase * 0;
*buf += out - prevOut;
prevOut = out;
cycleCounter += cycles;
diff --git a/libgambatte/src/sound/channel4.cpp b/libgambatte/src/sound/channel4.cpp
index b646dff..5132303 100644
--- a/libgambatte/src/sound/channel4.cpp
+++ b/libgambatte/src/sound/channel4.cpp
@@ -264,14 +264,13 @@ void Channel4::loadState(const SaveState &state) {
void Channel4::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cycles) {
const unsigned outBase = envelopeUnit.dacIsOn() ? soBaseVol & soMask : 0;
- const unsigned outLow = outBase * (0 - 15ul);
const unsigned endCycles = cycleCounter + cycles;
for (;;) {
- const unsigned outHigh = /*master ? */outBase * (envelopeUnit.getVolume() * 2 - 15ul)/* : outLow*/;
+ const unsigned outHigh = /*master ? */outBase * (envelopeUnit.getVolume())/* : outLow*/;
+ const unsigned outLow = -outHigh;
const unsigned nextMajorEvent = nextEventUnit->getCounter() < endCycles ? nextEventUnit->getCounter() : endCycles;
unsigned out = lfsr.isHighState() ? outHigh : outLow;
-
while (lfsr.getCounter() <= nextMajorEvent) {
*buf += out - prevOut;
prevOut = out;
--
1.8.5

View file

@ -0,0 +1,124 @@
From 1bcbfe173abb9650c8ae13677d4dca4f0222ab7e Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Mon, 18 Nov 2013 01:53:58 +0200
Subject: [PATCH 2/4] Expose CPU registers
---
libgambatte/include/gambatte.h | 22 +++++++++++++++++++
libgambatte/src/cpu.h | 4 ++--
libgambatte/src/gambatte.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/libgambatte/include/gambatte.h b/libgambatte/include/gambatte.h
index 2901fdf..5094906 100644
--- a/libgambatte/include/gambatte.h
+++ b/libgambatte/include/gambatte.h
@@ -237,6 +237,28 @@ public:
/** Get version. */
static std::string version();
+
+ /** CPU registers. */
+ enum cpu_register
+ {
+ REG_CYCLECOUNTER,
+ REG_PC,
+ REG_SP,
+ REG_HF1,
+ REG_HF2,
+ REG_ZF,
+ REG_CF,
+ REG_A,
+ REG_B,
+ REG_C,
+ REG_D,
+ REG_E,
+ REG_F,
+ REG_H,
+ REG_L
+ };
+ uint32_t get_cpureg(enum cpu_register reg);
+ void set_cpureg(enum cpu_register reg, uint32_t val);
private:
void preload_common();
void postload_common(const unsigned flags);
diff --git a/libgambatte/src/cpu.h b/libgambatte/src/cpu.h
index 9f9a11e..224ba0b 100644
--- a/libgambatte/src/cpu.h
+++ b/libgambatte/src/cpu.h
@@ -88,13 +88,13 @@ public:
std::pair<unsigned char*, size_t> getIoRam() { return mem_.getIoRam(); }
std::pair<unsigned char*, size_t> getVideoRam() { return mem_.getVideoRam(); };
-private:
- Memory mem_;
unsigned cycleCounter_;
unsigned short pc_;
unsigned short sp;
unsigned hf1, hf2, zf, cf;
unsigned char a_, b, c, d, e, /*f,*/ h, l;
+private:
+ Memory mem_;
bool skip_;
void process(unsigned cycles);
diff --git a/libgambatte/src/gambatte.cpp b/libgambatte/src/gambatte.cpp
index 0204557..a61e177 100644
--- a/libgambatte/src/gambatte.cpp
+++ b/libgambatte/src/gambatte.cpp
@@ -298,4 +298,52 @@ std::string GB::version()
return "r537";
}
+uint32_t GB::get_cpureg(enum cpu_register _reg)
+{
+ switch(_reg) {
+ case REG_CYCLECOUNTER: return p_->cpu.cycleCounter_;
+ case REG_PC: return p_->cpu.pc_;
+ case REG_SP: return p_->cpu.sp;
+ case REG_HF1: return p_->cpu.hf1;
+ case REG_HF2: return p_->cpu.hf2;
+ case REG_ZF: return p_->cpu.zf;
+ case REG_CF: return p_->cpu.cf;
+ case REG_A: return p_->cpu.a_;
+ case REG_B: return p_->cpu.b;
+ case REG_C: return p_->cpu.c;
+ case REG_D: return p_->cpu.d;
+ case REG_E: return p_->cpu.e;
+ case REG_F:
+ return ((p_->cpu.hf2 & 0x600 | (p_->cpu.cf & 0x100)) >> 4)
+ | (p_->cpu.zf & 0xFF ? 0 : 0x80);
+ case REG_H: return p_->cpu.h;
+ case REG_L: return p_->cpu.l;
+ default: return 0;
+ }
+}
+
+void GB::set_cpureg(enum cpu_register _reg, uint32_t val)
+{
+ switch(_reg) {
+ case REG_PC: p_->cpu.pc_ = val; break;
+ case REG_SP: p_->cpu.sp = val; break;
+ case REG_HF1: p_->cpu.hf1 = val; break;
+ case REG_HF2: p_->cpu.hf2 = val; break;
+ case REG_ZF: p_->cpu.zf = val; break;
+ case REG_CF: p_->cpu.cf = val; break;
+ case REG_A: p_->cpu.a_ = val; break;
+ case REG_B: p_->cpu.b = val; break;
+ case REG_C: p_->cpu.c = val; break;
+ case REG_D: p_->cpu.d = val; break;
+ case REG_E: p_->cpu.e = val; break;
+ case REG_F:
+ p_->cpu.hf2 = (val << 4) & 0x600;
+ p_->cpu.cf = (val << 4) & 0x100;
+ p_->cpu.zf = val & 0x80;
+ break;
+ case REG_H: p_->cpu.h = val; break;
+ case REG_L: p_->cpu.l = val; break;
+ default: break;
+ }
+}
}
--
1.8.5

View file

@ -0,0 +1,490 @@
From 6725b4545adc3e94e0344e5f904267349ce167ba Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Thu, 28 Nov 2013 22:05:32 +0200
Subject: [PATCH 3/4] Breakpoints & debugging
---
libgambatte/include/gambatte.h | 23 +++++++++
libgambatte/src/cpu.cpp | 9 ++--
libgambatte/src/cpu.h | 7 +++
libgambatte/src/gambatte.cpp | 16 ++++++
libgambatte/src/mem/cartridge.cpp | 6 +++
libgambatte/src/mem/cartridge.h | 1 +
libgambatte/src/memory.cpp | 100 ++++++++++++++++++++++++++++++--------
libgambatte/src/memory.h | 93 ++++++++++++++++++++++++++++++++---
8 files changed, 225 insertions(+), 30 deletions(-)
diff --git a/libgambatte/include/gambatte.h b/libgambatte/include/gambatte.h
index 5094906..ea2558c 100644
--- a/libgambatte/include/gambatte.h
+++ b/libgambatte/include/gambatte.h
@@ -18,6 +18,7 @@
***************************************************************************/
#ifndef GAMBATTE_H
#define GAMBATTE_H
+#define GAMBATTE_SUPPORTS_ADV_DEBUG
#include "gbint.h"
#include "inputgetter.h"
@@ -25,6 +26,8 @@
#include <cstddef>
#include <string>
#include <vector>
+#include <functional>
+#include <map>
//
// Modified 2012-07-10 to 2012-07-14 by H. Ilari Liusvaara
@@ -34,6 +37,23 @@ namespace gambatte {
enum { BG_PALETTE = 0, SP1_PALETTE = 1, SP2_PALETTE = 2 };
+struct debugbuffer
+{
+ //1 => Read, 2 => Write, 4 => Execute, 8 => Cheat
+ uint8_t* wram; //32kB, id1.
+ uint8_t* ioamhram; //512 bytes, id2.
+ uint8_t* cart; //As needed, id3.
+ uint8_t* sram; //As needed, id4.
+ uint8_t* bus; //64kB, id0
+ std::map<unsigned, uint8_t> wramcheat;
+ std::map<unsigned, uint8_t> sramcheat;
+ std::map<unsigned, uint8_t> cartcheat;
+ std::function<void(unsigned, unsigned, uint8_t, bool)> read;
+ std::function<void(unsigned, unsigned, uint8_t)> write;
+ std::function<void(uint16_t)> trace;
+ bool trace_cpu;
+};
+
class GB {
public:
GB();
@@ -259,6 +279,9 @@ public:
};
uint32_t get_cpureg(enum cpu_register reg);
void set_cpureg(enum cpu_register reg, uint32_t val);
+ void set_debug_buffer(debugbuffer& dbgbuf);
+ uint8_t bus_read(unsigned addr);
+ void bus_write(unsigned addr, uint8_t val);
private:
void preload_common();
void postload_common(const unsigned flags);
diff --git a/libgambatte/src/cpu.cpp b/libgambatte/src/cpu.cpp
index 06400c5..40a81e6 100644
--- a/libgambatte/src/cpu.cpp
+++ b/libgambatte/src/cpu.cpp
@@ -154,8 +154,8 @@ void CPU::loadOrSave(loadsave& state)
#define de() ( d << 8 | e )
#define hl() ( h << 8 | l )
-#define READ(dest, addr) do { (dest) = mem_.read(addr, cycleCounter); cycleCounter += 4; } while (0)
-#define PC_READ(dest) do { (dest) = mem_.read(pc, cycleCounter); pc = (pc + 1) & 0xFFFF; cycleCounter += 4; } while (0)
+#define READ(dest, addr) do { (dest) = mem_.read(addr, cycleCounter, false); cycleCounter += 4; } while (0)
+#define PC_READ(dest) do { (dest) = mem_.read(pc, cycleCounter, true); pc = (pc + 1) & 0xFFFF; cycleCounter += 4; } while (0)
#define FF_READ(dest, addr) do { (dest) = mem_.ff_read(addr, cycleCounter); cycleCounter += 4; } while (0)
#define WRITE(addr, data) do { mem_.write(addr, data, cycleCounter); cycleCounter += 4; } while (0)
@@ -525,7 +525,8 @@ void CPU::process(unsigned const cycles) {
}
} else while (cycleCounter < mem_.nextEventTime()) {
unsigned char opcode;
-
+ if(__builtin_expect(mem_.get_debug()->trace_cpu, 0))
+ mem_.get_debug()->trace(pc);
PC_READ(opcode);
if (skip_) {
@@ -923,7 +924,7 @@ void CPU::process(unsigned const cycles) {
case 0x3A:
{
unsigned addr = hl();
- a = mem_.read(addr, cycleCounter);
+ a = mem_.read(addr, cycleCounter, false);
cycleCounter += 4;
addr = (addr - 1) & 0xFFFF;
diff --git a/libgambatte/src/cpu.h b/libgambatte/src/cpu.h
index 224ba0b..e7e46ff 100644
--- a/libgambatte/src/cpu.h
+++ b/libgambatte/src/cpu.h
@@ -51,6 +51,11 @@ public:
mem_.setSaveDir(sdir);
}
+ void set_debug_buffer(debugbuffer& dbgbuf)
+ {
+ mem_.set_debug_buffer(dbgbuf);
+ }
+
std::string const saveBasePath() const {
return mem_.saveBasePath();
}
@@ -87,6 +92,8 @@ public:
std::pair<unsigned char*, size_t> getSaveRam() { return mem_.getSaveRam(); }
std::pair<unsigned char*, size_t> getIoRam() { return mem_.getIoRam(); }
std::pair<unsigned char*, size_t> getVideoRam() { return mem_.getVideoRam(); };
+ uint8_t bus_read(unsigned addr) { return mem_.read(addr, cycleCounter_, false); }
+ void bus_write(unsigned addr, uint8_t val) { mem_.write(addr, val, cycleCounter_); }
unsigned cycleCounter_;
unsigned short pc_;
diff --git a/libgambatte/src/gambatte.cpp b/libgambatte/src/gambatte.cpp
index a61e177..47f894e 100644
--- a/libgambatte/src/gambatte.cpp
+++ b/libgambatte/src/gambatte.cpp
@@ -346,4 +346,20 @@ void GB::set_cpureg(enum cpu_register _reg, uint32_t val)
default: break;
}
}
+
+void GB::set_debug_buffer(debugbuffer& dbgbuf)
+{
+ p_->cpu.set_debug_buffer(dbgbuf);
+}
+
+uint8_t GB::bus_read(unsigned addr)
+{
+ return p_->cpu.bus_read(addr);
+}
+
+void GB::bus_write(unsigned addr, uint8_t val)
+{
+ p_->cpu.bus_write(addr, val);
+}
+
}
diff --git a/libgambatte/src/mem/cartridge.cpp b/libgambatte/src/mem/cartridge.cpp
index d593dc5..1775139 100644
--- a/libgambatte/src/mem/cartridge.cpp
+++ b/libgambatte/src/mem/cartridge.cpp
@@ -858,6 +858,12 @@ std::pair<unsigned char*, size_t> Cartridge::getWorkRam() {
return std::make_pair(memptrs_.wramdata(0), worksize);
}
+std::pair<unsigned char*, size_t> Cartridge::getCartRom()
+{
+ size_t worksize = memptrs_.romdataend() - memptrs_.romdata(0);
+ return std::make_pair(memptrs_.romdata(0), worksize);
+}
+
Cartridge::Cartridge(time_t (**_getCurrentTime)())
: rtc_(_getCurrentTime) {
memoryCartridge = true;
diff --git a/libgambatte/src/mem/cartridge.h b/libgambatte/src/mem/cartridge.h
index dd342b6..3a0466c 100644
--- a/libgambatte/src/mem/cartridge.h
+++ b/libgambatte/src/mem/cartridge.h
@@ -81,6 +81,7 @@ public:
void loadOrSave(loadsave& state);
void setRtcBase(time_t time) { rtc_.setBaseTime(time); }
time_t getRtcBase() { return rtc_.getBaseTime(); }
+ std::pair<unsigned char*, size_t> getCartRom();
std::pair<unsigned char*, size_t> getWorkRam();
std::pair<unsigned char*, size_t> getSaveRam();
std::pair<unsigned char*, size_t> getVideoRam();
diff --git a/libgambatte/src/memory.cpp b/libgambatte/src/memory.cpp
index cc76f96..c42af88 100644
--- a/libgambatte/src/memory.cpp
+++ b/libgambatte/src/memory.cpp
@@ -234,7 +234,7 @@ unsigned Memory::event(unsigned cc) {
unsigned const src = dmaSrc++ & 0xFFFF;
unsigned const data = (src & 0xE000) == 0x8000 || src > 0xFDFF
? 0xFF
- : read(src, cc);
+ : read(src, cc, false);
cc += 2 << doubleSpeed;
@@ -550,18 +550,31 @@ static bool isInOamDmaConflictArea(OamDmaSrc const oamDmaSrc, unsigned const p,
&& p - a[oamDmaSrc].exceptAreaLower >= a[oamDmaSrc].exceptAreaWidth;
}
-unsigned Memory::nontrivial_read(unsigned const p, unsigned const cc) {
+unsigned Memory::nontrivial_read(unsigned const p, unsigned const cc, bool exec) {
if (p < 0xFF80) {
if (lastOamDmaUpdate_ != disabled_time) {
updateOamDma(cc);
- if (isInOamDmaConflictArea(cart_.oamDmaSrc(), p, isCgb()) && oamDmaPos_ < 0xA0)
+ if (isInOamDmaConflictArea(cart_.oamDmaSrc(), p, isCgb()) && oamDmaPos_ < 0xA0) {
return ioamhram_[oamDmaPos_];
+ }
}
if (p < 0xC000) {
- if (p < 0x8000)
- return cart_.romdata(p >> 14)[p];
+ if (p < 0x8000) {
+ const unsigned char* aaddr = cart_.romdata(p >> 14) + p;
+ auto a = cart_.getCartRom();
+ if(aaddr >= a.first && aaddr < a.first + a.second)
+ if(__builtin_expect(dbg->cart[aaddr - a.first] & (exec ? 0x4C : 0x19), 0)) {
+ if(dbg->cart[aaddr - a.first] & (exec ? 0x44 : 0x11))
+ dbg->read(3, aaddr - a.first, *aaddr, exec);
+ if(dbg->cart[aaddr - a.first] & 8) {
+ auto itr = dbg->cartcheat.find(aaddr - a.first);
+ if(itr != dbg->cartcheat.end()) return itr->second;
+ }
+ }
+ return *aaddr;
+ }
if (p < 0xA000) {
if (!lcd_.vramAccessible(cc))
@@ -570,23 +583,52 @@ unsigned Memory::nontrivial_read(unsigned const p, unsigned const cc) {
return cart_.vrambankptr()[p];
}
- if (cart_.rsrambankptr())
- return cart_.rsrambankptr()[p];
+ if (cart_.rsrambankptr()) {
+ const unsigned char* aaddr = cart_.rsrambankptr() + p;
+ auto a = cart_.getSaveRam();
+ if(aaddr >= a.first && aaddr < a.first + a.second)
+ if(__builtin_expect(dbg->sram[aaddr - a.first] & (exec ? 0x4C : 0x19), 0)) {
+ if(dbg->sram[aaddr - a.first] & (exec ? 0x44 : 0x11))
+ dbg->read(4, aaddr - a.first, *aaddr, exec);
+ if(dbg->sram[aaddr - a.first] & 8) {
+ auto itr = dbg->sramcheat.find(aaddr - a.first);
+ if(itr != dbg->sramcheat.end()) return itr->second;
+ }
+ }
+ return *aaddr;
+ }
return cart_.rtcRead();
}
- if (p < 0xFE00)
- return cart_.wramdata(p >> 12 & 1)[p & 0xFFF];
+ if (p < 0xFE00) {
+ unsigned char* aaddr = cart_.wramdata(p >> 12 & 1) + (p & 0xFFF);
+ auto a = cart_.getWorkRam();
+ if(aaddr >= a.first && aaddr < a.first + a.second)
+ if(__builtin_expect(dbg->wram[aaddr - a.first] & (exec ? 0x4C : 0x19), 0)) {
+ if(dbg->wram[aaddr - a.first] & (exec ? 0x44 : 0x11))
+ dbg->read(1, aaddr - a.first, *aaddr, exec);
+ if(dbg->wram[aaddr - a.first] & 8) {
+ auto itr = dbg->wramcheat.find(aaddr - a.first);
+ if(itr != dbg->wramcheat.end()) return itr->second;
+ }
+ }
+ return *aaddr;
+ }
long const ffp = long(p) - 0xFF00;
- if (ffp >= 0)
- return nontrivial_ff_read(ffp, cc);
+ if (ffp >= 0) {
+ uint8_t v = nontrivial_ff_read(ffp, cc);
+ if(__builtin_expect(dbg->ioamhram[ffp + 0x100] & (exec ? 0x44 : 0x11), 0))
+ dbg->read(2, ffp + 0x100, v, exec);
+ return v;
+ }
if (!lcd_.oamReadable(cc) || oamDmaPos_ < 0xA0)
return 0xFF;
}
-
+ if(__builtin_expect(dbg->ioamhram[p - 0xFE00] & (exec ? 0x44 : 0x11), 0))
+ dbg->read(2, p - 0xFE00, ioamhram_[p - 0xFE00], exec);
return ioamhram_[p - 0xFE00];
}
@@ -1023,18 +1065,32 @@ void Memory::nontrivial_write(unsigned const p, unsigned const data, unsigned co
if (p < 0xFE00) {
if (p < 0xA000) {
if (p < 0x8000) {
+ //Being a write on MBC, this is not ROM write.
cart_.mbcWrite(p, data);
} else if (lcd_.vramAccessible(cc)) {
lcd_.vramChange(cc);
cart_.vrambankptr()[p] = data;
}
} else if (p < 0xC000) {
- if (cart_.wsrambankptr())
- cart_.wsrambankptr()[p] = data;
- else
+ if (cart_.wsrambankptr()) {
+ unsigned char* aaddr = cart_.wsrambankptr() + p;
+ auto a = cart_.getSaveRam();
+ if(aaddr >= a.first && aaddr < a.first + a.second)
+ if(__builtin_expect(dbg->sram[aaddr - a.first] & 0x22, 0))
+ dbg->write(4, aaddr - a.first, data);
+ *aaddr = data;
+ } else {
+ //Being I/O write, this is not write on SRAM.
cart_.rtcWrite(data);
- } else
- cart_.wramdata(p >> 12 & 1)[p & 0xFFF] = data;
+ }
+ } else {
+ unsigned char* aaddr = cart_.wramdata(p >> 12 & 1) + (p & 0xFFF);
+ auto a = cart_.getWorkRam();
+ if(aaddr >= a.first && aaddr < a.first + a.second)
+ if(__builtin_expect(dbg->wram[aaddr - a.first] & 0x22, 0))
+ dbg->write(1, aaddr - a.first, data);
+ *aaddr = data;
+ }
} else if (p - 0xFF80u >= 0x7Fu) {
long const ffp = long(p) - 0xFF00;
if (ffp < 0) {
@@ -1042,10 +1098,16 @@ void Memory::nontrivial_write(unsigned const p, unsigned const data, unsigned co
lcd_.oamChange(cc);
ioamhram_[p - 0xFE00] = data;
}
- } else
+ } else {
+ if(__builtin_expect(dbg->ioamhram[ffp + 0x100] & 0x22, 0))
+ dbg->write(2, ffp + 0x100, data);
nontrivial_ff_write(ffp, data, cc);
- } else
+ }
+ } else {
+ if(__builtin_expect(dbg->ioamhram[p - 0xFE00] & 0x22, 0))
+ dbg->write(2, p - 0xFE00, data);
ioamhram_[p - 0xFE00] = data;
+ }
}
void Memory::postLoadRom()
diff --git a/libgambatte/src/memory.h b/libgambatte/src/memory.h
index a531930..4a252b7 100644
--- a/libgambatte/src/memory.h
+++ b/libgambatte/src/memory.h
@@ -23,6 +23,7 @@
// Modified 2012-07-10 to 2012-07-14 by H. Ilari Liusvaara
// - Make it rerecording-friendly.
+#include "gambatte.h"
#include "mem/cartridge.h"
#include "interrupter.h"
#include "pakinfo.h"
@@ -71,22 +72,99 @@ public:
void ei(unsigned cycleCounter) { if (!ime()) { intreq_.ei(cycleCounter); } }
void di() { intreq_.di(); }
+ void set_debug_buffer(debugbuffer& dbgbuf)
+ {
+ dbg = &dbgbuf;
+ }
+
unsigned ff_read(unsigned p, unsigned cc) {
- return p < 0x80 ? nontrivial_ff_read(p, cc) : ioamhram_[p + 0x100];
+ uint8_t v = p < 0x80 ? nontrivial_ff_read(p, cc) : ioamhram_[p + 0x100];
+ if(__builtin_expect(dbg->ioamhram[0x100 + p] & 1, 0))
+ dbg->read(2, 0x100 + p, v, false);
+ if(__builtin_expect(dbg->bus[0xFF00 + p] & 1, 0))
+ dbg->read(0, 0xFF00 + p, v, false);
+ return v;
+ }
+
+ inline uint8_t do_read_trap(const uint8_t* addr, std::pair<unsigned char*, size_t> area, unsigned clazz,
+ const uint8_t* dbgflags, std::map<unsigned, uint8_t>& cheats, uint8_t v, uint8_t mask, bool exec)
+ {
+ if(addr >= area.first && addr < area.first + area.second) {
+ if(__builtin_expect(dbgflags[addr - area.first] & mask, 0)) {
+ if(dbgflags[addr - area.first] & (mask & 77))
+ dbg->read(clazz, addr - area.first, v, exec);
+ if(__builtin_expect(dbgflags[addr - area.first] & 8, 0)) {
+ auto itr = cheats.find(addr - area.first);
+ if(itr != cheats.end()) v = itr->second;
+ }
+ }
+ }
+ return v;
}
- unsigned read(unsigned p, unsigned cc) {
- return cart_.rmem(p >> 12) ? cart_.rmem(p >> 12)[p] : nontrivial_read(p, cc);
+ inline void do_write_trap(const uint8_t* addr, std::pair<unsigned char*, size_t> area, unsigned clazz,
+ const uint8_t* dbgflags, uint8_t v)
+ {
+ if(addr >= area.first && addr < area.first + area.second)
+ if(__builtin_expect(dbgflags[addr - area.first] & 0x22, 0))
+ dbg->write(clazz, addr - area.first, v);
+ }
+
+ unsigned read(unsigned p, unsigned cc, bool exec) {
+ uint8_t mask = exec ? 0x4C : 0x19;
+ const unsigned char* memblock = cart_.rmem(p >> 12);
+ uint8_t v = memblock ? memblock[p] : nontrivial_read(p, cc, exec);
+ uint8_t v2 = v;
+ if(memblock) {
+ if(p >= 0xFE00) { //IOAMHRAM.
+ if(__builtin_expect(dbg->ioamhram[p - 0xFE00] & mask, 0))
+ dbg->read(2, 0x100 + p, v, false);
+ } else {
+ const uint8_t* addr = memblock + p;
+ static void* targets[8] = {&&cart, &&cart, &&cart, &&cart, &&out, &&sram, &&wram,
+ &&wram};
+ goto *targets[p >> 13];
+wram:
+ v2 = do_read_trap(addr, cart_.getWorkRam(), 1, dbg->wram, dbg->wramcheat, v, mask, exec);
+ goto out;
+sram:
+ v2 = do_read_trap(addr, cart_.getSaveRam(), 4, dbg->sram, dbg->sramcheat, v, mask, exec);
+ goto out;
+cart:
+ v2 = do_read_trap(addr, cart_.getCartRom(), 3, dbg->cart, dbg->cartcheat, v, mask, exec);
+ goto out;
+ }
+out: ;
+ }
+ if(__builtin_expect(dbg->bus[p] & mask, 0))
+ dbg->read(0, p, v, false);
+ return v2;
}
void write(unsigned p, unsigned data, unsigned cc) {
- if (cart_.wmem(p >> 12)) {
- cart_.wmem(p >> 12)[p] = data;
+ if(__builtin_expect(dbg->bus[0xFF00 + p] & 0x22, 0))
+ dbg->write(0, p, data);
+ unsigned char* memblock = cart_.wmem(p >> 12);
+ if(memblock) {
+ if(p >= 0xFE00) //IOAMHRAM.
+ if(__builtin_expect(dbg->ioamhram[p - 0xFE00] & 2, 0))
+ dbg->write(2, 0x100 + p, data);
+ uint8_t* addr = memblock + p;
+ do_write_trap(addr, cart_.getWorkRam(), 1, dbg->wram, data);
+ do_write_trap(addr, cart_.getSaveRam(), 4, dbg->sram, data);
+ do_write_trap(addr, cart_.getCartRom(), 3, dbg->cart, data);
+ }
+ if (memblock) {
+ memblock[p] = data;
} else
nontrivial_write(p, data, cc);
}
void ff_write(unsigned p, unsigned data, unsigned cc) {
+ if(__builtin_expect(dbg->ioamhram[0x100 + p] & 2, 0))
+ dbg->write(2, 0x100 + p, data);
+ if(__builtin_expect(dbg->bus[0xFF00 + p] & 2, 0))
+ dbg->write(0, 0xFF00 + p, data);
if (p - 0x80u < 0x7Fu) {
ioamhram_[p + 0x100] = data;
} else
@@ -119,8 +197,9 @@ public:
void setDmgPaletteColor(unsigned palNum, unsigned colorNum, uint_least32_t rgb32);
void setGameGenie(std::string const &codes) { cart_.setGameGenie(codes); }
void setGameShark(std::string const &codes) { interrupter_.setGameShark(codes); }
-
+ debugbuffer* get_debug() { return dbg; }
private:
+ debugbuffer* dbg;
Cartridge cart_;
unsigned char ioamhram_[0x200];
InputGetter *getInput_;
@@ -147,7 +226,7 @@ private:
void endOamDma(unsigned cycleCounter);
unsigned char const * oamDmaSrcPtr() const;
unsigned nontrivial_ff_read(unsigned p, unsigned cycleCounter);
- unsigned nontrivial_read(unsigned p, unsigned cycleCounter);
+ unsigned nontrivial_read(unsigned p, unsigned cycleCounter, bool exec);
void nontrivial_ff_write(unsigned p, unsigned data, unsigned cycleCounter);
void nontrivial_write(unsigned p, unsigned data, unsigned cycleCounter);
void updateSerial(unsigned cc);
--
1.8.5

View file

@ -0,0 +1,109 @@
From 607d3e252c43d67cea54ec222ef1767a86b3660b Mon Sep 17 00:00:00 2001
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Date: Thu, 5 Dec 2013 08:48:21 +0200
Subject: [PATCH 4/4] Fix sound DC levels
This was causing popping in Mega Man (I)
---
libgambatte/src/sound/channel1.cpp | 6 +++---
libgambatte/src/sound/channel2.cpp | 6 +++---
libgambatte/src/sound/channel3.cpp | 8 ++++----
libgambatte/src/sound/channel4.cpp | 4 ++--
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/libgambatte/src/sound/channel1.cpp b/libgambatte/src/sound/channel1.cpp
index c517965..dd83894 100644
--- a/libgambatte/src/sound/channel1.cpp
+++ b/libgambatte/src/sound/channel1.cpp
@@ -218,13 +218,13 @@ void Channel1::loadState(SaveState const &state) {
void Channel1::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cycles) {
unsigned const outBase = envelopeUnit_.dacIsOn() ? soBaseVol & soMask_ : 0;
- unsigned const outLow = outBase * (0 - 15ul);
unsigned const endCycles = cycleCounter_ + cycles;
for (;;) {
unsigned const outHigh = master_
- ? outBase * (envelopeUnit_.getVolume() * 2 - 15ul)
- : outLow;
+ ? outBase * (envelopeUnit_.getVolume())
+ : 0;
+ unsigned const outLow = -outHigh;
unsigned const nextMajorEvent = std::min(nextEventUnit_->counter(), endCycles);
unsigned out = dutyUnit_.isHighState() ? outHigh : outLow;
diff --git a/libgambatte/src/sound/channel2.cpp b/libgambatte/src/sound/channel2.cpp
index f154249..6024d79 100644
--- a/libgambatte/src/sound/channel2.cpp
+++ b/libgambatte/src/sound/channel2.cpp
@@ -122,13 +122,13 @@ void Channel2::loadState(SaveState const &state) {
void Channel2::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cycles) {
unsigned const outBase = envelopeUnit_.dacIsOn() ? soBaseVol & soMask_ : 0;
- unsigned const outLow = outBase * (0 - 15ul);
unsigned const endCycles = cycleCounter_ + cycles;
for (;;) {
unsigned const outHigh = master_
- ? outBase * (envelopeUnit_.getVolume() * 2 - 15ul)
- : outLow;
+ ? outBase * (envelopeUnit_.getVolume())
+ : 0;
+ unsigned const outLow = -outHigh;
unsigned const nextMajorEvent = std::min(nextEventUnit->counter(), endCycles);
unsigned out = dutyUnit_.isHighState() ? outHigh : outLow;
diff --git a/libgambatte/src/sound/channel3.cpp b/libgambatte/src/sound/channel3.cpp
index c583949..f25c96d 100644
--- a/libgambatte/src/sound/channel3.cpp
+++ b/libgambatte/src/sound/channel3.cpp
@@ -156,8 +156,8 @@ void Channel3::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cy
unsigned const nextMajorEvent =
std::min(lengthCounter_.counter(), endCycles);
unsigned out = master_
- ? ((sampleBuf_ >> (~wavePos_ << 2 & 4) & 0xF) >> rshift_) * 2 - 15ul
- : 0 - 15ul;
+ ? ((sampleBuf_ >> (~wavePos_ << 2 & 4) & 0xF) >> rshift_) * 2 - (15 >> rshift_)
+ : 0;
out *= outBase;
while (waveCounter_ <= nextMajorEvent) {
@@ -171,7 +171,7 @@ void Channel3::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cy
++wavePos_;
wavePos_ &= 0x1F;
sampleBuf_ = waveRam_[wavePos_ >> 1];
- out = ((sampleBuf_ >> (~wavePos_ << 2 & 4) & 0xF) >> rshift_) * 2 - 15ul;
+ out = ((sampleBuf_ >> (~wavePos_ << 2 & 4) & 0xF) >> rshift_) * 2 - (15 >> rshift_);
out *= outBase;
}
@@ -188,7 +188,7 @@ void Channel3::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cy
break;
}
} else {
- unsigned const out = outBase * (0 - 15ul);
+ unsigned const out = 0;
*buf += out - prevOut_;
prevOut_ = out;
cycleCounter_ += cycles;
diff --git a/libgambatte/src/sound/channel4.cpp b/libgambatte/src/sound/channel4.cpp
index bc0a312..0abd4fb 100644
--- a/libgambatte/src/sound/channel4.cpp
+++ b/libgambatte/src/sound/channel4.cpp
@@ -224,11 +224,11 @@ void Channel4::loadState(SaveState const &state) {
void Channel4::update(uint_least32_t *buf, unsigned const soBaseVol, unsigned cycles) {
unsigned const outBase = envelopeUnit_.dacIsOn() ? soBaseVol & soMask_ : 0;
- unsigned const outLow = outBase * (0 - 15ul);
unsigned const endCycles = cycleCounter_ + cycles;
for (;;) {
- unsigned const outHigh = outBase * (envelopeUnit_.getVolume() * 2 - 15ul);
+ unsigned const outHigh = outBase * (envelopeUnit_.getVolume());
+ unsigned const outLow = -outHigh;
unsigned const nextMajorEvent = std::min(nextEventUnit_->counter(), endCycles);
unsigned out = lfsr_.isHighState() ? outHigh : outLow;
--
1.8.5

View file

@ -280,7 +280,11 @@ namespace
if(write)
SNES::bus.write(offset, data);
else
#ifdef BSNES_SUPPORTS_ADV_BREAKPOINTS
return SNES::bus.read(offset, false);
#else
return SNES::bus.read(offset);
#endif
}
uint8_t ptrtable_iospace_rw(uint64_t offset, uint8_t data, bool write)

View file

@ -53,6 +53,10 @@ const char* button_symbols = "ABsSrlud";
namespace
{
#ifdef GAMBATTE_SUPPORTS_ADV_DEBUG
size_t debug_size;
gambatte::debugbuffer debugbuf;
#endif
int regions_compatible(unsigned rom, unsigned run)
{
return 1;
@ -141,6 +145,24 @@ namespace
romdata.resize(size);
memcpy(&romdata[0], data, size);
internal_rom = inttype;
size_t dsize = (size > 65536) ? size : 65536;
if(dsize < instance->getSaveRam().second) dsize = instance->getSaveRam().second;
if(debug_size < dsize) {
if(debugbuf.wram) delete[] debugbuf.wram;
debugbuf.wram = NULL;
uint8_t* tmp = new uint8_t[dsize];
memset(tmp, 0, dsize);
debug_size = dsize;
debugbuf.wram = tmp;
}
debugbuf.bus = debugbuf.wram;
debugbuf.ioamhram = debugbuf.wram;
debugbuf.sram = debugbuf.wram;
debugbuf.cart = debugbuf.wram;
debugbuf.trace_cpu = false;
instance->set_debug_buffer(debugbuf);
return 1;
}
@ -315,6 +337,16 @@ void do_basic_core_init()
instance = new gambatte::GB;
instance->setInputGetter(&getinput);
instance->set_walltime_fn(walltime_fn);
debug_size = 65536;
uint8_t* tmp = new uint8_t[debug_size];
memset(tmp, 0, debug_size);
debugbuf.wram = tmp;
debugbuf.bus = tmp;
debugbuf.ioamhram = tmp;
debugbuf.sram = tmp;
debugbuf.cart = tmp;
debugbuf.trace_cpu = false;
instance->set_debug_buffer(debugbuf);
}
void core_power()