Wednesday, February 20, 2013

Allegro the static beast

Recently I wrote an article on compiling Allegro. Please note this was only for a dynamically linked library.
Now for a statically built library!

Friday, February 15, 2013

Sub repositories and Mercurial

So today I had finished up my game ready for release (Theseus and the Minotaur). Which can be found here.
One of the things I came across is how do I have sub repositories for both git and mercurial under mercurial?
I had a lot of trouble with it so here is what I've learnt.

Monday, February 11, 2013

Allegro compilation

So yesturday I started work on making a game.
This was all well and good except it would help to have a game engine.
I choose Allegro for it being c based so much more easier to interface to D. (Bindings already exist).

My primary platform is Windows 7 64bit.
This was primarily because dmd (D's compiler) uses Microsofts toolchain for linking. This is rather nice thing for COFF support as it's linker (optilink) only support OMF and thats for 32bit only.

Saturday, January 19, 2013

D dynamic runtime function calling

Recently I did some work towards making a dynamic function caller in D. Note this is a very unsafe operation in such a language.
The premise is simple take any argument and then call a function without a return type.

The answer didn't appear as simple though.
I manually pushed to the stack the arguments then called using a pointer which has been casted to void the function.
Great it works! But umm how do we push arguments to the stack? That is the hard part.
Primitives have to be dealt with individually. Structs have no super type and Objects aka classes have the Object super type so very easy. Arrays are also a type so they are easy to do when registering a type. Last associative arrays a type that requires two other types to make it; not so easy.

I got Objects, primitives, arrays and any other type you manually register. Why the registering? Because I used the Variant type and this is where it all falls apart.
The Variant type is great for storing and retrieving values out off, IF you know the type at compile time for when you retrieve it.
So using templates I created a registration system that created a function that was designed specifically for a type you register.

Most of the time it was a non issue with calling the get!type function on Variant and then just exiting the function created but some which types use a more complex pointer values in registers had to be modified to be allowed for.

Also the float type was stored in different registers different from other types its size. I implemented the registration system to allow for system level types and user types. The system types have the override for said type that was manually implemented.

How could this have been done simpler?
In short a container type that allowed for pushing the value directly on to the stack without knowing its type. Because the type and hence its size was known directly at creation I don't need to know it when pushing; it should have been retrieved and stored then (value.sizeof).
This would have void'd the need for the registration system completely.

To see this check out link.

I hope this gives you all some ideas; but remember this is not safe,even if I called it that. D is simply not the right type of language to do any sort of reflection type activity like this.

Concurrency design with D

During my development with CivBot (an IRC bot written in D) I have come across some things which make me go wow; One of these is threading.
This may seem like well just use mutexs but how can you really use it efficiently is what I am trying to come to grips with.
I'm looking at two types of concurrency in D, mutexs and message passing.

Monday, October 22, 2012

Lately in D

I know I haven't really written much in the past while but here goes.
For the past 4 months or so I've been working with D in windows and Linux on and off.
Now I've had people say why not use C++? or something more industry standard.
Well coming from a high level background of Java, Groovy, PHP it feels easier on me then C++ or C is.
This isn't because its a high level language either. The folks at Digital Mars have been very strict on what goes into the D syntax. Its quite small for a language like it. I have in fact done C++ in past on linux but to me I just don't like it.

Sunday, February 5, 2012

Assembly explaining the IO with c

Following on from my last post relating to IO using the c API's I am now going to explain how it works.

The biggest difference in the build process was that instead of linking the Assembly library created by NASM I am compiling and linking with gcc.