shithub: rgbds

Download patch

ref: 59e73e64ca2f5d9665b314279b87d376a5eafddb
parent: 972d06bb41c2857cfbfe47a9b3d297f0333bdc54
author: ISSOtm <eldredhabert0@gmail.com>
date: Sat Apr 30 09:17:45 EDT 2022

Unconditionally output ROM0 even without any sections

Required for example when "overlaying" over a ROM and only patching ROMX.
Fixes #993

--- a/src/link/output.c
+++ b/src/link/output.c
@@ -39,7 +39,7 @@
 };
 
 static struct {
-	uint32_t nbBanks;
+	uint32_t nbBanks; // Size of the array below (which may be NULL if this is 0)
 	struct SortedSections {
 		struct SortedSection *sections;
 		struct SortedSection *zeroLenSections;
@@ -243,9 +243,9 @@
 		coverOverlayBanks(nbOverlayBanks);
 
 	if (outputFile) {
-		if (sections[SECTTYPE_ROM0].nbBanks > 0)
-			writeBank(sections[SECTTYPE_ROM0].banks[0].sections,
-				  startaddr[SECTTYPE_ROM0], maxsize[SECTTYPE_ROM0]);
+		writeBank(sections[SECTTYPE_ROM0].banks ? sections[SECTTYPE_ROM0].banks[0].sections
+							: NULL,
+			  startaddr[SECTTYPE_ROM0], maxsize[SECTTYPE_ROM0]);
 
 		for (uint32_t i = 0 ; i < sections[SECTTYPE_ROMX].nbBanks; i++)
 			writeBank(sections[SECTTYPE_ROMX].banks[i].sections,