From 9ce2fa6124abb1c16352293307b27e3f2a61dbe0 Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 28 Jan 2023 03:41:04 +0100 Subject: [PATCH] supply rom as cmd line argument --- src/Application.cpp | 8 ++++---- src/Application.hpp | 4 ++-- src/Bus.cpp | 4 ++-- src/Bus.hpp | 2 +- src/debugger/Debugger.cpp | 2 +- src/debugger/imgui.ini | 13 +++++++++++++ src/main.cpp | 10 ++++++++-- 7 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 src/debugger/imgui.ini diff --git a/src/Application.cpp b/src/Application.cpp index 62f4570..d6d5599 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -14,14 +14,14 @@ #include "Debugger.hpp" #include "gfx/Window.hpp" -void Application::Launch() +void Application::Launch(const char* rom) { glfwInit(); Application* app = nullptr; try { - app = new Application; + app = new Application(rom); } catch (const std::runtime_error& err) { @@ -43,7 +43,7 @@ void Application::Launch() glfwTerminate(); } -Application::Application() : +Application::Application(const char* rom) : bus(nullptr), window(nullptr) { LOG_CORE_INFO("Creating window"); @@ -93,7 +93,7 @@ Application::Application() : throw err; } - bus = new Bus(screen); + bus = new Bus(rom, screen); debugger = new Debugger(bus); } diff --git a/src/Application.hpp b/src/Application.hpp index 1001bd4..16ba5ff 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -14,10 +14,10 @@ public: /** * @brief Create and launch a new application. */ - static void Launch(); + static void Launch(const char* rom); private: - Application(); + Application(const char* rom); ~Application(); /** diff --git a/src/Bus.cpp b/src/Bus.cpp index cc9a5d9..cc1e167 100644 --- a/src/Bus.cpp +++ b/src/Bus.cpp @@ -5,7 +5,7 @@ #include "controllers/StandardController.hpp" -Bus::Bus(Screen* screen) : +Bus::Bus(const char* rom, Screen* screen) : cpu(this), ppu(this, screen), apu(this), cartridge(this) { LOG_CORE_INFO("Allocating RAM"); @@ -16,7 +16,7 @@ Bus::Bus(Screen* screen) : palettes = std::vector(0x20, 0); LOG_CORE_INFO("Inserting cartridge"); - cartridge.Load("roms/mario.nes"); + cartridge.Load(rom); LOG_CORE_INFO("Powering up CPU"); cpu.Powerup(); diff --git a/src/Bus.hpp b/src/Bus.hpp index 9a65c9b..5536f6d 100644 --- a/src/Bus.hpp +++ b/src/Bus.hpp @@ -25,7 +25,7 @@ class Bus friend class Palettes; public: - Bus(Screen* screen); + Bus(const char* rom, Screen* screen); /** * @brief Reboot the NES. diff --git a/src/debugger/Debugger.cpp b/src/debugger/Debugger.cpp index 772911d..17b4386 100644 --- a/src/debugger/Debugger.cpp +++ b/src/debugger/Debugger.cpp @@ -61,7 +61,7 @@ bool Debugger::Frame() return true; } - return false; + return true; } bool Debugger::Update() diff --git a/src/debugger/imgui.ini b/src/debugger/imgui.ini new file mode 100644 index 0000000..a04ff2b --- /dev/null +++ b/src/debugger/imgui.ini @@ -0,0 +1,13 @@ +[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0 + +[Window][Debugger] +ViewportPos=1419,173 +ViewportId=0x289D2C3F +Size=400,600 +Collapsed=0 + +[Docking][Data] + diff --git a/src/main.cpp b/src/main.cpp index 75ba410..0339887 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,16 @@ #include "Application.hpp" #include "Log.hpp" -int main() +int main(int argc, char** argv) { Log::Init(); - Application::Launch(); + + if (argc != 2) { + LOG_CORE_FATAL("Usage: {0} ", argv[0]); + return -1; + } + + Application::Launch(argv[1]); return 0; }