diff options
Diffstat (limited to 'src/map_name_popup.c')
-rw-r--r-- | src/map_name_popup.c | 109 |
1 files changed, 65 insertions, 44 deletions
diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 87df371ce..b7b9f85eb 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -18,26 +18,36 @@ static u16 MapNamePopupCreateWindow(bool32 palIntoFadedBuffer); static void MapNamePopupPrintMapNameOnWindow(u16 windowId); static u8 *MapNamePopupAppendFloorNum(u8 *dest, s8 flags); +#define tState data[0] +#define tTimer data[1] +#define tPos data[2] +#define tReshow data[3] +#define tWindowId data[4] +#define tWindowExists data[5] +#define tWindowCleared data[6] +#define tWindowDestroyed data[7] +#define tPalIntoFadedBuffer data[8] + void ShowMapNamePopup(bool32 palIntoFadedBuffer) { u8 taskId; - if (FlagGet(FLAG_SPECIAL_FLAG_0x4000) != TRUE && !(gQuestLogState == 2 || gQuestLogState == 3)) + if (FlagGet(FLAG_DONT_SHOW_MAP_NAME_POPUP) != TRUE && !(gQuestLogState == QL_STATE_2 || gQuestLogState == QL_STATE_3)) { taskId = FindTaskIdByFunc(Task_MapNamePopup); if (taskId == 0xFF) { taskId = CreateTask(Task_MapNamePopup, 90); - ChangeBgX(0, 0x00000000, 0); - ChangeBgY(0, 0xFFFFEF7F, 0); - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[2] = 0; - gTasks[taskId].data[8] = palIntoFadedBuffer; + ChangeBgX(0, 0x0000, 0); + ChangeBgY(0, -0x1081, 0); + gTasks[taskId].tState = 0; + gTasks[taskId].tPos = 0; + gTasks[taskId].tPalIntoFadedBuffer = palIntoFadedBuffer; } else { - if (gTasks[taskId].data[0] != 4) - gTasks[taskId].data[0] = 4; - gTasks[taskId].data[3] = 1; + if (gTasks[taskId].tState != 4) + gTasks[taskId].tState = 4; + gTasks[taskId].tReshow = 1; } } } @@ -45,71 +55,71 @@ void ShowMapNamePopup(bool32 palIntoFadedBuffer) static void Task_MapNamePopup(u8 taskId) { struct Task * task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: - task->data[4] = MapNamePopupCreateWindow(task->data[8]); - task->data[5] = 1; - task->data[0] = 1; + task->tWindowId = MapNamePopupCreateWindow(task->tPalIntoFadedBuffer); + task->tWindowExists = 1; + task->tState = 1; break; case 1: if (IsDma3ManagerBusyWithBgCopy()) break; // fallthrough case 2: - task->data[2] -= 2; - if (task->data[2] <= -24) + task->tPos -= 2; + if (task->tPos <= -24) { - task->data[0] = 3; - task->data[1] = 0; + task->tState = 3; + task->tTimer = 0; } break; case 3: - task->data[1]++; - if (task->data[1] > 120) + task->tTimer++; + if (task->tTimer > 120) { - task->data[1] = 0; - task->data[0] = 4; + task->tTimer = 0; + task->tState = 4; } break; case 4: - task->data[2] += 2; - if (task->data[2] >= 0) + task->tPos += 2; + if (task->tPos >= 0) { - if (task->data[3]) + if (task->tReshow) { - MapNamePopupPrintMapNameOnWindow(task->data[4]); - CopyWindowToVram(task->data[4], 2); - task->data[0] = 1; - task->data[3] = 0; + MapNamePopupPrintMapNameOnWindow(task->tWindowId); + CopyWindowToVram(task->tWindowId, 2); + task->tState = 1; + task->tReshow = 0; } else { - task->data[0] = 6; + task->tState = 6; return; } } case 5: break; case 6: - if (task->data[5] && !task->data[6]) + if (task->tWindowExists && !task->tWindowCleared) { - rbox_fill_rectangle(task->data[4]); - CopyWindowToVram(task->data[4], 1); - task->data[6] = 1; + rbox_fill_rectangle(task->tWindowId); + CopyWindowToVram(task->tWindowId, 1); + task->tWindowCleared = TRUE; } - task->data[0] = 7; + task->tState = 7; return; case 7: if (!IsDma3ManagerBusyWithBgCopy()) { - if (task->data[5]) + if (task->tWindowExists) { - RemoveWindow(task->data[4]); - task->data[5] = 0; - task->data[7] = 1; + RemoveWindow(task->tWindowId); + task->tWindowExists = FALSE; + task->tWindowDestroyed = 1; } - task->data[0] = 8; + task->tState = 8; ChangeBgY(0, 0x00000000, 0); } return; @@ -117,7 +127,7 @@ static void Task_MapNamePopup(u8 taskId) DestroyTask(taskId); return; } - SetGpuReg(REG_OFFSET_BG0VOFS, task->data[2]); + SetGpuReg(REG_OFFSET_BG0VOFS, task->tPos); } void DismissMapNamePopup(void) @@ -128,8 +138,8 @@ void DismissMapNamePopup(void) if (taskId != 0xFF) { data = gTasks[taskId].data; - if (data[0] < 6) - data[0] = 6; + if (tState < 6) + tState = 6; } } @@ -160,6 +170,7 @@ static u16 MapNamePopupCreateWindow(bool32 palintoFadedBuffer) } else { + // ROOFTOP windowTemplate.width += 8; r6 = 0x02D; } @@ -194,7 +205,7 @@ static void MapNamePopupPrintMapNameOnWindow(u16 windowId) } xpos = (maxWidth - GetStringWidth(2, mapName, -1)) / 2; FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); - AddTextPrinterParameterized(windowId, 2, mapName, xpos, 2, 0xFF, NULL); + AddTextPrinterParameterized(windowId, 2, mapName, xpos, 2, TEXT_SPEED_FF, NULL); } static u8 *MapNamePopupAppendFloorNum(u8 *dest, s8 floorNum) @@ -203,7 +214,7 @@ static u8 *MapNamePopupAppendFloorNum(u8 *dest, s8 floorNum) return dest; *dest++ = CHAR_SPACE; if (floorNum == 0x7F) - return StringCopy(dest, gUnknown_841D18D); + return StringCopy(dest, gText_Rooftop2); if (floorNum < 0) { *dest++ = CHAR_B; @@ -214,3 +225,13 @@ static u8 *MapNamePopupAppendFloorNum(u8 *dest, s8 floorNum) *dest = EOS; return dest; } + +#undef tPalIntoFadedBuffer +#undef tWindowDestroyed +#undef tWindowCleared +#undef tWindowExists +#undef tWindowId +#undef tReshow +#undef tPos +#undef tTimer +#undef tState |