Merge pull request #1 from ksherlock/rezflag

add -r flag to generate rez file
This commit is contained in:
Jeremy Rand 2021-05-05 23:28:12 -04:00 committed by GitHub
commit e7cef1bfca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View File

@ -26,7 +26,6 @@
// This enables a workaround for creating the resources by writing a .rez file rather than // This enables a workaround for creating the resources by writing a .rez file rather than
// writing it directly. At the moment, Golden Gate does not support writing resources // writing it directly. At the moment, Golden Gate does not support writing resources
// but this will let me test it without that capability. // but this will let me test it without that capability.
#define RESOURCE_WORKAROUND
#define TEACH_FILE_TYPE 0x50 #define TEACH_FILE_TYPE 0x50
#define TEACH_AUX_TYPE 0x5445 #define TEACH_AUX_TYPE 0x5445
@ -159,7 +158,6 @@ MD_SIZE outputPos(void)
static int writeResources(void) static int writeResources(void)
{ {
int result = 0; int result = 0;
#ifndef RESOURCE_WORKAROUND
int shutdownResources = 0; int shutdownResources = 0;
Word writeResId; Word writeResId;
Word oldResId; Word oldResId;
@ -216,7 +214,14 @@ error:
if (shutdownResources) if (shutdownResources)
ResourceShutDown(); ResourceShutDown();
#else
return result;
}
static int writeRez(void)
{
int result = 0;
FILE * rezFile; FILE * rezFile;
uint8_t * ptr; uint8_t * ptr;
uint32_t size; uint32_t size;
@ -279,7 +284,6 @@ error:
"\n"); "\n");
fclose(rezFile); fclose(rezFile);
#endif
return result; return result;
} }
@ -295,7 +299,7 @@ int closeOutputFile(void)
closeRec.refNum = writeRec.refNum; closeRec.refNum = writeRec.refNum;
CloseGS(&closeRec); CloseGS(&closeRec);
return writeResources(); return generateRez ? writeRez() : writeResources();
} }

View File

@ -36,13 +36,14 @@
char * commandName; char * commandName;
int debugEnabled = 0; int debugEnabled = 0;
int debugIndentLevel = 0; int debugIndentLevel = 0;
int generateRez = 0;
// Implementation // Implementation
static void printUsage(void) static void printUsage(void)
{ {
fprintf(stderr, "USAGE: %s [ -d ] inputfile outputfile\n", commandName); fprintf(stderr, "USAGE: %s [ -d -r ] inputfile outputfile\n", commandName);
} }
@ -64,6 +65,9 @@ static int parseArgs(int argc, char * argv[])
case 'd': case 'd':
debugEnabled = 1; debugEnabled = 1;
break; break;
case 'r':
generateRez = 1;
break;
default: default:
printUsage(); printUsage();

View File

@ -13,6 +13,6 @@
extern char * commandName; extern char * commandName;
extern int debugEnabled; extern int debugEnabled;
extern int debugIndentLevel; extern int debugIndentLevel;
extern int generateRez;
#endif /* main_h */ #endif /* main_h */