2020-08-04 08:49:11 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, func_802D5B10);
|
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 FadeOutMusic(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *ptrReadPos++);
|
|
|
|
s32* ptrNextPos = ptrReadPos++;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
return (set_music_track(itemID, -1, 0, get_variable(script, *ptrNextPos++), 8) != 0) * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SetMusicTrack(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 musicPlayer = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 songID = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 variation = get_variable(script, *ptrReadPos++);
|
2020-08-12 04:45:27 +02:00
|
|
|
s16 volume = get_variable(script, *ptrReadPos++);
|
2020-08-11 23:38:21 +02:00
|
|
|
|
2020-08-12 04:45:27 +02:00
|
|
|
return (set_music_track(musicPlayer, songID, variation, 0x1F4, volume) != 0) * 2;
|
2020-08-11 23:38:21 +02:00
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, FadeInMusic);
|
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 PlayAmbientSounds(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 soundID = get_variable(script, *ptrReadPos++);
|
|
|
|
|
|
|
|
return (play_ambient_sounds(soundID, 0xFA) != 0) * 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 PlaySound(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 soundID = get_variable(script, *ptrReadPos++);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
play_sound(soundID);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 func_802D617C(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 soundID = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 value2 = get_variable(script, *ptrReadPos++);
|
|
|
|
|
|
|
|
_play_sound(soundID, value2 & 0xFF, 0, 0);
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 PlaySoundAt(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 soundID = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 value2 = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 x = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 y = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 z = get_variable(script, *ptrReadPos++);
|
|
|
|
|
2020-08-12 04:29:31 +02:00
|
|
|
play_sound_at_position(soundID, value2, x, y, z);
|
2020-08-11 23:38:21 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 StopSound(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
stop_sound(get_variable(script, *ptrReadPos++));
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 func_802D62E4(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
func_80149A6C(get_variable(script, *ptrReadPos++), 1);
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 UseDoorSounds(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
gCurrentDoorSoundsSet = get_variable(script, *ptrReadPos++);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 func_802D6340(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
|
|
|
|
D_80151308 = get_variable(script, *ptrReadPos++);
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, PlaySoundAtF);
|
|
|
|
|
2020-08-12 03:59:46 +02:00
|
|
|
s32 RemoveKeyItemAt(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 index = get_variable(script, *ptrReadPos++);
|
|
|
|
s16* ptrTemp = D_8010F304;
|
2020-08-12 04:29:31 +02:00
|
|
|
|
2020-08-12 03:59:46 +02:00
|
|
|
ptrTemp[index] = 0;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 RemoveItemAt(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 index = get_variable(script, *ptrReadPos++);
|
|
|
|
s16* ptrTemp = D_8010F444;
|
2020-08-12 04:29:31 +02:00
|
|
|
|
2020-08-12 03:59:46 +02:00
|
|
|
ptrTemp[index] = 0;
|
|
|
|
sort_items();
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-12 22:53:01 +02:00
|
|
|
s32 AddKeyItem(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 value = *ptrReadPos++;
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
s32 itemID = get_variable(script, value);
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
if (itemID == FORTRESS_KEY) {
|
|
|
|
playerData->fortressKeyCount++;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2020-08-13 07:03:47 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
|
2020-08-12 22:53:01 +02:00
|
|
|
if (playerData->keyItems[i] == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-13 00:52:55 +02:00
|
|
|
if (i < ARRAY_COUNT(playerData->keyItems)) {
|
2020-08-12 22:53:01 +02:00
|
|
|
playerData->keyItems[i] = itemID;
|
|
|
|
}
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-12 22:53:01 +02:00
|
|
|
s32 func_802D6954(void) {
|
|
|
|
func_800E01A4();
|
|
|
|
disable_player_physics();
|
|
|
|
func_800EF600();
|
2020-08-13 00:52:55 +02:00
|
|
|
D_8009A650[0] &= ~0x40;
|
2020-08-12 22:53:01 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 HasKeyItem(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 value = *ptrReadPos++;
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
s32 i;
|
|
|
|
|
2020-08-13 07:03:47 +02:00
|
|
|
for(i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
|
2020-08-12 22:53:01 +02:00
|
|
|
if (playerData->keyItems[i] == itemID) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set_variable(script, value, i < ARRAY_COUNT(playerData->keyItems));
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-12 22:53:01 +02:00
|
|
|
s32 FindKeyItem(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 value = *ptrReadPos++;
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
s32 i;
|
|
|
|
s32 itemIndex;
|
|
|
|
|
2020-08-13 07:03:47 +02:00
|
|
|
for(i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
|
2020-08-12 22:53:01 +02:00
|
|
|
if (playerData->keyItems[i] == itemID) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
itemIndex = -1;
|
|
|
|
if (i != ARRAY_COUNT(playerData->keyItems)) {
|
|
|
|
itemIndex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_variable(script, value, itemIndex);
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 AddItem(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *ptrReadPos++);
|
|
|
|
s32* ptrNextPos = *ptrReadPos++;
|
|
|
|
|
|
|
|
set_variable(script, ptrNextPos, add_item(itemID));
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 func_802D6AF0(script_context* script, s32 initialCall) {
|
|
|
|
set_variable(script, *script->ptrReadPos, 0);
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-14 04:15:33 +02:00
|
|
|
s32 FindItem(script_context* script, s32 initialCall) {
|
2020-08-14 03:43:04 +02:00
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 value = *ptrReadPos++;
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
s32 i;
|
|
|
|
s32 itemIndex;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
|
|
|
|
if (playerData->invItems[i] == itemID) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
itemIndex = -1;
|
|
|
|
if (i != ARRAY_COUNT(playerData->invItems)) {
|
|
|
|
itemIndex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_variable(script, value, itemIndex);
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-14 04:15:33 +02:00
|
|
|
s32 RemoveItem(script_context* script, s32 initialCall) {
|
2020-08-14 03:55:06 +02:00
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *ptrReadPos++);
|
|
|
|
s32 value = *ptrReadPos++;
|
|
|
|
player_data* playerData = &gPlayerData;
|
|
|
|
s32 i;
|
|
|
|
s32 itemIndex;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
|
|
|
|
if (playerData->invItems[i] == itemID) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
itemIndex = -1;
|
|
|
|
if (i != ARRAY_COUNT(playerData->invItems)) {
|
|
|
|
itemIndex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemIndex >= 0) {
|
2020-08-14 04:07:24 +02:00
|
|
|
// This is `playerData->invItems[i]`, but we have to do weird
|
|
|
|
// pointer math to get the output asm to exactly match :/
|
|
|
|
*(playerData->invItems + i) = 0;
|
2020-08-14 03:55:06 +02:00
|
|
|
}
|
|
|
|
sort_items();
|
|
|
|
|
|
|
|
set_variable(script, value, itemIndex);
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-14 04:22:25 +02:00
|
|
|
s32 CountFortressKeys(script_context* script, s32 initialCall) {
|
|
|
|
s32 outVar = *script->ptrReadPos;
|
|
|
|
|
|
|
|
set_variable(script, outVar, get_fortress_key_count());
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, RemoveFortressKeys);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, MakeItemEntity);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, DropItemEntity);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, DropItemEntityB);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, RemoveItemEntity);
|
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 AddBadge(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 itemID = get_variable(script, *ptrReadPos++);
|
|
|
|
s32* ptrNextPos = *ptrReadPos++;
|
|
|
|
|
|
|
|
set_variable(script, ptrNextPos, add_badge(itemID));
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, RemoveBadge);
|
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 SetItemPos(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
2020-08-12 03:59:46 +02:00
|
|
|
item_entity* ptrItemEntity;
|
|
|
|
s32 itemEntityIndex;
|
|
|
|
s32 x, y, z;
|
2020-08-11 23:38:21 +02:00
|
|
|
|
|
|
|
itemEntityIndex = get_variable(script, *ptrReadPos++);
|
2020-08-12 03:59:46 +02:00
|
|
|
x = get_variable(script, *ptrReadPos++);
|
|
|
|
y = get_variable(script, *ptrReadPos++);
|
|
|
|
z = get_variable(script, *ptrReadPos++);
|
2020-08-11 23:38:21 +02:00
|
|
|
|
|
|
|
ptrItemEntity = get_item_entity(itemEntityIndex);
|
2020-08-12 04:29:31 +02:00
|
|
|
ptrItemEntity->position[0] = x;
|
|
|
|
ptrItemEntity->position[1] = y;
|
|
|
|
ptrItemEntity->position[2] = z;
|
2020-08-11 23:38:21 +02:00
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, SetItemFlags);
|
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 AddCoin(script_context* script, s32 initialCall) {
|
|
|
|
script->varTable[0] = add_coins(get_variable(script, *script->ptrReadPos));
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 AddStarPoints(script_context* script, s32 initialCall) {
|
|
|
|
script->varTable[0] = add_star_points(get_variable(script, *script->ptrReadPos));
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-08-11 23:38:21 +02:00
|
|
|
s32 AddStarPieces(script_context* script, s32 initialCall) {
|
|
|
|
script->varTable[0] = add_star_pieces(get_variable(script, *script->ptrReadPos));
|
|
|
|
return 2;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, GetItemPower);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, ShowGotItem);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, func_802D7460);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, func_802D74C0);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, ShowEmote);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, RemoveEffect);
|
2020-08-11 23:38:21 +02:00
|
|
|
/*
|
|
|
|
s32 RemoveEffect(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
|
|
|
|
remove_effect(get_variable(script, *ptrReadPos++));
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 func_802D7B10(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 ptrValue = get_variable(script, *ptrReadPos++);
|
|
|
|
*ptrValue = (*ptrValue | 0x10);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 func_802D7B44(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 ptrValue = get_variable(script, *ptrReadPos++);
|
|
|
|
*((ptrValue + 0xC) + 0x14) = 10;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 func_802D7B74(script_context* script, s32 initialCall) {
|
|
|
|
s32* ptrReadPos = script->ptrReadPos;
|
|
|
|
s32 ptrValue = get_variable(script, *ptrReadPos++);
|
|
|
|
*((ptrValue + 0xC) + 0x30) = 5;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
*/
|
2020-08-04 08:49:11 +02:00
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, ShowSleepBubble);
|
|
|
|
|
|
|
|
INCLUDE_ASM(code_fa4c0_len_3bf0, PlayEffect);
|