Skip to content

Commit

Permalink
md: add realtec mapper support
Browse files Browse the repository at this point in the history
  • Loading branch information
invertego authored and LukeUsher committed Mar 6, 2023
1 parent ae9c3ae commit 1359f36
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions ares/md/cartridge/board/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Board {
#include "banked.cpp"
#include "svp.cpp"
#include "j-cart.cpp"
#include "realtec.cpp"
#include "game-genie.cpp"
#include "mega-32x.cpp"
#include "debugger.cpp"
Expand Down
38 changes: 38 additions & 0 deletions ares/md/cartridge/board/realtec.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
struct Realtec : Interface {
using Interface::Interface;
Memory::Readable<n16> rom;

auto load() -> void override {
Interface::load(rom, "program.rom");
}

auto read(n1 upper, n1 lower, n24 address, n16 data) -> n16 override {
if(address < size * 0x20000)
address = address + bank * 0x20000;
else
address = (address & 0x1fff) + 0x7e000;
return rom[address >> 1];
}

auto write(n1 upper, n1 lower, n24 address, n16 data) -> void override {
if(address == 0x400000 && upper)
bank.bit(3, 4) = data.bit(9, 10);
if(address == 0x402000 && upper)
size = data.bit(8, 13);
if(address == 0x404000 && upper)
bank.bit(0, 2) = data.bit(8, 10);
}

auto power(bool reset) -> void override {
bank = 0;
size = 0;
}

auto serialize(serializer& s) -> void override {
s(bank);
s(size);
}

n5 bank;
n5 size;
};
2 changes: 2 additions & 0 deletions ares/md/cartridge/cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ auto Cartridge::connect() -> void {
board = new Board::GameGenie(*this);
} else if(pak->attribute("jcart").boolean()) {
board = new Board::JCart(*this);
} else if(pak->attribute("board") == "REALTEC") {
board = new Board::Realtec(*this);
} else {
board = new Board::Standard(*this);
}
Expand Down
29 changes: 29 additions & 0 deletions mia/medium/mega-drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ struct MegaDrive : Cartridge {
auto analyzePeripherals(vector<u8>& rom, string hash) -> void;
auto analyzeCopyProtection(vector<u8>& rom, string hash) -> void;

string board;

struct RAM {
explicit operator bool() const { return mode && size != 0; }

Expand Down Expand Up @@ -50,6 +52,7 @@ auto MegaDrive::load(string location) -> bool {
pak = new vfs::directory;
pak->setAttribute("title", document["game/title"].string());
pak->setAttribute("region", document["game/region"].string());
pak->setAttribute("board", document["game/board"].string());
pak->setAttribute("bootable", true);
pak->setAttribute("megacd", (bool)document["game/device"].string().split(", ").find("Mega CD"));
pak->append("manifest.bml", manifest);
Expand Down Expand Up @@ -115,6 +118,7 @@ auto MegaDrive::save(string location) -> bool {
auto MegaDrive::analyze(vector<u8>& rom) -> string {
if(rom.size() < 0x800) return {};

board = {};
ram = {};
eeprom = {};
peripherals = {};
Expand Down Expand Up @@ -208,6 +212,8 @@ auto MegaDrive::analyze(vector<u8>& rom) -> string {
s +={" region: ", regions.merge(", "), "\n"};
if(devices)
s +={" device: ", devices.merge(", "), "\n"};
if(board)
s +={" board: ", board, "\n"};
s += " board\n";

if(domesticName == "Game Genie") {
Expand Down Expand Up @@ -755,6 +761,29 @@ auto MegaDrive::analyzeStorage(vector<u8>& rom, string hash) -> void {
eeprom.wsda = 0;
eeprom.wscl = 8;
}

//REALTEC
//======

//Earth Defense ~ Earth Defend, The (USA, Taiwan) (En) (Unl)
if(hash == "2552a6fd12772f650dd91b8a6686d1d423ccde640bb728611f3b6d8c74696e98") {
board = "REALTEC";
}

//Funny World & Balloon Boy (USA) (Unl)
if(hash == "8f36a8ea96bbb09f8d4a2d7efb77a3c3da9a69e14c8a714b40bcdb856da2ef97") {
board = "REALTEC";
}

//Mallet Legend's Whac-a-Critter ~ Mallet Legend (USA, Taiwan) (En) (Unl)
if(hash == "0e137267121d63408562dac226f692b70a5399e2e6d359b3e0e570ca011e16a0") {
board = "REALTEC";
}

//Tom Clown (Taiwan) (En) (Unl)
if(hash == "b04b9a1f4b17ec5251857cf0a689f442229eecadba96adc405b84343c36ad0db") {
board = "REALTEC";
}
}

auto MegaDrive::analyzePeripherals(vector<u8>& rom, string hash) -> void {
Expand Down

0 comments on commit 1359f36

Please sign in to comment.