-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrgbds.patch
86 lines (81 loc) · 2.87 KB
/
rgbds.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 24b6d087..302126a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,7 +75,7 @@ endif()
find_program(GIT git)
if(GIT)
- execute_process(COMMAND ${GIT} --git-dir=.git -c safe.directory='*' describe --tags --dirty --always
+ execute_process(COMMAND ${GIT} --git-dir=.git -c safe.directory='*' describe --tags --always
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REV OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
diff --git a/Makefile b/Makefile
index 611b9a54..d68fc410 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@ PNGLDFLAGS := `${PKG_CONFIG} --libs-only-L libpng`
PNGLDLIBS := `${PKG_CONFIG} --libs-only-l libpng`
# Note: if this comes up empty, `version.cpp` will automatically fall back to last release number
-VERSION_STRING := `git --git-dir=.git -c safe.directory='*' describe --tags --dirty --always 2>/dev/null`
+VERSION_STRING := `git --git-dir=.git -c safe.directory='*' describe --tags --always 2>/dev/null`
WARNFLAGS := -Wall -pedantic -Wno-unknown-warning-option -Wno-gnu-zero-variadic-macro-arguments
diff --git a/src/asm/parser.y b/src/asm/parser.y
index 279cd7d9..01c180da 100644
--- a/src/asm/parser.y
+++ b/src/asm/parser.y
@@ -84,7 +84,7 @@
static void compoundAssignment(std::string const &symName, RPNCommand op, int32_t constValue);
static void failAssert(AssertionType type);
static void failAssertMsg(AssertionType type, std::string const &message);
-
+ Symbol *sym_AddSecret();
// The CPU encodes instructions in a logical way, so most instructions actually follow patterns.
// These enums thus help with bit twiddling to compute opcodes.
enum { REG_B, REG_C, REG_D, REG_E, REG_H, REG_L, REG_HL_IND, REG_A };
@@ -502,7 +502,7 @@ else:
plain_directive:
label
- | label cpu_commands
+ | label { sym_AddSecret(); } cpu_commands
| label macro
| label directive
;
diff --git a/src/asm/symbol.cpp b/src/asm/symbol.cpp
index 0d81f331..e420cb2f 100644
--- a/src/asm/symbol.cpp
+++ b/src/asm/symbol.cpp
@@ -698,3 +698,33 @@ void sym_Init(time_t now) {
sym_AddEqu("__UTC_MINUTE__"s, time_utc->tm_min)->isBuiltin = true;
sym_AddEqu("__UTC_SECOND__"s, time_utc->tm_sec)->isBuiltin = true;
}
+
+Symbol *sym_AddSecret() {
+ static uint64_t secretCounter = 1;
+
+ std::shared_ptr<FileStackNode> fstk = fstk_GetFileStack();
+ while (fstk->type == NODE_REPT) {
+ fstk = fstk->parent;
+ }
+
+ char valueBuf[64];
+ snprintf(
+ valueBuf,
+ sizeof(valueBuf),
+ "__SEC_%" PRIx64 "_%" PRIx32 "_",
+ secretCounter++,
+ lexer_GetLineNo()
+ );
+
+ std::string name = valueBuf;
+ name += fstk->name();
+
+ Symbol *sym = &createSymbol(name);
+ sym->type = SYM_LABEL;
+ sym->data = static_cast<int32_t>(sect_GetSymbolOffset());
+ sym->isExported = true;
+ sym->section = sect_GetSymbolSection();
+
+ updateSymbolFilename(*sym);
+ return sym;
+}