static void task_a_8143B68(u8 taskIdA) { u16 data1; if (gTasks[taskIdA].data[TDA_4]) { s16 taskIdC; taskIdC = gTasks[taskIdA].data[TDA_TASK_C_ID]; gTasks[taskIdC].data[TDC_0] = 30; gTasks[taskIdA].data[TDA_12] = 0x100; gTasks[taskIdA].func = task_a_8143EBC; return; } gUnknown_02039320 = 0; data1 = gTasks[taskIdA].data[TDA_11]; if (gTasks[taskIdA].data[TDA_11] == 1) { gTasks[taskIdA].data[TDA_13] = data1; gTasks[taskIdA].data[TDA_11] = 0; BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskIdA].func = task_a_8143BFC; } else if (gTasks[taskIdA].data[TDA_11] == 2) { gTasks[taskIdA].data[TDA_13] = data1; gTasks[taskIdA].data[TDA_11] = 0; BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskIdA].func = task_a_8143CC0; } }
static void task_a_8144080(u8 taskIdA) { if (!gPaletteFade.active) { if (gTasks[taskIdA].data[TDA_0] == 0) { FadeOutBGM(4); BeginNormalPaletteFade(0xFFFFFFFF, 8, 0, 16, FADE_COLOR_WHITE); gTasks[taskIdA].func = task_a_8144114; return; } if (gMain.newKeys) { FadeOutBGM(4); BeginNormalPaletteFade(0xFFFFFFFF, 8, 0, 16, FADE_COLOR_WHITE); gTasks[taskIdA].func = task_a_8144114; return; } if (gTasks[taskIdA].data[TDA_0] == 7144) { FadeOutBGM(8); } if (gTasks[taskIdA].data[TDA_0] == 6840) m4aSongNumStart(BGM_END); gTasks[taskIdA].data[TDA_0] -= 1; } }
void HandleBattleTowerPartyMenu(u8 taskId) { if (!gPaletteFade.active) { switch (HandleBattleTowerPartyMenuInput(taskId)) { case A_BUTTON: PlaySE(SE_SELECT); gLastFieldPokeMenuOpened = sub_806CA38(taskId); if (gLastFieldPokeMenuOpened != 6) { GetMonNickname(&gPlayerParty[gLastFieldPokeMenuOpened], gStringVar1); sub_81221F8(taskId); gTasks[taskId].func = sub_812238C; } else { gTasks[taskId].func = sub_81224A8; } sub_808B5B4(taskId); break; case B_BUTTON: PlaySE(SE_SELECT); ClearPartySelection(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskId].func = sub_8122450; break; } } }
static void ReshowPCMenuAfterHallOfFamePC(void) { ScriptContext2_Enable(); Overworld_PlaySpecialMapMusic(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(0, 0, 0)); ScrSpecial_CreatePCMenu(); ScriptMenu_DisplayPCStartupPrompt(); CreateTask(Task_WaitForPaletteFade, 10); }
static void task_a_8144024(u8 taskIdA) { if (!gPaletteFade.active) { sub_81452D0(0x3800, 0); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0, RGB(0, 0, 0)); gTasks[taskIdA].data[TDA_0] = 7200; gTasks[taskIdA].func = task_a_8144080; } }
static void task_a_8143FDC(u8 taskIdA) { if (gTasks[taskIdA].data[TDA_0]) { gTasks[taskIdA].data[TDA_0] -= 1; return; } BeginNormalPaletteFade(0xFFFFFFFF, 6, 0, 16, RGB(0, 0, 0)); gTasks[taskIdA].func = task_a_8144024; }
static void task_a_8143EBC(u8 taskIdA) { if (gTasks[taskIdA].data[TDA_12]) { gTasks[taskIdA].data[TDA_12] -= 1; return; } BeginNormalPaletteFade(0xFFFFFFFF, 12, 0, 16, RGB(0, 0, 0)); gTasks[taskIdA].func = task_a_8143F04; }
void task_a_8143D04(u8 taskIdA) { switch (gMain.state) { default: case 0: { u16 i; ResetSpriteData(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 8; LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM); LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800)); LoadPalette(gBirchBagGrassPal[0] + 1, 1, 31 * 2); for (i = 0; i < 0x800; i++) HALL_OF_FAME_SHEET_0[i] = 0x11; for (i = 0; i < 0x800; i++) HALL_OF_FAME_SHEET_1[i] = 0x22; for (i = 0; i < 0x800; i++) HALL_OF_FAME_SHEET_2[i] = 0x33; EWRAM_1F800[0] = 0; EWRAM_1F800[1] = 0x53FF; // light yellow EWRAM_1F800[2] = 0x529F; // light red EWRAM_1F800[3] = 0x7E94; // light blue LoadSpriteSheet(gUnknown_0840CAA0); LoadSpritePalette(gUnknown_0840CAB0); gMain.state += 1; break; } case 1: gTasks[taskIdA].data[TDA_TASK_D_ID] = CreateTask(task_d_8144514, 0); gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_STATE] = 1; gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_TASK_A_ID] = taskIdA; gTasks[gTasks[taskIdA].data[TDA_TASK_D_ID]].data[TDD_2] = gTasks[taskIdA].data[TDA_7]; BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(0, 0, 0)); REG_BG3HOFS = 0; REG_BG3VOFS = 32; REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; gMain.state = 0; gUnknown_0203935C = 0; gTasks[taskIdA].func = task_a_8143B38; break; } }
static void task_a_80C9BFC(u8 taskIdA) { u16 backup; SetVBlankCallback(NULL); if (sub_8144ECC(gTasks[taskIdA].data[TDA_7], taskIdA)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(0, 0, 0)); backup = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; REG_IME = backup; REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; SetVBlankCallback(vblank_8143948); gTasks[taskIdA].func = task_a_8143B38; } }
static void task_a_8143F3C(u8 taskIdA) { u16 backup; sub_8144130(); ResetPaletteFade(); sub_8145128(0, 0x3800, 0); ResetSpriteData(); FreeAllSpritePalettes(); BeginNormalPaletteFade(0xFFFFFFFF, 8, 16, 0, RGB(0, 0, 0)); REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7) | BGCNT_16COLOR | BGCNT_TXT256x256; backup = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; REG_IME = backup; REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON; gTasks[taskIdA].data[TDA_0] = 0x100; gTasks[taskIdA].func = task_a_8143FDC; }
static void sub_81224A8(u8 taskId) { u8 val = sub_81220C8(); if (val != 0xFF) { PrintPartyMenuPromptText(val, 0); gTasks[taskId].func = sub_8122480; } else { if (gSelectedOrderFromParty[0] != 0) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskId].func = sub_8122450; } else { PlaySE(SE_HAZURE); PrintPartyMenuPromptText(14, 0); gTasks[taskId].func = sub_8122480; } } }
void HandleDefaultPartyMenu(u8 taskID) { if (!gPaletteFade.active) { switch (HandleDefaultPartyMenuInput(taskID)) { case A_BUTTON: PlaySE(SE_SELECT); gLastFieldPokeMenuOpened = sub_806CA38(taskID); GetMonNickname(&gPlayerParty[gLastFieldPokeMenuOpened], gStringVar1); sub_8089A8C(); sPokeMenuCursorPos = 0; sub_8089C7C(0); gTasks[taskID].func = sub_8089D94; sub_808B5B4(taskID); break; case B_BUTTON: PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskID].func = sub_8089E4C; break; } } }
void WallyHandleOpenBag(void) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gBattleBankFunc[gActiveBattler] = sub_81374C4; gBankInMenu = gActiveBattler; }
static void task_b_81441B8(u8 taskIdB) { u16 i; switch (gTasks[taskIdB].data[TDB_0]) { case 0: case 6: case 7: case 8: case 9: default: if (!gPaletteFade.active) { gTasks[taskIdB].data[TDB_0] = 1; gTasks[taskIdB].data[TDB_3] = 0x58; gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 0; gUnknown_02039320 = 0; } return; case 1: if (gTasks[taskIdB].data[TDB_3] != 0) { gTasks[taskIdB].data[TDB_3] -= 1; return; } gTasks[taskIdB].data[TDB_0] += 1; return; case 2: REG_DISPCNT &= ~DISPCNT_BG0_ON; if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].func == task_a_8143B68) { if (gTasks[taskIdB].data[TDB_CURRENT_PAGE] < PAGE_COUNT) { for (i = 0; i < 5; i++) sub_8072BD8(gCreditsEntryPointerTable[gTasks[taskIdB].data[TDB_CURRENT_PAGE]][i]->text, 0, 9 + i * 2, 240); gTasks[taskIdB].data[TDB_CURRENT_PAGE] += 1; gTasks[taskIdB].data[TDB_0] += 1; gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 1; if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_13] == 1) BeginNormalPaletteFade(0x300, 0, 16, 0, COLOR_LIGHT_GREEN); else BeginNormalPaletteFade(0x300, 0, 16, 0, COLOR_DARK_GREEN); return; } gTasks[taskIdB].data[TDB_0] = 10; return; } gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_14] = 0; return; case 3: REG_DISPCNT |= DISPCNT_BG0_ON; if (!gPaletteFade.active) { gTasks[taskIdB].data[TDB_3] = UNK_DEFINE_82; gTasks[taskIdB].data[TDB_0] += 1; } return; case 4: if (gTasks[taskIdB].data[TDB_3] != 0) { gTasks[taskIdB].data[TDB_3] -= 1; return; } if (sub_8144454((u8)gTasks[taskIdB].data[TDB_CURRENT_PAGE], (u8)gTasks[taskIdB].data[TDB_TASK_A_ID])) { gTasks[taskIdB].data[TDB_0] += 1; return; } gTasks[taskIdB].data[TDB_0] += 1; if (gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_13] == 1) BeginNormalPaletteFade(0x300, 0, 0, 16, COLOR_LIGHT_GREEN); else BeginNormalPaletteFade(0x300, 0, 0, 16, COLOR_DARK_GREEN); return; case 5: if (!gPaletteFade.active) { Menu_EraseWindowRect(0, 9, 29, 19); gTasks[taskIdB].data[TDB_0] = 2; } return; case 10: gTasks[gTasks[taskIdB].data[TDB_TASK_A_ID]].data[TDA_4] = 1; DestroyTask(taskIdB); return; } }
void sub_81439D0(void) { u8 taskIdA; s16 taskIdC; u8 taskIdB; u16 savedIme; struct Unk201C000 *c000; sub_8144130(); SetVBlankCallback(NULL); ResetPaletteFade(); ResetTasks(); taskIdA = CreateTask(task_a_8143B38, 0); gTasks[taskIdA].data[TDA_4] = 0; gTasks[taskIdA].data[TDA_7] = 0; gTasks[taskIdA].data[TDA_11] = 0; gTasks[taskIdA].data[TDA_13] = 1; while (TRUE) { if (sub_8144ECC(0, taskIdA)) break; } taskIdC = gTasks[taskIdA].data[TDA_TASK_C_ID]; gTasks[taskIdC].data[TDC_0] = 40; Text_LoadWindowTemplate(&gWindowTemplate_81E7208); InitMenuWindow(&gWindowTemplate_81E7208); LoadPalette(&gUnknown_0840B7BC, 0x80, sizeof(gUnknown_0840B7BC)); CpuCopy16(&gUnknown_0840B7FC, (void *)(VRAM + 0xBEE0), sizeof(gUnknown_0840B7FC)); REG_BG0VOFS = 0xFFFC; taskIdB = CreateTask(task_b_81441B8, 0); gTasks[taskIdB].data[TDB_TASK_A_ID] = taskIdA; gTasks[taskIdA].data[TDA_TASK_B_ID] = taskIdB; BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(0, 0, 0)); savedIme = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; REG_IME = savedIme; REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; SetVBlankCallback(vblank_8143948); m4aSongNumStart(BGM_THANKFOR); SetMainCallback2(sub_814395C); gUnknown_02039325 = 0; c000 = &ewram1c000; sub_81458DC(); c000->unk88 = 0; c000->unk8A = 0; c000->unk8C = 0; gUnknown_02039322 = taskIdA; }
void Task_ResetRtcScreen(u8 taskId) { s16 *data = gTasks[taskId].data; switch (data[0]) { case 0: BeginNormalPaletteFade(0xFFFFFFFF, 1, 16, 0, FADE_COLOR_WHITE); data[0] = 1; break; case 1: if (!gPaletteFade.active) { if (gSaveFileStatus == 0 || gSaveFileStatus == 2) { ResetRtcScreen_ShowMessage(gSystemText_NoSaveFileNoTime); data[0] = 5; } else { RtcCalcLocalTime(); data[1] = CreateTask(Task_ShowResetRtcPrompt, 80); data[0] = 2; } } break; case 2: if (gTasks[data[1]].isActive != TRUE) { Menu_EraseScreen(); ResetRtcScreen_ShowMessage(gSystemText_PleaseResetTime); gLocalTime = gSaveBlock2.lastBerryTreeUpdate; data[1] = CreateTask(Task_ResetRtc_0, 80); data[0] = 3; } break; case 3: if (gTasks[data[1]].data[0]) { if (!gTasks[data[1]].data[1]) { DestroyTask(data[1]); data[0] = 2; } else { DestroyTask(data[1]); RtcReset(); RtcCalcLocalTimeOffset( gLocalTime.days, gLocalTime.hours, gLocalTime.minutes, gLocalTime.seconds); gSaveBlock2.lastBerryTreeUpdate = gLocalTime; VarSet(VAR_DAYS, gLocalTime.days); DisableResetRTC(); ResetRtcScreen_ShowMessage(gSystemText_ClockResetDataSave); data[0] = 4; } } break; case 4: if (Save_WriteData(0) == SAVE_STATUS_OK) { ResetRtcScreen_ShowMessage(gSystemText_SaveCompleted); PlaySE(SE_PINPON); } else { ResetRtcScreen_ShowMessage(gSystemText_SaveFailed); PlaySE(SE_BOO); } data[0] = 5; // fall through case 5: if (gMain.newKeys & A_BUTTON) { BeginNormalPaletteFade(0xFFFFFFFF, 1, 0, 16, FADE_COLOR_WHITE); data[0] = 6; } else { break; } // fall through case 6: if (!gPaletteFade.active) { DestroyTask(taskId); DoSoftReset(); } } }