Tuesday, October 20, 2015

End Of (Summer) Days

Progress has been delayed, but I'm still working on getting all of the pieces back together. The widget system rework was already taking longer than I expected and in the process, I decided to bear down on the part that I consider most important.

Mana's object system must be easy to use and as fast as possible.

Since Lua is the scripting language that drives Mana functionality, I was concerned about certain performance bottlenecks. I'd been using Lua's C-API for connecting Mana and Lua. In an attempt to keep as much as possible on the C (BlitzMax) side, I wrote all of Lua's metatable access functions* in BlitzMax and put all of the exposed functions in a hash table. Then it occurred to me that doing it that way would result in very (extremely) inefficient look ups. Sure enough, a few tests confirmed my worries.

This revelation led me to do some digging on the LuaJIT forums and eventually decide to rewrite a significant portion of the Lua interface code. LuaJIT has an FFI, or Foreign Function Interface, that allows Lua to directly call C functions and best of all, they are inlined - in other words, fast!

The decision has added almost two months to my plan, but the resulting speed gain on non-engine related logic should be a factor of three to thirty or more!

* Lua doesn't have objects, per se. Without getting too technical (...), it uses tables to store object data. The tables have special attached functions (methods) that control data access. These methods can be redefined in ways that change, to some extent, the way the language works. This feature makes Lua particularly suitable for customization and great for scripting.

Monday, June 8, 2015

One (baby) Step At A Time

The Mana engine rebuild took about six weeks and went well...so well that I decided to rebuild everything! .........yay.

Although Mana was getting powerful, it had also become somewhat cumbersome to use. Despite my best efforts, there were too many dependencies and that made results hard to predict in some cases. In my mind, the best games (usually) have simple rules that combine for great variety in gameplay. Thinking along those lines, my approach to Mana architecture was to create the simplest rule set possible. At least, that was the theory.

However, every idea spawns more ideas and more complexity. As Mana evolved, it finally dawned on me around the end of 2013 that Mana's defining feature was an application building block system that I had implemented on top of a bunch of other things...remnants of ideas that I was loathe to abandon.

So, it's time to move on.

I am currently breaking Mana into smaller, more manageable, and more flexible, pieces. By the end of the summer, I expect all of its functionality will be back.