ref: f3635416112b6444c0f1dd53744a72b3e05c9c19
parent: fa1fba7fd9f61197ee7b94a5aa4b949237c7ecbc
author: ISSOtm <eldredhabert0@gmail.com>
date: Mon Jan 27 05:06:17 EST 2020
Introduce revision number field
--- a/include/linkdefs.h
+++ b/include/linkdefs.h
@@ -14,6 +14,7 @@
#define RGBDS_OBJECT_VERSION_STRING "RGB%1hhu"
#define RGBDS_OBJECT_VERSION_NUMBER (uint8_t)9
+#define RGBDS_OBJECT_REV 0
enum RPNCommand {
RPN_ADD = 0x00,
--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -542,6 +542,7 @@
fatalerror("Couldn't write file '%s'\n", tzObjectname);
fprintf(f, RGBDS_OBJECT_VERSION_STRING, RGBDS_OBJECT_VERSION_NUMBER);
+ fputlong(RGBDS_OBJECT_REV, f);
fputlong(countsymbols(), f);
fputlong(countsections(), f);
--- a/src/link/object.c
+++ b/src/link/object.c
@@ -340,6 +340,14 @@
*/
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 nbSections;
@@ -434,10 +442,8 @@
{
FILE *file = strcmp("-", fileName) ? fopen(fileName, "rb") : stdin;
- if (!file) {
+ if (!file)
err(1, "Could not open file %s", fileName);
- return;
- }
/* Begin by reading the magic bytes and version number */
uint8_t versionNumber;
@@ -450,7 +456,7 @@
verbosePrint("Reading object file %s, version %hhu\n",
fileName, versionNumber);
- if (versionNumber != 7)
+ if (versionNumber != RGBDS_OBJECT_VERSION_NUMBER)
errx(1, "\"%s\" is an incompatible version %hhu object file",
fileName, versionNumber);