From e3109af2f8943ea410b2ace30cc57d7b6f04ea25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Sat, 8 Apr 2017 18:08:51 +0100 Subject: [PATCH] Rename OPT_CONTWRAM to OPT_DMG_MODE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- include/link/mylink.h | 2 +- src/link/assign.c | 8 ++++++-- src/link/main.c | 12 ++++++++---- src/link/object.c | 9 +++++++-- src/link/rgblink.1 | 5 ++++- src/link/script.c | 9 +++++++-- test/link/test.sh | 18 +++++++++++++++--- test/link/update-refs.sh | 14 +++++++++++--- test/link/vram-fixed-dmg-mode-no-w.out | 0 test/link/vram-fixed-dmg-mode-w.out | 1 + test/link/vram-fixed-dmg-mode.asm | 6 ++++++ test/link/vram-floating-dmg-mode-no-w.out | 0 test/link/vram-floating-dmg-mode-w.out | 1 + test/link/vram-floating-dmg-mode.asm | 6 ++++++ ...ntwram-no-w.out => wramx-dmg-mode-no-w.out} | 0 ...amx-contwram-w.out => wramx-dmg-mode-w.out} | 0 .../{wramx-contwram.asm => wramx-dmg-mode.asm} | 0 17 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 test/link/vram-fixed-dmg-mode-no-w.out create mode 100644 test/link/vram-fixed-dmg-mode-w.out create mode 100644 test/link/vram-fixed-dmg-mode.asm create mode 100644 test/link/vram-floating-dmg-mode-no-w.out create mode 100644 test/link/vram-floating-dmg-mode-w.out create mode 100644 test/link/vram-floating-dmg-mode.asm rename test/link/{wramx-contwram-no-w.out => wramx-dmg-mode-no-w.out} (100%) rename test/link/{wramx-contwram-w.out => wramx-dmg-mode-w.out} (100%) rename test/link/{wramx-contwram.asm => wramx-dmg-mode.asm} (100%) diff --git a/include/link/mylink.h b/include/link/mylink.h index 9bff627f..30c03309 100644 --- a/include/link/mylink.h +++ b/include/link/mylink.h @@ -11,7 +11,7 @@ extern SLONG options; #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, diff --git a/src/link/assign.c b/src/link/assign.c index 95f83af1..e05cbadb 100644 --- a/src/link/assign.c +++ b/src/link/assign.c @@ -402,7 +402,7 @@ AssignSections(void) } 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 @@ AssignSections(void) } 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; diff --git a/src/link/main.c b/src/link/main.c index b56363d6..d602f77f 100644 --- a/src/link/main.c +++ b/src/link/main.c @@ -92,10 +92,14 @@ main(int argc, char *argv[]) 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(); diff --git a/src/link/object.c b/src/link/object.c index 9972877b..8cca04da 100644 --- a/src/link/object.c +++ b/src/link/object.c @@ -159,8 +159,13 @@ obj_ReadRGBSection(FILE * f) 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)) { diff --git a/src/link/rgblink.1 b/src/link/rgblink.1 index 43505d69..7e7328d6 100644 --- 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 @@ sections are placed in any bank except bank 0. 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 @@ The default is 0x00. .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 diff --git a/src/link/script.c b/src/link/script.c index 75fdf80b..659d49ed 100644 --- a/src/link/script.c +++ b/src/link/script.c @@ -49,7 +49,7 @@ void script_InitSections(void) } 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 @@ void script_InitSections(void) } 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; diff --git a/test/link/test.sh b/test/link/test.sh index ae2a26b4..b0aa1e86 100644 --- a/test/link/test.sh +++ b/test/link/test.sh @@ -12,11 +12,23 @@ diff bank-numbers.out $outtemp 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 diff --git a/test/link/update-refs.sh b/test/link/update-refs.sh index 1c7235d6..759c26fd 100644 --- a/test/link/update-refs.sh +++ b/test/link/update-refs.sh @@ -8,9 +8,17 @@ $RGBASM -o $otemp bank-numbers.asm $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 diff --git a/test/link/vram-fixed-dmg-mode-no-w.out b/test/link/vram-fixed-dmg-mode-no-w.out new file mode 100644 index 00000000..e69de29b diff --git a/test/link/vram-fixed-dmg-mode-w.out b/test/link/vram-fixed-dmg-mode-w.out new file mode 100644 index 00000000..277c6954 --- /dev/null +++ b/test/link/vram-fixed-dmg-mode-w.out @@ -0,0 +1 @@ +rgblink: error: VRAM bank 1 can't be used with option -w. diff --git a/test/link/vram-fixed-dmg-mode.asm b/test/link/vram-fixed-dmg-mode.asm new file mode 100644 index 00000000..433375a8 --- /dev/null +++ b/test/link/vram-fixed-dmg-mode.asm @@ -0,0 +1,6 @@ +SECTION "v0", VRAM, BANK[0] +DS $2000 + +SECTION "v1", VRAM, BANK[1] +DS $2000 + diff --git a/test/link/vram-floating-dmg-mode-no-w.out b/test/link/vram-floating-dmg-mode-no-w.out new file mode 100644 index 00000000..e69de29b diff --git a/test/link/vram-floating-dmg-mode-w.out b/test/link/vram-floating-dmg-mode-w.out new file mode 100644 index 00000000..31ad1d17 --- /dev/null +++ b/test/link/vram-floating-dmg-mode-w.out @@ -0,0 +1 @@ +rgblink: error: Unable to place 'v1' (VRAM section) in any bank diff --git a/test/link/vram-floating-dmg-mode.asm b/test/link/vram-floating-dmg-mode.asm new file mode 100644 index 00000000..6510e3da --- /dev/null +++ b/test/link/vram-floating-dmg-mode.asm @@ -0,0 +1,6 @@ +SECTION "v0", VRAM +DS $2000 + +SECTION "v1", VRAM +DS $2000 + diff --git a/test/link/wramx-contwram-no-w.out b/test/link/wramx-dmg-mode-no-w.out similarity index 100% rename from test/link/wramx-contwram-no-w.out rename to test/link/wramx-dmg-mode-no-w.out diff --git a/test/link/wramx-contwram-w.out b/test/link/wramx-dmg-mode-w.out similarity index 100% rename from test/link/wramx-contwram-w.out rename to test/link/wramx-dmg-mode-w.out diff --git a/test/link/wramx-contwram.asm b/test/link/wramx-dmg-mode.asm similarity index 100% rename from test/link/wramx-contwram.asm rename to test/link/wramx-dmg-mode.asm