Group extern RGBASM variables in an Options struct

This commit is contained in:
Rangi42
2025-07-21 19:01:23 -04:00
parent d652212857
commit d1493a9f96
18 changed files with 133 additions and 156 deletions

View File

@@ -5,9 +5,6 @@
#include <stdint.h>
extern uint8_t fixPrecision;
uint8_t fix_Precision();
int32_t fix_Sin(int32_t i, int32_t q);
int32_t fix_Cos(int32_t i, int32_t q);
int32_t fix_Tan(int32_t i, int32_t q);

View File

@@ -47,8 +47,6 @@ struct FileStackNode {
std::string reptChain() const;
};
extern size_t maxRecursionDepth;
struct MacroArgs;
bool fstk_DumpCurrent();

View File

@@ -116,9 +116,6 @@ struct LexerState {
void clear(uint32_t lineNo_);
};
extern char binDigits[2];
extern char gfxDigits[4];
void lexer_SetBinDigits(char const digits[2]);
void lexer_SetGfxDigits(char const digits[4]);

View File

@@ -3,28 +3,51 @@
#ifndef RGBDS_ASM_MAIN_HPP
#define RGBDS_ASM_MAIN_HPP
#include <stdint.h>
#include <stdio.h>
#include <string>
extern bool verbose;
#define verbosePrint(...) \
do { \
if (verbose) { \
fprintf(stderr, __VA_ARGS__); \
} \
} while (0)
enum MissingInclude {
INC_ERROR, // A missing included file is an error that halts assembly
GEN_EXIT, // A missing included file is assumed to be generated; exit normally
GEN_CONTINUE, // A missing included file is assumed to be generated; continue assembling
};
extern FILE *dependFile;
extern std::string targetFileName;
extern MissingInclude missingIncludeState;
extern bool generatePhonyDeps;
struct Options {
uint8_t fixPrecision = 16; // -Q
size_t maxRecursionDepth; // -r
char binDigits[2] = {'0', '1'}; // -b
char gfxDigits[4] = {'0', '1', '2', '3'}; // -g
bool verbose = false; // -v
FILE *dependFile = nullptr; // -M
std::string targetFileName; // -MQ, -MT
MissingInclude missingIncludeState = INC_ERROR; // -MC, -MG
bool generatePhonyDeps = false; // -MP
std::string objectFileName; // -o
uint8_t padByte = 0; // -p
unsigned int maxErrors = 0; // -X
~Options() {
if (dependFile) {
fclose(dependFile);
}
}
void printDep(std::string const &depName) {
if (dependFile) {
fprintf(dependFile, "%s: %s\n", targetFileName.c_str(), depName.c_str());
}
}
};
extern Options options;
extern bool failedOnMissingInclude;
#define verbosePrint(...) \
do { \
if (options.verbose) { \
fprintf(stderr, __VA_ARGS__); \
} \
} while (0)
#endif // RGBDS_ASM_MAIN_HPP

View File

@@ -5,10 +5,10 @@
#include <stdint.h>
void opt_B(char const chars[2]);
void opt_G(char const chars[4]);
void opt_B(char const binDigits[2]);
void opt_G(char const gfxDigits[4]);
void opt_P(uint8_t padByte);
void opt_Q(uint8_t precision);
void opt_Q(uint8_t fixPrecision);
void opt_W(char const *flag);
void opt_Parse(char const *option);

View File

@@ -16,8 +16,6 @@ struct FileStackNode;
enum StateFeature { STATE_EQU, STATE_VAR, STATE_EQUS, STATE_CHAR, STATE_MACRO, NB_STATE_FEATURES };
extern std::string objectFileName;
void out_RegisterNode(std::shared_ptr<FileStackNode> node);
void out_SetFileName(std::string const &name);
void out_CreatePatch(uint32_t type, Expression const &expr, uint32_t ofs, uint32_t pcShift);

View File

@@ -12,8 +12,6 @@
#include "linkdefs.hpp"
extern uint8_t fillByte;
struct Expression;
struct FileStackNode;
struct Section;

View File

@@ -7,7 +7,7 @@
#include "diagnostics.hpp"
extern unsigned int nbErrors, maxErrors;
extern unsigned int nbErrors;
enum WarningLevel {
LEVEL_DEFAULT, // Warnings that are enabled by default