Skip to content

Commit e004ded

Browse files
authored
sega/model2: apply color table to tilemap layers; indy500 supports 16:9 (#14515)
* sega/model2: apply color table to tilemap layers; indy500 supports 16:9 Also use correct CRTC offset values when drawing directly to the framebuffer
1 parent 4b584d3 commit e004ded

File tree

3 files changed

+41
-14
lines changed

3 files changed

+41
-14
lines changed

src/mame/sega/model2.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,14 @@ void model2c_state::machine_reset()
323323
void model2_state::palette_w(offs_t offset, u16 data, u16 mem_mask)
324324
{
325325
COMBINE_DATA(&m_palram[offset]);
326-
u16 color = m_palram[offset];
327-
m_palette->set_pen_color(offset, pal5bit(color >> 0), pal5bit(color >> 5), pal5bit(color >> 10));
326+
u16 palcolor = m_palram[offset];
327+
u8 r = m_colorxlat[0x0080 / 2 + ((palcolor >> 0) & 0x1f) * 0x100];
328+
u8 g = m_colorxlat[0x4080 / 2 + ((palcolor >> 5) & 0x1f) * 0x100];
329+
u8 b = m_colorxlat[0x8080 / 2 + ((palcolor >> 10) & 0x1f) * 0x100];
330+
r = m_gamma_table[r];
331+
g = m_gamma_table[g];
332+
b = m_gamma_table[b];
333+
m_palette->set_pen_color(offset, r, g, b);
328334
}
329335

330336
u16 model2_state::palette_r(offs_t offset)
@@ -335,6 +341,10 @@ u16 model2_state::palette_r(offs_t offset)
335341
void model2_state::colorxlat_w(offs_t offset, u16 data, u16 mem_mask)
336342
{
337343
COMBINE_DATA(&m_colorxlat[offset]);
344+
345+
// if writing to the scroll color table, mark the palette as dirty
346+
if ((offset & 0xff) == 0x80 / 2)
347+
m_palette_dirty = true;
338348
}
339349

340350
u16 model2_state::colorxlat_r(offs_t offset)
@@ -7575,9 +7585,9 @@ GAME( 1994, vstrikero, vstriker, model2b, vstriker, model2b_state, empty_
75757585
GAME( 1995, fvipers, 0, model2b, vf2, model2b_state, empty_init, ROT0, "Sega", "Fighting Vipers (Revision D)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS )
75767586
GAME( 1995, fvipersb, fvipers, model2b, vf2, model2b_state, empty_init, ROT0, "Sega", "Fighting Vipers (Revision B)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS )
75777587
GAME( 1995, gunblade, 0, gunblade, gunblade, model2b_state, empty_init, ROT0, "Sega", "Gunblade NY (Revision A)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS )
7578-
GAME( 1995, indy500, 0, indy500, indy500, model2b_state, empty_init, ROT0, "Sega", "INDY 500 Twin (Revision A, Newer)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS )
7579-
GAME( 1995, indy500d, indy500, indy500, indy500, model2b_state, empty_init, ROT0, "Sega", "INDY 500 Deluxe (Revision A)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS )
7580-
GAME( 1995, indy500to, indy500, indy500, indy500, model2b_state, empty_init, ROT0, "Sega", "INDY 500 Twin (Revision A)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS )
7588+
GAMEL(1995, indy500, 0, indy500, indy500, model2b_state, empty_init, ROT0, "Sega", "INDY 500 Twin (Revision A, Newer)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS, layout_vr)
7589+
GAMEL(1995, indy500d, indy500, indy500, indy500, model2b_state, empty_init, ROT0, "Sega", "INDY 500 Deluxe (Revision A)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS, layout_vr)
7590+
GAMEL(1995, indy500to, indy500, indy500, indy500, model2b_state, empty_init, ROT0, "Sega", "INDY 500 Twin (Revision A)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS, layout_vr)
75817591
GAME( 1995, von, 0, model2b, von, model2b_state, empty_init, ROT0, "Sega", "Cyber Troopers Virtual-On - Twin (Export)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS )
75827592
GAME( 1995, vonu, von, model2b, von, model2b_state, empty_init, ROT0, "Sega", "Cyber Troopers Virtual-On - Twin (USA, Revision B)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS )
75837593
GAME( 1995, vonj, von, model2b, von, model2b_state, empty_init, ROT0, "Sega", "Cyber Troopers Virtual-On - Twin (Japan, Revision B)", MACHINE_NOT_WORKING|MACHINE_IMPERFECT_GRAPHICS )

src/mame/sega/model2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ class model2_state : public driver_device
273273
bool m_render_mode = false;
274274
bool m_render_test_mode = false;
275275
int16_t m_crtc_xoffset = 0, m_crtc_yoffset = 0;
276+
bool m_palette_dirty = false;
276277

277278
u32 *geo_process_command( geo_state *geo, u32 opcode, u32 *input, bool *end_code );
278279
// geo commands

src/mame/sega/model2_v.cpp

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -938,21 +938,21 @@ void model2_state::model2_3d_frame_end( bitmap_rgb32 &bitmap, const rectangle &c
938938
void model2_state::draw_framebuffer( bitmap_rgb32 &bitmap, const rectangle &cliprect )
939939
{
940940
u16 *fbvram = &(m_screen->frame_number() & 1 ? m_fbvramB[0] : m_fbvramA[0]);
941-
// TODO: halved crtc values?
942-
int xoffs = (-m_crtc_xoffset)/2;
943-
int yoffs = m_crtc_yoffset/2;
941+
int xoffs = -m_crtc_xoffset;
942+
int yoffs = (512 - 384) - m_crtc_yoffset;
944943

945944
for (int y = cliprect.min_y; y < cliprect.max_y; ++y)
946945
{
947946
for (int x = cliprect.min_x; x < cliprect.max_x; x++)
948947
{
949948
int offset = (x + xoffs) + (y + yoffs)*512;
950-
int b = (fbvram[offset] >> 0) & 0x1f;
951-
int r = (fbvram[offset] >> 5) & 0x1f;
952-
int g = (fbvram[offset] >> 10) & 0x1f;
953-
r = pal5bit(r);
954-
g = pal5bit(g);
955-
b = pal5bit(b);
949+
// assuming the scroll color table is used
950+
int r = m_colorxlat[0x0080 / 2 + ((fbvram[offset] >> 5) & 0x1f) * 0x100];
951+
int g = m_colorxlat[0x4080 / 2 + ((fbvram[offset] >> 10) & 0x1f) * 0x100];
952+
int b = m_colorxlat[0x8080 / 2 + ((fbvram[offset] >> 0) & 0x1f) * 0x100];
953+
r = m_gamma_table[r];
954+
g = m_gamma_table[g];
955+
b = m_gamma_table[b];
956956
bitmap.pix(y, x) = r << 16 | g << 8 | b;
957957
}
958958
}
@@ -2595,6 +2595,22 @@ void model2_state::video_start()
25952595

25962596
u32 model2_state::screen_update_model2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
25972597
{
2598+
// if the scroll color table was written to, we need to refresh the palette
2599+
if (m_palette_dirty)
2600+
{
2601+
for (int i = 0; i < 0x1000; i++)
2602+
{
2603+
u16 palcolor = m_palram[i];
2604+
u8 r = m_colorxlat[0x0080 / 2 + ((palcolor >> 0) & 0x1f) * 0x100];
2605+
u8 g = m_colorxlat[0x4080 / 2 + ((palcolor >> 5) & 0x1f) * 0x100];
2606+
u8 b = m_colorxlat[0x8080 / 2 + ((palcolor >> 10) & 0x1f) * 0x100];
2607+
r = m_gamma_table[r];
2608+
g = m_gamma_table[g];
2609+
b = m_gamma_table[b];
2610+
m_palette->set_pen_color(i, r, g, b);
2611+
}
2612+
}
2613+
25982614
//logerror("--- frame ---\n");
25992615
bitmap.fill(m_palette->pen(0), cliprect);
26002616
m_sys24_bitmap.fill(0, cliprect);

0 commit comments

Comments
 (0)