Hi there, yes certainly, you can’t put the assembly code directly inline with your GDScript or C# code but what you can do is the following. Though possible this was never really our intent. We designed the system to run the entire program in assembly to take advantage of script queueing and such. Also running a script in this fashion does not necessarily mean it will run immediately. There may be other scripts is the queue waiting to run ahead of it.
func isTheWorldFlat ( radius: float ) -> bool:
DroofusCore.execute_asm_with_value( "worldFlatnessCalculator.asm", radius )
if DroofusCore.get_value_by_name("curve") > 0:
return false
return true
Running a script in this fashion sets the following engine flag .sharedData to true. When true all values remain in memory after a script exits.
You have to realise thought that in assembly all variables (we’ll call them that for sanity sake) are global. If we were to run the following script multiple times that would be fine, with .sharedData turned on script names are added to the prior scripts list so the compiler skips repeated variable creation for those scripts. But if we were to run another script which defined the variable “curve” we’d get a compile error.
With .sharedData turned on if your code expects a variable value to be as originally created, you’d need to set it back to the original value in code before use if run repeatedly.
.sharedData is one of the only engine flags not reset back to default after a script finishes, so for all scripts after this one .sharedData would be on unless you explicitly set it back to false in code.
There is also a .clearData directive you can use to reset everything if you wanted. The .sharedData flag though, would still remain in it current state..
Dot directives are compiler switches and are only evaluated at compile time and stripped from the final opCode. There’s no point putting one in the middle of a loop expecting it to be repeatedly called. It’ll still be evaluated at compile time, but gone at runtime.
In our early game demo you saw at the end of the video we’ve edited the droofus_defaults file to have shareData on by default.
Sorry for the longwinded explanation.
.debug false
.sharedData true
.optimiseLoops true
_start:
lda #0 #reset the variable
sta curve
pop a #get the passed value off the stack
# Some calculations
sta curve
brk
.dd curve, 0