papermario/src/code_80850_len_3060.c

1167 lines
30 KiB
C
Raw Normal View History

2020-08-04 08:49:11 +02:00
#include "common.h"
2020-08-09 06:20:53 +02:00
void clear_player_data(void) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-09 06:20:53 +02:00
s32 i;
D_8010CD10 = 0;
D_8010CD12 = 0;
playerData->hammerLevel = -1;
playerData->curHP = 10;
playerData->curMaxHP = 10;
playerData->hardMaxHP = 10;
playerData->curFP = 5;
playerData->curMaxFP = 5;
playerData->hardMaxFP = 5;
playerData->maxBP = 3;
playerData->level = 1;
playerData->bootsLevel = 0;
playerData->hasActionCommands = 0;
playerData->coins = 0;
playerData->fortressKeyCount = 0;
playerData->starPieces = 0;
playerData->starPoints = 0;
playerData->unk_11 = 0;
playerData->unk_288 = 0;
playerData->merleeSpellType = 0;
playerData->merleeCastsLeft = 0;
playerData->merleeTurnCount = -1;
playerData->maxStarPower = 0;
playerData->specialBarsFilled = 0;
playerData->unk_292[0] = 0;
2020-08-09 06:20:53 +02:00
playerData->currentPartner = 0;
2020-08-09 07:40:10 +02:00
for (i = 0; i < ARRAY_COUNT(playerData->partners); i++) {
2020-08-09 06:20:53 +02:00
playerData->partners[i].enabled = 0;
playerData->partners[i].level = 0;
playerData->partners[i].unk_02[0] = 0;
2020-08-14 23:53:45 +02:00
playerData->partners[i].unk_02[1] = 0;
playerData->partners[i].unk_02[2] = 0;
2020-08-09 06:20:53 +02:00
}
2020-08-09 07:40:10 +02:00
for (i = ARRAY_COUNT(playerData->keyItems) - 1; i >= 0; i--) {
2020-08-09 06:20:53 +02:00
playerData->keyItems[i] = 0;
}
2020-08-09 07:40:10 +02:00
for (i = ARRAY_COUNT(playerData->badges) - 1; i >= 0; i--) {
2020-08-09 06:20:53 +02:00
playerData->badges[i] = 0;
}
2020-08-09 07:40:10 +02:00
for (i = ARRAY_COUNT(playerData->invItems) - 1; i >= 0; i--) {
2020-08-09 06:20:53 +02:00
playerData->invItems[i] = 0;
}
2020-08-09 07:40:10 +02:00
for (i = ARRAY_COUNT(playerData->equippedBadges) - 1; i >= 0; i--) {
2020-08-09 06:20:53 +02:00
playerData->equippedBadges[i] = 0;
}
2020-08-09 07:40:10 +02:00
for (i = ARRAY_COUNT(playerData->storedItems) - 1; i >= 0; i--) {
2020-08-09 06:20:53 +02:00
playerData->storedItems[i] = 0;
}
playerData->otherHitsTaken = 0;
2020-08-14 23:53:45 +02:00
playerData->unk_296 = 0;
2020-08-09 06:20:53 +02:00
playerData->hitsTaken = 0;
playerData->hitsBlocked = 0;
playerData->playerFirstStrikes = 0;
playerData->enemyFirstStrikes = 0;
playerData->powerBounces = 0;
playerData->battlesCount = 0;
2020-08-14 23:53:45 +02:00
playerData->unk_2A4[0] = 0;
playerData->unk_2A4[1] = 0;
playerData->unk_2A4[2] = 0;
playerData->unk_2A4[3] = 0;
playerData->unk_2AC = 0;
playerData->unk_2B0 = 0;
2020-08-09 06:20:53 +02:00
playerData->idleFrameCounter = 0;
playerData->totalCoinsEarned = 0;
playerData->frameCounter = 0;
playerData->quizzesAnswered = 0;
playerData->quizzesCorrect = 0;
2020-08-09 07:40:10 +02:00
for (i = 0; i < ARRAY_COUNT(playerData->unk_2C4); i++) {
2020-08-09 06:20:53 +02:00
playerData->unk_2C4[i] = 0;
2020-08-14 23:53:45 +02:00
playerData->unk_2F4[i] = 0;
2020-08-09 06:20:53 +02:00
}
2020-08-14 23:53:45 +02:00
playerData->unk_328 = 0;
2020-08-09 06:20:53 +02:00
playerData->starPiecesCollected = 0;
playerData->jumpGamePlays = 0;
playerData->jumpGameTotal = 0;
playerData->jumpGameRecord = 0;
playerData->smashGamePlays = 0;
playerData->smashGameTotal = 0;
playerData->smashGameRecord = 0;
}
2020-08-04 08:49:11 +02:00
2020-08-16 05:19:00 +02:00
PlayerData* get_player_data(void) {
2020-08-06 20:54:37 +02:00
return &gPlayerData;
}
2020-08-04 08:49:11 +02:00
2020-08-08 17:26:50 +02:00
s32 add_item(s32 itemID) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-08 12:23:26 +02:00
s32 i;
sort_items();
2020-08-09 07:40:10 +02:00
for (i = 0; i < ARRAY_COUNT(gPlayerData.invItems); i++) {
2020-08-08 12:23:26 +02:00
if (playerData->invItems[i] == 0) {
break;
}
}
2020-08-09 04:17:37 +02:00
if (i == ARRAY_COUNT(gPlayerData.invItems)) {
2020-08-08 12:23:26 +02:00
return -1;
}
2020-08-09 07:40:10 +02:00
2020-08-08 17:26:50 +02:00
playerData->invItems[i] = itemID;
2020-08-08 12:23:26 +02:00
return i;
2020-08-08 17:26:50 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-09 04:17:37 +02:00
s32 get_item_count(void) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-09 04:17:37 +02:00
s32 i = 0;
s32 sum = 0;
for (i; i < ARRAY_COUNT(gPlayerData.invItems); i++) {
if (playerData->invItems[i] != 0) {
sum++;
}
}
2020-08-09 07:40:10 +02:00
2020-08-09 04:17:37 +02:00
return sum;
}
2020-08-04 08:49:11 +02:00
2020-08-09 04:17:37 +02:00
s32 get_item_empty_count(void) {
return ARRAY_COUNT(gPlayerData.invItems) - get_item_count();
}
2020-08-04 08:49:11 +02:00
2020-08-09 07:00:08 +02:00
s32 find_item(s32 itemID) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
StaticItem* item = &gItemTable[itemID];
2020-08-09 07:00:08 +02:00
s32 i;
2020-08-09 08:30:42 +02:00
if ((item->typeFlags & 8) != 0) {
2020-08-09 07:40:10 +02:00
for (i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
2020-08-09 07:00:08 +02:00
if (playerData->keyItems[i] == itemID) {
break;
}
}
if (i >= ARRAY_COUNT(playerData->keyItems)) {
return -1;
}
2020-08-09 07:40:10 +02:00
2020-08-09 07:00:08 +02:00
return i;
}
2020-08-09 07:00:08 +02:00
2020-08-09 07:40:10 +02:00
for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
if (playerData->invItems[i] == itemID) {
break;
2020-08-09 07:40:10 +02:00
}
}
2020-08-09 07:40:10 +02:00
if (i == ARRAY_COUNT(playerData->invItems)) {
return -1;
}
2020-08-09 07:40:10 +02:00
return i;
2020-08-09 07:00:08 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-12 04:08:48 +02:00
void sort_items(void) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-09 09:11:16 +02:00
int j;
int i;
for (i = ARRAY_COUNT(playerData->invItems) - 2; i >= 0; i--) {
if (playerData->invItems[i] != 0) {
for (j = ARRAY_COUNT(playerData->invItems) - 1; i < j; j--) {
if (playerData->invItems[j] == 0) {
playerData->invItems[j] = playerData->invItems[i];
playerData->invItems[i] = 0;
break;
}
}
}
}
return;
}
2020-08-04 08:49:11 +02:00
2020-08-09 08:30:42 +02:00
s32 add_badge(s32 itemID) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
StaticItem* item = &gItemTable[itemID];
2020-08-09 08:30:42 +02:00
s32 i;
if ((item->typeFlags & 0x40) == 0) {
return add_item(itemID);
}
for (i = 0; i < ARRAY_COUNT(playerData->badges); i++) {
if (playerData->badges[i] == 0) {
break;
}
}
if (i >= ARRAY_COUNT(playerData->badges)) {
return 0;
}
2020-08-12 04:08:48 +02:00
2020-08-09 08:30:42 +02:00
playerData->badges[i] = itemID;
return i;
}
2020-08-04 08:49:11 +02:00
2020-08-09 04:17:37 +02:00
s32 store_item(s32 itemID) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-09 04:17:37 +02:00
s32 i;
2020-08-04 08:49:11 +02:00
2020-08-09 04:17:37 +02:00
for (i = 0; i < ARRAY_COUNT(gPlayerData.storedItems); i++) {
if (playerData->storedItems[i] == 0) {
break;
}
}
if (i == ARRAY_COUNT(gPlayerData.storedItems)) {
return -1;
} else {
playerData->storedItems[i] = itemID;
}
2020-08-09 07:40:10 +02:00
2020-08-09 04:17:37 +02:00
return i;
}
s32 get_stored_count(void) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-09 04:17:37 +02:00
s32 i = 0;
s32 sum = 0;
for (i; i < ARRAY_COUNT(gPlayerData.storedItems); i++) {
if (playerData->storedItems[i] != 0) {
sum++;
}
}
2020-08-09 07:40:10 +02:00
2020-08-09 04:17:37 +02:00
return sum;
}
2020-08-04 08:49:11 +02:00
2020-08-06 20:54:37 +02:00
s32 get_stored_empty_count(void) {
2020-08-09 04:17:37 +02:00
return ARRAY_COUNT(gPlayerData.storedItems) - get_stored_count();
2020-08-06 20:54:37 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-10 09:42:50 +02:00
void enforce_hpfp_limits(void) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
PlayerData* playerData2 = &gPlayerData;
2020-08-10 09:42:50 +02:00
playerData->curMaxHP = playerData->hardMaxHP + (is_ability_active(4) * 5);
if (playerData->curMaxHP > 75) {
playerData->curMaxHP = 75;
}
if (playerData->curHP > playerData->curMaxHP) {
playerData->curHP = playerData->curMaxHP;
}
playerData2->curMaxFP = playerData2->hardMaxFP + (is_ability_active(12) * 5);
if (playerData2->curMaxFP > 75) {
playerData2->curMaxFP = 75;
}
if (playerData2->curFP > playerData2->curMaxFP) {
playerData2->curFP = playerData2->curMaxFP;
}
}
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_80850_len_3060", initialize_status_menu);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_80850_len_3060", status_menu_draw_number);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_80850_len_3060", status_menu_draw_stat);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_80850_len_3060", update_status_menu);
2020-08-04 08:49:11 +02:00
2020-08-11 04:04:25 +02:00
void coin_counter_draw_content(UNK_TYPE arg0, s32 posX, s32 posY) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-11 04:04:25 +02:00
s32 iconIndex;
if ((gPlayerData.coins != uiStatus->displayCoins) && (((*gGameStatusPtr)->frameCounter % 3) == 0)) {
2020-08-11 04:04:25 +02:00
play_sound(0x211);
}
iconIndex = uiStatus->iconIndex10;
set_icon_render_pos(iconIndex, posX + 27, posY + 11);
draw_icon_0(iconIndex);
iconIndex = uiStatus->iconIndex11;
set_icon_render_pos(iconIndex, posX + 15, posY + 11);
draw_icon_0(iconIndex);
draw_number(uiStatus->displayCoins, posX + 58, posY + 4, 1, 10, 255, 3);
}
2020-08-04 08:49:11 +02:00
void update_coin_counter(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
PlayerData* playerData = &gPlayerData;
2020-08-12 04:08:48 +02:00
do {} while(0); // Needed to match
if (uiStatus->unk_6C[1] != 0) {
uiStatus->unk_6C[1] -= 1;
if (((uiStatus->unk_6C[1] << 24) == 0) && (uiStatus->iconIndex12 >= 0)) {
2020-08-12 04:08:48 +02:00
free_icon(uiStatus->iconIndex12);
free_icon(uiStatus->iconIndex13);
uiStatus->iconIndex12 = -1;
}
D_8010CD12 = 0;
}
if (uiStatus->unk_6C[0] != 0) {
if ((uiStatus->displayCoins == playerData->coins) && (uiStatus->unk_6C[0] > 30)) {
uiStatus->unk_6C[0] = 30;
}
if ((uiStatus->displayCoins == playerData->coins) || (uiStatus->unk_6C[0] <= 30)) {
uiStatus->unk_6C[0] -= 1;
if (uiStatus->unk_6C[0] == 0) {
2020-08-12 04:08:48 +02:00
func_80147E7C(20, &D_80147574);
uiStatus->unk_6C[1] = 15;
2020-08-12 04:08:48 +02:00
D_8010CD10 = 0;
D_8010CD12 = 1;
uiStatus->iconIndex12 = uiStatus->iconIndex10;
uiStatus->iconIndex13 = uiStatus->iconIndex11;
uiStatus->displayCoins = playerData->coins;
if (uiStatus->unk_6C[2] > -1) {
uiStatus->ignoreChanges = uiStatus->unk_6C[2];
uiStatus->unk_6C[2] = -1;
2020-08-12 04:08:48 +02:00
}
}
}
}
2020-08-12 04:08:48 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-10 23:35:37 +02:00
void show_coin_counter(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-12 04:08:48 +02:00
s16* coinCounterUnk = &D_8010CD10;
2020-08-10 23:35:37 +02:00
s32 index;
if ((*coinCounterUnk != 0) || (D_8010CD12 != 0)) {
func_80147E7C(0x14, 2);
if (uiStatus->iconIndex12 > -1) {
free_icon(uiStatus->iconIndex10);
free_icon(uiStatus->iconIndex11);
uiStatus->iconIndex12 = -1;
}
uiStatus->unk_6C[0] = 0;
uiStatus->unk_6C[1] = 0;
2020-08-10 23:35:37 +02:00
*coinCounterUnk = 0;
D_8010CD12 = 0;
}
if (uiStatus->unk_6C[0]== 0) {
2020-08-12 04:08:48 +02:00
func_80147CC8(0x14, 0x20, 0xa4, 0x40, 0x14, 0x15, &D_800E92D8, 0, -1);
func_80147E7C(0x14, &D_80147474);
index = create_icon(&D_80109270);
uiStatus->iconIndex10 = index;
set_icon_flags(index, 0x80);
func_80144EFC(index, 0xff, 0xff, 0xff);
index = create_icon(&D_80108558);
uiStatus->iconIndex11 = index;
set_icon_flags(index, 0x80);
func_80144EFC(index, 0xff, 0xff, 0xff);
uiStatus->unk_6C[0] = 0;
2020-08-10 23:35:37 +02:00
if (uiStatus->unk_6C[2] < 0) {
uiStatus->unk_6C[2] = uiStatus->ignoreChanges;
2020-08-12 04:08:48 +02:00
}
2020-08-10 23:35:37 +02:00
2020-08-12 04:08:48 +02:00
uiStatus->ignoreChanges = 1;
D_8010CD10 = 1;
}
return;
2020-08-10 23:35:37 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-09 06:37:06 +02:00
void hide_coin_counter(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 06:37:06 +02:00
if ((D_8010CD10 != 0) && (uiStatus->unk_6C[0]== 0)) {
uiStatus->unk_6C[0] = 60;
2020-08-09 06:37:06 +02:00
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 06:37:06 +02:00
void func_800E96C8(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 06:37:06 +02:00
if ((D_8010CD10 != 0) && (uiStatus->unk_6C[0]== 0)) {
uiStatus->unk_6C[0]= 1;
2020-08-09 06:37:06 +02:00
}
}
2020-08-04 08:49:11 +02:00
2020-08-16 08:55:51 +02:00
ApiStatus ShowCoinCounter(ScriptInstance* script, s32 isInitialCall) {
2020-08-09 05:46:54 +02:00
if (get_variable(script, *script->ptrReadPos)) {
show_coin_counter();
} else {
hide_coin_counter();
}
2020-08-16 08:55:51 +02:00
return ApiStatus_DONE2;
2020-08-09 05:46:54 +02:00
}
2020-08-09 06:30:57 +02:00
void func_800E973C(void) {
update_status_menu();
update_coin_counter();
}
2020-08-04 08:49:11 +02:00
2020-08-09 05:46:54 +02:00
void open_status_menu_long(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-04 08:49:11 +02:00
2020-08-09 05:46:54 +02:00
if (uiStatus->hidden) {
uiStatus->showTimer = 210;
uiStatus->hidden = 0;
uiStatus->unk_3B[0] = 1;
2020-08-09 05:46:54 +02:00
}
}
void open_status_menu_short(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 05:46:54 +02:00
if (uiStatus->hidden) {
uiStatus->showTimer = 105;
uiStatus->hidden = 0;
uiStatus->unk_3B[0] = 1;
2020-08-09 05:46:54 +02:00
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 06:30:57 +02:00
void func_800E97B8(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 06:30:57 +02:00
if (uiStatus->hidden != 1) {
uiStatus->hidden = 1;
uiStatus->showTimer = 0;
uiStatus->unk_3B[0] = 1;
2020-08-09 06:30:57 +02:00
}
}
2020-08-04 08:49:11 +02:00
void func_800E97E4(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 06:30:57 +02:00
uiStatus->drawPosY = -100;
2020-08-09 06:30:57 +02:00
uiStatus->ignoreChanges = 0;
uiStatus->showTimer = 0;
2020-08-09 06:30:57 +02:00
uiStatus->hidden = 1;
uiStatus->unk_3B[0] = 0;
uiStatus->unk_3B[1] = 0;
}
2020-08-04 08:49:11 +02:00
2020-08-09 06:30:57 +02:00
void func_800E9810(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-04 08:49:11 +02:00
2020-08-09 06:30:57 +02:00
uiStatus->showTimer = 210;
uiStatus->drawPosY = 0;
uiStatus->ignoreChanges = 0;
uiStatus->hidden = 0;
uiStatus->unk_3B[0] = 1;
uiStatus->unk_3B[1] = 0;
2020-08-09 06:30:57 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-09 06:30:57 +02:00
void func_800E983C(void) {
gUIStatus.unk_45[0] = 0;
2020-08-09 06:30:57 +02:00
}
void func_800E984C(void) {
gUIStatus.unk_45[0] = 1;
2020-08-09 06:30:57 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-09 07:26:10 +02:00
s32 func_800E9860(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
UiStatus* uiStatus2 = &gUIStatus;
s32 ret = 1 - uiStatus->unk_45[0];
2020-08-09 07:26:10 +02:00
if (uiStatus->unk_45[1] != 0) {
2020-08-09 07:26:10 +02:00
ret = 0;
}
if (uiStatus2->ignoreChanges) {
ret = 0;
}
return ret;
}
2020-08-04 08:49:11 +02:00
2020-08-09 06:30:57 +02:00
void status_menu_enable_ignore_changes(void) {
gUIStatus.ignoreChanges = 1;
}
void func_800E98A8(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-04 08:49:11 +02:00
2020-08-09 06:30:57 +02:00
uiStatus->ignoreChanges = 1;
uiStatus->drawPosY = 18;
}
void status_menu_disable_ignore_changes(void) {
gUIStatus.ignoreChanges = 0;
}
2020-08-04 08:49:11 +02:00
2020-08-09 05:53:24 +02:00
s32 func_800E98D4(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 05:53:24 +02:00
return uiStatus->unk_45[1] + uiStatus->ignoreChanges;
2020-08-09 05:53:24 +02:00
}
2020-08-09 06:30:57 +02:00
void func_800E98EC(void) {
gUIStatus.unk_45[1] = 1;
2020-08-09 06:30:57 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-09 05:53:24 +02:00
void func_800E9900(void) {
gUIStatus.unk_45[1] = 0;
2020-08-09 05:53:24 +02:00
}
s32 is_status_menu_visible(void) {
return !gUIStatus.hidden;
}
2020-08-04 08:49:11 +02:00
2020-08-09 05:38:42 +02:00
void status_menu_start_blinking_hp(void) {
2020-08-16 05:19:00 +02:00
GameStatus* gameStatus = (*gGameStatusPtr);
UiStatus* uiStatus = &gUIStatus;
UiStatus* uiStatus2 = &gUIStatus;
2020-08-09 05:38:42 +02:00
2020-08-14 23:53:45 +02:00
if (gameStatus->isBattle == 0) {
2020-08-09 05:38:42 +02:00
uiStatus->hpBlinkTimer = 120;
}
if (uiStatus2->hpBlinking != 1) {
uiStatus2->hpBlinking = 1;
uiStatus2->hpBlinkCounter = 0;
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 04:52:50 +02:00
void status_menu_stop_blinking_hp(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 04:52:50 +02:00
if (uiStatus->hpBlinking != 0) {
uiStatus->hpBlinking = 0;
uiStatus->hpBlinkCounter = 0;
uiStatus->hpBlinkTimer = 0;
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 05:38:42 +02:00
void status_menu_start_blinking_fp(void) {
2020-08-16 05:19:00 +02:00
GameStatus* gameStatus = (*gGameStatusPtr);
UiStatus* uiStatus = &gUIStatus;
UiStatus* uiStatus2 = &gUIStatus;
2020-08-09 05:38:42 +02:00
2020-08-14 23:53:45 +02:00
if (gameStatus->isBattle == 0) {
2020-08-09 05:38:42 +02:00
uiStatus->fpBlinkTimer = 120;
}
if (uiStatus2->fpBlinking != 1) {
uiStatus2->fpBlinking = 1;
uiStatus2->fpBlinkCounter = 0;
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 04:52:50 +02:00
void status_menu_stop_blinking_fp(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 04:52:50 +02:00
if (uiStatus->fpBlinking != 0) {
uiStatus->fpBlinking = 0;
uiStatus->fpBlinkCounter = 0;
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 05:38:42 +02:00
void status_menu_start_blinking_coins(void) {
2020-08-16 05:19:00 +02:00
GameStatus* gameStatus = (*gGameStatusPtr);
UiStatus* uiStatus = &gUIStatus;
UiStatus* uiStatus2 = &gUIStatus;
2020-08-09 05:38:42 +02:00
2020-08-14 23:53:45 +02:00
if (gameStatus->isBattle == 0) {
2020-08-09 05:38:42 +02:00
uiStatus->coinsBlinkTimer = 120;
}
if (uiStatus2->coinsBlinking != 1) {
uiStatus2->coinsBlinking = 1;
uiStatus2->coinsBlinkCounter = 0;
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 04:52:50 +02:00
void status_menu_stop_blinking_coins(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 04:52:50 +02:00
if (uiStatus->coinsBlinking != 0) {
uiStatus->coinsBlinking = 0;
uiStatus->coinsBlinkCounter = 0;
uiStatus->coinsBlinkTimer = 0;
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 05:38:42 +02:00
void status_menu_start_blinking_sp(void) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
UiStatus* uiStatus = &gUIStatus;
2020-08-09 05:38:42 +02:00
uiStatus->spBarsToBlink = playerData->maxStarPower;
if (uiStatus->spBlinking != 1) {
uiStatus->spBlinking = 1;
uiStatus->spBlinkCounter = 0;
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 04:52:50 +02:00
void status_menu_stop_blinking_sp(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 04:52:50 +02:00
if (uiStatus->spBlinking != 0) {
uiStatus->spBlinking = 0;
uiStatus->spBlinkCounter = 0;
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 05:38:42 +02:00
void status_menu_start_blinking_sp_bars(s8 numBarsToBlink) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-04 08:49:11 +02:00
2020-08-09 05:38:42 +02:00
uiStatus->spBarsToBlink = numBarsToBlink;
if (uiStatus->spBlinking != 1) {
uiStatus->spBlinking = 1;
uiStatus->spBlinkCounter = 0;
}
}
void status_menu_start_blinking_starpoints(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 05:38:42 +02:00
if (uiStatus->starpointsBlinking != 1) {
uiStatus->starpointsBlinking = 1;
uiStatus->starpointsBlinkCounter = 0;
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 04:52:50 +02:00
void status_menu_stop_blinking_starpoints(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-04 08:49:11 +02:00
2020-08-09 04:52:50 +02:00
if (uiStatus->starpointsBlinking != 0) {
uiStatus->starpointsBlinking = 0;
uiStatus->starpointsBlinkCounter = 0;
}
}
void decrement_status_menu_disabled(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-09 04:52:50 +02:00
if (uiStatus->disabled > 0) {
uiStatus->disabled--;
}
}
2020-08-04 08:49:11 +02:00
2020-08-09 04:52:50 +02:00
void increment_status_menu_disabled(void) {
2020-08-16 05:19:00 +02:00
UiStatus* uiStatus = &gUIStatus;
2020-08-04 08:49:11 +02:00
2020-08-09 04:52:50 +02:00
uiStatus->disabled++;
}
void sync_status_menu(void) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
UiStatus* uiStatus = &gUIStatus;
2020-08-09 04:52:50 +02:00
uiStatus->displayHP = playerData->curHP;
uiStatus->displayFP = playerData->curFP;
uiStatus->displaySP = playerData->specialBarsFilled;
uiStatus->displayCoins = playerData->coins;
uiStatus->displayStarpoints = playerData->starPoints;
}
2020-08-04 08:49:11 +02:00
2020-08-09 09:20:32 +02:00
void reset_status_menu(void) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
UiStatus* uiStatus = &gUIStatus;
2020-08-14 23:53:45 +02:00
s32 i;
2020-08-09 09:20:32 +02:00
uiStatus->drawPosX = 12;
uiStatus->drawPosY = -100;
uiStatus->hidden = 0;
uiStatus->showTimer = 210;
uiStatus->unk_3B[0] = 0;
2020-08-09 09:20:32 +02:00
uiStatus->ignoreChanges = 0;
uiStatus->unk_45[0] = 0;
uiStatus->unk_45[1] = 0;
2020-08-09 09:20:32 +02:00
uiStatus->hpBlinking = 0;
uiStatus->hpBlinkCounter = 0;
uiStatus->hpBlinkTimer = 0;
uiStatus->fpBlinking = 0;
uiStatus->fpBlinkCounter = 0;
uiStatus->fpBlinkTimer = 0;
uiStatus->coinsBlinking = 0;
uiStatus->coinsBlinkCounter = 0;
uiStatus->coinsBlinkTimer = 0;
uiStatus->spBlinking = 0;
uiStatus->spBlinkCounter = 0;
uiStatus->disabled = 0;
uiStatus->starpointsBlinking = 0;
uiStatus->starpointsBlinkCounter = 0;
uiStatus->unk_6C[2] = -1;
2020-08-09 09:20:32 +02:00
uiStatus->displayHP = playerData->curHP;
uiStatus->displayFP = playerData->curFP;
uiStatus->displayCoins = playerData->coins;
uiStatus->displayStarpoints = playerData->starPoints;
uiStatus->displaySP = playerData->specialBarsFilled;
uiStatus->unk_3B[1] = 0;
2020-08-09 09:20:32 +02:00
2020-08-14 23:53:45 +02:00
for (i = 0; i < 2; i++) {
func_801452B4(uiStatus->hpIconIndexes[i], uiStatus->hpIconIndexes[i]);
}
for (i = 0; i < 2; i++) {
func_801452B4(uiStatus->fpIconIndexes[i], uiStatus->fpIconIndexes[i]);
}
2020-08-16 05:19:00 +02:00
2020-08-09 09:20:32 +02:00
func_801452B4(uiStatus->coinIconIndex, uiStatus->coinIconIndex);
func_801452B4(uiStatus->coinIconIndex2, uiStatus->coinIconIndex2);
func_801452B4(uiStatus->starpointsIconIndex, uiStatus->starpointsIconIndex);
func_801452B4(uiStatus->starpointsIconIndex2, uiStatus->starpointsIconIndex2);
func_801452B4(uiStatus->iconIndex8, uiStatus->iconIndex8);
func_801452B4(uiStatus->iconIndex9, uiStatus->iconIndex9);
func_801452B4(uiStatus->iconIndexA, uiStatus->iconIndexA);
func_801452B4(uiStatus->iconIndexB, uiStatus->iconIndexB);
func_801452B4(uiStatus->iconIndexC, uiStatus->iconIndexC);
}
2020-08-04 08:49:11 +02:00
2020-08-08 12:23:26 +02:00
// uses a jumptable, which we need .rodata support for.
s32 INCLUDE_ASM("code_80850_len_3060", is_ability_active, s32 arg0);
// Somewhat close. Needs work.
/*s32 is_ability_active(s32 arg0) {
s32 iVar2;
u32 uVar3;
s32 iVar5;
s32 piVar6;
s32 i;
s32 local_20[6];
s32 badge;
player_data* playerData = &gPlayerData;
s32 iVar7 = 0;
u32 uVar4;
iVar5 = 0;
//iVar7 = 0;
for(i = 5; i >= 0; i--) {
local_20[i] = 0;
}
if (((*gGameStatusPtr)->unk_7E & 1) == 0) {
iVar2 = 0;
iVar7 = 0;
piVar6 = 0;
for (i = 0; i < ARRAY_COUNT(playerData->equippedBadges); i++) {
s32 index = i;
badge = playerData->equippedBadges[index];
if (playerData->equippedBadges[index] != 0) {
uVar4 = gItemTable[badge].moveID;
}
switch (arg0) {
case 0:
uVar3 = 0x4c;
break;
default:
continue;
case 2:
uVar3 = 0x40;
break;
case 3:
uVar3 = 0x4d;
break;
case 4:
uVar3 = 0x52;
break;
case 5:
uVar3 = 0x35;
break;
case 6:
if (uVar4 == 0x53) {
iVar7++;
}
if (playerData->hasActionCommands != 0) {
iVar7++;
}
continue;
case 7:
uVar3 = 0x41;
break;
case 8:
uVar3 = 0x42;
break;
case 9:
uVar3 = 0x5a;
break;
case 10:
uVar3 = 0x3c;
break;
case 0xb:
uVar3 = 0x4e;
break;
case 0xc:
uVar3 = 0x5b;
break;
case 0xd:
uVar3 = 0x3d;
break;
case 0xe:
uVar3 = 0x43;
break;
case 0xf:
if (uVar4 == 0x54) {
local_20[piVar6] = 1;
piVar6++;
iVar5++;
iVar7 = -1;
}
if (uVar4 == 0x55) {
local_20[piVar6] = 2;
piVar6++;
iVar5++;
iVar7 = -1;
}
if (uVar4 == 0x56) {
local_20[piVar6] = 3;
piVar6++;
iVar5++;
iVar7 = -1;
}
if (uVar4 == 0x57) {
local_20[piVar6] = 4;
piVar6++;
iVar5++;
iVar7 = -1;
}
if (uVar4 == 0x58) {
local_20[piVar6] = 5;
piVar6++;
iVar5++;
iVar7 = -1;
}
if (uVar4 == 0x59) {
local_20[piVar6] = 6;
piVar6++;
iVar5++;
iVar7 = -1;
}
continue;
case 0x10:
uVar3 = 0x5c;
break;
case 0x11:
uVar3 = 0x5d;
break;
case 0x12:
uVar3 = 0x5e;
break;
case 0x13:
uVar3 = 0x44;
break;
case 0x14:
uVar3 = 0x5f;
break;
case 0x15:
uVar3 = 0x60;
break;
case 0x16:
uVar3 = 0x4f;
break;
case 0x17:
uVar3 = 0x61;
break;
case 0x18:
uVar3 = 0x62;
break;
case 0x19:
uVar3 = 99;
break;
case 0x1b:
uVar3 = 0x45;
break;
case 0x1c:
uVar3 = 0x3b;
break;
case 0x1d:
uVar3 = 0x6e;
break;
case 0x1e:
uVar3 = 100;
break;
case 0x1f:
uVar3 = 0x65;
break;
case 0x20:
uVar3 = 0x46;
break;
case 0x21:
uVar3 = 0x47;
break;
case 0x22:
uVar3 = 0x3e;
break;
case 0x23:
uVar3 = 0x48;
break;
case 0x24:
uVar3 = 0x66;
break;
case 0x25:
uVar3 = 0x49;
break;
case 0x26:
uVar3 = 0x67;
break;
case 0x27:
uVar3 = 0x6d;
break;
case 0x28:
uVar3 = 0x6a;
break;
case 0x29:
uVar3 = 0x6c;
break;
case 0x2a:
uVar3 = 0x50;
break;
case 0x1a:
uVar3 = 0x38;
break;
case 0x2b:
uVar3 = 0x68;
break;
case 0x2c:
uVar3 = 0x69;
break;
case 0x2d:
uVar3 = 0x6b;
break;
case 0x2e:
uVar3 = 0x6f;
break;
case 0x2f:
uVar3 = 0x70;
break;
case 0x30:
uVar3 = 0x71;
break;
case 0x31:
uVar3 = 0x72;
break;
case 0x32:
uVar3 = 0x73;
break;
case 0x33:
uVar3 = 0x33;
break;
case 0x34:
uVar3 = 0x74;
break;
case 0x35:
uVar3 = 0x75;
break;
case 0x36:
uVar3 = 0x76;
break;
case 0x37:
uVar3 = 0x4a;
}
if (uVar4 == uVar3) {
iVar7++;
}
}
if (iVar7 < 0) {
iVar7 = local_20[rand_int(iVar5 - 1)];
}
return iVar7;
}
}*/
2020-08-04 08:49:11 +02:00
2020-08-06 07:00:11 +02:00
s32 is_partner_ability_active(void) {
return 0;
}
2020-08-04 08:49:11 +02:00
2020-08-08 12:23:26 +02:00
s16 add_coins(s32 amt) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-08 17:26:50 +02:00
s16 newCoins = playerData->coins + amt;
2020-08-08 12:23:26 +02:00
2020-08-08 17:26:50 +02:00
playerData->coins = newCoins;
if (newCoins > 999) {
2020-08-08 12:23:26 +02:00
playerData->coins = 999;
}
if (playerData->coins < 0) {
playerData->coins = 0;
}
if (amt > 0) {
2020-08-08 17:26:50 +02:00
playerData->totalCoinsEarned += amt;
if (playerData->totalCoinsEarned > 99999) {
2020-08-08 12:23:26 +02:00
playerData->totalCoinsEarned = 99999;
}
}
return playerData->coins;
}
s8 add_star_points(s32 amt) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
PlayerData* playerData2 = &gPlayerData;
2020-08-08 17:26:50 +02:00
s8 newSP = playerData->starPoints + amt;
2020-08-08 12:23:26 +02:00
2020-08-12 04:08:48 +02:00
// TODO: probably a macro!
2020-08-08 17:26:50 +02:00
playerData2->starPoints = newSP;
if (newSP > 100) {
2020-08-09 07:40:10 +02:00
playerData2->starPoints = 100;
2020-08-08 12:23:26 +02:00
}
2020-08-12 04:08:48 +02:00
// TODO: probably a macro!
2020-08-08 17:26:50 +02:00
newSP = playerData2->starPoints;
if (newSP < 0) {
2020-08-09 07:40:10 +02:00
playerData2->starPoints = 0;
2020-08-08 12:23:26 +02:00
}
return gPlayerData.starPoints;
}
2020-08-04 08:49:11 +02:00
2020-08-08 10:23:02 +02:00
u8 add_star_pieces(s32 amt) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
PlayerData* playerData2 = &gPlayerData;
2020-08-08 10:23:02 +02:00
s32 newSP = playerData->starPieces;
newSP += amt;
if (newSP > 222) {
newSP = 222;
2020-08-08 10:14:42 +02:00
}
2020-08-08 10:23:02 +02:00
if (newSP < 0) {
newSP = 0;
}
playerData->starPieces = newSP;
2020-08-08 10:14:42 +02:00
if (amt > 0) {
playerData->starPiecesCollected += amt;
}
2020-08-08 10:23:02 +02:00
return playerData2->starPieces;
}
2020-08-04 08:49:11 +02:00
2020-08-08 10:14:42 +02:00
void increment_max_SP() {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-08 10:14:42 +02:00
playerData->maxStarPower++;
playerData->specialBarsFilled = playerData->maxStarPower * 256;
}
void set_max_SP(s8 newMaxSP) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-08 10:14:42 +02:00
playerData->maxStarPower = newMaxSP;
playerData->specialBarsFilled = newMaxSP * 256;
}
2020-08-04 08:49:11 +02:00
2020-08-09 07:26:10 +02:00
void add_SP(s32 amt) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
PlayerData* playerData2 = &gPlayerData;
UiStatus* uiStatus = &gUIStatus;
UiStatus* uiStatus2 = &gUIStatus;
2020-08-09 07:26:10 +02:00
s32 phi_v1;
s32 blah;
uiStatus->unk_57[0] = 1;
uiStatus->unk_57[1] = 60;
2020-08-09 07:26:10 +02:00
phi_v1 = playerData->specialBarsFilled;
if (phi_v1 < 0) {
phi_v1 = playerData->specialBarsFilled + 31;
}
uiStatus->unk_57[2] = phi_v1 >> 5;
2020-08-09 07:26:10 +02:00
playerData->specialBarsFilled += amt;
2020-08-09 07:40:10 +02:00
2020-08-09 07:26:10 +02:00
blah = playerData->maxStarPower << 8;
if (playerData->specialBarsFilled > blah) {
playerData->specialBarsFilled = blah;
}
uiStatus2->displaySP = playerData2->specialBarsFilled;
}
2020-08-04 08:49:11 +02:00
2020-08-08 10:14:42 +02:00
s32 recover_fp(s32 amt) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-08 10:14:42 +02:00
s32 newFP = playerData->curFP;
s32 ret;
if (amt == -2) {
playerData->curMaxFP += 1;
playerData->curFP = playerData->curMaxFP;
return playerData->curMaxFP;
}
if (amt > 0) {
newFP += amt;
}
if ((amt == -1) || (ret = newFP, (playerData->curMaxFP < newFP))) {
ret = playerData->curMaxFP;
}
playerData->curFP = ret;
return ret;
}
2020-08-04 08:49:11 +02:00
2020-08-08 10:14:42 +02:00
s32 recover_hp(s32 amt) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-08 10:14:42 +02:00
s32 newHP = playerData->curHP;
s32 ret;
if (amt == -2) {
playerData->curMaxHP += 1;
playerData->curHP = playerData->curMaxHP;
return playerData->curMaxHP;
}
if (amt > 0) {
newHP += amt;
}
if ((amt == -1) || (ret = newHP, (playerData->curMaxHP < newHP))) {
ret = playerData->curMaxHP;
}
playerData->curHP = ret;
return ret;
}
2020-08-04 08:49:11 +02:00
2020-08-08 07:25:36 +02:00
void subtract_hp(s32 amt) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-08 10:14:42 +02:00
s32 newHP = playerData->curHP;
2020-08-08 10:23:02 +02:00
2020-08-08 07:25:36 +02:00
if (amt > 0) {
newHP -= amt;
}
if (amt < 0 || newHP < 1) {
newHP = 1;
}
playerData->curHP = newHP;
}
2020-08-04 08:49:11 +02:00
2020-08-06 07:00:11 +02:00
s8 has_full_hp(void) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-06 07:00:11 +02:00
return playerData->curMaxHP == playerData->curHP;
}
s8 has_full_fp(void) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-06 07:00:11 +02:00
return playerData->curMaxFP == playerData->curFP;
}
s8 add_fortress_keys(s32 amt) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
2020-08-08 10:23:02 +02:00
2020-08-06 07:00:11 +02:00
playerData->fortressKeyCount += amt;
return playerData->fortressKeyCount;
}
2020-08-06 20:54:37 +02:00
s8 subtract_fortress_keys(s8 amt) {
2020-08-16 05:19:00 +02:00
PlayerData* playerData = &gPlayerData;
PlayerData* playerData2 = &gPlayerData; // required to match
2020-08-08 10:23:02 +02:00
2020-08-06 07:00:11 +02:00
playerData->fortressKeyCount -= amt;
if (playerData->fortressKeyCount < 0) {
playerData->fortressKeyCount = 0;
}
2020-08-08 10:23:02 +02:00
2020-08-06 20:54:37 +02:00
return playerData2->fortressKeyCount; // required to use playerData2 here to match
2020-08-06 07:00:11 +02:00
}
2020-08-04 08:49:11 +02:00
2020-08-06 20:54:37 +02:00
s8 get_fortress_key_count(void) {
return gPlayerData.fortressKeyCount;
}