From d3dd6abf8787df5a9eb2104f7d556065cadfcbd2 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:19:15 +0100 Subject: [PATCH] expansion changes to m4a and crt0 --- ld_script_modern.ld | 2 +- ld_script_test.ld | 22 +++++++++++++--------- src/crt0.s | 8 ++++---- src/daycare.c | 2 +- src/m4a.c | 4 ---- src/m4a_1.s | 10 ++++++---- src/main.c | 5 +---- 7 files changed, 26 insertions(+), 27 deletions(-) diff --git a/ld_script_modern.ld b/ld_script_modern.ld index 99b9c5877..095b142ad 100644 --- a/ld_script_modern.ld +++ b/ld_script_modern.ld @@ -67,7 +67,7 @@ SECTIONS { asm/*.o(.text*); } > ROM =0 - script_data (READONLY): + script_data : ALIGN(4) { data/*.o(script_data); diff --git a/ld_script_test.ld b/ld_script_test.ld index 10b919d04..981965d22 100644 --- a/ld_script_test.ld +++ b/ld_script_test.ld @@ -38,7 +38,7 @@ SECTIONS { __iwram_end = .; } > IWRAM - .iwram.sbss (NOLOAD) : + .iwram.bss (NOLOAD) : ALIGN(4) { src/*.o(.bss); @@ -55,13 +55,17 @@ SECTIONS { data/*.o(COMMON); test/*.o(COMMON); *libc.a:sbrkr.o(COMMON); - . = ALIGN(4); + } > IWRAM - /* .persistent starts at 0x3007F00 */ - /* WARNING: This is the end of the IRQ stack, if there's too - * much data it WILL be overwritten. */ - . = 0x7F00; - test/*.o(.persistent); + /* .persistent starts at 0x3007F00 */ + /* WARNING: This is the end of the IRQ stack, if there's too + * much data it WILL be overwritten. */ + + . = 0x03007F00; + .iwram.persistent (NOLOAD) : + ALIGN(4) + { + test/*.o(.persistent); } > IWRAM /* BEGIN ROM DATA */ @@ -78,7 +82,7 @@ SECTIONS { script_data : ALIGN(4) { - data/*.o(script_data); + data/*.o(script_data); } > ROM =0 lib_text : @@ -113,7 +117,7 @@ SECTIONS { } > ROM =0 .data.iwram : - ALIGN(4) + ALIGN(8) { __iwram_lma = .; . = . + (__iwram_end - __iwram_start); diff --git a/src/crt0.s b/src/crt0.s index af6ea0bc9..dea501da3 100644 --- a/src/crt0.s +++ b/src/crt0.s @@ -14,15 +14,15 @@ Init:: mov r0, #PSR_SYS_MODE msr cpsr_cf, r0 ldr sp, sp_sys -@ Prepare for interrupt handling - ldr r1, =INTR_VECTOR - adr r0, IntrMain - str r0, [r1] @ Dispatch memory reset request to hardware mov r0, #255 @ RESET_ALL svc #1 << 16 @ Fill RAM areas with appropriate data bl InitializeWorkingMemory +@ Prepare for interrupt handling + ldr r1, =INTR_VECTOR + adr r0, IntrMain + str r0, [r1] @ Jump to AgbMain ldr r1, =AgbMain + 1 mov lr, pc diff --git a/src/daycare.c b/src/daycare.c index d8dc58cee..376725760 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -1303,7 +1303,7 @@ static void _GiveEggFromDaycare(struct DayCare *daycare) { struct Pokemon egg; u16 species; - u8 parentSlots[DAYCARE_MON_COUNT]; + u8 parentSlots[DAYCARE_MON_COUNT] = {0}; bool8 isEgg; species = DetermineEggSpeciesAndParentSlots(daycare, parentSlots); diff --git a/src/m4a.c b/src/m4a.c index 3417d97bc..9e6c1ca3c 100644 --- a/src/m4a.c +++ b/src/m4a.c @@ -5,8 +5,6 @@ extern const u8 gCgb3Vol[]; #define BSS_CODE __attribute__((section(".bss.code"))) -BSS_CODE ALIGNED(4) char SoundMainRAM_Buffer[0x800] = {0}; - struct SoundInfo gSoundInfo; struct PokemonCrySong gPokemonCrySongs[MAX_POKEMON_CRIES]; struct MusicPlayerInfo gPokemonCryMusicPlayers[MAX_POKEMON_CRIES]; @@ -71,8 +69,6 @@ void m4aSoundInit(void) { s32 i; - CpuCopy32((void *)((s32)SoundMainRAM & ~1), SoundMainRAM_Buffer, sizeof(SoundMainRAM_Buffer)); - SoundInit(&gSoundInfo); MPlayExtender(gCgbChans); m4aSoundMode(SOUND_MODE_DA_BIT_8 diff --git a/src/m4a_1.s b/src/m4a_1.s index 4cbbf0812..afe009c6e 100644 --- a/src/m4a_1.s +++ b/src/m4a_1.s @@ -52,11 +52,11 @@ SoundMain_3: cmp r3, 0 beq SoundMain_4 ldr r0, [r0, o_SoundInfo_musicPlayerHead] - bl _081DD25E + bl call_r3 ldr r0, [sp, 0x18] SoundMain_4: ldr r3, [r0, o_SoundInfo_CgbSound] - bl _081DD25E + bl call_r3 ldr r0, [sp, 0x18] ldr r3, [r0, o_SoundInfo_pcmSamplesPerVBlank] mov r8, r3 @@ -73,18 +73,19 @@ SoundMain_4: SoundMain_5: str r5, [sp, 0x8] ldr r6, lt_PCM_DMA_BUF_SIZE - ldr r3, lt_SoundMainRAM_Buffer + ldr r3, lt_SoundMainRAM bx r3 .align 2, 0 lt_SOUND_INFO_PTR: .word SOUND_INFO_PTR lt_ID_NUMBER: .word ID_NUMBER -lt_SoundMainRAM_Buffer: .word SoundMainRAM_Buffer + 1 +lt_SoundMainRAM: .word SoundMainRAM + 1 lt_REG_VCOUNT: .word REG_VCOUNT lt_o_SoundInfo_pcmBuffer: .word o_SoundInfo_pcmBuffer lt_PCM_DMA_BUF_SIZE: .word PCM_DMA_BUF_SIZE thumb_func_end SoundMain + .section .iwram.code thumb_func_start SoundMainRAM SoundMainRAM: ldrb r3, [r0, o_SoundInfo_reverb] @@ -708,6 +709,7 @@ _081DD594: .pool arm_func_end SoundMainRAM_Unk2 + .text thumb_func_start SoundMainBTM SoundMainBTM: mov r12, r4 diff --git a/src/main.c b/src/main.c index 97bd41da1..aa053f451 100644 --- a/src/main.c +++ b/src/main.c @@ -67,7 +67,6 @@ u16 gKeyRepeatContinueDelay; u8 gSoftResetDisabled; IntrFunc gIntrTable[INTR_COUNT]; bool8 gLinkVSyncDisabled; -u32 IntrMain_Buffer[0x200]; u8 gPcmDmaCounter; void *gAgbMainLoop_sp; @@ -309,9 +308,7 @@ void InitIntrHandlers(void) for (i = 0; i < INTR_COUNT; i++) gIntrTable[i] = gIntrTableTemplate[i]; - DmaCopy32(3, IntrMain, IntrMain_Buffer, sizeof(IntrMain_Buffer)); - - INTR_VECTOR = IntrMain_Buffer; + INTR_VECTOR = IntrMain; SetVBlankCallback(NULL); SetHBlankCallback(NULL);