示例#1
0
文件: menus.c 项目: Oibaf66/fbzx-wii
void tools_menu() {

	unsigned char *fbuffer,fin;
	int ancho=screen->w;

	fbuffer=screen->pixels;

	fin=1;
	do {
		clean_screen();

		print_string(fbuffer,"Tools",-1,20,15,0,ancho);

		print_string(fbuffer,"1:",14,60,12,0,ancho);
		print_string(fbuffer,"show keyboard template",62,60,15,0,ancho);

		print_string(fbuffer,"2:",14,100,12,0,ancho);
		print_string(fbuffer,"insert POKEs",62,100,15,0,ancho);

		print_string(fbuffer,"ESC:",14,250,12,0,ancho);
		print_string(fbuffer,"return emulator",78,250,15,0,ancho);

		//print_copy(fbuffer,ancho);

		switch(wait_key()) {
		case SDLK_ESCAPE: // to exit the help
			fin=0;
		break;
		case SDLK_1:
			fin=0;
			keyboard_menu();
		break;
		case SDLK_2:
			fin=0;
			do_poke();
		break;
		default:
		break;
		}

	} while(fin);

	clean_screen();
}
int main(int argc, char *argv[])
{
	int fd;
	int pipefd[2];
	long err;
	pid_t cpid;
	void *p;
	struct sigaction sa = {
		.sa_sigaction = sigchld_handler,
		.sa_flags = SA_SIGINFO,
	};
	struct sigaction old_sa;


	test_init(argc, argv);

	hpage_size = check_hugepagesize();

	fd = hugetlbfs_unlinked_fd();
	if (fd < 0)
		FAIL("hugetlbfs_unlinked_fd()");

	err = sigaction(SIGCHLD, &sa, &old_sa);
	if (err)
		FAIL("Can't install SIGCHLD handler: %s", strerror(errno));

	err = pipe(pipefd);
	if (err)
		FAIL("pipe(): %s", strerror(errno));

	cpid = fork();
	if (cpid < 0)
		FAIL("fork(): %s", strerror(errno));


	if (cpid == 0) {
		child(fd, pipefd[1]);
		exit(0);
	}

	/* Parent */
	err = read(pipefd[0], &p, sizeof(p));
	if (err == -1)
		FAIL("Reading pipe: %s\n", strerror(errno));
	if (err != sizeof(p))
		FAIL("Short read over pipe");

	verbose_printf("Parent received address %p\n", p);

	err = ptrace(PTRACE_ATTACH, cpid, NULL, NULL);
	if (err)
		FAIL("ptrace(ATTACH): %s", strerror(errno));

	while (! ready_to_trace)
		;

	do_poke(cpid, p);
	do_poke(cpid, p + getpagesize());

	err = sigaction(SIGCHLD, &old_sa, NULL);
	if (err)
		FAIL("Clearing SIGCHLD handler: %s", strerror(errno));

	ptrace(PTRACE_KILL, cpid, NULL, NULL);

	PASS();
}