Skip to content

Commit

Permalink
Refactor: Clarifying the palette translation tables
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jul 1, 2012
1 parent 8162e1e commit fcc3b41
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion doomsday/engine/portable/include/r_data.h
Expand Up @@ -45,7 +45,9 @@ struct texture_s;
struct font_s;

// Maximum number of palette translation tables.
#define MAX_TRANSLATION_TABLES 7
#define NUM_TRANSLATION_CLASSES 3
#define NUM_TRANSLATION_MAPS_PER_CLASS 7
#define NUM_TRANSLATION_TABLES (NUM_TRANSLATION_CLASSES * NUM_TRANSLATION_MAPS_PER_CLASS)

// Flags for material decorations.
#define DCRF_NO_IWAD 0x1 // Don't use if from IWAD.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/gl_texmanager.c
Expand Up @@ -2267,7 +2267,7 @@ static void loadDoomPatch(uint8_t* buffer, int texwidth, int texheight,
if(tmap || tclass)
{
// We need to translate the patch.
trans = MAX_OF(0, 7 * tclass + tmap - 1);
trans = MAX_OF(0, NUM_TRANSLATION_MAPS_PER_CLASS * tclass + tmap - 1);
DEBUG_Message(("loadDoomPatch: tclass=%i tmap=%i => TransPal# %i\n",
tclass, tmap, trans));

Expand Down Expand Up @@ -2308,7 +2308,7 @@ static void loadDoomPatch(uint8_t* buffer, int texwidth, int texheight,
if(trans >= 0)
{
// Check bounds.
assert(trans + palidx < 256 * 3 * MAX_TRANSLATION_TABLES);
assert(trans + palidx < 256 * NUM_TRANSLATION_TABLES);

palidx = translationTables[trans + palidx];
}
Expand Down
4 changes: 3 additions & 1 deletion doomsday/engine/portable/src/r_data.c
Expand Up @@ -2547,7 +2547,9 @@ void R_UpdateData(void)

void R_InitTranslationTables(void)
{
translationTables = Z_Calloc(256 * 3 * MAX_TRANSLATION_TABLES, PU_REFRESHTRANS, 0);
// The translation tables consist of a number of translation maps, each
// containing 256 palette indices.
translationTables = Z_Calloc(NUM_TRANSLATION_TABLES * 256, PU_REFRESHTRANS, 0);
}

void R_UpdateTranslationTables(void)
Expand Down

0 comments on commit fcc3b41

Please sign in to comment.