model2.cpp: convert colorxlat & lumaram to 16-bit accessors (nw)

This commit is contained in:
angelosa 2018-02-09 18:06:52 +01:00
parent a7cb7b8e58
commit 09b3b850ca
4 changed files with 59 additions and 50 deletions

View File

@ -495,17 +495,27 @@ static void chcolor(palette_device &palette, pen_t color, uint16_t data)
palette.set_pen_color(color, pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
}
WRITE16_MEMBER(model2_state::model2_palette_w)
WRITE16_MEMBER(model2_state::palette_w)
{
COMBINE_DATA(&m_palram[offset]);
chcolor(*m_palette, offset, m_palram[offset]);
}
READ16_MEMBER(model2_state::model2_palette_r)
READ16_MEMBER(model2_state::palette_r)
{
return m_palram[offset];
}
WRITE16_MEMBER(model2_state::colorxlat_w)
{
COMBINE_DATA(&m_colorxlat[offset]);
}
READ16_MEMBER(model2_state::colorxlat_r)
{
return m_colorxlat[offset];
}
WRITE32_MEMBER(model2_state::ctrl0_w)
{
if(ACCESSING_BITS_0_7)
@ -1406,18 +1416,14 @@ WRITE32_MEMBER(model2_state::model2o_tex_w1)
}
}
WRITE32_MEMBER(model2_state::model2o_luma_w)
READ16_MEMBER(model2_state::lumaram_r)
{
if ( (offset & 1) == 0 )
{
m_lumaram[offset>>1] &= 0xffff0000;
m_lumaram[offset>>1] |= data & 0xffff;
}
else
{
m_lumaram[offset>>1] &= 0x0000ffff;
m_lumaram[offset>>1] |= (data & 0xffff) << 16;
}
return m_lumaram[offset];
}
WRITE16_MEMBER(model2_state::lumaram_w)
{
COMBINE_DATA(&m_lumaram[offset]);
}
/* Top Skater reads here and discards the result */
@ -1465,8 +1471,8 @@ static ADDRESS_MAP_START( model2_base_mem, AS_PROGRAM, 32, model2_state )
AM_RANGE(0x01070000, 0x01070003) AM_WRITENOP AM_MIRROR(0x100000) // Video synchronization switch
AM_RANGE(0x01080000, 0x010fffff) AM_DEVREADWRITE16("tile", segas24_tile_device, char_r, char_w,0xffffffff) AM_MIRROR(0x100000)
AM_RANGE(0x01800000, 0x01803fff) AM_READWRITE16(model2_palette_r,model2_palette_w,0xffffffff)
AM_RANGE(0x01810000, 0x0181bfff) AM_RAM AM_SHARE("colorxlat")
AM_RANGE(0x01800000, 0x01803fff) AM_READWRITE16(palette_r, palette_w,0xffffffff)
AM_RANGE(0x01810000, 0x0181bfff) AM_READWRITE16(colorxlat_r,colorxlat_w,0xffffffff)
AM_RANGE(0x0181c000, 0x0181c003) AM_WRITE(model2_3d_zclip_w)
AM_RANGE(0x01a10000, 0x01a13fff) AM_DEVREADWRITE8("m2comm", m2comm_device, share_r, share_w, 0xffffffff)
AM_RANGE(0x01a14000, 0x01a14003) AM_DEVREADWRITE8("m2comm", m2comm_device, cn_r, cn_w, 0x000000ff)
@ -1483,6 +1489,8 @@ static ADDRESS_MAP_START( model2_base_mem, AS_PROGRAM, 32, model2_state )
// format is xGGGGGBBBBBRRRRR (512x400)
AM_RANGE(0x11600000, 0x1167ffff) AM_RAM AM_SHARE("fbvram1") // framebuffer A (last bronx title screen)
AM_RANGE(0x11680000, 0x116fffff) AM_RAM AM_SHARE("fbvram2") // framebuffer B
AM_RANGE(0x12800000, 0x1281ffff) AM_READWRITE16(lumaram_r,lumaram_w,0x0000ffff) // polygon "luma" RAM
ADDRESS_MAP_END
READ8_MEMBER(model2_state::virtuacop_lightgun_r)
@ -1555,7 +1563,6 @@ static ADDRESS_MAP_START( model2o_mem, AS_PROGRAM, 32, model2_state )
AM_RANGE(0x12000000, 0x121fffff) AM_RAM_WRITE(model2o_tex_w0) AM_MIRROR(0x200000) AM_SHARE("textureram0") // texture RAM 0
AM_RANGE(0x12400000, 0x125fffff) AM_RAM_WRITE(model2o_tex_w1) AM_MIRROR(0x200000) AM_SHARE("textureram1") // texture RAM 1
AM_RANGE(0x12800000, 0x1281ffff) AM_RAM_WRITE(model2o_luma_w) AM_SHARE("lumaram") // polygon "luma" RAM
AM_RANGE(0x01c00000, 0x01c0001f) AM_READ8(model2o_in_r, 0x00ff00ff)
AM_RANGE(0x01c00040, 0x01c00043) AM_READ(daytona_unk_r)
@ -1591,7 +1598,6 @@ static ADDRESS_MAP_START( model2a_crx_mem, AS_PROGRAM, 32, model2_state )
AM_RANGE(0x12000000, 0x121fffff) AM_RAM_WRITE(model2o_tex_w0) AM_MIRROR(0x200000) AM_SHARE("textureram0") // texture RAM 0
AM_RANGE(0x12400000, 0x125fffff) AM_RAM_WRITE(model2o_tex_w1) AM_MIRROR(0x200000) AM_SHARE("textureram1") // texture RAM 1
AM_RANGE(0x12800000, 0x1281ffff) AM_RAM_WRITE(model2o_luma_w) AM_SHARE("lumaram") // polygon "luma" RAM
AM_RANGE(0x01c00000, 0x01c0001f) AM_READ8(model2_crx_in_r, 0x00ff00ff)
AM_RANGE(0x01c00000, 0x01c00003) AM_WRITE(ctrl0_w)
@ -1628,8 +1634,8 @@ static ADDRESS_MAP_START( model2b_crx_mem, AS_PROGRAM, 32, model2_state )
AM_RANGE(0x11100000, 0x111fffff) AM_RAM AM_SHARE("textureram0") // texture RAM 0 (2b/2c)
AM_RANGE(0x11200000, 0x112fffff) AM_RAM AM_SHARE("textureram1") // texture RAM 1 (2b/2c)
AM_RANGE(0x11300000, 0x113fffff) AM_RAM AM_SHARE("textureram1") // texture RAM 1 (2b/2c)
AM_RANGE(0x11400000, 0x1140ffff) AM_RAM AM_SHARE("lumaram") // polygon "luma" RAM (2b/2c)
AM_RANGE(0x12800000, 0x1281ffff) AM_RAM AM_SHARE("lumaram") // polygon "luma" RAM
AM_RANGE(0x11400000, 0x1140ffff) AM_READWRITE16(lumaram_r,lumaram_w,0xffffffff) // polygon "luma" RAM (2b/2c)
AM_RANGE(0x12800000, 0x1281ffff) AM_READWRITE16(lumaram_r,lumaram_w,0x0000ffff) // polygon "luma" RAM
AM_RANGE(0x01c00000, 0x01c0001f) AM_READ8(model2_crx_in_r, 0x00ff00ff)
AM_RANGE(0x01c00000, 0x01c00003) AM_WRITE(ctrl0_w)
@ -1657,8 +1663,9 @@ static ADDRESS_MAP_START( model2c_crx_mem, AS_PROGRAM, 32, model2_state )
AM_RANGE(0x11000000, 0x111fffff) AM_RAM AM_SHARE("textureram0") // texture RAM 0 (2b/2c)
AM_RANGE(0x11200000, 0x113fffff) AM_RAM AM_SHARE("textureram1") // texture RAM 1 (2b/2c)
AM_RANGE(0x11400000, 0x1140ffff) AM_RAM AM_SHARE("lumaram") // polygon "luma" RAM (2b/2c)
AM_RANGE(0x11400000, 0x1140ffff) AM_READWRITE16(lumaram_r,lumaram_w,0xffffffff) // polygon "luma" RAM (2b/2c)
AM_RANGE(0x12800000, 0x1281ffff) AM_READWRITE16(lumaram_r,lumaram_w,0x0000ffff) // polygon "luma" RAM
AM_RANGE(0x01c00000, 0x01c0001f) AM_READ8(model2_crx_in_r, 0x00ff00ff)
AM_RANGE(0x01c00000, 0x01c00003) AM_WRITE(ctrl0_w)
AM_RANGE(0x01c00014, 0x01c00017) AM_WRITE(hotd_lightgun_w)

View File

@ -25,10 +25,8 @@ public:
: driver_device(mconfig, type, tag),
m_workram(*this, "workram"),
m_bufferram(*this, "bufferram"),
m_colorxlat(*this, "colorxlat"),
m_textureram0(*this, "textureram0"),
m_textureram1(*this, "textureram1"),
m_lumaram(*this, "lumaram"),
m_fbvram1(*this, "fbvram1"),
m_fbvram2(*this, "fbvram2"),
m_soundram(*this, "soundram"),
@ -62,10 +60,10 @@ public:
required_shared_ptr<uint32_t> m_workram;
required_shared_ptr<uint32_t> m_bufferram;
std::unique_ptr<uint16_t[]> m_palram;
required_shared_ptr<uint32_t> m_colorxlat;
std::unique_ptr<uint16_t[]> m_colorxlat;
required_shared_ptr<uint32_t> m_textureram0;
required_shared_ptr<uint32_t> m_textureram1;
required_shared_ptr<uint32_t> m_lumaram;
std::unique_ptr<uint16_t[]> m_lumaram;
required_shared_ptr<uint32_t> m_fbvram1;
required_shared_ptr<uint32_t> m_fbvram2;
optional_shared_ptr<uint16_t> m_soundram;
@ -151,8 +149,10 @@ public:
DECLARE_CUSTOM_INPUT_MEMBER(rchase2_devices_r);
DECLARE_READ32_MEMBER(timers_r);
DECLARE_WRITE32_MEMBER(timers_w);
DECLARE_READ16_MEMBER(model2_palette_r);
DECLARE_WRITE16_MEMBER(model2_palette_w);
DECLARE_READ16_MEMBER(palette_r);
DECLARE_WRITE16_MEMBER(palette_w);
DECLARE_READ16_MEMBER(colorxlat_r);
DECLARE_WRITE16_MEMBER(colorxlat_w);
DECLARE_WRITE32_MEMBER(ctrl0_w);
DECLARE_WRITE32_MEMBER(analog_2b_w);
DECLARE_READ32_MEMBER(fifoctl_r);
@ -193,7 +193,8 @@ public:
DECLARE_WRITE32_MEMBER(mode_w);
DECLARE_WRITE32_MEMBER(model2o_tex_w0);
DECLARE_WRITE32_MEMBER(model2o_tex_w1);
DECLARE_WRITE32_MEMBER(model2o_luma_w);
DECLARE_READ16_MEMBER(lumaram_r);
DECLARE_WRITE16_MEMBER(lumaram_w);
DECLARE_WRITE32_MEMBER(model2_3d_zclip_w);
DECLARE_WRITE16_MEMBER(model2snd_ctrl);
DECLARE_READ32_MEMBER(copro_sharc_input_fifo_r);

View File

@ -2599,7 +2599,9 @@ VIDEO_START_MEMBER(model2_state,model2)
geo_init( (uint32_t*)memregion("user2")->base() );
/* init various video-related pointers */
m_palram = make_unique_clear<uint16_t[]>(0x2000);
m_palram = make_unique_clear<uint16_t[]>(0x4000/2);
m_colorxlat = make_unique_clear<uint16_t[]>(0xc000/2);
m_lumaram = make_unique_clear<uint16_t[]>(0x10000/2);
}
uint32_t model2_state::screen_update_model2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)

View File

@ -64,10 +64,10 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex
uint32_t *p = &destmap->pix32(scanline);
/* extract color information */
const uint16_t *colortable_r = (const uint16_t *)&state->m_colorxlat[0x0000/4];
const uint16_t *colortable_g = (const uint16_t *)&state->m_colorxlat[0x4000/4];
const uint16_t *colortable_b = (const uint16_t *)&state->m_colorxlat[0x8000/4];
const uint16_t *lumaram = (const uint16_t *)state->m_lumaram.target();
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;
@ -79,13 +79,12 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex
return;
#else
luma = lumaram[BYTE_XOR_LE(lumabase + (0xf << 3))];
luma = lumaram[(lumabase + (0xf << 3))];
// fix luma overflow
if(luma > 0x3f)
luma = 0x3f;
color = state->m_palram[BYTE_XOR_LE(color + 0x1000)] & 0x7fff;
luma = std::min((int)luma,0x3f);
color = state->m_palram[(color + 0x1000)] & 0x7fff;
colortable_r += ((color >> 0) & 0x1f) << 8;
colortable_g += ((color >> 5) & 0x1f) << 8;
@ -94,9 +93,9 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex
/* 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[BYTE_XOR_LE(luma)] & 0xff;
tg = colortable_g[BYTE_XOR_LE(luma)] & 0xff;
tb = colortable_b[BYTE_XOR_LE(luma)] & 0xff;
tr = colortable_r[(luma)] & 0xff;
tg = colortable_g[(luma)] & 0xff;
tb = colortable_b[(luma)] & 0xff;
/* build the final color */
color = rgb_t(tr, tg, tb);
@ -122,10 +121,10 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex
uint32_t tex_height = object.texheight;
/* extract color information */
const uint16_t *colortable_r = (const uint16_t *)&state->m_colorxlat[0x0000/4];
const uint16_t *colortable_g = (const uint16_t *)&state->m_colorxlat[0x4000/4];
const uint16_t *colortable_b = (const uint16_t *)&state->m_colorxlat[0x8000/4];
const uint16_t *lumaram = (const uint16_t *)state->m_lumaram.target();
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 colorbase = object.colorbase;
uint32_t lumabase = object.lumabase;
uint32_t tex_x = object.texx;
@ -145,7 +144,7 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex
tex_x_mask = tex_width - 1;
tex_y_mask = tex_height - 1;
colorbase = state->m_palram[BYTE_XOR_LE(colorbase + 0x1000)] & 0x7fff;
colorbase = state->m_palram[(colorbase + 0x1000)] & 0x7fff;
colortable_r += ((colorbase >> 0) & 0x1f) << 8;
colortable_g += ((colorbase >> 5) & 0x1f) << 8;
@ -181,7 +180,7 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex
if ( t == 0x0f )
continue;
#endif
luma = lumaram[BYTE_XOR_LE(lumabase + (t << 3))];
luma = lumaram[(lumabase + (t << 3))];
// Virtua Striker sets up a luma of 0x40 for national flags on bleachers, fix here.
luma = std::min((int)luma,0x3f);
@ -189,9 +188,9 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex
/* 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[BYTE_XOR_LE(luma)] & 0xff;
tg = colortable_g[BYTE_XOR_LE(luma)] & 0xff;
tb = colortable_b[BYTE_XOR_LE(luma)] & 0xff;
tr = colortable_r[(luma)] & 0xff;
tg = colortable_g[(luma)] & 0xff;
tb = colortable_b[(luma)] & 0xff;
p[x] = rgb_t(tr, tg, tb);
}