summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile9
-rw-r--r--asm/main.s4
-rw-r--r--asm/rom_header.s6
-rw-r--r--ld_script.txt40
-rw-r--r--main.c7
5 files changed, 39 insertions, 27 deletions
diff --git a/Makefile b/Makefile
index 738cc646..cb5149ba 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ MWCCVERSION := 2.0/base
CROSS := arm-linux-gnueabi-
-MWCCARM := tools/mwccarm/2.0/base/mwccarm.exe
+MWCCARM := tools/mwccarm/$(MWCCVERSION)/mwccarm.exe
AS := $(CROSS)as
CC := $(MWCCARM)
@@ -65,8 +65,11 @@ $(BUILD_DIR)/%.o: %.c
$(BUILD_DIR)/%.o: %.s
$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<
-$(ELF): $(O_FILES) $(LD_SCRIPT) undefined_syms.txt
- $(LD) -T undefined_syms.txt -T $(LD_SCRIPT) -o $(ELF)
+$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT)
+ $(CPP) $(VERSION_CFLAGS) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $<
+
+$(ELF): $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt
+ $(LD) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -o $(ELF) -Map $(BUILD_DIR)/$(TARGET).map
$(ROM): $(ELF)
$(OBJCOPY) -O binary $< $@
diff --git a/asm/main.s b/asm/main.s
index 80f388cd..e069ed79 100644
--- a/asm/main.s
+++ b/asm/main.s
@@ -2,8 +2,8 @@
.text
- arm_func_start Main
-Main: @ 0x02000800
+ arm_func_start Entry
+Entry: @ 0x02000800
mov ip, #0x4000000
str ip, [ip, #0x208]
_02000808:
diff --git a/asm/rom_header.s b/asm/rom_header.s
index e850d0f8..a8583e2b 100644
--- a/asm/rom_header.s
+++ b/asm/rom_header.s
@@ -29,11 +29,11 @@ RomVersion:
.space 1
ARM9ROMOffset:
-.word 0x00004000
+.word _rom_codeSegmentRomStart
ARM9EntryAddress:
-.word 0x02000800
+.word Entry
ARM9RAMAddress:
-.word 0x02000000
+.word _rom_codeSegmentStart
ARM9CodeSize:
.word 0x00107724
ARM7ROMOffset:
diff --git a/ld_script.txt b/ld_script.txt
index e904d75e..ec6e4c0c 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -1,16 +1,32 @@
+/* Linker Script to build Pokemon Diamond */
+
+#define BEGIN_SEG(name, addr) \
+ _##name##SegmentStart = ADDR(.name); \
+ _##name##SegmentRomStart = __romPos; \
+ .name addr : AT(__romPos)
+
+#define END_SEG(name) \
+ _##name##SegmentEnd = ADDR(.name) + SIZEOF(.name); \
+ _##name##SegmentRomEnd = __romPos + SIZEOF(.name); \
+ __romPos += SIZEOF(.name);
+
SECTIONS {
- header :
- {
- build/asm/rom_header.o(.text);
- }
+ __romPos = 0;
+ BEGIN_SEG(header, 0x0)
+ {
+ build/asm/rom_header.o(.text);
+ }
+ END_SEG(header)
- . = 0x4000;
- rom_code :
- {
+ __romPos += 0x3E00;
+
+ BEGIN_SEG(rom_code, 0x2000000)
+ {
build/asm/secure.o(.text);
- build/asm/main.o(.text);
- build/asm/rom.o(.text);
- build/src/sub_02000DF4.o(.text);
- build/asm/rom2.o(.text);
- }
+ build/asm/main.o(.text);
+ build/asm/rom.o(.text);
+ build/src/sub_02000DF4.o(.text);
+ build/asm/rom2.o(.text);
+ }
+ END_SEG(rom_code)
}
diff --git a/main.c b/main.c
deleted file mode 100644
index 17e69b3d..00000000
--- a/main.c
+++ /dev/null
@@ -1,7 +0,0 @@
-// Just includes for now so CLion sees the files
-#include "structs/structs.h"
-#include "nitro/nitro.h"
-
-void main() {
- int x = NULL;
-}