audio odyssey (#744)

* first pass

* seq cmd args retyping

* some SEF commands

* etc

* couple more SND commands

* more functions

* checkpoint

* five more

* another one

* more funcs + cleanup

* reverted unnecessary unions

* all SEF commands done

* a bunch more

* more!

* morrrrrrre

* almost done for now

* 99%

* 100

* few names and types

* reorg

* minor chnages

* miscmiscmisc

* yet more

* another day another func

* eth wip func_8004EC68

* some sym names

* retyping sound mgr fields

* minor renames

* D_80078400

* bigger func

* retypings

* enhanced drum info

* the evil is defeated

* merged

* prelim ambient sound func names

* audio frame

* checkpoint

* renames

* learnin bout sounds

* latest

* fix snd_load_BK_to_bank

* func_80056FA4

* warnings

* cosmetics

* func_800522A8

* struct reorg

* figured some stuff out

* much more info

* fx params

* cleanin up

* revert accidental changes to jp

* more accidental jp changes reverted

* misc names

* small stuff

* migrated all audio data

* checkpoint

* header reorg begins

* audio public/private headers

* fixed headers

* fixin warnins

* oops

* 51 fixed

* formatted binary data in 30450

* workwork

* cleanup

* misc

* flip macro arg order

* more names

* audio event triggers

* various

* sfx player cleanup

* start bgm player cleanup

* names names names

* priorities

* merlow

* misc enum vals

* rocking chair

* kmr_00 funcs

* enough

* restore delete jp file

* func_80055EB4

* fix func name

* addressed comments

* demoted a couple variables from global

* couple hidden panel things

* credits mostly

* credits dedupe in progress

* jump table repair

* 'finished' end dedupe

Co-authored-by: HailSanta <Hail2Santa@gmail.com>
Co-authored-by: Ethan Roseman <ethteck@gmail.com>
This commit is contained in:
HailSanta 2022-08-06 08:14:04 -04:00 committed by GitHub
parent ae64b1b5cc
commit 1ce49b1ba9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
406 changed files with 13278 additions and 23250 deletions

115
include/PR/n_abi.h Normal file
View File

@ -0,0 +1,115 @@
/*====================================================================
*
* Copyright 1993, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
#ifndef __N_ABI__
#define __N_ABI__
/*
* BEGIN C-specific section: (typedef's)
*/
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
/*
* Macros to assemble the audio command list
*/
#define n_aADPCMdec(pkt, s, f, c, a, d) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = (_SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(s, 0, 24)); \
_a->words.w1 = (_SHIFTL(f, 28, 4) | _SHIFTL(c, 16, 12) | \
_SHIFTL(a, 12, 4) | _SHIFTL(d, 0, 12)); \
}
#define n_aPoleFilter(pkt, f, g, t, s) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \
_SHIFTL(g, 0, 16)); \
_a->words.w1 = (_SHIFTL(t, 24, 8) | \
_SHIFTL((unsigned int)(s), 0, 24)); \
}
#define n_aEnvMixer(pkt, f, t, s) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = (_SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8) |\
_SHIFTL(t, 0, 16)); \
_a->words.w1 = (unsigned int)(s); \
}
#define n_aInterleave(pkt) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \
}
#define n_aLoadBuffer(pkt, c, d, s) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = (_SHIFTL(A_LOADBUFF, 24, 8) | _SHIFTL(c, 12, 12)|\
_SHIFTL(d, 0, 12)); \
_a->words.w1 = (unsigned int)(s); \
}
#define n_aResample(pkt, s, f, p, i, o) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(s, 0, 24));\
_a->words.w1 = (_SHIFTL(f, 30, 2) | _SHIFTL(p, 14, 16) | \
_SHIFTL(i, 2, 12) | _SHIFTL(o, 0, 2)); \
}
#define n_aSaveBuffer(pkt, c, d, s) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = (_SHIFTL(A_SAVEBUFF, 24, 8) | _SHIFTL(c, 12, 12)|\
_SHIFTL(d, 0, 12)); \
_a->words.w1 = (unsigned int)(s); \
}
#define n_aSetVolume(pkt, f, v, t, r) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 8) | \
_SHIFTL(v, 0, 16)); \
_a->words.w1 = _SHIFTL(t, 16, 16) | _SHIFTL(r, 0, 16); \
}
#define n_aLoadADPCM(pkt, c, d) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \
_a->words.w1 = (unsigned int) d; \
}
#endif /* _LANGUAGE_C */
#endif /* __N_ABI__ */

View File

@ -13,6 +13,12 @@ typedef ApiStatus(*ApiFunc)(struct Evt*, s32);
typedef Bytecode EvtScript[0]; typedef Bytecode EvtScript[0];
typedef void NoArgCallback(void*);
#define MSG_PTR u8*
#define IMG_PTR u8*
#define PAL_PTR u16*
typedef struct { typedef struct {
u8 r, g, b, a; u8 r, g, b, a;
} Color_RGBA8; } Color_RGBA8;
@ -560,21 +566,29 @@ typedef DynamicEntity* DynamicEntityList[MAX_DYNAMIC_ENTITIES];
typedef struct MusicSettings { typedef struct MusicSettings {
/* 0x00 */ u16 flags; /* 0x00 */ u16 flags;
/* 0x02 */ s16 unk_02; /* 0x02 */ s16 state;
/* 0x04 */ s32 fadeOutTime; /* 0x04 */ s32 fadeOutTime;
/* 0x08 */ s32 fadeInTime; /* 0x08 */ s32 fadeInTime;
/* 0x0C */ s16 unk_0C; /* 0x0C */ s16 fadeStartVolume;
/* 0x0E */ s16 unk_0E; /* 0x0E */ s16 fadeEndVolume;
/* 0x10 */ s32 songID; /* 0x10 */ s32 songID;
/* 0x14 */ s32 variation; /* 0x14 */ s32 variation;
/* 0x18 */ s32 songName; /* 0x18 */ s32 songName;
/* 0x1C */ s32 unk_1C; /* 0x1C */ s32 battleSongID;
/* 0x20 */ s32 unk_20; /* 0x20 */ s32 battleVariation;
/* 0x24 */ s32 unk_24; /* 0x24 */ s32 savedSongID;
/* 0x28 */ s32 unk_28; /* 0x28 */ s32 savedVariation;
/* 0x2C */ s32 unk_2C; /* 0x2C */ s32 savedSongName;
} MusicSettings; // size = 0x30 } MusicSettings; // size = 0x30
typedef struct MusicProximityTrigger {
/* 0x00 */ Vec2XZf pos;
/* 0x08 */ f32 innerDist;
/* 0x0C */ f32 outerDist;
/* 0x10 */ s32 unk;
/* 0x14 */ s32 manualActivationFlag;
} MusicProximityTrigger; // size = 0x18
typedef struct UiStatus { typedef struct UiStatus {
/* 0x00 */ s32 hpIconIndices[2]; /* 0x00 */ s32 hpIconIndices[2];
/* 0x08 */ s32 fpIconIndices[2]; /* 0x08 */ s32 fpIconIndices[2];
@ -908,6 +922,7 @@ typedef struct BattleStatus {
/* 0x45C */ char unk_45C[4]; /* 0x45C */ char unk_45C[4];
} BattleStatus; // size = 0x460 } BattleStatus; // size = 0x460
// alternative name: TileDescriptor
typedef struct TextureHeader { typedef struct TextureHeader {
/* 0x00 */ s8 name[32]; /* 0x00 */ s8 name[32];
/* 0x20 */ s16 auxW; /* 0x20 */ s16 auxW;
@ -1237,11 +1252,11 @@ typedef struct MessageCharset {
} MessageCharset; // size = 0xA; } MessageCharset; // size = 0xA;
typedef struct MesasgeFontGlyphData { typedef struct MesasgeFontGlyphData {
/* 0x0 */ s8* raster; /* 0x0 */ IMG_PTR raster;
/* 0x4 */ s16* palette; /* 0x4 */ PAL_PTR palette;
/* 0x8 */ Vec2b texSize; /* 0x8 */ Vec2bu texSize;
/* 0xA */ s8 charWidth; /* 0xA */ u8 charWidth;
/* 0xB */ s8 charHeight; /* 0xB */ u8 charHeight;
} MesasgeFontGlyphData; // size = 0xC } MesasgeFontGlyphData; // size = 0xC
typedef struct MessageImageData { typedef struct MessageImageData {
@ -1286,7 +1301,7 @@ typedef struct ShopItemLocation {
typedef struct ShopItemData { typedef struct ShopItemData {
/* 0x0 */ u32 itemID; /* 0x0 */ u32 itemID;
/* 0x4 */ s32 price; /* 0x4 */ s32 price;
/* 0x8 */ s32 unk_08; /* 0x8 */ s32 descMsg;
} ShopItemData; // size = 0xC } ShopItemData; // size = 0xC
typedef struct ShopSellPriceData { typedef struct ShopSellPriceData {
@ -2251,14 +2266,14 @@ typedef struct PopupMessage {
/* 0x18 */ Message* message; /* 0x18 */ Message* message;
} PopupMessage; // size = 0x1C } PopupMessage; // size = 0x1C
typedef struct Struct8015A578 { typedef struct HiddenPanelsData {
/* 0x00 */ s8 unk_00; /* 0x00 */ s8 tryFlipTrigger;
/* 0x01 */ u8 unk_01; /* 0x01 */ u8 panelsCount;
/* 0x02 */ s8 unk_02; /* 0x02 */ s8 activateISpy;
/* 0x03 */ u8 unk_03[5]; /* 0x03 */ char unk_03[0x5];
/* 0x08 */ f32 unk_08; /* 0x08 */ f32 flipTriggerPosY;
/* 0x0C */ char unk_0C[0x4]; /* 0x0C */ char unk_0C[0x4];
} Struct8015A578; // size = 0x10 } HiddenPanelsData; // size = 0x10
typedef struct SpriteShadingLightSource { typedef struct SpriteShadingLightSource {
/* 0x00 */ s8 flags; /* 0x00 */ s8 flags;
@ -2300,8 +2315,8 @@ typedef struct UnkStruct0 {
} UnkStruct0; } UnkStruct0;
typedef struct FoldImageRecPart { typedef struct FoldImageRecPart {
/* 0x00 */ s8* raster; /* 0x00 */ IMG_PTR raster;
/* 0x04 */ s8* palette; /* 0x04 */ PAL_PTR palette;
/* 0x08 */ u16 width; /* 0x08 */ u16 width;
/* 0x0A */ u16 height; /* 0x0A */ u16 height;
/* 0x0C */ s16 xOffset; /* 0x0C */ s16 xOffset;
@ -2326,4 +2341,108 @@ typedef struct FoldImageRec {
/* 0x24 */ u8 alphaMultiplier; /* 0x24 */ u8 alphaMultiplier;
} FoldImageRec; // size = 0x25 } FoldImageRec; // size = 0x25
typedef struct SongUpdateEvent {
/* 0x00 */ s32 songName;
/* 0x04 */ s32 duration;
/* 0x08 */ s32 startVolume;
/* 0x0C */ s32 finalVolume;
/* 0x10 */ s32 variation;
/* 0x14 */ s32 unk14;
/* 0x18 */ s32 unk18;
/* 0x1C */ s32 unk1C; // may be fake
} SongUpdateEvent; // size = 0x1C or 0x20
// unfortunately, cant use bitfield for this
// format: ABCC00DD
// A = playerID
// B = trackIndex
// C = musicEventID
// D = scriptSelector
typedef u32 MusicEventTrigger;
// allows Evt scripts to be triggered by BGM commands
typedef struct MusicEvent {
s32 musicEventID; // user-defined, events will respond to BGM Trigger commands with matching ID
EvtScript* scripts[4];
} MusicEvent;
typedef struct ParadeNpcInfo {
/* 0x00 */ u32 initialAnim;
/* 0x04 */ u32** animList;
/* 0x08 */ Vec3f pos;
/* 0x14 */ f32 yaw;
} ParadeNpcInfo; // size = 0x18
typedef struct CreditsEntry {
/* 0x00 */ s32 msgID;
/* 0x04 */ s32 posX;
/* 0x08 */ s32 posY;
/* 0x0C */ s32 palette;
/* 0x10 */ s32 appearMode;
/* 0x14 */ s32 appearTime;
/* 0x18 */ s32 perCharDelayIn;
/* 0x1C */ s32 holdMode;
/* 0x20 */ s32 holdTime;
/* 0x24 */ s32 vanishMode;
/* 0x28 */ s32 vanishTime;
/* 0x2C */ s32 perCharDelayOut;
/* 0x30 */ s32 next;
/* 0x34 */ s16 flags;
/* 0x36 */ char pad_36[2];
} CreditsEntry; // size = 0x38
typedef struct CreditsLine {
/* 0x00 */ u8* message;
/* 0x04 */ s32 unk__04;
/* 0x08 */ s32 time;
/* 0x0C */ s32 state;
/* 0x10 */ s32 palette;
/* 0x14 */ s32 msgWidth;
/* 0x18 */ s32 appearMode;
/* 0x1C */ s32 appearTime;
/* 0x20 */ s32 perCharDelayIn;
/* 0x24 */ s32 unk__24;
/* 0x28 */ s32 unk__28;
/* 0x2C */ s32 unk__2C;
/* 0x30 */ s32 unk__30;
/* 0x34 */ s32 holdMode;
/* 0x38 */ s32 holdTime;
/* 0x3C */ s32 unk__3C;
/* 0x40 */ s32 unk__40;
/* 0x44 */ s32 unk__44;
/* 0x48 */ s32 unk__48;
/* 0x4C */ s32 vanishMode;
/* 0x50 */ s32 vanishTime;
/* 0x54 */ s32 perCharDelayOut;
/* 0x58 */ s32 unk__58;
/* 0x5C */ s32 unk__5C;
/* 0x60 */ s32 unk__60;
/* 0x64 */ s32 unk__64;
/* 0x68 */ s32 posX;
/* 0x6C */ s32 posY;
/* 0x70 */ s16 flags;
/* 0x72 */ char unk_72[2];
} CreditsLine; // size = 0x74
typedef struct CreditsChar {
/* 0x00 */ s32 charIndex;
/* 0x04 */ s32 font;
/* 0x08 */ s32 variation;
/* 0x0C */ s32 palette;
/* 0x10 */ s32 posX;
/* 0x14 */ s32 posY;
/* 0x18 */ s32 fadeInTime;
} CreditsChar; // size = unk
typedef struct CreditsData {
/* 0x00 */ u32 workerID;
/* 0x04 */ CreditsLine lines[32];
} CreditsData; // size = 0x74
typedef struct CreditsUnkBeta {
/* 0x00 */ u8 unk_00;
/* 0x01 */ u8 unk_01;
/* 0x02 */ s16 size;
} CreditsUnkBeta; // size = 0x4
#endif #endif

View File

@ -589,6 +589,7 @@ enum SoundIDs {
SOUND_METAL_GATE_CLOSE = 0x000001CA, SOUND_METAL_GATE_CLOSE = 0x000001CA,
SOUND_1CB = 0x000001CB, SOUND_1CB = 0x000001CB,
SOUND_1CC = 0x000001CC, SOUND_1CC = 0x000001CC,
SOUND_CREAKY_ROCKING_CHAIR = 0x000001D6,
SOUND_1E2 = 0x000001E2, SOUND_1E2 = 0x000001E2,
SOUND_211 = 0x00000211, SOUND_211 = 0x00000211,
SOUND_213 = 0x00000213, SOUND_213 = 0x00000213,
@ -655,6 +656,7 @@ enum SoundIDs {
SOUND_32E = 0x0000032E, SOUND_32E = 0x0000032E,
SOUND_32F = 0x0000032F, SOUND_32F = 0x0000032F,
SOUND_349 = 0x00000349, SOUND_349 = 0x00000349,
SOUND_34A = 0x0000034A,
SOUND_34E = 0x0000034E, SOUND_34E = 0x0000034E,
SOUND_359 = 0x00000359, SOUND_359 = 0x00000359,
SOUND_35D = 0x0000035D, SOUND_35D = 0x0000035D,
@ -811,6 +813,68 @@ enum SoundIDs {
SOUND_B000001E = 0xB000001E, SOUND_B000001E = 0xB000001E,
}; };
enum SoundInstanceFlags {
SOUND_INSTANCE_FLAG_4 = 0x00000004,
};
enum SoundType {
SOUND_TYPE_SPECIAL = 0x80000000,
SOUND_TYPE_LOOPING = 0,
SOUND_TYPE_DOOR1 = 1,
SOUND_TYPE_DOOR2 = 2,
SOUND_TYPE_ALTERNATING = 3
};
enum SoundIDBits {
SOUND_ID_10000 = 0x00010000,
SOUND_ID_LOWER = 0x000023FF,
SOUND_ID_MID = 0x00000C00,
};
typedef enum AuResult {
AU_RESULT_OK = 0,
AU_ERROR_1 = 1,
AU_AMBIENCE_ERROR_1 = 1,
AU_ERROR_SONG_NOT_PLAYING = 2, // player not found for songName
AU_AMBIENCE_ERROR_2 = 2,
AU_ERROR_NULL_SONG_NAME = 3, // songName is NULL
AU_AMBIENCE_ERROR_3 = 3,
AU_ERROR_INVALID_SONG_DURATION = 4, // duration out of bounds: (250,10000)
AU_ERROR_6 = 6,
AU_ERROR_7 = 7,
AU_ERROR_11 = 11,
AU_ERROR_SBN_INDEX_OUT_OF_RANGE = 101,
AU_ERROR_SBN_FORMAT_MISMATCH = 102,
AU_ERROR_151 = 151,
AU_ERROR_201 = 201
} AuResult;
typedef enum AuFileFormat {
AU_FMT_BGM = 0x10,
AU_FMT_SEF = 0x20,
AU_FMT_BK = 0x30,
AU_FMT_PER = 0x40,
AU_FMT_PRG = 0x40,
AU_FMT_MSEQ = 0x40
} AuFileFormat;
enum {
MUSIC_PROXIMITY_FAR,
MUSIC_PROXIMITY_NEAR,
MUSIC_PROXIMITY_FULL
};
typedef enum MusicTrackVols {
TRACK_VOLS_0 = 0,
TRACK_VOLS_1 = 1,
TRACK_VOLS_2 = 2,
TRACK_VOLS_3 = 3,
TRACK_VOLS_KPA_OUTSIDE = 4,
TRACK_VOLS_KPA_1 = 5,
TRACK_VOLS_KPA_2 = 6,
TRACK_VOLS_KPA_3 = 7
} MusicTrackVols;
enum Cams { enum Cams {
CAM_DEFAULT = 0, CAM_DEFAULT = 0,
CAM_BATTLE = 1, CAM_BATTLE = 1,
@ -1338,7 +1402,10 @@ enum AmbientSounds {
AMBIENT_UNDER_SEA6 = 11, AMBIENT_UNDER_SEA6 = 11,
AMBIENT_BIRDS = 12, AMBIENT_BIRDS = 12,
AMBIENT_SEA = 13, AMBIENT_SEA = 13,
AMBIENT_MUSIC = 16, AMBIENT_RADIO = 16, // radio songs for nok
// the following 4 IDs are reserved for additional radio songs,
// and no more are expected to follow after that
// see: func_80053F80
}; };
enum EncounterOutcomes { enum EncounterOutcomes {
@ -3696,10 +3763,25 @@ enum FoldStateFlags {
FOLD_STATE_FLAG_8000 = 0x00008000, FOLD_STATE_FLAG_8000 = 0x00008000,
FOLD_STATE_FLAG_10000 = 0x00010000, FOLD_STATE_FLAG_10000 = 0x00010000,
FOLD_STATE_FLAG_20000 = 0x00020000, FOLD_STATE_FLAG_20000 = 0x00020000,
FOLD_STATE_FLAG_40000 = 0x00040000,
FOLD_STATE_FLAG_80000 = 0x00080000, FOLD_STATE_FLAG_80000 = 0x00080000,
FOLD_STATE_FLAG_100000 = 0x00100000, FOLD_STATE_FLAG_100000 = 0x00100000,
}; };
typedef enum FoldType {
FOLD_TYPE_NONE = 0x0,
FOLD_TYPE_1 = 0x1,
FOLD_TYPE_2 = 0x2,
FOLD_TYPE_3 = 0x3,
FOLD_TYPE_4 = 0x4,
FOLD_TYPE_5 = 0x5,
FOLD_TYPE_6 = 0x6,
FOLD_TYPE_7 = 0x7,
FOLD_TYPE_8 = 0x8,
FOLD_TYPE_9 = 0x9,
FOLD_TYPE_A = 0xA,
} FoldType;
enum MoveType { enum MoveType {
MOVE_TYPE_NONE = 0, MOVE_TYPE_NONE = 0,
MOVE_TYPE_HAMMER = 1, MOVE_TYPE_HAMMER = 1,

View File

@ -266,11 +266,7 @@ s32 round(f32);
f32 atan2(f32 startX, f32 startZ, f32 endX, f32 endZ); f32 atan2(f32 startX, f32 startZ, f32 endX, f32 endZ);
f32 clamp_angle(f32 theta); f32 clamp_angle(f32 theta);
s32 sign(s32 value); s32 sign(s32 value);
s32 func_80055448(s32);
s32 func_80055464(s32, s32);
s32 func_80055618(s32, s32);
s32 func_800557CC(s32);
s32 func_80055848(s32);
s32 func_800E0208(void); s32 func_800E0208(void);
s32 battle_heap_create(void); s32 battle_heap_create(void);
@ -515,18 +511,15 @@ f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by);
f32 dist3D(f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz); f32 dist3D(f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz);
void add_vec2D_polar(f32* x, f32* y, f32 r, f32 theta); void add_vec2D_polar(f32* x, f32* y, f32 r, f32 theta);
s32 sfx_adjust_env_sound_pos(s32 soundID, s32 arg1, f32 arg2, f32 arg3, f32 arg4); //TODO -- remove these and use audio/public.h instead
void sfx_play_sound(s32 soundID);
void sfx_play_sound_at_position(s32 soundID, s32 value2, f32 posX, f32 posY, f32 posZ);
void sfx_play_sound_at_player(s32 soundID, s32 arg0);
void sfx_play_sound_at_npc(s32 soundID, s32 arg1, s32 npcID);
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume); s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume);
void bgm_set_battle_song(s32, s32); void bgm_set_battle_song(s32, s32);
void bgm_push_battle_song(void); void bgm_push_battle_song(void);
void func_801497FC(s32 arg0); s32 bgm_adjust_proximity(s32 playerIndex, s32 arg1, s16 arg2);
s32 func_8014A964(s32 playerIndex, s32 songID, s32 variation, s32 fadeInTime, s16 arg4, s16 arg5); s32 func_8014A964(s32 playerIndex, s32 songID, s32 variation, s32 fadeInTime, s16 arg4, s16 arg5);
s32 func_8014AA54(s32 playerIndex, s32 arg1, s16 arg2);
s32 func_8014AB0C(s32 playerIndex, s16 arg1); #include "audio/public.h"
void basic_window_update(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY, void basic_window_update(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, f32* scaleX, f32* scaleY,
f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity); f32* rotX, f32* rotY, f32* rotZ, s32* darkening, s32* opacity);
@ -577,9 +570,7 @@ void update_entities(void);
void func_80138198(void); void func_80138198(void);
void bgm_update_music_settings(void); void bgm_update_music_settings(void);
void update_ambient_sounds(void); void update_ambient_sounds(void);
void sfx_update_looping_sound_params(void);
void update_windows(void); void update_windows(void);
void sfx_stop_env_sounds(void);
void player_render_interact_prompts(void); void player_render_interact_prompts(void);
void func_802C3EE4(void); void func_802C3EE4(void);
void render_screen_overlay_backUI(void); void render_screen_overlay_backUI(void);
@ -597,7 +588,6 @@ void func_80028838(void);
void clear_screen_overlays(void); void clear_screen_overlays(void);
void bgm_reset_sequence_players(void); void bgm_reset_sequence_players(void);
void reset_ambient_sounds(void); void reset_ambient_sounds(void);
void sfx_clear_sounds(void);
void poll_rumble(void); void poll_rumble(void);
void bgm_pop_song(void); void bgm_pop_song(void);
void bgm_push_song(s32 songID, s32 variation); void bgm_push_song(s32 songID, s32 variation);
@ -621,8 +611,6 @@ void suspend_all_group(s32 groupFlags);
void kill_script(Evt* instanceToKill); void kill_script(Evt* instanceToKill);
void exec_entity_commandlist(Entity* entity); void exec_entity_commandlist(Entity* entity);
void sfx_reset_door_sounds(void);
void show_start_recovery_shimmer(f32 x, f32 y, f32 z, s32 arg3); void show_start_recovery_shimmer(f32 x, f32 y, f32 z, s32 arg3);
void show_recovery_shimmer(f32 x, f32 y, f32 z, s32 arg3); void show_recovery_shimmer(f32 x, f32 y, f32 z, s32 arg3);
@ -778,13 +766,11 @@ s32 create_generic_entity_world(WorldArgs, WorldArgs);
EntityModel* get_entity_model(s32 idx); EntityModel* get_entity_model(s32 idx);
f32 phys_get_spin_history(s32 lag, s32* x, s32* y, s32* z); f32 phys_get_spin_history(s32 lag, s32* x, s32* y, s32* z);
void fold_update(u32, s32, s32, s32, s32, s32, s32); void fold_update(u32, FoldType, s32, s32, s32, s32, s32);
s32 fold_appendGfx_component(s32, FoldImageRecPart*, u32, Matrix4f); s32 fold_appendGfx_component(s32, FoldImageRecPart*, u32, Matrix4f);
s32 func_8013A704(s32); s32 func_8013A704(s32);
void free_generic_entity(s32); void free_generic_entity(s32);
void sfx_get_spatialized_sound_params(f32 arg0, f32 arg1, f32 arg2, s16* arg3, s16* arg4, s32 arg5);
void sfx_play_sound_with_params(s32 arg0, u8 arg1, u8 arg2, s16 arg3);
s32 ai_check_fwd_collisions(Npc* npc, f32 arg1, f32* arg2, f32* arg3, f32* arg4, f32* arg5); s32 ai_check_fwd_collisions(Npc* npc, f32 arg1, f32* arg2, f32* arg3, f32* arg4, f32* arg5);
void basic_ai_loiter_init(Evt* script, NpcAISettings* aiSettings, EnemyDetectVolume* territory); void basic_ai_loiter_init(Evt* script, NpcAISettings* aiSettings, EnemyDetectVolume* territory);
void PatrolAI_LoiterInit(Evt* script, NpcAISettings* aiSettings, EnemyDetectVolume* territory); void PatrolAI_LoiterInit(Evt* script, NpcAISettings* aiSettings, EnemyDetectVolume* territory);
@ -825,19 +811,12 @@ void func_800EF3E4(void);
void func_80268858(void); void func_80268858(void);
void func_80269118(void); void func_80269118(void);
s32 func_80268224(s32); s32 func_80268224(s32);
void func_80149A6C(s32, s32);
void func_800EF300(void); void func_800EF300(void);
void enable_player_shadow(void); void enable_player_shadow(void);
s32 get_msg_lines(s32 messageID); s32 get_msg_lines(s32 messageID);
void set_window_properties(s32 panelID, s32 posX, s32 posY, s32 width, s32 height, u8, void* drawContents, void* drawContentsArg, s8 parent); void set_window_properties(s32 panelID, s32 posX, s32 posY, s32 width, s32 height, u8, void* drawContents, void* drawContentsArg, s8 parent);
void set_window_update(s32 panelID, s32); void set_window_update(s32 panelID, s32);
void set_windows_visible(s32 groupIdx); void set_windows_visible(s32 groupIdx);
void snd_stop_sound(s32 soundID);
void snd_start_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void snd_adjust_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void sfx_adjust_env_sound_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void sfx_stop_sound(s32 soundID);
void partner_disable_input(void); void partner_disable_input(void);
void partner_set_goal_pos(s32 x, s32 z); void partner_set_goal_pos(s32 x, s32 z);

View File

@ -65,9 +65,4 @@ MapConfig* get_current_map_header(void);
/// Zero-terminated. /// Zero-terminated.
extern Area gAreas[29]; extern Area gAreas[29];
/// Lists the songs that are forced to use the variation determined by `map.songVariation & 1`.
/// @see bgm_get_map_default_variation
extern s32 gSongsUsingVariationFlag[6];
extern s16 D_8014F738;
#endif #endif

View File

@ -78,24 +78,9 @@ typedef struct ModelTreeInfo {
/* 0x03 */ char unk_03; /* 0x03 */ char unk_03;
} ModelTreeInfo; // size = 0x04 } ModelTreeInfo; // size = 0x04
typedef struct TileDescriptor {
/* 0x00 */ s8 name[32];
/* 0x20 */ u16 auxW;
/* 0x22 */ u16 mainW;
/* 0x24 */ u16 auxH;
/* 0x26 */ u16 mainH;
/* 0x28 */ char unk_28;
/* 0x29 */ u8 extraTiles;
/* 0x2A */ u16 colorCombine;
/* 0x2C */ u8 bitDepth;
/* 0x2D */ u8 wrapH;
/* 0x2E */ u8 wrapV;
/* 0x2F */ u8 filtering;
} TileDescriptor; // size = 0x30
typedef struct TextureHandle { typedef struct TextureHandle {
/* 0x00 */ Gfx* gfx; /* 0x00 */ Gfx* gfx;
/* 0x04 */ TileDescriptor desc; /* 0x04 */ TextureHeader header;
/* 0x34 */ s32* raster; /* 0x34 */ s32* raster;
/* 0x38 */ s32* palette; /* 0x38 */ s32* palette;
/* 0x3C */ s32* auxRaster; /* 0x3C */ s32* auxRaster;

View File

@ -74,13 +74,13 @@ extern s8 D_800A0900;
extern f32 GravityParamsStartFall[]; extern f32 GravityParamsStartFall[];
extern s16 D_800F7B80; extern s16 D_800F7B80;
extern u8* D_801512F0; extern u8* D_801512F0;
extern s16 D_80151308; extern u16 D_80151308;
extern s32 gEntityHideMode; extern s32 gEntityHideMode;
extern s32 D_8010C92C; extern s32 D_8010C92C;
extern s32 D_8010C950; extern s32 D_8010C950;
extern s32 D_801595A0; extern s32 D_801595A0;
extern Struct8015A578 D_8015A578; extern HiddenPanelsData gCurrentHiddenPanels;
extern BackgroundHeader gBackgroundImage; extern BackgroundHeader gBackgroundImage;
@ -176,7 +176,7 @@ extern f32 gCurtainFade;
extern f32 gCurtainFadeGoal; extern f32 gCurtainFadeGoal;
extern UNK_FUN_PTR(gCurtainDrawCallback); extern UNK_FUN_PTR(gCurtainDrawCallback);
extern s16 gCurrentDoorSoundsSet; extern u16 gCurrentDoorSoundsSet;
extern s32 D_800D9620; extern s32 D_800D9620;
extern UNK_TYPE D_800E92D8; extern UNK_TYPE D_800E92D8;
@ -231,12 +231,7 @@ extern EvtScript SCRIPT_NpcDefeat;
extern EvtScript ShakeCam1; extern EvtScript ShakeCam1;
extern EvtScript ShakeCamX; extern EvtScript ShakeCamX;
extern s16 gMusicUnkVolume;
extern s16 gMusicUnkVolume2;
extern s16 gMusicCurrentVolume;
extern s16 gMusicTargetVolume;
extern MusicSettings gMusicSettings[4]; extern MusicSettings gMusicSettings[4];
extern MusicSettings D_8014F6F0;
// OS // OS
extern OSThread D_800A4270; // idle thread, id 1 extern OSThread D_800A4270; // idle thread, id 1

View File

@ -1,7 +1,7 @@
#include "common.h" #include "common.h"
#include "filemenu.h" #include "filemenu.h"
#include "hud_element.h" #include "hud_element.h"
#include "audio.h" #include "audio/public.h"
#include "fio.h" #include "fio.h"
extern HudScript* filemenu_hudElemScripts[14]; extern HudScript* filemenu_hudElemScripts[14];

View File

@ -236,7 +236,7 @@ void btl_state_update_begin_player_turn(void) {
gBattleState2 = BATTLE_STATE2_PLAYER_DEFEATED; gBattleState2 = BATTLE_STATE2_PLAYER_DEFEATED;
} else { } else {
battleStatus->battlePhase = 0xC; battleStatus->battlePhase = 0xC;
script = start_script(partner->onTurnChanceScriptSource, 0xA, 0); script = start_script(partner->onTurnChanceScriptSource, EVT_PRIORITY_A, 0);
partner->onTurnChangeScript = script; partner->onTurnChangeScript = script;
gBattleState2 = BATTLE_STATE2_UNK_14; gBattleState2 = BATTLE_STATE2_UNK_14;
partner->onTurnChangeID = script->id; partner->onTurnChangeID = script->id;
@ -462,7 +462,7 @@ void btl_state_update_begin_player_turn(void) {
if (battleStatus->hammerLossTurns >= 0) { if (battleStatus->hammerLossTurns >= 0) {
battleStatus->hammerLossTurns--; battleStatus->hammerLossTurns--;
if (battleStatus->hammerLossTurns == -1) { if (battleStatus->hammerLossTurns == -1) {
script = start_script(RegainAbility, 0xA, 0); script = start_script(RegainAbility, EVT_PRIORITY_A, 0);
player->takeTurnScript = script; player->takeTurnScript = script;
player->takeTurnID = script->id; player->takeTurnID = script->id;
script->varTable[0] = 1; script->varTable[0] = 1;
@ -477,7 +477,7 @@ void btl_state_update_begin_player_turn(void) {
if (battleStatus->jumpLossTurns >= 0) { if (battleStatus->jumpLossTurns >= 0) {
battleStatus->jumpLossTurns--; battleStatus->jumpLossTurns--;
if (battleStatus->jumpLossTurns == -1) { if (battleStatus->jumpLossTurns == -1) {
script = start_script(RegainAbility, 0xA, 0); script = start_script(RegainAbility, EVT_PRIORITY_A, 0);
player->takeTurnScript = script; player->takeTurnScript = script;
player->takeTurnID = script->id; player->takeTurnID = script->id;
script->varTable[0] = phi_s0_3; script->varTable[0] = phi_s0_3;
@ -491,7 +491,7 @@ void btl_state_update_begin_player_turn(void) {
if (battleStatus->itemLossTurns >= 0) { if (battleStatus->itemLossTurns >= 0) {
battleStatus->itemLossTurns--; battleStatus->itemLossTurns--;
if (battleStatus->itemLossTurns == -1) { if (battleStatus->itemLossTurns == -1) {
script = start_script(RegainAbility, 0xA, 0); script = start_script(RegainAbility, EVT_PRIORITY_A, 0);
player->takeTurnScript = script; player->takeTurnScript = script;
player->takeTurnID = script->id; player->takeTurnID = script->id;
script->varTable[10] = 2; script->varTable[10] = 2;
@ -651,7 +651,7 @@ block_27:
Evt* script; Evt* script;
battleStatus->battlePhase = 0xC; battleStatus->battlePhase = 0xC;
script = start_script(partner->onTurnChanceScriptSource, 0xA, 0); script = start_script(partner->onTurnChanceScriptSource, EVT_PRIORITY_A, 0);
partner->onTurnChangeScript = script; partner->onTurnChangeScript = script;
partner->onTurnChangeID = script->id; partner->onTurnChangeID = script->id;
script->owner1.actorID = ACTOR_PARTNER; script->owner1.actorID = ACTOR_PARTNER;
@ -1037,7 +1037,7 @@ void btl_state_update_end_training_battle(void) {
Evt* script; Evt* script;
battleStatus->battlePhase = PHASE_ENEMY_BEGIN; battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
script = start_script(partner->onTurnChanceScriptSource, 0xA, 0); script = start_script(partner->onTurnChanceScriptSource, EVT_PRIORITY_A, 0);
partner->onTurnChangeScript = script; partner->onTurnChangeScript = script;
gBattleState2 = BATTLE_STATE2_UNK_C; gBattleState2 = BATTLE_STATE2_UNK_C;
partner->onTurnChangeID = script->id; partner->onTurnChangeID = script->id;
@ -1122,7 +1122,7 @@ void btl_state_update_end_battle(void) {
gBattleState2 = BATTLE_STATE2_UNK_4; gBattleState2 = BATTLE_STATE2_UNK_4;
return; return;
} }
script = start_script(stage->postBattle, 0xA, 0); script = start_script(stage->postBattle, EVT_PRIORITY_A, 0);
battleStatus->controlScript = script; battleStatus->controlScript = script;
gBattleState2 = BATTLE_STATE2_UNK_3; gBattleState2 = BATTLE_STATE2_UNK_3;
battleStatus->controlScriptID = script->id; battleStatus->controlScriptID = script->id;
@ -1274,12 +1274,12 @@ void btl_state_update_run_away(void) {
player->state.varTable[0] = 100; player->state.varTable[0] = 100;
} }
battleStatus->battlePhase = 3; battleStatus->battlePhase = 3;
script = start_script(PlayerScriptDispatcher, 0xA, 0); script = start_script(PlayerScriptDispatcher, EVT_PRIORITY_A, 0);
player->takeTurnScript = script; player->takeTurnScript = script;
player->takeTurnID = script->id; player->takeTurnID = script->id;
script->owner1.actorID = ACTOR_PLAYER; script->owner1.actorID = ACTOR_PLAYER;
if (partner != NULL && partner->koStatus == 0) { if (partner != NULL && partner->koStatus == 0) {
script = start_script(partner->takeTurnScriptSource, 0xA, 0); script = start_script(partner->takeTurnScriptSource, EVT_PRIORITY_A, 0);
partner->takeTurnScript = script; partner->takeTurnScript = script;
partner->takeTurnID = script->id; partner->takeTurnID = script->id;
script->owner1.actorID = ACTOR_PARTNER; script->owner1.actorID = ACTOR_PARTNER;
@ -1353,12 +1353,12 @@ void btl_state_update_run_away(void) {
switch (gBattleState2) { switch (gBattleState2) {
case BATTLE_STATE2_UNK_3: case BATTLE_STATE2_UNK_3:
battleStatus->battlePhase = 7; battleStatus->battlePhase = 7;
script = start_script(PlayerScriptDispatcher, 0xA, 0); script = start_script(PlayerScriptDispatcher, EVT_PRIORITY_A, 0);
player->takeTurnScript = script; player->takeTurnScript = script;
player->takeTurnID = script->id; player->takeTurnID = script->id;
script->owner1.actorID = ACTOR_PLAYER; script->owner1.actorID = ACTOR_PLAYER;
if (partner != NULL && partner->koStatus == 0) { if (partner != NULL && partner->koStatus == 0) {
script = start_script(partner->takeTurnScriptSource, 0xA, 0); script = start_script(partner->takeTurnScriptSource, EVT_PRIORITY_A, 0);
partner->takeTurnScript = script; partner->takeTurnScript = script;
partner->takeTurnID = script->id; partner->takeTurnID = script->id;
script->owner1.actorID = ACTOR_PARTNER; script->owner1.actorID = ACTOR_PARTNER;
@ -1981,7 +1981,7 @@ void btl_state_update_next_enemy(void) {
Evt* onTurnChanceScript; Evt* onTurnChanceScript;
battleStatus->battlePhase = PHASE_ENEMY_BEGIN; battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
onTurnChanceScript = start_script(enemy->onTurnChanceScriptSource, 0xA, 0); onTurnChanceScript = start_script(enemy->onTurnChanceScriptSource, EVT_PRIORITY_A, 0);
enemy->onTurnChangeScript = onTurnChanceScript; enemy->onTurnChangeScript = onTurnChanceScript;
enemy->onTurnChangeID = onTurnChanceScript->id; enemy->onTurnChangeID = onTurnChanceScript->id;
onTurnChanceScript->owner1.actorID = battleStatus->activeEnemyActorID; onTurnChanceScript->owner1.actorID = battleStatus->activeEnemyActorID;
@ -2071,7 +2071,7 @@ void btl_state_update_partner_striking_first(void) {
actor = get_actor(ACTOR_ENEMY0); actor = get_actor(ACTOR_ENEMY0);
if (actor->onHitScriptSource != NULL) { if (actor->onHitScriptSource != NULL) {
actor->lastEventType = EVENT_BEGIN_FIRST_STRIKE; actor->lastEventType = EVENT_BEGIN_FIRST_STRIKE;
script = start_script(actor->onHitScriptSource, 0xA, 0x20); script = start_script(actor->onHitScriptSource, EVT_PRIORITY_A, EVT_FLAG_20);
actor->onHitScript = script; actor->onHitScript = script;
actor->onHitID = script->id; actor->onHitID = script->id;
script->owner1.actorID = actor->actorID; script->owner1.actorID = actor->actorID;
@ -2094,7 +2094,7 @@ void btl_state_update_partner_striking_first(void) {
btl_cam_target_actor(ACTOR_PARTNER); btl_cam_target_actor(ACTOR_PARTNER);
reset_actor_turn_info(); reset_actor_turn_info();
battleStatus->battlePhase = PHASE_FIRST_STRIKE; battleStatus->battlePhase = PHASE_FIRST_STRIKE;
script = start_script(partner->takeTurnScriptSource, 0xA, 0); script = start_script(partner->takeTurnScriptSource, EVT_PRIORITY_A, 0);
partner->takeTurnScript = script; partner->takeTurnScript = script;
D_8029F248 = 3; D_8029F248 = 3;
gBattleState2 = BATTLE_STATE2_UNK_2; gBattleState2 = BATTLE_STATE2_UNK_2;
@ -2154,7 +2154,7 @@ void btl_state_update_partner_striking_first(void) {
if (actor != NULL) { if (actor != NULL) {
if (actor->onHitScriptSource != NULL) { if (actor->onHitScriptSource != NULL) {
actor->lastEventType = EVENT_END_FIRST_STRIKE; actor->lastEventType = EVENT_END_FIRST_STRIKE;
script = start_script(actor->onHitScriptSource, 0xA, 0x20); script = start_script(actor->onHitScriptSource, EVT_PRIORITY_A, EVT_FLAG_20);
actor->onHitScript = script; actor->onHitScript = script;
actor->onHitID = script->id; actor->onHitID = script->id;
script->owner1.actorID = actor->actorID; script->owner1.actorID = actor->actorID;
@ -2320,7 +2320,7 @@ void btl_state_update_enemy_striking_first(void) {
enemy = battleStatus->currentTurnEnemy; enemy = battleStatus->currentTurnEnemy;
reset_actor_turn_info(); reset_actor_turn_info();
battleStatus->battlePhase = 1; battleStatus->battlePhase = 1;
script = start_script(enemy->takeTurnScriptSource, 0xA, 0); script = start_script(enemy->takeTurnScriptSource, EVT_PRIORITY_A, 0);
enemy->takeTurnScript = script; enemy->takeTurnScript = script;
D_8029F248 = 3; D_8029F248 = 3;
enemy->takeTurnID = script->id; enemy->takeTurnID = script->id;
@ -2455,7 +2455,7 @@ void btl_state_update_end_demo_battle(void) {
if (stage->postBattle == NULL) { if (stage->postBattle == NULL) {
gBattleState2 = BATTLE_STATE2_UNK_4; gBattleState2 = BATTLE_STATE2_UNK_4;
} else { } else {
battleStatus->controlScript = start_script(stage->postBattle, 0xA, 0); battleStatus->controlScript = start_script(stage->postBattle, EVT_PRIORITY_A, 0);
gBattleState2 = BATTLE_STATE2_UNK_3; gBattleState2 = BATTLE_STATE2_UNK_3;
battleStatus->controlScriptID = battleStatus->controlScript->id; battleStatus->controlScriptID = battleStatus->controlScript->id;
} }

View File

@ -78,8 +78,8 @@ EvtScript BtlBringPartnerOut = {
}; };
extern s32 D_8029DA30; extern s32 bSavedPartner;
extern s32 D_8029DA34; extern s32 bSavedOverrideFlags;
extern s32 D_8029DA40; extern s32 D_8029DA40;
extern s32 D_8029DA44; extern s32 D_8029DA44;
extern s32 D_8029DA48; extern s32 D_8029DA48;
@ -157,7 +157,7 @@ void initialize_battle(void) {
gBattleStatus.flags1 = 0; gBattleStatus.flags1 = 0;
gBattleStatus.flags2 = 0; gBattleStatus.flags2 = 0;
gBattleStatus.flags1 = 0; gBattleStatus.flags1 = 0;
D_8029DA34 = gOverrideFlags; bSavedOverrideFlags = gOverrideFlags;
gOverrideFlags &= ~GLOBAL_OVERRIDES_80; gOverrideFlags &= ~GLOBAL_OVERRIDES_80;
gBattleStatus.inputBitmask = -1; gBattleStatus.inputBitmask = -1;
gOverrideFlags &= ~GLOBAL_OVERRIDES_80; gOverrideFlags &= ~GLOBAL_OVERRIDES_80;
@ -225,7 +225,7 @@ void initialize_battle(void) {
playerData->battlesCount++; playerData->battlesCount++;
} }
D_8029DA30 = playerData->currentPartner; bSavedPartner = playerData->currentPartner;
if (gBattleStatus.flags2 & BS_FLAGS2_40) { if (gBattleStatus.flags2 & BS_FLAGS2_40) {
playerData->currentPartner = PARTNER_TWINK; playerData->currentPartner = PARTNER_TWINK;
} }
@ -964,14 +964,14 @@ void btl_restore_world_cameras(void) {
playerStatus->position.y = D_8029EFB4; playerStatus->position.y = D_8029EFB4;
playerStatus->position.z = D_8029EFB8; playerStatus->position.z = D_8029EFB8;
if (D_8029DA34 & 0x80) { if (bSavedOverrideFlags & GLOBAL_OVERRIDES_80) {
gOverrideFlags |= GLOBAL_OVERRIDES_80; gOverrideFlags |= GLOBAL_OVERRIDES_80;
} else { } else {
gOverrideFlags &= ~GLOBAL_OVERRIDES_80; gOverrideFlags &= ~GLOBAL_OVERRIDES_80;
} }
if (gBattleStatus.flags2 & 0x40) { if (gBattleStatus.flags2 & 0x40) {
playerData->currentPartner = D_8029DA30; playerData->currentPartner = bSavedPartner;
} }
} }

View File

@ -1528,7 +1528,7 @@ void close_action_command_instruction_popup(void) {
void func_8024FB3C(void* data) { void func_8024FB3C(void* data) {
PopupMessage* popup = data; PopupMessage* popup = data;
BattleStatus* battleStatus = &gBattleStatus; BattleStatus* battleStatus = &gBattleStatus;
s32 cond = FALSE; s32 shouldDisposeWindow = FALSE;
s32 temp_a0; s32 temp_a0;
@ -1605,7 +1605,7 @@ void func_8024FB3C(void* data) {
} }
break; break;
case 4: case 4:
cond = TRUE; shouldDisposeWindow = TRUE;
break; break;
case 3: case 3:
popup->unk_16 = 4; popup->unk_16 = 4;
@ -1637,7 +1637,7 @@ void func_8024FB3C(void* data) {
D_8029F64A = TRUE; D_8029F64A = TRUE;
if (temp_a0 == 0) { if (temp_a0 == 0) {
D_8029F64A = FALSE; D_8029F64A = FALSE;
cond = TRUE; shouldDisposeWindow = TRUE;
break; break;
} }
@ -1783,11 +1783,11 @@ void func_8024FB3C(void* data) {
case 1: case 1:
if (gBattleStatus.flags1 & BS_FLAGS1_10000) { if (gBattleStatus.flags1 & BS_FLAGS1_10000) {
gBattleStatus.flags1 &= ~BS_FLAGS1_4000; gBattleStatus.flags1 &= ~BS_FLAGS1_4000;
set_window_update(9, 7); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW_TRANSPARENT);
popup->duration = 0; popup->duration = 0;
popup->unk_16 = 2; popup->unk_16 = 2;
} else if (!(gBattleStatus.flags1 & BS_FLAGS1_4000) && (temp_a0 != 2)) { } else if (!(gBattleStatus.flags1 & BS_FLAGS1_4000) && (temp_a0 != 2)) {
set_window_update(9, 7); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW_TRANSPARENT);
switch (popup->messageIndex) { switch (popup->messageIndex) {
case 49: case 49:
hud_element_set_script(D_8029F642, &HES_MashAButton); hud_element_set_script(D_8029F642, &HES_MashAButton);
@ -1923,7 +1923,7 @@ void func_8024FB3C(void* data) {
break; break;
} }
D_8029F64A = FALSE; D_8029F64A = FALSE;
cond = TRUE; shouldDisposeWindow = TRUE;
} }
} }
} }
@ -1960,7 +1960,7 @@ void func_8024FB3C(void* data) {
popup->unk_16 = 4; popup->unk_16 = 4;
break; break;
case 4: case 4:
cond = TRUE; shouldDisposeWindow = TRUE;
break; break;
} }
break; break;
@ -2017,14 +2017,14 @@ void func_8024FB3C(void* data) {
popup->duration--; popup->duration--;
break; break;
} }
cond = TRUE; shouldDisposeWindow = TRUE;
hud_element_free(D_8029F642); hud_element_free(D_8029F642);
break; break;
} }
break; break;
} }
if (cond) { if (shouldDisposeWindow) {
set_window_update(9, 2); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_HIDE);
D_802838F8 = NULL; D_802838F8 = NULL;
free_popup(popup); free_popup(popup);
} }
@ -2354,8 +2354,8 @@ void btl_show_message_popup(void* data) {
width = msgWidth; width = msgWidth;
numLines = get_msg_lines(messageID) - 1; numLines = get_msg_lines(messageID) - 1;
height = bMsgHeights[numLines]; height = bMsgHeights[numLines];
set_window_properties(9, posX, posY, width, height, 0, func_80250818, popup, -1); set_window_properties(WINDOW_ID_9, posX, posY, width, height, 0, func_80250818, popup, -1);
set_window_update(9, 1); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW);
} }
break; break;
case 73: case 73:
@ -2371,8 +2371,8 @@ void btl_show_message_popup(void* data) {
posX = 160 - (msgWidth / 2); posX = 160 - (msgWidth / 2);
width = msgWidth; width = msgWidth;
height = 40; height = 40;
set_window_properties(9, posX, posY, width, height, 0, func_80250818, popup, -1); set_window_properties(WINDOW_ID_9, posX, posY, width, height, 0, func_80250818, popup, -1);
set_window_update(9, 1); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW);
} }
break; break;
case 4: case 4:
@ -2396,8 +2396,8 @@ void btl_show_message_popup(void* data) {
width = msgWidth; width = msgWidth;
numLines = get_msg_lines(messageID) - 1; numLines = get_msg_lines(messageID) - 1;
height = bMsgHeights[numLines]; height = bMsgHeights[numLines];
set_window_properties(9, posX, posY, width, height, 0, func_80250818, popup, -1); set_window_properties(WINDOW_ID_9, posX, posY, width, height, 0, func_80250818, popup, -1);
set_window_update(9, 1); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW);
} }
break; break;
case 81: case 81:
@ -2412,8 +2412,8 @@ void btl_show_message_popup(void* data) {
width = msgWidth; width = msgWidth;
numLines = get_msg_lines(messageID) - 1; numLines = get_msg_lines(messageID) - 1;
height = bMsgHeights[numLines]; height = bMsgHeights[numLines];
set_window_properties(9, posX, posY, width, height, 0, func_80250818, popup, -1); set_window_properties(WINDOW_ID_9, posX, posY, width, height, 0, func_80250818, popup, -1);
set_window_update(9, 1); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW);
} }
break; break;
case 46: case 46:
@ -2456,11 +2456,11 @@ void btl_show_message_popup(void* data) {
D_8029F650 = D_802835D8[numLines]; D_8029F650 = D_802835D8[numLines];
posY = D_8029F64E + D_8029F650; posY = D_8029F64E + D_8029F650;
set_window_properties(9, posX, posY, width, height, 0, func_80250818, popup, -1); set_window_properties(WINDOW_ID_9, posX, posY, width, height, 0, func_80250818, popup, -1);
if (popup->messageIndex == 0x3B) { if (popup->messageIndex == 0x3B) {
set_window_update(9, 1); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW);
} else { } else {
set_window_update(9, 8); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW_DARKENED);
} }
} }
break; break;

View File

@ -456,54 +456,54 @@ s32 calc_item_damage_enemy(void) {
} }
if ((battleStatus->currentAttackStatus & STATUS_FLAG_SLEEP) && wasStatusInflicted) { if ((battleStatus->currentAttackStatus & STATUS_FLAG_SLEEP) && wasStatusInflicted) {
script = start_script(DoSleepHit, EVT_PRIORITY_A, 0); script = start_script(&DoSleepHit, EVT_PRIORITY_A, 0);
script->varTable[0] = state->goalPos.x; script->varTable[0] = state->goalPos.x;
script->varTable[1] = state->goalPos.y; script->varTable[1] = state->goalPos.y;
script->varTable[2] = state->goalPos.z; script->varTable[2] = state->goalPos.z;
sfx_play_sound_at_position(SOUND_INFLICT_SLEEP, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z); sfx_play_sound_at_position(SOUND_INFLICT_SLEEP, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
} }
if ((battleStatus->currentAttackStatus & STATUS_FLAG_DIZZY) && wasStatusInflicted) { if ((battleStatus->currentAttackStatus & STATUS_FLAG_DIZZY) && wasStatusInflicted) {
script = start_script(DoDizzyHit, EVT_PRIORITY_A, 0); script = start_script(&DoDizzyHit, EVT_PRIORITY_A, 0);
script->varTable[0] = state->goalPos.x; script->varTable[0] = state->goalPos.x;
script->varTable[1] = state->goalPos.y; script->varTable[1] = state->goalPos.y;
script->varTable[2] = state->goalPos.z; script->varTable[2] = state->goalPos.z;
sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z); sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
} }
if ((battleStatus->currentAttackStatus & STATUS_FLAG_PARALYZE) && wasStatusInflicted) { if ((battleStatus->currentAttackStatus & STATUS_FLAG_PARALYZE) && wasStatusInflicted) {
script = start_script(DoParalyzeHit, EVT_PRIORITY_A, 0); script = start_script(&DoParalyzeHit, EVT_PRIORITY_A, 0);
script->varTable[0] = state->goalPos.x; script->varTable[0] = state->goalPos.x;
script->varTable[1] = state->goalPos.y; script->varTable[1] = state->goalPos.y;
script->varTable[2] = state->goalPos.z; script->varTable[2] = state->goalPos.z;
sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z); sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
} }
if ((battleStatus->currentAttackStatus & STATUS_FLAG_POISON) && wasStatusInflicted) { if ((battleStatus->currentAttackStatus & STATUS_FLAG_POISON) && wasStatusInflicted) {
script = start_script(DoPoisonHit, EVT_PRIORITY_A, 0); script = start_script(&DoPoisonHit, EVT_PRIORITY_A, 0);
script->varTable[0] = state->goalPos.x; script->varTable[0] = state->goalPos.x;
script->varTable[1] = state->goalPos.y; script->varTable[1] = state->goalPos.y;
script->varTable[2] = state->goalPos.z; script->varTable[2] = state->goalPos.z;
sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z); sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
} }
if ((battleStatus->currentAttackStatus & STATUS_FLAG_STOP) && wasStatusInflicted) { if ((battleStatus->currentAttackStatus & STATUS_FLAG_STOP) && wasStatusInflicted) {
script = start_script(DoStopHit, EVT_PRIORITY_A, 0); script = start_script(&DoStopHit, EVT_PRIORITY_A, 0);
script->varTable[0] = state->goalPos.x; script->varTable[0] = state->goalPos.x;
script->varTable[1] = state->goalPos.y; script->varTable[1] = state->goalPos.y;
script->varTable[2] = state->goalPos.z; script->varTable[2] = state->goalPos.z;
sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z); sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
} }
if ((battleStatus->currentAttackStatus & STATUS_FLAG_FROZEN) && wasStatusInflicted) { if ((battleStatus->currentAttackStatus & STATUS_FLAG_FROZEN) && wasStatusInflicted) {
script = start_script(DoFreezeHit, EVT_PRIORITY_A, 0); script = start_script(&DoFreezeHit, EVT_PRIORITY_A, 0);
script->varTable[0] = state->goalPos.x; script->varTable[0] = state->goalPos.x;
script->varTable[1] = state->goalPos.y; script->varTable[1] = state->goalPos.y;
script->varTable[2] = state->goalPos.z; script->varTable[2] = state->goalPos.z;
script->varTable[3] = target; script->varTablePtr[3] = target;
sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z); sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
} }
if ((battleStatus->currentAttackStatus & STATUS_FLAG_SHRINK) && wasStatusInflicted) { if ((battleStatus->currentAttackStatus & STATUS_FLAG_SHRINK) && wasStatusInflicted) {
script = start_script(DoShrinkHit, EVT_PRIORITY_A, 0); script = start_script(&DoShrinkHit, EVT_PRIORITY_A, 0);
script->varTable[0] = state->goalPos.x; script->varTable[0] = state->goalPos.x;
script->varTable[1] = state->goalPos.y; script->varTable[1] = state->goalPos.y;
script->varTable[2] = state->goalPos.z; script->varTable[2] = state->goalPos.z;
script->varTable[3] = target; script->varTablePtr[3] = target;
sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z); sfx_play_sound_at_position(SOUND_INFLICT_STATUS, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
} }
if ((battleStatus->currentAttackElement & DAMAGE_TYPE_SMASH) && (target->actorType == ACTOR_TYPE_GOOMNUT_TREE)) { if ((battleStatus->currentAttackElement & DAMAGE_TYPE_SMASH) && (target->actorType == ACTOR_TYPE_GOOMNUT_TREE)) {

View File

@ -618,7 +618,7 @@ void btl_state_update_celebration(void) {
hud_element_set_tint(id, 128, 128, 128); hud_element_set_tint(id, 128, 128, 128);
x = 20; x = 20;
y = 186; y = 186;
set_window_properties(8, 20, 186, 280, 32, 20, func_80260948, NULL, -1); set_window_properties(WINDOW_ID_8, 20, 186, 280, 32, 20, func_80260948, NULL, -1);
set_window_update(WINDOW_ID_8, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_8, WINDOW_UPDATE_SHOW);
gBattleState2 = BATTLE_STATE2_UNK_8; gBattleState2 = BATTLE_STATE2_UNK_8;
} }
@ -769,7 +769,7 @@ void btl_state_update_celebration(void) {
width = get_msg_width(0x1D00AB, 0) + 31; width = get_msg_width(0x1D00AB, 0) + 31;
x = 160 - (width / 2); x = 160 - (width / 2);
y = 80; y = 80;
set_window_properties(9, x, y, width, 28, 10, func_80260A20, NULL, -1); set_window_properties(WINDOW_ID_9, x, y, width, 28, 10, func_80260A20, NULL, -1);
set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW);
D_8029FB4C = 60; D_8029FB4C = 60;
gBattleState2 = BATTLE_STATE2_UNK_10; gBattleState2 = BATTLE_STATE2_UNK_10;

View File

@ -1,348 +0,0 @@
#include "common.h"
#include "audio.h"
void snd_SEFCmd_00_SetVolume(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_01_SetPan(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_02_SetInstrument(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_03_SetReverb(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_04(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_05(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_06(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_07(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_08(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_09_StartLoop(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_0A_EndLoop(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_0B(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_0C(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_0D(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_0E(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_0F(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_10_Jump(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_13(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_14(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_15(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_16(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_17(SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_18(SoundManager* manager, SoundPlayer* player);
void func_8004B440(SoundManager* manager, u8 arg1, u8 arg2, UnkAl19E0* arg3, u8 arg4) {
u32 i;
s32 c = 0x6A25E;
manager->soundData = arg3;
manager->unkCounterStep = 312500;
manager->unkCounterMax = manager->unkCounter = c;
manager->unk_BC = arg1;
manager->unk_BE = arg2;
if (arg4 > 0x10) {
manager->sfxPlayerSelector = 0x10;
} else {
manager->sfxPlayerSelector = arg4;
}
manager->unk_5C = 0x8000;
manager->unk_B8 = 0x8000;
manager->playCounter = 0;
manager->unk_60 = 0;
for (i = 0; i < ARRAY_COUNT(manager->unk_16C); i++) {
SoundPlayer* sub = &manager->unk_16C[i];
sub->sefDataReadPos = 0;
sub->sfxVolume = 0;
sub->unk_8E = 0;
sub->unk_90 = 0;
sub->unk_92 = 0;
sub->unk_94 = 0;
sub->sfxPan = 0;
sub->reverb = 0;
sub->instrumentIndex = 0;
sub->unk_9E = 0;
sub->unk_9F = 0;
sub->unk_99 = 0;
sub->locatorB = 0;
sub->locatorC = 0;
sub->locatorD = 0;
sub->unk_7B = 0x40;
sub->unk_7C = 0;
sub->unk_7D = 0xB0;
sub->unk_7E = 0;
sub->unk_7F = 0;
}
for (i = 0; i < ARRAY_COUNT(manager->unk_90); i++) {
manager->unk_90[i] = 0;
}
for (i = 0; i < ARRAY_COUNT(manager->unk_A0); i++) {
manager->unk_A0[i].x = 0;
}
manager->unk_168 = 0;
func_8004BA54(manager, 0);
snd_clear_sfx_queue(manager);
snd_initialize_bgm_fade(&manager->unk_40, 0, 0x7FFF, 0x7FFF);
func_80053A98(manager->unk_BE, manager->unk_40.currentVolume.u16, manager->unk_5C);
manager->unk_8C = 0xFF;
manager->unk_64[0] = &D_80078290;
manager->unk_64[1] = &D_800782F8;
manager->unk_64[2] = &D_80078320;
manager->unk_64[3] = &D_80078348;
manager->unk_64[4] = &D_80078348;
manager->unk_64[5] = &D_80078348;
manager->unk_64[6] = &D_80078348;
manager->unk_64[7] = &D_80078348;
manager->unk_84[0] = 0x10;
manager->unk_84[1] = 0x20;
manager->unk_84[2] = 0x20;
manager->unk_84[3] = 0x20;
manager->unk_84[4] = 0x20;
manager->unk_84[5] = 0x30;
manager->unk_84[6] = 0x40;
manager->unk_84[7] = 0x50;
func_8004B9E4(manager, 0);
}
INCLUDE_ASM(void, "26840_len_20d0", snd_load_sfx_groups_from_SEF, SoundManager* manager);
void snd_clear_sfx_queue(SoundManager* manager) {
s32 i;
for (i = 0; i < ARRAY_COUNT(manager->unk_C2); i++) {
manager->unk_C2[i].soundID = 0;
manager->unk_C2[i].upperSoundID = 0;
manager->unk_C2[i].volume = 0;
manager->unk_C2[i].pitchShift = 0;
manager->unk_C2[i].pan = 0;
}
manager->unk_165 = 0;
manager->sfxQueueNextPos = 0;
manager->sfxQueuePosOffset = 0;
manager->unk_162 = 0;
}
void snd_enqueue_sfx_event(SoundManager* manager, s32 soundID, s16 volume, s16 pitchShift, u8 pan) {
u32 queuePos = manager->sfxQueueNextPos;
s32 queueAmt = manager->sfxQueueNextPos - manager->sfxQueuePosOffset;
if (queueAmt < 0) {
queueAmt += 16;
}
if (queueAmt < 16) {
u32 queueNextPos = queuePos;
manager->unk_C2[queueNextPos].soundID = soundID & 0xBFFF;
manager->unk_C2[queueNextPos].upperSoundID = (((u32) soundID >> 0x10) & 0x3FF);
manager->unk_C2[queueNextPos].volume = volume;
manager->unk_C2[queueNextPos].pitchShift = pitchShift;
manager->unk_C2[queueNextPos].pan = pan;
queueNextPos++;
if (queueNextPos >= 16) {
queueNextPos = 0;
}
manager->sfxQueueNextPos = queueNextPos;
}
}
INCLUDE_ASM(void, "26840_len_20d0", func_8004B748, SoundManager* manager);
s32 func_8004B9E4(SoundManager* manager, s32 arg1) {
s32 a1 = (u8) arg1;
if (a1 != 0xF0) {
if (a1 < 8) {
if (manager->unk_8C != a1) {
manager->unk_8C = a1;
manager->soundData->unk_40[1].unk_00 = 6;
manager->soundData->unk_40[1].unk_01 = 1;
D_8007F1F8[0] = manager->unk_64[a1];
}
manager->unk_8D = manager->unk_84[a1];
} else {
manager->unk_8C = 0xFF;
manager->unk_8D = 0;
}
}
return manager->unk_8C;
}
void func_8004BA54(SoundManager* manager, s32 arg1) {
if (arg1 == 0) {
manager->unk_C0 = 0;
} else if (arg1 == 1) {
manager->unk_C0 = 1;
}
}
INCLUDE_ASM(s32, "26840_len_20d0", func_8004BA74);
INCLUDE_ASM(s32, "26840_len_20d0", func_8004C0E4);
INCLUDE_ASM(s32, "26840_len_20d0", func_8004C268);
INCLUDE_ASM(s32, "26840_len_20d0", func_8004C2A4);
INCLUDE_ASM(s32, "26840_len_20d0", func_8004C300);
INCLUDE_ASM(void, "26840_len_20d0", snd_set_modifiers, SoundManager* manager, SoundSFXEntry* sfxEntry);
void snd_set_player_modifiers(SoundManager* manager, SoundSFXEntry* sfxEntry);
INCLUDE_ASM(void, "26840_len_20d0", snd_set_player_modifiers, SoundManager* manager, SoundSFXEntry* sfxEntry);
void func_8004C578(SoundManager*, SoundPlayer*, UnkAl48*, u32);
void func_8004C884(SoundManager*, SoundPlayer*, UnkAl48*, u32);
s16 func_8004C444(SoundManager* arg0) {
u32 phi_a3 = arg0->sfxPlayerSelector;
u16 temp = arg0->unk_60;
u16 playCounter = arg0->playCounter;
SoundPlayer* temp_a1;
UnkAl48* temp_a2;
u8 i;
arg0->unk_60 = temp + playCounter;
for (i = phi_a3, phi_a3 += 8; i < (u8)phi_a3; i++){
temp_a1 = &arg0->unk_16C[i - arg0->sfxPlayerSelector];
if (temp_a1->sefDataReadPos != 0) {
arg0->unk_04 = temp_a2 = &arg0->soundData->unk_1320[i];
if (arg0->unk_04->unk_45 <= arg0->unk_BC) {
arg0->unk_BF = i;
switch (temp_a1->sfxParamsFlags & 3) {
case 0:
func_8004C578(arg0, temp_a1, temp_a2, i);
break;
case 1:
func_8004C884(arg0, temp_a1, temp_a2, i);
break;
case 2: // Yes, this is needed.
break;
}
} else {
temp_a1->sefDataReadPos = NULL;
temp_a1->currentSoundID = 0;
temp_a1->unk_98 = 0;
}
}
}
return 0;
}
INCLUDE_ASM(s32, "26840_len_20d0", func_8004C578);
INCLUDE_ASM(s32, "26840_len_20d0", snd_get_scaled_volume);
INCLUDE_ASM(s32, "26840_len_20d0", func_8004C884);
INCLUDE_ASM(s32, "26840_len_20d0", snd_set_voice_volume);
INCLUDE_ASM(s32, "26840_len_20d0", func_8004CDF8);
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_00_SetVolume, SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_01_SetPan(SoundManager* manager, SoundPlayer* player) {
s8 sfxPan = *player->sefDataReadPos;
player->sefDataReadPos++;
player->changedPan = TRUE;
player->sfxPan = sfxPan;
}
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_02_SetInstrument, SoundManager* manager, SoundPlayer* player);
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_03_SetReverb, SoundManager* manager, SoundPlayer* player);
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_04, SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_05(SoundManager* manager, SoundPlayer* player) {
s32 temp_v1 = *player->sefDataReadPos;
player->sefDataReadPos++;
player->unk_92 = temp_v1 * 100;
}
void snd_SEFCmd_06(SoundManager* manager, SoundPlayer* player) {
s8 temp_v1 = *player->sefDataReadPos;
player->sefDataReadPos++;
player->unk_94 = temp_v1;
}
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_07, SoundManager* manager, SoundPlayer* player);
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_08, SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_09_StartLoop(SoundManager* manager, SoundPlayer* player) {
s8 loopIterCount = *player->sefDataReadPos;
player->sefDataReadPos++;
player->loopStartPos = player->sefDataReadPos;
player->loopIterCount = loopIterCount;
}
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_0A_EndLoop, SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_0B(SoundManager* manager, SoundPlayer* player) {
if (player->unk_90 != 0) {
player->unk_8E = 3;
player->sefDataReadPos--;
}
}
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_0C, SoundManager* manager, SoundPlayer* player);
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_0D, SoundManager* manager, SoundPlayer* player);
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_0E, SoundManager* manager, SoundPlayer* player);
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_0F, SoundManager* manager, SoundPlayer* player);
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_10_Jump, SoundManager* manager, SoundPlayer* player);
void snd_SEFCmd_11_Restart(SoundManager* manager, SoundPlayer* player) {
player->sefDataReadPos = player->sefReadStart;
}
void snd_SEFCmd_12_NOP(SoundManager* manager, SoundPlayer* player) {
}
void snd_SEFCmd_13(SoundManager* manager, SoundPlayer* player) {
s8 temp_v1 = *player->sefDataReadPos;
player->sefDataReadPos++;
player->unk_A1 = temp_v1;
}
void snd_SEFCmd_14(SoundManager* manager, SoundPlayer* player) {
s8 temp_v1 = *player->sefDataReadPos;
player->sefDataReadPos++;
player->unk_A2 = temp_v1;
}
void snd_SEFCmd_15(SoundManager* manager, SoundPlayer* player) {
s8 temp_v1 = *player->sefDataReadPos;
player->sefDataReadPos++;
player->unk_A3 = temp_v1;
}
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_16, SoundManager* manager, SoundPlayer* player);
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_17, SoundManager* manager, SoundPlayer* player);
INCLUDE_ASM(void, "26840_len_20d0", snd_SEFCmd_18, SoundManager* manager, SoundPlayer* player);
INCLUDE_ASM(s32, "26840_len_20d0", func_8004D428);
INCLUDE_ASM(s32, "26840_len_20d0", func_8004D484);
INCLUDE_ASM(s32, "26840_len_20d0", func_8004D4BC);

View File

@ -1,497 +0,0 @@
#include "audio.h"
INCLUDE_ASM(void, "28910_len_5090", func_8004D510, BGMPlayer* arg0);
// Return values are being pushed into v0 in the wrong place
// May depend on data decomp
#ifdef NON_EQUIVALENT
BGMPlayer* snd_get_player_with_song_name(s32 songString) {
UnkAl19E0* temp_v1 = D_8009A664->data;
if (songString == temp_v1->currentTrackData[0][2]) {
return D_8009A664;
}
if (songString == temp_v1->currentTrackData[1][2]) {
return D_8009A5FC;
}
return NULL;
}
#else
INCLUDE_ASM(BGMPlayer*, "28910_len_5090", snd_get_player_with_song_name, s32 songString);
#endif
INCLUDE_ASM(s32, "28910_len_5090", snd_dispatch_bgm_player_event);
s32 func_8004DA0C(s32 songName) {
s32 ret = 0;
if (songName != 0) {
BGMPlayer* player = snd_get_player_with_song_name(songName);
do {} while (0);
do {
if (player == NULL) {
ret = 2;
} else if (songName == player->songName) {
func_8004DAA8(player);
ret = 0;
}
} while (0);
} else {
ret = 3;
}
return ret;
}
void func_8004DA74(void) {
func_8004DAA8(D_8009A664);
func_8004DAA8(D_8009A5FC);
}
void func_8004DAA8(BGMPlayer* player) {
if (player->unk_221 != 0) {
player->unk_221 = 4;
player->unk_10 = 1;
player->unkFrequency = 1;
snd_clear_bgm_fade(&player->fadeInfo);
}
}
s32 snd_is_song_playing(s32 songName) {
if (songName != 0) {
BGMPlayer* player = snd_get_player_with_song_name(songName);
if (player != NULL) {
return songName == player->songName;
}
return 2;
}
return 3;
}
INCLUDE_ASM(s32, "28910_len_5090", func_8004DB28);
INCLUDE_ASM(s32, "28910_len_5090", func_8004DB4C);
INCLUDE_ASM(s32, "28910_len_5090", func_8004DC80);
INCLUDE_ASM(s32, "28910_len_5090", func_8004DCB8);
INCLUDE_ASM(s32, "28910_len_5090", func_8004DE2C);
INCLUDE_ASM(void, "28910_len_5090", func_8004DFD4, UnkAl19E0* arg0);
INCLUDE_ASM(s32, "28910_len_5090", func_8004E0F4);
void func_8004E158(BGMPlayer* player, s32 arg1, s32 arg2, UnkAl19E0* arg3) {
s16 i;
player->data = arg3;
func_8004E880(player, 0x2625A, 0x30);
player->unk_48 = 0x8000;
player->unk_B0 = 0x3CF0;
player->unk_C0 = 0x7F000000;
player->unk_22B = 1;
player->unk_14 = 0;
player->unk_18 = 0;
player->songName = 0;
player->fadeSongName = 0;
player->unk_58 = 0;
player->unk_5A = 0;
player->unk_68 = 0;
player->unk_6C = 0;
player->unk_70 = 0;
player->unk_BC = 0;
player->unk_B8 = 0;
player->unk_B4 = 0;
player->unk_CC = 0;
player->unk_C8 = 0;
player->unk_C4 = 0;
player->unk_20C = 0;
player->unk_20E = 0;
player->unk_220 = 0;
player->unk_204 = 0;
player->unk_232 = 0;
player->unk_221 = 0;
player->unk_234 = arg1;
player->unk_235 = arg2;
player->unk_168 = 0;
player->unk_222 = 0;
player->unk_223 = 0;
player->unk_22A = 0;
player->unk_22C = 0;
player->unk_D0 = 1.0f;
player->unk_22D = 0;
player->unk_22F = 2;
player->unk_230 = 3;
player->unk_22E = 0;
player->unk_231 = 4;
for (i = 0; i < ARRAY_COUNT(player->unk_25C); i++) {
BGMPlayerTrack* temp = &player->unk_25C[i];
temp->subTrackVolume = 0;
temp->unk_28 = 0;
temp->subTrackCoarseTune = 0;
temp->subTrackFineTune = 0;
temp->subTrackPan = 0;
temp->subTrackReverb = 0;
temp->unk_44 = 0;
temp->unk_58 = 0;
temp->segTrackVolume = 0x7F;
temp->unk_4C = 0;
if (i < ARRAY_COUNT(player->unk_238)) {
player->unk_238[i] = 0;
}
}
for (i = 0; i < ARRAY_COUNT(player->unk_85C); i++) {
UnkAl24* temp = &player->unk_85C[i];
temp->unk_08 = 0;
temp->unk_0A = 0;
temp->unk_0C = 0;
temp->unk_14 = 0;
temp->unk_16 = 0;
temp->unk_17 = 0;
}
func_80053AEC(&player->fadeInfo, 0x7FFF);
func_80055110(player);
}
INCLUDE_ASM(s32, "28910_len_5090", func_8004E344);
void snd_update_bgm_fade(BGMPlayer* player) {
player->fadeInfo.fadeTime--;
if (player->fadeInfo.fadeTime != 0) {
player->fadeInfo.currentVolume.s32 += player->fadeInfo.fadeStep;
} else {
player->fadeInfo.currentVolume.s32 = player->fadeInfo.endVolume << 16;
if (player->fadeInfo.fpFadeCallback != NULL) {
player->fadeInfo.fpFadeCallback();
}
if (player->fadeSongName != 0) {
func_8004DC80(player->fadeSongName);
} else if (player->fadeInfo.currentVolume.s32 == 0) {
func_8004DAA8(player);
}
}
func_8004E444(player);
}
void func_8004E444(BGMPlayer* arg0) {
u16 mult = (arg0->fadeInfo.currentVolume.u16 * arg0->fadeInfo.unk_10.u16) >> 15;
s32 i;
for (i = 0; i < 4; i++) {
s8 temp = arg0->unk_4C[i];
if (temp < 0) {
return;
}
func_80053A98(temp, mult, arg0->unk_48);
}
}
INCLUDE_ASM(s16, "28910_len_5090", func_8004E4B8, BGMPlayer* player);
INCLUDE_ASM(s32, "28910_len_5090", snd_initialize_bgm_player, BGMPlayer* player);
INCLUDE_ASM(s32, "28910_len_5090", func_8004E844);
INCLUDE_ASM(s32, "28910_len_5090", func_8004E880);
INCLUDE_ASM(s32, "28910_len_5090", func_8004E904);
INCLUDE_ASM(s32, "28910_len_5090", func_8004EA34);
INCLUDE_ASM(s32, "28910_len_5090", func_8004EAD4);
INCLUDE_ASM(s32, "28910_len_5090", func_8004EC04);
INCLUDE_ASM(s32, "28910_len_5090", func_8004EC68);
void snd_BGMCmd_E0_MasterTempo(BGMPlayer* player, BGMPlayerTrack* track) {
u32 unk_D4 = player->unk_D4.u16;
s32 temp_v0;
player->unk_208 = unk_D4;
temp_v0 = snd_bpm_to_tempo(player, unk_D4);
player->unk_B0 = temp_v0;
player->unkFrequency = temp_v0 * 10;
player->unk_BC = 0;
player->unk_B8 = 0;
player->unk_B4 = 0;
}
s32 snd_bpm_to_tempo(BGMPlayer* player, u32 tempo) {
u32 unk_20A = player->unk_20A;
u32 ret = tempo;
ret *= player->unk_D0;
if (unk_20A < ret) {
ret = unk_20A;
} else if (ret == 0) {
ret = 1;
}
return ret * 100;
}
void snd_BGMCmd_E1_MasterVolume(BGMPlayer* player, BGMPlayerTrack* track) {
s32 unk_D4 = player->unk_D4.u8[0] & 0x7F;
if (unk_D4 != 0) {
unk_D4 = unk_D4 << 0x18;
}
player->unk_C0 = unk_D4;
player->unk_CC = 0;
player->unk_C8 = 0;
player->unk_C4 = 0;
player->unk_21A = 1;
track->volumeChanged = 1;
}
void snd_BGMCmd_E2_MasterTranspose(BGMPlayer* player, BGMPlayerTrack* track) {
player->unk_20C = (s8)player->unk_D4.u8[0] * 100;
}
void snd_BGMCmd_E3(BGMPlayer* player, BGMPlayerTrack* track) {
player->data->unk_40[player->unk_235].unk_00 = player->unk_D4.u8[0];
player->data->unk_40[player->unk_235].unk_01 = 1;
}
void snd_BGMCmd_E6_MasterEffect(BGMPlayer* player, BGMPlayerTrack* track) {
u8 unk_D4 = player->unk_D4.u8[0];
u32 temp_v1 = player->unk_4C[unk_D4];
if ((unk_D4 < 4) && (temp_v1 < 0x80)) {
if (player->data->unk_40[temp_v1].unk_00 != player->unk_D4.u8[1]) {
player->data->unk_40[temp_v1].unk_00 = player->unk_D4.u8[1];
player->data->unk_40[temp_v1].unk_01 = 1;
}
player->unk_224[unk_D4] = player->unk_D4.u8[1];
}
}
void snd_BGMCmd_E4_MasterTempoFade(BGMPlayer* player, BGMPlayerTrack* track) {
s32 unk_D4 = player->unk_D4.u16;
s32 temp_a0 = snd_bpm_to_tempo(player, player->unk_D6.u16);
s32 temp_v0;
if (unk_D4 <= 0) {
unk_D4 = 1;
}
temp_v0 = (temp_a0 - player->unk_B0) / unk_D4;
player->unk_BC = unk_D4;
player->unk_B8 = temp_a0;
player->unk_B4 = temp_v0;
}
void snd_BGMCmd_E5_MasterVolumeFade(BGMPlayer* player, BGMPlayerTrack* track) {
s32 temp_a1 = player->unk_D4.u16;
s32 temp_a2 = player->unk_D6.u8[0] & 0x7F;
if (temp_a2 != 0) {
temp_a2 = temp_a2 << 0x18;
}
if (temp_a1 <= 0) {
temp_a1 = 1;
}
player->unk_CC = temp_a1;
player->unk_C8 = temp_a2;
player->unk_C4 = (temp_a2 - player->unk_C0) / temp_a1;
}
void snd_BGMCmd_E8_TrackOverridePatch(BGMPlayer* player, BGMPlayerTrack* track) {
track->unk_44 = player->unk_D4.u8[1];
track->unk_0C = func_80053BE8(player->data, player->unk_D4.u8[0], track->unk_44, track->unk_10);
}
void snd_BGMCmd_E9_SubTrackVolume(BGMPlayer* arg0, BGMPlayerTrack* track) {
u32 unk_D4 = arg0->unk_D4.u8[0] & 0x7F;
if (unk_D4 != 0) {
unk_D4 = unk_D4 << 0x18;
}
track->subTrackVolume = unk_D4;
track->volumeChanged = 1;
}
void snd_BGMCmd_F6_TrackVolumeFade(BGMPlayer* player, BGMPlayerTrack* track) {
s32 temp_a0 = player->unk_D6.u8[0] & 0x7F;
s32 temp_a2 = player->unk_D4.u16;
if (temp_a0 != 0) {
temp_a0 = temp_a0 << 0x18;
}
if (temp_a0 != track->subTrackVolume) {
if (temp_a2 <= 0) {
temp_a2 = 1;
}
track->subTrackVolumeFadeTime = temp_a2;
track->subTrackVolumeFadeVolume = temp_a0;
track->subTrackVolumeFadeDelta = (temp_a0 - track->subTrackVolume) / temp_a2;
}
}
void snd_BGMCmd_EA_SubTrackPan(BGMPlayer* player, BGMPlayerTrack* track) {
track->subTrackPan = player->unk_D4.u8[0] & 0x7F;
track->unk_57 = 0;
track->panChanged = 1;
}
void snd_BGMCmd_EB_SubTrackReverb(BGMPlayer* player, BGMPlayerTrack* track) {
track->subTrackReverb = player->unk_D4.u8[0] & 0x7F;
track->reverbChanged = 1;
}
void snd_BGMCmd_EC_SegTrackVolume(BGMPlayer* player, BGMPlayerTrack* track) {
track->segTrackVolume = player->unk_D4.u8[0] & 0x7F;
track->volumeChanged = 1;
}
void snd_BGMCmd_ED_SubTrackCoarseTune(BGMPlayer* player, BGMPlayerTrack* track) {
track->subTrackCoarseTune = (s8)player->unk_D4.u8[0] * 100;
}
void snd_BGMCmd_EE_SubTrackFineTune(BGMPlayer* player, BGMPlayerTrack* track) {
track->subTrackFineTune = player->unk_D4.u8[0];
}
void snd_BGMCmd_EF_SegTrackTune(BGMPlayer* player, BGMPlayerTrack* track) {
track->segTrackTune = player->unk_D4.u16;
track->tuneChanged = 1;
}
void snd_BGMCmd_F0_TrackTremolo(BGMPlayer* player, BGMPlayerTrack* track) {
track->trackTremoloAmount = player->unk_D4.u8[0];
track->trackTremoloSpeed = player->unk_D4.u8[1];
track->trackTremoloTime = player->unk_D6.u8[0];
}
void snd_BGMCmd_F1_TrackTremoloSpeed(BGMPlayer* player, BGMPlayerTrack* track) {
track->trackTremoloSpeed = player->unk_D4.u8[0];
}
void snd_BGMCmd_F2_TrackTremoloTime(BGMPlayer* player, BGMPlayerTrack* track) {
track->trackTremoloTime = player->unk_D4.u8[0];
}
void snd_BGMCmd_F3_TrackTremoloStop(BGMPlayer* player, BGMPlayerTrack* track) {
track->trackTremoloTime = 0;
}
void snd_BGMCmd_F4(BGMPlayer* player, BGMPlayerTrack* track) {
track->subTrackPan = player->unk_D4.u8[0] & 0x7F;
track->unk_57 = player->unk_D4.u8[1] & 0x7F;
}
INCLUDE_ASM(void, "28910_len_5090", snd_BGMCmd_F5_TrackVoice, BGMPlayer* player, BGMPlayerTrack* track);
void snd_BGMCmd_F7_SubTrackReverbType(BGMPlayer* player, BGMPlayerTrack* track) {
u8 temp_v0 = player->unk_D4.u8[0];
u8 temp_v1 = player->unk_4C[temp_v0];
if ((temp_v0 < 4) && ((s8)temp_v1 >= 0)) {
track->subtrackReverbType = temp_v1;
} else {
track->subtrackReverbType = player->unk_235;
}
}
// unk_D4 type shenanigans
#ifdef NON_EQUIVALENT
void snd_BGMCmd_FD(BGMPlayer* player, BGMPlayerTrack* track) {
func_800560BC(player->unk_234, track->unk_5C, player->unk_D4.u16 >> 8);
}
#else
INCLUDE_ASM(void, "28910_len_5090", snd_BGMCmd_FD, BGMPlayer* player, BGMPlayerTrack* track);
#endif
void snd_BGMCmd_FE(BGMPlayer* player, BGMPlayerTrack* track) {
s32 temp = player->unk_D4.u16 + (s32)player->unk_64;
track->unk_3E = player->unk_D6.u8[0];
track->unk_04 = track->bgmReadPos;
track->bgmReadPos = temp;
}
INCLUDE_ASM(void, "28910_len_5090", snd_BGMCmd_FC_Jump, BGMPlayer* player, BGMPlayerTrack* track);
INCLUDE_ASM(void, "28910_len_5090", snd_BGMCmd_FF, BGMPlayer* player, BGMPlayerTrack* track);
void snd_BGMCmd_NOP(BGMPlayer* player, BGMPlayerTrack* track) {
}
INCLUDE_ASM(s32, "28910_len_5090", func_80050568);
INCLUDE_ASM(s32, "28910_len_5090", func_800505E4);
INCLUDE_ASM(s32, "28910_len_5090", func_80050654);
INCLUDE_ASM(s32, "28910_len_5090", func_8005068C);
INCLUDE_ASM(s32, "28910_len_5090", func_800506C8, s32 arg0, s32 arg1);
void func_80050770(BGMPlayer* player, f32 arg1) {
if (arg1 > 2.0) {
arg1 = 2.0f;
} else if (arg1 < 0.25) {
arg1 = 0.25f;
}
player->unk_D0 = arg1;
player->unk_B0 = snd_bpm_to_tempo(player, player->unk_208);
player->unkFrequency = player->unk_B0 * 10;
player->unk_BC = 0;
player->unk_B8 = 0;
player->unk_B4 = 0;
}
void func_80050818(BGMPlayer* player, s32 arg1) {
if (arg1 > 1200) {
arg1 = 1200;
} else if (arg1 < -2400) {
arg1 = -2400;
}
player->unk_20E = arg1;
}
void func_8005083C(BGMPlayer* arg0, s32 arg1, s16 arg2, s8 arg3) {
BGMPlayerTrack* temp_a1 = &arg0->unk_25C[arg1];
if (temp_a1->bgmReadPos != 0) {
arg0->unk_D4.u16 = arg2;
arg0->unk_D6.u8[0] = arg3;
snd_BGMCmd_F6_TrackVolumeFade(arg0, temp_a1);
}
}
void func_8005087C(BGMPlayer* player, s32* arg1, s32 arg2) {
player->unk_204 = arg1;
player->unk_232 = arg2;
}
INCLUDE_ASM(s32, "28910_len_5090", func_80050888);
INCLUDE_ASM(s32, "28910_len_5090", func_80050900);
INCLUDE_ASM(s32, "28910_len_5090", func_80050970);

View File

@ -1,97 +0,0 @@
#include "audio.h"
INCLUDE_ASM(s32, "2BF90", func_80050B90);
s32 func_80050C30(u32 arg0) {
if (D_8009A628->unk_20 <= arg0) {
return 3;
} else {
return 0;
}
}
void func_80050C54(s32 arg0, s8 arg1) {
D_8009A628->unk_21 = arg1;
}
INCLUDE_ASM(s32, "2BF90", func_80050C64);
INCLUDE_ASM(s32, "2BF90", func_80050CA0);
INCLUDE_ASM(void, "2BF90", func_80050D50, UnkAl1E4* arg0);
INCLUDE_ASM(s32, "2BF90", func_80050E18);
INCLUDE_ASM(s32, "2BF90", func_80050E84);
INCLUDE_ASM(s32, "2BF90", func_80050EF0);
INCLUDE_ASM(s32, "2BF90", func_80050F64);
INCLUDE_ASM(s32, "2BF90", func_80050FD0);
INCLUDE_ASM(s32, "2BF90", func_80051050);
INCLUDE_ASM(s32, "2BF90", func_800510A4);
void func_800511BC(UnkAl834* arg0) {
u32 i;
s32 j;
for (i = 0; i < ARRAY_COUNT(arg0->unk_7B4); i++) {
UnkAl8* temp = &arg0->unk_7B4[i];
if ((temp->unk_00.u8[3] == 1) && (arg0->unk_00->unk_1320[i].unk_45 != arg0->unk_22)) {
temp->unk_00.s32 = 0;
}
}
for (j = 0; j < ARRAY_COUNT(arg0->unk_24); j++) {
UnkAl1E4* temp = &arg0->unk_24[j];
s32 var;
if (temp->unk_08 != 0) {
if (arg0->unk_21 != 0) {
func_80051334(arg0, temp);
}
var = temp->unk_24;
if (var != 0) {
if (var == 3) {
temp->unk_24 = 2;
func_800522A8(arg0, temp);
func_800521E8(arg0, temp);
} else if (temp->unk_24 == 1) {
temp->unk_24 = 0;
if (temp->unk_28 != 0) {
func_80050D50(temp);
}
func_8005232C(arg0, temp);
}
} else {
if (temp->unk_28 != 0) {
func_80050D50(temp);
}
if (temp->unk_25 == 2) {
func_800521E8(arg0, temp);
temp->unk_25 = 1;
}
func_80051434(arg0, temp);
}
}
}
arg0->unk_21 = 0;
}
INCLUDE_ASM(void, "2BF90", func_80051334, UnkAl834* arg0, UnkAl1E4* arg1);
INCLUDE_ASM(void, "2BF90", func_80051434, UnkAl834* arg0, UnkAl1E4* arg1);
INCLUDE_ASM(s32, "2BF90", func_800521D0);
INCLUDE_ASM(void, "2BF90", func_800521E8, UnkAl834* arg0, UnkAl1E4* arg1);
INCLUDE_ASM(void, "2BF90", func_800522A8, UnkAl834* arg0, UnkAl1E4* arg1);
INCLUDE_ASM(void, "2BF90", func_8005232C, UnkAl834* arg0, UnkAl1E4* arg1);

View File

@ -1,58 +0,0 @@
#include "common.h"
#include "audio.h"
void func_800525A0(UnkAl19E0* arg0) {
s32 i;
for (i = 0; i < ARRAY_COUNT(arg0->unk_1320); i++) {
UnkAl48* temp = &arg0->unk_1320[i];
if (temp->unk_42 != 0) {
func_80056EE8(i);
temp->unk_42 = 0;
temp->unk_1C = NULL;
temp->unk_45 = 0;
}
}
}
void func_80052614(UnkAl19E0* arg0) {
s32 i;
for (i = 0; i < ARRAY_COUNT(arg0->unk_1320); i++) {
UnkAl48* temp = &arg0->unk_1320[i];
temp->unk_1C = 0;
temp->unk_20 = 0;
temp->unk_24 = 0;
temp->unk_28 = 0;
temp->unk_3B = 0;
temp->unk_3C = 0;
temp->unk_3D = 0;
temp->unk_3E = 0;
temp->unk_3F = 0x80;
}
}
INCLUDE_ASM(void, "2d9a0_len_890", func_80052660, UnkAl19E0* arg0);
void func_80052B44(UnkAl48* arg0) {
s32 temp_lo = ((arg0->unk_3A * arg0->unk_40 * arg0->unk_3F) >> 14) * arg0->unk_30;
arg0->unk_0C = temp_lo >> 7;
arg0->unk_08 = func_80052BC0(arg0->unk_28);
arg0->unk_3D &= ~0x2;
arg0->unk_43 |= 0x4;
}
s32 func_80052BC0(s32 arg0) {
return (arg0 / 5750) * 0xB8;
}
INCLUDE_ASM(void, "2d9a0_len_890", func_80052BF8, UnkAl48* arg0, s32* arg1);
INCLUDE_ASM(s32, "2d9a0_len_890", func_80052CFC, UnkAl48* arg0);
void func_80052E18(UnkAl48* arg0) {
arg0->unk_3D |= 0x20;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,610 +0,0 @@
#include "common.h"
#include "audio.h"
s32 D_80078DB0 = 0;
u16 D_80078DB4 = 0;
u16 D_80078DB6 = 0;
// chunks of data, not sure what
s32 D_80078DB8[] = { 0x025E0350, 0x04640554, 0x00000000, };
s32 D_80078DC4[] = { 0x0264036E, 0x045A0000, };
s32 D_80078DCC[] = { 0x025F0000, };
s32 D_80078DD0[] = { 0x0546065A, 0x075A0864, 0x00000000, };
s32 D_80078DDC[] = { 0x05000600, 0x07000800, 0x09000A00, 0x0B000C00, 0x0D000E00, 0x0F001000, 0x00000000, };
s32 D_80078DF8[] = { 0x05640666, 0x0758086E, 0x09000A00, 0x0B000C00, 0x0D000E00, 0x0F001000, 0x00000000, };
s32 D_80078E14[] = { 0x05640666, 0x0758086E, 0x097E0A58, 0x0B640C00, 0x0D000E00, 0x0F001000, 0x00000000, };
s32 D_80078E30[] = { 0x05640666, 0x0758086E, 0x097E0A58, 0x0B640C64, 0x0D6A0E64, 0x0F64106E, 0x00000000, 0x00000000, };
void func_80055050(ALHeap* heap) {
D_80078DB4 = 1;
D_80078DB0 = 0;
}
void func_80055068(u32 arg0) {
u16 temp_a0 = D_80078DB4;
u32 temp_v1 = arg0 & 0xF;
if (temp_a0 == 1) {
switch (temp_v1) {
case 2:
case 3:
break;
case 4:
snd_start_sound_with_shift(arg0 >> 4, 0, 0, 0);
break;
case 1:
if (temp_v1 == temp_a0) {
s32 filename = snd_load_song((arg0 >> 4) & 0xFF, 0);
if (filename > ASCII_TO_U32('0', ' ', ' ', '\0')) {
snd_start_song_variation(filename, (arg0 >> 0xC) & 3);
}
}
break;
}
}
}
void func_80055110(BGMPlayer* player) {
s32 i;
for (i = 0; i < ARRAY_COUNT(player->unk_238); i++) {
player->unk_238[i] = 0;
}
player->unk_25B = 0;
player->unk_25A = 0;
player->unk_259 = 0;
player->unk_258 = 0;
}
void func_8005513C(u32 arg0) {
BGMPlayer* player = NULL;
u32 playerSwitch = arg0 & 0xF;
if (playerSwitch != 0) {
if (playerSwitch == 1) {
player = D_8009A664;
} else if (playerSwitch == 2) {
player = D_8009A5FC;
}
if (player != NULL) {
u32 temp;
if (player->unk_258 < 8) {
temp = player->unk_25A;
player->unk_238[temp] = arg0 >> 4;
temp++;
if (temp >= 8) {
temp = 0;
}
player->unk_25A = temp;
player->unk_258++;
} else {
temp = player->unk_25B + 1;
if (temp > 99) {
temp = 99;
}
player->unk_25B = temp;
}
}
}
}
void snd_start_sound(s32 soundID, u8 volume, u8 pan) {
SoundManager* soundManager = D_8009A640;
s16 a1temp = volume * 256;
if (a1temp != 0) {
a1temp |= 0xFF;
}
if (pan > 0x7F) {
pan = 0x7F;
}
snd_enqueue_sfx_event(soundManager, soundID, a1temp, 0, pan);
}
void snd_start_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift) {
SoundManager* soundManager = D_8009A640;
s16 a1temp = volume * 256;
if (a1temp != 0) {
a1temp |= 0xFF;
}
if (pan > 0x7F) {
pan = 0x7F;
}
if (pitchShift > 0x960) {
pitchShift = 0x960;
} else if (pitchShift < -0x960) {
pitchShift = -0x960;
}
snd_enqueue_sfx_event(soundManager, soundID, a1temp, pitchShift, pan);
}
void snd_adjust_sound(s32 soundID, u8 volume, u8 pan) {
SoundManager* soundManager = D_8009A640;
s16 a1temp = volume * 256;
if (a1temp != 0) {
a1temp |= 0xFF;
}
if (pan > 0x7F) {
pan = 0x7F;
}
snd_enqueue_sfx_event(soundManager, soundID | 0x1000, a1temp, 0, pan);
}
void snd_adjust_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift) {
SoundManager* soundManager = D_8009A640;
s16 a1temp = volume * 256;
if (a1temp != 0) {
a1temp |= 0xFF;
}
if (pan > 0x7F) {
pan = 0x7F;
}
if (pitchShift > 0x960) {
pitchShift = 0x960;
} else if (pitchShift < -0x960) {
pitchShift = -0x960;
}
snd_enqueue_sfx_event(soundManager, soundID | 0x1000, a1temp, pitchShift, pan);
}
void snd_stop_sound(s32 soundID) {
SoundManager* soundManager = D_8009A640;
snd_enqueue_sfx_event(soundManager, soundID | 0x8000, 0, 0, 0);
}
void func_800553F4(void) {
D_8009A640->unk_168 = 1;
}
void snd_start_sound_raw(s32 soundID, s16 volume, s16 pitchShift, s32 pan) {
SoundManager* soundManager = D_8009A640;
snd_enqueue_sfx_event(soundManager, soundID, volume, pitchShift, pan);
}
s32 func_80055448(s32 arg0) {
return func_80053F80(arg0);
}
s32 func_80055464(s32 arg0, s32 arg1) {
if (func_80050C30(arg0) == 0) {
func_80050CA0(arg0, arg1);
}
}
s32 func_800554A4(s32 arg0) {
s32 ret = func_80050C30(arg0);
if (ret == 0) {
func_80050EF0(arg0);
}
return ret;
}
s32 func_800554E8(s32 arg0, s32 arg1) {
s32 ret = func_80050C30(arg0);
if (ret == 0) {
func_80050F64(arg0, arg1);
}
return ret;
}
s32 func_8005553C(s32 arg0, s32 arg1) {
s32 ret = func_80050C30(arg0);
if (ret == 0) {
func_80050E18(arg0, arg1);
}
return ret;
}
s32 func_80055590(s32 arg0, s32 arg1) {
s32 ret = func_80050C30(arg0);
if (ret == 0) {
func_80050E84(arg0, arg1);
}
return ret;
}
void func_800555E4(s32 arg0) {
if (func_80050C30(arg0) == 0) {
func_80051050(arg0);
}
}
s32 func_80055618(s32 arg0, s32 arg1) {
s32 ret = func_80050C30(arg0);
if (ret == 0) {
func_80050C54(arg0, arg1);
}
return ret;
}
s32 func_8005566C(s32 arg0, s32 arg1, s32 arg2) {
s32 ret = func_80050C30(arg0);
if (ret == 0) {
func_80050FD0(arg0, arg1, arg2);
}
return ret;
}
s32 func_800556D0(s32 arg0) {
s32 ret = func_80050C30(arg0);
if (ret == 0) {
func_80050C64(arg0, 1);
}
return ret;
}
s32 func_80055718(s32 arg0) {
s32 ret = func_80050C30(arg0);
if (ret == 0) {
func_80050C64(arg0, 0);
}
return ret;
}
void func_80055760(s32 arg0) {
u32 i;
s32 lim = 4;
D_80078DB6 = 0xFF;
for (i = 0; i < lim; i++) {
if (func_80055464(i, 0) != 0) {
return;
}
}
func_80055848(arg0);
}
s32 func_800557CC(s32 arg0) {
u32 i;
s32 lim = 4;
s32 phi_v1;
for (i = 0; i < lim; i++) {
if (i == D_80078DB6) {
phi_v1 = func_800554E8(i, arg0);
} else {
phi_v1 = func_800554A4(i);
}
if (phi_v1 != 0) {
break;
}
}
return phi_v1;
}
s32 func_80055848(s32 arg0) {
s32 lim = 4;
s32 phi_v1 = 0;
if (arg0 != D_80078DB6) {
u32 i;
for (i = 0; i < lim; i++) {
if (i == arg0) {
phi_v1 = func_80055718(arg0);
} else {
phi_v1 = func_800556D0(i);
}
if (phi_v1 != 0) {
break;
}
}
if (phi_v1 == 0) {
D_80078DB6 = arg0;
}
}
return phi_v1;
}
s32 snd_load_song(s32 songID, s32 playerIndex) {
s32* currentTrackData;
BGMPlayer* songPlayer;
snd_get_sequence_player_and_track(playerIndex, &currentTrackData, &songPlayer);
if (currentTrackData != NULL) {
return snd_load_song_files(songID, currentTrackData, songPlayer);
} else {
return 3;
}
}
INCLUDE_ASM(s32, "30450", snd_start_song);
INCLUDE_ASM(s32, "30450", snd_start_song_variation);
s32 func_800559C4(UNK_TYPE arg0) {
return func_8004DA0C(arg0);
}
void func_800559E0(void) {
func_8004DA74();
}
s32 func_800559FC(void) {
return snd_is_song_playing();
}
INCLUDE_ASM(s32, "30450", snd_set_song_variation_fade);
INCLUDE_ASM(s32, "30450", snd_set_song_fade);
INCLUDE_ASM(s32, "30450", snd_set_song_variation_fade_time);
INCLUDE_ASM(s32, "30450", func_80055AF0);
INCLUDE_ASM(s32, "30450", func_80055B28);
INCLUDE_ASM(s32, "30450", func_80055B80);
INCLUDE_ASM(s32, "30450", func_80055BB8);
INCLUDE_ASM(s32, "30450", func_80055BF0);
INCLUDE_ASM(s32, "30450", func_80055C2C);
INCLUDE_ASM(s32, "30450", func_80055C64);
INCLUDE_ASM(s32, "30450", func_80055C94);
INCLUDE_ASM(s32, "30450", func_80055CC4);
s32 func_80055CE8(s32 songName, s32* arg1, BGMPlayer** player);
// We need to figure out what currentTrackData is a list of
#ifdef NON_EQUIVALENT
s32 func_80055CE8(s32 songName, s32* arg1, BGMPlayer** player) {
UnkAl19E0* temp_a3 = D_8009A5C0;
s32 ret = 0;
if (songName == temp_a3->currentTrackData[0][2]) {
*arg1 = temp_a3->currentTrackData[0];
*player = D_8009A664;
} else if (songName == temp_a3->currentTrackData[1][2]) {
*arg1 = temp_a3->currentTrackData[1];
*player = D_8009A5FC;
} else {
ret = 1;
}
return ret;
}
#else
INCLUDE_ASM(s32, "30450", func_80055CE8, s32 songName, s32* arg1, BGMPlayer** player);
#endif
s32 func_80055D38(s32 songName, f32 arg1) {
s32 ret;
s32 unkArg1;
BGMPlayer* bgmPlayer;
ret = func_80055CE8(songName, &unkArg1, &bgmPlayer);
if (ret == 0) {
func_80050770(bgmPlayer, arg1);
}
return ret;
}
s32 func_80055D8C(s32 songName, s32 arg1) {
s32 ret;
s32 unkArg1;
BGMPlayer* bgmPlayer;
ret = func_80055CE8(songName, &unkArg1, &bgmPlayer);
if (ret == 0) {
func_80050818(bgmPlayer, arg1);
}
return ret;
}
s32 func_80055DDC(s32 songName, s32 arg1) {
s32 ret;
s32 unkArg1;
BGMPlayer* bgmPlayer;
ret = func_80055CE8(songName, &unkArg1, &bgmPlayer);
if (ret == 0) {
s32* temp_v0 = func_80055EB4(arg1);
if (temp_v0 != NULL) {
func_8005087C(bgmPlayer, temp_v0, 1);
} else {
ret = 11;
}
}
return ret;
}
s32 func_80055E48(s32 songName, s32 arg1) {
s32 ret;
s32 unkArg1;
BGMPlayer* bgmPlayer;
ret = func_80055CE8(songName, &unkArg1, &bgmPlayer);
if (ret == 0) {
s32* temp_v0 = func_80055EB4(arg1);
if (temp_v0 != NULL) {
func_8005087C(bgmPlayer, temp_v0, 0);
} else {
ret = 11;
}
}
return ret;
}
s32* func_80055EB4(s32 arg0) {
s32* ret = NULL;
switch (arg0) {
case 0:
ret = &D_80078DB8;
break;
case 1:
ret = &D_80078DC4;
break;
case 2:
ret = &D_80078DCC;
break;
case 3:
ret = &D_80078DD0;
break;
case 4:
ret = &D_80078DDC;
break;
case 5:
ret = &D_80078DF8;
break;
case 6:
ret = &D_80078E14;
break;
case 7:
ret = &D_80078E30;
break;
}
return ret;
}
static const f32 padding[] = {0.0f};
s32 func_80055F58(s32 arg0, u32 arg1, u32 arg2) {
s32* subroutine_arg4;
s32* subroutine_arg5;
s32 temp_s2 = func_80055CE8(arg0, &subroutine_arg4, &subroutine_arg5);
if (temp_s2 == 0) {
if (arg2 > 0x7F) {
arg2 = 0x7F;
}
if (arg1 > 0xF) {
arg1 = 0xF;
}
func_8005083C(subroutine_arg5, arg1, 0x60, (u8)arg2); // todo remove cast when func is defined
}
return temp_s2;
}
s32 func_80055FD4(s32 arg0, s32 arg1) {
return func_80055F58(arg0, arg1, 0);
}
s32 func_80055FF0(s32 arg0, s32 arg1) {
return func_80055F58(arg0, arg1, 0x3F);
}
s32 func_8005600C(s32 arg0, s32 arg1) {
return func_80055F58(arg0, arg1, 0x7F);
}
s32 func_80056028(s32 arg0, u8 arg1) {
return func_800506C8(arg0, arg1);
}
s32 func_80056044(s32 arg0, u8 arg1) {
return func_800506C8(arg0, arg1 | 0x57000000);
}
s32 func_80056068(s32 arg0, u8 arg1) {
return func_800506C8(arg0, arg1 | 0x7F000000);
}
void func_8005608C(s32* arg0, s32* arg1) {
UnkAl19E0* temp_v0 = D_8009A5C0;
*arg0 = temp_v0->unk_94;
*arg1 = temp_v0->unk_98;
}
void func_800560A8(void) {
D_8009A5C0->unk_9C = 1;
}
INCLUDE_ASM(s32, "30450", func_800560BC);
INCLUDE_ASM(void, "30450", func_8005610C, void);
void func_80056144(UnkFuncAl arg0, s32 arg1) {
D_8009A5C0->unk_A4[arg1] = arg0;
}
void audio_set_stereo(void) {
func_80056D5C(1);
func_80054DA8(0);
}
void audio_set_mono(void) {
func_80056D5C(0);
func_80054DA8(1);
}
void func_800561A4(s32 arg0) {
func_80054CE0(1, arg0);
}
void func_800561C4(s32 arg0) {
func_80054CE0(16, arg0);
}
void func_800561E4(s32 arg0) {
func_80054D74(16, arg0);
}
void func_80056204(void) {
func_8004BA54(D_8009A640, 0);
}
void func_80056228(void) {
func_8004BA54(D_8009A640, 1);
}

View File

@ -1,331 +0,0 @@
#include "common.h"
#include "audio.h"
#include "nu/nualsgi.h"
UnkAl0* D_80078E50 = NULL;
UnkAl0* D_80078E54 = NULL;
s8 D_80078E58 = 0;
s16 D_80078E5A = 0x7FFF;
s8 D_80078E5C = 0;
s32 D_80078E60[] = { 0x7FFF7FFC, 0x7FF57FE8, 0x7FD77FC0, 0x7FA57F84, 0x7F5F7F34, 0x7F057ED0, 0x7E977E58, 0x7E157DCD,
0x7D7F7D2D, 0x7CD67C7A, 0x7C1A7BB4, 0x7B497ADA, 0x7A6679ED, 0x796F78ED, 0x786677DA, 0x774976B4, 0x761A757B,
0x74D87430, 0x738472D3, 0x721E7164, 0x70A66FE3, 0x6F1C6E51, 0x6D816CAD, 0x6BD56AF9, 0x6A186933, 0x684A675D,
0x666C6577, 0x647E6381, 0x6280617C, 0x60735F67, 0x5E575D43, 0x5C2C5B11,
};
void func_80056250(UnkAl0* globals, ALConfig* config) {
s32 i;
ALHeap* heap = config->heap;
if (D_80078E50 != NULL) {
return;
}
globals->unk_0C = config->unk_00;
globals->unk_10 = config->unk_04;
globals->unk_00 = 0;
globals->unk_04 = 0;
globals->frequency = config->frequency;
globals->dmaNew = config->dmaNew;
D_80078E50 = globals;
D_80078E54 = globals;
D_80078E58 = 0;
D_80078E5A = 0x7FFF;
D_80078E5C = 1;
D_80078E54->unk_1C = alHeapAlloc(heap, config->unk_00, sizeof(UnkAl7C));
for (i = 0; i < config->unk_00; i++) {
UnkAl7C* al7C = &D_80078E54->unk_1C[i];
al7C->unk_04 = alHeapAlloc(heap, 1, 0x20);
al7C->unk_08 = alHeapAlloc(heap, 1, 0x20);
al7C->dmaProc = ((ALDMAproc (*)(NUDMAState**))(D_80078E54->dmaNew))(&al7C->dmaState);
al7C->unk_2C = 0;
al7C->unk_30 = 1;
al7C->unk_34 = 0;
al7C->unk_38 = alHeapAlloc(heap, 1, 0x20);
al7C->unk_40 = 0;
al7C->unk_44 = 1;
al7C->unk_3C = 1.0f;
al7C->unk_48 = alHeapAlloc(heap, 1, 0x50);
al7C->unk_6C = 1;
al7C->unk_70 = 0;
al7C->unk_4E = 1;
al7C->unk_5C = 1;
al7C->unk_62 = 1;
al7C->unk_50 = 1;
al7C->unk_52 = 1;
al7C->unk_54 = 0;
al7C->unk_56 = 0;
al7C->unk_5A = 1;
al7C->unk_58 = 0;
al7C->unk_60 = 1;
al7C->unk_5E = 0;
al7C->unk_64 = 0;
al7C->unk_68 = 0;
al7C->unk_4C = 64;
al7C->unk_74 = 0;
al7C->unk_00 = 0;
al7C->unk_78 = 0;
al7C->unk_79 = i;
}
D_80078E54->unk_20 = alHeapAlloc(heap, config->unk_04, sizeof(UnkLen18));
for (i = 0; i < config->unk_04; i++) {
UnkLen18* temp = &D_80078E54->unk_20[i];
temp->unk_10 = 0;
temp->unk_14 = 0;
temp->unk_00 = 0x7FFF;
temp->unk_0C = 0;
temp->unk_04 = alHeapAlloc(heap, 1, 0x14);
temp->unk_08 = alHeapAlloc(heap, 1, 0x14);
func_80058E84(temp->unk_04, temp->unk_0C, heap);
func_80058E84(temp->unk_08, temp->unk_0C, heap);
}
D_80078E54->unk_24 = alHeapAlloc(heap, 0x170, 2);
D_80078E54->unk_28 = alHeapAlloc(heap, 0x170, 2);
D_800A3FEC = 0;
D_800A3FEE = 0;
D_800A3FF0 = 4;
D_800A3FE0 = alHeapAlloc(heap, 0x2E0, 2);
D_800A3FE4 = alHeapAlloc(heap, 0x2E0, 2);
for (i = 0; i < 0x2E0; i++) {
D_800A3FE4[i] = D_800A3FE0[i] = 0;
}
D_80078E54->heap = heap;
}
void func_800565A4(void) {
if (D_80078E50 != NULL) {
D_80078E50 = NULL;
}
}
INCLUDE_ASM(Acmd*, "31650", alAudioFrame, Acmd* cmdList, s32* cmdLen, s16* outBuf, s32 outLen);
void func_80056D34(void) {
D_80078E58 = 1;
}
void func_80056D44(s16 arg0) {
D_80078E5A = arg0;
}
s16 func_80056D50(void) {
return D_80078E5A;
}
#ifdef NON_MATCHING
void func_80056D5C(s8 arg0) {
D_80078181 = arg0;
D_80078E5C = 1;
}
#else
INCLUDE_ASM(s32, "31650", func_80056D5C);
#endif
void func_80056D78(u8 arg0, u16 arg1) {
UnkLen18* temp = &D_80078E54->unk_20[arg0];
temp->unk_00 = arg1 & 0x7FFF;
}
u16 func_80056DA4(u8 arg0, u16 arg1) {
UnkLen18* temp = &D_80078E54->unk_20[arg0];
return temp->unk_00;
}
void func_80056DCC(u8 arg0, u8 arg1) {
UnkLen18* temp = &D_80078E54->unk_20[arg0];
temp->unk_0C = arg1;
func_8005904C(temp->unk_04, arg1);
func_8005904C(temp->unk_08, arg1);
}
INCLUDE_ASM(s32, "31650", func_80056E34);
void func_80056EC0(u8 arg0, s8 arg1) {
UnkAl7C* al7C = &D_80078E54->unk_1C[arg0];
al7C->unk_78 = arg1;
}
INCLUDE_ASM(void, "31650", func_80056EE8, u8 arg0);
void func_80056F78(u8 arg0) {
UnkAl7C* al7C = &D_80078E54->unk_1C[arg0];
al7C->unk_70 = 1;
}
INCLUDE_ASM(void, "31650", func_80056FA4, u8 arg0, u8 arg1, s32 arg2, f32 arg3, s16 arg4, u8 arg5, u8 arg6,
s32 arg7);
INCLUDE_ASM(void, "31650", func_80057224, u8 arg0, Instrument* arg1);
void func_80057344(u8 arg0, f32 arg1) {
UnkAl7C* al7C = &D_80078E54->unk_1C[arg0];
al7C->unk_3C = arg1;
}
INCLUDE_ASM(void, "31650", func_8005736C, u8 arg0, s16 arg1, s32 arg2, u8 arg3, u8 arg4);
INCLUDE_ASM(void, "31650", func_80057548, u8 arg0, u8 arg1, u8 arg2);
INCLUDE_ASM(void, "31650", func_800576EC, u8 arg0, s32 arg1, s32 arg2);
INCLUDE_ASM(s32, "31650", func_80057874);
INCLUDE_ASM(s32, "31650", func_800579D8);
s32 func_80057B64(u8 arg0) {
UnkAl7C* al7C = &D_80078E54->unk_1C[arg0];
return al7C->unk_70;
}
s32 func_80057B8C(u8 arg0) {
UnkAl7C* al7C = &D_80078E54->unk_1C[arg0];
return al7C->unk_78;
}
f32 func_80057BB4(u8 arg0) {
UnkAl7C* al7C = &D_80078E54->unk_1C[arg0];
return al7C->unk_3C;
}
u8 func_80057BDC(u8 arg0) {
UnkAl7C* al7C = &D_80078E54->unk_1C[arg0];
return al7C->unk_4C_s.unk_4D;
}
s16 func_80057C04(u8 arg0) {
UnkAl7C* al7C = &D_80078E54->unk_1C[arg0];
return al7C->unk_54;
}
s16 func_80057C2C(u8 arg0) {
UnkAl7C* al7C = &D_80078E54->unk_1C[arg0];
return al7C->unk_56;
}
INCLUDE_ASM(s32, "31650", func_80057C54);
INCLUDE_ASM(s32, "31650", func_80057D0C);
void func_80057DC8(s32 arg0) {
if (arg0 < 2) {
D_800A3FF0 = 0;
D_800A3FEE = 0;
}
D_800A3FF0 = arg0;
if (arg0 >= 5) {
D_800A3FF0 = 4;
}
}
void func_80057E08(u8 arg0) {
s32* phi_a1 = (s32*)D_800A3FE0;
s32* phi_v1 = (s32*)D_800A3FE4;
s32 i;
for (i = 0; i < 0x170; i++) {
*phi_a1++ = 0;
*phi_v1++ = 0;
}
D_800A3FEC = arg0;
D_800A3FEE = 1;
D_800A3FE8 = 0;
}
void func_80057E5C(u8 arg0) {
s32* phi_a1 = (s32*)D_800A3FE0;
s32* phi_v1 = (s32*)D_800A3FE4;
s32 i;
for (i = 0; i < 0x170; i++) {
*phi_a1++ = 0;
*phi_v1++ = 0;
}
D_800A3FEC = arg0;
D_800A3FEE = 2;
D_800A3FE8 = 0;
}
void func_80057EB0(void) {
D_800A3FEC = 0;
D_800A3FEE = 0;
D_800A3FE8 = 0;
}
void func_80057ED0(s16 arg0) {
s32* phi_a1 = (s32*)D_800A3FE0;
s32* phi_v1 = (s32*)D_800A3FE4;
s32 i;
for (i = 0; i < 0x170; i++) {
*phi_a1++ = 0;
*phi_v1++ = 0;
}
D_800A3FEC = 0;
D_800A3FEE = arg0;
D_800A3FE8 = 0;
}
void alHeapInit(ALHeap* hp, u8* base, s32 len) {
u32 i;
s32 alignBytes = 0x10 - ((s32)base & 0xF);
if (alignBytes != 0x10) {
hp->base = base + alignBytes;
} else {
hp->base = base;
}
hp->len = len;
hp->count = 0;
hp->cur = hp->base;
for (i = 0; i < (u32)(hp->len) >> 2; i++) {
((u32*)hp->base)[i] = 0;
}
}
void* alHeapAlloc(ALHeap* heap, s32 arg1, s32 size) {
void* ret = NULL;
u8* newCur = &heap->cur[ALIGN16(arg1 * size)];
if (&heap->base[heap->len] >= newCur) {
ret = heap->cur;
heap->cur = newCur;
}
return ret;
}
void alCopy(void* src, void* dst, s32 size) {
s32 i;
u8* srcIt = src;
u8* dstIt = dst;
for (i = 0; i < size; i++) {
*dstIt++ = *srcIt++;
}
}
INCLUDE_ASM(s32, "31650", func_80058004);

View File

@ -1,7 +0,0 @@
#include "common.h"
INCLUDE_ASM(s32, "33450", func_80058050);
INCLUDE_ASM(s32, "33450", func_80058B20);
INCLUDE_ASM(s32, "33450", func_80058C6C);

View File

@ -1,87 +0,0 @@
#include "common.h"
s32 D_8007EFE0[] = {
0x00000003, 0x0000000B, 0x00000000, 0x00000009, 0x00002666, 0xFFFFD99A, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000003, 0x00000007, 0x00000CCC, 0xFFFFF334, 0x00003FFF, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x0000000A, 0x00001388, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00005000
};
s32 D_8007F048[] = {
0x00000004, 0x0000000E, 0x00000000, 0x00000009, 0x00002666, 0xFFFFD99A, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000002, 0x00000006, 0x00000CCC, 0xFFFFF334, 0x00003FFF, 0x00000000, 0x00000000, 0x00000000,
0x00000009, 0x0000000C, 0x00000CCC, 0xFFFFF334, 0x00003FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x0000000D, 0x00001770, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00005000, 0x00000004, 0x00000011,
0x00000000, 0x0000000B, 0x00002666, 0xFFFFD99A, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004,
0x00000009, 0x00000CCC, 0xFFFFF334, 0x00003FFF, 0x00000000, 0x00000000, 0x00000000, 0x0000000B, 0x0000000F,
0x00000CCC, 0xFFFFF334, 0x00003FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0x00001F40,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00005000
};
s32 D_8007F158[] = {
0x00000001, 0x0000000E, 0x00000000, 0x0000000D, 0x00004E20, 0x00000000, 0x00007FFF, 0x00000000, 0x00000000,
0x00007FFF
};
s32 D_8007F180[] = {
0x00000001, 0x00000003, 0x00000000, 0x00000001, 0x00004000, 0x00000000, 0x00007FFF, 0x00001DB0, 0x000002BC,
0x00000000
};
s32 D_8007F1A8[] = {
0x00000001, 0x00000003, 0x00000000, 0x00000001, 0x00000000, 0x00005FFF, 0x00007FFF, 0x0000017C, 0x000001F4,
0x00000000
};
s32 D_8007F1D0[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000
};
typedef struct unk341d0 {
s32 unk_00;
s16 unk_04;
s16 unk_06;
s16 unk_08;
s16 unk_0A;
s16* unk_0C;
s16* unk_10;
} unk341d0;
s32* D_8007F1F8 = D_8007F1D0;
s32* D_8007F1FC = D_8007F1D0;
s32* D_8007F200 = D_8007F1D0;
s32* D_8007F204 = D_8007F1D0;
void func_80058DD0(s16* arg);
INCLUDE_ASM(s32, "341d0", func_80058DD0);
INCLUDE_ASM(s32, "341d0", func_80058E84);
INCLUDE_ASM(s32, "341d0", func_80058F88);
void func_80059008(unk341d0* arg0, s16 arg1, s16 arg2, s16 arg3) {
arg0->unk_06 = arg1;
arg0->unk_08 = arg2;
if (arg3 != 0) {
arg0->unk_0C = arg0->unk_10;
*arg0->unk_0C = arg3;
func_80058DD0(arg0->unk_0C);
return;
}
arg0->unk_0C = NULL;
}
INCLUDE_ASM(s32, "341d0", func_8005904C);
INCLUDE_ASM(s32, "341d0", func_80059310);
INCLUDE_ASM(s32, "341d0", func_800598A0);
INCLUDE_ASM(s32, "341d0", func_80059AB8);
INCLUDE_ASM(s32, "341d0", func_80059BD4);

View File

@ -473,11 +473,11 @@ f32 func_800E34D8(void) {
return ret; return ret;
} }
f32 player_check_collision_below(f32 arg0, s32* colliderID) { f32 player_check_collision_below(f32 offset, s32* colliderID) {
PlayerStatus* playerStatus = &gPlayerStatus; PlayerStatus* playerStatus = &gPlayerStatus;
CollisionStatus* collisionStatus = &gCollisionStatus; CollisionStatus* collisionStatus = &gCollisionStatus;
f32 temp_f4 = playerStatus->colliderHeight * 0.5f; f32 temp_f4 = playerStatus->colliderHeight * 0.5f;
f32 outLength = fabsf(arg0) + temp_f4; f32 outLength = fabsf(offset) + temp_f4;
f32 x = playerStatus->position.x; f32 x = playerStatus->position.x;
f32 y = playerStatus->position.y + temp_f4; f32 y = playerStatus->position.y + temp_f4;
f32 z = playerStatus->position.z; f32 z = playerStatus->position.z;
@ -486,10 +486,10 @@ f32 player_check_collision_below(f32 arg0, s32* colliderID) {
&sp38, &sp3C, &sp40, &sp44); &sp38, &sp3C, &sp40, &sp44);
if (hit < 0) { if (hit < 0) {
if (arg0 >= 0.0f && collisionStatus->currentCeiling >= 0) { if (offset >= 0.0f && collisionStatus->currentCeiling >= 0) {
return playerStatus->position.y; return playerStatus->position.y;
} }
y = playerStatus->position.y + arg0; y = playerStatus->position.y + offset;
} else { } else {
collisionStatus->currentFloor = hit; collisionStatus->currentFloor = hit;
collisionStatus->lastTouchedFloor = -1; collisionStatus->lastTouchedFloor = -1;

View File

@ -530,7 +530,7 @@ void show_coin_counter(void) {
} }
if (uiStatus->unk_6C[0] == 0) { if (uiStatus->unk_6C[0] == 0) {
set_window_properties(0x14, 32, 164, 64, 20, 0x15, coin_counter_draw_content, 0, -1); set_window_properties(WINDOW_ID_20, 32, 164, 64, 20, 0x15, coin_counter_draw_content, 0, -1);
set_window_update(WINDOW_ID_20, (s32)basic_window_update); set_window_update(WINDOW_ID_20, (s32)basic_window_update);
index = hud_element_create(&HES_MenuTimes); index = hud_element_create(&HES_MenuTimes);
uiStatus->iconIndex10 = index; uiStatus->iconIndex10 = index;

View File

@ -413,9 +413,9 @@ void set_cam_viewport(s16 id, s16 x, s16 y, s16 width, s16 height) {
camera->vp.vp.vscale[2] = 0x1FF; camera->vp.vp.vscale[2] = 0x1FF;
camera->vp.vp.vscale[3] = 0; camera->vp.vp.vscale[3] = 0;
camera->vp.vp.vtrans[0] = (((u16)camera->viewportStartX + (camera->viewportW / 2)) << 16) >> 14; camera->vp.vp.vtrans[0] = 4 * (s16) ((u16) camera->viewportStartX + (camera->viewportW / 2));
camera->vp.vp.vtrans[1] = ((u16)camera->viewportStartY + (camera->viewportH / 2)); camera->vp.vp.vtrans[1] = (s16) ((u16) camera->viewportStartY + (camera->viewportH / 2));
camera->vp.vp.vtrans[1] = (camera->vp.vp.vtrans[1] << 16) >> 14; // needed to match camera->vp.vp.vtrans[1] = 4 * camera->vp.vp.vtrans[1];
camera->vp.vp.vtrans[2] = 0x1FF; camera->vp.vp.vtrans[2] = 0x1FF;
camera->vp.vp.vtrans[3] = 0; camera->vp.vp.vtrans[3] = 0;
@ -424,8 +424,8 @@ void set_cam_viewport(s16 id, s16 x, s16 y, s16 width, s16 height) {
camera->vpAlt.vp.vscale[2] = 0x1FF; camera->vpAlt.vp.vscale[2] = 0x1FF;
camera->vpAlt.vp.vscale[3] = 0; camera->vpAlt.vp.vscale[3] = 0;
camera->vpAlt.vp.vtrans[0] = gGameStatusPtr->unk_82 + ((((u16) camera->viewportStartX + (camera->viewportW / 2)) << 16) >> 14); camera->vpAlt.vp.vtrans[0] = gGameStatusPtr->unk_82 + 4 * (s16) ((u16) camera->viewportStartX + (camera->viewportW / 2));
camera->vpAlt.vp.vtrans[1] = gGameStatusPtr->unk_83 + ((((u16) camera->viewportStartY + (camera->viewportH / 2)) << 16) >> 14); camera->vpAlt.vp.vtrans[1] = gGameStatusPtr->unk_83 + 4 * (s16) ((u16) camera->viewportStartY + (camera->viewportH / 2));
camera->vpAlt.vp.vtrans[2] = 0x200; camera->vpAlt.vp.vtrans[2] = 0x200;
camera->vpAlt.vp.vtrans[3] = 0; camera->vpAlt.vp.vtrans[3] = 0;
} }

View File

@ -165,7 +165,7 @@ s32 popup_menu_update(void) {
D_8010D65C = elementID; D_8010D65C = elementID;
hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_80); hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_80);
hud_element_set_tint(elementID, 255, 255, 255); hud_element_set_tint(elementID, 255, 255, 255);
if (gPopupMenu->popupType != 2) { if (gPopupMenu->popupType != POPUP_MENU_THROW_AWAY_ITEM) {
hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_DISABLED); hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_DISABLED);
} }
@ -187,31 +187,31 @@ s32 popup_menu_update(void) {
D_8010D674 = elementID; D_8010D674 = elementID;
hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_DROP_SHADOW | HUD_ELEMENT_FLAGS_80); hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_DROP_SHADOW | HUD_ELEMENT_FLAGS_80);
if (gPopupMenu->popupType == 3) { if (gPopupMenu->popupType == POPUP_MENU_TRADE_FOR_BADGE) {
D_8010D660 = hud_element_create(&HES_StatusStarPiece); D_8010D660 = hud_element_create(&HES_StatusStarPiece);
elementID = D_8010D660; elementID = D_8010D660;
hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_80); hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_80);
hud_element_set_tint(elementID, 255, 255, 255); hud_element_set_tint(elementID, 255, 255, 255);
} }
if (gPopupMenu->popupType == 4) { if (gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
D_8010D660 = hud_element_create(&HES_StatusStarPiece); D_8010D660 = hud_element_create(&HES_StatusStarPiece);
elementID = D_8010D660; elementID = D_8010D660;
hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80); hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_FILTER_TEX | HUD_ELEMENT_FLAGS_80);
hud_element_set_tint(elementID, 255, 255, 255); hud_element_set_tint(elementID, 255, 255, 255);
} }
if (gPopupMenu->popupType == 5) { if (gPopupMenu->popupType == POPUP_MENU_SELL_ITEM) {
D_8010D660 = hud_element_create(&HES_StatusCoin); D_8010D660 = hud_element_create(&HES_StatusCoin);
elementID = D_8010D660; elementID = D_8010D660;
hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_80); hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_80);
hud_element_set_tint(elementID, 255, 255, 255); hud_element_set_tint(elementID, 255, 255, 255);
} }
if (gPopupMenu->popupType == 3 || gPopupMenu->popupType == 4) { if (gPopupMenu->popupType == POPUP_MENU_TRADE_FOR_BADGE || gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
D_8010D664 = hud_element_create(&HES_MenuTimes); D_8010D664 = hud_element_create(&HES_MenuTimes);
elementID = D_8010D664; elementID = D_8010D664;
hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_80); hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_80);
hud_element_set_tint(elementID, 255, 255, 255); hud_element_set_tint(elementID, 255, 255, 255);
} }
if (gPopupMenu->popupType == one || gPopupMenu->popupType == 4) { if (gPopupMenu->popupType == one || gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
D_8010D668 = hud_element_create(D_80109890[0]); D_8010D668 = hud_element_create(D_80109890[0]);
elementID = D_8010D668; elementID = D_8010D668;
hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_80); hud_element_set_flags(elementID, HUD_ELEMENT_FLAGS_80);
@ -233,66 +233,66 @@ s32 popup_menu_update(void) {
case 6: case 6:
case 7: case 7:
case 12: case 12:
set_window_properties(0xE, posX, posY, 0x91, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1); set_window_properties(WINDOW_ID_14, posX, posY, 0x91, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1);
if (gPopupMenu->unk_31C == 0) { if (gPopupMenu->unk_31C == 0) {
set_window_properties(0xF, 0x19, -6, 0x5F, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_15, 0x19, -6, 0x5F, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
} else { } else {
set_window_properties(0xF, 0xC, -6, 0x79, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_15, 0xC, -6, 0x79, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
} }
set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW);
set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE);
break; break;
case 1: case 1:
set_window_properties(0xE, posX, posY, 0x8B, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1); set_window_properties(WINDOW_ID_14, posX, posY, 0x8B, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1);
set_window_properties(0x11, 0xD, -6, 0x72, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_17, 0xD, -6, 0x72, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
set_window_update(WINDOW_ID_15, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_15, WINDOW_UPDATE_HIDE);
set_window_update(WINDOW_ID_17, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_17, WINDOW_UPDATE_SHOW);
break; break;
case 3: case 3:
set_window_properties(0xE, posX, posY, 0xA2, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1); set_window_properties(WINDOW_ID_14, posX, posY, 0xA2, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1);
set_window_properties(0xF, 0x11, -6, 0x60, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_15, 0x11, -6, 0x60, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW);
set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE);
break; break;
case 4: case 4:
set_window_properties(0xE, posX, posY, 0x92, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1); set_window_properties(WINDOW_ID_14, posX, posY, 0x92, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1);
set_window_properties(0x11, 0xC, -6, 0x72, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_17, 0xC, -6, 0x72, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
set_window_update(WINDOW_ID_15, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_15, WINDOW_UPDATE_HIDE);
set_window_update(WINDOW_ID_17, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_17, WINDOW_UPDATE_SHOW);
break; break;
case 5: case 5:
set_window_properties(0xE, posX, posY, 0xA7, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1); set_window_properties(WINDOW_ID_14, posX, posY, 0xA7, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1);
set_window_properties(0xF, 0x16, -6, 0x5F, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_15, 0x16, -6, 0x5F, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW);
set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE);
break; break;
case 8: case 8:
set_window_properties(0xE, posX, posY, 0xAA, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1); set_window_properties(WINDOW_ID_14, posX, posY, 0xAA, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1);
set_window_properties(0xF, 0x20, -6, 0x68, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_15, 0x20, -6, 0x68, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW);
set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE);
break; break;
case 9: case 9:
set_window_properties(0xE, posX, posY, 0x91, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1); set_window_properties(WINDOW_ID_14, posX, posY, 0x91, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1);
set_window_properties(0xF, 0xC, -6, 0x79, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_15, 0xC, -6, 0x79, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW);
set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE);
break; break;
case 10: case 10:
set_window_properties(0xE, posX, posY, 0x80, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1); set_window_properties(WINDOW_ID_14, posX, posY, 0x80, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1);
set_window_properties(0xF, 0xC, -6, 0x68, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_15, 0xC, -6, 0x68, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW);
set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE);
break; break;
case 11: case 11:
set_window_properties(0xE, posX, posY, 0x95, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1); set_window_properties(WINDOW_ID_14, posX, posY, 0x95, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1);
set_window_properties(0xF, 6, -6, 0x8B, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_15, 6, -6, 0x8B, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_15, WINDOW_UPDATE_SHOW);
set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_17, WINDOW_UPDATE_HIDE);
break; break;
case 13: case 13:
set_window_properties(0xE, posX, posY, 0x83, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1); set_window_properties(WINDOW_ID_14, posX, posY, 0x83, ((s8) D_8010D656 * 0xD) + 0x1A, 0x14, popup_menu_draw_menu_contents, NULL, -1);
set_window_properties(0x11, 0xA, -6, 0x72, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE); set_window_properties(WINDOW_ID_17, 0xA, -6, 0x72, 0x10, 0x15, popup_menu_draw_title_contents, NULL, 0xE);
set_window_update(WINDOW_ID_15, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_15, WINDOW_UPDATE_HIDE);
set_window_update(WINDOW_ID_17, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_17, WINDOW_UPDATE_SHOW);
break; break;
@ -300,15 +300,15 @@ s32 popup_menu_update(void) {
switch (gPopupMenu->popupType) { switch (gPopupMenu->popupType) {
case 3: case 3:
set_window_properties(0x10, 0x7E, -0xE, 0x20, 0x20, 0x15, func_800F4C6C, NULL, 0xE); set_window_properties(WINDOW_ID_16, 0x7E, -0xE, 0x20, 0x20, 0x15, func_800F4C6C, NULL, 0xE);
break; break;
case 5: case 5:
set_window_properties(0x10, 0x83, -0xE, 0x20, 0x20, 0x15, func_800F4C6C, NULL, 0xE); set_window_properties(WINDOW_ID_16, 0x83, -0xE, 0x20, 0x20, 0x15, func_800F4C6C, NULL, 0xE);
break; break;
} }
if (gPopupMenu->popupType == 3) { if (gPopupMenu->popupType == POPUP_MENU_TRADE_FOR_BADGE) {
set_window_properties(0x14, D_8010D688, D_8010D68A, 0x40, 0x14, 0x15, func_800F4D28, NULL, -1); set_window_properties(WINDOW_ID_20, D_8010D688, D_8010D68A, 0x40, 0x14, 0x15, func_800F4D28, NULL, -1);
} }
do { do {
@ -328,8 +328,9 @@ s32 popup_menu_update(void) {
D_8010D655 = D_8010D654 + D_8010D68F; D_8010D655 = D_8010D654 + D_8010D68F;
D_8010D658 = -D_8010D654 * 0xD; D_8010D658 = -D_8010D654 * 0xD;
if (gPopupMenu->popupType >= 0 && (gPopupMenu->popupType < 0xA || gPopupMenu->popupType == 0xC)) { if (gPopupMenu->popupType >= POPUP_MENU_USE_ITEM
set_window_properties(0x13, D_8010D680, D_8010D682, 0x118, 0x20, 0x14, func_800F48F4, NULL, -1); && (gPopupMenu->popupType < POPUP_MENU_READ_DIARY_PAGE || gPopupMenu->popupType == POPUP_MENU_USEKEY)) {
set_window_properties(WINDOW_ID_19, D_8010D680, D_8010D682, 0x118, 0x20, 0x14, func_800F48F4, NULL, -1);
} }
posX = D_8010D684; posX = D_8010D684;
@ -340,26 +341,26 @@ s32 popup_menu_update(void) {
case 7: case 7:
case 9: case 9:
case 12: case 12:
set_window_properties(0x15, posX, posY, 0x90, 0x20, 0x14, func_800F4944, NULL, -1); set_window_properties(WINDOW_ID_21, posX, posY, 0x90, 0x20, 0x14, func_800F4944, NULL, -1);
break; break;
case 1: case 1:
case 2: case 2:
case 13: case 13:
set_window_properties(0x15, posX, posY, 0x90, 0x28, 0x14, func_800F4944, NULL, -1); set_window_properties(WINDOW_ID_21, posX, posY, 0x90, 0x28, 0x14, func_800F4944, NULL, -1);
break; break;
case 3: case 3:
case 10: case 10:
case 11: case 11:
set_window_properties(0x15, posX, posY, 0x80, 0x28, 0x14, func_800F4944, NULL, -1); set_window_properties(WINDOW_ID_21, posX, posY, 0x80, 0x28, 0x14, func_800F4944, NULL, -1);
break; break;
case 4: case 4:
set_window_properties(0x15, posX, posY, 0x88, 0x28, 0x14, func_800F4944, NULL, -1); set_window_properties(WINDOW_ID_21, posX, posY, 0x88, 0x28, 0x14, func_800F4944, NULL, -1);
break; break;
case 8: case 8:
set_window_properties(0x15, posX, posY, 0x70, 0x28, 0x14, func_800F4944, NULL, -1); set_window_properties(WINDOW_ID_21, posX, posY, 0x70, 0x28, 0x14, func_800F4944, NULL, -1);
break; break;
case 5: case 5:
set_window_properties(0x15, posX, posY, 0x78, 0x20, 0x14, func_800F4944, NULL, -1); set_window_properties(WINDOW_ID_21, posX, posY, 0x78, 0x20, 0x14, func_800F4944, NULL, -1);
break; break;
} }
@ -419,14 +420,14 @@ s32 popup_menu_update(void) {
set_window_update(WINDOW_ID_21, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_21, WINDOW_UPDATE_SHOW);
} }
if (gPopupMenu->popupType == 3) { if (gPopupMenu->popupType == POPUP_MENU_TRADE_FOR_BADGE) {
set_window_update(WINDOW_ID_16, (s32)basic_window_update); set_window_update(WINDOW_ID_16, (s32)basic_window_update);
set_window_update(WINDOW_ID_20, (s32)basic_window_update); set_window_update(WINDOW_ID_20, (s32)basic_window_update);
} }
if (gPopupMenu->popupType == 4) { if (gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
set_window_update(WINDOW_ID_18, (s32)basic_window_update); set_window_update(WINDOW_ID_18, (s32)basic_window_update);
} }
if (gPopupMenu->popupType == 5) { if (gPopupMenu->popupType == POPUP_MENU_SELL_ITEM) {
set_window_update(WINDOW_ID_16, (s32)basic_window_update); set_window_update(WINDOW_ID_16, (s32)basic_window_update);
} }
D_8010D640 = 1; D_8010D640 = 1;
@ -438,7 +439,7 @@ s32 popup_menu_update(void) {
D_8010D64C = D_8010D648; D_8010D64C = D_8010D648;
if (gGameStatusPtr->heldButtons[0] & (BUTTON_STICK_UP | BUTTON_Z) && if (gGameStatusPtr->heldButtons[0] & (BUTTON_STICK_UP | BUTTON_Z) &&
(D_8010D648 > 0 || (gGameStatusPtr->pressedButtons[0] & 0x12000))) (D_8010D648 > 0 || (gGameStatusPtr->pressedButtons[0] & (BUTTON_STICK_UP | BUTTON_Z))))
{ {
do { do {
D_8010D648--; D_8010D648--;
@ -519,7 +520,7 @@ s32 popup_menu_update(void) {
D_8010D640 = 0x1E; D_8010D640 = 0x1E;
break; break;
} }
if ((D_8010D68E != 0) && (gPopupMenu->popupType == 0 || gPopupMenu->popupType == 3)) { if ((D_8010D68E != 0) && (gPopupMenu->popupType == POPUP_MENU_USE_ITEM || gPopupMenu->popupType == POPUP_MENU_TRADE_FOR_BADGE)) {
sfx_play_sound(SOUND_MENU_ERROR); sfx_play_sound(SOUND_MENU_ERROR);
} }
break; break;
@ -604,18 +605,18 @@ s32 popup_menu_update(void) {
hud_element_set_tint(D_8010D670, 160, 160, 160); hud_element_set_tint(D_8010D670, 160, 160, 160);
hud_element_set_tint(D_8010D674, 160, 160, 160); hud_element_set_tint(D_8010D674, 160, 160, 160);
hud_element_set_script(D_8010D66C, &HES_HandPointer); hud_element_set_script(D_8010D66C, &HES_HandPointer);
if (gPopupMenu->popupType == 3) { if (gPopupMenu->popupType == POPUP_MENU_TRADE_FOR_BADGE) {
hud_element_set_tint(D_8010D660, 160, 160, 160); hud_element_set_tint(D_8010D660, 160, 160, 160);
hud_element_set_tint(D_8010D664, 160, 160, 160); hud_element_set_tint(D_8010D664, 160, 160, 160);
} }
if (gPopupMenu->popupType == 4) { if (gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
hud_element_set_tint(D_8010D660, 160, 160, 160); hud_element_set_tint(D_8010D660, 160, 160, 160);
hud_element_set_tint(D_8010D664, 160, 160, 160); hud_element_set_tint(D_8010D664, 160, 160, 160);
} }
if (gPopupMenu->popupType == 1 || gPopupMenu->popupType == 4) { if (gPopupMenu->popupType == 1 || gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
hud_element_set_tint(D_8010D668, 160, 160, 160); hud_element_set_tint(D_8010D668, 160, 160, 160);
} }
if (gPopupMenu->popupType == 5) { if (gPopupMenu->popupType == POPUP_MENU_SELL_ITEM) {
hud_element_set_tint(D_8010D660, 160, 160, 160); hud_element_set_tint(D_8010D660, 160, 160, 160);
} }
D_8010D690 = 0xD; D_8010D690 = 0xD;
@ -694,7 +695,7 @@ s32 popup_menu_update(void) {
set_window_update(WINDOW_ID_21, WINDOW_UPDATE_HIDE); set_window_update(WINDOW_ID_21, WINDOW_UPDATE_HIDE);
} }
width = get_msg_width(0x1D006B, 0) + 23; width = get_msg_width(0x1D006B, 0) + 23;
set_window_properties(9, 160 - (width / 2), 0x50, width, 0x28, 0x14, func_800F4CF0, NULL, -1); set_window_properties(WINDOW_ID_9, 160 - (width / 2), 0x50, width, 0x28, 0x14, func_800F4CF0, NULL, -1);
set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW);
D_8010D644 = 0x3C; D_8010D644 = 0x3C;
D_8010D640 = 0x20; D_8010D640 = 0x20;
@ -724,18 +725,18 @@ s32 popup_menu_update(void) {
hud_element_set_tint(D_8010D674, 160, 160, 160); hud_element_set_tint(D_8010D674, 160, 160, 160);
hud_element_set_script(D_8010D66C, &HES_HandPointer); hud_element_set_script(D_8010D66C, &HES_HandPointer);
if (gPopupMenu->popupType == 3) { if (gPopupMenu->popupType == POPUP_MENU_TRADE_FOR_BADGE) {
hud_element_set_tint(D_8010D660, 160, 160, 160); hud_element_set_tint(D_8010D660, 160, 160, 160);
hud_element_set_tint(D_8010D664, 160, 160, 160); hud_element_set_tint(D_8010D664, 160, 160, 160);
} }
if (gPopupMenu->popupType == 4) { if (gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
hud_element_set_tint(D_8010D660, 160, 160, 160); hud_element_set_tint(D_8010D660, 160, 160, 160);
hud_element_set_tint(D_8010D664, 160, 160, 160); hud_element_set_tint(D_8010D664, 160, 160, 160);
} }
if (gPopupMenu->popupType == 1 || gPopupMenu->popupType == 4) { if (gPopupMenu->popupType == 1 || gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
hud_element_set_tint(D_8010D668, 160, 160, 160); hud_element_set_tint(D_8010D668, 160, 160, 160);
} }
if (gPopupMenu->popupType == 5) { if (gPopupMenu->popupType == POPUP_MENU_SELL_ITEM) {
hud_element_set_tint(D_8010D660, 160, 160, 160); hud_element_set_tint(D_8010D660, 160, 160, 160);
} }
@ -771,7 +772,7 @@ s32 popup_menu_update(void) {
msgID = 0x1D0069; msgID = 0x1D0069;
} }
width = get_msg_width(msgID, 0) + 23; width = get_msg_width(msgID, 0) + 23;
set_window_properties(0x15, 160 - (width / 2), 76, width, 32, 0x13, func_800F4C1C, NULL, -1); set_window_properties(WINDOW_ID_21, 160 - (width / 2), 76, width, 32, 0x13, func_800F4C1C, NULL, -1);
set_window_update(WINDOW_ID_21, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_21, WINDOW_UPDATE_SHOW);
D_8010D6A0 = msg_get_printer_for_msg(0x1E001D, &D_8010D6A4); D_8010D6A0 = msg_get_printer_for_msg(0x1E001D, &D_8010D6A4);
msg_printer_set_origin_pos(D_8010D6A0, 160, 0x90); msg_printer_set_origin_pos(D_8010D6A0, 160, 0x90);
@ -799,18 +800,18 @@ s32 popup_menu_update(void) {
hud_element_set_tint(D_8010D66C, 255, 255, 255); hud_element_set_tint(D_8010D66C, 255, 255, 255);
hud_element_set_tint(D_8010D670, 255, 255, 255); hud_element_set_tint(D_8010D670, 255, 255, 255);
hud_element_set_tint(D_8010D674, 255, 255, 255); hud_element_set_tint(D_8010D674, 255, 255, 255);
if (gPopupMenu->popupType == 3) { if (gPopupMenu->popupType == POPUP_MENU_TRADE_FOR_BADGE) {
hud_element_set_tint(D_8010D660, 160, 160, 160); hud_element_set_tint(D_8010D660, 160, 160, 160);
hud_element_set_tint(D_8010D664, 160, 160, 160); hud_element_set_tint(D_8010D664, 160, 160, 160);
} }
if (gPopupMenu->popupType == 4) { if (gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
hud_element_set_tint(D_8010D660, 160, 160, 160); hud_element_set_tint(D_8010D660, 160, 160, 160);
hud_element_set_tint(D_8010D664, 160, 160, 160); hud_element_set_tint(D_8010D664, 160, 160, 160);
} }
if (gPopupMenu->popupType == 1 || gPopupMenu->popupType == 4) { if (gPopupMenu->popupType == 1 || gPopupMenu->popupType == POPUP_MENU_UPGRADE_PARTNER) {
hud_element_set_tint(D_8010D668, 160, 160, 160); hud_element_set_tint(D_8010D668, 160, 160, 160);
} }
if (gPopupMenu->popupType == 5) { if (gPopupMenu->popupType == POPUP_MENU_SELL_ITEM) {
hud_element_set_tint(D_8010D660, 160, 160, 160); hud_element_set_tint(D_8010D660, 160, 160, 160);
} }
hud_element_set_script(D_8010D66C, &HES_HandPointer); hud_element_set_script(D_8010D66C, &HES_HandPointer);

View File

@ -1254,24 +1254,24 @@ void func_801363A0(ItemEntity* itemEntity) {
temp = 0; temp = 0;
} }
if (gItemTable[itemEntity->itemID].typeFlags) { if (gItemTable[itemEntity->itemID].typeFlags) {
set_window_properties(0xC, s1, s3 - 0x18 + temp, offsetY, set_window_properties(WINDOW_ID_12, s1, s3 - 0x18 + temp, offsetY,
temp2, 0, func_8013673C, itemEntity, -1); temp2, 0, func_8013673C, itemEntity, -1);
} else { } else {
set_window_properties(0xC, s1, s3 - 0x18 + temp, offsetY, set_window_properties(WINDOW_ID_12, s1, s3 - 0x18 + temp, offsetY,
temp2, 0, func_8013673C, itemEntity, -1); temp2, 0, func_8013673C, itemEntity, -1);
} }
if (itemEntity->itemID != ITEM_STAR_PIECE && itemEntity->itemID != ITEM_COIN) { if (itemEntity->itemID != ITEM_STAR_PIECE && itemEntity->itemID != ITEM_COIN) {
set_window_properties(0x13, 0x14, 0xBA, 0x118, 0x20, NULL, func_80136A08, itemEntity, -1); set_window_properties(WINDOW_ID_19, 0x14, 0xBA, 0x118, 0x20, NULL, func_80136A08, itemEntity, -1);
} }
if (itemEntity->state != 2) { if (itemEntity->state != 2) {
offsetY = get_msg_width(MESSAGE_ID(0x1D, 0x060), 0) + 0x18; offsetY = get_msg_width(MESSAGE_ID(0x1D, 0x060), 0) + 0x18;
set_window_properties(0x11, 160 - offsetY / 2, 0x24, offsetY, 40, NULL, func_801369D0, itemEntity, -1); set_window_properties(WINDOW_ID_17, 160 - offsetY / 2, 0x24, offsetY, 40, NULL, func_801369D0, itemEntity, -1);
} }
break; break;
case 12: case 12:
set_message_msg(itemData->nameMsg, 0); set_message_msg(itemData->nameMsg, 0);
offsetY = get_msg_width(MESSAGE_ID(0x1D, 0x05F), 0) + 0x36; offsetY = get_msg_width(MESSAGE_ID(0x1D, 0x05F), 0) + 0x36;
set_window_properties(0xC, 160 - offsetY / 2, 0x4C, offsetY, 40, NULL, func_8013673C, itemEntity, -1); set_window_properties(WINDOW_ID_12, 160 - offsetY / 2, 0x4C, offsetY, 40, NULL, func_8013673C, itemEntity, -1);
break; break;
} }
} }

View File

@ -76,7 +76,7 @@ void func_802B7000_E225B0(void) {
foldImage.palette = D_802B7BE0_E23190; foldImage.palette = D_802B7BE0_E23190;
break; break;
} }
fold_update(0, 7, 0xFF, 0xFF, 0xFF, D_802B7C78_E23228->unk_28, 0); fold_update(0, FOLD_TYPE_7, 0xFF, 0xFF, 0xFF, D_802B7C78_E23228->unk_28, 0);
foldImage.raster = D_802B7580_E22B30; foldImage.raster = D_802B7580_E22B30;
foldImage.width = 56; foldImage.width = 56;
@ -161,7 +161,7 @@ void func_802B735C_E2290C(void) {
} }
if (D_802B7C78_E23228->unk_18++ > 50) { if (D_802B7C78_E23228->unk_18++ > 50) {
D_8015A578.unk_02 = FALSE; gCurrentHiddenPanels.activateISpy = FALSE;
D_8010C93C = NULL; D_8010C93C = NULL;
playerStatus->animFlags &= ~0x100; playerStatus->animFlags &= ~0x100;
} }

View File

@ -1031,7 +1031,7 @@ extern EntityBlueprint* bEntityBlueprint[4];
extern s32* D_801516F4; extern s32* D_801516F4;
extern TileDescriptor gCurrentTileDescriptor; extern TextureHeader gCurrentTileDescriptor;
extern ModelList wModelList; extern ModelList wModelList;
extern ModelList bModelList; extern ModelList bModelList;
@ -1063,7 +1063,7 @@ extern s32 texPannerMainU[MAX_TEX_PANNERS];
extern s32 texPannerMainV[MAX_TEX_PANNERS]; extern s32 texPannerMainV[MAX_TEX_PANNERS];
extern s32 texPannerAuxU[MAX_TEX_PANNERS]; extern s32 texPannerAuxU[MAX_TEX_PANNERS];
extern s32 texPannerAuxV[MAX_TEX_PANNERS]; extern s32 texPannerAuxV[MAX_TEX_PANNERS];
extern u32 mdl_nextTextureAddress; extern u8* mdl_nextTextureAddress;
extern u16 mdl_currentTransformGroupChildIndex; extern u16 mdl_currentTransformGroupChildIndex;
extern u16 D_80153226; extern u16 D_80153226;
extern ModelNode* D_80153370; extern ModelNode* D_80153370;
@ -1218,7 +1218,7 @@ void update_entities(void) {
} }
update_shadows(); update_shadows();
D_8015A578.unk_00 = FALSE; gCurrentHiddenPanels.tryFlipTrigger = FALSE;
} }
void update_shadows(void) { void update_shadows(void) {
@ -1814,8 +1814,8 @@ void clear_entity_data(s32 arg0) {
} }
entity_area_specific_data_is_loaded = FALSE; entity_area_specific_data_is_loaded = FALSE;
D_8015A578.unk_01 = 0; gCurrentHiddenPanels.panelsCount = 0;
D_8015A578.unk_02 = FALSE; gCurrentHiddenPanels.activateISpy = FALSE;
if (!arg0) { if (!arg0) {
D_80151344 = 0; D_80151344 = 0;
} }
@ -2970,7 +2970,35 @@ void state_render_frontUI(void) {
void appendGfx_model(Model* model); void appendGfx_model(Model* model);
INCLUDE_ASM(void, "a5dd0_len_114e0", appendGfx_model, Model*); INCLUDE_ASM(void, "a5dd0_len_114e0", appendGfx_model, Model*);
INCLUDE_ASM(s32, "a5dd0_len_114e0", func_80114B58); void func_80114B58(u32 romOffset, TextureHandle* handle, TextureHeader* header, s32 mainSize, s32 mainPalSize, s32 auxSize, s32 auxPalSize) {
handle->raster = (u32*) mdl_nextTextureAddress;
if (mainPalSize != 0) {
handle->palette = (u32*) (mdl_nextTextureAddress + mainSize);
} else {
handle->palette = NULL;
}
dma_copy((u8*) romOffset, (u8*) (romOffset + mainSize + mainPalSize), mdl_nextTextureAddress);
romOffset += mainSize + mainPalSize;
mdl_nextTextureAddress += mainSize + mainPalSize;
if (auxSize != 0) {
handle->auxRaster = (u32*) mdl_nextTextureAddress;
if (auxPalSize != 0) {
handle->auxPalette = (u32*) (mdl_nextTextureAddress + auxSize);
} else {
handle->auxPalette = NULL;
}
dma_copy((u8*) romOffset, (u8*) (romOffset + auxSize + auxPalSize), mdl_nextTextureAddress);
mdl_nextTextureAddress += auxSize + auxPalSize;
} else {
handle->auxPalette = NULL;
handle->auxRaster = NULL;
}
handle->gfx = (Gfx*) mdl_nextTextureAddress;
memcpy(&handle->header, header, sizeof(*header));
func_801180E8(header, &mdl_nextTextureAddress, handle->raster, handle->palette, handle->auxRaster, handle->auxPalette, 0, 0, 0, 0);
gSPEndDisplayList(((Gfx*) mdl_nextTextureAddress)++);
}
void load_tile_header(char* textureName, s32 romOffset, s32 size); void load_tile_header(char* textureName, s32 romOffset, s32 size);
INCLUDE_ASM(s32, "a5dd0_len_114e0", load_tile_header); INCLUDE_ASM(s32, "a5dd0_len_114e0", load_tile_header);
@ -4101,7 +4129,7 @@ void get_model_fog_color_parameters(u8* primR, u8* primG, u8* primB, u8* primA,
*fogEnd = mdl_renderModelFogEnd; *fogEnd = mdl_renderModelFogEnd;
} }
void set_model_env_color_parameters(u8 primR, u8 primG, u8 primB, u8 envR, s32 envG, s32 envB) { void set_model_env_color_parameters(u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB) {
gRenderModelPrimR = primR; gRenderModelPrimR = primR;
gRenderModelPrimG = primG; gRenderModelPrimG = primG;
gRenderModelPrimB = primB; gRenderModelPrimB = primB;

File diff suppressed because it is too large Load Diff

View File

@ -8,54 +8,48 @@ NUAuPreNMIFunc nuAuPreNMIFunc = NULL;
s32 nuAuDmaNext = 0; s32 nuAuDmaNext = 0;
u32 nuAuFrameCounter = 0; u32 nuAuFrameCounter = 0;
u8 nuAuTaskStop = NU_AU_TASK_RUN; u8 nuAuTaskStop = NU_AU_TASK_RUN;
u8 D_80078181 = 1; u8 volatile AuSynUseStereo = TRUE;
//bss //bss
extern Acmd* D_800A3510[3]; extern Acmd* AlCmdListBuffers[3];
extern NUScTask D_800A3520[3]; extern NUScTask D_800A3520[3];
extern u8* D_800A3628[3]; extern u8* D_800A3628[3];
extern s32 D_800A3634; extern s32 AlFrameSize;
extern s32 D_800A3638; extern s32 AlMinFrameSize;
extern OSMesgQueue nuAuDmaMesgQ; extern OSMesgQueue nuAuDmaMesgQ;
extern OSMesg nuAuDmaMesgBuf[50]; extern OSMesg nuAuDmaMesgBuf[50];
extern OSIoMesg nuAuDmaIOMesgBuf[]; extern OSIoMesg nuAuDmaIOMesgBuf[];
extern NUDMABuffer* D_800A3BD4; extern NUDMABuffer* D_800A3BD4;
extern NUDMABuffer nuAuDmaBufList[50]; extern NUDMABuffer nuAuDmaBufList[50];
extern u8 D_800B91A0[]; extern AuSynDriver auSynDriver;
extern u64 rspbootUcodeBuffer[]; extern u64 rspbootUcodeBuffer[];
extern OSMesgQueue D_800DA444; extern OSMesgQueue D_800DA444;
extern s32 D_800DAAB8; extern s32 AlNumFields;
extern u64 n_aspMain_text_bin[]; extern u64 n_aspMain_text_bin[];
extern u64 n_aspMain_data_bin[]; extern u64 n_aspMain_data_bin[];
extern u8 D_801AA000[0x56000]; extern u8 AuHeapBase[AUDIO_HEAP_SIZE];
s32 nuAuDmaCallBack(s32 addr, s32 len, void* state, u8 arg3);
void func_8004B328(NUScMsg, u32);
void func_80056250(u8*, ALConfig*);
void nuAuMgr(void*);
void snd_load_audio_data(s32 frequency);
void create_audio_system(void) { void create_audio_system(void) {
u32 i; u32 i;
u32 freq, freq2; u32 outputRate, frameSize;
ALConfig config; ALConfig config;
nuAuTaskStop = NU_AU_TASK_RUN; nuAuTaskStop = NU_AU_TASK_RUN;
nuAuPreNMI = 0; nuAuPreNMI = 0;
alHeapInit(&nuAuHeap, D_801AA000, 0x56000); alHeapInit(&nuAuHeap, AuHeapBase, AUDIO_HEAP_SIZE);
config.unk_00 = 24; config.num_pvoice = 24;
config.unk_04 = 4; config.unk_num_gamma = 4;
freq = osAiSetFrequency(32000); outputRate = osAiSetFrequency(32000);
freq2 = (D_800DAAB8 * freq + 59) / 60; frameSize = (AlNumFields * outputRate + 59) / 60;
config.frequency = freq; config.outputRate = outputRate;
config.unk_0C = 0; config.unk_0C = 0;
config.heap = &nuAuHeap; config.heap = &nuAuHeap;
config.dmaNew = nuAuDmaNew; config.dmaNew = nuAuDmaNew;
D_800A3634 = (freq2 / 184 + 1) * 184; // NU_AU_AUDIO_SAMPLES ? AlFrameSize = ((frameSize / AUDIO_SAMPLES) + 1) * AUDIO_SAMPLES;
D_800A3638 = D_800A3634 - 184; AlMinFrameSize = AlFrameSize - AUDIO_SAMPLES;
for (i = 0; i < ARRAY_COUNT(D_800A3510); i++) { for (i = 0; i < ARRAY_COUNT(AlCmdListBuffers); i++) {
D_800A3510[i] = alHeapAlloc(config.heap, 1, 0x4000); AlCmdListBuffers[i] = alHeapAlloc(config.heap, 1, AUDIO_COMMAND_LIST_BUFFER_SIZE);
} }
for (i = 0; i < ARRAY_COUNT(D_800A3520); i++) { for (i = 0; i < ARRAY_COUNT(D_800A3520); i++) {
@ -76,7 +70,7 @@ void create_audio_system(void) {
} }
for (i = 0; i < ARRAY_COUNT(D_800A3628); i++) { for (i = 0; i < ARRAY_COUNT(D_800A3628); i++) {
D_800A3628[i] = alHeapAlloc(config.heap, 1, D_800A3634 * 4); D_800A3628[i] = alHeapAlloc(config.heap, 1, AlFrameSize * 4);
} }
nuAuDmaBufList[0].node.next = nuAuDmaBufList[0].node.prev = NULL; nuAuDmaBufList[0].node.next = nuAuDmaBufList[0].node.prev = NULL;
@ -88,9 +82,9 @@ void create_audio_system(void) {
osCreateMesgQueue(&nuAuDmaMesgQ, nuAuDmaMesgBuf, 50); osCreateMesgQueue(&nuAuDmaMesgQ, nuAuDmaMesgBuf, 50);
nuAuPreNMIFunc = func_8004B328; nuAuPreNMIFunc = func_8004B328;
func_80056250(D_800B91A0, &config); au_driver_init(&auSynDriver, &config);
snd_load_audio_data(config.frequency); au_engine_init(config.outputRate);
osCreateThread(&nuAuMgrThread, NU_MAIN_THREAD_ID, nuAuMgr, NULL, &D_800A3510, NU_AU_MGR_THREAD_PRI); //why main thread? osCreateThread(&nuAuMgrThread, NU_MAIN_THREAD_ID, nuAuMgr, NULL, &AlCmdListBuffers, NU_AU_MGR_THREAD_PRI); //why main thread?
osStartThread(&nuAuMgrThread); osStartThread(&nuAuMgrThread);
} }
@ -126,7 +120,7 @@ void nuAuMgr(void* arg) {
cmdListIndex = 0; cmdListIndex = 0;
bufferIndex = 0; bufferIndex = 0;
samples = 0; samples = 0;
cmdListBuf = D_800A3510[0]; cmdListBuf = AlCmdListBuffers[0];
bufferPtr = D_800A3628[0]; bufferPtr = D_800A3628[0];
while (TRUE) { while (TRUE) {
osRecvMesg(&auMesgQ, (OSMesg*)&mesg_type, OS_MESG_BLOCK); osRecvMesg(&auMesgQ, (OSMesg*)&mesg_type, OS_MESG_BLOCK);
@ -153,14 +147,14 @@ void nuAuMgr(void* arg) {
sampleSize = osAiGetLength() >> 2; sampleSize = osAiGetLength() >> 2;
if (cmdList_len != 0 && nuAuTaskStop == NU_AU_TASK_RUN) { if (cmdList_len != 0 && nuAuTaskStop == NU_AU_TASK_RUN) {
osAiSetNextBuffer(bufferPtr, samples * 4); osAiSetNextBuffer(bufferPtr, samples * 4);
cmdListBuf = D_800A3510[cmdListIndex]; cmdListBuf = AlCmdListBuffers[cmdListIndex];
bufferPtr = D_800A3628[bufferIndex]; bufferPtr = D_800A3628[bufferIndex];
} }
if (sampleSize < 184 || cond) { if (sampleSize < AUDIO_SAMPLES || cond) {
samples = D_800A3634; samples = AlFrameSize;
cond = FALSE; cond = FALSE;
} else { } else {
samples = D_800A3638; samples = AlMinFrameSize;
cond = TRUE; cond = TRUE;
} }
cmdListAfter_ptr = alAudioFrame(cmdListBuf, &cmdList_len, (s16*)osVirtualToPhysical(bufferPtr), samples); cmdListAfter_ptr = alAudioFrame(cmdListBuf, &cmdList_len, (s16*)osVirtualToPhysical(bufferPtr), samples);
@ -301,6 +295,7 @@ void nuAuCleanDMABuffers(void) {
// Nop issue // Nop issue
// try again when bss is figured out up until this file // try again when bss is figured out up until this file
// rename: default_nuAuPreNMIFunc
#ifdef NON_MATCHING #ifdef NON_MATCHING
void func_8004B328(NUScMsg mesg_type, u32 frameCounter) { void func_8004B328(NUScMsg mesg_type, u32 frameCounter) {
s16 temp; s16 temp;
@ -329,7 +324,7 @@ void func_8004B328(NUScMsg mesg_type, u32 frameCounter) {
} }
} }
#else #else
INCLUDE_ASM(s32, "25f00_len_940", func_8004B328); INCLUDE_ASM(s32, "audio/25f00_len_940", func_8004B328);
#endif #endif
void alLink(ALLink* element, ALLink* after) { void alLink(ALLink* element, ALLink* after) {

2076
src/audio/28910_len_5090.c Normal file

File diff suppressed because it is too large Load Diff

419
src/audio/2BF90.c Normal file
View File

@ -0,0 +1,419 @@
#include "audio.h"
extern s8 BlankMseqData;
enum LambdaState24 {
LAMBDA_24_0 = 0,
LAMBDA_24_1 = 1,
LAMBDA_24_2 = 2,
LAMBDA_24_3 = 3
};
enum MseqPlayState {
MSEQ_PLAYER_PLAYING = 0,
MSEQ_PLAYER_STOPPED = 1,
MSEQ_PLAYER_STOPPING = 2
};
void au_mseq_manager_init(AuAmbienceManager* manager, s8 priority, s8 reverbType, AuGlobals* globals) {
AuAmbPlayer* lambda;
s32 i;
au_memset(manager, sizeof(*manager), 0);
for (i = 0; i < ARRAY_COUNT(manager->mseqPlayers); i++) {
lambda = &manager->mseqPlayers[i];
lambda->unk_14.u8[0] = i;
lambda->unk_18 = 1;
lambda->unk_38 = 0x7F000000;
}
manager->globals = globals;
manager->nextUpdateStep = 1;
manager->nextUpdateCounter = 2;
manager->nextUpdateInterval = 2;
manager->priority = priority;
manager->defaultReverbType = reverbType;
}
AuResult func_80050C30(u32 arg0) {
if (gAuAmbienceManager->unk_20 <= arg0) {
return AU_AMBIENCE_ERROR_3;
} else {
return AU_RESULT_OK;
}
}
void func_80050C54(s32 arg0, s32 arg1) {
gAuAmbienceManager->unk_21 = arg1;
}
void au_mseq_set_disabled(s32 index, s32 disable) {
AuAmbienceManager* manager = gAuAmbienceManager;
AuAmbPlayer* ambPlayer = &manager->mseqPlayers[index];
if (!disable) {
ambPlayer->playState = MSEQ_PLAYER_PLAYING;
} else {
ambPlayer->playState = MSEQ_PLAYER_STOPPING;
}
}
AuResult func_80050CA0(s32 index, s32 time) {
AuAmbPlayer* lambda = &gAuAmbienceManager->mseqPlayers[index];
MSEQHeader* mseq = gAuAmbienceManager->mseqFiles[index];
AuResult status = AU_RESULT_OK;
if (mseq != NULL) {
if (lambda->mseqName == 0) {
func_800510A4(gAuAmbienceManager, mseq, index);
if (time != 0) {
lambda->time = time;
lambda->unk_2A = 0;
lambda->volume = 0x7F;
lambda->unk_26 = 0;
func_80050D50(lambda);
}
} else {
status = AU_AMBIENCE_ERROR_1;
}
} else {
status = AU_AMBIENCE_ERROR_2;
}
return status;
}
void func_80050D50(AuAmbPlayer* lambda) {
u16 time = lambda->time;
if (lambda->unk_2A == 0xFF) {
lambda->unk_2A = lambda->unk_38 >> 0x18;
}
if (time >= SND_MIN_DURATION && time <= SND_MAX_DURATION) {
lambda->unk_38 = lambda->unk_2A << 0x18;
lambda->unk_42 = lambda->volume;
lambda->volInterpTime = (u32)(time * 10) / 115;
lambda->volInterpStep = ((lambda->volume - lambda->unk_2A) << 0x18) / ((s16)lambda->volInterpTime & 0xFFFF);
}
lambda->time = 0;
lambda->unk_2A = 0;
lambda->volume = 0;
}
void func_80050EF0_fade_out_unk(s32 index, s32 time) {
AuAmbPlayer* lambda = &gAuAmbienceManager->mseqPlayers[index];
if ((lambda->mseqReadStart != NULL) && (lambda->mseqReadPos != NULL)) {
if (time != 0) {
lambda->unk_2A = 0xFF;
lambda->time = time;
lambda->volume = 0;
lambda->unk_26 = 2;
return;
}
lambda->unk_24 = LAMBDA_24_3;
}
}
void func_80050EF0_fade_in_unk(s32 index, s32 time) {
AuAmbPlayer* lambda = &gAuAmbienceManager->mseqPlayers[index];
if ((lambda->mseqReadStart != NULL) && (lambda->mseqReadPos != NULL)) {
lambda->unk_24 = LAMBDA_24_1;
if (time != 0) {
lambda->time = time;
} else {
lambda->time = SND_MIN_DURATION;
}
lambda->unk_2A = 0;
lambda->volume = SND_MAX_VOLUME_8;
lambda->unk_26 = 0;
}
}
void func_80050EF0_fade_out_quick(s32 index) {
AuAmbPlayer* lambda = &gAuAmbienceManager->mseqPlayers[index];
if ((lambda->mseqReadStart != NULL) && (lambda->mseqReadPos != NULL)) {
if (lambda->unk_24 != LAMBDA_24_0) {
lambda->mseqReadPos = NULL;
lambda->mseqName = 0;
lambda->unk_24 = LAMBDA_24_0;
return;
}
lambda->mseqReadPos = &BlankMseqData;
lambda->unk_18 = 1;
}
}
void func_80050EF0_fade_out_slow(s32 index, s32 time) {
AuAmbPlayer* lambda = &gAuAmbienceManager->mseqPlayers[index];
if ((lambda->mseqReadStart != NULL) && (lambda->mseqReadPos != NULL)) {
if (time != 0) {
lambda->time = time;
} else {
lambda->time = SND_MIN_DURATION;
}
lambda->unk_2A = -1;
lambda->volume = 0;
lambda->unk_26 = 1;
}
}
void au_mseq_set_volume(s32 index, s32 time, s32 volume) {
AuAmbPlayer* lambda = &gAuAmbienceManager->mseqPlayers[index];
if ((lambda->mseqReadStart != 0) && (lambda->mseqReadPos != 0)) {
if (volume <= 0) {
volume = 1;
} else if (volume > SND_MAX_VOLUME_8) {
volume = SND_MAX_VOLUME_8;
}
if (time != 0) {
lambda->time = time;
} else {
lambda->time = SND_MIN_DURATION;
}
lambda->unk_2A = -1;
lambda->volume = volume;
lambda->unk_26 = 0;
}
}
AuResult func_80051050(s32 arg0) {
AuAmbPlayer* lambda = &gAuAmbienceManager->mseqPlayers[arg0];
AuResult status = AU_RESULT_OK;
if ((lambda->mseqReadStart != NULL) && (lambda->mseqReadPos != NULL)) {
status = AU_AMBIENCE_ERROR_1;
if (lambda->unk_24 != LAMBDA_24_0) {
status = AU_AMBIENCE_ERROR_2;
}
}
return status;
}
void func_800510A4(AuAmbienceManager* manager, MSEQHeader* mseqFile, s32 index) {
AuAmbPlayer* lambda;
AlUnkXi* xi;
AuFilePos readPos;
s32 i;
lambda = &manager->mseqPlayers[index];
au_memset(lambda, sizeof(*lambda), 0);
lambda->mseqFile = mseqFile;
readPos = AU_FILE_RELATIVE(mseqFile->dataStart, mseqFile);
lambda->unk_14.u8[0] = index;
lambda->mseqReadPos = readPos;
lambda->unk_10 = readPos;
lambda->unk_0C = readPos;
lambda->mseqReadStart = readPos;
lambda->unk_18 = 1;
lambda->unk_38 = 0x7F000000;
lambda->unk_42 = 0x7F;
lambda->mseqName = lambda->mseqFile->name;
lambda->firstVoiceIdx = lambda->mseqFile->first_iota;
lambda->lastVoiceIdx = lambda->firstVoiceIdx + 16;
if (lambda->lastVoiceIdx > 24) {
lambda->lastVoiceIdx = 24;
}
for (i = 0; i < 10; i++) {
xi = &lambda->unk_44[i];
xi->instrument = manager->globals->defaultInstrument;
xi->unk_18.full = 0x7FFFFFFF;
xi->pan = 0x40;
}
lambda->unk_43 = 1;
}
void snd_ambient_manager_update(AuAmbienceManager* manager) {
u32 i;
s32 j;
for (i = 0; i < ARRAY_COUNT(manager->mseqVoiceStates); i++) {
AlUnkIota* temp = &manager->mseqVoiceStates[i];
if ((temp->unk_00.u8[3] == 1) && (manager->globals->voices[i].priority != manager->priority)) {
temp->unk_00.s32 = 0;
}
}
for (j = 0; j < ARRAY_COUNT(manager->mseqPlayers); j++) {
AuAmbPlayer* lambda = &manager->mseqPlayers[j];
s32 var;
if (lambda->mseqReadPos != NULL) {
if (manager->unk_21) {
// not usually taken
func_80051334(manager, lambda);
}
var = lambda->unk_24;
if (var != LAMBDA_24_0) {
if (var == LAMBDA_24_3) {
lambda->unk_24 = LAMBDA_24_2;
func_800522A8(manager, lambda);
au_mseq_player_stop(manager, lambda);
} else if (lambda->unk_24 == LAMBDA_24_1) {
lambda->unk_24 = LAMBDA_24_0;
if (lambda->time != 0) {
func_80050D50(lambda);
}
func_8005232C(manager, lambda);
}
} else {
if (lambda->time != 0) {
func_80050D50(lambda);
}
if (lambda->playState == MSEQ_PLAYER_STOPPING) {
au_mseq_player_stop(manager, lambda);
lambda->playState = MSEQ_PLAYER_STOPPED;
}
func_80051434(manager, lambda);
}
}
}
manager->unk_21 = FALSE;
}
void func_80051334(AuAmbienceManager* manager, AuAmbPlayer* lambda) {
MSEQHeader* mseqFile;
AlUnkMSEQData* var_a0;
AlUnkXi* xi;
s32 offset;
s32 count;
s32 lim;
mseqFile = lambda->mseqFile;
count = mseqFile->unkCount;
if (count != 0 && mseqFile->unkOffset != 0) {
var_a0 = AU_FILE_RELATIVE(mseqFile->unkOffset, mseqFile);
while (count--) {
xi = &lambda->unk_44[var_a0->unk_00];
if (var_a0->unk_01 == 0) {
xi->unk_14 = var_a0->unk_02;
xi->unk_10 = (var_a0->unk_04 << 0x10) / var_a0->unk_02;
xi->unk_16 = var_a0->unk_06;
} else if (var_a0->unk_01 == 1) {
xi->unk_20 = var_a0->unk_02;
xi->unk_1C = (var_a0->unk_04 << 0x10) / var_a0->unk_02;
xi->unk_22 = var_a0->unk_06;
}
var_a0++;
}
}
}
INCLUDE_ASM(void, "audio/2BF90", func_80051434, AuAmbienceManager* arg0, AuAmbPlayer* arg1);
// could return u8?
s32 au_mseq_read_next(AuAmbPlayer* state) {
u8 value = *state->mseqReadPos++;
return value;
}
void au_mseq_player_stop(AuAmbienceManager* manager, AuAmbPlayer* lambda) {
AlUnkVoice* voice;
Q32* temp_s1;
s32 i;
for (i = lambda->firstVoiceIdx; i < lambda->lastVoiceIdx; i++) {
temp_s1 = &manager->mseqVoiceStates[i - lambda->firstVoiceIdx].unk_00;
if (*temp_s1->u8 == lambda->unk_14.u8[0]) {
voice = &manager->globals->voices[i];
if (voice->priority == manager->priority) {
au_reset_voice(voice, i);
}
temp_s1->s32 = 0;
}
}
}
void func_800522A8(AuAmbienceManager* arg0, AuAmbPlayer* lambda) {
AlUnkOmega* omega = lambda->unk_1D4;
u32 copied = 0;
s32 i;
for (i = lambda->firstVoiceIdx; i < lambda->lastVoiceIdx; i++) {
AlUnkIota* iota = &arg0->mseqVoiceStates[i - lambda->firstVoiceIdx];
if (iota->unk_07 == 0) {
continue;
}
omega->unk_00 = iota->unk_00.u8[1];
omega->unk_01 = iota->unk_00.u8[2];
omega->unk_02 = iota->volume;
omega++;
copied++;
if (copied >= 4) {
break;
}
}
}
void func_8005232C(AuAmbienceManager* manager, AuAmbPlayer* lambda) {
AuGlobals* globals;
AlUnkVoice* voice;
AlUnkOmega* omega;
AlUnkIota* iota;
AlUnkXi* xi;
u32 i, j;
globals = manager->globals;
if (lambda->playState == MSEQ_PLAYER_PLAYING) {
for (i = 0; i < ARRAY_COUNT(lambda->unk_1D4); i++) {
omega = &lambda->unk_1D4[i];
if (omega->unk_01 != 0) {
xi = &lambda->unk_44[omega->unk_00];
// find first free voice
for (j = lambda->firstVoiceIdx; j < lambda->lastVoiceIdx; j++) {
voice = &globals->voices[j];
if (voice->priority == AU_PRIORITY_FREE) {
break;
}
}
// try stealing a voice with lower priority
if (j >= lambda->lastVoiceIdx) {
for (j = lambda->firstVoiceIdx; j < lambda->lastVoiceIdx; j++) {
voice = &globals->voices[j];
if (voice->priority < manager->priority) {
au_reset_voice(voice, j);
break;
}
}
}
if (j < lambda->lastVoiceIdx) {
iota = &manager->mseqVoiceStates[j - lambda->firstVoiceIdx];
iota->unk_00.s32 = lambda->unk_14.s32 + (omega->unk_00 << 0x10) + (omega->unk_01 << 8);
iota->pitch = ((omega->unk_01 & 0x7F) * 100) - xi->instrument->keyBase;
iota->volume = omega->unk_02 & 0x7F;
voice->adjustedVolume = ((lambda->unk_38 >> 0x18) * xi->unk_18.half * iota->volume) >> 0xE;
voice->pitchRatio = au_compute_pitch_ratio(iota->pitch + xi->pitch) * xi->instrument->pitchRatio;
voice->pan = xi->pan;
voice->reverbAmt = xi->reverb;
voice->instrument = xi->instrument;
voice->reverbType = manager->defaultReverbType;
voice->unk_14.unk_00 = xi->unk_04.unk_00;
voice->unk_14.unk_04 = xi->unk_04.unk_04;
voice->unk_flags_43 = AU_VOICE_SYNC_FLAGS_ALL;
voice->priority = manager->priority;
voice->priorityCopy = voice->priority;
}
}
omega->unk_00 = 0;
omega->unk_01 = 0;
omega->unk_02 = 0;
}
}
}

203
src/audio/2d9a0_len_890.c Normal file
View File

@ -0,0 +1,203 @@
#include "common.h"
#include "audio.h"
void func_800525A0(AuGlobals* globals) {
s32 i;
for (i = 0; i < ARRAY_COUNT(globals->voices); i++) {
AlUnkVoice* voice = &globals->voices[i];
if (voice->unk_42 != 0) {
au_pvoice_reset_filter(i);
voice->unk_42 = 0;
voice->unk_1C = NULL;
voice->priority = AU_PRIORITY_FREE;
}
}
}
void func_80052614(AuGlobals* globals) {
s32 i;
for (i = 0; i < ARRAY_COUNT(globals->voices); i++) {
AlUnkVoice* temp = &globals->voices[i];
temp->unk_1C = NULL;
temp->unk_20 = 0;
temp->unk_24 = 0;
temp->unk_28 = 0;
temp->unk_3B = 0;
temp->unk_3C = 0;
temp->unk_flags_3D = 0;
temp->unk_3E = 0;
temp->unk_3F = 0x80;
}
}
void func_80052660(AuGlobals* globals) {
AlUnkVoice* voice;
s8 var_a0;
s16 unkTemp;
s32 i;
for (i = 0; i < ARRAY_COUNT(globals->voices); i++) {
voice = &globals->voices[i];
if (voice->unk_1C == NULL) {
continue;
}
if (voice->unk_flags_3D & AU_VOICE_3D_FLAGS_HANDLED_VOL_CHANGE) {
func_80052B44(voice);
continue;
}
if (voice->unk_flags_3D & AU_VOICE_3D_FLAGS_10) {
voice->unk_flags_3D &= ~AU_VOICE_3D_FLAGS_10;
voice->unk_flags_3D |= AU_VOICE_3D_FLAGS_1;
voice->unk_1C = (u8*)voice->unk_14.unk_04;
if (voice->unk_28 > AU_5750) {
voice->unk_39 = voice->unk_39 + (s32) (voice->unk_2C * (f32) (voice->unk_24 - voice->unk_28));
} else {
voice->unk_39 = voice->unk_3A;
}
voice->unk_3B = *voice->unk_1C++;
var_a0 = *voice->unk_1C;
if (*(s8*)voice->unk_1C++ < 0) {
var_a0 &= 0x7F;
voice->unk_3E = 1;
voice->unk_3F = voice->unk_39;
}
voice->unk_3A = var_a0;
voice->unk_28 = D_800785A0[voice->unk_3B];
voice->unk_24 = voice->unk_28;
if (voice->unk_flags_3D & AU_VOICE_3D_FLAGS_VOL_CHANGED) {
voice->unk_flags_3D &= ~AU_VOICE_3D_FLAGS_VOL_CHANGED;
if (voice->unk_28 > AU_5750) {
voice->unk_28 -= AU_5750;
voice->unk_flags_3D |= AU_VOICE_3D_FLAGS_HANDLED_VOL_CHANGE;
unkTemp = voice->unk_39 + (s32) (voice->unk_2C * (voice->unk_24 - voice->unk_28));
} else {
unkTemp = voice->unk_3A;
}
voice->unk_08 = AUDIO_SAMPLES;
} else {
voice->unk_08 = func_80052BC0(voice->unk_24);
unkTemp = voice->unk_3A;
}
voice->volume = (((unkTemp * voice->adjustedVolume * voice->unk_3F) >> 0xE) * voice->unk_30) >> 7;
voice->unk_flags_43 |= AU_VOICE_SYNC_FLAGS_4;
} else {
if (voice->unk_28 == -1) {
if (voice->unk_flags_3D & AU_VOICE_3D_FLAGS_VOL_CHANGED) {
voice->unk_flags_3D &= ~AU_VOICE_3D_FLAGS_VOL_CHANGED;
voice->volume = (((voice->unk_39 * voice->adjustedVolume * voice->unk_3F) >> 0xE) * voice->unk_30) >> 7;
voice->unk_flags_43 |= AU_VOICE_SYNC_FLAGS_4;
}
} else {
voice->unk_28 -= AU_5750;
if (voice->unk_28 <= 0) {
if (*voice->unk_1C == 0xFF) {
if (voice->unk_flags_3D & AU_VOICE_3D_FLAGS_1) {
voice->unk_flags_3D = 0;
voice->unk_1C = NULL;
voice->unk_42 = 1;
} else {
voice->unk_28 = -1;
voice->unk_24 = -1;
voice->unk_3B = 0x3B;
voice->unk_08 = AUDIO_SAMPLES;
voice->unk_2C = 0.0f;
voice->unk_39 = voice->unk_3A;
}
} else {
voice->unk_3B = func_80052CFC(voice);
voice->unk_39 = voice->unk_3A;
voice->unk_3A = (*voice->unk_1C++) & 0x7F;
voice->unk_28 = D_800785A0[voice->unk_3B];
voice->unk_24 = voice->unk_28;
if (voice->unk_24 != 0) {
voice->unk_2C = ((f32) voice->unk_3A - (f32) voice->unk_39) / (f32) voice->unk_24;
} else {
voice->unk_2C = 0.0f;
}
if (voice->unk_flags_3D & AU_VOICE_3D_FLAGS_VOL_CHANGED) {
voice->unk_flags_3D &= ~AU_VOICE_3D_FLAGS_VOL_CHANGED;
if (voice->unk_28 > AU_5750) {
voice->unk_28 -= AU_5750;
voice->unk_flags_3D |= AU_VOICE_3D_FLAGS_HANDLED_VOL_CHANGE;
unkTemp = voice->unk_39 + (s32) (voice->unk_2C * (voice->unk_24 - voice->unk_28));
} else {
unkTemp = voice->unk_3A;
}
voice->unk_08 = AUDIO_SAMPLES;
} else {
voice->unk_08 = func_80052BC0(voice->unk_24);
unkTemp = voice->unk_3A;
}
voice->volume = (((unkTemp * voice->adjustedVolume * voice->unk_3F) >> 0xE) * voice->unk_30) >> 7;
voice->unk_flags_43 |= AU_VOICE_SYNC_FLAGS_4;
}
} else {
if (voice->unk_flags_3D & AU_VOICE_3D_FLAGS_VOL_CHANGED) {
voice->unk_flags_3D &= ~AU_VOICE_3D_FLAGS_VOL_CHANGED;
if (voice->unk_28 > AU_5750) {
voice->unk_28 -= AU_5750;
voice->unk_flags_3D |= AU_VOICE_3D_FLAGS_HANDLED_VOL_CHANGE;
unkTemp = voice->unk_39 + (s32) (voice->unk_2C * (voice->unk_24 - voice->unk_28));
} else {
unkTemp = voice->unk_3A;
}
voice->unk_08 = AUDIO_SAMPLES;
voice->volume = (((unkTemp * voice->adjustedVolume * voice->unk_3F) >> 0xE) * voice->unk_30) >> 7;
voice->unk_flags_43 |= AU_VOICE_SYNC_FLAGS_4;
}
}
}
}
}
}
void func_80052B44(AlUnkVoice* arg0) {
arg0->volume = (((arg0->unk_3A * arg0->adjustedVolume * arg0->unk_3F) >> 14) * arg0->unk_30) >> 7;
arg0->unk_08 = func_80052BC0(arg0->unk_28);
arg0->unk_flags_3D &= ~AU_VOICE_3D_FLAGS_HANDLED_VOL_CHANGE;
arg0->unk_flags_43 |= AU_VOICE_SYNC_FLAGS_4;
}
s32 func_80052BC0(s32 arg0) {
return (arg0 / AU_5750) * AUDIO_SAMPLES;
}
void func_80052BF8(AlUnkVoice* voice, AlUnkInstrumentData* arg1) {
s32 x;
voice->unk_14.unk_00 = arg1->unk_00;
voice->unk_1C = voice->unk_14.unk_00;
voice->unk_14.unk_04 = arg1->unk_04;
voice->unk_30 = 0x80;
voice->unk_34 = 0;
x = func_80052CFC(voice);
voice->unk_flags_3D = 0;
voice->unk_39 = 0;
voice->unk_3A = *voice->unk_1C++;
voice->unk_3B = x;
voice->unk_24 = D_800785A0[x];
voice->unk_28 = voice->unk_24;
voice->volume = (voice->unk_3A * voice->adjustedVolume * voice->unk_30) >> 14;
voice->unk_08 = func_80052BC0(voice->unk_24);
if (voice->unk_24 != 0) {
voice->unk_2C = ((f32) voice->unk_3A - (f32) voice->unk_39) / voice->unk_24;
} else {
voice->unk_2C = 0.0f;
}
voice->unk_3E = 0;
voice->unk_3F = 0x80;
}
INCLUDE_ASM(u8, "audio/2d9a0_len_890", func_80052CFC, AlUnkVoice* arg0);
void func_80052E18(AlUnkVoice* arg0) {
arg0->unk_flags_3D |= AU_VOICE_3D_FLAGS_VOL_CHANGED;
}

1185
src/audio/2e230_len_2190.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,22 +4,22 @@
typedef struct BufferEntry { typedef struct BufferEntry {
/* 0x0 */ u16 fileIndex; /* 0x0 */ u16 fileIndex;
/* 0x2 */ u8 bankIndex; /* 0x2 */ u8 bankIndex;
/* 0x3 */ u8 unk_3; /* 0x3 */ u8 bankGroup;
} BufferEntry; // size = 4 } BufferEntry; // size = 4
void snd_load_BK_headers(UnkAl19E0* soundData, ALHeap* arg1) { void au_load_BK_headers(AuGlobals* globals, ALHeap* heap) {
SBNFileEntry fileEntry; SBNFileEntry fileEntry;
BufferEntry buffer[80]; BufferEntry buffer[80];
s32 i; s32 i;
snd_read_rom(soundData->bkFileListOffset, &buffer, soundData->bkListLength); au_read_rom(globals->bkFileListOffset, &buffer, globals->bkListLength);
for (i = 0; i < ARRAY_COUNT(buffer); i++) { for (i = 0; i < ARRAY_COUNT(buffer); i++) {
if (buffer[i].fileIndex == 0xFFFF) { if (buffer[i].fileIndex == 0xFFFF) {
break; break;
} }
snd_fetch_SBN_file(buffer[i].fileIndex, 0x30, &fileEntry); au_fetch_SBN_file(buffer[i].fileIndex, AU_FMT_BK, &fileEntry);
snd_load_BK_to_bank(fileEntry.offset, NULL, buffer[i].bankIndex, buffer[i].unk_3); snd_load_BK_to_bank(fileEntry.offset, NULL, buffer[i].bankIndex, buffer[i].bankGroup);
} }
} }

869
src/audio/30450.c Normal file
View File

@ -0,0 +1,869 @@
#include "common.h"
#include "audio.h"
static u8* snd_song_get_track_volumes_set(MusicTrackVols arg0);
s32 PreventBGMPlayerUpdate = FALSE;
u16 D_80078DB4 = 0;
u16 D_80078DB6 = 0;
// lists of data:
// u8 trackIdx
// u8 volume?
// repeated until idx = 0
u8 D_80078DB8[] = {
2, 94,
3, 80,
4, 100,
5, 84,
0
};
u8 D_80078DC4[] = {
2, 100,
3, 110,
4, 90,
0
};
u8 D_80078DCC[] = {
2, 95,
0
};
u8 D_80078DD0[] = {
5, 70,
6, 90,
7, 90,
8, 100,
0
};
// used in kpa_60-63
u8 TrackVols_KPA_Outside[] = {
5, 0,
6, 0,
7, 0,
8, 0,
9, 0,
10, 0,
11, 0,
12, 0,
13, 0,
14, 0,
15, 0,
16, 0,
0
};
// starting areas, only basic instrumentation
u8 TrackVols_KPA_1[] = {
5, 100,
6, 102,
7, 88,
8, 110,
9, 0,
10, 0,
11, 0,
12, 0,
13, 0,
14, 0,
15, 0,
16, 0,
0
};
// middle areas
u8 TrackVols_KPA_2[] = {
5, 100,
6, 102,
7, 88,
8, 110,
9, 126,
10, 88,
11, 100,
12, 0,
13, 0,
14, 0,
15, 0,
16, 0,
0
};
// final areas, full instrumentation
u8 TrackVols_KPA_3[] = {
5, 100,
6, 102,
7, 88,
8, 110,
9, 126,
10, 88,
11, 100,
12, 100,
13, 106,
14, 100,
15, 100,
16, 110,
0
};
void func_80055050(ALHeap* heap) {
D_80078DB4 = 1;
PreventBGMPlayerUpdate = FALSE;
}
void func_80055068(u32 arg0) {
u16 temp_a0 = D_80078DB4;
u32 temp_v1 = arg0 & 0xF;
if (temp_a0 == 1) {
switch (temp_v1) {
case 2:
case 3:
break;
case 4:
snd_start_sound_with_shift(arg0 >> 4, 0, 0, 0);
break;
case 1:
if (temp_v1 == 1) {
s32 filename = au_song_load((arg0 >> 4) & 0xFF, 0);
if (filename > ASCII_TO_U32('0', ' ', ' ', '\0')) {
au_song_start_variation(filename, (arg0 >> 0xC) & 3);
}
}
break;
}
}
}
void func_80055110(BGMPlayer* player) {
s32 i;
for (i = 0; i < ARRAY_COUNT(player->unk_238); i++) {
player->unk_238[i] = 0;
}
player->unk_25B = 0;
player->unk_25A = 0;
player->unk_259 = 0;
player->unk_258 = 0;
}
void func_8005513C(u32 arg0) {
BGMPlayer* player = NULL;
u32 playerSwitch = arg0 & 0xF;
if (playerSwitch != 0) {
if (playerSwitch == 1) {
player = gBGMPlayerA;
} else if (playerSwitch == 2) {
player = gBGMPlayerB;
}
if (player != NULL) {
u32 temp;
if (player->unk_258 < 8) {
temp = player->unk_25A;
player->unk_238[temp] = arg0 >> 4;
temp++;
if (temp >= 8) {
temp = 0;
}
player->unk_25A = temp;
player->unk_258++;
} else {
temp = player->unk_25B + 1;
if (temp > 99) {
temp = 99;
}
player->unk_25B = temp;
}
}
}
}
void snd_start_sound(s32 soundID, u8 volume, u8 pan) {
SoundManager* soundManager = gSoundManager;
s16 vol = volume << 8;
if (vol != 0) {
vol |= 0xFF;
}
if (pan > 0x7F) {
pan = 0x7F;
}
au_sfx_enqueue_event(soundManager, soundID, vol, 0, pan);
}
void snd_start_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift) {
SoundManager* soundManager = gSoundManager;
s16 vol = volume << 8;
if (vol != 0) {
vol |= 0xFF;
}
if (pan > 0x7F) {
pan = 0x7F;
}
if (pitchShift > 2400) {
pitchShift = 2400;
} else if (pitchShift < -2400) {
pitchShift = -2400;
}
au_sfx_enqueue_event(soundManager, soundID, vol, pitchShift, pan);
}
void snd_adjust_sound(s32 soundID, u8 volume, u8 pan) {
SoundManager* soundManager = gSoundManager;
s16 vol = volume << 8;
if (vol != 0) {
vol |= 0xFF;
}
if (pan > 0x7F) {
pan = 0x7F;
}
au_sfx_enqueue_event(soundManager, soundID | 0x1000, vol, 0, pan);
}
void snd_adjust_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift) {
SoundManager* soundManager = gSoundManager;
s16 vol = volume << 8;
if (vol != 0) {
vol |= 0xFF;
}
if (pan > 0x7F) {
pan = 0x7F;
}
if (pitchShift > 2400) {
pitchShift = 2400;
} else if (pitchShift < -2400) {
pitchShift = -2400;
}
au_sfx_enqueue_event(soundManager, soundID | 0x1000, vol, pitchShift, pan);
}
void snd_stop_sound(s32 soundID) {
SoundManager* soundManager = gSoundManager;
au_sfx_enqueue_event(soundManager, soundID | 0x8000, 0, 0, 0);
}
void func_800553F4(void) {
gSoundManager->unk_168 = 1;
}
void snd_start_sound_raw(s32 soundID, s16 volume, s16 pitchShift, s32 pan) {
SoundManager* soundManager = gSoundManager;
au_sfx_enqueue_event(soundManager, soundID, volume, pitchShift, pan);
}
AuResult snd_ambient_80055448(s32 ambSoundID) {
return func_80053F80(ambSoundID);
}
AuResult snd_ambient_80055464(s32 arg0, s32 arg1) {
AuResult status = func_80050C30(arg0);
if (status != AU_RESULT_OK) {
return status;
}
return func_80050CA0(arg0, arg1);
}
AuResult snd_ambient_quick_fade_out(s32 arg0) {
AuResult status = func_80050C30(arg0);
if (status == AU_RESULT_OK) {
func_80050EF0_fade_out_quick(arg0);
}
return status;
}
AuResult snd_ambient_slow_fade_out(s32 arg0, s32 arg1) {
AuResult status = func_80050C30(arg0);
if (status == AU_RESULT_OK) {
func_80050EF0_fade_out_slow(arg0, arg1);
}
return status;
}
// fade out sounds (kmr_00)
AuResult snd_ambient_8005553C(s32 arg0, s32 arg1) {
AuResult status = func_80050C30(arg0);
if (status == AU_RESULT_OK) {
func_80050EF0_fade_out_unk(arg0, arg1);
}
return status;
}
// fade in sounds (kmr_00) -- restart?
AuResult snd_ambient_80055590(s32 arg0, s32 arg1) {
AuResult status = func_80050C30(arg0);
if (status == AU_RESULT_OK) {
func_80050EF0_fade_in_unk(arg0, arg1);
}
return status;
}
AuResult snd_ambient_800555E4(s32 arg0) {
AuResult status = func_80050C30(arg0);
if (status != AU_RESULT_OK) {
return status;
}
return func_80051050(arg0);
}
//TODO au_ambience_disable? -- sets a flag which tells the manager to mute players
AuResult snd_ambient_80055618(s32 index, s32 arg1) {
AuResult status = func_80050C30(index);
if (status == AU_RESULT_OK) {
func_80050C54(index, arg1);
}
return status;
}
AuResult au_ambience_set_volume(s32 index, s32 time, s32 volume) {
AuResult status = func_80050C30(index);
if (status == AU_RESULT_OK) {
au_mseq_set_volume(index, time, volume);
}
return status;
}
AuResult au_ambience_disable(s32 index) {
AuResult status = func_80050C30(index);
if (status == AU_RESULT_OK) {
au_mseq_set_disabled(index, TRUE);
}
return status;
}
AuResult au_ambience_enable(s32 index) {
AuResult status = func_80050C30(index);
if (status == AU_RESULT_OK) {
au_mseq_set_disabled(index, FALSE);
}
return status;
}
void snd_ambient_80055760(s32 arg0) {
u32 i;
s32 lim = 4;
D_80078DB6 = 0xFF;
for (i = 0; i < lim; i++) {
if (snd_ambient_80055464(i, 0) != AU_RESULT_OK) {
return;
}
}
snd_ambient_80055848(arg0);
}
AuResult snd_ambient_800557CC(s32 arg0) {
AuResult status = AU_RESULT_OK;
s32 lim = 4;
u32 i;
for (i = 0; i < lim; i++) {
if (i == D_80078DB6) {
status = snd_ambient_slow_fade_out(i, arg0);
} else {
status = snd_ambient_quick_fade_out(i);
}
if (status != AU_RESULT_OK) {
break;
}
}
return status;
}
// play only
AuResult snd_ambient_80055848(s32 index) {
AuResult status = AU_RESULT_OK;
s32 lim = 4;
if (index != D_80078DB6) {
u32 i;
for (i = 0; i < lim; i++) {
if (i == index) {
status = au_ambience_enable(index);
} else {
status = au_ambience_disable(i); // mute
}
if (status != AU_RESULT_OK) {
break;
}
}
if (status == AU_RESULT_OK) {
D_80078DB6 = index;
}
}
return status;
}
AuResult au_song_load(s32 songID, s32 playerIndex) {
BGMHeader* bgmFile;
BGMPlayer* player;
au_get_bgm_player_and_file(playerIndex, &bgmFile, &player);
if (bgmFile != NULL) {
return au_load_song_files(songID, bgmFile, player);
} else {
return AU_ERROR_NULL_SONG_NAME;
}
}
AuResult au_song_start(s32 songName) {
AuResult status;
SongUpdateEvent s;
PreventBGMPlayerUpdate = TRUE;
s.songName = songName;
s.duration = 0;
s.startVolume = 127;
s.finalVolume = 127;
s.variation = 0;
s.unk14 = 0;
status = au_bgm_dispatch_player_event(&s);
PreventBGMPlayerUpdate = FALSE;
return status;
}
AuResult au_song_start_variation(s32 songName, s32 variation) {
AuResult status;
SongUpdateEvent s;
PreventBGMPlayerUpdate = TRUE;
s.songName = songName;
s.duration = 0;
s.startVolume = 127;
s.finalVolume = 127;
s.variation = variation;
s.unk14 = 0;
status = au_bgm_dispatch_player_event(&s);
PreventBGMPlayerUpdate = FALSE;
return status;
}
AuResult au_song_stop(s32 songName) {
return au_bgm_stop_song(songName);
}
void au_stop_songs(void) {
au_bgm_stop_all();
}
AuResult au_song_is_playing(s32 songName) {
return au_bgm_is_song_playing(songName);
}
AuResult snd_set_song_variation_fade(s32 songName, s32 variation, s32 fadeInTime, s32 startVolume, s32 endVolume) {
AuResult status;
SongUpdateEvent s;
PreventBGMPlayerUpdate = TRUE;
s.songName = songName;
s.duration = fadeInTime;
s.startVolume = startVolume;
s.finalVolume = endVolume;
s.variation = variation;
s.unk14 = 0;
status = au_bgm_dispatch_player_event(&s);
PreventBGMPlayerUpdate = FALSE;
return status;
}
AuResult snd_set_song_fade(s32 songName, s32 fadeInTime, s32 startVolume, s32 endVolume) {
AuResult status;
SongUpdateEvent s;
PreventBGMPlayerUpdate = TRUE;
s.songName = songName;
s.duration = fadeInTime;
s.startVolume = startVolume;
s.finalVolume = endVolume;
s.variation = 0;
s.unk14 = 0;
status = au_bgm_dispatch_player_event(&s);
PreventBGMPlayerUpdate = FALSE;
return status;
}
AuResult snd_set_song_variation_fade_time(s32 songName, s32 fadeTime, s32 variation) {
SongUpdateEvent s;
s.songName = songName;
s.duration = fadeTime;
s.startVolume = 0;
s.finalVolume = 0;
s.variation = variation;
s.unk14 = 0;
return func_8004DB4C(&s);
}
AuResult func_80055AF0(s32 songName) {
SongUpdateEvent s;
s.songName = songName;
s.duration = 0;
s.startVolume = 0;
s.finalVolume = 0;
s.variation = 0;
s.unk14 = 0;
return func_8004DCB8(&s, 0);
}
AuResult func_80055B28(s32 songName) {
AuResult status;
SongUpdateEvent s;
PreventBGMPlayerUpdate = TRUE;
s.songName = songName;
s.duration = 2000;
s.startVolume = 1;
s.finalVolume = 127;
s.variation = 0;
s.unk14 = 0;
status = func_8004DE2C(&s);
PreventBGMPlayerUpdate = FALSE;
return status;
}
AuResult func_80055B80(s32 songName) {
SongUpdateEvent s;
s.songName = songName;
s.duration = 0;
s.startVolume = 0;
s.finalVolume = 0;
s.variation = 0;
s.unk14 = 0;
return func_8004DCB8(&s, 1);
}
AuResult func_80055BB8(s32 songName, s32 fadeTime) {
SongUpdateEvent s;
s.songName = songName;
s.duration = fadeTime;
s.startVolume = 0;
s.finalVolume = 0;
s.variation = 0;
s.unk14 = 1;
return func_8004DB4C(&s);
}
AuResult func_80055BF0(s32 songName) {
SongUpdateEvent s;
s.songName = songName;
s.duration = 0;
s.startVolume = 0;
s.finalVolume = 0;
s.variation = 0;
s.unk14 = 1;
return func_8004DCB8(&s, 0);
}
AuResult func_80055C2C(s32 songName) {
SongUpdateEvent s;
s.songName = songName;
s.duration = 0;
s.startVolume = 0;
s.finalVolume = 0;
s.variation = 0;
s.unk14 = 1;
return func_8004DE2C(&s);
}
AuResult func_80055C64(s32 songName) {
SongUpdateEvent s;
s.songName = songName;
s.duration = 500;
s.finalVolume = 0x2000;
return func_8004E0F4(&s);
}
AuResult func_80055C94(s32 songName) {
SongUpdateEvent s;
s.songName = songName;
s.duration = 500;
s.finalVolume = 0x7FFF;
return func_8004E0F4(&s);
}
AuResult snd_set_song_variation(s32 songName, s32 variation) {
SongUpdateEvent s;
s.songName = songName;
s.variation = variation;
return func_80050970(&s);
}
// get file and player information for a given song name if it's currently playing
AuResult snd_song_get_playing_info(s32 songName, BGMHeader** outFile, BGMPlayer** outPlayer) {
AuResult status = AU_RESULT_OK;
BGMHeader* bgmFile;
bgmFile = gSoundGlobals->dataBGM[0];
if (songName == bgmFile->name) {
*outPlayer = gBGMPlayerA;
*outFile = bgmFile;
} else {
bgmFile = gSoundGlobals->dataBGM[1];
if (songName == bgmFile->name) {
*outPlayer = gBGMPlayerB;
*outFile = bgmFile;
} else {
status = AU_ERROR_1;
}
}
return status;
}
AuResult func_80055D38(s32 songName, f32 arg1) {
BGMPlayer* bgmPlayer;
BGMHeader* bgmFile;
AuResult status;
status = snd_song_get_playing_info(songName, &bgmFile, &bgmPlayer);
if (status == AU_RESULT_OK) {
func_80050770(bgmPlayer, arg1);
}
return status;
}
AuResult func_80055D8C(s32 songName, s32 arg1) {
BGMPlayer* bgmPlayer;
BGMHeader* bgmFile;
AuResult status;
status = snd_song_get_playing_info(songName, &bgmFile, &bgmPlayer);
if (status == AU_RESULT_OK) {
func_80050818(bgmPlayer, arg1);
}
return status;
}
AuResult snd_song_set_track_volumes(s32 songName, MusicTrackVols trackVolSet) {
BGMPlayer* bgmPlayer;
BGMHeader* bgmFile;
AuResult status;
status = snd_song_get_playing_info(songName, &bgmFile, &bgmPlayer);
if (status == AU_RESULT_OK) {
u8* trackVols = snd_song_get_track_volumes_set(trackVolSet);
if (trackVols != NULL) {
au_bgm_set_track_volumes(bgmPlayer, trackVols, TRUE);
} else {
status = AU_ERROR_11;
}
}
return status;
}
AuResult snd_song_clear_track_volumes(s32 songName, MusicTrackVols trackVolSet) {
BGMPlayer* bgmPlayer;
BGMHeader* bgmFile;
AuResult status;
status = snd_song_get_playing_info(songName, &bgmFile, &bgmPlayer);
if (status == AU_RESULT_OK) {
u8* trackVols = snd_song_get_track_volumes_set(trackVolSet);
if (trackVols != NULL) {
au_bgm_set_track_volumes(bgmPlayer, trackVols, FALSE);
} else {
status = AU_ERROR_11;
}
}
return status;
}
static u8* snd_song_get_track_volumes_set(MusicTrackVols trackVolSet) {
u8* trackVols = NULL;
switch (trackVolSet) {
case TRACK_VOLS_0:
trackVols = D_80078DB8;
break;
case TRACK_VOLS_1:
trackVols = D_80078DC4;
break;
case TRACK_VOLS_2:
trackVols = D_80078DCC;
break;
case TRACK_VOLS_3:
trackVols = D_80078DD0;
break;
case TRACK_VOLS_KPA_OUTSIDE:
trackVols = TrackVols_KPA_Outside;
break;
case TRACK_VOLS_KPA_1:
trackVols = TrackVols_KPA_1;
break;
case TRACK_VOLS_KPA_2:
trackVols = TrackVols_KPA_2;
break;
case TRACK_VOLS_KPA_3:
trackVols = TrackVols_KPA_3;
break;
}
return trackVols;
}
static const f32 padding[] = {0.0f};
static AuResult snd_song_change_track_volume(s32 songName, u32 trackIdx, u32 volume) {
BGMPlayer* bgmPlayer;
BGMHeader* bgmFile;
AuResult status;
status = snd_song_get_playing_info(songName, &bgmFile, &bgmPlayer);
if (status == AU_RESULT_OK) {
if (volume > 0x7F) {
volume = 0x7F;
}
if (trackIdx > 15) {
trackIdx = 15;
}
au_bgm_change_track_volume(bgmPlayer, trackIdx, 96, volume);
}
return status;
}
AuResult snd_song_set_track_vol_mute(s32 songName, s32 trackIdx) {
return snd_song_change_track_volume(songName, trackIdx, 0);
}
AuResult snd_song_set_track_vol_quiet(s32 songName, s32 trackIdx) {
return snd_song_change_track_volume(songName, trackIdx, 0x3F);
}
AuResult snd_song_set_track_vol_full(s32 songName, s32 trackIdx) {
return snd_song_change_track_volume(songName, trackIdx, 0x7F);
}
void bgm_set_proximity_mix_far(s32 songName, s32 mix) {
au_bgm_set_proximity_mix(songName, (u8)mix);
}
void bgm_set_proximity_mix_near(s32 songName, s32 mix) {
au_bgm_set_proximity_mix(songName, (u8)mix | 0x57000000);
}
void bgm_set_proximity_mix_full(s32 songName, s32 mix) {
au_bgm_set_proximity_mix(songName, (u8)mix | 0x7F000000);
}
void bgm_poll_music_events(MusicEventTrigger** musicEvents, s32* count) {
AuGlobals* globals = gSoundGlobals;
*musicEvents = globals->musicEventQueue;
*count = globals->musicEventQueueCount;
}
void bgm_flush_music_events(void) {
gSoundGlobals->flushMusicEventQueue = TRUE;
}
void bgm_trigger_music_event(s32 playerID, s32 trackIndex, s32 eventInfo) {
AuGlobals* globals = gSoundGlobals;
if (globals->musicEventQueueCount < 16) {
*globals->musicEventQueuePos++ = ((playerID << 0x1C) + ((trackIndex & 0xF) << 0x18) + eventInfo);
globals->musicEventQueueCount++;
}
}
void bgm_clear_music_events(void) {
AuGlobals* globals = gSoundGlobals;
s32* buf = globals->musicEventQueue;
s32 i = 15;
do {
*buf++ = 0;
} while(i-- != 0);
globals->musicEventQueueCount = 0;
globals->flushMusicEventQueue = FALSE;
globals->musicEventQueuePos = globals->musicEventQueue;
}
void au_register_callback(AuCallback func, s32 index) {
gSoundGlobals->audioThreadCallbacks[index] = func;
}
void audio_set_stereo(void) {
func_80056D5C(1);
func_80054DA8(0);
}
void audio_set_mono(void) {
func_80056D5C(0);
func_80054DA8(1);
}
void func_800561A4(s32 arg0) {
func_80054CE0(1, arg0);
}
void func_800561C4(s32 arg0) {
func_80054CE0(0x10, arg0);
}
void func_800561E4(s32 arg0) {
func_80054D74(0x10, arg0);
}
void func_80056204(void) {
func_8004BA54(gSoundManager, 0);
}
void func_80056228(void) {
func_8004BA54(gSoundManager, 1);
}

763
src/audio/31650.c Normal file
View File

@ -0,0 +1,763 @@
#include "common.h"
#include "audio.h"
#include "nu/nualsgi.h"
static s16 _getVol(s16 arg0, s32 arg1, s16 arg2, u16 arg3);
AuSynDriver* gActiveSynDriverPtr = NULL;
AuSynDriver* gSynDriverPtr = NULL;
u8 D_80078E58 = FALSE;
u16 D_80078E5A = 0x7FFF;
u8 D_80078E5C = FALSE;
extern s16 AuEqPower[128];
#define AU_EQPOW_MID_IDX 64
#define AU_EQPOW_MAX_IDX 127
void au_driver_init(AuSynDriver* driver, ALConfig* config) {
s32 i;
ALHeap* heap = config->heap;
if (gActiveSynDriverPtr != NULL) {
return;
}
driver->num_pvoice = config->num_pvoice;
driver->unk_num_gamma = config->unk_num_gamma;
driver->curSamples = 0;
driver->unk_04 = 0;
driver->outputRate = config->outputRate;
driver->dmaNew = config->dmaNew;
gActiveSynDriverPtr = driver;
gSynDriverPtr = driver;
D_80078E58 = FALSE;
D_80078E5A = 0x7FFF;
D_80078E5C = TRUE;
gSynDriverPtr->pvoices = alHeapAlloc(heap, config->num_pvoice, sizeof(*gSynDriverPtr->pvoices));
// this is inlined alN_PVoiceNew
for (i = 0; i < config->num_pvoice; i++) {
AuPVoice* voice = &gSynDriverPtr->pvoices[i];
voice->loadFilter.dc_state = alHeapAlloc(heap, 1, sizeof(*voice->loadFilter.dc_state));
voice->loadFilter.dc_lstate = alHeapAlloc(heap, 1, sizeof(*voice->loadFilter.dc_lstate));
// note: dmaNew has type ALDMANew (nuAuDmaNew), which returns a ALDMAproc (nuAuDmaCallBack)
voice->loadFilter.dc_dmaFunc = ((ALDMAproc (*)(NUDMAState**))(gSynDriverPtr->dmaNew))(&voice->loadFilter.dc_dmaState);
voice->loadFilter.dc_lastsam = 0;
voice->loadFilter.dc_first = 1;
voice->loadFilter.dc_memin = NULL;
voice->resampler.rs_state = alHeapAlloc(heap, 1, sizeof(*voice->resampler.rs_state));
voice->resampler.delta = 0;
voice->resampler.first = 1;
voice->resampler.rs_ratio = 1.0f;
voice->envMixer.em_state = alHeapAlloc(heap, 1, sizeof(*voice->envMixer.em_state));
voice->envMixer.em_first = 1;
voice->envMixer.em_motion = AL_STOPPED;
voice->envMixer.em_volume = 1;
voice->envMixer.em_ltgt = 1;
voice->envMixer.em_rtgt = 1;
voice->envMixer.em_cvolL = 1;
voice->envMixer.em_cvolR = 1;
voice->envMixer.em_dryamt = 0;
voice->envMixer.em_wetamt = 0;
voice->envMixer.em_lratm = 1;
voice->envMixer.em_lratl = 0;
voice->envMixer.em_rratm = 1;
voice->envMixer.em_rratl = 0;
voice->envMixer.em_delta = 0;
voice->envMixer.em_segEnd = 0;
voice->envMixer.em_pan = 64;
voice->unk_74 = 0;
voice->next = NULL;
voice->gammaID = 0;
voice->index = i;
}
gSynDriverPtr->al_unk_gamma = alHeapAlloc(heap, config->unk_num_gamma, sizeof(*gSynDriverPtr->al_unk_gamma));
for (i = 0; i < config->unk_num_gamma; i++) {
AlUnkGamma* gamma = &gSynDriverPtr->al_unk_gamma[i];
gamma->pvoice_10 = NULL;
gamma->pvoice_14 = NULL;
gamma->unk_00 = 0x7FFF;
gamma->currentEffectType = AU_FX_NONE;
gamma->fxL = alHeapAlloc(heap, 1, sizeof(*gamma->fxL));
gamma->fxR = alHeapAlloc(heap, 1, sizeof(*gamma->fxR));
func_80058E84(gamma->fxL, gamma->currentEffectType, heap);
func_80058E84(gamma->fxR, gamma->currentEffectType, heap);
}
gSynDriverPtr->unk_drvr_24 = alHeapAlloc(heap, 2 * AUDIO_SAMPLES, 2);
gSynDriverPtr->unk_drvr_28 = alHeapAlloc(heap, 2 * AUDIO_SAMPLES, 2);
D_800A3FEC = 0;
D_800A3FEE = 0;
D_800A3FF0 = 4;
D_800A3FE0 = alHeapAlloc(heap, 4 * AUDIO_SAMPLES, 2);
D_800A3FE4 = alHeapAlloc(heap, 4 * AUDIO_SAMPLES, 2);
for (i = 0; i < 4 * AUDIO_SAMPLES; i++) {
D_800A3FE4[i] = D_800A3FE0[i] = 0;
}
gSynDriverPtr->heap = heap;
}
void au_driver_release(void) {
if (gActiveSynDriverPtr != NULL) {
gActiveSynDriverPtr = NULL;
}
}
Acmd* alAudioFrame(Acmd* cmdList, s32* cmdLen, s16* outBuf, s32 outLen) {
Acmd* cmdListPos;
AuPVoice* pvoice;
AlUnkGamma* gamma;
s16* bufPos;
s16 auxOut;
s16 mainOut;
s32 i;
s32 var_s7 = FALSE;
cmdListPos = cmdList;
bufPos = outBuf;
if (gActiveSynDriverPtr == NULL) {
*cmdLen = 0;
} else {
au_update_players_main();
if (D_80078E5C) {
for (i = 0; i < gSynDriverPtr->num_pvoice; i++) {
pvoice = &gSynDriverPtr->pvoices[i];
if (pvoice->envMixer.em_motion == AL_PLAYING) {
func_80057874(i, pvoice->envMixer.em_pan);
}
}
D_80078E5C = FALSE;
}
while (outLen > 0) {
au_update_clients_2();
for (i = 0; i < gSynDriverPtr->num_pvoice; i++) {
pvoice = &gSynDriverPtr->pvoices[i];
if ((pvoice->gammaID != 0xFF) && (pvoice->gammaID < gSynDriverPtr->unk_num_gamma)) {
gamma = &gSynDriverPtr->al_unk_gamma[pvoice->gammaID];
if (gamma->pvoice_14 != NULL) {
gamma->pvoice_14->next = pvoice;
} else {
gamma->pvoice_10 = pvoice;
}
gamma->pvoice_14 = pvoice;
}
}
var_s7 = TRUE;
for (i = 0; i < gSynDriverPtr->unk_num_gamma; i++) {
gamma = &gSynDriverPtr->al_unk_gamma[i];
if (gamma->pvoice_10 != NULL) {
aClearBuffer(cmdListPos++, N_AL_MAIN_L_OUT, 8 * AUDIO_SAMPLES);
if (gamma->pvoice_10 != NULL) {
AuPVoice* next;
do {
cmdListPos = func_80058050(gamma->pvoice_10, cmdListPos);
next = gamma->pvoice_10->next;
gamma->pvoice_10->next = NULL;
gamma->pvoice_10 = next;
} while (next != NULL);
gamma->pvoice_14 = 0;
}
if (gamma->currentEffectType != AU_FX_NONE) {
cmdListPos = func_80059310(gamma->fxL, cmdListPos, N_AL_AUX_L_OUT, 0);
cmdListPos = func_80059310(gamma->fxR, cmdListPos, N_AL_AUX_R_OUT, 0);
}
if (i == D_800A3FEC) {
mainOut = -1;
switch (D_800A3FEE) {
case 1:
mainOut = N_AL_MAIN_L_OUT;
auxOut = N_AL_AUX_L_OUT;
break;
case 2:
mainOut = N_AL_MAIN_R_OUT;
auxOut = N_AL_AUX_R_OUT;
break;
}
if (mainOut != -1) {
aSaveBufferSize(cmdListPos++, 2 * AUDIO_SAMPLES, mainOut, osVirtualToPhysical(D_800A3FE0 + (D_800A3FE8 % D_800A3FF0) * AUDIO_SAMPLES));
aLoadBufferSize(cmdListPos++, 2 * AUDIO_SAMPLES, mainOut, osVirtualToPhysical(D_800A3FE0 + ((D_800A3FE8 + 1) % D_800A3FF0) * AUDIO_SAMPLES));
aSaveBufferSize(cmdListPos++, 2 * AUDIO_SAMPLES, auxOut, osVirtualToPhysical(D_800A3FE4 + (D_800A3FE8 % D_800A3FF0) * AUDIO_SAMPLES));
aLoadBufferSize(cmdListPos++, 2 * AUDIO_SAMPLES, auxOut, osVirtualToPhysical(D_800A3FE4 + ((D_800A3FE8 + 1) % D_800A3FF0) * AUDIO_SAMPLES));
}
}
if (var_s7) {
aClearBuffer(cmdListPos++, 0, 4 * AUDIO_SAMPLES);
} else {
aLoadBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->unk_drvr_28));
}
aMix(cmdListPos++, 0, gamma->unk_00, N_AL_AUX_L_OUT, 0);
aMix(cmdListPos++, 0, gamma->unk_00, N_AL_AUX_R_OUT, 2 * AUDIO_SAMPLES);
aSaveBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->unk_drvr_28));
if (var_s7) {
aClearBuffer(cmdListPos++, 0, 4 * AUDIO_SAMPLES);
var_s7 = FALSE;
} else {
aLoadBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->unk_drvr_24));
}
aMix(cmdListPos++, 0, gamma->unk_00, N_AL_MAIN_L_OUT, 0);
aMix(cmdListPos++, 0, gamma->unk_00, N_AL_MAIN_R_OUT, 2 * AUDIO_SAMPLES);
aSaveBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, 0, osVirtualToPhysical(gSynDriverPtr->unk_drvr_24));
}
}
aDMEMMove(cmdListPos++, 0, N_AL_MAIN_L_OUT, 4 * AUDIO_SAMPLES);
aLoadBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, N_AL_AUX_L_OUT, osVirtualToPhysical(gSynDriverPtr->unk_drvr_28));
aMix(cmdListPos++, 0, 0x7FFF, N_AL_AUX_L_OUT, N_AL_MAIN_L_OUT);
aMix(cmdListPos++, 0, 0x7FFF, N_AL_AUX_R_OUT, N_AL_MAIN_R_OUT);
if (D_80078E58) {
u16 temp;
aDMEMMove(cmdListPos++, N_AL_MAIN_L_OUT, 0, 4 * AUDIO_SAMPLES);
aClearBuffer(cmdListPos++, N_AL_MAIN_L_OUT, 4 * AUDIO_SAMPLES);
temp = D_80078E5A;
aMix(cmdListPos++, 0, temp, 0, N_AL_MAIN_L_OUT);
aMix(cmdListPos++, 0, temp, 2 * AUDIO_SAMPLES, N_AL_MAIN_R_OUT);
}
outLen -= AUDIO_SAMPLES;
aInterleavePart(cmdListPos++);
aSaveBufferSize(cmdListPos++, 4 * AUDIO_SAMPLES, 0, bufPos);
bufPos += 2 * AUDIO_SAMPLES;
D_800A3FE8++;
gSynDriverPtr->curSamples += AUDIO_SAMPLES;
}
*cmdLen = (cmdListPos - cmdList);
}
return cmdListPos;
}
void func_80056D34(void) {
D_80078E58 = TRUE;
}
void func_80056D44(s16 arg0) {
D_80078E5A = arg0;
}
s16 func_80056D50(void) {
return D_80078E5A;
}
void func_80056D5C(u8 bStereoSound) {
AuSynUseStereo = bStereoSound;
D_80078E5C = TRUE;
}
void func_80056D78(u8 index, u16 arg1) {
AlUnkGamma* gamma = &gSynDriverPtr->al_unk_gamma[index];
gamma->unk_00 = arg1 & 0x7FFF;
}
u16 func_80056DA4(u8 index, u16 arg1) {
AlUnkGamma* gamma = &gSynDriverPtr->al_unk_gamma[index];
return gamma->unk_00;
}
void func_80056DCC(u8 index, u8 effectType) {
AlUnkGamma* gamma = &gSynDriverPtr->al_unk_gamma[index];
gamma->currentEffectType = effectType;
func_8005904C(gamma->fxL, effectType);
func_8005904C(gamma->fxR, effectType);
}
void func_80056E34(u8 index, s16 delayIndex, s16 paramID, s32 value) {
AlUnkGamma* gamma = &gSynDriverPtr->al_unk_gamma[index];
au_fx_param_hdl(gamma->fxL, delayIndex, paramID, value);
au_fx_param_hdl(gamma->fxR, delayIndex, paramID, value);
}
void func_80056EC0(u8 index, s8 arg1) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[index];
pvoice->gammaID = arg1;
}
// n_alLoadParam case AL_FILTER_RESET
void au_pvoice_reset_filter(u8 voiceIdx) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
AuLoadFilter* filter = &pvoice->loadFilter;
pvoice->envMixer.em_motion = AL_STOPPED;
pvoice->envMixer.em_first = 1;
pvoice->envMixer.em_volume = 1;
pvoice->resampler.delta = 0;
pvoice->resampler.first = 1;
filter->dc_lastsam = 0;
filter->dc_first = 1;
filter->dc_sample = 0;
if (filter->instrument != NULL) {
filter->dc_memin = filter->instrument->base;
if (filter->instrument->type == 0) {
if (filter->instrument->loopEnd != 0){
filter->dc_loop.count = filter->instrument->loopCount;
}
} else if (filter->instrument->type == 1) {
if (filter->instrument->loopEnd != 0){
filter->dc_loop.count = filter->instrument->loopCount;
}
}
}
}
// n_alEnvmixerParam case AL_FILTER_START
void au_pvoice_set_playing(u8 index) {
AuPVoice* pvoice = (AuPVoice*)&gSynDriverPtr->pvoices[index];
pvoice->envMixer.em_motion = AL_PLAYING;
}
#define ADPCMFBYTES 9
// n_alLoadParam case AL_FILTER_SET_WAVETABLE
void au_pvoice_set_filter(u8 index, u8 reverbType, Instrument* instrument, f32 pitchRatio, s16 arg4, u8 pan, u8 reverb, s32 arg7) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[index];
AuLoadFilter* filter = &pvoice->loadFilter;
AuEnvMixer* envMixer = &pvoice->envMixer;
AuResampler* resampler = &pvoice->resampler;
pvoice->gammaID = reverbType;
filter->instrument = instrument;
pvoice->loadFilter.dc_memin = filter->instrument->base;
pvoice->loadFilter.dc_sample = 0;
switch (filter->instrument->type) {
case AL_ADPCM_WAVE:
filter->instrument->wavDataLength = (filter->instrument->wavDataLength / ADPCMFBYTES) * ADPCMFBYTES;
pvoice->loadFilter.dc_bookSize = filter->instrument->dc_bookSize;
if (filter->instrument->loopEnd == 0) {
filter->dc_loop.count = 0;
filter->dc_loop.end = 0;
filter->dc_loop.start = 0;
} else {
filter->dc_loop.start = filter->instrument->loopStart;
filter->dc_loop.end = filter->instrument->loopEnd;
filter->dc_loop.count = filter->instrument->loopCount;
alCopy(filter->instrument->loopPredictor, filter->dc_lstate, sizeof(ADPCM_STATE));
}
break;
case AL_RAW16_WAVE:
if (filter->instrument->loopEnd != 0) {
filter->dc_loop.start = filter->instrument->loopStart;
filter->dc_loop.end = filter->instrument->loopEnd;
filter->dc_loop.count = filter->instrument->loopCount;
} else {
filter->dc_loop.count = 0;
filter->dc_loop.end = 0;
filter->dc_loop.start = 0;
}
break;
}
envMixer->em_motion = AL_PLAYING;
envMixer->em_first = 1;
envMixer->em_delta = 0;
envMixer->em_segEnd = arg7;
envMixer->em_pan = pan;
envMixer->em_volume = SQ(arg4) >> 0xF;
envMixer->em_dryamt = AuEqPower[reverb];
envMixer->em_wetamt = AuEqPower[AU_EQPOW_MAX_IDX - reverb];
if (envMixer->em_segEnd != 0) {
envMixer->em_cvolL = 1;
envMixer->em_cvolR = 1;
} else {
if (!AuSynUseStereo) {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
} else {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF;
}
}
resampler->rs_ratio = pitchRatio;
}
void au_pvoice_set_filter_wavetable(u8 voiceIdx, Instrument* instrument) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
AuLoadFilter* filter = &pvoice->loadFilter;
pvoice->loadFilter.instrument = instrument;
pvoice->loadFilter.dc_memin = filter->instrument->base;
pvoice->loadFilter.dc_sample = 0;
switch (filter->instrument->type) {
case AL_ADPCM_WAVE:
filter->instrument->wavDataLength = (filter->instrument->wavDataLength / ADPCMFBYTES) * ADPCMFBYTES;
pvoice->loadFilter.dc_bookSize = filter->instrument->dc_bookSize;
if (filter->instrument->loopEnd == 0) {
pvoice->loadFilter.dc_loop.count = 0;
pvoice->loadFilter.dc_loop.end = 0;
pvoice->loadFilter.dc_loop.start = 0;
} else {
pvoice->loadFilter.dc_loop.start = filter->instrument->loopStart;
pvoice->loadFilter.dc_loop.end = filter->instrument->loopEnd;
pvoice->loadFilter.dc_loop.count = filter->instrument->loopCount;
alCopy(filter->instrument->loopPredictor, pvoice->loadFilter.dc_lstate, sizeof(ADPCM_STATE));
}
break;
case AL_RAW16_WAVE:
if (filter->instrument->loopEnd != 0) {
pvoice->loadFilter.dc_loop.start = filter->instrument->loopStart;
pvoice->loadFilter.dc_loop.end = filter->instrument->loopEnd;
pvoice->loadFilter.dc_loop.count = filter->instrument->loopCount;
} else {
pvoice->loadFilter.dc_loop.count = 0;
pvoice->loadFilter.dc_loop.end = 0;
pvoice->loadFilter.dc_loop.start = 0;
}
break;
}
}
void au_pvoice_set_pitch_ratio(u8 voiceIdx, f32 pitchRatio) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
pvoice->resampler.rs_ratio = pitchRatio;
}
void func_8005736C(u8 voiceIdx, s16 volume, s32 arg2, u8 pan, u8 arg4) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
AuEnvMixer* envMixer = &pvoice->envMixer;
if (envMixer->em_delta >= envMixer->em_segEnd) {
envMixer->em_delta = envMixer->em_segEnd;
if (!AuSynUseStereo) {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
} else {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF;
}
} else {
envMixer->em_cvolL = _getVol(envMixer->em_cvolL, envMixer->em_delta, envMixer->em_lratm, envMixer->em_lratl);
envMixer->em_cvolR = _getVol(envMixer->em_cvolR, envMixer->em_delta, envMixer->em_rratm, envMixer->em_rratl);
}
if (envMixer->em_cvolL == 0) {
envMixer->em_cvolL = 1;
}
if (envMixer->em_cvolR == 0) {
envMixer->em_cvolR = 1;
}
envMixer->em_delta = 0;
envMixer->em_segEnd = arg2;
envMixer->em_pan = pan;
envMixer->em_volume = SQ(volume) >> 0xF;
envMixer->em_dryamt = AuEqPower[arg4];
envMixer->em_wetamt = AuEqPower[AU_EQPOW_MAX_IDX - arg4];
envMixer->em_first = 1;
}
void func_80057548(u8 voiceIdx, u8 pan, u8 arg2) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
AuEnvMixer* envMixer = &pvoice->envMixer;
if (envMixer->em_delta >= envMixer->em_segEnd) {
envMixer->em_delta = envMixer->em_segEnd;
if (!AuSynUseStereo) {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
} else {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF;
}
} else {
envMixer->em_cvolL = _getVol(envMixer->em_cvolL, envMixer->em_delta, envMixer->em_lratm, envMixer->em_lratl);
envMixer->em_cvolR = _getVol(envMixer->em_cvolR, envMixer->em_delta, envMixer->em_rratm, envMixer->em_rratl);
}
if (envMixer->em_cvolL == 0) {
envMixer->em_cvolL = 1;
}
if (envMixer->em_cvolR == 0) {
envMixer->em_cvolR = 1;
}
envMixer->em_pan = pan;
envMixer->em_dryamt = AuEqPower[arg2];
envMixer->em_wetamt = AuEqPower[AU_EQPOW_MAX_IDX - arg2];
envMixer->em_first = 1;
}
void func_800576EC(u8 voiceIdx, s16 arg1, s32 arg2) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
AuEnvMixer* envMixer = &pvoice->envMixer;
if (envMixer->em_delta >= envMixer->em_segEnd) {
envMixer->em_delta = envMixer->em_segEnd;
if (!AuSynUseStereo) {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
} else {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF;
}
} else {
envMixer->em_cvolL = _getVol(envMixer->em_cvolL, envMixer->em_delta, envMixer->em_lratm, envMixer->em_lratl);
envMixer->em_cvolR = _getVol(envMixer->em_cvolR, envMixer->em_delta, envMixer->em_rratm, envMixer->em_rratl);
}
if (envMixer->em_cvolL == 0) {
envMixer->em_cvolL = 1;
}
if (envMixer->em_cvolR == 0) {
envMixer->em_cvolR = 1;
}
envMixer->em_volume = SQ(arg1) >> 0xF;
envMixer->em_delta = 0;
envMixer->em_segEnd = arg2;
envMixer->em_first = 1;
}
void func_80057874(u8 voiceIdx, u8 pan) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
AuEnvMixer* envMixer = &pvoice->envMixer;
if (envMixer->em_delta >= envMixer->em_segEnd) {
envMixer->em_delta = envMixer->em_segEnd;
if (!AuSynUseStereo) {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
} else {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF;
}
} else {
envMixer->em_cvolL = _getVol(envMixer->em_cvolL, envMixer->em_delta, envMixer->em_lratm, envMixer->em_lratl);
envMixer->em_cvolR = _getVol(envMixer->em_cvolR, envMixer->em_delta, envMixer->em_rratm, envMixer->em_rratl);
}
if (envMixer->em_cvolL == 0) {
envMixer->em_cvolL = 1;
}
if (envMixer->em_cvolR == 0) {
envMixer->em_cvolR = 1;
}
envMixer->em_pan = pan;
envMixer->em_first = 1;
}
void func_800579D8(u8 voiceIdx, u8 dryAmt) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
AuEnvMixer* envMixer = &pvoice->envMixer;
if (envMixer->em_delta >= envMixer->em_segEnd) {
envMixer->em_delta = envMixer->em_segEnd;
if (!AuSynUseStereo) {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MID_IDX]) >> 0xF;
} else {
envMixer->em_cvolL = (envMixer->em_volume * AuEqPower[envMixer->em_pan]) >> 0xF;
envMixer->em_cvolR = (envMixer->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - envMixer->em_pan]) >> 0xF;
}
} else {
envMixer->em_cvolL = _getVol(envMixer->em_cvolL, envMixer->em_delta, envMixer->em_lratm, envMixer->em_lratl);
envMixer->em_cvolR = _getVol(envMixer->em_cvolR, envMixer->em_delta, envMixer->em_rratm, envMixer->em_rratl);
}
if (envMixer->em_cvolL == 0) {
envMixer->em_cvolL = 1;
}
if (envMixer->em_cvolR == 0) {
envMixer->em_cvolR = 1;
}
envMixer->em_dryamt = AuEqPower[dryAmt];
envMixer->em_wetamt = AuEqPower[AU_EQPOW_MAX_IDX - dryAmt];
envMixer->em_first = 1;
}
s32 func_80057B64(u8 voiceIdx) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
return pvoice->envMixer.em_motion;
}
s32 func_80057B8C(u8 voiceIdx) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
return pvoice->gammaID;
}
f32 func_80057BB4(u8 voiceIdx) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
return pvoice->resampler.rs_ratio;
}
u8 func_80057BDC(u8 voiceIdx) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
return pvoice->envMixer.em_pan;
}
s16 func_80057C04(u8 voiceIdx) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
return pvoice->envMixer.em_dryamt;
}
s16 func_80057C2C(u8 voiceIdx) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
return pvoice->envMixer.em_wetamt;
}
s32 func_80057C54(u8 voiceIdx) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
AuEnvMixer* sub48 = &pvoice->envMixer;
u32 retVal;
if (sub48->em_delta >= sub48->em_segEnd) {
if (!AuSynUseStereo) {
retVal = (sub48->em_volume * AuEqPower[AU_EQPOW_MID_IDX] * 2) >> 0x10;
} else {
retVal = (sub48->em_volume * AuEqPower[sub48->em_pan] * 2) >> 0x10;
}
} else {
retVal = _getVol(sub48->em_cvolL, sub48->em_delta, sub48->em_lratm, sub48->em_lratl);
}
return retVal;
}
s32 func_80057D0C(u8 voiceIdx) {
AuPVoice* pvoice = &gSynDriverPtr->pvoices[voiceIdx];
AuEnvMixer* sub48 = &pvoice->envMixer;
u32 retVal;
if (sub48->em_delta >= sub48->em_segEnd) {
if (!AuSynUseStereo) {
retVal = (sub48->em_volume * AuEqPower[AU_EQPOW_MID_IDX] * 2) >> 0x10;
} else {
retVal = (sub48->em_volume * AuEqPower[AU_EQPOW_MAX_IDX - sub48->em_pan] * 2) >> 0x10;
}
} else {
retVal = _getVol(sub48->em_cvolL, sub48->em_delta, sub48->em_lratm, sub48->em_lratl);
}
return retVal;
}
void func_80057DC8(s32 arg0) {
if (arg0 < 2) {
D_800A3FF0 = 0;
D_800A3FEE = 0;
}
D_800A3FF0 = arg0;
if (arg0 >= 5) {
D_800A3FF0 = 4;
}
}
void func_80057E08(u8 arg0) {
s32* phi_a1 = (s32*)D_800A3FE0;
s32* phi_v1 = (s32*)D_800A3FE4;
s32 i;
for (i = 0; i < 2 * AUDIO_SAMPLES; i++) {
*phi_a1++ = 0;
*phi_v1++ = 0;
}
D_800A3FEC = arg0;
D_800A3FEE = 1;
D_800A3FE8 = 0;
}
void func_80057E5C(u8 arg0) {
s32* phi_a1 = (s32*)D_800A3FE0;
s32* phi_v1 = (s32*)D_800A3FE4;
s32 i;
for (i = 0; i < 2 * AUDIO_SAMPLES; i++) {
*phi_a1++ = 0;
*phi_v1++ = 0;
}
D_800A3FEC = arg0;
D_800A3FEE = 2;
D_800A3FE8 = 0;
}
void func_80057EB0(void) {
D_800A3FEC = 0;
D_800A3FEE = 0;
D_800A3FE8 = 0;
}
void func_80057ED0(s16 arg0) {
s32* phi_a1 = (s32*)D_800A3FE0;
s32* phi_v1 = (s32*)D_800A3FE4;
s32 i;
for (i = 0; i < 2 * AUDIO_SAMPLES; i++) {
*phi_a1++ = 0;
*phi_v1++ = 0;
}
D_800A3FEC = 0;
D_800A3FEE = arg0;
D_800A3FE8 = 0;
}
void alHeapInit(ALHeap* hp, u8* base, s32 len) {
u32 i;
s32 alignBytes = 0x10 - ((s32)base & 0xF);
if (alignBytes != 0x10) {
hp->base = base + alignBytes;
} else {
hp->base = base;
}
hp->len = len;
hp->count = 0;
hp->cur = hp->base;
for (i = 0; i < (u32)(hp->len) >> 2; i++) {
((u32*)hp->base)[i] = 0;
}
}
void* alHeapAlloc(ALHeap* heap, s32 count, s32 size) {
void* ret = NULL;
u8* newCur = &heap->cur[ALIGN16(count * size)];
if (&heap->base[heap->len] >= newCur) {
ret = heap->cur;
heap->cur = newCur;
}
return ret;
}
void alCopy(void* src, void* dst, s32 size) {
s32 i;
u8* srcIt = src;
u8* dstIt = dst;
for (i = 0; i < size; i++) {
*dstIt++ = *srcIt++;
}
}
static s16 _getVol(s16 ivol, s32 samples, s16 ratem, u16 ratel) {
s32 tmpl;
samples = samples >> 3;
if (samples == 0) {
return ivol;
}
tmpl = ratel * samples;
tmpl = tmpl >> 16;
tmpl += ratem * samples;
return ivol + tmpl;
}

92
src/audio/33450.c Normal file
View File

@ -0,0 +1,92 @@
#include "common.h"
#include "audio.h"
// values for cosine from 0 to pi/2 multiplied by 32767
// called n_eqpower in libultra
s16 AuEqPower[128] = {
32767, 32764, 32757, 32744, 32727, 32704, 32677, 32644,
32607, 32564, 32517, 32464, 32407, 32344, 32277, 32205,
32127, 32045, 31958, 31866, 31770, 31668, 31561, 31450,
31334, 31213, 31087, 30957, 30822, 30682, 30537, 30388,
30234, 30075, 29912, 29744, 29572, 29395, 29214, 29028,
28838, 28643, 28444, 28241, 28033, 27821, 27605, 27385,
27160, 26931, 26698, 26461, 26220, 25975, 25726, 25473,
25216, 24956, 24691, 24423, 24151, 23875, 23596, 23313,
23026, 22736, 22442, 22145, 21845, 21541, 21234, 20924,
20610, 20294, 19974, 19651, 19325, 18997, 18665, 18331,
17993, 17653, 17310, 16965, 16617, 16266, 15913, 15558,
15200, 14840, 14477, 14113, 13746, 13377, 13006, 12633,
12258, 11881, 11503, 11122, 10740, 10357, 9971, 9584,
9196, 8806, 8415, 8023, 7630, 7235, 6839, 6442,
6044, 5646, 5246, 4845, 4444, 4042, 3640, 3237,
2833, 2429, 2025, 1620, 1216, 810, 405, 0
};
static Acmd* _decodeChunk(Acmd* cmdBufPos, AuLoadFilter* arg1, s32 count, s32 size, s16 arg4, s16 arg5, s32 flags);
static s16 _getRate(f64 arg0, f64 arg1, s32 arg4, u16* arg5);
// au_pull_voice -- based on n_alAdpcmPull
INCLUDE_ASM(s32, "audio/33450", func_80058050);
static Acmd* _decodeChunk(Acmd* cmdBufPos, AuLoadFilter* filter, s32 tsam, s32 nbytes, s16 output, s16 input, s32 flags) {
s32 endAddr;
s32 endAlign;
s32 paddedSize;
if (nbytes > 0) {
endAddr = filter->dc_dmaFunc(filter->dc_memin, nbytes, filter->dc_dmaState, filter->instrument->unk_25); // ALDMAproc has an extra arg added
endAlign = endAddr & 7;
nbytes += endAlign;
paddedSize = nbytes + 8 - (nbytes & 7);
n_aLoadBuffer(cmdBufPos++, paddedSize, input, endAddr - endAlign);
} else {
endAlign = 0;
}
if (flags & A_LOOP) {
aSetLoop(cmdBufPos++, K0_TO_PHYS(filter->dc_lstate));
}
n_aADPCMdec(cmdBufPos++, filter->dc_state, flags, tsam << 1, endAlign, output);
filter->dc_first = 0;
return cmdBufPos;
}
static s16 _getRate(f64 vol, f64 tgt, s32 count, u16* ratel) {
f64 inv;
f64 a;
f64 b;
s16 c_int;
s16 a_int;
s16 b_int;
if (count == 0) {
if (tgt >= vol) {
*ratel = 0xFFFF;
return 0x7FFF;
} else {
*ratel = 0;
return 0;
}
}
inv = (1.0 / count);
if (tgt < 1.0) {
tgt = 1.0;
}
if (vol <= 0.0) {
vol = 1.0;
}
a = (tgt - vol) * inv * 8.0;
a_int = a;
c_int = (a_int - 1);
b = (a - a_int) + 1.0;
b_int = b;
c_int += b_int;
*ratel = (b - b_int) * 0xFFFF;
return c_int;
}

89
src/audio/ambience.c Normal file
View File

@ -0,0 +1,89 @@
#include "common.h"
//#include "audio/public.h"
typedef struct {
/* 0x0 */ s16 flags;
/* 0x2 */ s16 fadeState;
/* 0x4 */ s32 fadeTime;
/* 0x8 */ s32 soundID;
/* 0xC */ s32 unkC;
} AmbientSoundSettings;
typedef enum AmbientSoundState {
AMBIENT_SOUND_IDLE = 0,
AMBIENT_SOUND_FADE_OUT = 1, // fade out old sounds
AMBIENT_SOUND_FADE_IN = 2 // fade in new sounds
} AmbientSoundState;
AmbientSoundSettings DefaultAmbientSoundData = {
.flags = 0,
.fadeState = 0,
.fadeTime = 0,
.soundID = -1,
.unkC = -1
};
extern AmbientSoundSettings AmbientSoundData;
void reset_ambient_sounds(void) {
AmbientSoundData = DefaultAmbientSoundData;
}
void update_ambient_sounds(void) {
AmbientSoundSettings* ambientSoundState = &AmbientSoundData;
s32 error;
switch (ambientSoundState->fadeState) {
case AMBIENT_SOUND_IDLE:
break;
case AMBIENT_SOUND_FADE_OUT:
if (ambientSoundState->flags & 1) {
if (ambientSoundState->fadeTime < 250) {
error = snd_ambient_quick_fade_out(0);
} else {
error = snd_ambient_slow_fade_out(0, ambientSoundState->fadeTime);
}
if (error != AU_RESULT_OK) {
return;
}
}
ambientSoundState->fadeState = AMBIENT_SOUND_FADE_IN;
break;
case AMBIENT_SOUND_FADE_IN:
if (ambientSoundState->flags & 1) {
if (snd_ambient_800555E4(0) != AU_RESULT_OK) {
return;
}
ambientSoundState->flags &= ~1;
}
if (ambientSoundState->soundID < 0) {
ambientSoundState->fadeState = AMBIENT_SOUND_IDLE;
} else if (snd_ambient_80055448(ambientSoundState->soundID) == AU_RESULT_OK) {
if (snd_ambient_80055464(0, 0) == AU_RESULT_OK) {
ambientSoundState->fadeState = AMBIENT_SOUND_IDLE;
ambientSoundState->flags |= 1;
}
}
break;
}
}
s32 play_ambient_sounds(s32 soundID, s32 fadeTime) {
AmbientSoundSettings* state = &AmbientSoundData;
if (!gGameStatusPtr->musicEnabled) {
snd_ambient_quick_fade_out(state->soundID);
state->flags &= ~1;
return 1;
}
if (state->soundID == soundID) {
return 2;
}
state->soundID = soundID;
state->fadeTime = fadeTime;
state->fadeState = AMBIENT_SOUND_FADE_OUT;
return 1;
}

432
src/audio/e0b30_len_b80.c Normal file
View File

@ -0,0 +1,432 @@
#include "common.h"
#include "npc.h"
void bgm_update_volume(void);
void bgm_set_target_volume(s16 volume);
// these are BSS
extern s16 MusicDefaultVolume;
extern s16 MusicMaxVolume;
extern s16 MusicCurrentVolume;
extern s16 MusicTargetVolume;
MusicSettings BlankMusicSettings = {
.flags = 0,
.state = 0,
.fadeOutTime = -1,
.fadeInTime = 0,
.fadeStartVolume = 0,
.fadeEndVolume = 0,
.songID = -1,
.variation = -1,
.songName = -1,
.battleSongID = 0,
.battleVariation = 0,
.savedSongID = 0,
.savedVariation = 0,
.savedSongName = 0
};
/// Lists the songs that are forced to use the variation determined by `map.songVariation & 1`.
/// @see bgm_get_map_default_variation
s32 SongsUsingVariationFlag[] = {
SONG_SPECIAL_BATTLE,
SONG_TUBBA_BLUBBA_BATTLE,
SONG_JR_TROOPA_BATTLE,
SONG_YOSHI_KIDS_FOUND,
SONG_ITEM_UPGRADE,
SONG_NEW_PARTNER,
};
s16 NextVolumeUpdateTimer = 0;
/// If the given song ID is present in SongsUsingVariationFlag, returns the current
/// map's `songVariation & 1` value. Otherwise, returns -1.
///
/// @see SongsUsingVariationFlag
/// @returns -1: no override; 0: override to variation 0; 1 override to variation 1
s32 bgm_get_map_default_variation(s32 songID) {
u32 i;
for (i = 0; i < ARRAY_COUNT(SongsUsingVariationFlag); i++) {
if (SongsUsingVariationFlag[i] == songID) {
Map* map = &gAreas[gGameStatusPtr->areaID].maps[gGameStatusPtr->mapID];
return map->unk_1C.bytes.songVariation & 1;
}
}
return -1;
}
void bgm_reset_sequence_players(void) {
s32 i;
for (i = 0; i < 2; i++) {
gMusicSettings[i] = BlankMusicSettings;
}
MusicTargetVolume = 8;
MusicMaxVolume = 8;
MusicCurrentVolume = 8;
func_800561A4(8);
}
void bgm_reset_volume(void) {
MusicTargetVolume = 8;
MusicMaxVolume = 8;
}
//TODO refactor out constants
void bgm_update_music_settings(void) {
MusicSettings* music = gMusicSettings;
s32 i = 0;
s16 state2 = 2;
s16 flag4 = MUSIC_SETTINGS_FLAGS_4;
s32 flags;
for (i; i < 2; i++, music++) {
switch (music->state) {
case 0:
break;
case 1:
if (music->flags & MUSIC_SETTINGS_FLAGS_1) {
if (music->fadeOutTime < 250) {
if (!(music->flags & MUSIC_SETTINGS_FLAGS_4)) {
if (au_song_stop(music->songName) == AU_RESULT_OK) {
music->state = state2;
}
} else {
if (func_80055AF0(music->songName) == AU_RESULT_OK) {
music->state = state2;
}
}
} else if (!(music->flags & MUSIC_SETTINGS_FLAGS_4)) {
if (snd_set_song_variation_fade_time(music->songName, music->fadeOutTime, 0) == 0) {
music->state = state2;
}
} else {
if (func_80055BB8(music->songName, 250) == AU_RESULT_OK) {
music->state = state2;
}
}
} else {
if (music->flags & MUSIC_SETTINGS_FLAGS_4) {
music->flags |= MUSIC_SETTINGS_FLAGS_10;
}
music->flags &= ~flag4;
music->state = 5;
}
break;
case 2:
flags = music->flags;
music->flags &= ~flag4;
if (flags & 1) {
if (au_song_is_playing(music->songName) == AU_RESULT_OK) {
music->flags &= ~MUSIC_SETTINGS_FLAGS_1;
music->state = 3;
}
} else {
music->state = 5;
}
break;
case 3:
music->state = 4;
break;
case 4:
music->state = 5;
break;
case 5:
if (!(music->flags & MUSIC_SETTINGS_FLAGS_8)) {
if (music->songID < 0) {
music->state = 0;
} else {
music->songName = au_song_load(music->songID, i);
if (music->songName > 0xFFFFU) {
if ((music->flags & MUSIC_SETTINGS_FLAGS_20)) {
snd_set_song_variation_fade(music->songName, music->variation,
music->fadeInTime, music->fadeStartVolume, music->fadeEndVolume);
music->flags &= ~MUSIC_SETTINGS_FLAGS_20;
} else {
bgm_set_target_volume(MusicDefaultVolume);
}
if (au_song_start_variation(music->songName, music->variation) == 0) {
music->flags |= MUSIC_SETTINGS_FLAGS_1;
music->state = 0;
}
}
}
} else {
if (music->flags & MUSIC_SETTINGS_FLAGS_10) {
music->state = 0;
music->flags &= ~(MUSIC_SETTINGS_FLAGS_10 | MUSIC_SETTINGS_FLAGS_8);
} else if (func_80055B28(music->savedSongName) == 0) {
music->songID = music->savedSongID;
music->variation = music->savedVariation;
music->songName = music->savedSongName;
music->state = 0;
music->flags |= MUSIC_SETTINGS_FLAGS_1;
music->flags &= ~MUSIC_SETTINGS_FLAGS_8;
}
}
break;
}
}
bgm_update_volume();
}
static const f32 padding = 0.0f;
s32 _bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume) {
MusicSettings* musicSetting;
s32 mapSongVariation;
if (gGameStatusPtr->demoState != 0) {
return 1;
}
musicSetting = &gMusicSettings[playerIndex];
if (!gGameStatusPtr->musicEnabled) {
au_song_stop(musicSetting->songName);
musicSetting->flags &= ~MUSIC_SETTINGS_FLAGS_1;
return 1;
}
mapSongVariation = bgm_get_map_default_variation(songID);
if (mapSongVariation >= 0) {
variation = mapSongVariation;
}
if (musicSetting->songID == songID && musicSetting->variation == variation) {
bgm_set_target_volume(volume);
if (musicSetting->flags & MUSIC_SETTINGS_FLAGS_4) {
func_80055B80(musicSetting->songName);
musicSetting->flags &= ~MUSIC_SETTINGS_FLAGS_4;
}
return 2;
}
MusicDefaultVolume = volume;
musicSetting->songID = songID;
musicSetting->variation = variation;
musicSetting->fadeOutTime = fadeOutTime;
musicSetting->state = 1;
musicSetting->flags &= ~MUSIC_SETTINGS_FLAGS_2;
return 1;
}
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume) {
gMusicSettings[playerIndex].flags &= ~MUSIC_SETTINGS_FLAGS_8;
return _bgm_set_song(playerIndex, songID, variation, fadeOutTime, volume);
}
s32 func_8014A964(s32 playerIndex, s32 songID, s32 variation, s32 fadeInTime, s16 fadeStartVolume, s16 fadeEndVolume) {
MusicSettings* musicSetting;
s32 mapSongVariation;
if (gGameStatusPtr->demoState) {
return 1;
}
musicSetting = &gMusicSettings[playerIndex];
if (!gGameStatusPtr->musicEnabled) {
au_song_stop(musicSetting->songName);
musicSetting->flags &= ~MUSIC_SETTINGS_FLAGS_1;
return 1;
}
mapSongVariation = bgm_get_map_default_variation(songID);
if (mapSongVariation >= 0) {
variation = mapSongVariation;
}
musicSetting->fadeInTime = fadeInTime;
musicSetting->fadeStartVolume = fadeStartVolume;
musicSetting->fadeEndVolume = fadeEndVolume;
musicSetting->songID = songID;
musicSetting->variation = variation;
musicSetting->flags |= MUSIC_SETTINGS_FLAGS_20;
musicSetting->state = 1;
musicSetting->flags &= ~MUSIC_SETTINGS_FLAGS_2;
return 1;
}
s32 bgm_adjust_proximity(s32 playerIndex, s32 mix, s16 state) {
MusicSettings* musicSetting = &gMusicSettings[playerIndex];
if (!(musicSetting->flags & MUSIC_SETTINGS_FLAGS_1)) {
return FALSE;
}
if (!(musicSetting->flags & MUSIC_SETTINGS_FLAGS_2)) {
return FALSE;
}
switch (state) {
case MUSIC_PROXIMITY_FAR:
bgm_set_proximity_mix_far(musicSetting->songName, mix);
break;
case MUSIC_PROXIMITY_NEAR:
bgm_set_proximity_mix_near(musicSetting->songName, mix);
break;
case MUSIC_PROXIMITY_FULL:
bgm_set_proximity_mix_full(musicSetting->songName, mix);
break;
}
return TRUE;
}
AuResult bgm_set_track_volumes(s32 playerIndex, s16 trackVolSet) {
MusicSettings* musicSetting = &gMusicSettings[playerIndex];
if (!(musicSetting->flags & MUSIC_SETTINGS_FLAGS_1)) {
return AU_RESULT_OK;
}
return snd_song_set_track_volumes(musicSetting->songName, trackVolSet);
}
AuResult bgm_clear_track_volumes(s32 playerIndex, s16 trackVolSet) {
MusicSettings* musicSetting = &gMusicSettings[playerIndex];
if (!(musicSetting->flags & MUSIC_SETTINGS_FLAGS_1)) {
return AU_RESULT_OK;
}
return snd_song_clear_track_volumes(musicSetting->songName, trackVolSet);
}
AuResult bgm_set_variation(s32 playerIndex, s16 arg1) {
MusicSettings* musicSetting = &gMusicSettings[playerIndex];
if (!(musicSetting->flags & MUSIC_SETTINGS_FLAGS_1)) {
return AU_RESULT_OK;
}
return snd_set_song_variation(musicSetting->songName, arg1);
}
s32 bgm_init_music_players(void) {
bgm_set_song(0, -1, 0, 250, 8);
bgm_set_song(1, -1, 0, 250, 8);
return 1;
}
void bgm_quiet_max_volume(void) {
MusicMaxVolume = 4;
}
void bgm_reset_max_volume(void) {
MusicMaxVolume = 8;
}
void bgm_set_target_volume(s16 volume) {
MusicTargetVolume = volume;
}
void bgm_update_volume(void) {
s16 toVolume;
if (NextVolumeUpdateTimer != 0) {
NextVolumeUpdateTimer--;
return;
}
toVolume = MusicTargetVolume;
if (toVolume > MusicMaxVolume) {
toVolume = MusicMaxVolume;
}
if (MusicCurrentVolume != toVolume) {
if (MusicCurrentVolume >= toVolume) {
MusicCurrentVolume--;
} else {
MusicCurrentVolume++;
}
func_800561A4(MusicCurrentVolume);
NextVolumeUpdateTimer = 3;
}
}
s32 func_8014AD40(void) {
MusicSettings* settings = gMusicSettings;
s32 i;
for (i = 0; i < 2; i++, settings++) {
if (!(settings->flags & MUSIC_SETTINGS_FLAGS_1)) {
continue;
}
if (au_song_is_playing(settings->songName)) {
return TRUE;
}
}
return FALSE;
}
void bgm_pop_song(void) {
MusicSettings* musicSetting = gMusicSettings;
if (gGameStatusPtr->demoState == 0) {
musicSetting->flags |= MUSIC_SETTINGS_FLAGS_8;
_bgm_set_song(0, musicSetting->savedSongID, musicSetting->savedVariation, 0, 8);
}
}
void bgm_push_song(s32 songID, s32 variation) {
MusicSettings* musicSetting = gMusicSettings;
if (gGameStatusPtr->demoState == 0) {
musicSetting->savedSongID = musicSetting->songID;
musicSetting->savedVariation = musicSetting->variation;
musicSetting->savedSongName = musicSetting->songName;
musicSetting->flags |= MUSIC_SETTINGS_FLAGS_4;
bgm_set_song(0, songID, variation, 500, 8);
}
}
void bgm_pop_battle_song(void) {
MusicSettings* musicSetting = gMusicSettings;
if (gGameStatusPtr->demoState == 0) {
if (gOverrideFlags & GLOBAL_OVERRIDES_20000) {
gOverrideFlags &= ~GLOBAL_OVERRIDES_20000;
} else {
musicSetting->flags |= MUSIC_SETTINGS_FLAGS_8;
_bgm_set_song(0, musicSetting->savedSongID, musicSetting->savedVariation, 0, 8);
snd_ambient_80055590(0, 250);
}
}
}
void bgm_push_battle_song(void) {
MusicSettings* musicSetting = gMusicSettings;
if (gGameStatusPtr->demoState == 0 && !(gOverrideFlags & GLOBAL_OVERRIDES_20000)) {
snd_ambient_8005553C(0, 250);
musicSetting->savedSongID = musicSetting->songID;
musicSetting->savedVariation = musicSetting->variation;
musicSetting->savedSongName = musicSetting->songName;
musicSetting->flags |= MUSIC_SETTINGS_FLAGS_4;
bgm_set_song(0, musicSetting->battleSongID, musicSetting->battleVariation, 500, 8);
}
}
void bgm_set_battle_song(s32 songID, s32 variation) {
MusicSettings* musicSetting = gMusicSettings;
musicSetting->battleSongID = songID;
musicSetting->battleVariation = variation;
}
void func_8014AFA0(void) {
}

326
src/audio/private.h Normal file
View File

@ -0,0 +1,326 @@
// 2BF90.c
void au_mseq_manager_init(AuAmbienceManager* arg0, s8 arg1, s8 reverbType, AuGlobals* arg3);
AuResult func_80050C30(u32 arg0);
void func_80050C54(s32 arg0, s32 arg1);
void au_mseq_set_disabled(s32 arg0, s32 arg1);
AuResult func_80050CA0(s32 arg0, s32 arg1);
void func_80050D50(AuAmbPlayer* arg0);
void func_80050EF0_fade_out_unk(s32 arg0, s32 arg1);
void func_80050EF0_fade_in_unk(s32 arg0, s32 arg1);
void func_80050EF0_fade_out_quick(s32 arg0);
void func_80050EF0_fade_out_slow(s32 arg0, s32 arg1);
void au_mseq_set_volume(s32 arg0, s32 arg1, s32 arg2);
AuResult func_80051050(s32 arg0);
void func_800510A4(AuAmbienceManager* arg0, MSEQHeader* mseq, s32 index);
void snd_ambient_manager_update(AuAmbienceManager* arg0);
void func_80051334(AuAmbienceManager* manager, AuAmbPlayer* lambda);
void func_80051434(AuAmbienceManager* manager, AuAmbPlayer* lambda);
s32 au_mseq_read_next(AuAmbPlayer* arg0);
void au_mseq_player_stop(AuAmbienceManager* arg0, AuAmbPlayer* arg1);
void func_800522A8(AuAmbienceManager* arg0, AuAmbPlayer* lambda);
void func_8005232C(AuAmbienceManager* manager, AuAmbPlayer* lambda);
// 2d9a0_len_890.c
void func_800525A0(AuGlobals* globals);
void func_80052614(AuGlobals* globals);
void func_80052660(AuGlobals* globals);
void func_80052B44(AlUnkVoice* arg0);
s32 func_80052BC0(s32 arg0);
void func_80052BF8(AlUnkVoice* voice, AlUnkInstrumentData* arg1);
u8 func_80052CFC(AlUnkVoice* voice);
void func_80052E18(AlUnkVoice* arg0);
//2e230_len_2190.c
void func_80052E30(u8 index);
void au_engine_init(s32 outputRate);
static void au_reset_instrument(Instrument* instrument);
static void au_reset_drum_entry(BGMDrumInfo* arg0);
static void au_reset_instrument_entry(BGMInstrumentInfo* arg0);
void au_update_clients_2(void);
void au_update_players_main(void);
void func_80053654(AuGlobals* globals);
void func_80053888(AlUnkVoice* arg0, u8 arg1);
void au_reset_voice(AlUnkVoice* arg0, u8 arg1);
f32 au_compute_pitch_ratio(s32 arg0);
void au_fade_init(Fade* fade, s32 time, s32 startValue, s32 endValue);
void au_fade_clear(Fade* fade);
void au_fade_update(Fade* fade);
void func_80053A98(u8 arg0, u16 arg1, s32 arg2);
void func_80053AC8(Fade* fade);
void au_fade_set_vol_scale(Fade* fade, s16 value);
void func_80053B04(Fade* fade, u32 arg1, s32 target);
void func_80053BA8(Fade* fade);
Instrument* au_get_instrument(AuGlobals* globals, u32 bank, u32 patch, AlUnkInstrumentData* arg3);
void au_get_bgm_player_and_file(u32 playerIndex, BGMHeader** outCurrentTrackData, BGMPlayer** outPlayer);
void au_get_bgm_player(u32 playerIndex, BGMPlayer** outPlayer);
AuResult au_load_song_files(u32 arg0, BGMHeader* arg1, BGMPlayer* arg2);
AuResult func_80053E58(s32 arg0, BGMHeader* arg1);
BGMPlayer* func_80053F64(s32 arg0);
AuResult func_80053F80(u32 arg0);
BGMPlayer* func_80054248(u8 arg0);
void au_load_INIT(AuGlobals* arg0, s32 romAddr, ALHeap* heap);
AuResult au_fetch_SBN_file(u32 fileIdx, AuFileFormat format, SBNFileEntry* arg2);
void au_load_PER(AuGlobals* globals, s32 romAddr);
void au_load_PRG(AuGlobals* arg0, s32 romAddr);
// INCLUDE_ASM(s32, "audio/2e230_len_2190", snd_load_BGM);
InstrumentGroup* au_get_BK_instruments(s32 bankGroup, u32 bankIndex);
SoundBank* snd_load_BK_to_bank(s32 bkFileOffset, SoundBank* bank, s32 bankIndex, s32 bankGroup);
void au_swizzle_BK_instruments(s32 bkFileOffset, SoundBank* bank, InstrumentGroup instruments, u32 instrumentCount, u8 arg4);
s32* func_80054AA0(s32* bkFileOffset, void* vaddr, s32 bankIndex, s32 bankGroup);
s32 snd_load_BK(s32 bkFileOffset, s32 bankIndex);
void func_80054C84(s32 bankIndex, s32 bankGroup);
void func_80054CE0(s32 arg0, u32 idx);
s32 func_80054D74(s32 arg0, s32 arg1);
void func_80054DA8(u32 arg0);
void au_read_rom(s32 romAddr, void* buffer, u32 size);
void au_memset(void* dst, s32 size, u8 value);
void au_copy_bytes(s8* src, s8* dest, s32 size);
void au_copy_words(void* src, void* dst, s32 size);
// 25f00_len_940.c
void create_audio_system(void);
//void nuAuPreNMIFuncSet(NUAuPreNMIFunc func);
void nuAuMgr(void* arg);
s32 nuAuDmaCallBack(s32 addr, s32 len, void *state, u8 arg3);
//ALDMAproc nuAuDmaNew(NUDMAState** state);
//void nuAuCleanDMABuffers(void);
void func_8004B328(NUScMsg mesg_type, u32 frameCounter);
//void alLink(ALLink* element, ALLink* after);
//void alUnlink(ALLink* element);
// 303c0_len_3e10.c
void au_load_BK_headers(AuGlobals* arg0, ALHeap*);
// sfx_player.c
void au_sfx_init(SoundManager* manager, u8 arg1, u8 arg2, AuGlobals* arg3, u8 arg4);
void au_sfx_load_groups_from_SEF(SoundManager* sndMgr);
void au_sfx_clear_queue(SoundManager* manager);
void au_sfx_enqueue_event(SoundManager* manager, u32 soundID, s16 volume, s16 pitchShift, u8 pan);
void au_sfx_update_main(SoundManager* manager);
s32 func_8004B9E4(SoundManager* manager, s32 arg1);
void func_8004BA54(SoundManager* manager, s32 arg1);
void func_8004BA74(SoundManager* manager, SoundSFXEntry* entry, SoundManagerA0*);
s16 au_sfx_manager_update(SoundManager* manager);
// 28910_len_5090.c
void au_bgm_update_main(BGMPlayer* player);
BGMPlayer* au_bgm_get_player_with_song_name(s32 songString);
AuResult au_bgm_dispatch_player_event(SongUpdateEvent* event);
AuResult au_bgm_stop_song(s32 songName);
void au_bgm_stop_all(void);
AuResult au_bgm_is_song_playing(s32 songName);
s32 func_8004DB28(BGMPlayer* player);
AuResult func_8004DB4C(SongUpdateEvent* s);
AuResult func_8004DC80(s32 songName);
AuResult func_8004DCB8(SongUpdateEvent* update, s32 clearChanged);
AuResult func_8004DE2C(SongUpdateEvent* update);
void func_8004DFD4(AuGlobals* globals);
AuResult func_8004E0F4(SongUpdateEvent* update);
void au_bgm_player_init(BGMPlayer* player, s32 arg1, s32 arg2, AuGlobals* arg3);
void au_bgm_set_effect_indices(BGMPlayer* player, u8* list);
void au_bgm_update_fade(BGMPlayer* player);
void func_8004E444(BGMPlayer* arg0);
s32 au_bgm_player_update_main(BGMPlayer* player);
void au_bgm_player_initialize(BGMPlayer* player);
void func_8004E844(BGMPlayer* player, s32 arg1);
void func_8004E880(BGMPlayer* player, s32 sampleRate, s32 divisor);
void au_bgm_player_read_segment(BGMPlayer* player);
void au_bgm_end_segment_loop(BGMPlayer* player, u32 cmd);
void au_bgm_load_subsegment(BGMPlayer* player, u32 cmd);
void au_bgm_player_update_stop(BGMPlayer* player);
void au_bgm_player_update_playing(BGMPlayer *player);
void au_BGMCmd_E0_MasterTempo(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_E1_MasterVolume(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_E2_MasterPitchShift(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_E3(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_E6_MasterEffect(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_E4_MasterTempoFade(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_E5_MasterVolumeFade(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_E8_TrackOverridePatch(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_E9_SubTrackVolume(BGMPlayer* arg0, BGMPlayerTrack* track);
void au_BGMCmd_F6_TrackVolumeFade(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_EA_SubTrackPan(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_EB_SubTrackReverb(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_EC_SegTrackVolume(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_ED_SubTrackCoarseTune(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_EE_SubTrackFineTune(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_EF_SegTrackTune(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_F0_TrackTremolo(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_F1_TrackTremoloSpeed(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_F2_TrackTremoloTime(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_F3_TrackTremoloStop(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_F4(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_F5_TrackVoice(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_F7_SubTrackReverbType(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_FD_EventTrigger(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_FE_Detour(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_FC_Jump(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_FF(BGMPlayer* player, BGMPlayerTrack* track);
void au_BGMCmd_NOP(BGMPlayer* player, BGMPlayerTrack* track);
void au_bgm_set_proximity_mix(s32 songName, u32 mix);
void func_80050770(BGMPlayer* player, f32 arg1);
void func_80050818(BGMPlayer* player, s32 arg1);
void au_bgm_change_track_volume(BGMPlayer* player, s32 trackIdx, s16 arg2, u8 arg3);
void au_bgm_set_track_volumes(BGMPlayer* player, u8* arg1, s32 arg2);
void func_80050888(BGMPlayer* player, BGMPlayerTrack* track, s32 target, s32 duration);
void func_80050900(BGMPlayer* player);
AuResult func_80050970(SongUpdateEvent* arg0);
// 30450.c
/*
void func_80055050(ALHeap* heap);
void func_80055068(u32 arg0);
*/
void func_80055110(BGMPlayer* player);
/*
void func_8005513C(u32 arg0);
void snd_start_sound(s32 soundID, u8 volume, u8 pan);
void snd_start_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void snd_adjust_sound(s32 soundID, u8 volume, u8 pan);
void snd_adjust_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void snd_stop_sound(s32 soundID);
void func_800553F4(void);
void snd_start_sound_raw(s32 soundID, s16 volume, s16 pitchShift, s32 pan);
AuResult snd_ambient_80055448(s32 arg0);
AuResult snd_ambient_80055464(s32 arg0, s32 arg1);
AuResult snd_ambient_quick_fade_out(s32 arg0);
AuResult snd_ambient_slow_fade_out(s32 arg0, s32 arg1);
AuResult snd_ambient_8005553C(s32 arg0, s32 arg1);
AuResult snd_ambient_80055590(s32 arg0, s32 arg1);
AuResult snd_ambient_800555E4(s32 arg0);
AuResult snd_ambient_80055618(s32 arg0, s32 arg1);
AuResult au_ambience_set_volume(s32 arg0, s32 arg1, s32 arg2);
AuResult au_ambience_disable(s32 arg0);
AuResult au_ambience_enable(s32 arg0);
void snd_ambient_80055760(s32 arg0);
AuResult snd_ambient_800557CC(s32 arg0);
AuResult snd_ambient_80055848(s32 arg0);
AuResult au_song_load(s32 songID, s32 playerIndex);
AuResult au_song_start(s32 songName);
AuResult au_song_start_variation(s32 songName, s32 variation);
AuResult au_song_stop(s32 songName);
void au_stop_songs(void);
AuResult au_song_is_playing(s32 songName);
AuResult snd_set_song_variation_fade(s32 songName, s32 variation, s32 fadeInTime, s32 startVolume, s32 endVolume);
AuResult snd_set_song_fade(s32 songName, s32 fadeInTime, s32 startVolume, s32 endVolume);
AuResult snd_set_song_variation_fade_time(s32 songName, s32 fadeTime, s32 variation);
AuResult func_80055AF0(s32 songName);
AuResult func_80055B28(s32 songName);
AuResult func_80055B80(s32 songName);
AuResult func_80055BB8(s32 songName, s32 fadeTime);
AuResult func_80055BF0(s32 songName);
AuResult func_80055C2C(s32 songName);
AuResult func_80055C64(s32 songName);
AuResult func_80055C94(s32 songName);
AuResult snd_set_song_variation(s32 songName, s32 variation);
*/
AuResult snd_song_get_playing_info(s32 songName, BGMHeader** outTrackData, BGMPlayer** outPlayer);
/*
AuResult func_80055D38(s32 songName, f32 arg1);
AuResult func_80055D8C(s32 songName, s32 arg1);
AuResult func_80055DDC(s32 songName, s32 arg1);
AuResult snd_song_clear_track_volumes(s32 songName, MusicTrackVols arg1);
u8* func_80055EB4(MusicTrackVols arg0);
static AuResult snd_song_change_track_volume(s32 arg0, u32 arg1, u32 arg2);
AuResult snd_song_set_track_vol_mute(s32 arg0, s32 arg1);
AuResult snd_song_set_track_vol_quiet(s32 arg0, s32 arg1);
AuResult snd_song_set_track_vol_full(s32 arg0, s32 arg1);
void bgm_set_proximity_mix_far(s32 songName, s32 mix);
void bgm_set_proximity_mix_near(s32 songName, s32 mix);
void bgm_set_proximity_mix_full(s32 songName, s32 mix);
void bgm_poll_music_events(u32** arg0, s32* arg1);
void bgm_flush_music_events(void);
void music_event_trigger(s32 arg0, s32 arg1, s32 arg2);
void func_8005610C(void);
*/
void au_register_callback(AuCallback arg0, s32 arg1);
/*
void audio_set_stereo(void);
void audio_set_mono(void);
void func_800561A4(s32 arg0);
void func_800561C4(s32 arg0);
void func_800561E4(s32 arg0);
void func_80056204(void);
void func_80056228(void);
*/
// 31650.c
void au_driver_init(AuSynDriver* driver, ALConfig* config);
void au_driver_release(void);
//Acmd* alAudioFrame(Acmd* cmdList, s32* cmdLen, s16* outBuf, s32 outLen);
void func_80056D34(void);
void func_80056D44(s16 arg0);
s16 func_80056D50(void);
void func_80056D5C(u8 arg0);
void func_80056D78(u8 arg0, u16 arg1);
u16 func_80056DA4(u8 arg0, u16 arg1);
void func_80056DCC(u8 arg0, u8 effectID);
void func_80056E34(u8 arg0, s16 arg1, s16 arg2, s32 arg3);
void func_80056EC0(u8 arg0, s8 arg1);
void au_pvoice_reset_filter(u8 voiceIdx);
void au_pvoice_set_playing(u8 index);
void au_pvoice_set_filter(u8 index, u8 reverbType, Instrument* table, f32 pitchRatio, s16 arg4, u8 pan, u8 reverb, s32 arg7);
void au_pvoice_set_filter_wavetable(u8 voiceIdx, Instrument* table);
void au_pvoice_set_pitch_ratio(u8 voiceIdx, f32 pitchRatio);
void func_8005736C(u8 voiceIdx, s16 volume, s32 arg2, u8 arg3, u8 arg4);
void func_80057548(u8 voiceIdx, u8 arg1, u8 arg2);
void func_800576EC(u8 voiceIdx, s16 arg1, s32 arg2);
void func_80057874(u8 voiceIdx, u8 pan);
void func_800579D8(u8 voiceIdx, u8 dryAmt);
s32 func_80057B64(u8 voiceIdx);
s32 func_80057B8C(u8 voiceIdx);
f32 func_80057BB4(u8 voiceIdx);
u8 func_80057BDC(u8 voiceIdx);
s16 func_80057C04(u8 voiceIdx);
s16 func_80057C2C(u8 voiceIdx);
s32 func_80057C54(u8 voiceIdx);
s32 func_80057D0C(u8 voiceIdx);
void func_80057DC8(s32 arg0);
void func_80057E08(u8 arg0);
void func_80057E5C(u8 arg0);
void func_80057EB0(void);
void func_80057ED0(s16 arg0);
//void alHeapInit(ALHeap* hp, u8* base, s32 len);
//void alCopy(void* src, void* dst, s32 size);
#undef alHeapAlloc
void* alHeapAlloc(ALHeap* heap, s32 arg1, s32 size);
// 33450.c
Acmd* func_80058050(AuPVoice* pvoice, Acmd* cmdBufPos);
// reverb.c
void func_80058E84(AuFX* fx, u8 mode, ALHeap* heap);
void func_80058F88(AlUnkKappa* kappa, ALHeap* heap);
void func_80059008(AlUnkKappa* kappa, s16 arg1, s16 arg2, s16 fc);
void func_8005904C(AuFX* fx, u8 effectType);
Acmd* func_80059310(AuFX* fx, Acmd* cmdBusPos, s16, s16);
s32 au_fx_param_hdl(AuFX* fx, s16 index, s16 paramID, s32 value);
// sfx.c
/*
void sfx_reset_door_sounds(void);
void sfx_clear_sounds(void);
void sfx_clear_env_sounds(s16 playSounds);
void sfx_update_looping_sound_params(void);
void func_801497FC(s32 arg0);
s32 func_80149828(void);
void sfx_stop_env_sounds(void);
*/
SoundInstance* sfx_get_env_sound_instance(s32 soundID);
/*
void sfx_play_sound_looping(s32 soundId, u8 volume, u8 pan, s16 pitchShift);
void sfx_register_looping_sound_at_position(s32 soundID, s32 flags, f32 x, f32 y, f32 z);
s32 sfx_adjust_env_sound_pos(s32 soundID, s32 sourceFlags, f32 x, f32 y, f32 z);
void func_80149A6C(s32 soundID, s32 keepPlaying);
void sfx_play_sound_with_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void sfx_adjust_env_sound_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void sfx_stop_sound(s32 soundID);
void sfx_play_sound(s32 soundID);
void sfx_play_sound_at_player(s32 soundID, s32 arg1);
void sfx_play_sound_at_npc(s32 soundID, s32 arg1, s32 npcID);
void sfx_play_sound_at_position(s32 soundID, s32 flags, f32 posX, f32 posY, f32 posZ);
void sfx_get_spatialized_sound_params(f32 x, f32 y, f32 z, s16* volume, s16* pan, s32 flags);
void sfx_compute_spatialized_sound_params_0(f32 x, f32 y, f32 z, s16* volume, s16* pan);
void sfx_compute_spatialized_sound_params_1(f32 x, f32 y, f32 z, s16* volume, s16* pan);
void sfx_compute_spatialized_sound_params_2(f32 x, f32 y, f32 z, s16* volume, s16* pan, s32 flags);
*/

97
src/audio/public.h Normal file
View File

@ -0,0 +1,97 @@
#ifndef _AUDIO_PUBLIC_H_
#define _AUDIO_PUBLIC_H_
// 30450.c
void func_80055050(ALHeap* heap);
void func_80055068(u32 arg0);
//void func_80055110(BGMPlayer* player);
void func_8005513C(u32 arg0);
void snd_start_sound(s32 soundID, u8 volume, u8 pan);
void snd_start_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void snd_adjust_sound(s32 soundID, u8 volume, u8 pan);
void snd_adjust_sound_with_shift(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void snd_stop_sound(s32 soundID);
void func_800553F4(void);
void snd_start_sound_raw(s32 soundID, s16 volume, s16 pitchShift, s32 pan);
AuResult snd_ambient_80055448(s32 arg0);
AuResult snd_ambient_80055464(s32 arg0, s32 arg1);
AuResult snd_ambient_quick_fade_out(s32 arg0);
AuResult snd_ambient_slow_fade_out(s32 arg0, s32 arg1);
AuResult snd_ambient_8005553C(s32 arg0, s32 arg1);
AuResult snd_ambient_80055590(s32 arg0, s32 arg1);
AuResult snd_ambient_800555E4(s32 arg0);
AuResult snd_ambient_80055618(s32 arg0, s32 arg1);
AuResult au_ambience_set_volume(s32 arg0, s32 arg1, s32 arg2);
AuResult au_ambience_disable(s32 arg0);
AuResult au_ambience_enable(s32 arg0);
void snd_ambient_80055760(s32 arg0);
AuResult snd_ambient_800557CC(s32 arg0);
AuResult snd_ambient_80055848(s32 arg0);
AuResult au_song_load(s32 songID, s32 playerIndex);
AuResult au_song_start(s32 songName);
AuResult au_song_start_variation(s32 songName, s32 variation);
AuResult au_song_stop(s32 songName);
void au_stop_songs(void);
AuResult au_song_is_playing(s32 songName);
AuResult snd_set_song_variation_fade(s32 songName, s32 variation, s32 fadeInTime, s32 startVolume, s32 endVolume);
AuResult snd_set_song_fade(s32 songName, s32 fadeInTime, s32 startVolume, s32 endVolume);
AuResult snd_set_song_variation_fade_time(s32 songName, s32 fadeTime, s32 variation);
AuResult func_80055AF0(s32 songName);
AuResult func_80055B28(s32 songName);
AuResult func_80055B80(s32 songName);
AuResult func_80055BB8(s32 songName, s32 fadeTime);
AuResult func_80055BF0(s32 songName);
AuResult func_80055C2C(s32 songName);
AuResult func_80055C64(s32 songName);
AuResult func_80055C94(s32 songName);
AuResult snd_set_song_variation(s32 songName, s32 variation);
//AuResult snd_song_get_playing_info(s32 songName, BGMHeader** outTrackData, BGMPlayer** outPlayer);
AuResult func_80055D38(s32 songName, f32 arg1);
AuResult func_80055D8C(s32 songName, s32 arg1);
AuResult snd_song_set_track_volumes(s32 songName, MusicTrackVols arg1);
AuResult snd_song_clear_track_volumes(s32 songName, MusicTrackVols arg1);
AuResult snd_song_set_track_vol_mute(s32 arg0, s32 arg1);
AuResult snd_song_set_track_vol_quiet(s32 arg0, s32 arg1);
AuResult snd_song_set_track_vol_full(s32 arg0, s32 arg1);
void bgm_set_proximity_mix_far(s32 songName, s32 mix);
void bgm_set_proximity_mix_near(s32 songName, s32 mix);
void bgm_set_proximity_mix_full(s32 songName, s32 mix);
void bgm_poll_music_events(u32** arg0, s32* arg1);
void bgm_flush_music_events(void);
void bgm_trigger_music_event(s32 arg0, s32 arg1, s32 arg2);
void bgm_clear_music_events(void);
//void func_80056144(AuCallback arg0, s32 arg1);
void audio_set_stereo(void);
void audio_set_mono(void);
void func_800561A4(s32 arg0);
void func_800561C4(s32 arg0);
void func_800561E4(s32 arg0);
void func_80056204(void);
void func_80056228(void);
// sfx.h
void sfx_reset_door_sounds(void);
void sfx_clear_sounds(void);
void sfx_clear_env_sounds(s16 playSounds);
void sfx_update_looping_sound_params(void);
void func_801497FC(s32 arg0);
s32 func_80149828(void);
void sfx_stop_env_sounds(void);
//SoundInstance* sfx_get_env_sound_instance(s32 soundID);
void sfx_play_sound_looping(s32 soundId, u8 volume, u8 pan, s16 pitchShift);
void sfx_register_looping_sound_at_position(s32 soundID, s32 flags, f32 x, f32 y, f32 z);
s32 sfx_adjust_env_sound_pos(s32 soundID, s32 sourceFlags, f32 x, f32 y, f32 z);
void func_80149A6C(s32 soundID, s32 keepPlaying);
void sfx_play_sound_with_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void sfx_adjust_env_sound_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift);
void sfx_stop_sound(s32 soundID);
void sfx_play_sound(s32 soundID);
void sfx_play_sound_at_player(s32 soundID, s32 arg1);
void sfx_play_sound_at_npc(s32 soundID, s32 arg1, s32 npcID);
void sfx_play_sound_at_position(s32 soundID, s32 flags, f32 posX, f32 posY, f32 posZ);
void sfx_get_spatialized_sound_params(f32 x, f32 y, f32 z, s16* volume, s16* pan, s32 flags);
void sfx_compute_spatialized_sound_params_0(f32 x, f32 y, f32 z, s16* volume, s16* pan);
void sfx_compute_spatialized_sound_params_1(f32 x, f32 y, f32 z, s16* volume, s16* pan);
void sfx_compute_spatialized_sound_params_2(f32 x, f32 y, f32 z, s16* volume, s16* pan, s32 flags);
#endif

339
src/audio/reverb.c Normal file
View File

@ -0,0 +1,339 @@
#include "common.h"
#include "audio.h"
static void _init_lpfilter(AuLowPass* lp);
static Acmd* _saveBuffer(AuFX* fx, s16* oldPos, s32 buff, s32 count, Acmd* cmdBufPos);
static f32 func_80059BD4(AuDelay* delay, s32 rsdelta);
/*
* the following constant is derived from:
*
* ratio = 2^(cents/1200)
*
* and therefore for hundredths of a cent
* x
* ln(ratio) = ---------------
* (120,000)/ln(2)
* where
* 120,000/ln(2) = 173123.40...
*/
#define CONVERT 173123.404906676
/*
* WARNING: THE FOLLOWING CONSTANT MUST BE KEPT IN SYNC
* WITH SCALING IN MICROCODE!!!
*/
#define SCALE 16384
// #define ms *(((s32)((f32)44.1))&~0x7)
s32 SMALL_ROOM_PARAMS[] = {
/* sections length */
3, 11,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 9, 9830, -9830, 0, 0, 0, 0,
3, 7, 3276, -3276, 0x3FFF, 0, 0, 0,
0, 10, 5000, 0, 0, 0, 0, 0x5000
};
s32 BIG_ROOM_PARAMS[] = {
/* sections length */
4, 14,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 9, 9830, -9830, 0, 0, 0, 0,
2, 6, 3276, -3276, 0x3FFF, 0, 0, 0,
9, 12, 3276, -3276, 0x3FFF, 0, 0, 0,
0, 13, 6000, 0, 0, 0, 0, 0x5000
};
// unused
s32 D_8007F0C0[] = {
/* sections length */
4, 17,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 11, 9830, -9830, 0, 0, 0, 0,
4, 9, 3276, -3276, 0x3FFF, 0, 0, 0,
11, 15, 3276, -3276, 0x3FFF, 0, 0, 0,
0, 16, 8000, 0, 0, 0, 0, 0x5000
};
s32 ECHO_PARAMS[] = {
/* sections length */
1, 14,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 13, 20000, 0, 0x7FFF, 0, 0, 0x7FFF
};
s32 CHORUS_PARAMS[] = {
/* sections length */
1, 3,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 1, 16384, 0, 0x7FFF, 7600, 700, 0
};
s32 FLANGE_PARAMS[] = {
/* sections length */
1, 3,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 1, 0, 0x5FFF, 0x7FFF, 380, 500, 0
};
s32 NULL_PARAMS[] = {
/* sections length */
0, 0,
/* chorus chorus filter
input output fbcoef ffcoef gain rate depth coef */
0, 0, 0, 0, 0, 0, 0, 0
};
// up to four custom effects can be defined and installed here at runtime
s32* AU_FX_CUSTOM_PARAMS[] = {
NULL_PARAMS, NULL_PARAMS, NULL_PARAMS, NULL_PARAMS
};
static void _init_lpfilter(AuLowPass* lp) {
f64 attenuation;
s16 timeConstant;
u32 temp;
s32 i;
lp->first = 1;
temp = lp->fc;
timeConstant = temp;
timeConstant = timeConstant >> 1;
lp->fgain = SCALE - timeConstant;
for (i = 0; i < 8; i++) {
lp->fccoef[i] = 0;
}
lp->fccoef[8] = timeConstant;
// ith value is 16384 * (timeConstant / 16384)^(i-7)
// ex: i = 9 --> timeConstant^2 / 16384
attenuation = ((f64)timeConstant / SCALE);
for (i = 9; i < 16; i++) {
attenuation *= ((f64)timeConstant /SCALE);
lp->fccoef[i] = attenuation * SCALE;
}
}
// definately AuFX, evidenced by call to func_8005904C
// this is n_alFxNew
/// @param effectType from enum AuEffectType
void func_80058E84(AuFX* fx, u8 effectType, ALHeap* heap) {
AuDelay* delay;
u16 i;
// allocate space for 4 AuDelay
fx->delays = alHeapAlloc(heap, AU_FX_DELAY_COUNT, sizeof(AuDelay));
fx->base = alHeapAlloc(heap, AU_FX_LENGTH, sizeof(s16));
for (i = 0; i < AU_FX_DELAY_COUNT; i++) {
delay = &fx->delays[i];
delay->resampler_2C = alHeapAlloc(heap, 1, sizeof(AuResampler));
delay->resampler_2C->rs_state = alHeapAlloc(heap, 1, sizeof(RESAMPLE_STATE));
delay->lowpass_24 = alHeapAlloc(heap, 1, sizeof(AuLowPass));
delay->lowpass_24->fstate = alHeapAlloc(heap, 1, sizeof(POLEF_STATE));
}
func_8005904C(fx, effectType);
}
// no known calls to this function
void func_80058F88(AlUnkKappa* kappa, ALHeap* heap) {
kappa->unk_00 = alHeapAlloc(heap, 0x1420, sizeof(s16));
kappa->lowpass_10 = alHeapAlloc(heap, 1, sizeof(AuLowPass));
kappa->lowpass_10->fstate = alHeapAlloc(heap, 1, sizeof(POLEF_STATE));
func_80059008(kappa, 0, 0, 0x5000);
}
// no known entry point to this function, called only by func_80058F88
void func_80059008(AlUnkKappa* kappa, s16 arg1, s16 arg2, s16 fc) {
kappa->unk_06 = arg1;
kappa->unk_08 = arg2;
if (fc != 0) {
kappa->lowpass_0C = kappa->lowpass_10;
kappa->lowpass_0C->fc = fc;
_init_lpfilter(kappa->lowpass_0C);
return;
}
kappa->lowpass_0C = NULL;
}
// part of n_alFxNew, extracted to allow reseting fx without reallocating AuFX
void func_8005904C(AuFX* fx, u8 effectType) {
s32* params;
s32* clr;
s32 i, j;
clr = (s32*)fx->base;
switch (effectType) {
case AU_FX_SMALLROOM:
params = SMALL_ROOM_PARAMS;
break;
case AU_FX_BIGROOM:
params = BIG_ROOM_PARAMS;
break;
case AU_FX_ECHO:
params = ECHO_PARAMS;
break;
case AU_FX_CHORUS:
params = CHORUS_PARAMS;
break;
case AU_FX_FLANGE:
params = FLANGE_PARAMS;
break;
case AU_FX_CUSTOM_0:
params = AU_FX_CUSTOM_PARAMS[0];
break;
case AU_FX_CUSTOM_1:
params = AU_FX_CUSTOM_PARAMS[1];
break;
case AU_FX_CUSTOM_2:
params = AU_FX_CUSTOM_PARAMS[2];
break;
case AU_FX_CUSTOM_3:
params = AU_FX_CUSTOM_PARAMS[3];
break;
case AU_FX_OTHER_BIGROOM:
params = BIG_ROOM_PARAMS;
break;
default:
params = NULL_PARAMS;
break;
}
j = 0;
fx->delayCount = params[j++];
fx->length = params[j++] * AUDIO_SAMPLES;
fx->input = fx->base;
for (i = 0; i < AU_FX_LENGTH/2; i++) {
*clr++ = 0;
}
for (i = 0; i < fx->delayCount; i++) {
AuDelay* delay = &fx->delays[i];
delay->input = params[j++] * AUDIO_SAMPLES;
delay->output = params[j++] * AUDIO_SAMPLES;
delay->fbcoef = (u16) params[j++];
delay->ffcoef = (u16) params[j++];
delay->gain = (u16) params[j++];
if (params[j]) {
delay->rsinc = (2.0 * (params[j++] / 1000.0f)) / gActiveSynDriverPtr->outputRate;
delay->rsgain = ((f32)params[j++] / CONVERT) * (delay->output - delay->input);
delay->rsval = 1.0f;
delay->rsdelta = 0.0f;
delay->resampler_28 = delay->resampler_2C;
delay->resampler_2C->delta = 0.0;
delay->resampler_28->first = 1;
} else {
delay->resampler_28 = NULL;
j++;
j++;
}
if (params[j]) {
delay->lowpass_20 = delay->lowpass_24;
delay->lowpass_20->fc = params[j++];
_init_lpfilter(delay->lowpass_20);
} else {
delay->lowpass_20 = NULL;
j++;
}
}
}
// au_pull_fx -- based on alFxPull
// AuFX from gSynDriverPtr
INCLUDE_ASM(s32, "audio/reverb", func_80059310);
#define INPUT_PARAM 0
#define OUTPUT_PARAM 1
#define FBCOEF_PARAM 2
#define FFCOEF_PARAM 3
#define GAIN_PARAM 4
#define CHORUSRATE_PARAM 5
#define CHORUSDEPTH_PARAM 6
#define LPFILT_PARAM 7
// based on alFxParamHdl
s32 au_fx_param_hdl(AuFX* fx, s16 index, s16 paramID, s32 value) {
switch (paramID) {
case INPUT_PARAM:
fx->delays[index].input = value & 0xFFFFFFF8;
break;
case OUTPUT_PARAM:
fx->delays[index].output = value & 0xFFFFFFF8;
break;
case FFCOEF_PARAM:
fx->delays[index].ffcoef = value;
break;
case FBCOEF_PARAM:
fx->delays[index].fbcoef = value;
break;
case GAIN_PARAM:
fx->delays[index].gain = value;
break;
case CHORUSRATE_PARAM:
fx->delays[index].rsinc = (2.0 * (value / 1000.0f)) / gActiveSynDriverPtr->outputRate;
break;
case CHORUSDEPTH_PARAM:
fx->delays[index].rsgain = ((f32)value / CONVERT) * (fx->delays[index].output - fx->delays[index].input);
break;
case LPFILT_PARAM:
if (fx->delays[index].lowpass_20) {
fx->delays[index].lowpass_20->fc = value;
_init_lpfilter(fx->delays[index].lowpass_20);
}
break;
}
return 0;
}
// TODO: _n_loadBuffer
static Acmd* _saveBuffer(AuFX* fx, s16* oldPos, s32 buf, s32 count, Acmd* cmdBufPos) {
Acmd *ptr = cmdBufPos;
s16* newPos = oldPos + count;
s16* delayEnd = &fx->base[fx->length];
if (delayEnd < newPos) {
s32 before = delayEnd - oldPos;
s32 after = newPos - delayEnd;
n_aLoadBuffer(ptr++, before<<1, buf, osVirtualToPhysical(oldPos));
n_aLoadBuffer(ptr++, after<<1, buf + (before<<1), osVirtualToPhysical(fx->base));
} else {
n_aLoadBuffer(ptr++, count<<1, buf, osVirtualToPhysical(oldPos));
}
return ptr;
}
// updates rsval, producing a triangle wave between ±1
// time delta specified in samples
//TODO rename to _updateTriWaveModulation
static f32 func_80059BD4(AuDelay* delay, s32 rsdelta) {
f32 result;
delay->rsval += delay->rsinc * rsdelta;
delay->rsval = (delay->rsval > 2.0) ? delay->rsval - 4.0 : delay->rsval;
result = delay->rsval;
if (result < 0.0f) {
result = -result;
}
result = result - 1.0;
return delay->rsgain * result;
}

View File

@ -3,24 +3,8 @@
#define MAX_SOUND_INSTANCES 10 #define MAX_SOUND_INSTANCES 10
typedef struct SoundInstance {
/* 0x00 */ s32 flags;
/* 0x04 */ s32 soundID;
/* 0x08 */ s32 sourceFlags;
/* 0x0C */ u8 volume;
/* 0x0D */ u8 pan;
/* 0x0E */ s16 pitchShift;
/* 0x10 */ Vec3f position;
} SoundInstance; // size = 0x1C
typedef struct AlternatingSoundSet {
/* 0x00 */ s32* sounds;
/* 0x04 */ s16 soundCount;
/* 0x06 */ s16 currentIndex;
} AlternatingSoundSet; // size = 0x08
// sound IDs // sound IDs
s32 D_8014F2D0[] = { s32 LoopingSounds[] = {
0x00000287, 0x000002A8, 0x00000054, 0x00000056, 0x00000024, 0x00000027, 0x00000021, 0x00000022, 0x00000349, 0x00000287, 0x000002A8, 0x00000054, 0x00000056, 0x00000024, 0x00000027, 0x00000021, 0x00000022, 0x00000349,
0x00000273, 0x00000275, 0x00000275, 0x00000274, 0x00000273, 0x00000274, 0x00000099, 0x0000009E, 0x0000032E, 0x00000273, 0x00000275, 0x00000275, 0x00000274, 0x00000273, 0x00000274, 0x00000099, 0x0000009E, 0x0000032E,
0x0000008E, 0x00000089, 0x00000083, 0x00000388, 0x000000A0, 0x0000004A, 0x0000009F, 0x00000168, 0x00000185, 0x0000008E, 0x00000089, 0x00000083, 0x00000388, 0x000000A0, 0x0000004A, 0x0000009F, 0x00000168, 0x00000185,
@ -36,6 +20,7 @@ s32 D_8014F2D0[] = {
0x000003AD, 0x0000022C, 0x0000022D, 0x000003AD, 0x0000022C, 0x0000022D,
}; };
// all sound IDs for alternating sounds
s32 D_8014F48C[] = { 0x00000336, 0x00000316 }; s32 D_8014F48C[] = { 0x00000336, 0x00000316 };
s32 D_8014F494[] = { 0x00000337, 0x00000317 }; s32 D_8014F494[] = { 0x00000337, 0x00000317 };
s32 D_8014F49C[] = { 0x00000338, 0x00000318 }; s32 D_8014F49C[] = { 0x00000338, 0x00000318 };
@ -71,7 +56,7 @@ s32 D_8014F58C[] = { 0x00002043, 0x00002044 };
s32 D_8014F594[] = { 0x00002078, 0x00002079 }; s32 D_8014F594[] = { 0x00002078, 0x00002079 };
s32 D_8014F59C[] = { 0x000003B6, 0x000003B7 }; s32 D_8014F59C[] = { 0x000003B6, 0x000003B7 };
AlternatingSoundSet D_8014F5A4[] = { AlternatingSoundSet AlternatingSounds[] = {
{ {
.sounds = D_8014F48C, .sounds = D_8014F48C,
.soundCount = ARRAY_COUNT(D_8014F48C), .soundCount = ARRAY_COUNT(D_8014F48C),
@ -210,21 +195,14 @@ AlternatingSoundSet D_8014F5A4[] = {
} }
}; };
s32 D_8014F6B4[] = { s32 OpenCloseSounds[][2] = {
SOUND_BASIC_DOOR_OPEN, { SOUND_BASIC_DOOR_OPEN, SOUND_BASIC_DOOR_CLOSE },
SOUND_BASIC_DOOR_CLOSE, { SOUND_METAL_DOOR_OPEN, SOUND_METAL_DOOR_CLOSE },
SOUND_METAL_DOOR_OPEN, { SOUND_LARGE_DOOR_OPEN, SOUND_LARGE_DOOR_CLOSE },
SOUND_METAL_DOOR_CLOSE, { SOUND_CREAKY_DOOR_OPEN, SOUND_CREAKY_DOOR_CLOSE },
SOUND_LARGE_DOOR_OPEN, { SOUND_METAL_GATE_OPEN, SOUND_METAL_GATE_CLOSE },
SOUND_LARGE_DOOR_CLOSE, { SOUND_1CB, SOUND_1CC },
SOUND_CREAKY_DOOR_OPEN, { SOUND_20A3, SOUND_20A4 },
SOUND_CREAKY_DOOR_CLOSE,
SOUND_METAL_GATE_OPEN,
SOUND_METAL_GATE_CLOSE,
SOUND_1CB,
SOUND_1CC,
SOUND_20A3,
SOUND_20A4,
}; };
extern SoundInstance D_801598A0[MAX_SOUND_INSTANCES]; extern SoundInstance D_801598A0[MAX_SOUND_INSTANCES];
@ -232,9 +210,6 @@ extern SoundInstance D_801599B8[MAX_SOUND_INSTANCES];
extern SoundInstance* D_80159AD0; extern SoundInstance* D_80159AD0;
extern s32 D_80159AD4; extern s32 D_80159AD4;
void sfx_compute_spatialized_sound_params_0(f32 x, f32 y, f32 z, s16* volume, s16* pan);
void sfx_compute_spatialized_sound_params_1(f32 x, f32 y, f32 z, s16* volume, s16* pan);
void sfx_compute_spatialized_sound_params_2(f32 x, f32 y, f32 z, s16* volume, s16* pan, s32 flags) { void sfx_compute_spatialized_sound_params_2(f32 x, f32 y, f32 z, s16* volume, s16* pan, s32 flags) {
s32 screenX, screenY, screenZ; s32 screenX, screenY, screenZ;
f32 f1, f2, f3; f32 f1, f2, f3;
@ -475,57 +450,50 @@ void func_80149A6C(s32 soundID, s32 keepPlaying) {
SoundInstance* sound = sfx_get_env_sound_instance(soundID); SoundInstance* sound = sfx_get_env_sound_instance(soundID);
if (sound != NULL) { if (sound != NULL) {
sound->flags &= -4; sound->flags &= -SOUND_INSTANCE_FLAG_4;
if (!keepPlaying) { if (!keepPlaying) {
snd_stop_sound(sound->soundID); snd_stop_sound(sound->soundID);
} }
} }
} }
#ifdef NON_EQUIVALENT // weird & 0xFF everywhere void sfx_play_sound_with_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift) {
void sfx_play_sound_with_params(s32 soundID, u8 arg1, u8 arg2, s16 arg3) { AlternatingSoundSet* alternatingSet;
AlternatingSoundSet* alternatingSound;
if (gGameStatusPtr->demoState) { if (gGameStatusPtr->demoState) {
return; return;
} }
if (soundID < 0) { if (soundID & SOUND_TYPE_SPECIAL) {
s32 sound = soundID & 0xFF; s32 soundIndex = soundID & 0xFF;
switch ((soundID >> 0x1C) & 7) { s32 soundType = ((u32)soundID >> 0x1C) & 7;
case 0: switch (soundType) {
sfx_play_sound_looping(D_8014F2D0[sound], arg1, arg2, arg3); case SOUND_TYPE_LOOPING:
sfx_play_sound_looping(LoopingSounds[soundIndex], volume, pan, pitchShift);
return;
case SOUND_TYPE_DOOR1:
soundID = OpenCloseSounds[gCurrentDoorSoundsSet][soundIndex];
break; break;
case 1: case SOUND_TYPE_DOOR2:
snd_start_sound_with_shift(D_8014F6B4[sound + ((u16)gCurrentDoorSoundsSet * 2)], arg1, arg2, arg3); soundID = OpenCloseSounds[D_80151308][soundIndex];
break; break;
case 2: case SOUND_TYPE_ALTERNATING:
snd_start_sound_with_shift(D_8014F6B4[sound + ((u16)D_80151308 * 2)], arg1, arg2, arg3); alternatingSet = &AlternatingSounds[soundIndex];
break; if (alternatingSet->currentIndex >= alternatingSet->soundCount) {
case 3: alternatingSet->currentIndex = 0;
alternatingSound = &D_8014F5A4[sound];
if (alternatingSound->currentIndex >= alternatingSound->soundCount) {
alternatingSound->currentIndex = 0;
} }
snd_start_sound_with_shift(alternatingSound->sounds[alternatingSound->currentIndex++], arg1, arg2, arg3); soundID = alternatingSet->sounds[alternatingSet->currentIndex++];
break;
default:
snd_start_sound_with_shift(soundID, arg1, arg2, arg3);
break; break;
} }
} else {
snd_start_sound_with_shift(soundID, arg1, arg2, arg3);
} }
snd_start_sound_with_shift(soundID, volume, pan, pitchShift);
} }
#else
INCLUDE_ASM(void, "sfx", sfx_play_sound_with_params, s32 arg0, u8 arg1, u8 arg2, s16 arg3);
#endif
void sfx_adjust_env_sound_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift) { void sfx_adjust_env_sound_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift) {
SoundInstance* sound; SoundInstance* sound;
if (soundID < 0) { if (soundID & SOUND_TYPE_SPECIAL) {
sound = sfx_get_env_sound_instance(D_8014F2D0[soundID & 0xFFFF]); sound = sfx_get_env_sound_instance(LoopingSounds[soundID & 0xFFFF]);
if (sound != NULL) { if (sound != NULL) {
sound->volume = volume; sound->volume = volume;
sound->pan = pan; sound->pan = pan;
@ -539,8 +507,8 @@ void sfx_adjust_env_sound_params(s32 soundID, u8 volume, u8 pan, s16 pitchShift)
void sfx_stop_sound(s32 soundID) { void sfx_stop_sound(s32 soundID) {
s32 sound = soundID; s32 sound = soundID;
if (sound < 0) { if (sound & SOUND_TYPE_SPECIAL) {
func_80149A6C(D_8014F2D0[sound & 0xFFFF], 0); func_80149A6C(LoopingSounds[sound & 0xFFFF], 0);
} else { } else {
snd_stop_sound(sound); snd_stop_sound(sound);
} }
@ -566,7 +534,7 @@ void sfx_play_sound_at_npc(s32 soundID, s32 arg1, s32 npcID) {
void sfx_play_sound_at_position(s32 soundID, s32 flags, f32 posX, f32 posY, f32 posZ) { void sfx_play_sound_at_position(s32 soundID, s32 flags, f32 posX, f32 posY, f32 posZ) {
if ((soundID & 0xF0000000) == 0x80000000) { if ((soundID & 0xF0000000) == 0x80000000) {
s32 id = D_8014F2D0[soundID & 0xFFFF]; s32 id = LoopingSounds[soundID & 0xFFFF];
sfx_register_looping_sound_at_position(id, flags, posX, posY, posZ); sfx_register_looping_sound_at_position(id, flags, posX, posY, posZ);
} else { } else {
@ -581,16 +549,16 @@ void sfx_play_sound_at_position(s32 soundID, s32 flags, f32 posX, f32 posY, f32
} }
void sfx_get_spatialized_sound_params(f32 x, f32 y, f32 z, s16* volume, s16* pan, s32 flags) { void sfx_get_spatialized_sound_params(f32 x, f32 y, f32 z, s16* volume, s16* pan, s32 flags) {
s32 temp_s0; u32 upperFlags;
u32 temp_2; u32 lowerFlags;
temp_s0 = flags & 0xFFFF0000; upperFlags = flags & 0xFFFF0000;
do { do {
temp_2 = flags & 0xFFFF; lowerFlags = flags & 0xFFFF;
} while (0); // required to match } while (0); // required to match
switch (temp_2) { switch (lowerFlags) {
case 0: case 0:
sfx_compute_spatialized_sound_params_0(x, y, z, volume, pan); sfx_compute_spatialized_sound_params_0(x, y, z, volume, pan);
break; break;
@ -598,21 +566,21 @@ void sfx_get_spatialized_sound_params(f32 x, f32 y, f32 z, s16* volume, s16* pan
sfx_compute_spatialized_sound_params_1(x, y, z, volume, pan); sfx_compute_spatialized_sound_params_1(x, y, z, volume, pan);
break; break;
case 2: case 2:
sfx_compute_spatialized_sound_params_2(x, y, z, volume, pan, temp_s0); sfx_compute_spatialized_sound_params_2(x, y, z, volume, pan, upperFlags);
break; break;
} }
if (temp_s0 & 0x10000) { if (upperFlags & 0x10000) {
*volume = 0; *volume = 0;
} else if (temp_s0 & 0x400000) { } else if (upperFlags & 0x400000) {
if (*volume < 80) { if (*volume < 80) {
*volume = 80; *volume = 80;
} }
} else if (temp_s0 & 0x200000) { } else if (upperFlags & 0x200000) {
if (*volume < 60) { if (*volume < 60) {
*volume = 60; *volume = 60;
} }
} else if (temp_s0 & 0x100000) { } else if (upperFlags & 0x100000) {
if (*volume < 40) { if (*volume < 40) {
*volume = 40; *volume = 40;
} }
@ -655,7 +623,7 @@ void sfx_compute_spatialized_sound_params_0(f32 x, f32 y, f32 z, s16* volume, s1
*pan = (screenX * 0.2f) + 32.0f; *pan = (screenX * 0.2f) + 32.0f;
} else { } else {
f32 temp_f20 = ((screenX * 127.0) / 320.0) - 64.0; f32 temp_f20 = ((screenX * 127.0) / 320.0) - 64.0;
*pan = (s32) (temp_f20 * sin_rad((fabs(temp_f20) * 90.0 * 0.015625 * TAU) / 360.0)) + 64; *pan = (s32) (temp_f20 * sin_rad((fabs(temp_f20) * 90.0 * (1/64.0) * TAU) / 360.0)) + 64;
} }
} }

1443
src/audio/sfx_player.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
#include "common.h" #include "common.h"
#include "hud_element.h" #include "hud_element.h"
#include "audio/public.h"
#define NAMESPACE action_command_dizzy_shell #define NAMESPACE action_command_dizzy_shell

View File

@ -1,5 +1,6 @@
#include "common.h" #include "common.h"
#include "hud_element.h" #include "hud_element.h"
#include "audio/public.h"
#define NAMESPACE action_command_mega_shock #define NAMESPACE action_command_mega_shock

View File

@ -1,5 +1,6 @@
#include "common.h" #include "common.h"
#include "hud_element.h" #include "hud_element.h"
#include "audio/public.h"
#define NAMESPACE action_command_spook #define NAMESPACE action_command_spook

View File

@ -12,22 +12,22 @@ BSS u8 nuScPreNMIFlag;
BSS char D_8009A5B4[0x4]; BSS char D_8009A5B4[0x4];
BSS s32 D_8009A5B8; BSS s32 D_8009A5B8;
BSS char D_8009A5BC[0x4]; BSS char D_8009A5BC[0x4];
BSS s32 D_8009A5C0; BSS s32 gSoundGlobals;
BSS char D_8009A5C4[0x4]; BSS char D_8009A5C4[0x4];
BSS s32 __osBaseCounter; BSS s32 __osBaseCounter;
BSS s32 D_8009A5CC; BSS s32 gBGMPlayerC;
BSS s32 D_8009A5D0; BSS s32 D_8009A5D0;
BSS s32 D_8009A5D4; BSS void (*CurrentSefCmdHandler)(void*, void*); // SoundManager*, SoundPlayer*
BSS s32 timeFreezeMode; BSS s32 timeFreezeMode;
BSS s32 nuGfxZBuffer; BSS s32 nuGfxZBuffer;
BSS u32 nuContDataLockKey; BSS u32 nuContDataLockKey;
BSS s32 __osViIntrCount; BSS s32 __osViIntrCount;
BSS s32 D_8009A5E8; BSS s32 BeginSoundUpdateCallback;
BSS float D_8009A5EC; BSS float D_8009A5EC;
BSS u32 nuGfxCfbCounter; BSS u32 nuGfxCfbCounter;
BSS s32 mdl_currentModelTreeNodeInfo; BSS s32 mdl_currentModelTreeNodeInfo;
BSS u32 nuGfxDisplay; BSS u32 nuGfxDisplay;
BSS s32 D_8009A5FC; BSS s32 gBGMPlayerB;
BSS s32 gGameState; BSS s32 gGameState;
BSS s16 gNpcCount; BSS s16 gNpcCount;
BSS s16 __osMaxControllers; BSS s16 __osMaxControllers;
@ -39,13 +39,13 @@ BSS u32 nuGfxTaskSpool;
BSS u8 __osContLastCmd; BSS u8 __osContLastCmd;
BSS s32 D_8009A620; BSS s32 D_8009A620;
BSS char D_8009A624[0x4]; BSS char D_8009A624[0x4];
BSS s32 D_8009A628; BSS s32 gAuAmbienceManager;
BSS s32 __osTimerCounter; BSS s32 __osTimerCounter;
BSS s32 D_8009A630; BSS s32 D_8009A630;
BSS s16 gCurrentCamID; BSS s16 gCurrentCamID;
BSS s32 nuPiCartHandle; BSS s32 nuPiCartHandle;
BSS s32 D_8009A63C; BSS s32 D_8009A63C;
BSS s32 D_8009A640; BSS s32 gSoundManager;
BSS char D_8009A644[0x8]; BSS char D_8009A644[0x8];
BSS s32 nuGfxCfb_ptr; BSS s32 nuGfxCfb_ptr;
BSS s32 gOverrideFlags; BSS s32 gOverrideFlags;
@ -53,7 +53,7 @@ BSS s8 D_8009A654;
BSS s32* nuGfxCfb; BSS s32* nuGfxCfb;
BSS char D_8009A65C[0x4]; BSS char D_8009A65C[0x4];
BSS s32 D_8009A660; BSS s32 D_8009A660;
BSS s32 D_8009A664; BSS s32 gBGMPlayerA;
BSS s16 D_8009A668; BSS s16 D_8009A668;
BSS s32 gMasterGfxPos; BSS s32 gMasterGfxPos;
BSS s32 D_8009A670; BSS s32 D_8009A670;
@ -164,13 +164,13 @@ BSS char D_800A0F48[0x8];
BSS u16 D_800A0F50; BSS u16 D_800A0F50;
BSS char D_800A0F54[0x4]; BSS char D_800A0F54[0x4];
BSS s8 nuAuMgrThread[0x25B8]; BSS s8 nuAuMgrThread[0x25B8];
BSS s32 D_800A3510[3]; BSS s32 AlCmdListBuffers[3];
BSS char D_800A351C[4]; BSS char D_800A351C[4];
BSS s32 D_800A3520; BSS s32 D_800A3520;
BSS char D_800A3524[0x104]; BSS char D_800A3524[0x104];
BSS s8 D_800A3628[0xC]; BSS s8 D_800A3628[0xC];
BSS s16 D_800A3634; BSS s32 AlFrameSize;
BSS s32 D_800A3638; BSS s32 AlMinFrameSize;
BSS char D_800A363C[0x4]; BSS char D_800A363C[0x4];
BSS s32 nuAuDmaMesgQ; BSS s32 nuAuDmaMesgQ;
BSS char D_800A3644[0x14]; BSS char D_800A3644[0x14];
@ -181,12 +181,12 @@ BSS s32 D_800A3BD4;
BSS char D_800A3BD8[0x8]; BSS char D_800A3BD8[0x8];
BSS s8 nuAuDmaBufList[50 * 0x14]; BSS s8 nuAuDmaBufList[50 * 0x14];
BSS s8 D_800A3FC8[8]; BSS s8 D_800A3FC8[8];
BSS s32 D_800A3FD0; BSS s32 CurrentSeqCmdHandler;
BSS char D_800A3FD4[0xC]; BSS char D_800A3FD4[0xC];
BSS s32 D_800A3FE0; BSS s32 D_800A3FE0;
BSS s32 D_800A3FE4; BSS s32 D_800A3FE4;
BSS s32 D_800A3FE8; BSS s32 D_800A3FE8;
BSS s8 D_800A3FEC; BSS u8 D_800A3FEC;
BSS s16 D_800A3FEE; BSS s16 D_800A3FEE;
BSS s32 D_800A3FF0; BSS s32 D_800A3FF0;
BSS char D_800A3FF4[0xC]; BSS char D_800A3FF4[0xC];
@ -315,7 +315,7 @@ BSS s8 D_800B451F;
BSS s8 D_800B4520[0x2070]; BSS s8 D_800B4520[0x2070];
BSS s8 D_800B6590[0x2000]; BSS s8 D_800B6590[0x2000];
BSS u8 nuYieldBuf[0xC10]; BSS u8 nuYieldBuf[0xC10];
BSS s8 D_800B91A0[0x30]; BSS s8 auSynDriver[0x30]; // type: AuSynDriver
BSS s8 D_800B91D0[0x20000]; BSS s8 D_800B91D0[0x20000];
BSS s8 gZoneCollisionData[0x10]; BSS s8 gZoneCollisionData[0x10];
BSS s8 wMapHitName[0x18]; BSS s8 wMapHitName[0x18];
@ -339,7 +339,8 @@ BSS s8 D_800DA47C[0x38];
BSS s8 D_800DA4B4[0xA8]; BSS s8 D_800DA4B4[0xA8];
BSS s8 D_800DA55C[0x54C]; BSS s8 D_800DA55C[0x54C];
BSS s8 D_800DAAA8[0x10]; BSS s8 D_800DAAA8[0x10];
BSS s8 D_800DAAB8[0x5]; BSS s32 AlNumFields;
BSS s8 D_800DAABC;
BSS s8 D_800DAABD; BSS s8 D_800DAABD;
BSS s8 D_800DAAC0[0x18]; BSS s8 D_800DAAC0[0x18];
BSS s8 nuContPfs[0x1A0]; BSS s8 nuContPfs[0x1A0];

View File

@ -31,7 +31,7 @@ BSS s32 ItemEntitiesCreated;
BSS s32 gCurrentModelTreeRoot; BSS s32 gCurrentModelTreeRoot;
BSS s32 gEntityHeapBottom; BSS s32 gEntityHeapBottom;
BSS s32 D_80151304; BSS s32 D_80151304;
BSS s32 D_80151308; BSS u32 D_80151308;
BSS s16 gMsgBGScrollAmtY; BSS s16 gMsgBGScrollAmtY;
BSS s16 D_8015130E; BSS s16 D_8015130E;
BSS s32 gEntityHideMode; BSS s32 gEntityHideMode;
@ -46,7 +46,7 @@ BSS s32 entity_updateCounter;
BSS s32 gTriggerCount; BSS s32 gTriggerCount;
BSS s32 D_80151338; BSS s32 D_80151338;
BSS s32 gHudElementCacheSize; BSS s32 gHudElementCacheSize;
BSS s32 gCurrentDoorSoundsSet; BSS u32 gCurrentDoorSoundsSet;
BSS s32 D_80151344; BSS s32 D_80151344;
BSS char D_80151348[0x38]; BSS char D_80151348[0x38];
BSS s8 gWorldEntityList[0x78]; BSS s8 gWorldEntityList[0x78];
@ -230,13 +230,12 @@ BSS s8 D_801599B8[0x118];
BSS s32 D_80159AD0; BSS s32 D_80159AD0;
BSS s32 D_80159AD4; BSS s32 D_80159AD4;
BSS char D_80159AD8[0x8]; BSS char D_80159AD8[0x8];
BSS s16 gMusicUnkVolume; BSS s16 MusicDefaultVolume;
BSS s16 gMusicTargetVolume; BSS s16 MusicTargetVolume;
BSS s16 gMusicUnkVolume2; BSS s16 MusicMaxVolume;
BSS s16 gMusicCurrentVolume; BSS s16 MusicCurrentVolume;
BSS char D_80159AE8[0x8]; BSS char D_80159AE8[0x8];
BSS s8 gMusicSettings[0x18]; BSS s8 gMusicSettings[0x60];
BSS s8 D_80159B08[0x48];
BSS s8 D_80159B50[0x200]; BSS s8 D_80159B50[0x200];
BSS s32 gWindows; BSS s32 gWindows;
BSS s8 D_80159D54[0xC]; BSS s8 D_80159D54[0xC];
@ -261,11 +260,11 @@ BSS char D_8015A2C0[0x10];
BSS s8 D_8015A2D0[0xA0]; BSS s8 D_8015A2D0[0xA0];
BSS s8 D_8015A370[0x1E0]; BSS s8 D_8015A370[0x1E0];
BSS s8 gCollisionStatus[0x28]; BSS s8 gCollisionStatus[0x28];
BSS s16 D_8015A578; BSS s16 gCurrentHiddenPanels;
BSS s16 D_8015A57A; BSS s16 D_8015A57A;
BSS char D_8015A57C[0x14]; BSS char D_8015A57C[0x14];
BSS s8 mdl_textureHandles[0x2200]; BSS s8 mdl_textureHandles[0x2200];
BSS s8 D_8015C790[0x30]; BSS s8 D_8015C790[0x30];
BSS s8 D_8015C7C0[0x10]; BSS s8 AmbientSoundData[0x10];
BSS s32 CreateEntityVarArgBuffer[4]; BSS s32 CreateEntityVarArgBuffer[4];
BSS s32 D_8015C7E0; BSS s32 D_8015C7E0;

View File

@ -397,7 +397,7 @@ void fold_init_state(FoldState* state) {
} }
} }
void fold_update(u32 idx, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) { void fold_update(u32 idx, FoldType arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) {
FoldState* state = &(*D_80156954)[idx]; FoldState* state = &(*D_80156954)[idx];
s32 oldFlags; s32 oldFlags;
s32 t1; s32 t1;

View File

@ -1,84 +0,0 @@
#include "common.h"
// TODO: most likely part of the MusicPlayer struct
typedef struct {
/* 0x0 */ s16 fadeFlags;
/* 0x2 */ s16 fadeState;
/* 0x4 */ s32 fadeOutTime;
/* 0x8 */ s32 fadeInTime;
/* 0xC */ s32 unkC;
} struct_80147230;
struct_80147230 D_8014F140 = {
.fadeFlags = 0,
.fadeState = 0,
.fadeOutTime = 0,
.fadeInTime = -1,
.unkC = -1
};
extern struct_80147230 D_8015C7C0;
void reset_ambient_sounds(void) {
D_8015C7C0 = D_8014F140;
}
void update_ambient_sounds(void) {
struct_80147230* temp = &D_8015C7C0;
switch (temp->fadeState) {
case 0: // idle
break;
case 1: // fading out
if (temp->fadeFlags & 1) {
s32 phi_v0;
if (temp->fadeOutTime < 250) {
phi_v0 = func_800554A4(0, temp->fadeOutTime);
} else {
phi_v0 = func_800554E8(0, temp->fadeOutTime);
}
if (phi_v0 != 0) {
return;
}
}
temp->fadeState = 2;
break;
case 2: // fading in
if (temp->fadeFlags & 1) {
if (func_800555E4(0) != 0) {
return;
}
temp->fadeFlags &= ~1;
}
if (temp->fadeInTime < 0) {
temp->fadeState = 0;
} else if (func_80055448(temp->fadeInTime) == 0) {
if (func_80055464(0, 0) == 0) {
temp->fadeState = 0;
temp->fadeFlags |= 1;
}
}
break;
}
}
s32 play_ambient_sounds(s32 fadeInTime, s32 fadeOutTime) {
struct_80147230* temp1 = &D_8015C7C0;
struct_80147230* temp2 = &D_8015C7C0;
if (!gGameStatusPtr->musicEnabled) {
func_800554A4(temp1->fadeInTime, fadeOutTime);
temp1->fadeFlags &= ~1;
return 1;
}
if (temp1->fadeInTime == fadeInTime) {
return 2;
}
temp2->fadeInTime = fadeInTime;
temp2->fadeOutTime = fadeOutTime;
temp2->fadeState = 1;
return 1;
}

View File

@ -1,445 +0,0 @@
#include "common.h"
#include "npc.h"
MusicSettings D_8014F6F0 = {
.flags = 0,
.unk_02 = 0,
.fadeOutTime = -1,
.fadeInTime = 0,
.unk_0C = 0,
.unk_0E = 0,
.songID = -1,
.variation = -1,
.songName = -1,
.unk_20 = 0,
.unk_24 = 0,
.unk_28 = 0,
.unk_2C = 0
};
s32 gSongsUsingVariationFlag[] = {
SONG_SPECIAL_BATTLE,
SONG_TUBBA_BLUBBA_BATTLE,
SONG_JR_TROOPA_BATTLE,
SONG_YOSHI_KIDS_FOUND,
SONG_ITEM_UPGRADE,
SONG_NEW_PARTNER,
};
s16 D_8014F738 = 0;
void bgm_set_target_volume(s16 volume);
/// If the given song ID is present in gSongsUsingVariationFlag, returns the current
/// map's `songVariation & 1` value. Otherwise, returns -1.
///
/// @see gSongsUsingVariationFlag
/// @returns -1: no override; 0: override to variation 0; 1 override to variation 1
s32 bgm_get_map_default_variation(s32 songID) {
u32 i;
for (i = 0; i < ARRAY_COUNT(gSongsUsingVariationFlag); i++) {
if (gSongsUsingVariationFlag[i] == songID) {
Map* map = &gAreas[gGameStatusPtr->areaID].maps[gGameStatusPtr->mapID];
return map->unk_1C.bytes.songVariation & 1;
}
}
return -1;
}
void bgm_reset_sequence_players(void) {
s32 i;
for (i = 0; i < 2; i++) {
gMusicSettings[i] = D_8014F6F0;
}
gMusicTargetVolume = 8;
gMusicUnkVolume2 = 8;
gMusicCurrentVolume = 8;
func_800561A4(8);
}
void bgm_reset_volume(void) {
gMusicTargetVolume = 8;
gMusicUnkVolume2 = 8;
}
// Loop struct shenanigans
#ifdef NON_EQUIVALENT
// Experiment to fix loop
typedef struct MusicSettingsInner {
/* 0x02 */ s16 unk_02;
/* 0x04 */ s32 fadeOutTime;
/* 0x08 */ s32 fadeInTime;
/* 0x0C */ s16 unk_0C;
/* 0x0E */ s16 unk_0E;
/* 0x10 */ s32 songID;
/* 0x14 */ s32 variation;
/* 0x18 */ s32 songName;
/* 0x1C */ s32 unk_1C;
/* 0x20 */ s32 unk_20;
/* 0x24 */ s32 unk_24;
/* 0x28 */ s32 unk_28;
/* 0x2C */ s32 unk_2C;
} MusicSettingsInner;
typedef struct MusicSettings2 {
/* 0x00 */ u16 flags;
/* 0x02 */ MusicSettingsInner unk_02;
} MusicSettings2; // size = 0x30
void bgm_update_music_settings(void) {
MusicSettingsInner* inner;
MusicSettings2* phi_s1;
s32* flags;
s32 phi_v0;
s32 i;
s32 a;
s32 c;
phi_s1 = gMusicSettings;
for (i = 0; i < 2; i++, phi_s1++) {
inner = &phi_s1->unk_02;
c = 2;
a = ~0x4;
switch (inner->unk_02) {
case 0:
break;
case 1:
if (phi_s1->flags & 1) {
if (inner->fadeOutTime < 250) {
if (!(phi_s1->flags & 4)) {
phi_v0 = func_800559C4(inner->songName);
} else {
phi_v0 = func_80055AF0(inner->songName);
}
} else if (!(phi_s1->flags & 4)) {
phi_v0 = snd_set_song_variation_fade_time(inner->songName, inner->fadeOutTime, 0);
} else {
phi_v0 = func_80055BB8(inner->songName, 0xFA);
}
if (phi_v0 == 0) {
inner->unk_02 = c;
}
} else {
if (phi_s1->flags & 4) {
phi_s1->flags |= 0x10;
}
phi_s1->flags &= a;
inner->unk_02 = 5;
}
break;
case 2:
phi_s1->flags &= a;
if (!(phi_s1->flags & 1)) {
inner->unk_02 = 5;
break;
}
if (func_800559FC(inner->songName) == 0) {
phi_s1->flags &= ~0x1;
inner->unk_02 = 3;
}
break;
case 3:
inner->unk_02 = 4;
break;
case 4:
inner->unk_02 = 5;
break;
case 5:
if (!(phi_s1->flags & 8)) {
if (inner->songID < 0) {
inner->unk_02 = 0;
} else {
inner->songName = snd_load_song(inner->songID, i);
if (inner->songName > 0xFFFFU) {
if ((phi_s1->flags & 0x20) != 0) {
snd_set_song_variation_fade(inner->songName, inner->variation, inner->fadeInTime, inner->unk_0C, inner->unk_0E);
phi_s1->flags &= ~0x20;
} else {
bgm_set_target_volume(gMusicUnkVolume);
}
if (snd_start_song_variation(inner->songName, inner->variation) == 0) {
phi_s1->flags |= 1;
inner->unk_02 = 0;
}
}
}
} else {
if (phi_s1->flags & 0x10) {
inner->unk_02 = 0;
phi_s1->flags &= ~0x18;
} else if (func_80055B28(inner->unk_2C) == 0) {
inner->unk_02 = 0;
inner->songID = inner->unk_24;
inner->variation = inner->unk_28;
inner->songName = inner->unk_2C;
phi_s1->flags |= 1;
phi_s1->flags &= ~0x8;
}
}
break;
}
}
bgm_update_volume();
}
#else
INCLUDE_ASM(s32, "e0b30_len_b80", bgm_update_music_settings);
#endif
s32 _bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume) {
if (gGameStatusPtr->demoState != 0) {
return 1;
} else {
MusicSettings* musicSetting = &gMusicSettings[playerIndex];
if (!gGameStatusPtr->musicEnabled) {
func_800559C4(musicSetting->songName);
musicSetting->flags &= ~MUSIC_SETTINGS_FLAGS_1;
return 1;
} else {
s32 override = bgm_get_map_default_variation(songID);
if (override >= 0) {
variation = override;
}
if (musicSetting->songID == songID && musicSetting->variation == variation) {
bgm_set_target_volume(volume);
if (musicSetting->flags & MUSIC_SETTINGS_FLAGS_4) {
func_80055B80(musicSetting->songName);
musicSetting->flags &= ~MUSIC_SETTINGS_FLAGS_4;
}
return 2;
}
gMusicUnkVolume = volume;
musicSetting->songID = songID;
musicSetting->variation = variation;
musicSetting->fadeOutTime = fadeOutTime;
musicSetting->unk_02 = 1;
musicSetting->flags &= ~MUSIC_SETTINGS_FLAGS_2;
return 1;
}
}
}
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume) {
gMusicSettings[playerIndex].flags &= ~8;
return _bgm_set_song(playerIndex, songID, variation, fadeOutTime, volume);
}
s32 func_8014A964(s32 playerIndex, s32 songID, s32 variation, s32 fadeInTime, s16 arg4, s16 arg5) {
if (gGameStatusPtr->demoState != 0) {
return TRUE;
} else {
MusicSettings* musicSetting = &gMusicSettings[playerIndex];
if (!gGameStatusPtr->musicEnabled) {
func_800559C4(musicSetting->songName);
musicSetting->flags &= ~MUSIC_SETTINGS_FLAGS_1;
return TRUE;
} else {
s32 defaultVariation = bgm_get_map_default_variation(songID);
if (defaultVariation >= 0) {
variation = defaultVariation;
}
musicSetting->fadeInTime = fadeInTime;
musicSetting->unk_0C = arg4;
musicSetting->unk_0E = arg5;
musicSetting->songID = songID;
musicSetting->variation = variation;
musicSetting->flags |= MUSIC_SETTINGS_FLAGS_20;
musicSetting->unk_02 = 1;
musicSetting->flags &= ~MUSIC_SETTINGS_FLAGS_2;
return TRUE;
}
}
}
s32 func_8014AA54(s32 playerIndex, s32 arg1, s16 arg2) {
MusicSettings* musicSetting = &gMusicSettings[playerIndex];
if (!(musicSetting->flags & MUSIC_SETTINGS_FLAGS_1)) {
return FALSE;
}
if (!(musicSetting->flags & MUSIC_SETTINGS_FLAGS_2)) {
return FALSE;
}
switch (arg2) {
case 0:
func_80056028(musicSetting->songName, arg1);
break;
case 1:
func_80056044(musicSetting->songName, arg1);
break;
case 2:
func_80056068(musicSetting->songName, arg1);
break;
}
return TRUE;
}
s32 func_8014AB0C(s32 playerIndex, s16 arg1) {
MusicSettings* musicSetting = &gMusicSettings[playerIndex];
if (!(musicSetting->flags & MUSIC_SETTINGS_FLAGS_1)) {
return 0;
}
return func_80055DDC(musicSetting->songName, arg1);
}
s32 func_8014AB60(s32 playerIndex, s16 arg1) {
MusicSettings* musicSetting = &gMusicSettings[playerIndex];
if (!(musicSetting->flags & MUSIC_SETTINGS_FLAGS_1)) {
return 0;
}
return func_80055E48(musicSetting->songName, arg1);
}
s32 func_8014ABB4(s32 playerIndex, s16 arg1) {
MusicSettings* musicSetting = &gMusicSettings[playerIndex];
if (!(musicSetting->flags & MUSIC_SETTINGS_FLAGS_1)) {
return 0;
}
return func_80055CC4(musicSetting->songName, arg1);
}
s32 bgm_init_music_players(void) {
bgm_set_song(0, -1, 0, 250, 8);
bgm_set_song(1, -1, 0, 250, 8);
return 1;
}
void bgm_quiet_max_volume(void) {
gMusicUnkVolume2 = 4;
}
void bgm_reset_max_volume(void) {
gMusicUnkVolume2 = 8;
}
void bgm_set_target_volume(s16 volume) {
gMusicTargetVolume = volume;
}
void bgm_update_volume(void) {
s16 toVolume;
if (D_8014F738 != 0) {
D_8014F738--;
return;
}
toVolume = gMusicTargetVolume;
if (toVolume > gMusicUnkVolume2) {
toVolume = gMusicUnkVolume2;
}
if (gMusicCurrentVolume != toVolume) {
if (gMusicCurrentVolume >= toVolume) {
gMusicCurrentVolume--;
} else {
gMusicCurrentVolume++;
}
func_800561A4(gMusicCurrentVolume);
D_8014F738 = 3;
}
}
s32 func_8014AD40(void) {
MusicSettings* settings = &gMusicSettings[0];
s32 i;
for (i = 0; i < 2; i++, settings++) {
if (!(settings->flags & MUSIC_SETTINGS_FLAGS_1)) {
continue;
}
if (func_800559FC(settings->songName)) {
return TRUE;
}
}
return FALSE;
}
void bgm_pop_song(void) {
MusicSettings* musicSetting = &gMusicSettings[0];
if (gGameStatusPtr->demoState == 0) {
musicSetting->flags |= MUSIC_SETTINGS_FLAGS_8;
_bgm_set_song(0, musicSetting->unk_24, musicSetting->unk_28, 0, 8);
}
}
void bgm_push_song(s32 songID, s32 variation) {
MusicSettings* musicSetting = &gMusicSettings[0];
if (gGameStatusPtr->demoState == 0) {
musicSetting->unk_24 = musicSetting->songID;
musicSetting->unk_28 = musicSetting->variation;
musicSetting->unk_2C = musicSetting->songName;
musicSetting->flags |= MUSIC_SETTINGS_FLAGS_4;
bgm_set_song(0, songID, variation, 500, 8);
}
}
void bgm_pop_battle_song(void) {
MusicSettings* musicSetting = &gMusicSettings[0];
if (gGameStatusPtr->demoState == 0) {
if (gOverrideFlags & GLOBAL_OVERRIDES_20000) {
gOverrideFlags &= ~GLOBAL_OVERRIDES_20000;
} else {
musicSetting->flags |= MUSIC_SETTINGS_FLAGS_8;
_bgm_set_song(0, musicSetting->unk_24, musicSetting->unk_28, 0, 8);
func_80055590(0, 250);
}
}
}
void bgm_push_battle_song(void) {
MusicSettings* musicSetting = &gMusicSettings[0];
if (gGameStatusPtr->demoState == 0 && !(gOverrideFlags & GLOBAL_OVERRIDES_20000)) {
func_8005553C(0, 250);
musicSetting->unk_24 = musicSetting->songID;
musicSetting->unk_28 = musicSetting->variation;
musicSetting->unk_2C = musicSetting->songName;
musicSetting->flags |= MUSIC_SETTINGS_FLAGS_4;
bgm_set_song(0, musicSetting->unk_1C, musicSetting->unk_20, 500, 8);
}
}
void bgm_set_battle_song(s32 arg0, s32 arg1) {
MusicSettings* musicSetting = &gMusicSettings[0];
musicSetting->unk_1C = arg0;
musicSetting->unk_20 = arg1;
}
void func_8014AFA0(void) {
}

View File

@ -323,7 +323,7 @@ ApiStatus BindNpcAI(Evt* script, s32 isInitialCall) {
Evt* scriptTemp = script; Evt* scriptTemp = script;
ApiStatus ret = ApiStatus_DONE2; ApiStatus ret = ApiStatus_DONE2;
Evt* aiScript; Evt* aiScript;
s32 phi_s1; s32 groupFlags;
if ((s32)enemy != NPC_SELF && (id == NPC_SELF || enemy->npcID == id)) { if ((s32)enemy != NPC_SELF && (id == NPC_SELF || enemy->npcID == id)) {
id = enemy->npcID; id = enemy->npcID;
@ -345,9 +345,9 @@ ApiStatus BindNpcAI(Evt* script, s32 isInitialCall) {
} }
if (enemy->flags & ENEMY_FLAGS_1) { if (enemy->flags & ENEMY_FLAGS_1) {
phi_s1 = 10; groupFlags = EVT_GROUP_08 | EVT_GROUP_02;
} else { } else {
phi_s1 = 11; groupFlags = EVT_GROUP_08 | EVT_GROUP_02 | EVT_GROUP_01;
} }
if (enemy->aiScript != NULL) { if (enemy->aiScript != NULL) {
@ -361,7 +361,7 @@ ApiStatus BindNpcAI(Evt* script, s32 isInitialCall) {
enemy->aiScriptID = scriptTemp->id; enemy->aiScriptID = scriptTemp->id;
scriptTemp->owner1.enemy = enemy; scriptTemp->owner1.enemy = enemy;
scriptTemp->owner2.npcID = id; scriptTemp->owner2.npcID = id;
scriptTemp->groupFlags = phi_s1; scriptTemp->groupFlags = groupFlags;
return ret; return ret;
} }
@ -395,9 +395,9 @@ ApiStatus RestartNpcAI(Evt* script, s32 isInitialCall) {
npc = get_enemy(npcId); npc = get_enemy(npcId);
if (npc->flags & 1) { if (npc->flags & 1) {
groupFlags = 10; groupFlags = EVT_GROUP_08 | EVT_GROUP_02;
} else { } else {
groupFlags = 11; groupFlags = EVT_GROUP_08 | EVT_GROUP_02 | EVT_GROUP_01;
} }
if (npc->aiScript != NULL) { if (npc->aiScript != NULL) {
@ -513,9 +513,9 @@ ApiStatus RestartNpcAux(Evt* script, s32 isInitialCall) {
enemy = get_enemy(npcID); enemy = get_enemy(npcID);
if (enemy->flags & 1) { if (enemy->flags & 1) {
groupFlags = 10; groupFlags = EVT_GROUP_08 | EVT_GROUP_02;
} else { } else {
groupFlags = 11; groupFlags = EVT_GROUP_08 | EVT_GROUP_02 | EVT_GROUP_01;
} }
if (enemy->auxScript != NULL) { if (enemy->auxScript != NULL) {

View File

@ -8,27 +8,27 @@ void entity_HiddenPanel_flip_over(Entity*);
void mdl_project_tex_coords(s32 modelID, Gfx* destGfx, Matrix4f destMtx, void* destVertices); void mdl_project_tex_coords(s32 modelID, Gfx* destGfx, Matrix4f destMtx, void* destVertices);
s32 npc_find_standing_on_entity(s32 entityIndex); s32 npc_find_standing_on_entity(s32 entityIndex);
extern s32 Entity_HiddenPanel_RenderScript2[]; extern s32 ERS_AltHiddenPanel[];
extern Gfx Entity_HiddenPanel_RenderTop[]; extern Gfx Gfx_HiddenPanel_RenderTop[];
extern Gfx Entity_HiddenPanel_RenderTop2[]; extern Gfx Gfx_AltHiddenPanel_RenderTop[];
extern Gfx Entity_HiddenPanel_RenderBottomDark[]; extern Gfx Gfx_HiddenPanel_RenderHole[];
extern Gfx Entity_HiddenPanel_Render[]; extern Gfx Gfx_HiddenPanel_Render[];
extern Gfx Entity_HiddenPanel_Render2[]; extern Gfx Gfx_HiddenPanel_Render2[];
void entity_HiddenPanel_setupGfx(s32 entityIndex) { void entity_HiddenPanel_setupGfx(s32 entityIndex) {
Entity* entity = get_entity_by_index(entityIndex); Entity* entity = get_entity_by_index(entityIndex);
HiddenPanelData* data = entity->dataBuf.hiddenPanel; HiddenPanelData* data = entity->dataBuf.hiddenPanel;
Matrix4f sp10; Matrix4f rotMtx;
Matrix4f sp50; Matrix4f tempMtx;
if (entity->position.y != data->initialY) { if (entity->position.y != data->initialY) {
guMtxIdentF(sp10); guMtxIdentF(rotMtx);
guTranslateF(sp50, entity->position.x, data->initialY + 1.0f, entity->position.z); guTranslateF(tempMtx, entity->position.x, data->initialY + 1.0f, entity->position.z);
guMtxCatF(sp50, sp10, sp50); guMtxCatF(tempMtx, rotMtx, tempMtx);
guMtxF2L(sp50, &gDisplayContext->matrixStack[gMatrixListPos]); guMtxF2L(tempMtx, &gDisplayContext->matrixStack[gMatrixListPos]);
gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(gMasterGfxPos++, ENTITY_ADDR(entity, Gfx*, Entity_HiddenPanel_RenderBottomDark)); gSPDisplayList(gMasterGfxPos++, ENTITY_ADDR(entity, Gfx*, Gfx_HiddenPanel_RenderHole));
gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW);
} }
mdl_project_tex_coords(data->modelID, data->renderDList, data->entityMatrix, entity->gfxBaseAddr); mdl_project_tex_coords(data->modelID, data->renderDList, data->entityMatrix, entity->gfxBaseAddr);
@ -38,8 +38,8 @@ void entity_HiddenPanel_setupGfx(s32 entityIndex) {
void entity_HiddenPanel_set_ispy_notification(Entity* entity) { void entity_HiddenPanel_set_ispy_notification(Entity* entity) {
HiddenPanelData* data = entity->dataBuf.hiddenPanel; HiddenPanelData* data = entity->dataBuf.hiddenPanel;
if (is_ability_active(ABILITY_I_SPY) && !get_global_flag(data->pickupVar) && !D_8015A578.unk_02) { if (is_ability_active(ABILITY_I_SPY) && !get_global_flag(data->pickupVar) && !gCurrentHiddenPanels.activateISpy) {
D_8015A578.unk_02 = TRUE; gCurrentHiddenPanels.activateISpy = TRUE;
} }
} }
@ -64,7 +64,7 @@ void entity_HiddenPanel_idle(Entity* entity) {
data->standingNpcIndex = -1; data->standingNpcIndex = -1;
data->npcFlags = 0; data->npcFlags = 0;
if (D_8015A578.unk_00 && fabs(D_8015A578.unk_08 - entity->position.y) <= 10.0) { if (gCurrentHiddenPanels.tryFlipTrigger && fabs(gCurrentHiddenPanels.flipTriggerPosY - entity->position.y) <= 10.0) {
data->state = 10; data->state = 10;
distToPlayer = get_xz_dist_to_player(entity->position.x, entity->position.z); distToPlayer = get_xz_dist_to_player(entity->position.x, entity->position.z);
if (distToPlayer <= 100) { if (distToPlayer <= 100) {
@ -293,7 +293,7 @@ void entity_HiddenPanel_init(Entity* entity) {
Matrix4f sp58; Matrix4f sp58;
Gfx* dlist; Gfx* dlist;
mem_clear(&D_8015A578, sizeof(D_8015A578)); mem_clear(&gCurrentHiddenPanels, sizeof(gCurrentHiddenPanels));
entity->renderSetupFunc = entity_HiddenPanel_setupGfx; entity->renderSetupFunc = entity_HiddenPanel_setupGfx;
data->pickupVar = 0xFFFF; data->pickupVar = 0xFFFF;
data->initialY = entity->position.y; data->initialY = entity->position.y;
@ -317,16 +317,16 @@ void entity_HiddenPanel_init(Entity* entity) {
guScaleF(sp58, entity->scale.x, entity->scale.y, entity->scale.z); guScaleF(sp58, entity->scale.x, entity->scale.y, entity->scale.z);
guMtxCatF(sp58, sp18, data->entityMatrix); guMtxCatF(sp58, sp18, data->entityMatrix);
if (D_8015A578.unk_01 & 1) { if (gCurrentHiddenPanels.panelsCount & 1) {
dlist = Entity_HiddenPanel_RenderTop2; dlist = Gfx_AltHiddenPanel_RenderTop;
entity_set_render_script(entity, Entity_HiddenPanel_RenderScript2); entity_set_render_script(entity, ERS_AltHiddenPanel);
} else { } else {
dlist = Entity_HiddenPanel_RenderTop; dlist = Gfx_HiddenPanel_RenderTop;
} }
data->renderDList = ENTITY_ADDR(entity, Gfx*, dlist); data->renderDList = ENTITY_ADDR(entity, Gfx*, dlist);
mdl_project_tex_coords(data->modelID, data->renderDList, data->entityMatrix, entity->gfxBaseAddr); mdl_project_tex_coords(data->modelID, data->renderDList, data->entityMatrix, entity->gfxBaseAddr);
D_8015A578.unk_01++; gCurrentHiddenPanels.panelsCount++;
} }
EntityScript Entity_HiddenPanel_Script = { EntityScript Entity_HiddenPanel_Script = {
@ -339,18 +339,18 @@ EntityScript Entity_HiddenPanel_Script = {
es_End es_End
}; };
EntityModelScript Entity_HiddenPanel_RenderScript = { EntityModelScript ERS_HiddenPanel = {
ems_SetRenderMode(RENDER_MODE_SURFACE_OPA) ems_SetRenderMode(RENDER_MODE_SURFACE_OPA)
ems_SetFlags(ENTITY_MODEL_FLAGS_10000) ems_SetFlags(ENTITY_MODEL_FLAGS_10000)
ems_Draw(Entity_HiddenPanel_Render, 60) ems_Draw(Gfx_HiddenPanel_Render, 60)
ems_Restart ems_Restart
ems_End ems_End
}; };
EntityModelScript Entity_HiddenPanel_RenderScript2 = { EntityModelScript ERS_AltHiddenPanel = {
ems_SetRenderMode(RENDER_MODE_SURFACE_OPA) ems_SetRenderMode(RENDER_MODE_SURFACE_OPA)
ems_SetFlags(ENTITY_MODEL_FLAGS_10000) ems_SetFlags(ENTITY_MODEL_FLAGS_10000)
ems_Draw(Entity_HiddenPanel_Render2, 60) ems_Draw(Gfx_HiddenPanel_Render2, 60)
ems_Restart ems_Restart
ems_End ems_End
}; };
@ -358,7 +358,7 @@ EntityModelScript Entity_HiddenPanel_RenderScript2 = {
EntityBlueprint Entity_HiddenPanel = { EntityBlueprint Entity_HiddenPanel = {
.flags = ENTITY_FLAGS_HIDDEN, .flags = ENTITY_FLAGS_HIDDEN,
.typeDataSize = sizeof(HiddenPanelData), .typeDataSize = sizeof(HiddenPanelData),
.renderCommandList = Entity_HiddenPanel_RenderScript, .renderCommandList = ERS_HiddenPanel,
.modelAnimationNodes = 0, .modelAnimationNodes = 0,
.fpInit = entity_HiddenPanel_init, .fpInit = entity_HiddenPanel_init,
.updateEntityScript = Entity_HiddenPanel_Script, .updateEntityScript = Entity_HiddenPanel_Script,

View File

@ -37,7 +37,7 @@ Vtx D_0A000020_E56BA0[] = {
{{{ 30, 0, -30 }, 0, { 0, 0 }, { 10, 10, 10, 128 }}}, {{{ 30, 0, -30 }, 0, { 0, 0 }, { 10, 10, 10, 128 }}},
}; };
Gfx Entity_HiddenPanel_RenderTop[] = { Gfx Gfx_HiddenPanel_RenderTop[] = {
gsDPPipeSync(), gsDPPipeSync(),
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING), gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK), gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK),
@ -46,7 +46,7 @@ Gfx Entity_HiddenPanel_RenderTop[] = {
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };
Gfx Entity_HiddenPanel_RenderTop2[] = { Gfx Gfx_AltHiddenPanel_RenderTop[] = {
gsDPPipeSync(), gsDPPipeSync(),
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING), gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK), gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK),
@ -55,7 +55,7 @@ Gfx Entity_HiddenPanel_RenderTop2[] = {
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };
Gfx Entity_HiddenPanel_RenderBottom[] = { Gfx Gfx_HiddenPanel_RenderBottom[] = {
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF),
gsDPPipeSync(), gsDPPipeSync(),
gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetCycleType(G_CYC_1CYCLE),
@ -68,7 +68,7 @@ Gfx Entity_HiddenPanel_RenderBottom[] = {
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };
Gfx Entity_HiddenPanel_RenderBottomDark[] = { Gfx Gfx_HiddenPanel_RenderHole[] = {
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF),
gsDPPipeSync(), gsDPPipeSync(),
gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetCycleType(G_CYC_1CYCLE),
@ -81,16 +81,16 @@ Gfx Entity_HiddenPanel_RenderBottomDark[] = {
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };
Gfx Entity_HiddenPanel_Render[] = { Gfx Gfx_HiddenPanel_Render[] = {
gsDPPipeSync(), gsDPPipeSync(),
gsSPDisplayList(Entity_HiddenPanel_RenderTop), gsSPDisplayList(Gfx_HiddenPanel_RenderTop),
gsSPDisplayList(Entity_HiddenPanel_RenderBottom), gsSPDisplayList(Gfx_HiddenPanel_RenderBottom),
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };
Gfx Entity_HiddenPanel_Render2[] = { Gfx Gfx_HiddenPanel_Render2[] = {
gsDPPipeSync(), gsDPPipeSync(),
gsSPDisplayList(Entity_HiddenPanel_RenderTop2), gsSPDisplayList(Gfx_AltHiddenPanel_RenderTop),
gsSPDisplayList(Entity_HiddenPanel_RenderBottom), gsSPDisplayList(Gfx_HiddenPanel_RenderBottom),
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };

View File

@ -3,45 +3,81 @@
#include "hud_element.h" #include "hud_element.h"
#include "world/partners.h" #include "world/partners.h"
extern EvtScript D_802D9D34; AuResult bgm_set_track_volumes(s32 playerIndex, s16 trackVolSet);
extern s32* D_802DB7D0; static ApiStatus PollMusicEvents(Evt* script, s32 isInitialCall);
extern s32 D_802DB7D8[10];
extern s32 D_802DB800[10]; extern MusicEvent* MusicEventList;
extern Evt* RunningMusicEvents[10];
extern s32 RunningMusicEventIDs[10];
extern PopupMenu D_802DB830; extern PopupMenu D_802DB830;
ApiStatus func_802D5B10(Evt* script, s32 isInitialCall); s32 MusicEventPollCount = 0;
s32 D_802D9D30 = 0; static EvtScript EVS_MusicEventMonitor = {
EVT_CALL(PollMusicEvents)
EvtScript D_802D9D34 = {
EVT_CALL(func_802D5B10)
EVT_RETURN EVT_RETURN
EVT_END EVT_END
}; };
INCLUDE_ASM(s32, "evt/fa4c0_len_3bf0", func_802D5B10); static s32 PollMusicEvents(Evt* script, s32 isInitialCall) {
MusicEventTrigger* list;
s32 musicEventID, scriptSelector;
u32 count;
s32 i;
ApiStatus func_802D5C70(Evt* script) { bgm_poll_music_events(&list, &count);
for (i = 0; i < count; i++, list++) {
MusicEvent* cur = MusicEventList;
musicEventID = (*list & 0xFF0000) >> 0x10;
scriptSelector = *list & 0xFF;
while (cur->musicEventID != -1) {
if (cur->musicEventID == musicEventID) {
break;
}
cur++;
}
// bug? can cur ever be NULL here?
// condition should probably be if (cur->musicEventID != -1)
if (cur != NULL) {
EvtScript* newSource = cur->scripts[scriptSelector];
if (RunningMusicEvents[musicEventID] != NULL) {
kill_script_by_ID(RunningMusicEventIDs[musicEventID]);
}
if (newSource != NULL) {
Evt* newEvt = start_script(newSource, 1, 0);
RunningMusicEvents[musicEventID] = newEvt;
RunningMusicEventIDs[musicEventID] = newEvt->id;
}
}
}
bgm_flush_music_events();
MusicEventPollCount++;
return ApiStatus_BLOCK;
}
ApiStatus RegisterMusicEvents(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 i; s32 i;
D_802DB7D0 = (s32*) evt_get_variable(script, *args++); // expects a list of MusicEvent, terminated by -1 0 0 0 0
MusicEventList = (MusicEvent*) evt_get_variable(script, *args++);
for (i = 0; i < ARRAY_COUNT(D_802DB7D8); i++) { for (i = 0; i < ARRAY_COUNT(RunningMusicEvents); i++) {
D_802DB7D8[i] = 0; RunningMusicEvents[i] = NULL;
D_802DB800[i] = 0; RunningMusicEventIDs[i] = 0;
} }
start_script(&D_802D9D34, EVT_PRIORITY_1, 0); start_script(&EVS_MusicEventMonitor, EVT_PRIORITY_1, 0);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus FadeOutMusic(Evt* script, s32 isInitialCall) { ApiStatus FadeOutMusic(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 itemID = evt_get_variable(script, *args++); s32 musicPlayer = evt_get_variable(script, *args++);
s32* ptrNextPos = args++; s32 fadeTime = evt_get_variable(script, *args++);
if (bgm_set_song(itemID, -1, 0, evt_get_variable(script, *ptrNextPos++), 8) != 0) { if (bgm_set_song(musicPlayer, -1, 0, fadeTime, 8)) {
return ApiStatus_DONE2; return ApiStatus_DONE2;
} else { } else {
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
@ -55,7 +91,7 @@ ApiStatus SetMusicTrack(Evt* script, s32 isInitialCall) {
s32 variation = evt_get_variable(script, *args++); s32 variation = evt_get_variable(script, *args++);
s16 volume = evt_get_variable(script, *args++); s16 volume = evt_get_variable(script, *args++);
if (bgm_set_song(musicPlayer, songID, variation, 500, volume) != 0) { if (bgm_set_song(musicPlayer, songID, variation, 500, volume)) {
return ApiStatus_DONE2; return ApiStatus_DONE2;
} else { } else {
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
@ -64,14 +100,14 @@ ApiStatus SetMusicTrack(Evt* script, s32 isInitialCall) {
ApiStatus FadeInMusic(Evt* script, s32 isInitialCall) { ApiStatus FadeInMusic(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 var0 = evt_get_variable(script, *args++); s32 musicPlayer = evt_get_variable(script, *args++);
s32 var1 = evt_get_variable(script, *args++); s32 songID = evt_get_variable(script, *args++);
s32 var2 = evt_get_variable(script, *args++); s32 variation = evt_get_variable(script, *args++);
s32 var3 = evt_get_variable(script, *args++); s32 fadeTime = evt_get_variable(script, *args++);
s16 var4 = evt_get_variable(script, *args++); s16 fadeStartVolume = evt_get_variable(script, *args++);
s16 var5 = evt_get_variable(script, *args++); s16 fadeEndVolume = evt_get_variable(script, *args++);
if (func_8014A964(var0, var1, var2, var3, var4, var5) != 0) { if (func_8014A964(musicPlayer, songID, variation, fadeTime, fadeStartVolume, fadeEndVolume)) {
return ApiStatus_DONE2; return ApiStatus_DONE2;
} else { } else {
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
@ -80,20 +116,27 @@ ApiStatus FadeInMusic(Evt* script, s32 isInitialCall) {
ApiStatus func_802D5EE0(Evt* script, s32 isInitialCall) { ApiStatus func_802D5EE0(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 playerIndex = evt_get_variable(script, *args++);
(&gMusicSettings[evt_get_variable(script, *args++)])->flags |= 0x2; gMusicSettings[playerIndex].flags |= MUSIC_SETTINGS_FLAGS_2;
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_802D5F28(Evt* script, s32 isInitialCall) { ApiStatus AdjustMusicProximityMix(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 playerIndex = evt_get_variable(script, *args++);
s32 mix = evt_get_variable(script, *args++);
s32 state = evt_get_variable(script, *args++);
func_8014AA54(evt_get_variable(script, *args++), evt_get_variable(script, *args++), (s16)evt_get_variable(script, *args++)); bgm_adjust_proximity(playerIndex, mix, state);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_802D5FA4(Evt* script, s32 isInitialCall) { ApiStatus SetMusicTrackVolumes(Evt* script, s32 isInitialCall) {
func_8014AB0C(0, (s16)evt_get_variable(script, *script->ptrReadPos)); Bytecode* args = script->ptrReadPos;
s16 trackVolSet = evt_get_variable(script, *args++);
bgm_set_track_volumes(0, trackVolSet);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
@ -104,8 +147,10 @@ ApiStatus PopSong(Evt* script, s32 isInitialCall) {
ApiStatus PushSong(Evt* script, s32 isInitialCall) { ApiStatus PushSong(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 songID = evt_get_variable(script, *args++);
s32 variation = evt_get_variable(script, *args++);
bgm_push_song(evt_get_variable(script, *args++), evt_get_variable(script, *args++)); bgm_push_song(songID, variation);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
@ -121,16 +166,18 @@ ApiStatus PushBattleSong(Evt* script, s32 isInitialCall) {
ApiStatus SetBattleSong(Evt* script, s32 isInitialCall) { ApiStatus SetBattleSong(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 songID = evt_get_variable(script, *args++);
s32 variation = evt_get_variable(script, *args++);
bgm_set_battle_song(evt_get_variable(script, *args++), evt_get_variable(script, *args++)); bgm_set_battle_song(songID, variation);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus ClearAmbientSounds(Evt* script, s32 isInitialCall) { ApiStatus ClearAmbientSounds(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 flags = evt_get_variable(script, *args++); s32 time = evt_get_variable(script, *args++);
if (play_ambient_sounds(-1, flags) != 0) { if (play_ambient_sounds(-1, time)) {
return ApiStatus_DONE2; return ApiStatus_DONE2;
} else { } else {
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
@ -141,7 +188,7 @@ ApiStatus PlayAmbientSounds(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 soundID = evt_get_variable(script, *args++); s32 soundID = evt_get_variable(script, *args++);
if (play_ambient_sounds(soundID, 0xFA) != 0) { if (play_ambient_sounds(soundID, 250)) {
return ApiStatus_DONE2; return ApiStatus_DONE2;
} else { } else {
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
@ -159,9 +206,9 @@ ApiStatus PlaySound(Evt* script, s32 isInitialCall) {
ApiStatus PlaySoundWithVolume(Evt* script, s32 isInitialCall) { ApiStatus PlaySoundWithVolume(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 soundID = evt_get_variable(script, *args++); s32 soundID = evt_get_variable(script, *args++);
s32 value2 = evt_get_variable(script, *args++); s32 volume = evt_get_variable(script, *args++);
sfx_play_sound_with_params(soundID, value2 & 0xFF, 0, 0); sfx_play_sound_with_params(soundID, volume, 0, 0);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
@ -179,15 +226,17 @@ ApiStatus PlaySoundAt(Evt* script, s32 isInitialCall) {
ApiStatus StopSound(Evt* script, s32 isInitialCall) { ApiStatus StopSound(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 soundID = evt_get_variable(script, *args++);
sfx_stop_sound(evt_get_variable(script, *args++)); sfx_stop_sound(soundID);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_802D62E4(Evt* script, s32 isInitialCall) { ApiStatus func_802D62E4(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 soundID = evt_get_variable(script, *args++);
func_80149A6C(evt_get_variable(script, *args++), 1); func_80149A6C(soundID, TRUE);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
@ -208,12 +257,12 @@ ApiStatus UseAdvancedDoorSounds(Evt* script, s32 isInitialCall) {
ApiStatus PlaySoundAtF(Evt* script, s32 isInitialCall) { ApiStatus PlaySoundAtF(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
Bytecode soundID = *args++; Bytecode soundID = *args++;
u16 value2 = evt_get_variable(script, *args++); u16 spatializationFlags = evt_get_variable(script, *args++);
f32 x = evt_get_float_variable(script, *args++); f32 x = evt_get_float_variable(script, *args++);
f32 y = evt_get_float_variable(script, *args++); f32 y = evt_get_float_variable(script, *args++);
f32 z = evt_get_float_variable(script, *args++); f32 z = evt_get_float_variable(script, *args++);
sfx_play_sound_at_position(soundID, value2, x, y, z); sfx_play_sound_at_position(soundID, spatializationFlags, x, y, z);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
@ -272,7 +321,7 @@ ApiStatus ShowKeyChoicePopup(Evt* script, s32 isInitialCall) {
script->varTable[0] = 0; script->varTable[0] = 0;
return ApiStatus_DONE1; return ApiStatus_DONE1;
} }
menu->popupType = 0xC; menu->popupType = POPUP_MENU_USEKEY;
menu->numEntries = numEntries; menu->numEntries = numEntries;
menu->initialPos = 0; menu->initialPos = 0;
create_popup_menu(menu); create_popup_menu(menu);
@ -363,7 +412,7 @@ ApiStatus ShowConsumableChoicePopup(Evt* script, s32 isInitialCall) {
script->varTable[0] = 0; script->varTable[0] = 0;
return ApiStatus_DONE1; return ApiStatus_DONE1;
} }
menu->popupType = 0xC; menu->popupType = POPUP_MENU_USEKEY;
menu->numEntries = numEntries; menu->numEntries = numEntries;
menu->initialPos = 0; menu->initialPos = 0;
create_popup_menu(menu); create_popup_menu(menu);
@ -399,8 +448,6 @@ ApiStatus ShowConsumableChoicePopup(Evt* script, s32 isInitialCall) {
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
} }
// TODO: probably a split here (sound_api, item_api)
ApiStatus RemoveKeyItemAt(Evt* script, s32 isInitialCall) { ApiStatus RemoveKeyItemAt(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 index = evt_get_variable(script, *args++); s32 index = evt_get_variable(script, *args++);

View File

@ -743,9 +743,9 @@ ApiStatus DisablePulseStone(Evt* script, s32 isInitialCall) {
PlayerStatus* playerStatus = &gPlayerStatus; PlayerStatus* playerStatus = &gPlayerStatus;
if (evt_get_variable(script, *script->ptrReadPos)) { if (evt_get_variable(script, *script->ptrReadPos)) {
playerStatus->animFlags &= ~0x80; playerStatus->animFlags &= ~PLAYER_STATUS_ANIM_FLAGS_USING_PULSE_STONE;
} else { } else {
playerStatus->animFlags |= 0x80; playerStatus->animFlags |= PLAYER_STATUS_ANIM_FLAGS_USING_PULSE_STONE;
} }
return ApiStatus_DONE2; return ApiStatus_DONE2;
@ -753,7 +753,7 @@ ApiStatus DisablePulseStone(Evt* script, s32 isInitialCall) {
ApiStatus GetCurrentPartner(Evt* script, s32 isInitialCall) { ApiStatus GetCurrentPartner(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
Bytecode a0 = *args; Bytecode outVar = *args++;
PlayerData* playerData = &gPlayerData; PlayerData* playerData = &gPlayerData;
s32 currentPartner = 0; s32 currentPartner = 0;
@ -761,21 +761,21 @@ ApiStatus GetCurrentPartner(Evt* script, s32 isInitialCall) {
currentPartner = playerData->currentPartner; currentPartner = playerData->currentPartner;
} }
evt_set_variable(script, a0, currentPartner); evt_set_variable(script, outVar, currentPartner);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_802D2B50(void) { ApiStatus func_802D2B50(void) {
PlayerStatus* playerStatus = &gPlayerStatus; PlayerStatus* playerStatus = &gPlayerStatus;
playerStatus->animFlags |= 8; playerStatus->animFlags |= PLAYER_STATUS_ANIM_FLAGS_8;
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_802D2B6C(Evt* script, s32 isInitialCall) { ApiStatus func_802D2B6C(Evt* script, s32 isInitialCall) {
PlayerStatus* playerStatus = &gPlayerStatus; PlayerStatus* playerStatus = &gPlayerStatus;
playerStatus->animFlags |= 4; playerStatus->animFlags |= PLAYER_STATUS_ANIM_FLAGS_4;
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
@ -786,11 +786,13 @@ ApiStatus Disable8bitMario(Evt* script, s32 isInitialCall) {
if (evt_get_variable(script, *args)) { if (evt_get_variable(script, *args)) {
playerStatus->colliderHeight = 37; playerStatus->colliderHeight = 37;
playerStatus->colliderDiameter = 26; playerStatus->colliderDiameter = 26;
playerStatus->animFlags &= ~0x4000; playerStatus->animFlags &= ~PLAYER_STATUS_ANIM_FLAGS_8BIT_MARIO;
} else { } else {
playerStatus->colliderHeight = 19; playerStatus->colliderHeight = 19;
playerStatus->colliderDiameter = 26; playerStatus->colliderDiameter = 26;
playerStatus->animFlags |= 0x44004; playerStatus->animFlags |= PLAYER_STATUS_ANIM_FLAGS_8BIT_MARIO
| PLAYER_STATUS_ANIM_FLAGS_40000
| PLAYER_STATUS_ANIM_FLAGS_4;
} }
return ApiStatus_DONE2; return ApiStatus_DONE2;
@ -848,13 +850,13 @@ void virtual_entity_render_quad(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4
virtual_entity_appendGfx_quad(arg0, arg1, arg2, arg3, arg4, arg5, temp1, temp2); virtual_entity_appendGfx_quad(arg0, arg1, arg2, arg3, arg4, arg5, temp1, temp2);
} }
void virtual_entity_move_polar(VirtualEntity* virtualEntity, f32 arg1, f32 arg2) { void virtual_entity_move_polar(VirtualEntity* virtualEntity, f32 magnitude, f32 angle) {
f32 theta = (arg2 * TAU) / 360.0f; f32 theta = (angle * TAU) / 360.0f;
f32 sinTheta = sin_rad(theta); f32 sinTheta = sin_rad(theta);
f32 cosTheta = cos_rad(theta); f32 cosTheta = cos_rad(theta);
virtualEntity->pos.x += arg1 * sinTheta; virtualEntity->pos.x += magnitude * sinTheta;
virtualEntity->pos.z += -arg1 * cosTheta; virtualEntity->pos.z += -magnitude * cosTheta;
} }
void virtual_entity_list_update(void) { void virtual_entity_list_update(void) {
@ -874,11 +876,11 @@ void virtual_entity_list_render_world(void) {
Matrix4f xRot; Matrix4f xRot;
Matrix4f yRot; Matrix4f yRot;
Matrix4f zRot; Matrix4f zRot;
Matrix4f sp118; Matrix4f rotation;
Matrix4f sp158; Matrix4f temp;
Matrix4f sp198; Matrix4f transform;
Matrix4f scale; Matrix4f scale;
Mtx sp218; Mtx transformMtxL;
VirtualEntity* virtualEntity; VirtualEntity* virtualEntity;
s32 i; s32 i;
@ -891,12 +893,12 @@ void virtual_entity_list_render_world(void) {
guRotateF(yRot, virtualEntity->rot.y, 0.0f, 1.0f, 0.0f); guRotateF(yRot, virtualEntity->rot.y, 0.0f, 1.0f, 0.0f);
guRotateF(zRot, virtualEntity->rot.z, 0.0f, 0.0f, 1.0f); guRotateF(zRot, virtualEntity->rot.z, 0.0f, 0.0f, 1.0f);
guScaleF(scale, virtualEntity->scale.x, virtualEntity->scale.y, virtualEntity->scale.z); guScaleF(scale, virtualEntity->scale.x, virtualEntity->scale.y, virtualEntity->scale.z);
guMtxCatF(zRot, xRot, sp158); guMtxCatF(zRot, xRot, temp);
guMtxCatF(sp158, yRot, sp118); guMtxCatF(temp, yRot, rotation);
guMtxCatF(scale, sp118, sp158); guMtxCatF(scale, rotation, temp);
guMtxCatF(sp158, translation, sp198); guMtxCatF(temp, translation, transform);
guMtxF2L(sp198, &sp218); guMtxF2L(transform, &transformMtxL);
draw_entity_model_A(virtualEntity->entityModelIndex, &sp218); draw_entity_model_A(virtualEntity->entityModelIndex, &transformMtxL);
} }
} }
} }
@ -907,11 +909,11 @@ void virtual_entity_list_render_UI(void) {
Matrix4f xRot; Matrix4f xRot;
Matrix4f yRot; Matrix4f yRot;
Matrix4f zRot; Matrix4f zRot;
Matrix4f sp118; Matrix4f rotation;
Matrix4f sp158; Matrix4f temp;
Matrix4f sp198; Matrix4f transform;
Matrix4f scale; Matrix4f scale;
Mtx sp218; Mtx transformMtxL;
VirtualEntity* virtualEntity; VirtualEntity* virtualEntity;
s32 i; s32 i;
@ -924,12 +926,12 @@ void virtual_entity_list_render_UI(void) {
guRotateF(yRot, virtualEntity->rot.y, 0.0f, 1.0f, 0.0f); guRotateF(yRot, virtualEntity->rot.y, 0.0f, 1.0f, 0.0f);
guRotateF(zRot, virtualEntity->rot.z, 0.0f, 0.0f, 1.0f); guRotateF(zRot, virtualEntity->rot.z, 0.0f, 0.0f, 1.0f);
guScaleF(scale, virtualEntity->scale.x, virtualEntity->scale.y, virtualEntity->scale.z); guScaleF(scale, virtualEntity->scale.x, virtualEntity->scale.y, virtualEntity->scale.z);
guMtxCatF(zRot, xRot, sp158); guMtxCatF(zRot, xRot, temp);
guMtxCatF(sp158, yRot, sp118); guMtxCatF(temp, yRot, rotation);
guMtxCatF(scale, sp118, sp158); guMtxCatF(scale, rotation, temp);
guMtxCatF(sp158, translation, sp198); guMtxCatF(temp, translation, transform);
guMtxF2L(sp198, &sp218); guMtxF2L(transform, &transformMtxL);
draw_entity_model_E(virtualEntity->entityModelIndex, &sp218); draw_entity_model_E(virtualEntity->entityModelIndex, &transformMtxL);
} }
} }
} }

View File

@ -310,7 +310,6 @@ void hud_element_draw_rect(HudElement* hudElement, s16 texSizeX, s16 texSizeY, s
baseY = tempY + 2; baseY = tempY + 2;
} }
flags1 = (hudElement->flags & HUD_ELEMENT_FLAGS_FMT_CI4); flags1 = (hudElement->flags & HUD_ELEMENT_FLAGS_FMT_CI4);
isFmtCI4 = flags1 != 0; isFmtCI4 = flags1 != 0;
flags1 = (hudElement->flags & HUD_ELEMENT_FLAGS_FMT_IA8); flags1 = (hudElement->flags & HUD_ELEMENT_FLAGS_FMT_IA8);
@ -320,8 +319,8 @@ void hud_element_draw_rect(HudElement* hudElement, s16 texSizeX, s16 texSizeY, s
flags2 = (hudElement->flags & HUD_ELEMENT_FLAGS_FLIPY); flags2 = (hudElement->flags & HUD_ELEMENT_FLAGS_FLIPY);
flipY = flags2 != 0; flipY = flags2 != 0;
fmt = 0; // stays the same if (isFmtCI4 == FALSE && isFmtIA8 == FALSE) fmt = 0;
if (isFmtCI4 == TRUE && isFmtIA8 == TRUE) { if (isFmtCI4 == FALSE && isFmtIA8 == FALSE) {
fmt = 0; // RGBA fmt = 0; // RGBA
} }
if (isFmtCI4 == TRUE && isFmtIA8 == FALSE) { if (isFmtCI4 == TRUE && isFmtIA8 == FALSE) {
@ -1512,9 +1511,9 @@ void render_hud_element(HudElement* hudElement) {
case 1: case 1:
if (hudElement->flags & HUD_ELEMENT_FLAGS_NO_FOLD) { if (hudElement->flags & HUD_ELEMENT_FLAGS_NO_FOLD) {
if (hudElement->flags & HUD_ELEMENT_FLAGS_TRANSPARENT) { if (hudElement->flags & HUD_ELEMENT_FLAGS_TRANSPARENT) {
fold_update(0, 7, 255, 255, 255, hudElement->opacity, 0); fold_update(0, FOLD_TYPE_7, 255, 255, 255, hudElement->opacity, 0);
} else { } else {
fold_update(0, 0, 0, 0, 0, 0, 0); fold_update(0, FOLD_TYPE_NONE, 0, 0, 0, 0, 0);
} }
} else { } else {
if (hudElement->flags & HUD_ELEMENT_FLAGS_TRANSPARENT) { if (hudElement->flags & HUD_ELEMENT_FLAGS_TRANSPARENT) {

View File

@ -271,7 +271,7 @@ void draw_merlee_message(void* data) {
messageID = D_80078168[popup->messageIndex]; messageID = D_80078168[popup->messageIndex];
width = get_msg_width(messageID, 0) + 30; width = get_msg_width(messageID, 0) + 30;
xPos = 160 - (width / 2); xPos = 160 - (width / 2);
set_window_properties(9, xPos, 80, width, D_80078160[get_msg_lines(messageID) - 1], 0, draw_merlee_message_string, popup, -1); set_window_properties(WINDOW_ID_9, xPos, 80, width, D_80078160[get_msg_lines(messageID) - 1], 0, draw_merlee_message_string, popup, -1);
set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW); set_window_update(WINDOW_ID_9, WINDOW_UPDATE_SHOW);
} }
} }

View File

@ -377,8 +377,8 @@ void func_802B6820_E256F0(void) {
} }
if (HammerHit->hitID < 0 && gPlayerData.hammerLevel >= 2) { if (HammerHit->hitID < 0 && gPlayerData.hammerLevel >= 2) {
D_8015A578.unk_00 = TRUE; gCurrentHiddenPanels.tryFlipTrigger = TRUE;
D_8015A578.unk_08 = playerStatus->position.y; gCurrentHiddenPanels.flipTriggerPosY = playerStatus->position.y;
} }
} }

View File

@ -26,22 +26,21 @@ void func_802B6000_E27510(void) {
void func_802B6060_E27570(void) { void func_802B6060_E27570(void) {
PlayerStatus* playerStatus = &gPlayerStatus; PlayerStatus* playerStatus = &gPlayerStatus;
CollisionStatus* collisionStatus; CollisionStatus* collisionStatus;
f32 sp50; f32 cosA;
f32 sp4C; f32 sinA;
s32 sp48; s32 hitID;
f32 sp44; f32 hitDirZ;
f32 sp40; f32 hitDirX;
f32 sp3C; f32 hitRy;
f32 sp38; f32 hitRx;
f32 sp34; f32 depth;
f32 sp30; f32 posZ;
f32 sp2C; f32 posY;
f32 sp28; f32 posX;
f32 tempCurrentSpeed; f32 tempCurrentSpeed;
u8 colliderTemp;
if (playerStatus->flags & (1 << 31)) { if (playerStatus->flags & PLAYER_STATUS_FLAGS_ACTION_STATE_CHANGED) {
playerStatus->flags &= ~0x80000000; playerStatus->flags &= ~PLAYER_STATUS_FLAGS_ACTION_STATE_CHANGED;
playerStatus->fallState = 0; playerStatus->fallState = 0;
playerStatus->currentSpeed = 0.0f; playerStatus->currentSpeed = 0.0f;
playerStatus->animFlags |= 4; playerStatus->animFlags |= 4;
@ -56,13 +55,13 @@ void func_802B6060_E27570(void) {
gCameras[CAM_DEFAULT].moveFlags |= CAMERA_MOVE_FLAGS_1; gCameras[CAM_DEFAULT].moveFlags |= CAMERA_MOVE_FLAGS_1;
} }
tempCurrentSpeed = playerStatus->currentSpeed; tempCurrentSpeed = playerStatus->currentSpeed;
sp28 = playerStatus->position.x; posX = playerStatus->position.x;
sp2C = playerStatus->position.y; posY = playerStatus->position.y;
sp30 = playerStatus->position.z; posZ = playerStatus->position.z;
sp48 = player_test_move_with_slipping(playerStatus, &sp28, &sp2C, &sp30, tempCurrentSpeed, playerStatus->heading); hitID = player_test_move_with_slipping(playerStatus, &posX, &posY, &posZ, tempCurrentSpeed, playerStatus->heading);
playerStatus->position.x = sp28; playerStatus->position.x = posX;
playerStatus->position.z = sp30; playerStatus->position.z = posZ;
playerStatus->position.y = sp2C; playerStatus->position.y = posY;
switch (playerStatus->fallState) { switch (playerStatus->fallState) {
case 0: case 0:
@ -74,20 +73,19 @@ void func_802B6060_E27570(void) {
if (D_802B6788 <= playerStatus->currentSpeed) { if (D_802B6788 <= playerStatus->currentSpeed) {
playerStatus->currentSpeed = D_802B6788; playerStatus->currentSpeed = D_802B6788;
} }
sp28 = playerStatus->position.x; posX = playerStatus->position.x;
sp34 = 100.0f; depth = 100.0f;
sp30 = playerStatus->position.z; posZ = playerStatus->position.z;
D_802B6794 = D_802B6798; D_802B6794 = D_802B6798;
sp2C = playerStatus->position.y + (playerStatus->colliderHeight * 0.5f); posY = playerStatus->position.y + (playerStatus->colliderHeight * 0.5f);
sp48 = player_raycast_below_cam_relative(playerStatus, &sp28, &sp2C, &sp30, &sp34, &sp38, &sp3C, &sp40, &sp44); hitID = player_raycast_below_cam_relative(playerStatus, &posX, &posY, &posZ, &depth, &hitRx, &hitRy, &hitDirX, &hitDirZ);
D_802B6798 = sp3C; D_802B6798 = hitRy;
if (sp48 >= 0) { if (hitID >= 0) {
collisionStatus = &gCollisionStatus; collisionStatus = &gCollisionStatus;
colliderTemp = get_collider_type_by_id(sp48); if ((u8)get_collider_type_by_id(hitID) == 5) {
if (colliderTemp == 5) { collisionStatus->currentFloor = hitID;
collisionStatus->currentFloor = sp48; playerStatus->position.y = posY;
playerStatus->position.y = sp2C; D_802B6790 = hitRy + 180.0f;
D_802B6790 = sp3C + 180.0f;
break; break;
} }
if (!(fabs(D_802B6794 - D_802B6798) >= 50.0)) { if (!(fabs(D_802B6794 - D_802B6798) >= 50.0)) {
@ -98,17 +96,17 @@ void func_802B6060_E27570(void) {
} else { } else {
playerStatus->fallState = 2; playerStatus->fallState = 2;
} }
sin_cos_rad((D_802B6790 * TAU) / 360.0f, &sp4C, &sp50); sin_cos_rad((D_802B6790 * TAU) / 360.0f, &sinA, &cosA);
playerStatus->position.y += fabsf((sp4C / sp50) * playerStatus->currentSpeed); playerStatus->position.y += fabsf((sinA / cosA) * playerStatus->currentSpeed);
snd_stop_sound(SOUND_167); snd_stop_sound(SOUND_167);
break; break;
case 1: case 1:
sp28 = playerStatus->position.x; posX = playerStatus->position.x;
sp34 = 50.0f; depth = 50.0f;
sp30 = playerStatus->position.z; posZ = playerStatus->position.z;
sp2C = playerStatus->position.y + (playerStatus->colliderHeight * 0.5f); posY = playerStatus->position.y + (playerStatus->colliderHeight * 0.5f);
sp48 = player_raycast_below_cam_relative(playerStatus, &sp28, &sp2C, &sp30, &sp34, &sp38, &sp3C, &sp40, &sp44); hitID = player_raycast_below_cam_relative(playerStatus, &posX, &posY, &posZ, &depth, &hitRx, &hitRy, &hitDirX, &hitDirZ);
if (sp48 >= 0) { if (hitID >= 0) {
tempCurrentSpeed = playerStatus->currentSpeed / 3.0f; tempCurrentSpeed = playerStatus->currentSpeed / 3.0f;
if (tempCurrentSpeed < 0.01) { if (tempCurrentSpeed < 0.01) {
playerStatus->currentSpeed = 0.0f; playerStatus->currentSpeed = 0.0f;
@ -120,7 +118,7 @@ void func_802B6060_E27570(void) {
playerStatus->fallState = 6; playerStatus->fallState = 6;
playerStatus->currentStateTime = 15; playerStatus->currentStateTime = 15;
playerStatus->currentSpeed = 0.0f; playerStatus->currentSpeed = 0.0f;
playerStatus->position.y = sp2C; playerStatus->position.y = posY;
} }
break; break;
} }
@ -144,8 +142,8 @@ void func_802B6060_E27570(void) {
if (playerStatus->currentSpeed <= 0.0f) { if (playerStatus->currentSpeed <= 0.0f) {
playerStatus->currentSpeed = 0.0f; playerStatus->currentSpeed = 0.0f;
} }
playerStatus->position.y = player_check_collision_below(func_800E34D8(), &sp48); playerStatus->position.y = player_check_collision_below(func_800E34D8(), &hitID);
if (sp48 >= 0) { if (hitID >= 0) {
D_802B678C = -1; D_802B678C = -1;
suggest_player_anim_setUnkFlag(0x80003); suggest_player_anim_setUnkFlag(0x80003);
sfx_play_sound_at_player(SOUND_162, 0); sfx_play_sound_at_player(SOUND_162, 0);

View File

@ -8,7 +8,7 @@ void func_802B6000_E26DE0(void) {
PlayerStatus* playerStatus = &gPlayerStatus; PlayerStatus* playerStatus = &gPlayerStatus;
CollisionStatus* collisionStatus = &gCollisionStatus; CollisionStatus* collisionStatus = &gCollisionStatus;
Entity* entity; Entity* entity;
Struct8015A578* tempStruct; HiddenPanelsData* panels;
s32 sp10; s32 sp10;
s32 tempCondition; s32 tempCondition;
f32 temp_f20; f32 temp_f20;
@ -97,19 +97,19 @@ void func_802B6000_E26DE0(void) {
entityType == ENTITY_TYPE_RED_SWITCH || entityType == ENTITY_TYPE_BLUE_SWITCH)) { entityType == ENTITY_TYPE_RED_SWITCH || entityType == ENTITY_TYPE_BLUE_SWITCH)) {
get_entity_by_index(collisionStatus->currentFloor)->collisionFlags |= ENTITY_COLLISION_PLAYER_TOUCH_FLOOR; get_entity_by_index(collisionStatus->currentFloor)->collisionFlags |= ENTITY_COLLISION_PLAYER_TOUCH_FLOOR;
playerStatus->fallState = 0xB; playerStatus->fallState = 0xB;
playerStatus->flags &= ~0x8; playerStatus->flags &= ~PLAYER_STATUS_FLAGS_FLYING;
break; break;
} else { } else {
colliderType = get_collider_type_by_id(sp10); colliderType = get_collider_type_by_id(sp10);
if (colliderType == 3) { if (colliderType == 3) {
playerStatus->unk_BF = 1; playerStatus->unk_BF = 1;
set_action_state(ACTION_STATE_HIT_LAVA); set_action_state(ACTION_STATE_HIT_LAVA);
playerStatus->flags |= 0x800; playerStatus->flags |= PLAYER_STATUS_FLAGS_800;
playerStatus->flags &= ~0x8; playerStatus->flags &= ~PLAYER_STATUS_FLAGS_FLYING;
return; return;
} else if (colliderType == 2) { } else if (colliderType == 2) {
set_action_state(ACTION_STATE_HIT_LAVA); set_action_state(ACTION_STATE_HIT_LAVA);
playerStatus->flags &= ~0x8; playerStatus->flags &= ~PLAYER_STATUS_FLAGS_FLYING;
return; return;
} else { } else {
playerStatus->gravityIntegrator[1] = -3.4744f; playerStatus->gravityIntegrator[1] = -3.4744f;
@ -125,10 +125,10 @@ void func_802B6000_E26DE0(void) {
exec_ShakeCam1(0, 0, 4); exec_ShakeCam1(0, 0, 4);
sfx_play_sound_at_player(SOUND_149, 0); sfx_play_sound_at_player(SOUND_149, 0);
start_rumble(0x80, 0x19); start_rumble(0x80, 0x19);
tempStruct = &D_8015A578; panels = &gCurrentHiddenPanels;
tempStruct->unk_00 = TRUE; panels->tryFlipTrigger = TRUE;
tempStruct->unk_08 = playerStatus->position.y; panels->flipTriggerPosY = playerStatus->position.y;
playerStatus->flags |= 0x400; playerStatus->flags |= PLAYER_STATUS_FLAGS_400;
} }
} }
} }

View File

@ -10,15 +10,15 @@ void func_802B6000_E26710(void) {
PlayerStatus* playerStatus = &gPlayerStatus; PlayerStatus* playerStatus = &gPlayerStatus;
CollisionStatus* collisionStatus = &gCollisionStatus; CollisionStatus* collisionStatus = &gCollisionStatus;
f32 temp_f0; f32 temp_f0;
f32 temp_f20; f32 fallVelocity;
u8 colliderType; u8 colliderType;
f32 phi_f4; f32 phi_f4;
s32 sp10; s32 colliderBelow;
u32 entityType; u32 entityType;
if (playerStatus->flags & PLAYER_STATUS_FLAGS_ACTION_STATE_CHANGED) { if (playerStatus->flags & PLAYER_STATUS_FLAGS_ACTION_STATE_CHANGED) {
playerStatus->flags &= ~PLAYER_STATUS_FLAGS_ACTION_STATE_CHANGED; playerStatus->flags &= ~PLAYER_STATUS_FLAGS_ACTION_STATE_CHANGED;
playerStatus->flags |= 0x2000A; playerStatus->flags |= (PLAYER_STATUS_FLAGS_20000 | PLAYER_STATUS_FLAGS_FLYING | PLAYER_STATUS_FLAGS_JUMPING);
phys_clear_spin_history(); phys_clear_spin_history();
playerStatus->fallState = 0; playerStatus->fallState = 0;
playerStatus->currentSpeed = 0.0f; playerStatus->currentSpeed = 0.0f;
@ -62,9 +62,9 @@ void func_802B6000_E26710(void) {
switch (playerStatus->fallState) { switch (playerStatus->fallState) {
case 0: case 0:
temp_f20 = integrate_gravity(); fallVelocity = integrate_gravity();
playerStatus->position.y = player_check_collision_below(temp_f20, &sp10); playerStatus->position.y = player_check_collision_below(fallVelocity, &colliderBelow);
if (sp10 >= 0 && collisionStatus->currentFloor & COLLISION_WITH_ENTITY_BIT ) { if (colliderBelow >= 0 && collisionStatus->currentFloor & COLLISION_WITH_ENTITY_BIT ) {
entityType = get_entity_type(collisionStatus->currentFloor); entityType = get_entity_type(collisionStatus->currentFloor);
if (entityType == ENTITY_TYPE_BLUE_SWITCH || entityType == ENTITY_TYPE_RED_SWITCH) { if (entityType == ENTITY_TYPE_BLUE_SWITCH || entityType == ENTITY_TYPE_RED_SWITCH) {
get_entity_by_index(collisionStatus->currentFloor)->collisionFlags |= ENTITY_COLLISION_PLAYER_TOUCH_FLOOR; get_entity_by_index(collisionStatus->currentFloor)->collisionFlags |= ENTITY_COLLISION_PLAYER_TOUCH_FLOOR;
@ -73,15 +73,15 @@ void func_802B6000_E26710(void) {
break; break;
} }
} }
if (temp_f20 <= 0.0f) { if (fallVelocity <= 0.0f) {
record_jump_apex(); record_jump_apex();
playerStatus->currentStateTime = 3; playerStatus->currentStateTime = 3;
playerStatus->flags |= 4; playerStatus->flags |= PLAYER_STATUS_FLAGS_FALLING;
playerStatus->fallState++; playerStatus->fallState++;
sfx_play_sound_at_player(SOUND_TORNADO_JUMP, 0); sfx_play_sound_at_player(SOUND_TORNADO_JUMP, 0);
} }
if (sp10 >= 0) { if (colliderBelow >= 0) {
playerStatus->flags &= ~0x00020008; playerStatus->flags &= ~(PLAYER_STATUS_FLAGS_20000 | PLAYER_STATUS_FLAGS_FLYING);
set_action_state(ACTION_STATE_LAND); set_action_state(ACTION_STATE_LAND);
} }
break; break;
@ -91,64 +91,64 @@ void func_802B6000_E26710(void) {
} }
break; break;
case 2: case 2:
temp_f20 = integrate_gravity(); fallVelocity = integrate_gravity();
playerStatus->position.y = player_check_collision_below(temp_f20, &sp10); playerStatus->position.y = player_check_collision_below(fallVelocity, &colliderBelow);
if (temp_f20 < -100.0f) { if (fallVelocity < -100.0f) {
playerStatus->gravityIntegrator[3] = 0.0f; playerStatus->gravityIntegrator[3] = 0.0f;
playerStatus->gravityIntegrator[2] = 0.0f; playerStatus->gravityIntegrator[2] = 0.0f;
playerStatus->gravityIntegrator[1] = 0.0f; playerStatus->gravityIntegrator[1] = 0.0f;
playerStatus->gravityIntegrator[0] = -100.0f; playerStatus->gravityIntegrator[0] = -100.0f;
} }
if (sp10 >= 0) { if (colliderBelow >= 0) {
if (collisionStatus->currentFloor & COLLISION_WITH_ENTITY_BIT) { if (collisionStatus->currentFloor & COLLISION_WITH_ENTITY_BIT) {
entityType = get_entity_type(collisionStatus->currentFloor); entityType = get_entity_type(collisionStatus->currentFloor);
if (entityType == ENTITY_TYPE_SIMPLE_SPRING || entityType == ENTITY_TYPE_SCRIPT_SPRING) { if (entityType == ENTITY_TYPE_SIMPLE_SPRING || entityType == ENTITY_TYPE_SCRIPT_SPRING) {
playerStatus->flags &= ~0x00020008; playerStatus->flags &= ~(PLAYER_STATUS_FLAGS_20000 | PLAYER_STATUS_FLAGS_FLYING);
set_action_state(ACTION_STATE_LAND); set_action_state(ACTION_STATE_LAND);
return; return;
} else if (entityType == ENTITY_TYPE_BLUE_SWITCH || entityType == ENTITY_TYPE_RED_SWITCH) { } else if (entityType == ENTITY_TYPE_BLUE_SWITCH || entityType == ENTITY_TYPE_RED_SWITCH) {
playerStatus->flags &= ~0x00020008; playerStatus->flags &= ~(PLAYER_STATUS_FLAGS_20000 | PLAYER_STATUS_FLAGS_FLYING);
phys_player_land(); phys_player_land();
exec_ShakeCam1(0, 0, 4); exec_ShakeCam1(0, 0, 4);
sfx_play_sound_at_player(SOUND_14A, 0); sfx_play_sound_at_player(SOUND_14A, 0);
start_rumble(0x100, 0x32); start_rumble(256, 50);
D_8015A578.unk_00 = TRUE; gCurrentHiddenPanels.tryFlipTrigger = TRUE;
D_8015A578.unk_08 = playerStatus->position.y; gCurrentHiddenPanels.flipTriggerPosY = playerStatus->position.y;
playerStatus->flags |= 0x400; playerStatus->flags |= PLAYER_STATUS_FLAGS_400;
return; return;
} }
} }
colliderType = get_collider_type_by_id(sp10); colliderType = get_collider_type_by_id(colliderBelow);
if (colliderType == 3) { if (colliderType == 3) {
playerStatus->unk_BF = 1; playerStatus->unk_BF = 1;
playerStatus->flags &= ~0x00020008; playerStatus->flags &= ~(PLAYER_STATUS_FLAGS_20000 | PLAYER_STATUS_FLAGS_FLYING);
set_action_state(ACTION_STATE_HIT_LAVA); set_action_state(ACTION_STATE_HIT_LAVA);
playerStatus->flags |= 0x800; playerStatus->flags |= PLAYER_STATUS_FLAGS_800;
return; return;
} else if (colliderType == 2) { } else if (colliderType == 2) {
set_action_state(ACTION_STATE_HIT_LAVA); set_action_state(ACTION_STATE_HIT_LAVA);
playerStatus->flags &= ~0x00020008; playerStatus->flags &= ~(PLAYER_STATUS_FLAGS_20000 | PLAYER_STATUS_FLAGS_FLYING);
return; return;
} }
playerStatus->currentStateTime = 8; playerStatus->currentStateTime = 8;
playerStatus->timeInAir = 0; playerStatus->timeInAir = 0;
playerStatus->actionState = 0x10; playerStatus->actionState = ACTION_STATE_ULTRA_POUND;
playerStatus->fallState++; playerStatus->fallState++;
exec_ShakeCam1(0, 0, 4); exec_ShakeCam1(0, 0, 4);
sfx_play_sound_at_player(SOUND_14A, 0); sfx_play_sound_at_player(SOUND_14A, 0);
start_rumble(0x100, 0x32); start_rumble(256, 50);
D_8015A578.unk_00 = TRUE; gCurrentHiddenPanels.tryFlipTrigger = TRUE;
D_8015A578.unk_08 = playerStatus->position.y; gCurrentHiddenPanels.flipTriggerPosY = playerStatus->position.y;
playerStatus->flags |= 0x400; playerStatus->flags |= PLAYER_STATUS_FLAGS_400;
} }
break; break;
case 3: case 3:
if (--playerStatus->currentStateTime == 0) { if (--playerStatus->currentStateTime == 0) {
playerStatus->fallState++; playerStatus->fallState++;
playerStatus->flags &= ~0x00020008; playerStatus->flags &= ~(PLAYER_STATUS_FLAGS_20000 | PLAYER_STATUS_FLAGS_FLYING);
set_action_state(ACTION_STATE_LAND); set_action_state(ACTION_STATE_LAND);
} }
break; break;
@ -162,10 +162,10 @@ void func_802B6000_E26710(void) {
} }
if (playerStatus->gravityIntegrator[0] < 0.0f) { if (playerStatus->gravityIntegrator[0] < 0.0f) {
sp10 = func_802B65F8_E26D08(); colliderBelow = func_802B65F8_E26D08();
if (sp10 >= 0) { if (colliderBelow >= 0) {
collisionStatus->lastTouchedFloor = -1; collisionStatus->lastTouchedFloor = -1;
collisionStatus->currentFloor = sp10; collisionStatus->currentFloor = colliderBelow;
} }
} }
} }

View File

@ -1,94 +1,295 @@
#include "end_00.h" #include "end_00.h"
typedef struct End18 {
/* 0x00 */ s32 initialAnim;
/* 0x04 */ s32** animList;
/* 0x08 */ Vec3f pos;
/* 0x14 */ f32 yaw;
} End18; // size = 0x18
extern s32 spr_allocateBtlComponentsOnWorldHeap; extern s32 spr_allocateBtlComponentsOnWorldHeap;
extern End18 D_80244D74_DFB774[]; extern ParadeNpcInfo N(ParadeNpcsTable)[];
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80240020_DF6A20); extern CreditsUnkBeta N(Font4Patterns)[16];
extern CreditsUnkBeta N(Font3Patterns)[16];
extern Vp N(CreditsViewport);
extern s32 N(CreditsBufferIndex);
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80240270_DF6C70); // start of BSS:
extern CreditsData N(CreditsData);
extern CreditsData* N(CreditsDataPtr);
extern u8 N(CreditsMessageBuffers)[23][256];
extern Mtx N(CreditsProjMatrices)[2];
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80240540_DF6F40); s32 msg_get_print_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u8 flags);
void dma_load_msg(u32 msgID, void* dest);
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_8024081C_DF721C); #include "world/common/atomic/Credits_1.inc.c"
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80240AE8_DF74E8); void N(credits_update_line)(CreditsLine* line) {
CreditsChar creditsChar;
CreditsChar* curChar = &creditsChar;
CreditsUnkBeta* curPattern;
s32 msgHeight, msgWidth, msgMaxLineChars;
s32 doneCurrentState;
s32 readPos;
u8 curMsgChar;
u16 nextMsgChar1, nextMsgChar2;
u16 doneCalcLoop, doneDrawLoop;
s32 drawCount;
s32 posX;
s32 i;
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80240EB0_DF78B0); doneCurrentState = FALSE;
if (line->flags & CREDITS_LINE_FLAG_2) {
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80240FEC_DF79EC); line->flags &= ~CREDITS_LINE_FLAG_2;
line->time = 0;
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_802411CC_DF7BCC); line->state = 0;
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80241294_DF7C94);
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_802414CC_DF7ECC);
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80241768_DF8168);
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_802419F8_DF83F8);
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80241B34_DF8534);
static char* N(exit_str_0) = "end_01";
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_802421D8_DF8BD8);
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80242358_DF8D58);
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80242500_DF8F00);
ApiStatus func_80242558_DF8F58(Evt* script, s32 isInitialCall) {
func_80242500_DF8F00();
load_font(1);
return ApiStatus_DONE2;
} }
INCLUDE_ASM(s32, "world/area_end/end_00/DF6A20", func_80242580_DF8F80); get_msg_properties(line->message, &msgHeight, &msgWidth, &msgMaxLineChars, NULL, NULL, NULL, 0);
curChar->font = 0;
curChar->variation = 0;
// calculate message width
msgWidth = 1;
readPos = 0;
do {
curMsgChar = line->message[readPos++];
nextMsgChar1 = line->message[readPos];
doneCalcLoop = FALSE;
switch (curMsgChar) {
case MSG_CHAR_READ_VARIANT0:
case MSG_CHAR_READ_VARIANT1:
case MSG_CHAR_READ_VARIANT2:
curChar->variation = curMsgChar - MSG_CHAR_READ_VARIANT0;
break;
case MSG_CHAR_READ_ENDL:
case MSG_CHAR_READ_END:
doneCalcLoop = TRUE;
break;
case MSG_CHAR_READ_FUNCTION:
// only support function for selecting font
if (line->message[readPos++] == MSG_READ_FUNC_FONT) {
curChar->font = line->message[readPos++];
}
break;
default:
msgWidth += msg_get_print_char_width(curMsgChar, curChar->font, curChar->variation, 1.0f, 0, 1) - 1;
if (curChar->font == MSG_FONT_TITLE || curChar->font == MSG_FONT_SUBTITLE) {
curPattern = N(Font3Patterns);
if (curChar->font == MSG_FONT_SUBTITLE) {
curPattern = N(Font4Patterns);
}
i = 0;
if (curChar->font == MSG_FONT_SUBTITLE) {
if (curMsgChar == MSG_CHAR_LPAREN || nextMsgChar1 == MSG_CHAR_LPAREN) {
msgWidth++;
}
}
do {
if (curMsgChar == curPattern[i].unk_00 && nextMsgChar1 == curPattern[i].unk_01) {
msgWidth += curPattern[i].size;
}
i++;
} while (curPattern[i].size != 0);
}
break;
}
} while (!doneCalcLoop);
line->msgWidth = msgWidth;
if (line->flags & CREDITS_LINE_FLAG_1) {
posX = line->posX - (((f32) msgWidth * 0.5) + 0.0);
} else {
posX = line->posX;
}
curChar->font = 0;
curChar->variation = 0;
curChar->palette = line->palette;
drawCount = 0;
readPos = 0;
do {
curMsgChar = line->message[readPos++];
nextMsgChar2 = line->message[readPos];
doneDrawLoop = FALSE;
switch (curMsgChar) {
case MSG_CHAR_READ_VARIANT0:
case MSG_CHAR_READ_VARIANT1:
case MSG_CHAR_READ_VARIANT2:
curChar->variation = curMsgChar - MSG_CHAR_READ_VARIANT0;
break;
case MSG_CHAR_READ_ENDL:
case MSG_CHAR_READ_END:
doneDrawLoop = TRUE;
break;
case MSG_CHAR_READ_FUNCTION:
if (line->message[readPos++] == 0) {
curChar->font = line->message[readPos++];
}
break;
default:
if (curMsgChar < MSG_CHAR_READ_ENDL) {
curChar->charIndex = curMsgChar;
curChar->posX = posX;
curChar->posY = line->posY;
switch (line->state) {
case CREDITS_LINE_APPEARING:
curChar->fadeInTime = line->time - (line->perCharDelayIn * drawCount);
if (curChar->fadeInTime >= 0) {
if (line->appearTime < curChar->fadeInTime) {
curChar->fadeInTime = line->appearTime;
}
if ((nextMsgChar2 == MSG_CHAR_READ_END) && (curChar->fadeInTime == line->appearTime)) {
doneCurrentState = TRUE;
}
switch (line->appearMode) {
case 0:
N(CharAnim_FadeIn_5)(line, curChar);
break;
case 1:
N(CharAnim_FadeIn_1)(line, curChar);
break;
case 2:
N(CharAnim_FadeIn_2)(line, curChar);
break;
case 3:
N(CharAnim_FadeIn_3)(line, curChar);
break;
case 4:
N(CharAnim_FadeIn_4)(line, curChar);
break;
case 5:
N(CharAnim_FadeIn_5)(line, curChar);
break;
}
}
break;
case CREDITS_LINE_HOLDING:
if (nextMsgChar2 == MSG_CHAR_READ_END) {
if (line->time == line->holdTime) {
doneCurrentState = TRUE;
}
}
N(CharAnim_Hold)(line, curChar);
break;
case CREDITS_LINE_VANISHING:
curChar->fadeInTime = line->time - (line->perCharDelayOut * drawCount);
if (curChar->fadeInTime < 0) {
curChar->fadeInTime = 0;
}
if (curChar->fadeInTime > line->vanishTime) {
curChar->fadeInTime = line->vanishTime;
}
if (nextMsgChar2 == MSG_CHAR_READ_END && curChar->fadeInTime == line->vanishTime) {
doneCurrentState = TRUE;
}
switch (line->vanishMode) {
case 0:
N(CharAnim_FadeOut_3)(line, curChar);
break;
case 1:
N(CharAnim_FadeOut_1)(line, curChar);
break;
case 2:
N(CharAnim_FadeOut_2)(line, curChar);
break;
case 3:
N(CharAnim_FadeOut_3)(line, curChar);
break;
}
break;
}
drawCount++;
}
posX += msg_get_print_char_width(curMsgChar, curChar->font, curChar->variation, 1.0f, 0, 1) - 1;
if (curChar->font == MSG_FONT_TITLE || curChar->font == MSG_FONT_SUBTITLE) {
curPattern = N(Font3Patterns);
if (curChar->font == MSG_FONT_SUBTITLE) {
curPattern = N(Font4Patterns);
}
i = 0;
if (curChar->font == MSG_FONT_SUBTITLE) {
if (curMsgChar == MSG_CHAR_LPAREN || nextMsgChar2 == MSG_CHAR_LPAREN) {
posX++;
}
}
do {
if (curMsgChar == curPattern[i].unk_00 && nextMsgChar2 == curPattern[i].unk_01) {
posX += curPattern[i].size;
}
i++;
} while (curPattern[i].size != 0);
}
break;
}
} while (!doneDrawLoop);
if ((line->state == CREDITS_LINE_APPEARING) && doneCurrentState) {
s32 temp = 0;
get_msg_properties(line->message, NULL, NULL, &temp, NULL, NULL, NULL, 0);
line->time = 0;
line->state++;
if (line->holdTime <= 0) {
line->state++;
}
} else if ((line->state == CREDITS_LINE_HOLDING) && doneCurrentState) {
line->time = 0;
line->state++;
} else if ((line->state == CREDITS_LINE_VANISHING) && doneCurrentState) {
line->flags &= ~CREDITS_LINE_FLAG_1;
}
line->time++;
}
#include "world/common/atomic/Credits_2.inc.c"
ApiStatus func_80242680_DF9080(Evt* script, s32 isInitialCall) { ApiStatus func_80242680_DF9080(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 npcID = evt_get_variable(script, *args++); s32 npcID = evt_get_variable(script, *args++);
End18* end18 = &D_80244D74_DFB774[npcID]; ParadeNpcInfo* npcInfo = &N(ParadeNpcsTable)[npcID];
NpcBlueprint bp; NpcBlueprint bp;
Npc* npc; Npc* npc;
bp.flags = 0x100; bp.flags = NPC_FLAG_100;
bp.initialAnim = end18->initialAnim; bp.initialAnim = npcInfo->initialAnim;
bp.onUpdate = NULL; bp.onUpdate = NULL;
bp.onRender = NULL; bp.onRender = NULL;
spr_allocateBtlComponentsOnWorldHeap = TRUE; spr_allocateBtlComponentsOnWorldHeap = TRUE;
npc = get_npc_by_index(_create_npc_standard(&bp, end18->animList)); npc = get_npc_by_index(_create_npc_standard(&bp, npcInfo->animList));
npc->npcID = npcID; npc->npcID = npcID;
npc->flags &= ~NPC_FLAG_PARTICLE; npc->flags &= ~NPC_FLAG_PARTICLE;
npc->pos.x = end18->pos.x; npc->pos.x = npcInfo->pos.x;
npc->pos.y = end18->pos.y; npc->pos.y = npcInfo->pos.y;
npc->pos.z = end18->pos.z; npc->pos.z = npcInfo->pos.z;
set_npc_yaw(npc, end18->yaw); set_npc_yaw(npc, npcInfo->yaw);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_80242744_DF9144(Evt* script, s32 isInitialCall) { ApiStatus func_80242744_DF9144(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 var1 = evt_get_variable(script, *args++); s32 heapSize = evt_get_variable(script, *args++);
s32 a1 = *args++; s32 outVar = *args++;
evt_set_variable(script, a1, _heap_malloc(&gSpriteHeapPtr, var1)); evt_set_variable(script, outVar, _heap_malloc(&gSpriteHeapPtr, heapSize));
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_802427A4_DF91A4(Evt* script, s32 isInitialCall) { ApiStatus func_802427A4_DF91A4(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
s32 pointer = *args++;
_heap_free(&gSpriteHeapPtr, evt_get_variable(script, *args++)); _heap_free(&gSpriteHeapPtr, evt_get_variable(script, pointer));
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
@ -111,7 +312,7 @@ ApiStatus N(SetNpcShadowScale)(Evt* script, s32 isInitialCall) {
ApiStatus func_80242898_DF9298(Evt* script, s32 isInitialCall) { ApiStatus func_80242898_DF9298(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
Npc** npc = (Npc**)&script->functionTemp[1]; Npc** npc = (Npc**)&script->functionTempPtr[1];
if (isInitialCall) { if (isInitialCall) {
*npc = get_npc_unsafe(evt_get_variable(script, *args++)); *npc = get_npc_unsafe(evt_get_variable(script, *args++));
@ -121,3 +322,5 @@ ApiStatus func_80242898_DF9298(Evt* script, s32 isInitialCall) {
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
} }
static char* N(exit_str_0) = "end_01";

View File

@ -1,3 +1,11 @@
#include "end_00.h" #include "end_00.h"
#ifdef NON_MATCHING
ApiStatus func_80242AD4_DF94D4(Evt *script, s32 isInitialCall) {
D_80249D60_E00760 = evt_get_variable(script, *script->ptrReadPos);
return ApiStatus_DONE2;
}
#else
INCLUDE_ASM(s32, "world/area_end/end_00/DF9510", func_80242B10_DF9510); INCLUDE_ASM(s32, "world/area_end/end_00/DF9510", func_80242B10_DF9510);
#endif

View File

@ -1,51 +1,327 @@
#include "end_01.h" #include "end_01.h"
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80240030_E05390); extern s32 spr_allocateBtlComponentsOnWorldHeap;
extern ParadeNpcInfo N(ParadeNpcsTable)[];
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80240280_E055E0); extern CreditsUnkBeta N(Font4Patterns)[16];
extern CreditsUnkBeta N(Font3Patterns)[16];
extern Vp N(CreditsViewport);
extern s32 N(CreditsBufferIndex);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80240550_E058B0); // start of BSS:
extern CreditsData N(CreditsData);
extern CreditsData* N(CreditsDataPtr);
extern u8 N(CreditsMessageBuffers)[23][256];
extern Mtx N(CreditsProjMatrices)[2];
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_8024082C_E05B8C); s32 msg_get_print_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u8 flags);
void dma_load_msg(u32 msgID, void* dest);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80240AF8_E05E58); #include "world/common/atomic/Credits_1.inc.c"
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80240EC0_E06220); // same as end_00_credits_update_line, but Font3Patterns and Font4Patterns are swapped...
// might be able to fix this when data for this map is done?
void N(credits_update_line)(CreditsLine* line) {
CreditsChar creditsChar;
CreditsChar* curChar = &creditsChar;
CreditsUnkBeta* curPattern;
s32 msgHeight, msgWidth, msgMaxLineChars;
s32 doneCurrentState;
s32 readPos;
u8 curMsgChar;
u16 nextMsgChar1, nextMsgChar2;
u16 doneCalcLoop, doneDrawLoop;
s32 drawCount;
s32 posX;
s32 i;
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80240FFC_E0635C); doneCurrentState = FALSE;
if (line->flags & CREDITS_LINE_FLAG_2) {
line->flags &= ~CREDITS_LINE_FLAG_2;
line->time = 0;
line->state = 0;
}
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_802411DC_E0653C); get_msg_properties(line->message, &msgHeight, &msgWidth, &msgMaxLineChars, NULL, NULL, NULL, 0);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_802412A4_E06604); curChar->font = 0;
curChar->variation = 0;
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_802414DC_E0683C); // calculate message width
msgWidth = 1;
readPos = 0;
do {
curMsgChar = line->message[readPos++];
nextMsgChar1 = line->message[readPos];
doneCalcLoop = FALSE;
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80241778_E06AD8); switch (curMsgChar) {
case MSG_CHAR_READ_VARIANT0:
case MSG_CHAR_READ_VARIANT1:
case MSG_CHAR_READ_VARIANT2:
curChar->variation = curMsgChar - MSG_CHAR_READ_VARIANT0;
break;
case MSG_CHAR_READ_ENDL:
case MSG_CHAR_READ_END:
doneCalcLoop = TRUE;
break;
case MSG_CHAR_READ_FUNCTION:
// only support function for selecting font
if (line->message[readPos++] == MSG_READ_FUNC_FONT) {
curChar->font = line->message[readPos++];
}
break;
default:
msgWidth += msg_get_print_char_width(curMsgChar, curChar->font, curChar->variation, 1.0f, 0, 1) - 1;
if (curChar->font == MSG_FONT_TITLE || curChar->font == MSG_FONT_SUBTITLE) {
curPattern = N(Font4Patterns);
if (curChar->font == MSG_FONT_SUBTITLE) {
curPattern = N(Font3Patterns);
}
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80241A08_E06D68); i = 0;
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80241B44_E06EA4); if (curChar->font == MSG_FONT_SUBTITLE) {
if (curMsgChar == MSG_CHAR_LPAREN || nextMsgChar1 == MSG_CHAR_LPAREN) {
msgWidth++;
}
}
do {
if (curMsgChar == curPattern[i].unk_00 && nextMsgChar1 == curPattern[i].unk_01) {
msgWidth += curPattern[i].size;
}
i++;
} while (curPattern[i].size != 0);
}
break;
}
} while (!doneCalcLoop);
line->msgWidth = msgWidth;
if (line->flags & CREDITS_LINE_FLAG_1) {
posX = line->posX - (((f32) msgWidth * 0.5) + 0.0);
} else {
posX = line->posX;
}
curChar->font = 0;
curChar->variation = 0;
curChar->palette = line->palette;
drawCount = 0;
readPos = 0;
do {
curMsgChar = line->message[readPos++];
nextMsgChar2 = line->message[readPos];
doneDrawLoop = FALSE;
switch (curMsgChar) {
case MSG_CHAR_READ_VARIANT0:
case MSG_CHAR_READ_VARIANT1:
case MSG_CHAR_READ_VARIANT2:
curChar->variation = curMsgChar - MSG_CHAR_READ_VARIANT0;
break;
case MSG_CHAR_READ_ENDL:
case MSG_CHAR_READ_END:
doneDrawLoop = TRUE;
break;
case MSG_CHAR_READ_FUNCTION:
if (line->message[readPos++] == 0) {
curChar->font = line->message[readPos++];
}
break;
default:
if (curMsgChar < MSG_CHAR_READ_ENDL) {
curChar->charIndex = curMsgChar;
curChar->posX = posX;
curChar->posY = line->posY;
switch (line->state) {
case CREDITS_LINE_APPEARING:
curChar->fadeInTime = line->time - (line->perCharDelayIn * drawCount);
if (curChar->fadeInTime >= 0) {
if (line->appearTime < curChar->fadeInTime) {
curChar->fadeInTime = line->appearTime;
}
if ((nextMsgChar2 == MSG_CHAR_READ_END) && (curChar->fadeInTime == line->appearTime)) {
doneCurrentState = TRUE;
}
switch (line->appearMode) {
case 0:
N(CharAnim_FadeIn_5)(line, curChar);
break;
case 1:
N(CharAnim_FadeIn_1)(line, curChar);
break;
case 2:
N(CharAnim_FadeIn_2)(line, curChar);
break;
case 3:
N(CharAnim_FadeIn_3)(line, curChar);
break;
case 4:
N(CharAnim_FadeIn_4)(line, curChar);
break;
case 5:
N(CharAnim_FadeIn_5)(line, curChar);
break;
}
}
break;
case CREDITS_LINE_HOLDING:
if (nextMsgChar2 == MSG_CHAR_READ_END) {
if (line->time == line->holdTime) {
doneCurrentState = TRUE;
}
}
N(CharAnim_Hold)(line, curChar);
break;
case CREDITS_LINE_VANISHING:
curChar->fadeInTime = line->time - (line->perCharDelayOut * drawCount);
if (curChar->fadeInTime < 0) {
curChar->fadeInTime = 0;
}
if (curChar->fadeInTime > line->vanishTime) {
curChar->fadeInTime = line->vanishTime;
}
if (nextMsgChar2 == MSG_CHAR_READ_END && curChar->fadeInTime == line->vanishTime) {
doneCurrentState = TRUE;
}
switch (line->vanishMode) {
case 0:
N(CharAnim_FadeOut_3)(line, curChar);
break;
case 1:
N(CharAnim_FadeOut_1)(line, curChar);
break;
case 2:
N(CharAnim_FadeOut_2)(line, curChar);
break;
case 3:
N(CharAnim_FadeOut_3)(line, curChar);
break;
}
break;
}
drawCount++;
}
posX += msg_get_print_char_width(curMsgChar, curChar->font, curChar->variation, 1.0f, 0, 1) - 1;
if (curChar->font == MSG_FONT_TITLE || curChar->font == MSG_FONT_SUBTITLE) {
curPattern = N(Font4Patterns);
if (curChar->font == MSG_FONT_SUBTITLE) {
curPattern = N(Font3Patterns);
}
i = 0;
if (curChar->font == MSG_FONT_SUBTITLE) {
if (curMsgChar == MSG_CHAR_LPAREN || nextMsgChar2 == MSG_CHAR_LPAREN) {
posX++;
}
}
do {
if (curMsgChar == curPattern[i].unk_00 && nextMsgChar2 == curPattern[i].unk_01) {
posX += curPattern[i].size;
}
i++;
} while (curPattern[i].size != 0);
}
break;
}
} while (!doneDrawLoop);
if ((line->state == CREDITS_LINE_APPEARING) && doneCurrentState) {
s32 temp = 0;
get_msg_properties(line->message, NULL, NULL, &temp, NULL, NULL, NULL, 0);
line->time = 0;
line->state++;
if (line->holdTime <= 0) {
line->state++;
}
} else if ((line->state == CREDITS_LINE_HOLDING) && doneCurrentState) {
line->time = 0;
line->state++;
} else if ((line->state == CREDITS_LINE_VANISHING) && doneCurrentState) {
line->flags &= ~CREDITS_LINE_FLAG_1;
}
line->time++;
}
#include "world/common/atomic/Credits_2.inc.c"
ApiStatus func_80242690_E079F0(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 npcID = evt_get_variable(script, *args++);
ParadeNpcInfo* npcInfo = &N(ParadeNpcsTable)[npcID];
NpcBlueprint bp;
Npc* npc;
bp.flags = NPC_FLAG_100;
bp.initialAnim = npcInfo->initialAnim;
bp.onUpdate = NULL;
bp.onRender = NULL;
spr_allocateBtlComponentsOnWorldHeap = TRUE;
npc = get_npc_by_index(_create_npc_standard(&bp, npcInfo->animList));
npc->npcID = npcID;
npc->flags &= ~NPC_FLAG_PARTICLE;
npc->pos.x = npcInfo->pos.x;
npc->pos.y = npcInfo->pos.y;
npc->pos.z = npcInfo->pos.z;
set_npc_yaw(npc, npcInfo->yaw);
return ApiStatus_DONE2;
}
ApiStatus func_80242754_E07AB4(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 heapSize = evt_get_variable(script, *args++);
s32 outVar = *args++;
evt_set_variable(script, outVar, _heap_malloc(&gSpriteHeapPtr, heapSize));
return ApiStatus_DONE2;
}
ApiStatus func_802427B4_E07B14(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 pointer = *args++;
_heap_free(&gSpriteHeapPtr, evt_get_variable(script, pointer));
return ApiStatus_DONE2;
}
ApiStatus func_802427E8_E07B48(Evt* script, s32 isInitialCall) {
Camera* camera = &gCameras[gCurrentCameraID];
camera->unk_506 = 1;
camera->movePos.x += 0.6666667f;
return ApiStatus_DONE2;
}
ApiStatus func_80242840_E07BA0(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
Npc** npc = (Npc**)&script->functionTempPtr[1];
if (isInitialCall) {
*npc = get_npc_unsafe(evt_get_variable(script, *args++));
}
(*npc)->pos.x += 0.6666667f;
return ApiStatus_BLOCK;
}
ApiStatus func_8024289C_E07BFC(Evt* script, s32 isInitialCall) {
if (gGameStatusPtr->pressedButtons[0] & (BUTTON_A | BUTTON_START)) {
return ApiStatus_DONE2;
} else {
return ApiStatus_BLOCK;
}
}
static char* N(exit_str_0) = "kmr_30"; static char* N(exit_str_0) = "kmr_30";
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_802421E8_E07548);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80242368_E076C8);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80242510_E07870);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80242568_E078C8);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80242590_E078F0);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80242690_E079F0);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80242754_E07AB4);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_802427B4_E07B14);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_802427E8_E07B48);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_80242840_E07BA0);
INCLUDE_ASM(s32, "world/area_end/end_01/E05390", func_8024289C_E07BFC);

View File

@ -1,6 +1,8 @@
#include "hos_05.h" #include "hos_05.h"
void set_model_fog_color_parameters(u8 var2, u8 var3, u8 var4, u8 var5, u8 var6, u8 var7, u8 var8, s32 var9, s32 var10); void set_model_fog_color_parameters(u8 var2, u8 var3, u8 var4, u8 var5, u8 var6, u8 var7, u8 var8, s32 var9, s32 var10);
void set_model_env_color_parameters(u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB);
void get_model_env_color_parameters(u8* primR, u8* primG, u8* primB, u8* envR, u8* envG, u8* envB);
ApiStatus func_80240880_A2AAC0(Evt* script, s32 isInitialCall) { ApiStatus func_80240880_A2AAC0(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
@ -18,7 +20,48 @@ ApiStatus func_80240880_A2AAC0(Evt* script, s32 isInitialCall) {
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
INCLUDE_ASM(s32, "world/area_hos/hos_05/A2AAC0", func_802409C4_A2AC04); ApiStatus func_802409C4_A2AC04(Evt* script, s32 isInitialCall) {
Bytecode* args;
static u8 oldPrimR, oldPrimG, oldPrimB;
static u8 oldEnvR, oldEnvG, oldEnvB;
static s32 newPrimR, newPrimG, newPrimB;
static s32 newEnvR, newEnvG, newEnvB;
static s32 duration, time;
args = script->ptrReadPos;
if (isInitialCall) {
get_model_env_color_parameters(&oldPrimR, &oldPrimG, &oldPrimB, &oldEnvR, &oldEnvG, &oldEnvB);
newPrimR = evt_get_variable(script, *args++);
newPrimG = evt_get_variable(script, *args++);
newPrimB = evt_get_variable(script, *args++);
newEnvR = evt_get_variable(script, *args++);
newEnvG = evt_get_variable(script, *args++);
newEnvB = evt_get_variable(script, *args++);
duration = evt_get_variable(script, *args++);
time = 0;
}
if (duration > 0) {
if(time >= duration) {
return ApiStatus_DONE2;
}
time++;
set_model_env_color_parameters(
(oldPrimR + ((newPrimR - oldPrimR) * time) / duration),
(oldPrimG + ((newPrimG - oldPrimG) * time) / duration),
(oldPrimB + ((newPrimB - oldPrimB) * time) / duration),
(oldEnvR + ( (newEnvR - oldEnvR) * time) / duration),
(oldEnvG + ( (newEnvG - oldEnvG) * time) / duration),
(oldEnvB + ( (newEnvB - oldEnvB) * time) / duration));
if (time >= duration) {
return ApiStatus_DONE2;
}
} else {
set_model_env_color_parameters(newPrimR, newPrimG, newPrimB, newEnvR, newEnvG, newEnvB);
return ApiStatus_DONE2;
}
return ApiStatus_BLOCK;
}
void func_80240D54_A2AF94(s32 camID, f32 fov) { void func_80240D54_A2AF94(s32 camID, f32 fov) {
Camera* camera = &gCameras[camID]; Camera* camera = &gCameras[camID];

View File

@ -2,6 +2,11 @@
INCLUDE_ASM(s32, "world/area_hos/hos_05/A2EC30", func_802449F0_A2EC30); INCLUDE_ASM(s32, "world/area_hos/hos_05/A2EC30", func_802449F0_A2EC30);
INCLUDE_ASM(s32, "world/area_hos/hos_05/A2EC30", func_80244C60_A2EEA0); ApiStatus func_80244C60_A2EEA0(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
void (*callback)(void) = (void (*)(void))evt_get_variable(script, *args++);
set_curtain_draw_callback(callback);
return ApiStatus_DONE2;
}
INCLUDE_ASM(s32, "world/area_hos/hos_05/A2EC30", func_80244C8C_A2EECC); INCLUDE_ASM(s32, "world/area_hos/hos_05/A2EC30", func_80244C8C_A2EECC);

View File

@ -11,7 +11,53 @@ extern u8 D_802D9D73;
#define NAMESPACE hos_05 #define NAMESPACE hos_05
// should match when preceding bss is worked out
#ifdef NON_MATCHING
void set_model_env_color_parameters(u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB);
void get_model_env_color_parameters(u8* primR, u8* primG, u8* primB, u8* envR, u8* envG, u8* envB);
ApiStatus func_802452C4_A2F504(Evt* script, s32 isInitialCall) {
Bytecode* args;
static u8 oldPrimR, oldPrimG, oldPrimB;
static u8 oldEnvR, oldEnvG, oldEnvB;
static s32 newPrimR, newPrimG, newPrimB;
static s32 newEnvR, newEnvG, newEnvB;
static s32 duration, time;
args = script->ptrReadPos;
if (isInitialCall) {
get_model_env_color_parameters(&oldPrimR, &oldPrimG, &oldPrimB, &oldEnvR, &oldEnvG, &oldEnvB);
newPrimR = evt_get_variable(script, *args++);
newPrimG = evt_get_variable(script, *args++);
newPrimB = evt_get_variable(script, *args++);
newEnvR = evt_get_variable(script, *args++);
newEnvG = evt_get_variable(script, *args++);
newEnvB = evt_get_variable(script, *args++);
duration = evt_get_variable(script, *args++);
time = 0;
}
if (duration > 0) {
time++;
set_model_env_color_parameters(
(oldPrimR + ((newPrimR - oldPrimR) * time) / duration),
(oldPrimG + ((newPrimG - oldPrimG) * time) / duration),
(oldPrimB + ((newPrimB - oldPrimB) * time) / duration),
(oldEnvR + ( (newEnvR - oldEnvR) * time) / duration),
(oldEnvG + ( (newEnvG - oldEnvG) * time) / duration),
(oldEnvB + ( (newEnvB - oldEnvB) * time) / duration));
if (time >= duration) {
return ApiStatus_DONE2;
}
} else {
set_model_env_color_parameters(newPrimR, newPrimG, newPrimB, newEnvR, newEnvG, newEnvB);
return ApiStatus_DONE2;
}
return ApiStatus_BLOCK;
}
#else
INCLUDE_ASM(s32, "world/area_hos/hos_05/A2EF00", func_802452C4_A2F504); INCLUDE_ASM(s32, "world/area_hos/hos_05/A2EF00", func_802452C4_A2F504);
#endif
void func_8024564C_A2F88C(void) { void func_8024564C_A2F88C(void) {
gDPSetCombineLERP(gMasterGfxPos++, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, gDPSetCombineLERP(gMasterGfxPos++, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0,

View File

@ -1,4 +1,8 @@
#include "hos_06.h" #include "hos_06.h"
#include "hud_element.h"
extern ShopItemData D_802435EC_A3CACC[];
extern IconHudScriptPair gItemHudScripts[];
#include "world/common/StashVars.inc.c" #include "world/common/StashVars.inc.c"
@ -21,8 +25,83 @@ INCLUDE_ASM(s32, "world/area_hos/hos_06/A397F0", func_802406E0_A39BC0);
extern s32 N(LetterDelivery_SavedNpcAnim); extern s32 N(LetterDelivery_SavedNpcAnim);
#include "world/common/LetterDelivery.inc.c" #include "world/common/LetterDelivery.inc.c"
INCLUDE_ASM(s32, "world/area_hos/hos_06/A397F0", func_80240A68_A39F48); ApiStatus Merlow_GetPlayerStarPieces(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
INCLUDE_ASM(s32, "world/area_hos/hos_06/A397F0", func_80240A94_A39F74); evt_set_variable(script, *args++, gPlayerData.starPieces);
return ApiStatus_DONE2;
}
INCLUDE_ASM(s32, "world/area_hos/hos_06/A397F0", func_80240AD0_A39FB0); ApiStatus Merlow_SetBadgePurchased(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 index = evt_get_variable(script, *args++);
evt_set_variable(NULL, GSWF(1771) + index, TRUE);
return ApiStatus_DONE2;
}
ApiStatus Merlow_ShopBadgesPopup(Evt* script, s32 isInitialCall) {
PlayerData* playerData = &gPlayerData;
PopupMenu* menu;
s32 selected, menuPos, i;
if (isInitialCall) {
script->functionTempPtr[2] = heap_malloc(sizeof(*menu));
menu = script->functionTempPtr[2];
menuPos = 0;
for (i = 0; i < 15; i++) {
if (!evt_get_variable(NULL, GSWF(1771) + i)) {
ItemData* item = &gItemTable[D_802435EC_A3CACC[i].itemID];
IconHudScriptPair* itemHudScripts = &gItemHudScripts[item->hudElemID];
menu->userIndex[menuPos] = i;
menu->nameMsg[menuPos] = item->nameMsg;
menu->ptrIcon[menuPos] = itemHudScripts->enabled;
menu->enabled[menuPos] = playerData->starPieces >= D_802435EC_A3CACC[i].price;
if (playerData->starPieces < D_802435EC_A3CACC[i].price) {
menu->ptrIcon[menuPos] = itemHudScripts->disabled;
menu->enabled[menuPos] = FALSE;
}
menu->descMsg[menuPos] = D_802435EC_A3CACC[i].descMsg;
menu->value[menuPos] = D_802435EC_A3CACC[i].price;
menuPos++;
}
}
menu->popupType = POPUP_MENU_TRADE_FOR_BADGE;
menu->numEntries = menuPos;
menu->initialPos = 0;
create_popup_menu(menu);
script->functionTemp[0] = 0;
}
menu = script->functionTempPtr[2];
if (script->functionTemp[0] == 0) {
script->functionTemp[1] = menu->result;
if (script->functionTemp[1] != 0) {
hide_popup_menu();
} else {
return ApiStatus_BLOCK;
}
}
script->functionTemp[0]++;
if (script->functionTemp[0] < 20) {
return ApiStatus_BLOCK;
}
destroy_popup_menu();
selected = script->functionTemp[1];
if (selected != 0xFF) {
ShopItemData* selectedItem;
i = menu->userIndex[selected - 1];
selectedItem = &D_802435EC_A3CACC[i];
script->varTable[0] = selectedItem->itemID;
script->varTable[1] = selectedItem->price;
script->varTable[2] = i;
script->varTable[4] = gItemTable[selectedItem->itemID].nameMsg;
script->varTable[5] = gMoveTable[gItemTable[selectedItem->itemID].moveID].costBP;
} else {
script->varTable[0] = -1;
}
heap_free(script->functionTempPtr[2]);
return ApiStatus_DONE2;
}

View File

@ -1,3 +1,6 @@
#include "hos_06.h" #include "hos_06.h"
INCLUDE_ASM(s32, "world/area_hos/hos_06/A3A210", func_80240D30_A3A210); ApiStatus func_80240D30_A3A210(Evt* script, s32 isInitialCall) {
script->varTable[0] = gGameStatusPtr->entryID;
return ApiStatus_DONE2;
}

View File

@ -16,9 +16,28 @@ INCLUDE_ASM(s32, "world/area_hos/hos_06/A3A230", func_80241008_A3A4E8);
#include "world/common/GetItemName.inc.c" #include "world/common/GetItemName.inc.c"
INCLUDE_ASM(s32, "world/area_hos/hos_06/A3A230", func_802411BC_A3A69C); s32 func_802411BC_A3A69C(s32 badgeID) {
s32 i;
INCLUDE_ASM(s32, "world/area_hos/hos_06/A3A230", func_802411F0_A3A6D0); for (i = 0; i < ARRAY_COUNT(gPlayerData.badges); i++) {
if (gPlayerData.badges[i] == badgeID) {
return TRUE;
}
}
return FALSE;
}
ApiStatus func_802411F0_A3A6D0(Evt* script, s32 isInitialCall) {
u32 i;
for (i = 0; i < 79; i++) {
evt_set_variable(NULL, LSWF(3) + i, 0);
}
for (i = 0; i < 16; i++) {
evt_set_variable(NULL, LSWF(100) + i, 0);
}
return ApiStatus_DONE2;
}
INCLUDE_ASM(s32, "world/area_hos/hos_06/A3A230", func_8024126C_A3A74C); INCLUDE_ASM(s32, "world/area_hos/hos_06/A3A230", func_8024126C_A3A74C);

View File

@ -3,4 +3,7 @@
static char* N(exit_str_0) = "jan_01"; static char* N(exit_str_0) = "jan_01";
static char* N(exit_str_1) = "jan_03"; static char* N(exit_str_1) = "jan_03";
INCLUDE_ASM(s32, "world/area_jan/jan_02/B2C470", func_80240000_B2C470); ApiStatus func_80240000_B2C470(Evt* script, s32 isInitialCall) {
bgm_set_track_volumes(0, 0);
return ApiStatus_DONE2;
}

View File

@ -4,9 +4,56 @@
static char* N(exit_str_0) = "kmr_02"; static char* N(exit_str_0) = "kmr_02";
static char* N(exit_str_1) = "kmr_02\0"; static char* N(exit_str_1) = "kmr_02\0";
INCLUDE_ASM(s32, "world/area_kmr/kmr_00/8ABF90", func_80240000_8ABF90); extern s16 D_80242D60_8AECF0[8];
INCLUDE_ASM(s32, "world/area_kmr/kmr_00/8ABF90", func_80240388_8AC318); void set_model_env_color_parameters(u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB);
void get_model_env_color_parameters(u8* primR, u8* primG, u8* primB, u8* envR, u8* envG, u8* envB);
ApiStatus func_80240000_8ABF90(Evt* script, s32 isInitialCall) {
Bytecode* args;
static u8 oldPrimR, oldPrimG, oldPrimB;
static u8 oldEnvR, oldEnvG, oldEnvB;
static s32 newPrimR, newPrimG, newPrimB;
static s32 newEnvR, newEnvG, newEnvB;
static s32 duration, time;
args = script->ptrReadPos;
if (isInitialCall) {
get_model_env_color_parameters(&oldPrimR, &oldPrimG, &oldPrimB, &oldEnvR, &oldEnvG, &oldEnvB);
newPrimR = evt_get_variable(script, *args++);
newPrimG = evt_get_variable(script, *args++);
newPrimB = evt_get_variable(script, *args++);
newEnvR = evt_get_variable(script, *args++);
newEnvG = evt_get_variable(script, *args++);
newEnvB = evt_get_variable(script, *args++);
duration = evt_get_variable(script, *args++);
time = 0;
}
if (duration > 0) {
time++;
set_model_env_color_parameters(
(oldPrimR + ((newPrimR - oldPrimR) * time) / duration),
(oldPrimG + ((newPrimG - oldPrimG) * time) / duration),
(oldPrimB + ((newPrimB - oldPrimB) * time) / duration),
(oldEnvR + ( (newEnvR - oldEnvR) * time) / duration),
(oldEnvG + ( (newEnvG - oldEnvG) * time) / duration),
(oldEnvB + ( (newEnvB - oldEnvB) * time) / duration));
if (time >= duration) {
return ApiStatus_DONE2;
}
} else {
set_model_env_color_parameters(newPrimR, newPrimG, newPrimB, newEnvR, newEnvG, newEnvB);
return ApiStatus_DONE2;
}
return ApiStatus_BLOCK;
}
ApiStatus func_80240388_8AC318(Evt* script, s32 isInitialCall) {
mdl_set_all_fog_mode(3);
*D_801512F0 = 3;
return ApiStatus_DONE2;
}
ApiStatus func_802403B8_8AC348(Evt* script, s32 isInitialCall) { ApiStatus func_802403B8_8AC348(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
@ -25,31 +72,123 @@ ApiStatus func_802404A0_8AC430(Evt* script, s32 isInitialCall) {
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
INCLUDE_ASM(s32, "world/area_kmr/kmr_00/8ABF90", func_802404E8_8AC478); ApiStatus func_802404E8_8AC478(Evt* script, s32 isInitialCall) {
s32 pitch = evt_get_variable(script, script->varTable[0]);
gCameras->controlSettings.boomPitch = pitch * 0.001f;
return ApiStatus_DONE2;
}
ApiStatus func_80240530_8AC4C0(Evt* script, s32 isInitialCall) { ApiStatus func_80240530_8AC4C0(Evt* script, s32 isInitialCall) {
Npc* npc = get_npc_unsafe(evt_get_variable(script, *script->ptrReadPos)); Bytecode* args = script->ptrReadPos;
s32 npcID = evt_get_variable(script, *args++);
Npc* npc = get_npc_unsafe(npcID);
fx_sparkles(3, npc->pos.x, npc->pos.y + 10.0f, npc->pos.z, 10.0f); fx_sparkles(3, npc->pos.x, npc->pos.y + 10.0f, npc->pos.z, 10.0f);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_80240584_8AC514(Evt* script, s32 isInitialCall) { ApiStatus func_80240584_8AC514(Evt* script, s32 isInitialCall) {
func_8005553C(0, 2000); snd_ambient_8005553C(0, 2000);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_802405A8_8AC538(Evt* script, s32 isInitialCall) { ApiStatus func_802405A8_8AC538(Evt* script, s32 isInitialCall) {
func_80055590(0, 2000); snd_ambient_80055590(0, 2000);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_802405CC_8AC55C(Evt* script, s32 isInitialCall) { ApiStatus func_802405CC_8AC55C(Evt* script, s32 isInitialCall) {
func_800554E8(0, 1000); snd_ambient_slow_fade_out(0, 1000);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
INCLUDE_ASM(s32, "world/area_kmr/kmr_00/8ABF90", func_802405F0_8AC580); ApiStatus func_802405F0_8AC580(Evt* script, s32 isInitialCall) {
enum {
FUNC_STATE_0 = 0,
FUNC_STATE_1 = 1,
FUNC_STATE_2 = 2,
FUNC_STATE_3 = 3
};
Bytecode* args = script->ptrReadPos;
ApiStatus retVal = ApiStatus_BLOCK;
Npc* npc;
if (isInitialCall) {
script->functionTemp[1] = evt_get_variable(script, *args++);
script->functionTemp[2] = evt_get_variable(script, *args++);
script->varTable[15] = evt_get_variable(script, *args++);
script->functionTemp[0] = FUNC_STATE_0;
script->functionTemp[3] = 0;
}
npc = get_npc_unsafe(script->functionTemp[1]);
switch (script->functionTemp[0]) {
case FUNC_STATE_0:
npc->pos.x = 0.0f;
npc->pos.y = -1000.0f;
npc->pos.z = -50.0f;
npc->moveToPos.x = script->functionTemp[3] * 3;
npc->moveToPos.y = 3.0f;
if (script->functionTemp[3] >= script->varTable[15]) {
npc->pos.y = 100.0f;
add_vec2D_polar(&npc->pos.x, &npc->pos.z, 70.0f, npc->moveToPos.x + (script->functionTemp[2] * 51) + 153.0f);
npc->pos.y += (-npc->pos.z + -50.0f + 70.0f) * 0.15f;
sfx_play_sound_at_position(0xB000001E, 0, npc->pos.x, npc->pos.y, npc->pos.z);
fx_sparkles(0, npc->pos.x, npc->pos.y + 20.0f, npc->pos.z, 20.0f);
script->functionTemp[0] = FUNC_STATE_1;
}
break;
case FUNC_STATE_1:
npc->pos.x = 0.0f;
npc->pos.z = -50.0f;
npc->pos.y = 100.0f;
add_vec2D_polar(&npc->pos.x, &npc->pos.z, 70.0f, npc->moveToPos.x + (script->functionTemp[2] * 51) + 153.0f);
npc->pos.y += (-npc->pos.z + -50.0f + 70.0f) * 0.15f;
if ((script->functionTemp[3] + script->functionTemp[2]) ==
(((script->functionTemp[3] + script->functionTemp[2]) / 13) * 13)) {
fx_sparkles(3, npc->pos.x, npc->pos.y + 10.0f, npc->pos.z, 10.0f);
}
if (script->functionTemp[3] > 256) {
script->functionTemp[0] = FUNC_STATE_2;
script->varTable[14] = 0;
}
break;
case FUNC_STATE_2:
npc->pos.x = 0.0f;
npc->pos.z = -50.0f;
npc->pos.y = 100.0f - (script->varTable[14] * 0.3f);
add_vec2D_polar(&npc->pos.x, &npc->pos.z, 70.0f, npc->moveToPos.x + (script->functionTemp[2] * 51) + 153.0f);
npc->pos.y += (-npc->pos.z + -50.0f + 70.0f) * 0.15f;
if ((script->functionTemp[3] + script->functionTemp[2]) ==
(((script->functionTemp[3] + script->functionTemp[2]) / 13) * 13)) {
fx_sparkles(3, npc->pos.x, npc->pos.y + 10.0f, npc->pos.z, 10.0f);
}
if (script->varTable[14]++ > 180) {
script->functionTemp[0] = FUNC_STATE_3;
script->varTable[14] = 0;
}
break;
case FUNC_STATE_3:
npc->moveToPos.y -= 0.03f;
npc->pos.x = 0.0f;
npc->pos.z = -50.0f;
npc->pos.y = 45.999996f;
add_vec2D_polar(&npc->pos.x, &npc->pos.z, 70.0f, npc->moveToPos.x + (script->functionTemp[2] * 51) + 153.0f);
npc->pos.y += (-npc->pos.z + -50.0f + 70.0f) * 0.15f;
if ((script->functionTemp[3] + script->functionTemp[2]) ==
(((script->functionTemp[3] + script->functionTemp[2]) / 13) * 13)) {
fx_sparkles(3, npc->pos.x, npc->pos.y + 10.0f, npc->pos.z, 10.0f);
}
if (npc->moveToPos.y < 0.0f) {
retVal = ApiStatus_DONE2;
}
break;
}
script->functionTemp[3]++;
npc->moveToPos.x += npc->moveToPos.y;
return retVal;
}
ApiStatus func_80240BD8_8ACB68(Evt* script, s32 isInitialCall) { ApiStatus func_80240BD8_8ACB68(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
@ -73,4 +212,21 @@ ApiStatus func_80240BD8_8ACB68(Evt* script, s32 isInitialCall) {
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
} }
INCLUDE_ASM(s32, "world/area_kmr/kmr_00/8ABF90", func_80240CB0_8ACC40); ApiStatus func_80240CB0_8ACC40(Evt* script, s32 isInitialCall) {
s32 retVal;
if (isInitialCall) {
script->functionTemp[1] = 0;
script->functionTempPtr[2] = get_npc_safe(script->owner2.npcID);
script->functionTemp[3] = D_80242D60_8AECF0[script->owner2.npcID - 1];
}
if (script->functionTemp[3] == 0) {
Npc* npc = script->functionTempPtr[2];
npc->verticalRenderOffset = sin_deg(script->functionTempF[1]) * 1.5f;
script->functionTempF[1] = clamp_angle(script->functionTempF[1] + 18.0f);
retVal = ApiStatus_BLOCK;
} else {
script->functionTemp[3]--;
retVal = ApiStatus_BLOCK;
}
return retVal;
}

View File

@ -70,7 +70,51 @@ INCLUDE_ASM(s32, "world/area_kmr/kmr_02/8B0070", func_8024295C_8B29CC);
INCLUDE_ASM(s32, "world/area_kmr/kmr_02/8B0070", func_80242BA8_8B2C18); INCLUDE_ASM(s32, "world/area_kmr/kmr_02/8B0070", func_80242BA8_8B2C18);
// will match when preceding bss is worked out
#ifdef NON_MATCHING
s32 func_80242BC0_8B2C30(Evt* script, s32 isInitialCall) {
Bytecode* args;
static u8 oldPrimR, oldPrimG, oldPrimB;
static u8 oldEnvR, oldEnvG, oldEnvB;
s32 newEnvR, newEnvB, newEnvG;
s32 newPrimR, newPrimG, newPrimB;
s32 duration;
args = script->ptrReadPos;
newPrimR = evt_get_variable(script, *args++);
newPrimG = evt_get_variable(script, *args++);
newPrimB = evt_get_variable(script, *args++);
newEnvR = evt_get_variable(script, *args++);
newEnvG = evt_get_variable(script, *args++);
newEnvB = evt_get_variable(script, *args++);
duration = evt_get_variable(script, *args++);
if (isInitialCall) {
get_model_env_color_parameters(&oldPrimR, &oldPrimG, &oldPrimB, &oldEnvR, &oldEnvG, &oldEnvB);
script->functionTemp[0] = 0;
}
if (duration > 0) {
set_model_env_color_parameters(
oldPrimR + ((newPrimR - oldPrimR) * script->functionTemp[0]) / duration,
oldPrimG + ((newPrimG - oldPrimG) * script->functionTemp[0]) / duration,
oldPrimB + ((newPrimB - oldPrimB) * script->functionTemp[0]) / duration,
oldEnvR + ( (newEnvR - oldEnvR) * script->functionTemp[0]) / duration,
oldEnvG + ( (newEnvG - oldEnvG) * script->functionTemp[0]) / duration,
oldEnvB + ( (newEnvB - oldEnvB) * script->functionTemp[0]) / duration);
script->functionTemp[0]++;
if (duration < script->functionTemp[0]) {
return 2;
}
} else {
set_model_env_color_parameters(newPrimR, newPrimG, newPrimB, newEnvR, newEnvG, newEnvB);
return 2;
}
return 0;
}
#else
INCLUDE_ASM(s32, "world/area_kmr/kmr_02/8B0070", func_80242BC0_8B2C30); INCLUDE_ASM(s32, "world/area_kmr/kmr_02/8B0070", func_80242BC0_8B2C30);
#endif
INCLUDE_ASM(s32, "world/area_kmr/kmr_02/8B0070", func_80242F08_8B2F78); INCLUDE_ASM(s32, "world/area_kmr/kmr_02/8B0070", func_80242F08_8B2F78);

View File

@ -7,4 +7,7 @@ static char* N(exit_str_3) = "kmr_02";
static char* N(exit_str_4) = "mac_00\0\0"; static char* N(exit_str_4) = "mac_00\0\0";
static char* N(exit_str_5) = ""; static char* N(exit_str_5) = "";
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EBE20", func_80240000_8EBE20); ApiStatus func_80240000_8EBE20(Evt* script, s32 isInitialCall) {
snd_ambient_slow_fade_out(0, 500);
return ApiStatus_DONE2;
}

View File

@ -4,9 +4,15 @@
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EBE50", func_80240310_8EC130); INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EBE50", func_80240310_8EC130);
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EBE50", func_80240330_8EC150); ApiStatus func_80240330_8EC150(Evt* script, s32 isInitialCall) {
au_ambience_set_volume(0, 1000, 0x3F);
return ApiStatus_DONE2;
}
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EBE50", func_80240358_8EC178); ApiStatus func_80240358_8EC178(Evt* script, s32 isInitialCall) {
au_ambience_set_volume(0, 1000, 0x7F);
return ApiStatus_DONE2;
}
#include "common/foliage.inc.c" #include "common/foliage.inc.c"
@ -22,4 +28,7 @@ INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EBE50", func_80240B48_8EC968);
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EBE50", func_80240B54_8EC974); INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EBE50", func_80240B54_8EC974);
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EBE50", func_80240DA4_8ECBC4); ApiStatus func_80240DA4_8ECBC4(Evt* script, s32 isInitialCall) {
au_ambience_set_volume(0, 1000, 1);
return ApiStatus_DONE2;
}

View File

@ -1,5 +1,8 @@
#include "kmr_20.h" #include "kmr_20.h"
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8ECBF0", func_80240DD0_8ECBF0); ApiStatus func_80240DD0_8ECBF0(Evt* script, s32 isInitialCall) {
au_ambience_set_volume(0, 1000, 0x3F);
return ApiStatus_DONE2;
}
#include "world/common/UnsetCamera0MoveFlag1.inc.c" #include "world/common/UnsetCamera0MoveFlag1.inc.c"

View File

@ -2,8 +2,14 @@
#include "world/common/atomic/ToadHouse.inc.c" #include "world/common/atomic/ToadHouse.inc.c"
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8ED0C0", func_8024159C_8ED3BC); ApiStatus func_8024159C_8ED3BC(Evt* script, s32 isInitialCall) {
au_ambience_set_volume(0, 1000, 1);
return ApiStatus_DONE2;
}
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8ED0C0", func_802415C4_8ED3E4); ApiStatus func_802415C4_8ED3E4(Evt* script, s32 isInitialCall) {
au_ambience_set_volume(0, 1000, 0x3F);
return ApiStatus_DONE2;
}
#include "world/common/WaitForPlayerToLand.inc.c" #include "world/common/WaitForPlayerToLand.inc.c"

View File

@ -12,4 +12,7 @@ INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8ED5A0", func_80241C9C_8EDABC);
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8ED5A0", func_80241CF0_8EDB10); INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8ED5A0", func_80241CF0_8EDB10);
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8ED5A0", func_80241D1C_8EDB3C); ApiStatus func_80241D1C_8EDB3C(Evt* script, s32 isInitialCall) {
au_ambience_set_volume(0, 1000, 0x3F);
return ApiStatus_DONE2;
}

View File

@ -10,6 +10,12 @@ INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EDB70", func_80242084_8EDEA4);
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EDB70", func_802420EC_8EDF0C); INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EDB70", func_802420EC_8EDF0C);
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EDB70", func_80242144_8EDF64); ApiStatus func_80242144_8EDF64(Evt* script, s32 isInitialCall) {
au_ambience_set_volume(0, 1000, 0x3F);
return ApiStatus_DONE2;
}
INCLUDE_ASM(s32, "world/area_kmr/kmr_20/8EDB70", func_8024216C_8EDF8C); ApiStatus func_8024216C_8EDF8C(Evt* script, s32 isInitialCall) {
au_ambience_set_volume(0, 1000, 0x7F);
return ApiStatus_DONE2;
}

View File

@ -1,7 +1,16 @@
#include "kpa_16.h" #include "kpa_16.h"
INCLUDE_ASM(s32, "world/area_kpa/kpa_16/A5A340", func_80240310_A5A340); ApiStatus func_80240310_A5A340(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
f32 zoom = evt_get_variable(script, *args++);
INCLUDE_ASM(s32, "world/area_kpa/kpa_16/A5A340", func_8024034C_A5A37C); set_screen_overlay_params_front(0, zoom);
return ApiStatus_DONE2;
}
ApiStatus func_8024034C_A5A37C(Evt* script, s32 isInitialCall) {
snd_ambient_80055618(0, 1);
return ApiStatus_DONE2;
}
#include "world/common/GetFloorCollider.inc.c" #include "world/common/GetFloorCollider.inc.c"

View File

@ -7,4 +7,7 @@ INCLUDE_ASM(s32, "world/area_kzn/kzn_06/C6CD10", func_80240738_C6D058);
INCLUDE_ASM(s32, "world/area_kzn/kzn_06/C6CD10", func_802407FC_C6D11C); INCLUDE_ASM(s32, "world/area_kzn/kzn_06/C6CD10", func_802407FC_C6D11C);
INCLUDE_ASM(s32, "world/area_kzn/kzn_06/C6CD10", func_80240A44_C6D364); ApiStatus func_80240A44_C6D364(Evt* script, s32 isInitialCall) {
snd_ambient_80055618(0, 1);
return ApiStatus_DONE2;
}

View File

@ -17,6 +17,10 @@ INCLUDE_ASM(s32, "world/area_kzn/kzn_20/C96240", func_802406E0_C96610);
extern s32 N(LetterDelivery_SavedNpcAnim); extern s32 N(LetterDelivery_SavedNpcAnim);
#include "world/common/LetterDelivery.inc.c" #include "world/common/LetterDelivery.inc.c"
INCLUDE_ASM(s32, "world/area_kzn/kzn_20/C96240", func_80240A68_C96998); ApiStatus func_80240A68_C96998(Evt* script, s32 isInitialCall) {
snd_ambient_80055618(0, 1);
return ApiStatus_DONE2;
}
#include "world/common/GetFloorCollider.inc.c" #include "world/common/GetFloorCollider.inc.c"

View File

@ -4,4 +4,7 @@
#include "world/common/GetFloorCollider.inc.c" #include "world/common/GetFloorCollider.inc.c"
#define NAMESPACE kzn_22 #define NAMESPACE kzn_22
INCLUDE_ASM(s32, "world/area_kzn/kzn_22/C9A540", func_8024036C_C9A56C); ApiStatus func_8024036C_C9A56C(Evt* script, s32 isInitialCall) {
snd_ambient_80055618(0, 1);
return ApiStatus_DONE2;
}

View File

@ -1,5 +1,5 @@
#include "mac_00.h" #include "mac_00.h"
#include "world/common/UnkMusicFunc.inc.c" #include "world/common/atomic/MonitorMusicProximityTrigger.inc.c"
INCLUDE_ASM(s32, "world/area_mac/mac_00/7ECFD0", func_802423F0_7ED100); INCLUDE_ASM(s32, "world/area_mac/mac_00/7ECFD0", func_802423F0_7ED100);

View File

@ -4,7 +4,7 @@
extern u8 D_80258407_818C87; extern u8 D_80258407_818C87;
#include "world/common/UnkMusicFunc.inc.c" #include "world/common/atomic/MonitorMusicProximityTrigger.inc.c"
#include "world/common/enemy/PatrolNoAttackAI.inc.c" #include "world/common/enemy/PatrolNoAttackAI.inc.c"

View File

@ -106,4 +106,4 @@ ApiStatus func_802430D0_826390(Evt* script, s32 isInitialCall) {
extern s32 N(LetterDelivery_SavedNpcAnim); extern s32 N(LetterDelivery_SavedNpcAnim);
#include "world/common/LetterDelivery.inc.c" #include "world/common/LetterDelivery.inc.c"
#include "world/common/UnkMusicFunc.inc.c" #include "world/common/atomic/MonitorMusicProximityTrigger.inc.c"

View File

@ -1,3 +1,3 @@
#include "mac_04.h" #include "mac_04.h"
#include "world/common/UnkMusicFunc.inc.c" #include "world/common/atomic/MonitorMusicProximityTrigger.inc.c"

View File

@ -1,6 +1,5 @@
#include "mgm_00.h" #include "mgm_00.h"
void snd_start_sound(s32 soundID, u8 volume, u8 pan);
void msg_draw_frame(s32 posX, s32 posY, s32 sizeX, s32 sizeY, s32 style, s32 palette, s32 fading, s32 bgAlpha, s32 frameAlpha); void msg_draw_frame(s32 posX, s32 posY, s32 sizeX, s32 sizeY, s32 style, s32 palette, s32 fading, s32 bgAlpha, s32 frameAlpha);
extern Gfx D_80243C50_E123F0[]; extern Gfx D_80243C50_E123F0[];

View File

@ -103,9 +103,9 @@ ApiStatus func_802427C0_9C7BA0(Evt* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos; Bytecode* args = script->ptrReadPos;
evt_get_variable(script, *args++); evt_get_variable(script, *args++);
func_80055448(16); snd_ambient_80055448(16);
func_80055760(4); snd_ambient_80055760(4);
func_8005566C(0, 250, 1); au_ambience_set_volume(0, 250, 1);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
@ -114,16 +114,29 @@ INCLUDE_ASM(s32, "world/area_nok/nok_01/9C53E0", func_80242804_9C7BE4);
INCLUDE_ASM(s32, "world/area_nok/nok_01/9C53E0", func_80242858_9C7C38); INCLUDE_ASM(s32, "world/area_nok/nok_01/9C53E0", func_80242858_9C7C38);
ApiStatus func_80242898_9C7C78(Evt* script, s32 isInitialCall) { ApiStatus func_80242898_9C7C78(Evt* script, s32 isInitialCall) {
func_80055848(4); snd_ambient_80055848(4);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
ApiStatus func_802428B8_9C7C98(Evt* script, s32 isInitialCall) { ApiStatus func_802428B8_9C7C98(Evt* script, s32 isInitialCall) {
func_800557CC(100); snd_ambient_800557CC(100);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
// Requires BSS
#ifdef NON_MATCHING
ApiStatus func_802428D8_9C7CB8(Evt* script, s32 isInitialCall) {
static s16 D_80250810_9D5BF0[] = { 0, 2, 1, 4 };
Bytecode* args = script->ptrReadPos;
s32 index = evt_get_variable(script, *args++);
snd_ambient_80055848(D_80250810_9D5BF0[index]);
return ApiStatus_DONE2;
}
#else
INCLUDE_ASM(s32, "world/area_nok/nok_01/9C53E0", func_802428D8_9C7CB8); INCLUDE_ASM(s32, "world/area_nok/nok_01/9C53E0", func_802428D8_9C7CB8);
#endif
ApiStatus func_80242910_9C7CF0(Evt* script, s32 isInitialCall) { ApiStatus func_80242910_9C7CF0(Evt* script, s32 isInitialCall) {
gPlayerData.tradeEventStartTime = gPlayerData.frameCounter; gPlayerData.tradeEventStartTime = gPlayerData.frameCounter;

View File

@ -1,4 +1,7 @@
#include "obk_05.h" #include "obk_05.h"
#include "model.h"
#include "mapfs/obk_05_shape.h"
#include "mapfs/obk_05_hit.h"
static char* N(exit_str_0) = "obk_01"; static char* N(exit_str_0) = "obk_01";
static char* N(exit_str_1) = "obk_06"; static char* N(exit_str_1) = "obk_06";
@ -7,6 +10,193 @@ static char* N(exit_str_1) = "obk_06";
#include "world/common/SetCamera0MoveFlag1.inc.c" #include "world/common/SetCamera0MoveFlag1.inc.c"
INCLUDE_ASM(s32, "world/area_obk/obk_05/BCD060", func_80240038_BCD098); ApiStatus N(RetroJar_AwaitPlayerEntry)(Evt* script, s32 isInitialCall) {
if (gCollisionStatus.currentFloor == COLLIDER_o420) {
return ApiStatus_DONE2;
} else {
return ApiStatus_BLOCK;
}
}
INCLUDE_ASM(s32, "world/area_obk/obk_05/BCD060", func_80240050_BCD0B0); ApiStatus N(RockingChair_UpdatePhysics)(Evt* script, s32 isInitialCall) {
typedef struct RockingChairPhysics {
/* 0x00 */ f32 angleDelta;
/* 0x04 */ f32 angularAccel;
/* 0x08 */ f32 rotationAngle;
/* 0x0C */ f32 verticalOffset;
/* 0x10 */ f32 angleB;
/* 0x14 */ f32 angleA;
/* 0x18 */ f32 mass;
/* 0x1C */ f32 equilibriumAngle;
} RockingChairPhysics; // size = 0x20
enum RockingChairState {
CHAIR_STATE_INITIAL = 0,
CHAIR_STATE_PLAYER_TOUCHING = 1,
CHAIR_STATE_PLAYER_NOT_TOUCHING = 2
};
PlayerStatus* playerStatus = &gPlayerStatus;
CollisionStatus* collisionStatus = &gCollisionStatus;
RockingChairPhysics* physics;
f32 centerX, centerY, centerZ;
Matrix4f tempMtx;
Model* model;
s16 currentFloor;
if (isInitialCall) {
physics = heap_malloc(sizeof(*physics));
script->functionTempPtr[1] = physics;
physics->angleDelta = 0;
physics->verticalOffset = 0;
physics->rotationAngle = 0;
physics->angleB = 0;
physics->angleA = 0;
physics->angularAccel = 0.1f;
physics->mass = 3.0f;
script->functionTemp[0] = CHAIR_STATE_INITIAL;
script->functionTemp[2] = 0;
script->functionTemp[3] = 0;
}
physics = script->functionTempPtr[1];
switch (script->functionTemp[0]) {
case CHAIR_STATE_INITIAL:
if (collisionStatus->currentFloor == COLLIDER_i3) {
script->functionTemp[0] = CHAIR_STATE_PLAYER_TOUCHING;
}
if (collisionStatus->currentFloor == COLLIDER_i2) {
script->functionTemp[0] = CHAIR_STATE_PLAYER_TOUCHING;
}
physics->angleDelta = 0.0f;
physics->verticalOffset = 0.0f;
physics->angleB = 0.0f;
physics->angleA = 0.0f;
physics->rotationAngle = 0.0f;
physics->angularAccel = 0.1f;
physics->mass = 3.0f;
physics->equilibriumAngle = 20.0f;
break;
case CHAIR_STATE_PLAYER_TOUCHING:
//TODO odd match
currentFloor = collisionStatus->currentFloor;
if (currentFloor != COLLIDER_i3 && collisionStatus->currentFloor != COLLIDER_i2) {
script->functionTemp[3] = 120; // settle time
script->functionTemp[0] = CHAIR_STATE_PLAYER_NOT_TOUCHING;
}
if (fabsf(physics->rotationAngle) < 5.0f) {
physics->angularAccel = fabsf(0.0 - playerStatus->position.x) / 200.0f;
} else {
physics->angularAccel = 0.1f;
}
if (playerStatus->position.x <= 0.0) {
physics->angleB += physics->angularAccel;
physics->equilibriumAngle = SQ(fabsf(0.0 - playerStatus->position.x)) / 50.0f;
if (physics->equilibriumAngle > 15.0f) {
physics->equilibriumAngle = 15.0f;
}
if (physics->rotationAngle > physics->equilibriumAngle) {
physics->angleA += physics->angularAccel * physics->mass;
}
} else {
physics->angleA += physics->angularAccel;
physics->equilibriumAngle = -SQ(-fabsf(0.0 - playerStatus->position.x) * 0.5f) / 50.0f;
if (physics->equilibriumAngle < -5.0f) {
physics->equilibriumAngle = -5.0f;
}
if (physics->rotationAngle < physics->equilibriumAngle) {
physics->angleB += physics->angularAccel * physics->mass;
}
}
if ((physics->angleB > 100.0) && (physics->angleA > 100.0)) {
physics->angleB -= 100.0;
physics->angleA -= 100.0;
}
// clamp difference to 1.5 degrees
if (fabsf(physics->angleB - physics->angleA) > 1.5) {
if (physics->angleA > physics->angleB) {
physics->angleA = physics->angleB + 1.5;
} else {
physics->angleB = physics->angleA + 1.5;
}
}
physics->angleDelta = physics->angleB - physics->angleA;
physics->rotationAngle += physics->angleDelta;
break;
case CHAIR_STATE_PLAYER_NOT_TOUCHING:
if (collisionStatus->currentFloor == COLLIDER_i3) {
script->functionTemp[0] = CHAIR_STATE_PLAYER_TOUCHING;
}
if (collisionStatus->currentFloor == COLLIDER_i2) {
script->functionTemp[0] = CHAIR_STATE_PLAYER_TOUCHING;
}
physics->angularAccel = 0.1f;
physics->equilibriumAngle = 0;
physics->angleB += physics->angularAccel;
if (physics->rotationAngle > physics->equilibriumAngle) {
physics->angleA += physics->angularAccel * physics->mass;
}
if ((physics->angleB > 100.0) && ( physics->angleA > 100.0)) {
physics->angleB -= 100.0;
physics->angleA -= 100.0;
}
if (fabsf(physics->angleB - physics->angleA) > 0.5) {
if (physics->angleA > physics->angleB) {
physics->angleA = physics->angleB + 0.5;
} else {
physics->angleB = physics->angleA + 0.5;
}
}
if (script->functionTemp[3] < 0) {
f32 zero = 0.0f;
physics->angleA = zero;
physics->angleB = zero;
physics->angleDelta = zero;
physics->rotationAngle = zero;
} else {
script->functionTemp[3]--;
}
physics->angleDelta = physics->angleB - physics->angleA;
physics->rotationAngle += physics->angleDelta;
break;
}
// play creak sound once per cycle
if (physics->rotationAngle <= -7.0f) {
if (script->functionTemp[2] != -1) {
get_collider_center(COLLIDER_i3, &centerX, &centerY, &centerZ);
sfx_play_sound_at_position(SOUND_CREAKY_ROCKING_CHAIR, 0, centerX, centerY, centerZ);
script->functionTemp[2] = -1;
}
} else {
script->functionTemp[2] = 0;
}
physics->verticalOffset = SQ(physics->rotationAngle) / 90.0f;
model = get_model_from_list_index(get_model_list_index_from_tree_index(MODEL_i3));
model->flags |= (MODEL_FLAGS_USES_TRANSFORM_MATRIX | MODEL_FLAGS_HAS_TRANSFORM_APPLIED);
guTranslateF(model->transformMatrix, 0.0f, physics->verticalOffset, 0.0f);
guRotateF(tempMtx, physics->rotationAngle, 0.0f, 0.0f, 1.0f);
guMtxCatF(model->transformMatrix, tempMtx, model->transformMatrix);
update_collider_transform(COLLIDER_i3);
update_collider_transform(COLLIDER_i2);
model = get_model_from_list_index(get_model_list_index_from_tree_index(MODEL_i2));
model->flags |= (MODEL_FLAGS_USES_TRANSFORM_MATRIX | MODEL_FLAGS_HAS_TRANSFORM_APPLIED);
guTranslateF(model->transformMatrix, 0.0f, physics->verticalOffset, 0.0f);
guRotateF(tempMtx, physics->rotationAngle, 0.0f, 0.0f, 1.0f);
guMtxCatF(model->transformMatrix, tempMtx, model->transformMatrix);
model = get_model_from_list_index(get_model_list_index_from_tree_index(MODEL_i1));
model->flags |= (MODEL_FLAGS_USES_TRANSFORM_MATRIX | MODEL_FLAGS_HAS_TRANSFORM_APPLIED);
guTranslateF(model->transformMatrix, 0.0f, physics->verticalOffset, 0.0f);
guRotateF(tempMtx, physics->rotationAngle, 0.0f, 0.0f, 1.0f);
guMtxCatF(model->transformMatrix, tempMtx, model->transformMatrix);
update_collider_transform(COLLIDER_i1);
return ApiStatus_BLOCK;
}

View File

@ -1,8 +1,19 @@
#include "obk_05.h" #include "obk_05.h"
INCLUDE_ASM(s32, "world/area_obk/obk_05/BCD7D0", func_80240770_BCD7D0); extern s16 D_8024100C_BCE06C[4];
INCLUDE_ASM(s32, "world/area_obk/obk_05/BCD7D0", func_802407A0_BCD800); ApiStatus func_80240770_BCD7D0(Evt* script, s32 isInitialCall) {
if (gPlayerStatus.position.y < -50.0f) {
return ApiStatus_DONE2;
} else {
return ApiStatus_BLOCK;
}
}
ApiStatus func_802407A0_BCD800(Evt* script, s32 isInitialCall) {
script->functionTemp[1] = 0;
return ApiStatus_DONE2;
}
ApiStatus func_802407AC_BCD80C(Evt* script, s32 isInitialCall) { ApiStatus func_802407AC_BCD80C(Evt* script, s32 isInitialCall) {
Npc* npc = get_npc_safe(script->owner2.npcID); Npc* npc = get_npc_safe(script->owner2.npcID);
@ -38,4 +49,32 @@ ApiStatus func_802407AC_BCD80C(Evt* script, s32 isInitialCall) {
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
INCLUDE_ASM(s32, "world/area_obk/obk_05/BCD7D0", func_80240934_BCD994); ApiStatus func_80240934_BCD994(Evt* script, s32 isInitialCall) {
s32 var0 = script->varTable[0];
s32 var1 = script->varTable[1];
s32 temp;
if (var1 == 0) {
script->functionTemp[2] = D_8024100C_BCE06C[rand_int(3)];
var1 = rand_int(50) + 30;
}
var1--;
temp = script->functionTemp[2];
if (var0 < temp) {
var0 += 10;
if (temp < var0) {
var0 = temp;
}
}
if (temp < var0) {
var0 -= 10;
if (var0 < temp) {
var0 = temp;
}
}
script->varTable[0] = var0;
script->varTable[1] = var1;
return ApiStatus_DONE2;
}

View File

@ -10,15 +10,15 @@ static char* N(exit_str_5) = "";
void get_model_env_color_parameters(u8* arg0, u8* arg1, u8* arg2, u8* arg3, u8* arg4, u8* arg5); void get_model_env_color_parameters(u8* arg0, u8* arg1, u8* arg2, u8* arg3, u8* arg4, u8* arg5);
s32 func_80240000_92A2B0(void) { s32 N(GetTattle)(void) {
s32 phi; s32 msg;
if (evt_get_variable(NULL, EVT_STORY_PROGRESS) > STORY_CH2_GOT_PULSE_STONE) { if (evt_get_variable(NULL, EVT_STORY_PROGRESS) > STORY_CH2_GOT_PULSE_STONE) {
phi = 0x190063; msg = MESSAGE_ID(0x19, 0x63);
} else { } else {
phi = 0x190062; msg = MESSAGE_ID(0x19, 0x62);
} }
return phi; return msg;
} }
#include "world/common/atomic/UnkFunc27.inc.c" #include "world/common/atomic/UnkFunc27.inc.c"

View File

@ -7,8 +7,14 @@ static char* N(exit_str_3) = "";
#include "world/common/SpawnSunEffect.inc.c" #include "world/common/SpawnSunEffect.inc.c"
INCLUDE_ASM(s32, "world/area_sbk/sbk_56/953FC0", func_80240038_953FF8); ApiStatus func_80240038_953FF8(void) {
bgm_set_variation(0, 1);
return ApiStatus_DONE2;
}
INCLUDE_ASM(s32, "world/area_sbk/sbk_56/953FC0", func_8024005C_95401C); ApiStatus func_8024005C_95401C(void) {
bgm_set_variation(0, 0);
return ApiStatus_DONE2;
}
#include "world/common/atomic/SuperBlock.inc.c" #include "world/common/atomic/SuperBlock.inc.c"

View File

@ -6,7 +6,7 @@ static char* N(exit_str_2) = "tik_22";
static char* N(exit_str_3) = ""; static char* N(exit_str_3) = "";
ApiStatus func_80240000_892A20(Evt* script, s32 isInitialCall) { ApiStatus func_80240000_892A20(Evt* script, s32 isInitialCall) {
func_8014AB0C(0, 2); bgm_set_track_volumes(0, 2);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }

View File

@ -4,6 +4,6 @@ static char* N(exit_str_0) = "tik_21";
static char* N(exit_str_1) = "tik_17"; static char* N(exit_str_1) = "tik_17";
ApiStatus func_80240000_89FEC0(Evt* script, s32 isInitialCall) { ApiStatus func_80240000_89FEC0(Evt* script, s32 isInitialCall) {
func_8014AB0C(0, 2); bgm_set_track_volumes(0, 2);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }

View File

@ -4,10 +4,10 @@
#include "world/common/atomic/Pipe.inc.c" #include "world/common/atomic/Pipe.inc.c"
s32 func_8014AB60(s32, s16); s32 bgm_clear_track_volumes(s32, s16);
ApiStatus func_8024061C_8A04DC(Evt* script, s32 isInitialCall) { ApiStatus func_8024061C_8A04DC(Evt* script, s32 isInitialCall) {
func_8014AB60(0, 2); bgm_clear_track_volumes(0, 2);
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }

Some files were not shown because too many files have changed in this diff Show More