From 0f58b15b2788a1fe5c299000c69ab8d3d71fc4c9 Mon Sep 17 00:00:00 2001 From: Roman971 <32455037+Roman971@users.noreply.github.com> Date: Wed, 24 Nov 2021 03:07:48 +0100 Subject: Minor data/ cleanups (#1025) * Moved code_800D2E30's data to C * Moved some audio data from asm to C * Made separate data files for unknown pointer arrays * Fixed a few missing balign directives --- src/code/audio_effects.c | 14 ++++++-------- src/code/audio_seqplayer.c | 10 ++++++++-- src/code/code_800D2E30.c | 5 ++--- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src/code') diff --git a/src/code/audio_effects.c b/src/code/audio_effects.c index 04aa5e006..b87186719 100644 --- a/src/code/audio_effects.c +++ b/src/code/audio_effects.c @@ -105,13 +105,13 @@ s16 Audio_GetVibratoPitchChange(VibratoState* vib) { } f32 Audio_GetVibratoFreqScale(VibratoState* vib) { + static f32 D_80130510 = 0.0f; + static s32 D_80130514 = 0; f32 pitchChange; f32 extent; f32 invExtent; f32 result; f32 temp; - f32 twoToThe16th = 65536.0f; - s32 one = 1; SequenceChannel* channel = vib->channel; if (vib->delay != 0) { @@ -160,13 +160,11 @@ f32 Audio_GetVibratoFreqScale(VibratoState* vib) { extent = temp + 1.0f; invExtent = 1.0f / extent; - // fakematch: 2^16 and 1 need to be set at the very top of this function, - // or else the addresses of D_80130510 and D_80130514 get computed once - // instead of twice. 'temp' is also a fakematch sign; removing it causes - // regalloc differences and reorderings at the top of the function. - result = 1.0f / ((extent - invExtent) * pitchChange / twoToThe16th + invExtent); + result = 1.0f / ((extent - invExtent) * pitchChange / 65536.0f + invExtent); + D_80130510 += result; - D_80130514 += one; + D_80130514++; + return result; } diff --git a/src/code/audio_seqplayer.c b/src/code/audio_seqplayer.c index 0cbe6a539..547a957a9 100644 --- a/src/code/audio_seqplayer.c +++ b/src/code/audio_seqplayer.c @@ -9,14 +9,20 @@ #define PORTAMENTO_MODE_4 4 #define PORTAMENTO_MODE_5 5 -extern u8 D_80130470[]; - u8 AudioSeq_ScriptReadU8(SeqScriptState* state); s16 AudioSeq_ScriptReadS16(SeqScriptState* state); u16 AudioSeq_ScriptReadCompressedU16(SeqScriptState* state); u8 AudioSeq_GetInstrument(SequenceChannel* channel, u8 instId, Instrument** instOut, AdsrSettings* adsr); +u8 D_80130520[] = { + 0x81, 0x00, 0x81, 0x01, 0x00, 0x00, 0x00, 0x81, 0x01, 0x01, 0x01, 0x42, 0x81, 0xC2, 0x00, 0x00, + 0x00, 0x01, 0x81, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x81, 0x01, 0x01, 0x81, 0x81, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x01, 0x01, 0x01, 0x81, 0x01, + 0x01, 0x03, 0x03, 0x01, 0x00, 0x01, 0x01, 0x81, 0x03, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x82, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x81, 0x00, 0x00, 0x01, 0x81, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, +}; + u16 AudioSeq_GetScriptControlFlowArgument(SeqScriptState* state, u8 arg1) { u8 temp_v0 = D_80130520[arg1 - 0xB0]; u8 loBits = temp_v0 & 3; diff --git a/src/code/code_800D2E30.c b/src/code/code_800D2E30.c index 1c731c9bd..a182926f1 100644 --- a/src/code/code_800D2E30.c +++ b/src/code/code_800D2E30.c @@ -1,23 +1,22 @@ #include "global.h" void func_800D2E30(UnkRumbleStruct* arg0) { + static u8 D_8012DBB0 = 1; s32 i; s32 unk_a3; s32 index = -1; - UnkRumbleStruct* new_var; for (i = 0; i < 4; i++) { arg0->rumbleEnable[i] = 0; } if (arg0->unk_105 == 0) { - new_var = arg0; if (D_8012DBB0 != 0) { for (i = 0; i < 4; i++) { gPadMgr.pakType[i] = 0; } } - D_8012DBB0 = new_var->unk_105; + D_8012DBB0 = arg0->unk_105; return; } -- cgit v1.2.3