Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RGBDS to 0.9.0 #61

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
SelvinPL marked this conversation as resolved.
Show resolved Hide resolved
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();
+
Rangi42 marked this conversation as resolved.
Show resolved Hide resolved
#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
Loading