Language…
11 users online: 7 up, Abdu, Blaagon, bravetoaster, Cote de Boeuf, karls_Corinthia, katun24, kurtistrydiz, Phyll, Selicre, TokZone - Guests: 61 - Bots: 84
Users: 57,945 (2,499 active)
Latest user: karls_Corinthia

Asar: Under new management

Yeah, it really shouldn't require absolute paths. It it does, that's definitely a bug. I will try to reproduce the problem. I know we had a bug like that at one point, though I thought we had already fixed that. The test suite actually has a test like that which it assembles fine.

However, I have another idea. The test suite always sets an include path when assembling stuff. Maybe it only magically works because of that and doesn't actually work when no include path is set? (I mean it's supposed to be like that for the test suite because of how it works, but it should at least work when trying to assemble any of the tests directly).

Can you you show me what command line you're using to assemble your file? And what is the working directory you're using (or in other words: from where are you launching Asar?). Those could also affect how Asar does stuff.

EDIT:
Apparently the problem is that Asar's path builder doesn't work correctly when passing a relative file to the executable. For example: when your working directory is C:/my_game/asm and you have a file C:/my_game/asm/patch.asm and pass patch.asm to asar.exe, it actually tries to open "asm/patch.asm" instead of "patch.asm" for some reason. When you change your working directory to C:/my_game/ and pass asm/patch.asm to asar.exe, it actually tries to open asm/asm/patch.exe etc. This means that for now, you can work around the problem by passing the full path to the patch to asar.exe (which means you don't have to use a full path in the patch itself). So in this case, you would pass "C:/my_game/asm/patch.asm" to asar.exe.
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
Hopefully fixed it for good this time. Should now work correctly with both, relative and absolute, file paths, whether passed directly to the Asar executable or used in incsrc etc. Want to give it another try?
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
yes, woiks good #smw{:TUP:}
Rounding doesn't seems to work:

Code
;rounding test

!ValueA = 5


math round on

print "testing123...... ", dec(!ValueA/2)


Asar prints “testing123...... 2

Sent a request through PM to RPG Hacker requesting floor, ceiling, and truncate functions.

Another feature request, have round functions in formulaic expressions, for example: Ceiling(!Value/5) when !Value is 1, which causes 1/5 to happen, the result is 0.2, and the ceiling functions maps the value to 1.
Give thanks to RPG hacker for working on Asar.
Rounding affects internal calculations, not the result. You can't put the byte 0.5 in the ROM, can you? print is the only one where non-integral results make sense, so I didn't bother.

You'll find a difference between round on and round off if you print 5/2*2.
<blm> zsnes users are the flatearthers of emulation
As already mentioned in the PM, Asar doesn't actually round numbers, it only converts them to integers (in other words, it truncates them). I think this should actually be mentioned in the manual, but I'm not sure.
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
In 1.60 though it will be proper rounding (see here). This is because an int cast broke really large numbers (so dd $FFFFFFFF would return an incorrect result).

Also I think we should update the first post here to include known issues in asar 1.50 and other stuff that will change in 1.60 so people don't report issues multiple times. Also possibly ask people to request features on github if possible?
I didn't realise it was fixed that way. I don't think we should do that, as it's a behavior change and thus might break compatibility of some patches (even if it may just be very few patches that rely on this behavior). I don't think round is the proper solution here. If anything, the trunc() function should be used there, which should behave more like an int cast (but hopefully without the weirdness).
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
I think I've found a workaround for this issue: use modulo function.

Code
5/2 = 2
5 MOD 2 = 1


If the modulo result is 1, add 1 to the quotient, otherwise leave it be.

But when you do division by other than 2, and want to round, here a successful solution [round(100/3)]:

Code
100/3 = 33
100 MOD 3 = 1


Now check if remainder ≥ half the divisor:

The half-divisor also must round upwards (using the previous 5/2), in this case 1.5 would round up to 2. If the remainder is greater than or equal to 2, increment the quotient.

Here is an example for general usage:

Code
;Round(A/B)
!ValueA	= 100
!ValueB	= 3

!Quotient		= !ValueA/!ValueB
!Remainder		= !ValueA%!ValueB
!HalfDivisorTrunc	= !ValueB/2
!HalfDivisor_Remainder	= !ValueB%2

;Get the halfpoint:
!HalfDivisor		= !HalfDivisorTrunc ;>Defualt as round down
if !HalfDivisor_Remainder == 1
 !HalfDivisor		= !HalfDivisorTrunc+1 ;>increment 1/2 way point
endif

;Round upwards if remainder is greater than/equal to halfpoint:
!RoundedQuotient	= !Quotient
if !Remainder >= !HalfDivisor
 !RoundedQuotient	= !Quotient+1
endif

;!RoundedQuotient should now hold the rounded quotient

print "round testing ", dec(!ValueA),"/",dec(!ValueB),"=",dec(!RoundedQuotient)
;^A test to see if asar did it right.


Edit: Wow, worked first time. This only works with unsigned A and B.

Here is the macro version.
Give thanks to RPG hacker for working on Asar.
Why not just
Code
math round off
print round(100/3, 0)
?
The 0 specifies how many decimal places to keep. In this case we're rounding to nearest integer.
Originally posted by randomdude999
Why not just
Code
math round off
print round(100/3, 0)
?
The 0 specifies how many decimal places to keep. In this case we're rounding to nearest integer.


Code
test.asm:23: error: Unknown variable. [print round(100/3,0)]


Looks like I'm going to do it my own way.
Give thanks to RPG hacker for working on Asar.
I recall print not supporting math correctly. Try:
Code
math round off
!a #= round(100/3, 0)
print "!a"
Actually that's precisely what the dec(), hex() and double() functions are for.

Code
math round off
print double(round(100/3, 0))


Something like this should work.
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
As a sidenote can you document these mathematical functions into the readme? Like it mentions that the mathematical functions are based on C++, and such? Again, just like the notepad++ plugin extension, it’s very obscure.
Give thanks to RPG hacker for working on Asar.
Doing so would be beyond the scope of the manual - they're not something easily explained in a sentence or two. It's best to check Wikipedia or Google for sin(), cos(), tan(), log() etc. For all other occurences where C++ is mentioned (I think I mentioned fmod() somewhere), a simple Google search for "C++ [function name]" should already answer all questions. Don't think it's a good idea for me to include all that in the manual, because not only are those functions rarely needed, I also would do a horrible job at explaining them; there are way better explanations already available out there. Even disregarding all of that, the manual is only meant to give an overview on Asar functionality, not to give short math lessons. Therefore I don't think detailed information on those functions should go into the manual.

Adding a short explanation on the syntax highlighting file sounds reasonable, though. Probably should go into the simple readme that is coming with the next release.

EDIT:
Unless I'm missunderstanding what you meant by "these mathematical functions". If you're talking about round(), double() etc., they're already explained in the manual.
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
Originally posted by RPG Hacker
Actually that's precisely what the dec(), hex() and double() functions are for.

Code
math round off
print double(round(100/3, 0))


Something like this should work.


Still doesn't work:
Code
error: Malformed function call. [print double(round(100/3,0))


You sure you tested this, on version 1.50?
Give thanks to RPG hacker for working on Asar.
print double() seems to be a bit broken, for now just use dec() and hex().
Code
math round off
print dec(round(3/2, 0))
Seems there is a bug with the double() function. Maybe only when not using the optional parameter? It's worth checking out.

Does this version work?

Code
math round off
print double(round(100/3, 0), 5)

Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!
Petition to rename it to float() because it prints floating-point numbers. The name 'double' only makes sense if 'float' is already taken, or if you want to force feed people a dose of C datatypes.

It wouldn't be the first program to call double 'float', Python does that too.
<blm> zsnes users are the flatearthers of emulation
I wouldn't rename it, since it's already in the currently released version (and thus code might use it already), but I could add an alias. Not sure if I want to, I'm not a fan of aliases at all. I also don't think float() is really any more correct than double() here. Maybe more well-known, but it's still a programming/computer science term, so if the only point was to not expose poor ASM coders to C++ terminology, I would go with real() or decimal() instead. Of course the latter one can't be used, since it's already taken by the dec() function, leaving real() as the only option I would consider for an alias, but I doubt I will, it just doesn't strike me as important. I don't think anyone will stumble upon that function without the manual, anyways, and the manual does mention that it prints decimal numbers with n decimal places, I doubt anyone will missunderstand that.

Would be funny, though, if someone saw that function and thought its purpose was to print x * 2.
Feel free to visit my website/blog - it's updated rarely, but it looks pretty cool!