Language…
8 users online:  bebn legg, Blaagon, Cote de Boeuf, Heitor Porfirio, karls_Corinthia, Konaoto, yoshi9429, Zavok - Guests: 42 - Bots: 79
Users: 57,945 (2,499 active)
Latest user: karls_Corinthia

Asar: Under new management

Originally posted by Alcaro
A freespace finder for the unexpanded area is a good idea in theory, but dangerous in practice. First, I'm not sure how well RATS tags work in the unexpanded area, I think LM gets angry if you try. Second, unexpanded freespace is FF FF FF FF, and many tables are terminated by one or more FFs; there's no way to know whether this one FF is used or not.


I wasn't strictly speaking about the area used by SMW but more in general to have bank control over freespace. Admitting, it could pose a problem in those areas if you're unlucky enough to run into a freespace area following an $FF terminated table.

Originally posted by Alcaro
Please don't. While it is indeed slightly inconvenient, it is highly intentional: It makes two of four un/headered sfc/smc combinations highly inconvenient, leaving the extension as an accurate indicator of whether it's headered. I consider this worth the minor inconvenience.

Except people don't know this and Lunar Magic will force a header anyway. Most newbies will just download a ROM and open it with Lunar Magic first, see it works and not question it further.
Not to mention any faulty files already flying around the internet as is.


Also, something else I forgot, hand in hand with the bank thing maybe to be able to use identifiers to split freespace sections. I remember this from VLDC9 where it was managing multiple patches by just having a huge incsrc file, thus also wasting some bytes on repeated freespace search. What I mean is something along these lines:

Code
;applied file
	incsrc "file 1.asm"
	incsrc "file 2.asm"

;file 1
	org $xxxxxx
		autoclean JML hi1
	freespace group(1)
		hi1:
		;code

;file 2
	org $xxxxxx
		autoclean JML hi2
	freespace group(1)
		hi2:
		;code


Asar would try to append the code of freesoace in file 2 after file 1.
Anime statistic on MyAnimeList:
400 animes completed ✓
6000 episodes completed ✓
100 Days completed ✓
... what even am I doing with my life?
Originally posted by JackTheSpades
Except people don't know this and Lunar Magic will force a header anyway. Most newbies will just download a ROM and open it with Lunar Magic first, see it works and not question it further.
Not to mention any faulty files already flying around the internet as is.

That should be fixed in LM, not worked around in unrelated tools. Mandatory headers were a good idea a few years ago, but their utility has decreased drastically recently, to the point where it's actively harmful these days.

Rewording the error or making Asar auto-rename the ROM is a good idea, as long as said faulty files are loudly labeled as such.

Quote
Also, something else I forgot, hand in hand with the bank thing maybe to be able to use identifiers to split freespace sections. I remember this from VLDC9 where it was managing multiple patches by just having a huge incsrc file, thus also wasting some bytes on repeated freespace search. What I mean is something along these lines:

Code
;applied file
	freespace
	incsrc "file 1.asm"
	incsrc "file 2.asm"

;file 1
	pushpc
	org $xxxxxx
		autoclean JML hi1
	pullpc
		hi1:
		;code

;file 2
	pushpc
	org $xxxxxx
		autoclean JML hi2
	pullpc
		hi2:
		;code

It's slightly less flexible than your proposal, but I don't think the added flexibility has any practical applications.
<blm> zsnes users are the flatearthers of emulation
Originally posted by Alcaro
--code--

Until you try to separate code and data blocks.

Also, if I had to guess, Lunar Magic might be using hardcoded hijacks. Thus making all of them work on either ROM might just be a lot of work and error prone anyway.

Personally, I could also live with asar, uppon finding a faulty ROM name, just checks the total file size % 0x400 == 0x200 and prints a message about .smc and .sfc file naming if needed. Eg. something like:

Your ROM name is .- .-.. -.-. .- .-. --- which sounds wrong.
Given the filesize, this probably should be an .smc file. Try renaming it.
Anime statistic on MyAnimeList:
400 animes completed ✓
6000 episodes completed ✓
100 Days completed ✓
... what even am I doing with my life?
Originally posted by JackTheSpades
Originally posted by Alcaro
--code--

Until you try to separate code and data blocks.

Okay, you're right, that is a valid usecase. But still rare, I'm not sure if it's worth caring about.

If yes, probably best implemented via some variant of pushpc (switchpc?), rather than numbering the freespace regions; easier to move things around.

Quote
Also, if I had to guess, Lunar Magic might be using hardcoded hijacks. Thus making all of them work on either ROM might just be a lot of work and error prone anyway.

Judging by the number of PC addresses in the manual, that's likely.

But it's all code, it's fixable. I'd be happy to fix it myself if I could. You know what I mean, FuSoYa.

Quote
Personally, I could also live with asar, uppon finding a faulty ROM name, just checks the total file size % 0x400 == 0x200

I've seen 0x8000 and 0x1000, I use the former myself. Feels safer if some idiot uses a 0x400 byte header, or something.

But no big deal, do whatever.

Quote
and prints a message about .smc and .sfc file naming if needed. Eg. something like:

Your ROM name is .- .-.. -.-. .- .-. --- which sounds wrong.
Given the filesize, this probably should be an .smc file. Try renaming it.

Asar does suggest snespurify, but that one hasn't really existed for the last couple of years. Replacing that would indeed be an improvement.

And the 'abort?' question should probably be hardcoded to false, at least unless its extension matches the filesize.
<blm> zsnes users are the flatearthers of emulation
Hey, I've got a question. How feasible would it be to allow using math when defining a start and endpoint in the incbin command? I'm trying to create a setup for something I'm working on that allows asar to insert data from a file where the location of the data can vary. Specifically, I'm trying to get asar to read some bytes in an mwl file and then have asar use those bytes to determine where it should look in the mwl when it goes to insert its data. I can't just incbin the mwl, because there is a bunch of non-level data throughout the mwl that I don't want inserted.

If that isn't feasible, then is there a workaround that would give the same results besides just manually defining the start and endpoints for each incbin?
My Hacks:
Mario's Strange Quest V1.6
Yoshi's Strange Quest V1.3 / V1.3.1 Beta 4.6
Mario & Yoshi's Strange Quests (7/8/2022 Build)

Other stuff:
My SMW/SMAS/SMAS+W disassembly
Yoshifanatic's Discord Server: A place for fans of my stuff and/or Yoshi to chat with others.
This might be possible with some hardcore macro abuse, though I'm not sure. If so, it would certainly be tricky.

A simpler workaround: I think you should be able to get the desired result by just using while loops coupled with the #= define operator. This only works if defines can be passed to functions, but if I remember correctly, they can. Instead of using incbin to include a huge block of data all at once, you would basically use a while loop and include single bytes of data repeatedly. The caveat is that this might be slower, though I'm not even sure about that and even if it is, it's probably neglectible.

So in theory, you should be able to do something like this (in pseudo-code, since out of my head I'm not sure if the syntax and function names are correct):

Code
!offset #= readfile3("infile.mwl", 0)
!num_bytes #= readfile3("infile.mwl", 3)

while !num_bytes > 0
	!byte = readfile1("infile.mwl", !offset)
	db !byte
	!offset #= !offset+1
	!num_bytes #= !num_bytes-1
endif


So basically, I would give that a try.

I agree that having such functionality natively would be quite useful, though. Don't know how easy it would be to rewrite the incbin command for that. It might be somewhat messy and require some amount of work.
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
I just gave your suggestion a try and it works. Thanks RPGHacker! :)

Edit: It turns out that it's actually possible to use math with the incbin command, albeit indirectly, thanks to the #= operator. However, even with that, it still doesn't quite work because, unless I was doing something wrong, asar seems to get confused whether it's handling decimal or hexadecimal numbers.

If I do this and the result of the readfile3's are $00C0 and $0117:
Code
!start #= readfile2("MWLs/Level_000.mwl",72)+$0008
!end #= readfile2("MWLs/Level_000.mwl",80)-$0008

incbin "MWLs/Level_000.mwl":!start-!end


Asar will start reading from $0200 and stop at $0271 during the incbin, instead of at $00C8-$010F.

I think I'd prefer to use incbin for what I'm trying to do rather than a while loop, because doing it the latter way is much slower.


Also, unrelated, but I'm 99.9% sure that asar crashes if it attempts to open more than 16 files through the readfile command. I know that is says in the changelog that asar will keep up to 16 files open when using readfile, but I would have expected asar to just close the oldest file it opened so it can open up the new file.
My Hacks:
Mario's Strange Quest V1.6
Yoshi's Strange Quest V1.3 / V1.3.1 Beta 4.6
Mario & Yoshi's Strange Quests (7/8/2022 Build)

Other stuff:
My SMW/SMAS/SMAS+W disassembly
Yoshifanatic's Discord Server: A place for fans of my stuff and/or Yoshi to chat with others.
Late reply, but I've just recently seen your edit, yoshifanatic. Don't know if it's still relevant to you or if you'll even see this in the first place, but I'll try to explain what was happening there, anyways.

$00C0 in decimal is 192 and $0117 in decimal is 279. If you add and subtract the $0008, respectively, you end up with 200 and 271 in decimal. I guess the #= operator resolves defines to decimal numbers internally. Now when you do the incbin, all asar does with the defines is replaced the strings with their current values, 200 and 271. Since incbin (as stated in the manual) actually requires hexadecimal numbers to work, it interprets those decimal numbers as hexadecimal, so you get the result you're describing here.

Fixing this might be possible, but tricky. Basically, you would need macros which convert decimal numbers in a defines to hexadecimal numbers. So basically, a macro which you pass !start and !end and which converts "200" and "271" to "$00C8" and "$0117" respectively.
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
I'm curious; why is the Asar icon a viking hat? Is it because Asar is related to vikings or something?
My Mode 0 guide.

My Discord server. It has a lot of archived ASM stuff, so check that out!

Yes, it is. The Asar are the viking gods.
<blm> zsnes users are the flatearthers of emulation
Thank you, Alcaro
My Mode 0 guide.

My Discord server. It has a lot of archived ASM stuff, so check that out!

Are you sure structs work? I tried to compile a file with those on it but it's just throwing unknown command.
e: okay my asar dll wasn't updated lmao
Ok so an issue I'm having: I'm trying to use structs like this, however your version of Asar refuses to compile this unless I remove the freespace command. Is there a way to fix this? Else this won't be of much use...
never really worked with structs, so this is more of a blind guess, but try either putting the autoclean dl label before the struct or using pushpc/pullpc. It might mess with the counter.
Anime statistic on MyAnimeList:
400 animes completed ✓
6000 episodes completed ✓
100 Days completed ✓
... what even am I doing with my life?
I actually had to specify the size for them to work. ...as random as it sounds.
You mean the size in the "skip !slots*2"?
I didn't write the code for structs myself, I pretty much just (manually) merged from p4plus2's repository, so I don't know much about how they work, but since Asar doesn't use a preprocessor for its defines and macros, I have already seen it mess up quite badly in a few other places when attempting to use defines, so I wouldn't be surprised if that was the case here.
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
Any chance we could get some sort of pushlabel/pulllabel?
Just to preserve the current label levels.

Code
label_A:
.sublabel1	;label_A_sublabel1

pushlabel
label_B:
.sublabel1	;label_B_sublabel1
pulllabel

..subsub1	;label_A_sublabel1_subsub1
.sublabel2	;label_A_sublabel2


Might be better/easier than macro labels and in combination with incsrc.
Anime statistic on MyAnimeList:
400 animes completed ✓
6000 episodes completed ✓
100 Days completed ✓
... what even am I doing with my life?
I'd rather see macrolabels completely divorced from sublabels.

foo:
JSR .baz
%macro() containing ?bar:
.baz

should attach .baz to foo:, not ?bar:.

I was an idiot when I added macrolabels. Actually, I was an idiot when I followed byuu, who was also an idiot back then.
<blm> zsnes users are the flatearthers of emulation
I'd have to check the source code first to see how easily this is doable.

Anyways, do you have a concrete usage example from a patch or something like that? Is it mainly for macro usage, like in Alcaro's example?
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
Well actually it's mainly for macros.
Practical example would be pixi and GPS' shared routines which on first call create a label and thus can easily mess up any sublabels:

Code
Graphics:
	;stuff
	%GetDrawInfo()
.return		;not sublabel of Graphics
	RTS

Anime statistic on MyAnimeList:
400 animes completed ✓
6000 episodes completed ✓
100 Days completed ✓
... what even am I doing with my life?