system: added 8MB ram size option

This commit is contained in:
Jakub Czekański 2021-11-13 01:29:34 +01:00
parent edb3989e11
commit 7112db1437
11 changed files with 55 additions and 11 deletions

View file

@ -306,6 +306,7 @@ set(SOURCES
src/platform/windows/gui/options/bios.cpp
src/platform/windows/gui/options/memory_card.cpp
src/platform/windows/gui/options/options.cpp
src/platform/windows/gui/options/system.cpp
src/platform/windows/gui/toasts.cpp
src/platform/windows/input/key.cpp
src/platform/windows/input/sdl_input_manager.cpp

View file

@ -75,6 +75,10 @@ struct avocado_config_t {
bool timeTravel = false;
} emulator;
struct {
bool ram8mb = false;
} system;
} options;
struct {

View file

@ -20,7 +20,7 @@ struct Segment {
};
namespace segments {
Segment RAM = {"RAM", System::RAM_BASE, System::RAM_SIZE};
Segment RAM = {"RAM", System::RAM_BASE, System::RAM_SIZE_8MB};
Segment EXPANSION = {"EXPANSION", System::EXPANSION_BASE, System::EXPANSION_SIZE};
Segment SCRATCHPAD = {"SCRATCHPAD", System::SCRATCHPAD_BASE, System::SCRATCHPAD_SIZE};
Segment IO = {"IO", System::IO_BASE, System::IO_SIZE};
@ -469,7 +469,7 @@ void CPU::watchWindow(System* sys) {
void CPU::ramWindow(System* sys) {
editor.Open = ramWindowOpen;
editor.DrawWindow("Ram", sys->ram.data(), System::RAM_SIZE);
editor.DrawWindow("Ram", sys->ram.data(), sys->ram.size());
ramWindowOpen = editor.Open;
}

View file

@ -217,6 +217,8 @@ void GUI::mainMenu(std::unique_ptr<System>& sys) {
if (ImGui::MenuItem("Hotkeys", nullptr)) showHotkeysSetupWindow = true;
ImGui::MenuItem("Memory Card", nullptr, &memoryCardOptions.memoryCardWindowOpen);
ImGui::MenuItem("System", nullptr, &systemOptions.systemWindowOpen);
bool soundEnabled = config.options.sound.enabled;
if (ImGui::MenuItem("Sound", nullptr, &soundEnabled)) {
config.options.sound.enabled = soundEnabled;
@ -307,6 +309,7 @@ void GUI::render(std::unique_ptr<System>& sys) {
biosOptions.displayWindows();
memoryCardOptions.displayWindows(sys.get());
systemOptions.displayWindows();
// Help
aboutHelp.displayWindows();

View file

@ -14,6 +14,7 @@
#include "options/bios.h"
#include "options/memory_card.h"
#include "options/options.h"
#include "options/system.h"
#include "toasts.h"
struct System;
@ -36,6 +37,7 @@ class GUI {
gui::options::Bios biosOptions;
gui::options::MemoryCard memoryCardOptions;
gui::options::System systemOptions;
gui::help::About aboutHelp;

View file

@ -3,7 +3,7 @@
#include <imgui.h>
#include <misc/cpp/imgui_stdlib.h>
#include "config.h"
#include "system.h"
#include "../../../../system.h"
namespace gui::options {

View file

@ -0,0 +1,23 @@
#include "system.h"
#include "config.h"
#include <imgui.h>
namespace gui::options {
void System::displayWindows() {
if (!systemWindowOpen) return;
ImGui::Begin("System", &systemWindowOpen, ImGuiWindowFlags_AlwaysAutoResize);
if (ImGui::Checkbox("8MB ram", &config.options.system.ram8mb)) {
bus.notify(Event::System::HardReset{});
}
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 0.8f, 0.8f, 1.f));
ImGui::Text(
"Warning: Changing any of these settings\n"
" will result in system hard reset.");
ImGui::PopStyleColor();
ImGui::End();
}
}; // namespace gui::options

View file

@ -0,0 +1,10 @@
#pragma once
namespace gui::options {
class System {
public:
bool systemWindowOpen = false;
void displayWindows();
};
}; // namespace gui::options

View file

@ -20,7 +20,7 @@ namespace state {
const char* lastSaveName = "last.state";
struct StateMetadata {
inline static const uint32_t SAVESTATE_VERSION = 7;
inline static const uint32_t SAVESTATE_VERSION = 8;
uint32_t version = SAVESTATE_VERSION;
std::string biosPath;

View file

@ -12,7 +12,7 @@
System::System() {
bios.fill(0);
ram.fill(0);
ram.resize(!config.options.system.ram8mb ? RAM_SIZE_2MB : RAM_SIZE_8MB, 0);
scratchpad.fill(0);
expansion.fill(0);
@ -147,8 +147,8 @@ INLINE T System::readMemory(uint32_t address) {
uint32_t addr = align_mips<T>(address);
if (in_range<RAM_BASE, RAM_SIZE * 4>(addr)) {
return read_fast<T>(ram.data(), (addr - RAM_BASE) & (RAM_SIZE - 1));
if (in_range<RAM_BASE, RAM_SIZE_8MB>(addr)) {
return read_fast<T>(ram.data(), (addr - RAM_BASE) & (ram.size() - 1));
}
if (in_range<EXPANSION_BASE, EXPANSION_SIZE>(addr)) {
return read_fast<T>(expansion.data(), addr - EXPANSION_BASE);
@ -199,8 +199,8 @@ INLINE void System::writeMemory(uint32_t address, T data) {
uint32_t addr = align_mips<T>(address);
if (in_range<RAM_BASE, RAM_SIZE * 4>(addr)) {
return write_fast<T>(ram.data(), (addr - RAM_BASE) & (RAM_SIZE - 1), data);
if (in_range<RAM_BASE, RAM_SIZE_8MB>(addr)) {
return write_fast<T>(ram.data(), (addr - RAM_BASE) & (ram.size() - 1), data);
}
if (in_range<EXPANSION_BASE, EXPANSION_SIZE>(addr)) {
return write_fast<T>(expansion.data(), addr - EXPANSION_BASE, data);

View file

@ -52,14 +52,15 @@ struct System {
static const int IO_BASE = 0x1f801000;
static const int BIOS_SIZE = 512 * 1024;
static const int RAM_SIZE = 2 * 1024 * 1024;
static const int RAM_SIZE_2MB = 2 * 1024 * 1024;
static const int RAM_SIZE_8MB = 8 * 1024 * 1024;
static const int SCRATCHPAD_SIZE = 1024;
static const int EXPANSION_SIZE = 1 * 1024 * 1024;
static const int IO_SIZE = 0x2000;
State state = State::stop;
std::array<uint8_t, BIOS_SIZE> bios;
std::array<uint8_t, RAM_SIZE> ram;
std::vector<uint8_t> ram;
std::array<uint8_t, SCRATCHPAD_SIZE> scratchpad;
std::array<uint8_t, EXPANSION_SIZE> expansion;