-
Notifications
You must be signed in to change notification settings - Fork 2
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
Upgraded GDA syntax #2
base: main
Are you sure you want to change the base?
Conversation
c047f93
to
ccd6749
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a couple comment things I noticed and should be done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aight done! Sorry it took so long, I have a job now (^o^)/
Okay, so I've worked a bit on this. I'm joking, I did A LOT. Basically through my decompilation efforts (which I sadly don't have a good non-DMCA way to share yet) I've learned a lot about GDS, including that it has control flow instructions, an IEEE-754 32-bit float datatype (which the NDS processor doesn't even support! All the operations are implemented in software. And for what? For most of the floats being integers anyway. I'll take "things that solve my problem easier" for 100$, "what are fixed-point floats?") and a bit of other stuff I'll need to look into more. For now, based on these discoveries, which I've tried to collect in two writeups, I've designed and implemented GDA as a DSL for decompiling GDS scripts. The decompiler even has a few bells and whistles, for example it can add comments with helpful context information into the resulting script (the only place I've implemented this for now is textbox scripts displaying the english text corresponding to their event-text ID, but adding this to more commands is just a matter of declaration in the command YAML files). Oh yeah, speaking of. The old Obviously this is a REALLY big one, and I wouldn't be surprised if the review takes longer than the writing. I'm 100% open for questions, mostly asynchronously though (bc job and stuff, and maybe timezones idk) |
… can detect input file type automatically. Added yaml export type, and fixed a few bugs.
TODO: improve the parser to handle jumps and address labels TODO: create the GDA parsing and writing logic
… in the original game scripts, it perfectly decompiles all scripts and reassembles then into the same binaries.
… scripts in a nice format, with indentations too!
…unded to the lowest number of decimal points that still produces identical byte data.
…res changes to tagged-enums)
… GDS files into identical binaries (except patches)
…N/YAML is no longer possible, but also not desirable for a DSL representation.
…iously didn't understand, as well as actual parameter lengths
So as I mentioned, my intention was to create a human-readable script-like format, where each command in a GDS script is listed with a human-readable name (and possibly named parameters) that could be de- and recompiled from and to GDS. Turns out that's exactly what GDA was. I'm not sure why the code implies this format is old or legacy stuff or sth, but it seems very useful, so this PR beefs it up a bit. If there's a defined GDA standard out there I couldn't find it, and so my modifications probably would't follow it.
Here's what I did:
decompile
a GDS file into a GDA script, and renamed/changed helpstrings for the other gds commands (specifically, JSON isn't considered the main format anymore)data/commands.json
) can be used, along withcmd_{decimal number}
(TODO: maybe prefer the latter in decompilations, or let the user choose). Unrecognized commands in user-written GDA scripts can't be mapped to numerical command codes, and thus still throw an error. It's possible to map different names to the same code using analias
property; for example to update a name in later versions, or if a code is just used for multiple purposes (support for this in decompilation is TODO, could e.g. show possible alternative command meanings in a comment above the line)!5(0xABCD)
(parens with payload only in case where the type supports it). This syntax was chosen instead of a keyword, to allow for parameter names to be documented and inserted as named parameter for user information later.In my opinion the ultimate goals of this component should be, in this order:
To this end I've also extended the format used by
commands.json
to include command & params documentation (potentially usable by automated tools, or a gui!) and added a few commands that I could figure out at a glance. This could definitely be further improved: