L1VM - preprocessor function

I wrote a new preprocessor function for checking if a “x/y” position is inside a “x/x2” and “y/y2” coordinate position:

``````#func inside_coord (MX, MY, X, Y, X2, Y2) :{f~ = ((MX > X) && (MX < X2)) && ((MY > Y) && (MY < Y2))}
``````

To use this you just do:

``````inside_coord (mx, my, x, y, x2, y2)
``````

Here “mx/my” is the coordinate to check. Here is a full example:

``````// coord-xy.l1com
// preprocessor function demo
//
#include <intr.l1h>

#func inside_coord (MX, MY, X, Y, X2, Y2) :{f~ = ((MX > X) && (MX < X2)) && ((MY > Y) && (MY < Y2))}

(main func)
(set int64 1 zero 0)
(set int64 1 one 1)
(set int64 1 x 100)
(set int64 1 x2 200)
(set int64 1 y 50)
(set int64 1 y2 100)
(set int64 1 mx 110)
(set int64 1 my 60)
(set int64 1 f~ 0)
(set string s insidestr "m position inside!")
(set string s outsidestr "m position outside!")
inside_coord (mx, my, x, y, x2, y2)
(f~ if+)
print_s (insidestr)
print_n
(else)
print_s (outsidestr)
print_n
(endif)
exit (zero)
(funcend)
``````

And here is the assembly output of the Brackets compiler:

``````.data
Q, 1, zero
@, 0Q, 0
Q, 1, one
@, 8Q, 1
Q, 1, x
@, 16Q, 100
Q, 1, x2
@, 24Q, 200
Q, 1, y
@, 32Q, 50
Q, 1, y2
@, 40Q, 100
Q, 1, mx
@, 48Q, 110
Q, 1, my
@, 56Q, 60
Q, 1, f~
@, 64Q, 0
B, 19, insidestr
@, 72Q, "m position inside!"
@, 91Q, 72Q
B, 20, outsidestr
@, 99Q, "m position outside!"
@, 119Q, 99Q
.dend
.code
:main
gri 1, 2, 3
lsi 1, 4, 5
andi 3, 5, 6
gri 7, 8, 9
lsi 7, 10, 11
andi 9, 11, 12
andi 6, 12, 13
pullqw 13, 14, 0
jmpi 13, :if_0
jmp :else_0
:if_0
intr0 6, 14, 0, 0
intr0 7, 0, 0, 0
jmp :endif_0
:else_0
intr0 6, 15, 0, 0
intr0 7, 0, 0, 0
:endif_0
intr0 255, 0, 0, 0
rts
.cend
``````

As you can see this is compact code just with no optimization tricks there!