start iwram init

This commit is contained in:
DizzyEggg
2024-12-18 11:28:07 +01:00
parent aa8b3cd44a
commit 0c53d4011f
20 changed files with 83 additions and 55 deletions

View File

@@ -261,11 +261,17 @@ $(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
$(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
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

@@ -3,9 +3,6 @@
.syntax unified
.section .rodata
.space 0x3C
.text

View File

@@ -7,9 +7,11 @@
#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")))
#define IWRAM_INIT __attribute__((section("iwram_init")))
#define UNUSED __attribute__((unused))
#define NAKED __attribute__((naked))

View File

@@ -37,7 +37,6 @@ SECTIONS {
{
iwram_start = .;
INCLUDE "sym_iwram.ld"
. = 0x8000;
} > IWRAM
/* BEGIN ROM DATA */
@@ -342,10 +341,14 @@ SECTIONS {
src/ground_sprite.o(.text);
asm/ground_sprite.o(.text);
src/code_80A7714.o(.text);
src/ground_lives.o(.text);
asm/ground_lives.o(.text);
src/ground_object.o(.text);
asm/ground_object.o(.text);
src/ground_effect.o(.text);
asm/ground_effect.o(.text);
src/ground_link.o(.text);
src/ground_event.o(.text);
asm/ground_event.o(.text);
src/m4a_1.o(.text);
src/m4a.o(.text);
@@ -741,15 +744,26 @@ SECTIONS {
EWRAM_INIT_ROM_START = LOADADDR(ewram_init);
iwram_init :
ALIGN(4)
{
INCLUDE "sym_iwram_init.ld"
} > IWRAM AT>ROM
unk_code = LOADADDR(iwram_init);
unk_code_section :
ALIGN(4)
{
unk_code = .;
asm/code_8272724.o(.rodata);
src/code_8272724.o(.text);
asm/code_8272724.o(.text);
unk_code_end = .;
} > ROM =0
iwram_data_2 (NOLOAD) :
ALIGN(4)
{
INCLUDE "sym_iwram_2.ld"
} > IWRAM
unk_code_section_size = (unk_code_end - unk_code);
unk_code_ram_end = unk_code_ram + unk_code_section_size;

View File

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

4
src/code_80035F0.c Normal file
View File

@@ -0,0 +1,4 @@
#include "global.h"
IWRAM_INIT u16 gUnknown_3001B58 = 0;
IWRAM_INIT u16 gUnknown_3001B5A = 0;

View File

@@ -21,7 +21,7 @@ EWRAM_INIT s32 gUnknown_203B2A4 = 1;
EWRAM_INIT u16 gUnknown_203B2A8 = 0;
EWRAM_INIT u16 gUnknown_203B2AA = 0;
static IWRAM_DATA unkStruct_3001B5C *gUnknown_3001B5C = {NULL};
static IWRAM_INIT unkStruct_3001B5C *gUnknown_3001B5C = {NULL};
#include "data/code_8023144.h"

View File

@@ -7,7 +7,7 @@
#include "text_util.h"
//static // MAKE STATIC WHEN code_8023868.s IS DONE
IWRAM_DATA struct unkStruct_3001B60 *gUnknown_3001B60 = {0};
IWRAM_INIT struct unkStruct_3001B60 *gUnknown_3001B60 = {NULL};
#include "data/code_8023868.h"

View File

@@ -4,7 +4,7 @@
#include "string_format.h"
#include "structs/str_3001B64.h"
IWRAM_DATA struct unkStruct_3001B64 *gUnknown_3001B64 = {0};
IWRAM_INIT struct unkStruct_3001B64 *gUnknown_3001B64 = {NULL};
extern u16 gUnknown_20399DC;
extern u16 gUnknown_20399DE;

View File

@@ -24,7 +24,7 @@ struct unkStruct_3001B68
u8 unk20;
};
IWRAM_DATA struct unkStruct_3001B68 *gUnknown_3001B68 = {0};
IWRAM_INIT struct unkStruct_3001B68 *gUnknown_3001B68 = {NULL};
struct unkStruct_20399E0

3
src/ground_effect.c Normal file
View File

@@ -0,0 +1,3 @@
#include "global.h"
IWRAM_INIT void *gGroundEffects = NULL;

3
src/ground_event.c Normal file
View File

@@ -0,0 +1,3 @@
#include "global.h"
IWRAM_INIT void *gGroundEvents = NULL;

4
src/ground_lives.c Normal file
View File

@@ -0,0 +1,4 @@
#include "global.h"
IWRAM_INIT void *gGroundLivesMeta = NULL;
IWRAM_INIT void *gGroundLives = NULL;

View File

@@ -7,8 +7,8 @@
#include "ground_script.h"
#include "memory.h"
IWRAM_DATA GroundMapAction *gGroundMapAction = {0};
IWRAM_DATA unkStruct_3001B70 *gGroundMapDungeon_3001B70 = {0};
IWRAM_INIT GroundMapAction *gGroundMapAction = {NULL};
IWRAM_INIT unkStruct_3001B70 *gGroundMapDungeon_3001B70 = {NULL};
extern GroundMapAction *gGroundMapAction;

View File

@@ -7,8 +7,8 @@
extern u16 gUnknown_2026E4E;
IWRAM_DATA unkStruct_3001B74 *gUnknown_3001B74 = {0};
IWRAM_DATA unkStruct_3001B70 *gUnknown_3001B78 = {0};
IWRAM_INIT unkStruct_3001B74 *gUnknown_3001B74 = {NULL};
IWRAM_INIT unkStruct_3001B70 *gUnknown_3001B78 = {NULL};
extern const u8 gUnknown_8117784[];
extern const s16 gUnknown_811E5F4[][2];

3
src/ground_object.c Normal file
View File

@@ -0,0 +1,3 @@
#include "global.h"
IWRAM_INIT void *gGroundObjects = NULL;

View File

@@ -9,7 +9,7 @@
#include "memory.h"
#include "sprite.h"
IWRAM_DATA unkStruct_3001B7C *gUnknown_3001B7C = {0};
IWRAM_INIT unkStruct_3001B7C *gUnknown_3001B7C = {NULL};
EWRAM_DATA unkStruct_2039DB0 gUnknown_2039DB0 = {0};
EWRAM_DATA u32 sUnknown_2039DBC = {0}; // Unused, for alignment

View File

@@ -17,44 +17,6 @@ gUnknown_3001018: /* 3001018 */
.include "src/code_8094D28.o"
iwramClearEnd:
unk_code_ram: /* 3001B58 */
gUnknown_3001B58: /* 3001B58 */
.space 0x2
gUnknown_3001B5A: /* 3001B5A */
.space 0x2
.include "src/code_8023144.o"
.include "src/code_8023868.o"
.include "src/code_809A560.o"
.include "src/code_809C5C4.o"
.include "src/ground_map.o"
.include "src/ground_map_2.o"
.include "src/ground_sprite.o"
gGroundLivesMeta: /* 3001B80 */
.space 0x4
gGroundLives: /* 3001B84 */
.space 0x4
gGroundObjects: /* 3001B88 */
.space 0x4
gGroundEffects: /* 3001B8C */
.space 0x4
gGroundEvents: /* 3001B90 */
.space 0x4
gUnkIwramFunc1Buffer: /* 3001B94 */
.space 0x110
gUnkIwramFunc2Buffer: /* 3001CA4 */
.space 0x134
gUnkIwramFunc3Buffer: /* 3001DD8 */
.space 0xD4
gUnkIwramFunc4Buffer: /* 3001EAC */
.space 0x2154
.include "src/code_80001DC.o"

14
sym_iwram_2.txt Normal file
View File

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

16
sym_iwram_init.txt Normal file
View File

@@ -0,0 +1,16 @@
.align 2
unk_code_ram: /* 3001B58 */
.include "src/code_80035F0.o"
.include "src/code_8023144.o"
.include "src/code_8023868.o"
.include "src/code_809A560.o"
.include "src/code_809C5C4.o"
.include "src/ground_map.o"
.include "src/ground_map_2.o"
.include "src/ground_sprite.o"
.include "src/ground_lives.o"
.include "src/ground_object.o"
.include "src/ground_effect.o"
.include "src/ground_event.o"