Skip to content

Commit

Permalink
Update to ares v118r04 release.
Browse files Browse the repository at this point in the history
This WIP has the new mia system. It's a pretty massive change ... I hope it will
go okay for you. Feel free to ping me and I'll walk you through it.

Essentially, we want to edit mia/system/neo-geo-(aes|mvs).cpp to load in the
necessary files from MAME's neogeo.zip that is given to it (I have a helper
Pak::read(zipfile, pattern) function to grab files out of the archive for you
into a vector<u8>), do endian conversion, add to the pak, then the Neo Geo core
can see it.

The Neo Geo cartridge support should be enough for Magician Lord and super early
games with no mappers or crypto, so we'll start there and work our way up.
  • Loading branch information
near-san committed Mar 7, 2021
1 parent 007b277 commit a38a31e
Show file tree
Hide file tree
Showing 186 changed files with 9,104 additions and 7,092 deletions.
13 changes: 12 additions & 1 deletion ares/ares/ares.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
using namespace nall;

namespace ares {
static const string Name = "ares";
static const string Version = "118.4";
static const string Copyright = "Near";
static const string License = "CC BY-NC-ND 4.0";
static const string LicenseURI = "https://creativecommons.org/licenses/by-nc-nd/4.0/";
static const string Website = "ares.dev";
static const string WebsiteURI = "https://ares.dev";

//incremented only when serialization format changes
static const u32 SerializerSignature = 0x31545342; //"BST1" (little-endian)
static const string SerializerVersion = "118";

namespace VFS {
using Pak = shared_pointer<vfs::directory>;
using File = shared_pointer<vfs::file>;
Expand All @@ -56,7 +68,6 @@ namespace ares {
inline auto setRunAhead(bool runAhead) -> void { _runAhead = runAhead; }
}

#include <ares/information.hpp>
#include <ares/types.hpp>
#include <ares/random.hpp>
#include <ares/debug/debug.hpp>
Expand Down
15 changes: 0 additions & 15 deletions ares/ares/information.hpp

This file was deleted.

4 changes: 2 additions & 2 deletions ares/gb/system/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ auto System::unload() -> void {
auto System::power(bool reset) -> void {
for(auto& setting : node->find<Node::Setting::Setting>()) setting->setLatch();

string name = "boot.rom"; //fallback name (should not be used)
string name = "boot.rom";

if(GameBoy::Model::GameBoy()) {
bootROM.allocate(256);
Expand All @@ -130,7 +130,7 @@ auto System::power(bool reset) -> void {
if(cpu.version->latch() == "CPU CGB E" ) name = "boot.cgb-1.rom";
}

if(auto fp = pak->read(name)) {
if(auto fp = pak->read(!GameBoy::Model::SuperGameBoy() ? "boot.rom" : "sm83.boot.rom")) {
bootROM.load(fp);

if(fastBoot->latch()) {
Expand Down
2 changes: 1 addition & 1 deletion ares/md/cartridge/board/game-genie.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
struct GameGenie : Interface {
using Interface::Interface;
Memory::Readable<n16> rom;
CartridgeSlot slot{"Cartridge Slot"};
CartridgeSlot slot{"Cartridge Slot", "Cartridge"};

auto load() -> void override {
Interface::load(rom, "program.rom");
Expand Down
2 changes: 1 addition & 1 deletion ares/md/cartridge/board/lock-on.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ struct LockOn : Interface {
using Interface::Interface;
Memory::Readable<n16> rom;
Memory::Readable<n16> patch;
CartridgeSlot slot{"Cartridge Slot"};
CartridgeSlot slot{"Cartridge Slot", "Cartridge"};

auto load() -> void override {
Interface::load(rom, "program.rom");
Expand Down
12 changes: 11 additions & 1 deletion ares/md/cartridge/cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace ares::MegaDrive {

Cartridge& cartridge = cartridgeSlot.cartridge;
Cartridge& expansion = expansionSlot.cartridge;
#include "board/board.cpp"
#include "slot.cpp"
#include "serialization.cpp"

auto Cartridge::allocate(Node::Port parent) -> Node::Peripheral {
return node = parent->append<Node::Peripheral>("Mega Drive Cartridge");
return node = parent->append<Node::Peripheral>(string{"Mega Drive ", parent->type()});
}

auto Cartridge::connect() -> void {
Expand All @@ -30,6 +31,11 @@ auto Cartridge::connect() -> void {
}
board->pak = pak;
board->load();

if(auto fp = pak->read("backup.ram")) {
mcd.bram.load(fp);
}

power();
}

Expand All @@ -45,6 +51,10 @@ auto Cartridge::disconnect() -> void {
auto Cartridge::save() -> void {
if(!node) return;
board->save();

if(auto fp = pak->write("backup.ram")) {
mcd.bram.save(fp);
}
}

auto Cartridge::power() -> void {
Expand Down
1 change: 1 addition & 0 deletions ares/md/cartridge/cartridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ struct Cartridge {

#include "slot.hpp"
extern Cartridge& cartridge;
extern Cartridge& expansion;
7 changes: 4 additions & 3 deletions ares/md/cartridge/slot.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
CartridgeSlot cartridgeSlot{"Cartridge Slot"};
CartridgeSlot cartridgeSlot{"Cartridge Slot", "Cartridge"};
CartridgeSlot expansionSlot{"Expansion Slot", "Expansion"};

CartridgeSlot::CartridgeSlot(string name) : name(name) {
CartridgeSlot::CartridgeSlot(string name, string type) : name(name), type(type) {
}

auto CartridgeSlot::load(Node::Object parent) -> void {
port = parent->append<Node::Port>(name);
port->setFamily("Mega Drive");
port->setType("Cartridge");
port->setType(type);
port->setAllocate([&](auto name) { return cartridge.allocate(port); });
port->setConnect([&] { return cartridge.connect(); });
port->setDisconnect([&] { return cartridge.disconnect(); });
Expand Down
4 changes: 3 additions & 1 deletion ares/md/cartridge/slot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ struct CartridgeSlot {
auto connected() const -> bool { return (bool)cartridge.node; }

//slot.cpp
CartridgeSlot(string name);
CartridgeSlot(string name, string type);
auto load(Node::Object) -> void;
auto unload() -> void;

const string name;
const string type;
};

extern CartridgeSlot cartridgeSlot;
extern CartridgeSlot expansionSlot;
2 changes: 1 addition & 1 deletion ares/md/mcd/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ auto MCD::writeIO(n1 upper, n1 lower, n24 address, n16 data) -> void {
io.wramSelect = data.bit(0);
io.wramMode = data.bit(2);
io.wramPriority = data.bit(3,4);
io.wramSwitch = 0;
if(io.wramSelect) io.wramSwitch = 0;
}
}

Expand Down
9 changes: 1 addition & 8 deletions ares/md/mcd/mcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ auto MCD::connect() -> void {

fd = pak->read("cd.rom");
cdd.insert();

if(auto fp = system.pak->read("backup.ram")) {
bram.load(fp);
}
}

auto MCD::disconnect() -> void {
Expand All @@ -90,9 +86,6 @@ auto MCD::disconnect() -> void {
}

auto MCD::save() -> void {
if(auto fp = system.pak->write("backup.ram")) {
bram.save(fp);
}
}

auto MCD::main() -> void {
Expand Down Expand Up @@ -171,7 +164,7 @@ auto MCD::wait(u32 clocks) -> void {
}

auto MCD::power(bool reset) -> void {
if(auto fp = system.pak->read("bios.rom")) {
if(auto fp = expansion.pak->read("bios.rom")) {
for(u32 address : range(bios.size())) bios.program(address, fp->readm(2));
}

Expand Down
1 change: 1 addition & 0 deletions ares/md/system/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ auto System::unserialize(serializer& s) -> bool {
auto System::serialize(serializer& s, bool synchronize) -> void {
scheduler.setSynchronize(synchronize);
if(cartridge.node) s(cartridge);
if(expansion.node) s(expansion);
if(MegaCD()) s(mcd);
s(cpu);
s(apu);
Expand Down
5 changes: 4 additions & 1 deletion ares/md/system/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ auto System::load(Node::System& root, string name) -> bool {
psg.load(node);
opn2.load(node);
cartridgeSlot.load(node);
expansionSlot.load(node);
if(MegaCD()) mcd.load(node);
controllerPort1.load(node);
controllerPort2.load(node);
Expand All @@ -112,8 +113,9 @@ auto System::unload() -> void {
vdp.unload();
psg.unload();
opn2.unload();
cartridgeSlot.unload();
if(MegaCD()) mcd.unload();
cartridgeSlot.unload();
expansionSlot.unload();
controllerPort1.unload();
controllerPort2.unload();
extensionPort.unload();
Expand All @@ -133,6 +135,7 @@ auto System::power(bool reset) -> void {
random.entropy(Random::Entropy::Low);

if(cartridge.node) cartridge.power();
if(expansion.node) expansion.power();
if(MegaCD()) mcd.power(reset);
cpu.power(reset);
apu.power(reset);
Expand Down
27 changes: 24 additions & 3 deletions ares/n64/si/si.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,18 @@ auto SI::main() -> void {
}
valid = 1;
}
if(channel >= 4 && send == 1 && recv == 3 && cartridge.eeprom) {
if(channel >= 4 && send == 1 && recv == 3 && cartridge.eeprom.size == 512) {
output[0] = 0x00;
output[1] = 0x80;
output[2] = 0x00;
valid = 1;
}
if(channel >= 4 && send == 1 && recv == 3 && cartridge.eeprom.size == 2048) {
output[0] = 0x00;
output[1] = 0xc0;
output[2] = 0x00;
valid = 1;
}
}
if(input[0] == 0x01) {
//read controller state
Expand Down Expand Up @@ -186,24 +192,39 @@ auto SI::main() -> void {
}
if(input[0] == 0x04) {
//read EEPROM
if(cartridge.eeprom && send == 2 && recv == 8) {
if(send == 2 && recv == 8 && cartridge.eeprom.size == 512) {
u32 address = input[1] * 8;
for(u32 index : range(8)) {
output[index] = cartridge.eeprom.readByte(address++);
}
valid = 1;
}
if(send == 2 && recv == 32 && cartridge.eeprom.size == 2048) {
u32 address = input[1] * 32;
for(u32 index : range(32)) {
output[index] = cartridge.eeprom.readByte(address++);
}
valid = 1;
}
}
if(input[0] == 0x05) {
//write EEPROM
if(cartridge.eeprom && recv == 1 && send == 10) {
if(recv == 1 && send == 10 && cartridge.eeprom.size == 512) {
u32 address = input[1] * 8;
for(u32 index : range(8)) {
cartridge.eeprom.writeByte(address++, input[2 + index]);
}
output[0] = 0x00;
valid = 1;
}
if(recv == 1 && send == 34 && cartridge.eeprom.size == 2048) {
u32 address = input[1] * 32;
for(u32 index : range(32)) {
cartridge.eeprom.writeByte(address++, input[2 + index]);
}
output[0] = 0x00;
valid = 1;
}
}
if(!valid) {
pi.ram.writeByte(recvOffset, 0x80 | recv & 0x3f);
Expand Down
9 changes: 0 additions & 9 deletions ares/pce/cartridge/cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ auto Cartridge::connect() -> void {
if(!board) board = new Board::Interface{*this};
board->pak = pak;
board->load();

if(auto fp = pak->read("backup.ram")) {
pcd.bram.load(fp);
}

power();
}

Expand All @@ -49,10 +44,6 @@ auto Cartridge::disconnect() -> void {
auto Cartridge::save() -> void {
if(!node) return;
board->save();

if(auto fp = pak->write("backup.ram")) {
pcd.bram.save(fp);
}
}

auto Cartridge::power() -> void {
Expand Down
2 changes: 1 addition & 1 deletion ares/sfc/ppu-performance/background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ auto PPU::Background::render() -> void {
u32 tileNumber = getTile(hoffset, voffset);
u32 mirrorY = tileNumber & 0x8000 ? 7 : 0;
u32 mirrorX = tileNumber & 0x4000 ? 7 : 0;
n8 tilePriority = io.priority[bool(tileNumber & 0x2000)];
u8 tilePriority = io.priority[bool(tileNumber & 0x2000)];
u32 paletteNumber = tileNumber >> 10 & 7;
u32 paletteIndex = paletteBase + (paletteNumber << paletteShift) & 0xff;

Expand Down
2 changes: 1 addition & 1 deletion ares/sfc/ppu-performance/ppu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ auto PPU::main() -> void {
u32 width = hires() ? 512 : 256;
if(width == 256) width256 = 1;
if(width == 512) width512 = 1;
widths[vcounter()] = width;
widths[vcounter() + !state.overscan * 8] = width;

step(renderingCycle);
mosaic.scanline();
Expand Down
2 changes: 1 addition & 1 deletion ares/sfc/system/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ auto System::load(Node::System& root, string name) -> bool {
information.name = "Super Famicom";
}
if(name.find("Super Nintendo")) {
information.name = "Super Nintendo";
information.name = "Super Famicom";
}
if(name.find("NTSC")) {
information.region = Region::NTSC;
Expand Down
22 changes: 17 additions & 5 deletions hiro/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ ifeq ($(platform),windows)
endif

ifeq ($(hiro),gtk2)
hiro.flags = $(flags.cpp) -DHIRO_GTK=2 $(shell pkg-config --cflags gtk+-2.0 gtksourceview-2.0)
hiro.options = $(shell pkg-config --libs gtk+-2.0 gtksourceview-2.0)
hiro.flags = $(flags.cpp) -DHIRO_GTK=2 $(shell pkg-config --cflags gtk+-2.0) -Wno-deprecated-declarations
hiro.options = $(shell pkg-config --libs gtk+-2.0)
endif

ifeq ($(hiro),gtk3)
hiro.flags = $(flags.cpp) -DHIRO_GTK=3 $(shell pkg-config --cflags gtk+-3.0 gtksourceview-3.0) -Wno-deprecated-declarations
hiro.options = $(shell pkg-config --libs gtk+-3.0 gtksourceview-3.0)
hiro.flags = $(flags.cpp) -DHIRO_GTK=3 $(shell pkg-config --cflags gtk+-3.0) -Wno-deprecated-declarations
hiro.options = $(shell pkg-config --libs gtk+-3.0)
endif
endif

Expand All @@ -36,11 +36,23 @@ ifneq ($(filter $(platform),linux bsd),)
endif

ifeq ($(hiro),gtk2)
hiro.flags = $(flags.cpp) -DHIRO_GTK=2 $(shell pkg-config --cflags gtk+-2.0 gtksourceview-2.0)
hiro.flags = $(flags.cpp) -DHIRO_GTK=2 $(shell pkg-config --cflags gtk+-2.0) -Wno-deprecated-declarations
hiro.options = -L/usr/local/lib -lX11 $(shell pkg-config --libs gtk+-2.0)
endif

ifeq ($(hiro),gtk2-se)
flags += -DHiro_SourceEdit
hiro.flags = $(flags.cpp) -DHIRO_GTK=2 $(shell pkg-config --cflags gtk+-2.0 gtksourceview-2.0) -Wno-deprecated-declarations
hiro.options = -L/usr/local/lib -lX11 $(shell pkg-config --libs gtk+-2.0 gtksourceview-2.0)
endif

ifeq ($(hiro),gtk3)
hiro.flags = $(flags.cpp) -DHIRO_GTK=3 $(shell pkg-config --cflags gtk+-3.0) -Wno-deprecated-declarations
hiro.options = -L/usr/local/lib -lX11 $(shell pkg-config --libs gtk+-3.0)
endif

ifeq ($(hiro),gtk3-se)
flags += -DHiro_SourceEdit
hiro.flags = $(flags.cpp) -DHIRO_GTK=3 $(shell pkg-config --cflags gtk+-3.0 gtksourceview-3.0) -Wno-deprecated-declarations
hiro.options = -L/usr/local/lib -lX11 $(shell pkg-config --libs gtk+-3.0 gtksourceview-3.0)
endif
Expand Down
2 changes: 1 addition & 1 deletion hiro/components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#define Hiro_ProgressBar
#define Hiro_RadioButton
#define Hiro_RadioLabel
#define Hiro_SourceEdit
//#define Hiro_SourceEdit //added via GNUmakefile
#define Hiro_TabFrame
#define Hiro_TableView
#define Hiro_TextEdit
Expand Down
Loading

0 comments on commit a38a31e

Please sign in to comment.