Make CPU respect chosen option (JIT, etc)
This commit is contained in:
@@ -3,7 +3,13 @@
|
|||||||
#include <Scheduler.hpp>
|
#include <Scheduler.hpp>
|
||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
Core::Core() : cpu(std::make_unique<Interpreter>(parallel)) {}
|
Core::Core(CPUType cpuType) {
|
||||||
|
switch (cpuType) {
|
||||||
|
case Interpreted: cpu = std::make_unique<Interpreter>(parallel); break;
|
||||||
|
case DynamicRecompiler: cpu = std::make_unique<JIT>(parallel); break;
|
||||||
|
default: Util::panic("Unimplemented CPU type\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Core::Stop() {
|
void Core::Stop() {
|
||||||
pause = true;
|
pause = true;
|
||||||
|
|||||||
@@ -6,7 +6,12 @@
|
|||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
struct Core {
|
struct Core {
|
||||||
explicit Core();
|
enum CPUType {
|
||||||
|
Interpreted,
|
||||||
|
DynamicRecompiler,
|
||||||
|
CachedInterpreter
|
||||||
|
};
|
||||||
|
explicit Core(CPUType);
|
||||||
void Stop();
|
void Stop();
|
||||||
void LoadROM(const std::string &);
|
void LoadROM(const std::string &);
|
||||||
[[nodiscard]] bool LoadTAS(const fs::path &) const;
|
[[nodiscard]] bool LoadTAS(const fs::path &) const;
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ bool AudioSettings::render() {
|
|||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if(ImGui::SliderFloat("Volume L", &volumeL, 0.f, 100.f, "%.2f")) {
|
if(ImGui::SliderFloat("Volume L", &volumeL, 0.f, 100.f, "%.2f")) {
|
||||||
Options::GetInstance().SetValue("audio", "volumeL", volumeL / 100.f);
|
Options::GetInstance().SetValue("audio", "volumeL", volumeL / 100.f);
|
||||||
if (lockChannels) {
|
if (lockChannels) {
|
||||||
@@ -30,8 +28,6 @@ bool AudioSettings::render() {
|
|||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
ImGui::BeginDisabled(lockChannels);
|
ImGui::BeginDisabled(lockChannels);
|
||||||
if(ImGui::SliderFloat("Volume R", &volumeR, 0.f, 100.f, "%.2f")) {
|
if(ImGui::SliderFloat("Volume R", &volumeR, 0.f, 100.f, "%.2f")) {
|
||||||
Options::GetInstance().SetValue("audio", "volumeR", volumeR / 100.f);
|
Options::GetInstance().SetValue("audio", "volumeR", volumeR / 100.f);
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ bool CPUSettings::render() {
|
|||||||
const char* combo_preview_value = items[selectedCpuTypeIndex];
|
const char* combo_preview_value = items[selectedCpuTypeIndex];
|
||||||
if (ImGui::BeginCombo("CPU Type", combo_preview_value)) {
|
if (ImGui::BeginCombo("CPU Type", combo_preview_value)) {
|
||||||
for (int n = 0; n < IM_ARRAYSIZE(items); n++) {
|
for (int n = 0; n < IM_ARRAYSIZE(items); n++) {
|
||||||
if(n == 1) // make JIT non-selectable but visible for now.
|
|
||||||
ImGui::BeginDisabled(true);
|
|
||||||
|
|
||||||
const bool is_selected = (selectedCpuTypeIndex == n);
|
const bool is_selected = (selectedCpuTypeIndex == n);
|
||||||
if (ImGui::Selectable(items[n], is_selected)) {
|
if (ImGui::Selectable(items[n], is_selected)) {
|
||||||
selectedCpuTypeIndex = n;
|
selectedCpuTypeIndex = n;
|
||||||
@@ -32,9 +29,6 @@ bool CPUSettings::render() {
|
|||||||
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
|
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
|
||||||
if (is_selected)
|
if (is_selected)
|
||||||
ImGui::SetItemDefaultFocus();
|
ImGui::SetItemDefaultFocus();
|
||||||
|
|
||||||
if(n == 1) // make JIT non-selectable but visible for now.
|
|
||||||
ImGui::EndDisabled();
|
|
||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
@@ -43,7 +37,7 @@ bool CPUSettings::render() {
|
|||||||
if(selectedCpuTypeIndex == 0) {
|
if(selectedCpuTypeIndex == 0) {
|
||||||
Options::GetInstance().SetValue<std::string>("cpu", "type", "interpreter");
|
Options::GetInstance().SetValue<std::string>("cpu", "type", "interpreter");
|
||||||
} else {
|
} else {
|
||||||
Util::panic("JIT should not be selectable??");
|
Options::GetInstance().SetValue<std::string>("cpu", "type", "jit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class CPUSettings final {
|
|||||||
int selectedCpuTypeIndex = 0;
|
int selectedCpuTypeIndex = 0;
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
public:
|
public:
|
||||||
|
int GetCPUType() { return selectedCpuTypeIndex; }
|
||||||
bool render();
|
bool render();
|
||||||
explicit CPUSettings();
|
explicit CPUSettings();
|
||||||
void setModified(bool v) { modified = v; }
|
void setModified(bool v) { modified = v; }
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <ImGuiImpl/StatusBar.hpp>
|
#include <ImGuiImpl/StatusBar.hpp>
|
||||||
#include <resources/gamecontrollerdb.h>
|
#include <resources/gamecontrollerdb.h>
|
||||||
|
|
||||||
KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_shared<n64::Core>()), vulkanWidget(core, window.getHandle()), emuThread(core, fpsCounter, vulkanWidget, settingsWindow) {
|
KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_shared<n64::Core>(static_cast<n64::Core::CPUType>(settingsWindow.cpuSettings.GetCPUType()))), vulkanWidget(core, window.getHandle()), emuThread(core, fpsCounter, vulkanWidget, settingsWindow) {
|
||||||
gui::Initialize(core->parallel.wsi, window.getHandle());
|
gui::Initialize(core->parallel.wsi, window.getHandle());
|
||||||
SDL_InitSubSystem(SDL_INIT_GAMEPAD);
|
SDL_InitSubSystem(SDL_INIT_GAMEPAD);
|
||||||
|
|
||||||
@@ -179,34 +179,47 @@ void KaizenGui::RenderUI() {
|
|||||||
|
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
if(ImGui::MenuItem("Settings")) {
|
if(ImGui::MenuItem("Options")) {
|
||||||
settingsWindow.render();
|
settingsWindow.isOpen = true;
|
||||||
}
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
if(ImGui::BeginMenu("Help")) {
|
if(ImGui::BeginMenu("Help")) {
|
||||||
if(ImGui::MenuItem("About")) {
|
if(ImGui::MenuItem("About")) {
|
||||||
ImGui::OpenPopup("About Kaizen");
|
aboutOpen = true;
|
||||||
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
|
||||||
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
|
||||||
|
|
||||||
if (ImGui::BeginPopupModal("About Kaizen", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
|
||||||
ImGui::Text("Kaizen is a Nintendo 64 emulator that strives");
|
|
||||||
ImGui::Text("to offer a friendly user experience and compatibility.");
|
|
||||||
ImGui::Text("Kaizen is licensed under the BSD 3-clause license.");
|
|
||||||
ImGui::Text("Nintendo 64 is a registered trademark of Nintendo Co., Ltd.");
|
|
||||||
if(ImGui::Button("OK")) {
|
|
||||||
ImGui::CloseCurrentPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
ImGui::EndMainMenuBar();
|
ImGui::EndMainMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(settingsWindow.isOpen) {
|
||||||
|
ImGui::OpenPopup("Settings", ImGuiPopupFlags_None);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(aboutOpen) {
|
||||||
|
ImGui::OpenPopup("About Kaizen");
|
||||||
|
}
|
||||||
|
|
||||||
|
settingsWindow.render();
|
||||||
|
|
||||||
|
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
||||||
|
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||||
|
|
||||||
|
if (ImGui::BeginPopupModal("About Kaizen", &aboutOpen, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
|
ImGui::Text("Kaizen is a Nintendo 64 emulator that strives");
|
||||||
|
ImGui::Text("to offer a friendly user experience and compatibility.");
|
||||||
|
ImGui::Text("Kaizen is licensed under the BSD 3-clause license.");
|
||||||
|
ImGui::Text("Nintendo 64 is a registered trademark of Nintendo Co., Ltd.");
|
||||||
|
if(ImGui::Button("OK")) {
|
||||||
|
aboutOpen = false;
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
if(ImGui::BeginMainStatusBar()) {
|
if(ImGui::BeginMainStatusBar()) {
|
||||||
ImGui::Text("FPS: %.2f", ImGui::GetIO().Framerate);
|
ImGui::Text("FPS: %.2f", ImGui::GetIO().Framerate);
|
||||||
ImGui::EndMainStatusBar();
|
ImGui::EndMainStatusBar();
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ public:
|
|||||||
|
|
||||||
double fpsCounter = -1.0;
|
double fpsCounter = -1.0;
|
||||||
|
|
||||||
|
SettingsWindow settingsWindow;
|
||||||
std::shared_ptr<n64::Core> core;
|
std::shared_ptr<n64::Core> core;
|
||||||
RenderWidget vulkanWidget;
|
RenderWidget vulkanWidget;
|
||||||
SettingsWindow settingsWindow;
|
|
||||||
EmuThread emuThread;
|
EmuThread emuThread;
|
||||||
|
|
||||||
SDL_Gamepad* gamepad = nullptr;
|
SDL_Gamepad* gamepad = nullptr;
|
||||||
@@ -25,6 +25,7 @@ public:
|
|||||||
void LoadTAS(const std::string &path) const noexcept;
|
void LoadTAS(const std::string &path) const noexcept;
|
||||||
void LoadROM(const std::string &path) noexcept;
|
void LoadROM(const std::string &path) noexcept;
|
||||||
private:
|
private:
|
||||||
|
bool aboutOpen = false;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
std::function<void()> emuExitFunc;
|
std::function<void()> emuExitFunc;
|
||||||
void FileDialog();
|
void FileDialog();
|
||||||
|
|||||||
@@ -8,17 +8,12 @@
|
|||||||
std::string savePath;
|
std::string savePath;
|
||||||
|
|
||||||
bool SettingsWindow::render() {
|
bool SettingsWindow::render() {
|
||||||
ImGui::OpenPopup("Settings", ImGuiPopupFlags_None);
|
|
||||||
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
||||||
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||||
|
|
||||||
if(ImGui::BeginPopupModal("Settings")) {
|
if(ImGui::BeginPopupModal("Settings", &isOpen)) {
|
||||||
if(ImGui::BeginTabBar("SettingsTabBar")) {
|
if(ImGui::BeginTabBar("SettingsTabBar")) {
|
||||||
if(ImGui::BeginTabItem("General")) {
|
if(ImGui::BeginTabItem("General")) {
|
||||||
ImGui::BeginDisabled();
|
|
||||||
ImGui::InputText("Save Path", (char*)savesPath.c_str(), savesPath.length());
|
|
||||||
ImGui::EndDisabled();
|
|
||||||
ImGui::SameLine();
|
|
||||||
if(ImGui::Button("Pick...")) {
|
if(ImGui::Button("Pick...")) {
|
||||||
NFD::Guard guard;
|
NFD::Guard guard;
|
||||||
NFD::UniquePath outPath;
|
NFD::UniquePath outPath;
|
||||||
@@ -33,6 +28,10 @@ bool SettingsWindow::render() {
|
|||||||
applyEnabled = true;
|
applyEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::BeginDisabled();
|
||||||
|
ImGui::InputText("Save Path", (char*)savesPath.c_str(), savesPath.length());
|
||||||
|
ImGui::EndDisabled();
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +64,7 @@ bool SettingsWindow::render() {
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if(ImGui::Button("Cancel")) {
|
if(ImGui::Button("Cancel")) {
|
||||||
|
isOpen = false;
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
|||||||
@@ -5,11 +5,12 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class SettingsWindow final {
|
class SettingsWindow final {
|
||||||
CPUSettings cpuSettings;
|
|
||||||
AudioSettings audioSettings;
|
AudioSettings audioSettings;
|
||||||
std::string savesPath;
|
std::string savesPath;
|
||||||
bool applyEnabled = false;
|
bool applyEnabled = false;
|
||||||
public:
|
public:
|
||||||
|
CPUSettings cpuSettings;
|
||||||
|
bool isOpen = false;
|
||||||
bool render();
|
bool render();
|
||||||
SettingsWindow() = default;
|
SettingsWindow() = default;
|
||||||
[[nodiscard]] float getVolumeL() const { return audioSettings.volumeL / 100.f; }
|
[[nodiscard]] float getVolumeL() const { return audioSettings.volumeL / 100.f; }
|
||||||
|
|||||||
Reference in New Issue
Block a user