Introduce revision number field

This commit is contained in:
ISSOtm
2020-01-27 10:06:17 +01:00
parent fa1fba7fd9
commit f363541611
3 changed files with 12 additions and 4 deletions

View File

@@ -14,6 +14,7 @@
#define RGBDS_OBJECT_VERSION_STRING "RGB%1hhu" #define RGBDS_OBJECT_VERSION_STRING "RGB%1hhu"
#define RGBDS_OBJECT_VERSION_NUMBER (uint8_t)9 #define RGBDS_OBJECT_VERSION_NUMBER (uint8_t)9
#define RGBDS_OBJECT_REV 0
enum RPNCommand { enum RPNCommand {
RPN_ADD = 0x00, RPN_ADD = 0x00,

View File

@@ -542,6 +542,7 @@ void out_WriteObject(void)
fatalerror("Couldn't write file '%s'\n", tzObjectname); fatalerror("Couldn't write file '%s'\n", tzObjectname);
fprintf(f, RGBDS_OBJECT_VERSION_STRING, RGBDS_OBJECT_VERSION_NUMBER); fprintf(f, RGBDS_OBJECT_VERSION_STRING, RGBDS_OBJECT_VERSION_NUMBER);
fputlong(RGBDS_OBJECT_REV, f);
fputlong(countsymbols(), f); fputlong(countsymbols(), f);
fputlong(countsections(), f); fputlong(countsections(), f);

View File

@@ -340,6 +340,14 @@ static void linkSymToSect(struct Symbol const *symbol, struct Section *section)
*/ */
static void readRGB7File(FILE *file, char const *fileName) static void readRGB7File(FILE *file, char const *fileName)
{ {
uint32_t revNum;
tryReadlong(revNum, file, "%s: Cannot read revision number: %s",
fileName);
if (revNum != RGBDS_OBJECT_REV)
errx(1, "%s is a revision 0x%04x object file, only 0x%04x is supported",
fileName, revNum, RGBDS_OBJECT_REV);
uint32_t nbSymbols; uint32_t nbSymbols;
uint32_t nbSections; uint32_t nbSections;
@@ -434,10 +442,8 @@ void obj_ReadFile(char const *fileName)
{ {
FILE *file = strcmp("-", fileName) ? fopen(fileName, "rb") : stdin; FILE *file = strcmp("-", fileName) ? fopen(fileName, "rb") : stdin;
if (!file) { if (!file)
err(1, "Could not open file %s", fileName); err(1, "Could not open file %s", fileName);
return;
}
/* Begin by reading the magic bytes and version number */ /* Begin by reading the magic bytes and version number */
uint8_t versionNumber; uint8_t versionNumber;
@@ -450,7 +456,7 @@ void obj_ReadFile(char const *fileName)
verbosePrint("Reading object file %s, version %hhu\n", verbosePrint("Reading object file %s, version %hhu\n",
fileName, versionNumber); fileName, versionNumber);
if (versionNumber != 7) if (versionNumber != RGBDS_OBJECT_VERSION_NUMBER)
errx(1, "\"%s\" is an incompatible version %hhu object file", errx(1, "\"%s\" is an incompatible version %hhu object file",
fileName, versionNumber); fileName, versionNumber);