shithub: rgbds

Download patch

ref: 6579743410f64c8781da66ae6b0baa88df4a31dd
parent: b90406861d2262c77c23513becceaba5d08b3161
author: Anthony J. Bentley <[email protected]>
date: Wed Dec 26 16:41:47 EST 2012

Add support for 8 MiB ROMs, the largest size possible with MBC5.

--- a/include/link/assign.h
+++ b/include/link/assign.h
@@ -5,11 +5,11 @@
 
 enum eBankDefine {
 	BANK_HOME = 0,
-	BANK_BSS = 256,
+	BANK_BSS = 512,
 	BANK_VRAM,
 	BANK_HRAM
 };
-#define MAXBANKS	259
+#define MAXBANKS	515
 
 extern SLONG area_Avail(SLONG bank);
 extern void AssignSections(void);
--- a/src/asm/gameboy/yaccprt4.y
+++ b/src/asm/gameboy/yaccprt4.y
@@ -13,7 +13,7 @@
 	|	T_POP_SECTION string ',' sectiontype ',' T_OP_BANK '[' const ']'
 		{
 			if( $4==SECT_CODE ) {
-				if( $8>=1 && $8<=255 )
+				if( $8>=1 && $8<=0x1ff )
 					out_NewAbsSection($2,$4,-1,$8);
 				else
 					yyerror( "BANK value out of range" );
@@ -24,7 +24,7 @@
 		{
 			if( $4==SECT_CODE ) {
 				if( $6>=0 && $6<0x10000 ) {
-					if( $11>=1 && $11<=255 )
+					if( $11>=1 && $11<=0x1ff )
 						out_NewAbsSection($2,$4,$6,$11);
 					else
 						yyerror( "BANK value out of range" );
--- a/src/link/assign.c
+++ b/src/link/assign.c
@@ -90,7 +90,7 @@
 {
 	SLONG i;
 
-	for (i = 1; i <= 255; i += 1) {
+	for (i = 1; i <= 511; i += 1) {
 		if (area_AllocAbs(&BankFree[i], org, size) == org)
 			return (i);
 	}
@@ -126,7 +126,7 @@
 {
 	SLONG i, org;
 
-	for (i = 1; i <= 255; i += 1) {
+	for (i = 1; i <= 511; i += 1) {
 		if ((org = area_Alloc(&BankFree[i], size)) != -1)
 			return ((i << 16) | org);
 	}
@@ -204,7 +204,7 @@
 				BankFree[i]->nSize = 0x4000;
 				MaxAvail[i] = 0x4000;
 			}
-		} else if (i >= 1 && i <= 255) {
+		} else if (i >= 1 && i <= 511) {
 			BankFree[i]->nOrg = 0x4000;
 			/*
 			 * Now, this shouldn't really be necessary... but for
@@ -327,7 +327,7 @@
 						 */
 
 						if (pSection->nBank >= 1
-						    && pSection->nBank <= 255) {
+						    && pSection->nBank <= 511) {
 							if (area_AllocAbs
 							    (&BankFree
 								[pSection->nBank],
@@ -365,7 +365,7 @@
 		    && pSection->Type == SECT_CODE
 		    && pSection->nOrg == -1 && pSection->nBank != -1) {
 			/* User wants to have a say... and he's pissed */
-			if (pSection->nBank >= 1 && pSection->nBank <= 255) {
+			if (pSection->nBank >= 1 && pSection->nBank <= 511) {
 				if ((pSection->nOrg =
 					area_Alloc(&BankFree[pSection->nBank],
 					    pSection->nByteSize)) == -1) {
--- a/src/link/mapfile.c
+++ b/src/link/mapfile.c
@@ -59,7 +59,7 @@
 		currentbank = bank;
 		if (bank == 0)
 			fprintf(mf, "Bank #0 (HOME):\n");
-		else if (bank <= 255)
+		else if (bank < BANK_BSS)
 			fprintf(mf, "Bank #%ld:\n", bank);
 		else if (bank == BANK_BSS)
 			fprintf(mf, "BSS:\n");
@@ -69,7 +69,7 @@
 			fprintf(mf, "VRAM:\n");
 	}
 	if (sf) {
-		sfbank = (bank >= 1 && bank <= 255) ? bank : 0;
+		sfbank = (bank >= 1 && bank <= 511) ? bank : 0;
 	}
 }