ref: e4b4e427f12769fd309792c37bbbc1daf7908add
parent: 2138bb46fd7614d78679572172bd29a763c4370a
author: AntonioND <[email protected]>
date: Mon Apr 3 17:03:03 EDT 2017
Return bank 0 for labels in HRAM Instead of returning the internal representation of the linker, return 0 when using BANK() on a label in HRAM. Also, generate a warning when calculating the bank of labels in OAM and HRAM, as there is no valid reason for doing it, so it's likely a programming mistake. Signed-off-by: AntonioND <[email protected]>
--- a/src/link/patch.c
+++ b/src/link/patch.c
@@ -68,13 +68,22 @@
errx(1, "*INTERNAL* UNKNOWN SYMBOL TYPE");
}
- if (nBank == BANK_WRAM0 || nBank == BANK_OAM) return 0;
- if (nBank >= BANK_WRAMX && nBank < (BANK_WRAMX + BANK_COUNT_WRAMX))
+ if (nBank == BANK_WRAM0 || nBank == BANK_ROM0) {
+ /* This can have practical uses. */
+ return 0;
+ } else if (nBank == BANK_OAM) {
+ warnx("Trying to calculate BANK() of label in OAM.");
+ return 0;
+ } else if (nBank == BANK_HRAM) {
+ warnx("Trying to calculate BANK() of label in HRAM.");
+ return 0;
+ } else if (nBank >= BANK_WRAMX && nBank < (BANK_WRAMX + BANK_COUNT_WRAMX)) {
return nBank - BANK_WRAMX + 1;
- if (nBank >= BANK_VRAM && nBank < (BANK_VRAM + BANK_COUNT_VRAM))
+ } else if (nBank >= BANK_VRAM && nBank < (BANK_VRAM + BANK_COUNT_VRAM)) {
return nBank - BANK_VRAM;
- if (nBank >= BANK_SRAM && nBank < (BANK_SRAM + BANK_COUNT_SRAM))
+ } else if (nBank >= BANK_SRAM && nBank < (BANK_SRAM + BANK_COUNT_SRAM)) {
return nBank - BANK_SRAM;
+ }
return nBank;
}