ref: 82cf3eb48f72e94c4dc346a5ee8f4a1b01ad8e56
parent: 4f86a1253940f8f866413a2095ae3b21598d6b6f
parent: 3dcfe2b9f647dba25fdc1c3490073c5f4d20be61
author: AntonioND <[email protected]>
date: Sat Mar 11 07:18:40 EST 2017
Merge pull request #134 from Ben10do/oam-sections Add support for OAM Sections
--- a/include/asm/mylink.h
+++ b/include/asm/mylink.h
@@ -101,7 +101,8 @@
SECT_ROM0,
SECT_HRAM,
SECT_WRAMX,
- SECT_SRAM
+ SECT_SRAM,
+ SECT_OAM
};
enum {
--- a/include/link/assign.h
+++ b/include/link/assign.h
@@ -3,16 +3,6 @@
#include "types.h"
-enum eBankDefine {
- BANK_ROM0 = 0,
- BANK_ROMX,
- BANK_WRAM0 = 512,
- BANK_WRAMX,
- BANK_VRAM = 520,
- BANK_HRAM = 522,
- BANK_SRAM = 523
-};
-
enum eBankCount {
BANK_COUNT_ROM0 = 1,
BANK_COUNT_ROMX = 511,
@@ -19,12 +9,24 @@
BANK_COUNT_WRAM0 = 1,
BANK_COUNT_WRAMX = 7,
BANK_COUNT_VRAM = 2,
+ BANK_COUNT_OAM = 1,
BANK_COUNT_HRAM = 1,
BANK_COUNT_SRAM = 16
};
+enum eBankDefine {
+ BANK_ROM0 = 0,
+ BANK_ROMX = BANK_ROM0 + BANK_COUNT_ROM0,
+ BANK_WRAM0 = BANK_ROMX + BANK_COUNT_ROMX,
+ BANK_WRAMX = BANK_WRAM0 + BANK_COUNT_WRAM0,
+ BANK_VRAM = BANK_WRAMX + BANK_COUNT_WRAMX,
+ BANK_OAM = BANK_VRAM + BANK_COUNT_VRAM,
+ BANK_HRAM = BANK_OAM + BANK_COUNT_OAM,
+ BANK_SRAM = BANK_HRAM + BANK_COUNT_HRAM
+};
+
#define MAXBANKS (BANK_COUNT_ROM0 + BANK_COUNT_ROMX + BANK_COUNT_WRAM0 + BANK_COUNT_WRAMX \
- + BANK_COUNT_VRAM + BANK_COUNT_HRAM + BANK_COUNT_SRAM)
+ + BANK_COUNT_VRAM + BANK_COUNT_OAM + BANK_COUNT_HRAM + BANK_COUNT_SRAM)
extern SLONG area_Avail(SLONG bank);
extern void AssignSections(void);
--- a/include/link/mylink.h
+++ b/include/link/mylink.h
@@ -57,7 +57,8 @@
SECT_ROM0,
SECT_HRAM,
SECT_WRAMX,
- SECT_SRAM
+ SECT_SRAM,
+ SECT_OAM
};
struct sSection {
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -513,7 +513,7 @@
%token T_POP_POPO
%token T_POP_PUSHO
%token T_POP_OPT
-%token T_SECT_WRAM0 T_SECT_VRAM T_SECT_ROMX T_SECT_ROM0 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 T_SECT_OAM
%token T_Z80_ADC T_Z80_ADD T_Z80_AND
%token T_Z80_BIT
@@ -1146,6 +1146,7 @@
| T_SECT_HRAM { $$=SECT_HRAM; }
| T_SECT_WRAMX { $$=SECT_WRAMX; }
| T_SECT_SRAM { $$=SECT_SRAM; }
+ | T_SECT_OAM { $$=SECT_OAM; }
;
--- a/src/asm/globlex.c
+++ b/src/asm/globlex.c
@@ -342,6 +342,7 @@
{"hram", T_SECT_HRAM},
{"wramx", T_SECT_WRAMX},
{"sram", T_SECT_SRAM},
+ {"oam", T_SECT_OAM},
{NAME_RB, T_POP_RB},
{NAME_RW, T_POP_RW},
--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -491,7 +491,7 @@
struct PatchSymbol *pSym;
struct Section *pSect;
- fwrite("RGB3", 1, 4, f);
+ fwrite("RGB4", 1, 4, f);
fputlong(countsymbols(), f);
fputlong(countsections(), f);
--- a/src/link/assign.c
+++ b/src/link/assign.c
@@ -30,7 +30,7 @@
SLONG MaxVBankUsed;
const enum eSectionType SECT_MIN = SECT_WRAM0;
-const enum eSectionType SECT_MAX = SECT_SRAM;
+const enum eSectionType SECT_MAX = SECT_OAM;
const struct sSectionAttributes SECT_ATTRIBUTES[] = {
{"WRAM0", BANK_WRAM0, 0, 0, BANK_COUNT_WRAM0},
{"VRAM", BANK_VRAM, 0, 0, BANK_COUNT_VRAM},
@@ -38,7 +38,8 @@
{"ROM0", BANK_ROM0, 0, 0, BANK_COUNT_ROM0},
{"HRAM", BANK_HRAM, 0, 0, BANK_COUNT_HRAM},
{"WRAMX", BANK_WRAMX, 0, 0, BANK_COUNT_WRAMX},
- {"SRAM", BANK_SRAM, 0, 0, BANK_COUNT_SRAM}
+ {"SRAM", BANK_SRAM, 0, 0, BANK_COUNT_SRAM},
+ {"OAM", BANK_OAM, 0, 0, BANK_COUNT_OAM}
};
#define DOMAXBANK(x, y) {switch (x) { \
@@ -326,6 +327,9 @@
/* Swappable VRAM bank */
BankFree[i]->nOrg = 0x8000;
BankFree[i]->nSize = 0x2000;
+ } else if (i == BANK_OAM) {
+ BankFree[i]->nOrg = 0xFE00;
+ BankFree[i]->nSize = 0x00A0;
} else if (i == BANK_HRAM) {
/* HRAM */
BankFree[i]->nOrg = 0xFF80;
@@ -355,6 +359,7 @@
case SECT_WRAM0:
case SECT_HRAM:
case SECT_ROM0:
+ case SECT_OAM:
pSection->nBank = SECT_ATTRIBUTES[pSection->Type].bank;
if (area_AllocAbs(&BankFree[pSection->nBank], pSection->nOrg,
pSection->nByteSize) == -1) {
--- a/src/link/mapfile.c
+++ b/src/link/mapfile.c
@@ -65,6 +65,8 @@
fprintf(mf, "HRAM:\n");
else if (bank == BANK_VRAM || bank == BANK_VRAM + 1)
fprintf(mf, "VRAM Bank #%ld:\n", bank - BANK_VRAM);
+ else if (bank == BANK_OAM)
+ fprintf(mf, "OAM:\n");
else if (bank < MAXBANKS)
fprintf(mf, "SRAM Bank #%ld:\n", bank - BANK_SRAM);
}
@@ -79,6 +81,8 @@
sfbank = 0;
else if (bank == BANK_VRAM || bank == BANK_VRAM + 1)
sfbank = bank - BANK_VRAM;
+ else if (bank == BANK_OAM)
+ sfbank = 0;
else if (bank < MAXBANKS)
sfbank = bank - BANK_SRAM;
else
--- a/src/link/object.c
+++ b/src/link/object.c
@@ -446,8 +446,8 @@
//V2 is really the same but the are new patch types
obj_ReadRGB(pObjfile, 0);
break;
- case '3':
- // V3 is very similiar, but contains section names and byte alignment
+ case '3': // V3 is very similiar, but contains section names and byte alignment
+ case '4': // V4 supports OAM sections, but is otherwise identical
obj_ReadRGB(pObjfile, CONTAINS_SECTION_NAME | CONTAINS_SECTION_ALIGNMENT);
break;
default:
--- a/src/link/patch.c
+++ b/src/link/patch.c
@@ -68,12 +68,12 @@
errx(1, "*INTERNAL* UNKNOWN SYMBOL TYPE");
}
- if (nBank == BANK_WRAM0) return 0;
- if (nBank >= BANK_WRAMX && nBank <= (BANK_WRAMX+6))
+ if (nBank == BANK_WRAM0 || nBank == BANK_OAM) return 0;
+ if (nBank >= BANK_WRAMX && nBank < (BANK_WRAMX + BANK_COUNT_WRAMX))
return nBank - BANK_WRAMX + 1;
- if (nBank >= BANK_VRAM && nBank <= (BANK_VRAM+1))
+ if (nBank >= BANK_VRAM && nBank < (BANK_VRAM + BANK_COUNT_VRAM))
return nBank - BANK_VRAM;
- if (nBank >= BANK_SRAM && nBank <= (BANK_SRAM+3))
+ if (nBank >= BANK_SRAM && nBank < (BANK_SRAM + BANK_COUNT_SRAM))
return nBank - BANK_SRAM;
return nBank;