
Originally posted by WhiteYoshiEgg
And while I'm at it, @Alcaro: you once mentioned you had discontinued Asar and dislike the way you coded it back then. Just out of curiosity, would you mind explaining what you'd do differently today?
As RPG Hacker said, it's a fucking mess.
To make a good program, you need to either know how the finished product should look before starting (and act on that, rather than taking a dozen 'good enough for now' shortcuts), or be willing to rewrite half of it. Naturally, I did neither, so it became a wall of crap.
A good architecture for this thing would be multiple passes, where each pass simplifies the internal representation. Replacing freecode with org, evaluating defines/if/incsrc/etc, replacing sublabels with non-namespaced ones, etc. (Not in that order, of course.)
Instead, Asar parses the entire thing thrice, with each pass gathering only the minimal information needed by the next pass; the first pass finds label freespace IDs and approximate freespace sizes, the second pass assigns freespaces and finds label locations, and only the third pass is kept.
Naturally, I've had about 999999999999999999999 different bugs where the passes don't assemble things the same way. For example:
- if read3(random address that's also written by the patch)
- labels are treated as 0 in the first pass; 'if label' will take different branches between passes
- not resetting defines between passes, so ?= takes the other branch
- letting pass-1 labels leak, like this guy
- to ensure errors aren't ignored nor repeated, they all know which pass they should be in, and are silent in other passes - but still set the 'errors happened, not writing rom' flag. Guess what happened when I divided by a label? (No, I don't remember what I was doing when I found that.)
- that's not the only phantom error I've fixed, I've had so many I had to give them a name
- check my changelogs in this thread if you need more
(In my defense, xkas did it exactly the same way, I just copied its architecture. Along with about forty other braindead things. Like the macro/define split - they're both text replacement, they should be replaced with something that can represent both features. Instead, I created a third kind!)
Originally posted by RPG Hacker
I'll take a stab it at later and then probably bump the version to 1.41.
Perhaps jump straight to 1.42, so we don't get two tools (Sprite Tool) at 1.41. It could be slightly confusing.
<blm> zsnes users are the flatearthers of emulation