supply rom as cmd line argument

This commit is contained in:
Robert 2023-01-28 03:41:04 +01:00
parent 1510bb94be
commit 9ce2fa6124
7 changed files with 31 additions and 12 deletions

View file

@ -14,14 +14,14 @@
#include "Debugger.hpp" #include "Debugger.hpp"
#include "gfx/Window.hpp" #include "gfx/Window.hpp"
void Application::Launch() void Application::Launch(const char* rom)
{ {
glfwInit(); glfwInit();
Application* app = nullptr; Application* app = nullptr;
try try
{ {
app = new Application; app = new Application(rom);
} }
catch (const std::runtime_error& err) catch (const std::runtime_error& err)
{ {
@ -43,7 +43,7 @@ void Application::Launch()
glfwTerminate(); glfwTerminate();
} }
Application::Application() : Application::Application(const char* rom) :
bus(nullptr), window(nullptr) bus(nullptr), window(nullptr)
{ {
LOG_CORE_INFO("Creating window"); LOG_CORE_INFO("Creating window");
@ -93,7 +93,7 @@ Application::Application() :
throw err; throw err;
} }
bus = new Bus(screen); bus = new Bus(rom, screen);
debugger = new Debugger(bus); debugger = new Debugger(bus);
} }

View file

@ -14,10 +14,10 @@ public:
/** /**
* @brief Create and launch a new application. * @brief Create and launch a new application.
*/ */
static void Launch(); static void Launch(const char* rom);
private: private:
Application(); Application(const char* rom);
~Application(); ~Application();
/** /**

View file

@ -5,7 +5,7 @@
#include "controllers/StandardController.hpp" #include "controllers/StandardController.hpp"
Bus::Bus(Screen* screen) : Bus::Bus(const char* rom, Screen* screen) :
cpu(this), ppu(this, screen), apu(this), cartridge(this) cpu(this), ppu(this, screen), apu(this), cartridge(this)
{ {
LOG_CORE_INFO("Allocating RAM"); LOG_CORE_INFO("Allocating RAM");
@ -16,7 +16,7 @@ Bus::Bus(Screen* screen) :
palettes = std::vector<Byte>(0x20, 0); palettes = std::vector<Byte>(0x20, 0);
LOG_CORE_INFO("Inserting cartridge"); LOG_CORE_INFO("Inserting cartridge");
cartridge.Load("roms/mario.nes"); cartridge.Load(rom);
LOG_CORE_INFO("Powering up CPU"); LOG_CORE_INFO("Powering up CPU");
cpu.Powerup(); cpu.Powerup();

View file

@ -25,7 +25,7 @@ class Bus
friend class Palettes; friend class Palettes;
public: public:
Bus(Screen* screen); Bus(const char* rom, Screen* screen);
/** /**
* @brief Reboot the NES. * @brief Reboot the NES.

View file

@ -61,7 +61,7 @@ bool Debugger::Frame()
return true; return true;
} }
return false; return true;
} }
bool Debugger::Update() bool Debugger::Update()

13
src/debugger/imgui.ini Normal file
View file

@ -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]

View file

@ -1,10 +1,16 @@
#include "Application.hpp" #include "Application.hpp"
#include "Log.hpp" #include "Log.hpp"
int main() int main(int argc, char** argv)
{ {
Log::Init(); Log::Init();
Application::Launch();
if (argc != 2) {
LOG_CORE_FATAL("Usage: {0} <rom>", argv[0]);
return -1;
}
Application::Launch(argv[1]);
return 0; return 0;
} }