static void AboutBox_Layout(bool setup) { t_app_about_box *app = &AboutBox; // Global instance const int dragon_h = al_get_bitmap_height(Graphics.Misc.Dragon); al_set_target_bitmap(app->box->gfx_buffer); al_clear_to_color(COLOR_SKIN_WINDOW_BACKGROUND); if (setup) widget_closebox_add(app->box, (t_widget_callback)AboutBox_Switch); // Draw MEKA dragon sprite al_draw_bitmap(Graphics.Misc.Dragon, 16, (app->box->frame.size.y - dragon_h) / 2, 0); // Print about information lines { int y = 12; Font_SetCurrent((t_font_id)g_config.font_about); for (int i = 0; i < 4; i ++) { char buffer[256]; switch (i) { case 0: snprintf(buffer, countof(buffer), Msg_Get(MSG_About_Line_Meka_Date), MEKA_NAME_VERSION, MEKA_DATE); break; case 1: snprintf(buffer, countof(buffer), Msg_Get(MSG_About_Line_Authors), MEKA_AUTHORS_SHORT); break; case 2: snprintf(buffer, countof(buffer), Msg_Get(MSG_About_Line_Homepage), MEKA_HOMEPAGE); break; case 3: snprintf(buffer, countof(buffer), "Built %s, %s", MEKA_BUILD_DATE, MEKA_BUILD_TIME); break; } const int x = (( (app->box->frame.size.x - dragon_h - 18 - 6) - Font_TextWidth(FONTID_CUR, buffer) ) / 2) + dragon_h + 8 + 6; Font_Print(FONTID_CUR, buffer, x, y, COLOR_SKIN_WINDOW_TEXT); y += Font_Height() + 3; } } }
static void Options_Layout_AddLine(t_app_options* app, bool setup, t_frame *frame, const char *text, bool *v, void (*func)()) { frame->pos.x = OPTIONS_PAD_X; if (setup) widget_checkbox_add(Options.box, frame, v, (t_widget_callback)func); // FIXME: Cast frame->pos.x += frame->size.x + Font_TextWidth(app->font_id, " "); Font_Print(app->font_id, text, frame->pos.x, frame->pos.y+2, COLOR_SKIN_WINDOW_TEXT); frame->pos.y += (int)(Font_Height(app->font_id) * 1.3f); }
void BrainWash_Draw_Score (void) { char s [20]; static int last_level = -1; if (bwo.level == last_level) return; Font_SetCurrent (F_MIDDLE); rectfill (bwo.scr, 1, 1, 80, 8, COLOR_BLACK); sprintf (s, "LEVEL: %d", bwo.level); Font_Print (-1, bwo.scr, s, 1, 1, COLOR_WHITE); last_level = bwo.level; if (bwo.level==1) return; switch (bwo.level) { case 2: Msg (MSGT_USER, "Too easy game..."); break; case 4: Msg (MSGT_USER, "Oh did you notice that figures seem to change ?"); break; case 8: Msg (MSGT_USER, "I suppose you notice that texts change too !"); break; case 10: Msg (MSGT_USER, "Er...Still there ?"); break; case 15: Msg (MSGT_USER, "You like this game ?"); break; case 25: Msg (MSGT_USER, "Woaw, you are a real warrior in order to come here"); break; case 35: Msg (MSGT_USER, "Ok, I'll tell you one..."); break; case 40: Msg (MSGT_USER, "... cheat code... try..."); break; case 60: Msg (MSGT_USER, "... the..."); break; case 65: Msg (MSGT_USER, "... T key !"); break; default: if (bwo.level>=100) Msg (MSGT_USER, "You are a cheater !"); if (bwo.level>=1000) Msg (MSGT_USER, "Doh ! A nice TV effect like Zoop's one !"); } }
void BreakOut_Draw_Score (void) { int i; char s [20]; static int last_score = -1; if (bo.score == last_score) return; Font_SetCurrent (F_MIDDLE); rectfill (bo.scr, 1, 1, 80, Font_Height(-1), COLOR_BLACK); sprintf (s, "SCORE: %d", bo.score); for (i = 0; i < 5; i ++) if (Random(2)) s [i] += ('a' - 'A'); Font_Print (-1, bo.scr, s, 1, 1, COLOR_WHITE); last_score = bo.score; if ((bo.score % 56) == 0) switch (bo.score / 56) { case 1: Msg (MSGT_USER, "Are you crazy or what ?"); break; case 2: Msg (MSGT_USER, "Don't you have better things to do ?"); break; case 3: Msg (MSGT_USER, "There are better games to play, really.."); break; case 4: Msg (MSGT_USER, "Let me tell you a secret.."); break; case 5: Msg (MSGT_USER, "HAHAHAHA - I have no secrets to tell you (yet)"); break; case 6: Msg (MSGT_USER, "Still playing ?"); break; case 7: Msg (MSGT_USER, "Ok, I'll shut up."); break; default: if ((bo.score / 56) >= 8) // False secret message :) Msg (MSGT_USER, "Xfg6_ZhDjsA_9dyAyz_dSyQA_UdEDjDy2"); break; } }
void Render(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glViewport(0, 0, Width, Height); glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); Font_Print(0.0f, Height-12.0f, "FPS: %0.1f\n" "\x1B[91m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[92m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[93m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[94m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[95m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[96m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[97m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[31m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[32m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[33m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[34m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[35m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[36m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" "\x1B[37m" "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz\n" , fps); glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); }
static void TechInfo_Redraw(t_app_tech_info *app) { int i; bool dirty = FALSE; for (i = 0; i != TECHINFO_LINES; i++) { if (app->lines_dirty[i]) { const int h = Font_Height (F_MIDDLE); const int y = (h * i); rectfill(app->box->gfx_buffer, 0, y, app->box->frame.size.x, y + h - 1, COLOR_SKIN_WINDOW_BACKGROUND); Font_Print(F_MIDDLE, app->box->gfx_buffer, app->lines[i], 4, y, COLOR_SKIN_WINDOW_TEXT); app->lines_dirty[i] = FALSE; dirty = TRUE; } } if (dirty) app->box->flags |= GUI_BOX_FLAGS_DIRTY_REDRAW; }
void Inputs_CFG_Current_Source_Draw (void) { t_app_inputs_config *app = &Inputs_CFG; // Global instance BITMAP *bmp = app->box->gfx_buffer; int i; int x = 165; int y = 10; int font_height; int frame_x = INPUTS_CFG_FRAME_X; int frame_y = INPUTS_CFG_FRAME_Y; t_input_src * input_src = Inputs.Sources [Inputs_CFG.Current_Source]; // x = 165 + (i / 2) * (frame_sx + GUI_LOOK_FRAME_SPACING_X); // y = 10 + (i % 2) * (frame_sy + GUI_LOOK_FRAME_SPACING_Y); // Set update flag app->box->flags |= GUI_BOX_FLAGS_DIRTY_REDRAW; // Set font to use Font_SetCurrent (F_MIDDLE); font_height = Font_Height (-1); // Clear area to display on rectfill (app->box->gfx_buffer, x, y - font_height / 2, x + frame_x, y - font_height / 2 + frame_y, COLOR_SKIN_WINDOW_BACKGROUND); // Do the actual display { char buf[128]; sprintf(buf, "%d/%d: %s >>", app->Current_Source+1, Inputs.Sources_Max, input_src->name); gui_rect_titled (bmp, buf, F_MIDDLE, LOOK_THIN, x, y, x + frame_x, y + frame_y, COLOR_SKIN_WIDGET_GENERIC_BORDER, COLOR_SKIN_WINDOW_BACKGROUND, /*COLOR_SKIN_WINDOW_TEXT*/COLOR_SKIN_WINDOW_TEXT_HIGHLIGHT); } // Set font to use Font_SetCurrent (F_SMALL); font_height = Font_Height (-1); y += GUI_LOOK_FRAME_PAD1_Y; // Enable Check Font_Print (-1, bmp, Msg_Get(MSG_Inputs_Config_Source_Enabled), x + GUI_LOOK_FRAME_PAD_X + INPUTS_CFG_CHECK_X + 3, y, COLOR_SKIN_WINDOW_TEXT); y += font_height + GUI_LOOK_LINES_SPACING_Y; // Player { char buf[64]; snprintf(buf, sizeof(buf), Msg_Get(MSG_Inputs_Config_Source_Player), input_src->player + 1); Font_Print(-1, bmp, buf, x + GUI_LOOK_FRAME_PAD_X + INPUTS_CFG_CHECK_X + 3, y, COLOR_SKIN_WINDOW_TEXT); y += font_height + GUI_LOOK_LINES_SPACING_Y; } // Horizontal Separator line (bmp, x + 4, y + 3, x + frame_x - 4, y + 3, COLOR_SKIN_WINDOW_SEPARATORS); y += 7; // Mapping for (i = 0; i < INPUT_MAP_MAX; i++) if (Inputs_CFG_Current_Source_Draw_Map (i, COLOR_SKIN_WINDOW_TEXT)) y += font_height + GUI_LOOK_LINES_SPACING_Y; // Quit now if it is not an analog device.. if (!(input_src->flags & INPUT_SRC_FLAGS_ANALOG)) return; // Horizontal Separator line (bmp, x + 4, y + 3, x + frame_x - 4, y + 3, COLOR_SKIN_WINDOW_SEPARATORS); y += 7; // Emulate Digital widget_checkbox_redraw (app->CheckBox_Emulate_Digital); Font_Print (-1, bmp, Msg_Get(MSG_Inputs_Config_Source_Emulate_Joypad), x + GUI_LOOK_FRAME_PAD_X + INPUTS_CFG_CHECK_X + 3, y, COLOR_SKIN_WINDOW_TEXT); y += font_height + GUI_LOOK_LINES_SPACING_Y; }
byte Inputs_CFG_Current_Source_Draw_Map (int i, int Color) { t_app_inputs_config *app = &Inputs_CFG; // Global instance int x, y; char * MapName; char MapValue[128]; t_input_src *input_src = Inputs.Sources [Inputs_CFG.Current_Source]; t_input_map *Map = &input_src->Map[i]; MapName = Inputs_Get_MapName (input_src->type, i); if (MapName == NULL) return FALSE; // Set default font Font_SetCurrent (F_SMALL); x = 165; // Shift Y position by 2 steps for analog devices if (input_src->flags & INPUT_SRC_FLAGS_ANALOG && i > INPUT_MAP_ANALOG_AXIS_Y_REL) i -= 2; y = 10 + GUI_LOOK_FRAME_PAD1_Y + (2 + i) * (Font_Height(-1) + GUI_LOOK_LINES_SPACING_Y) + 7; if (Map->Idx == -1) sprintf (MapValue, "<Null>"); else { switch (input_src->type) { case INPUT_SRC_TYPE_KEYBOARD: { const t_key_info *key_info = KeyInfo_FindByScancode (Map->Idx); strcpy (MapValue, key_info ? key_info->name : "error"); break; } case INPUT_SRC_TYPE_JOYPAD: switch (Map->Type) { case INPUT_MAP_TYPE_JOY_AXIS: sprintf (MapValue, "Stick %d, Axis %d, %c", INPUT_MAP_GET_STICK(Map->Idx), INPUT_MAP_GET_AXIS(Map->Idx), INPUT_MAP_GET_DIR_LR(Map->Idx) ? '+' : '-'); break; // case INPUT_MAP_TYPE_JOY_AXIS_ANAL: case INPUT_MAP_TYPE_JOY_BUTTON: sprintf (MapValue, "Button %d", Map->Idx); break; } break; case INPUT_SRC_TYPE_MOUSE: switch (Map->Type) { case INPUT_MAP_TYPE_MOUSE_AXIS: sprintf (MapValue, "Axis %d (%c)", INPUT_MAP_GET_AXIS(Map->Idx), 'X' + INPUT_MAP_GET_AXIS(Map->Idx)); break; case INPUT_MAP_TYPE_MOUSE_BUTTON: sprintf (MapValue, "Button %d", Map->Idx+1); break; } break; } } Font_Print (-1, app->box->gfx_buffer, MapName, x + GUI_LOOK_FRAME_PAD_X, y, Color); Font_Print (-1, app->box->gfx_buffer, MapValue, x + (INPUTS_CFG_FRAME_X / 2), y, Color); // y += Font_Height() + GUI_LOOK_LINES_SPACING_Y; // Set both checkbox widgets as dirty (because we drawn over them during the clear) widget_set_dirty(app->CheckBox_Enabled); widget_set_dirty(app->CheckBox_Emulate_Digital); return TRUE; }
void gui_draw() { // If we were asked to redraw everything, redraw the background as well if (gui.info.must_redraw == TRUE) gui_draw_background(); al_set_target_bitmap(gui_buffer); for (int i = gui.boxes_count - 1; i >= 0; i--) { t_gui_box* b = gui.boxes_z_ordered[i]; const t_frame bb = b->frame; const v2i bb_min = bb.GetMin(); const v2i bb_max = bb.GetMax(); if (!(b->flags & GUI_BOX_FLAGS_ACTIVE)) continue; // Draw widgets for (t_list* widgets = b->widgets; widgets != NULL; widgets = widgets->next) { t_widget *w = (t_widget *)widgets->elem; if (w->enabled && w->type != WIDGET_TYPE_CLOSEBOX) if (w->redraw_func != NULL) w->redraw_func(w); } // Blit content switch (b->type) { case GUI_BOX_TYPE_STANDARD: al_set_target_bitmap(gui_buffer); al_draw_bitmap_region(b->gfx_buffer, 0, 0, bb.size.x + 1, bb.size.y + 1, bb.pos.x, bb.pos.y, 0x0000); break; case GUI_BOX_TYPE_GAME: gamebox_draw(b, screenbuffer); break; } // Draw borders al_set_target_bitmap(gui_buffer); gui_rect(LOOK_ROUND, bb.pos.x - 2, bb.pos.y - 20, bb.pos.x + bb.size.x + 2, bb.pos.y + bb.size.y + 2, COLOR_SKIN_WINDOW_BORDER); al_draw_line(bb.pos.x, bb.pos.y - 1.5f, bb.pos.x + bb.size.x + 1, bb.pos.y - 1.5f, COLOR_SKIN_WINDOW_BORDER, 0); al_draw_line(bb.pos.x, bb.pos.y - 0.5f, bb.pos.x + bb.size.x + 1, bb.pos.y - 0.5f, COLOR_SKIN_WINDOW_BORDER, 0); // Draw resize widget (invisible for game window) if (b->flags & GUI_BOX_FLAGS_ALLOW_RESIZE) { const bool is_resizing = (gui.mouse.focus == GUI_FOCUS_BOX && gui.mouse.focus_box == b && gui.mouse.focus_is_resizing); if (b->type != GUI_BOX_TYPE_GAME || is_resizing) { const int sz = 9; // display size is 9, interaction is 12 const ALLEGRO_COLOR color = is_resizing ? COLOR_SKIN_WINDOW_TEXT_HIGHLIGHT : COLOR_SKIN_WINDOW_TITLEBAR_TEXT_UNACTIVE; al_draw_filled_triangle(bb_max.x+2, bb_max.y+2, bb_max.x+2-sz, bb_max.y+2, bb_max.x+2, bb_max.y+2-sz, color); } } // Draw title bar { t_frame titlebar_frame; titlebar_frame.pos.x = bb.pos.x; titlebar_frame.pos.y = bb.pos.y - 18; titlebar_frame.size.x = bb.size.x; titlebar_frame.size.y = 15; SkinGradient_DrawHorizontal(&Skins_GetCurrentSkin()->gradient_window_titlebar, gui_buffer, &titlebar_frame); // Draw title bar text, with wrapping // Is window the focused one? const ALLEGRO_COLOR color = (i == 0) ? COLOR_SKIN_WINDOW_TITLEBAR_TEXT : COLOR_SKIN_WINDOW_TITLEBAR_TEXT_UNACTIVE; Font_SetCurrent(FONTID_LARGE); if (Font_TextWidth(FONTID_CUR, b->title) <= (bb.size.x - 8)) { Font_Print (FONTID_CUR, b->title, bb.pos.x + 4, bb.pos.y - 17, color); } else { // FIXME-OPT: shit code. char title[256]; int len = strlen(b->title); strcpy(title, b->title); while (Font_TextWidth(FONTID_CUR, title) > (bb.size.x - 17)) title[--len] = EOSTR; strcat(title, ".."); Font_Print(FONTID_CUR, title, bb.pos.x + 4, bb.pos.y - 17, color); } // Draw widgets for (t_list* widgets = b->widgets; widgets != NULL; widgets = widgets->next) { t_widget *w = (t_widget *)widgets->elem; if (w->enabled && w->type == WIDGET_TYPE_CLOSEBOX) if (w->redraw_func != NULL) w->redraw_func(w); } } } // Redraw menus on top of the desktop gui_redraw_menus(); // Update applets that comes after the redraw gui_update_applets_after_redraw(); // Clear global redrawing flag and makes mouse reappear gui.info.must_redraw = FALSE; }
void engine_draw_frame(void) { float h2=(float)height/2.25f; if(display==NULL) return; if(fTime>(1.0f/20.0f)) { float iTimeFull; PullData(); iTimeFull=(MSDat.iTimeX*65536)+ShortSwap(MSDat.iTime); RPM=iTimeFull>0?(60000000*2.0f)/(iTimeFull*4):0; //0 to 8000 CLT=cltTable[MSDat.cltADC]; //-115 to 430 TPS=tpsTable[MSDat.tpsADC]; //-11 to 128 BAT=(float)MSDat.batADC/255.0f*30.0f; //7 to 21 MAP=(float)MSDat.mapADC; //0 to 255 MAT=matTable[MSDat.matADC]; //-85 to 430 AFR=10+(MSDat.egoADC*0.039216); //10 to 19.4 ADV=(MSDat.advance*0.352)-10; //50 to -10 fTime=0.0f; } glClear(GL_COLOR_BUFFER_BIT); glUseProgram(Objects[GLSL_GAUGE_SHADER]); glUniform1i(Objects[GLSL_GAUGE_TEX], 0); glUniform1f(Objects[GLSL_GAUGE_WIDTH], (float)width); glUniform1f(Objects[GLSL_GAUGE_HEIGHT], (float)height); glActiveTexture(GL_TEXTURE0); glUniform1f(Objects[GLSL_GAUGE_AMOUNT], RPM/8000.0f); glBindTexture(GL_TEXTURE_2D, Objects[TEXTURE_RPM]); drawquad(0.0f, h2, h2); glUniform1f(Objects[GLSL_GAUGE_AMOUNT], (CLT+40)/(250+40)); glBindTexture(GL_TEXTURE_2D, Objects[TEXTURE_CLT]); drawquad(h2, h2, h2); glUniform1f(Objects[GLSL_GAUGE_AMOUNT], TPS/100); glBindTexture(GL_TEXTURE_2D, Objects[TEXTURE_TPS]); drawquad(h2+h2, h2, h2); glUniform1f(Objects[GLSL_GAUGE_AMOUNT], (BAT-7)/(21-7)); glBindTexture(GL_TEXTURE_2D, Objects[TEXTURE_BAT]); drawquad(h2+h2+h2, h2, h2); glUniform1f(Objects[GLSL_GAUGE_AMOUNT], MAP/255.0f); glBindTexture(GL_TEXTURE_2D, Objects[TEXTURE_MAP]); drawquad(0.0f, 0.0f, h2); glUniform1f(Objects[GLSL_GAUGE_AMOUNT], (MAT+40)/(220+40)); glBindTexture(GL_TEXTURE_2D, Objects[TEXTURE_MAT]); drawquad(h2, 0.0f, h2); glUniform1f(Objects[GLSL_GAUGE_AMOUNT], (AFR-10)/(19-10)); glBindTexture(GL_TEXTURE_2D, Objects[TEXTURE_AFR]); drawquad(h2+h2, 0.0f, h2); glUniform1f(Objects[GLSL_GAUGE_AMOUNT], (ADV+10)/(50+10)); glBindTexture(GL_TEXTURE_2D, Objects[TEXTURE_IGN]); drawquad(h2+h2+h2, 0.0f, h2); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); Font_Print(0+100, h2+75, "%0.2f", RPM); Font_Print(h2+100, h2+75, "%0.2f", CLT); Font_Print(h2+h2+100, h2+75, "%0.2f", TPS); Font_Print(h2+h2+h2+100, h2+75, "%0.2f", BAT); Font_Print(0+100, 0+75, "%0.2f", MAP); Font_Print(h2+100, 0+75, "%0.2f", MAT); Font_Print(h2+h2+100, 0+75, "%0.2f", AFR); Font_Print(h2+h2+h2+100, 0+75, "%0.2f", ADV); Font_Print(0, 0, "FPS %0.3f\n%s", FPS, MSVer); glDisable(GL_BLEND); eglSwapBuffers(display, surface); }
void Pong_Update (void) { char score [20]; circlefill (pong.scr, pong.ballx, pong.bally, 3, COLOR_BLACK); pong.ballx += pong.balldx; pong.bally += pong.balldy; circlefill (pong.scr, pong.ballx, pong.bally, 3, COLOR_WHITE); if (pong.balldx > 0) { if (pong.ballx > 255) { pong.p1score ++; circlefill (pong.scr, pong.ballx, pong.bally, 3, COLOR_BLACK); Pong_Init_Ball (); } if (pong.ballx > 245) if ((pong.bally >= pong.p2y - 1) && (pong.bally <= pong.p2y + 33)) { pong.balldx =- pong.balldx; pong.balldy = (pong.bally - pong.p2y - 16) / 6; } } else { if (pong.ballx < 9) { pong.p2score ++; circlefill (pong.scr, pong.ballx, pong.bally, 3, COLOR_BLACK); Pong_Init_Ball (); } if (pong.ballx < 19) if ((pong.bally >= pong.p1y - 1) && (pong.bally <= pong.p1y + 33)) { pong.balldx =- pong.balldx; pong.balldy = (pong.bally - pong.p1y - 16) / 6; } } if (key[KEY_W] | key[KEY_S]) { rectfill (pong.scr, 9, pong.p1y, 13, pong.p1y + 32, COLOR_BLACK); if ((key [KEY_W]) && (pong.p1y > 12)) pong.p1y -= 3; if ((key [KEY_S]) && (pong.p1y < 157)) pong.p1y += 3; rectfill (pong.scr, 9, pong.p1y, 13, pong.p1y + 32, COLOR_WHITE); } if (key [KEY_UP] | key [KEY_DOWN]) { rectfill (pong.scr, 250, pong.p2y, 254, pong.p2y + 32, COLOR_BLACK); if ((key[KEY_UP]) && (pong.p2y > 12)) pong.p2y -= 3; if ((key[KEY_DOWN]) && (pong.p2y < 157)) pong.p2y += 3; rectfill (pong.scr, 250, pong.p2y, 254, pong.p2y + 32, COLOR_WHITE); } if ((pong.balldy > 0) && (pong.bally > 187)) pong.balldy =- pong.balldy; if ((pong.balldy < 0) && (pong.bally < 14)) pong.balldy =- pong.balldy; Font_SetCurrent (F_MIDDLE); sprintf (score, "%d - %d", pong.p1score, pong.p2score); rectfill (pong.scr, 0, 1, 255, 1 + Font_Height(-1), COLOR_BLACK); Font_Print (-1, pong.scr, score, 8 + ((248 - Font_TextLength(-1, score)) / 2), 1, COLOR_WHITE); Games_Blit (); }
void Tetris_Draw_Score (void) { char s[20]; static int last_score = -1; static int last_level = -1; if (to.score == last_score) return; Font_SetCurrent (F_MIDDLE); rectfill (to.scr, 171, 1, 250, Font_Height(-1), COLOR_BLACK); sprintf (s, "Score: %d", to.score); Font_Print (-1, to.scr, s, 171, 1, COLOR_WHITE); last_score = to.score; if (to.level != last_level) { rectfill (to.scr, 171, 41, 250, Font_Height(-1), COLOR_BLACK); sprintf (s, "Level: %d", to.level); Font_Print (-1, to.scr, s, 171, 41, COLOR_WHITE); last_level = to.level; if (to.level > 1) switch (to.level) { case 2: Msg (MSGT_USER, "Do you enjoy wasting your time ?"); break; case 3: Msg (MSGT_USER, "I think you should get a life !"); break; case 4: Msg (MSGT_USER, "Ok... you must be very bored..."); break; case 5: Msg (MSGT_USER, "...So, i'll propose you a new game."); break; case 6: Msg (MSGT_USER, "Find the bugs of this game :-)"); break; case 7: Msg (MSGT_USER, "You don't have find them yet ?"); break; case 8: Msg (MSGT_USER, "Ok, I'll tell you one..."); break; case 9: Msg (MSGT_USER, "... play another 2147483638 levels.."); break; case 10: Msg (MSGT_USER, "... and you'll see that the game is very slow !"); break; default: switch (Random(3)) { case 0: Msg (MSGT_USER, "only %i levels to wait..", 2147483638-to.level); break; case 1: Msg (MSGT_USER, "Windows will crash before, anyway"); break; case 2: Msg (MSGT_USER, "In fact, Windows have the same bug :"); Msg (MSGT_USER, "when the timer int overflows, Windows crash :-)"); break; } } } }
void TileViewer_Update(t_app_tile_viewer *app) { ALLEGRO_BITMAP *bmp = app->box->gfx_buffer; // Skip update if not active if (!app->active) return; // If skin has changed, redraw everything if (app->box->flags & GUI_BOX_FLAGS_DIRTY_REDRAW_ALL_LAYOUT) { TileViewer_Layout(app, FALSE); app->box->flags &= ~GUI_BOX_FLAGS_DIRTY_REDRAW_ALL_LAYOUT; app->dirty = TRUE; } bool dirty_all = app->dirty || Palette_EmulationDirtyAny; bool dirty = dirty_all; // Update hovered tile index { const int mx = app->tiles_display_zone->mouse_x; const int my = app->tiles_display_zone->mouse_y; // Msg(MSGT_USER, "mx = %d, my = %d", mx, my); if (app->tiles_display_zone->mouse_action & WIDGET_MOUSE_ACTION_HOVER) app->tile_hovered = ((my / 8) * 16) + mx / 8; else app->tile_hovered = -1; } // Compute the tile that is to display in the bottom info line int tile_current = (app->tile_hovered != -1) ? app->tile_hovered : app->tile_selected; bool tile_current_refresh = /*(tile_current == -1) ? FALSE : */ (((tile_current != app->tile_displayed) || dirty_all || tgfx.Tile_Dirty [tile_current])); int tile_current_addr = -1; const v2i tiles_frame_pos = app->tiles_display_frame.pos; const v2i tile_selected_pos = v2i(app->tile_selected_frame.pos.x + 2, app->tile_selected_frame.pos.y + 2); int vram_addr_min = 0x0000; int vram_addr_size = 0; int vram_tile_size = 1; // Then redraw all tiles ALLEGRO_LOCKED_REGION* locked_region = al_lock_bitmap(app->box->gfx_buffer, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READWRITE); switch (g_driver->vdp) { case VDP_SMSGG: { widget_set_enabled(app->vram_addr_tms9918_scrollbar, false); vram_addr_min = 0; vram_addr_size = 0x4000; vram_tile_size = 32; int n = 0; const u8 * nd = &tgfx.Tile_Decoded[0][0]; const u32 * palette_host = app->palette ? &Palette_EmulationToHostGui[16] : &Palette_EmulationToHostGui[0]; for (int y = 0; y != app->tiles_height; y++) { for (int x = 0; x != app->tiles_width; x++) { if (tgfx.Tile_Dirty [n] & TILE_DIRTY_DECODE) Decode_Tile (n); if (dirty_all || tgfx.Tile_Dirty [n]) { VDP_Mode4_DrawTile(app->box->gfx_buffer, locked_region, nd, palette_host, tiles_frame_pos.x+(x * 8), tiles_frame_pos.y+(y * 8), 0); tgfx.Tile_Dirty [n] = 0; dirty = TRUE; } if (n == tile_current) { tile_current_addr = vram_addr_min + (n * 32); VDP_Mode4_DrawTile(app->box->gfx_buffer, locked_region, nd, palette_host, tile_selected_pos.x, tile_selected_pos.y, 0); } n ++; nd += 64; } } break; } case VDP_TMS9918: { widget_set_enabled(app->vram_addr_tms9918_scrollbar, true); vram_addr_min = 0x0000 + app->vram_addr_tms9918_current*0x1000; vram_addr_size = 0x1000; vram_tile_size = 8; const int fg_color = Palette_EmulationToHostGui[app->palette + 1]; const int bg_color = Palette_EmulationToHostGui[(app->palette != 0) ? 1 : 15]; const u8 * addr = VRAM + vram_addr_min; //VRAM = g_machine.VDP.sg_pattern_gen_address; // addr = &VRAM[apps.opt.Tiles_Base]; int n = 0; for (int y = 0; y != app->tiles_height; y ++) { for (int x = 0; x != app->tiles_width; x ++) { if ((addr - VRAM) > 0x4000) break; VDP_Mode0123_DrawTile(bmp, locked_region, tiles_frame_pos.x+(x * 8), tiles_frame_pos.y+(y * 8), addr, fg_color, bg_color); if (n == tile_current) { tile_current_addr = vram_addr_min + (n * 8); VDP_Mode0123_DrawTile(bmp, locked_region, tile_selected_pos.x, tile_selected_pos.y, addr, fg_color, bg_color); } n++; addr += 8; } } dirty = TRUE; // to be replaced later break; } } al_unlock_bitmap(app->box->gfx_buffer); // Refresh top status line (address range) al_set_target_bitmap(bmp); { // FIXME-OPT const int y = -1; al_draw_filled_rectangle(0, y + 1, app->vram_addr_tms9918_scrollbar->enabled ? app->vram_addr_tms9918_scrollbar->frame.pos.x-1 : 128-1, y + 11+1, COLOR_SKIN_WINDOW_BACKGROUND); char buf[64]; sprintf(buf, "Range: $%04X-$%04X", vram_addr_min, vram_addr_min+vram_addr_size-1); Font_Print(FONTID_SMALL, buf, 0, y + 1, COLOR_SKIN_WINDOW_TEXT); dirty = true; } // Refresh bottom status line (selected tile) if (dirty_all || tile_current_refresh) { const int y = app->tiles_display_frame.GetMax().y; al_draw_filled_rectangle(16, y + 1, 127+1, y + 11+1, COLOR_SKIN_WINDOW_BACKGROUND); dirty = TRUE; if (tile_current != -1) { // Description char addr[16]; if (tile_current_addr != -1) sprintf(addr, "$%04X", tile_current_addr); else sprintf(addr, "????"); char buf[128]; const int tile_index = tile_current_addr / vram_tile_size; sprintf(buf, Msg_Get(MSG_TilesViewer_Tile), tile_index, tile_index, addr); Font_Print(FONTID_SMALL, buf, 16, y + 1, COLOR_SKIN_WINDOW_TEXT); app->tile_displayed = tile_current; } else { // Fill tile with black const t_frame* fr = &app->tile_selected_frame; al_draw_filled_rectangle(fr->pos.x+2, fr->pos.y+2, fr->pos.x+2+8, fr->pos.y+2+8, COLOR_BLACK); } } if (dirty_all || dirty) app->dirty = FALSE; }