model2.cpp: fixed untextured path colors (Motor Raid, Daytona USA) [Angelo Salese]

This commit is contained in:
angelosa 2018-03-08 15:38:02 +01:00
parent 54a87f0c0c
commit 05e851cc83

View File

@ -62,15 +62,16 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex
model2_state *state = object.state;
bitmap_rgb32 *destmap = (bitmap_rgb32 *)&m_destmap;
uint32_t *p = &destmap->pix32(scanline);
// uint8_t *gamma_value = &state->m_gamma_table[0];
/* extract color information */
const uint16_t *colortable_r = &state->m_colorxlat[0x0000/2];
const uint16_t *colortable_g = &state->m_colorxlat[0x4000/2];
const uint16_t *colortable_b = &state->m_colorxlat[0x8000/2];
const uint16_t *lumaram = &state->m_lumaram[0];
uint32_t lumabase = object.lumabase;
// const uint16_t *colortable_r = &state->m_colorxlat[0x0000/2];
// const uint16_t *colortable_g = &state->m_colorxlat[0x4000/2];
// const uint16_t *colortable_b = &state->m_colorxlat[0x8000/2];
// const uint16_t *lumaram = &state->m_lumaram[0];
// uint32_t lumabase = object.lumabase;
uint32_t color = object.colorbase;
uint8_t luma;
// uint8_t luma;
uint32_t tr, tg, tb;
int x;
#endif
@ -79,24 +80,28 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex
return;
#else
luma = lumaram[(lumabase + (0xf << 3))];
// luma = lumaram[(lumabase + (0xf << 3))];
// fix luma overflow
luma = std::min((int)luma,0x3f);
// luma = std::min((int)luma,0x3f);
color = state->m_palram[(color + 0x1000)] & 0x7fff;
color = state->m_palram[(color + 0x1000)] & 0xffff;
colortable_r += ((color >> 0) & 0x1f) << 8;
colortable_g += ((color >> 5) & 0x1f) << 8;
colortable_b += ((color >> 10) & 0x1f) << 8;
// colortable_r += ((color >> 0) & 0x1f) << 8;
// colortable_g += ((color >> 5) & 0x1f) << 8;
// colortable_b += ((color >> 10) & 0x1f) << 8;
/* we have the 6 bits of luma information along with 5 bits per color component */
/* now build and index into the master color lookup table and extract the raw RGB values */
tr = colortable_r[(luma)] & 0xff;
tg = colortable_g[(luma)] & 0xff;
tb = colortable_b[(luma)] & 0xff;
// untextured path doesn't use luma & color table, cfr. Daytona and Motor Raid
tr = pal5bit((color >> 0) & 0x1f); //colortable_r[(luma)] & 0xff;
tg = pal5bit((color >> 5) & 0x1f); //colortable_g[(luma)] & 0xff;
tb = pal5bit((color >> 10) & 0x1f); //colortable_b[(luma)] & 0xff;
// tr = gamma_value[tr];
// tg = gamma_value[tg];
// tb = gamma_value[tb];
/* build the final color */
color = rgb_t(tr, tg, tb);