Skip to content

Commit

Permalink
added support to boot the xband USA rom!
Browse files Browse the repository at this point in the history
  • Loading branch information
fresh-eggs committed Jul 11, 2021
1 parent 02852ba commit 0ab3a8e
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 14 deletions.
148 changes: 148 additions & 0 deletions bsnes-plus-diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
diff --git a/bsnes/Makefile b/bsnes/Makefile
index 0bc6d76..1b87705 100644
--- a/bsnes/Makefile
+++ b/bsnes/Makefile
@@ -6,7 +6,7 @@ ifeq ($(ui),)
ui := ui-qt
endif

-profile := accuracy
+profile := compatibility
ifeq ($(profile),)
profile := compatibility
ifeq ($(out),)
diff --git a/bsnes/snes/chip/xband/xband.hpp b/bsnes/snes/chip/xband/xband.hpp
index 14b0157..31ceff1 100644
--- a/bsnes/snes/chip/xband/xband.hpp
+++ b/bsnes/snes/chip/xband/xband.hpp
@@ -1,4 +1,4 @@
-class XBANDBase : public Coprocessor, public MMIO {
+class XBANDBase : public Coprocessor, public Memory {
public:
MappedRAM sram;

@@ -22,6 +22,9 @@ public:
uint8 mmio_read(unsigned addr);
void mmio_write(unsigned addr, uint8 data);

+ uint8 read(unsigned addr);
+ void write(unsigned addr, uint8 data);
+
void serialize(serializer&);

private:
diff --git a/bsnes/snes/chip/xband/xband_base.cpp b/bsnes/snes/chip/xband/xband_base.cpp
index 1b907df..941d94b 100644
--- a/bsnes/snes/chip/xband/xband_base.cpp
+++ b/bsnes/snes/chip/xband/xband_base.cpp
@@ -19,7 +19,8 @@ void XBANDBase::init() {

void XBANDBase::enable() {
fprintf(stderr, "[*][XBANDBase][enable_start]\n");
- memory::mmio.map(0xc180, 0xc1bf, *this);
+ //memory::mmio.map(0xc180, 0xc1bf, *this);
+ bus.map(Bus::MapMode::Direct, 0xe0, 0xff, 0x0000, 0xffff, *this);
fprintf(stderr, "[*][XBANDBase][enable_end]\n");
}

@@ -40,8 +41,8 @@ void XBANDBase::unload() {
}


-uint8 XBANDBase::mmio_read(unsigned addr) { 
- fprintf(stderr, "[*][xband_cart.cpp:mmimo_read] addr: 0x%x\n", addr);
+uint8 XBANDBase::read(unsigned addr) { 
+ //fprintf(stderr, "[*][xband_base.cpp:mmimo_read] addr: 0x%x\n", addr);
if(within<0xe0, 0xfa, 0x0000, 0xffff>(addr)
|| within<0xfb, 0xfb, 0x0000, 0xbfff>(addr)
|| within<0xfc, 0xff, 0x0000, 0xffff>(addr)
@@ -118,8 +119,8 @@ uint8 XBANDBase::mmio_read(unsigned addr) {
return 0xff;
}

-void XBANDBase::mmio_write(unsigned addr, uint8 data) {
-
+void XBANDBase::write(unsigned addr, uint8 data) {
+ //fprintf(stderr, "[*][xband_base][mimo_write] addr: 0x%x | data: 0x%x\n", addr, data);
if(within<0xe0, 0xfa, 0x0000, 0xffff>(addr)) {
addr = (addr & 0x1fffff);
addr = bus.mirror(addr, memory::xbandSram.size());
diff --git a/bsnes/snes/chip/xband/xband_cart.cpp b/bsnes/snes/chip/xband/xband_cart.cpp
index 1ed0ebf..d4e491f 100644
--- a/bsnes/snes/chip/xband/xband_cart.cpp
+++ b/bsnes/snes/chip/xband/xband_cart.cpp
@@ -29,13 +29,17 @@ void XBANDCart::unload() {

void XBANDCart::power() {
fprintf(stderr, "[*][xband_cart.cpp:power] enter \n");
- bus.map(Bus::MapMode::Linear, 0x7d, 0xe0, 0x0000, 0x7fff, memory::xbandSram);
- //bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x8000, 0xffff, memory::xbandSram);
- //bus.map(Bus::MapMode::Direct, 0x40, 0x7d, 0x0000, 0xffff, memory::xbandSram);
- //bus.map(Bus::MapMode::Direct, 0xc0, 0xdf, 0x0000, 0xffff, memory::xbandSram);
+ bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x8000, 0xffff, *this);
+ bus.map(Bus::MapMode::Direct, 0x40, 0x7d, 0x0000, 0xffff, *this);
+ bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x8000, 0xffff, *this);
+ bus.map(Bus::MapMode::Direct, 0xc0, 0xdf, 0x0000, 0xffff, *this);
+ 
//Force MMIO Map
//bus.map(Bus::MapMode::Direct, 0xe0, 0xff, 0x0000, 0xffff, memory::xbandSram);

+ //map SRAM
+ //bus.map(Bus::MapMode::Linear, 0x7d, 0xe0, 0x0000, 0x7fff, memory::xbandSram);
+
//bus.map(Bus::MapMode::Linear, 0x80, 0xbf, 0x8000, 0xffff, memory::cartrom);
fprintf(stderr, "[*][xband_cart.cpp:power] exit \n");
reset();
@@ -95,7 +99,7 @@ uint8 XBANDCart::read(unsigned addr) {
////fprintf(stderr, "[*][xband_cart.cpp:read][!] addr_translated: 0x%x\n", addr);
////fprintf(stderr, "[*]---------------------------------------------\n"); 
//fprintf(stderr, "[*]---------------------------------------------\n");
- fprintf(stderr, "[*][xband_cart.cpp:read][regular read] addr: 0x%x\n", addr);
+ //fprintf(stderr, "[*][xband_cart.cpp:read][regular read] addr: 0x%x\n", addr);
//fprintf(stderr, "[*]---------------------------------------------\n");

return -1;
@@ -105,7 +109,7 @@ void XBANDCart::write(unsigned addr, uint8 data) {
addr = ((addr & 0x3f0000 >> 1) | (addr & 0xffff));
addr = bus.mirror(addr, memory::cartrom.size());
//addr = (addr & 0x0fffff); //make offset into xband rom at 0 for access into data_
- fprintf(stderr, "[*][xband_cart.cpp:write] addr: 0x%x, data: %d\n", addr, data);
+ //fprintf(stderr, "[*][xband_cart.cpp:write] addr: 0x%x, data: %d\n", addr, data);
memory::cartrom.write(addr, data);
}

diff --git a/common/nall/snes/cartridge.hpp b/common/nall/snes/cartridge.hpp
index f894e6b..7111229 100644
--- a/common/nall/snes/cartridge.hpp
+++ b/common/nall/snes/cartridge.hpp
@@ -103,7 +103,7 @@ public:
SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
fprintf(stderr, "[*][cartride.hpp] SNESCartridge::SNESCartridge\n");
read_header(data, size);
- type = TypeXBand;
+ //type = TypeXBand;

string xml = "<?xml version='1.0' encoding='UTF-8'?>\n";

diff --git a/notes b/notes
index 86075eb..3893aed 100644
--- a/notes
+++ b/notes
@@ -394,6 +394,17 @@ if it is actually ending up in snesreader_load_normal, why isn't changing the 0x
afaict, everything required for the xband_base coprocessor to work is now present in the code base. The translation of requests into the xband maped memory should reflect what was done in the bsx-2 implementation.


+----
+
+- you haven't got much farther, the emulator is now crashing in a new place since attempting to more closely match what mapping were being forced in the bsx-2 in the XML mapping in the bsnes-plus (done by moving the ram mapping in xband so you can map it)
+
+- continue to attempt to debug the current segfault.
+
+- might be worth burning everything down and starting the implementation from mostly scract? Either that or whiteboard the current state of the implementation.
+
+- you could also reach out for help on the nesdev forums, anyone who is willing to try and get xband implementation working on bsnes-plus
+
+- oh btw now the emulator looks to be arbitrarily crashing at the same system bug mapping of wram section again... fun



3 changes: 2 additions & 1 deletion bsnes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ ifeq ($(ui),)
ui := ui-qt
endif

profile := accuracy
#profile := accuracy
profile := compatibility
ifeq ($(profile),)
profile := compatibility
ifeq ($(out),)
Expand Down
5 changes: 4 additions & 1 deletion bsnes/snes/chip/xband/xband.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class XBANDBase : public Coprocessor, public MMIO {
class XBANDBase : public Coprocessor, public Memory {
public:
MappedRAM sram;

Expand All @@ -22,6 +22,9 @@ class XBANDBase : public Coprocessor, public MMIO {
uint8 mmio_read(unsigned addr);
void mmio_write(unsigned addr, uint8 data);

uint8 read(unsigned addr);
void write(unsigned addr, uint8 data);

void serialize(serializer&);

private:
Expand Down
11 changes: 6 additions & 5 deletions bsnes/snes/chip/xband/xband_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ void XBANDBase::init() {

void XBANDBase::enable() {
fprintf(stderr, "[*][XBANDBase][enable_start]\n");
memory::mmio.map(0xc180, 0xc1bf, *this);
//memory::mmio.map(0xc180, 0xc1bf, *this);
bus.map(Bus::MapMode::Direct, 0xe0, 0xff, 0x0000, 0xffff, *this);
fprintf(stderr, "[*][XBANDBase][enable_end]\n");
}

Expand All @@ -40,8 +41,8 @@ void XBANDBase::unload() {
}


uint8 XBANDBase::mmio_read(unsigned addr) {
fprintf(stderr, "[*][xband_cart.cpp:mmimo_read] addr: 0x%x\n", addr);
uint8 XBANDBase::read(unsigned addr) {
//fprintf(stderr, "[*][xband_base.cpp:mmimo_read] addr: 0x%x\n", addr);
if(within<0xe0, 0xfa, 0x0000, 0xffff>(addr)
|| within<0xfb, 0xfb, 0x0000, 0xbfff>(addr)
|| within<0xfc, 0xff, 0x0000, 0xffff>(addr)
Expand Down Expand Up @@ -118,8 +119,8 @@ uint8 XBANDBase::mmio_read(unsigned addr) {
return 0xff;
}

void XBANDBase::mmio_write(unsigned addr, uint8 data) {

void XBANDBase::write(unsigned addr, uint8 data) {
//fprintf(stderr, "[*][xband_base][mimo_write] addr: 0x%x | data: 0x%x\n", addr, data);
if(within<0xe0, 0xfa, 0x0000, 0xffff>(addr)) {
addr = (addr & 0x1fffff);
addr = bus.mirror(addr, memory::xbandSram.size());
Expand Down
16 changes: 10 additions & 6 deletions bsnes/snes/chip/xband/xband_cart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ void XBANDCart::unload() {

void XBANDCart::power() {
fprintf(stderr, "[*][xband_cart.cpp:power] enter \n");
bus.map(Bus::MapMode::Linear, 0x7d, 0xe0, 0x0000, 0x7fff, memory::xbandSram);
//bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x8000, 0xffff, memory::xbandSram);
//bus.map(Bus::MapMode::Direct, 0x40, 0x7d, 0x0000, 0xffff, memory::xbandSram);
//bus.map(Bus::MapMode::Direct, 0xc0, 0xdf, 0x0000, 0xffff, memory::xbandSram);
bus.map(Bus::MapMode::Direct, 0x00, 0x3f, 0x8000, 0xffff, *this);
bus.map(Bus::MapMode::Direct, 0x40, 0x7d, 0x0000, 0xffff, *this);
bus.map(Bus::MapMode::Direct, 0x80, 0xbf, 0x8000, 0xffff, *this);
bus.map(Bus::MapMode::Direct, 0xc0, 0xdf, 0x0000, 0xffff, *this);

//Force MMIO Map
//bus.map(Bus::MapMode::Direct, 0xe0, 0xff, 0x0000, 0xffff, memory::xbandSram);

//map SRAM
//bus.map(Bus::MapMode::Linear, 0x7d, 0xe0, 0x0000, 0x7fff, memory::xbandSram);

//bus.map(Bus::MapMode::Linear, 0x80, 0xbf, 0x8000, 0xffff, memory::cartrom);
fprintf(stderr, "[*][xband_cart.cpp:power] exit \n");
reset();
Expand Down Expand Up @@ -95,7 +99,7 @@ uint8 XBANDCart::read(unsigned addr) {
////fprintf(stderr, "[*][xband_cart.cpp:read][!] addr_translated: 0x%x\n", addr);
////fprintf(stderr, "[*]---------------------------------------------\n");
//fprintf(stderr, "[*]---------------------------------------------\n");
fprintf(stderr, "[*][xband_cart.cpp:read][regular read] addr: 0x%x\n", addr);
//fprintf(stderr, "[*][xband_cart.cpp:read][regular read] addr: 0x%x\n", addr);
//fprintf(stderr, "[*]---------------------------------------------\n");

return -1;
Expand All @@ -105,7 +109,7 @@ void XBANDCart::write(unsigned addr, uint8 data) {
addr = ((addr & 0x3f0000 >> 1) | (addr & 0xffff));
addr = bus.mirror(addr, memory::cartrom.size());
//addr = (addr & 0x0fffff); //make offset into xband rom at 0 for access into data_
fprintf(stderr, "[*][xband_cart.cpp:write] addr: 0x%x, data: %d\n", addr, data);
//fprintf(stderr, "[*][xband_cart.cpp:write] addr: 0x%x, data: %d\n", addr, data);
memory::cartrom.write(addr, data);
}

Expand Down
2 changes: 1 addition & 1 deletion common/nall/snes/cartridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class SNESCartridge {
SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
fprintf(stderr, "[*][cartride.hpp] SNESCartridge::SNESCartridge\n");
read_header(data, size);
type = TypeXBand;
//type = TypeXBand;

string xml = "<?xml version='1.0' encoding='UTF-8'?>\n";

Expand Down
11 changes: 11 additions & 0 deletions notes
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,17 @@ if it is actually ending up in snesreader_load_normal, why isn't changing the 0x
afaict, everything required for the xband_base coprocessor to work is now present in the code base. The translation of requests into the xband maped memory should reflect what was done in the bsx-2 implementation.


----

- you haven't got much farther, the emulator is now crashing in a new place since attempting to more closely match what mapping were being forced in the bsx-2 in the XML mapping in the bsnes-plus (done by moving the ram mapping in xband so you can map it)

- continue to attempt to debug the current segfault.

- might be worth burning everything down and starting the implementation from mostly scract? Either that or whiteboard the current state of the implementation.

- you could also reach out for help on the nesdev forums, anyone who is willing to try and get xband implementation working on bsnes-plus

- oh btw now the emulator looks to be arbitrarily crashing at the same system bug mapping of wram section again... fun



Expand Down

0 comments on commit 0ab3a8e

Please sign in to comment.