Contiguous WRAM

This commit is contained in:
scnorton
2017-02-06 16:11:17 -05:00
parent 5ee058f217
commit 6d1c60b0a6
3 changed files with 28 additions and 13 deletions

View File

@@ -10,6 +10,7 @@
extern SLONG options; extern SLONG options;
#define OPT_SMALL 0x01 #define OPT_SMALL 0x01
#define OPT_SMART_C_LINK 0x02 #define OPT_SMART_C_LINK 0x02
#define OPT_CONTWRAM 0x04
enum eRpnData { enum eRpnData {
RPN_ADD = 0, RPN_ADD = 0,

View File

@@ -60,7 +60,7 @@ ensureSectionTypeIsValid(enum eSectionType type)
} }
} }
SLONG SLONG
area_Avail(SLONG bank) area_Avail(SLONG bank)
{ {
SLONG r; SLONG r;
@@ -131,7 +131,7 @@ area_AllocAbsAnyBank(SLONG org, SLONG size, enum eSectionType type)
SLONG startBank = SECT_ATTRIBUTES[type].bank; SLONG startBank = SECT_ATTRIBUTES[type].bank;
SLONG bankCount = SECT_ATTRIBUTES[type].bankCount; SLONG bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) { for (int i = 0; i < bankCount; i++) {
if (area_AllocAbs(&BankFree[startBank + i], org, size) != -1) { if (area_AllocAbs(&BankFree[startBank + i], org, size) != -1) {
return startBank + i; return startBank + i;
@@ -141,7 +141,7 @@ area_AllocAbsAnyBank(SLONG org, SLONG size, enum eSectionType type)
return -1; return -1;
} }
SLONG SLONG
area_Alloc(struct sFreeArea ** ppArea, SLONG size) area_Alloc(struct sFreeArea ** ppArea, SLONG size)
{ {
struct sFreeArea *pArea; struct sFreeArea *pArea;
@@ -170,7 +170,7 @@ area_AllocAnyBank(SLONG size, enum eSectionType type) {
SLONG startBank = SECT_ATTRIBUTES[type].bank; SLONG startBank = SECT_ATTRIBUTES[type].bank;
SLONG bankCount = SECT_ATTRIBUTES[type].bankCount; SLONG bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) { for (int i = 0; i < bankCount; i++) {
SLONG org = area_Alloc(&BankFree[startBank + i], size); SLONG org = area_Alloc(&BankFree[startBank + i], size);
if (org != -1) { if (org != -1) {
@@ -231,7 +231,7 @@ VerifyAndSetBank(struct sSection *pSection)
&& pSection->nBank < SECT_ATTRIBUTES[pSection->Type].minBank + SECT_ATTRIBUTES[pSection->Type].bankCount) { && pSection->nBank < SECT_ATTRIBUTES[pSection->Type].minBank + SECT_ATTRIBUTES[pSection->Type].bankCount) {
pSection->nBank += SECT_ATTRIBUTES[pSection->Type].bank + SECT_ATTRIBUTES[pSection->Type].offset; pSection->nBank += SECT_ATTRIBUTES[pSection->Type].bank + SECT_ATTRIBUTES[pSection->Type].offset;
return true; return true;
} else { } else {
return false; return false;
} }
@@ -280,7 +280,11 @@ AssignSections(void)
} else if (i == BANK_WRAM0) { } else if (i == BANK_WRAM0) {
/* WRAM */ /* WRAM */
BankFree[i]->nOrg = 0xC000; BankFree[i]->nOrg = 0xC000;
BankFree[i]->nSize = 0x1000; if (options & OPT_CONTWRAM) {
BankFree[i]->nSize = 0x2000;
} else {
BankFree[i]->nSize = 0x1000;
}
} else if (i >= BANK_SRAM && i < BANK_SRAM + BANK_COUNT_SRAM) { } else if (i >= BANK_SRAM && i < BANK_SRAM + BANK_COUNT_SRAM) {
/* Swappable SRAM bank */ /* Swappable SRAM bank */
BankFree[i]->nOrg = 0xA000; BankFree[i]->nOrg = 0xA000;
@@ -300,7 +304,7 @@ AssignSections(void)
} else { } else {
errx(1, "(INTERNAL) Unknown bank type!"); errx(1, "(INTERNAL) Unknown bank type!");
} }
MaxAvail[i] = BankFree[i]->nSize; MaxAvail[i] = BankFree[i]->nSize;
BankFree[i]->pPrev = NULL; BankFree[i]->pPrev = NULL;
BankFree[i]->pNext = NULL; BankFree[i]->pNext = NULL;
@@ -318,6 +322,10 @@ AssignSections(void)
&& pSection->oAssigned == 0) { && pSection->oAssigned == 0) {
/* User wants to have a say... */ /* User wants to have a say... */
if (pSection->Type == SECT_WRAMX && options & OPT_CONTWRAM) {
errx(1, "WRAMX not compatible with -w!");
}
switch (pSection->Type) { switch (pSection->Type) {
case SECT_WRAM0: case SECT_WRAM0:
case SECT_HRAM: case SECT_HRAM:
@@ -407,7 +415,7 @@ AssignSections(void)
pSection->oAssigned = 1; pSection->oAssigned = 1;
DOMAXBANK(pSection->Type, pSection->nBank); DOMAXBANK(pSection->Type, pSection->nBank);
break; break;
default: // Handle other sections later default: // Handle other sections later
break; break;
} }
@@ -458,7 +466,7 @@ AssignSections(void)
AssignBankedSections(SECT_SRAM); AssignBankedSections(SECT_SRAM);
} }
void void
CreateSymbolTable(void) CreateSymbolTable(void)
{ {
struct sSection *pSect; struct sSection *pSect;

View File

@@ -31,11 +31,11 @@ char *progname;
* *
*/ */
static void static void
usage(void) usage(void)
{ {
printf( printf(
"usage: rgblink [-t] [-m mapfile] [-n symfile] [-o outfile] [-p pad_value]\n" "usage: rgblink [-tw] [-m mapfile] [-n symfile] [-o outfile] [-p pad_value]\n"
" [-s symbol] file [...]\n"); " [-s symbol] file [...]\n");
exit(1); exit(1);
} }
@@ -45,7 +45,7 @@ usage(void)
* *
*/ */
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int ch; int ch;
@@ -56,7 +56,7 @@ main(int argc, char *argv[])
progname = argv[0]; progname = argv[0];
while ((ch = getopt(argc, argv, "m:n:o:p:s:t")) != -1) { while ((ch = getopt(argc, argv, "m:n:o:p:s:t:w")) != -1) {
switch (ch) { switch (ch) {
case 'm': case 'm':
SetMapfileName(optarg); SetMapfileName(optarg);
@@ -84,6 +84,12 @@ main(int argc, char *argv[])
case 't': case 't':
options |= OPT_SMALL; options |= OPT_SMALL;
break; 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;
break;
default: default:
usage(); usage();
/* NOTREACHED */ /* NOTREACHED */