mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-22 19:22:05 +00:00
Redefine consistent names for section types, and document the changes.
This commit is contained in:
@@ -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