Language…
13 users online:  AmperSam, dotCoockie, Golden Yoshi, Hayashi Neru, jirok1, JPhanto, Mario's GameBase,  MarioFanGamer, MorrieTheMagpie, Rykon-V73, Sparkz314, timothy726, toady - Guests: 250 - Bots: 288
Users: 64,795 (2,377 active)
Latest user: mathew

asar-tc: asar for toolchain use (and more)

https://github.com/zetaPRIME/asar-tc

This is a fork of asar with some additional features (and fixes) useful as part of a ROMhacking toolchain (and probably elsewhere.)

Fixes and features so far:
- Defines are now evaluated in numeric comparisons so it doesn't just spit "invalid number" at you
+ import <file>: includes a file from a specified directory (default ./lib/) relative to the ROM; assumes .asm if no extension given
+ assertdef <define>: if define doesn't exist, create it with value 0 (useful for checking for flags set by macros/libraries)
+ undef <define>: deletes a define

(precompiled binaries coming soon)
Originally posted by JVyrn
- Defines are now evaluated in numeric comparisons so it doesn't just spit "invalid number" at you

When would that be possible to trigger? 'Numeric comparisons' sounds like stuff like 'if', and those commands run after expanding the defines. Please post a code that triggers that bug.

Quote
+ assertdef <define>: if define doesn't exist, create it with value 0 (useful for checking for flags set by macros/libraries)

Well that's a pointless limitation.

And your desired feature exists already. Without hardcoded zeroes, and with a syntax I feel is more natural. (Apparently I forgot documenting it.)

!a = $42
!a ?= $33
db !a

Also existing (all of those end with !a = 42):
!a = 42 : !a := !a (evaluates defines in the target value; without the colon, !a becomes !a, which is an infinite loop to evaluate)
!a = 4 : !a += 2 (same as :=, but prepends the original)
!a = 40 : !a #= !a+2 (evaluates the input as math, then stringifies it)
...and I forgot writing them down in the documentation, apparently.
<blm> zsnes users are the flatearthers of emulation
Originally posted by Alcaro
Originally posted by JVyrn
- Defines are now evaluated in numeric comparisons so it doesn't just spit "invalid number" at you

When would that be possible to trigger? 'Numeric comparisons' sounds like stuff like 'if', and those commands run after expanding the defines. Please post a code that triggers that bug.


http://puu.sh/mMDV3/f9fea6aa49.txt
The "elseif !_LIB_VERSION_<name> < <version>" was throwing invalid-number for no apparent reason and now it isn't, so...
Looks like elseif doesn't parse defines. Probably since it's seen as being inside the previous if statement and Asar doesn't want to throw errors from code that's not being assembled.

The math parser is a quite weird place to fix it (it fits better in the elseif handler, run the define expander again or something), but it works, so it works.

Except when it doesn't. Try this code with your patch:
!x = 1
!y = x
print "!{!y}"
if 0
elseif !{!y}
print "1"
endif
<blm> zsnes users are the flatearthers of emulation
...huh. right. *pokes at code*

edit: fixed properly this time! ...I think