forked from higan-emu/higan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Nintendo 64: emulation core started
- Loading branch information
byuu
committed
Apr 28, 2020
1 parent
470c2ec
commit c43fc28
Showing
46 changed files
with
759 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
auto VR4300::serialize(serializer& s) -> void { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <ares/ares.hpp> | ||
#include "vr4300.hpp" | ||
|
||
namespace ares { | ||
|
||
#include "serialization.cpp" | ||
|
||
auto VR4300::power() -> void { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
//NEC VR4300 | ||
|
||
namespace ares { | ||
|
||
struct VR4300 { | ||
//vr4300.cpp | ||
auto power() -> void; | ||
|
||
//serialization.cpp | ||
auto serialize(serializer&) -> void; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
ares.components += vr4300 | ||
|
||
ares.objects += ares-n64-interface ares-n64-system | ||
ares.objects += ares-n64-cartridge ares-n64-controller | ||
ares.objects += ares-n64-cpu ares-n64-rdp ares-n64-rsp | ||
|
||
$(object.path)/ares-n64-interface.o: $(ares.path)/n64/interface/interface.cpp | ||
$(object.path)/ares-n64-system.o: $(ares.path)/n64/system/system.cpp | ||
$(object.path)/ares-n64-cartridge.o: $(ares.path)/n64/cartridge/cartridge.cpp | ||
$(object.path)/ares-n64-controller.o: $(ares.path)/n64/controller/controller.cpp | ||
$(object.path)/ares-n64-cpu.o: $(ares.path)/n64/cpu/cpu.cpp | ||
$(object.path)/ares-n64-rdp.o: $(ares.path)/n64/rdp/rdp.cpp | ||
$(object.path)/ares-n64-rsp.o: $(ares.path)/n64/rsp/rsp.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <n64/n64.hpp> | ||
|
||
namespace ares::Nintendo64 { | ||
|
||
Cartridge& cartridge = cartridgeSlot.cartridge; | ||
#include "slot.cpp" | ||
#include "serialization.cpp" | ||
|
||
auto Cartridge::allocate(Node::Port parent) -> Node::Peripheral { | ||
return node = parent->append<Node::Peripheral>(interface->name()); | ||
} | ||
|
||
auto Cartridge::connect() -> void { | ||
node->setManifest([&] { return information.manifest; }); | ||
|
||
information = {}; | ||
|
||
if(auto fp = platform->open(node, "manifest.bml", File::Read, File::Required)) { | ||
information.manifest = fp->reads(); | ||
} | ||
|
||
auto document = BML::unserialize(information.manifest); | ||
information.name = document["game/label"].string(); | ||
|
||
if(auto memory = document["game/board/memory(type=ROM,content=Program)"]) { | ||
rom.allocate(memory["size"].natural()); | ||
if(auto fp = platform->open(node, "program.rom", File::Read, File::Required)) { | ||
rom.load(fp); | ||
} | ||
} | ||
|
||
power(); | ||
} | ||
|
||
auto Cartridge::disconnect() -> void { | ||
if(!node) return; | ||
save(); | ||
node = {}; | ||
} | ||
|
||
auto Cartridge::save() -> void { | ||
if(!node) return; | ||
auto document = BML::unserialize(information.manifest); | ||
} | ||
|
||
auto Cartridge::power() -> void { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
struct Cartridge { | ||
Node::Peripheral node; | ||
Memory::Readable<uint8> rom; | ||
|
||
auto manifest() const -> string { return information.manifest; } | ||
auto name() const -> string { return information.name; } | ||
|
||
//cartridge.cpp | ||
auto allocate(Node::Port) -> Node::Peripheral; | ||
auto connect() -> void; | ||
auto disconnect() -> void; | ||
|
||
auto save() -> void; | ||
auto power() -> void; | ||
|
||
//serialization.cpp | ||
auto serialize(serializer&) -> void; | ||
|
||
private: | ||
struct Information { | ||
string manifest; | ||
string name; | ||
} information; | ||
}; | ||
|
||
#include "slot.hpp" | ||
extern Cartridge& cartridge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
auto Cartridge::serialize(serializer& s) -> void { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CartridgeSlot cartridgeSlot{"Cartridge Slot"}; | ||
|
||
CartridgeSlot::CartridgeSlot(string name) : name(name) { | ||
} | ||
|
||
auto CartridgeSlot::load(Node::Object parent) -> void { | ||
port = parent->append<Node::Port>(name); | ||
port->setFamily(interface->name()); | ||
port->setType("Cartridge"); | ||
port->setAllocate([&](auto name) { return cartridge.allocate(port); }); | ||
port->setConnect([&] { return cartridge.connect(); }); | ||
port->setDisconnect([&] { return cartridge.disconnect(); }); | ||
} | ||
|
||
auto CartridgeSlot::unload() -> void { | ||
cartridge.disconnect(); | ||
port = {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
struct CartridgeSlot { | ||
Node::Port port; | ||
Cartridge cartridge; | ||
|
||
//slot.cpp | ||
CartridgeSlot(string name); | ||
auto load(Node::Object) -> void; | ||
auto unload() -> void; | ||
|
||
const string name; | ||
}; | ||
|
||
extern CartridgeSlot cartridgeSlot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <n64/n64.hpp> | ||
|
||
namespace ares::Nintendo64 { | ||
|
||
#include "port.cpp" | ||
#include "gamepad/gamepad.cpp" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
struct Controller { | ||
Node::Peripheral node; | ||
|
||
virtual ~Controller() = default; | ||
}; | ||
|
||
#include "port.hpp" | ||
#include "gamepad/gamepad.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Gamepad::Gamepad(Node::Port parent) { | ||
node = parent->append<Node::Peripheral>("Gamepad"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
struct Gamepad : Controller { | ||
Gamepad(Node::Port); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
ControllerPort controllerPort1{"Controller Port 1"}; | ||
ControllerPort controllerPort2{"Controller Port 2"}; | ||
ControllerPort controllerPort3{"Controller Port 3"}; | ||
ControllerPort controllerPort4{"Controller Port 4"}; | ||
|
||
ControllerPort::ControllerPort(string name) : name(name) { | ||
} | ||
|
||
auto ControllerPort::load(Node::Object parent) -> void { | ||
port = parent->append<Node::Port>(name); | ||
port->setFamily("Nintendo 64"); | ||
port->setType("Controller"); | ||
port->setHotSwappable(true); | ||
port->setAllocate([&](auto name) { return allocate(name); }); | ||
} | ||
|
||
auto ControllerPort::unload() -> void { | ||
device = {}; | ||
port = {}; | ||
} | ||
|
||
auto ControllerPort::allocate(string name) -> Node::Peripheral { | ||
if(name == "Gamepad") device = new Gamepad(port); | ||
if(device) return device->node; | ||
return {}; | ||
} | ||
|
||
auto ControllerPort::serialize(serializer& s) -> void { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
struct ControllerPort { | ||
Node::Port port; | ||
unique_pointer<Controller> device; | ||
|
||
//port.cpp | ||
ControllerPort(string name); | ||
auto load(Node::Object) -> void; | ||
auto unload() -> void; | ||
auto allocate(string name) -> Node::Peripheral; | ||
|
||
auto serialize(serializer&) -> void; | ||
|
||
const string name; | ||
}; | ||
|
||
extern ControllerPort controllerPort1; | ||
extern ControllerPort controllerPort2; | ||
extern ControllerPort controllerPort3; | ||
extern ControllerPort controllerPort4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <n64/n64.hpp> | ||
|
||
namespace ares::Nintendo64 { | ||
|
||
CPU cpu; | ||
#include "serialization.cpp" | ||
|
||
auto CPU::load(Node::Object parent) -> void { | ||
node = parent->append<Node::Component>("CPU"); | ||
} | ||
|
||
auto CPU::unload() -> void { | ||
node = {}; | ||
} | ||
|
||
auto CPU::main() -> void { | ||
step(20); | ||
} | ||
|
||
auto CPU::step(uint clocks) -> void { | ||
Thread::step(clocks); | ||
Thread::synchronize(); | ||
} | ||
|
||
auto CPU::power() -> void { | ||
VR4300::power(); | ||
Thread::create(93'750'000, {&CPU::main, this}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//NEC VR4300 | ||
|
||
struct CPU : VR4300, Thread { | ||
Node::Component node; | ||
|
||
//cpu.cpp | ||
auto load(Node::Object) -> void; | ||
auto unload() -> void; | ||
|
||
auto main() -> void; | ||
auto step(uint clocks) -> void; | ||
|
||
auto power() -> void; | ||
|
||
//serialization.cpp | ||
auto serialize(serializer&) -> void; | ||
}; | ||
|
||
extern CPU cpu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
auto CPU::serialize(serializer& s) -> void { | ||
VR4300::serialize(s); | ||
Thread::serialize(s); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <n64/n64.hpp> | ||
|
||
namespace ares::Nintendo64 { | ||
|
||
Interface* interface = nullptr; | ||
|
||
auto Nintendo64Interface::game() -> string { | ||
if(cartridge.node) { | ||
return cartridge.name(); | ||
} | ||
|
||
return "(no cartridge connected)"; | ||
} | ||
|
||
auto Nintendo64Interface::root() -> Node::Object { | ||
return system.node; | ||
} | ||
|
||
auto Nintendo64Interface::load(Node::Object& root) -> void { | ||
interface = this; | ||
system.load(root); | ||
} | ||
|
||
auto Nintendo64Interface::unload() -> void { | ||
system.unload(); | ||
} | ||
|
||
auto Nintendo64Interface::save() -> void { | ||
system.save(); | ||
} | ||
|
||
auto Nintendo64Interface::power() -> void { | ||
system.power(false); | ||
} | ||
|
||
auto Nintendo64Interface::run() -> void { | ||
system.run(); | ||
} | ||
|
||
auto Nintendo64Interface::serialize(bool synchronize) -> serializer { | ||
return system.serialize(synchronize); | ||
} | ||
|
||
auto Nintendo64Interface::unserialize(serializer& s) -> bool { | ||
return system.unserialize(s); | ||
} | ||
|
||
} |
Oops, something went wrong.