GLK: ALAN3: Change header version field from char[4] to byte[4]

This commit is contained in:
Paul Gilbert 2019-06-28 19:48:56 -07:00
parent 5c8c4b3b6e
commit 395174301b
7 changed files with 24 additions and 24 deletions

View File

@ -505,7 +505,7 @@ struct DictionaryEntry { /* Dictionary */
struct ACodeHeader {
/* Important info */
char tag[4]; /* "ALAN" */
char version[4]; /* Version of compiler */
byte version[4]; /* Version of compiler */
Aword uid; /* Unique id of the compiled game */
Aword size; /* Size of ACD-file in Awords */
/* Options */
@ -562,7 +562,7 @@ struct ACodeHeader {
struct Pre3_0beta2Header {
/* Important info */
char tag[4]; /* "ALAN" */
char version[4]; /* Version of compiler */
byte version[4]; /* Version of compiler */
Aword uid; /* Unique id of the compiled game */
Aword size; /* Size of ACD-file in Awords */
/* Options */
@ -618,7 +618,7 @@ struct Pre3_0beta2Header {
struct Pre3_0alpha5Header {
/* Important info */
char tag[4]; /* "ALAN" */
char version[4]; /* Version of compiler */
byte version[4]; /* Version of compiler */
Aword uid; /* Unique id of the compiled game */
Aword size; /* Size of ACD-file in Awords */
/* Options */

View File

@ -26,42 +26,42 @@ namespace Glk {
namespace Alan3 {
/*----------------------------------------------------------------------*/
static bool is3_0Alpha(char version[]) {
static bool is3_0Alpha(const byte version[]) {
return version[3] == 3 && version[2] == 0 && version[0] == 'a';
}
/*----------------------------------------------------------------------*/
static bool is3_0Beta(char version[]) {
static bool is3_0Beta(const byte version[]) {
return version[3] == 3 && version[2] == 0 && version[0] == 'b';
}
/*----------------------------------------------------------------------*/
static int correction(char version[]) {
static int correction(const byte version[]) {
return version[1];
}
/*======================================================================*/
bool isPreAlpha5(char version[4]) {
bool isPreAlpha5(const byte version[4]) {
return is3_0Alpha(version) && correction(version) < 5;
}
/*======================================================================*/
bool isPreBeta2(char version[4]) {
bool isPreBeta2(const byte version[4]) {
return is3_0Alpha(version) || (is3_0Beta(version) && correction(version) == 1);
}
/*======================================================================*/
bool isPreBeta3(char version[4]) {
bool isPreBeta3(const byte version[4]) {
return is3_0Alpha(version) || (is3_0Beta(version) && correction(version) <= 2);
}
/*======================================================================*/
bool isPreBeta4(char version[4]) {
bool isPreBeta4(const byte version[4]) {
return is3_0Alpha(version) || (is3_0Beta(version) && correction(version) <= 3);
}
/*======================================================================*/
bool isPreBeta5(char version[4]) {
bool isPreBeta5(const byte version[4]) {
return is3_0Alpha(version) || (is3_0Beta(version) && correction(version) <= 4);
}

View File

@ -29,12 +29,12 @@ namespace Glk {
namespace Alan3 {
/* FUNCTIONS: */
extern bool isPreAlpha5(char version[4]);
extern bool isPreBeta2(char version[4]);
extern bool isPreBeta3(char version[4]);
extern bool isPreBeta4(char version[4]);
extern bool isPreBeta5(char version[4]);
extern char *decodedGameVersion(char version[]);
extern bool isPreAlpha5(const byte version[4]);
extern bool isPreBeta2(const byte version[4]);
extern bool isPreBeta3(const byte version[4]);
extern bool isPreBeta4(const byte version[4]);
extern bool isPreBeta5(const byte version[4]);
extern char *decodedGameVersion(const byte version[]);
} // End of namespace Alan3
} // End of namespace Glk

View File

@ -120,7 +120,7 @@ Common::SeekableReadStream *codfil;
be compatible. If header size changes this should return beta2
header size for later versions.
*/
static int crcStart(char version[4]) {
static int crcStart(const byte version[4]) {
/* Some earlier versions had a shorter header */
if (isPreAlpha5(version))
return sizeof(Pre3_0alpha5Header) / sizeof(Aword);
@ -229,7 +229,7 @@ static const char *decodeState(int c) {
}
/*======================================================================*/
char *decodedGameVersion(char version[]) {
char *decodedGameVersion(const byte version[]) {
static char str[100];
sprintf(str, "%d.%d%s%d",
(int)version[3],
@ -278,7 +278,7 @@ static void alphaRunningLaterGame(char gameState) {
}
/*----------------------------------------------------------------------*/
static void nonDevelopmentRunningDevelopmentStateGame(char version[]) {
static void nonDevelopmentRunningDevelopmentStateGame(const byte version[]) {
char errorMessage[200];
char versionString[100];

View File

@ -368,7 +368,7 @@ static void reverseSyntaxTablePreBeta2(Aword adr) {
}
static void reverseSyntaxTable(Aword adr, char version[]) {
static void reverseSyntaxTable(Aword adr, byte version[]) {
if (!adr || alreadyDone(adr)) return;
if (isPreBeta2(version))
@ -634,7 +634,7 @@ static void reverseNative() {
*/
void reverseACD(void) {
ACodeHeader *hdr = (ACodeHeader *)memory;
char version[4];
byte version[4];
int i;
/* Make a copy of the version marking to reverse */

View File

@ -243,7 +243,7 @@ void evaluateRules(RuleEntry ruleList[]) {
/*=======================================================================*/
void resetAndEvaluateRules(RuleEntry ruleList[], char *version) {
void resetAndEvaluateRules(RuleEntry ruleList[], const byte *version) {
if (isPreBeta2(version))
evaluateRulesPreBeta2();
else if (isPreBeta3(version))

View File

@ -36,7 +36,7 @@ extern bool anyRuleRun; /* Did any rule run? */
/* FUNCTIONS */
extern void initRules(Aaddr rulesTableAddress);
extern void resetAndEvaluateRules(RuleEntry rules[], char *version);
extern void resetAndEvaluateRules(RuleEntry rules[], const byte *version);
extern void resetRules(void);
extern void evaluateRules(RuleEntry rules[]);