Thanks!
Originally posted by JackTheSpadesNo seriously, if everything in this works as intended, making tools could be a bit easier with asar.dll ^^'
I sure hope it does! I honestly forgot to test a few of the features as much as I probably should have, such as the "written blocks" API. I did test it for a bit and it seemed to work as intended (espcially the "sorting ROM writes into banks" part), though I'm not sure if it works as intended in 100% of cases. Anyways, that's why my post exists in the first place. If something broke from my changes, I hope someone will notice it soon enough.
Originally posted by JackTheSpadesThough I don't know what problem you had with C#. I've used it before and never ran into any trouble with it?
Well, it's possible that the exception it threw wasn't harmful at all and only appeared in debug builds (and even then only when enabling certain debug settings). In my case, the exception was thrown when calling Asar.patch(), I think. I think the exception mentioned a stack imbalance or something like that. In any case, adding the C calling convention as an attribute to each function made the exception disappear completely, so I suppose it's better and safer like that.
Originally posted by JackTheSpadesSpeaking of tools, think you could add a way of adding defines via CLI/API? Similiar to gccs -D flag
Originally posted by gcc-D name
Predefine name as a macro, with definition 1.
-D name=definition
I forgot the exact syntax, but iirc asar has a way of checking for labels, so this could allow tools (or batch files) to use 1 asm file in multiple variations.
One way you could potentially solve this now already would be to include your patch from another file and then pass that file's path to Asar. Something like this:
Code; settings1.main:
!define1=0
!define2=0
incsrc actual_patch.asm
Code; settings2.main:
!define1=1
!define2=2
incsrc actual_patch.asm
Code; actual_patch.asm
!define1 ?= -1
!define2 ?= -1
if !define1 <= 0 || !define2 <= 0
error "Some defines are not set - are you trying to patch actual_patch.asm directly?"
endif
if !define1 == 0
; Do something
else
; Do something else
endif
if !define2 == 0
; Do something
elseif !define2 == 1
; Do something else
else
; Do something entirely different
endif
Code> asar.exe settings1.main output_rom.smc
Or if you absolutely need this behavior dynamically, you could just let your application create a text file in the Windows temp folder and then pass the path to that text file to Asar.
Anyways, for now, I'm not planning to add any more new features to Asar (although I'll still try to fix all bugs introduced in v1.40 or v1.50 if people report any). Back then, I really only started on v1.40 because there were a few features I absolutely wanted to have in Asar for a patch of mine. Then, when people suggested new features for v1.50, I wanted to do them a favor and try to add all these features. After that, I quickly lost motivation, though, which is why progress has been lying dormant for a couple of months on the new version. This shows me that it's probably better to leave it at that, so I decided to quickly finish this version some time ago so that I could finally move on (or rather move back to the patch that orignally made me start implementing new features).
Anyways, the source code of Asar is, of course, publicly available, and this feature in particular sounds like it would be quite easy to implement (I think you really only have to modify a global array containing the defines). So maybe someone else can give it a try?

Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!