예제 #1
0
파일: gameboy.c 프로젝트: aidenfoxx/foxxgb
void gameboyStep(Gameboy *gameboy)
{
	inputStep(gameboy->joypad, gameboy->mmu);
	cpuStep(gameboy->cpu, gameboy->mmu);
	timerStep(gameboy->timer, gameboy->mmu, gameboy->cpu->cycles);
	displayStep(gameboy->display, gameboy->mmu, gameboy->cpu->cycles);
}
예제 #2
0
파일: main.c 프로젝트: NanoCoaster/Cinoop
int main(int argc, char **argv) {
	char *filename = NULL;
	
	printf("Starting...\n");
	
	dpy = XOpenDisplay(NULL);
	
	if(dpy == NULL) {
		printf("Cannot connect to X server!\n");
		exit(0);
	}
	
	root = DefaultRootWindow(dpy);
	
	vi = glXChooseVisual(dpy, 0, att);
	
	if(vi == NULL) {
		printf("No appropriate visual found!\n");
		exit(0);
	}
	
	cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);
	
	swa.colormap = cmap;
	swa.event_mask = ExposureMask | KeyPressMask;
	
	win = XCreateWindow(dpy, root, 0, 0, 160, 144, 0, vi->depth, InputOutput, vi->visual, CWColormap | CWEventMask, &swa);
	
	XMapWindow(dpy, win);
	XStoreName(dpy, win, "Cinoop");
	
	glc = glXCreateContext(dpy, vi, NULL, GL_TRUE);
	glXMakeCurrent(dpy, win, glc);
	
	printf("argc = %d\n", argc);
	int i;
	for(i = 1; i < argc; i++) {
		filename = argv[i];
	}
	
	if(filename == NULL) {
		printf("No ROM input\n");
		
		quit();
		return 1;
	}
	
	printf("Loading file \"%s\"...\n", filename);
	
	if(!loadROM(filename)) {
		printf("Failed!\n");
		
		quit();
		return 1;
	}
	
	printf("Passed!\n");
	
	srand(time(NULL));
	reset();
	
	while(1) {
		if(XPending(dpy)) {
			XNextEvent(dpy, &xev);
			
			if(xev.type == KeyPress || xev.type == KeyRelease) {
				switch(xev.xkey.keycode) {
					//case XK_BackSpace:
					case 59:
						keys.select = (xev.type == KeyPress ? 1 : 0);
						break;
					
					//case XK_Return:
					case 44:
						keys.start = (xev.type == KeyPress ? 1 : 0);
						break;
					
					//case XK_z:
					case 14:
						keys.b = (xev.type == KeyPress);
						break;
					
					//case XK_x:
					case 15:
						keys.a = (xev.type == KeyPress);
						break;
					
					//case XK_Left:
					case 131:
						keys.left = (xev.type == KeyPress);
						break;
					
					//case XK_Right:
					case 132:
						keys.right = (xev.type == KeyPress);
						break;
					
					//case XK_Up:
					case 134:
						keys.up = (xev.type == KeyPress);
						break;
					
					//case XK_Down:
					case 133:
						keys.down = (xev.type == KeyPress);
						break;
				}
			}
		}
		
		cpuStep();
		gpuStep();
		interruptStep();
	}
	
	quit();
	
	return 0;
}