Emulator: Change main to become an Inferno application

This commit is contained in:
Riyyi
2022-10-16 12:46:10 +02:00
parent ce46f5033a
commit fcfd27468d
3 changed files with 44 additions and 25 deletions
-9
View File
@@ -78,15 +78,6 @@ void Loader::init()
Emu::the().writeMemory(i, bootrom[i]);
}
update();
}
void Loader::update()
{
while (true) {
Emu::the().update();
}
}
void Loader::destroy()
-1
View File
@@ -22,7 +22,6 @@ public:
private:
void init();
void update();
void destroy();
void loadCartridgeHeader();
+34 -5
View File
@@ -5,14 +5,22 @@
* SPDX-License-Identifier: MIT
*/
#include "loader.h"
#include <string_view>
#include "inferno.h"
#include "inferno/entrypoint.h"
#include "ruc/argparser.h"
#include "ruc/format/print.h"
#include "ruc/timer.h"
#include <string_view>
int main(int argc, const char* argv[])
{
#include "emu.h"
#include "loader.h"
class GarbAGE final : public Inferno::Application {
public:
GarbAGE(int argc, char* argv[])
: Application()
{
std::string_view bootrom_path = "gbc_bios.bin";
std::string_view rom_path;
@@ -23,6 +31,27 @@ int main(int argc, const char* argv[])
Loader::the().setBootromPath(bootrom_path);
Loader::the().loadRom(rom_path);
}
return 0;
~GarbAGE()
{
}
void update() override
{
// 154 scanlines * 456 cycles = 70224 cycles per frame
for (int i = 0; i < (144 * 456 + 10 * 456); ++i) {
Emu::the().update();
}
}
void render() override
{
}
};
Inferno::Application* Inferno::createApplication(int argc, char* argv[])
{
GarbAGE* gameboy = new GarbAGE(argc, argv);
return gameboy;
}