2020-08-04 08:49:11 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
2020-08-09 09:11:16 +02:00
|
|
|
void sort_items(void);
|
|
|
|
|
2020-08-09 06:20:53 +02:00
|
|
|
void clear_player_data(void) {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
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;
|
2020-08-14 22:10:34 +02:00
|
|
|
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;
|
2020-08-14 22:10:34 +02:00
|
|
|
playerData->partners[i].unk_02[0] = 0;
|
|
|
|
playerData->partners[i].unk_02[2] = 0;
|
|
|
|
playerData->partners[i].unk_02[4] = 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 22:10:34 +02:00
|
|
|
playerData->unk_296[0] = 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 22:10:34 +02:00
|
|
|
playerData->unk_2A4[0x0] = 0;
|
|
|
|
playerData->unk_2A4[0x2] = 0;
|
|
|
|
playerData->unk_2A4[0x4] = 0;
|
|
|
|
playerData->unk_2A4[0x8] = 0;
|
|
|
|
playerData->unk_2A4[0xA] = 0;
|
|
|
|
playerData->unk_2A4[0xC] = 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 22:10:34 +02:00
|
|
|
playerData->unk_2C4[i + 0xB0] = 0;
|
2020-08-09 06:20:53 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
playerData->unk_2C4[0x64] = 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-06 20:54:37 +02:00
|
|
|
player_data* get_player_data(void) {
|
|
|
|
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-08 12:23:26 +02:00
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
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-12 04:08:48 +02:00
|
|
|
player_data* 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-12 04:08:48 +02:00
|
|
|
player_data* playerData = &gPlayerData;
|
2020-08-09 08:30:42 +02:00
|
|
|
item_table_entry* 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:23:07 +02:00
|
|
|
}
|
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) {
|
2020-08-09 07:23:07 +02:00
|
|
|
break;
|
2020-08-09 07:40:10 +02:00
|
|
|
}
|
2020-08-09 07:23:07 +02:00
|
|
|
}
|
2020-08-09 07:40:10 +02:00
|
|
|
|
2020-08-09 07:23:07 +02:00
|
|
|
if (i == ARRAY_COUNT(playerData->invItems)) {
|
|
|
|
return -1;
|
|
|
|
}
|
2020-08-09 07:40:10 +02:00
|
|
|
|
2020-08-09 07:23:07 +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-09 09:11:16 +02:00
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
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) {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
item_table_entry* item = &gItemTable[itemID];
|
|
|
|
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-12 04:08:48 +02:00
|
|
|
player_data* 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-12 04:08:48 +02:00
|
|
|
player_data* 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) {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
player_data* playerData2 = &gPlayerData;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_80850_len_3060, status_menu_draw_number);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_80850_len_3060, status_menu_draw_stat);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_80850_len_3060, update_status_menu);
|
|
|
|
|
2020-08-11 04:04:25 +02:00
|
|
|
void coin_counter_draw_content(UNK_TYPE arg0, s32 posX, s32 posY) {
|
2020-08-12 04:08:48 +02:00
|
|
|
ui_status* uiStatus = &gUIStatus;
|
2020-08-11 04:04:25 +02:00
|
|
|
s32 iconIndex;
|
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
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
|
|
|
|
2020-08-12 03:01:33 +02:00
|
|
|
void update_coin_counter(void) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
|
2020-08-12 04:08:48 +02:00
|
|
|
do {} while(0); // Needed to match
|
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
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;
|
2020-08-12 03:01:33 +02:00
|
|
|
}
|
|
|
|
D_8010CD12 = 0;
|
|
|
|
}
|
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
if (uiStatus->unk_6C[0] != 0) {
|
|
|
|
if ((uiStatus->displayCoins == playerData->coins) && (uiStatus->unk_6C[0] > 30)) {
|
|
|
|
uiStatus->unk_6C[0] = 30;
|
2020-08-12 03:01:33 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
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);
|
2020-08-14 22:10:34 +02:00
|
|
|
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;
|
2020-08-14 22:10:34 +02:00
|
|
|
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 03:01:33 +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) {
|
|
|
|
ui_status* 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;
|
|
|
|
}
|
2020-08-14 22:10:34 +02:00
|
|
|
uiStatus->unk_6C[0] = 0;
|
|
|
|
uiStatus->unk_6C[1] = 0;
|
2020-08-10 23:35:37 +02:00
|
|
|
*coinCounterUnk = 0;
|
|
|
|
D_8010CD12 = 0;
|
|
|
|
}
|
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
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);
|
2020-08-14 22:10:34 +02:00
|
|
|
uiStatus->unk_6C[0] = 0;
|
2020-08-10 23:35:37 +02:00
|
|
|
|
2020-08-14 22:10:34 +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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
2020-08-14 22:10:34 +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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
2020-08-14 22:10:34 +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-10 07:03:56 +02:00
|
|
|
s32 ShowCoinCounter(script_context* script) {
|
2020-08-09 05:46:54 +02:00
|
|
|
if (get_variable(script, *script->ptrReadPos)) {
|
|
|
|
show_coin_counter();
|
|
|
|
} else {
|
|
|
|
hide_coin_counter();
|
|
|
|
}
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
ui_status* 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;
|
2020-08-14 22:10:34 +02:00
|
|
|
uiStatus->unk_3B[0] = 1;
|
2020-08-09 05:46:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void open_status_menu_short(void) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
if (uiStatus->hidden) {
|
|
|
|
uiStatus->showTimer = 105;
|
|
|
|
uiStatus->hidden = 0;
|
2020-08-14 22:10:34 +02:00
|
|
|
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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
if (uiStatus->hidden != 1) {
|
|
|
|
uiStatus->hidden = 1;
|
|
|
|
uiStatus->showTimer = 0;
|
2020-08-14 22:10:34 +02:00
|
|
|
uiStatus->unk_3B[0] = 1;
|
2020-08-09 06:30:57 +02:00
|
|
|
}
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-09 07:23:07 +02:00
|
|
|
void func_800E97E4(void) {
|
2020-08-09 06:30:57 +02:00
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
2020-08-09 07:23:07 +02:00
|
|
|
uiStatus->drawPosY = -100;
|
2020-08-09 06:30:57 +02:00
|
|
|
uiStatus->ignoreChanges = 0;
|
2020-08-09 07:23:07 +02:00
|
|
|
uiStatus->showTimer = 0;
|
2020-08-09 06:30:57 +02:00
|
|
|
uiStatus->hidden = 1;
|
2020-08-14 22:10:34 +02:00
|
|
|
uiStatus->unk_3B[0] = 0;
|
|
|
|
uiStatus->unk_3B[1] = 0;
|
2020-08-09 07:23:07 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-09 06:30:57 +02:00
|
|
|
void func_800E9810(void) {
|
|
|
|
ui_status* 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;
|
2020-08-14 22:10:34 +02:00
|
|
|
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) {
|
2020-08-14 22:10:34 +02:00
|
|
|
gUIStatus.unk_45[0] = 0;
|
2020-08-09 06:30:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void func_800E984C(void) {
|
2020-08-14 22:10:34 +02:00
|
|
|
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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
ui_status* uiStatus2 = &gUIStatus;
|
2020-08-14 22:10:34 +02:00
|
|
|
s32 ret = 1 - uiStatus->unk_45[0];
|
2020-08-09 07:26:10 +02:00
|
|
|
|
2020-08-14 22:10:34 +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) {
|
|
|
|
ui_status* 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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
2020-08-14 22:10:34 +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) {
|
2020-08-14 22:10:34 +02:00
|
|
|
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) {
|
2020-08-14 22:10:34 +02:00
|
|
|
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) {
|
|
|
|
game_status* gameStatus = (*gGameStatusPtr);
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
ui_status* uiStatus2 = &gUIStatus;
|
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
if (gameStatus->mainScriptID == 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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
game_status* gameStatus = (*gGameStatusPtr);
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
ui_status* uiStatus2 = &gUIStatus;
|
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
if (gameStatus->mainScriptID == 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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
game_status* gameStatus = (*gGameStatusPtr);
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
ui_status* uiStatus2 = &gUIStatus;
|
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
if (gameStatus->mainScriptID == 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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
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-09 09:20:32 +02:00
|
|
|
player_data* playerData = &gPlayerData;
|
2020-08-09 05:38:42 +02:00
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
ui_status* 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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
ui_status* 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) {
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
ui_status* 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-09 09:20:32 +02:00
|
|
|
player_data* playerData = &gPlayerData;
|
2020-08-09 04:52:50 +02:00
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
|
|
|
|
uiStatus->drawPosX = 12;
|
|
|
|
uiStatus->drawPosY = -100;
|
|
|
|
uiStatus->hidden = 0;
|
|
|
|
uiStatus->showTimer = 210;
|
2020-08-14 22:10:34 +02:00
|
|
|
uiStatus->unk_3B[0] = 0;
|
2020-08-09 09:20:32 +02:00
|
|
|
uiStatus->ignoreChanges = 0;
|
2020-08-14 22:10:34 +02:00
|
|
|
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;
|
2020-08-14 22:10:34 +02:00
|
|
|
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;
|
2020-08-14 22:10:34 +02:00
|
|
|
uiStatus->unk_3B[1] = 0;
|
2020-08-09 09:20:32 +02:00
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
func_801452B4(uiStatus->hpIconIndex, uiStatus->hpIconIndex);
|
|
|
|
func_801452B4(uiStatus->heartIconIndex, uiStatus->heartIconIndex);
|
|
|
|
func_801452B4(uiStatus->fpIconIndex, uiStatus->fpIconIndex);
|
|
|
|
func_801452B4(uiStatus->flowerIconIndex, uiStatus->flowerIconIndex);
|
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.
|
2020-08-04 08:49:11 +02:00
|
|
|
INCLUDE_ASM(code_80850_len_3060, is_ability_active);
|
|
|
|
|
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-12 04:08:48 +02:00
|
|
|
player_data* 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-12 04:08:48 +02:00
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
player_data* 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-12 04:08:48 +02:00
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
player_data* 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() {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
|
|
|
|
playerData->maxStarPower++;
|
|
|
|
playerData->specialBarsFilled = playerData->maxStarPower * 256;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_max_SP(s8 newMaxSP) {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
player_data* playerData2 = &gPlayerData;
|
|
|
|
ui_status* uiStatus = &gUIStatus;
|
|
|
|
ui_status* uiStatus2 = &gUIStatus;
|
|
|
|
s32 phi_v1;
|
|
|
|
s32 blah;
|
|
|
|
|
2020-08-14 22:10:34 +02:00
|
|
|
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;
|
|
|
|
}
|
2020-08-14 22:10:34 +02:00
|
|
|
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) {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
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) {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
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) {
|
|
|
|
player_data* 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) {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
|
|
|
|
return playerData->curMaxHP == playerData->curHP;
|
|
|
|
}
|
|
|
|
|
|
|
|
s8 has_full_fp(void) {
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
|
|
|
|
return playerData->curMaxFP == playerData->curFP;
|
|
|
|
}
|
|
|
|
|
|
|
|
s8 add_fortress_keys(s32 amt) {
|
|
|
|
player_data* 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-06 07:00:11 +02:00
|
|
|
player_data* playerData = &gPlayerData;
|
2020-08-06 20:54:37 +02:00
|
|
|
player_data* 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;
|
|
|
|
}
|