match get_song_variation_override_for_cur_map

This was previously called get_default_variation_for_song, but its more of an override than a default.
This commit is contained in:
Alex Bates 2020-10-29 22:41:43 +00:00
parent c1df09dba8
commit db1ee14d8f
No known key found for this signature in database
GPG Key ID: 5E11C2DB78877706
8 changed files with 72 additions and 70 deletions

View File

@ -1,19 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_8004DAA8
/* 28EA8 8004DAA8 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 28EAC 8004DAAC AFBF0010 */ sw $ra, 0x10($sp)
/* 28EB0 8004DAB0 90820221 */ lbu $v0, 0x221($a0)
/* 28EB4 8004DAB4 10400007 */ beqz $v0, .L8004DAD4
/* 28EB8 8004DAB8 24020004 */ addiu $v0, $zero, 4
/* 28EBC 8004DABC A0820221 */ sb $v0, 0x221($a0)
/* 28EC0 8004DAC0 24020001 */ addiu $v0, $zero, 1
/* 28EC4 8004DAC4 AC820010 */ sw $v0, 0x10($a0)
/* 28EC8 8004DAC8 AC820008 */ sw $v0, 8($a0)
/* 28ECC 8004DACC 0C014E86 */ jal func_80053A18
/* 28ED0 8004DAD0 2484002C */ addiu $a0, $a0, 0x2c
.L8004DAD4:
/* 28ED4 8004DAD4 8FBF0010 */ lw $ra, 0x10($sp)
/* 28ED8 8004DAD8 03E00008 */ jr $ra
/* 28EDC 8004DADC 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,8 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_80053A18
/* 2EE18 80053A18 A480000A */ sh $zero, 0xa($a0)
/* 2EE1C 80053A1C AC800004 */ sw $zero, 4($a0)
/* 2EE20 80053A20 03E00008 */ jr $ra
/* 2EE24 80053A24 AC80000C */ sw $zero, 0xc($a0)

View File

@ -1,32 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel get_default_variation_for_song
/* E0B30 8014A430 0000302D */ daddu $a2, $zero, $zero
/* E0B34 8014A434 3C078009 */ lui $a3, 0x8009
/* E0B38 8014A438 24E734F0 */ addiu $a3, $a3, 0x34f0
/* E0B3C 8014A43C 3C038007 */ lui $v1, %hi(gGameStatusPtr)
/* E0B40 8014A440 2463419C */ addiu $v1, $v1, %lo(gGameStatusPtr)
/* E0B44 8014A444 3C058015 */ lui $a1, 0x8015
/* E0B48 8014A448 24A5F720 */ addiu $a1, $a1, -0x8e0
.L8014A44C:
/* E0B4C 8014A44C 8CA20000 */ lw $v0, ($a1)
/* E0B50 8014A450 1444000C */ bne $v0, $a0, .L8014A484
/* E0B54 8014A454 24C60001 */ addiu $a2, $a2, 1
/* E0B58 8014A458 8C630000 */ lw $v1, ($v1)
/* E0B5C 8014A45C 84620086 */ lh $v0, 0x86($v1)
/* E0B60 8014A460 8463008C */ lh $v1, 0x8c($v1)
/* E0B64 8014A464 00021100 */ sll $v0, $v0, 4
/* E0B68 8014A468 00471021 */ addu $v0, $v0, $a3
/* E0B6C 8014A46C 8C420004 */ lw $v0, 4($v0)
/* E0B70 8014A470 00031940 */ sll $v1, $v1, 5
/* E0B74 8014A474 00431021 */ addu $v0, $v0, $v1
/* E0B78 8014A478 9042001E */ lbu $v0, 0x1e($v0)
/* E0B7C 8014A47C 03E00008 */ jr $ra
/* E0B80 8014A480 30420001 */ andi $v0, $v0, 1
.L8014A484:
/* E0B84 8014A484 2CC20006 */ sltiu $v0, $a2, 6
/* E0B88 8014A488 1440FFF0 */ bnez $v0, .L8014A44C
/* E0B8C 8014A48C 24A50004 */ addiu $a1, $a1, 4
/* E0B90 8014A490 03E00008 */ jr $ra
/* E0B94 8014A494 2402FFFF */ addiu $v0, $zero, -1

View File

@ -260,7 +260,7 @@ typedef UNK_TYPE SpriteId;
#define SpriteId_PARADE_TWINK 0x000000E8
#define SpriteId_LEAF 0x000000E9
typedef UNK_TYPE Song;
typedef s32 SongID;
#define Song_TOAD_TOWN 0x00000000
#define Song_NORMAL_BATTLE 0x00000002
#define Song_SPECIAL_BATTLE 0x00000003

View File

@ -13,12 +13,19 @@
typedef Vec4f EntryList[];
/// Fields other than main, entryList, entryCount, background, and tattle are initialised when the map loads.
typedef struct MapConfig {
/* 0x00 */ char unk_00[0x10];
/* 0x00 */ ModelNode* modelTreeRoot;
/* 0x04 */ UNK_PTR collision;
/* 0x08 */ char unk_08[8];
/* 0x10 */ Script* main;
/* 0x14 */ EntryList* entryList;
/* 0x18 */ s32 entryCount;
/* 0x1C */ char unk_1C[0x1C];
/* 0x1C */ char unk_1C[12];
/* 0x28 */ char** modelNameList;
/* 0x2C */ char** colliderNameList;
/* 0x30 */ char** zoneNameList;
/* 0x34 */ char unk_34[4];
/* 0x38 */ BackgroundHeader* background;
/* 0x3C */ union {
MessageID msgID;
@ -26,6 +33,26 @@ typedef struct MapConfig {
} tattle;
} MapConfig; // size = 0x40
#define MAP_ID_MAX_LEN 7 ///< "xxx_yyy" excluding null terminator.
typedef struct Map {
/* 0x00 */ char* id; ///< @see MAP_ID_MAX_LEN
/* 0x04 */ MapConfig* config;
/* 0x08 */ void* dmaStart;
/* 0x0C */ void* dmaEnd;
/* 0x10 */ void* dmaDest;
/* 0x14 */ char* bgName;
/* 0x18 */ s32 (*init)(void); ///< Return TRUE to skip normal asset (shape/hit/bg/tex) loading.
/* 0x1C */ s16 flags1;
/* 0x1E */ s8 flags2;
/* 0x1F */ s8 flags3;
} Map; // size = 0x20
typedef struct Area {
/* 0x00 */ s32 mapCount;
/* 0x04 */ Map* maps;
/* 0x08 */ char* id; ///< "area_xxx"
/* 0x0C */ char* name; ///< JP debug name.
} Area; // size = 0x10
typedef struct NpcAISettings {
/* 0x00 */ f32 moveSpeed;
/* 0x04 */ s32 moveTime;
@ -218,4 +245,11 @@ typedef struct {
Enemy* get_enemy(NpcId npcId);
/// Zero-terminated.
extern Area gAreas[];
/// Lists the songs that are forced to use the variation determined by `map.flags2 & 1`.
/// @see get_song_variation_override_for_cur_map
extern SongID gSongsUsingVariationFlag[6];
#endif

View File

@ -1,8 +1,30 @@
#include "common.h"
#include "map.h"
void func_8014AC84(s16 volume);
INCLUDE_ASM(s32, "code_e0b30_len_b80", get_default_variation_for_song);
/// If the given song ID is present in gSongsUsingVariationFlag, returns the current
/// map's `flags2 & 1` value. Otherwise, returns -1.
///
/// @see gSongsUsingVariationFlag
/// @returns -1: no override; 0: override to variation 0; 1 override to variation 1
s32 get_song_variation_override_for_cur_map(SongID songID) {
u32 i = 0;
Area* areas = gAreas;
SongID* allowed = gSongsUsingVariationFlag;
GameStatus** gameStatusPtr = gGameStatusPtr;
for (i = 0; i < ARRAY_COUNT(gSongsUsingVariationFlag); i++) {
if (allowed[i] == songID) {
GameStatus* gameStatus = *gameStatusPtr;
Map* map = &areas[gameStatus->areaID].maps[gameStatus->mapID];
return map->flags2 & 1;
}
}
return -1;
}
INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014A498);
@ -13,7 +35,7 @@ void func_8014A52C(void) {
INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014A548);
s32 _set_music_track(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume) {
s32 _set_music_track(s32 playerIndex, SongID songID, s32 variation, s32 fadeOutTime, s16 volume) {
GameStatus* gameStatus = GAME_STATUS;
if (gameStatus->demoState != 0) {
@ -29,9 +51,9 @@ s32 _set_music_track(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime
return 1;
} else {
s32 defaultVariation = get_default_variation_for_song(songID);
if (defaultVariation >= 0) {
variation = defaultVariation;
s32 override = get_song_variation_override_for_cur_map(songID);
if (override >= 0) {
variation = override;
}
if (musicPlayer->songID == songID && musicPlayer->variation == variation) {
@ -57,7 +79,7 @@ s32 _set_music_track(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime
}
}
s32 set_music_track(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume) {
s32 set_music_track(s32 playerIndex, SongID songID, s32 variation, s32 fadeOutTime, s16 volume) {
MusicPlayer* musicPlayers = gMusicPlayers;
musicPlayers[playerIndex].flags &= ~8;
@ -65,7 +87,7 @@ s32 set_music_track(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime,
return _set_music_track(playerIndex, songID, variation, fadeOutTime, volume);
}
s32 func_8014A964(s32 playerIndex, s32 songID, s32 variation, s32 fadeInTime, s16 arg4, s16 arg5) {
s32 func_8014A964(s32 playerIndex, SongID songID, s32 variation, s32 fadeInTime, s16 arg4, s16 arg5) {
GameStatus* gameStatus = GAME_STATUS;
if (gameStatus->demoState != 0) {
@ -80,7 +102,7 @@ s32 func_8014A964(s32 playerIndex, s32 songID, s32 variation, s32 fadeInTime, s1
return 1;
} else {
s32 defaultVariation = get_default_variation_for_song(songID);
s32 defaultVariation = get_song_variation_override_for_cur_map(songID);
if (defaultVariation >= 0) {
variation = defaultVariation;
}

View File

@ -1904,3 +1904,5 @@ gMusicUnkVolume;0x80159AE0
gMusicUnkVolume2;0x80159AE4
gMusicTargetVolume;0x80159AE2
gMusicCurVolume;0x80159AE6
gAreas;0x800934F0
gSongArray;0x8014F720

View File

@ -267,3 +267,6 @@ EnemyNpcDefeat = 0x8007809C;
D_80078DB0 = 0x80078DB0;
D_80078DB4 = 0x80078DB4;
gAreas = 0x800934F0;
gSongsUsingVariationFlag = 0x8014F720;