Converted rollrace.cpp foreground to tilemap system and fixed flip flags in it, fixes service mode in rollace2 set [Angelo Salese]

(also fixed a wrap-around regression)
This commit is contained in:
angelosa 2016-09-15 19:00:45 +02:00
parent f14945d891
commit a90b026136
3 changed files with 88 additions and 79 deletions

View File

@ -58,8 +58,8 @@ static ADDRESS_MAP_START( rollrace_map, AS_PROGRAM, 8, rollrace_state )
AM_RANGE(0xc000, 0xcfff) AM_RAM
AM_RANGE(0xd806, 0xd806) AM_READNOP /* looks like a watchdog, bit4 checked*/
AM_RANGE(0xd900, 0xd900) AM_READWRITE(fake_d800_r,fake_d800_w) /* protection ??*/
AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_SHARE("videoram")
AM_RANGE(0xe400, 0xe47f) AM_RAM AM_SHARE("colorram")
AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(vram_w) AM_SHARE("videoram")
AM_RANGE(0xe400, 0xe47f) AM_RAM_WRITE(cram_w) AM_SHARE("colorram")
AM_RANGE(0xe800, 0xe800) AM_DEVWRITE("soundlatch", generic_latch_8_device, write)
AM_RANGE(0xec00, 0xec0f) AM_NOP /* Analog sound effects ?? ec00 sound enable ?*/
AM_RANGE(0xf000, 0xf0ff) AM_RAM AM_SHARE("spriteram")
@ -253,7 +253,7 @@ static MACHINE_CONFIG_START( rollrace, rollrace_state )
MCFG_SCREEN_REFRESH_RATE(60)
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
MCFG_SCREEN_SIZE(256, 256)
MCFG_SCREEN_VISIBLE_AREA(16,255,16, 255-16)
MCFG_SCREEN_VISIBLE_AREA(0,256-1,16, 255-16)
MCFG_SCREEN_UPDATE_DRIVER(rollrace_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
@ -280,8 +280,8 @@ static MACHINE_CONFIG_DERIVED( rollace2, rollrace )
/* basic machine hardware */
MCFG_SCREEN_MODIFY("screen")
MCFG_SCREEN_VISIBLE_AREA(0,255-24,16, 255-16)
// MCFG_SCREEN_MODIFY("screen")
// MCFG_SCREEN_VISIBLE_AREA(0,256-1,16, 255-16)
MACHINE_CONFIG_END

View File

@ -19,6 +19,7 @@ public:
required_shared_ptr<UINT8> m_colorram;
required_shared_ptr<UINT8> m_spriteram;
tilemap_t *m_fg_tilemap;
int m_charbank[2];
int m_bkgpage;
int m_bkgflip;
@ -43,9 +44,15 @@ public:
DECLARE_WRITE8_MEMBER(backgroundcolor_w);
DECLARE_WRITE8_MEMBER(flipy_w);
DECLARE_WRITE8_MEMBER(flipx_w);
DECLARE_WRITE8_MEMBER(vram_w);
DECLARE_WRITE8_MEMBER(cram_w);
TILE_GET_INFO_MEMBER(get_fg_tile_info);
void tilemap_refresh_flip();
DECLARE_PALETTE_INIT(rollrace);
virtual void machine_start() override;
virtual void video_start() override;
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);

View File

@ -9,6 +9,45 @@
#define RA_BGCHAR_BASE 4
#define RA_SP_BASE 5
TILE_GET_INFO_MEMBER(rollrace_state::get_fg_tile_info)
{
int code = m_videoram[tile_index];
int color = m_colorram[(tile_index & 0x1f)*2+1] & 0x1f;
SET_TILE_INFO_MEMBER(RA_FGCHAR_BASE + m_chrbank,
code,
color,
TILE_FLIPY);
}
void rollrace_state::video_start()
{
m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(rollrace_state::get_fg_tile_info),this),TILEMAP_SCAN_ROWS,8,8,32,32 );
m_fg_tilemap->set_transparent_pen(0);
m_fg_tilemap->set_scroll_cols(32);
}
WRITE8_MEMBER(rollrace_state::vram_w)
{
m_videoram[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
WRITE8_MEMBER(rollrace_state::cram_w)
{
m_colorram[offset] = data;
if(offset & 1)
{
// TODO: optimize
m_fg_tilemap->mark_all_dirty();
//for(int x = 0; x < 32; x++)
// m_fg_tilemap->mark_tile_dirty(x + ((offset >> 1)*32));
}
else
m_fg_tilemap->set_scrolly(offset >> 1,data);
}
/***************************************************************************
Convert the color PROMs into a more useable format.
@ -27,12 +66,10 @@ PALETTE_INIT_MEMBER(rollrace_state, rollrace)
const UINT8 *color_prom = memregion("proms")->base();
int i;
for (i = 0;i < palette.entries();i++)
{
int bit0,bit1,bit2,bit3,r,g,b;
bit0 = (color_prom[0] >> 0) & 0x01;
bit1 = (color_prom[0] >> 1) & 0x01;
bit2 = (color_prom[0] >> 2) & 0x01;
@ -59,9 +96,9 @@ WRITE8_MEMBER(rollrace_state::charbank_w)
{
m_charbank[offset&1] = data;
m_chrbank = m_charbank[0] | (m_charbank[1] << 1) ;
m_fg_tilemap->mark_all_dirty();
}
WRITE8_MEMBER(rollrace_state::bkgpen_w)
{
m_bkgpen = data;
@ -88,11 +125,13 @@ WRITE8_MEMBER(rollrace_state::backgroundcolor_w)
WRITE8_MEMBER(rollrace_state::flipy_w)
{
m_flipy = data & 0x01;
// bit 2: cleared at night stage in attract, unknown purpose
}
WRITE8_MEMBER(rollrace_state::flipx_w)
{
m_flipx = data & 0x01;
m_fg_tilemap->set_flip(m_flipx ? TILEMAP_FLIPX|TILEMAP_FLIPY : 0);
}
UINT32 rollrace_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
@ -100,8 +139,6 @@ UINT32 rollrace_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap
UINT8 *spriteram = m_spriteram;
int offs;
int sx, sy;
int scroll;
int col;
const UINT8 *mem = memregion("user1")->base();
/* fill in background colour*/
@ -109,35 +146,28 @@ UINT32 rollrace_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap
/* draw road */
for (offs = 0x3ff; offs >= 0; offs--)
{
if(!(m_bkgflip))
{
sy = ( 31 - offs / 32 ) ;
}
else
sy = ( offs / 32 ) ;
{
if(!(m_bkgflip))
sy = ( 31 - offs / 32 ) ;
else
sy = ( offs / 32 ) ;
sx = ( offs%32 ) ;
if(m_flipx)
sx = 31-sx ;
if(m_flipy)
sy = 31-sy ;
m_gfxdecode->gfx(RA_BGCHAR_BASE)->transpen(bitmap,
cliprect,
mem[offs + ( m_bkgpage * 1024 )]
+ ((( mem[offs + 0x4000 + ( m_bkgpage * 1024 )] & 0xc0 ) >> 6 ) * 256 ) ,
m_bkgcol,
m_flipx,(m_bkgflip^m_flipy),
sx*8,sy*8,0);
}
sx = ( offs%32 ) ;
if(m_flipx)
sx = 31-sx ;
if(m_flipy)
sy = 31-sy ;
m_gfxdecode->gfx(RA_BGCHAR_BASE)->transpen(bitmap,
cliprect,
mem[offs + ( m_bkgpage * 1024 )]
+ ((( mem[offs + 0x4000 + ( m_bkgpage * 1024 )] & 0xc0 ) >> 6 ) * 256 ) ,
m_bkgcol,
m_flipx,(m_bkgflip^m_flipy),
sx*8,sy*8,0);
}
/* sprites */
for ( offs = 0x80-4 ; offs >=0x0 ; offs -= 4)
@ -150,55 +180,27 @@ UINT32 rollrace_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap
if(sx && sy)
{
if(m_flipx)
sx = 224 - sx;
if(m_flipy)
sy = 224 - sy;
if(m_flipx)
sx = 224 - sx;
if(m_flipy)
sy = 224 - sy;
if(spriteram[offs+1] & 0x80)
s_flipy = 1;
if(spriteram[offs+1] & 0x80)
s_flipy = 1;
bank = (( spriteram[offs+1] & 0x40 ) >> 6 ) ;
bank = (( spriteram[offs+1] & 0x40 ) >> 6 ) ;
if(bank)
bank += m_spritebank;
if(bank)
bank += m_spritebank;
m_gfxdecode->gfx( RA_SP_BASE + bank )->transpen(bitmap,cliprect,
spriteram[offs+1] & 0x3f ,
spriteram[offs+2] & 0x1f,
m_flipx,!(s_flipy^m_flipy),
sx,sy,0);
m_gfxdecode->gfx( RA_SP_BASE + bank )->transpen(bitmap,cliprect,
spriteram[offs+1] & 0x3f ,
spriteram[offs+2] & 0x1f,
m_flipx,!(s_flipy^m_flipy),
sx,sy,0);
}
}
/* draw foreground characters */
for (offs = 0x3ff; offs >= 0; offs--)
{
sx = offs % 32;
sy = offs / 32;
scroll = ( 8 * sy - m_colorram[2 * sx] ) % 256;
col = m_colorram[ sx * 2 + 1 ]&0x1f;
if (!m_flipy)
{
scroll = (248 - scroll) % 256;
}
if (m_flipx) sx = 31 - sx;
m_gfxdecode->gfx(RA_FGCHAR_BASE + m_chrbank) ->transpen(bitmap,cliprect,
m_videoram[ offs ] ,
col,
m_flipx,m_flipy,
8*sx,scroll,0);
}
m_fg_tilemap->draw(screen,bitmap,cliprect,0,0);
return 0;
}