ref: e3109af2f8943ea410b2ace30cc57d7b6f04ea25
parent: 928b347dfcaf860f0a4e3519fb87e87db094001d
author: Antonio Niño Díaz <[email protected]>
date: Sat Apr 8 14:08:51 EDT 2017
Rename OPT_CONTWRAM to OPT_DMG_MODE Now, it will also make sure that VRAM bank 1 isn't used. Man page updated. Tests added. Signed-off-by: Antonio Niño Díaz <[email protected]>
--- a/include/link/mylink.h
+++ b/include/link/mylink.h
@@ -11,7 +11,7 @@
#define OPT_TINY 0x01
#define OPT_SMART_C_LINK 0x02
#define OPT_OVERLAY 0x04
-#define OPT_CONTWRAM 0x08
+#define OPT_DMG_MODE 0x08
enum eRpnData {
RPN_ADD = 0,
--- a/src/link/assign.c
+++ b/src/link/assign.c
@@ -402,7 +402,7 @@
} else if (i == BANK_WRAM0) {
/* WRAM */
BankFree[i]->nOrg = 0xC000;
- if (options & OPT_CONTWRAM) {
+ if (options & OPT_DMG_MODE) {
BankFree[i]->nSize = 0x2000;
} else {
BankFree[i]->nSize = 0x1000;
@@ -418,7 +418,11 @@
} else if (i >= BANK_VRAM && i < BANK_VRAM + BANK_COUNT_VRAM) {
/* Swappable VRAM bank */
BankFree[i]->nOrg = 0x8000;
- BankFree[i]->nSize = 0x2000;
+ if (options & OPT_DMG_MODE && i != BANK_VRAM) {
+ BankFree[i]->nSize = 0;
+ } else {
+ BankFree[i]->nSize = 0x2000;
+ }
} else if (i == BANK_OAM) {
BankFree[i]->nOrg = 0xFE00;
BankFree[i]->nSize = 0x00A0;
--- a/src/link/main.c
+++ b/src/link/main.c
@@ -92,10 +92,14 @@
options |= OPT_TINY;
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;
+ /*
+ * 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. VRAM bank 1 can't be used if
+ * this option is enabled either.
+ */
+ options |= OPT_DMG_MODE;
break;
default:
usage();
--- a/src/link/object.c
+++ b/src/link/object.c
@@ -159,8 +159,13 @@
if ((options & OPT_TINY) && (pSection->Type == SECT_ROMX)) {
errx(1, "ROMX sections can't be used with option -t.");
}
- if ((options & OPT_CONTWRAM) && (pSection->Type == SECT_WRAMX)) {
- errx(1, "WRAMX sections can't be used with option -w.");
+ if (options & OPT_DMG_MODE) {
+ if (pSection->Type == SECT_WRAMX) {
+ errx(1, "WRAMX sections can't be used with option -w.");
+ }
+ if (pSection->Type == SECT_VRAM && pSection->nBank == 1) {
+ errx(1, "VRAM bank 1 can't be used with option -w.");
+ }
}
if ((pSection->Type == SECT_ROMX) || (pSection->Type == SECT_ROM0)) {
--- a/src/link/rgblink.1
+++ b/src/link/rgblink.1
@@ -12,7 +12,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd March 27, 2017
+.Dd April 8, 2017
.Dt RGBLINK 1
.Os RGBDS Manual
.Sh NAME
@@ -48,6 +48,7 @@
If your ROM is designed for DMG, you can use the
.Fl w
option to override this.
+It will also prohibit the use of VRAM bank 1.
.Pp
The arguments are as follows:
.Bl -tag -width Ds
@@ -67,8 +68,10 @@
.It Fl s Ar symbol
???
.It Fl w
+Enable DMG mode.
Expand the WRAM0 section size from 4KiB to the full 8KiB assigned to WRAM and
prohibit the use of WRAMX sections.
+Prohibit the use of VRAM bank 1.
Useful for ROMs designed for DMG.
.It Fl t
Expand the ROM0 section size from 16KiB to the full 32KiB assigned to ROM and
--- a/src/link/script.c
+++ b/src/link/script.c
@@ -49,7 +49,7 @@
} else if (i == BANK_WRAM0) {
/* WRAM */
bank[i].address = 0xC000;
- if (options & OPT_CONTWRAM) {
+ if (options & OPT_DMG_MODE) {
bank[i].top_address = 0xE000;
} else {
bank[i].top_address = 0xD000;
@@ -68,8 +68,13 @@
} else if (i >= BANK_VRAM && i < BANK_VRAM + BANK_COUNT_VRAM) {
/* Swappable VRAM bank */
bank[i].address = 0x8000;
- bank[i].top_address = 0xA000;
bank[i].type = SECT_VRAM;
+ if (options & OPT_DMG_MODE && i != BANK_VRAM) {
+ /* In DMG the only available bank is bank 0. */
+ bank[i].top_address = 0x8000;
+ } else {
+ bank[i].top_address = 0xA000;
+ }
} else if (i == BANK_OAM) {
/* OAM */
bank[i].address = 0xFE00;
--- a/test/link/test.sh
+++ b/test/link/test.sh
@@ -12,11 +12,23 @@
head -c 20 $gbtemp > $otemp 2>&1
diff bank-numbers.out.bin $otemp
-$RGBASM -o $otemp wramx-contwram.asm
+$RGBASM -o $otemp wramx-dmg-mode.asm
$RGBLINK -o $gbtemp $otemp > $outtemp 2>&1
-diff wramx-contwram-no-w.out $outtemp
+diff wramx-dmg-mode-no-w.out $outtemp
$RGBLINK -w -o $gbtemp $otemp > $outtemp 2>&1
-diff wramx-contwram-w.out $outtemp
+diff wramx-dmg-mode-w.out $outtemp
+
+$RGBASM -o $otemp vram-fixed-dmg-mode.asm
+$RGBLINK -o $gbtemp $otemp > $outtemp 2>&1
+diff vram-fixed-dmg-mode-no-w.out $outtemp
+$RGBLINK -w -o $gbtemp $otemp > $outtemp 2>&1
+diff vram-fixed-dmg-mode-w.out $outtemp
+
+$RGBASM -o $otemp vram-floating-dmg-mode.asm
+$RGBLINK -o $gbtemp $otemp > $outtemp 2>&1
+diff vram-floating-dmg-mode-no-w.out $outtemp
+$RGBLINK -w -o $gbtemp $otemp > $outtemp 2>&1
+diff vram-floating-dmg-mode-w.out $outtemp
$RGBASM -o $otemp romx-tiny.asm
$RGBLINK -o $gbtemp $otemp > $outtemp 2>&1
--- a/test/link/update-refs.sh
+++ b/test/link/update-refs.sh
@@ -8,9 +8,17 @@
$RGBLINK -o $gbtemp $otemp > bank-numbers.out 2>&1
head -c 20 $gbtemp > bank-numbers.out.bin 2>&1
-$RGBASM -o $otemp wramx-contwram.asm
-$RGBLINK -o $gbtemp $otemp > wramx-contwram-no-w.out 2>&1
-$RGBLINK -w -o $gbtemp $otemp > wramx-contwram-w.out 2>&1
+$RGBASM -o $otemp wramx-dmg-mode.asm
+$RGBLINK -o $gbtemp $otemp > wramx-dmg-mode-no-w.out 2>&1
+$RGBLINK -w -o $gbtemp $otemp > wramx-dmg-mode-w.out 2>&1
+
+$RGBASM -o $otemp vram-fixed-dmg-mode.asm
+$RGBLINK -o $gbtemp $otemp > vram-fixed-dmg-mode-no-w.out 2>&1
+$RGBLINK -w -o $gbtemp $otemp > vram-fixed-dmg-mode-w.out 2>&1
+
+$RGBASM -o $otemp vram-floating-dmg-mode.asm
+$RGBLINK -o $gbtemp $otemp > vram-floating-dmg-mode-no-w.out 2>&1
+$RGBLINK -w -o $gbtemp $otemp > vram-floating-dmg-mode-w.out 2>&1
$RGBASM -o $otemp romx-tiny.asm
$RGBLINK -o $gbtemp $otemp > romx-tiny-no-t.out 2>&1
--- /dev/null
+++ b/test/link/vram-fixed-dmg-mode-w.out
@@ -1,0 +1,1 @@
+rgblink: error: VRAM bank 1 can't be used with option -w.
--- /dev/null
+++ b/test/link/vram-fixed-dmg-mode.asm
@@ -1,0 +1,6 @@
+SECTION "v0", VRAM, BANK[0]
+DS $2000
+
+SECTION "v1", VRAM, BANK[1]
+DS $2000
+
--- /dev/null
+++ b/test/link/vram-floating-dmg-mode-w.out
@@ -1,0 +1,1 @@
+rgblink: error: Unable to place 'v1' (VRAM section) in any bank
--- /dev/null
+++ b/test/link/vram-floating-dmg-mode.asm
@@ -1,0 +1,6 @@
+SECTION "v0", VRAM
+DS $2000
+
+SECTION "v1", VRAM
+DS $2000
+
--- a/test/link/wramx-contwram-no-w.out
+++ /dev/null
@@ -1,1 +1,0 @@
-rgblink: error: Unable to place 'w0b' (WRAM0 section) anywhere
--- a/test/link/wramx-contwram-w.out
+++ /dev/null
@@ -1,1 +1,0 @@
-rgblink: error: WRAMX sections can't be used with option -w.
--- a/test/link/wramx-contwram.asm
+++ /dev/null
@@ -1,8 +1,0 @@
-SECTION "w0a", WRAM0
-DS $1000
-
-SECTION "wx", WRAMX
-DS $1000
-
-SECTION "w0b", WRAM0
-DS $1000
--- /dev/null
+++ b/test/link/wramx-dmg-mode-no-w.out
@@ -1,0 +1,1 @@
+rgblink: error: Unable to place 'w0b' (WRAM0 section) anywhere
--- /dev/null
+++ b/test/link/wramx-dmg-mode-w.out
@@ -1,0 +1,1 @@
+rgblink: error: WRAMX sections can't be used with option -w.
--- /dev/null
+++ b/test/link/wramx-dmg-mode.asm
@@ -1,0 +1,8 @@
+SECTION "w0a", WRAM0
+DS $1000
+
+SECTION "wx", WRAMX
+DS $1000
+
+SECTION "w0b", WRAM0
+DS $1000