mirror of
https://github.com/gbdev/rgbds.git
synced 2026-01-12 11:31:50 +00:00
Redefine consistent names for section types, and document the changes.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
%token T_SECT_BSS T_SECT_VRAM T_SECT_CODE T_SECT_HOME T_SECT_HRAM T_SECT_WRAMX T_SECT_SRAM
|
||||
%token T_SECT_WRAM0 T_SECT_VRAM T_SECT_ROMX T_SECT_ROM0 T_SECT_HRAM T_SECT_WRAMX T_SECT_SRAM
|
||||
|
||||
%token T_Z80_ADC T_Z80_ADD T_Z80_AND
|
||||
%token T_Z80_BIT
|
||||
|
||||
@@ -12,7 +12,7 @@ section:
|
||||
}
|
||||
| T_POP_SECTION string ',' sectiontype ',' T_OP_BANK '[' const ']'
|
||||
{
|
||||
if( $4==SECT_CODE ) {
|
||||
if( $4==SECT_ROMX ) {
|
||||
if( $8>=1 && $8<=0x1ff )
|
||||
out_NewAbsSection($2,$4,-1,$8);
|
||||
else
|
||||
@@ -36,12 +36,12 @@ section:
|
||||
yyerror("VRAM bank value $%x out of range (0 to 1)", $8);
|
||||
}
|
||||
} else {
|
||||
yyerror("BANK only allowed for CODE/DATA, WRAMX, SRAM, or VRAM sections");
|
||||
yyerror("BANK only allowed for ROMX, WRAMX, SRAM, or VRAM sections");
|
||||
}
|
||||
}
|
||||
| T_POP_SECTION string ',' sectiontype '[' const ']' ',' T_OP_BANK '[' const ']'
|
||||
{
|
||||
if( $4==SECT_CODE ) {
|
||||
if( $4==SECT_ROMX ) {
|
||||
if( $6>=0 && $6<0x10000 ) {
|
||||
if( $11>=1 && $11<=0x1ff )
|
||||
out_NewAbsSection($2,$4,$6,$11);
|
||||
@@ -80,16 +80,16 @@ section:
|
||||
yyerror("Address $%x not 16-bit", $6);
|
||||
}
|
||||
} else {
|
||||
yyerror("BANK only allowed for CODE/DATA, WRAMX, SRAM, or VRAM sections");
|
||||
yyerror("BANK only allowed for ROMX, WRAMX, SRAM, or VRAM sections");
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
sectiontype:
|
||||
T_SECT_BSS { $$=SECT_BSS; }
|
||||
T_SECT_WRAM0 { $$=SECT_WRAM0; }
|
||||
| T_SECT_VRAM { $$=SECT_VRAM; }
|
||||
| T_SECT_CODE { $$=SECT_CODE; }
|
||||
| T_SECT_HOME { $$=SECT_HOME; }
|
||||
| T_SECT_ROMX { $$=SECT_ROMX; }
|
||||
| T_SECT_ROM0 { $$=SECT_ROM0; }
|
||||
| T_SECT_HRAM { $$=SECT_HRAM; }
|
||||
| T_SECT_WRAMX { $$=SECT_WRAMX; }
|
||||
| T_SECT_SRAM { $$=SECT_SRAM; }
|
||||
|
||||
@@ -316,11 +316,14 @@ struct sLexInitString staticstrings[] = {
|
||||
{"else", T_POP_ELSE},
|
||||
{"endc", T_POP_ENDC},
|
||||
|
||||
{"bss", T_SECT_BSS},
|
||||
{"wram0", T_SECT_WRAM0},
|
||||
{"bss", T_SECT_WRAM0}, /* deprecated */
|
||||
{"vram", T_SECT_VRAM},
|
||||
{"code", T_SECT_CODE},
|
||||
{"data", T_SECT_CODE},
|
||||
{"home", T_SECT_HOME},
|
||||
{"code", T_SECT_ROMX}, /* deprecated */
|
||||
{"data", T_SECT_ROMX}, /* deprecated */
|
||||
{"romx", T_SECT_ROMX},
|
||||
{"home", T_SECT_ROM0}, /* deprecated */
|
||||
{"rom0", T_SECT_ROM0},
|
||||
{"hram", T_SECT_HRAM},
|
||||
{"wramx", T_SECT_WRAMX},
|
||||
{"sram", T_SECT_SRAM},
|
||||
|
||||
@@ -252,8 +252,8 @@ writesection(struct Section * pSect, FILE * f)
|
||||
fputlong(pSect->nBank, f);
|
||||
//RGB1 addition
|
||||
|
||||
if ((pSect->nType == SECT_HOME)
|
||||
|| (pSect->nType == SECT_CODE)) {
|
||||
if ((pSect->nType == SECT_ROM0)
|
||||
|| (pSect->nType == SECT_ROMX)) {
|
||||
struct Patch *pPatch;
|
||||
|
||||
fwrite(pSect->tData, 1, pSect->nPC, f);
|
||||
@@ -504,13 +504,13 @@ void
|
||||
checkcodesection(SLONG size)
|
||||
{
|
||||
checksection();
|
||||
if ((pCurrentSection->nType == SECT_HOME
|
||||
|| pCurrentSection->nType == SECT_CODE)
|
||||
if ((pCurrentSection->nType == SECT_ROM0
|
||||
|| pCurrentSection->nType == SECT_ROMX)
|
||||
&& (pCurrentSection->nPC + size <= MAXSECTIONSIZE)) {
|
||||
if (((pCurrentSection->nPC % SECTIONCHUNK) >
|
||||
((pCurrentSection->nPC + size) % SECTIONCHUNK))
|
||||
&& (pCurrentSection->nType == SECT_HOME
|
||||
|| pCurrentSection->nType == SECT_CODE)) {
|
||||
&& (pCurrentSection->nType == SECT_ROM0
|
||||
|| pCurrentSection->nType == SECT_ROMX)) {
|
||||
if ((pCurrentSection->tData =
|
||||
(UBYTE *) realloc(pCurrentSection->tData,
|
||||
((pCurrentSection->nPC +
|
||||
@@ -725,8 +725,8 @@ void
|
||||
out_Skip(int skip)
|
||||
{
|
||||
checksection();
|
||||
if (!((pCurrentSection->nType == SECT_HOME)
|
||||
|| (pCurrentSection->nType == SECT_CODE))) {
|
||||
if (!((pCurrentSection->nType == SECT_ROM0)
|
||||
|| (pCurrentSection->nType == SECT_ROMX))) {
|
||||
pCurrentSection->nPC += skip;
|
||||
nPC += skip;
|
||||
pPCSymbol->nValue += skip;
|
||||
|
||||
@@ -132,7 +132,7 @@ area_AllocAbsVRAMAnyBank(SLONG org, SLONG size)
|
||||
}
|
||||
|
||||
SLONG
|
||||
area_AllocAbsCODEAnyBank(SLONG org, SLONG size)
|
||||
area_AllocAbsROMXAnyBank(SLONG org, SLONG size)
|
||||
{
|
||||
SLONG i;
|
||||
|
||||
@@ -208,7 +208,7 @@ area_AllocWRAMAnyBank(SLONG size)
|
||||
}
|
||||
|
||||
SLONG
|
||||
area_AllocCODEAnyBank(SLONG size)
|
||||
area_AllocROMXAnyBank(SLONG size)
|
||||
{
|
||||
SLONG i, org;
|
||||
|
||||
@@ -285,7 +285,7 @@ FindLargestCode(void)
|
||||
|
||||
pSection = pSections;
|
||||
while (pSection) {
|
||||
if (pSection->oAssigned == 0 && pSection->Type == SECT_CODE) {
|
||||
if (pSection->oAssigned == 0 && pSection->Type == SECT_ROMX) {
|
||||
if (pSection->nByteSize > nLargest) {
|
||||
nLargest = pSection->nByteSize;
|
||||
r = pSection;
|
||||
@@ -367,14 +367,14 @@ AssignCodeSections(void)
|
||||
while ((pSection = FindLargestCode())) {
|
||||
SLONG org;
|
||||
|
||||
if ((org = area_AllocCODEAnyBank(pSection->nByteSize)) != -1) {
|
||||
if ((org = area_AllocROMXAnyBank(pSection->nByteSize)) != -1) {
|
||||
pSection->nOrg = org & 0xFFFF;
|
||||
pSection->nBank = org >> 16;
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXBANK(pSection->nBank);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unable to place CODE section anywhere\n");
|
||||
"Unable to place ROMX section anywhere\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -425,7 +425,7 @@ AssignSections(void)
|
||||
BankFree[i]->nSize = 0x4000;
|
||||
MaxAvail[i] = 0x4000;
|
||||
}
|
||||
} else if (i == BANK_BSS) {
|
||||
} else if (i == BANK_WRAM0) {
|
||||
/* WRAM */
|
||||
BankFree[i]->nOrg = 0xC000;
|
||||
BankFree[i]->nSize = 0x1000;
|
||||
@@ -468,17 +468,17 @@ AssignSections(void)
|
||||
/* User wants to have a say... */
|
||||
|
||||
switch (pSection->Type) {
|
||||
case SECT_BSS:
|
||||
case SECT_WRAM0:
|
||||
if (area_AllocAbs
|
||||
(&BankFree[BANK_BSS], pSection->nOrg,
|
||||
(&BankFree[BANK_WRAM0], pSection->nOrg,
|
||||
pSection->nByteSize) != pSection->nOrg) {
|
||||
fprintf(stderr,
|
||||
"Unable to load fixed BSS section "
|
||||
"Unable to load fixed WRAM0 section "
|
||||
"at $%lX\n", pSection->nOrg);
|
||||
exit(1);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
pSection->nBank = BANK_BSS;
|
||||
pSection->nBank = BANK_WRAM0;
|
||||
break;
|
||||
case SECT_HRAM:
|
||||
if (area_AllocAbs
|
||||
@@ -651,19 +651,19 @@ AssignSections(void)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SECT_HOME:
|
||||
case SECT_ROM0:
|
||||
if (area_AllocAbs
|
||||
(&BankFree[BANK_HOME], pSection->nOrg,
|
||||
(&BankFree[BANK_ROM0], pSection->nOrg,
|
||||
pSection->nByteSize) != pSection->nOrg) {
|
||||
fprintf(stderr, "Unable to load fixed "
|
||||
"HOME section at $%lX\n",
|
||||
"ROM0 section at $%lX\n",
|
||||
pSection->nOrg);
|
||||
exit(1);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
pSection->nBank = BANK_HOME;
|
||||
pSection->nBank = BANK_ROM0;
|
||||
break;
|
||||
case SECT_CODE:
|
||||
case SECT_ROMX:
|
||||
if (pSection->nBank == -1) {
|
||||
/*
|
||||
* User doesn't care which bank, so he must want to
|
||||
@@ -703,14 +703,14 @@ AssignSections(void)
|
||||
pSection->
|
||||
nByteSize) !=
|
||||
pSection->nOrg) {
|
||||
fprintf(stderr, "Unable to load fixed CODE/DATA section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
fprintf(stderr, "Unable to load fixed ROMX section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
exit(1);
|
||||
}
|
||||
DOMAXBANK(pSection->
|
||||
nBank);
|
||||
pSection->oAssigned = 1;
|
||||
} else {
|
||||
fprintf(stderr, "Unable to load fixed CODE/DATA section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
fprintf(stderr, "Unable to load fixed ROMX section at $%lX in bank $%02lX\n", pSection->nOrg, pSection->nBank);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -723,27 +723,27 @@ AssignSections(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Next, let's assign all the bankfixed ONLY CODE sections...
|
||||
* Next, let's assign all the bankfixed ONLY ROMX sections...
|
||||
*
|
||||
*/
|
||||
|
||||
pSection = pSections;
|
||||
while (pSection) {
|
||||
if (pSection->oAssigned == 0
|
||||
&& pSection->Type == SECT_CODE
|
||||
&& pSection->Type == SECT_ROMX
|
||||
&& pSection->nOrg == -1 && pSection->nBank != -1) {
|
||||
/* User wants to have a say... and he's pissed */
|
||||
if (pSection->nBank >= 1 && pSection->nBank <= 511) {
|
||||
if ((pSection->nOrg =
|
||||
area_Alloc(&BankFree[pSection->nBank],
|
||||
pSection->nByteSize)) == -1) {
|
||||
fprintf(stderr, "Unable to load fixed CODE/DATA section into bank $%02lX\n", pSection->nBank);
|
||||
fprintf(stderr, "Unable to load fixed ROMX section into bank $%02lX\n", pSection->nBank);
|
||||
exit(1);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
DOMAXBANK(pSection->nBank);
|
||||
} else {
|
||||
fprintf(stderr, "Unable to load fixed CODE/DATA section into bank $%02lX\n", pSection->nBank);
|
||||
fprintf(stderr, "Unable to load fixed ROMX section into bank $%02lX\n", pSection->nBank);
|
||||
exit(1);
|
||||
}
|
||||
} else if (pSection->oAssigned == 0
|
||||
@@ -805,22 +805,22 @@ AssignSections(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Now, let's assign all the floating bank but fixed CODE sections...
|
||||
* Now, let's assign all the floating bank but fixed ROMX sections...
|
||||
*
|
||||
*/
|
||||
|
||||
pSection = pSections;
|
||||
while (pSection) {
|
||||
if (pSection->oAssigned == 0
|
||||
&& pSection->Type == SECT_CODE
|
||||
&& pSection->Type == SECT_ROMX
|
||||
&& pSection->nOrg != -1 && pSection->nBank == -1) {
|
||||
/* User wants to have a say... and he's back with a
|
||||
* vengeance */
|
||||
if ((pSection->nBank =
|
||||
area_AllocAbsCODEAnyBank(pSection->nOrg,
|
||||
area_AllocAbsROMXAnyBank(pSection->nOrg,
|
||||
pSection->nByteSize)) ==
|
||||
-1) {
|
||||
fprintf(stderr, "Unable to load fixed CODE/DATA section at $%lX into any bank\n", pSection->nOrg);
|
||||
fprintf(stderr, "Unable to load fixed ROMX section at $%lX into any bank\n", pSection->nOrg);
|
||||
exit(1);
|
||||
}
|
||||
pSection->oAssigned = 1;
|
||||
@@ -881,14 +881,14 @@ AssignSections(void)
|
||||
while (pSection) {
|
||||
if (pSection->oAssigned == 0) {
|
||||
switch (pSection->Type) {
|
||||
case SECT_BSS:
|
||||
case SECT_WRAM0:
|
||||
if ((pSection->nOrg =
|
||||
area_Alloc(&BankFree[BANK_BSS],
|
||||
area_Alloc(&BankFree[BANK_WRAM0],
|
||||
pSection->nByteSize)) == -1) {
|
||||
fprintf(stderr, "BSS section too large\n");
|
||||
fprintf(stderr, "WRAM0 section too large\n");
|
||||
exit(1);
|
||||
}
|
||||
pSection->nBank = BANK_BSS;
|
||||
pSection->nBank = BANK_WRAM0;
|
||||
pSection->oAssigned = 1;
|
||||
break;
|
||||
case SECT_HRAM:
|
||||
@@ -907,17 +907,17 @@ AssignSections(void)
|
||||
break;
|
||||
case SECT_WRAMX:
|
||||
break;
|
||||
case SECT_HOME:
|
||||
case SECT_ROM0:
|
||||
if ((pSection->nOrg =
|
||||
area_Alloc(&BankFree[BANK_HOME],
|
||||
area_Alloc(&BankFree[BANK_ROM0],
|
||||
pSection->nByteSize)) == -1) {
|
||||
fprintf(stderr, "HOME section too large\n");
|
||||
fprintf(stderr, "ROM0 section too large\n");
|
||||
exit(1);
|
||||
}
|
||||
pSection->nBank = BANK_HOME;
|
||||
pSection->nBank = BANK_ROM0;
|
||||
pSection->oAssigned = 1;
|
||||
break;
|
||||
case SECT_CODE:
|
||||
case SECT_ROMX:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "(INTERNAL) Unknown section type!\n");
|
||||
|
||||
@@ -59,10 +59,10 @@ MapfileInitBank(SLONG bank)
|
||||
currentbank = bank;
|
||||
if (bank == 0)
|
||||
fprintf(mf, "Bank #0 (HOME):\n");
|
||||
else if (bank < BANK_BSS)
|
||||
else if (bank < BANK_WRAM0)
|
||||
fprintf(mf, "Bank #%ld:\n", bank);
|
||||
else if (bank == BANK_BSS)
|
||||
fprintf(mf, "BSS:\n");
|
||||
else if (bank == BANK_WRAM0)
|
||||
fprintf(mf, "WRAM0:\n");
|
||||
else if (bank == BANK_HRAM)
|
||||
fprintf(mf, "HRAM:\n");
|
||||
else if (bank == BANK_VRAM || bank == BANK_VRAM + 1)
|
||||
|
||||
@@ -139,10 +139,10 @@ obj_ReadRGB0Section(FILE * f)
|
||||
|
||||
/* does the user want the -s mode? */
|
||||
|
||||
if ((options & OPT_SMALL) && (pSection->Type == SECT_CODE)) {
|
||||
pSection->Type = SECT_HOME;
|
||||
if ((options & OPT_SMALL) && (pSection->Type == SECT_ROMX)) {
|
||||
pSection->Type = SECT_ROM0;
|
||||
}
|
||||
if ((pSection->Type == SECT_CODE) || (pSection->Type == SECT_HOME)) {
|
||||
if ((pSection->Type == SECT_ROMX) || (pSection->Type == SECT_ROM0)) {
|
||||
/*
|
||||
* These sectiontypes contain data...
|
||||
*
|
||||
@@ -294,10 +294,10 @@ obj_ReadRGB1Section(FILE * f)
|
||||
|
||||
/* does the user want the -s mode? */
|
||||
|
||||
if ((options & OPT_SMALL) && (pSection->Type == SECT_CODE)) {
|
||||
pSection->Type = SECT_HOME;
|
||||
if ((options & OPT_SMALL) && (pSection->Type == SECT_ROMX)) {
|
||||
pSection->Type = SECT_ROM0;
|
||||
}
|
||||
if ((pSection->Type == SECT_CODE) || (pSection->Type == SECT_HOME)) {
|
||||
if ((pSection->Type == SECT_ROMX) || (pSection->Type == SECT_ROM0)) {
|
||||
/*
|
||||
* These sectiontypes contain data...
|
||||
*
|
||||
|
||||
@@ -16,16 +16,16 @@ writehome(FILE * f)
|
||||
struct sSection *pSect;
|
||||
UBYTE *mem;
|
||||
|
||||
mem = malloc(MaxAvail[BANK_HOME]);
|
||||
mem = malloc(MaxAvail[BANK_ROM0]);
|
||||
if (!mem)
|
||||
return;
|
||||
|
||||
memset(mem, fillchar, MaxAvail[BANK_HOME]);
|
||||
memset(mem, fillchar, MaxAvail[BANK_ROM0]);
|
||||
MapfileInitBank(0);
|
||||
|
||||
pSect = pSections;
|
||||
while (pSect) {
|
||||
if (pSect->Type == SECT_HOME) {
|
||||
if (pSect->Type == SECT_ROM0) {
|
||||
memcpy(mem + pSect->nOrg, pSect->pData,
|
||||
pSect->nByteSize);
|
||||
MapfileWriteSection(pSect);
|
||||
@@ -35,7 +35,7 @@ writehome(FILE * f)
|
||||
|
||||
MapfileCloseBank(area_Avail(0));
|
||||
|
||||
fwrite(mem, 1, MaxAvail[BANK_HOME], f);
|
||||
fwrite(mem, 1, MaxAvail[BANK_ROM0], f);
|
||||
free(mem);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ writebank(FILE * f, SLONG bank)
|
||||
|
||||
pSect = pSections;
|
||||
while (pSect) {
|
||||
if (pSect->Type == SECT_CODE && pSect->nBank == bank) {
|
||||
if (pSect->Type == SECT_ROMX && pSect->nBank == bank) {
|
||||
memcpy(mem + pSect->nOrg - 0x4000, pSect->pData,
|
||||
pSect->nByteSize);
|
||||
MapfileWriteSection(pSect);
|
||||
|
||||
@@ -21,8 +21,8 @@ program links objects created by
|
||||
.Xr rgbasm 1
|
||||
into a single Game Boy ROM file.
|
||||
.Pp
|
||||
By default, HOME sections created by the assembler are placed in the 16KiB
|
||||
bank 0, and CODE/DATA sections are placed in any bank except bank 0.
|
||||
By default, ROM0 sections created by the assembler are placed in the 16KiB
|
||||
bank 0, and ROMX sections are placed in any bank except bank 0.
|
||||
If your ROM will only be 32KiB, you can use the
|
||||
.Fl t
|
||||
option to override this.
|
||||
@@ -50,7 +50,7 @@ The default is 0x00.
|
||||
Write a tiny
|
||||
.Pq 32KiB
|
||||
ROM file.
|
||||
This forces all DATA/CODE sections to be of type HOME, and increases the HOME
|
||||
This forces all ROMX sections to be of type ROM0, and increases the ROM0
|
||||
section size from 16KiB to 32KiB.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
|
||||
Reference in New Issue
Block a user