summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--pokegold-spaceworld.link5
-rw-r--r--tools/make_shim.c18
3 files changed, 22 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index bf7cf66..9fd252a 100644
--- a/Makefile
+++ b/Makefile
@@ -59,6 +59,14 @@ clean:
mostlyclean:
rm -rf $(ROM) $(CORRECTEDROM) $(OBJS) $(OBJS:.o=.d) $(ROMS:.gb=.sym) $(ROMS:.gb=.map)
+.PHONY: linkerscript
+linkerscript: $(ROM:.gb=.link)
+
+%.link: %.map
+ $(PYTHON3) tools/map2link.py $< $@
+
+%.map: %.gb;
+
$(CORRECTEDROM): %-correctheader.gb: %.gb
cp $< $@
$(RGBFIX) -f hg -m 0x10 $@
diff --git a/pokegold-spaceworld.link b/pokegold-spaceworld.link
index fb0f24a..a1ff508 100644
--- a/pokegold-spaceworld.link
+++ b/pokegold-spaceworld.link
@@ -249,13 +249,10 @@ ROMX $03
"Shim for Function_cd6f" ; size: $0000
org $4de3
"Shim for Function_cde3" ; size: $0000
- "Shim for Function_cde3_2" ; size: $0000
- "Shim for Function_cde3_3" ; size: $0000
org $4df9
"Shim for Function_cdf9" ; size: $0000
org $4e10
"Shim for Function_ce10" ; size: $0000
- "Shim for Function_ce10_2" ; size: $0000
org $4e3c
"Shim for Function_ce3c" ; size: $0000
org $4e7c
@@ -595,7 +592,6 @@ ROMX $32
"Shim for Function_cb733" ; size: $0000
ROMX $33
"Shim for Function_cc000" ; size: $0000
- "Shim for Function_cc000_2" ; size: $0000
org $4001
"Shim for Function_cc001" ; size: $0000
ROMX $37
@@ -723,7 +719,6 @@ WRAM0
org $cbe5
"CBD2" ; size: $0014
"Shim for wWindowData" ; size: $0000
- "Shim for wWindowStackPointer" ; size: $0000
org $cbf7
"CBF7" ; size: $0001
org $cc02
diff --git a/tools/make_shim.c b/tools/make_shim.c
index 70da31d..fc60821 100644
--- a/tools/make_shim.c
+++ b/tools/make_shim.c
@@ -95,6 +95,8 @@ int main(int argc, char * argv[]) {
}
for (int arg_idx = optind; arg_idx < argc; arg_idx++) {
+ int last = -1;
+ int curr;
eline[0] = 0;
lineno = 0;
fname = argv[arg_idx];
@@ -102,6 +104,7 @@ int main(int argc, char * argv[]) {
if (file == NULL)
RIP("Unable to open file");
while ((lineptr = fgets(line, sizeof(line), file)) != NULL) {
+ // Assume it's already sorted
lineno++;
unsigned short bank = 0;
unsigned short pointer = 0;
@@ -135,6 +138,7 @@ int main(int argc, char * argv[]) {
bank = strtoul(lineptr, &end, 16);
if (bank == 0 && end == lineptr)
RIP("Unable to parse bank number");
+ curr = (bank << 14) | (pointer & 0x3fff);
// Main loop
const char * section = NULL;
@@ -157,10 +161,16 @@ int main(int argc, char * argv[]) {
// Found section, but cannot shim it
continue;
- printf("SECTION \"Shim for %s\", %s[$%04X]", symbol, section, pointer);
- if (bank)
- printf(", BANK[$%04X]", bank);
- printf("\n%s::\n\n", symbol);
+ if (curr != last) {
+ if (last != -1)
+ fputc('\n', stdout);
+ printf("SECTION \"Shim for %s\", %s[$%04X]", symbol, section, pointer);
+ if (bank)
+ printf(", BANK[$%04X]", bank);
+ printf("\n%s::\n", symbol);
+ last = curr;
+ } else
+ printf("%s::\n", symbol);
fflush(stdout);
}
fclose(file);