/********************************************************************************* * Description : 关机设定界面 * * Arguments : * * Returns : * * Notes : 标准功能菜单控件 * *********************************************************************************/ INT32 SET_PowerDownSetting(void) { INT32 result = 0; GUI_ClearScreen(NULL); GUI_ResShowPic(GUI_IMG_POWER, 0, 0); GUI_DisplayTextCenter(0, GUI_GetString(GUI_STR_POWEOFFTIME)); GUI_DisplayBattaryLever(); slider.min = 0; slider.max = 60; slider.step = 10; slider.value = g_comval->StandbyTime; result = GUI_Slider(&slider, NULL); if(result != 0) { return result; } g_comval->StandbyTime = (UINT8)slider.value; //重新设置关机时间 MESSAGE_Initial(g_comval); return result; }
INT32 APP_StandBy(void) { UINT32 key; INT wakeup = 0; GUI_DisplayMessage(0, GUI_STR_STANDBY, NULL, GUI_MSG_FLAG_WAIT); if(AP_Support_LCD()) { GUI_ClearScreen(NULL);//清全屏幕 GUI_UpdateScreen(NULL); CloseBacklight(); } ui_auto_update = FALSE; //APP_Sleep(); #ifdef XDL_35uA_POWEROFF//warkey 2.1 //进入超低电流关机 rfd_XcvRegForceWrite32k(); #endif while(1) { key = MESSAGE_Wait(); if(key == AP_MSG_RTC && GetBattery() >= 0) { if(tgt_GetKeyCode(0) == KEY_POWER) { app_trace(APP_MAIN_TRC, "APP_StandBy call DM_DeviceSwithOff"); DM_DeviceSwithOff(); } else // 如果power键长高,无法关机,进入睡眠 { app_trace(APP_MAIN_TRC, "APP_StandBy call APP_Sleep"); APP_Sleep(); } continue; } if(key == (AP_KEY_POWER | AP_KEY_PRESS)) { wakeup = 1; } if(key == (AP_KEY_PLAY | AP_KEY_HOLD)) if(MESSAGE_IsHold()) { wakeup = 1; } if((key & 0xffff) == AP_KEY_UP && wakeup) { key = RESULT_POWERON; break; } if(key == AP_MSG_ALARM) { key = RESULT_ALARM; break; } } APP_Wakeup(); return key; }
static void GameLoop_FinishAnimation(void) { GUI_DrawText_Wrapper(NULL, 0, 0, 0, 0, 0x1); GUI_DrawText_Wrapper(NULL, 0, 0, 0, 0, 0x2); GUI_SetPaletteAnimated(g_palette2, 60); GUI_ClearScreen(SCREEN_0); Input_History_Clear(); GFX_ClearBlock(SCREEN_3); }
/********************************************************************************* * Description : 固件版本界面 * * Arguments : * * Returns : * * Notes : * *********************************************************************************/ INT32 SET_FirmwareSetting(void) { UINT32 key; INT8 buf[20]; BOOL need_draw = TRUE; while(1) { if(need_draw) { // INT8 *p; // UINT8 ch1,ch2,ch3,ch4; GUI_ClearScreen(NULL); //show barcode GUI_ResShowPic(GUI_IMG_FWBCODE, 10, 0); sprintf(buf, "APP:%d.%d", AP_GetVersion() >> 8, AP_GetVersion() & 0xff); GUI_DisplayText(0, 16, buf); sprintf(buf, "Date: %08d", AP_GetBuildDate()); GUI_DisplayText(0, 32, buf); sprintf(buf, "HW:%d.%d r%d", GetPlatformVersion() >> 8, GetPlatformVersion() & 0xff, GetPlatformRevision()); GUI_DisplayText(0, 48, buf); GUI_UpdateScreen(NULL); need_draw = FALSE; }//need_draw key = MESSAGE_Wait(); switch( key ) { case AP_MSG_WAIT_TIMEOUT: //子菜单界面在8秒后返回系统功能菜单 case AP_KEY_MODE | AP_KEY_UP: case AP_KEY_PLAY | AP_KEY_UP: return 0; default: key = MESSAGE_HandleHotkey(key); if(key == RESULT_REDRAW) { need_draw = TRUE; } else if(key != 0) { return key; } } }//while(1) }
INT32 SET_BackLightSetting(void) { GUI_ClearScreen(NULL); GUI_ResShowPic(GUI_IMG_BKLIGHT, 10, 0); GUI_ResShowPic(GUI_IMG_BKLIGHTA, 98, 0); GUI_DisplayBattaryLever(); slider.min = 0; slider.max = 7; slider.step = 1; slider.value = g_comval->BackLight; return GUI_Slider(&slider, SET_BackLightCb); }
/********************************************************************************* * Description : 对比度设定界面 * * Arguments : * * Returns : * * Notes : 注意背景先画 * *********************************************************************************/ INT32 SET_ContrastSetting(void) { GUI_ClearScreen(NULL); GUI_ResShowPic(GUI_IMG_CONTRSTW, 10, 0); GUI_ResShowPic(GUI_IMG_CONTRSTB, 98, 0); GUI_DisplayBattaryLever(); slider.min = 1; slider.max = 7; slider.step = 1; slider.value = g_comval->DisplayContrast; return GUI_Slider(&slider, SET_ContrastCb); }
/********************************************************************************* * Description : 背光时间设定界面 * * Arguments : * * Returns : * * Notes : * *********************************************************************************/ INT32 SET_BackLightTimeSetting(void) { INT32 result = 0; GUI_ClearScreen(NULL); GUI_ResShowPic(GUI_IMG_BKLIGHT, 0, 0); GUI_DisplayBattaryLever(); GUI_DisplayTextCenter(0, GUI_GetString(GUI_STR_BACKLIGHTTIME)); slider.max = 30; slider.min = 0; slider.step = 3; slider.value = g_comval->LightTime; result = GUI_Slider(&slider, SET_BackLightTimeCb); return result; }
/********************************************************************************* * Description : 固件升级 * * Arguments : * * Returns : 结果消息 * * Notes : * *********************************************************************************/ INT32 SET_UpdateSetting(void) { file_location_t location; INT32 file; INT32 result; INT8 *string; INT i; slider.min = 0; slider.max = 100; slider.step = 0; result = GUI_Directory(&location, FSEL_TYPE_ALLFILE, 0); if(result != 0) { return result; } file = FS_OpenDirect(location.file_entry, /*FS_O_RDONLY*/FS_O_RDWR, 0); if(file < 0) { GUI_DisplayMessage(0, GUI_STR_MREADERR, NULL, GUI_MSG_FLAG_WAIT); return; } GUI_ClearScreen(NULL); string = GUI_GetString(GUI_STR_UPGRADING); GUI_DisplayTextCenter(16, string); GUI_UpdateScreen(NULL); /*for(i=0;i<100;i++) { slider.value = i; GUI_Slider(&slider, NULL); MESSAGE_Sleep(1); }*/ Upgrade_Flash(file); GUI_DisplayMessage(0, GUI_STR_UPGRADE_COMPLETE, NULL, GUI_MSG_FLAG_WAIT); RestartSystem(); return RESULT_MAIN; }
/** * Shows the game credits. */ static void GameLoop_GameCredits(void) { static const uint8 colours[] = {0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0}; uint16 i; uint8 *memory; GUI_Mouse_Hide_Safe(); Widget_SetCurrentWidget(20); Sprites_LoadImage("BIGPLAN.CPS", SCREEN_1, g_palette_998A); GUI_ClearScreen(SCREEN_0); GUI_Screen_Copy(g_curWidgetXBase, g_curWidgetYBase, g_curWidgetXBase, g_curWidgetYBase, g_curWidgetWidth, g_curWidgetHeight, SCREEN_1, SCREEN_0); GUI_SetPaletteAnimated(g_palette_998A, 60); Music_Play(0); GameLoop_Uninit(); Music_Play(33); memory = GFX_Screen_Get_ByIndex(SCREEN_2); for (i = 0; i < 256; i++) { uint8 loc06; uint8 loc04; memory[i] = i & 0xFF; loc06 = i / 16; loc04 = i % 16; if (loc06 == 9 && loc04 <= 6) { memory[i] = (g_playerHouseID * 16) + loc04 + 144; } } Sprites_LoadImage("MAPPLAN.CPS", SCREEN_1, g_palette_998A); GUI_Palette_RemapScreen(g_curWidgetXBase << 3, g_curWidgetYBase, g_curWidgetWidth << 3, g_curWidgetHeight, SCREEN_1, memory); GUI_Screen_FadeIn2(g_curWidgetXBase << 3, g_curWidgetYBase, g_curWidgetWidth << 3, g_curWidgetHeight, SCREEN_1, SCREEN_0, 1, false); GameCredits_LoadPalette(); GUI_Mouse_Hide_Safe(); GUI_InitColors(colours, 0, lengthof(colours) - 1); g_fontCharOffset = -1; GFX_SetPalette(g_palette1); for (;; sleepIdle()) { File_ReadBlockFile(String_GenerateFilename("CREDITS"), s_buffer_1832, GFX_Screen_GetSize_ByIndex(SCREEN_3)); GameCredits_Play(s_buffer_1832, 20, SCREEN_1, SCREEN_2, 6); if (Input_Keyboard_NextKey() != 0) break; Music_Play(33); } GUI_SetPaletteAnimated(g_palette2, 60); Driver_Music_FadeOut(); GFX_ClearScreen(); }
static void GameLoop_PlayAnimation(void) { const HouseAnimation_Animation *animation; uint8 animationMode = 0; animation = s_houseAnimation_animation; while (animation->duration != 0) { uint16 loc04; uint16 posX = 0; uint16 posY = 0; uint32 loc10 = g_timerGUI + animation->duration * 6; uint32 loc14 = loc10 + 30; uint32 loc18; uint32 loc1C; uint16 mode = animation->flags & 0x3; bool loc20; uint32 loc24; uint16 locdi; uint16 frame; void *wsa; if ((animation->flags & 0x20) == 0) { posX = 8; posY = 24; } s_var_8068 = 0; if (mode == 0) { wsa = NULL; frame = 0; } else { char filenameBuffer[16]; if (mode == 3) { frame = animation->frameCount; loc20 = true; } else { frame = 0; loc20 = ((animation->flags & 0x40) != 0) ? true : false; } if ((animation->flags & 0x480) != 0) { GUI_ClearScreen(SCREEN_1); wsa = GFX_Screen_Get_ByIndex(SCREEN_2); loc24 = GFX_Screen_GetSize_ByIndex(SCREEN_2) + GFX_Screen_GetSize_ByIndex(SCREEN_3); loc20 = false; } else { wsa = GFX_Screen_Get_ByIndex(SCREEN_1); loc24 = GFX_Screen_GetSize_ByIndex(SCREEN_1) + GFX_Screen_GetSize_ByIndex(SCREEN_2) + GFX_Screen_GetSize_ByIndex(SCREEN_3); } snprintf(filenameBuffer, sizeof(filenameBuffer), "%s.WSA", animation->string); wsa = WSA_LoadFile(filenameBuffer, wsa, loc24, loc20); } locdi = 0; if ((animation->flags & 0x8) != 0) { loc10 -= 45; locdi++; } else { if ((animation->flags & 0x10) != 0) { loc10 -= 15; locdi++; } } if ((animation->flags & 0x4) != 0) { GameLoop_PlaySubtitle(animationMode); WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_0); GameLoop_PalettePart_Update(true); memcpy(&g_palette1[215 * 3], s_palettePartCurrent, 18); GUI_SetPaletteAnimated(g_palette1, 45); locdi++; } else { if ((animation->flags & 0x480) != 0) { GameLoop_PlaySubtitle(animationMode); WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_1); locdi++; if ((animation->flags & 0x480) == 0x80) { GUI_Screen_FadeIn2(8, 24, 304, 120, SCREEN_1, SCREEN_0, 1, false); } else if ((animation->flags & 0x480) == 0x400) { GUI_Screen_FadeIn(1, 24, 1, 24, 38, 120, SCREEN_1, SCREEN_0); } } } loc1C = loc10 - g_timerGUI; loc18 = 0; loc04 = 1; switch (mode) { case 0: loc04 = animation->frameCount - locdi; loc18 = loc1C / loc04; break; case 1: loc04 = WSA_GetFrameCount(wsa); loc18 = loc1C / animation->frameCount; break; case 2: loc04 = WSA_GetFrameCount(wsa) - locdi; loc18 = loc1C / loc04; loc10 -= loc18; break; case 3: frame = animation->frameCount; loc04 = 1; loc18 = loc1C / 20; break; default: PrepareEnd(); Error("Bad mode in animation #%i.\n", animationMode); exit(0); } while (loc10 > g_timerGUI) { g_timerTimeout = loc18; GameLoop_PlaySubtitle(animationMode); WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_0); if (mode == 1 && frame == loc04) { frame = 0; } else { if (mode == 3) frame--; } if (Input_Keyboard_NextKey() != 0 && g_canSkipIntro) { WSA_Unload(wsa); return; } do { GameLoop_PalettePart_Update(false); sleepIdle(); } while (g_timerTimeout != 0 && loc10 > g_timerGUI); } if (mode == 2) { bool displayed; do { GameLoop_PlaySubtitle(animationMode); displayed = WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_0); } while (displayed); } if ((animation->flags & 0x10) != 0) { memset(&g_palette_998A[3 * 1], 63, 255 * 3); memcpy(&g_palette_998A[215 * 3], s_palettePartCurrent, 18); GUI_SetPaletteAnimated(g_palette_998A, 15); memcpy(g_palette_998A, g_palette1, 256 * 3); } if ((animation->flags & 0x8) != 0) { GameLoop_PalettePart_Update(true); memcpy(&g_palette_998A[215 * 3], s_palettePartCurrent, 18); GUI_SetPaletteAnimated(g_palette_998A, 45); } WSA_Unload(wsa); animationMode++; animation++; while (loc14 > g_timerGUI) sleepIdle(); } }
/** * Main game loop. */ static void GameLoop_Main(void) { static uint32 l_timerNext = 0; static uint32 l_timerUnitStatus = 0; static int16 l_selectionState = -2; uint16 key; String_Init(); Sprites_Init(); Input_Flags_SetBits(INPUT_FLAG_KEY_REPEAT | INPUT_FLAG_UNKNOWN_0010 | INPUT_FLAG_UNKNOWN_0200 | INPUT_FLAG_UNKNOWN_2000); Input_Flags_ClearBits(INPUT_FLAG_KEY_RELEASE | INPUT_FLAG_UNKNOWN_0400 | INPUT_FLAG_UNKNOWN_0100 | INPUT_FLAG_UNKNOWN_0080 | INPUT_FLAG_UNKNOWN_0040 | INPUT_FLAG_UNKNOWN_0020 | INPUT_FLAG_UNKNOWN_0008 | INPUT_FLAG_UNKNOWN_0004 | INPUT_FLAG_NO_TRANSLATE); Timer_SetTimer(TIMER_GAME, true); Timer_SetTimer(TIMER_GUI, true); g_campaignID = 0; g_scenarioID = 1; g_playerHouseID = HOUSE_INVALID; g_debugScenario = false; g_selectionType = SELECTIONTYPE_MENTAT; g_selectionTypeNew = SELECTIONTYPE_MENTAT; g_palette1 = calloc(1, 256 * 3); g_palette2 = calloc(1, 256 * 3); g_readBufferSize = 12000; g_readBuffer = calloc(1, g_readBufferSize); ReadProfileIni("PROFILE.INI"); free(g_readBuffer); g_readBuffer = NULL; File_ReadBlockFile("IBM.PAL", g_palette_998A, 256 * 3); memmove(g_palette1, g_palette_998A, 256 * 3); GUI_ClearScreen(SCREEN_0); Video_SetPalette(g_palette1, 0, 256); GFX_SetPalette(g_palette1); GFX_SetPalette(g_palette2); g_paletteMapping1 = malloc(256); g_paletteMapping2 = malloc(256); GUI_Palette_CreateMapping(g_palette1, g_paletteMapping1, 0xC, 0x55); g_paletteMapping1[0xFF] = 0xFF; g_paletteMapping1[0xDF] = 0xDF; g_paletteMapping1[0xEF] = 0xEF; GUI_Palette_CreateMapping(g_palette1, g_paletteMapping2, 0xF, 0x55); g_paletteMapping2[0xFF] = 0xFF; g_paletteMapping2[0xDF] = 0xDF; g_paletteMapping2[0xEF] = 0xEF; Script_LoadFromFile("TEAM.EMC", g_scriptTeam, g_scriptFunctionsTeam, NULL); Script_LoadFromFile("BUILD.EMC", g_scriptStructure, g_scriptFunctionsStructure, NULL); GUI_Palette_CreateRemap(HOUSE_MERCENARY); g_cursorSpriteID = 0; Sprites_SetMouseSprite(0, 0, g_sprites[0]); while (g_mouseHiddenDepth > 1) { GUI_Mouse_Show_Safe(); } Window_WidgetClick_Create(); GameOptions_Load(); Unit_Init(); Team_Init(); House_Init(); Structure_Init(); GUI_Mouse_Show_Safe(); if (g_debugSkipDialogs) { Music_Play(0); free(g_readBuffer); g_readBufferSize = (g_enableVoices == 0) ? 12000 : 20000; g_readBuffer = calloc(1, g_readBufferSize); g_gameMode = GM_NORMAL; } for (;; sleepIdle()) { if (g_gameMode == GM_MENU) { GameLoop_GameIntroAnimationMenu(); if (!g_running) break; if (g_gameMode == GM_MENU) continue; GUI_Mouse_Hide_Safe(); g_canSkipIntro = false; GUI_DrawFilledRectangle(g_curWidgetXBase << 3, g_curWidgetYBase, (g_curWidgetXBase + g_curWidgetWidth) << 3, g_curWidgetYBase + g_curWidgetHeight, 12); Input_History_Clear(); if (s_enableLog != 0) Mouse_SetMouseMode((uint8)s_enableLog, "DUNE.LOG"); GFX_SetPalette(g_palette1); GUI_Mouse_Show_Safe(); } if (g_gameMode == GM_PICKHOUSE) { Music_Play(28); g_playerHouseID = HOUSE_MERCENARY; g_playerHouseID = GUI_PickHouse(); GUI_Mouse_Hide_Safe(); GFX_ClearBlock(SCREEN_0); Sprites_LoadTiles(); GUI_Palette_CreateRemap(g_playerHouseID); Voice_LoadVoices(g_playerHouseID); GUI_Mouse_Show_Safe(); g_gameMode = GM_RESTART; g_scenarioID = 1; g_campaignID = 0; g_strategicRegionBits = 0; } if (g_selectionTypeNew != g_selectionType) { GUI_ChangeSelectionType(g_selectionTypeNew); } GUI_PaletteAnimate(); if (g_gameMode == GM_RESTART) { GUI_ChangeSelectionType(SELECTIONTYPE_MENTAT); Game_LoadScenario(g_playerHouseID, g_scenarioID); if (!g_debugScenario && !g_debugSkipDialogs) GUI_Mentat_ShowBriefing(); g_gameMode = GM_NORMAL; GUI_ChangeSelectionType(g_debugScenario ? SELECTIONTYPE_DEBUG : SELECTIONTYPE_STRUCTURE); Music_Play(Tools_RandomLCG_Range(0, 8) + 8); l_timerNext = g_timerGUI + 300; } if (l_selectionState != g_selectionState) { Map_SetSelectionObjectPosition(0xFFFF); Map_SetSelectionObjectPosition(g_selectionRectanglePosition); l_selectionState = g_selectionState; } if (!Driver_Voice_IsPlaying() && !Sound_StartSpeech()) { if (g_gameConfig.music == 0) { Music_Play(2); g_musicInBattle = 0; } else if (g_musicInBattle > 0) { Music_Play(Tools_RandomLCG_Range(0, 5) + 17); l_timerNext = g_timerGUI + 300; g_musicInBattle = -1; } else { g_musicInBattle = 0; if (g_enableSoundMusic != 0 && g_timerGUI > l_timerNext) { if (!Driver_Music_IsPlaying()) { Music_Play(Tools_RandomLCG_Range(0, 8) + 8); l_timerNext = g_timerGUI + 300; } } } } GFX_Screen_SetActive(SCREEN_0); key = GUI_Widget_HandleEvents(g_widgetLinkedListHead); if (g_selectionType == SELECTIONTYPE_TARGET || g_selectionType == SELECTIONTYPE_PLACE || g_selectionType == SELECTIONTYPE_UNIT || g_selectionType == SELECTIONTYPE_STRUCTURE) { if (g_unitSelected != NULL) { if (l_timerUnitStatus < g_timerGame) { Unit_DisplayStatusText(g_unitSelected); l_timerUnitStatus = g_timerGame + 300; } if (g_selectionType != SELECTIONTYPE_TARGET) { g_selectionPosition = Tile_PackTile(Tile_Center(g_unitSelected->o.position)); } } GUI_Widget_ActionPanel_Draw(false); InGame_Numpad_Move(key); GUI_DrawCredits(g_playerHouseID, 0); GameLoop_Team(); GameLoop_Unit(); GameLoop_Structure(); GameLoop_House(); GUI_DrawScreen(SCREEN_0); } GUI_DisplayText(NULL, 0); if (g_running && !g_debugScenario) { GameLoop_LevelEnd(); } if (!g_running) break; } GUI_Mouse_Hide_Safe(); if (s_enableLog != 0) Mouse_SetMouseMode(INPUT_MOUSE_MODE_NORMAL, "DUNE.LOG"); GUI_Mouse_Hide_Safe(); Widget_SetCurrentWidget(0); GFX_Screen_SetActive(SCREEN_1); GFX_ClearScreen(); GUI_Screen_FadeIn(g_curWidgetXBase, g_curWidgetYBase, g_curWidgetXBase, g_curWidgetYBase, g_curWidgetWidth, g_curWidgetHeight, SCREEN_1, SCREEN_0); }
/** * Intro menu. */ static void GameLoop_GameIntroAnimationMenu(void) { static const uint16 mainMenuStrings[][6] = { {STR_PLAY_A_GAME, STR_REPLAY_INTRODUCTION, STR_EXIT_GAME, STR_NULL, STR_NULL, STR_NULL}, /* Neither HOF nor save. */ {STR_PLAY_A_GAME, STR_REPLAY_INTRODUCTION, STR_LOAD_GAME, STR_EXIT_GAME, STR_NULL, STR_NULL}, /* Has a save game. */ {STR_PLAY_A_GAME, STR_REPLAY_INTRODUCTION, STR_EXIT_GAME, STR_HALL_OF_FAME, STR_NULL, STR_NULL}, /* Has a HOF. */ {STR_PLAY_A_GAME, STR_REPLAY_INTRODUCTION, STR_LOAD_GAME, STR_EXIT_GAME, STR_HALL_OF_FAME, STR_NULL} /* Has a HOF and a save game. */ }; bool loadGame = false; static bool drawMenu = true; static uint16 stringID = STR_REPLAY_INTRODUCTION; uint16 maxWidth; static bool hasSave = false; static bool hasFame = false; static const char *strings[6]; static uint16 index = 0xFFFF; if (index == 0xFFFF) { hasSave = File_Exists("_save000.dat"); hasFame = File_Exists("SAVEFAME.DAT"); index = (hasFame ? 2 : 0) + (hasSave ? 1 : 0); } if (hasSave || File_Exists("ONETIME.DAT")) g_canSkipIntro = true; switch (stringID) { case STR_REPLAY_INTRODUCTION: Music_Play(0); free(g_readBuffer); g_readBufferSize = (g_enableVoices == 0) ? 12000 : 28000; g_readBuffer = calloc(1, g_readBufferSize); GUI_Mouse_Hide_Safe(); Driver_Music_FadeOut(); GameLoop_GameIntroAnimation(); Sound_Output_Feedback(0xFFFE); File_ReadBlockFile("IBM.PAL", g_palette_998A, 256 * 3); memmove(g_palette1, g_palette_998A, 256 * 3); if (!g_canSkipIntro) { File_Create("ONETIME.DAT"); g_canSkipIntro = true; } Music_Play(0); free(g_readBuffer); g_readBufferSize = (g_enableVoices == 0) ? 12000 : 20000; g_readBuffer = calloc(1, g_readBufferSize); GUI_Mouse_Show_Safe(); Music_Play(28); drawMenu = true; break; case STR_EXIT_GAME: g_running = false; return; case STR_HALL_OF_FAME: GUI_HallOfFame_Show(0xFFFF); GFX_SetPalette(g_palette2); hasFame = File_Exists("SAVEFAME.DAT"); drawMenu = true; break; case STR_LOAD_GAME: GUI_Mouse_Hide_Safe(); GUI_SetPaletteAnimated(g_palette2, 30); GUI_ClearScreen(SCREEN_0); GUI_Mouse_Show_Safe(); GFX_SetPalette(g_palette1); if (GUI_Widget_SaveLoad_Click(false)) { loadGame = true; if (g_gameMode == GM_RESTART) break; g_gameMode = GM_NORMAL; } else { GFX_SetPalette(g_palette2); drawMenu = true; } break; default: break; } if (drawMenu) { uint16 i; g_widgetProperties[21].height = 0; for (i = 0; i < 6; i++) { strings[i] = NULL; if (mainMenuStrings[index][i] == 0) { if (g_widgetProperties[21].height == 0) g_widgetProperties[21].height = i; continue; } strings[i] = String_Get_ByIndex(mainMenuStrings[index][i]); } GUI_DrawText_Wrapper(NULL, 0, 0, 0, 0, 0x22); maxWidth = 0; for (i = 0; i < g_widgetProperties[21].height; i++) { if (Font_GetStringWidth(strings[i]) <= maxWidth) continue; maxWidth = Font_GetStringWidth(strings[i]); } maxWidth += 7; g_widgetProperties[21].width = maxWidth >> 3; g_widgetProperties[13].width = g_widgetProperties[21].width + 2; g_widgetProperties[13].xBase = 19 - (maxWidth >> 4); g_widgetProperties[13].yBase = 160 - ((g_widgetProperties[21].height * g_fontCurrent->height) >> 1); g_widgetProperties[13].height = (g_widgetProperties[21].height * g_fontCurrent->height) + 11; Sprites_LoadImage(String_GenerateFilename("TITLE"), SCREEN_1, NULL); GUI_Mouse_Hide_Safe(); GUI_ClearScreen(SCREEN_0); GUI_Screen_Copy(0, 0, 0, 0, SCREEN_WIDTH / 8, SCREEN_HEIGHT, SCREEN_1, SCREEN_0); GUI_SetPaletteAnimated(g_palette1, 30); GUI_DrawText_Wrapper("V1.07", 319, 192, 133, 0, 0x231, 0x39); GUI_DrawText_Wrapper(NULL, 0, 0, 0, 0, 0x22); Widget_SetCurrentWidget(13); GUI_Widget_DrawBorder(13, 2, 1); GameLoop_DrawMenu(strings); GUI_Mouse_Show_Safe(); drawMenu = false; } if (loadGame) return; stringID = GameLoop_HandleEvents(strings); if (stringID != 0xFFFF) stringID = mainMenuStrings[index][stringID]; GUI_PaletteAnimate(); if (stringID == STR_PLAY_A_GAME) g_gameMode = GM_PICKHOUSE; }
/** * Checks if the level comes to an end. If so, it shows all end-level stuff, * and prepares for the next level. */ static void GameLoop_LevelEnd(void) { static uint32 levelEndTimer = 0; if (levelEndTimer >= g_timerGame && !s_debugForceWin) return; if (GameLoop_IsLevelFinished()) { Music_Play(0); g_cursorSpriteID = 0; Sprites_SetMouseSprite(0, 0, g_sprites[0]); Sound_Output_Feedback(0xFFFE); GUI_ChangeSelectionType(SELECTIONTYPE_MENTAT); if (GameLoop_IsLevelWon()) { Sound_Output_Feedback(40); GUI_DisplayModalMessage(String_Get_ByIndex(STR_YOU_HAVE_SUCCESSFULLY_COMPLETED_YOUR_MISSION), 0xFFFF); GUI_Mentat_ShowWin(); Sprites_UnloadTiles(); g_campaignID++; GUI_EndStats_Show(g_scenario.killedAllied, g_scenario.killedEnemy, g_scenario.destroyedAllied, g_scenario.destroyedEnemy, g_scenario.harvestedAllied, g_scenario.harvestedEnemy, g_scenario.score, g_playerHouseID); if (g_campaignID == 9) { GUI_Mouse_Hide_Safe(); GUI_SetPaletteAnimated(g_palette2, 15); GUI_ClearScreen(SCREEN_0); GameLoop_GameEndAnimation(); PrepareEnd(); exit(0); } GUI_Mouse_Hide_Safe(); GameLoop_LevelEndAnimation(); GUI_Mouse_Show_Safe(); File_ReadBlockFile("IBM.PAL", g_palette1, 256 * 3); g_scenarioID = GUI_StrategicMap_Show(g_campaignID, true); GUI_SetPaletteAnimated(g_palette2, 15); if (g_campaignID == 1 || g_campaignID == 7) { if (!GUI_Security_Show()) { PrepareEnd(); exit(0); } } } else { Sound_Output_Feedback(41); GUI_DisplayModalMessage(String_Get_ByIndex(STR_YOU_HAVE_FAILED_YOUR_MISSION), 0xFFFF); GUI_Mentat_ShowLose(); Sprites_UnloadTiles(); g_scenarioID = GUI_StrategicMap_Show(g_campaignID, false); } g_playerHouse->flags.doneFullScaleAttack = false; Sprites_LoadTiles(); g_gameMode = GM_RESTART; s_debugForceWin = false; } levelEndTimer = g_timerGame + 300; }
/** * Intro menu. */ static void GameLoop_GameIntroAnimationMenu() { Timer_SetTimer(TIMER_GUI, true); g_techLevel = 0; g_campaignID = 0; g_scenarioID = 1; g_playerHouseID = HOUSE_INVALID; g_debugScenario = false; g_selectionType = SELECTIONTYPE_MENTAT; g_selectionTypeNew = SELECTIONTYPE_MENTAT; memset(g_palette1, 0, 3 * 256); memset(g_palette2, 0, 3 * 256); g_readBufferSize = 12000; g_readBuffer = NULL; File_ReadBlockFile("IBM.PAL", g_palette_998A, 256 * 3); memmove(g_palette1, g_palette_998A, 256 * 3); GUI_ClearScreen(SCREEN_0); GFX_SetPalette(g_palette1); GFX_SetPalette(g_palette2); GUI_Palette_CreateMapping(g_palette1, g_paletteMapping1, 0xC, 0x55); g_paletteMapping1[0xFF] = 0xFF; g_paletteMapping1[0xDF] = 0xDF; g_paletteMapping1[0xEF] = 0xEF; GUI_Palette_CreateMapping(g_palette1, g_paletteMapping2, 0xF, 0x55); g_paletteMapping2[0xFF] = 0xFF; g_paletteMapping2[0xDF] = 0xDF; g_paletteMapping2[0xEF] = 0xEF; Script_LoadFromFile("TEAM.EMC", g_scriptTeam, g_scriptFunctionsTeam, NULL); Script_LoadFromFile("BUILD.EMC", g_scriptStructure, g_scriptFunctionsStructure, NULL); GUI_Palette_CreateRemap(HOUSE_MERCENARY); Video_SetCursor(SHAPE_CURSOR_NORMAL); Window_WidgetClick_Create(); Unit_Init(); UnitAI_ClearSquads(); Team_Init(); House_Init(); Structure_Init(); { Audio_PlayMusic(MUSIC_STOP); free(g_readBuffer); g_readBufferSize = 0x6D60; g_readBuffer = calloc(1, g_readBufferSize); Menu_GameStarted(); } GFX_SetPalette(g_palette1); }
/********************************************************************************* * Description : 储存状况界面 * * Arguments : * * Returns : * * Notes : * *********************************************************************************/ INT32 SET_StorageSetting(void) { BOOL mem_ok = FALSE; //主内存是否可用 BOOL card_ok = FALSE; //卡是否可用 UINT64 total1 = 0L, free1 = 0L; //内存 UINT8 percent1 = 0; UINT64 total2 = 0L, free2 = 0L; //插卡 UINT8 percent2 = 0L; INT8 toshow = 0; //要显示那个, 0:main, 1:card UINT32 key; BOOL need_draw = TRUE; INT8 buf[20]; // 1024M<100%> card_ok = MountDisk(FS_DEV_TYPE_TFLASH); if(card_ok) { total2 = FS_GetSpace(FS_DEV_TYPE_TFLASH, FS_GET_SPACE_TOTAL); free2 = FS_GetSpace(FS_DEV_TYPE_TFLASH, FS_GET_SPACE_FREE); //处理<1% if(total2 == free2) { percent2 = 0; } else { percent2 = (total2 - free2) * 100 / total2; if(percent2 == 0) { percent2 = 1; } } toshow = 1; } #if APP_SUPPORT_USB mem_ok = MountDisk(FS_DEV_TYPE_USBDISK); if(mem_ok) { total1 = FS_GetSpace(FS_DEV_TYPE_USBDISK, FS_GET_SPACE_TOTAL); free1 = FS_GetSpace(FS_DEV_TYPE_USBDISK, FS_GET_SPACE_FREE); //处理<1% if(total1 == free1) { percent1 = 0; } else { percent1 = (total1 - free1) * 100 / total1; if(percent1 == 0) { percent1 = 1; } } toshow = 0; } #endif //control slider.min = 0; slider.max = 100; while(1) { if(need_draw) { GUI_ClearScreen(NULL); //show progress bar & text//percentage #if APP_SUPPORT_USB if(toshow == 0) { slider.value = percent1; //显示主内存图标 GUI_ResShowImage(GUI_IMG_DEVICE, FS_DEV_TYPE_USBDISK, 0, 0); //显示箭头 if(card_ok) { GUI_ResShowPic(GUI_IMG_CARROWR, 115, 0); } //显示文字 SET_FmtStorage(buf, total1 / 1024 / 1024, percent1); GUI_DisplayTextCenter(0, buf); //GUI_UpdateScreen(NULL); //GUI_Display_Progress(&progress); GUI_Slider(&slider, NULL); } else if(toshow == 1) #endif { slider.value = percent2;//percentage //显示卡图标 GUI_ResShowImage(GUI_IMG_DEVICE, FS_DEV_TYPE_TFLASH, 0, 0); //显示箭头 if(mem_ok) { GUI_ResShowPic(GUI_IMG_CARROWL, 115, 0); } //显示文字 SET_FmtStorage(buf, total2 / 1024 / 1024, percent2); GUI_DisplayTextCenter(0, buf); //GUI_UpdateScreen(NULL); //GUI_Display_Progress(&progress);//progress bar GUI_Slider(&slider, NULL); } need_draw = FALSE; }//need_draw key = MESSAGE_Wait(); switch( key ) { case AP_MSG_WAIT_TIMEOUT: //子菜单界面在8秒后返回系统功能菜单 case AP_KEY_MODE | AP_KEY_UP: case AP_KEY_PLAY | AP_KEY_UP: return 0; //退出 case AP_KEY_NEXT | AP_KEY_PRESS: case AP_KEY_PREV | AP_KEY_PRESS: if(toshow == 0 && card_ok) { toshow = 1; } else if(toshow == 1 && mem_ok) { toshow = 0; } need_draw = TRUE; break; default: key = MESSAGE_HandleHotkey(key); if(key == RESULT_REDRAW) { need_draw = TRUE; } else if(key != 0) { return key; } }//switch(key) }//while(1) }
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_PlayAnimation(const HouseAnimation_Animation *animation) { uint8 animationMode = 0; while (animation->duration != 0) { uint16 frameCount; uint16 posX = 0; uint16 posY = 0; uint32 timeout = g_timerGUI + animation->duration * 6; uint32 timeout2 = timeout + 30; /* timeout + 0.5 s */ uint32 timeLeftForFrame; uint32 timeLeft; uint16 mode = animation->flags & 0x3; uint16 addFrameCount; /* additional frame count */ uint16 frame; void *wsa; if ((animation->flags & 0x20) == 0) { posX = 8; posY = 24; } s_var_8068 = 0; if (mode == 0) { wsa = NULL; frame = 0; } else { char filenameBuffer[16]; uint32 wsaSize; bool wsaReservedDisplayFrame; if (mode == 3) { frame = animation->frameCount; wsaReservedDisplayFrame = true; } else { frame = 0; wsaReservedDisplayFrame = ((animation->flags & 0x40) != 0) ? true : false; } if ((animation->flags & 0x480) != 0) { GUI_ClearScreen(SCREEN_1); wsa = GFX_Screen_Get_ByIndex(SCREEN_2); wsaSize = GFX_Screen_GetSize_ByIndex(SCREEN_2) + GFX_Screen_GetSize_ByIndex(SCREEN_3); wsaReservedDisplayFrame = false; } else { wsa = GFX_Screen_Get_ByIndex(SCREEN_1); wsaSize = GFX_Screen_GetSize_ByIndex(SCREEN_1) + GFX_Screen_GetSize_ByIndex(SCREEN_2) + GFX_Screen_GetSize_ByIndex(SCREEN_3); } snprintf(filenameBuffer, sizeof(filenameBuffer), "%s.WSA", animation->string); wsa = WSA_LoadFile(filenameBuffer, wsa, wsaSize, wsaReservedDisplayFrame); } addFrameCount = 0; if ((animation->flags & 0x8) != 0) { timeout -= 45; addFrameCount++; } else if ((animation->flags & 0x10) != 0) { timeout -= 15; addFrameCount++; } if ((animation->flags & 0x4) != 0) { GameLoop_PlaySubtitle(animationMode); WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_0); GameLoop_PalettePart_Update(true); memcpy(&g_palette1[215 * 3], s_palettePartCurrent, 18); GUI_SetPaletteAnimated(g_palette1, 45); addFrameCount++; } else { if ((animation->flags & 0x480) != 0) { GameLoop_PlaySubtitle(animationMode); WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_1); addFrameCount++; if ((animation->flags & 0x480) == 0x80) { GUI_Screen_FadeIn2(8, 24, 304, 120, SCREEN_1, SCREEN_0, 1, false); } else if ((animation->flags & 0x480) == 0x400) { GUI_Screen_FadeIn(1, 24, 1, 24, 38, 120, SCREEN_1, SCREEN_0); } } } timeLeft = timeout - g_timerGUI; timeLeftForFrame = 0; frameCount = 1; switch (mode) { case 0: frameCount = animation->frameCount - addFrameCount; timeLeftForFrame = timeLeft / frameCount; break; case 1: frameCount = WSA_GetFrameCount(wsa); timeLeftForFrame = timeLeft / animation->frameCount; break; case 2: frameCount = WSA_GetFrameCount(wsa) - addFrameCount; timeLeftForFrame = timeLeft / frameCount; timeout -= timeLeftForFrame; break; case 3: frame = animation->frameCount; frameCount = 1; timeLeftForFrame = timeLeft / 20; break; default: PrepareEnd(); Error("Bad mode in animation #%i.\n", animationMode); exit(0); } while (timeout > g_timerGUI) { g_timerTimeout = timeLeftForFrame; GameLoop_PlaySubtitle(animationMode); WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_0); if (mode == 1 && frame == frameCount) { frame = 0; } else { if (mode == 3) frame--; } if (Input_Keyboard_NextKey() != 0 && g_canSkipIntro) { WSA_Unload(wsa); return; } do { GameLoop_PalettePart_Update(false); sleepIdle(); } while (g_timerTimeout != 0 && timeout > g_timerGUI); } if (mode == 2) { bool displayed; do { GameLoop_PlaySubtitle(animationMode); displayed = WSA_DisplayFrame(wsa, frame++, posX, posY, SCREEN_0); } while (displayed); } if ((animation->flags & 0x10) != 0) { memset(&g_palette_998A[3 * 1], 63, 255 * 3); memcpy(&g_palette_998A[215 * 3], s_palettePartCurrent, 18); GUI_SetPaletteAnimated(g_palette_998A, 15); memcpy(g_palette_998A, g_palette1, 256 * 3); } if ((animation->flags & 0x8) != 0) { GameLoop_PalettePart_Update(true); memcpy(&g_palette_998A[215 * 3], s_palettePartCurrent, 18); GUI_SetPaletteAnimated(g_palette_998A, 45); } WSA_Unload(wsa); animationMode++; animation++; while (timeout2 > g_timerGUI) sleepIdle(); } }
/********************************************************************************* * Description : 显示系统开机动画 * * Arguments : wait_key_up, 是否要等待按键 * * Returns : TRUE, 正常 FALSE, enter testmode * * Notes : * *********************************************************************************/ BOOL APP_DisplaySysLogo(BOOL wait_key_up) { INT32 i, j; BOOL keydown = FALSE; UINT32 key; UINT32 prekey = 0; hal_HstSendEvent(SYS_EVENT, 0x19884501); hal_HstSendEvent(SYS_EVENT, g_displayconfig.log_image_time); hal_HstSendEvent(SYS_EVENT, g_displayconfig.log_image_count); if(g_displayconfig.log_image_count == 0 && g_displayconfig.log_image_time == 0) { for(i = 0; i < 1; i++) for(j = 0; j < 1;) { key = MESSAGE_Wait(); //app_trace(APP_MAIN_TRC, "Display Log receive event 0x%x,prekey=0x%x, keydown=%d", key, prekey, keydown); switch(key) { case AP_MSG_RTC: case AP_MSG_CHARGING: j++; break; default: if((key & 0xffff) == AP_KEY_DOWN) { if(prekey != 0 || key != (AP_KEY_DOWN | AP_KEY_POWER)) { keydown = TRUE; } prekey = key; } if(keydown && (key & 0xffff) == AP_KEY_UP) { return TRUE; } key = MESSAGE_HandleHotkey(key);//handle unusual usb/t-card/line-in pluging event if(key != 0) { event_detected_displaying_log = key; hal_HstSendEvent(SYS_EVENT, 0x13063002); hal_HstSendEvent(SYS_EVENT, key); } break; } } } for(i = 0; i < g_displayconfig.log_image_count; i++) { #if APP_SUPPORT_RGBLCD==1 if(AP_Support_LCD()) { GUI_ClearScreen(NULL);//清全屏幕 GUI_ResShowImage(GUI_IMG_LOGO, i, 0, 40); //g_displayconfig.log_x, g_displayconfig.log_y);/*BootLogo*/ GUI_UpdateScreen(NULL); } #elif APP_SUPPORT_LCD==1 if(AP_Support_LCD()) { GUI_ClearScreen(NULL);//清全屏幕 GUI_ResShowImage(GUI_IMG_LOGO, i, 0, 8); //g_displayconfig.log_x, g_displayconfig.log_y);/*BootLogo*/ GUI_UpdateScreen(NULL); } #elif APP_SUPPORT_LED8S==1 GUI_ClearScreen(NULL); GUI_ResShowPic(0xffff, 0, 0); GUI_DisplayText(0, 0, "8888"); GUI_UpdateScreen(NULL); #endif hal_HstSendEvent(SYS_EVENT, 0x19884500); hal_HstSendEvent(SYS_EVENT, g_displayconfig.log_image_time); for(j = 0; j < g_displayconfig.log_image_time; ) { key = MESSAGE_Wait(); //app_trace(APP_MAIN_TRC, "Display Log receive event 0x%x,prekey=0x%x, keydown=%d", key, prekey, keydown); switch(key) { case AP_MSG_RTC: case AP_MSG_CHARGING: j++; break; default: if((key & 0xffff) == AP_KEY_DOWN) { if(prekey != 0 || key != (AP_KEY_DOWN | AP_KEY_POWER)) { keydown = TRUE; } prekey = key; } if(keydown && (key & 0xffff) == AP_KEY_UP) { return TRUE; } break; } } } return TRUE; }
TASK_ENTRY BAL_MainTaskEntry(void *pData) { INT8 IsUDisk = 0; BOOL need_draw = TRUE; INT32 active = 0; //当前活动的项目 INT32 result = APP_DEFAULT_RESULT; INT32 ret = RESULT_NULL; INT32 bt_active_ret = RESULT_NULL; TM_SYSTEMTIME systime; extern BOOL g_usb_connected; // dump version and date //hal_HstSendEvent(SYS_EVENT,0x11223344); //hal_HstSendEvent(SYS_EVENT,GetPlatformVersion()); //hal_HstSendEvent(SYS_EVENT,GetPlatformRevision()); //hal_HstSendEvent(SYS_EVENT,GetPlatformBuildDate()); //hal_HstSendEvent(SYS_EVENT,AP_GetVersion()); //hal_HstSendEvent(SYS_EVENT,AP_GetBuildDate()); APP_ReadComPara(); //读取系统的全局变量。可以放在os初始化的过程中做 #if XDL_APP_SUPPORT_LOWBAT_DETECT==1//warkey 2.1 StartBatTimer(); #endif gui_load_resource(g_comval->langid); LED_SetPattern(GUI_LED_POWERON, 1); #if APP_SUPPORT_LCD==1 if(AP_Support_LCD()) { lcdd_Open(); GUI_Initialise(g_displayconfig.lcd_width, g_displayconfig.lcd_heigth); GUI_SetTextColor(g_displayconfig.font_color); GUI_SetBackColor(g_displayconfig.back_color); } #endif if(g_test_mode) { NVRAMWriteData(); APP_Test_Mode(); } APP_DisplaySysLogo(FALSE); AP_GetBuildDate();//force link date time functions. // check systemtime TM_GetSystemTime(&systime); if(systime.uHour >= 24 || systime.uDay == 0 || systime.uYear > 2050) // invalid date time { systime.uYear = 2012; systime.uMonth = 8; systime.uDay = 15; systime.uHour = 12; systime.uMinute = 30; TM_SetSystemTime(&systime); } #if APP_SUPPORT_LCD==1 TIMER_SetAlarm(1); #endif hal_HstSendEvent(SYS_EVENT, 0x09250001); APP_InitialFunPtr(); //初始化各个模块的回调函数,最后通过宏定义来实现开关 APP_Read_Sys_Config(); LED_SetPattern(GUI_LED_NONE, 1); hal_HstSendEvent(BOOT_EVENT, 0x09558000); #if APP_SUPPORT_LCD==0 //added for T_card update without LCD. Search TF card, if there is a file with the name "tflash_update.bin", then do the update. #ifdef MCD_TFCARD_SUPPORT { INT32 file = -1, card_ok = -1; UINT32 cur_data = AP_GetBuildDate(); UINT32 cur_time = AP_GetBuildTime(); boolean needupdate = FALSE; hal_HstSendEvent(BOOT_EVENT, 0x98880001); hal_HstSendEvent(BOOT_EVENT, cur_data); hal_HstSendEvent(BOOT_EVENT, cur_time); hal_HstSendEvent(BOOT_EVENT, 0x98880001); card_ok = FS_MountDevice(FS_DEV_TYPE_TFLASH); hal_HstSendEvent(BOOT_EVENT, card_ok); if(card_ok == ERR_SUCCESS) { FS_FILE_ATTR file_attr; TM_FILETIME sFileTime; TM_SYSTEMTIME sSysTm; UINT32 bin_createDate = 0; UINT32 bin_createTime = 0; UINT32 offset = 0; file = FS_Open(UPDATE_TFLASH_BIN_NAME, FS_O_RDWR, 0); hal_HstSendEvent(BOOT_EVENT, 0x09550000); hal_HstSendEvent(BOOT_EVENT, file); hal_HstSendEvent(BOOT_EVENT, 0x09550000); #if 1 FS_Seek(file, 0xc, FS_SEEK_SET); FS_Read(file, &offset, 4); FS_Seek(file, ((offset & 0x00ffffff)) - 0x10, FS_SEEK_SET); FS_Read(file, &bin_createDate, 4); FS_Read(file, &bin_createTime, 4); hal_HstSendEvent(BOOT_EVENT, 0x98880002); hal_HstSendEvent(BOOT_EVENT, bin_createDate); hal_HstSendEvent(BOOT_EVENT, bin_createTime); hal_HstSendEvent(BOOT_EVENT, 0x98880002); #else if(FS_GetFileAttrByHandle(file, &file_attr) == 0) { sFileTime.DateTime = file_attr.i_mtime; TM_FileTimeToSystemTime(sFileTime, &sSysTm); bin_createDate = ((sSysTm.uYear) * 10000 + ((sSysTm.uMonth) * 100) + sSysTm.uDay); bin_createTime = sSysTm.uHour * 10000 + sSysTm.uMinute * 100 + sSysTm.uSecond; hal_HstSendEvent(BOOT_EVENT, 0x98880002); hal_HstSendEvent(BOOT_EVENT, bin_createDate); hal_HstSendEvent(BOOT_EVENT, bin_createTime); hal_HstSendEvent(BOOT_EVENT, 0x98880002); } #endif //if((cur_data<bin_createDate) || //(cur_data==bin_createDate && cur_time<bin_createTime)) if((cur_data != bin_createDate) || (cur_time != bin_createTime)) //只要不是同一软件就允许升级 { needupdate = TRUE; } hal_HstSendEvent(BOOT_EVENT, needupdate); hal_HstSendEvent(BOOT_EVENT, 0x98880008); if(file >= 0 && needupdate) { Upgrade_Flash(file); RestartSystem(); } else { FS_Close(file); } } } #endif #endif g_last_reslt = result; if(GetUsbCableStatus()) { hal_HstSendEvent(APP_EVENT, 0x13113001); result = RESULT_UDISK; } if(gpio_detect_linein() == GPIO_DETECTED) { hal_HstSendEvent(APP_EVENT, 0x13113002); result = RESULT_LINE_IN; } // IsUDisk = g_comval->Onlinedev; #ifdef SUPPORT_POWERON_ENTER_CHARGE_AP//warkey 2.1 app_trace(APP_MAIN_TRC, "GetBattery:%d", GetBattery()); if(-1 == GetBattery() && g_usb_connected == 0) { // hal_HstSendEvent(SYS_EVENT, 0x13062707); hal_HstSendEvent(APP_EVENT, 0x13113003); result = Charging_Entry(); } #endif while(1) { if(result==RESULT_STANDBY) { LED_SetPattern(GUI_LED_NONE, 0xde); } else { LED_SetPattern(GUI_LED_NONE, 1); } hal_HstSendEvent(SYS_EVENT, 0x09250002); hal_HstSendEvent(SYS_EVENT, result); if(result == RESULT_NULL || result == RESULT_MAIN) { #if APP_SUPPORT_MENU==1 if(AP_Support_MENU()) { ui_auto_select = FALSE; result = GUI_Display_Menu(GUI_MENU_MAIN, main_menu_callback); g_last_reslt = RESULT_NULL; if(result == RESULT_TIMEOUT || result == RESULT_IGNORE || result == RESULT_NULL) { result = RESULT_IDLE; // RESULT_CALENDAR; } } else #endif { if(RESULT_STANDBY != result) { result = g_last_reslt; } switch(result) { case RESULT_STANDBY: break; case RESULT_BT: #if APP_SUPPORT_MUSIC==1 result = RESULT_MUSIC; break; case RESULT_MUSIC: #endif #if APP_SUPPORT_FM || APP_SUPPORT_LINEIN //没有Line in时才进入FM 2012-9-27 if(gpio_detect_linein() == GPIO_DETECTED) { #if APP_SUPPORT_LINEIN ==1 result = RESULT_LINE_IN; break; #else result = RESULT_RADIO; break; #endif } else { #if APP_SUPPORT_FM==1 result = RESULT_RADIO; break; #endif } case RESULT_LINE_IN: case RESULT_RADIO: #endif #if APP_SUPPORT_RECORD if(AP_Support_RECORD()) { result = RESULT_RECORD_NOSTART; break; } case RESULT_RECORD_NOSTART: #endif #if APP_SUPPORT_BLUETOOTH result = RESULT_BT; break; #endif default: result = APP_DEFAULT_RESULT; break; } } } else if(result == RESULT_POWERON) { if(AP_Support_LCD()) { GUI_ClearScreen(NULL); GUI_UpdateScreen(NULL); } LED_SetPattern(GUI_LED_POWERON, 1); APP_DisplaySysLogo(TRUE); LED_SetPattern(GUI_LED_NONE, 1); if (g_comval->LightTime == 0) //每次开机判断一次!解决Bug Report:27 { CloseBacklight(); } else { OpenBacklight(); } //APP_DUMP("g_last_reslt:", g_last_reslt); result = g_last_reslt; if(GetUsbCableStatus()) { hal_HstSendEvent(APP_EVENT, 0x07021549); result = RESULT_UDISK; } if(gpio_detect_linein() == GPIO_DETECTED) { hal_HstSendEvent(APP_EVENT, 0x07021550); result = RESULT_LINE_IN; } need_draw = TRUE; } else //boot with param or result != 0 { switch( result) { #if APP_SUPPORT_MUSIC==1 case RESULT_MUSIC: hal_HstSendEvent(SYS_EVENT, 0x20120000); ret = APP_ModCall(FUN_MUSIC, 0); g_last_reslt = result; result = ret; #if APP_SUPPORT_FADE_INOUT==1 if(g_fade_volume_backup != -1) { // hal_HstSendEvent(SYS_EVENT, 0x13101701); // hal_HstSendEvent(SYS_EVENT, g_fade_volume_backup); SetPAVolume(g_fade_volume_backup); g_fade_volume_backup = -1; } #endif if(g_usb_audio_tcard&&GetUsbCableStatus())//plug in tcard when usb audio is running { result = RESULT_UDISK; } hal_HstSendEvent(SYS_EVENT, 0x20124444); hal_HstSendEvent(SYS_EVENT, g_last_reslt); hal_HstSendEvent(SYS_EVENT, result); break; #endif case RESULT_RADIO: hal_HstSendEvent(SYS_EVENT, 0x20120033); ret = APP_ModCall(FUN_FM, 0); hal_HstSendEvent(SYS_EVENT, 0x20120044); g_last_reslt = result; result = ret; hal_HstSendEvent(SYS_EVENT, 0x20123001); break; case RESULT_RECORD_START: //进入录音 case RESULT_RECORD_NOSTART: case RESULT_FMREC_START: case RESULT_FMREC_NOSTART: ret = APP_ModCall(FUN_RECORD, result); //传入result,以判断是否直接开始FM录音? g_last_reslt = result; result = ret; break; case RESULT_RECORD_SWITCH: if(g_last_reslt == RESULT_RECORD_START || g_last_reslt == RESULT_RECORD_NOSTART) { result = RESULT_FMREC_NOSTART; } else if(g_last_reslt == RESULT_FMREC_START || g_last_reslt == RESULT_FMREC_NOSTART) { result = RESULT_RECORD_NOSTART; } ret = APP_ModCall(FUN_RECORD, result); //传入result,以判断是否直接开始FM录音? g_last_reslt = result; result = ret; break; case RESULT_CHARGING: result = APP_ModCall(FUN_CHARGING, 0); break; case RESULT_IDLE: //APP_DUMP("g_last_reslt:", g_last_reslt); result = APP_ModCall(FUN_IDLE, 0); break; case RESULT_LINE_IN: hal_HstSendEvent(SYS_EVENT, 0x20128888); if(event_detected_displaying_log == RESULT_LINE_IN) { event_detected_displaying_log = 0; } result = APP_ModCall(FUN_LINEIN, 0); hal_HstSendEvent(SYS_EVENT, 0x20129999); hal_HstSendEvent(SYS_EVENT, g_last_reslt); hal_HstSendEvent(SYS_EVENT, result); // if(result == RESULT_NULL || result == RESULT_MAIN) if(g_linein_out_event == 1)//line-in was removed { result = g_last_reslt; if(result == RESULT_LINE_IN) { result = APP_DEFAULT_RESULT; } g_linein_out_event = 0; if(g_usb_audio_linein&&GetUsbCableStatus())//plug in line-in when usb audio is running, so return usb audio again { result = RESULT_UDISK; hal_HstSendEvent(SYS_EVENT, 0x13071801); } } else { g_last_reslt = RESULT_LINE_IN; } break; case RESULT_STANDBY: { extern UINT8 g_light_time; #ifdef SUPPORT_POWERON_ENTER_CHARGE_AP//warkey 2.1 if(-1 == GetBattery()) { result = Charging_Entry(); } else #endif { g_light_time = 0; result = APP_StandBy(); if(g_comval->LightTime != 0) { g_light_time = g_comval->LightTime * 2; OpenBacklight(); } } } break; #if APP_SUPPORT_CALIB_KEY==1 case RESULT_KEYCALIB: result = APP_CalibKey(); break; #endif case RESULT_SYSTEM: ret = APP_ModCall(FUN_SYSTEM_SETTING, 0); g_last_reslt = result; result = ret; break; case RESULT_ALARM: ret = APP_ModCall(FUN_TIMER, 1); g_last_reslt = result; result = ret; break; case RESULT_TIMER: ret = APP_ModCall(FUN_TIMER, 0); g_last_reslt = result; result = ret; break; case RESULT_UDISK: //IsUDisk=1; //if(IsUDisk) { if(g_usb_active_after_bt != 0) { g_usb_active_after_bt = 0; } if(event_detected_displaying_log == RESULT_UDISK) { event_detected_displaying_log = 0; } hal_HstSendEvent(SYS_EVENT, 0x09250003); result = APP_ModCall(FUN_USB, 0); hal_HstSendEvent(SYS_EVENT, 0x09250004); } if(result == RESULT_NULL) { result = g_last_reslt; if(result == RESULT_UDISK) { result = APP_DEFAULT_RESULT; } } if(result == RESULT_BT_ACTIVE) { bt_active_ret = RESULT_UDISK; } //fix udisk return, drop key up //result = RESULT_MUSIC; hal_HstSendEvent(SYS_EVENT, result); break; #if APP_SUPPORT_BLUETOOTH==1 case RESULT_BT: hal_HstSendEvent(SYS_EVENT, 0x20120001); ret = APP_ModCall(FUN_BT, -1); g_last_reslt = result; result = ret; if(musicplay_timer) { COS_KillTimer(musicplay_timer); musicplay_timer = 0; } hal_HstSendEvent(SYS_EVENT, 0x20127777); hal_HstSendEvent(SYS_EVENT, g_last_reslt); hal_HstSendEvent(SYS_EVENT, result); break; case RESULT_BT_ACTIVE: hal_HstSendEvent(SYS_EVENT, 0x20120002); if(bt_active_ret != RESULT_NULL) { result = APP_ModCall(FUN_BT, bt_active_ret); } else { result = APP_ModCall(FUN_BT, g_last_reslt); } //add by wuxiang call_status = 0; g_bt_call_time = 0; bt_active_ret = RESULT_NULL; if(musicplay_timer) { COS_KillTimer(musicplay_timer); musicplay_timer = 0; } //add end hal_HstSendEvent(SYS_EVENT, 0x20126666); if(g_last_reslt == RESULT_ALARM) { result = RESULT_IDLE; } break; #endif case RESULT_CALENDAR: ret = APP_ModCall(FUN_CALENDAR, 0); g_last_reslt = result; result = ret; break; default: //APP_DUMP("never run here: ", result); hal_HstSendEvent(SYS_EVENT, 0x20125555); hal_HstSendEvent(SYS_EVENT, result); result = RESULT_MAIN; break; }//switch(reault) //APP_ReadComPara(); //IsUDisk = 1; //更新Onlinedev need_draw = TRUE; } }//while never exit }
/** * Logos at begin of intro. */ static void Gameloop_Logos(void) { Screen oldScreenID; void *wsa; uint16 frame; oldScreenID = GFX_Screen_SetActive(SCREEN_0); GFX_SetPalette(g_palette2); GFX_ClearScreen(); File_ReadBlockFile("WESTWOOD.PAL", g_palette_998A, 256 * 3); frame = 0; wsa = WSA_LoadFile("WESTWOOD.WSA", GFX_Screen_Get_ByIndex(SCREEN_1), GFX_Screen_GetSize_ByIndex(SCREEN_1) + GFX_Screen_GetSize_ByIndex(SCREEN_2) + GFX_Screen_GetSize_ByIndex(SCREEN_3), true); WSA_DisplayFrame(wsa, frame++, 0, 0, SCREEN_0); GUI_SetPaletteAnimated(g_palette_998A, 60); Music_Play(0x24); g_timerTimeout = 360; while (WSA_DisplayFrame(wsa, frame++, 0, 0, SCREEN_0)) Timer_Sleep(6); WSA_Unload(wsa); if (Input_Keyboard_NextKey() != 0 && g_canSkipIntro) goto logos_exit; Voice_LoadVoices(0xFFFF); for (; g_timerTimeout != 0; sleepIdle()) { if (Input_Keyboard_NextKey() != 0 && g_canSkipIntro) goto logos_exit; } GUI_SetPaletteAnimated(g_palette2, 60); while (Driver_Music_IsPlaying()) sleepIdle(); GUI_SetPaletteAnimated(g_palette2, 60); GFX_ClearScreen(); Sprites_LoadImage(String_GenerateFilename("AND"), SCREEN_1, g_palette_998A); GUI_Screen_Copy(0, 0, 0, 0, SCREEN_WIDTH / 8, SCREEN_HEIGHT, SCREEN_1, SCREEN_0); GUI_SetPaletteAnimated(g_palette_998A, 30); for (g_timerTimeout = 60; g_timerTimeout != 0; sleepIdle()) { if (Input_Keyboard_NextKey() != 0 && g_canSkipIntro) goto logos_exit; } GUI_SetPaletteAnimated(g_palette2, 30); GUI_ClearScreen(SCREEN_0); Sprites_LoadImage("VIRGIN.CPS", SCREEN_1, g_palette_998A); GUI_Screen_Copy(0, 0, 0, 0, SCREEN_WIDTH / 8, SCREEN_HEIGHT, SCREEN_1, SCREEN_0); GUI_SetPaletteAnimated(g_palette_998A, 30); for (g_timerTimeout = 180; g_timerTimeout != 0; sleepIdle()) { if (Input_Keyboard_NextKey() != 0 && g_canSkipIntro) goto logos_exit; } logos_exit: GUI_SetPaletteAnimated(g_palette2, 30); GUI_ClearScreen(SCREEN_0); GFX_Screen_SetActive(oldScreenID); }
/********************************************************************************* * Description : IDLE 函数,在该模式下面会省电,但是希望能显示电子时钟的功能 * * Arguments : * * Returns : * * Notes : * *********************************************************************************/ INT32 Charging_Entry(void) { BOOL need_draw = TRUE; UINT32 key; BOOL is_full = FALSE; while(1) { if(GetUsbCableStatus()) { return ;// usb irq came } if(need_draw) { #if APP_SUPPORT_RGBLCD==1 if(AP_Support_LCD()) { GUI_ClearScreen(NULL);//清全屏幕 if(!is_full) { GUI_DisplayMessage(0, GUI_STR_CHARGING, 0, GUI_MSG_FLAG_DISPLAY); } else { GUI_DisplayMessage(0, GUI_STR_FULL_CHARGING, 0, GUI_MSG_FLAG_DISPLAY); } GUI_DisplayBattaryLever(); GUI_UpdateScreen(NULL); } #elif APP_SUPPORT_LCD==1 if(AP_Support_LCD()) { GUI_ClearScreen(NULL);//清全屏幕 if(!is_full) { GUI_DisplayMessage(0, GUI_STR_CHARGING, 0, GUI_MSG_FLAG_DISPLAY); } else { GUI_DisplayMessage(0, GUI_STR_FULL_CHARGING, 0, GUI_MSG_FLAG_DISPLAY); } GUI_DisplayBattaryLever(); GUI_UpdateScreen(NULL); } #elif APP_SUPPORT_LED8S==1 { } #endif need_draw = FALSE; } key = MESSAGE_Wait(); switch( key ) { case AP_MSG_WAIT_TIMEOUT: break; case AP_KEY_NULL: break; case AP_MSG_RTC: need_draw = TRUE; if(is_full && GetBattery() != 100) { DM_DeviceSwithOff(); } if(-1 != GetBattery()) { is_full = TRUE; } break; case AP_KEY_POWER | AP_KEY_PRESS: return RESULT_POWERON; } } }
INT32 GUI_ClockSetting(date_t *date, ap_time_t *time, UINT16 img_id, UINT16 str_id) { UINT8 bSettime = 0; INT8 buf[11]; //date & time UINT32 key; INT8 set_what = 0; //0, 非设定状态, 1,year, 2,month... BOOL show_what = TRUE; //TRUE, 显示, FALSE, 不显示 INT8 days; //本月的天数 INT8 item_start, item_end; BOOL need_draw = TRUE; BOOL need_draw_backgroud = TRUE; BOOL set_ok = FALSE; //设置完成 BOOL adjusting = FALSE; //正在设置,不要闪烁 region_t clock_region = {32, 40, 64, 16}; region_t setting_region = {0, 0, 0, 0}; const char *format = date_formats[g_comval->DateFormat]; g_pCalendarInfo = (clndr_table_struct*)GetCalendarData(); if(date == NULL && time == NULL) { return 0; } if(date) { item_start = CLOCK_SET_YEAR; } else { item_start = CLOCK_SET_HOUR; } if(time) { time->second = 0; item_end = CLOCK_SET_MINUTE; } else { item_end = CLOCK_SET_DAY; } if(date) { if(date->year > g_pCalendarInfo->last_year) { date->year = g_pCalendarInfo->last_year; } else if(date->year < g_pCalendarInfo->first_year) { date->year = g_pCalendarInfo->first_year; } } while(1) { //显示背景 if(need_draw_backgroud) { GUI_ClearScreen(NULL); ui_auto_update = FALSE; if(img_id) { GUI_ResShowPic(img_id, 0, 0); //show icon } GUI_DisplayTextCenter(0, GUI_GetString(str_id)); GUI_DisplayBattaryLever(); ui_auto_update = TRUE; need_draw_backgroud = FALSE; } //显示时钟 if(need_draw) { setting_region.width = 16; setting_region.height = 16; if(date) { GUI_DisplayDateText(24, 24, TRUE, ((date->year) << 9) + (date->month << 5) + date->day); if(set_what < CLOCK_SET_HOUR) { setting_region.x = 24 + (set_what - 1) * 24; setting_region.y = 24; if(format[(set_what - 1) * 3] == 'Y') { setting_region.width = 32; } else { if((set_what == 2 && format[0] == 'Y') || (set_what == 3 && (format[0] == 'Y' || format[3] == 'Y'))) { setting_region.x += 16; } } } } if(time) { UINT32 time_value = ((time->hour * 60 + time->minute) * 60 + time->second) * 1000; if(set_what >= CLOCK_SET_HOUR) { setting_region.x = 44 + (set_what - CLOCK_SET_HOUR) * 24; } if(date) { GUI_DisplayTimeText(44, 40, GUI_TIME_DISPLAY_HOUR_MINUTE, time_value); if(set_what >= CLOCK_SET_HOUR) { setting_region.y = 40; } } else { GUI_DisplayTimeText(44, 24, GUI_TIME_DISPLAY_HOUR_MINUTE, time_value); if(set_what >= CLOCK_SET_HOUR) { setting_region.y = 24; } } } if(set_what != 0) { if(show_what == 0) { GUI_ClearScreen(&setting_region); } //GUI_InvertRegion(&setting_region); } //to reduce scr flash GUI_UpdateScreen(NULL); need_draw = FALSE; } key = MESSAGE_Wait(); switch( key ) { case AP_MSG_RTC: if(adjusting) { show_what = TRUE; } else { show_what = !show_what; } need_draw = TRUE; break; case AP_KEY_NEXT | AP_KEY_PRESS: if(set_what >= item_end || set_what < item_start) { set_what = item_start; } else { set_what++; } break; case AP_KEY_PREV | AP_KEY_PRESS: if(set_what <= item_start) { set_what = item_end; } else { set_what--; } break; case AP_KEY_VOLADD | AP_KEY_HOLD: adjusting = TRUE; case AP_KEY_VOLADD | AP_KEY_PRESS: //in setting clock bSettime = SET_DateAndTime(set_what, &days, date, time, 1); need_draw = TRUE; break; case AP_KEY_VOLSUB | AP_KEY_HOLD: adjusting = TRUE; case AP_KEY_VOLSUB | AP_KEY_PRESS: //in setting clock bSettime = SET_DateAndTime(set_what, &days, date, time, 0); need_draw = TRUE; break; case AP_KEY_VOLADD| AP_KEY_UP: case AP_KEY_VOLSUB| AP_KEY_UP: adjusting = FALSE; break; case AP_KEY_MODE | AP_KEY_PRESS: case AP_MSG_WAIT_TIMEOUT: //子菜单界面在8秒后返回系统功能菜单 bSettime = 0; case AP_KEY_PLAY | AP_KEY_PRESS: key = 0; set_ok = TRUE; break; default: key = MESSAGE_HandleHotkey(key); if(key == RESULT_REDRAW) { need_draw_backgroud = TRUE; need_draw = TRUE; } else if(key != 0) { set_ok = TRUE; } } //switch(key) if(set_ok) { break; } }//while(1) if(bSettime == 0) { return key; } else if ( key != 0 ) //不是按mode退出的都不保存设置,如USB线插上等 { return key; } if(date) { //re-check the date/time format days = month_days[date->month - 1]; if((date->year % 4 == 0) && (date->month == 2)) { days++; //润年 } if(date->day > days) { date->day = days; } } if(time) { time->second = 0; } }
void APP_Test_Mode(void) { UINT32 key; g_test_mode = TRUE; // test leds MESSAGE_Sleep(1); LED_SetPattern(GUI_LED_TEST_PATTERN1, 1); MESSAGE_Sleep(1); LED_SetPattern(GUI_LED_TEST_PATTERN2, 1); SetPAVolume(0); hal_HstSendEvent(BOOT_EVENT, 0x7e570100); // 10% // test lcd #if APP_SUPPORT_RGBLCD==1 if(AP_Support_LCD()) { GUI_ClearScreen(NULL); GUI_InvertRegion(NULL); GUI_UpdateScreen(NULL); MESSAGE_Sleep(1); GUI_InvertRegion(NULL); GUI_UpdateScreen(NULL); MESSAGE_Sleep(1); } #elif APP_SUPPORT_LCD==1 if(AP_Support_LCD()) { GUI_ClearScreen(NULL); GUI_InvertRegion(NULL); GUI_UpdateScreen(NULL); MESSAGE_Sleep(1); GUI_InvertRegion(NULL); GUI_UpdateScreen(NULL); MESSAGE_Sleep(1); } #elif APP_SUPPORT_LED8S==1 GUI_ClearScreen(NULL); GUI_ResShowPic(0xffff, 0, 0); GUI_UpdateScreen(NULL); COS_Sleep(200); GUI_DisplayText(0, 0, "8"); GUI_UpdateScreen(NULL); COS_Sleep(200); GUI_DisplayText(1, 0, "8"); GUI_UpdateScreen(NULL); COS_Sleep(200); GUI_DisplayText(2, 0, "8"); GUI_UpdateScreen(NULL); COS_Sleep(200); GUI_DisplayText(3, 0, "8"); GUI_UpdateScreen(NULL); COS_Sleep(200); #endif hal_HstSendEvent(BOOT_EVENT, 0x7e570300); // 30% // test fm #if APP_SUPPORT_FM hal_HstSendEvent(SYS_EVENT, 0x11220010); { extern FM_play_status_t *FMStatus; FMStatus = (FM_play_status_t*)NVRAMGetData(VM_AP_RADIO, sizeof(FM_play_status_t)); FM_SendCommand(MC_OPEN, 0); FMStatus->freq = AP_TEST_FM_FREQ1; FM_SendCommand(MC_PLAY, 0); if(!fmd_ValidStop(FMStatus->freq)) { FMStatus->freq = AP_TEST_FM_FREQ2; if(!fmd_ValidStop(FMStatus->freq)) { FMStatus->freq = AP_TEST_FM_FREQ3; if(!fmd_ValidStop(FMStatus->freq)) { goto test_fail; } } } SetPAVolume(0); FM_SendCommand(MC_CLOSE, 0); } #endif hal_HstSendEvent(BOOT_EVENT, 0x7e570500); // 50% // test bluetooth #if APP_SUPPORT_BLUETOOTH==1 hal_HstSendEvent(SYS_EVENT, 0x11220020); { extern bt_vars_t *g_pBT_vars; extern INT8 g_bt_cur_device; g_bt_cur_device = -1; g_pBT_vars = (bt_vars_t*)NVRAMGetData(VM_AP_BLUETOOTH, sizeof(bt_vars_t)); if(BT_Active_Bluetooth() != 0) { goto test_fail; // test_fail } } #endif hal_HstSendEvent(BOOT_EVENT, 0x7e570800); // 80% // test audio #if APP_SUPPORT_MUSIC==1 { hal_HstSendEvent(SYS_EVENT, 0x11220030); if(!MountDisk(FS_DEV_TYPE_TFLASH)) { goto test_fail; // test_fail } hal_HstSendEvent(SYS_EVENT, 0x11220040); if(!fselInit(FSEL_TYPE_MUSIC, FSEL_ALL_SEQUENCE, FSEL_TYPE_COMMONDIR, FS_DEV_TYPE_TFLASH)) { goto test_fail; // test_fail } if(!fselGetNextFile(&g_testfile_entry)) { goto test_fail; // test_fail } hal_HstSendEvent(SYS_EVENT, 0x11220042); hal_HstSendEvent(SYS_EVENT, g_testfile_entry); g_current_fd = FS_OpenDirect(g_testfile_entry, FS_O_RDONLY, 0); hal_HstSendEvent(SYS_EVENT, g_current_fd); if(g_current_fd < 0) { goto test_fail; // test_fail } hal_HstSendEvent(SYS_EVENT, 0x11220050); if(MCI_ERR_NO != MCI_AudioPlay(0, g_current_fd, MCI_TYPE_DAF, play_finished, 0)) { goto test_fail; } SetPAVolume(0); play_end = FALSE; GUI_DisplayMessage(0, 0, "Test Sucess!", GUI_MSG_FLAG_DISPLAY); hal_HstSendEvent(SYS_EVENT, 0x11220060); hal_HstSendEvent(BOOT_EVENT, 0x7e570a00); // 100% hal_HstSendEvent(BOOT_EVENT, 0x7e5752cc); // test success LED_SetPattern(GUI_LED_TEST_SUCESS, LED_LOOP_INFINITE); while(1) { key = MESSAGE_Wait(); if(play_end) { play_end = FALSE; MCI_AudioStop(); MCI_AudioPlay(0, g_current_fd, MCI_TYPE_DAF, play_finished, 0); } #if 1//warkey //按任意键打开音量播放音乐,MODE键退出并重启 if(key == (AP_KEY_MODE | AP_KEY_DOWN)) { MCI_AudioStop(); FS_Close(g_current_fd); RestartSystem(); } else if(((key >> 16) > 0) && ((key >> 16) < MAX_KEYS)) { if((key & 0xffff) == AP_KEY_DOWN) { SetPAVolume(7); } else if((key & 0xffff) == AP_KEY_UP) { SetPAVolume(0); g_test_mode = FALSE; } } #else//原始 if(key == (AP_KEY_PLAY | AP_KEY_DOWN)) { SetPAVolume(7); } else if(key == (AP_KEY_PLAY | AP_KEY_UP)) { SetPAVolume(0); hal_HstSendEvent(BOOT_EVENT, 0x7e5752cc); // test success g_test_mode = FALSE; } else if(key == (AP_KEY_MODE | AP_KEY_DOWN)) { MCI_AudioStop(); FS_Close(g_current_fd); RestartSystem(); } #endif }; } #else hal_HstSendEvent(BOOT_EVENT, 0x7e570a00); // 100% LED_SetPattern(GUI_LED_TEST_SUCESS, LED_LOOP_INFINITE); hal_HstSendEvent(BOOT_EVENT, 0x7e5752cc); // test success g_test_mode = FALSE; while(1) { key = MESSAGE_Wait(); if(key == (AP_KEY_MODE | AP_KEY_DOWN)) { RestartSystem(); } if(key == (AP_KEY_POWER | AP_KEY_DOWN)) { DM_DeviceSwithOff(); } }; #endif test_fail: GUI_DisplayMessage(0, 0, "Test Fail!", GUI_MSG_FLAG_DISPLAY); LED_SetPattern(GUI_LED_TEST_FAIL, LED_LOOP_INFINITE); hal_HstSendEvent(BOOT_EVENT, 0x7e57fa11); // test fail g_test_mode = FALSE; while(1) { key = MESSAGE_Wait(); if(key == (AP_KEY_MODE | AP_KEY_DOWN)) { RestartSystem(); } if(key == (AP_KEY_POWER | AP_KEY_DOWN)) { DM_DeviceSwithOff(); } } }