Example #1
0
void waitclickwin(SDL_Surface *scr, char *toquit, CurrentMenu *clickedmenu)
{
    int click = 0;
    SDL_Event event;

    while(!click)
    {
        SDL_WaitEvent(&event);
        switch(event.type)/*kattintasra vagy gomb lenyomasra a fomenube jut vissza*/
        {
            case SDL_QUIT:
                *toquit = click = 1;
                break;
            case SDL_KEYDOWN:
                click = 1;
                *clickedmenu = MAIN;
                clearscreen(scr);
                break;
            case SDL_MOUSEBUTTONUP:
                click = 1;
                *clickedmenu = MAIN;
                clearscreen(scr);
                break;
        }
    }
}
Example #2
0
void waitclickscoressmenu(SDL_Surface *scr, char *toquit, CurrentMenu *clickedmenu, int *diff)
{
    int click = 0;
    SDL_Event event;
    while(!click)
    {
        SDL_WaitEvent(&event);
        switch (event.type)
        {
            case SDL_QUIT:
                click = *toquit = 1;
                break;
            case SDL_MOUSEBUTTONUP:
                if (event.button.button == SDL_BUTTON_LEFT && /*ha a vissza gombra kattint -> vissza a fomenube*/
                    event.button.x < scr->w-20 && event.button.x > scr->w-160 &&
                    event.button.y < scr->h-20 && event.button.y > scr->h-70)
                {
                    click = 1;
                    *clickedmenu = MAIN;
                    clearscreen(scr);
                }
                else if(event.button.button == SDL_BUTTON_LEFT && /*ha a nyilakra kattint, akkor ranglistak kozotti valtas*/
                        ((event.button.x < (scr->w/2)-90 && event.button.x > (scr->w/2)-110) ||
                        (event.button.x > (scr->w/2)+90 && event.button.x < (scr->w/2)+110)) &&
                        event.button.y < 445 && event.button.y > 415)
                {
                    click = 1;
                    *diff = *diff ? 0 : 1;
                    clearscreen(scr);
                }
                break;
        }
    }
}
Example #3
0
void waitclickmainmenu(SDL_Surface *scr, char *toquit, CurrentMenu *clickedmenu)
{
    SDL_Event event;
    int click = 0, column1, column2, row1, row2;
    while (!click)
    {
        SDL_WaitEvent(&event);
        column1 = event.button.x < scr->w/2-20 && event.button.x > scr->w/2-280;
        column2 = event.button.x > scr->w/2+20 && event.button.x < scr->w/2+280;
        row1 = event.button.y < 210 && event.button.y > 150;
        row2 = event.button.y < 310 && event.button.y > 250;
        switch(event.type)
        {
            case SDL_QUIT: /*Ha a piros x-re kattint*/
                click = 1;
                *toquit = 1;
                break;
            case SDL_MOUSEBUTTONUP:
                if (event.button.button == SDL_BUTTON_LEFT &&
                    event.button.x < scr->w/2+130 && event.button.x > scr->w/2-130 &&
                    event.button.y < 410 && event.button.y > 350) /*Ha a kilepesra kattint*/
                        click = *toquit = 1;
                else if (event.button.button == SDL_BUTTON_LEFT &&
                         column1 && row2) /* Ha a beallitasokra kattint*/
                    {
                        *clickedmenu = OPTIONS;/*valtas beallitasok menure*/
                        click = 1;
                        clearscreen(scr);
                    }
                else if (event.button.button == SDL_BUTTON_LEFT &&
                         column1 && row1) /* Ha az Uj jatekra kattint*/
                    {
                        *clickedmenu = NEWGAME;/*Jatek!*/
                        click = 1;
                        clearscreen(scr);
                    }
                else if (event.button.button == SDL_BUTTON_LEFT &&
                         column2 && row1 && fexist("save.txt"))/*ha a betoltesre kattint*/
                    {
                        *clickedmenu = LOADGAME;
                        click = 1;
                        clearscreen(scr);
                    }
                else if (event.button.button == SDL_BUTTON_LEFT &&
                         column2 && row2) /*Ha a ranglistara kattint*/
                    {
                        *clickedmenu = SCORES;/*Ranglista*/
                        click = 1;
                        clearscreen(scr);
                    }
                break;
        }
    }
}
Example #4
0
/* update the position Data on the display */
void Display::update(long _scenePos, long _framePos, long _x, long _y, long _z) {
  if (_framePos < 1) {
    clearscreen();
    moveto(1,1);
    Serial.print("go to scene "); 
    moveto(13,1);
    Serial.print(_scenePos); 
    moveto(16,1);
    Serial.print("T"); 
    moveto(17,1);
    Serial.print(_framePos); 

    moveto(1,2);
    Serial.print("x"); 
    moveto(2,2);
    Serial.print(_x); 
    moveto(8,2);
    Serial.print("y"); 
    moveto(9,2);
    Serial.print(_y); 
    moveto(15,2);
    Serial.print("z"); 
    moveto(16,2);
    Serial.print(_z); 
  } else {
    clearscreen();
    moveto(1,1);
    Serial.print("scene "); 
    moveto(7,1);
    Serial.print(_scenePos); 
    moveto(10,1);
    Serial.print("frame "); 
    moveto(16,1);
    Serial.print(_framePos); 
 
    moveto(1,2);
    Serial.print("x"); 
    moveto(2,2);
    Serial.print(_x); 
    moveto(8,2);
    Serial.print("y"); 
    moveto(9,2);
    Serial.print(_y); 
    moveto(15,2);
    Serial.print("z"); 
    moveto(16,2);
    Serial.print(_z); 
  }
}
Example #5
0
void mainmenu(void)
{
	int running = GL_TRUE;
	uint32 time;
	uint32 lpstimer = 0;
	uint32 lps = 0;

	while( running )
	{
		time = (uint32)glfwGetTime();

		clearscreen(1,1,1,1);

		drawstatereset();
		widgetmanager();
		//Clear information from last draw
		glFlush();
		glfwSwapBuffers();

		if(lpstimer < time)
		{//calculates the loops per second the code does, through everything
			printf("%i\n",lps);
			lpstimer = time + 1;

			lps = 0;
		}

		lps += 1;

		//glfwSleep(.005); //used to save cpu

		// Check if ESC key was pressed or window was closed
		running = glfwGetWindowParam( GLFW_OPENED );
	}
}
Example #6
0
/*
void test(void)
{
	window win;
	char name[10]="window";
	clearscreen();
	win_init(&win,1,1,10,40,name,blightgray|fwhite,blightgray|fblack);
	win_create(&win);

	win_putchar(&win,'n');
	win_putchar(&win,'\n');

	int i;
	for(i=0;i<7;i++)
	win_putstring(&win,"testing win_putstring\n");/
	for(i=0;i<4;i++)//
	win_putstring(&win,"new line\n");

}
*/
int main(struct multiboot *mboot_ptr)
{
	welcome();		

	init_descriptor_tables();

	asm volatile("sti");
	
	init_timer(1);

	wait(1);
	win_clear(&win_boot);

	win_putstring(&win_boot,"\ninitializing timer...\t");
	wait(1);
	win_putstring(&win_boot," done");

	win_putstring(&win_boot,"\ninitializing keyboard...\t");
	init_kbd();
	wait(1);
	win_putstring(&win_boot," done");

	win_putstring(&win_boot,"\npress any key to continue...\n");

	u8int s,a;

	kbd_read(&s,&a);

	clearscreen();
	terminal();	
	
	while(1);	
    return 0;

}
Example #7
0
int main() {
    init();
    clearscreen();
	isShoot = 0;
    pthread_t plane;
    pthread_create(&plane,NULL,threadHandler,NULL);
	degree = 0;
	int c;
	while(1){
		key = kbhit();
		if (!key){
		
		}
		else {
			c = getchar();
			if(c == 'd') {
				if (degree <= 87)
					degree +=1;
				target(degree);
			}
			else if(c == 'a') {
				if (degree >= 1)
					degree -=1;
				target(degree);
			}
			else if(c == '\n'){
				isShoot = shoot();
			}
				key = 0;
		}
	}
    munmap(fbp, screensize);
    close(fbfd);
    return 0;
}
Example #8
0
int main()
{
    //maakt buiten kant weg
    for( j = 0 ; j < 75 ; ++j ){
        for( i = 0; i < 75 ; ++i ){
            map[j][linksbuiten] = '|';
            map[j][rechtsbuiten] = '|';
        }
    }
    //maakt de binnen weg
    for(int i=0; i < 20; ++i) {
        for(int j=0; j < 20; ++j) {
            map[i][linksbinnen] = '#';
            map[i][rechtsbinnen] = '#';
        }
    }

    for( ; ; )
    {
        weggetje();
        clearscreen();
        //getch();
        acceleration();
        keyhit();
    }
}
Example #9
0
void Display::boot() {
  clearscreen();
  moveto(1,1);
  Serial.print("check film state &");
  moveto(1,2);
  Serial.print("start or rewind film");
}
Example #10
0
void PrintCenteredTextLine(char textstring[]){
	SDL_Color text_color;
	text_color.r = foreground_color.r;
	text_color.g = foreground_color.g;
	text_color.b = foreground_color.b;
	
	SDL_Surface *textSurface = TTF_RenderText_Blended(fntc64, textstring, text_color);
	
	SDL_Rect textDestRect;
	
	if (textSurface) {
		/* now center it horizontally and position it just below the logo */
		textDestRect.x = (screen->w - textSurface->w) / 2;
		textDestRect.y = GetTextYPos(text_row);
		textDestRect.w = textSurface->w;
		textDestRect.h = textSurface->h;
		SDL_BlitSurface(textSurface, NULL, screen, &textDestRect);
		SDL_FreeSurface(textSurface);
	}
	SDL_Flip(screen);
	
	text_row++; /* increment the text display row */

	/* Check if the text has hit the bottom of the screen */
	if(text_row> total_text_rows)
	{
		clearscreen();  /* reset the row to the 0 and clear the screen */
	}

	
}
Example #11
0
void makeframe()
{
	reshapeviewport();
	getsize(&xsize,&ysize);
	getorigin(&xorg,&yorg);
	clearscreen();
}
Example #12
0
File: menu.c Project: graue/spray
int showmenu(const int score)
{
	char scorestring[12] = "";
	SDL_Event event;

	snprintf(scorestring, sizeof scorestring, "%d", score);
	displaytext(scorestring);

	while (1)
	{
		if (SDL_PollEvent(&event))
		{
			if (event.type == SDL_QUIT)
				return 0;
			if (event.type != SDL_KEYDOWN)
				continue;
			if (event.key.keysym.sym == SDLK_ESCAPE)
				return 0;
			if (event.key.keysym.sym != SDLK_SPACE
				&& event.key.keysym.sym != SDLK_RETURN)
			{
				continue;
			}
			break;
		}
		else
			SDL_Delay(10);
	}

	clearscreen();
	return 1;
}
Example #13
0
void gfx_set_picasso_modeinfo (uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgbfmt)
{
	printf("gfx_set_picasso_modeinfo %d %d %d %d\n", w, h, depth, rgbfmt);
	exit(1);
#if 0
	int need;
	if (!screen_is_picasso)
		return;
	clearscreen ();
#endif
	gfx_set_picasso_colors (rgbfmt);
#if 0
	updatemodes ();
	need = modeswitchneeded (currentmode);
	update_gfxparams ();
	if (need > 0) {
		open_screen ();
	} else if (need < 0) {
		open_windows (0);
	}
#endif
#ifdef RETROPLATFORM
	rp_set_hwnd (hAmigaWnd);
#endif
}
Example #14
0
void pause(int i) {
#ifdef CLOAKING
	if (iscloaked) return;
#endif
	putchar('\n');
	if (i==1) {
		if (skill > SFAIR)
			prout("[ANNOUNCEMENT ARRIVING...]");
		else
			prout("[IMPORTANT ANNOUNCEMENT ARRIVING -- HIT SPACE BAR TO CONTINUE]");
		getch();
	}
	else {
		if (skill > SFAIR)
			proutn("[CONTINUE?]");
		else
			proutn("[HIT SPACE BAR TO CONTINUE]");
		getch();
		proutn("\r                           \r");
	}
	if (i != 0) {
		clearscreen();
	}
    linecount = 0;
}
/* ### le thread du cercle ### */
void * cercle_run(void * args) {
    struct cercle_run_args * the_args = args;

    while(get_stop_machine() != 1) {
        //sleep(1); // slowing simulation
        pthread_mutex_lock(&mutex_cercle);
        // On attend que tout les robots aient fini
        printf("On attend que les robots soient prets\n");
        while(nb_robot_fini < the_args->nb_robot && get_stop_machine() != 1) {
            pthread_cond_wait(&cond_fin_robot, &mutex_cercle);
            printf("arrivee d'un robot (%d/%d)\n", nb_robot_fini, the_args->nb_robot);
        }
        clearscreen();
        // On fait tourner le cercle
        printf("On fait tourner le cercle\n");
        cercle_tourner(the_args->nb_sections);
        // On reveille les robots
        printf("On previent tout les robots que le cercle a tourné\n");
        pthread_cond_broadcast(&cond_start_robot);
        nb_robot_fini = 0;
        pthread_mutex_unlock(&mutex_cercle);
    }
    // on debloque les robots qui attendaient déja
    pthread_cond_broadcast(&cond_start_robot);

    free(the_args);

    return (void *) 0;
}
Example #16
0
File: plane.c Project: entropia/lcd
int main(int argc, char *argv[]) {
    int i=0;
    int x=40,y=20;
    srandom(time(NULL));
    while(1) {
        if (i==0) {
            x=rand()%XSIZE;
            y=rand()%YSIZE;
            clearscreen();
        }
        printf("fljsdf\n");
        i=(i+1)%1000;

            x=XSIZE+(x-1+rand()%2) % XSIZE;
            y=YSIZE+(y-1+rand()%2) % YSIZE;
            setpixel(x,y);
            setpixel(x+1,y);
            setpixel(x+1,y+1);
            setpixel(x,y+1);
        
        writescreen();
        usleep(15000);
    }
    return 0;
}
Example #17
0
File: loop.c Project: laaph/FTRV
void upgrade_ship()
{
    clearscreen();
    draw_ship_info(2, 2);
    draw_upgrade_menu(42, 2);
    // Do upgrade switch
    
}
Example #18
0
static void setadplugvideo()
  /* Setup AdPlay's idea of the video state */
{
  setvideomode(3);
  if(hivideo) load88font();
  clearscreen(backcol);
  hidecursor();
}
Example #19
0
static void drawscreen (void) {

/* This is the screen redrawing routine that event_loop assumes exists.  *
 * It erases whatever is on screen, then calls redraw_screen to redraw   *
 * it.                                                                   */

 clearscreen();
 redraw_screen ();
}
Example #20
0
/**
 * Showfile screen
 *
 * Display the file selection to the user
 */
static void
ShowFiles (int offset, int selection)
{
  int i, j;
  char text[MAXPATHLEN];
  int ypos;
  int w;
  
  setfontsize(18);
  clearscreen ();

  ypos = (screenheight - ((PAGESIZE - 1) * 20)) >> 1;

  if (screenheight == 480)
    ypos += 24;
  else
    ypos += 10;


  j = 0;
  for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)

    {
      if (filelist[i].flags)	// if a dir

        {
          strcpy (text, "[");
          strcat (text, filelist[i].displayname);
          strcat (text, "]");
        }

      else
        strcpy (text, filelist[i].displayname);
      if (j == (selection - offset))

        {

            /*** Highlighted text entry ***/
          for ( w = 0; w < 20; w++ )
                DrawLineFast( 30, 610, ( j * 20 ) + (ypos-16) + w, 0x80, 0x80, 0x80 );

          setfontcolour (0x00, 0x00, 0xe0);
          DrawText (-1, (j * 20) + ypos, text);
          setfontcolour (0x00, 0x00, 0x00);
        }

      else

        {
                        /*** Normal entry ***/
          DrawText (-1, (j * 20) + ypos, text);
        }
      j++;
    }
  showscreen ();

}
Example #21
0
/* -------------------------------------------------------------------------- */
void
fbanner( cstream sout )
{   char date[16], time[9];

    when(date, time);
    clearscreen();
    fprintf( sout, "\n-------------------------------------------------------\n" );
    fprintf( sout, "\t%s \n\t%s \n\t%s  %s\n", NAME, CLASS, date, time );
    fprintf( sout,   "-------------------------------------------------------\n" );
}
Example #22
0
int main(void)
{
	OSInit();
	volatile short * pixel_ctrl_ptr = pixel_buffer_start;
	volatile char * char_ctrl_ptr = character_buffer;
	int err = ALT_SEM_CREATE(&display,1);
	if(err != 0)
		printf("Semaphore not created\n");
	 err = ALT_SEM_CREATE(&audio,1);
	if(err != 0)
		printf("Semaphore not created\n");

	*(dma_control) &= (1<<2); //Enable DMA controller

	clearscreen(pixel_ctrl_ptr);
	drawbox(pixel_ctrl_ptr, 34*4, 9*4, 48, 10,0xFA01);

	wait_for_vsync(buffer_register,dma_control);




	OSTaskCreateExt(task1,
			pixel_ctrl_ptr,
			(void *)&task1_stk[TASK_STACKSIZE-1],
			TASK1_PRIORITY,
			TASK1_PRIORITY,
			task1_stk,
			TASK_STACKSIZE,
			NULL,
			0);


	OSTaskCreateExt(task2,
			char_ctrl_ptr,
			(void *)&task2_stk[TASK_STACKSIZE-1],
			TASK2_PRIORITY,
			TASK2_PRIORITY,
			task2_stk,
			TASK_STACKSIZE,
			NULL,
			0);

	OSTaskCreateExt(getcontrols,
			char_ctrl_ptr,
			(void *)&getcontrols_stk[TASK_STACKSIZE-1],
			GETCONTROLS_PRIORITY,
			GETCONTROLS_PRIORITY,
			getcontrols_stk,
			TASK_STACKSIZE,
			NULL,
			0);
	OSStart();
	return 0;
}
void drawLogs()
{
	int i=which_logfile, j, k, l, done=0;
	s_screen *Viewer = NULL;

	bothkeys = bothnewkeys = 0;
	Viewer = allocscreen(Source->width, Source->height, Source->pixelformat);
	clearscreen(Viewer);
	bothkeys = bothnewkeys = 0;

	while(!done)
	{
	    copyScreens(Viewer);
	    //inputrefresh();
	    refreshInput();
	    printText((isWide ? 410 : 250), 3, RED, 0, 0, "Quit : 1/B");
		if(buttonsPressed & (WIIMOTE_1|CC_B|GC_B)) done = 1;

		if(logfile[i].ready)
		{
			printText(5, 3, RED, 0, 0, "OpenBorLog.txt");
			if(buttonsHeld & DIR_UP) --logfile[i].line;
	        if(buttonsHeld & DIR_DOWN) ++logfile[i].line;
			if(buttonsHeld & DIR_LEFT) logfile[i].line = 0;
			if(buttonsHeld & DIR_RIGHT) logfile[i].line = logfile[i].rows - (LOG_SCREEN_END - LOG_SCREEN_TOP);
			if(logfile[i].line > logfile[i].rows - (LOG_SCREEN_END - LOG_SCREEN_TOP) - 1) logfile[i].line = logfile[i].rows - (LOG_SCREEN_END - LOG_SCREEN_TOP) - 1;
			if(logfile[i].line < 0) logfile[i].line = 0;
			for(l=LOG_SCREEN_TOP, j=logfile[i].line; j<logfile[i].rows-1; l++, j++)
			{
				if(l<LOG_SCREEN_END)
				{
					char textpad[480] = {""};
					for(k=0; k<480; k++)
					{
						if(!logfile[i].buf->ptr[logfile[i].pos[j]+k]) break;
						textpad[k] = logfile[i].buf->ptr[logfile[i].pos[j]+k];
					}
					if(logfile[i].rows>0xFFFF)
						printText(5, l*10, WHITE, 0, 0, "0x%08x:  %s", j, textpad);
					else
						printText(5, l*10, WHITE, 0, 0, "0x%04x:  %s", j, textpad);
				}
				else break;
			}
		}
		else if(i == SCRIPT_LOG) printText(5, 3, RED, 0, 0, "Log NOT Found: ScriptLog.txt");
		else                     printText(5, 3, RED, 0, 0, "Log NOT Found: OpenBorLog.txt");

	    drawScreens(NULL, 0, 0);
	}
	freescreen(&Viewer);
	Viewer = NULL;
	drawMenu();
}
Example #24
0
static void drawInit( int sizex, int sizey, char* seqName, char* filename, float score) {

 int i,k=0;
 int x,y;
 char* c;
 c =(char*)malloc(sizeof(char)*1000);
 


/* initialize display */
 init_graphics("RNA");


/* still picture drawing allows user to zoom, etc. */
 init_world (0.,0.,CELLSIZE*sizex,CELLSIZE*sizey);
 //event_loop(button_press, drawscreen);   

/* animation section */
 clearscreen();
 init_postscript(filename);
 clearscreen();
 
 sprintf(c, "%s%s%s%d%s%f%s", "RNA: ", seqName, ", length = ", sizex, ", energy = ",-score/1000.0, " kal/mol");
 //printf(" output string is %s\n",c);
 update_message("RNA secondary structure");
 flushinput();
 
 drawtext (sizex*CELLSIZE/2,sizey*CELLSIZE/10,c,1.0e6);
 flushinput();
 setcolor (BLACK);
 setlinewidth(1);
 setlinestyle (SOLID);
 for (i=0;i<=sizex;i++) {
    drawline (i*CELLSIZE,(sizey/2-1)*CELLSIZE,i*CELLSIZE,CELLSIZE*sizey/2);
    flushinput();
 }
 drawline(0,(sizey/2-1)*CELLSIZE, sizex*CELLSIZE, CELLSIZE*(sizey/2-1));
 drawline(0,sizey*CELLSIZE/2, sizex*CELLSIZE, CELLSIZE*sizey/2);
 flushinput();
 free(c);
}
Example #25
0
void freeze()
{
	int i;
	// store custom chips
	store_mem[0xd300] = *atari_portb;
	{
		//backup last value written to custom chip regs
		//gtia
		memcp8(custom_mirror,store_mem,0xd000,0x20);
		//pokey1/2
		memcp8(custom_mirror,store_mem,0xd200,0x20);
		//antic
		memcp8(custom_mirror,store_mem,0xd400,0x10);

		// Write 0 to custom chip regs
		memset8(atari_base+0xd000,0,0x20);
		memset8(atari_base+0xd200,0,0x20);
		memset8(atari_base+0xd400,0,0x10);
	}

	*atari_portb = 0xff;

	// Copy 64k ram to sdram
	// Atari screen memory...
	memcp8(atari_base,store_mem,0,0xd000);
	memcp8(atari_base,store_mem,0xd800,0x2800);

	//Clear, except dl (first 0x40 bytes)
	clearscreen();

	// Put custom chips in a safe state
	// write a display list at 0600
	memcp8(dl,atari_base+0x600,0,sizeof(dl));

	// point antic at my display list
	*atari_dlisth = 0x06;
	*atari_dlistl = 0x00;

	*atari_colbk = 0x00;
	*atari_colpf0 = 0x2f;
	*atari_colpf1 = 0x3f;
	*atari_colpf2 = 0x00;
	*atari_colpf3 = 0x1f;
	*atari_prior = 0x00;
	*atari_chbase = 0xe0;
	*atari_dmactl = 0x22;
	*atari_skctl = 0x3;
	*atari_chactl = 0x2;
}
Example #26
0
void shoot(){
    cleararea(133,298,227,392);
	int xPos = calculateX(135+degree, calculateY(135+degree));
	int yPos;
	if (xPos == 750){
		yPos = calculateIfXMax(135+degree, calculateY(135+degree));
	}
	else {
		yPos = 20;
	}
    draw_line(135,390,xPos,yPos,pixel_color(200,0,0,&vinfo));
    usleep(10000);
    clearscreen();
	target(degree);
}
Example #27
0
File: loop.c Project: laaph/FTRV
void refuel()
{
    int input;
    int cost_of_fuel = 2;
    int max_fuel = 20;
    
    while(true)
    {
        clearscreen();
        drawspaceship (4, 2);
        drawcharacters(4, 2);
        drawroomnumbers(4, 2);
        drawstats();
        
        if(player_ship.fuel >= max_fuel)
        {
            draw_gas_station_all_full(10,10);
            refresh();
            getch();
            return;
        }
        draw_gas_station(10, 10, player_ship.fuel, max_fuel, cost_of_fuel);
        refresh();
        
        input = getch();
        if(input == 27 || input == 'x' || input == 'X')
        {
            return;
        }
        if(input == '0' && (max_fuel - player_ship.fuel > 10) && (money > 10 * cost_of_fuel))
        {
            money = money - (10 * cost_of_fuel);
            player_ship.fuel = player_ship.fuel + 10;
        }
        if(input >= '1' && input <= '9')
        {
            // We can do this later
        }
        if((input == 'F' || input == 'f') && ( money >= 10 * cost_of_fuel * (max_fuel - player_ship.fuel)))
        {
            money = money - cost_of_fuel * (max_fuel - player_ship.fuel);
            player_ship.fuel = 20;
        }
    }
    
}
Example #28
0
/* 0x1000 */
void _start(void)
{
    clearscreen();

    init_gdt();
    print("Loading IDT\n");
    init_idt();
    print("Loading PIC\n");
    init_pic();
    print("Running kmain()\n");
    sti;

    kmain();                    /* Call kernel's kmain() */

    while (1)
    {                           /* Never return */
        print("hlt;\n");
    }
}
int main(int argc, char **argv){
	setvbuf (stdout, NULL, _IONBF, 0); // needed to print to the command line

	while (1){
		clearscreen();
		printf("Pin 1: %G \n", read_voltage(0x68,1, 18, 1, 1)); // read from adc chip 1, channel 1, 18 bit, pga gain set to 1 and continuous conversion mode
		printf("Pin 2: %G \n", read_voltage(0x68,2, 16, 1, 1)); // read from adc chip 1, channel 2, 16 bit, pga gain set to 1 and continuous conversion mode
		printf("Pin 3: %G \n", read_voltage(0x68,3, 14, 1, 1)); // read from adc chip 1, channel 3, 14 bit, pga gain set to 1 and continuous conversion mode
		printf("Pin 4: %G \n", read_voltage(0x68,4, 12, 1, 1)); // read from adc chip 1, channel 4, 12 bit, pga gain set to 1 and continuous conversion mode
		printf("Pin 5: %G \n", read_voltage(0x69,1, 12, 1, 1)); // read from adc chip 2, channel 1, 12 bit, pga gain set to 1 and continuous conversion mode
		printf("Pin 6: %G \n", read_voltage(0x69,2, 12, 1, 1)); // read from adc chip 2, channel 2, 12 bit, pga gain set to 1 and continuous conversion mode
		printf("Pin 7: %G \n", read_voltage(0x69,3, 12, 1, 1)); // read from adc chip 2, channel 3, 12 bit, pga gain set to 1 and continuous conversion mode
		printf("Pin 8: %G \n", read_voltage(0x69,4, 12, 1, 1)); // read from adc chip 2, channel 4, 12 bit, pga gain set to 1 and continuous conversion mode
		usleep(200000); // sleep 0.2 seconds

	}

	return (0);
}
Example #30
0
/*
 * Function Name: Timer0IntHandler()
 * Input: none
 * Output: none
 * Description: Interrupt handler for timerA
 * Example Call: Timer0IntHandler();
 */
void Timer0IntHandler(void) {
	// Clear the timer interrupt
	TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	unsigned char deg = 176;
	if (mode == 0) {
		clearscreen();
		UARTCharPut(UART0_BASE, 'C');
		UARTCharPut(UART0_BASE, 'u');
		UARTCharPut(UART0_BASE, 'r');
		UARTCharPut(UART0_BASE, 'r');
		UARTCharPut(UART0_BASE, 'e');
		UARTCharPut(UART0_BASE, 'n');
		UARTCharPut(UART0_BASE, 't');
		UARTCharPut(UART0_BASE, ' ');
		UARTCharPut(UART0_BASE, 'T');
		UARTCharPut(UART0_BASE, 'e');
		UARTCharPut(UART0_BASE, 'm');
		UARTCharPut(UART0_BASE, 'p');
		UARTCharPut(UART0_BASE, ' ');
		UARTCharPut(UART0_BASE, (ui32TempValueC) / 10 + '0');
		UARTCharPut(UART0_BASE, (ui32TempValueC) % 10 + '0');
		UARTCharPut(UART0_BASE, ' ');
		UARTCharPut(UART0_BASE, deg);
		UARTCharPut(UART0_BASE, 'C');
		UARTCharPut(UART0_BASE, ',');
		UARTCharPut(UART0_BASE, ' ');
		UARTCharPut(UART0_BASE, 'S');
		UARTCharPut(UART0_BASE, 'e');
		UARTCharPut(UART0_BASE, 't');
		UARTCharPut(UART0_BASE, ' ');
		UARTCharPut(UART0_BASE, 'T');
		UARTCharPut(UART0_BASE, 'e');
		UARTCharPut(UART0_BASE, 'm');
		UARTCharPut(UART0_BASE, 'p');
		UARTCharPut(UART0_BASE, ' ');
		UARTCharPut(UART0_BASE, (ui32SetTempValueC) / 10 + '0');
		UARTCharPut(UART0_BASE, (ui32SetTempValueC) % 10 + '0');
		UARTCharPut(UART0_BASE, ' ');
		UARTCharPut(UART0_BASE, deg);
		UARTCharPut(UART0_BASE, 'C');
		UARTCharPut(UART0_BASE, '\r');
	}
}