Exemplo n.º 1
0
void end( void )
{
    end_game();
    end_gui();

    exit(0);
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: rtobar/imanes
int main(int args, char *argv[]) {

	char *save_file;
	ines_file *nes_rom;

	/* Print NOW everything :D */
#ifdef _MSC_VER
	setvbuf(stdout,NULL,_IONBF,0);
	setvbuf(stderr,NULL,_IONBF,0);
#else
	setbuf(stdout,NULL);
	setbuf(stderr,NULL);
#endif

	/* i18n stuff */
	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	/* Parse command line options */
	initialize_configuration();
	switch ( parse_options(args, argv) ) {
		case -1:
			usage(stderr,argv);
			exit(EXIT_FAILURE);
		case 0:
			exit(EXIT_SUCCESS);
		default:
			break;
	}

	load_user_configuration();

	/* Initialize static data */
	initialize_palette();
	initialize_instruction_set();
	initialize_playback();
	initialize_apu();
	initialize_cpu();
	initialize_ppu();
	initialize_clock();
	initialize_pads();

	/* Read the ines file and get all the ROM/VROM */
	config.rom_file = argv[optind];
	nes_rom = check_ines_file(config.rom_file);
	map_rom_memory(nes_rom);
	save_file = load_sram(config.rom_file);

	/* Init the graphics engine */
	init_screen();
	init_gui();

	/* Main execution loop */
	main_loop();

	/* After finishing the emulation, save the SRAM if necessary */
	save_sram(save_file);
	free(save_file);

	/* Free all the used resources */
	mapper->end_mapper();
	end_screen();
	end_gui();
	end_ppu();
	end_cpu();
	end_apu();
	end_playback();
	free_ines_file(nes_rom);

	return 0;
}