From bdb976dc27b00a7e86c0bda10911c67c9d296c35 Mon Sep 17 00:00:00 2001 From: pi1024e <49824824+pi1024e@users.noreply.github.com> Date: Sat, 29 Aug 2020 13:18:35 -0400 Subject: [PATCH] fixed mistakes --- constants/m4a_constants.inc | 350 ++++++++++++++++++---------------- include/gba/m4a_internal.h | 6 +- libagbsyscall/libagbsyscall.s | 2 +- src/AgbRfu_LinkManager.c | 2 +- src/m4a.c | 2 - 5 files changed, 188 insertions(+), 174 deletions(-) diff --git a/constants/m4a_constants.inc b/constants/m4a_constants.inc index d57b5b5c2..62ca5bb55 100644 --- a/constants/m4a_constants.inc +++ b/constants/m4a_constants.inc @@ -6,178 +6,194 @@ .equiv TONEDATA_TYPE_FIX, 0x08 .equiv TONEDATA_TYPE_SPL, 0x40 @ key split .equiv TONEDATA_TYPE_RHY, 0x80 @ rhythm - .equiv TONEDATA_P_S_PAN, 0xc0 - .equiv o_SoundChannel_status, 0 - .equiv o_SoundChannel_type, 1 - .equiv o_SoundChannel_rightVolume, 2 - .equiv o_SoundChannel_leftVolume, 3 - .equiv o_SoundChannel_attack, 4 - .equiv o_SoundChannel_decay, 5 - .equiv o_SoundChannel_sustain, 6 - .equiv o_SoundChannel_release, 7 - .equiv o_SoundChannel_ky, 8 - .equiv o_SoundChannel_ev, 9 - .equiv o_SoundChannel_er, 10 - .equiv o_SoundChannel_el, 11 - .equiv o_SoundChannel_iev, 12 - .equiv o_SoundChannel_iel, 13 - .equiv o_SoundChannel_d1, 14 - .equiv o_SoundChannel_d2, 15 - .equiv o_SoundChannel_gt, 16 - .equiv o_SoundChannel_mk, 17 - .equiv o_SoundChannel_ve, 18 - .equiv o_SoundChannel_pr, 19 - .equiv o_SoundChannel_d3, 20 - .equiv o_SoundChannel_ct, 24 - .equiv o_SoundChannel_fw, 28 - .equiv o_SoundChannel_freq, 32 - .equiv o_SoundChannel_wav, 36 - .equiv o_SoundChannel_cp, 40 - .equiv o_SoundChannel_track, 44 - .equiv o_SoundChannel_pp, 48 - .equiv o_SoundChannel_np, 52 - .equiv o_SoundChannel_d4, 56 - .equiv o_SoundChannel_xpi, 60 - .equiv o_SoundChannel_xpc, 62 + .macro struct_begin + .struct 0 + .endm - .equiv SoundChannel_size, 64 + .macro struct_field name, size +\name: + .struct \name + \size + .endm - .equiv o_SoundInfo_ident, 0 - .equiv o_SoundInfo_pcmDmaCounter, 4 - .equiv o_SoundInfo_reverb, 5 - .equiv o_SoundInfo_maxChans, 6 - .equiv o_SoundInfo_masterVolume, 7 - .equiv o_SoundInfo_freq, 8 - .equiv o_SoundInfo_mode, 9 - .equiv o_SoundInfo_c15, 10 - .equiv o_SoundInfo_pcmDmaPeriod, 11 - .equiv o_SoundInfo_maxLines, 12 - .equiv o_SoundInfo_gap, 13 - .equiv o_SoundInfo_pcmSamplesPerVBlank, 16 - .equiv o_SoundInfo_pcmFreq, 20 - .equiv o_SoundInfo_divFreq, 24 - .equiv o_SoundInfo_cgbChans, 28 - .equiv o_SoundInfo_func, 32 - .equiv o_SoundInfo_intp, 36 - .equiv o_SoundInfo_CgbSound, 40 - .equiv o_SoundInfo_CgbOscOff, 44 - .equiv o_SoundInfo_MidiKeyToCgbFreq, 48 - .equiv o_SoundInfo_MPlayJumpTable, 52 - .equiv o_SoundInfo_plynote, 56 - .equiv o_SoundInfo_ExtVolPit, 60 - .equiv o_SoundInfo_gap2, 64 - .equiv o_SoundInfo_chans, 80 - .equiv o_SoundInfo_pcmBuffer, o_SoundInfo_chans + (SoundChannel_size * 12) + struct_begin + struct_field o_SoundInfo_ident, 4 + struct_field o_SoundInfo_pcmDmaCounter, 1 + struct_field o_SoundInfo_reverb, 1 + struct_field o_SoundInfo_maxChans, 1 + struct_field o_SoundInfo_masterVolume, 1 + struct_field o_SoundInfo_freq, 1 + struct_field o_SoundInfo_mode, 1 + struct_field o_SoundInfo_c15, 1 + struct_field o_SoundInfo_pcmDmaPeriod, 1 + struct_field o_SoundInfo_maxLines, 1 + struct_field o_SoundInfo_gap, 3 + struct_field o_SoundInfo_pcmSamplesPerVBlank, 4 + struct_field o_SoundInfo_pcmFreq, 4 + struct_field o_SoundInfo_divFreq, 4 + struct_field o_SoundInfo_cgbChans, 4 + struct_field o_SoundInfo_func, 4 + struct_field o_SoundInfo_intp, 4 + struct_field o_SoundInfo_CgbSound, 4 + struct_field o_SoundInfo_CgbOscOff, 4 + struct_field o_SoundInfo_MidiKeyToCgbFreq, 4 + struct_field o_SoundInfo_MPlayJumpTable, 4 + struct_field o_SoundInfo_plynote, 4 + struct_field o_SoundInfo_ExtVolPit, 4 + struct_field o_SoundInfo_gap2, 16 + struct_field o_SoundInfo_chans, 768 + struct_field o_SoundInfo_pcmBuffer, PCM_DMA_BUF_SIZE * 2 + struct_field SoundInfo_size, 0 - .equiv o_MusicPlayerTrack_flags, 0 - .equiv o_MusicPlayerTrack_wait, 1 - .equiv o_MusicPlayerTrack_patternLevel, 2 - .equiv o_MusicPlayerTrack_repN, 3 - .equiv o_MusicPlayerTrack_gateTime, 4 - .equiv o_MusicPlayerTrack_key, 5 - .equiv o_MusicPlayerTrack_velocity, 6 - .equiv o_MusicPlayerTrack_runningStatus, 7 - .equiv o_MusicPlayerTrack_keyM, 8 - .equiv o_MusicPlayerTrack_pitM, 9 - .equiv o_MusicPlayerTrack_keyShift, 10 - .equiv o_MusicPlayerTrack_keyShiftX, 11 - .equiv o_MusicPlayerTrack_tune, 12 - .equiv o_MusicPlayerTrack_pitX, 13 - .equiv o_MusicPlayerTrack_bend, 14 - .equiv o_MusicPlayerTrack_bendRange, 15 - .equiv o_MusicPlayerTrack_volMR, 16 - .equiv o_MusicPlayerTrack_volML, 17 - .equiv o_MusicPlayerTrack_vol, 18 - .equiv o_MusicPlayerTrack_volX, 19 - .equiv o_MusicPlayerTrack_pan, 20 - .equiv o_MusicPlayerTrack_panX, 21 - .equiv o_MusicPlayerTrack_modM, 22 - .equiv o_MusicPlayerTrack_mod, 23 - .equiv o_MusicPlayerTrack_modT, 24 - .equiv o_MusicPlayerTrack_lfoSpeed, 25 - .equiv o_MusicPlayerTrack_lfoSpeedC, 26 - .equiv o_MusicPlayerTrack_lfoDelay, 27 - .equiv o_MusicPlayerTrack_lfoDelayC, 28 - .equiv o_MusicPlayerTrack_priority, 29 - .equiv o_MusicPlayerTrack_echoVolume, 30 - .equiv o_MusicPlayerTrack_echoLength, 31 - .equiv o_MusicPlayerTrack_chan, 32 - .equiv o_MusicPlayerTrack_ToneData_type, 36 - .equiv o_MusicPlayerTrack_ToneData_key, 37 - .equiv o_MusicPlayerTrack_ToneData_length, 38 - .equiv o_MusicPlayerTrack_ToneData_pan_sweep, 39 - .equiv o_MusicPlayerTrack_ToneData_wav, 40 - .equiv o_MusicPlayerTrack_ToneData_attack, 44 - .equiv o_MusicPlayerTrack_ToneData_decay, 45 - .equiv o_MusicPlayerTrack_ToneData_sustain, 46 - .equiv o_MusicPlayerTrack_ToneData_release, 47 - .equiv o_MusicPlayerTrack_gap, 48 - .equiv o_MusicPlayerTrack_unk_3A, 58 - .equiv o_MusicPlayerTrack_unk_3C, 60 - .equiv o_MusicPlayerTrack_cmdPtr, 64 - .equiv o_MusicPlayerTrack_patternStack, 68 - .equiv MusicPlayerTrack_size, 80 + struct_begin + struct_field o_SoundChannel_status, 1 + struct_field o_SoundChannel_type, 1 + struct_field o_SoundChannel_rightVolume, 1 + struct_field o_SoundChannel_leftVolume, 1 + struct_field o_SoundChannel_attack, 1 + struct_field o_SoundChannel_decay, 1 + struct_field o_SoundChannel_sustain, 1 + struct_field o_SoundChannel_release, 1 + struct_field o_SoundChannel_ky, 1 + struct_field o_SoundChannel_ev, 1 + struct_field o_SoundChannel_er, 1 + struct_field o_SoundChannel_el, 1 + struct_field o_SoundChannel_iev, 1 + struct_field o_SoundChannel_iel, 1 + struct_field o_SoundChannel_d1, 1 + struct_field o_SoundChannel_d2, 1 + struct_field o_SoundChannel_gt, 1 + struct_field o_SoundChannel_mk, 1 + struct_field o_SoundChannel_ve, 1 + struct_field o_SoundChannel_pr, 1 + struct_field o_SoundChannel_rp, 1 + struct_field o_SoundChannel_d3, 3 + struct_field o_SoundChannel_ct, 4 + struct_field o_SoundChannel_fw, 4 + struct_field o_SoundChannel_freq, 4 + struct_field o_SoundChannel_wav, 4 + struct_field o_SoundChannel_cp, 4 + struct_field o_SoundChannel_track, 4 + struct_field o_SoundChannel_pp, 4 + struct_field o_SoundChannel_np, 4 + struct_field o_SoundChannel_d4, 4 + struct_field o_SoundChannel_xpi, 2 + struct_field o_SoundChannel_xpc, 2 + struct_field SoundChannel_size, 0 + + struct_begin + struct_field o_MusicPlayerTrack_flags, 1 + struct_field o_MusicPlayerTrack_wait, 1 + struct_field o_MusicPlayerTrack_patternLevel, 1 + struct_field o_MusicPlayerTrack_repN, 1 + struct_field o_MusicPlayerTrack_gateTime, 1 + struct_field o_MusicPlayerTrack_key, 1 + struct_field o_MusicPlayerTrack_velocity, 1 + struct_field o_MusicPlayerTrack_runningStatus, 1 + struct_field o_MusicPlayerTrack_keyM, 1 + struct_field o_MusicPlayerTrack_pitM, 1 + struct_field o_MusicPlayerTrack_keyShift, 1 + struct_field o_MusicPlayerTrack_keyShiftX, 1 + struct_field o_MusicPlayerTrack_tune, 1 + struct_field o_MusicPlayerTrack_pitX, 1 + struct_field o_MusicPlayerTrack_bend, 1 + struct_field o_MusicPlayerTrack_bendRange, 1 + struct_field o_MusicPlayerTrack_volMR, 1 + struct_field o_MusicPlayerTrack_volML, 1 + struct_field o_MusicPlayerTrack_vol, 1 + struct_field o_MusicPlayerTrack_volX, 1 + struct_field o_MusicPlayerTrack_pan, 1 + struct_field o_MusicPlayerTrack_panX, 1 + struct_field o_MusicPlayerTrack_modM, 1 + struct_field o_MusicPlayerTrack_mod, 1 + struct_field o_MusicPlayerTrack_modT, 1 + struct_field o_MusicPlayerTrack_lfoSpeed, 1 + struct_field o_MusicPlayerTrack_lfoSpeedC, 1 + struct_field o_MusicPlayerTrack_lfoDelay, 1 + struct_field o_MusicPlayerTrack_lfoDelayC, 1 + struct_field o_MusicPlayerTrack_priority, 1 + struct_field o_MusicPlayerTrack_echoVolume, 1 + struct_field o_MusicPlayerTrack_echoLength, 1 + struct_field o_MusicPlayerTrack_chan, 4 + struct_field o_MusicPlayerTrack_ToneData_type, 1 + struct_field o_MusicPlayerTrack_ToneData_key, 1 + struct_field o_MusicPlayerTrack_ToneData_length, 1 + struct_field o_MusicPlayerTrack_ToneData_pan_sweep, 1 + struct_field o_MusicPlayerTrack_ToneData_wav, 4 + struct_field o_MusicPlayerTrack_ToneData_attack, 1 + struct_field o_MusicPlayerTrack_ToneData_decay, 1 + struct_field o_MusicPlayerTrack_ToneData_sustain, 1 + struct_field o_MusicPlayerTrack_ToneData_release, 1 + struct_field o_MusicPlayerTrack_gap, 10 + struct_field o_MusicPlayerTrack_unk_3A, 2 + struct_field o_MusicPlayerTrack_unk_3C, 4 + struct_field o_MusicPlayerTrack_cmdPtr, 4 + struct_field o_MusicPlayerTrack_patternStack, 12 + struct_field MusicPlayerTrack_size, 0 .equiv o_MusicPlayerTrack_ToneData_keySplitTable, o_MusicPlayerTrack_ToneData_attack - .equiv o_MusicPlayerInfo_songHeader, 0 - .equiv o_MusicPlayerInfo_status, 4 - .equiv o_MusicPlayerInfo_trackCount, 8 - .equiv o_MusicPlayerInfo_priority, 9 - .equiv o_MusicPlayerInfo_cmd, 10 - .equiv o_MusicPlayerInfo_unk_B, 11 - .equiv o_MusicPlayerInfo_clock, 12 - .equiv o_MusicPlayerInfo_memAccArea, 16 - .equiv o_MusicPlayerInfo_tempoD, 28 - .equiv o_MusicPlayerInfo_tempoU, 30 - .equiv o_MusicPlayerInfo_tempoI, 32 - .equiv o_MusicPlayerInfo_tempoC, 34 - .equiv o_MusicPlayerInfo_fadeOI, 36 - .equiv o_MusicPlayerInfo_fadeOC, 38 - .equiv o_MusicPlayerInfo_fadeOV, 40 - .equiv o_MusicPlayerInfo_padding, 42 - .equiv o_MusicPlayerInfo_tracks, 44 - .equiv o_MusicPlayerInfo_tone, 48 - .equiv o_MusicPlayerInfo_ident, 52 - .equiv o_MusicPlayerInfo_func, 56 - .equiv o_MusicPlayerInfo_intp, 60 - .equiv MusicPlayerInfo_size, 64 + struct_begin + struct_field o_MusicPlayerInfo_songHeader, 4 + struct_field o_MusicPlayerInfo_status, 4 + struct_field o_MusicPlayerInfo_trackCount, 1 + struct_field o_MusicPlayerInfo_priority, 1 + struct_field o_MusicPlayerInfo_cmd, 1 + struct_field o_MusicPlayerInfo_unk_B, 1 + struct_field o_MusicPlayerInfo_clock, 4 + struct_field o_MusicPlayerInfo_gap, 8 + struct_field o_MusicPlayerInfo_memAccArea, 4 + struct_field o_MusicPlayerInfo_tempoD, 2 + struct_field o_MusicPlayerInfo_tempoU, 2 + struct_field o_MusicPlayerInfo_tempoI, 2 + struct_field o_MusicPlayerInfo_tempoC, 2 + struct_field o_MusicPlayerInfo_fadeOI, 2 + struct_field o_MusicPlayerInfo_fadeOC, 2 + struct_field o_MusicPlayerInfo_fadeOV, 2 + struct_field o_MusicPlayerInfo_padding, 2 + struct_field o_MusicPlayerInfo_tracks, 4 + struct_field o_MusicPlayerInfo_tone, 4 + struct_field o_MusicPlayerInfo_ident, 4 + struct_field o_MusicPlayerInfo_func, 4 + struct_field o_MusicPlayerInfo_intp, 4 + struct_field MusicPlayerInfo_size, 0 - .equiv o_CgbChannel_sf, 0 - .equiv o_CgbChannel_ty, 1 - .equiv o_CgbChannel_rightVolume, 2 - .equiv o_CgbChannel_leftVolume, 3 - .equiv o_CgbChannel_at, 4 - .equiv o_CgbChannel_de, 5 - .equiv o_CgbChannel_su, 6 - .equiv o_CgbChannel_re, 7 - .equiv o_CgbChannel_ky, 8 - .equiv o_CgbChannel_ev, 9 - .equiv o_CgbChannel_eg, 10 - .equiv o_CgbChannel_ec, 11 - .equiv o_CgbChannel_echoVolume, 12 - .equiv o_CgbChannel_echoLength, 13 - .equiv o_CgbChannel_d1, 14 - .equiv o_CgbChannel_d2, 15 - .equiv o_CgbChannel_gt, 16 - .equiv o_CgbChannel_mk, 17 - .equiv o_CgbChannel_ve, 18 - .equiv o_CgbChannel_pr, 19 - .equiv o_CgbChannel_d3, 20 - .equiv o_CgbChannel_d5, 24 - .equiv o_CgbChannel_sg, 25 - .equiv o_CgbChannel_n4, 26 - .equiv o_CgbChannel_pan, 27 - .equiv o_CgbChannel_panMask, 28 - .equiv o_CgbChannel_mo, 29 - .equiv o_CgbChannel_le, 30 - .equiv o_CgbChannel_sw, 31 - .equiv o_CgbChannel_fr, 32 - .equiv o_CgbChannel_wp, 36 - .equiv o_CgbChannel_cp, 40 - .equiv o_CgbChannel_tp, 44 - .equiv o_CgbChannel_pp, 48 - .equiv o_CgbChannel_np, 52 - .equiv o_CgbChannel_d4, 56 - .equiv CgbChannel_size, 64 + struct_begin + struct_field o_CgbChannel_sf, 1 + struct_field o_CgbChannel_ty, 1 + struct_field o_CgbChannel_rightVolume, 1 + struct_field o_CgbChannel_leftVolume, 1 + struct_field o_CgbChannel_at, 1 + struct_field o_CgbChannel_de, 1 + struct_field o_CgbChannel_su, 1 + struct_field o_CgbChannel_re, 1 + struct_field o_CgbChannel_ky, 1 + struct_field o_CgbChannel_ev, 1 + struct_field o_CgbChannel_eg, 1 + struct_field o_CgbChannel_ec, 1 + struct_field o_CgbChannel_echoVolume, 1 + struct_field o_CgbChannel_echoLength, 1 + struct_field o_CgbChannel_d1, 1 + struct_field o_CgbChannel_d2, 1 + struct_field o_CgbChannel_gt, 1 + struct_field o_CgbChannel_mk, 1 + struct_field o_CgbChannel_ve, 1 + struct_field o_CgbChannel_pr, 1 + struct_field o_CgbChannel_rp, 1 + struct_field o_CgbChannel_d3, 3 + struct_field o_CgbChannel_d5, 1 + struct_field o_CgbChannel_sg, 1 + struct_field o_CgbChannel_n4, 1 + struct_field o_CgbChannel_pan, 1 + struct_field o_CgbChannel_panMask, 1 + struct_field o_CgbChannel_mo, 1 + struct_field o_CgbChannel_le, 1 + struct_field o_CgbChannel_sw, 1 + struct_field o_CgbChannel_fr, 4 + struct_field o_CgbChannel_wp, 4 + struct_field o_CgbChannel_cp, 4 + struct_field o_CgbChannel_tp, 4 + struct_field o_CgbChannel_pp, 4 + struct_field o_CgbChannel_np, 4 + struct_field o_CgbChannel_d4, 8 + struct_field CgbChannel_size, 0 diff --git a/include/gba/m4a_internal.h b/include/gba/m4a_internal.h index 58b258a1a..bdff1b865 100644 --- a/include/gba/m4a_internal.h +++ b/include/gba/m4a_internal.h @@ -140,9 +140,9 @@ struct SoundChannel struct WaveData *wav; u32 cp; struct MusicPlayerTrack *track; - void* pp; - void* np; - void* d4; + void *pp; + void *np; + void *d4; u16 xpi; u16 xpc; }; diff --git a/libagbsyscall/libagbsyscall.s b/libagbsyscall/libagbsyscall.s index b30b586ee..0c90da9ed 100644 --- a/libagbsyscall/libagbsyscall.s +++ b/libagbsyscall/libagbsyscall.s @@ -6,7 +6,7 @@ .text .set SOFT_RESET_DIRECT_BUF, 0x03007FFA - .set USER_STACK, 0x03007F00 + .set USER_STACK, 0x03007F00 .set RESET_EX_WRAM_FLAG, 0x1 .ifdef NO_GRANULAR_AGBSYSCALL diff --git a/src/AgbRfu_LinkManager.c b/src/AgbRfu_LinkManager.c index 6fc8dc89a..42cc9aea3 100644 --- a/src/AgbRfu_LinkManager.c +++ b/src/AgbRfu_LinkManager.c @@ -352,7 +352,7 @@ static bool8 rfu_LMAN_linkWatcher(u16 REQ_commandID) { for (i = 0; i < RFU_CHILD_MAX; i++) { - if ((bm_linkLossSlot) & (1 << i)) + if (bm_linkLossSlot & (1 << i)) { lman.linkRecoveryTimer.active |= (1 << i); lman.linkRecoveryTimer.count[i] = lman.linkRecoveryTimer.count_max; diff --git a/src/m4a.c b/src/m4a.c index 66f563bd4..f9a9bf1cc 100644 --- a/src/m4a.c +++ b/src/m4a.c @@ -431,8 +431,6 @@ void m4aSoundMode(u32 mode) soundInfo->maxChans = temp >> SOUND_MODE_MAXCHN_SHIFT; - temp = MAX_DIRECTSOUND_CHANNELS; - for (temp = MAX_DIRECTSOUND_CHANNELS, chan = soundInfo->chans; temp != 0; temp--,chan++) { chan->status = 0;