From 1c3c7b194a47d740196cad7bcb2e79b41b7f578d Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 24 Jun 2023 13:48:44 -0700 Subject: [PATCH] Fixed vanilla sounds on 32-bit --- Makefile | 3 +++ include/seq_macros.inc | 6 +++++- sound/sequences/00_sound_player.s | 7 ++++++- src/audio/seqplayer.c | 12 ++++++++---- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 885f9095..2ef923aa 100644 --- a/Makefile +++ b/Makefile @@ -175,6 +175,9 @@ else EXTRA_CPP_INCLUDES ?= endif +ifeq ($(TARGET_BITS), 32) + DEFINES += BITS_32=1 +endif # VERSION - selects the version of the game to build # jp - builds the 1996 Japanese version diff --git a/include/seq_macros.inc b/include/seq_macros.inc index 33c33208..1b6827e3 100644 --- a/include/seq_macros.inc +++ b/include/seq_macros.inc @@ -91,7 +91,11 @@ .macro seq_initchannels_extended a .byte 0xc1 - .byte (\a >> 56) & 0xff, (\a >> 48) & 0xff, (\a >> 40) & 0xff, (\a >> 32) & 0xff, (\a >> 24) & 0xff, (\a >> 16) & 0xff, (\a >> 8) & 0xff, \a & 0xff + .ifdef BITS_32 + .byte 0, 0, 0, 0, (\a >> 24) & 0xff, (\a >> 16) & 0xff, (\a >> 8) & 0xff, \a & 0xff + .else + .byte (\a >> 56) & 0xff, (\a >> 48) & 0xff, (\a >> 40) & 0xff, (\a >> 32) & 0xff, (\a >> 24) & 0xff, (\a >> 16) & 0xff, (\a >> 8) & 0xff, \a & 0xff + .endif .endm .macro seq_changevol a diff --git a/sound/sequences/00_sound_player.s b/sound/sequences/00_sound_player.s index acbeee3d..342086c5 100644 --- a/sound/sequences/00_sound_player.s +++ b/sound/sequences/00_sound_player.s @@ -18,7 +18,12 @@ seq_setmutescale 0 seq_setvol 127 .endif seq_settempo 120 -seq_initchannels_extended 0xffffffffffffffff + +.ifdef BITS_32 + seq_initchannels_extended 0xb33f +.else + seq_initchannels_extended 0xffffffffffffffff +.endif # SOUND_BANK_ACTION seq_startchannel_extended 0, .channel0 diff --git a/src/audio/seqplayer.c b/src/audio/seqplayer.c index 990da028..38b5a043 100644 --- a/src/audio/seqplayer.c +++ b/src/audio/seqplayer.c @@ -532,10 +532,11 @@ s32 m64_read_s32(struct M64ScriptState* state) { assert(state != NULL); assert(state->pc != NULL); #endif - s32 ret = *(state->pc++) << 24; - ret = (*(state->pc++) << 16) | ret; - ret = (*(state->pc++) << 8) | ret; - ret = *(state->pc++) | ret; + s32 ret = 0; + ret = (((u32)*(state->pc++) << 24)) | ret; + ret = (((u32)*(state->pc++) << 16)) | ret; + ret = (((u32)*(state->pc++) << 8)) | ret; + ret = (((u32)*(state->pc++) << 0)) | ret; return ret; } @@ -2750,6 +2751,9 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { case 0xc1: // seq_initchannels_extended u64v = m64_read_s64(state); +#ifdef BITS_32 + if (u64v == 0xb33f) { u64v = 0xffffffffffffffff; } +#endif sequence_player_init_channels_extended(seqPlayer, u64v); break;