From 5fe3a0adb6f1a2d44d6c94a785a3cdb5df50f5d3 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Mon, 13 Apr 2020 17:15:00 +0200 Subject: [PATCH] Remove non-OPT options from `Options` struct --- include/asm/main.h | 9 ++++----- src/asm/asmy.y | 10 +++++----- src/asm/fstack.c | 2 +- src/asm/main.c | 30 +++++++++++++++++------------- src/asm/output.c | 2 +- src/asm/warning.c | 2 +- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/asm/main.h b/include/asm/main.h index bf396ddd..1ef1aa1e 100644 --- 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 uint32_t curOffset; /* Offset into the current section */ 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; diff --git a/src/asm/asmy.y b/src/asm/asmy.y index b7df86cc..c3ab1954 100644 --- a/src/asm/asmy.y +++ b/src/asm/asmy.y @@ -1618,7 +1618,7 @@ z80_ei : T_Z80_EI { out_AbsByte(0xFB); } z80_halt : T_Z80_HALT { out_AbsByte(0x76); - if (CurrentOptions.haltnop) + if (haltnop) out_AbsByte(0x00); } ; @@ -1718,8 +1718,8 @@ z80_ld_mem : T_Z80_LD op_mem_ind ',' T_MODE_SP { 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 @@ z80_ld_a : T_Z80_LD reg_r ',' T_MODE_C_IND { } | 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); diff --git a/src/asm/fstack.c b/src/asm/fstack.c index e00ebf99..3ebfe51c 100644 --- a/src/asm/fstack.c +++ b/src/asm/fstack.c @@ -434,7 +434,7 @@ void fstk_RunInclude(char *tzFileName) 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); diff --git a/src/asm/main.c b/src/asm/main.c index 4b94e5f2..daaadafc 100644 --- a/src/asm/main.c +++ b/src/asm/main.c @@ -63,6 +63,10 @@ char *tzTargetFileName; 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 @@ int main(int argc, char *argv[]) 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 @@ int main(int argc, char *argv[]) opt_AddDefine(optarg); break; case 'E': - newopt.exportall = true; + exportall = true; break; case 'g': if (strlen(optarg) == 4) { @@ -399,13 +403,13 @@ int main(int argc, char *argv[]) } 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 @@ int main(int argc, char *argv[]) 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 @@ int main(int argc, char *argv[]) setup_lexer(); - if (CurrentOptions.verbose) + if (verbose) printf("Assembling %s\n", tzMainfile); if (dependfile) { @@ -528,7 +532,7 @@ int main(int argc, char *argv[]) skipElif = true; nUnionDepth = 0; sym_Init(); - sym_SetExportAll(CurrentOptions.exportall); + sym_SetExportAll(exportall); fstk_Init(tzMainfile); opt_ParseDefines(); charmap_InitMain(); @@ -554,7 +558,7 @@ int main(int argc, char *argv[]) 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) diff --git a/src/asm/output.c b/src/asm/output.c index fc1b906e..646efb9f 100644 --- a/src/asm/output.c +++ b/src/asm/output.c @@ -416,6 +416,6 @@ void out_WriteObject(void) void out_SetFileName(char *s) { tzObjectname = s; - if (CurrentOptions.verbose) + if (verbose) printf("Output filename %s\n", s); } diff --git a/src/asm/warning.c b/src/asm/warning.c index fe8fb2c7..4ee419a3 100644 --- a/src/asm/warning.c +++ b/src/asm/warning.c @@ -48,7 +48,7 @@ static bool warningsAreErrors; /* Set if `-Werror` was specified */ 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 */