/* * Update part of the palette one step. * @param finishNow Finish all steps now. * @return Direction of change for the next call. * @note If \a finishNow, the new palette is not written to the screen. * @see PalettePartDirection */ static ushort GameLoop_PalettePart_Update(bool finishNow) { Sound_StartSpeech(); if (s_palettePartDirection == PalettePartDirection.PPD_STOPPED) { return(0); } if (s_paletteAnimationTimeout >= g_timerGUI && !finishNow) { return((ushort)s_palettePartDirection); } s_paletteAnimationTimeout = g_timerGUI + 7; if (--s_palettePartCount == 0 || finishNow) { if (s_palettePartDirection == PalettePartDirection.PPD_TO_NEW_PALETTE) { Buffer.BlockCopy(s_palettePartTarget, 0, s_palettePartCurrent, 0, 18); //memcpy(s_palettePartCurrent, s_palettePartTarget, 18); } else { Array.Fill <byte>(s_palettePartCurrent, 0, 0, 18); //memset(s_palettePartCurrent, 0, 18); } s_palettePartDirection = PalettePartDirection.PPD_STOPPED; } else { byte i; for (i = 0; i < 18; i++) { s_palettePartCurrent[i] = s_palettePartDirection == PalettePartDirection.PPD_TO_NEW_PALETTE ? (byte)Math.Min(s_palettePartCurrent[i] + s_palettePartChange[i], s_palettePartTarget[i]) : (byte)Math.Max(s_palettePartCurrent[i] - s_palettePartChange[i], 0); } } if (finishNow) { return((ushort)s_palettePartDirection); } Buffer.BlockCopy(s_palettePartCurrent, 0, g_palette_998A, 215 * 3, 18); //memcpy(&g_palette_998A[215 * 3], s_palettePartCurrent, 18); GFX_SetPalette(g_palette_998A); return((ushort)s_palettePartDirection); }
static void GameLoop_PrepareAnimation(HouseAnimation_Subtitle[] subtitle, ushort feedback_base_index, HouseAnimation_SoundEffect[] soundEffect) { byte i; var colors = new byte[16]; s_houseAnimation_subtitle = subtitle; s_houseAnimation_soundEffect = soundEffect; s_houseAnimation_currentSubtitle = 0; s_houseAnimation_currentSoundEffect = 0; g_fontCharOffset = 0; s_feedback_base_index = feedback_base_index; s_subtitleIndex = 0; s_subtitleWait = 0xFFFF; s_subtitleActive = false; s_palettePartDirection = PalettePartDirection.PPD_STOPPED; s_palettePartCount = 0; s_paletteAnimationTimeout = 0; GFX_ClearScreen(Screen.ACTIVE); File_ReadBlockFile("INTRO.PAL", g_palette1, 256 * 3); Buffer.BlockCopy(g_palette1, 0, g_palette_998A, 0, 256 * 3); //memcpy(g_palette_998A, g_palette1, 256 * 3); Font_Select(g_fontIntro); GFX_Screen_SetActive(Screen.NO0); Buffer.BlockCopy(g_palette1, (144 + s_houseAnimation_subtitle[0].colour * 16) * 3, s_palettePartTarget, 0, 6 * 3); //memcpy(s_palettePartTarget, &g_palette1[(144 + s_houseAnimation_subtitle->colour * 16) * 3], 6 * 3); Array.Fill <byte>(g_palette1, 0, 215 * 3, 6 * 3); //memset(&g_palette1[215 * 3], 0, 6 * 3); Buffer.BlockCopy(s_palettePartTarget, 0, s_palettePartCurrent, 0, 6 * 3); //memcpy(s_palettePartCurrent, s_palettePartTarget, 6 * 3); Array.Fill <byte>(s_palettePartChange, 0, 0, 6 * 3); //memset(s_palettePartChange, 0, 6 * 3); colors[0] = 0; for (i = 0; i < 6; i++) { colors[i + 1] = (byte)(215 + i); } GUI_InitColors(colors, 0, 15); }
static void GameLoop_PlaySubtitle(byte animation) { HouseAnimation_Subtitle subtitle; byte i; var colors = new byte[16]; s_subtitleIndex++; 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 = PalettePartDirection.PPD_TO_BLACK; if (subtitle.paletteFadeout != 0) { s_palettePartCount = subtitle.paletteFadeout; for (i = 0; i < 18; i++) { s_palettePartChange[i] = (byte)(s_palettePartTarget[i] / s_palettePartCount); if (s_palettePartChange[i] == 0) { s_palettePartChange[i] = 1; } } return; } Buffer.BlockCopy(s_palettePartTarget, 0, s_palettePartChange, 0, 18); //memcpy(s_palettePartChange, s_palettePartTarget, 18); s_palettePartCount = 1; return; } if (s_subtitleWait == 0xFFFF) { s_subtitleWait = subtitle.waitFadein; } if (s_subtitleWait-- != 0) { return; } Buffer.BlockCopy(g_palette1, (144 + (subtitle.colour * 16)) * 3, s_palettePartTarget, 0, 18); //memcpy(s_palettePartTarget, &g_palette1[(144 + (subtitle.colour * 16)) * 3], 18); s_subtitleActive = true; GUI_DrawFilledRectangle(0, (short)(subtitle.top == 85 ? 0 : subtitle.top), SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0); if (g_enableVoices && s_feedback_base_index != 0xFFFF && s_houseAnimation_currentSubtitle != 0 && g_config.language == (byte)Language.ENGLISH) { /* specific code for Intro * @see GameLoop_GameIntroAnimation() */ var feedback_index = (ushort)(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 != (ushort)Text.STR_NULL) { GameLoop_DrawText(String_Get_ByIndex(subtitle.stringID), subtitle.top); } } s_palettePartDirection = PalettePartDirection.PPD_TO_NEW_PALETTE; if (subtitle.paletteFadein != 0) { s_palettePartCount = subtitle.paletteFadein; for (i = 0; i < 18; i++) { s_palettePartChange[i] = (byte)(s_palettePartTarget[i] / s_palettePartCount); if (s_palettePartChange[i] == 0) { s_palettePartChange[i] = 1; } } } else { Buffer.BlockCopy(s_palettePartTarget, 0, s_palettePartChange, 0, 18); //memcpy(s_palettePartChange, s_palettePartTarget, 18); s_palettePartCount = 1; } if (g_playerHouseID != HouseType.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] = (byte)(215 + i); } GUI_InitColors(colors, 0, 15); Font_Select(g_fontIntro); }