static void GameLoop_PrepareAnimation(const HouseAnimation_Animation *animation, const HouseAnimation_Subtitle *subtitle, uint16 arg_8062, const HouseAnimation_SoundEffect *soundEffect) { uint8 i; uint8 colors[16]; s_houseAnimation_animation = animation; s_houseAnimation_subtitle = subtitle; s_houseAnimation_soundEffect = soundEffect; s_houseAnimation_currentSubtitle = 0; s_houseAnimation_currentSoundEffect = 0; g_fontCharOffset = 0; s_var_8062 = arg_8062; s_var_8068 = 0; s_subtitleWait = 0xFFFF; s_subtitleActive = false; s_palettePartDirection = PPD_STOPPED; s_palettePartCount = 0; s_paletteAnimationTimeout = 0; GFX_ClearScreen(); File_ReadBlockFile("INTRO.PAL", g_palette1, 256 * 3); memcpy(g_palette_998A, g_palette1, 256 * 3); Font_Select(g_fontIntro); GFX_Screen_SetActive(SCREEN_0); memcpy(s_palettePartTarget, &g_palette1[(144 + s_houseAnimation_subtitle->colour * 16) * 3], 6 * 3); memset(&g_palette1[215 * 3], 0, 6 * 3); memcpy(s_palettePartCurrent, s_palettePartTarget, 6 * 3); memset(s_palettePartChange, 0, 6 * 3); colors[0] = 0; for (i = 0; i < 6; i++) colors[i + 1] = 215 + i; GUI_InitColors(colors, 0, 15); }
static bool Unknown_25C4_000E(void) { Timer_Init(); if (!Video_Init()) return false; Mouse_Init(); /* Add the general tickers */ Timer_Add(Video_Tick, 1000000 / 60); Timer_Add(Timer_Tick, 1000000 / 60); g_var_7097 = -1; GFX_Init(); GFX_ClearScreen(); if (!Font_Init()) { Error( "--------------------------\n" "ERROR LOADING DATA FILE\n" "\n" "Did you copy the Dune2 1.07eu data files into the data directory ?\n" "\n" ); return false; } Font_Select(g_fontNew8p); g_palette_998A = calloc(256 * 3, sizeof(uint8)); memset(&g_palette_998A[45], 63, 3); GFX_SetPalette(g_palette_998A); Tools_RandomLCG_Seed((unsigned)time(NULL)); Widget_SetCurrentWidget(0); return true; }
/** * Initialize Timer, Video, Mouse, GFX, Fonts, Random number generator * and current Widget */ static bool OpenDune_Init(int screen_magnification, VideoScaleFilter filter) { if (!Font_Init()) { Error( "--------------------------\n" "ERROR LOADING DATA FILE\n" "\n" "Did you copy the Dune2 1.07eu data files into the data directory ?\n" "\n" ); return false; } Timer_Init(); if (!Video_Init(screen_magnification, filter)) return false; Mouse_Init(); /* Add the general tickers */ Timer_Add(Timer_Tick, 1000000 / 60, false); Timer_Add(Video_Tick, 1000000 / 60, true); g_mouseDisabled = -1; GFX_Init(); GFX_ClearScreen(); Font_Select(g_fontNew8p); g_palette_998A = calloc(256 * 3, sizeof(uint8)); memset(&g_palette_998A[45], 63, 3); GFX_SetPalette(g_palette_998A); Tools_RandomLCG_Seed((unsigned)time(NULL)); Widget_SetCurrentWidget(0); return true; }
static bool Unknown_25C4_000E() { if (!Video_Init()) return false; /* g_var_7097 = -1; */ GFX_Init(); GFX_ClearScreen(); if (!Font_Init()) { Error( "--------------------------\n" "ERROR LOADING DATA FILE\n" "\n" "Did you copy the Dune2 1.07eu data files into the data directory\n" "%s/data ?\n" "\n", g_dune_data_dir ); return false; } Font_Select(g_fontNew8p); memset(g_palette_998A, 0, 3 * 256); memset(&g_palette_998A[45], 63, 3); GFX_SetPalette(g_palette_998A); srand((unsigned)time(NULL)); Tools_RandomLCG_Seed((unsigned)time(NULL)); Widget_SetCurrentWidget(0); return true; }
static void GameCredits_Play(char *data, uint16 windowID, Screen memory, Screen screenID, uint16 delay) { uint16 loc02; uint16 stringCount = 0; uint32 loc0C; uint16 spriteID = 514; bool loc10 = false; uint16 spriteX; uint16 spriteY; uint16 spritePos = 0; struct { uint16 x; int16 y; char *text; uint8 separator; uint8 charHeight; uint8 type; } strings[33]; struct { uint16 x; uint16 y; } positions[6]; uint16 stage = 4; uint16 counter = 60; Widget_SetCurrentWidget(windowID); spriteX = (g_curWidgetWidth << 3) - Sprite_GetWidth(g_sprites[spriteID]); spriteY = g_curWidgetHeight - Sprite_GetHeight(g_sprites[spriteID]); positions[0].x = spriteX; positions[0].y = 0; positions[1].x = 0; positions[1].y = spriteY / 2; positions[2].x = spriteX; positions[2].y = spriteY; positions[3].x = 0; positions[3].y = 0; positions[4].x = spriteX; positions[4].y = spriteY / 2; positions[5].x = 0; positions[5].y = spriteY; GUI_Screen_Copy(0, 0, 0, 0, SCREEN_WIDTH / 8, SCREEN_HEIGHT, SCREEN_0, memory); GUI_Screen_Copy(0, 0, 0, 0, SCREEN_WIDTH / 8, SCREEN_HEIGHT, memory, screenID); GameCredits_SwapScreen(g_curWidgetYBase, g_curWidgetHeight, memory, s_buffer_182E); GFX_Screen_SetActive(SCREEN_0); loc0C = g_timerSleep; Input_History_Clear(); while (true) { while (loc0C > g_timerSleep) sleepIdle(); loc0C = g_timerSleep + delay; while ((g_curWidgetHeight / 6) + 2 > stringCount && *data != 0) { char *text = data; uint16 y; if (stringCount != 0) { y = strings[stringCount - 1].y; if (strings[stringCount - 1].separator != 5) y += strings[stringCount - 1].charHeight + strings[stringCount - 1].charHeight / 8; } else { y = g_curWidgetHeight; } text = data; data = strpbrk(data, "\x05\r"); if (data == NULL) data = strchr(text, '\0'); strings[stringCount].separator = *data; *data = '\0'; if (strings[stringCount].separator != 0) data++; strings[stringCount].type = 0; if (*text == 3 || *text == 4) strings[stringCount].type = *text++; if (*text == 1) { text++; Font_Select(g_fontNew6p); } else if (*text == 2) { text++; Font_Select(g_fontNew8p); } strings[stringCount].charHeight = g_fontCurrent->height; switch (strings[stringCount].type) { case 3: strings[stringCount].x = 157 - Font_GetStringWidth(text); break; case 4: strings[stringCount].x = 161; break; default: strings[stringCount].x = 1 + (SCREEN_WIDTH - Font_GetStringWidth(text)) / 2; break; } strings[stringCount].y = y; strings[stringCount].text = text; stringCount++; } switch (stage) { case 0: GUI_ClearScreen(memory); if (spriteID == 514) GUI_ClearScreen(screenID); stage++; counter = 2; break; case 1: case 4: if (counter-- == 0) { counter = 0; stage++; } break; case 2: if (spriteID == 525) spriteID = 514; GUI_DrawSprite(memory, g_sprites[spriteID], positions[spritePos].x, positions[spritePos].y, windowID, 0x4000); counter = 8; stage++; spriteID++; if (++spritePos > 5) spritePos = 0;; break; case 3: if (counter < 8) GFX_SetPalette(g_palette1 + 256 * 3 * counter); if (counter-- == 0) { stage++; counter = 20; } break; case 5: if (counter > 0) GFX_SetPalette(g_palette1 + 256 * 3 * counter); if (counter++ >= 8) stage = 0; break; default: break; } GUI_Screen_Copy(g_curWidgetXBase, g_curWidgetYBase, g_curWidgetXBase, g_curWidgetYBase, g_curWidgetWidth, g_curWidgetHeight, memory, screenID); for (loc02 = 0; loc02 < stringCount; loc02++) { if ((int16)strings[loc02].y < g_curWidgetHeight) { GFX_Screen_SetActive(screenID); Font_Select(g_fontNew8p); if (strings[loc02].charHeight != g_fontCurrent->height) Font_Select(g_fontNew6p); GUI_DrawText(strings[loc02].text, strings[loc02].x, strings[loc02].y + g_curWidgetYBase, 255, 0); GFX_Screen_SetActive(SCREEN_0); } strings[loc02].y--; } GameCredits_SwapScreen(g_curWidgetYBase, g_curWidgetHeight, screenID, s_buffer_182E); if ((int16)strings[0].y < -10) { strings[0].text += strlen(strings[0].text); *strings[0].text = strings[0].separator; stringCount--; memcpy(&strings[0], &strings[1], stringCount * sizeof(*strings)); } if ((g_curWidgetHeight / 6 + 2) > stringCount) { if (strings[stringCount - 1].y + strings[stringCount - 1].charHeight < g_curWidgetYBase + g_curWidgetHeight) loc10 = true; } if (loc10 && stage == 0) break; if (Input_Keyboard_NextKey() != 0) break; } GUI_SetPaletteAnimated(g_palette2, 120); GUI_ClearScreen(SCREEN_0); GUI_ClearScreen(memory); GUI_ClearScreen(screenID); }
static void GameLoop_PlaySubtitle(uint8 animation) { const HouseAnimation_Subtitle *subtitle; uint8 i; uint8 colors[16]; s_var_8068++; GameLoop_PlaySoundEffect(animation); subtitle = &s_houseAnimation_subtitle[s_houseAnimation_currentSubtitle]; if (subtitle->stringID == 0xFFFF || subtitle->animationID > animation) return; if (s_subtitleActive) { if (s_subtitleWait == 0xFFFF) s_subtitleWait = subtitle->waitFadeout; if (s_subtitleWait-- != 0) return; s_subtitleActive = false; s_houseAnimation_currentSubtitle++; s_palettePartDirection = PPD_TO_BLACK; if (subtitle->paletteFadeout != 0) { s_palettePartCount = subtitle->paletteFadeout; for (i = 0; i < 18; i++) { s_palettePartChange[i] = s_palettePartTarget[i] / s_palettePartCount; if (s_palettePartChange[i] == 0) s_palettePartChange[i] = 1; } return; } memcpy(s_palettePartChange, s_palettePartTarget, 18); s_palettePartCount = 1; return; } if (s_subtitleWait == 0xFFFF) s_subtitleWait = subtitle->waitFadein; if (s_subtitleWait-- != 0) return; memcpy(s_palettePartTarget, &g_palette1[(144 + (subtitle->colour * 16)) * 3], 18); s_subtitleActive = true; GUI_DrawFilledRectangle(0, subtitle->top == 85 ? 0 : subtitle->top, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0); if (g_enableVoices != 0 && s_feedback_base_index != 0xFFFF && s_houseAnimation_currentSubtitle != 0 && g_config.language == LANGUAGE_ENGLISH) { /* specific code for Intro * @see GameLoop_GameIntroAnimation() */ uint16 feedback_index = s_feedback_base_index + s_houseAnimation_currentSubtitle; Sound_Output_Feedback(feedback_index); if (g_feedback[feedback_index].messageId != 0) { /* force drawing of subtitle */ GameLoop_DrawText(String_Get_ByIndex(subtitle->stringID), subtitle->top); } } else { if (subtitle->stringID != STR_NULL) { GameLoop_DrawText(String_Get_ByIndex(subtitle->stringID), subtitle->top); } } s_palettePartDirection = PPD_TO_NEW_PALETTE; if (subtitle->paletteFadein != 0) { s_palettePartCount = subtitle->paletteFadein; for (i = 0; i < 18; i++) { s_palettePartChange[i] = s_palettePartTarget[i] / s_palettePartCount; if (s_palettePartChange[i] == 0) s_palettePartChange[i] = 1; } } else { memcpy(s_palettePartChange, s_palettePartTarget, 18); s_palettePartCount = 1; } if (g_playerHouseID != HOUSE_INVALID || s_houseAnimation_currentSubtitle != 2) return; GUI_DrawText_Wrapper(NULL, 0, 0, 0, 0, 0x21); GUI_DrawText_Wrapper("Copyright (c) 1992 Westwood Studios, Inc.", 160, 189, 215, 0, 0x112); g_fontCharOffset = 0; colors[0] = 0; for (i = 0; i < 6; i++) colors[i + 1] = 215 + i; GUI_InitColors(colors, 0, 15); Font_Select(g_fontIntro); }