void my_display(void) { #ifdef ANTIALIASING int passes = 8; int i; #endif #ifdef BLACK_LETTERS_WHITE_BACKGROUND glClearColor(1.0, 1.0, 1.0, 0.0); #else glClearColor(0.0, 0.0, 0.0, 0.0); #endif #ifdef ANTIALIASING glClear(GL_ACCUM_BUFFER_BIT); for (i=0; i<passes; i++) { glClear(GL_COLOR_BUFFER_BIT); do_ortho(GL_TRUE, j8[i].x, j8[i].y); draw_logo(scale); glAccum(GL_ACCUM, 1.0/(GLfloat)passes); } glAccum(GL_RETURN, 1.0); glFlush(); #else glClear(GL_COLOR_BUFFER_BIT); do_ortho(GL_FALSE, 0.0, 0.0); draw_logo(scale); #endif glutSwapBuffers(); }
void draw(void) { if ( u8g_GetMode(&u8g) == U8G_MODE_HICOLOR || u8g_GetMode(&u8g) == U8G_MODE_R3G3B2) { COLOR_BOX(); } if ( u8g_GetMode(&u8g) == U8G_MODE_HICOLOR || u8g_GetMode(&u8g) == U8G_MODE_R3G3B2) { u8g_SetRGB(&u8g, 0x080, 0x040, 0); draw_logo(2); u8g_SetRGB(&u8g, 0x080, 0x080, 0); draw_logo(1); u8g_SetRGB(&u8g, 0x0ff, 0x0ff, 0); } else { u8g_SetColorIndex(&u8g, 1); if ( U8G_MODE_GET_BITS_PER_PIXEL(u8g_GetMode(&u8g)) > 1 ) { draw_logo(2); u8g_SetColorIndex(&u8g, 2); draw_logo(1); u8g_SetColorIndex(&u8g, 3); } } draw_logo(0); draw_url(); }
static void main_menu_background_draw(void) { glPushAttrib(GL_ALL_ATTRIB_BITS); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(20, -5, -eye_z); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, (GLfloat *)&light_pos); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); draw_background(0, 0, 0); glMatrixMode(GL_MODELVIEW); glPopMatrix(); if (menu_is_on_top_level(main_menu)) { draw_logo(); if (menu_is_visible()) { draw_highscore_table(380, 20 + (float)highscore_spread*(400 - 20)/ START_HIGHSCORE_SPREAD, highscore_spread); } } glPopAttrib(); }
void load_settings(void){ int i; struct screen* display; FOR_NB_SCREENS(i){ display=rb->screens[i]; display->clear_display(); draw_logo(display); draw_message(display, MESSAGE_LOADING, 1); display->update(); } enum settings_file_status load_status= clock_settings_load(&clock_settings, settings_filename); FOR_NB_SCREENS(i){ display=rb->screens[i]; if(load_status==LOADED) draw_message(display, MESSAGE_LOADED, 1); else draw_message(display, MESSAGE_ERRLOAD, 1); display->update(); } rb->storage_sleep(); rb->sleep(HZ); }
void render(void) { CLEAR; // Logo glColor3f(0.5, 0.75, 0.25); PUSH; glTranslatef(70, 90, 0); glScalef(5, 5, 1); draw_logo(); POP; // Text 'OPENGL LEARNING' glColor3f(0.8, 0.55, 0.25); PUSH; glTranslatef(-120, 90, 0); glScalef(6, 6, 1); draw_string("OPENGL"); POP; PUSH; glTranslatef(-120, 76, 0); glScalef(4.2, 4, 1); draw_string("LEARNING"); POP; PUSH; draw(); POP; SWAP; }
void save_settings(void){ int i; struct screen* display; if(!settings_needs_saving(&clock_settings)) return; FOR_NB_SCREENS(i){ display=rb->screens[i]; display->clear_display(); draw_logo(display); draw_message(display, MESSAGE_SAVING, 1); display->update(); } enum settings_file_status load_status= clock_settings_save(&clock_settings, settings_filename); FOR_NB_SCREENS(i){ display=rb->screens[i]; if(load_status==SAVED) draw_message(display, MESSAGE_SAVED, 1); else draw_message(display, MESSAGE_ERRSAVE, 1); display->update(); } rb->sleep(HZ); }
int mcde_logo_init(void) { if (!load_565rle_image(INIT_IMAGE_FILE)) draw_logo(); return 0; }
void do_display (void) { #ifdef STEREO /* enclose original rendering code in 2-pass loop */ int i; for (i=0; i<2; i++) { /* select left, right, or default back buffer for drawing */ glDrawBuffer(stereo ? ((i==0) ? GL_BACK_LEFT : GL_BACK_RIGHT) : GL_BACK); /* select left, right, or default central viewpt for camera */ viewpt = (stereo) ? ((i==0) ? +1 : -1) : 0; #endif SetCamera(); draw_logo(); glFlush(); #ifdef STEREO /* render twice for stereo, or only once for mono */ if (!stereo) break; } #endif glutSwapBuffers(); }
/* free all graphics */ static void mw_shutdown () { chat_show (-1, -1, -1, -1); gfx_blitdraw (); draw_logo (); SDL_Flip (gfx.screen); };
int __init logo_init(void) { if (display_on_in_boot) printk(KERN_INFO "Skip drawing logo. Already drawn in boot.\n"); else if (!load_565rle_image(INIT_IMAGE_FILE)) draw_logo(); return 0; }
/* this will load some graphics and so other stuff */ static void mw_init () { team_update (); gfx_blitdraw (); draw_logo (); gfx_blitdraw (); bman.updatestatusbar = 1; d_playerdetail ("mw_init:\n"); SDL_Flip (gfx.screen); chat_show (10, gfx.res.y / 2, gfx.res.x - 20, gfx.res.y / 2 - 10); chat_setactive (1, 1); };
/* スレッドからの要求を処理する */ static int display_cmdproc(char *p) { int cmd = p[0]; switch (cmd) { case DISPLAY_CMD_LCD_CLEAR: NTLEVT_START(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_CLEAR); sg12232c_clear(); NTLEVT_END(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_CLEAR); break; case DISPLAY_CMD_LCD_DRAW_BOX: NTLEVT_START(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_DRAWBOX); sg12232c_draw_box(p[1], p[2], p[3], p[4], p[5]); NTLEVT_END(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_DRAWBOX); break; case DISPLAY_CMD_LCD_DRAW_LOGO: NTLEVT_START(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_DRAWLOGO); draw_logo(p[1], p[2], p[3]); NTLEVT_END(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_DRAWLOGO); break; case DISPLAY_CMD_LCD_DRAW_TEXT: NTLEVT_START(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_DRAWTEXT); sg12232c_draw_string(p[1], p[2], &p[3], 0); NTLEVT_END(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_DRAWTEXT); break; case DISPLAY_CMD_LCD_DRAW_PBAR: NTLEVT_START(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_DRAWPROG); sg12232c_draw_progressbar( p[1], p[2], p[3], p[4], p[5], p[6], p[7], 0); NTLEVT_END(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_DRAWPROG); break; case DISPLAY_CMD_LED_ON: NTLEVT_START(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_LEDON); led_write(p[1] - '0', LedOn); NTLEVT_END(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_LEDON); break; case DISPLAY_CMD_LED_OFF: NTLEVT_START(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_LEDOFF); led_write(p[1] - '0', LedOff); NTLEVT_END(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_LEDOFF); break; case DISPLAY_CMD_LED_TOGGLE: NTLEVT_START(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_LEDTOGGLE); led_toggle(p[1] - '0'); NTLEVT_END(NTLUSR_TRACK_DISPLAY, NTLUSR_EVENT_DISPLAY_LEDTOGGLE); break; default: break; } kz_kmfree(p); return 0; }
void drawMainscreen(void) { set_font(SMALLFONT); lcd_fill(0); draw_logo(); draw_block(0, 0, 99, 9, 3, DRAW_ERASE); draw_string(0,0,getSetName(irDevTab.device[irDevTab.active].encoder, irDevTab.device[irDevTab.active].set), 3, DRAW_PUT); printTime(86,152,(struct time_ *)&time); printDate(0,152,(struct date_ *)&date,0); showBat(); }
int splash_main(int argc, char **argv) { osd_surface_t *surface; int ret = -1; int c, opt_index; char *opt_p = NULL, *opt_s = NULL; av_init(); if (av_get_mode() == AV_MODE_PAL) { width = 720; height = 576; av_set_mode(AV_MODE_PAL); } else { width = 720; height = 480; } if ((surface=osd_create_surface(width, height, 0, OSD_FB)) == NULL) { goto err; } while ((c=getopt_long(argc, argv, "blp:s:", opts, &opt_index)) != -1) { switch (c) { case 'b': ret = blank(surface); break; #if defined(STANDALONE) case 'l': ret = draw_logo(surface); break; #endif /* STANDALONE */ case 'p': opt_p = strdup(optarg); break; case 's': opt_s = strdup(optarg); break; } } if (opt_p && opt_s) { ret = draw_progress(surface, atoi(opt_p), atoi(opt_s)); } err: return ret; }
int misc_init_r(void) { #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG set_board_info(); #endif #ifdef CONFIG_LCD_MENU keys_init(); check_boot_mode(); #endif #ifdef CONFIG_CMD_BMP if (panel_info.logo_on) draw_logo(); #endif return 0; }
/* the loop itself */ void wait_for_players () { SDL_Event event; mw_init (); do { if (s_fetchevent (&event) != 0) switch (event.type) { case (SDL_QUIT): bman.state = GS_quit; break; } /* * check some little things and do the network stuff */ network_loop (); /* * the drawing stuff */ if (mw_check_screenredraw()) { d_printf ("Draw Status\n"); gfx_blitdraw (); draw_logo (); if (bman.gametype==GT_team) mw_draw_all_teams(); else mw_draw_all_player (); } gfx_blitdraw (); /* * input handling */ keyb_loop (&event); mw_keys_loop (); chat_loop (&event); chat.active = 1; s_calctimesync (); } while (bman.state == GS_wait && bman.sock != -1); mw_shutdown (); };
static void on_draw (view_t *view, ply_pixel_buffer_t *pixel_buffer, int x, int y, int width, int height) { ply_boot_splash_plugin_t *plugin; ply_rectangle_t area; area.x = x; area.y = y; area.width = width; area.height = height; plugin = view->plugin; draw_background (view, pixel_buffer, x, y, width, height); if (plugin->state == PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY || plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY ) { uint32_t *box_data, *lock_data; box_data = ply_image_get_data (plugin->box_image); ply_pixel_buffer_fill_with_argb32_data (pixel_buffer, &view->box_area, 0, 0, box_data); ply_entry_draw_area (view->entry, pixel_buffer, x, y, width, height); ply_label_draw_area (view->label, pixel_buffer, x, y, width, height); lock_data = ply_image_get_data (plugin->lock_image); ply_pixel_buffer_fill_with_argb32_data (pixel_buffer, &view->lock_area, 0, 0, lock_data); } else { draw_logo (view, pixel_buffer); ply_throbber_draw_area (view->throbber, pixel_buffer, x, y, width, height); ply_progress_bar_draw_area (view->progress_bar, pixel_buffer, x, y, width, height); } }
void redraw_all(void) { // reset ncurses endwin(); refresh(); // clear screen clear(); // re-draw everything draw_borders(); draw_grid(); draw_logo(); draw_numbers(); // show cursor show_cursor(); }
void draw_menu_full(void) { draw_edge(); draw_logo(); draw_color_list(); draw_init_size(); draw_direction(); draw_speed(); draw_function(); draw_control_buttons(); draw_io_buttons(); draw_size(); draw_steps(); draw_labels(); wnoutrefresh(menuw); if (dialogw) { draw_dialog(); } }
void game_showresult () { char text[255]; SDL_Event event; Uint8 *keys; int done = 0, keypressed = 0, x, y; gfx_blitdraw (); draw_logo (); strcpy (text, "Game Result"); x = (gfx.res.x - (font[2].size.x * strlen (text)) - 64) / 2; y = 0; font_drawbold (x, y, text, 2, 6, 2); font_draw (x, y, text, 2, 5); y += font[2].size.x; strcpy (text, "[CTRL],[RETURN] or [STRG] for another game"); x = (gfx.res.x - (font[1].size.x * strlen (text)) - 64) / 2; font_drawbold (x, gfx.res.y - (2 * font[0].size.y) - 2, text, 0, COLOR_brown, 1); font_draw (x, gfx.res.y - (2 * font[0].size.y) - 2, text, 0, COLOR_yellow); strcpy (text, "or [ESC] to leave the game."); x = (gfx.res.x - (font[1].size.x * strlen (text)) - 64) / 2; font_drawbold (x, gfx.res.y - font[0].size.y - 2, text, 0, COLOR_brown, 1); font_draw (x, gfx.res.y - font[0].size.y - 2, text, 0, COLOR_yellow); if (bman.gametype == GT_team) game_showresultteam (10, 50, gfx.res.x - 20, gfx.res.y - 100); else game_showresultnormal (10, 50, gfx.res.x - 20, gfx.res.y - 100); gfx_blitdraw (); SDL_Flip (gfx.screen); while (!done && bman.state != GS_quit) { /* do the keyboard handling */ if (s_fetchevent (&event) != 0) switch (event.type) { case (SDL_QUIT): bman.state = GS_quit; bman.p_nr = -1; done = 1; } keys = SDL_GetKeyState (NULL); if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { /* we want to quit */ done = 1; bman.p_nr = -1; keypressed = 1; bman.state = GS_startup; } if ((keys[SDLK_RETURN] || keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) && (!keypressed) && (event.type = SDL_KEYDOWN)) { done = 1; keypressed = 1; } if (keys[SDLK_F8] && event.type == SDL_KEYDOWN) { /* Switch Fullscreen */ SDL_WM_ToggleFullScreen (gfx.screen); gfx.fullscreen = !gfx.fullscreen; bman.updatestatusbar = 1; // force an update } if (event.type == SDL_KEYUP) keypressed = 0; else if (event.type == SDL_KEYDOWN) keypressed = 1; s_delay (25); } if (bman.state != GS_quit && bman.state != GS_startup) bman.state = GS_running; };
/* single player game win/point screen * 1. setup all player data * 2. setup second local player and ai players * 3. setup all other game related data */ void single_playergame (int second_player, int ai_players) { int p, done = 0; bman.p_nr = -1; bman.p2_nr = -1; /* delete player and teams from the game */ for (p = 0; p < MAX_PLAYERS; p++) { players[p].points = 0; players[p].wins = 0; players[p].state = 0; players[p].team_nr = -1; players[p].gfx_nr = -1; players[p].gfx = NULL; memset (&players[p].net, 0x0, sizeof (_net_player)); } for (p = 0; p < MAX_TEAMS; p++) { teams[p].wins = 0; teams[p].points = 0; for (done = 0; done < MAX_PLAYERS; done++) teams[p].players[done] = NULL; } done = 0; for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++) if (!(PS_IS_used (players[p].state))) bman.p_nr = p; players[bman.p_nr].team_nr = 0; if (bman.p_nr >= MAX_PLAYERS) { printf ("ERROR in function (single_game_new): couldn't find any free player\n"); exit (1); } strncpy (players[bman.p_nr].name, bman.playername, LEN_PLAYERNAME); do { done = playermenu_selgfx (bman.p_nr); } while (players[bman.p_nr].gfx_nr == -1 && done != -1); players[bman.p_nr].state = PSF_used + PSF_alife + PSF_playing; strncpy (players[bman.p_nr].name, bman.playername, LEN_PLAYERNAME); if (done != -1 && second_player) { player2_join (); do { done = playermenu_selgfx (bman.p2_nr); } while (players[bman.p2_nr].gfx_nr == -1 && done != -1); players[bman.p2_nr].team_nr = 0; } if (done == -1) return; single_create_ai (ai_players); if (bman.gametype == GT_team) { playermenu (); team_update (); ai_team_choosegfx (); } bman.state = GS_ready; while (!done && bman.state != GS_quit && bman.state != GS_startup) { single_game_new (); game_start (); bman.state = GS_running; game_loop (); game_end (); } gfx_blitdraw (); draw_logo (); gfx_blitdraw (); };
void render(void) { CLEAR; switch (stage) { case 0: time = 0; stage++; case 1: PUSH; if ((time / 1000) & 1) glColor3f(MAP_SMOOTH(time%1000, 0, 1000, 0.2, 1.0), MAP_SMOOTH(time%1000, 0, 1000, 0.6, 1.0), MAP_SMOOTH(time%1000, 0, 1000, 1.0, 0.5)); else glColor3f(MAP_SMOOTH(time%1000, 0, 1000, 1.0, 0.2), MAP_SMOOTH(time%1000, 0, 1000, 1.0, 0.6), MAP_SMOOTH(time%1000, 0, 1000, 0.5, 1.0)); glScalef(6, 6, 1); glTranslatef(-5, 0, 0); draw_string("Loading..."); POP; if (time >= 4000) stage++; break; case 2: PUSH; glColor3f(MAP_SMOOTH(time%1000, 0, 1000, 1.0, 0.0), MAP_SMOOTH(time%1000, 0, 1000, 1.0, 0.0), MAP_SMOOTH(time%1000, 0, 1000, 0.5, 0.0)); glScalef(6, 6, 1); glTranslatef(-5, 0, 0); draw_string("Loading..."); POP; if (time >= 5000) { stage++; sound_play(); time = 0; } break; case 3: // Logo glColor3f(0.5, 0.75, 0.25); PUSH; glTranslatef(70, 90, 0); glScalef(5, 5, 1); draw_logo(); POP; // Row PUSH; { char buf[40]; if (time % 1000 > frame_time) frame_time = time % 1000; else { fps = frame; frame = 0; frame_time = 0; } frame++; glTranslatef(-120, -90, 0); glScalef(5, 5, 1); sprintf(buf, "row %2.2X\tfps %d", row, fps); draw_string(buf); } POP; // Draw PUSH; draw(); POP; break; } SWAP; }
int main(int argc, char *argv[]) { int mode = 0; initscr(); /* Start curses mode */ start_color(); /* Start color functionality */ init_pair(10,COLOR_WHITE,COLOR_WHITE); init_pair(11,COLOR_YELLOW,COLOR_YELLOW); init_pair(12,COLOR_MAGENTA,COLOR_MAGENTA); init_pair(13,COLOR_CYAN,COLOR_CYAN); init_pair(14,COLOR_GREEN,COLOR_GREEN); init_pair(15,COLOR_RED,COLOR_RED); init_pair(16,COLOR_BLUE,COLOR_BLUE); init_pair(17,COLOR_WHITE,COLOR_WHITE); init_pair(18,COLOR_YELLOW,COLOR_YELLOW); init_pair(19,COLOR_MAGENTA,COLOR_MAGENTA); init_pair(20,COLOR_BLACK,COLOR_WHITE); init_pair(21,COLOR_BLACK,COLOR_YELLOW); init_pair(22,COLOR_WHITE,COLOR_MAGENTA); init_pair(23,COLOR_WHITE,COLOR_CYAN); init_pair(24,COLOR_WHITE,COLOR_GREEN); init_pair(25,COLOR_WHITE,COLOR_RED); init_pair(26,COLOR_WHITE,COLOR_BLUE); curs_set(0); noecho(); keypad(stdscr,TRUE); refresh(); WINDOW **logo; WINDOW **menu; int i = 0; int score = 0; while (i == 0) { logo = draw_logo(); menu = draw_menu(); if (score > 0 ) { mode = 1; } else { mode = scroll_menu(menu); } switch (mode) { case 0: delete_menu(menu,5); delete_menu(logo,169); score = tetris_init(); break; case 1: delete_menu(menu,5); if (score > 0) { draw_hiscores(1,score); } else { draw_hiscores(0,score); } score = 0; break; case 2: delete_menu(menu,5); draw_help(); break; case 3: delete_menu(menu,5); delete_menu(logo,169); i = 1; break; } } /*getch();*/ endwin(); /* End curses mode */ }
/* sets up everything for the network game.. on servers the game field will be created and the clients will wait for the game data within the network loop */ void net_transmit_gamedata () { int done = 0, keypressed = 0, x, y, // network upload status for one step p, i, net_istep; // network init step SDL_Event event; Uint8 *keys; Uint32 downtimestamp = 0; draw_logo (); if (GT_MP_PTPM) font_draw (100, 0, "Waiting for the Clients", 1, 0); else font_draw (100, 0, "Downloading Data", 1, 0); /* prepare everything for the loop */ for (x = 0; x < MAX_PLAYERS; x++) { players[x].net.timestamp = 0; players[x].net.net_status = -1; if ((PS_IS_aiplayer (players[x].state)) || (x == bman.p_servnr) || (x == bman.p2_nr) || (players[x].net.flags & NETF_local2) == NETF_local2) players[x].net.net_istep = 0; else players[x].net.net_istep = 3; } y = -1; if (GT_MP_PTPM) net_istep = 0; else net_istep = 3; draw_netupdatestate (1); SDL_Flip (gfx.screen); downtimestamp = timestamp; while (!done && (bman.state == GS_update || (GT_MP_PTPS && net_istep != 0))) { /* the network thing */ network_loop (); /* if PTPM check if all players are ready */ if (GT_MP_PTPM) { if (timestamp - downtimestamp > TIME_UPDATEINFO) { downtimestamp = timestamp; net_send_updateinfo (); } for (p = 0, i = 1; p < MAX_PLAYERS; p++) if (PS_IS_playing (players[p].state) && players[p].net.net_istep != 0) i = 0; if (i == 1) { /* all players are ready */ done = 1; bman.state = GS_ready; } } /* if PTPS get all data */ if (GT_MP_PTPS) { if (net_istep == 3) { /* get tunneldata */ if ((y < GAME_MAX_TUNNELS - 1 && y == players[bman.p_nr].net.net_status) || y == -1) { y++; downtimestamp = timestamp; send_tunneldata (&players[bman.p_servnr].net.addr, y, -1, -1); } else if (y < GAME_MAX_TUNNELS && y != players[bman.p_nr].net.net_status && y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { /* we have got no tunnel data */ y--; } else if (y == GAME_MAX_TUNNELS - 1 && players[bman.p_nr].net.net_status == y) { /* we have got all tunnel data */ y = -1; players[bman.p_nr].net.net_istep = --net_istep; players[bman.p_nr].net.net_status = -1; } } if (net_istep == 2) { /* get field data */ if ((y < map.size.y - 1 && y == players[bman.p_nr].net.net_status) || y == -1) { /* send field data req */ y++; downtimestamp = timestamp; send_getfield (&players[bman.p_servnr].net.addr, y); } else if (y < map.size.y && y != players[bman.p_nr].net.net_status && y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { /* getdata timed out - we have got no field data */ y--; } else if (y == map.size.y - 1 && players[bman.p_nr].net.net_status == y) { /* we have got all field data */ y = -1; players[bman.p_nr].net.net_istep = --net_istep; players[bman.p_nr].net.net_status = -1; } } if (net_istep == 1) { /* get player data */ if ((y < MAX_PLAYERS - 1 && y == players[bman.p_nr].net.net_status) || y == -1) { /* send player date req */ y++; downtimestamp = timestamp; send_getplayerdata (&players[bman.p_servnr].net.addr, y); } if (y < MAX_PLAYERS && y != players[bman.p_nr].net.net_status && y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { /* we have got no player data */ y--; } if (y == MAX_PLAYERS - 1 && players[bman.p_nr].net.net_status == y) { /* we have got all playerdata */ y = -1; players[bman.p_nr].net.net_istep = --net_istep; players[bman.p_nr].net.net_status = -1; downtimestamp = timestamp; send_playerstatus (&players[bman.p_servnr].net.addr, bman.p_nr, 0, 0); } } if (net_istep == 0 && players[bman.p_nr].net.net_status == -1 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { /* server did not send informations back */ downtimestamp = timestamp; send_playerstatus (&players[bman.p_servnr].net.addr, bman.p_nr, 0, 0); } } /* do the grafik work */ draw_netupdatestate (0); if (s_fetchevent (&event) != 0) switch (event.type) { case (SDL_QUIT): bman.state = GS_quit; bman.p_nr = -1; done = 1; } keys = SDL_GetKeyState (NULL); if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { done = 1; bman.p_nr = -1; keypressed = 1; bman.state = GS_startup; } if (event.type == SDL_KEYUP) keypressed = 0; } timestamp = SDL_GetTicks (); // needed for time sync. SDL_Delay (1); // we don't need here anything better /* player is only watching so just go after we have got everything go to show the field */ if (GT_MP_PTPS && bman.state == GS_update && net_istep == 0 && players[bman.p_nr].gfx_nr == -1) { done = 1; bman.state = GS_running; } };
void game_loop () { SDL_Event event; int done = 0, eventstate; if (GT_MP) net_game_fillsockaddr (); if ( SDL_InitSubSystem ( SDL_INIT_JOYSTICK ) < 0 ) { fprintf ( stderr, "Unable to initialize Joystick: %s\n", SDL_GetError() ); } printf ( "%i joysticks found\n", SDL_NumJoysticks () ); menu = NULL; bman.updatestatusbar = 1; // force an update timestamp = SDL_GetTicks (); // needed for time sync. d_gamedetail ("GAME START"); gfx_blitupdaterectclear (); draw_logo (); draw_field (); SDL_Flip (gfx.screen); draw_players (); if (bman.p_nr >= 0 && bman.p_nr < MAX_PLAYERS) { players[bman.p_nr].ready = 1; if (GT_MP_PTPS) send_playerdata (&players[bman.p_servnr].net.addr, bman.p_nr, &players[bman.p_nr]); } if (bman.p2_nr >= 0 && bman.p2_nr < MAX_PLAYERS) { players[bman.p2_nr].ready = 1; if (GT_MP_PTPS) send_playerdata (&players[bman.p_servnr].net.addr, bman.p2_nr, &players[bman.p2_nr]); } fire_init(); while (!done && (bman.state == GS_running || bman.state == GS_ready)) { SDL_JoystickUpdate (); if ((eventstate = SDL_PollEvent (&event)) != 0) switch (event.type) { case (SDL_QUIT): done = 1; bman.state = GS_quit; } /* * input handling */ keyb_loop (&event); game_keys_loop (); if (GT_MP) chat_loop (&event); if ((!IS_LPLAYER2) && (!chat.active)) chat_setactive (1, 1); restore_players_screen (); player_check (bman.p_nr); if (IS_LPLAYER2) player_check (bman.p2_nr); dead_playerani (); special_loop (); player_move (bman.p_nr); if (IS_LPLAYER2) player_move (bman.p2_nr); if (GT_MP) { player_calcpos (); network_loop (); } if (bman.state == GS_running) single_loop (); bomb_loop (); /* wind_loop (); SOON */ fire_loop (); field_loop (); flitems_loop (); draw_players (); game_draw_info (); // will set the var bman.player_nr /* check if there is only one player left and the game is in multiplayer mode and if there the last dieing animation is done */ if (game_check_endgame () && bman.timeout >= 0.0f) bman.timeout = 0.0f; if ((GT_SP || GT_MP_PTPM) && bman.timeout < -GAME_OVERTIMEOUT) { d_printf ("GAME: Game Over\n"); done = 1; } stonelist_draw (); /* if there is any menu displayed do so */ if (menu != NULL) game_menu_loop (&event, eventstate); gfx_blitdraw (); s_calctimesync (); bman.timeout -= timediff; } if (menu != NULL) { menu_delete (menu); menu = NULL; } gfx_blitdraw (); chat_show (-1, -1, -1, -1); draw_logo (); gfx_blitupdaterectclear (); SDL_Flip (gfx.screen); d_gamedetail ("GAME END"); d_printf ("done = %d\n", done); };
static void display(void) { float x, y, z, c; calc_spline(view_from, view_from_spline, current_time); calc_spline(view_to, view_to_spline, current_time); calc_spline(light_pos, light_pos_spline, current_time); light_pos[3] = 0.0; calc_spline(logo_pos, logo_pos_spline, current_time); calc_spline(logo_rot, logo_rot_spline, current_time); tmplight[1] = light_pos[X] - logo_pos[X]; tmplight[2] = light_pos[Y] - logo_pos[Y]; tmplight[3] = light_pos[Z] - logo_pos[Z]; glNewList(LIGHT_TMP, GL_COMPILE); glMaterialf(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, * tmplight); glEndList(); tv[0][0] = tv[1][1] = tv[2][2] = light_pos[Y]; glColor3ub(0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* * SHADOW */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(view_from[X], view_from[Y], view_from[Z], view_to[X], view_to[Y], view_to[Z], 0.0, 1.0, 0.0); if (view_from[Y] > 0.0) draw_table(); glEnable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); if (logo_pos[Y] < 0.0) { if (logo_pos[Y]>-0.33) { /* We're emerging from the table */ c = 1.0 - (logo_pos[Y]) / -0.33; pca /= 4.0; glColor3ub((GLubyte)(128.0*(1.0-c)*0.5 + 255.0*pca*c), (GLubyte)(102.0*(1.0-c)*0.5 + 255.0*pca*c), (GLubyte)(179.0*(1.0-c)*0.5 + 200.0*pca*c)); } else { /* Still under table */ glColor3ub(128/2, 102/2, 179/2); } glPushMatrix(); glScalef(0.04, 0.0, 0.04); glRotatef(0.1 * (-900), 1.0, 0.0, 0.0); glRotatef(0.1 * ((int)(10.0*logo_rot[Z])), 0.0, 0.0, 1.0); glRotatef(0.1 * ((int)(10.0*logo_rot[Y])), 0.0, 1.0, 0.0); glRotatef(0.1 * ((int)(10.0*logo_rot[X])), 1.0, 0.0, 0.0); glRotatef(0.1 * (353), 1.0, 0.0, 0.0); glRotatef(0.1 * (450), 0.0, 1.0, 0.0); draw_logo_shadow(); glPopMatrix(); } if (logo_pos[Y] > 0.0) { glPushMatrix(); if (logo_pos[Y]<0.33) { pca /= 4.0; c = 1.0 - (logo_pos[Y])/0.33; glColor3ub((GLubyte)(255.0*pca*c), (GLubyte)(255.0*pca*c), (GLubyte)(200.0*pca*c)); } else { glColor3ub(0, 0, 0); } glTranslatef(light_pos[X], light_pos[Y], light_pos[Z]); glMultMatrixf(&tv[0][0]); glTranslatef(-light_pos[X]+logo_pos[X], -light_pos[Y]+logo_pos[Y], -light_pos[Z]+logo_pos[Z]); glScalef(0.04, 0.04, 0.04); glRotatef (0.1 * (-900), 1.0, 0.0, 0.0); glRotatef (0.1 * ((int)(10.0*logo_rot[Z])), 0.0, 0.0, 1.0); glRotatef (0.1 * ((int)(10.0*logo_rot[Y])), 0.0, 1.0, 0.0); glRotatef (0.1 * ((int)(10.0*logo_rot[X])), 1.0, 0.0, 0.0); glRotatef (0.1 * (353), 1.0, 0.0, 0.0); glRotatef (0.1 * (450), 0.0, 1.0, 0.0); glEnable(GL_POLYGON_STIPPLE); glPolygonStipple(stipple); draw_logo_shadow(); glDisable(GL_POLYGON_STIPPLE); glPopMatrix(); } /* * DONE SHADOW */ glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glEnable(GL_LIGHTING); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(.1*(450), 5.0/4.0, 0.5, 20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(view_from[X], view_from[Y], view_from[Z], view_to[X], view_to[Y], view_to[Z], 0.0, 1.0, 0.0); glCallList( MAT_HOLDER_RINGS); glPushMatrix(); glTranslatef(light_pos[X], light_pos[Y], light_pos[Z]); glScalef(0.1, 0.1, 0.1); x = light_pos[X] - logo_pos[X]; y = light_pos[Y] - logo_pos[Y]; z = light_pos[Z] - logo_pos[Z]; if (x!=0.0) { a3 = -atan2(z, x)*10.0 RAD; } else a3 = 0.0; a4 = -atan2(sqrt(x*x + z*z), y)*10.0 RAD; glRotatef (0.1 * ((int)a3), 0.0, 1.0, 0.0); glRotatef (0.1 * ((int)a4), 0.0, 0.0, 1.0); glRotatef (0.1 * (-900), 1.0, 0.0, 0.0); glEnable(GL_LIGHT2); glEnable(GL_LIGHT3); glCallList(MAT_HEMISPHERE); glEnable(GL_NORMALIZE); draw_hemisphere(); glDisable(GL_NORMALIZE); glPopMatrix(); glDisable(GL_LIGHT2); glDisable(GL_LIGHT3); glEnable(GL_LIGHT1); glLightfv(GL_LIGHT1, GL_POSITION, light_pos); if (logo_pos[Y] > -0.33) { glCallList(MAT_LOGO); glPushMatrix(); glTranslatef(logo_pos[X], logo_pos[Y], logo_pos[Z]); glScalef(0.04, 0.04, 0.04); glRotatef (0.1 * (-900), 1.0, 0.0, 0.0); glRotatef (0.1 * ((int)(10.0*logo_rot[Z])), 0.0, 0.0, 1.0); glRotatef (0.1 * ((int)(10.0*logo_rot[Y])), 0.0, 1.0, 0.0); glRotatef (0.1 * ((int)(10.0*logo_rot[X])), 1.0, 0.0, 0.0); glRotatef (0.1 * (353), 1.0, 0.0, 0.0); glRotatef (0.1 * (450), 0.0, 1.0, 0.0); glEnable(GL_LIGHTING); draw_logo(); glPopMatrix(); } if (view_from[Y] < 0.0) draw_under_table(); glutSwapBuffers(); if(post_idle) do_post_idle(); }
void on_recv_message() { //bool ack = false; switch (msg.cmd) { case LCD_SEND_CMD: for (uint8_t i = 0; i < msg.len; i++) GLCD.SendCmd(msg.data[i]); break; case LCD_SEND_DATA: for (uint8_t i = 0; i < msg.len; i++) GLCD.SendData(msg.data[i]); break; case LCD_READ_REG: break; case LCD_READ_DATA: break; case LCD_SET_COLOR: GLCD.SetColor(msg.data[0], msg.data[1]); break; case LCD_CLEAR_SCREEN: GLCD.ClearScreen(); break; case LCD_DRAW_HLINE: GLCD.DrawHLine(msg.data[0], msg.data[1], msg.data[2]); break; case LCD_DRAW_VLINE: GLCD.DrawVLine(msg.data[0], msg.data[1], msg.data[2]); break; case LCD_DRAW_LINE: GLCD.DrawLine(msg.data[0], msg.data[1], msg.data[2], msg.data[3]); break; case LCD_DRAW_RECT: GLCD.DrawRect(msg.data[0], msg.data[1], msg.data[2], msg.data[3]); break; case LCD_FILL_RECT: GLCD.FillRect(msg.data[0], msg.data[1], msg.data[2], msg.data[3], msg.data[4]); break; case LCD_DRAW_ROUND_RECT: GLCD.DrawRoundRect(msg.data[0], msg.data[1], msg.data[2], msg.data[3], msg.data[4]); break; case LCD_DRAW_CIRCLE: GLCD.DrawCircle(msg.data[0], msg.data[1], msg.data[2]); break; case LCD_FILL_CIRCLE: GLCD.FillCircle(msg.data[0], msg.data[1], msg.data[2]); break; case LCD_DRAW_STRING: GLCD.DrawString(msg.data[0], msg.data[1], (char*)&msg.data[2], msg.len - 2); break; case LCD_DRAW_HPARALLEL: GLCD.DrawHParallel(msg.data[0], msg.data[1], msg.data[2], msg.data[3], msg.data[4]); break; case LCD_DRAW_VPARALLEL: GLCD.DrawVParallel(msg.data[0], msg.data[1], msg.data[2], msg.data[3], msg.data[4]); break; case LCD_DRAW_IMAGE: //draw_image(msg.data[0], msg.data[1], (IMAGE_ID)msg.data[2]); GLCD.DrawMBitmap_P(IMAGES[msg.data[2]], msg.data[0], msg.data[1]); //GLCD.DrawMBitmap_P(IMAGES[IMG_ID_MODE], 10, 20); break; case LCD_DRAW_LOGO: draw_logo(); break; case LCD_SET_BRIGHTNESS: setting.brightness = msg.data[0]; GLCD.SetBrightness(setting.brightness); break; case LCD_GET_BRIGHTNESS: link.send_message(LCD_SET_BRIGHTNESS, &setting.brightness, sizeof(setting.brightness)); break; case LCD_SET_CONTRAST: setting.contrast = msg.data[0]; GLCD.SetContrast(setting.contrast); break; case LCD_GET_CONTRAST: link.send_message(LCD_SET_CONTRAST, &setting.contrast, sizeof(setting.contrast)); break; case LCD_SET_BL_TIMEOUT: setting.el_timeout = *((int16_t*)msg.data); back_light_timeout = setting.el_timeout * 50; break; case LCD_GET_BL_TIMEOUT: link.send_message(LCD_SET_BL_TIMEOUT, &setting.el_timeout, sizeof(setting.el_timeout)); break; case LCD_SAVE_SETTING: eeprom_write_block(&setting, (void*)1, sizeof(setting)); //link.send_message(LCD_SAVE_SETTING); break; case KEY_STATE: { uint8_t key_state = Keyboard.GetKeyState(); link.send_message(KEY_STATE, &key_state, 1); //ack = false; } break; //case CMD_ACK: //case CMD_NACK: // ack = false; // break; case CTRL_UPDATE: update_mode = msg.data[0]; break; case CTRL_RESET: break; case DEV_QUERY: link.send_message(DEV_READY, 0, 0); break; } //if (ack) // link.send_message(CMD_ACK, &msg.seq, 1); }
int main() { init(); _delay_ms(100); debug("uart port test\r\n"); //GLCD.SetColor(0, 0); GLCD.ClearScreen(); draw_logo(); GLCD.DrawString(30, 65, "System Booting..."); /*if (!ep) { GLCD.DrawString(30, 65, "read eeprom error"); } else { char str[64]; sprintf(str, "%d bright %d ", sizeof(setting), setting.brightness); GLCD.DrawString(30, 65, str); } */ reset_2560(); //draw_image(0, 0, IMG_ //GLCD.DrawString(9, 40, "Mavlink Antenna Tracker"); //GLCD.DrawString(18, 50, "System Initiating..."); //link.send_message(DEV_READY, NULL, 0); back_light_timeout = setting.el_timeout * 50; while (1) { wdt_reset(); while (uart_available()) { uint8_t c = uart_getc(); if (link.parse_message(c, &msg)) { // got_msg = true; on_recv_message(); } wdt_reset(); } if (tick) { tick = false; //uart_putc('t'); debug("t"); link.timeout_tick(); Keyboard.Update(); uint8_t press = Keyboard.GetPressKey(); if (press) { debug("key pressed\r\n"); link.send_message(KEY_PRESS, &press, 1); if (back_light_timeout == 0) GLCD.TurnOnBackLight(); back_light_timeout = setting.el_timeout * 50; } if (setting.el_timeout > 0 && back_light_timeout > 0 && --back_light_timeout == 0) GLCD.TurnOffBackLight(); } } return 0; }