Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Kaiser

Modifying translation table code in Doom

Recommended Posts

I've been looking though the prboom/boom source code and I can not find where the translation color is set.

I've inspected this code from v_video.c

/*
 * V_InitColorTranslation
 *
 * Loads the color translation tables from predefined lumps at game start
 * No return
 *
 * Used for translating text colors from the red palette range
 * to other colors. The first nine entries can be used to dynamically
 * switch the output of text color thru the HUlib_drawText routine
 * by embedding ESCn in the text to obtain color n. Symbols for n are
 * provided in v_video.h.
 *
 * cphipps - constness of crdef_t stuff fixed
 */

typedef struct {
  const char *name;
  const byte **map;
} crdef_t;

// killough 5/2/98: table-driven approach
static const crdef_t crdefs[] = {
  {"CRBRICK",  &colrngs[CR_BRICK ]},
  {"CRTAN",    &colrngs[CR_TAN   ]},
  {"CRGRAY",   &colrngs[CR_GRAY  ]},
  {"CRGREEN",  &colrngs[CR_GREEN ]},
  {"CRBROWN",  &colrngs[CR_BROWN ]},
  {"CRGOLD",   &colrngs[CR_GOLD  ]},
  {"CRRED",    &colrngs[CR_RED   ]},
  {"CRBLUE",   &colrngs[CR_BLUE  ]},
  {"CRORANGE", &colrngs[CR_ORANGE]},
  {"CRYELLOW", &colrngs[CR_YELLOW]},
  {"CRBLUE2",  &colrngs[CR_BLUE2]},
  {NULL}
};

// killough 5/2/98: tiny engine driven by table above
void V_InitColorTranslation(void)
{
  register const crdef_t *p;
  for (p=crdefs; p->name; p++)
    *p->map = W_CacheLumpName(p->name);
}
however, I can not find where it tells what color index to load for CR_RED etc,

the red table in doom's pallete starts from 176 to 191, but I cannot find where the code defines this.

Also in Boom, the sttnum lumps for the stats bar can be changed colors, with red as the base color to translate to other colors, but I can't figure out where its defined in the code. Same for the player's default green color (changable to other colors)

I appriciate anyone's help.

EDIT: I apologize, I meant to post this in the edit forum...

Share this post


Link to post
Deathman said:

I've been looking though the prboom/boom source code and I can not find where the translation color is set.

I've inspected this code from v_video.c

/*
 * V_InitColorTranslation
 *
 * Loads the color translation tables from predefined lumps at game start
 * No return
 *
 * Used for translating text colors from the red palette range
 * to other colors. The first nine entries can be used to dynamically
 * switch the output of text color thru the HUlib_drawText routine
 * by embedding ESCn in the text to obtain color n. Symbols for n are
 * provided in v_video.h.
 *
 * cphipps - constness of crdef_t stuff fixed
 */

typedef struct {
  const char *name;
  const byte **map;
} crdef_t;

// killough 5/2/98: table-driven approach
static const crdef_t crdefs[] = {
  {"CRBRICK",  &colrngs[CR_BRICK ]},
  {"CRTAN",    &colrngs[CR_TAN   ]},
  {"CRGRAY",   &colrngs[CR_GRAY  ]},
  {"CRGREEN",  &colrngs[CR_GREEN ]},
  {"CRBROWN",  &colrngs[CR_BROWN ]},
  {"CRGOLD",   &colrngs[CR_GOLD  ]},
  {"CRRED",    &colrngs[CR_RED   ]},
  {"CRBLUE",   &colrngs[CR_BLUE  ]},
  {"CRORANGE", &colrngs[CR_ORANGE]},
  {"CRYELLOW", &colrngs[CR_YELLOW]},
  {"CRBLUE2",  &colrngs[CR_BLUE2]},
  {NULL}
};

// killough 5/2/98: tiny engine driven by table above
void V_InitColorTranslation(void)
{
  register const crdef_t *p;
  for (p=crdefs; p->name; p++)
    *p->map = W_CacheLumpName(p->name);
}
however, I can not find where it tells what color index to load for CR_RED etc,

the red table in doom's pallete starts from 176 to 191, but I cannot find where the code defines this.

Also in Boom, the sttnum lumps for the stats bar can be changed colors, with red as the base color to translate to other colors, but I can't figure out where its defined in the code. Same for the player's default green color (changable to other colors)

I appriciate anyone's help.

EDIT: I apologize, I meant to post this in the edit forum...



The CR_* lumps are for changing the font in the menu and the HUD. They are 256 bytes long and represent a complete palette remapping. That's how the STTNUM stuff is recolorized.
The function doing the remapping is V_DrawNumPatch and can be found in inl/v_video.inl (that's PrBoom v 2.3.0)

Share this post


Link to post
Graf Zahl said:

The CR_* lumps are for changing the font in the menu and the HUD. They are 256 bytes long and represent a complete palette remapping. That's how the STTNUM stuff is recolorized.
The function doing the remapping is V_DrawNumPatch and can be found in inl/v_video.inl (that's PrBoom v 2.3.0)


yes, and the engine reconizes the red table as the color to translate.

Palette index 176-191 is all red and thats the color thats translated, but I want to see where the code tells prboom to use the red table as the color to translate. I want to modify this because the STTNUM/STCFN lumps from Strife uses different colors (gold color) and since they do not contain any red, they are not effected by any translation.

Share this post


Link to post
Deathman said:

yes, and the engine reconizes the red table as the color to translate.

Palette index 176-191 is all red and thats the color thats translated, but I want to see where the code tells prboom to use the red table as the color to translate. I want to modify this because the STTNUM/STCFN lumps from Strife uses different colors (gold color) and since they do not contain any red, they are not effected by any translation.



The code doesn't tell anywhere that only the red range has to be translated. The CR_* files contain a complete palette translation but only the indices 176-191 don't map to themselves. If you want to translate the Strife fonts you have to replace these tables with your own ones that translate the colors you need.

Share this post


Link to post

OH, the CR_ files are a lump on its own (looks at prboom.wad)


now I really feel like a newbie...

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×