split world map music file

This commit is contained in:
DizzyEggg 2025-06-11 17:18:24 +02:00
parent 7ae42259bb
commit d3597af1b3
36 changed files with 201 additions and 177 deletions

View File

@ -2,8 +2,6 @@
.align 2,0
.asciz "pksdir0"
.asciz "pksdir0"
.global gUnknown_80D4144
gUnknown_80D4144: @ 80D4144

View File

@ -2,25 +2,20 @@
#define GUARD_CODE_80118A4_H
void FadeOutAllMusic(u16);
void PlayAcceptSoundEffect(void);
void PlayCancelSoundEffect(void);
void PlayCursorUpDownSoundEffect(void);
void PlayMenuSoundEffect(u32);
void PlaySound(u16);
void StopAllMusic_1(void);
void sub_8011760(void);
void sub_80117AC(void);
void sub_801180C(void);
void sub_8011830(void);
void sub_8011860(void);
void xxx_call_fade_in_new_bgm(u16 songIndex, u16 speed);
void xxx_call_fade_out_bgm(u16 speed);
void xxx_call_fade_out_fanfare_se(u16 songIndex, u16 speed);
void xxx_call_queue_bgm(u16 songIndex);
void xxx_call_play_fanfare_se(u16 songIndex, u16 volume);
void xxx_call_start_bg_music(void);
void FadeInNewBGM_(u16 songIndex, u16 speed);
void FadeOutBGM_(u16 speed);
void FadeOutSound(u16 songIndex, u16 speed);
void QueueBGM_(u16 songIndex);
void PlaySoundWithVolume(u16 songIndex, u16 volume);
void StartBGMusic(void);
void xxx_call_start_new_bgm(u16 songIndex);
void xxx_call_stop_bgm(void);
void xxx_call_stop_fanfare_se(u16 songIndex);
void StopBGMusic(void);
void StopSound(u16 songIndex);
#endif // GUARD_CODE_80118A4_H

View File

@ -0,0 +1,9 @@
#ifndef GUARD_DUNGEON_RUN_END
#define GUARD_DUNGEON_RUN_END
#include "structs/str_dungeon.h"
void PrintOnDungeonFinishedWindow(u32 windowId, const u8 *headerText, UnkDungeonGlobal_unk1CE98_sub *param_3);
s16 sub_8094828(u16 moveID, u8 id);
#endif

View File

@ -79,7 +79,7 @@ extern const u8 *const gTacticsNames[NUM_TACTICS];
extern const u8 *const gTacticsDescriptions[NUM_TACTICS + 12];
extern const struct unkStruct_8113080 gSpecialDeathTexts[55];
extern const u8 *const gText_DeathToMove;
extern const u8 *const gUnknown_8113850;
extern const u8 *const gText_AlignPlaceX;
extern const u8 *const gText_Pokemon1WasDefeatedBy;
extern const u8 *const gText_Pokemon1;
extern const u8 *const gUnknown_8113898;
@ -94,7 +94,7 @@ extern const u8 *const gUnknown_8113974;
extern const u8 *const gUnknown_8113990;
extern const u8 *const gUnknown_81139B4;
extern const u8 *const gUnknown_81139B8;
extern const u8 *const gUnknown_81139CC;
extern const u8 *const gText_ItemAlignedX;
extern const u8 *const gFriendAreaNames[NUM_FRIEND_AREAS];
extern const u8 *const gFriendAreaDescriptions[NUM_FRIEND_AREAS];
extern const u8 *const gUnknown_8115718[100];

View File

@ -29,7 +29,7 @@ void PrintStringOnWindow(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminat
void PrintStringOnWindow2(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 lineSpacing);
bool8 sub_8008D8C(s32 windowId);
void sub_8008DC8(s32 x, s32 y, u16 bg0Val, u16 bg1Val);
s32 sub_8008ED0(const u8 *str);
s32 GetStringLineWidth(const u8 *str);
void sub_8009388(void);
void sub_8009408(s32 from, s32 to);
void sub_8009524(s32 windowId);

12
include/world_map_sound.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef GUARD_WORLD_MAP_SOUND_H
#define GUARD_WORLD_MAP_SOUND_H
void PlayFriendAreasMapBGM(void);
void PlayWorldMapBGM(void);
void FadeOutFriendAreasMapBGM(void);
void FadeOutWorldMapBGM(void);
void PlayAcceptSoundEffect(void);
void PlayCancelSoundEffect(void);
void PlayCursorUpDownSoundEffect(void);
#endif // GUARD_WORLD_MAP_SOUND_H

View File

@ -91,7 +91,8 @@ SECTIONS {
src/friend_areas_map.o(.text);
src/world_map.o(.text);
src/friend_areas_map_util.o(.text);
src/code_80118A4.o(.text);
src/world_map_sound.o(.text);
src/music_util.o(.text);
src/debug.o(.text);
src/save.o(.text);
src/save_read.o(.text);
@ -317,7 +318,7 @@ SECTIONS {
src/friend_area.o(.text);
src/moves.o(.text);
src/number_util.o(.text);
src/code_809447C.o(.text);
src/dungeon_run_end.o(.text);
src/data_serializer.o(.text);
src/game_options.o(.text);
src/random_mersenne_twister.o(.text);
@ -448,6 +449,8 @@ SECTIONS {
src/friend_areas_map.o(.rodata);
src/world_map.o(.rodata);
src/friend_areas_map_util.o(.rodata);
src/world_map_sound.o(.rodata);
src/music_util.o(.rodata);
data/data_80CE77C_2.o(.rodata);
src/debug.o(.rodata);
src/save.o(.rodata);
@ -687,7 +690,7 @@ SECTIONS {
src/friend_area.o(.rodata);
src/moves.o(.rodata);
src/number_util.o(.rodata);
src/code_809447C.o(.rodata);
src/dungeon_run_end.o(.rodata);
src/data_serializer.o(.rodata);
src/game_options.o(.rodata);
src/random_mersenne_twister.o(.rodata);

View File

@ -574,7 +574,7 @@ static void sub_801D894(void)
location = GetFriendAreaName(sUnknown_203B250->currFriendAreaLocation);
FormatString(location, buffer, buffer + sizeof(buffer), 0);
location_length = sub_8008ED0(buffer);
location_length = GetStringLineWidth(buffer);
x_coord = (128 - location_length) / 2; // Centers the location name
CallPrepareTextbox_8008C54(1);
sub_80073B8(1);

View File

@ -492,7 +492,7 @@ static bool8 sub_809CBBC(const struct ItemWithQuantity *itemToAdd, const u8 *max
if (itemGivenStr != 0) {
strcpy(gFormatBuffer_Items[0], buffer);
ScriptPrintText(0, -1, itemGivenStr);
xxx_call_play_fanfare_se(0xcb,0x100);
PlaySoundWithVolume(0xcb,0x100);
}
return TRUE;

View File

@ -6,8 +6,8 @@
#include "input.h"
#include "text_1.h"
#include "run_dungeon.h"
#include "dungeon_run_end.h"
extern void sub_8094558(u32 param_1, const u8 *param_2,UnkDungeonGlobal_unk1CE98_sub *param_3);
extern void PlayDungeonCompleteBGM(void);
extern void PlayDungeonFailBGM(void);
extern void PlayDungeonConfirmationSE(void);
@ -46,7 +46,7 @@ void ShowDungeonClearedWindow(void)
else {
PlayDungeonFailBGM();
}
sub_8094558(0, gText_TheLastOuting,&gDungeon->unk1CE98);
PrintOnDungeonFinishedWindow(0, gText_TheLastOuting,&gDungeon->unk1CE98);
while(1) {
sub_803E668(0x36);
UpdateDungeonMusic();

View File

@ -1589,7 +1589,7 @@ static void PrintOnMainMenu(bool8 printAll)
EntityInfo *leaderInfo = GetEntInfo(GetLeader());
const u8 *dungeonName = GetCurrentDungeonName();
x = (136 - sub_8008ED0(dungeonName)) / 2;
x = (136 - GetStringLineWidth(dungeonName)) / 2;
sub_80073B8(1);
PrintStringOnWindow(x, 2, dungeonName, 1, 0);
sub_80073E0(1);

View File

@ -39,6 +39,7 @@
#include "weather.h"
#include "targeting_flags.h"
#include "pokemon_types.h"
#include "dungeon_run_end.h"
extern void sub_80429C8(Entity *r0);
extern bool8 sub_8045888(Entity *r0);
@ -58,7 +59,6 @@ extern void sub_800E3AC(s32 a0, DungeonPos *pos, s32 a2);
extern void sub_8041168(Entity *entity, Entity *entity2, Move *,DungeonPos *);
extern Entity *GetMonsterAtPos(DungeonPos *pos);
extern s32 sub_800ED20(u16 param_1);
extern s16 sub_8094828(u16, u8);
struct UnkStruct_sub_800E308_1
{
s16 unk0;

View File

@ -125,7 +125,7 @@ void DungeonFadeOutBGM(u16 speed)
void DungeonStopBGM(void)
{
StopDungeonBGM();
xxx_call_stop_bgm();
StopBGMusic();
}
u16 DungeonGetCurrentBGSong(void)

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "globaldata.h"
#include "dungeon_run_end.h"
#include "structs/str_dungeon.h"
#include "data_serializer.h"
#include "dungeon_info.h"
@ -11,6 +12,8 @@
#include "text_util.h"
#include "strings.h"
#define TEXT_BUFFER_LEN 200
static void WriteDeathText(s16 moveID, u8 *buffer)
{
u16 moveID_u16;
@ -22,17 +25,17 @@ static void WriteDeathText(s16 moveID, u8 *buffer)
moveID_u16 = moveID_s32;
InitPokemonMoveOrNullObject(&move, moveID_u16);
BufferMoveName(gFormatBuffer_Items[0], &move, NULL);
FormatString(gText_DeathToMove, buffer, buffer + 200, 0); // $m0's $i0
FormatString(gText_DeathToMove, buffer, buffer + TEXT_BUFFER_LEN, 0); // $m0's $i0
} else {
strncpy(buffer, gSpecialDeathTexts[moveID - 0x1F4].text, 200);
strncpy(buffer, gSpecialDeathTexts[moveID - 0x1F4].text, TEXT_BUFFER_LEN);
}
}
static u8 sub_8094528(s16 moveID)
static bool8 WasDefeatedByMove(s16 moveID)
{
if(moveID < 0x1F4)
{
return 1;
return TRUE;
}
else
{
@ -40,20 +43,20 @@ static u8 sub_8094528(s16 moveID)
}
}
void sub_8094558(u32 param_1,u8 *param_2,UnkDungeonGlobal_unk1CE98_sub *param_3)
void PrintOnDungeonFinishedWindow(u32 windowId, const u8 *headerText, UnkDungeonGlobal_unk1CE98_sub *param_3)
{
u8 buffer [200];
u8 buffer[TEXT_BUFFER_LEN];
s32 x, y;
Item *item;
sub_80073B8(param_1);
PrintFormattedStringOnWindow(0x10,0,param_2,param_1,0);
sub_80073B8(windowId);
PrintFormattedStringOnWindow(16,0,headerText,windowId,0);
PrintYellowDungeonNametoBuffer(gFormatBuffer_Monsters[0], &param_3->dungeonLocation);
PrintFormattedStringOnWindow(4,0x10,gUnknown_8113850,param_1,0); // #+Place: $m0
y = 0x1A;
PrintFormattedStringOnWindow(4,16,gText_AlignPlaceX,windowId,0); // #+Place: $m0
y = 26;
StrncpyCustom(gFormatBuffer_Monsters[0], param_3->buffer1, POKEMON_NAME_LENGTH);
StrncpyCustom(gFormatBuffer_Monsters[1], param_3->buffer2, POKEMON_NAME_LENGTH);
if (sub_8094528(param_3->moveID) != 0) {
if (WasDefeatedByMove(param_3->moveID) != 0) {
// $m1 was defeated by
FormatString(gText_Pokemon1WasDefeatedBy,buffer, buffer + sizeof(buffer),0);
}
@ -62,62 +65,62 @@ void sub_8094558(u32 param_1,u8 *param_2,UnkDungeonGlobal_unk1CE98_sub *param_3)
FormatString(gText_Pokemon1,buffer, buffer + sizeof(buffer),0);
}
x = (0xb0 - sub_8008ED0(buffer)) / 2;
PrintFormattedStringOnWindow(x,y,buffer,param_1,0);
x = (176 - GetStringLineWidth(buffer)) / 2;
PrintFormattedStringOnWindow(x,y,buffer,windowId,0);
y += 0xA;
y += 10;
WriteDeathText(param_3->moveID, buffer);
x = (0xb0 - sub_8008ED0(buffer)) / 2;
PrintFormattedStringOnWindow(x,y,buffer,param_1,0);
x = (176 - GetStringLineWidth(buffer)) / 2;
PrintFormattedStringOnWindow(x,y,buffer,windowId,0);
y += 0x10;
y += 16;
gFormatArgs[0] = param_3->exp;
gFormatArgs[1] = param_3->level;
if (gFormatArgs[1] >= 100) {
PrintFormattedStringOnWindow(4,y,gUnknown_81138C0,param_1,0);
PrintFormattedStringOnWindow(4,y,gUnknown_81138C0,windowId,0);
}
else {
PrintFormattedStringOnWindow(4,y,gUnknown_8113898,param_1,0);
PrintFormattedStringOnWindow(4,y,gUnknown_8113898,windowId,0);
}
y += 0xA;
y += 10;
gFormatArgs[0] = param_3->maxHPStat;
PrintFormattedStringOnWindow(4,y,gUnknown_81138D0,param_1,0);
y += 0xA;
PrintFormattedStringOnWindow(4,y,gUnknown_81138D0,windowId,0);
y += 10;
gFormatArgs[0] = param_3->atk;
gFormatArgs[1] = param_3->def;
if (param_3->attBoost) {
gFormatArgs[0] = gFormatArgs[0] + param_3->attBoost;
PrintFormattedStringOnWindow(4,y,gUnknown_8113950,param_1,0);
PrintFormattedStringOnWindow(4,y,gUnknown_8113950,windowId,0);
}
else {
PrintFormattedStringOnWindow(4,y,gUnknown_81138E4,param_1,0);
PrintFormattedStringOnWindow(4,y,gUnknown_81138E4,windowId,0);
}
if (param_3->defBoost) {
gFormatArgs[1] = gFormatArgs[1] + param_3->defBoost;
PrintFormattedStringOnWindow(4,y,gUnknown_8113974,param_1,0);
PrintFormattedStringOnWindow(4,y,gUnknown_8113974,windowId,0);
}
else {
PrintFormattedStringOnWindow(4,y,gUnknown_8113900,param_1,0);
PrintFormattedStringOnWindow(4,y,gUnknown_8113900,windowId,0);
}
y += 0xA;
y += 10;
gFormatArgs[0] = param_3->spAtk;
gFormatArgs[1] = param_3->spDef;
if (param_3->spAttBoost) {
gFormatArgs[0] = gFormatArgs[0] + param_3->spAttBoost;
PrintFormattedStringOnWindow(4,y,gUnknown_8113990,param_1,0);
PrintFormattedStringOnWindow(4,y,gUnknown_8113990,windowId,0);
}
else {
PrintFormattedStringOnWindow(4,y,gUnknown_8113918,param_1,0);
PrintFormattedStringOnWindow(4,y,gUnknown_8113918,windowId,0);
}
if (param_3->spDefBoost) {
gFormatArgs[1] = gFormatArgs[1] + param_3->spDefBoost;
PrintFormattedStringOnWindow(4,y,gUnknown_81139B4,param_1,0);
PrintFormattedStringOnWindow(4,y,gUnknown_81139B4,windowId,0);
}
else {
PrintFormattedStringOnWindow(4,y,gUnknown_8113934,param_1,0);
PrintFormattedStringOnWindow(4,y,gUnknown_8113934,windowId,0);
}
y += 0x10;
y += 16;
item = &(param_3->heldItem);
if ((param_3->heldItem.flags & ITEM_FLAG_EXISTS)) {
sub_8090E14(gFormatBuffer_Items[0],item,0);
@ -125,8 +128,8 @@ void sub_8094558(u32 param_1,u8 *param_2,UnkDungeonGlobal_unk1CE98_sub *param_3)
else {
strcpy(gFormatBuffer_Items[0],gUnknown_81139B8);
}
PrintFormattedStringOnWindow(4,y,gUnknown_81139CC,param_1,0);
sub_80073E0(param_1);
PrintFormattedStringOnWindow(4,y,gText_ItemAlignedX,windowId,0);
sub_80073E0(windowId);
}
s16 sub_8094828(u16 moveID, u8 id)

View File

@ -21,6 +21,7 @@
#include "string_format.h"
#include "text_1.h"
#include "text_3.h"
#include "world_map_sound.h"
EWRAM_INIT struct FriendAreasMap *gFriendAreasMapPtr = NULL;
EWRAM_DATA static u8 sCurrDirection = 0;
@ -50,7 +51,7 @@ void ShowFriendAreasMap_Async(struct FriendAreasMapSetupStruct *setupPtr)
gFriendAreasMapPtr->locationIdOnBPress = gFriendAreasMapPtr->teamBaseLocationId;
sCurrDirection = 0xff;
sHeldDpadCounter = 0;
sub_8011760();
PlayFriendAreasMapBGM();
while (TRUE) {
s32 newLocationId = 0;
@ -162,7 +163,7 @@ static void FriendAreasMap_FadeOut_Async(void)
s32 i;
FriendAreasMap_HideTextWindowAndArrows();
sub_80117AC();
FadeOutFriendAreasMapBGM();
for (i = 0; i < 60; i++) {
gFriendAreasMapPtr->brightness -= 2;

View File

@ -1010,7 +1010,7 @@ void sub_8032828(void)
}
}
}
xxx_call_start_bg_music();
StartBGMusic();
break;
case 0x10:
CreateDialogueBoxAndPortrait(&gUnknown_80E2F14[0], 0, 0, 0x101);
@ -1125,7 +1125,7 @@ void sub_8032828(void)
break;
}
}
xxx_call_start_bg_music();
StartBGMusic();
break;
case 0x72:
CreateDialogueBoxAndPortrait(gUnknown_80E311C, 0, 0, 0x101);

View File

@ -127,7 +127,7 @@ void DeleteGroundLives(void);
void DeleteGroundObjects(void);
void DeleteGroundEffects(void);
s32 ExecuteScriptCommand(Action *action);
bool8 IsFanfareSEPlaying_1(u16 songIndex);
bool8 IsSoundPlaying(u16 songIndex);
bool8 IsEqualtoBGTrack(u16 songIndex);
bool8 sub_8099B94(void);
PixelPos SetVecFromDirectionSpeed(s8, s32);
@ -664,7 +664,7 @@ s16 HandleAction(Action *action, DebugLocation *debug)
}
case 0xe1: case 0xe2: {
cmd = *action->scriptData.curPtr;
if (IsFanfareSEPlaying_1(cmd.argShort)) {
if (IsSoundPlaying(cmd.argShort)) {
if (action->scriptData.unk2C++ < 3600) {
loopContinue = FALSE;
}
@ -2037,44 +2037,44 @@ s32 ExecuteScriptCommand(Action *action)
if (id != 999) {
xxx_call_start_new_bgm((u16)id);
} else {
xxx_call_stop_bgm();
StopBGMusic();
}
break;
}
case 0x45: {
u16 id = curCmd.argByte == 0 ? sub_80A25AC((u16)curCmd.arg1) : curCmd.arg1;
if (id != 999) {
xxx_call_fade_in_new_bgm((u16)id, (u16)curCmd.argShort); //sub_8011900
FadeInNewBGM_((u16)id, (u16)curCmd.argShort); //sub_8011900
} else {
xxx_call_stop_bgm();
StopBGMusic();
}
break;
}
case 0x46: {
u16 id = curCmd.argByte == 0 ? sub_80A25AC((u16)curCmd.arg1) : curCmd.arg1;
if (id != 999) {
xxx_call_queue_bgm((u16)id);
QueueBGM_((u16)id);
}
break;
}
case 0x47: {
xxx_call_stop_bgm();
StopBGMusic();
break;
}
case 0x48: {
xxx_call_fade_out_bgm(curCmd.argShort < 0 ? 30 : (u16)curCmd.argShort);
FadeOutBGM_(curCmd.argShort < 0 ? 30 : (u16)curCmd.argShort);
break;
}
case 0x49: case 0x4c: {
xxx_call_play_fanfare_se((u16)curCmd.arg1, 256);
PlaySoundWithVolume((u16)curCmd.arg1, 256);
break;
}
case 0x4a: case 0x4d: {
xxx_call_stop_fanfare_se((u16)curCmd.arg1);
StopSound((u16)curCmd.arg1);
break;
}
case 0x4b: case 0x4e: {
xxx_call_fade_out_fanfare_se((u16)curCmd.arg1, curCmd.argShort < 0 ? 30 : (u16)curCmd.argShort);
FadeOutSound((u16)curCmd.arg1, curCmd.argShort < 0 ? 30 : (u16)curCmd.argShort);
break;
}
case 0x4f: {
@ -3849,7 +3849,7 @@ s32 sub_80A14E8(Action *action, u8 idx, u32 r2, s32 r3)
case 0x45:
if (gUnknown_2039DA8 != STOP_BGM)
{
xxx_call_fade_in_new_bgm(gUnknown_2039DA8, r2);
FadeInNewBGM_(gUnknown_2039DA8, r2);
gUnknown_2039DA8 = STOP_BGM;
return 1;
}
@ -3857,7 +3857,7 @@ s32 sub_80A14E8(Action *action, u8 idx, u32 r2, s32 r3)
case 0x46:
if (gUnknown_2039DA8 != STOP_BGM)
{
xxx_call_queue_bgm(gUnknown_2039DA8);
QueueBGM_(gUnknown_2039DA8);
gUnknown_2039DA8 = STOP_BGM;
return 1;
}

View File

@ -232,7 +232,7 @@ static void UpdateLuminousCaveDialogue(void)
break;
case LUMINOUS_CAVE_SHALL_RETURN:
sLuminousCaveWork->fallbackState = 4;
xxx_call_fade_in_new_bgm(MUS_FILE_SELECT,0x3c);
FadeInNewBGM_(MUS_FILE_SELECT,0x3c);
CreateDialogueBoxAndPortrait(sYeShallReturn,0,0,0x305);
break;
case LUMINOUS_CAVE_GIVE_ITEM_1:
@ -297,7 +297,7 @@ static void UpdateLuminousCaveDialogue(void)
sLuminousCaveWork->fallbackState = LUMINOUS_CAVE_LACK_ITEM;
else
sLuminousCaveWork->fallbackState = LUMINOUS_CAVE_CANT_EVOLVE_YET;
xxx_call_fade_out_bgm(0x3c);
FadeOutBGM_(0x3c);
CreateDialogueBoxAndPortrait(sLetUsBegin,0,0,0x105);
break;
case LUMINOUS_CAVE_CHANGED_APPEARANCE:
@ -323,7 +323,7 @@ static void UpdateLuminousCaveDialogue(void)
ClearItemSlotAt(sLuminousCaveWork->evoItem2_InvIndex);
}
FillInventoryGaps();
xxx_call_stop_fanfare_se(0x1ff);
StopSound(0x1ff);
PlaySound(0xd2);
if (sLuminousCaveWork->pokeRenamed) {
BoundedCopyStringtoBuffer(sLuminousCaveWork->pokeStruct->name,GetMonSpecies(sLuminousCaveWork->pokeStruct->speciesNum),POKEMON_NAME_LENGTH);
@ -364,7 +364,7 @@ static void UpdateLuminousCaveDialogue(void)
CreateDialogueBoxAndPortrait(sCannotEvolveYet,0,0,0x105);
break;
case LUMINOUS_CAVE_PROMPT_NAME:
xxx_call_fade_in_new_bgm(8,0x3c);
FadeInNewBGM_(8,0x3c);
sLuminousCaveWork->fallbackState = LUMINOUS_CAVE_FINISH_NAME;
CreateDialogueBoxAndPortrait(sMustGiveName,0,0,0x105);
break;

View File

@ -911,7 +911,7 @@ static void LoadAndRunQuickSaveDungeon_Async(DungeonSetupStruct *setupStr)
else
sub_80121E0(0xF1209);
xxx_call_start_bg_music();
StartBGMusic();
}
else {
GeneratePelipperJobs();
@ -933,7 +933,7 @@ static void LoadAndRunQuickSaveDungeon_Async(DungeonSetupStruct *setupStr)
if (setupStr->info.unk7C == 3 || setupStr->info.unk7C == -2) {
SetDungeonLocationInfo(&setupStr->info.unk80);
xxx_call_stop_bgm();
StopBGMusic();
if (setupStr->info.unk7C == -2)
PrepareQuickSaveWrite(setupStr->info.unk74, local_1c, 1);

View File

@ -232,7 +232,7 @@ void sub_8012CAC(WindowTemplate *a0, const MenuItem *a1)
for (; a1->text != NULL; a1++) {
count = (s16)(count + 1); // Because a simple `count++;` wasn't enough.
length = (s16) sub_8008ED0(a1->text);
length = (s16) GetStringLineWidth(a1->text);
if (length > maxLength) {
maxLength = length;
}
@ -397,7 +397,7 @@ void sub_8012EBC(MenuStruct *param_1)
if (window->type == WINDOW_TYPE_WITH_HEADER) {
WindowTemplate *windowTemplate = &winTemplates.id[index];
RestoreSavedWindows(&winTemplates);
x = sub_8008ED0(param_1->unk0);
x = GetStringLineWidth(param_1->unk0);
PrintFormattedStringOnWindow(((windowTemplate->header->width * 8 - x) / 2) + 8, 0, param_1->unk0, param_1->index, 0);
}

View File

@ -586,14 +586,14 @@ void UpdateSound(void)
else if (sBGMusicPlayerstate != BG_PLAYER_STATE_INITIALIZE) {
switch (sBGMusicPlayerstate) {
case BG_PLAYER_STATE_PLAYING:
if (sCurrentBGSong == STOP_BGM || IsMusicPlayerPlaying(INDEX_BGM)) // INDEX_BGM
if (sCurrentBGSong == STOP_BGM || IsMusicPlayerPlaying(INDEX_BGM))
sBGMusicPlayerstate = 2;
break;
case 2:
case 3:
if (sCurrentBGSong != STOP_BGM) {
if (IsMusicPlayerPlaying(INDEX_BGM))
break; // INDEX_BGM
break;
}
else
m4aMPlayStop(&gMPlayInfo_BGM);

View File

@ -1,64 +1,15 @@
#include "global.h"
#include "structs/axdata.h"
#include "graphics_memory.h"
#include "globaldata.h"
#include "code_80118A4.h"
#include "music.h"
#include "constants/bg_music.h"
#include "config.h"
#include "event_flag.h"
#include "file_system.h"
extern const u16 gUnknown_80D4144[8];
EWRAM_DATA u32 gUnknown_202DE1C = {0}; // R=202DE1C | B=2134218
EWRAM_DATA s16 gUnknown_202DE20 = {0}; // R=202DE20 | B=213420C
EWRAM_DATA s16 gUnknown_202DE22 = {0}; // R=202DE22 | B=2134210
EWRAM_DATA s16 gUnknown_202DE24 = {0}; // R=202DE24 | B=2134214
void sub_8011760(void)
{
if (sub_80023E4(13))
StartNewBGM(MUS_WORLD_CALAMITY);
else if (sub_80023E4(12))
StartNewBGM(MUS_POKEMON_SQUARE);
}
void sub_801178C(void)
{
if (sub_80023E4(13))
StartNewBGM(MUS_WORLD_CALAMITY);
else
StartNewBGM(MUS_POKEMON_SQUARE);
}
void sub_80117AC(void)
{
if (!sub_80023E4(13))
FadeOutBGM(30);
}
void sub_80117C4(void)
{
FadeOutBGM(30);
}
// When you press A on a menu
void PlayAcceptSoundEffect(void)
{
PlayFanfareSE(302, MAX_VOLUME);
}
// When you press B on a menu
void PlayCancelSoundEffect(void)
{
PlayFanfareSE(303, MAX_VOLUME);
}
// When you go up or down
void PlayCursorUpDownSoundEffect(void)
{
PlayFanfareSE(301, MAX_VOLUME);
}
static EWRAM_DATA u32 gUnknown_202DE1C = {0}; // R=202DE1C | B=2134218
static EWRAM_DATA s16 gUnknown_202DE20 = {0}; // R=202DE20 | B=213420C
static EWRAM_DATA s16 gUnknown_202DE22 = {0}; // R=202DE22 | B=2134210
static EWRAM_DATA s16 gUnknown_202DE24 = {0}; // R=202DE24 | B=2134214
void sub_801180C(void)
{
@ -76,7 +27,7 @@ void sub_8011830(void)
gUnknown_202DE24 = 0;
}
void xxx_call_start_bg_music(void)
void StartBGMusic(void)
{
StartBGMusicVSync();
}
@ -96,9 +47,9 @@ void sub_8011860(void)
void StopAllMusic_1(void)
{
xxx_call_stop_bgm();
xxx_call_stop_fanfare_se(STOP_FANFARE);
xxx_call_stop_fanfare_se(STOP_SOUND_EFFECT);
StopBGMusic();
StopSound(STOP_FANFARE);
StopSound(STOP_SOUND_EFFECT);
}
void FadeOutAllMusic(u16 speed)
@ -113,22 +64,22 @@ void xxx_call_start_new_bgm(u16 songIndex)
StartNewBGM(songIndex);
}
void xxx_call_fade_in_new_bgm(u16 songIndex, u16 speed)
void FadeInNewBGM_(u16 songIndex, u16 speed)
{
FadeInNewBGM(songIndex, speed);
}
void xxx_call_queue_bgm(u16 songIndex)
void QueueBGM_(u16 songIndex)
{
QueueBGM(songIndex);
}
void xxx_call_stop_bgm()
void StopBGMusic(void)
{
StopBGM();
}
void xxx_call_fade_out_bgm(u16 speed)
void FadeOutBGM_(u16 speed)
{
FadeOutBGM(speed);
}
@ -143,7 +94,7 @@ bool8 IsEqualtoBGTrack(u16 songIndex)
return currBGSong == songIndex;
}
void xxx_call_play_fanfare_se(u16 songIndex, u16 volume)
void PlaySoundWithVolume(u16 songIndex, u16 volume)
{
PlayFanfareSE(songIndex, volume);
}
@ -154,17 +105,17 @@ void PlaySound(u16 songIndex)
PlayFanfareSE(songIndex, MAX_VOLUME);
}
void xxx_call_stop_fanfare_se(u16 songIndex)
void StopSound(u16 songIndex)
{
StopFanfareSE(songIndex);
}
void xxx_call_fade_out_fanfare_se(u16 songIndex, u16 speed)
void FadeOutSound(u16 songIndex, u16 speed)
{
FadeOutFanfareSE(songIndex, speed);
}
bool8 IsFanfareSEPlaying_1(u16 songIndex)
bool8 IsSoundPlaying(u16 songIndex)
{
return IsFanfareSEPlaying(songIndex);
}

View File

@ -111,15 +111,15 @@ static void CreateOptionsMenu(void)
switch (sUnknown_203B260->optionsMenu->windowColor) {
case WINDOW_COLOR_BLUE:
length = sub_8008ED0(sBlue);
length = GetStringLineWidth(sBlue);
AddDoubleUnderScoreHighlight(sUnknown_203B260->unk44, (sUnknown_203B260->optionsMenu->windowColor * 40) + 80, y + 10, length, COLOR_WHITE_2);
break;
case WINDOW_COLOR_RED:
length = sub_8008ED0(sRed);
length = GetStringLineWidth(sRed);
AddDoubleUnderScoreHighlight(sUnknown_203B260->unk44, (sUnknown_203B260->optionsMenu->windowColor * 40) + 80, y + 10, length, COLOR_WHITE_2);
break;
case WINDOW_COLOR_GREEN:
length = sub_8008ED0(sGreen);
length = GetStringLineWidth(sGreen);
AddDoubleUnderScoreHighlight(sUnknown_203B260->unk44, (sUnknown_203B260->optionsMenu->windowColor * 40) + 80, y + 10, length, COLOR_WHITE_2);
break;
}

View File

@ -326,7 +326,7 @@ static void sub_8037400(void)
}
}
xxx_call_start_bg_music();
StartBGMusic();
}
static void sub_80376CC(void)

View File

@ -783,7 +783,7 @@ void sub_8026E08(u32 r0)
StrncpyCustom(gFormatBuffer_Monsters[0], sUnknown_203B2B8->pokeStruct->name, POKEMON_NAME_LENGTH);
sub_808D930(buffer, sUnknown_203B2B8->pokeStruct->speciesNum);
sprintfStatic(buffer1, sUnknown_80DD6E0, gFormatBuffer_Monsters[0]);
x = sub_8008ED0(buffer1);
x = GetStringLineWidth(buffer1);
PrintStringOnWindow(((sUnknown_80DD370.width << 3) - x) / 2, 3, buffer1, r0, 0);
sub_80073E0(r0);
}

View File

@ -406,7 +406,7 @@ u32 sub_8012240(void)
MemoryFill8(r5, 0xFF, 0x4);
sub_8011830();
status = WriteFlashData(0x1F, (u8 *)r5, sizeof(struct unk_struct));
xxx_call_start_bg_music();
StartBGMusic();
MemoryFree(r5);
if (status != 0)
return SAVE_FAILED;

View File

@ -39,7 +39,7 @@ void sub_80140F8(void)
}
void sub_8014114(void) {
xxx_call_start_bg_music();
StartBGMusic();
SetSavingIconCoords(NULL);
}
@ -611,7 +611,7 @@ static void sub_8014A88(void)
r5 += 12;
FormatString(menuItem->text, text, text + sizeof(text), 0);
val = sub_8008ED0(text);
val = GetStringLineWidth(text);
if (r7 < val) {
r7 = val;
}

View File

@ -918,7 +918,7 @@ const struct unkStruct_8113080 gSpecialDeathTexts[55] = {
};
const u8 *const gText_DeathToMove = _("{POKEMON_0}'s {MOVE_ITEM_0}.");
const u8 *const gUnknown_8113850 = _("{CENTER_ALIGN}Place: {POKEMON_0}");
const u8 *const gText_AlignPlaceX = _("{CENTER_ALIGN}Place: {POKEMON_0}");
const u8 *const gText_Pokemon1WasDefeatedBy = _("{POKEMON_1} was defeated by");
const u8 *const gText_Pokemon1 = _("{POKEMON_1}");
const u8 *const gUnknown_8113898 = _("Level {UNK_MACRO_3E M3E_42}{VALUE_1}{UNK_MACRO_3E M3E_64}Exp. Pts. {VALUE_0} ");
@ -933,7 +933,7 @@ const u8 *const gUnknown_8113974 = _("{UNK_MACRO_3E M3E_80}Defense{UNK_MACRO_3E
const u8 *const gUnknown_8113990 = _("Sp. Atk.{UNK_MACRO_3E M3E_42}{color RED}{VALUE_0}{reset} ");
const u8 *const gUnknown_81139B4 = _("{UNK_MACRO_3E M3E_80}Sp. Def.{UNK_MACRO_3E M3E_128}{color RED}{VALUE_1}{reset} ");
const u8 *const gUnknown_81139B8 = _("None");
const u8 *const gUnknown_81139CC = _("Item:{UNK_MACRO_3E M3E_42}{MOVE_ITEM_0} ");
const u8 *const gText_ItemAlignedX = _("Item:{UNK_MACRO_3E M3E_42}{MOVE_ITEM_0} ");
const u8 *const gFriendAreaNames[NUM_FRIEND_AREAS] = {
[FRIEND_AREA_NONE] = _("None"),
[BOUNTIFUL_SEA] = _("Bountiful Sea"),

View File

@ -82,7 +82,7 @@ UNUSED static void sub_8008E58(s32 a0, s32 a1, u8 *a2, s32 a3)
#endif
// arm9.bin::02003B34
s32 sub_8008ED0(const u8 *str)
s32 GetStringLineWidth(const u8 *str)
{
s32 ret = 0;
@ -316,7 +316,7 @@ static const u8 *HandleTextFormat(Window *windows, const u8 *str, UnkDrawStringS
}
else if (str[1] == '+') {
str += 2;
sp->x = (windows[0].width * 8) - sub_8008ED0(str);
sp->x = (windows[0].width * 8) - GetStringLineWidth(str);
sp->x /= 2;
}
else if (str[1] == 'C') {

View File

@ -1322,7 +1322,7 @@ void UpdateThankYouMailText(void)
}
}
}
xxx_call_start_bg_music();
StartBGMusic();
break;
case PROMPT_THANK_YOU_PASSWORD:
// OK. Please enter the Thank-You Mail Password

View File

@ -557,7 +557,7 @@ void sub_8036B28(void)
if(sTradeItemsMenu->linkStatus == COMMS_GOOD && sTradeItemsMenu->itemMode <= 1){
sTradeItemsMenu->linkStatus = sub_80381F4(sTradeItemsMenu->itemMode,&sTradeItemsMenu->unk244,&sTradeItemsMenu->unk24C);
}
xxx_call_start_bg_music();
StartBGMusic();
break;
case 0xe:
if (sTradeItemsMenu->unk24C.quantity == 0) {

View File

@ -545,11 +545,11 @@ void sub_8028348(void)
break;
}
}
xxx_call_start_bg_music();
StartBGMusic();
}
else
{
xxx_call_start_bg_music();
StartBGMusic();
}
break;
case RECEIVED_FRIEND_SOS_MAIL:

View File

@ -553,7 +553,7 @@ void WonderMailMainMenuCallback(void)
}
}
}
xxx_call_start_bg_music();
StartBGMusic();
break;
case PROMPT_PASSWORD_ENTRY:
CreateDialogueBoxAndPortrait(gUnknown_80E7C98,0,0,0x101);

View File

@ -8,6 +8,7 @@
#include "code_800C9CC.h"
#include "code_800D090.h"
#include "code_80118A4.h"
#include "world_map_sound.h"
#include "decompress_at.h"
#include "decompress_sir.h"
#include "def_filearchives.h"
@ -25,8 +26,6 @@
#include "text_3.h"
#include "world_map.h"
extern void sub_801178C(void);
extern void sub_80117C4(void);
extern void WaitForNextFrameAndAdvanceRNG(void);
extern void CopyDungeonName1toBuffer(u8 *buffer, DungeonLocation *dungeonLocation);
@ -81,7 +80,7 @@ void ShowWorldMap_Async(struct WorldMapSetupStruct *setupPtr)
UpdateFadeInTile(2);
sub_801059C();
sub_8010494(&setupPtr->info);
sub_801178C();
PlayWorldMapBGM();
// 60 frame delay
for (i = 0; i < 60; i++)
@ -386,7 +385,7 @@ static void FadeFromWorldMap_Async(void)
s32 i;
ClearWindows();
sub_80117C4();
FadeOutWorldMapBGM();
for (i = 0; i < 60; i++) {
sWorldMapPtr->brightness -= 2;
WorldMap_RunFrameActions();

53
src/world_map_sound.c Normal file
View File

@ -0,0 +1,53 @@
#include "global.h"
#include "globaldata.h"
#include "world_map_sound.h"
#include "music.h"
#include "constants/bg_music.h"
#include "event_flag.h"
// Also used for the friend areas map.
void PlayFriendAreasMapBGM(void)
{
if (sub_80023E4(13))
StartNewBGM(MUS_WORLD_CALAMITY);
else if (sub_80023E4(12))
StartNewBGM(MUS_POKEMON_SQUARE);
}
void PlayWorldMapBGM(void)
{
if (sub_80023E4(13))
StartNewBGM(MUS_WORLD_CALAMITY);
else
StartNewBGM(MUS_POKEMON_SQUARE);
}
void FadeOutFriendAreasMapBGM(void)
{
if (!sub_80023E4(13))
FadeOutBGM(30);
}
void FadeOutWorldMapBGM(void)
{
FadeOutBGM(30);
}
// When you press A on a menu
void PlayAcceptSoundEffect(void)
{
PlayFanfareSE(302, MAX_VOLUME);
}
// When you press B on a menu
void PlayCancelSoundEffect(void)
{
PlayFanfareSE(303, MAX_VOLUME);
}
// When you go up or down
void PlayCursorUpDownSoundEffect(void)
{
PlayFanfareSE(301, MAX_VOLUME);
}

View File

@ -19,7 +19,7 @@
.space 4
.include "src/code_800D090.o"
.include "src/friend_areas_map.o"
.include "src/code_80118A4.o"
.include "src/music_util.o"
.include "src/save.o"
.space 4
.include "src/string_format.o"