🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

AngelScript 2.2.0 WIP 5 (2005/05/31)

Started by
41 comments, last by kaysik 19 years ago
Drew_Benton:

It's difficult to pinpoint exactly where I picked up the knowledge to write AS. I think the first part was from University where I took a course in compiler technologies. But I think algorithms and data structures, and object oriented design has as much to give. In terms of articles, you may take a look at the following list: Creating your own language.

My knowledge of assembly has very little to do with it. After all, I don't really know that much about assembly. Also the VM is only a tiny part of the scripting library, the compiler is by far the most complex part.

EddHead:

I don't think I'll do a separate branch, but a preprocessor flag will let you turn on/off the JIT compiler. Just like with the assembler VM.

Rain Dog:

I assume you noticed that the assembler VM isn't a normal loop. Thanks to Lioric, the VM instead has a list of jump addresses that it jumps to sequencially. Of course, with Softwire that list could be eliminated completely, but I doubt that would give more than 10% at most in performance increase. The real increase in speed is where 75-90% of a bytecode instruction is eliminated by replacing it by a couple of x86 instructions.

Once I get the time, and have converted the VM to register based, I think I'll give Softwire and JIT compilation a try.

rck:

The book Game Scripting Mastery, looks like an interesting read. Maybe I'll pick it up, although I usually don't read a lot of books (I prefer separate articles on the internet). Thanks for the tip.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Yeah, as i was writing the post i was inspecting the ASM VM and realized it just incremented the "instruction pointer" so to speak and jumped to it.
Thanks everyone for the advice! [smile] I wanted to have a few things to research this summer [wink] As I see, my list of books I should get is dramatically growing everyday it seems [lol]. Thanks again, I will be taking a look at that link in your database Andreas. Aww, I just checked and it does not exist at that url anymore, time for some googling!
I wasn't referring to just one link in my database, but rather all of them in that category. :)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

The links are really good. 1 or 2 of them are no longer valid however.
I have Game Scripting Mastery too. It details the construction of a scripting libary from scratch, starting from simple ad hoc interpreters to a fully featured (but very basic) C-like scipting language. It also provides an introduction on some of the more common scripting languages, namely LUA, TCL and Python. IMHO, the highlight of the book however, is that it explains how to apply a sciprting language to games, that is, what sort of functions and data to expose, with several examples, including a fully featured simple action game that demonstrates simple scripting for AI and ambient effects.

For anyone serious about using scripting for their game or non-game application, I do recommend using an existing scripting library (namely this one!) rather than re-inventing the wheel.
tIDE Tile Map Editorhttp://tide.codeplex.com
I've made a small addition for WIP 3: auto handles.

It's now possible to register application functions as follows:

enigne->RegisterGlobalFunction("obj@+ PickOne(obj@+, obj@+)", asFUNCTION(PickOne), asCALL_CDECL);

void *PickOne(void *a, void *b)
{
return chooseTheFirst ? a : b;
}

The library will then take care of increasing the reference counter on the returned object handle, and decrease the reference counter on the arguments once the function returns. This makes the C++ code a little simpler, though obviously at a small performance cost since the library has to dynamically determine what needs to be done.

The main reason I added this feature, is that some application use a different set of rules for managing reference counters, or perhaps the application wishes to register functions that don't even know about any reference counters. Previously it was necessary to write wrappers for these cases, but that is no longer so.

I hope you like this addition.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Me like a lot. :)

I hope it covers my problems. I'll try it out whenever I get time for it.
Just started switching over to see if this works out. Found a little silly bug. The auto AddRef doesn't check if the object is null when AddRef'ing a returned object. (Dunno if there are more cases like this, but this is the only one I ran into right away.)

Solution (I think) is to change s_callfunc_x86.cpp:483 from:
if( sysFunc->returnAutoHandle )
to:
if( sysFunc->returnAutoHandle && context->objectRegister )

I guess there might be similar errors in the asm vm or something, I don't know the structure really. Hoped that helped anyway!

EDIT: Tried some more now, and other than that bug, it seems to work great. Thanks a million! (Now off for some precious sleep...)

/Anders Stenberg

[Edited by - Dentoid on May 8, 2005 8:47:12 PM]
Indeed. I forgot to verify the if the handle is a null pointer. Your bug fix is correct, I'll add it to the next WIP immediately.

The ASM VM calls the same function, so in this case you already fix that one. However, the ASM VM is currently not working for the WIP so don't try to use it yet.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement