things
This commit is contained in:
2
external/unarr
vendored
2
external/unarr
vendored
Submodule external/unarr updated: 569ffdb063...c5f9423568
@@ -2,46 +2,49 @@
|
|||||||
#include <Scheduler.hpp>
|
#include <Scheduler.hpp>
|
||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
Core::Core() : cpu{new Interpreter} {
|
Core::Core() {
|
||||||
if(SDL_GameControllerAddMappingsFromFile("resources/gamecontrollerdb.txt") < 0) {
|
if(SDL_GameControllerAddMappingsFromFile("resources/gamecontrollerdb.txt") < 0) {
|
||||||
Util::warn("Failed to load game controller DB");
|
Util::warn("Failed to load game controller DB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Stop() {
|
void Core::Stop() {
|
||||||
cpu->Reset();
|
cpu.Reset();
|
||||||
cpu->mem.Reset();
|
cpu.mem.Reset();
|
||||||
pause = true;
|
pause = true;
|
||||||
romLoaded = false;
|
romLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::LoadROM(const std::string& rom_) {
|
void Core::LoadROM(const std::string& rom_) {
|
||||||
rom = rom_;
|
rom = rom_;
|
||||||
cpu->Reset();
|
cpu.Reset();
|
||||||
pause = false;
|
pause = false;
|
||||||
romLoaded = true;
|
romLoaded = true;
|
||||||
|
|
||||||
auto extension = fs::path(rom).extension().string();
|
auto extension = fs::path(rom).extension().string();
|
||||||
|
bool isArchive = false;
|
||||||
|
for(const auto i : ARCHIVE_TYPES) {
|
||||||
|
if(extension == i) {
|
||||||
|
isArchive = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool isArchive = std::any_of(std::begin(ARCHIVE_TYPES), std::end(ARCHIVE_TYPES), [&](auto i) {
|
cpu.mem.LoadROM(isArchive, rom);
|
||||||
return extension == i;
|
GameDB::match(cpu.mem);
|
||||||
});
|
cpu.mem.mmio.vi.isPal = cpu.mem.IsROMPAL();
|
||||||
|
cpu.mem.mmio.si.pif.InitDevices(cpu.mem.saveType);
|
||||||
cpu->mem.LoadROM(isArchive, rom);
|
cpu.mem.mmio.si.pif.LoadMempak(rom);
|
||||||
GameDB::match(cpu->mem);
|
cpu.mem.mmio.si.pif.LoadEeprom(cpu.mem.saveType, rom);
|
||||||
cpu->mem.mmio.vi.isPal = cpu->mem.IsROMPAL();
|
cpu.mem.flash.Load(cpu.mem.saveType, rom);
|
||||||
cpu->mem.mmio.si.pif.InitDevices(cpu->mem.saveType);
|
cpu.mem.LoadSRAM(cpu.mem.saveType, rom);
|
||||||
cpu->mem.mmio.si.pif.LoadMempak(rom);
|
PIF::ExecutePIF(cpu.mem, cpu.regs);
|
||||||
cpu->mem.mmio.si.pif.LoadEeprom(cpu->mem.saveType, rom);
|
|
||||||
cpu->mem.flash.Load(cpu->mem.saveType, rom);
|
|
||||||
cpu->mem.LoadSRAM(cpu->mem.saveType, rom);
|
|
||||||
PIF::ExecutePIF(cpu->mem, cpu->regs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Run(float volumeL, float volumeR) {
|
void Core::Run(float volumeL, float volumeR) {
|
||||||
Mem& mem = cpu->mem;
|
Mem& mem = cpu.mem;
|
||||||
MMIO& mmio = mem.mmio;
|
MMIO& mmio = mem.mmio;
|
||||||
Registers& regs = cpu->regs;
|
Registers& regs = cpu.regs;
|
||||||
|
|
||||||
for (int field = 0; field < mmio.vi.numFields; field++) {
|
for (int field = 0; field < mmio.vi.numFields; field++) {
|
||||||
int frameCycles = 0;
|
int frameCycles = 0;
|
||||||
@@ -53,7 +56,7 @@ void Core::Run(float volumeL, float volumeR) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(; cycles < mem.mmio.vi.cyclesPerHalfline; cycles++, frameCycles++) {
|
for(; cycles < mem.mmio.vi.cyclesPerHalfline; cycles++, frameCycles++) {
|
||||||
int taken = cpu->Step();
|
int taken = cpu.Step();
|
||||||
static int cpuSteps = 0;
|
static int cpuSteps = 0;
|
||||||
cpuSteps += taken;
|
cpuSteps += taken;
|
||||||
if(mmio.rsp.spStatus.halt) {
|
if(mmio.rsp.spStatus.halt) {
|
||||||
@@ -83,7 +86,7 @@ void Core::Run(float volumeL, float volumeR) {
|
|||||||
InterruptRaise(mmio.mi, regs, Interrupt::VI);
|
InterruptRaise(mmio.mi, regs, Interrupt::VI);
|
||||||
}
|
}
|
||||||
|
|
||||||
mmio.ai.Step(cpu->mem, regs, frameCycles, volumeL, volumeR);
|
mmio.ai.Step(cpu.mem, regs, frameCycles, volumeL, volumeR);
|
||||||
scheduler.tick(frameCycles, mem, regs);
|
scheduler.tick(frameCycles, mem, regs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ struct Window;
|
|||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
struct Core {
|
struct Core {
|
||||||
~Core() { Stop(); delete cpu; }
|
~Core() { Stop(); }
|
||||||
Core();
|
Core();
|
||||||
void Stop();
|
void Stop();
|
||||||
void LoadROM(const std::string&);
|
void LoadROM(const std::string&);
|
||||||
void Run(float volumeL, float volumeR);
|
void Run(float volumeL, float volumeR);
|
||||||
void TogglePause() { pause = !pause; }
|
void TogglePause() { pause = !pause; }
|
||||||
[[nodiscard]] VI& GetVI() const { return cpu->mem.mmio.vi; }
|
[[nodiscard]] VI& GetVI() { return cpu.mem.mmio.vi; }
|
||||||
|
|
||||||
u32 breakpoint = 0;
|
u32 breakpoint = 0;
|
||||||
|
|
||||||
@@ -22,6 +22,6 @@ struct Core {
|
|||||||
int cycles = 0;
|
int cycles = 0;
|
||||||
bool romLoaded = false;
|
bool romLoaded = false;
|
||||||
std::string rom;
|
std::string rom;
|
||||||
Interpreter* cpu = nullptr;
|
Interpreter cpu;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ App::App() : window(core) {
|
|||||||
|
|
||||||
void App::Run() {
|
void App::Run() {
|
||||||
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||||
n64::SI& si = core.cpu->mem.mmio.si;
|
n64::SI& si = core.cpu.mem.mmio.si;
|
||||||
|
|
||||||
while (!window.done) {
|
while (!window.done) {
|
||||||
if(core.romLoaded) {
|
if(core.romLoaded) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace fs = std::filesystem;
|
|||||||
|
|
||||||
Window::Window(n64::Core& core) : settings() {
|
Window::Window(n64::Core& core) : settings() {
|
||||||
InitSDL();
|
InitSDL();
|
||||||
InitParallelRDP(core.cpu->mem.GetRDRAM(), window);
|
InitParallelRDP(core.cpu.mem.GetRDRAM(), window);
|
||||||
InitImgui();
|
InitImgui();
|
||||||
NFD::Init();
|
NFD::Init();
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ ImDrawData* Window::Present(n64::Core& core) {
|
|||||||
void Window::LoadROM(n64::Core& core, const std::string &path) {
|
void Window::LoadROM(n64::Core& core, const std::string &path) {
|
||||||
if(!path.empty()) {
|
if(!path.empty()) {
|
||||||
core.LoadROM(path);
|
core.LoadROM(path);
|
||||||
gameName = core.cpu->mem.rom.gameNameDB;
|
gameName = core.cpu.mem.rom.gameNameDB;
|
||||||
|
|
||||||
if(gameName.empty()) {
|
if(gameName.empty()) {
|
||||||
gameName = fs::path(path).stem().string();
|
gameName = fs::path(path).stem().string();
|
||||||
@@ -181,13 +181,13 @@ void Window::RenderMainMenuBar(n64::Core &core) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem("Dump RDRAM")) {
|
if (ImGui::MenuItem("Dump RDRAM")) {
|
||||||
core.cpu->mem.DumpRDRAM();
|
core.cpu.mem.DumpRDRAM();
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem("Dump IMEM")) {
|
if (ImGui::MenuItem("Dump IMEM")) {
|
||||||
core.cpu->mem.DumpIMEM();
|
core.cpu.mem.DumpIMEM();
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem("Dump DMEM")) {
|
if (ImGui::MenuItem("Dump DMEM")) {
|
||||||
core.cpu->mem.DumpDMEM();
|
core.cpu.mem.DumpDMEM();
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem("Exit")) {
|
if (ImGui::MenuItem("Exit")) {
|
||||||
done = true;
|
done = true;
|
||||||
@@ -232,8 +232,8 @@ void Window::Render(n64::Core& core) {
|
|||||||
static u32 lastFrame = 0;
|
static u32 lastFrame = 0;
|
||||||
if(!core.pause && lastFrame < ticks - 1000) {
|
if(!core.pause && lastFrame < ticks - 1000) {
|
||||||
lastFrame = ticks;
|
lastFrame = ticks;
|
||||||
windowTitle += fmt::format(" | {:02d} VI/s", core.cpu->mem.mmio.vi.swaps);
|
windowTitle += fmt::format(" | {:02d} VI/s", core.cpu.mem.mmio.vi.swaps);
|
||||||
core.cpu->mem.mmio.vi.swaps = 0;
|
core.cpu.mem.mmio.vi.swaps = 0;
|
||||||
SDL_SetWindowTitle(window, windowTitle.c_str());
|
SDL_SetWindowTitle(window, windowTitle.c_str());
|
||||||
windowTitle = shadowWindowTitle;
|
windowTitle = shadowWindowTitle;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
#include <MupenMovie.hpp>
|
#include <MupenMovie.hpp>
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
App app;
|
App* app = new App;
|
||||||
|
|
||||||
if(argc > 1) {
|
if(argc > 1) {
|
||||||
if(argc > 2) {
|
if(argc > 2) {
|
||||||
LoadTAS(argv[2]);
|
LoadTAS(argv[2]);
|
||||||
}
|
}
|
||||||
app.LoadROM(argv[1]);
|
app->LoadROM(argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Run();
|
app->Run();
|
||||||
|
|
||||||
|
delete app;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user