Removed 32 bit structs

This commit is contained in:
KiritoDv 2024-11-03 10:56:53 -06:00
parent 2a8ac4891e
commit 6393690103
4 changed files with 43 additions and 81 deletions

3
.gitignore vendored
View File

@ -47,4 +47,5 @@ starship.cfg.json
Starship.log
*.sav
*.lib
*.pdb
*.pdb
dumps/

View File

@ -224,12 +224,6 @@ typedef struct {
/* 0x08 */ s16* book; // size 8 * order * numPredictors.
} AdpcmBook; // size >= 8, 0x8 aligned
typedef struct {
/* 0x00 */ s32 order;
/* 0x04 */ s32 numPredictors;
/* 0x08 */ u32 book; // size 8 * order * numPredictors.
} AdpcmBook32Bit; // size >= 8, 0x8 aligned
typedef struct {
/* 0x00 */ u32 codec : 4; // The state of compression or decompression
/* 0x00 */ u32 medium : 2; // Medium where sample is currently stored
@ -244,28 +238,11 @@ typedef struct {
book; // Adpcm book parameters used by the sample. Offset from the start of the sound font / pointer to ram
} Sample; // size = 0x10
typedef struct {
/* 0x00 */ u32 codec : 4; // The state of compression or decompression
/* 0x00 */ u32 medium : 2; // Medium where sample is currently stored
/* 0x00 */ u32 unk_bit26 : 1;
/* 0x00 */ u32 isRelocated : 1; // Has the sample header been relocated (offsets to pointers)
/* 0x01 */ u32 size : 24; // Size of the sample
/* 0x04 */ u32 sampleAddr; // Raw sample data. Offset from the start of the sample bank or absolute address to
// either rom or ram
/* 0x08 */ u32 loop; // Adpcm loop parameters used by the sample. Offset from the start of the sound font / pointer to ram
/* 0x0C */ u32 book; // Adpcm book parameters used by the sample. Offset from the start of the sound font / pointer to ram
} Sample32Bit; // size = 0x10
typedef struct {
/* 0x00 */ Sample* sample;
/* 0x04 */ f32 tuning; // frequency modulation factor
} TunedSample;// size = 0x8
typedef struct {
/* 0x00 */ u32 sample;
/* 0x04 */ f32 tuning; // frequency modulation factor
} TunedSample32Bit;
typedef struct {
/* 0x00 */ u8 isRelocated; // have the envelope and all samples been relocated (offsets to pointers)
/* 0x01 */ u8 normalRangeLo;
@ -277,17 +254,6 @@ typedef struct {
/* 0x18 */ TunedSample highPitchTunedSample;
} Instrument; // size = 0x20
typedef struct {
/* 0x00 */ u8 isRelocated; // have the envelope and all samples been relocated (offsets to pointers)
/* 0x01 */ u8 normalRangeLo;
/* 0x02 */ u8 normalRangeHi;
/* 0x03 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable
/* 0x04 */ u32 envelope;
/* 0x08 */ TunedSample32Bit lowPitchTunedSample;
/* 0x10 */ TunedSample32Bit normalPitchTunedSample;
/* 0x18 */ TunedSample32Bit highPitchTunedSample;
} Instrument32Bit; // size = 0x20
typedef struct {
/* 0x00 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable
/* 0x01 */ u8 pan;
@ -296,14 +262,6 @@ typedef struct {
/* 0x0C */ EnvelopePoint* envelope;
} Drum; // size = 0x10
typedef struct {
/* 0x00 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable
/* 0x01 */ u8 pan;
/* 0x02 */ u8 isRelocated; // have tunedSample.sample and envelope been relocated (offsets to pointers)
/* 0x04 */ TunedSample tunedSample;
/* 0x0C */ EnvelopePoint* envelope;
} Drum32Bit; // size = 0x10
typedef struct {
/* 0x00 */ TunedSample tunedSample;
} SoundEffect; // size = 0x08

View File

@ -1209,41 +1209,41 @@ static const char devstr50[] = "Error: Already wavetable is touched %x.\n";
static const char devstr51[] = "Touch Warning: Length zero %x\n";
void AudioLoad_RelocateSample(TunedSample* tSample, u32 fontDataAddr, SampleBankRelocInfo* relocInfo) {
Sample32Bit* baseSample = fontDataAddr + BSWAP32(tSample->sample);
// "Touch Warning: Length zero %x\n";
if ((baseSample->size != 0) && (baseSample->isRelocated != 1)) {
Sample* output = memalloc(sizeof(Sample));
output->loop = Audio_LoadLoop(fontDataAddr + BSWAP32(baseSample->loop));
output->book = Audio_LoadBook(fontDataAddr + BSWAP32(baseSample->book));
output->codec = baseSample->codec;
output->medium = baseSample->medium;
output->unk_bit26 = baseSample->unk_bit26;
output->isRelocated = baseSample->isRelocated;
output->size = baseSample->size;
output->isRelocated = 1;
switch (baseSample->medium) {
case MEDIUM_RAM:
// baseSample->sampleAddr = Audio_LoadCopy(relocInfo->baseAddr1 + BSWAP32(baseSample->sampleAddr), BSWAP32(baseSample->size));
baseSample->medium = relocInfo->medium1;
break;
case MEDIUM_UNK:
// baseSample->sampleAddr = Audio_LoadCopy(relocInfo->baseAddr2 + BSWAP32(baseSample->sampleAddr), BSWAP32(baseSample->size));
baseSample->medium = relocInfo->medium2;
break;
case MEDIUM_CART:
case MEDIUM_DISK_DRIVE:
output->sampleAddr = fontDataAddr + BSWAP32(baseSample->sampleAddr);
break;
}
baseSample->isRelocated = true;
if (baseSample->unk_bit26 && (baseSample->medium != 0)) {
gUsedSamples[gNumUsedSamples++] = output;
}
}
// Sample32Bit* baseSample = fontDataAddr + BSWAP32(tSample->sample);
//
// // "Touch Warning: Length zero %x\n";
// if ((baseSample->size != 0) && (baseSample->isRelocated != 1)) {
// Sample* output = memalloc(sizeof(Sample));
//
// output->loop = Audio_LoadLoop(fontDataAddr + BSWAP32(baseSample->loop));
// output->book = Audio_LoadBook(fontDataAddr + BSWAP32(baseSample->book));
// output->codec = baseSample->codec;
// output->medium = baseSample->medium;
// output->unk_bit26 = baseSample->unk_bit26;
// output->isRelocated = baseSample->isRelocated;
// output->size = baseSample->size;
//
// output->isRelocated = 1;
// switch (baseSample->medium) {
// case MEDIUM_RAM:
//// baseSample->sampleAddr = Audio_LoadCopy(relocInfo->baseAddr1 + BSWAP32(baseSample->sampleAddr), BSWAP32(baseSample->size));
// baseSample->medium = relocInfo->medium1;
// break;
// case MEDIUM_UNK:
//// baseSample->sampleAddr = Audio_LoadCopy(relocInfo->baseAddr2 + BSWAP32(baseSample->sampleAddr), BSWAP32(baseSample->size));
// baseSample->medium = relocInfo->medium2;
// break;
// case MEDIUM_CART:
// case MEDIUM_DISK_DRIVE:
// output->sampleAddr = fontDataAddr + BSWAP32(baseSample->sampleAddr);
// break;
// }
//
// baseSample->isRelocated = true;
// if (baseSample->unk_bit26 && (baseSample->medium != 0)) {
// gUsedSamples[gNumUsedSamples++] = output;
// }
// }
}
static const char devstr52[] = "It's busy now!!!!! %d\n";

View File

@ -126,16 +126,19 @@ Sample* Audio_LoadSample(uint32_t sampleAddr, AudioTableEntry entry, uint32_t sa
Sample* sample = memalloc(Sample);
uint32_t flags = reader.ReadUInt32();
uint32_t addr = reader.ReadUInt32();
sample->codec = (flags >> 28) & 0x0F;
sample->medium = MEDIUM_RAM; // (flags >> 24) & 0x03;
sample->medium = (flags >> 24) & 0x03;
sample->unk_bit26 = (flags >> 22) & 0x01;
sample->size = flags;
uint32_t addr = reader.ReadUInt32();
sample->loop = Audio_LoadLoop(entry.romAddr + reader.ReadUInt32());
sample->book = Audio_LoadBook(entry.romAddr + reader.ReadUInt32());
sample->isRelocated = 1;
sample->sampleAddr = (uint8_t*) Audio_LoadBlob(gAudioTable, gSampleBankTable->entries[sampleBankID].romAddr + addr);
sample->isRelocated = 1;
sample->medium = MEDIUM_RAM;
std::filesystem::path path{ "dumps/" + std::to_string(addr) + ".raw" };
std::ofstream ofs(path);
ofs.write(reinterpret_cast<const char*>(sample->sampleAddr), sample->size);