Exemplo n.º 1
0
int main()
{
  int select;
  int err=1;
  /* array of grid members */
  GridMember** memberList;
  memberList = createGridList();
  /* setting random generator */
  srand(time(NULL));
  /* create game grid members */
  while(err) {
    /* clear screen and always show title */
    displayTitle();
    /* config game options */
    configGame(&select);
    err = createGridMembers(memberList, select);
  }
  /* enter game loop */
  while(1) {
    /* clear screen and always show title */
    displayTitle();
    /* show game grid */
    showGrid(memberList);
    /* count neighbours */
    countNeighbours(memberList);
    /* update status */
    updateGrid(memberList);
    /* time tick */
    timeTick();
  }
  displayEnd();
  freeGridList(memberList);
  return 0;
}
Exemplo n.º 2
0
int main(int argc, char **argv){

    SDL_Event event;                   //Event handler
    //init_apu();
    int QUIT = FALSE;
    
	if (argc < 2){
		printf("No Rom\n");
		return 1;
	}
	
	if (loadRom(argv[1])){
		return 1;
	}
    
    if (displayInit()){
        return 1;
    }
    
	
	hardwareReset();
    
    printf("[INFO] Version %s\n",version);
	printf("[INFO] System reset done\n");
    printf("[INFO] BUTTON A  = a\n");
    printf("[INFO] BUTTON B  = s\n");
    printf("[INFO] START     = q\n");
    printf("[INFO] SELECT    = w\n");
    printf("[INFO] DIRECTION = arrow keys\n");
    //display();
    
    int count = 0;
	
    while (!QUIT) {
    
        count++;    
        
        if (count > 100){                   /* Poll for events every 100 loops */  
            while (SDL_PollEvent(&event)) {
                
                inputHandleEvents(event);
                
                if( event.type == SDL_QUIT ) { 
                    QUIT = TRUE;
                }
        
                if (event.type == SDL_KEYDOWN){
                    if (event.key.keysym.sym == SDLK_ESCAPE){
                        QUIT = TRUE;
                    }
                    if (event.key.keysym.sym == SDLK_F1){
                        displayEnd();
                        return 1;
                    }
                    if (event.key.keysym.sym == SDLK_F9){
                        hardwareReset();
                    }
                }
                //inputHandleEvents(event);
                
            }
        count = 0;
        }       
              
		execute();
		//inputHandleEvents(event);
	}

    updateMBC2SRAM();   
    displayEnd();
	
return 0;
}