2019-04-16 06:25:00 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "dmg.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "rom.h"
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct cpu cpu;
|
|
|
|
struct rom rom;
|
|
|
|
struct dmg dmg;
|
2019-04-25 05:19:47 +00:00
|
|
|
int executed = 0;
|
2019-04-16 06:25:00 +00:00
|
|
|
|
|
|
|
if (argc < 2) {
|
|
|
|
printf("no rom specified\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rom_load(&rom, argv[1])) {
|
|
|
|
printf("error loading rom\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this might be too much abstraction but it'll let me
|
|
|
|
// test the cpu, rom, and dmg independently and use the cpu
|
|
|
|
// for other non-GB stuff
|
|
|
|
dmg_new(&dmg, &cpu, &rom);
|
|
|
|
cpu_bind_mem_model(&cpu, &dmg, dmg_read, dmg_write);
|
|
|
|
|
2019-04-25 05:19:47 +00:00
|
|
|
cpu.pc = 0;
|
2019-04-16 06:25:00 +00:00
|
|
|
|
2019-04-25 05:19:47 +00:00
|
|
|
for (; executed < 100000; executed++) {
|
2019-04-16 06:25:00 +00:00
|
|
|
cpu_step(&cpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
rom_free(&rom);
|
|
|
|
return 0;
|
|
|
|
}
|