Texturing Notes - 19/11/06
Each level texture object is associated with a texture either contained within the Lemmings DS object database, or packed within the level data.
Level texture objects are rendered pixel by pixel by starting at the top left of the texture object using texture coordinates TOX, TOY (Texture origin x, y), and advancing across the texture object in units of TSX, TSY (Texture scale x, y) per pixel.
Texture space is measured in 24.8 signed fixed point: each pixel of a texture at normal scaling will advance 1 << 8 through texture space per pixel. It is possible for a level texture object to have a negative TSX or TSY. In this case, the texture will appear mirrored when rendered. Texture space loops infinitely in all directions.
The sole image in the top right shows the brick texture source image.
The image in the top left of the square shows the texture looped four times in each direction using 1 << 8 for both TSX and TSY.
The image in the top right shows the texture looped twice in the x direction, and four times in the y direction using 1 << 7 for TSX and 1 << 8 for TSY.
The image in the top right shows the texture looped four times in the x direction, and twice in the y direction using 1 << 8 for TSX and 1 << 7 for TSY.
The image in the top right shows the texture looped twice in each direction using 1 << 7 for TSX and 1 << 7 for TSY.
Textures are series of raw values from 0x0 to 0xF for 16 colour textures, and 0x00 to 0xFF for 256 colour textures. For 16 colour textures, the first pixel is stored in the low byte.
They are stored as a series of constant arrays in the file lemmings_level_object_database.c. This file is used for both the Lemmings DS ROM, and the Lemmings DS Builder application. The array lemmings_level_object_database_16s holds the width, height, and data source array address of all 16 colour textures available for level rendering. The array lemmings_level_object_database_256s holds the width, height, and data source array address of all 256 colour textures available for level rendering.
An application called Usenti by Cearn can load many image types and export the necessary arrays.
It is possible to add new textures to the application and the Lemmings DS ROM by pasting extra texture data into the lemmings_level_object_database.c source file and updating the lemmings_level_object_database_*s arrays. However, this is not advised, as any levels made with a modified version of the Lemmings DS Builder application may not be compatible with other versions of the Lemmings DS ROM.
Note that there are no palettes built into the Lemmings DS Builder application or the Lemmings DS ROM. Palettes should be imported from bitmap files which contain the necessary palettes.
Colour zero is defined as transparent. However, this can be overridden as any texture colours can be have colour zero mapped to them in Lemmings DS Builder.