Creating a real main

This commit is contained in:
AnonymusRaccoon
2020-02-11 14:37:42 +01:00
parent aeb1e127f3
commit 1c5f82ed32
7 changed files with 17 additions and 30 deletions
+9 -22
View File
@@ -16,29 +16,16 @@ int main(int argc, char **argv)
std::cout << "ComSquare:" << std::endl << "\tUsage: " << argv[0] << " rom_path" << std::endl;
return 1;
}
Memory::MemoryBus bus;
Renderer::SFRenderer renderer(600, 800, 60);
SNES snes(std::make_shared<Memory::MemoryBus>(bus), argv[1], renderer);
bus.mapComponents(snes);
int incx = 0;
int incy = 0;
uint32_t pixel = 0x000000FF;
while (!renderer.shouldExit) {
renderer.putPixel(incy, incx++, pixel);
if (incx >= 800) {
incx = 0;
incy++;
try {
Renderer::SFRenderer renderer(600, 800, 60);
SNES snes(std::make_shared<Memory::MemoryBus>(), argv[1], renderer);
while (!renderer.shouldExit) {
unsigned cycleCount = snes.cpu->update();
snes.ppu->update(cycleCount);
snes.apu->update(cycleCount);
}
if (incy >= 600) {
incy = 0;
}
if (incx == 0) {
renderer.drawScreen();
pixel += 0xFF00FF00;
}
renderer.getEvents();
} catch (std::exception &e) {
std::cerr << "An error occurred: " << e.what() << std::endl;
}
return 0;
}