get rid of JIT and other things

This commit is contained in:
SimoneN64
2023-06-04 22:28:23 +02:00
parent 1ed2506523
commit 30fce7ecf7
36 changed files with 143 additions and 3602 deletions

View File

@@ -9,10 +9,17 @@ App::App() : window(core) {
void App::Run() {
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
n64::SI& si = core.cpu->mem.mmio.si;
n64::SI& si = core.cpu.mem.mmio.si;
while (!core.done) {
core.Run(window, window.settings.GetVolumeL(), window.settings.GetVolumeL());
if(core.romLoaded) {
if(!core.pause) {
core.Run(window.settings.GetVolumeL(), window.settings.GetVolumeR());
}
UpdateScreenParallelRdp(core, window, core.GetVI());
} else {
UpdateScreenParallelRdpNoGame(core, window);
}
SDL_Event event;
while (SDL_PollEvent(&event)) {

View File

@@ -27,34 +27,16 @@ Settings::Settings(n64::Core& core) {
if(fileExists) {
settingsFile = std::fstream("resources/settings.json", std::fstream::in | std::fstream::out);
settings = json::parse(settingsFile);
auto entryCpuType = settings["cpu"]["type"];
if(!entryCpuType.empty()) {
cpuType = entryCpuType.get<std::string>();
if(cpuType == "jit") {
core.cpuType = n64::CpuType::JIT;
} else if(cpuType == "interpreter") {
core.cpuType = n64::CpuType::Interpreter;
} else {
Util::panic("Unrecognized cpu type: {}\n", cpuType);
}
} else {
settingsFile.clear();
settings["cpu"]["type"] = "interpreter";
settingsFile << settings;
core.cpuType = n64::CpuType::Interpreter;
}
checkjsonentry(volumeR, float, "audio", "volumeR", 0.5);
checkjsonentry(volumeL, float, "audio", "volumeL", 0.5);
checkjsonentry(lockChannels, bool, "audio", "lockChannels", true);
} else {
settingsFile = std::fstream("resources/settings.json", std::fstream::trunc | std::fstream::in | std::fstream::out);
settings["cpu"]["type"] = "interpreter";
settings["audio"]["volumeR"] = 0.5;
settings["audio"]["volumeL"] = 0.5;
settings["audio"]["lockChannels"] = true;
core.cpuType = n64::CpuType::Interpreter;
volumeR = 0.5;
volumeL = 0.5;
lockChannels = true;
@@ -62,17 +44,6 @@ Settings::Settings(n64::Core& core) {
settingsFile << settings;
}
settingsFile.close();
switch(core.cpuType) {
case n64::CpuType::Interpreter:
core.cpu = std::make_unique<n64::Interpreter>();
break;
case n64::CpuType::JIT:
core.cpu = std::make_unique<n64::JIT>();
break;
case n64::CpuType::COUNT:
Util::panic("BRUH\n");
}
}
Settings::~Settings() {
@@ -81,7 +52,6 @@ Settings::~Settings() {
if(fileExists) {
settingsFile = std::fstream("resources/settings.json", std::fstream::trunc | std::fstream::out);
settings["cpu"]["type"] = cpuType;
settings["audio"]["volumeR"] = volumeR;
settings["audio"]["volumeL"] = volumeL;
settings["audio"]["lockChannels"] = lockChannels;
@@ -89,7 +59,6 @@ Settings::~Settings() {
} else {
settingsFile = std::fstream("resources/settings.json", std::fstream::out);
settings["cpu"]["type"] = cpuType;
settings["audio"]["volumeR"] = volumeR;
settings["audio"]["volumeL"] = volumeL;
settings["audio"]["lockChannels"] = lockChannels;
@@ -103,30 +72,12 @@ void Settings::RenderWidget(bool& show) {
if(show) {
ImGui::OpenPopup("Settings");
if(ImGui::BeginPopupModal("Settings", &show)) {
enum class SelectedSetting { CPU, Audio, COUNT };
enum class SelectedSetting { Audio, COUNT };
static SelectedSetting selectedSetting = SelectedSetting::Audio;
const char *categories[(int)SelectedSetting::COUNT] = { "CPU", "Audio" };
const char *categories[(int)SelectedSetting::COUNT] = { "Audio" };
CreateComboList("##", (int*)&selectedSetting, categories, (int)SelectedSetting::COUNT);
ImGui::Separator();
switch (selectedSetting) {
case SelectedSetting::CPU: {
const char* cpuTypes[(int)n64::CpuType::COUNT] = { "Interpreter", "JIT" };
static n64::CpuType currentType = n64::CpuType::Interpreter;
if (cpuType == "jit") currentType = n64::CpuType::JIT;
if (CreateComboList("Core type", (int*)&currentType, cpuTypes, (int)n64::CpuType::COUNT)) {
switch (currentType) {
case n64::CpuType::Interpreter:
cpuType = "interpreter";
break;
case n64::CpuType::JIT:
cpuType = "jit";
break;
case n64::CpuType::COUNT:
Util::panic("BRUH\n");
}
}
} break;
case SelectedSetting::Audio:
ImGui::Checkbox("Lock channels", &lockChannels);
ImGui::SliderFloat("Volume L", &volumeL, 0, 1, "%.2f", ImGuiSliderFlags_NoInput);

View File

@@ -11,11 +11,9 @@ struct Settings {
inline float GetVolumeL() const { return volumeL; };
inline float GetVolumeR() const { return volumeR; };
inline bool GetLockChannels() const { return lockChannels; }
inline std::string GetCpuType() const { return cpuType; }
void RenderWidget(bool& show);
private:
std::string cpuType = "interpreter";
float volumeL = 0.0, volumeR = 0.0;
bool lockChannels = true;
json settings;

View File

@@ -11,7 +11,7 @@ namespace fs = std::filesystem;
Window::Window(n64::Core& core) : settings(core) {
InitSDL();
InitParallelRDP(core.cpu->mem.GetRDRAM(), window);
InitParallelRDP(core.cpu.mem.GetRDRAM(), window);
InitImgui();
NFD::Init();
}
@@ -152,7 +152,7 @@ ImDrawData* Window::Present(n64::Core& core) {
void Window::LoadROM(n64::Core& core, const std::string &path) {
if(!path.empty()) {
core.LoadROM(path);
gameName = core.cpu->mem.rom.gameNameDB;
gameName = core.cpu.mem.rom.gameNameDB;
if(gameName.empty()) {
gameName = fs::path(path).stem().string();
@@ -181,13 +181,13 @@ void Window::RenderMainMenuBar(n64::Core &core) {
}
}
if (ImGui::MenuItem("Dump RDRAM")) {
core.cpu->mem.DumpRDRAM();
core.cpu.mem.DumpRDRAM();
}
if (ImGui::MenuItem("Dump IMEM")) {
core.cpu->mem.DumpIMEM();
core.cpu.mem.DumpIMEM();
}
if (ImGui::MenuItem("Dump DMEM")) {
core.cpu->mem.DumpDMEM();
core.cpu.mem.DumpDMEM();
}
if (ImGui::MenuItem("Exit")) {
core.done = true;
@@ -232,8 +232,8 @@ void Window::Render(n64::Core& core) {
static u32 lastFrame = 0;
if(!core.pause && lastFrame < ticks - 1000) {
lastFrame = ticks;
windowTitle += fmt::format(" | {:02d} VI/s", core.cpu->mem.mmio.vi.swaps);
core.cpu->mem.mmio.vi.swaps = 0;
windowTitle += fmt::format(" | {:02d} VI/s", core.cpu.mem.mmio.vi.swaps);
core.cpu.mem.mmio.vi.swaps = 0;
SDL_SetWindowTitle(window, windowTitle.c_str());
windowTitle = shadowWindowTitle;
}