iwram init done

This commit is contained in:
DizzyEggg 2024-12-18 12:09:22 +01:00
parent 0c53d4011f
commit bdae856769
10 changed files with 35 additions and 58 deletions

View File

@ -261,17 +261,14 @@ $(BUILD_DIR)/sym_ewram.ld: sym_ewram.txt
$(BUILD_DIR)/sym_iwram.ld: sym_iwram.txt
$(RAMSCRGEN) iwram_data $< ENGLISH > $@
$(BUILD_DIR)/sym_iwram_2.ld: sym_iwram_2.txt
$(RAMSCRGEN) iwram_data_2 $< ENGLISH > $@
$(BUILD_DIR)/sym_ewram_init.ld: sym_ewram_init.txt
$(RAMSCRGEN) ewram_init $< ENGLISH > $@
$(BUILD_DIR)/sym_iwram_init.ld: sym_iwram_init.txt
$(RAMSCRGEN) iwram_init $< ENGLISH > $@
$(LD_SCRIPT): ld_script.txt $(BUILD_DIR)/sym_ewram.ld $(BUILD_DIR)/sym_ewram_init.ld $(BUILD_DIR)/sym_iwram.ld $(BUILD_DIR)/sym_iwram_2.ld $(BUILD_DIR)/sym_iwram_init.ld
$(LD_SCRIPT): ld_script.txt $(BUILD_DIR)/sym_ewram.ld $(BUILD_DIR)/sym_ewram_init.ld $(BUILD_DIR)/sym_iwram.ld $(BUILD_DIR)/sym_iwram_init.ld
cd $(BUILD_DIR) && sed -e "s#tools/#../../tools/#g" ../../ld_script.txt >ld_script.ld
$(ELF): $(LD_SCRIPT) $(ALL_OBJECTS) $(LIBC) libagbsyscall tools

View File

@ -142,6 +142,7 @@ _08272860:
pop {r0}
bx r0
thumb_func_end sub_8272774
thumb_func_start sub_8272870
sub_8272870:
@ -311,6 +312,7 @@ _08272994:
pop {r0}
bx r0
thumb_func_end sub_8272884
thumb_func_start sub_82729A4
sub_82729A4:
@ -426,7 +428,7 @@ _08272A5A:
pop {r0}
bx r0
thumb_func_end sub_82729B8
thumb_func_start sub_8272A78
sub_8272A78:
push {lr}

View File

@ -7,7 +7,6 @@
#define FALSE 0
#define IWRAM_DATA __attribute__((section("iwram_data")))
#define IWRAM_DATA_2 __attribute__((section("iwram_data_2")))
#define EWRAM_DATA __attribute__((section("ewram_data")))
#define EWRAM_LIB __attribute__((section("ewram_lib"))) // Used only for agb flash and m4a
#define EWRAM_INIT __attribute__((section("ewram_init")))

View File

@ -37,6 +37,7 @@ SECTIONS {
{
iwram_start = .;
INCLUDE "sym_iwram.ld"
iwram_end = .;
} > IWRAM
/* BEGIN ROM DATA */
@ -747,28 +748,25 @@ SECTIONS {
iwram_init :
ALIGN(4)
{
iwram_init_start = .;
INCLUDE "sym_iwram_init.ld"
src/code_8272724.o(.text);
asm/code_8272724.o(.text);
iwram_init_end = .;
} > IWRAM AT>ROM
unk_code = LOADADDR(iwram_init);
unk_code_section :
ALIGN(4)
{
src/code_8272724.o(.text);
asm/code_8272724.o(.text);
unk_code_end = .;
} > ROM =0
IWRAM_INIT_ROM_START = LOADADDR(iwram_init);
iwram_data_2 (NOLOAD) :
iwram_lib (NOLOAD) :
ALIGN(4)
{
INCLUDE "sym_iwram_2.ld"
end = .; /* This is needed for the libc.a function _sbrk */
. = 0x2090;
gUnknown_3004000 = .; /* Used by sub_80001E0 */
} > IWRAM
unk_code_section_size = (unk_code_end - unk_code);
unk_code_ram_end = unk_code_ram + unk_code_section_size;
end = unk_code_ram_end;
unk_data 0x8300000 :
ALIGN(4)
{

View File

@ -1,6 +1,6 @@
#include "global.h"
IWRAM_DATA_2 u32 gUnknown_3004000 = {0};
extern u32 gUnknown_3004000;
// unused, returns stack pointer
u32 sub_80001DC() {

View File

@ -22,12 +22,12 @@ extern u8 ewram_end[]; // Force a second storage in the asm
extern u8 ewram_init_start[];
extern u8 ewram_init_end[];
extern u8 iwram_start[];
extern u8 iwramClearEnd[];
extern u8 unk_code[];
extern u8 unk_code_ram[];
extern u8 unk_code_ram_end[];
extern u8 iwram_end[];
extern u8 iwram_init_start[];
extern u8 iwram_init_end[];
extern const u8 EWRAM_INIT_ROM_START[];
extern const u8 IWRAM_INIT_ROM_START[];
UNUSED static const char sStringRomUserData[] = "PKD ROM USER DATA 000000";
@ -56,12 +56,12 @@ void AgbMain(void)
CpuSet(&value, ewram_start, CPU_SET_SRC_FIXED | CPU_SET_32BIT | (((ewram_end - ewram_start) / 4) & 0x1FFFFF));
}
if (unk_code_ram_end - unk_code_ram > 0)
CpuCopy32(unk_code, unk_code_ram, unk_code_ram_end - unk_code_ram);
if (iwram_init_end - iwram_init_start > 0)
CpuCopy32(IWRAM_INIT_ROM_START, iwram_init_start, iwram_init_end - iwram_init_start);
if (iwramClearEnd - iwram_start > 0) {
if (iwram_end - iwram_start > 0) {
memset(value, 0, sizeof(value));
CpuSet(&value, iwram_start, CPU_SET_SRC_FIXED | CPU_SET_32BIT | (((iwramClearEnd - iwram_start) / 4) & 0x1FFFFF));
CpuSet(&value, iwram_start, CPU_SET_SRC_FIXED | CPU_SET_32BIT | (((iwram_end - iwram_start) / 4) & 0x1FFFFF));
}
REG_WIN0H = 0;

View File

@ -41,15 +41,16 @@ EWRAM_DATA static u32 sTextShadowMask = 0; // Some text color info is stored; re
EWRAM_DATA static u8 sDrawTextShadow = 0;
EWRAM_DATA ALIGNED(4) u16 gUnknown_202B038[4][32][32] = {0};
extern ALIGNED(4) u8 gUnkIwramFunc1Buffer[];
extern ALIGNED(4) u8 gUnkIwramFunc2Buffer[];
extern ALIGNED(4) u8 gUnkIwramFunc3Buffer[];
extern ALIGNED(4) u8 gUnkIwramFunc4Buffer[];
extern void sub_8272760(s32 a0);
extern void sub_8272870(s32 a0);
extern void sub_82729A4(s32 a0);
extern void sub_8272A78(s32 a0);
// Despite these not being used anywhere in this file, file order and usage point to these variables being declared here
EWRAM_INIT void (*gUnknown_203B080)(s32 a0) = (void *) &gUnkIwramFunc1Buffer[1]; // + 1 because the function is in thumb!
EWRAM_INIT void (*gUnknown_203B084)(s32 a0) = (void *) &gUnkIwramFunc2Buffer[1]; // + 1 because the function is in thumb!
EWRAM_INIT void (*gUnknown_203B088)(s32 a0) = (void *) &gUnkIwramFunc3Buffer[1]; // + 1 because the function is in thumb!
EWRAM_INIT void (*gUnknown_203B08C)(s32 a0) = (void *) &gUnkIwramFunc4Buffer[1]; // + 1 because the function is in thumb!
EWRAM_INIT void (*gUnknown_203B080)(s32 a0) = sub_8272760;
EWRAM_INIT void (*gUnknown_203B084)(s32 a0) = sub_8272870;
EWRAM_INIT void (*gUnknown_203B088)(s32 a0) = sub_82729A4;
EWRAM_INIT void (*gUnknown_203B08C)(s32 a0) = sub_8272A78;
// This variable is only used in InitGraphics function, which could or could not belong to text.c
EWRAM_INIT u8 gUnknown_203B090 = 0;

View File

@ -16,7 +16,3 @@ gUnknown_3001018: /* 3001018 */
.include "src/code_8094D28.o"
iwramClearEnd:

View File

@ -1,14 +0,0 @@
.align 2
gUnkIwramFunc1Buffer: /* 3001B94 */
.space 0x110
gUnkIwramFunc2Buffer: /* 3001CA4 */
.space 0x134
gUnkIwramFunc3Buffer: /* 3001DD8 */
.space 0xD4
gUnkIwramFunc4Buffer: /* 3001EAC */
.space 0x2154
.include "src/code_80001DC.o"

View File

@ -1,7 +1,5 @@
.align 2
unk_code_ram: /* 3001B58 */
.include "src/code_80035F0.o"
.include "src/code_8023144.o"
.include "src/code_8023868.o"