shithub: rgbds

Download patch

ref: 5fe3a0adb6f1a2d44d6c94a785a3cdb5df50f5d3
parent: cdb4c5f553ace09bb984fe9546f15f66a1543c36
author: ISSOtm <[email protected]>
date: Mon Apr 13 13:15:00 EDT 2020

Remove non-OPT options from `Options` struct

--- a/include/asm/main.h
+++ b/include/asm/main.h
@@ -18,12 +18,7 @@
 struct sOptions {
 	char binary[2];
 	char gbgfx[4];
-	bool exportall;
 	int32_t fillchar;
-	bool haltnop;
-	bool optimizeloads;
-	bool verbose;
-	bool warnings; /* True to enable warnings, false to disable them. */
 };
 
 extern char *tzNewMacro;
@@ -35,6 +30,10 @@
 
 extern struct sOptions DefaultOptions;
 extern struct sOptions CurrentOptions;
+extern bool haltnop;
+extern bool optimizeloads;
+extern bool verbose;
+extern bool warnings; /* True to enable warnings, false to disable them. */
 
 extern FILE *dependfile;
 extern char *tzTargetFileName;
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -1618,7 +1618,7 @@
 
 z80_halt	: T_Z80_HALT {
 			out_AbsByte(0x76);
-			if (CurrentOptions.haltnop)
+			if (haltnop)
 				out_AbsByte(0x00);
 		}
 ;
@@ -1718,8 +1718,8 @@
 			out_RelWord(&$2);
 		}
 		| T_Z80_LD op_mem_ind ',' T_MODE_A {
-			if (CurrentOptions.optimizeloads &&
-			    (rpn_isKnown(&$2)) && ($2.nVal >= 0xFF00)) {
+			if (optimizeloads && rpn_isKnown(&$2)
+			 && $2.nVal >= 0xFF00) {
 				out_AbsByte(0xE0);
 				out_AbsByte($2.nVal & 0xFF);
 				rpn_Free(&$2);
@@ -1766,8 +1766,8 @@
 		}
 		| T_Z80_LD reg_r ',' op_mem_ind {
 			if ($2 == REG_A) {
-				if (CurrentOptions.optimizeloads &&
-				    (rpn_isKnown(&$4)) && ($4.nVal >= 0xFF00)) {
+				if (optimizeloads && rpn_isKnown(&$4)
+				 && $4.nVal >= 0xFF00) {
 					out_AbsByte(0xF0);
 					out_AbsByte($4.nVal & 0xFF);
 					rpn_Free(&$4);
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -434,7 +434,7 @@
 	nCurrentStatus = STAT_isInclude;
 	snprintf(tzCurrentFileName, sizeof(tzCurrentFileName), "%s%s",
 		 incPathUsed, tzFileName);
-	if (CurrentOptions.verbose)
+	if (verbose)
 		printf("Assembling %s\n", tzCurrentFileName);
 	pCurrentFile = f;
 	CurrentFlexHandle = yy_create_buffer(pCurrentFile);
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -63,6 +63,10 @@
 
 struct sOptions DefaultOptions;
 struct sOptions CurrentOptions;
+bool haltnop;
+bool optimizeloads;
+bool verbose;
+bool warnings; /* True to enable warnings, false to disable them. */
 
 struct sOptionStackEntry {
 	struct sOptions Options;
@@ -360,12 +364,12 @@
 	DefaultOptions.gbgfx[3] = '3';
 	DefaultOptions.binary[0] = '0';
 	DefaultOptions.binary[1] = '1';
-	DefaultOptions.exportall = false;
 	DefaultOptions.fillchar = 0;
-	DefaultOptions.optimizeloads = true;
-	DefaultOptions.haltnop = true;
-	DefaultOptions.verbose = false;
-	DefaultOptions.warnings = true;
+	optimizeloads = true;
+	haltnop = true;
+	verbose = false;
+	warnings = true;
+	bool exportall = false;
 
 	opt_SetCurrentOptions(&DefaultOptions);
 
@@ -386,7 +390,7 @@
 			opt_AddDefine(optarg);
 			break;
 		case 'E':
-			newopt.exportall = true;
+			exportall = true;
 			break;
 		case 'g':
 			if (strlen(optarg) == 4) {
@@ -399,13 +403,13 @@
 			}
 			break;
 		case 'h':
-			newopt.haltnop = false;
+			haltnop = false;
 			break;
 		case 'i':
 			fstk_AddIncludePath(optarg);
 			break;
 		case 'L':
-			newopt.optimizeloads = false;
+			optimizeloads = false;
 			break;
 		case 'M':
 			if (!strcmp("-", optarg))
@@ -439,13 +443,13 @@
 			printf("rgbasm %s\n", get_package_version_string());
 			exit(0);
 		case 'v':
-			newopt.verbose = true;
+			verbose = true;
 			break;
 		case 'W':
 			processWarningFlag(optarg);
 			break;
 		case 'w':
-			newopt.warnings = false;
+			warnings = false;
 			break;
 
 		/* Long-only options */
@@ -510,7 +514,7 @@
 
 	setup_lexer();
 
-	if (CurrentOptions.verbose)
+	if (verbose)
 		printf("Assembling %s\n", tzMainfile);
 
 	if (dependfile) {
@@ -528,7 +532,7 @@
 	skipElif = true;
 	nUnionDepth = 0;
 	sym_Init();
-	sym_SetExportAll(CurrentOptions.exportall);
+	sym_SetExportAll(exportall);
 	fstk_Init(tzMainfile);
 	opt_ParseDefines();
 	charmap_InitMain();
@@ -554,7 +558,7 @@
 	nEndClock = clock();
 	timespent = ((double)(nEndClock - nStartClock))
 		     / (double)CLOCKS_PER_SEC;
-	if (CurrentOptions.verbose) {
+	if (verbose) {
 		printf("Success! %u lines in %d.%02d seconds ", nTotalLines,
 		       (int)timespent, ((int)(timespent * 100.0)) % 100);
 		if (timespent < FLT_MIN_EXP)
--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -416,6 +416,6 @@
 void out_SetFileName(char *s)
 {
 	tzObjectname = s;
-	if (CurrentOptions.verbose)
+	if (verbose)
 		printf("Output filename %s\n", s);
 }
--- a/src/asm/warning.c
+++ b/src/asm/warning.c
@@ -48,7 +48,7 @@
 static enum WarningState warningState(enum WarningID id)
 {
 	/* Check if warnings are globally disabled */
-	if (!CurrentOptions.warnings)
+	if (!warnings)
 		return WARNING_DISABLED;
 
 	/* Get the actual state */