shithub: rgbds

Download patch

ref: 469e3e7c860ca83c85b06f46788ff6ddf72a49ac
parent: 9193710ff90fc2183a9079bea917b4be6b5edfc3
parent: 6d1c60b0a6ad8160e92f1739cf5d92cdd61b4237
author: AntonioND <[email protected]>
date: Wed Mar 15 16:52:44 EDT 2017

Merge branch 'contiguous-wram' of git://github.com/TwitchPlaysPokemon/rgbds into TwitchPlaysPokemon-contiguous-wram

--- a/include/link/mylink.h
+++ b/include/link/mylink.h
@@ -8,9 +8,10 @@
 #include "types.h"
 
 extern SLONG options;
-#define OPT_SMALL	0x01
+#define OPT_SMALL		0x01
 #define OPT_SMART_C_LINK	0x02
-#define OPT_OVERLAY	0x04
+#define OPT_OVERLAY		0x04
+#define OPT_CONTWRAM		0x08
 
 enum eRpnData {
 	RPN_ADD = 0,
--- a/src/link/assign.c
+++ b/src/link/assign.c
@@ -332,7 +332,11 @@
 		} else if (i == BANK_WRAM0) {
 			/* WRAM */
 			BankFree[i]->nOrg = 0xC000;
-			BankFree[i]->nSize = 0x1000;
+			if (options & OPT_CONTWRAM) {
+				BankFree[i]->nSize = 0x2000;
+			} else {
+				BankFree[i]->nSize = 0x1000;
+			}
 		} else if (i >= BANK_SRAM && i < BANK_SRAM + BANK_COUNT_SRAM) {
 			/* Swappable SRAM bank */
 			BankFree[i]->nOrg = 0xA000;
@@ -372,6 +376,10 @@
 		if ((pSection->nOrg != -1 || pSection->nBank != -1)
 		    && pSection->oAssigned == 0) {
 			/* User wants to have a say... */
+
+			if (pSection->Type == SECT_WRAMX && options & OPT_CONTWRAM) {
+				errx(1, "WRAMX not compatible with -w!");
+			}
 
 			switch (pSection->Type) {
 			case SECT_WRAM0:
--- a/src/link/main.c
+++ b/src/link/main.c
@@ -35,7 +35,7 @@
 usage(void)
 {
 	printf(
-"usage: rgblink [-t] [-m mapfile] [-n symfile] [-O overlay] [-o outfile] \n"
+"usage: rgblink [-tw] [-m mapfile] [-n symfile] [-O overlay] [-o outfile] \n"
 "               [-p pad_value] [-s symbol] file [...]\n");
 	exit(1);
 }
@@ -56,7 +56,7 @@
 
 	progname = argv[0];
 
-	while ((ch = getopt(argc, argv, "m:n:o:O:p:s:t")) != -1) {
+	while ((ch = getopt(argc, argv, "m:n:o:O:p:s:tw")) != -1) {
 		switch (ch) {
 		case 'm':
 			SetMapfileName(optarg);
@@ -87,6 +87,12 @@
 			break;
 		case 't':
 			options |= OPT_SMALL;
+			break;
+		case 'w':
+			/* Set to set WRAM as a single continuous block as on DMG.
+			All WRAM sections must be WRAM0 as bankable WRAM sections do
+			not exist in this mode. A WRAMX section will raise an error. */
+			options |= OPT_CONTWRAM;
 			break;
 		default:
 			usage();