int clean_up() { // free images / animations bomb_quit(); bomber_quit(); level_quit(); sound_quit(); graphics_quit(); input_quit(); config_quit(); return 0; }
int main(int argc, char* argv[]) { int i,j = 0; unsigned int frame = 0; char *rom_file = NULL; int rom_size = 0; double z80_cycles = 0; if (argc < 2) { fprintf(stderr, "Usage: %s ROM_FILE\n", argv[0]); return 1; } rom_file = argv[1]; memory_init(); rom_size = memory_load(rom_file); if (rom_size < 0) { fprintf(stderr, "Couldn't read ROM file %s\n", rom_file); return 1; } printf("Read ROM %s (%d bytes)\n", rom_file, rom_size); io_init(); video_init(); input_init(); vpu_init(); Z80Reset(&z80_state); z80_state.pc = 0; while (input_quit() == 0) { z80_cycles += Z80Emulate(&z80_state, Z80_CYCLES_PER_STEP); vpu_draw_screen(); video_flip(); video_wait_frame(); input_process(); Z80NonMaskableInterrupt (&z80_state); frame++; } printf("Ran %d frames and %f Z80 cycles.\n", frame, z80_cycles); return 0; }