Skip to content

Kal Info

Adrien edited this page Oct 22, 2023 · 1 revision

Kal engine

Introduction

Engine developed by Etranges Libellules (ELB) in the begininning of the 2000s.

First game using this engine released is Asterix & Obelix XXL in 2003, and it continued being used for their future games until 2012 when they closed. 7 games in total were developed using different iterations of the engine.

Kal is mainly written in C++ and uses Object-oriented programming (OOP). It uses Renderware as the middleware for graphics rendering, but also audio.

Class Reflection

Like any C++ OOP software, all features of the engine are encapsulated into classes. Classes can then be instantiated into one or more objects.

For every (registered) class, the engine has run-time access to the following information:

  • class name
  • class ID
  • factory functions p = new T; and p = new T[n];
  • destruction function delete p; and delete [] p;

Class ID

The ID of a class consists of two integers:

  • the first is the category of the class, a number between 0 and 14,
  • the second is the ID under the category.

There are 15 categories, which are:

  • 0: Manager, 1: Service, 2: Hook, 3: Hook Life
  • 4: Group, 5: Group Life, 6: Component, 7: Camera
  • 8: Cinematic Bloc, 9: Dictionary, 10: Geometry, 11: Scene Node
  • 12: Misc, 13: Graphic, 14: Error

Sometimes, the class category+ID are encoded as two separated integers, but often they are encoded as a single integer, which we will call the Full ID. The least 6 bits are used for the category, and the rest for the class ID. It can be computed as follows: fullID = class_category | (class_id << 6);

For example, the class CKSoundDictionary has:

  • category: 9 (Dictionary)
  • ID: 3
  • Full ID: 9 | (3 << 6) = 201 (or 0xC9 in hex)

See this file TODO for a list of all class IDs in XXL1.

Object serialization

Most Kal class objects can be serialized, that means they can be written from memory to a file. The file can then be read back to memory (deserialize).

In fact, when loading the a level, what the game pretty much does is instantiate the number of objects in the level for every class, then deserialize from the LVL/STR file.

Serializing an object often resumes in reading/writing every variable member of the object, such as integers, floats, strings, and even pointers to other objects.

Integers are serialized using low endianness. So for platforms using big endian CPUs (like the PowerPC on GameCube/Wii/Xbox 360), a conversion from low endian to big endian is done after reading the integer from the file.

Pointers, which are simply memory addresses to another Kal object during game execution, are encoded (usually) as 32-bit IDs, identifying the object pointed to in the LVL/STR file. More details later.

Clone this wiki locally