mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-02-03 00:33:55 +03:00
Trying to understand this thing
This commit is contained in:
parent
0169c08350
commit
c7507be77e
@ -517,20 +517,20 @@ typedef struct SequenceLayer {
|
|||||||
} SequenceLayer; // size = 0x80
|
} SequenceLayer; // size = 0x80
|
||||||
|
|
||||||
typedef struct UnkStruct_800097A8 {
|
typedef struct UnkStruct_800097A8 {
|
||||||
/* 0x00 */ s16* unk_0;
|
/* 0x00 */ s16* inputBuffer;
|
||||||
/* 0x04 */ s32 unk_4;
|
/* 0x04 */ s32 remainingLength;
|
||||||
/* 0x08 */ s32 unk_8;
|
/* 0x08 */ s32 totalLength;
|
||||||
/* 0x0C */ s16* unk_C;
|
/* 0x0C */ s16* tempBuffer;
|
||||||
/* 0x10 */ char pad10[4];
|
/* 0x10 */ char pad10[4];
|
||||||
/* 0x14 */ struct SampleDma* unk_14;
|
/* 0x14 */ struct SampleDma* dma;
|
||||||
/* 0x18 */ s16 unk18;
|
/* 0x18 */ s16 accumulator;
|
||||||
/* 0x1A */ char pad1A[6];
|
/* 0x1A */ char pad1A[6];
|
||||||
} UnkStruct_800097A8; /* size = 0x20 */
|
} DMADecompress; /* size = 0x20 */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x000 */ s16 adpcmdecState[16];
|
/* 0x000 */ s16 adpcmdecState[16];
|
||||||
/* 0x020 */ s16 finalResampleState[16];
|
/* 0x020 */ s16 finalResampleState[16];
|
||||||
/* 0x040 */ UnkStruct_800097A8 unk_40;
|
/* 0x040 */ DMADecompress unk_40;
|
||||||
/* 0x060 */ char pad[0x20];
|
/* 0x060 */ char pad[0x20];
|
||||||
/* 0x080 */ s16 panSamplesBuffer[0x20];
|
/* 0x080 */ s16 panSamplesBuffer[0x20];
|
||||||
// /* 0x040 */ s16 mixEnvelopeState[32];
|
// /* 0x040 */ s16 mixEnvelopeState[32];
|
||||||
|
@ -657,6 +657,9 @@ s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr
|
|||||||
OSMesgQueue* retQueue, s32 medium, const char* dmaType) {
|
OSMesgQueue* retQueue, s32 medium, const char* dmaType) {
|
||||||
OSPiHandle* handle;
|
OSPiHandle* handle;
|
||||||
|
|
||||||
|
memcpy(ramAddr, devAddr, size);
|
||||||
|
return 0;
|
||||||
|
|
||||||
// switch (medium) {
|
// switch (medium) {
|
||||||
// case MEDIUM_CART:
|
// case MEDIUM_CART:
|
||||||
// handle = osCartRomInit();
|
// handle = osCartRomInit();
|
||||||
@ -795,9 +798,9 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioLoad_ProcessLoads(s32 resetStatus) {
|
void AudioLoad_ProcessLoads(s32 resetStatus) {
|
||||||
// AudioLoad_ProcessSlowLoads(resetStatus);
|
AudioLoad_ProcessSlowLoads(resetStatus);
|
||||||
// AudioLoad_ProcessSamplePreloads(resetStatus);
|
AudioLoad_ProcessSamplePreloads(resetStatus);
|
||||||
// AudioLoad_ProcessAsyncLoads(resetStatus);
|
AudioLoad_ProcessAsyncLoads(resetStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char devstr27[] = "Clear Workarea %x -%x size %x \n";
|
static const char devstr27[] = "Clear Workarea %x -%x size %x \n";
|
||||||
@ -907,6 +910,7 @@ s32 AudioLoad_SlowLoadSample(s32 fontId, u8 instId, s8* status) {
|
|||||||
Sample* sample;
|
Sample* sample;
|
||||||
AudioSlowLoad* slowLoad;
|
AudioSlowLoad* slowLoad;
|
||||||
|
|
||||||
|
*status = SLOW_LOAD_DONE;
|
||||||
sample = AudioLoad_GetFontSample(fontId, instId);
|
sample = AudioLoad_GetFontSample(fontId, instId);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "sf64audio_provisional.h"
|
#include "sf64audio_provisional.h"
|
||||||
#include "audio/mixer.h"
|
#include "audio/mixer.h"
|
||||||
#include "endianness.h"
|
#include "endianness.h"
|
||||||
|
#include "port/Engine.h"
|
||||||
|
|
||||||
#define DMEM_WET_SCRATCH 0x470
|
#define DMEM_WET_SCRATCH 0x470
|
||||||
#define DMEM_COMPRESSED_ADPCM_DATA 0x990
|
#define DMEM_COMPRESSED_ADPCM_DATA 0x990
|
||||||
@ -390,7 +391,7 @@ void AudioSynth_HartleyTransform(f32* arg0, s32 arg1, f32* arg2) {
|
|||||||
|
|
||||||
// https://decomp.me/scratch/TZQNS
|
// https://decomp.me/scratch/TZQNS
|
||||||
#ifdef NON_MATCHING
|
#ifdef NON_MATCHING
|
||||||
void func_80009124(s16** arg0) {
|
void AudioSynth_DecodePCMChunk(s16** arg0) {
|
||||||
s16* var_a1;
|
s16* var_a1;
|
||||||
s32 temp_a0;
|
s32 temp_a0;
|
||||||
u8 temp_s0;
|
u8 temp_s0;
|
||||||
@ -517,22 +518,22 @@ void func_80009124(s16** arg0) {
|
|||||||
*arg0 = var_a1;
|
*arg0 = var_a1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void func_80009124(s16** arg0);
|
void AudioSynth_DecodePCMChunk(s16** arg0);
|
||||||
#pragma GLOBAL_ASM("asm/us/rev1/nonmatchings/audio/audio_synthesis/func_80009124.s")
|
#pragma GLOBAL_ASM("asm/us/rev1/nonmatchings/audio/audio_synthesis/AudioSynth_DecodePCMChunk.s")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void func_80009504(s16* arg0, UnkStruct_800097A8* arg1) {
|
void AudioSynth_DecodePCM(s16* arg0, DMADecompress* arg1) {
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
if (arg1->unk_0 != NULL) {
|
if (arg1->inputBuffer != NULL) {
|
||||||
arg1->unk_C = arg1->unk_0;
|
arg1->tempBuffer = arg1->inputBuffer;
|
||||||
arg1->unk_0 = 0;
|
arg1->inputBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
arg1->unk18 += D_8014C1B4;
|
arg1->accumulator += D_8014C1B4;
|
||||||
while (arg1->unk18 > 0x1000) {
|
while (arg1->accumulator > 0x1000) {
|
||||||
func_80009124(&arg1->unk_C);
|
AudioSynth_DecodePCMChunk(&arg1->tempBuffer);
|
||||||
arg1->unk18 -= 0x1000;
|
arg1->accumulator -= 0x1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioSynth_InverseDiscreteCosineTransform(D_80145D48, D_80146148, 8, D_80146548);
|
AudioSynth_InverseDiscreteCosineTransform(D_80145D48, D_80146148, 8, D_80146548);
|
||||||
@ -551,66 +552,63 @@ void func_80009504(s16* arg0, UnkStruct_800097A8* arg1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 func_8000967C(s32 length, s16* ramAddr, UnkStruct_800097A8* arg2) {
|
s32 AudioSynth_DecompressSample(s32 length, s16* ramAddr, DMADecompress* arg2) {
|
||||||
s32 pad;
|
s32 pad;
|
||||||
s32 temp_t0;
|
s32 chunkSize;
|
||||||
s32 i;
|
s32 i;
|
||||||
s32 var_s1;
|
s32 sampleIdx;
|
||||||
s16* temp_t7 = (s16*) arg2->unk_14->ramAddr;
|
s16* buffer = (s16*) arg2->dma->ramAddr;
|
||||||
|
|
||||||
for (i = 0; i < arg2->unk_4; i++) {
|
for (i = 0; i < arg2->remainingLength; i++) {
|
||||||
ramAddr[i] = temp_t7[i];
|
ramAddr[i] = buffer[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
var_s1 = arg2->unk_4;
|
sampleIdx = arg2->remainingLength;
|
||||||
temp_t0 = (length - arg2->unk_4 + 0xFF) / 256;
|
chunkSize = (length - arg2->remainingLength + 0xFF) / 256;
|
||||||
arg2->unk_4 = (temp_t0 * 256) + arg2->unk_4 - length;
|
arg2->remainingLength = (chunkSize * 256) + arg2->remainingLength - length;
|
||||||
|
|
||||||
for (i = 0; i < temp_t0; i++) {
|
for (i = 0; i < chunkSize; i++) {
|
||||||
func_80009504(&ramAddr[var_s1], arg2);
|
AudioSynth_DecodePCM(&ramAddr[sampleIdx], arg2);
|
||||||
var_s1 += 0x100;
|
sampleIdx += 0x100;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < arg2->unk_4; i++) {
|
for (i = 0; i < arg2->remainingLength; i++) {
|
||||||
temp_t7[i] = ramAddr[length + i];
|
buffer[i] = ramAddr[length + i];
|
||||||
}
|
}
|
||||||
return temp_t0;
|
return chunkSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* func_800097A8(Sample* sample, s32 length, u32 flags, UnkStruct_800097A8* arg3) {
|
static SampleDma pad2 = {0};
|
||||||
// @port: We don't need to do a dma call
|
static SampleDma sp1C = {0};
|
||||||
return sample->sampleAddr;
|
|
||||||
|
u8* AudioSynth_ProcessDecompression(Sample* sample, s32 length, u32 flags, DMADecompress* arg3) {
|
||||||
s32 pad1;
|
s32 pad1;
|
||||||
SampleDma* pad2;
|
|
||||||
SampleDma* sp1C;
|
if(sp1C.ramAddr == NULL){
|
||||||
|
sp1C.ramAddr = GameEngine_Malloc(0x1000 * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pad2.ramAddr == NULL){
|
||||||
|
pad2.ramAddr = GameEngine_Malloc(0x1000 * 2);
|
||||||
|
}
|
||||||
|
|
||||||
if (flags == A_INIT) {
|
if (flags == A_INIT) {
|
||||||
arg3->unk_0 = (s16*) sample->sampleAddr;
|
arg3->inputBuffer = (s16*) sample->sampleAddr;
|
||||||
arg3->unk_4 = 0;
|
arg3->remainingLength = 0;
|
||||||
arg3->unk_8 = 0;
|
arg3->totalLength = 0;
|
||||||
arg3->unk18 = 0;
|
arg3->accumulator = 0;
|
||||||
|
arg3->dma = &pad2;
|
||||||
if (gSampleDmaReuseQueue1RdPos != gSampleDmaReuseQueue1WrPos) {
|
arg3->dma->devAddr = -1;
|
||||||
arg3->unk_14 = &gSampleDmas[gSampleDmaReuseQueue1[gSampleDmaReuseQueue1RdPos++]];
|
arg3->dma->sizeUnused = 0;
|
||||||
arg3->unk_14->devAddr = -1;
|
|
||||||
arg3->unk_14->sizeUnused = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gSampleDmaReuseQueue1RdPos != gSampleDmaReuseQueue1WrPos) {
|
sp1C.ttl = 2;
|
||||||
sp1C = &gSampleDmas[gSampleDmaReuseQueue1[gSampleDmaReuseQueue1RdPos++]];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (1) {} //! FAKE
|
|
||||||
|
|
||||||
sp1C->ttl = 2;
|
|
||||||
// @port: (uintptr_t)
|
// @port: (uintptr_t)
|
||||||
sp1C->devAddr = (uintptr_t) sample->sampleAddr;
|
sp1C.devAddr = (uintptr_t) sample->sampleAddr;
|
||||||
sp1C->sizeUnused = length * 2;
|
sp1C.sizeUnused = length * 2;
|
||||||
pad2 = arg3->unk_14;
|
pad2.ttl = 2;
|
||||||
pad2->ttl = 2;
|
arg3->totalLength += AudioSynth_DecompressSample(length, (s16*) sp1C.ramAddr, arg3);
|
||||||
arg3->unk_8 += func_8000967C(length, (s16*) sp1C->ramAddr, arg3);
|
return sp1C.ramAddr;
|
||||||
return sp1C->ramAddr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Acmd* AudioSynth_LoadRingBufferPart(Acmd* aList, u16 dmem, u16 startPos, s32 size, s32 reverbIndex) {
|
Acmd* AudioSynth_LoadRingBufferPart(Acmd* aList, u16 dmem, u16 startPos, s32 size, s32 reverbIndex) {
|
||||||
@ -888,6 +886,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisSta
|
|||||||
s32 dmemUncompressedAddrOffset1;
|
s32 dmemUncompressedAddrOffset1;
|
||||||
u32 sampleslenFixedPoint;
|
u32 sampleslenFixedPoint;
|
||||||
u8* samplesToLoadAddr;
|
u8* samplesToLoadAddr;
|
||||||
|
uintptr_t buffAddr;
|
||||||
s32 gain;
|
s32 gain;
|
||||||
u32 nEntries;
|
u32 nEntries;
|
||||||
s32 aligned;
|
s32 aligned;
|
||||||
@ -1009,7 +1008,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisSta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (bookSample->codec) {
|
switch ((uint8_t) bookSample->codec) {
|
||||||
case CODEC_ADPCM:
|
case CODEC_ADPCM:
|
||||||
frameSize = 9;
|
frameSize = 9;
|
||||||
skipInitialSamples = SAMPLES_PER_FRAME;
|
skipInitialSamples = SAMPLES_PER_FRAME;
|
||||||
@ -1022,11 +1021,18 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisSta
|
|||||||
sampleDmaStart = 0;
|
sampleDmaStart = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODEC_S16_INMEMORY:
|
case CODEC_S16_INMEMORY: {
|
||||||
|
buffAddr = AudioSynth_ProcessDecompression(bookSample, numSamplesToLoadAdj, flags,
|
||||||
|
&synthState->synthesisBuffers->unk_40);
|
||||||
|
if (0) {}
|
||||||
|
aLoadBuffer(aList++, OS_K0_TO_PHYSICAL(buffAddr), DMEM_UNCOMPRESSED_NOTE,
|
||||||
|
(numSamplesToLoadAdj + SAMPLES_PER_FRAME) * 2);
|
||||||
|
flags = A_CONTINUE;
|
||||||
skipBytes = 0;
|
skipBytes = 0;
|
||||||
numSamplesProcessed = numSamplesToLoadAdj;
|
numSamplesProcessed = numSamplesToLoadAdj;
|
||||||
dmemUncompressedAddrOffset1 = numSamplesToLoadAdj;
|
dmemUncompressedAddrOffset1 = numSamplesToLoadAdj;
|
||||||
goto skip;
|
goto skip;
|
||||||
|
}
|
||||||
|
|
||||||
case CODEC_S16:
|
case CODEC_S16:
|
||||||
skipBytes = 0;
|
skipBytes = 0;
|
||||||
|
@ -11,9 +11,9 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinarySampleV1::ReadResource(std
|
|||||||
auto sample = std::make_shared<Sample>(file->InitData);
|
auto sample = std::make_shared<Sample>(file->InitData);
|
||||||
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
|
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
|
||||||
|
|
||||||
sample->mSample.codec = reader->ReadUInt32();
|
sample->mSample.codec = reader->ReadUByte();
|
||||||
sample->mSample.medium = reader->ReadUInt32();
|
sample->mSample.medium = reader->ReadUByte();
|
||||||
sample->mSample.unk = reader->ReadUInt32();
|
sample->mSample.unk = reader->ReadUByte();
|
||||||
sample->mSample.size = reader->ReadUInt32();
|
sample->mSample.size = reader->ReadUInt32();
|
||||||
sample->mSample.loop = LoadChild<AdpcmLoopData*>(reader->ReadUInt64());
|
sample->mSample.loop = LoadChild<AdpcmLoopData*>(reader->ReadUInt64());
|
||||||
sample->mSample.book = LoadChild<AdpcmBookData*>(reader->ReadUInt64());
|
sample->mSample.book = LoadChild<AdpcmBookData*>(reader->ReadUInt64());
|
||||||
@ -34,9 +34,9 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinarySampleV2::ReadResource(std
|
|||||||
auto sample = std::make_shared<Sample>(file->InitData);
|
auto sample = std::make_shared<Sample>(file->InitData);
|
||||||
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
|
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
|
||||||
|
|
||||||
sample->mSample.codec = reader->ReadUInt32();
|
sample->mSample.codec = reader->ReadUByte();
|
||||||
sample->mSample.medium = reader->ReadUInt32();
|
sample->mSample.medium = reader->ReadUByte();
|
||||||
sample->mSample.unk = reader->ReadUInt32();
|
sample->mSample.unk = reader->ReadUByte();
|
||||||
sample->mSample.size = reader->ReadUInt32();
|
sample->mSample.size = reader->ReadUInt32();
|
||||||
sample->mSample.tuning = reader->ReadFloat();
|
sample->mSample.tuning = reader->ReadFloat();
|
||||||
sample->mSample.loop = LoadChild<AdpcmLoopData*>(reader->ReadUInt64());
|
sample->mSample.loop = LoadChild<AdpcmLoopData*>(reader->ReadUInt64());
|
||||||
|
Loading…
Reference in New Issue
Block a user