Exemplo n.º 1
0
int main()
{
	printf("This is NES emulator on STM32F103\r\n");
	//init_test_rom(&hdr, ROM, pattern_table);
	init_test_rom(&hdr, ROM, pattern_table);
	clear_screen(WHITE);
	//clear_screen(BLACK);

	// Set LCD window for fast drawing
	// Direction
	tft_ili9325_wr_cmd(0x03, 0x1028); // set GRAM write direction and BGR = 1.
	// Window
	tft_ili9325_wr_cmd(0x50, 0);
	tft_ili9325_wr_cmd(0x51, 239);
	tft_ili9325_wr_cmd(0x52, 0);
	tft_ili9325_wr_cmd(0x53, 255);
	// VRAM start
	tft_ili9325_wr_cmd(0x20, 0);
	tft_ili9325_wr_cmd(0x21, 0);
	// GRAM register ready to write
	tft_ili9325_wr_reg(0x22);

	emulator_init();
	//update_regs();
	//ppu_print_status(&ppu);
	while (1)
	{
		step();
		//update_regs();
		//delay(9999);
	}
	return 0;
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
    emulator_init(&cmips_emu);
    cmips_emu.err_disp = catch_errs;

    parse_args(argc, argv, &cmips_arg_state);

    if (!cmips_arg_state.quiet)
        printf("%s", version_text);

    if (cmips_arg_state.run)
        emulator_run(&cmips_emu);

    if (!cmips_arg_state.noinput)
        run_input_loop();

    emulator_clear(&cmips_emu);

    return 0;
}
Exemplo n.º 3
0
int main(int argc, char** argv)
{
	int i;
	unsigned int cmd;
	unsigned int val;
	unsigned int addr;
	char* file_path;

	clear_screen();

#ifdef DEBUG_MODE
	for (i = 0; i < argc; ++i)
		debug_message("argv[%2d] : '%s'", i, argv[i]);
#endif
	printf("This is NES emulator.\n");

	if (argc >= 2)
	{
		char* arg = argv[1];
		int arg_len = strlen(arg);
		if (arg_len == 2)
		{
			if (arg[0] == '-' && (arg[1] == 't' || arg[1] == 'T'))			// TEST ROM
				init_test_rom(&hdr, ROM, pattern_table);
			else if (arg[0] == '-' && (arg[1] == 'd' || arg[1] == 'D'))		// Dumped image
			{
				FILE* rom_image;
				FILE* chr_image;

				if (argc < 3)
					return 1;

#if defined _WIN32 && defined _MSC_VER
				fopen_s(&rom_image, argv[2], "rb");
				fopen_s(&chr_image, argv[3], "rb");
#elif defined __linux__ || defined __GNUC__
				rom_image = fopen(argv[2], "rb");
				chr_image = fopen(argv[3], "rb");
#endif
				if (!rom_image || !chr_image)
				{
					debug_message("Could not open dumped ROM image!");
					return 1;
				}

				if (fread(ROM, ROM_SIZE, 1, rom_image) != 1)
					return 1;

				if (fread(pattern_table, PPU_PATTERN_TABLE_SIZE, 1, chr_image) != 1)
					return 1;
				
				fclose(rom_image);
				fclose(chr_image);
			}
			else if (arg[0] == '-' && (arg[1] == 'r' || arg[1] == 'R'))
			{
				if (argc < 3)
				{
					debug_message("File name required.");
					return 1;
				}
				
				if (dump_test_rom(argv[2]) != 1)
				{
					debug_message("Could not dump test ROM!");
					return 1;
				}

				debug_message("Test ROM dumped!");
				return 0;
			}
			else
			{
				debug_message("Invalid command line arguments!");
				return 1;
			}
		}
		else
		{
			file_path = argv[1];
			if (read_rom_image(file_path) != 1)
			{
				printf("Reading ROM image failed!\n");
				return 1;
			}
		}
	}
	else if (argc < 2)
	{
		printf("Emulation failed! No ROM image supplied!\n");
		return 1;
	}

	if (emulator_init() != 1)
	{
		printf("Emulator initialization failed!\n");
		return 1;
	}
	
	run();		// Comment this line for debuging.

	//clear_screen();
	gotoxy(REGS_X, REGS_Y);
	update_regs();
	gotoxy(CMD_X, CMD_Y);

	while (!finished_emulation)
	{
		clear_cmd_line();
		cmd = getch();
 		putchar(cmd);

		switch (cmd)
		{
			case 's':
			case 'S':
				step();
				update_regs();
				break;

			// Finish emulation
			case 'q':
			case 'Q':
				finished_emulation = 1;
				break;

			case 'w':
			case 'W':
				if (scanf_s("%4x %2x", &addr, &val))
					write(addr, val);
				break;

			case 'r':
			case 'R':
				if (scanf_s("%4x", &addr))
				{
					val = read(addr);
					printf("    $%04x : %02X", addr, val);
				}
				break;

			case 'd':
			case 'D':
				if (scanf_s("%4x %u", &addr, &val))
					for (i = 0; i < (int)val; ++i)
						printf("\n    %04X : %02X\n", addr + i, read(addr + i));
				break;

			case 'h':
			case 'H':
				printf("\n"
					"    S          : Step\n"
					"    Q          : Quit\n"
					"    W Addr Val : Write memory\n"
					"    R Addr     : Read memory\n"
					"    D Addr Sz  : Dump memory\n"
					"    C Val      : Run for Val cycles\n"
					"    H          : Help\n"
					"    E          : Run to PC equals to Val\n"
					);
				break;

			case 'a':
			case 'A':
				if (scanf_s("%2x", &val))
					write_a(&p, val);
				break;

			case 'x':
			case 'X':
				if (scanf_s("%2x", &val))
					write_x(&p, val);
				break;

			case 'y':
			case 'Y':
				if (scanf_s("%2x", &val))
					write_y(&p, val);
				break;

			case 'p':
			case 'P':
				if (scanf_s("%2x", &val))
					write_p(&p, val | FLAG_1);
				break;

			case 'c':
			case 'C':
				if (scanf_s("%u", &val))
				{
					run_cycles(val);
					update_regs();
				}
				break;

			case 'e':
			case 'E':
				if (scanf_s("%4x", &val))
				{
					while (p.pc.w != val)
						step();
					update_regs();
				}
				break;

			default:
				break;
		}
	}

	emulator_close();

	return 0;
}
Exemplo n.º 4
0
int main(int argc, char** argv)
{
	int i;
	int cmd;
	unsigned int val;
	unsigned int addr;

    printf("This is Atari 2600 emulator!\n\n");
	
	// Print command line arguments.
	debug_message("argc : %d", argc);
#if DEBUG_MODE
	for (i = 0; i < argc; ++i)
		debug_message("argv[%2d] : %s", i, argv[i]);
#endif

	if (argc < 2) {
		printf("Emulation failed! No ROM image supplied!\n");
		return 1;
	}

	if (emulator_init() != 1) {
		printf("Emulator initialization failed!\n");
		return 1;
	}

	init_console();
	gotoxy(REGS_X, REGS_Y);
	update_regs();

	while (!finished_emulation) {
		clear_cmd_line();
		cmd = getch();

		switch (cmd) {
			case 'q':
			case 'Q':
				finished_emulation = 1;
				break;

			case 's':
			case 'S':
				step();
				update_regs();
				break;

			case 'c':
			case 'C':
				if (scanf_s("%u", &val)) {
					run_cycles((int)val);
					update_regs();
				}
				break;

			case 'r':
			case 'R':
				if (scanf_s("%4x", &addr)) {
					val = read((uint16_t)addr);
					printf("    $%04x : $%02x", addr, val);
				}
				break;
		}
	}

	emulator_close();

    return 0;
}