summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSonic Dreamcaster <alejandro.asenjo88@gmail.com>2025-01-30 17:59:15 -0300
committerSonic Dreamcaster <alejandro.asenjo88@gmail.com>2025-01-30 17:59:15 -0300
commita241e77f781fcbdad7408af0b60ea41d616d2a94 (patch)
treeb19cdd5038581e600e9786e06e68736d0309bd28
parentd88cc5f58dd8bea0b7f18c4062fbfc72fd8a43a6 (diff)
endianess fixes and tester
-rw-r--r--include/sf64audio_provisional.h14
-rw-r--r--src/audio/audio_playback.c39
2 files changed, 40 insertions, 13 deletions
diff --git a/include/sf64audio_provisional.h b/include/sf64audio_provisional.h
index a7c90fe3..952af4dc 100644
--- a/include/sf64audio_provisional.h
+++ b/include/sf64audio_provisional.h
@@ -377,11 +377,10 @@ typedef struct {
typedef struct {
/* 0x00 */ union {
struct A {
- /* 0x00 */ u8 unused : 1;
- /* 0x00 */ u8 hang : 1;
- /* 0x00 */ u8 decay : 1;
/* 0x00 */ u8 release : 1;
- /* 0x00 */
+ /* 0x00 */ u8 decay : 1;
+ /* 0x00 */ u8 hang : 1;
+ /* 0x00 */ u8 unused : 1;
} s;
/* 0x00 */ u8 asByte;
} action;
@@ -432,9 +431,10 @@ typedef struct SequenceChannel {
/* 0x00 */ u8 unused : 1;
union {
struct {
- /* 0x01 */ u8 freqMod : 1;
- /* 0x01 */ u8 volume : 1;
- /* 0x01 */ u8 pan : 1;
+ /* 0x4 */ char pad_4 : 1;
+ /* 0x3 */ u8 pan : 1;
+ /* 0x2 */ u8 volume : 1;
+ /* 0x1 */ u8 freqMod : 1;
} s;
/* 0x01 */ u8 asByte;
} changes;
diff --git a/src/audio/audio_playback.c b/src/audio/audio_playback.c
index bd41160c..80235d68 100644
--- a/src/audio/audio_playback.c
+++ b/src/audio/audio_playback.c
@@ -40,6 +40,31 @@ void Audio_AudioListPushFront(AudioListItem* list, AudioListItem* item);
void Audio_AudioListRemove(Note* note);
void Audio_NoteInitForLayer(Note* note, SequenceLayer* layer);
+#if 0
+typedef struct { // Little Endian
+ /* 0x00 */ uint8_t strongLeft : 1; // 0000 0001
+ /* 0x00 */ uint8_t strongRight : 1; // 0000 0010
+ /* 0x00 */ uint8_t bit2 : 2; // 0000 0100
+ /* 0x00 */ uint8_t unused : 2; // 0001 0000
+ /* 0x00 */ uint8_t usesHeadsetPanEffects : 1; // 0100 0000
+ /* 0x00 */ uint8_t stereoHeadsetEffects : 1; // 1000 0000
+} StereoDataTest;
+
+typedef union {
+ StereoDataTest data;
+ uint8_t raw;
+} StereoUnionTest;
+
+int testBits(void) {
+ StereoUnionTest test;
+
+ test.raw = 0; // Clear all bits
+ test.data.stereoHeadsetEffects = 1;
+
+ printf("Raw byte value: 0x%08X\n", test.raw);
+}
+#endif
+
void Audio_InitNoteSub(Note* note, NoteAttributes* noteAttr) {
NoteSubEu* noteSub;
f32 panVolumeLeft;
@@ -53,6 +78,8 @@ void Audio_InitNoteSub(Note* note, NoteAttributes* noteAttr) {
u8 reverb;
Stereo stereo;
+ // testBits();
+
Audio_NoteSetResamplingRate(note, noteAttr->freqMod);
noteSub = &note->noteSubEu;
velocity = noteAttr->velocity;
@@ -168,9 +195,9 @@ TunedSample* Audio_GetInstrumentTunedSample(Instrument* instrument, s32 semitone
Instrument* Audio_GetInstrument(s32 fontId, s32 instId) {
Instrument* instrument;
- //fontId = 7;
+ // fontId = 7;
- if(gSoundFontList[fontId].instruments == NULL){
+ if (gSoundFontList[fontId].instruments == NULL) {
gSoundFontList[fontId] = *Audio_LoadFont(gSoundFontTable->entries[fontId], fontId);
}
@@ -194,7 +221,7 @@ Drum* Audio_GetDrum(s32 fontId, s32 drumId) {
Drum* drum;
// LTODO: Remove this
- if(gSoundFontList[fontId].drums == NULL){
+ if (gSoundFontList[fontId].drums == NULL) {
gSoundFontList[fontId] = *Audio_LoadFont(gSoundFontTable->entries[fontId], fontId);
}
@@ -206,9 +233,9 @@ Drum* Audio_GetDrum(s32 fontId, s32 drumId) {
D_80155D88 = (fontId << 8) + drumId + 0x04000000;
return NULL;
}
-// if ((u32) gSoundFontList[fontId].drums < AUDIO_RELOCATED_ADDRESS_START) {
-// return NULL;
-// }
+ // if ((u32) gSoundFontList[fontId].drums < AUDIO_RELOCATED_ADDRESS_START) {
+ // return NULL;
+ // }
drum = gSoundFontList[fontId].drums[drumId];
if (gSoundFontList[fontId].drums[drumId] == NULL) {
D_80155D88 = (fontId << 8) + drumId + 0x05000000;