You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Update macros.h + allow ALIGN macros to be used anywhere (#574)
* Update macros.h + allow ALIGN macros to be used anywhere * Fix wrong alignment in synthesis_sh.c * Revert bitmask in VIRTUAL_TO_PHYSICAL macro
This commit is contained in:
@@ -9,8 +9,6 @@
|
||||
#include "seqplayer.h"
|
||||
#include "game/puppyprint.h"
|
||||
|
||||
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
||||
|
||||
struct SharedDma {
|
||||
/*0x0*/ u8 *buffer; // target, points to pre-allocated buffer
|
||||
/*0x4*/ uintptr_t source; // device address
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include "load.h"
|
||||
#include "seqplayer.h"
|
||||
|
||||
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
||||
|
||||
struct SharedDma {
|
||||
/*0x0*/ u8 *buffer; // target, points to pre-allocated buffer
|
||||
/*0x4*/ uintptr_t source; // device address
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
aSetBuffer(pkt, 0, 0, c + DMEM_ADDR_WET_RIGHT_CH, d); \
|
||||
aSaveBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.right + (off)));
|
||||
|
||||
#define AUDIO_ALIGN(val, amnt) (((val) + (1 << amnt) - 1) & ~((1 << amnt) - 1))
|
||||
|
||||
#ifdef BETTER_REVERB
|
||||
// Do not touch these values manually, unless you want potential for problems.
|
||||
u8 gBetterReverbPreset = 0;
|
||||
@@ -575,7 +573,7 @@ u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s1
|
||||
aMix(cmd++, 0, 0x8000 + gSynthesisReverbs[reverbIndex].reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH);
|
||||
} else {
|
||||
startPad = (item->startPos & 0x7) * 2;
|
||||
paddedLengthA = AUDIO_ALIGN(startPad + item->lengthA, 4);
|
||||
paddedLengthA = ALIGN16(startPad + item->lengthA);
|
||||
|
||||
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED, (item->startPos - startPad / 2), DEFAULT_LEN_1CH, reverbIndex);
|
||||
if (item->lengthB != 0) {
|
||||
@@ -729,7 +727,7 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateI
|
||||
} else {
|
||||
// Same as above but upsample the previously downsampled samples used for reverb first
|
||||
t4 = (v1->startPos & 7) * 2;
|
||||
ra = AUDIO_ALIGN(v1->lengthA + t4, 4);
|
||||
ra = ALIGN16(v1->lengthA + t4);
|
||||
aSetLoadBufferPair(cmd++, 0, v1->startPos - t4 / 2);
|
||||
if (v1->lengthB != 0) {
|
||||
// Ring buffer wrapped
|
||||
@@ -1063,7 +1061,7 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
|
||||
sp130 = s2 * 2;
|
||||
} else {
|
||||
s5Aligned = AUDIO_ALIGN(s5, 5);
|
||||
s5Aligned = ALIGN32(s5);
|
||||
aSetBuffer(cmd++, 0, DMEM_ADDR_COMPRESSED_ADPCM_DATA + a3,
|
||||
DMEM_ADDR_UNCOMPRESSED_NOTE + s5Aligned, s0 * 2);
|
||||
aADPCMdec(cmd++, flags,
|
||||
@@ -1077,9 +1075,9 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->adpcmdecState));
|
||||
sp130 = s2 * 2;
|
||||
} else {
|
||||
aSetBuffer(cmd++, 0, DMEM_ADDR_COMPRESSED_ADPCM_DATA + a3, DMEM_ADDR_UNCOMPRESSED_NOTE + AUDIO_ALIGN(s5, 5), s0 * 2);
|
||||
aSetBuffer(cmd++, 0, DMEM_ADDR_COMPRESSED_ADPCM_DATA + a3, DMEM_ADDR_UNCOMPRESSED_NOTE + ALIGN32(s5), s0 * 2);
|
||||
aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->adpcmdecState));
|
||||
aDMEMMove(cmd++, DMEM_ADDR_UNCOMPRESSED_NOTE + AUDIO_ALIGN(s5, 5) + (s2 * 2), DMEM_ADDR_UNCOMPRESSED_NOTE + s5, (nSamplesInThisIteration) * 2);
|
||||
aDMEMMove(cmd++, DMEM_ADDR_UNCOMPRESSED_NOTE + ALIGN32(s5) + (s2 * 2), DMEM_ADDR_UNCOMPRESSED_NOTE + s5, (nSamplesInThisIteration) * 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
#define MAX_UPDATES_PER_FRAME 4
|
||||
#endif
|
||||
|
||||
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
||||
|
||||
#ifdef BETTER_REVERB
|
||||
|
||||
#define NUM_ALLPASS 12 // Maximum number of delay filters to use with better reverb; do not change this value if you don't know what you're doing.
|
||||
|
||||
@@ -33,9 +33,6 @@
|
||||
aSetBuffer(pkt, 0, 0, c + DMEM_ADDR_WET_RIGHT_CH, d); \
|
||||
aSaveBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.right + (off)));
|
||||
|
||||
#undef ALIGN
|
||||
#define ALIGN(val, amnt) (((val) + (1 << amnt) - 1) & ~((1 << amnt) - 1))
|
||||
|
||||
struct VolumeChange {
|
||||
u16 sourceLeft;
|
||||
u16 sourceRight;
|
||||
@@ -212,7 +209,7 @@ u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s1
|
||||
aMix(cmd++, 0x8000 + gSynthesisReverbs[reverbIndex].reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
} else {
|
||||
startPad = (item->startPos & 0x7) * 2;
|
||||
paddedLengthA = ALIGN(startPad + item->lengthA, 4);
|
||||
paddedLengthA = ALIGN16(startPad + item->lengthA);
|
||||
|
||||
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED, (item->startPos - startPad / 2), DEFAULT_LEN_1CH, reverbIndex);
|
||||
if (item->lengthB != 0) {
|
||||
@@ -542,13 +539,13 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
|
||||
v0_2 = sp84 + (temp * unk_s6) + sampleAddr;
|
||||
} else {
|
||||
v0_2 = dma_sample_data((uintptr_t)(sp84 + (temp * unk_s6) + sampleAddr),
|
||||
ALIGN(t0 * unk_s6 + 16, 4), flags, &synthesisState->sampleDmaIndex, audioBookSample->medium);
|
||||
ALIGN16(t0 * unk_s6 + 16), flags, &synthesisState->sampleDmaIndex, audioBookSample->medium);
|
||||
}
|
||||
|
||||
a3 = ((uintptr_t)v0_2 & 0xf);
|
||||
aligned = ALIGN(t0 * unk_s6 + 16, 4);
|
||||
aligned = ALIGN16(t0 * unk_s6 + 16);
|
||||
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
|
||||
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(v0_2 - a3), addr, ALIGN(t0 * unk_s6 + 16, 4));
|
||||
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(v0_2 - a3), addr, ALIGN16(t0 * unk_s6 + 16));
|
||||
} else {
|
||||
s0 = 0;
|
||||
a3 = 0;
|
||||
@@ -562,13 +559,13 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
|
||||
if (nAdpcmSamplesProcessed == 0) {
|
||||
switch (audioBookSample->codec) {
|
||||
case CODEC_ADPCM:
|
||||
aligned = ALIGN(t0 * unk_s6 + 16, 4);
|
||||
aligned = ALIGN16(t0 * unk_s6 + 16);
|
||||
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
|
||||
aSetBuffer(cmd++, 0, addr + a3, DMEM_ADDR_UNCOMPRESSED_NOTE, s0 * 2);
|
||||
aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
|
||||
break;
|
||||
case CODEC_S8:
|
||||
aligned = ALIGN(t0 * unk_s6 + 16, 4);
|
||||
aligned = ALIGN16(t0 * unk_s6 + 16);
|
||||
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
|
||||
aSetBuffer(cmd++, 0, addr + a3, DMEM_ADDR_UNCOMPRESSED_NOTE, s0 * 2);
|
||||
aS8Dec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
|
||||
@@ -576,16 +573,16 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
|
||||
}
|
||||
sp130 = s2 * 2;
|
||||
} else {
|
||||
s5Aligned = ALIGN(s5 + 16, 4);
|
||||
s5Aligned = ALIGN16(s5 + 16);
|
||||
switch (audioBookSample->codec) {
|
||||
case CODEC_ADPCM:
|
||||
aligned = ALIGN(t0 * unk_s6 + 16, 4);
|
||||
aligned = ALIGN16(t0 * unk_s6 + 16);
|
||||
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
|
||||
aSetBuffer(cmd++, 0, addr + a3, DMEM_ADDR_UNCOMPRESSED_NOTE + s5Aligned, s0 * 2);
|
||||
aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
|
||||
break;
|
||||
case CODEC_S8:
|
||||
aligned = ALIGN(t0 * unk_s6 + 16, 4);
|
||||
aligned = ALIGN16(t0 * unk_s6 + 16);
|
||||
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
|
||||
aSetBuffer(cmd++, 0, addr + a3, DMEM_ADDR_UNCOMPRESSED_NOTE + s5Aligned, s0 * 2);
|
||||
aS8Dec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
|
||||
@@ -635,7 +632,7 @@ skip:
|
||||
case 2:
|
||||
switch (curPart) {
|
||||
case 0:
|
||||
aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), DMEM_ADDR_UNCOMPRESSED_NOTE + sp130, DMEM_ADDR_RESAMPLED);
|
||||
aDownsampleHalf(cmd++, ALIGN8(samplesLenAdjusted / 2), DMEM_ADDR_UNCOMPRESSED_NOTE + sp130, DMEM_ADDR_RESAMPLED);
|
||||
resampledTempLen = samplesLenAdjusted;
|
||||
noteSamplesDmemAddrBeforeResampling = DMEM_ADDR_RESAMPLED;
|
||||
if (noteSubEu->finished != FALSE) {
|
||||
@@ -643,7 +640,7 @@ skip:
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), DMEM_ADDR_UNCOMPRESSED_NOTE + sp130, resampledTempLen + DMEM_ADDR_RESAMPLED);
|
||||
aDownsampleHalf(cmd++, ALIGN8(samplesLenAdjusted / 2), DMEM_ADDR_UNCOMPRESSED_NOTE + sp130, resampledTempLen + DMEM_ADDR_RESAMPLED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -858,7 +855,7 @@ u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struc
|
||||
|
||||
if (prevPanShift != 0) {
|
||||
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->panSamplesBuffer),
|
||||
DMEM_ADDR_NOTE_PAN_TEMP, ALIGN(prevPanShift, 4));
|
||||
DMEM_ADDR_NOTE_PAN_TEMP, ALIGN16(prevPanShift));
|
||||
aDMEMMove(cmd++, DMEM_ADDR_TEMP, DMEM_ADDR_NOTE_PAN_TEMP + prevPanShift, bufLen + panShift - prevPanShift);
|
||||
} else {
|
||||
aDMEMMove(cmd++, DMEM_ADDR_TEMP, DMEM_ADDR_NOTE_PAN_TEMP, bufLen + panShift);
|
||||
@@ -873,7 +870,7 @@ u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struc
|
||||
if (panShift) {
|
||||
// Save excessive samples for next iteration
|
||||
aSaveBuffer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP + bufLen,
|
||||
VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->panSamplesBuffer), ALIGN(panShift, 4));
|
||||
VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->panSamplesBuffer), ALIGN16(panShift));
|
||||
}
|
||||
|
||||
aAddMixer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, dest, (bufLen + 0x3f) & 0xffc0);
|
||||
|
||||
Reference in New Issue
Block a user