shithub: rgbds

Download patch

ref: fb81733b2b9d9b74a9cd560531be88399c22626e
parent: e7eac583daf97ff6eb69b7d6b36cb227fcee6876
parent: 71fe65255625e47e07fbd6e7314babfe84592efc
author: Eldred Habert <[email protected]>
date: Sun Jan 26 09:48:32 EST 2020

Merge pull request #472 from ISSOtm/romx-tiny

Allow ROMX and WRAMX sections in restricted modes

--- a/src/link/section.c
+++ b/src/link/section.c
@@ -118,12 +118,20 @@
 
 	if (section->type < 0 || section->type >= SECTTYPE_INVALID)
 		fail("Section \"%s\" has an invalid type.", section->name);
-	if (is32kMode && section->type == SECTTYPE_ROMX)
-		fail("%s: ROMX sections cannot be used with option -t.",
-		     section->name);
-	if (isWRA0Mode && section->type == SECTTYPE_WRAMX)
-		fail("%s: WRAMX sections cannot be used with options -w or -d.",
-		     section->name);
+	if (is32kMode && section->type == SECTTYPE_ROMX) {
+		if (section->isBankFixed && section->bank != 1)
+			fail("%s: ROMX sections must be in bank 1 with option -t.",
+			     section->name);
+		else
+			section->type = SECTTYPE_ROM0;
+	}
+	if (isWRA0Mode && section->type == SECTTYPE_WRAMX) {
+		if (section->isBankFixed && section->bank != 1)
+			fail("%s: WRAMX sections must be in bank 1 with options -w or -d.",
+			     section->name);
+		else
+			section->type = SECTTYPE_WRAMX;
+	}
 	if (isDmgMode && section->type == SECTTYPE_VRAM && section->bank == 1)
 		fail("%s: VRAM bank 1 can't be used with option -d.",
 		     section->name);
--- a/test/link/romx-tiny-t.out
+++ b/test/link/romx-tiny-t.out
@@ -1,2 +1,1 @@
-warning: rx: ROMX sections cannot be used with option -t.
-error: Sanity checks failed
+error: Unable to place "r0a" (ROM0 section) anywhere
--- a/test/link/wramx-dmg-mode-d.out
+++ b/test/link/wramx-dmg-mode-d.out
@@ -1,2 +1,0 @@
-warning: wx: WRAMX sections cannot be used with options -w or -d.
-error: Sanity checks failed