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 <antonio_nd@outlook.com>
This commit is contained in:
Antonio Niño Díaz
2017-04-08 18:08:51 +01:00
parent 928b347dfc
commit e3109af2f8
17 changed files with 73 additions and 18 deletions

View File

@@ -11,7 +11,7 @@ extern SLONG options;
#define OPT_TINY 0x01 #define OPT_TINY 0x01
#define OPT_SMART_C_LINK 0x02 #define OPT_SMART_C_LINK 0x02
#define OPT_OVERLAY 0x04 #define OPT_OVERLAY 0x04
#define OPT_CONTWRAM 0x08 #define OPT_DMG_MODE 0x08
enum eRpnData { enum eRpnData {
RPN_ADD = 0, RPN_ADD = 0,

View File

@@ -402,7 +402,7 @@ AssignSections(void)
} else if (i == BANK_WRAM0) { } else if (i == BANK_WRAM0) {
/* WRAM */ /* WRAM */
BankFree[i]->nOrg = 0xC000; BankFree[i]->nOrg = 0xC000;
if (options & OPT_CONTWRAM) { if (options & OPT_DMG_MODE) {
BankFree[i]->nSize = 0x2000; BankFree[i]->nSize = 0x2000;
} else { } else {
BankFree[i]->nSize = 0x1000; BankFree[i]->nSize = 0x1000;
@@ -418,7 +418,11 @@ AssignSections(void)
} else if (i >= BANK_VRAM && i < BANK_VRAM + BANK_COUNT_VRAM) { } else if (i >= BANK_VRAM && i < BANK_VRAM + BANK_COUNT_VRAM) {
/* Swappable VRAM bank */ /* Swappable VRAM bank */
BankFree[i]->nOrg = 0x8000; 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) { } else if (i == BANK_OAM) {
BankFree[i]->nOrg = 0xFE00; BankFree[i]->nOrg = 0xFE00;
BankFree[i]->nSize = 0x00A0; BankFree[i]->nSize = 0x00A0;

View File

@@ -92,10 +92,14 @@ main(int argc, char *argv[])
options |= OPT_TINY; options |= OPT_TINY;
break; break;
case 'w': 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 * Set to set WRAM as a single continuous block as on
not exist in this mode. A WRAMX section will raise an error. */ * DMG. All WRAM sections must be WRAM0 as bankable WRAM
options |= OPT_CONTWRAM; * 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; break;
default: default:
usage(); usage();

View File

@@ -159,8 +159,13 @@ obj_ReadRGBSection(FILE * f)
if ((options & OPT_TINY) && (pSection->Type == SECT_ROMX)) { if ((options & OPT_TINY) && (pSection->Type == SECT_ROMX)) {
errx(1, "ROMX sections can't be used with option -t."); errx(1, "ROMX sections can't be used with option -t.");
} }
if ((options & OPT_CONTWRAM) && (pSection->Type == SECT_WRAMX)) { if (options & OPT_DMG_MODE) {
errx(1, "WRAMX sections can't be used with option -w."); 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)) { if ((pSection->Type == SECT_ROMX) || (pSection->Type == SECT_ROM0)) {

View File

@@ -12,7 +12,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd March 27, 2017 .Dd April 8, 2017
.Dt RGBLINK 1 .Dt RGBLINK 1
.Os RGBDS Manual .Os RGBDS Manual
.Sh NAME .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 If your ROM is designed for DMG, you can use the
.Fl w .Fl w
option to override this. option to override this.
It will also prohibit the use of VRAM bank 1.
.Pp .Pp
The arguments are as follows: The arguments are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
@@ -67,8 +68,10 @@ The default is 0x00.
.It Fl s Ar symbol .It Fl s Ar symbol
??? ???
.It Fl w .It Fl w
Enable DMG mode.
Expand the WRAM0 section size from 4KiB to the full 8KiB assigned to WRAM and 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 WRAMX sections.
Prohibit the use of VRAM bank 1.
Useful for ROMs designed for DMG. Useful for ROMs designed for DMG.
.It Fl t .It Fl t
Expand the ROM0 section size from 16KiB to the full 32KiB assigned to ROM and Expand the ROM0 section size from 16KiB to the full 32KiB assigned to ROM and

View File

@@ -49,7 +49,7 @@ void script_InitSections(void)
} else if (i == BANK_WRAM0) { } else if (i == BANK_WRAM0) {
/* WRAM */ /* WRAM */
bank[i].address = 0xC000; bank[i].address = 0xC000;
if (options & OPT_CONTWRAM) { if (options & OPT_DMG_MODE) {
bank[i].top_address = 0xE000; bank[i].top_address = 0xE000;
} else { } else {
bank[i].top_address = 0xD000; bank[i].top_address = 0xD000;
@@ -68,8 +68,13 @@ void script_InitSections(void)
} else if (i >= BANK_VRAM && i < BANK_VRAM + BANK_COUNT_VRAM) { } else if (i >= BANK_VRAM && i < BANK_VRAM + BANK_COUNT_VRAM) {
/* Swappable VRAM bank */ /* Swappable VRAM bank */
bank[i].address = 0x8000; bank[i].address = 0x8000;
bank[i].top_address = 0xA000;
bank[i].type = SECT_VRAM; 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) { } else if (i == BANK_OAM) {
/* OAM */ /* OAM */
bank[i].address = 0xFE00; bank[i].address = 0xFE00;

View File

@@ -12,11 +12,23 @@ diff bank-numbers.out $outtemp
head -c 20 $gbtemp > $otemp 2>&1 head -c 20 $gbtemp > $otemp 2>&1
diff bank-numbers.out.bin $otemp 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 $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 $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 $RGBASM -o $otemp romx-tiny.asm
$RGBLINK -o $gbtemp $otemp > $outtemp 2>&1 $RGBLINK -o $gbtemp $otemp > $outtemp 2>&1

View File

@@ -8,9 +8,17 @@ $RGBASM -o $otemp bank-numbers.asm
$RGBLINK -o $gbtemp $otemp > bank-numbers.out 2>&1 $RGBLINK -o $gbtemp $otemp > bank-numbers.out 2>&1
head -c 20 $gbtemp > bank-numbers.out.bin 2>&1 head -c 20 $gbtemp > bank-numbers.out.bin 2>&1
$RGBASM -o $otemp wramx-contwram.asm $RGBASM -o $otemp wramx-dmg-mode.asm
$RGBLINK -o $gbtemp $otemp > wramx-contwram-no-w.out 2>&1 $RGBLINK -o $gbtemp $otemp > wramx-dmg-mode-no-w.out 2>&1
$RGBLINK -w -o $gbtemp $otemp > wramx-contwram-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 $RGBASM -o $otemp romx-tiny.asm
$RGBLINK -o $gbtemp $otemp > romx-tiny-no-t.out 2>&1 $RGBLINK -o $gbtemp $otemp > romx-tiny-no-t.out 2>&1

View File

View File

@@ -0,0 +1 @@
rgblink: error: VRAM bank 1 can't be used with option -w.

View File

@@ -0,0 +1,6 @@
SECTION "v0", VRAM, BANK[0]
DS $2000
SECTION "v1", VRAM, BANK[1]
DS $2000

View File

@@ -0,0 +1 @@
rgblink: error: Unable to place 'v1' (VRAM section) in any bank

View File

@@ -0,0 +1,6 @@
SECTION "v0", VRAM
DS $2000
SECTION "v1", VRAM
DS $2000