Refresh 7
This commit is contained in:
1 parent
9a801cb96d
commit
06ec56df7f
414 files changed
+7705
-10209
No files matched your search
+5
-5
@@ -4,10 +4,10 @@
|
||||
#include "data.h"
|
||||
#include "effects.h"
|
||||
|
||||
extern struct OSMesgQueue *OSMesgQueue0;
|
||||
extern struct OSMesgQueue *OSMesgQueue1;
|
||||
extern struct OSMesgQueue *OSMesgQueue2;
|
||||
extern struct OSMesgQueue *OSMesgQueue3;
|
||||
extern struct OSMesgQueue OSMesgQueue0;
|
||||
extern struct OSMesgQueue OSMesgQueue1;
|
||||
extern struct OSMesgQueue OSMesgQueue2;
|
||||
extern struct OSMesgQueue OSMesgQueue3;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
struct ReverbSettingsEU sReverbSettings[] = {
|
||||
@@ -182,7 +182,7 @@ struct AdsrEnvelope gDefaultEnvelope[] = {
|
||||
|
||||
#ifdef VERSION_EU
|
||||
struct NoteSubEu gZeroNoteSub = { 0 };
|
||||
struct NoteSubEu gDefaultNoteSub = { 1, 1 };
|
||||
struct NoteSubEu gDefaultNoteSub = { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL } };
|
||||
|
||||
s16 sSawtoothWaves[256] = {
|
||||
0, 1023, 2047, 3071, 4095, 5119, 6143, 7167, 8191, 9215, 10239,
|
||||
|
||||
+51
-98
@@ -13,47 +13,68 @@
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
void sequence_channel_process_sound(struct SequenceChannel *seqChannel, s32 arg1) {
|
||||
f32 weight;
|
||||
static void sequence_channel_process_sound(struct SequenceChannel *seqChannel, s32 recalculateVolume) {
|
||||
f32 channelVolume;
|
||||
s32 i;
|
||||
|
||||
if (seqChannel->unk1.as_bitfields.unk0b40 || arg1) {
|
||||
weight = seqChannel->volume * seqChannel->volumeScale * seqChannel->seqPlayer->unkEu2C;
|
||||
if (seqChannel->changes.as_bitfields.volume || recalculateVolume) {
|
||||
channelVolume = seqChannel->volume * seqChannel->volumeScale * seqChannel->seqPlayer->appliedFadeVolume;
|
||||
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0) {
|
||||
weight = seqChannel->seqPlayer->muteVolumeScale * weight;
|
||||
channelVolume = seqChannel->seqPlayer->muteVolumeScale * channelVolume;
|
||||
}
|
||||
seqChannel->panChannelWeight = weight;
|
||||
seqChannel->appliedVolume = channelVolume;
|
||||
}
|
||||
|
||||
if (seqChannel->unk1.as_bitfields.unk0b20) {
|
||||
seqChannel->pan = seqChannel->unk9 * seqChannel->unkA;
|
||||
if (seqChannel->changes.as_bitfields.pan) {
|
||||
seqChannel->pan = seqChannel->newPan * seqChannel->panChannelWeight;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; ++i) {
|
||||
struct SequenceChannelLayer *layer = seqChannel->layers[i];
|
||||
if (layer && layer->enabled && layer->note) {
|
||||
if (layer->unkEu0b4) {
|
||||
if (layer != NULL && layer->enabled && layer->note != NULL) {
|
||||
if (layer->notePropertiesNeedInit) {
|
||||
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale;
|
||||
layer->noteVelocity = layer->velocitySquare * seqChannel->panChannelWeight;
|
||||
layer->notePan = (seqChannel->pan + layer->euUnk5 * (0x80 - seqChannel->unkA)) >> 7;
|
||||
layer->unkEu0b4 = 0;
|
||||
layer->noteVelocity = layer->velocitySquare * seqChannel->appliedVolume;
|
||||
layer->notePan = (seqChannel->pan + layer->pan * (0x80 - seqChannel->panChannelWeight)) >> 7;
|
||||
layer->notePropertiesNeedInit = FALSE;
|
||||
} else {
|
||||
if (seqChannel->unk1.as_bitfields.unk0b80) {
|
||||
if (seqChannel->changes.as_bitfields.freqScale) {
|
||||
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale;
|
||||
}
|
||||
if (seqChannel->unk1.as_bitfields.unk0b40 || arg1) {
|
||||
layer->noteVelocity = layer->velocitySquare * seqChannel->panChannelWeight;
|
||||
if (seqChannel->changes.as_bitfields.volume || recalculateVolume) {
|
||||
layer->noteVelocity = layer->velocitySquare * seqChannel->appliedVolume;
|
||||
}
|
||||
if (seqChannel->unk1.as_bitfields.unk0b20) {
|
||||
layer->notePan = (seqChannel->pan + layer->euUnk5 * (0x80 - seqChannel->unkA)) >> 7;
|
||||
if (seqChannel->changes.as_bitfields.pan) {
|
||||
layer->notePan = (seqChannel->pan + layer->pan * (0x80 - seqChannel->panChannelWeight)) >> 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
seqChannel->unk1.as_u8 = 0;
|
||||
seqChannel->changes.as_u8 = 0;
|
||||
}
|
||||
#else
|
||||
void func_80319E70(void) {
|
||||
static void sequence_channel_process_sound(struct SequenceChannel *seqChannel) {
|
||||
f32 channelVolume;
|
||||
f32 panLayerWeight;
|
||||
f32 panFromChannel;
|
||||
s32 i;
|
||||
|
||||
channelVolume = seqChannel->volume * seqChannel->volumeScale * seqChannel->seqPlayer->fadeVolume;
|
||||
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0) {
|
||||
channelVolume *= seqChannel->seqPlayer->muteVolumeScale;
|
||||
}
|
||||
|
||||
panFromChannel = seqChannel->pan * seqChannel->panChannelWeight;
|
||||
panLayerWeight = US_FLOAT(1.0) - seqChannel->panChannelWeight;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
struct SequenceChannelLayer *layer = seqChannel->layers[i];
|
||||
if (layer != NULL && layer->enabled && layer->note != NULL) {
|
||||
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale;
|
||||
layer->noteVelocity = layer->velocitySquare * channelVolume;
|
||||
layer->notePan = (layer->pan * panLayerWeight) + panFromChannel;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -63,7 +84,7 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
|
||||
if (seqPlayer->fadeTimer != 0) {
|
||||
seqPlayer->fadeVolume += seqPlayer->fadeVelocity;
|
||||
#ifdef VERSION_EU
|
||||
seqPlayer->unk_eu = TRUE;
|
||||
seqPlayer->recalculateVolume = TRUE;
|
||||
#endif
|
||||
|
||||
if (seqPlayer->fadeVolume > US_FLOAT2(1)) {
|
||||
@@ -98,8 +119,8 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (seqPlayer->unk_eu) {
|
||||
seqPlayer->unkEu2C = seqPlayer->fadeVolume * seqPlayer->unkEu28;
|
||||
if (seqPlayer->recalculateVolume) {
|
||||
seqPlayer->appliedFadeVolume = seqPlayer->fadeVolume * seqPlayer->fadeVolumeScale;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -108,37 +129,15 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
|
||||
if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE
|
||||
&& seqPlayer->channels[i]->enabled == TRUE) {
|
||||
#ifdef VERSION_EU
|
||||
sequence_channel_process_sound(seqPlayer->channels[i], seqPlayer->unk_eu);
|
||||
sequence_channel_process_sound(seqPlayer->channels[i], seqPlayer->recalculateVolume);
|
||||
#else
|
||||
f32 channelVolume;
|
||||
f32 panLayerWeight;
|
||||
f32 panFromChannel;
|
||||
s32 layerIndex;
|
||||
struct SequenceChannel *seqChannel = seqPlayer->channels[i];
|
||||
|
||||
channelVolume =
|
||||
seqChannel->seqPlayer->fadeVolume * (seqChannel->volume * seqChannel->volumeScale);
|
||||
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0) {
|
||||
channelVolume *= seqChannel->seqPlayer->muteVolumeScale;
|
||||
}
|
||||
|
||||
panFromChannel = seqChannel->panChannelWeight * seqChannel->pan;
|
||||
panLayerWeight = US_FLOAT(1.0) - seqChannel->panChannelWeight;
|
||||
|
||||
for (layerIndex = 0; layerIndex < 4; layerIndex++) {
|
||||
struct SequenceChannelLayer *seqLayer = seqChannel->layers[layerIndex];
|
||||
if (seqLayer != NULL && seqLayer->enabled && seqLayer->note != NULL) {
|
||||
seqLayer->noteFreqScale = seqChannel->freqScale * seqLayer->freqScale;
|
||||
seqLayer->noteVelocity = seqLayer->velocitySquare * channelVolume;
|
||||
seqLayer->notePan = (seqLayer->pan * panLayerWeight) + panFromChannel;
|
||||
}
|
||||
}
|
||||
sequence_channel_process_sound(seqPlayer->channels[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
seqPlayer->unk_eu = FALSE;
|
||||
seqPlayer->recalculateVolume = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -224,18 +223,10 @@ f32 get_vibrato_freq_scale(struct VibratoState *vib) {
|
||||
}
|
||||
|
||||
vib->extentChangeTimer--;
|
||||
#ifdef VERSION_EU
|
||||
} else if ((s32) vib->extent != (*vib).seqChannel->vibratoExtentTarget) {
|
||||
} else if (vib->seqChannel->vibratoExtentTarget != (s32) vib->extent) {
|
||||
if ((vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay) == 0) {
|
||||
vib->extent = (s32) vib->seqChannel->vibratoExtentTarget;
|
||||
}
|
||||
#else
|
||||
} else if ((s32) vib->extent != vib->seqChannel->vibratoExtentTarget) {
|
||||
vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay;
|
||||
if (vib->extentChangeTimer == 0) {
|
||||
vib->extent = (s32) vib->seqChannel->vibratoExtentTarget;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (vib->rateChangeTimer) {
|
||||
@@ -246,18 +237,10 @@ f32 get_vibrato_freq_scale(struct VibratoState *vib) {
|
||||
}
|
||||
|
||||
vib->rateChangeTimer--;
|
||||
#ifdef VERSION_EU
|
||||
} else if ((s32) vib->rate != (*vib).seqChannel->vibratoRateTarget) {
|
||||
} else if (vib->seqChannel->vibratoRateTarget != (s32) vib->rate) {
|
||||
if ((vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay) == 0) {
|
||||
vib->rate = (s32) vib->seqChannel->vibratoRateTarget;
|
||||
}
|
||||
#else
|
||||
} else if ((s32) vib->rate != vib->seqChannel->vibratoRateTarget) {
|
||||
vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay;
|
||||
if (vib->rateChangeTimer == 0) {
|
||||
vib->rate = (s32) vib->seqChannel->vibratoRateTarget;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (vib->extent == 0) {
|
||||
@@ -339,15 +322,13 @@ void note_vibrato_init(struct Note *note) {
|
||||
vib->seqChannel = note->parentLayer->seqChannel;
|
||||
seqChannel = vib->seqChannel;
|
||||
|
||||
vib->extentChangeTimer = seqChannel->vibratoExtentChangeDelay;
|
||||
if (vib->extentChangeTimer == 0) {
|
||||
if ((vib->extentChangeTimer = seqChannel->vibratoExtentChangeDelay) == 0) {
|
||||
vib->extent = seqChannel->vibratoExtentTarget;
|
||||
} else {
|
||||
vib->extent = seqChannel->vibratoExtentStart;
|
||||
}
|
||||
|
||||
vib->rateChangeTimer = seqChannel->vibratoRateChangeDelay;
|
||||
if (vib->rateChangeTimer == 0) {
|
||||
if ((vib->rateChangeTimer = seqChannel->vibratoRateChangeDelay) == 0) {
|
||||
vib->rate = seqChannel->vibratoRateTarget;
|
||||
} else {
|
||||
vib->rate = seqChannel->vibratoRateStart;
|
||||
@@ -396,11 +377,7 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
#endif
|
||||
if (action & ADSR_ACTION_HANG) {
|
||||
adsr->state = ADSR_STATE_HANG;
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
}
|
||||
// fallthrough
|
||||
}
|
||||
@@ -446,11 +423,7 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
break;
|
||||
}
|
||||
if (adsr->state != ADSR_STATE_FADE) {
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
@@ -467,11 +440,7 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_HANG:
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
|
||||
case ADSR_STATE_DECAY:
|
||||
case ADSR_STATE_RELEASE: {
|
||||
@@ -490,11 +459,7 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
#endif
|
||||
adsr->state = ADSR_STATE_SUSTAIN;
|
||||
}
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
@@ -508,11 +473,7 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
adsr->state = ADSR_STATE_DISABLED;
|
||||
}
|
||||
#endif
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
}
|
||||
|
||||
case ADSR_STATE_SUSTAIN:
|
||||
@@ -520,17 +481,9 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
if (adsr->delay == 0) {
|
||||
adsr->state = ADSR_STATE_RELEASE;
|
||||
}
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef VERSION_EU
|
||||
CONT:
|
||||
#endif
|
||||
|
||||
if ((action & ADSR_ACTION_DECAY)) {
|
||||
adsr->state = ADSR_STATE_DECAY;
|
||||
adsr->action = action & ~ADSR_ACTION_DECAY;
|
||||
|
||||
+8
-16
@@ -1,6 +1,6 @@
|
||||
#include <ultra64.h>
|
||||
#include "sm64.h"
|
||||
#include "memory.h"
|
||||
#include "heap.h"
|
||||
#include "load.h"
|
||||
#include "data.h"
|
||||
#include "seqplayer.h"
|
||||
@@ -753,10 +753,8 @@ void func_8031D838(s32 player, FadeT fadeInTime, u8 targetVolume) {
|
||||
#ifdef VERSION_EU
|
||||
extern void func_802ad7a0(void);
|
||||
|
||||
void maybe_tick_game_sound(void)
|
||||
{
|
||||
if (sGameLoopTicked != 0)
|
||||
{
|
||||
void maybe_tick_game_sound(void) {
|
||||
if (sGameLoopTicked != 0) {
|
||||
update_game_sound();
|
||||
sGameLoopTicked = 0;
|
||||
}
|
||||
@@ -764,6 +762,7 @@ void maybe_tick_game_sound(void)
|
||||
}
|
||||
|
||||
void func_eu_802e9bec(s32 player, s32 channel, s32 arg2) {
|
||||
// EU verson of unused_803209D8
|
||||
// chan->stopSomething2 = arg2?
|
||||
func_802ad770(0x08000000 | (player & 0xff) << 16 | (channel & 0xff) << 8, (s8) arg2);
|
||||
}
|
||||
@@ -1607,12 +1606,6 @@ void update_game_sound(void) {
|
||||
#undef ARG2_VAL1
|
||||
#undef ARG2_VAL2
|
||||
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
// Just regalloc differences
|
||||
void play_sequence(u8 player, u8 seqId, u16 fadeTimer);
|
||||
GLOBAL_ASM("asm/non_matchings/eu/play_sequence.s")
|
||||
#else
|
||||
|
||||
void play_sequence(u8 player, u8 seqId, u16 fadeTimer) {
|
||||
u8 temp_ret;
|
||||
u8 i;
|
||||
@@ -1629,13 +1622,13 @@ void play_sequence(u8 player, u8 seqId, u16 fadeTimer) {
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
func_802ad770(0x46000000 | (player & 0xff) << 16, seqId & 0x80);
|
||||
func_802ad74c(0x82000000 | (player & 0xff) << 16 | ((seqId & 0x7f) & 0xff) << 8, fadeTimer);
|
||||
func_802ad770(0x46000000 | ((u8)(u32)player) << 16, seqId & 0x80);
|
||||
func_802ad74c(0x82000000 | ((u8)(u32)player) << 16 | ((u8)(seqId & 0x7f)) << 8, fadeTimer);
|
||||
|
||||
if (player == 0) {
|
||||
temp_ret = func_803200E4(0);
|
||||
if (temp_ret != 0xff) {
|
||||
gSequencePlayers[0].unkEu28 = (f32) temp_ret / US_FLOAT(127.0);
|
||||
gSequencePlayers[0].fadeVolumeScale = (f32) temp_ret / US_FLOAT(127.0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -1653,7 +1646,6 @@ void play_sequence(u8 player, u8 seqId, u16 fadeTimer) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void sequence_player_fade_out(u8 player, u16 fadeTimer) {
|
||||
#ifdef VERSION_EU
|
||||
@@ -2440,7 +2432,7 @@ void sound_reset(u8 presetId) {
|
||||
sGameLoopTicked = 0;
|
||||
disable_all_sequence_players();
|
||||
sound_init();
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
#if defined(VERSION_JP) || defined(VERSION_US) || defined(VERSION_SH)
|
||||
audio_reset_session(&gAudioSessionPresets[presetId]);
|
||||
#else
|
||||
audio_reset_session_eu(presetId);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <ultra64.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include "memory.h"
|
||||
#include "heap.h"
|
||||
#include "data.h"
|
||||
#include "load.h"
|
||||
#include "synthesis.h"
|
||||
@@ -31,7 +31,7 @@ u8 sReverbDownsampleRateLog; // never read
|
||||
struct SoundAllocPool gAudioSessionPool;
|
||||
struct SoundAllocPool gAudioInitPool;
|
||||
struct SoundAllocPool gNotesAndBuffersPool;
|
||||
u8 sAudioMemoryPad[0x20]; // probably two unused pools
|
||||
u8 sAudioHeapPad[0x20]; // probably two unused pools
|
||||
struct SoundAllocPool gSeqAndBankPool;
|
||||
struct SoundAllocPool gPersistentCommonPool;
|
||||
struct SoundAllocPool gTemporaryCommonPool;
|
||||
@@ -95,8 +95,7 @@ f64 root_newton_step(f64 x, s32 k, f64 d)
|
||||
*
|
||||
* @return the root, or 1.0 if d is 0
|
||||
*/
|
||||
f64 kth_root(f64 d, s32 k)
|
||||
{
|
||||
f64 kth_root(f64 d, s32 k) {
|
||||
f64 root = 1.5;
|
||||
f64 next;
|
||||
f64 diff;
|
||||
@@ -128,7 +127,7 @@ f64 kth_root(f64 d, s32 k)
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
void func_eu_802e1cd0(s32 UNUSED unused, s32 len) {
|
||||
void build_vol_rampings_table(s32 UNUSED unused, s32 len) {
|
||||
s32 i;
|
||||
s32 step;
|
||||
s32 d;
|
||||
@@ -308,30 +307,34 @@ static void unused_803163D4() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/alloc_bank_or_seq.s")
|
||||
#else
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg3, s32 id) {
|
||||
// arg3 = 0, 1 or 2?
|
||||
|
||||
u8 *table; // sp5C
|
||||
u8 isSound; // sp5B
|
||||
struct TemporaryPool *tp; // sp30
|
||||
struct PersistentPool *persistent = &arg0->persistent;
|
||||
struct SoundAllocPool *pool;
|
||||
void *ret;
|
||||
u32 firstVal;
|
||||
u32 secondVal;
|
||||
#ifndef VERSION_EU
|
||||
u16 UNUSED _firstVal;
|
||||
u16 UNUSED _secondVal;
|
||||
#else
|
||||
u16 firstVal;
|
||||
u16 secondVal;
|
||||
#endif
|
||||
u32 nullID = -1;
|
||||
u8 *table;
|
||||
u8 isSound;
|
||||
#ifndef VERSION_EU
|
||||
u16 firstVal;
|
||||
u16 secondVal;
|
||||
u32 bothDiscardable;
|
||||
u32 leftDiscardable, rightDiscardable;
|
||||
u32 leftNotLoaded, rightNotLoaded;
|
||||
u32 leftAvail, rightAvail;
|
||||
UNUSED s32 temp;
|
||||
struct TemporaryPool *v1; // sp30
|
||||
struct PersistentPool *persistent = &arg0->persistent;
|
||||
#endif
|
||||
|
||||
if (arg3 == 0) {
|
||||
v1 = &arg0->temporary;
|
||||
tp = &arg0->temporary;
|
||||
if (arg0 == &gSeqLoadedPool) {
|
||||
table = gSeqLoadStatus;
|
||||
isSound = FALSE;
|
||||
@@ -340,10 +343,10 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
isSound = TRUE;
|
||||
}
|
||||
|
||||
firstVal = (v1->entries[0].id == -1 ? SOUND_LOAD_STATUS_NOT_LOADED
|
||||
: table[v1->entries[0].id]); // a3, a2
|
||||
secondVal =
|
||||
(v1->entries[1].id == -1 ? SOUND_LOAD_STATUS_NOT_LOADED : table[v1->entries[1].id]); // a1
|
||||
firstVal = (tp->entries[0].id == (s8)nullID ? SOUND_LOAD_STATUS_NOT_LOADED : table[tp->entries[0].id]); // a3, a2
|
||||
secondVal = (tp->entries[1].id == (s8)nullID ? SOUND_LOAD_STATUS_NOT_LOADED : table[tp->entries[1].id]); // a1
|
||||
|
||||
#ifndef VERSION_EU
|
||||
leftNotLoaded = (firstVal == SOUND_LOAD_STATUS_NOT_LOADED);
|
||||
leftDiscardable = (firstVal == SOUND_LOAD_STATUS_DISCARDABLE); // t0
|
||||
leftAvail = (firstVal != SOUND_LOAD_STATUS_IN_PROGRESS);
|
||||
@@ -353,83 +356,111 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
bothDiscardable = (leftDiscardable && rightDiscardable); // a0
|
||||
|
||||
if (leftNotLoaded) {
|
||||
v1->nextSide = 0;
|
||||
tp->nextSide = 0;
|
||||
} else if (rightNotLoaded) {
|
||||
v1->nextSide = 1;
|
||||
tp->nextSide = 1;
|
||||
} else if (bothDiscardable) {
|
||||
// Use the opposite side from last time.
|
||||
} else if (leftDiscardable) {
|
||||
v1->nextSide = 0;
|
||||
} else if (firstVal == SOUND_LOAD_STATUS_DISCARDABLE) { //??!
|
||||
tp->nextSide = 0;
|
||||
} else if (rightDiscardable) {
|
||||
v1->nextSide = 1;
|
||||
tp->nextSide = 1;
|
||||
} else if (leftAvail) {
|
||||
v1->nextSide = 0;
|
||||
tp->nextSide = 0;
|
||||
} else if (rightAvail) {
|
||||
v1->nextSide = 1;
|
||||
tp->nextSide = 1;
|
||||
} else {
|
||||
// Both left and right sides are being loaded into.
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
if (firstVal == SOUND_LOAD_STATUS_NOT_LOADED) {
|
||||
tp->nextSide = 0;
|
||||
} else if (secondVal == SOUND_LOAD_STATUS_NOT_LOADED) {
|
||||
tp->nextSide = 1;
|
||||
} else if ((firstVal == SOUND_LOAD_STATUS_DISCARDABLE) && (secondVal == SOUND_LOAD_STATUS_DISCARDABLE)) {
|
||||
// Use the opposite side from last time.
|
||||
} else if (firstVal == SOUND_LOAD_STATUS_DISCARDABLE) {
|
||||
tp->nextSide = 0;
|
||||
} else if (secondVal == SOUND_LOAD_STATUS_DISCARDABLE) {
|
||||
tp->nextSide = 1;
|
||||
} else if (firstVal != SOUND_LOAD_STATUS_IN_PROGRESS) {
|
||||
tp->nextSide = 0;
|
||||
} else if (secondVal != SOUND_LOAD_STATUS_IN_PROGRESS) {
|
||||
tp->nextSide = 1;
|
||||
} else {
|
||||
// Both left and right sides are being loaded into.
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (v1->entries[v1->nextSide].id != -1) {
|
||||
table[v1->entries[v1->nextSide].id] = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
pool = &arg0->temporary.pool; // a1
|
||||
if (tp->entries[tp->nextSide].id != (s8)nullID) {
|
||||
table[tp->entries[tp->nextSide].id] = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
if (isSound == TRUE) {
|
||||
discard_bank(v1->entries[v1->nextSide].id);
|
||||
discard_bank(tp->entries[tp->nextSide].id);
|
||||
}
|
||||
}
|
||||
|
||||
pool = &arg0->temporary.pool; // a1
|
||||
switch (v1->nextSide) {
|
||||
switch (tp->nextSide) {
|
||||
case 0:
|
||||
v1->entries[0].ptr = pool->start;
|
||||
v1->entries[0].id = id;
|
||||
v1->entries[0].size = size;
|
||||
tp->entries[0].ptr = pool->start;
|
||||
tp->entries[0].id = id;
|
||||
tp->entries[0].size = size;
|
||||
|
||||
pool->cur = pool->start + size;
|
||||
|
||||
if (v1->entries[1].ptr < pool->cur) {
|
||||
if (tp->entries[1].ptr < pool->cur) {
|
||||
// Throw out the entry on the other side if it doesn't fit.
|
||||
// (possible @bug: what if it's currently being loaded?)
|
||||
table[v1->entries[1].id] = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
table[tp->entries[1].id] = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
|
||||
switch (isSound) {
|
||||
case FALSE:
|
||||
discard_sequence(v1->entries[1].id);
|
||||
discard_sequence(tp->entries[1].id);
|
||||
break;
|
||||
case TRUE:
|
||||
discard_bank(v1->entries[1].id);
|
||||
discard_bank(tp->entries[1].id);
|
||||
break;
|
||||
}
|
||||
|
||||
v1->entries[1].id = -1;
|
||||
v1->entries[1].ptr = pool->size + pool->start;
|
||||
tp->entries[1].id = (s32)nullID;
|
||||
#ifdef VERSION_EU
|
||||
tp->entries[1].ptr = pool->start + pool->size;
|
||||
#else
|
||||
tp->entries[1].ptr = pool->size + pool->start;
|
||||
#endif
|
||||
}
|
||||
|
||||
ret = v1->entries[0].ptr;
|
||||
ret = tp->entries[0].ptr;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
v1->entries[1].ptr = pool->size + pool->start - size - 0x10;
|
||||
v1->entries[1].id = id;
|
||||
v1->entries[1].size = size;
|
||||
#ifdef VERSION_EU
|
||||
tp->entries[1].ptr = pool->start + pool->size - size - 0x10;
|
||||
#else
|
||||
tp->entries[1].ptr = pool->size + pool->start - size - 0x10;
|
||||
#endif
|
||||
tp->entries[1].id = id;
|
||||
tp->entries[1].size = size;
|
||||
|
||||
if (v1->entries[1].ptr < pool->cur) {
|
||||
table[v1->entries[0].id] = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
if (tp->entries[1].ptr < pool->cur) {
|
||||
table[tp->entries[0].id] = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
|
||||
switch (isSound) {
|
||||
case FALSE:
|
||||
discard_sequence(v1->entries[0].id);
|
||||
discard_sequence(tp->entries[0].id);
|
||||
break;
|
||||
case TRUE:
|
||||
discard_bank(v1->entries[0].id);
|
||||
discard_bank(tp->entries[0].id);
|
||||
break;
|
||||
}
|
||||
|
||||
v1->entries[0].id = -1;
|
||||
tp->entries[0].id = (s32)nullID;
|
||||
pool->cur = pool->start;
|
||||
}
|
||||
|
||||
ret = v1->entries[1].ptr;
|
||||
ret = tp->entries[1].ptr;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -438,19 +469,31 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
|
||||
// Switch sides for next time in case both entries are
|
||||
// SOUND_LOAD_STATUS_DISCARDABLE.
|
||||
v1->nextSide ^= 1;
|
||||
tp->nextSide ^= 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
ret = soundAlloc(&arg0->persistent.pool, arg1 * size);
|
||||
arg0->persistent.entries[arg0->persistent.numEntries].ptr = ret;
|
||||
|
||||
if (ret == NULL)
|
||||
#else
|
||||
persistent->entries[persistent->numEntries].ptr = soundAlloc(&persistent->pool, arg1 * size);
|
||||
|
||||
if (persistent->entries[persistent->numEntries].ptr == NULL) {
|
||||
if (persistent->entries[persistent->numEntries].ptr == NULL)
|
||||
#endif
|
||||
{
|
||||
switch (arg3) {
|
||||
case 2:
|
||||
#ifdef VERSION_EU
|
||||
return alloc_bank_or_seq(arg0, arg1, size, 0, id);
|
||||
#else
|
||||
// Prevent tail call optimization.
|
||||
ret = alloc_bank_or_seq(arg0, arg1, size, 0, id);
|
||||
return ret;
|
||||
#endif
|
||||
case 1:
|
||||
return NULL;
|
||||
}
|
||||
@@ -460,14 +503,12 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
// Because the buffer is small enough that more don't fit?
|
||||
persistent->entries[persistent->numEntries].id = id;
|
||||
persistent->entries[persistent->numEntries].size = size;
|
||||
persistent->numEntries++;
|
||||
return persistent->entries[persistent->numEntries - 1].ptr;
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
return persistent->entries[persistent->numEntries++].ptr;
|
||||
#else
|
||||
GLOBAL_ASM("asm/non_matchings/alloc_bank_or_seq.s")
|
||||
#endif
|
||||
persistent->numEntries++; return persistent->entries[persistent->numEntries - 1].ptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id) {
|
||||
u32 i;
|
||||
@@ -548,7 +589,7 @@ void decrease_reverb_gain(void) {
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
s32 func_eu_802E2AA0(void) {
|
||||
s32 audio_shut_down_and_reset_step(void) {
|
||||
s32 i;
|
||||
s32 j;
|
||||
switch (gAudioResetStatus) {
|
||||
@@ -621,7 +662,6 @@ void wait_for_audio_frames(s32 frames) {
|
||||
void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
#else
|
||||
void audio_reset_session(void) {
|
||||
// TODO: verify compilation again and try to match better
|
||||
struct AudioSessionSettingsEU *preset = &gAudioSessionPresets[gAudioResetPresetIdToLoad];
|
||||
struct ReverbSettingsEU *reverbSettings;
|
||||
#endif
|
||||
@@ -886,7 +926,7 @@ void audio_reset_session(void) {
|
||||
init_sample_dma_buffers(gMaxSimultaneousNotes);
|
||||
|
||||
#ifdef VERSION_EU
|
||||
func_eu_802e1cd0(0, gAudioBufferParameters.samplesPerUpdate);
|
||||
build_vol_rampings_table(0, gAudioBufferParameters.samplesPerUpdate);
|
||||
#endif
|
||||
|
||||
osWritebackDCacheAll();
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef AUDIO_MEMORY_H
|
||||
#define AUDIO_MEMORY_H
|
||||
#ifndef AUDIO_HEAP_H
|
||||
#define AUDIO_HEAP_H
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@@ -63,9 +63,10 @@ void sound_init_main_pools(s32 sizeForAudioInitPool);
|
||||
void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg3, s32 id);
|
||||
void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 arg2);
|
||||
#ifdef VERSION_EU
|
||||
s32 audio_shut_down_and_reset_step(void);
|
||||
void audio_reset_session(void);
|
||||
#else
|
||||
void audio_reset_session(struct AudioSessionSettings *preset);
|
||||
#endif
|
||||
|
||||
#endif /* AUDIO_MEMORY_H */
|
||||
#endif /* AUDIO_HEAP_H */
|
||||
+45
-22
@@ -215,7 +215,7 @@ struct SequencePlayer
|
||||
/*0x000, 0x000*/ u8 seqDmaInProgress : 1;
|
||||
/*0x000, 0x000*/ u8 bankDmaInProgress : 1;
|
||||
#ifdef VERSION_EU
|
||||
/* 0x000*/ u8 unk_eu : 1;
|
||||
/* 0x000*/ u8 recalculateVolume : 1;
|
||||
#endif
|
||||
#ifndef VERSION_EU
|
||||
/*0x001 */ s8 seqVariation;
|
||||
@@ -251,8 +251,8 @@ struct SequencePlayer
|
||||
/*0x020, 0x020*/ f32 volume; // set to 0.0f
|
||||
/*0x024, 0x024*/ f32 muteVolumeScale; // set to 0.5f
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x028*/ f32 unkEu28;
|
||||
/* , 0x02C*/ f32 unkEu2C;
|
||||
/* , 0x028*/ f32 fadeVolumeScale;
|
||||
/* , 0x02C*/ f32 appliedFadeVolume;
|
||||
#else
|
||||
/* */ u8 pad2[4];
|
||||
#endif
|
||||
@@ -340,12 +340,12 @@ struct SequenceChannel
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x01*/ union {
|
||||
struct {
|
||||
u8 unk0b80 : 1;
|
||||
u8 unk0b40 : 1;
|
||||
u8 unk0b20 : 1;
|
||||
u8 freqScale : 1;
|
||||
u8 volume : 1;
|
||||
u8 pan : 1;
|
||||
} as_bitfields;
|
||||
u8 as_u8;
|
||||
} unk1;
|
||||
} changes;
|
||||
#endif
|
||||
/*0x01, 0x02*/ u8 noteAllocPolicy;
|
||||
/*0x02, 0x03*/ u8 muteBehavior;
|
||||
@@ -354,9 +354,9 @@ struct SequenceChannel
|
||||
/*0x05, 0x06*/ u8 bankId;
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x07*/ u8 reverbIndex;
|
||||
/* , 0x08*/ u8 unk8;
|
||||
/* , 0x09*/ u8 unk9;
|
||||
/* , 0x0A*/ u8 unkA;
|
||||
/* , 0x08*/ u8 bookOffset;
|
||||
/* , 0x09*/ u8 newPan;
|
||||
/* , 0x0A*/ u8 panChannelWeight; // proportion of pan that comes from the channel (0..128)
|
||||
#else
|
||||
/*0x06, */ u8 updatesPerFrameUnused;
|
||||
#endif
|
||||
@@ -374,11 +374,12 @@ struct SequenceChannel
|
||||
/*0x1C, 0x20*/ f32 volumeScale;
|
||||
/*0x20, 0x24*/ f32 volume;
|
||||
#ifndef VERSION_EU
|
||||
/*0x24, 0x28*/ f32 pan;
|
||||
/*0x24, */ f32 pan;
|
||||
/*0x28, */ f32 panChannelWeight; // proportion of pan that comes from the channel (0..1)
|
||||
#else
|
||||
/*0x24, 0x28*/ s32 pan;
|
||||
/* , 0x28*/ s32 pan;
|
||||
/* , 0x2C*/ f32 appliedVolume;
|
||||
#endif
|
||||
/*0x28, 0x2C*/ f32 panChannelWeight; // proportion of pan that comes from the channel (0..1)
|
||||
/*0x2C, 0x30*/ f32 freqScale;
|
||||
/*0x30, 0x34*/ u8 (*dynTable)[][2];
|
||||
/*0x34, ????*/ struct Note *noteUnused; // never read
|
||||
@@ -401,16 +402,16 @@ struct SequenceChannelLayer // Maybe SequenceTrack?
|
||||
/*0x00, 0x00*/ u8 stopSomething : 1; // ?
|
||||
/*0x00, 0x00*/ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x00*/ u8 unkEu0b8 : 1;
|
||||
/* , 0x00*/ u8 unkEu0b4 : 1;
|
||||
/* , 0x00*/ u8 unkEu0b2 : 1;
|
||||
/* , 0x01*/ u8 euUnk1; // euInstOrWave?
|
||||
/* , 0x00*/ u8 unusedEu0b8 : 1;
|
||||
/* , 0x00*/ u8 notePropertiesNeedInit : 1;
|
||||
/* , 0x00*/ u8 ignoreDrumPan : 1;
|
||||
/* , 0x01*/ u8 instOrWave;
|
||||
#endif
|
||||
/*0x01, 0x02*/ u8 status;
|
||||
/*0x02, 0x03*/ u8 noteDuration; // set to 0x80
|
||||
/*0x03, 0x04*/ u8 portamentoTargetNote;
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x05*/ u8 euUnk5; // contains US/JP pan * 128.0f
|
||||
/* , 0x05*/ u8 pan; // 0..128
|
||||
/* , 0x06*/ u8 notePan;
|
||||
#endif
|
||||
/*0x04, 0x08*/ struct Portamento portamento;
|
||||
@@ -422,7 +423,7 @@ struct SequenceChannelLayer // Maybe SequenceTrack?
|
||||
/*0x20, 0x24*/ f32 freqScale;
|
||||
/*0x24, 0x28*/ f32 velocitySquare;
|
||||
#ifndef VERSION_EU
|
||||
/*0x28*/ f32 pan;
|
||||
/*0x28, */ f32 pan; // 0..1
|
||||
#endif
|
||||
/*0x2C, 0x2C*/ f32 noteVelocity;
|
||||
#ifndef VERSION_EU
|
||||
@@ -452,7 +453,7 @@ struct NoteSynthesisState
|
||||
/*0x01*/ u8 sampleDmaIndex;
|
||||
/*0x02*/ u8 prevHeadsetPanRight;
|
||||
/*0x03*/ u8 prevHeadsetPanLeft;
|
||||
/* */ u16 samplePosFrac; //?
|
||||
/*0x04*/ u16 samplePosFrac;
|
||||
/*0x08*/ s32 samplePosInt;
|
||||
/*0x0C*/ struct NoteSynthesisBuffers *synthesisBuffers;
|
||||
/*0x10*/ s16 curVolLeft;
|
||||
@@ -485,8 +486,8 @@ struct NoteSubEu
|
||||
/*0x00*/ u8 stereoStrongLeft : 1;
|
||||
/*0x00*/ u8 stereoHeadsetEffects : 1;
|
||||
/*0x00*/ u8 usesHeadsetPanEffects : 1;
|
||||
/*0x01*/ u8 unk1b567 : 3;
|
||||
/*0x01*/ u8 unk1b234 : 3;
|
||||
/*0x01*/ u8 reverbIndex : 3;
|
||||
/*0x01*/ u8 bookOffset : 3;
|
||||
/*0x01*/ u8 isSyntheticWave : 1;
|
||||
/*0x01*/ u8 hasTwoAdpcmParts : 1;
|
||||
/*0x02*/ u8 bankId;
|
||||
@@ -506,7 +507,9 @@ struct Note
|
||||
/* U/J, EU */
|
||||
/*0xA4, 0x00*/ struct AudioListItem listItem;
|
||||
/* 0x10*/ struct NoteSynthesisState synthesisState;
|
||||
#ifdef TARGET_N64
|
||||
u8 pad0[12];
|
||||
#endif
|
||||
/*0x04, 0x30*/ u8 priority;
|
||||
/* 0x31*/ u8 waveId;
|
||||
/* 0x32*/ u8 sampleCountIndex;
|
||||
@@ -643,20 +646,40 @@ struct AudioBufferParametersEU {
|
||||
|
||||
struct EuAudioCmd {
|
||||
union {
|
||||
#if IS_BIG_ENDIAN
|
||||
struct {
|
||||
u8 op;
|
||||
u8 arg1;
|
||||
u8 arg2;
|
||||
u8 arg3;
|
||||
} s;
|
||||
#else
|
||||
struct {
|
||||
u8 arg3;
|
||||
u8 arg2;
|
||||
u8 arg1;
|
||||
u8 op;
|
||||
} s;
|
||||
#endif
|
||||
s32 first;
|
||||
} u;
|
||||
union {
|
||||
s32 as_s32;
|
||||
u32 as_u32;
|
||||
f32 as_f32;
|
||||
#if IS_BIG_ENDIAN
|
||||
u8 as_u8;
|
||||
s8 as_s8;
|
||||
#else
|
||||
struct {
|
||||
u8 pad0[3];
|
||||
u8 as_u8;
|
||||
};
|
||||
struct {
|
||||
u8 pad1[3];
|
||||
s8 as_s8;
|
||||
};
|
||||
#endif
|
||||
} u2;
|
||||
};
|
||||
|
||||
|
||||
+26
-27
@@ -2,7 +2,7 @@
|
||||
#include <macros.h>
|
||||
|
||||
#include "load.h"
|
||||
#include "memory.h"
|
||||
#include "heap.h"
|
||||
#include "data.h"
|
||||
#include "seqplayer.h"
|
||||
|
||||
@@ -19,8 +19,7 @@ struct SharedDma {
|
||||
}; // size = 0x10
|
||||
|
||||
// EU only
|
||||
void func_802ada64(void);
|
||||
s32 func_eu_802E2AA0(void);
|
||||
void port_eu_init(void);
|
||||
|
||||
struct Note *gNotes;
|
||||
|
||||
@@ -425,27 +424,27 @@ void patch_sound(UNUSED struct AudioBankSound *sound, UNUSED u8 *memBase, UNUSED
|
||||
}
|
||||
|
||||
#ifndef VERSION_EU
|
||||
#define PATCH_SOUND(_sound, mem, offset) \
|
||||
{ \
|
||||
struct AudioBankSound *sound = _sound; \
|
||||
struct AudioBankSample *sample; \
|
||||
void *patched; \
|
||||
if ((*sound).sample != (void *) 0) \
|
||||
{ \
|
||||
patched = (void *)(((unsigned int)(*sound).sample) + ((unsigned int)((unsigned char *) mem))); \
|
||||
(*sound).sample = patched; \
|
||||
sample = (*sound).sample; \
|
||||
if ((*sample).loaded == 0) \
|
||||
{ \
|
||||
patched = (void *)(((unsigned int)(*sample).sampleAddr) + ((unsigned int) offset)); \
|
||||
(*sample).sampleAddr = patched; \
|
||||
patched = (void *)(((unsigned int)(*sample).loop) + ((unsigned int)((unsigned char *) mem))); \
|
||||
(*sample).loop = patched; \
|
||||
patched = (void *)(((unsigned int)(*sample).book) + ((unsigned int)((unsigned char *) mem))); \
|
||||
(*sample).book = patched; \
|
||||
(*sample).loaded = 1; \
|
||||
} \
|
||||
} \
|
||||
#define PATCH_SOUND(_sound, mem, offset) \
|
||||
{ \
|
||||
struct AudioBankSound *sound = _sound; \
|
||||
struct AudioBankSample *sample; \
|
||||
void *patched; \
|
||||
if ((*sound).sample != (void *) 0) \
|
||||
{ \
|
||||
patched = (void *)(((uintptr_t)(*sound).sample) + ((uintptr_t)((u8 *) mem))); \
|
||||
(*sound).sample = patched; \
|
||||
sample = (*sound).sample; \
|
||||
if ((*sample).loaded == 0) \
|
||||
{ \
|
||||
patched = (void *)(((uintptr_t)(*sample).sampleAddr) + ((uintptr_t) offset)); \
|
||||
(*sample).sampleAddr = patched; \
|
||||
patched = (void *)(((uintptr_t)(*sample).loop) + ((uintptr_t)((u8 *) mem))); \
|
||||
(*sample).loop = patched; \
|
||||
patched = (void *)(((uintptr_t)(*sample).book) + ((uintptr_t)((u8 *) mem))); \
|
||||
(*sample).book = patched; \
|
||||
(*sample).loaded = 1; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -469,7 +468,7 @@ void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32
|
||||
drums = mem->drums;
|
||||
#ifndef VERSION_EU
|
||||
if (drums != NULL && numDrums > 0) {
|
||||
mem->drums = (void *)((unsigned int) drums + (unsigned int) mem);
|
||||
mem->drums = (void *)((uintptr_t) drums + (uintptr_t) mem);
|
||||
if (numDrums > 0) //! unneeded when -sopt is enabled
|
||||
for (i = 0; i < numDrums; i++) {
|
||||
#else
|
||||
@@ -923,7 +922,7 @@ void audio_init() {
|
||||
|
||||
D_EU_802298D0 = 20.03042f;
|
||||
gRefreshRate = 50;
|
||||
func_802ada64();
|
||||
port_eu_init();
|
||||
if (k) {
|
||||
}
|
||||
#endif
|
||||
@@ -958,7 +957,7 @@ void audio_init() {
|
||||
#ifdef VERSION_EU
|
||||
gAudioResetPresetIdToLoad = 0;
|
||||
gAudioResetStatus = 1;
|
||||
func_eu_802E2AA0();
|
||||
audio_shut_down_and_reset_step();
|
||||
#else
|
||||
audio_reset_session(&gAudioSessionPresets[0]);
|
||||
#endif
|
||||
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
#include <ultra64.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include "memory.h"
|
||||
#include "heap.h"
|
||||
#include "data.h"
|
||||
#include "load.h"
|
||||
#include "seqplayer.h"
|
||||
@@ -102,7 +102,7 @@ void note_set_resampling_rate(struct Note *note, f32 resamplingRateInput) {
|
||||
note->noteSubEu.resamplingRateFixedPoint = (s32) (resamplingRate * 32768.0f);
|
||||
}
|
||||
|
||||
struct AudioBankSound *func_eu_802e4e5c(struct Instrument *instrument, s32 semitone) {
|
||||
struct AudioBankSound *instrument_get_audio_bank_sound(struct Instrument *instrument, s32 semitone) {
|
||||
struct AudioBankSound *sound;
|
||||
if (semitone < instrument->normalRangeLo) {
|
||||
sound = &instrument->lowNotesSound;
|
||||
@@ -114,7 +114,7 @@ struct AudioBankSound *func_eu_802e4e5c(struct Instrument *instrument, s32 semit
|
||||
return sound;
|
||||
}
|
||||
|
||||
struct Instrument *func_eu_802e4e98(s32 bankId, s32 instId) {
|
||||
struct Instrument *get_instrument_inner(s32 bankId, s32 instId) {
|
||||
struct Instrument *inst;
|
||||
|
||||
if (IS_BANK_LOAD_COMPLETE(bankId) == FALSE) {
|
||||
@@ -146,7 +146,7 @@ struct Instrument *func_eu_802e4e98(s32 bankId, s32 instId) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct Drum *func_eu_802e4fb8(s32 bankId, s32 drumId) {
|
||||
struct Drum *get_drum(s32 bankId, s32 drumId) {
|
||||
struct Drum *drum;
|
||||
if (drumId >= gCtlEntries[bankId].numDrums) {
|
||||
gAudioErrorFlags = ((bankId << 8) + drumId) + 0x4000000;
|
||||
@@ -223,7 +223,7 @@ void process_notes(void) {
|
||||
u8 reverb;
|
||||
UNUSED u8 pad3;
|
||||
u8 pan;
|
||||
u8 unk;
|
||||
u8 bookOffset;
|
||||
#endif
|
||||
struct NoteAttributes *attributes;
|
||||
#ifndef VERSION_EU
|
||||
@@ -321,13 +321,13 @@ void process_notes(void) {
|
||||
reverb = attributes->reverb;
|
||||
if (1) {
|
||||
}
|
||||
unk = noteSubEu->unk1b234;
|
||||
bookOffset = noteSubEu->bookOffset;
|
||||
} else {
|
||||
frequency = playbackState->parentLayer->noteFreqScale;
|
||||
velocity = playbackState->parentLayer->noteVelocity;
|
||||
pan = playbackState->parentLayer->notePan;
|
||||
reverb = playbackState->parentLayer->seqChannel->reverb;
|
||||
unk = playbackState->parentLayer->seqChannel->unk8 & 0x7; // bitfield?
|
||||
bookOffset = playbackState->parentLayer->seqChannel->bookOffset & 0x7;
|
||||
}
|
||||
|
||||
frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale;
|
||||
@@ -335,7 +335,7 @@ void process_notes(void) {
|
||||
velocity = velocity * scale * scale;
|
||||
note_set_resampling_rate(note, frequency);
|
||||
note_set_vel_pan_reverb(note, velocity, pan, reverb);
|
||||
noteSubEu->unk1b234 = unk;
|
||||
noteSubEu->bookOffset = bookOffset;
|
||||
skip:;
|
||||
}
|
||||
#else
|
||||
@@ -589,7 +589,7 @@ void init_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLaye
|
||||
#ifdef VERSION_EU
|
||||
s32 sampleCountIndex;
|
||||
s32 waveSampleCountIndex;
|
||||
s32 waveId = seqLayer->euUnk1;
|
||||
s32 waveId = seqLayer->instOrWave;
|
||||
if (waveId == 0xff) {
|
||||
waveId = seqLayer->seqChannel->instOrWave;
|
||||
}
|
||||
@@ -799,14 +799,14 @@ void note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLaye
|
||||
note->prevParentLayer = NO_LAYER;
|
||||
note->parentLayer = seqLayer;
|
||||
note->priority = seqLayer->seqChannel->notePriority;
|
||||
seqLayer->unkEu0b4 = TRUE;
|
||||
seqLayer->notePropertiesNeedInit = TRUE;
|
||||
seqLayer->status = SOUND_LOAD_STATUS_DISCARDABLE; // "loaded"
|
||||
seqLayer->note = note;
|
||||
seqLayer->seqChannel->noteUnused = note;
|
||||
seqLayer->seqChannel->layerUnused = seqLayer;
|
||||
seqLayer->noteVelocity = 0.0f;
|
||||
note_init(note);
|
||||
instId = seqLayer->euUnk1;
|
||||
instId = seqLayer->instOrWave;
|
||||
if (instId == 0xff) {
|
||||
instId = seqLayer->seqChannel->instOrWave;
|
||||
}
|
||||
@@ -823,7 +823,7 @@ void note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLaye
|
||||
}
|
||||
sub->bankId = seqLayer->seqChannel->bankId;
|
||||
sub->stereoHeadsetEffects = seqLayer->seqChannel->stereoHeadsetEffects;
|
||||
sub->unk1b567 = seqLayer->seqChannel->reverbIndex & 3;
|
||||
sub->reverbIndex = seqLayer->seqChannel->reverbIndex & 3;
|
||||
}
|
||||
#else
|
||||
s32 note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
|
||||
@@ -29,8 +29,9 @@ void reclaim_notes(void);
|
||||
void note_init_all(void);
|
||||
|
||||
#ifdef VERSION_EU
|
||||
struct AudioBankSound *func_eu_802e4e5c(struct Instrument *instrument, s32 semitone);
|
||||
struct Drum *func_eu_802e4fb8(s32 bankId, s32 drumId);
|
||||
struct AudioBankSound *instrument_get_audio_bank_sound(struct Instrument *instrument, s32 semitone);
|
||||
struct Instrument *get_instrument_inner(s32 bankId, s32 instId);
|
||||
struct Drum *get_drum(s32 bankId, s32 drumId);
|
||||
void note_init_volume(struct Note *note);
|
||||
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverb);
|
||||
void note_set_frequency(struct Note *note, f32 frequency);
|
||||
|
||||
+15
-15
@@ -29,9 +29,9 @@ extern struct EuAudioCmd sAudioCmd[0x100];
|
||||
|
||||
void func_8031D690(s32 player, FadeT fadeInTime);
|
||||
void sequence_player_fade_out_internal(s32 player, FadeT fadeOutTime);
|
||||
void func_802ad668(void);
|
||||
void port_eu_init_queues(void);
|
||||
void decrease_sample_dma_ttls(void);
|
||||
s32 func_eu_802E2AA0(void);
|
||||
s32 audio_shut_down_and_reset_step(void);
|
||||
void func_802ad7ec(u32);
|
||||
|
||||
struct SPTask *create_next_audio_frame_task(void) {
|
||||
@@ -76,7 +76,7 @@ struct SPTask *create_next_audio_frame_task(void) {
|
||||
}
|
||||
|
||||
if (gAudioResetStatus != 0) {
|
||||
if (func_eu_802E2AA0() == 0) {
|
||||
if (audio_shut_down_and_reset_step() == 0) {
|
||||
if (gAudioResetStatus == 0) {
|
||||
osSendMesg(OSMesgQueues[3], (OSMesg) (s32) gAudioResetPresetIdToLoad, OS_MESG_NOBLOCK);
|
||||
}
|
||||
@@ -164,14 +164,14 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
|
||||
case 0xf1:
|
||||
for (i = 0; i < 4; i++) {
|
||||
gSequencePlayers[i].muted = TRUE;
|
||||
gSequencePlayers[i].unk_eu = TRUE;
|
||||
gSequencePlayers[i].recalculateVolume = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xf2:
|
||||
for (i = 0; i < 4; i++) {
|
||||
gSequencePlayers[i].muted = FALSE;
|
||||
gSequencePlayers[i].unk_eu = TRUE;
|
||||
gSequencePlayers[i].recalculateVolume = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ void func_8031D690(s32 player, FadeT fadeInTime) {
|
||||
}
|
||||
}
|
||||
|
||||
void func_802ad668(void) {
|
||||
void port_eu_init_queues(void) {
|
||||
D_EU_80302010 = 0;
|
||||
D_EU_80302014 = 0;
|
||||
osCreateMesgQueue(OSMesgQueues[0], &OSMesg0, 1);
|
||||
@@ -262,8 +262,8 @@ void func_802ad7ec(u32 arg0) {
|
||||
else if ((cmd->u.s.op & 0x40) != 0) {
|
||||
switch (cmd->u.s.op) {
|
||||
case 0x41:
|
||||
seqPlayer->unkEu28 = cmd->u2.as_f32;
|
||||
seqPlayer->unk_eu = TRUE;
|
||||
seqPlayer->fadeVolumeScale = cmd->u2.as_f32;
|
||||
seqPlayer->recalculateVolume = TRUE;
|
||||
break;
|
||||
|
||||
case 0x47:
|
||||
@@ -286,19 +286,19 @@ void func_802ad7ec(u32 arg0) {
|
||||
switch (cmd->u.s.op) {
|
||||
case 1:
|
||||
chan->volumeScale = cmd->u2.as_f32;
|
||||
chan->unk1.as_bitfields.unk0b40 = TRUE;
|
||||
chan->changes.as_bitfields.volume = TRUE;
|
||||
break;
|
||||
case 2:
|
||||
chan->volume = cmd->u2.as_f32;
|
||||
chan->unk1.as_bitfields.unk0b40 = TRUE;
|
||||
chan->changes.as_bitfields.volume = TRUE;
|
||||
break;
|
||||
case 3:
|
||||
chan->unk9 = cmd->u2.as_s8;
|
||||
chan->unk1.as_bitfields.unk0b20 = TRUE;
|
||||
chan->newPan = cmd->u2.as_s8;
|
||||
chan->changes.as_bitfields.pan = TRUE;
|
||||
break;
|
||||
case 4:
|
||||
chan->freqScale = cmd->u2.as_f32;
|
||||
chan->unk1.as_bitfields.unk0b80 = TRUE;
|
||||
chan->changes.as_bitfields.freqScale = TRUE;
|
||||
break;
|
||||
case 5:
|
||||
chan->reverb = cmd->u2.as_s8;
|
||||
@@ -319,8 +319,8 @@ void func_802ad7ec(u32 arg0) {
|
||||
}
|
||||
}
|
||||
|
||||
void func_802ada64(void) {
|
||||
func_802ad668();
|
||||
void port_eu_init(void) {
|
||||
port_eu_init_queues();
|
||||
}
|
||||
|
||||
#endif
|
||||
+68
-64
@@ -1,7 +1,7 @@
|
||||
#include <ultra64.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include "memory.h"
|
||||
#include "heap.h"
|
||||
#include "data.h"
|
||||
#include "load.h"
|
||||
#include "seqplayer.h"
|
||||
@@ -33,11 +33,11 @@ void sequence_channel_init(struct SequenceChannel *seqChannel) {
|
||||
seqChannel->transposition = 0;
|
||||
seqChannel->largeNotes = FALSE;
|
||||
#ifdef VERSION_EU
|
||||
seqChannel->unk8 = 0;
|
||||
seqChannel->unk1.as_u8 = 0xff;
|
||||
seqChannel->bookOffset = 0;
|
||||
seqChannel->changes.as_u8 = 0xff;
|
||||
seqChannel->scriptState.depth = 0;
|
||||
seqChannel->unk9 = 0x40;
|
||||
seqChannel->unkA = 0x80;
|
||||
seqChannel->newPan = 0x40;
|
||||
seqChannel->panChannelWeight = 0x80;
|
||||
seqChannel->noteUnused = NULL;
|
||||
seqChannel->reverbIndex = 0;
|
||||
#else
|
||||
@@ -105,14 +105,14 @@ s32 seq_channel_set_layer(struct SequenceChannel *seqChannel, s32 layerIndex) {
|
||||
layer->continuousNotes = FALSE;
|
||||
layer->finished = FALSE;
|
||||
#ifdef VERSION_EU
|
||||
layer->unkEu0b2 = FALSE;
|
||||
layer->ignoreDrumPan = FALSE;
|
||||
#endif
|
||||
layer->portamento.mode = 0;
|
||||
layer->scriptState.depth = 0;
|
||||
layer->status = SOUND_LOAD_STATUS_NOT_LOADED;
|
||||
layer->noteDuration = 0x80;
|
||||
#ifdef VERSION_EU
|
||||
layer->euUnk5 = 0x40;
|
||||
layer->pan = 0x40;
|
||||
#endif
|
||||
layer->transposition = 0;
|
||||
layer->delay = 0;
|
||||
@@ -123,7 +123,7 @@ s32 seq_channel_set_layer(struct SequenceChannel *seqChannel, s32 layerIndex) {
|
||||
#ifdef VERSION_EU
|
||||
layer->freqScale = 1.0f;
|
||||
layer->velocitySquare = 0.0f;
|
||||
layer->euUnk1 = 0xff;
|
||||
layer->instOrWave = 0xff;
|
||||
#else
|
||||
layer->velocitySquare = 0.0f;
|
||||
layer->pan = 0.5f;
|
||||
@@ -244,18 +244,18 @@ void sequence_player_disable_channels(struct SequencePlayer *seqPlayer, u16 chan
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/sequence_channel_enable.s")
|
||||
#else
|
||||
void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex, void *arg2) {
|
||||
struct SequenceChannel *seqChannel = seqPlayer->channels[channelIndex];
|
||||
s32 i;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == FALSE) {
|
||||
// not matching exactly, but this is the logic at least (stubbed printfs?)
|
||||
if (seqPlayer == &gSequencePlayers[0]) {
|
||||
} else if (seqPlayer == &gSequencePlayers[1]) {
|
||||
struct SequencePlayer *bgMusic = &gSequencePlayers[0];
|
||||
struct SequencePlayer *miscMusic = &gSequencePlayers[1];
|
||||
|
||||
if (seqPlayer == bgMusic) {
|
||||
} else if (seqPlayer == miscMusic) {
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
#else
|
||||
@@ -273,7 +273,6 @@ void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void sequence_player_disable(struct SequencePlayer *seqPlayer) {
|
||||
sequence_player_disable_channels(seqPlayer, 0xffff);
|
||||
@@ -464,7 +463,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
|
||||
seqPlayer = seqChannel->seqPlayer;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
layer->unkEu0b4 = TRUE;
|
||||
layer->notePropertiesNeedInit = TRUE;
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
@@ -553,7 +552,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
|
||||
layer->velocitySquare = (f32)(temp_a0_5 * temp_a0_5);
|
||||
} else {
|
||||
#ifdef VERSION_EU
|
||||
layer->euUnk5 = temp_a0_5;
|
||||
layer->pan = temp_a0_5;
|
||||
#else
|
||||
layer->pan = (f32) temp_a0_5 / US_FLOAT(128.0);
|
||||
#endif
|
||||
@@ -624,9 +623,9 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
|
||||
if (instId >= 0x7f) {
|
||||
#ifdef VERSION_EU
|
||||
if (instId == 0x7f) {
|
||||
layer->euUnk1 = 0;
|
||||
layer->instOrWave = 0;
|
||||
} else {
|
||||
layer->euUnk1 = instId;
|
||||
layer->instOrWave = instId;
|
||||
layer->instrument = NULL;
|
||||
}
|
||||
if (instId != 0xff) {
|
||||
@@ -639,11 +638,11 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
|
||||
|
||||
#ifdef VERSION_EU
|
||||
instId = get_instrument(seqChannel, instId, &layer->instrument, &layer->adsr);
|
||||
layer->euUnk1 = instId;
|
||||
layer->instOrWave = instId;
|
||||
if (instId == 0) {
|
||||
layer->euUnk1 = 0xff;
|
||||
layer->instOrWave = 0xff;
|
||||
}
|
||||
//layer->euUnk1 = instId == 0 ? 0xff : instId;
|
||||
//layer->instOrWave = instId == 0 ? 0xff : instId;
|
||||
break;
|
||||
#else
|
||||
bankId = seqChannel->bankId; // maybe a temp, to match get_instrument
|
||||
@@ -732,7 +731,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
|
||||
break;
|
||||
|
||||
case 0xcc:
|
||||
layer->unkEu0b2 = TRUE;
|
||||
layer->ignoreDrumPan = TRUE;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -869,9 +868,9 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
|
||||
layer->stopSomething = TRUE;
|
||||
} else {
|
||||
#ifdef VERSION_EU
|
||||
if ((layer->euUnk1 == 0xff ? seqChannel->instOrWave : layer->euUnk1) == 0) {
|
||||
if ((layer->instOrWave == 0xff ? seqChannel->instOrWave : layer->instOrWave) == 0) {
|
||||
drumIndex = cmdSemitone + seqChannel->transposition + layer->transposition;
|
||||
drum = func_eu_802e4fb8(seqChannel->bankId, drumIndex);
|
||||
drum = get_drum(seqChannel->bankId, drumIndex);
|
||||
#else
|
||||
if (seqChannel->instOrWave == 0) { // drum
|
||||
drumIndex = cmdSemitone + seqChannel->transposition + layer->transposition;
|
||||
@@ -893,8 +892,8 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
|
||||
layer->adsr.envelope = drum->envelope;
|
||||
layer->adsr.releaseRate = drum->releaseRate;
|
||||
#ifdef VERSION_EU
|
||||
if (!layer->unkEu0b2) {
|
||||
layer->euUnk5 = drum->pan;
|
||||
if (!layer->ignoreDrumPan) {
|
||||
layer->pan = drum->pan;
|
||||
}
|
||||
#else
|
||||
layer->pan = FLOAT_CAST(drum->pan) / US_FLOAT(128.0);
|
||||
@@ -912,7 +911,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
|
||||
layer->stopSomething = TRUE;
|
||||
} else {
|
||||
#ifdef VERSION_EU
|
||||
if (layer->euUnk1 == 0xff) {
|
||||
if (layer->instOrWave == 0xff) {
|
||||
instrument = seqChannel->instrument;
|
||||
} else {
|
||||
instrument = layer->instrument;
|
||||
@@ -931,7 +930,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
|
||||
}
|
||||
if (instrument != NULL) {
|
||||
#ifdef VERSION_EU
|
||||
sound = func_eu_802e4e5c(instrument, usedSemitone);
|
||||
sound = instrument_get_audio_bank_sound(instrument, usedSemitone);
|
||||
#else
|
||||
if (usedSemitone < instrument->normalRangeLo) {
|
||||
sound = &instrument->lowNotesSound;
|
||||
@@ -990,7 +989,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
|
||||
}
|
||||
} else if (instrument != NULL) {
|
||||
#ifdef VERSION_EU
|
||||
sound = func_eu_802e4e5c(instrument, semitone);
|
||||
sound = instrument_get_audio_bank_sound(instrument, semitone);
|
||||
#else
|
||||
if (semitone < instrument->normalRangeLo) {
|
||||
sound = &instrument->lowNotesSound;
|
||||
@@ -1055,14 +1054,12 @@ GLOBAL_ASM("asm/non_matchings/seq_channel_layer_process_script_jp.s")
|
||||
GLOBAL_ASM("asm/non_matchings/seq_channel_layer_process_script_us.s")
|
||||
#endif
|
||||
|
||||
struct Instrument *func_eu_802e4e98(s32 bankId, s32 instId);
|
||||
|
||||
u8 get_instrument(struct SequenceChannel *seqChannel, u8 instId, struct Instrument **instOut,
|
||||
struct AdsrSettings *adsr)
|
||||
{
|
||||
struct Instrument *inst;
|
||||
#ifdef VERSION_EU
|
||||
inst = func_eu_802e4e98(seqChannel->bankId, instId);
|
||||
inst = get_instrument_inner(seqChannel->bankId, instId);
|
||||
if (inst == NULL)
|
||||
{
|
||||
*instOut = NULL;
|
||||
@@ -1362,21 +1359,21 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
case 0xdf: // chan_setvol
|
||||
sequence_channel_set_volume(seqChannel, m64_read_u8(state));
|
||||
#ifdef VERSION_EU
|
||||
seqChannel->unk1.as_bitfields.unk0b40 = TRUE;
|
||||
seqChannel->changes.as_bitfields.volume = TRUE;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 0xe0: // chan_setvolscale
|
||||
seqChannel->volumeScale = FLOAT_CAST(m64_read_u8(state)) / US_FLOAT(128.0);
|
||||
#ifdef VERSION_EU
|
||||
seqChannel->unk1.as_bitfields.unk0b40 = TRUE;
|
||||
seqChannel->changes.as_bitfields.volume = TRUE;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 0xde: // chan_freqscale; pitch bend using raw frequency multiplier N/2^15 (N is u16)
|
||||
sp5A = m64_read_s16(state);
|
||||
#ifdef VERSION_EU
|
||||
seqChannel->unk1.as_bitfields.unk0b80 = TRUE;
|
||||
seqChannel->changes.as_bitfields.freqScale = TRUE;
|
||||
#endif
|
||||
seqChannel->freqScale = FLOAT_CAST(sp5A) / US_FLOAT(32768.0);
|
||||
break;
|
||||
@@ -1386,14 +1383,14 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
temp = m64_read_u8(state) + 127;
|
||||
seqChannel->freqScale = gPitchBendFrequencyScale[temp];
|
||||
#ifdef VERSION_EU
|
||||
seqChannel->unk1.as_bitfields.unk0b80 = TRUE;
|
||||
seqChannel->changes.as_bitfields.freqScale = TRUE;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 0xdd: // chan_setpan
|
||||
#ifdef VERSION_EU
|
||||
seqChannel->unk9 = m64_read_u8(state);
|
||||
seqChannel->unk1.as_bitfields.unk0b20 = TRUE;
|
||||
seqChannel->newPan = m64_read_u8(state);
|
||||
seqChannel->changes.as_bitfields.pan = TRUE;
|
||||
#else
|
||||
seqChannel->pan = FLOAT_CAST(m64_read_u8(state)) / US_FLOAT(128.0);
|
||||
#endif
|
||||
@@ -1401,8 +1398,8 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
|
||||
case 0xdc: // chan_setpanmix; set proportion of pan to come from channel (0..128)
|
||||
#ifdef VERSION_EU
|
||||
seqChannel->unkA = m64_read_u8(state);
|
||||
seqChannel->unk1.as_bitfields.unk0b20 = TRUE;
|
||||
seqChannel->panChannelWeight = m64_read_u8(state);
|
||||
seqChannel->changes.as_bitfields.pan = TRUE;
|
||||
#else
|
||||
seqChannel->panChannelWeight = FLOAT_CAST(m64_read_u8(state)) / US_FLOAT(128.0);
|
||||
#endif
|
||||
@@ -1544,7 +1541,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
|
||||
#ifdef VERSION_EU
|
||||
case 0xe6:
|
||||
seqChannel->unk8 = m64_read_u8(state);
|
||||
seqChannel->bookOffset = m64_read_u8(state);
|
||||
break;
|
||||
|
||||
case 0xe7:
|
||||
@@ -1554,11 +1551,11 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
seqChannel->noteAllocPolicy = *arr++;
|
||||
seqChannel->notePriority = *arr++;
|
||||
seqChannel->transposition = (s8) *arr++;
|
||||
seqChannel->unk9 = *arr++;
|
||||
seqChannel->unkA = *arr++;
|
||||
seqChannel->newPan = *arr++;
|
||||
seqChannel->panChannelWeight = *arr++;
|
||||
seqChannel->reverb = *arr++;
|
||||
seqChannel->reverbIndex = *arr++; // reverb index?
|
||||
seqChannel->unk1.as_bitfields.unk0b20 = TRUE;
|
||||
seqChannel->changes.as_bitfields.pan = TRUE;
|
||||
break;
|
||||
|
||||
case 0xe8:
|
||||
@@ -1566,11 +1563,11 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
seqChannel->noteAllocPolicy = m64_read_u8(state);
|
||||
seqChannel->notePriority = m64_read_u8(state);
|
||||
seqChannel->transposition = (s8) m64_read_u8(state);
|
||||
seqChannel->unk9 = m64_read_u8(state);
|
||||
seqChannel->unkA = m64_read_u8(state);
|
||||
seqChannel->newPan = m64_read_u8(state);
|
||||
seqChannel->panChannelWeight = m64_read_u8(state);
|
||||
seqChannel->reverb = m64_read_u8(state);
|
||||
seqChannel->reverbIndex = m64_read_u8(state);
|
||||
seqChannel->unk1.as_bitfields.unk0b20 = TRUE;
|
||||
seqChannel->changes.as_bitfields.pan = TRUE;
|
||||
break;
|
||||
|
||||
case 0xec:
|
||||
@@ -1689,14 +1686,10 @@ GLOBAL_ASM("asm/non_matchings/sequence_channel_process_script_jp.s")
|
||||
GLOBAL_ASM("asm/non_matchings/sequence_channel_process_script_us.s")
|
||||
#endif
|
||||
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/sequence_player_process_sequence.s")
|
||||
#else
|
||||
void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
u8 cmd;
|
||||
u8 loBits;
|
||||
u8 temp;
|
||||
s8 tempSigned;
|
||||
s32 value;
|
||||
s32 i;
|
||||
u16 u16v;
|
||||
@@ -1758,6 +1751,10 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
if (osRecvMesg(&seqPlayer->seqDmaMesgQueue, NULL, 0) == -1) {
|
||||
return;
|
||||
}
|
||||
#ifndef AVOID_UB
|
||||
if (temp) {
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
if (seqPlayer->seqDmaMesg == NULL) {
|
||||
return;
|
||||
@@ -1791,10 +1788,14 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
|
||||
state = &seqPlayer->scriptState;
|
||||
if (seqPlayer->delay > 1) {
|
||||
#ifndef AVOID_UB
|
||||
if (temp) {
|
||||
}
|
||||
#endif
|
||||
seqPlayer->delay--;
|
||||
} else {
|
||||
#ifdef VERSION_EU
|
||||
seqPlayer->unk_eu = 1;
|
||||
seqPlayer->recalculateVolume = 1;
|
||||
#endif
|
||||
for (;;) {
|
||||
cmd = m64_read_u8(state);
|
||||
@@ -1804,7 +1805,11 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
sequence_player_disable(seqPlayer);
|
||||
break;
|
||||
}
|
||||
#ifdef VERSION_EU
|
||||
state->pc = state->stack[--state->depth];
|
||||
#else
|
||||
state->depth--, state->pc = state->stack[state->depth];
|
||||
#endif
|
||||
}
|
||||
|
||||
if (cmd == 0xfd) // seq_delay
|
||||
@@ -1873,14 +1878,14 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
case 0xf4:
|
||||
case 0xf3:
|
||||
case 0xf2:
|
||||
tempSigned = m64_read_u8(state);
|
||||
temp = m64_read_u8(state);
|
||||
if (cmd == 0xf3 && value != 0) {
|
||||
break;
|
||||
}
|
||||
if (cmd == 0xf2 && value >= 0) {
|
||||
break;
|
||||
}
|
||||
state->pc += tempSigned;
|
||||
state->pc += (s8)temp;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -1942,7 +1947,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
case SEQUENCE_PLAYER_STATE_2:
|
||||
seqPlayer->fadeTimer = u16v;
|
||||
seqPlayer->state = temp;
|
||||
seqPlayer->fadeVelocity = (0.0f - seqPlayer->fadeVolume) / (s32) u16v;
|
||||
seqPlayer->fadeVelocity = (0.0f - seqPlayer->fadeVolume) / (s32) (u16v & 0xFFFFu);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -1988,16 +1993,16 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
break;
|
||||
|
||||
case 0xda: // seq_changevol
|
||||
tempSigned = m64_read_u8(state);
|
||||
temp = m64_read_u8(state);
|
||||
seqPlayer->fadeVolume =
|
||||
seqPlayer->fadeVolume + (f32) tempSigned / US_FLOAT(127.0);
|
||||
seqPlayer->fadeVolume + (f32) (s8)temp / US_FLOAT(127.0);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
case 0xd9:
|
||||
tempSigned = m64_read_u8(state);
|
||||
seqPlayer->unkEu28 = tempSigned / 127.0f;
|
||||
temp = m64_read_u8(state);
|
||||
seqPlayer->fadeVolumeScale = (s8)temp / 127.0f;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -2012,8 +2017,8 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
break;
|
||||
|
||||
case 0xd5: // seq_setmutescale
|
||||
tempSigned = m64_read_u8(state);
|
||||
seqPlayer->muteVolumeScale = (f32) tempSigned / US_FLOAT(127.0);
|
||||
temp = m64_read_u8(state);
|
||||
seqPlayer->muteVolumeScale = (f32) (s8)temp / US_FLOAT(127.0);
|
||||
break;
|
||||
|
||||
case 0xd4: // seq_mute
|
||||
@@ -2125,7 +2130,6 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// This runs 240 times per second.
|
||||
void process_sequences(UNUSED s32 iterationsRemaining) {
|
||||
@@ -2172,7 +2176,7 @@ void init_sequence_player(u32 player) {
|
||||
seqPlayer->shortNoteDurationTable = gDefaultShortNoteDurationTable;
|
||||
seqPlayer->fadeVolume = 1.0f;
|
||||
#ifdef VERSION_EU
|
||||
seqPlayer->unkEu28 = 1.0f;
|
||||
seqPlayer->fadeVolumeScale = 1.0f;
|
||||
#endif
|
||||
seqPlayer->fadeVelocity = 0.0f;
|
||||
seqPlayer->volume = 0.0f;
|
||||
|
||||
+131
-156
@@ -2,7 +2,7 @@
|
||||
#include <macros.h>
|
||||
|
||||
#include "synthesis.h"
|
||||
#include "memory.h"
|
||||
#include "heap.h"
|
||||
#include "data.h"
|
||||
#include "load.h"
|
||||
#include "seqplayer.h"
|
||||
@@ -81,19 +81,16 @@ u8 sAudioSynthesisPad[0x20];
|
||||
#endif
|
||||
|
||||
#if defined(VERSION_EU)
|
||||
#ifndef NON_MATCHING
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/prepare_reverb_ring_buffer.s")
|
||||
#else
|
||||
// Equivalent functionality as the US/JP version,
|
||||
// just that the reverb structure is chosen from an array with index
|
||||
void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex) {
|
||||
struct SynthesisReverb *reverb = &gSynthesisReverbs[reverbIndex];
|
||||
struct ReverbRingBufferItem *item;
|
||||
struct SynthesisReverb *reverb = &gSynthesisReverbs[reverbIndex];
|
||||
s32 srcPos;
|
||||
s32 dstPos;
|
||||
s32 nSamples;
|
||||
//s32 numSamplesAfterDownsampling;
|
||||
s32 excessiveSamples;
|
||||
s32 UNUSED pad[3];
|
||||
if (reverb->downsampleRate != 1) {
|
||||
if (reverb->framesLeftToIgnore == 0) {
|
||||
// Now that the RSP has finished, downsample the samples produced two frames ago by skipping
|
||||
@@ -105,9 +102,9 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
|
||||
|
||||
for (srcPos = 0, dstPos = 0; dstPos < item->lengths[0] / 2;
|
||||
srcPos += reverb->downsampleRate, dstPos++) {
|
||||
reverb->ringBuffer.left[dstPos + item->startPos] =
|
||||
reverb->ringBuffer.left[item->startPos + dstPos] =
|
||||
item->toDownsampleLeft[srcPos];
|
||||
reverb->ringBuffer.right[dstPos + item->startPos] =
|
||||
reverb->ringBuffer.right[item->startPos + dstPos] =
|
||||
item->toDownsampleRight[srcPos];
|
||||
}
|
||||
for (dstPos = 0; dstPos < item->lengths[1] / 2; srcPos += reverb->downsampleRate, dstPos++) {
|
||||
@@ -117,11 +114,9 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
|
||||
}
|
||||
}
|
||||
|
||||
//numSamplesAfterDownsampling =
|
||||
nSamples = chunkLen / reverb->downsampleRate;
|
||||
excessiveSamples =
|
||||
(nSamples + reverb->nextRingBufferPos) - reverb->bufSizePerChannel;
|
||||
item = &reverb->items[reverb->curFrame][updateIndex];
|
||||
nSamples = chunkLen / reverb->downsampleRate;
|
||||
excessiveSamples = (nSamples + reverb->nextRingBufferPos) - reverb->bufSizePerChannel;
|
||||
if (excessiveSamples < 0) {
|
||||
// There is space in the ring buffer before it wraps around
|
||||
item->lengths[0] = nSamples * 2;
|
||||
@@ -130,7 +125,6 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
|
||||
reverb->nextRingBufferPos += nSamples;
|
||||
} else {
|
||||
// Ring buffer wrapped around
|
||||
//nSamples = numSamplesAfterDownsampling - excessiveSamples;
|
||||
item->lengths[0] = (nSamples - excessiveSamples) * 2;
|
||||
item->lengths[1] = excessiveSamples * 2;
|
||||
item->startPos = reverb->nextRingBufferPos;
|
||||
@@ -140,7 +134,6 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
|
||||
item->numSamplesAfterDownsampling = nSamples;
|
||||
item->chunkLen = chunkLen;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex) {
|
||||
struct ReverbRingBufferItem *item;
|
||||
@@ -261,50 +254,33 @@ s32 get_volume_ramping(u16 sourceVol, u16 targetVol, s32 arg2) {
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#ifndef NON_MATCHING
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/synthesis_execute.s")
|
||||
#else
|
||||
//TODO: (Scrub C) pointless mask and whitespace
|
||||
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
|
||||
s32 nextVolRampTable;
|
||||
s32 temp;
|
||||
s32 i;
|
||||
s32 remaining;
|
||||
s32 i, j;
|
||||
f32 *leftVolRamp;
|
||||
f32 *rightVolRamp;
|
||||
s32 chunkLen;
|
||||
s32 j;
|
||||
u32 *aiBufPtr;
|
||||
u64 *cmd = cmdBuf;
|
||||
s32 chunkLen;
|
||||
s32 nextVolRampTable;
|
||||
|
||||
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
|
||||
process_sequences(i - 1);
|
||||
synthesis_load_note_subs_eu(gAudioBufferParameters.updatesPerFrame - i);
|
||||
}
|
||||
aSegment(cmd++, 0, 0);
|
||||
remaining = bufLen;
|
||||
aiBufPtr = (u32 *) aiBuf;
|
||||
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
|
||||
if (i == 1) {
|
||||
leftVolRamp = gLeftVolRampings[nextVolRampTable];
|
||||
rightVolRamp = gRightVolRampings[nextVolRampTable];
|
||||
chunkLen = remaining;
|
||||
// self-assignment has no affect when added here, could possibly simplify a macro definition
|
||||
chunkLen = bufLen; nextVolRampTable = nextVolRampTable; leftVolRamp = gLeftVolRampings[nextVolRampTable]; rightVolRamp = gRightVolRampings[nextVolRampTable & 0xFFFFFFFF];
|
||||
} else {
|
||||
temp = remaining / i;
|
||||
if (temp >= gAudioBufferParameters.samplesPerUpdateMax) {
|
||||
leftVolRamp = gLeftVolRampings[2];
|
||||
rightVolRamp = gRightVolRampings[2];
|
||||
chunkLen = gAudioBufferParameters.samplesPerUpdateMax;
|
||||
nextVolRampTable = 2;
|
||||
} else if (temp <= gAudioBufferParameters.samplesPerUpdateMin) {
|
||||
leftVolRamp = gLeftVolRampings[0];
|
||||
rightVolRamp = gRightVolRampings[0];
|
||||
chunkLen = gAudioBufferParameters.samplesPerUpdateMin;
|
||||
nextVolRampTable = 0;
|
||||
if (bufLen / i >= gAudioBufferParameters.samplesPerUpdateMax) {
|
||||
chunkLen = gAudioBufferParameters.samplesPerUpdateMax; nextVolRampTable = 2; leftVolRamp = gLeftVolRampings[2]; rightVolRamp = gRightVolRampings[2];
|
||||
} else if (bufLen / i <= gAudioBufferParameters.samplesPerUpdateMin) {
|
||||
chunkLen = gAudioBufferParameters.samplesPerUpdateMin; nextVolRampTable = 0; leftVolRamp = gLeftVolRampings[0]; rightVolRamp = gRightVolRampings[0];
|
||||
} else {
|
||||
leftVolRamp = gLeftVolRampings[1];
|
||||
rightVolRamp = gRightVolRampings[1];
|
||||
chunkLen = gAudioBufferParameters.samplesPerUpdate;
|
||||
nextVolRampTable = 1;
|
||||
chunkLen = gAudioBufferParameters.samplesPerUpdate; nextVolRampTable = 1; leftVolRamp = gLeftVolRampings[1]; rightVolRamp = gRightVolRampings[1];
|
||||
}
|
||||
}
|
||||
gCurrentLeftVolRamping = leftVolRamp;
|
||||
@@ -315,19 +291,19 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
|
||||
}
|
||||
}
|
||||
cmd = synthesis_do_one_audio_update((u16 *) aiBufPtr, chunkLen, cmd, gAudioBufferParameters.updatesPerFrame - i);
|
||||
remaining -= chunkLen;
|
||||
bufLen -= chunkLen;
|
||||
aiBufPtr += chunkLen;
|
||||
}
|
||||
for (i = 0; i < gNumSynthesisReverbs; i++) {
|
||||
if (gSynthesisReverbs[i].framesLeftToIgnore != 0) {
|
||||
gSynthesisReverbs[i].framesLeftToIgnore--;
|
||||
|
||||
for (j = 0; j < gNumSynthesisReverbs; j++) {
|
||||
if (gSynthesisReverbs[j].framesLeftToIgnore != 0) {
|
||||
gSynthesisReverbs[j].framesLeftToIgnore--;
|
||||
}
|
||||
gSynthesisReverbs[i].curFrame ^= 1;
|
||||
gSynthesisReverbs[j].curFrame ^= 1;
|
||||
}
|
||||
*writtenCmds = cmd - cmdBuf;
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
// bufLen will be divisible by 16
|
||||
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
|
||||
@@ -372,171 +348,153 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
|
||||
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#ifndef NON_MATCHING
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/synthesis_resample_and_mix_reverb.s")
|
||||
u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s16 updateIndex);
|
||||
#else
|
||||
u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s16 updateIndex) {
|
||||
struct ReverbRingBufferItem *item; // sp5C
|
||||
struct ReverbRingBufferItem *item;
|
||||
s16 temp_t9; // sp5a
|
||||
s16 sp58; // sp58
|
||||
struct SynthesisReverb *reverb;
|
||||
|
||||
reverb = &gSynthesisReverbs[reverbIndex];
|
||||
item = &reverb->items[reverb->curFrame][updateIndex];
|
||||
item = &gSynthesisReverbs[reverbIndex].items[gSynthesisReverbs[reverbIndex].curFrame][updateIndex];
|
||||
|
||||
aClearBuffer(cmd++, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
if (reverb->downsampleRate == 1) {
|
||||
if (gSynthesisReverbs[reverbIndex].downsampleRate == 1) {
|
||||
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH, item->startPos, item->lengths[0], reverbIndex);
|
||||
if (item->lengths[1] != 0) {
|
||||
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH + item->lengths[0], 0, item->lengths[1], reverbIndex);
|
||||
}
|
||||
aSetBuffer(cmd++, 0, 0, 0, DEFAULT_LEN_2CH);
|
||||
aMix(cmd++, 0, 0x7fff, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH);
|
||||
aMix(cmd++, 0, 0x8000 + reverb->reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH);
|
||||
aMix(cmd++, 0, 0x8000 + gSynthesisReverbs[reverbIndex].reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH);
|
||||
} else {
|
||||
temp_t9 = (item->startPos & 7) * 2;
|
||||
sp58 = ALIGN(temp_t9 + item->lengths[0], 4);
|
||||
temp_t9 = (item->startPos % 8u) * 2;
|
||||
sp58 = ALIGN(item->lengths[0] + (sp58=temp_t9), 4);
|
||||
|
||||
cmd = synthesis_load_reverb_ring_buffer(cmd, 0x20, (item->startPos - temp_t9 / 2), DEFAULT_LEN_1CH, reverbIndex);
|
||||
if (item->lengths[1] != 0) {
|
||||
cmd = synthesis_load_reverb_ring_buffer(cmd, 0x20 + sp58, 0, DEFAULT_LEN_1CH - sp58, reverbIndex);
|
||||
}
|
||||
|
||||
aSetBuffer(cmd++, 0, temp_t9 + DMEM_ADDR_ADPCM_RESAMPLED, DMEM_ADDR_WET_LEFT_CH, bufLen * 2);
|
||||
aResample(cmd++, reverb->resampleFlags, reverb->resampleRate, VIRTUAL_TO_PHYSICAL2(reverb->resampleStateLeft));
|
||||
aResample(cmd++, gSynthesisReverbs[reverbIndex].resampleFlags, gSynthesisReverbs[reverbIndex].resampleRate, VIRTUAL_TO_PHYSICAL2(gSynthesisReverbs[reverbIndex].resampleStateLeft));
|
||||
|
||||
aSetBuffer(cmd++, 0, temp_t9 + DMEM_ADDR_ADPCM_RESAMPLED2, DMEM_ADDR_WET_RIGHT_CH, bufLen * 2);
|
||||
aResample(cmd++, reverb->resampleFlags, reverb->resampleRate, VIRTUAL_TO_PHYSICAL2(reverb->resampleStateRight));
|
||||
aResample(cmd++, gSynthesisReverbs[reverbIndex].resampleFlags, gSynthesisReverbs[reverbIndex].resampleRate, VIRTUAL_TO_PHYSICAL2(gSynthesisReverbs[reverbIndex].resampleStateRight));
|
||||
|
||||
aSetBuffer(cmd++, 0, 0, 0, DEFAULT_LEN_2CH);
|
||||
aMix(cmd++, 0, 0x7fff, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH);
|
||||
aMix(cmd++, 0, 0x8000 + reverb->reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH);
|
||||
aMix(cmd++, 0, 0x8000 + gSynthesisReverbs[reverbIndex].reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH);
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NON_MATCHING
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/func_eu_802e00d8.s")
|
||||
u64 *func_eu_802e00d8(u64 *cmd, s16 reverbIndex, s16 updateIndex);
|
||||
#else
|
||||
u64 *func_eu_802e00d8(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
|
||||
struct SynthesisReverb *reverb;
|
||||
u64 *synthesis_save_reverb_samples(u64 *cmdBuf, s16 reverbIndex, s16 updateIndex) {
|
||||
struct ReverbRingBufferItem *item;
|
||||
struct SynthesisReverb *reverb;
|
||||
u64 *cmd = cmdBuf;
|
||||
|
||||
reverb = &gSynthesisReverbs[reverbIndex];
|
||||
item = &reverb->items[reverb->curFrame][updateIndex];
|
||||
if (reverb->useReverb != 0) {
|
||||
if (1) {
|
||||
}
|
||||
if (reverb->downsampleRate == 1) {
|
||||
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH, item->startPos, item->lengths[0], reverbIndex);
|
||||
// Put the oldest samples in the ring buffer into the wet channels
|
||||
cmd = cmdBuf = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH, item->startPos, item->lengths[0], reverbIndex);
|
||||
if (item->lengths[1] != 0) {
|
||||
// Ring buffer wrapped
|
||||
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH + item->lengths[0], 0, item->lengths[1], reverbIndex);
|
||||
cmdBuf = cmd;
|
||||
}
|
||||
} else {
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
aSaveBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(reverb->items[reverb->curFrame][updateIndex].toDownsampleLeft));
|
||||
// Downsampling is done later by CPU when RSP is done, therefore we need to have double
|
||||
// buffering. Left and right buffers are adjacent in memory.
|
||||
aSetBuffer(cmdBuf++, 0, 0, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
aSaveBuffer(cmdBuf++, VIRTUAL_TO_PHYSICAL2(reverb->items[reverb->curFrame][updateIndex].toDownsampleLeft));
|
||||
reverb->resampleFlags = 0;
|
||||
}
|
||||
}
|
||||
return cmd;
|
||||
return cmdBuf;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#ifndef NON_MATCHING
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/synthesis_do_one_audio_update.s")
|
||||
#else
|
||||
u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) {
|
||||
u8 sp84[60];
|
||||
struct SynthesisReverb *sp60;
|
||||
s32 temp_lo;
|
||||
s32 temp_lo_2;
|
||||
u8 temp_v1;
|
||||
u8 temp_v1_2;
|
||||
struct NoteSubEu *temp_t5;
|
||||
struct NoteSubEu *temp_v0;
|
||||
s32 phi_s1;
|
||||
s16 phi_s2;
|
||||
s16 phi_s3;
|
||||
s32 phi_s1_2;
|
||||
s32 phi_v1_2;
|
||||
s32 phi_s1_3;
|
||||
s16 phi_s3_2;
|
||||
s32 phi_s1_4;
|
||||
u8 *phi_s0_2;
|
||||
s32 bufLen2;
|
||||
struct NoteSubEu *noteSubEu;
|
||||
u8 noteIndices[56];
|
||||
s32 temp;
|
||||
s32 i;
|
||||
s16 j;
|
||||
s16 notePos = 0;
|
||||
|
||||
if (gNumSynthesisReverbs == 0) {
|
||||
phi_s2 = 0;
|
||||
for (phi_s1 = 0; phi_s1 < gMaxSimultaneousNotes; phi_s1++) {
|
||||
if (gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + phi_s1].enabled) {
|
||||
sp84[phi_s2++] = phi_s1;
|
||||
for (i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
temp = updateIndex;
|
||||
if (gNoteSubsEu[gMaxSimultaneousNotes * temp + i].enabled) {
|
||||
noteIndices[notePos++] = i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
phi_s2 = 0;
|
||||
for (phi_s3 = 0; phi_s3 < gNumSynthesisReverbs; phi_s3++) {
|
||||
for (phi_s1_2 = 0; phi_s1_2 < gMaxSimultaneousNotes; phi_s1_2++) {
|
||||
temp_v0 = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + phi_s1_2];
|
||||
if (temp_v0->enabled) {
|
||||
if (phi_s3 == temp_v0->unk1b567) {
|
||||
sp84[phi_s2++] = phi_s1_2;
|
||||
}
|
||||
for (j = 0; j < gNumSynthesisReverbs; j++) {
|
||||
for (i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
temp = updateIndex;
|
||||
noteSubEu = &gNoteSubsEu[gMaxSimultaneousNotes * temp + i];
|
||||
if (noteSubEu->enabled && j == noteSubEu->reverbIndex) {
|
||||
noteIndices[notePos++] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
phi_v1_2 = gMaxSimultaneousNotes * updateIndex;
|
||||
for (phi_s1_3 = 0; phi_s1_3 < gMaxSimultaneousNotes; phi_s1_3++) {
|
||||
if (gNoteSubsEu[phi_v1_2].enabled) {
|
||||
if (temp_v0->unk1b567 >= gNumSynthesisReverbs) {
|
||||
sp84[phi_s2++] = phi_s1_3;
|
||||
}
|
||||
|
||||
for (i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
temp = updateIndex;
|
||||
noteSubEu = &gNoteSubsEu[gMaxSimultaneousNotes * temp + i];
|
||||
if (noteSubEu->enabled && noteSubEu->reverbIndex >= gNumSynthesisReverbs) {
|
||||
noteIndices[notePos++] = i;
|
||||
}
|
||||
phi_v1_2++;
|
||||
}
|
||||
}
|
||||
aClearBuffer(cmd++, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
phi_s1_4 = 0;
|
||||
for (phi_s3_2 = 0; phi_s3_2 < gNumSynthesisReverbs; phi_s3_2++) {
|
||||
sp60 = &gSynthesisReverbs[phi_s3_2];
|
||||
gUseReverb = sp60->useReverb;
|
||||
i = 0;
|
||||
for (j = 0; j < gNumSynthesisReverbs; j++) {
|
||||
gUseReverb = gSynthesisReverbs[j].useReverb;
|
||||
if (gUseReverb != 0) {
|
||||
cmd = synthesis_resample_and_mix_reverb(cmd, bufLen, phi_s3_2, (s16) updateIndex);
|
||||
cmd = synthesis_resample_and_mix_reverb(cmd, bufLen, j, updateIndex);
|
||||
}
|
||||
for (; phi_s1_4 < phi_s2; phi_s1_4++) {
|
||||
temp_v1 = sp84[phi_s1_4];
|
||||
temp_lo = updateIndex * gMaxSimultaneousNotes;
|
||||
if (phi_s3_2 == gNoteSubsEu[temp_v1 + temp_lo].unk1b567) {
|
||||
cmd = synthesis_process_note(&gNotes[temp_v1], &gNoteSubsEu[temp_v1 + temp_lo], &gNotes[temp_v1].synthesisState, aiBuf, bufLen, cmd);
|
||||
for (; i < notePos; i++) {
|
||||
temp = updateIndex;
|
||||
temp *= gMaxSimultaneousNotes;
|
||||
if (j == gNoteSubsEu[temp + noteIndices[i]].reverbIndex) {
|
||||
cmd = synthesis_process_note(&gNotes[noteIndices[i]],
|
||||
&gNoteSubsEu[temp + noteIndices[i]],
|
||||
&gNotes[noteIndices[i]].synthesisState,
|
||||
aiBuf, bufLen, cmd);
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sp60->useReverb != 0) {
|
||||
cmd = func_eu_802e00d8(cmd, phi_s3_2, (s16) updateIndex);
|
||||
if (gSynthesisReverbs[j].useReverb != 0) {
|
||||
cmd = synthesis_save_reverb_samples(cmd, j, updateIndex);
|
||||
}
|
||||
}
|
||||
phi_s0_2 = &sp84[phi_s1_4];
|
||||
for (; phi_s1_4 < phi_s2; phi_s1_4++) {
|
||||
temp_v1_2 = *phi_s0_2;
|
||||
temp_lo_2 = updateIndex * gMaxSimultaneousNotes;
|
||||
temp_t5 = &gNoteSubsEu[temp_v1_2 + temp_lo_2];
|
||||
if (IS_BANK_LOAD_COMPLETE(temp_t5->bankId) == TRUE) {
|
||||
cmd = synthesis_process_note(&gNotes[temp_v1_2], &gNoteSubsEu[temp_v1_2 + temp_lo_2], &gNotes[temp_v1_2].synthesisState, aiBuf, bufLen, cmd);
|
||||
for (; i < notePos; i++) {
|
||||
temp = updateIndex;
|
||||
temp *= gMaxSimultaneousNotes;
|
||||
if (IS_BANK_LOAD_COMPLETE(gNoteSubsEu[temp + noteIndices[i]].bankId) == TRUE) {
|
||||
cmd = synthesis_process_note(&gNotes[noteIndices[i]],
|
||||
&gNoteSubsEu[temp + noteIndices[i]],
|
||||
&gNotes[noteIndices[i]].synthesisState,
|
||||
aiBuf, bufLen, cmd);
|
||||
} else {
|
||||
gAudioErrorFlags = (temp_t5->bankId + (phi_s1_4 << 8)) + 0x10000000;
|
||||
gAudioErrorFlags = (gNoteSubsEu[temp + noteIndices[i]].bankId + (i << 8)) + 0x10000000;
|
||||
}
|
||||
phi_s0_2++;
|
||||
}
|
||||
bufLen2 = bufLen * 2;
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_TEMP, bufLen2);
|
||||
|
||||
temp = bufLen * 2;
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_TEMP, temp);
|
||||
aInterleave(cmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_RIGHT_CH);
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_TEMP, bufLen2 * 2);
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_TEMP, temp * 2);
|
||||
aSaveBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(aiBuf));
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) {
|
||||
UNUSED s32 pad1[1];
|
||||
@@ -738,8 +696,8 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
if (noteSubEu->isSyntheticWave) {
|
||||
noteSamplesDmemAddrBeforeResampling =
|
||||
DMEM_ADDR_UNCOMPRESSED_NOTE + synthesisState->samplePosInt * 2;
|
||||
synthesisState->samplePosInt += (samplesLenFixedPoint >> 10);
|
||||
cmd = load_wave_samples(cmd, noteSubEu, synthesisState, samplesLenFixedPoint >> 10);
|
||||
synthesisState->samplePosInt += (samplesLenFixedPoint >> 0x10);
|
||||
cmd = load_wave_samples(cmd, noteSubEu, synthesisState, samplesLenFixedPoint >> 0x10);
|
||||
}
|
||||
#else
|
||||
if (note->sound == NULL) {
|
||||
@@ -798,11 +756,15 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
u32 nEntries; // v1
|
||||
curLoadedBook = audioBookSample->book->book;
|
||||
nEntries = audioBookSample->book->order * audioBookSample->book->npredictors;
|
||||
#ifdef VERSION_EU
|
||||
aLoadADPCM(cmd++, nEntries * 16, VIRTUAL_TO_PHYSICAL2(curLoadedBook + noteSubEu->bookOffset));
|
||||
#else
|
||||
aLoadADPCM(cmd++, nEntries * 16, VIRTUAL_TO_PHYSICAL2(curLoadedBook));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (noteSubEu->unk1b234) {
|
||||
if (noteSubEu->bookOffset) {
|
||||
curLoadedBook = (s16 *) &euUnknownData_80301950; // what's this? never read
|
||||
}
|
||||
#endif
|
||||
@@ -952,8 +914,8 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
(samplesLenAdjusted - nAdpcmSamplesProcessed) * 2);
|
||||
#ifdef VERSION_EU
|
||||
noteSubEu->finished = 1;
|
||||
noteSubEu->finished = 1;
|
||||
noteSubEu->enabled = 0;
|
||||
note->noteSubEu.finished = 1;
|
||||
note->noteSubEu.enabled = 0;
|
||||
#else
|
||||
note->samplePosInt = 0;
|
||||
note->finished = 1;
|
||||
@@ -1049,6 +1011,9 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
flags = A_INIT;
|
||||
noteSubEu->needsInit = FALSE;
|
||||
}
|
||||
|
||||
cmd = final_resample(cmd, synthesisState, bufLen * 2, resamplingRateFixedPoint,
|
||||
noteSamplesDmemAddrBeforeResampling, flags);
|
||||
#else
|
||||
if (note->needsInit == TRUE) {
|
||||
flags = A_INIT;
|
||||
@@ -1075,8 +1040,6 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
cmd = final_resample(cmd, synthesisState, bufLen * 2, resamplingRateFixedPoint,
|
||||
noteSamplesDmemAddrBeforeResampling, flags);
|
||||
cmd = process_envelope(cmd, noteSubEu, synthesisState, bufLen, 0, s0);
|
||||
#else
|
||||
cmd = process_envelope(cmd, note, bufLen, 0, s0, flags);
|
||||
@@ -1105,7 +1068,7 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
|
||||
return cmd;
|
||||
}
|
||||
#elif defined(VERSION_JP)
|
||||
#elif defined(VERSION_JP) || defined(VERSION_SH) // todo: extract this nonmatching if applicable.
|
||||
GLOBAL_ASM("asm/non_matchings/synthesis_process_notes_jp.s")
|
||||
#elif defined(VERSION_US)
|
||||
GLOBAL_ASM("asm/non_matchings/synthesis_process_notes_us.s")
|
||||
@@ -1335,41 +1298,44 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat
|
||||
return cmd;
|
||||
}
|
||||
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/note_apply_headset_pan_effects.s")
|
||||
#else
|
||||
#ifdef VERSION_EU
|
||||
u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight) {
|
||||
#else
|
||||
u64 *note_apply_headset_pan_effects(u64 *cmd, struct Note *note, s32 bufLen, s32 flags, s32 leftRight) {
|
||||
#endif
|
||||
u16 dest;
|
||||
u16 prevPanShift;
|
||||
u16 panShift;
|
||||
u16 pitch; // t2
|
||||
#ifndef VERSION_EU
|
||||
u16 prevPanShift;
|
||||
u16 panShift;
|
||||
UNUSED s32 padding[11];
|
||||
#else
|
||||
u8 prevPanShift;
|
||||
u8 panShift;
|
||||
UNUSED u8 unkDebug;
|
||||
#endif
|
||||
|
||||
switch (leftRight) {
|
||||
case 1:
|
||||
dest = DMEM_ADDR_LEFT_CH;
|
||||
note->prevHeadsetPanLeft = 0;
|
||||
#ifndef VERSION_EU
|
||||
note->prevHeadsetPanLeft = 0;
|
||||
panShift = note->headsetPanRight;
|
||||
#else
|
||||
panShift = noteSubEu->headsetPanRight;
|
||||
note->prevHeadsetPanLeft = 0;
|
||||
#endif
|
||||
prevPanShift = note->prevHeadsetPanRight;
|
||||
note->prevHeadsetPanRight = panShift;
|
||||
break;
|
||||
case 2:
|
||||
dest = DMEM_ADDR_RIGHT_CH;
|
||||
note->prevHeadsetPanRight = 0;
|
||||
#ifndef VERSION_EU
|
||||
note->prevHeadsetPanRight = 0;
|
||||
panShift = note->headsetPanLeft;
|
||||
#else
|
||||
panShift = noteSubEu->headsetPanLeft;
|
||||
note->prevHeadsetPanRight = 0;
|
||||
#endif
|
||||
|
||||
prevPanShift = note->prevHeadsetPanLeft;
|
||||
@@ -1392,13 +1358,23 @@ u64 *note_apply_headset_pan_effects(u64 *cmd, struct Note *note, s32 bufLen, s32
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_TEMP, 32);
|
||||
aSaveBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->panResampleState));
|
||||
|
||||
#ifdef VERSION_EU
|
||||
pitch = (bufLen << 0xf) / (bufLen + panShift - prevPanShift + 8);
|
||||
if (pitch) {
|
||||
}
|
||||
#else
|
||||
pitch = (bufLen << 0xf) / (panShift + bufLen - prevPanShift + 8);
|
||||
#endif
|
||||
aSetBuffer(cmd++, 0, DMEM_ADDR_NOTE_PAN_TEMP + 8, DMEM_ADDR_TEMP,
|
||||
panShift + bufLen - prevPanShift);
|
||||
aResample(cmd++, 0, pitch, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->panResampleState));
|
||||
} else {
|
||||
pitch = (panShift == 0) ? (bufLen << 0xf) / (bufLen - prevPanShift - 4)
|
||||
: (bufLen << 0xf) / (bufLen + panShift - prevPanShift);
|
||||
#if defined(VERSION_EU) && !defined(AVOID_UB)
|
||||
if (unkDebug) { // UB
|
||||
}
|
||||
#endif
|
||||
aSetBuffer(cmd++, 0, DMEM_ADDR_NOTE_PAN_TEMP, DMEM_ADDR_TEMP,
|
||||
panShift + bufLen - prevPanShift);
|
||||
aResample(cmd++, 0, pitch, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->panResampleState));
|
||||
@@ -1430,7 +1406,6 @@ u64 *note_apply_headset_pan_effects(u64 *cmd, struct Note *note, s32 bufLen, s32
|
||||
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(VERSION_EU)
|
||||
// Moved to playback.c in EU
|
||||
|
||||
Reference in new issue
Block a user