You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
refresh 4
This commit is contained in:
@@ -131,9 +131,9 @@ u8 gDefaultShortNoteDurationTable[16] = {
|
||||
s8 gVibratoCurve[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 };
|
||||
|
||||
struct AdsrEnvelope gDefaultEnvelope[] = {
|
||||
{ 4, 32000 }, // go from 0 to 32000 over the course of 16ms
|
||||
{ 1000, 32000 }, // stay there for 4.16 seconds
|
||||
{ ADSR_HANG, 0 } // then continue staying there
|
||||
{ BSWAP16(4), BSWAP16(32000) }, // go from 0 to 32000 over the course of 16ms
|
||||
{ BSWAP16(1000), BSWAP16(32000) }, // stay there for 4.16 seconds
|
||||
{ BSWAP16(ADSR_HANG), 0 } // then continue staying there
|
||||
};
|
||||
|
||||
s16 sSineWave[0x40] = {
|
||||
@@ -375,16 +375,16 @@ s8 sUnused8033EF8 = 24;
|
||||
struct CtlEntry *gCtlEntries;
|
||||
s32 gAiFrequency;
|
||||
u32 D_80226D68;
|
||||
s32 D_80226D6C;
|
||||
s32 gMaxAudioCmds;
|
||||
|
||||
s32 gMaxSimultaneousNotes;
|
||||
s32 D_80226D74;
|
||||
s32 gSamplesPerFrameTarget;
|
||||
s32 gMinAiBufferLength;
|
||||
s16 gTempoInternalToExternal;
|
||||
s8 gAudioUpdatesPerFrame;
|
||||
s8 gSoundMode;
|
||||
|
||||
volatile s32 gActiveAudioFrames;
|
||||
volatile s32 gAudioFrameCount;
|
||||
volatile s32 gCurrAudioFrameDmaCount;
|
||||
|
||||
s32 gAudioTaskIndex;
|
||||
@@ -402,4 +402,4 @@ s16 gAiBufferLengths[NUMAIBUFFERS];
|
||||
u32 gUnused80226E58[0x10];
|
||||
u16 gUnused80226E98[0x10];
|
||||
|
||||
u32 D_80226EB8;
|
||||
u32 gAudioRandom;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef _AUDIO_DATA_H
|
||||
#define _AUDIO_DATA_H
|
||||
#ifndef AUDIO_DATA_H
|
||||
#define AUDIO_DATA_H
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@@ -46,16 +46,16 @@ extern volatile s32 gAudioLoadLock;
|
||||
extern struct CtlEntry *gCtlEntries;
|
||||
extern s32 gAiFrequency;
|
||||
extern u32 D_80226D68;
|
||||
extern s32 D_80226D6C;
|
||||
extern s32 gMaxAudioCmds;
|
||||
|
||||
extern s32 gMaxSimultaneousNotes;
|
||||
extern s32 D_80226D74;
|
||||
extern s32 gSamplesPerFrameTarget;
|
||||
extern s32 gMinAiBufferLength;
|
||||
extern s16 gTempoInternalToExternal;
|
||||
extern s8 gAudioUpdatesPerFrame; // = 4
|
||||
extern s8 gSoundMode;
|
||||
|
||||
extern volatile s32 gActiveAudioFrames;
|
||||
extern volatile s32 gAudioFrameCount;
|
||||
extern volatile s32 gCurrAudioFrameDmaCount; // number of DMAs performed during this frame
|
||||
|
||||
extern s32 gAudioTaskIndex;
|
||||
@@ -73,6 +73,6 @@ extern s16 gAiBufferLengths[NUMAIBUFFERS];
|
||||
extern u32 gUnused80226E58[0x10];
|
||||
extern u16 gUnused80226E98[0x10];
|
||||
|
||||
extern u32 D_80226EB8;
|
||||
extern u32 gAudioRandom;
|
||||
|
||||
#endif /* _AUDIO_DATA_H */
|
||||
#endif /* AUDIO_DATA_H */
|
||||
|
||||
@@ -57,7 +57,7 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
|
||||
|
||||
channelVolume =
|
||||
seqChannel->seqPlayer->fadeVolume * (seqChannel->volume * seqChannel->volumeScale);
|
||||
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_20) != 0) {
|
||||
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0) {
|
||||
channelVolume *= seqChannel->seqPlayer->muteVolumeScale;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_LOOP:
|
||||
adsr->delay = adsr->envelope[adsr->envIndex].delay;
|
||||
adsr->delay = BSWAP16(adsr->envelope[adsr->envIndex].delay);
|
||||
switch (adsr->delay) {
|
||||
case ADSR_DISABLE:
|
||||
adsr->state = ADSR_STATE_DISABLED;
|
||||
@@ -266,14 +266,14 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
adsr->state = ADSR_STATE_HANG;
|
||||
break;
|
||||
case ADSR_GOTO:
|
||||
adsr->envIndex = adsr->envelope[adsr->envIndex].arg;
|
||||
adsr->envIndex = BSWAP16(adsr->envelope[adsr->envIndex].arg);
|
||||
break;
|
||||
case ADSR_RESTART:
|
||||
adsr->state = ADSR_STATE_INITIAL;
|
||||
break;
|
||||
|
||||
default:
|
||||
adsr->target = adsr->envelope[adsr->envIndex].arg;
|
||||
adsr->target = BSWAP16(adsr->envelope[adsr->envIndex].arg);
|
||||
adsr->velocity = ((adsr->target - adsr->current) << 0x10) / adsr->delay;
|
||||
adsr->state = ADSR_STATE_FADE;
|
||||
adsr->envIndex++;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#ifndef _AUDIO_EFFECTS_H
|
||||
#define _AUDIO_EFFECTS_H
|
||||
#ifndef AUDIO_EFFECTS_H
|
||||
#define AUDIO_EFFECTS_H
|
||||
|
||||
#include "internal.h"
|
||||
#include "platform_info.h"
|
||||
|
||||
#define ADSR_STATE_DISABLED 0
|
||||
#define ADSR_STATE_INITIAL 1
|
||||
@@ -22,10 +23,18 @@
|
||||
#define ADSR_GOTO -2
|
||||
#define ADSR_RESTART -3
|
||||
|
||||
// Envelopes are always stored as big endian, to match sequence files which are
|
||||
// byte blobs and can embed envelopes. Hence this byteswapping macro.
|
||||
#if IS_BIG_ENDIAN
|
||||
#define BSWAP16(x) (x)
|
||||
#else
|
||||
#define BSWAP16(x) (((x) & 0xff) << 8 | (((x) >> 8) & 0xff))
|
||||
#endif
|
||||
|
||||
void sequence_player_process_sound(struct SequencePlayer *seqPlayer);
|
||||
void note_vibrato_update(struct Note *note);
|
||||
void note_vibrato_init(struct Note *note);
|
||||
void adsr_init(struct AdsrState *adsr, struct AdsrEnvelope *envelope, s16 *volOut);
|
||||
s32 adsr_update(struct AdsrState *adsr);
|
||||
|
||||
#endif /* _AUDIO_EFFECTS_H */
|
||||
#endif /* AUDIO_EFFECTS_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
#ifndef _AUDIO_EXTERNAL_H
|
||||
#define _AUDIO_EXTERNAL_H
|
||||
#ifndef AUDIO_EXTERNAL_H
|
||||
#define AUDIO_EXTERNAL_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -53,4 +53,4 @@ void audio_set_sound_mode(u8 arg0);
|
||||
|
||||
void audio_init(void); // in load.c
|
||||
|
||||
#endif /* _AUDIO_EXTERNAL_H */
|
||||
#endif /* AUDIO_EXTERNAL_H */
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
#ifndef _AUDIO_INTERNAL_H
|
||||
#define _AUDIO_INTERNAL_H
|
||||
#ifndef AUDIO_INTERNAL_H
|
||||
#define AUDIO_INTERNAL_H
|
||||
|
||||
#include <ultra64.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define SEQUENCE_PLAYERS 3
|
||||
#define LAYERS_MAX 4
|
||||
#define CHANNELS_MAX 16
|
||||
|
||||
#define NO_LAYER ((struct SequenceChannelLayer *)(-1))
|
||||
|
||||
#define MUTE_BEHAVIOR_80 0x80
|
||||
#define MUTE_BEHAVIOR_40 0x40
|
||||
#define MUTE_BEHAVIOR_20 0x20
|
||||
#define MUTE_BEHAVIOR_STOP_SCRIPT 0x80 // stop processing sequence/channel scripts
|
||||
#define MUTE_BEHAVIOR_STOP_NOTES 0x40 // prevent further notes from playing
|
||||
#define MUTE_BEHAVIOR_SOFTEN 0x20 // lower volume, by default to half
|
||||
|
||||
#define SEQUENCE_PLAYER_STATE_0 0
|
||||
#define SEQUENCE_PLAYER_STATE_FADE_OUT 1
|
||||
@@ -151,7 +152,7 @@ struct Instrument
|
||||
struct Drum
|
||||
{
|
||||
u8 releaseRate;
|
||||
u8 unk1;
|
||||
u8 pan;
|
||||
u8 loaded;
|
||||
struct AudioBankSound sound;
|
||||
struct AdsrEnvelope *envelope;
|
||||
@@ -191,7 +192,7 @@ struct SequencePlayer
|
||||
/*0x003*/ u8 noteAllocPolicy;
|
||||
/*0x004*/ u8 muteBehavior;
|
||||
/*0x005*/ u8 seqId;
|
||||
/*0x006*/ u8 anyBank[1]; // must be an array to get a comparison
|
||||
/*0x006*/ u8 defaultBank[1]; // must be an array to get a comparison
|
||||
// to match; other u8's might also be part of that array
|
||||
/*0x007*/ u8 loadingBankId;
|
||||
/*0x008*/ u8 loadingBankNumInstruments;
|
||||
@@ -260,7 +261,7 @@ struct SequenceChannel
|
||||
/*0x00*/ u8 enabled : 1;
|
||||
/*0x00*/ u8 finished : 1;
|
||||
/*0x00*/ u8 stopScript : 1;
|
||||
/*0x00*/ u8 unk0b10 : 1;
|
||||
/*0x00*/ u8 stopSomething2 : 1; // sets SequenceChannelLayer.stopSomething
|
||||
/*0x00*/ u8 hasInstrument : 1;
|
||||
/*0x00*/ u8 stereoHeadsetEffects : 1;
|
||||
/*0x00*/ u8 largeNotes : 1; // notes specify duration and velocity
|
||||
@@ -292,7 +293,7 @@ struct SequenceChannel
|
||||
/*0x38*/ struct SequenceChannelLayer *layerUnused; // never read
|
||||
/*0x3C*/ struct Instrument *instrument;
|
||||
/*0x40*/ struct SequencePlayer *seqPlayer;
|
||||
/*0x44*/ struct SequenceChannelLayer *layers[4];
|
||||
/*0x44*/ struct SequenceChannelLayer *layers[LAYERS_MAX];
|
||||
/*0x54*/ s8 soundScriptIO[8]; // bridge between sound script and audio lib. For player 2,
|
||||
// [0] contains enabled, [4] contains sound ID, [5] contains reverb adjustment
|
||||
/*0x5C*/ struct M64ScriptState scriptState;
|
||||
@@ -304,9 +305,9 @@ struct SequenceChannelLayer // Maybe SequenceTrack?
|
||||
{
|
||||
/*0x00*/ u8 enabled : 1;
|
||||
/*0x00*/ u8 finished : 1;
|
||||
/*0x00*/ u8 unk0b20 : 1;
|
||||
/*0x00*/ u8 unk0b10 : 1;
|
||||
/*0x01*/ u8 unk1;
|
||||
/*0x00*/ u8 stopSomething : 1; // ?
|
||||
/*0x00*/ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
|
||||
/*0x01*/ u8 status;
|
||||
/*0x02*/ u8 noteDuration; // set to 0x80
|
||||
/*0x03*/ u8 portamentoTargetNote;
|
||||
/*0x04*/ struct Portamento portamento;
|
||||
@@ -408,4 +409,4 @@ struct AudioSessionSettings
|
||||
/*0x18*/ u32 temporaryBankMem;
|
||||
}; // size = 0x1C
|
||||
|
||||
#endif /* _AUDIO_INTERNAL_H */
|
||||
#endif /* AUDIO_INTERNAL_H */
|
||||
|
||||
@@ -23,9 +23,9 @@ struct SequencePlayer gSequencePlayers[SEQUENCE_PLAYERS];
|
||||
struct SequenceChannel gSequenceChannels[32];
|
||||
|
||||
#ifdef VERSION_JP
|
||||
struct SequenceChannelLayer D_802245D8[48];
|
||||
struct SequenceChannelLayer gSequenceLayers[48];
|
||||
#else
|
||||
struct SequenceChannelLayer D_802245D8[52];
|
||||
struct SequenceChannelLayer gSequenceLayers[52];
|
||||
#endif
|
||||
|
||||
struct SequenceChannel gSequenceChannelNone;
|
||||
@@ -212,7 +212,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *arg3) {
|
||||
}
|
||||
|
||||
// called from sound_reset
|
||||
void func_8031758C(UNUSED s32 arg0) {
|
||||
void init_sample_dma_buffers(UNUSED s32 arg0) {
|
||||
s32 i;
|
||||
s32 j;
|
||||
|
||||
@@ -287,7 +287,7 @@ static void unused_80317844(void) {
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void func_8031784C(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32 numDrums) {
|
||||
void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32 numDrums) {
|
||||
// Make pointers into real pointers rather than indices
|
||||
struct Instrument *instrument;
|
||||
struct Instrument **itInstrs;
|
||||
@@ -393,7 +393,7 @@ void func_8031784C(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32 nu
|
||||
}
|
||||
|
||||
#else
|
||||
GLOBAL_ASM("asm/non_matchings/func_8031784C.s")
|
||||
GLOBAL_ASM("asm/non_matchings/patch_audio_bank.s")
|
||||
#endif
|
||||
|
||||
struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1) {
|
||||
@@ -419,7 +419,7 @@ struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1) {
|
||||
numInstruments = buf[0];
|
||||
numDrums = buf[1];
|
||||
audio_dma_copy_immediate((uintptr_t)(ctlData + 0x10), ret, alloc);
|
||||
func_8031784C(ret, gAlTbl->seqArray[bankId].offset, numInstruments, numDrums);
|
||||
patch_audio_bank(ret, gAlTbl->seqArray[bankId].offset, numInstruments, numDrums);
|
||||
gCtlEntries[bankId].numInstruments = (u8) numInstruments;
|
||||
gCtlEntries[bankId].numDrums = (u8) numDrums;
|
||||
gCtlEntries[bankId].instruments = ret->instruments;
|
||||
@@ -635,11 +635,11 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) {
|
||||
// @bug This should set the last bank (i.e. the first in the JSON)
|
||||
// as default, not the missing one. This code path never gets
|
||||
// taken, though -- all sequence loading is synchronous.
|
||||
seqPlayer->anyBank[0] = bankId;
|
||||
} else if (load_banks_immediate(seqId, &seqPlayer->anyBank[0]) == NULL) {
|
||||
seqPlayer->defaultBank[0] = bankId;
|
||||
} else if (load_banks_immediate(seqId, &seqPlayer->defaultBank[0]) == NULL) {
|
||||
return;
|
||||
}
|
||||
} else if (load_banks_immediate(seqId, &seqPlayer->anyBank[0]) == NULL) {
|
||||
} else if (load_banks_immediate(seqId, &seqPlayer->defaultBank[0]) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ void audio_init() {
|
||||
gAiBufferLengths[i] = 0x00a0;
|
||||
}
|
||||
|
||||
gActiveAudioFrames = 0;
|
||||
gAudioFrameCount = 0;
|
||||
gAudioTaskIndex = 0;
|
||||
gCurrAiBufferIndex = 0;
|
||||
gSoundMode = 0;
|
||||
@@ -763,6 +763,6 @@ void audio_init() {
|
||||
gAlBankSets = soundAlloc(&gAudioInitPool, 0x100);
|
||||
audio_dma_copy_immediate((uintptr_t) gBankSetsData, gAlBankSets, 0x100);
|
||||
|
||||
func_8031D4B8();
|
||||
init_sequence_players();
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef _AUDIO_LOAD_H
|
||||
#define _AUDIO_LOAD_H
|
||||
#ifndef AUDIO_LOAD_H
|
||||
#define AUDIO_LOAD_H
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@@ -21,9 +21,9 @@ extern struct SequencePlayer gSequencePlayers[SEQUENCE_PLAYERS];
|
||||
extern struct SequenceChannel gSequenceChannels[32];
|
||||
|
||||
#ifdef VERSION_JP
|
||||
extern struct SequenceChannelLayer D_802245D8[48];
|
||||
extern struct SequenceChannelLayer gSequenceLayers[48];
|
||||
#else
|
||||
extern struct SequenceChannelLayer D_802245D8[52];
|
||||
extern struct SequenceChannelLayer gSequenceLayers[52];
|
||||
#endif
|
||||
|
||||
extern struct SequenceChannel gSequenceChannelNone;
|
||||
@@ -39,9 +39,9 @@ extern u8 *gAlBankSets;
|
||||
void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg);
|
||||
void decrease_sample_dma_ttls(void);
|
||||
void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *arg3);
|
||||
void func_8031758C(s32 arg0);
|
||||
void func_8031784C(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32 numDrums);
|
||||
void init_sample_dma_buffers(s32 arg0);
|
||||
void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32 numDrums);
|
||||
void preload_sequence(u32 seqId, u8 preloadMask);
|
||||
void load_sequence(u32 player, u32 seqId, s32 loadAsync);
|
||||
|
||||
#endif /* _AUDIO_LOAD_H */
|
||||
#endif /* AUDIO_LOAD_H */
|
||||
|
||||
@@ -47,7 +47,7 @@ u8 gSeqLoadStatus[0x100];
|
||||
|
||||
u8 gAudioUnusedBuffer[0x1000];
|
||||
|
||||
extern s32 D_80226D6C;
|
||||
extern s32 gMaxAudioCmds;
|
||||
|
||||
void reset_bank_and_seq_load_status(void) {
|
||||
s32 i;
|
||||
@@ -109,7 +109,7 @@ void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
|
||||
}
|
||||
|
||||
void sound_alloc_pool_init(struct SoundAllocPool *pool, void *memAddr, u32 size) {
|
||||
pool->cur = pool->start = (u8 *) (((uintptr_t) memAddr + 0xf) & -0x10);
|
||||
pool->cur = pool->start = (u8 *) ALIGN16((uintptr_t) memAddr);
|
||||
pool->size = size;
|
||||
pool->unused = 0;
|
||||
}
|
||||
@@ -374,9 +374,9 @@ void decrease_reverb_gain(void) {
|
||||
* Waits until a specified number of audio frames have been created
|
||||
*/
|
||||
void wait_for_audio_frames(s32 frames) {
|
||||
gActiveAudioFrames = 0;
|
||||
// Sound thread will update gActiveAudioFrames
|
||||
while (gActiveAudioFrames < frames) {
|
||||
gAudioFrameCount = 0;
|
||||
// Sound thread will update gAudioFrameCount
|
||||
while (gAudioFrameCount < frames) {
|
||||
// spin
|
||||
}
|
||||
}
|
||||
@@ -425,8 +425,13 @@ void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the reverb to finish as well
|
||||
decrease_reverb_gain();
|
||||
wait_for_audio_frames(3);
|
||||
|
||||
// The audio interface is double buffered; thus, we have to take the
|
||||
// load lock for 2 frames for the buffers to free up before we can
|
||||
// repurpose memory. Make that 3 frames, just in case.
|
||||
gAudioLoadLock = AUDIO_LOCK_LOADING;
|
||||
wait_for_audio_frames(3);
|
||||
|
||||
@@ -450,7 +455,7 @@ void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
reverbWindowSize = preset->reverbWindowSize;
|
||||
gAiFrequency = osAiSetFrequency(preset->frequency);
|
||||
gMaxSimultaneousNotes = preset->maxSimultaneousNotes;
|
||||
D_80226D74 = ALIGN16(gAiFrequency / 60);
|
||||
gSamplesPerFrameTarget = ALIGN16(gAiFrequency / 60);
|
||||
gReverbDownsampleRate = preset->reverbDownsampleRate;
|
||||
|
||||
switch (gReverbDownsampleRate) {
|
||||
@@ -475,9 +480,9 @@ void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
|
||||
gReverbDownsampleRate = preset->reverbDownsampleRate;
|
||||
gVolume = preset->volume;
|
||||
gMinAiBufferLength = D_80226D74 - 0x10;
|
||||
updatesPerFrame = D_80226D74 / 160 + 1;
|
||||
gAudioUpdatesPerFrame = D_80226D74 / 160 + 1;
|
||||
gMinAiBufferLength = gSamplesPerFrameTarget - 0x10;
|
||||
updatesPerFrame = gSamplesPerFrameTarget / 160 + 1;
|
||||
gAudioUpdatesPerFrame = gSamplesPerFrameTarget / 160 + 1;
|
||||
|
||||
// Compute conversion ratio from the internal unit tatums/tick to the
|
||||
// external beats/minute (JP) or tatums/minute (US). In practice this is
|
||||
@@ -488,7 +493,7 @@ void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
gTempoInternalToExternal = (u32)(updatesPerFrame * 2880000.0f / gTatumsPerBeat / 16.713f);
|
||||
#endif
|
||||
|
||||
D_80226D6C = gMaxSimultaneousNotes * 20 * updatesPerFrame + 320;
|
||||
gMaxAudioCmds = gMaxSimultaneousNotes * 20 * updatesPerFrame + 320;
|
||||
persistentMem = DOUBLE_SIZE_ON_64_BIT(preset->persistentBankMem + preset->persistentSeqMem);
|
||||
temporaryMem = DOUBLE_SIZE_ON_64_BIT(preset->temporaryBankMem + preset->temporarySeqMem);
|
||||
totalMem = persistentMem + temporaryMem;
|
||||
@@ -510,7 +515,7 @@ void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
reset_bank_and_seq_load_status();
|
||||
|
||||
for (j = 0; j < 2; j++) {
|
||||
gAudioCmdBuffers[j] = soundAlloc(&gNotesAndBuffersPool, D_80226D6C * 8);
|
||||
gAudioCmdBuffers[j] = soundAlloc(&gNotesAndBuffersPool, gMaxAudioCmds * sizeof(u64));
|
||||
}
|
||||
|
||||
gNotes = soundAlloc(&gNotesAndBuffersPool, gMaxSimultaneousNotes * sizeof(struct Note));
|
||||
@@ -537,17 +542,17 @@ void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
gSynthesisReverb.unk24 = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
gSynthesisReverb.unk28 = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
for (i = 0; i < gAudioUpdatesPerFrame; i++) {
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, 0x280);
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, DEFAULT_LEN_2CH);
|
||||
gSynthesisReverb.items[0][i].toDownsampleLeft = mem;
|
||||
gSynthesisReverb.items[0][i].toDownsampleRight = mem + 0xA0;
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, 0x280);
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, DEFAULT_LEN_2CH);
|
||||
gSynthesisReverb.items[1][i].toDownsampleLeft = mem;
|
||||
gSynthesisReverb.items[1][i].toDownsampleRight = mem + 0xA0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func_8031758C(gMaxSimultaneousNotes);
|
||||
init_sample_dma_buffers(gMaxSimultaneousNotes);
|
||||
osWritebackDCacheAll();
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef _AUDIO_MEMORY_H
|
||||
#define _AUDIO_MEMORY_H
|
||||
#ifndef AUDIO_MEMORY_H
|
||||
#define AUDIO_MEMORY_H
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@@ -49,7 +49,6 @@ struct SoundMultiPool
|
||||
extern u8 gAudioHeap[];
|
||||
extern s16 gVolume;
|
||||
extern s8 gReverbDownsampleRate;
|
||||
extern u8 sReverbDownsampleRateLog;
|
||||
extern struct SoundAllocPool gAudioInitPool;
|
||||
extern struct SoundAllocPool gNotesAndBuffersPool;
|
||||
extern struct SoundMultiPool gSeqLoadedPool;
|
||||
@@ -63,4 +62,4 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 arg2);
|
||||
void audio_reset_session(struct AudioSessionSettings *preset);
|
||||
|
||||
#endif /* _AUDIO_MEMORY_H */
|
||||
#endif /* AUDIO_MEMORY_H */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
s32 note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLayer);
|
||||
|
||||
void func_80318870(struct Note *note) {
|
||||
void note_init(struct Note *note) {
|
||||
if (note->parentLayer->adsr.releaseRate == 0) {
|
||||
adsr_init(¬e->adsr, note->parentLayer->seqChannel->adsr.envelope, ¬e->adsrVolScale);
|
||||
} else {
|
||||
@@ -26,7 +26,7 @@ void note_disable2(struct Note *note) {
|
||||
note_disable(note);
|
||||
}
|
||||
|
||||
void func_80318908(void) {
|
||||
void process_notes(void) {
|
||||
f32 scale;
|
||||
f32 frequency;
|
||||
u8 reverb;
|
||||
@@ -144,7 +144,7 @@ void seq_channel_layer_decay_release_internal(struct SequenceChannelLayer *seqLa
|
||||
return;
|
||||
}
|
||||
|
||||
seqLayer->unk1 = 0;
|
||||
seqLayer->status = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
if (note->adsr.state != ADSR_STATE_DECAY) {
|
||||
attributes->freqScale = seqLayer->noteFreqScale;
|
||||
attributes->velocity = seqLayer->noteVelocity;
|
||||
@@ -183,8 +183,7 @@ void seq_channel_layer_note_release(struct SequenceChannelLayer *seqLayer) {
|
||||
seq_channel_layer_decay_release_internal(seqLayer, ADSR_STATE_RELEASE);
|
||||
}
|
||||
|
||||
// wave synthesizer
|
||||
void func_80318F04(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
void build_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
s32 i;
|
||||
s32 j;
|
||||
s32 pos;
|
||||
@@ -239,9 +238,9 @@ void func_80318F04(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
osWritebackDCache(note->synthesisBuffers->samples, sizeof(note->synthesisBuffers->samples));
|
||||
}
|
||||
|
||||
void func_80319164(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
void init_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
s32 sampleCount = note->sampleCount;
|
||||
func_80318F04(note, seqLayer);
|
||||
build_synthetic_wave(note, seqLayer);
|
||||
if (sampleCount != 0) {
|
||||
note->samplePosInt *= note->sampleCount / sampleCount;
|
||||
} else {
|
||||
@@ -422,14 +421,14 @@ s32 note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLayer
|
||||
note->bankId = seqLayer->seqChannel->bankId;
|
||||
note->stereoHeadsetEffects = seqLayer->seqChannel->stereoHeadsetEffects;
|
||||
note->sound = seqLayer->sound;
|
||||
seqLayer->unk1 = 3;
|
||||
seqLayer->status = SOUND_LOAD_STATUS_DISCARDABLE; // "loaded"
|
||||
seqLayer->note = note;
|
||||
seqLayer->seqChannel->noteUnused = note;
|
||||
seqLayer->seqChannel->layerUnused = seqLayer;
|
||||
if (note->sound == NULL) {
|
||||
func_80318F04(note, seqLayer);
|
||||
build_synthetic_wave(note, seqLayer);
|
||||
}
|
||||
func_80318870(note);
|
||||
note_init(note);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -495,7 +494,7 @@ struct Note *alloc_note(struct SequenceChannelLayer *seqLayer) {
|
||||
if (!(ret = alloc_note_from_disabled(&seqLayer->seqChannel->notePool, seqLayer))
|
||||
&& !(ret = alloc_note_from_decaying(&seqLayer->seqChannel->notePool, seqLayer))
|
||||
&& !(ret = alloc_note_from_active(&seqLayer->seqChannel->notePool, seqLayer))) {
|
||||
seqLayer->unk1 = 0;
|
||||
seqLayer->status = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
@@ -508,7 +507,7 @@ struct Note *alloc_note(struct SequenceChannelLayer *seqLayer) {
|
||||
&& !(ret = alloc_note_from_decaying(&seqLayer->seqChannel->seqPlayer->notePool, seqLayer))
|
||||
&& !(ret = alloc_note_from_active(&seqLayer->seqChannel->notePool, seqLayer))
|
||||
&& !(ret = alloc_note_from_active(&seqLayer->seqChannel->seqPlayer->notePool, seqLayer))) {
|
||||
seqLayer->unk1 = 0;
|
||||
seqLayer->status = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
@@ -518,7 +517,7 @@ struct Note *alloc_note(struct SequenceChannelLayer *seqLayer) {
|
||||
if (!(ret = alloc_note_from_disabled(&gNoteFreeLists, seqLayer))
|
||||
&& !(ret = alloc_note_from_decaying(&gNoteFreeLists, seqLayer))
|
||||
&& !(ret = alloc_note_from_active(&gNoteFreeLists, seqLayer))) {
|
||||
seqLayer->unk1 = 0;
|
||||
seqLayer->status = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
@@ -533,13 +532,13 @@ struct Note *alloc_note(struct SequenceChannelLayer *seqLayer) {
|
||||
&& !(ret = alloc_note_from_active(&seqLayer->seqChannel->notePool, seqLayer))
|
||||
&& !(ret = alloc_note_from_active(&seqLayer->seqChannel->seqPlayer->notePool, seqLayer))
|
||||
&& !(ret = alloc_note_from_active(&gNoteFreeLists, seqLayer))) {
|
||||
seqLayer->unk1 = 0;
|
||||
seqLayer->status = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void func_80319BC8(void) {
|
||||
void reclaim_notes(void) {
|
||||
struct Note *note;
|
||||
s32 i;
|
||||
s32 cond;
|
||||
@@ -559,7 +558,7 @@ void func_80319BC8(void) {
|
||||
note->priority = NOTE_PRIORITY_STOPPING;
|
||||
} else if (note->parentLayer->seqChannel->seqPlayer->muted) {
|
||||
if (note->parentLayer->seqChannel->muteBehavior
|
||||
& (MUTE_BEHAVIOR_80 | MUTE_BEHAVIOR_40)) {
|
||||
& (MUTE_BEHAVIOR_STOP_SCRIPT | MUTE_BEHAVIOR_STOP_NOTES)) {
|
||||
cond = TRUE;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
#define NOTE_ALLOC_SEQ 4
|
||||
#define NOTE_ALLOC_GLOBAL_FREELIST 8
|
||||
|
||||
void func_80318908(void);
|
||||
void process_notes(void);
|
||||
void seq_channel_layer_note_decay(struct SequenceChannelLayer *seqLayer);
|
||||
void seq_channel_layer_note_release(struct SequenceChannelLayer *seqLayer);
|
||||
void func_80319164(struct Note *note, struct SequenceChannelLayer *seqLayer);
|
||||
void init_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLayer);
|
||||
void init_note_lists(struct NotePool *pool);
|
||||
void init_note_free_list(void);
|
||||
void note_pool_clear(struct NotePool *pool);
|
||||
@@ -25,7 +25,7 @@ void note_pool_fill(struct NotePool *pool, s32 count);
|
||||
void audio_list_push_front(struct AudioListItem *list, struct AudioListItem *item);
|
||||
void audio_list_remove(struct AudioListItem *item);
|
||||
struct Note *alloc_note(struct SequenceChannelLayer *seqLayer);
|
||||
void func_80319BC8(void);
|
||||
void reclaim_notes(void);
|
||||
void note_init_all(void);
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,6 @@ void audio_list_push_back(struct AudioListItem *list, struct AudioListItem *item
|
||||
void *audio_list_pop_back(struct AudioListItem *list);
|
||||
void process_sequences(s32 iterationsRemaining);
|
||||
void init_sequence_player(u32 player);
|
||||
void func_8031D4B8(void);
|
||||
void init_sequence_players(void);
|
||||
|
||||
#endif /* _AUDIO_SEQPLAYER_H */
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
#define DMEM_ADDR_WET_LEFT_CH 0x740
|
||||
#define DMEM_ADDR_WET_RIGHT_CH 0x880
|
||||
|
||||
#define DEFAULT_LEN_1CH 0x140
|
||||
#define DEFAULT_LEN_2CH 0x280
|
||||
|
||||
#define aSetLoadBufferPair(pkt, c, off) \
|
||||
aSetBuffer(pkt, 0, c + DMEM_ADDR_WET_LEFT_CH, 0, DEFAULT_LEN_1CH - c); \
|
||||
aLoadBuffer(pkt, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverb.ringBuffer.left[off])); \
|
||||
@@ -49,7 +46,7 @@ struct VolumeChange {
|
||||
};
|
||||
|
||||
u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex);
|
||||
u64 *process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd);
|
||||
u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd);
|
||||
u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad);
|
||||
u64 *final_resample(u64 *cmd, struct Note *note, s32 count, u16 pitch, u16 dmemIn, u32 flags);
|
||||
u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings,
|
||||
@@ -185,7 +182,7 @@ u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateI
|
||||
if (gSynthesisReverb.useReverb == 0) {
|
||||
|
||||
aClearBuffer(cmd++, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
cmd = process_notes(aiBuf, bufLen, cmd);
|
||||
cmd = synthesis_process_notes(aiBuf, bufLen, cmd);
|
||||
} else {
|
||||
if (gReverbDownsampleRate == 1) {
|
||||
// Put the oldest samples in the ring buffer into the wet channels
|
||||
@@ -224,7 +221,7 @@ u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateI
|
||||
/*out*/ DMEM_ADDR_LEFT_CH);
|
||||
aDMEMMove(cmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
}
|
||||
cmd = process_notes(aiBuf, bufLen, cmd);
|
||||
cmd = synthesis_process_notes(aiBuf, bufLen, cmd);
|
||||
if (gReverbDownsampleRate == 1) {
|
||||
aSetSaveBufferPair(cmd++, 0, v1->lengths[0], v1->startPos);
|
||||
if (v1->lengths[1] != 0) {
|
||||
@@ -246,7 +243,7 @@ u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateI
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
u64 *process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
s32 noteIndex; // sp174
|
||||
struct Note *note; // s7
|
||||
struct AudioBankSample *audioBookSample; // sp164
|
||||
@@ -571,9 +568,9 @@ u64 *process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
}
|
||||
|
||||
#elif defined(VERSION_JP)
|
||||
GLOBAL_ASM("asm/non_matchings/process_notes_jp.s")
|
||||
GLOBAL_ASM("asm/non_matchings/synthesis_process_notes_jp.s")
|
||||
#else
|
||||
GLOBAL_ASM("asm/non_matchings/process_notes_us.s")
|
||||
GLOBAL_ASM("asm/non_matchings/synthesis_process_notes_us.s")
|
||||
#endif
|
||||
|
||||
u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#ifndef _AUDIO_SYNTHESIS_H
|
||||
#define _AUDIO_SYNTHESIS_H
|
||||
#ifndef AUDIO_SYNTHESIS_H
|
||||
#define AUDIO_SYNTHESIS_H
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#define DEFAULT_LEN_1CH 0x140
|
||||
#define DEFAULT_LEN_2CH 0x280
|
||||
|
||||
#define MAX_UPDATES_PER_FRAME 4
|
||||
|
||||
struct ReverbRingBufferItem
|
||||
@@ -46,4 +49,4 @@ void note_set_frequency(struct Note *note, f32 frequency);
|
||||
void note_enable(struct Note *note);
|
||||
void note_disable(struct Note *note);
|
||||
|
||||
#endif /* _AUDIO_SYNTHESIS_H */
|
||||
#endif /* AUDIO_SYNTHESIS_H */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "sm64.h"
|
||||
|
||||
// 0x70800 bytes
|
||||
#if BUGFIXES_CRITICAL
|
||||
#ifdef AVOID_UB
|
||||
u16 gFrameBuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT];
|
||||
#else
|
||||
u16 gFrameBuffer0[SCREEN_WIDTH * SCREEN_HEIGHT];
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// level_script.c assumes that the frame buffers are adjacent, while game.c's
|
||||
// -g codegen implies that they are separate variables. This is impossible to
|
||||
// reconcile without undefined behavior. Avoid that on non-IDO.
|
||||
#if BUGFIXES_CRITICAL
|
||||
// reconcile without undefined behavior. Avoid that when possible.
|
||||
#ifdef AVOID_UB
|
||||
extern u16 gFrameBuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT];
|
||||
#define gFrameBuffer0 gFrameBuffers[0]
|
||||
#define gFrameBuffer1 gFrameBuffers[1]
|
||||
|
||||
5
src/buffers/zbuffer.c
Normal file
5
src/buffers/zbuffer.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <ultra64.h>
|
||||
|
||||
#include "zbuffer.h"
|
||||
|
||||
ALIGNED8 u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT];
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user