I am currently in the process of implementing a scripting engine into the core of my game engine. The language will not be incredibly advanced to start with; I just want to get it up and running, with a functional front- and back-end, and then I will add features.
One of the things I have been pondering about lately is the ability to call native engine functions from the script, functions that would be too slow for script execution. One of my current ideas is to map native functions in the engine to literal symbols, which would be easy to recognize and transform from the script manager/handler/whatever. On loading scripts, these symbols would then be substituted with function pointers, so that a lookup is not required on every native call.
My concern then comes to calling the native functions. They are not restricted to any number of specific parameters, so typedef’ing a common function type would not be practical. My idea was to write some assembly code to handle the loading of the different types of parameters, and then push those variables on to the stack. What I do not know, is how to do this efficiently. I am not that confident in the realm of assembly, but it would make it easier than doing it in C/C++ (if that is even possible). I have not decided on any final type of script stack, so anything is still possible. My first idea is to have two separate stacks: one for the script variables, and one for the values of the variable. The first stack of a common variable class, will hold different kinds of information on the values it points to in the second stack, which will just be an array of bytes, like offset, count and size. All the values of the script stack lay in a linear array, and I was wondering how different this is from the registers EBP/ESP. Would it be possible to just push the position of the first value on the value stack? This would remove any kind of formal-type recognition, and the need to write special code for different variable types.
Everyone is encouraged to toss any idea or suggestions you might have into the pool, everything will be appreciated. I have never done anything like this before, so all kinds of feedback is will surely help.
- Kenneth
Script formals to function formals
Started by Kenneth Gorking, Jan 10 2005 01:21 PM
6 replies to this topic
#1
Posted 10 January 2005 - 01:21 PM
"Stupid bug! You go squish now!!" - Homer Simpson
#2
Posted 10 January 2005 - 02:33 PM
i've just taken the easy way out and made a switch sentence :D
now my script lang is also only 10 instructions :cool:
now my script lang is also only 10 instructions :cool:
Peregrinus, expectavi pedos meos in cymbalis!
#3
Posted 10 January 2005 - 04:26 PM
If Prolog is the answer, what is the question ?
#4
Posted 10 January 2005 - 05:13 PM
Just the article I was about to refer too :) I found it in Game Programming Gems
#5
Posted 10 January 2005 - 05:20 PM
He he :D
I have already read that document, and I am not comfortable with scripts being able to call all my exported function (my engine.dll has ~1400, core.dll ~900), especially not functions like 'appCoreExit()', 'appFatalExit()', 'GiveMyCharacterInfinteLifeAndAllWeapons()' and so on, you get my point.
But thanks for the reply, keep 'em coming!
I have already read that document, and I am not comfortable with scripts being able to call all my exported function (my engine.dll has ~1400, core.dll ~900), especially not functions like 'appCoreExit()', 'appFatalExit()', 'GiveMyCharacterInfinteLifeAndAllWeapons()' and so on, you get my point.
But thanks for the reply, keep 'em coming!
"Stupid bug! You go squish now!!" - Homer Simpson
#6
Posted 10 January 2005 - 05:36 PM
JSoftware said:
10 instructions!?! My last VM had 140 instructions, and that was not even enough :blink:
Must be low in functionality...
"Stupid bug! You go squish now!!" - Homer Simpson
#7
Posted 11 January 2005 - 04:50 AM
Indeed it is
it's a stew of pic assembly and int 16.. with just the basic ops
but it works and it's fast as hell
it's a stew of pic assembly and int 16.. with just the basic ops
but it works and it's fast as hell
Peregrinus, expectavi pedos meos in cymbalis!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users













