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;
}
+2 -2
View File
@@ -47,8 +47,8 @@ namespace ComSquare::APU
}
}
bool APU::update()
bool APU::update(unsigned cycles)
{
throw NotImplementedException();
(void)cycles;
}
}
+1 -1
View File
@@ -125,7 +125,7 @@ namespace ComSquare::APU
//! @param data The new value of the register.
//! @throw InvalidAddress will be thrown if the address is more than $FF (the number of register).
void write(uint24_t addr, uint8_t data) override;
bool update();
bool update(unsigned cycles);
};
}
+2 -2
View File
@@ -184,9 +184,9 @@ namespace ComSquare::CPU
}
}
int CPU::update()
unsigned CPU::update()
{
int cycles = 0;
unsigned cycles = 0;
for (int i = 0; i < 0xFF; i++)
cycles += this->executeInstruction();
+1 -1
View File
@@ -216,7 +216,7 @@ namespace ComSquare::CPU
explicit CPU(std::shared_ptr<Memory::MemoryBus> bus, Cartridge::Header &cartridgeHeader);
//! @brief This function continue to execute the Cartridge code.
//! @return The number of CPU cycles that elapsed
int update();
unsigned update();
//! @brief Read from the internal CPU register.
//! @param addr The address to read from. The address 0x0 should refer to the first byte of the register.
//! @throw InvalidAddress will be thrown if the address is more than $1F (the number of register).
+1 -1
View File
@@ -70,7 +70,7 @@ namespace ComSquare::PPU
}
}
void PPU::update(int cycles)
void PPU::update(unsigned cycles)
{
(void)cycles;
}
+1 -1
View File
@@ -392,7 +392,7 @@ namespace ComSquare::PPU
void write(uint24_t addr, uint8_t data) override;
//! @brief Update the PPU of n cycles.
//! @param The number of cycles to update.
void update(int cycles);
void update(unsigned cycles);
};
}
#endif //COMSQUARE_PPU_HPP