Skip to content

Commit

Permalink
Update RGBDS to 0.9.0 (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
SelvinPL authored Jan 9, 2025
1 parent e8c2145 commit f1646cd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 36 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<ul>
<li id="infomenu">Info...</li>
<li>
<a href="https://rgbds.gbdev.io/docs/v0.8.0" target="_blank">rgbds manual</a>
<a href="https://rgbds.gbdev.io/docs/v0.9.0" target="_blank">rgbds manual</a>
</li>
<li>
<a href="https://github.com/gbdev/rgbds-live/issues" target="_blank">Report a problem</a>
Expand Down
73 changes: 39 additions & 34 deletions patches/rgbds.patch
Original file line number Diff line number Diff line change
@@ -1,55 +1,60 @@
diff --git a/include/asm/symbol.hpp b/include/asm/symbol.hpp
index 409e2ba5..58b78ba0 100644
--- a/include/asm/symbol.hpp
+++ b/include/asm/symbol.hpp
@@ -100,4 +100,6 @@ void sym_Init(time_t now);
std::optional<std::string> const &sym_GetCurrentSymbolScope();
void sym_SetCurrentSymbolScope(std::optional<std::string> const &newScope);

+Symbol *sym_AddSecret();
+
#endif // RGBDS_ASM_SYMBOL_HPP
diff --git a/src/asm/parser.y b/src/asm/parser.y
index 55044bfc..94ec183d 100644
index 437c6afa..61be7ae4 100644
--- a/src/asm/parser.y
+++ b/src/asm/parser.y
@@ -429,7 +429,9 @@ else:
@@ -86,7 +86,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 };
@@ -503,7 +503,7 @@ else:

plain_directive:
label
- | label cpu_commands
+ | label {
+ sym_AddSecret();
+ } cpu_commands
+ | label { sym_AddSecret(); } cpu_commands
| label macro
| label directive
;
diff --git a/src/asm/symbol.cpp b/src/asm/symbol.cpp
index 8d803a39..be108ae8 100644
index 1ae86aba..3ed2dcd4 100644
--- a/src/asm/symbol.cpp
+++ b/src/asm/symbol.cpp
@@ -597,3 +597,24 @@ void sym_Init(time_t now) {
@@ -669,3 +669,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;
}
+
+static uint32_t secret_counter = 0;
+Symbol *sym_AddSecret() {
+ Symbol *sym;
+ char name[256];
+ secret_counter += 1;
+ std::shared_ptr<FileStackNode> fstk = fstk_GetFileStack();
+ while(fstk->type == NODE_REPT) {
+ fstk = fstk->parent;
+ }
+ sprintf(name, "__SEC_%x_%x_%s", secret_counter, lexer_GetLineNo(), fstk->name().c_str());
+ 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();
+
+ sym = &createSymbol(name);
+ sym->type = SYM_LABEL;
+ sym->data = (int32_t)sect_GetSymbolOffset();
+ sym->isExported = true;
+ sym->section = sect_GetSymbolSection();
+ 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;
+ updateSymbolFilename(*sym);
+ return sym;
+}
2 changes: 1 addition & 1 deletion rgbds
Submodule rgbds updated 514 files

0 comments on commit f1646cd

Please sign in to comment.