Compare commits

...

3 Commits

Author SHA1 Message Date
Anthony J. Bentley
8811784b71 rgbfix: exit on invalid usage. 2013-04-11 09:28:38 -06:00
Anthony J. Bentley
6579743410 Add support for 8 MiB ROMs, the largest size possible with MBC5. 2012-12-26 21:41:47 -07:00
Anthony J. Bentley
b90406861d Readability (whitespace). 2012-12-26 21:12:52 -07:00
5 changed files with 51 additions and 52 deletions

View File

@@ -5,11 +5,11 @@
enum eBankDefine { enum eBankDefine {
BANK_HOME = 0, BANK_HOME = 0,
BANK_BSS = 256, BANK_BSS = 512,
BANK_VRAM, BANK_VRAM,
BANK_HRAM BANK_HRAM
}; };
#define MAXBANKS 259 #define MAXBANKS 515
extern SLONG area_Avail(SLONG bank); extern SLONG area_Avail(SLONG bank);
extern void AssignSections(void); extern void AssignSections(void);

View File

@@ -1,48 +1,46 @@
section : T_POP_SECTION string ',' sectiontype section:
{ out_NewSection($2,$4); } T_POP_SECTION string ',' sectiontype
| T_POP_SECTION string ',' sectiontype '[' const ']' {
{ out_NewSection($2,$4);
if( $6>=0 && $6<0x10000 ) }
out_NewAbsSection($2,$4,$6,-1); | T_POP_SECTION string ',' sectiontype '[' const ']'
else {
yyerror( "Address must be 16-bit" ); if( $6>=0 && $6<0x10000 )
} out_NewAbsSection($2,$4,$6,-1);
| T_POP_SECTION string ',' sectiontype ',' T_OP_BANK '[' const ']' else
{ yyerror( "Address must be 16-bit" );
if( $4==SECT_CODE ) }
{ | T_POP_SECTION string ',' sectiontype ',' T_OP_BANK '[' const ']'
if( $8>=1 && $8<=255 ) {
out_NewAbsSection($2,$4,-1,$8); if( $4==SECT_CODE ) {
else if( $8>=1 && $8<=0x1ff )
yyerror( "BANK value out of range" ); out_NewAbsSection($2,$4,-1,$8);
} else
else yyerror( "BANK value out of range" );
yyerror( "BANK only allowed for CODE/DATA" ); } else
} yyerror( "BANK only allowed for CODE/DATA" );
| T_POP_SECTION string ',' sectiontype '[' const ']' ',' T_OP_BANK '[' const ']' }
{ | T_POP_SECTION string ',' sectiontype '[' const ']' ',' T_OP_BANK '[' const ']'
if( $4==SECT_CODE ) {
{ if( $4==SECT_CODE ) {
if( $6>=0 && $6<0x10000 ) if( $6>=0 && $6<0x10000 ) {
{ if( $11>=1 && $11<=0x1ff )
if( $11>=1 && $11<=255 ) out_NewAbsSection($2,$4,$6,$11);
out_NewAbsSection($2,$4,$6,$11); else
else yyerror( "BANK value out of range" );
yyerror( "BANK value out of range" ); } else
} yyerror( "Address must be 16-bit" );
else } else
yyerror( "Address must be 16-bit" ); yyerror( "BANK only allowed for CODE/DATA" );
} }
else
yyerror( "BANK only allowed for CODE/DATA" );
}
; ;
sectiontype : T_SECT_BSS { $$=SECT_BSS; } sectiontype:
| T_SECT_VRAM { $$=SECT_VRAM; } T_SECT_BSS { $$=SECT_BSS; }
| T_SECT_CODE { $$=SECT_CODE; } | T_SECT_VRAM { $$=SECT_VRAM; }
| T_SECT_HOME { $$=SECT_HOME; } | T_SECT_CODE { $$=SECT_CODE; }
| T_SECT_HRAM { $$=SECT_HRAM; } | T_SECT_HOME { $$=SECT_HOME; }
| T_SECT_HRAM { $$=SECT_HRAM; }
; ;

View File

@@ -29,6 +29,7 @@ usage(void)
"[-l licensee_id]\n" " [-m mbc_type] [-n rom_version] " "[-l licensee_id]\n" " [-m mbc_type] [-n rom_version] "
"[-p pad_value] [-r ram_size]\n" "[-p pad_value] [-r ram_size]\n"
" [-t title_str] file.gb\n"); " [-t title_str] file.gb\n");
exit(1);
} }
int int

View File

@@ -90,7 +90,7 @@ area_AllocAbsCODEAnyBank(SLONG org, SLONG size)
{ {
SLONG i; SLONG i;
for (i = 1; i <= 255; i += 1) { for (i = 1; i <= 511; i += 1) {
if (area_AllocAbs(&BankFree[i], org, size) == org) if (area_AllocAbs(&BankFree[i], org, size) == org)
return (i); return (i);
} }
@@ -126,7 +126,7 @@ area_AllocCODEAnyBank(SLONG size)
{ {
SLONG i, org; 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) if ((org = area_Alloc(&BankFree[i], size)) != -1)
return ((i << 16) | org); return ((i << 16) | org);
} }
@@ -204,7 +204,7 @@ AssignSections(void)
BankFree[i]->nSize = 0x4000; BankFree[i]->nSize = 0x4000;
MaxAvail[i] = 0x4000; MaxAvail[i] = 0x4000;
} }
} else if (i >= 1 && i <= 255) { } else if (i >= 1 && i <= 511) {
BankFree[i]->nOrg = 0x4000; BankFree[i]->nOrg = 0x4000;
/* /*
* Now, this shouldn't really be necessary... but for * Now, this shouldn't really be necessary... but for
@@ -327,7 +327,7 @@ AssignSections(void)
*/ */
if (pSection->nBank >= 1 if (pSection->nBank >= 1
&& pSection->nBank <= 255) { && pSection->nBank <= 511) {
if (area_AllocAbs if (area_AllocAbs
(&BankFree (&BankFree
[pSection->nBank], [pSection->nBank],
@@ -365,7 +365,7 @@ AssignSections(void)
&& pSection->Type == SECT_CODE && pSection->Type == SECT_CODE
&& pSection->nOrg == -1 && pSection->nBank != -1) { && pSection->nOrg == -1 && pSection->nBank != -1) {
/* User wants to have a say... and he's pissed */ /* 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 = if ((pSection->nOrg =
area_Alloc(&BankFree[pSection->nBank], area_Alloc(&BankFree[pSection->nBank],
pSection->nByteSize)) == -1) { pSection->nByteSize)) == -1) {

View File

@@ -59,7 +59,7 @@ MapfileInitBank(SLONG bank)
currentbank = bank; currentbank = bank;
if (bank == 0) if (bank == 0)
fprintf(mf, "Bank #0 (HOME):\n"); fprintf(mf, "Bank #0 (HOME):\n");
else if (bank <= 255) else if (bank < BANK_BSS)
fprintf(mf, "Bank #%ld:\n", bank); fprintf(mf, "Bank #%ld:\n", bank);
else if (bank == BANK_BSS) else if (bank == BANK_BSS)
fprintf(mf, "BSS:\n"); fprintf(mf, "BSS:\n");
@@ -69,7 +69,7 @@ MapfileInitBank(SLONG bank)
fprintf(mf, "VRAM:\n"); fprintf(mf, "VRAM:\n");
} }
if (sf) { if (sf) {
sfbank = (bank >= 1 && bank <= 255) ? bank : 0; sfbank = (bank >= 1 && bank <= 511) ? bank : 0;
} }
} }