Removed some more DEBUG_PRINT statements and fixed padding.

This commit is contained in:
MeltyPlayer
2022-12-06 17:07:14 -06:00
parent 4b98663b59
commit 5faeaff908
4 changed files with 202 additions and 214 deletions
+1 -13
View File
@@ -1,7 +1,6 @@
#pragma once #pragma once
#include "convUtils.h" #include "convUtils.h"
#include "../../debug_print.h"
#include "utils.h" #include "utils.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@@ -22,8 +21,6 @@
unsigned char* gCtlSeqs; unsigned char* gCtlSeqs;
struct seqFile* parse_seqfile(unsigned char* seq){ /* Read SeqFile data */ struct seqFile* parse_seqfile(unsigned char* seq){ /* Read SeqFile data */
DEBUG_PRINT("parse_seqfile()");
short revision = read_u16_be(seq); short revision = read_u16_be(seq);
short bankCount = read_u16_be(seq + 2); short bankCount = read_u16_be(seq + 2);
@@ -37,20 +34,14 @@ struct seqFile* parse_seqfile(unsigned char* seq){ /* Read SeqFile data */
seqFile->seqArray[i].len = read_u32_be((seq + 4 + i * 8 + 4)); seqFile->seqArray[i].len = read_u32_be((seq + 4 + i * 8 + 4));
} }
DEBUG_PRINT("- revision: %d", revision);
if (revision == TYPE_CTL){ if (revision == TYPE_CTL){
DEBUG_PRINT("- ctl!");
// CTL file, contains instrument and drum data, this is really the only one that needs to be parsed, the rest only needs a header change // CTL file, contains instrument and drum data, this is really the only one that needs to be parsed, the rest only needs a header change
gCtlSeqs = (unsigned char*)calloc(0x20B40, 1); // We only really need 0x20AD0 bytes but still gCtlSeqs = (unsigned char*)calloc(0x20B40, 1); // We only really need 0x20AD0 bytes but still
uintptr_t pos = (uintptr_t)gCtlSeqs; uintptr_t pos = (uintptr_t)gCtlSeqs;
DEBUG_PRINT("- bank count: %d", bankCount);
for (int i = 0; i < bankCount; i++){ for (int i = 0; i < bankCount; i++){
DEBUG_PRINT("- ctl bank index: %d", i);
uintptr_t start = pos; uintptr_t start = pos;
struct CTL* ptr = parse_ctl_data(seq+(seqFile->seqArray[i].offset), &pos); struct CTL* ptr = parse_ctl_data(seq+(seqFile->seqArray[i].offset), &pos);
DEBUG_PRINT("- read ptr: %x", ptr);
seqFile->seqArray[i].offset = ptr; seqFile->seqArray[i].offset = ptr;
DEBUG_PRINT("- stored offset: %x", seqFile->seqArray[i].offset);
seqFile->seqArray[i].len = (unsigned int)(pos - start); seqFile->seqArray[i].len = (unsigned int)(pos - start);
} }
}else if (revision == TYPE_TBL){ }else if (revision == TYPE_TBL){
@@ -249,16 +240,13 @@ struct TBL* parse_tbl_data(unsigned char* tbl){
return tblData; return tblData;
} }
struct SEQ* parse_seq_data(unsigned char* seq){ struct SEQ* parse_seq_data(unsigned char* seq){
struct SEQ* seqData = malloc(sizeof(struct SEQ)); struct SEQ* seqData = malloc(sizeof(struct SEQ));
seqData->data = seq; seqData->data = seq;
return seqData; return seqData;
} }
struct CTL* parse_ctl_data(unsigned char* ctlData, uintptr_t* pos){ struct CTL* parse_ctl_data(unsigned char* ctlData, uintptr_t* pos){
DEBUG_PRINT("parse_ctl_data()");
DEBUG_PRINT("- ctlData: %x", ctlData);
DEBUG_PRINT("- pos: %x", pos);
int instruments=read_u32_be(ctlData); int instruments=read_u32_be(ctlData);
unsigned int size = sizeof(struct CTL) + sizeof(struct CInstrument*) * (instruments-1); unsigned int size = sizeof(struct CTL) + sizeof(struct CInstrument*) * (instruments-1);
struct CTL* ctl = (struct CTL*)(*pos); struct CTL* ctl = (struct CTL*)(*pos);
+1 -1
View File
@@ -149,7 +149,7 @@ extern SM64_LIB_FN uint32_t sm64_audio_tick( uint32_t numQueuedSamples, uint32_t
u32 num_audio_samples = numQueuedSamples < numDesiredSamples ? SAMPLES_HIGH : SAMPLES_LOW; u32 num_audio_samples = numQueuedSamples < numDesiredSamples ? SAMPLES_HIGH : SAMPLES_LOW;
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
create_next_audio_buffer(audio_buffer + i * (2 * num_audio_samples), num_audio_samples); create_next_audio_buffer( audio_buffer + i * ( 2 * num_audio_samples ), num_audio_samples );
} }
return num_audio_samples; return num_audio_samples;
+8 -8
View File
@@ -5,19 +5,19 @@
#include "decomp/audio/load_dat.h" #include "decomp/audio/load_dat.h"
extern void load_audio_banks( uint8_t *rom ) { extern void load_audio_banks( uint8_t *rom ) {
uint8_t *rom2 = malloc(0x800000); uint8_t *rom2 = malloc( 0x800000 );
memcpy(rom2, rom, 0x800000); memcpy( rom2, rom, 0x800000 );
rom = rom2; rom = rom2;
gSoundDataADSR = parse_seqfile(rom+0x57B720); //ctl gSoundDataADSR = parse_seqfile( rom+0x57B720 ); //ctl
gSoundDataRaw = parse_seqfile(rom+0x593560); //tbl gSoundDataRaw = parse_seqfile( rom+0x593560 ); //tbl
gMusicData = parse_seqfile(rom+0x7B0860); gMusicData = parse_seqfile( rom+0x7B0860 );
gBankSetsData = rom+0x7CC621; gBankSetsData = rom+0x7CC621;
memmove(gBankSetsData+0x45,gBankSetsData+0x45-1,0x5B); memmove( gBankSetsData+0x45,gBankSetsData+0x45-1,0x5B );
gBankSetsData[0x45]=0x00; gBankSetsData[0x45]=0x00;
ptrs_to_offsets(gSoundDataADSR); ptrs_to_offsets( gSoundDataADSR );
audio_init(); audio_init();
sound_init(); sound_init();
sound_reset(0); sound_reset( 0 );
} }