o cleanup
This commit is contained in:
54
tools/bsnes/memory/smemory/mapper/chip.cpp
Executable file
54
tools/bsnes/memory/smemory/mapper/chip.cpp
Executable file
@@ -0,0 +1,54 @@
|
||||
#ifdef SMEMORY_CPP
|
||||
|
||||
void sBus::map_cx4() {
|
||||
map(MapDirect, 0x00, 0x3f, 0x6000, 0x7fff, cx4);
|
||||
map(MapDirect, 0x80, 0xbf, 0x6000, 0x7fff, cx4);
|
||||
}
|
||||
|
||||
void sBus::map_dsp1() {
|
||||
switch(cartridge.dsp1_mapper()) {
|
||||
case Cartridge::DSP1LoROM1MB: {
|
||||
map(MapDirect, 0x20, 0x3f, 0x8000, 0xffff, dsp1);
|
||||
map(MapDirect, 0xa0, 0xbf, 0x8000, 0xffff, dsp1);
|
||||
} break;
|
||||
|
||||
case Cartridge::DSP1LoROM2MB: {
|
||||
map(MapDirect, 0x60, 0x6f, 0x0000, 0x7fff, dsp1);
|
||||
map(MapDirect, 0xe0, 0xef, 0x0000, 0x7fff, dsp1);
|
||||
} break;
|
||||
|
||||
case Cartridge::DSP1HiROM: {
|
||||
map(MapDirect, 0x00, 0x1f, 0x6000, 0x7fff, dsp1);
|
||||
map(MapDirect, 0x80, 0x9f, 0x6000, 0x7fff, dsp1);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void sBus::map_dsp2() {
|
||||
map(MapDirect, 0x20, 0x3f, 0x6000, 0x6fff, dsp2);
|
||||
map(MapDirect, 0x20, 0x3f, 0x8000, 0xbfff, dsp2);
|
||||
map(MapDirect, 0xa0, 0xbf, 0x6000, 0x6fff, dsp2);
|
||||
map(MapDirect, 0xa0, 0xbf, 0x8000, 0xbfff, dsp2);
|
||||
}
|
||||
|
||||
void sBus::map_dsp3() {
|
||||
map(MapDirect, 0x20, 0x3f, 0x8000, 0xffff, dsp3);
|
||||
map(MapDirect, 0xa0, 0xbf, 0x8000, 0xffff, dsp3);
|
||||
}
|
||||
|
||||
void sBus::map_dsp4() {
|
||||
map(MapDirect, 0x30, 0x3f, 0x8000, 0xffff, dsp4);
|
||||
map(MapDirect, 0xb0, 0xbf, 0x8000, 0xffff, dsp4);
|
||||
}
|
||||
|
||||
void sBus::map_obc1() {
|
||||
map(MapDirect, 0x00, 0x3f, 0x6000, 0x7fff, obc1);
|
||||
map(MapDirect, 0x80, 0xbf, 0x6000, 0x7fff, obc1);
|
||||
}
|
||||
|
||||
void sBus::map_st010() {
|
||||
map(MapDirect, 0x68, 0x6f, 0x0000, 0x0fff, st010);
|
||||
map(MapDirect, 0xe8, 0xef, 0x0000, 0x0fff, st010);
|
||||
}
|
||||
|
||||
#endif
|
||||
104
tools/bsnes/memory/smemory/mapper/generic.cpp
Executable file
104
tools/bsnes/memory/smemory/mapper/generic.cpp
Executable file
@@ -0,0 +1,104 @@
|
||||
#ifdef SMEMORY_CPP
|
||||
|
||||
void sBus::map_generic() {
|
||||
switch(cartridge.mapper()) {
|
||||
case Cartridge::LoROM: {
|
||||
map(MapLinear, 0x00, 0x7f, 0x8000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0x80, 0xff, 0x8000, 0xffff, memory::cartrom);
|
||||
map_generic_sram();
|
||||
} break;
|
||||
|
||||
case Cartridge::HiROM: {
|
||||
map(MapShadow, 0x00, 0x3f, 0x8000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0x40, 0x7f, 0x0000, 0xffff, memory::cartrom);
|
||||
map(MapShadow, 0x80, 0xbf, 0x8000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0xc0, 0xff, 0x0000, 0xffff, memory::cartrom);
|
||||
map_generic_sram();
|
||||
} break;
|
||||
|
||||
case Cartridge::ExLoROM: {
|
||||
map(MapLinear, 0x00, 0x3f, 0x8000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0x40, 0x7f, 0x0000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0x80, 0xbf, 0x8000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0xc0, 0xff, 0x0000, 0xffff, memory::cartrom);
|
||||
map_generic_sram();
|
||||
} break;
|
||||
|
||||
case Cartridge::ExHiROM: {
|
||||
map(MapShadow, 0x00, 0x3f, 0x8000, 0xffff, memory::cartrom, 0x400000);
|
||||
map(MapLinear, 0x40, 0x7f, 0x0000, 0xffff, memory::cartrom, 0x400000);
|
||||
map(MapShadow, 0x80, 0xbf, 0x8000, 0xffff, memory::cartrom, 0x000000);
|
||||
map(MapLinear, 0xc0, 0xff, 0x0000, 0xffff, memory::cartrom, 0x000000);
|
||||
map_generic_sram();
|
||||
} break;
|
||||
|
||||
case Cartridge::SPC7110ROM: {
|
||||
map(MapDirect, 0x00, 0x00, 0x6000, 0x7fff, spc7110); //save RAM w/custom logic
|
||||
map(MapShadow, 0x00, 0x0f, 0x8000, 0xffff, memory::cartrom); //program ROM
|
||||
map(MapDirect, 0x30, 0x30, 0x6000, 0x7fff, spc7110); //save RAM w/custom logic
|
||||
map(MapDirect, 0x50, 0x50, 0x0000, 0xffff, spc7110); //decompression MMIO port
|
||||
map(MapShadow, 0x80, 0x8f, 0x8000, 0xffff, memory::cartrom); //program ROM
|
||||
map(MapLinear, 0xc0, 0xcf, 0x0000, 0xffff, memory::cartrom); //program ROM
|
||||
map(MapDirect, 0xd0, 0xff, 0x0000, 0xffff, spc7110); //MMC-controlled data ROM
|
||||
} break;
|
||||
|
||||
case Cartridge::BSXROM: {
|
||||
//full map is dynamically mapped by:
|
||||
//src/chip/bsx/bsx_cart.cpp : BSXCart::update_memory_map();
|
||||
map(MapLinear, 0x00, 0x3f, 0x8000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0x80, 0xbf, 0x8000, 0xffff, memory::cartrom);
|
||||
} break;
|
||||
|
||||
case Cartridge::BSCLoROM: {
|
||||
map(MapLinear, 0x00, 0x1f, 0x8000, 0xffff, memory::cartrom, 0x000000);
|
||||
map(MapLinear, 0x20, 0x3f, 0x8000, 0xffff, memory::cartrom, 0x100000);
|
||||
map(MapLinear, 0x70, 0x7f, 0x0000, 0x7fff, memory::cartram, 0x000000);
|
||||
map(MapLinear, 0x80, 0x9f, 0x8000, 0xffff, memory::cartrom, 0x200000);
|
||||
map(MapLinear, 0xa0, 0xbf, 0x8000, 0xffff, memory::cartrom, 0x100000);
|
||||
map(MapLinear, 0xc0, 0xef, 0x0000, 0xffff, bsxflash);
|
||||
map(MapLinear, 0xf0, 0xff, 0x0000, 0x7fff, memory::cartram, 0x000000);
|
||||
} break;
|
||||
|
||||
case Cartridge::BSCHiROM: {
|
||||
map(MapShadow, 0x00, 0x1f, 0x8000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0x20, 0x3f, 0x6000, 0x7fff, memory::cartram);
|
||||
map(MapShadow, 0x20, 0x3f, 0x8000, 0xffff, bsxflash);
|
||||
map(MapLinear, 0x40, 0x5f, 0x0000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0x60, 0x7f, 0x0000, 0xffff, bsxflash);
|
||||
map(MapShadow, 0x80, 0x9f, 0x8000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0xa0, 0xbf, 0x6000, 0x7fff, memory::cartram);
|
||||
map(MapShadow, 0xa0, 0xbf, 0x8000, 0xffff, bsxflash);
|
||||
map(MapLinear, 0xc0, 0xdf, 0x0000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0xe0, 0xff, 0x0000, 0xffff, bsxflash);
|
||||
} break;
|
||||
|
||||
case Cartridge::STROM: {
|
||||
map(MapLinear, 0x00, 0x1f, 0x8000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0x20, 0x3f, 0x8000, 0xffff, memory::stArom);
|
||||
map(MapLinear, 0x40, 0x5f, 0x8000, 0xffff, memory::stBrom);
|
||||
map(MapLinear, 0x60, 0x63, 0x8000, 0xffff, memory::stAram);
|
||||
map(MapLinear, 0x70, 0x73, 0x8000, 0xffff, memory::stBram);
|
||||
map(MapLinear, 0x80, 0x9f, 0x8000, 0xffff, memory::cartrom);
|
||||
map(MapLinear, 0xa0, 0xbf, 0x8000, 0xffff, memory::stArom);
|
||||
map(MapLinear, 0xc0, 0xdf, 0x8000, 0xffff, memory::stBrom);
|
||||
map(MapLinear, 0xe0, 0xe3, 0x8000, 0xffff, memory::stAram);
|
||||
map(MapLinear, 0xf0, 0xf3, 0x8000, 0xffff, memory::stBram);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void sBus::map_generic_sram() {
|
||||
if(memory::cartram.size() == 0 || memory::cartram.size() == -1U) { return; }
|
||||
|
||||
map(MapLinear, 0x20, 0x3f, 0x6000, 0x7fff, memory::cartram);
|
||||
map(MapLinear, 0xa0, 0xbf, 0x6000, 0x7fff, memory::cartram);
|
||||
|
||||
//research shows only games with very large ROM/RAM sizes require MAD-1 memory mapping of SRAM
|
||||
//otherwise, default to safer, larger SRAM address window
|
||||
uint16 addr_hi = (memory::cartrom.size() > 0x200000 || memory::cartram.size() > 32 * 1024) ? 0x7fff : 0xffff;
|
||||
map(MapLinear, 0x70, 0x7f, 0x0000, addr_hi, memory::cartram);
|
||||
if(cartridge.mapper() != Cartridge::LoROM) return;
|
||||
map(MapLinear, 0xf0, 0xff, 0x0000, addr_hi, memory::cartram);
|
||||
}
|
||||
|
||||
#endif
|
||||
21
tools/bsnes/memory/smemory/mapper/system.cpp
Executable file
21
tools/bsnes/memory/smemory/mapper/system.cpp
Executable file
@@ -0,0 +1,21 @@
|
||||
#ifdef SMEMORY_CPP
|
||||
|
||||
void sBus::map_reset() {
|
||||
for(uint32_t i = 0x0000; i <= 0xffff; i++)
|
||||
map(i << 8, memory::memory_unmapped, 0);
|
||||
|
||||
for(uint16_t i = 0x2000; i <= 0x5fff; i++)
|
||||
memory::mmio.map(i, memory::mmio_unmapped);
|
||||
}
|
||||
|
||||
void sBus::map_system() {
|
||||
map(MapDirect, 0x00, 0x3f, 0x2000, 0x5fff, memory::mmio);
|
||||
map(MapDirect, 0x80, 0xbf, 0x2000, 0x5fff, memory::mmio);
|
||||
|
||||
map(MapLinear, 0x00, 0x3f, 0x0000, 0x1fff, memory::wram, 0x000000, 0x002000);
|
||||
map(MapLinear, 0x80, 0xbf, 0x0000, 0x1fff, memory::wram, 0x000000, 0x002000);
|
||||
|
||||
map(MapLinear, 0x7e, 0x7f, 0x0000, 0xffff, memory::wram);
|
||||
}
|
||||
|
||||
#endif
|
||||
45
tools/bsnes/memory/smemory/smemory.cpp
Executable file
45
tools/bsnes/memory/smemory/smemory.cpp
Executable file
@@ -0,0 +1,45 @@
|
||||
#include <../base.hpp>
|
||||
#include <../chip/chip.hpp>
|
||||
#include <../cart/cart.hpp>
|
||||
#define SMEMORY_CPP
|
||||
|
||||
#include "mapper/system.cpp"
|
||||
#include "mapper/generic.cpp"
|
||||
#include "mapper/chip.cpp"
|
||||
|
||||
void sBus::power() {
|
||||
for(unsigned i = 0x2000; i <= 0x5fff; i++) memory::mmio.map(i, memory::mmio_unmapped);
|
||||
for(unsigned i = 0; i < memory::wram.size(); i++) memory::wram[i] = snes.config.cpu.wram_init_value;
|
||||
reset();
|
||||
}
|
||||
|
||||
void sBus::reset() {
|
||||
set_speed(false);
|
||||
}
|
||||
|
||||
bool sBus::load_cart() {
|
||||
if(cartridge.loaded() == true) return false;
|
||||
|
||||
map_reset();
|
||||
map_generic();
|
||||
map_system();
|
||||
|
||||
if(cartridge.has_cx4()) map_cx4();
|
||||
if(cartridge.has_dsp1()) map_dsp1();
|
||||
if(cartridge.has_dsp2()) map_dsp2();
|
||||
if(cartridge.has_dsp3()) map_dsp3();
|
||||
if(cartridge.has_dsp4()) map_dsp4();
|
||||
if(cartridge.has_obc1()) map_obc1();
|
||||
if(cartridge.has_st010()) map_st010();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void sBus::unload_cart() {
|
||||
}
|
||||
|
||||
sBus::sBus() {
|
||||
}
|
||||
|
||||
sBus::~sBus() {
|
||||
}
|
||||
25
tools/bsnes/memory/smemory/smemory.hpp
Executable file
25
tools/bsnes/memory/smemory/smemory.hpp
Executable file
@@ -0,0 +1,25 @@
|
||||
class sBus : public Bus {
|
||||
public:
|
||||
bool load_cart();
|
||||
void unload_cart();
|
||||
|
||||
void power();
|
||||
void reset();
|
||||
|
||||
sBus();
|
||||
~sBus();
|
||||
|
||||
private:
|
||||
void map_reset();
|
||||
void map_system();
|
||||
void map_generic();
|
||||
void map_generic_sram();
|
||||
|
||||
void map_cx4();
|
||||
void map_dsp1();
|
||||
void map_dsp2();
|
||||
void map_dsp3();
|
||||
void map_dsp4();
|
||||
void map_obc1();
|
||||
void map_st010();
|
||||
};
|
||||
Reference in New Issue
Block a user