Skip to content

namcos21: Some cleanup & modernization #12566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions src/mame/namco/namcos21.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ class namcos21_state : public driver_device
m_namcos21_dsp(*this, "namcos21dsp")
{ }

void configure_c148_standard(machine_config &config);
void winrun(machine_config &config);
void winrun(machine_config &config) ATTR_COLD;

protected:
virtual void machine_start() override ATTR_COLD;
Expand Down Expand Up @@ -390,7 +389,8 @@ class namcos21_state : public driver_device

void winrun_bitmap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect);

void configure_c65_namcos21(machine_config &config);
void configure_c65_namcos21(machine_config &config) ATTR_COLD;
void configure_c148_standard(machine_config &config) ATTR_COLD;

void winrun_master_map(address_map &map) ATTR_COLD;
void winrun_slave_map(address_map &map) ATTR_COLD;
Expand All @@ -416,7 +416,7 @@ uint16_t namcos21_state::winrun_gpu_color_r()

void namcos21_state::winrun_gpu_color_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA( &m_winrun_color );
COMBINE_DATA(&m_winrun_color);
}

uint16_t namcos21_state::winrun_gpu_register_r(offs_t offset)
Expand All @@ -426,57 +426,58 @@ uint16_t namcos21_state::winrun_gpu_register_r(offs_t offset)

void namcos21_state::winrun_gpu_register_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA( &m_winrun_gpu_register[offset] );
COMBINE_DATA(&m_winrun_gpu_register[offset]);
m_screen->update_partial(m_screen->vpos());
}

void namcos21_state::winrun_gpu_videoram_w(offs_t offset, uint16_t data)
{
int color = data>>8;
int mask = data&0xff;
for( int i=0; i<8; i++ )
uint8_t color = data >> 8;
uint8_t mask = data & 0xff;

for (int i=0; i<8; i++)
{
if( mask&(0x01<<i) )
if (BIT(mask, i))
{
m_gpu_videoram[(offset+i)&0x7ffff] = color;
m_gpu_maskram[(offset+i)&0x7ffff] = mask;
m_gpu_videoram[(offset+i) & 0x7ffff] = color;
m_gpu_maskram[(offset+i) & 0x7ffff] = mask;
}
}
}

uint16_t namcos21_state::winrun_gpu_videoram_r(offs_t offset)
{
return (m_gpu_videoram[offset]<<8) | m_gpu_maskram[offset];
return (m_gpu_videoram[offset] << 8) | m_gpu_maskram[offset];
}

void namcos21_state::winrun_bitmap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
uint8_t const *const videoram = m_gpu_videoram.get();
//printf("%d %d (%d %d) - %04x %04x %04x|%04x %04x\n",cliprect.top(),cliprect.bottom(),m_screen->vpos(),m_gpu_intc->get_posirq_line(),m_winrun_gpu_register[0],m_winrun_gpu_register[2/2],m_winrun_gpu_register[4/2],m_winrun_gpu_register[0xa/2],m_winrun_gpu_register[0xc/2]);

int const yscroll = -cliprect.top()+(int16_t)m_winrun_gpu_register[0x2/2];
int const xscroll = 0;//m_winrun_gpu_register[0xc/2] >> 7;
int const base = 0x1000+0x100*(m_winrun_color&0xf);
for( int sy=cliprect.top(); sy<=cliprect.bottom(); sy++ )
int const yscroll = -cliprect.top() + (int16_t)m_winrun_gpu_register[0x2/2];
int const xscroll = 0; //m_winrun_gpu_register[0xc/2] >> 7;
int const base = 0x1000 + 0x100 * (m_winrun_color & 0xf);
for (int sy=cliprect.top(); sy<=cliprect.bottom(); sy++)
{
uint8_t const *const pSource = &videoram[((yscroll+sy)&0x3ff)*0x200];
uint8_t const *const pSource = &videoram[((yscroll+sy) & 0x3ff) * 0x200];
uint16_t *const pDest = &bitmap.pix(sy);
for( int sx=cliprect.left(); sx<=cliprect.right(); sx++ )
for (int sx=cliprect.left(); sx<=cliprect.right(); sx++)
{
int const pen = pSource[(sx+xscroll) & 0x1ff];
switch( pen )
switch (pen)
{
case 0xff:
break;
// TODO: additive blending? winrun car select uses register [0xc] for a xscroll value
case 0x00:
pDest[sx] = (pDest[sx]&0x1fff)+0x4000;
pDest[sx] = (pDest[sx] & 0x1fff) + 0x4000;
break;
case 0x01:
pDest[sx] = (pDest[sx]&0x1fff)+0x6000;
pDest[sx] = (pDest[sx] & 0x1fff) + 0x6000;
break;
default:
pDest[sx] = base|pen;
pDest[sx] = base | pen;
break;
}
}
Expand All @@ -486,11 +487,11 @@ void namcos21_state::winrun_bitmap_draw(bitmap_ind16 &bitmap, const rectangle &c

uint32_t namcos21_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
bitmap.fill(0xff, cliprect );
bitmap.fill(0xff, cliprect);

m_namcos21_3d->copy_visible_poly_framebuffer(bitmap, cliprect, 0x7fc0, 0x7ffe);
m_namcos21_3d->copy_visible_poly_framebuffer(bitmap, cliprect, 0, 0x7fbf);
winrun_bitmap_draw(bitmap,cliprect);
winrun_bitmap_draw(bitmap, cliprect);

//popmessage("%04x %04x %04x|%04x %04x",m_winrun_gpu_register[0],m_winrun_gpu_register[2/2],m_winrun_gpu_register[4/2],m_winrun_gpu_register[0xa/2],m_winrun_gpu_register[0xc/2]);

Expand All @@ -506,11 +507,10 @@ uint32_t namcos21_state::screen_update(screen_device &screen, bitmap_ind16 &bitm

[[maybe_unused]] void namcos21_state::video_enable_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA( &m_video_enable ); /* 0x40 = enable */
if( m_video_enable!=0 && m_video_enable!=0x40 )
{
logerror( "unexpected video_enable_w=0x%x\n", m_video_enable );
}
COMBINE_DATA(&m_video_enable); /* 0x40 = enable */

if (m_video_enable!=0 && m_video_enable!=0x40)
logerror("unexpected video_enable_w=0x%x\n", m_video_enable);
}

/***********************************************************/
Expand All @@ -524,9 +524,9 @@ uint16_t namcos21_state::dpram_word_r(offs_t offset)

void namcos21_state::dpram_word_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
if( ACCESSING_BITS_0_7 )
if (ACCESSING_BITS_0_7)
{
m_dpram[offset] = data&0xff;
m_dpram[offset] = data & 0xff;
}
}

Expand Down Expand Up @@ -630,7 +630,7 @@ void namcos21_state::c140_map(address_map &map)

void namcos21_state::configure_c65_namcos21(machine_config &config)
{
NAMCOC65(config, m_c65, 2048000);
NAMCOC65(config, m_c65, 2'048'000);
m_c65->in_pb_callback().set_ioport("MCUB");
m_c65->in_pc_callback().set_ioport("MCUC");
m_c65->in_ph_callback().set_ioport("MCUH");
Expand Down Expand Up @@ -788,7 +788,7 @@ void namcos21_state::sound_bankselect_w(uint8_t data)

void namcos21_state::sound_reset_w(uint8_t data)
{
if (data & 0x01)
if (BIT(data, 0))
{
/* Resume execution */
m_audiocpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
Expand All @@ -803,9 +803,9 @@ void namcos21_state::sound_reset_w(uint8_t data)

void namcos21_state::system_reset_w(uint8_t data)
{
reset_all_subcpus(data & 1 ? CLEAR_LINE : ASSERT_LINE);
reset_all_subcpus(BIT(data, 0) ? CLEAR_LINE : ASSERT_LINE);

if (data & 0x01)
if (BIT(data, 0))
m_maincpu->yield();
}

Expand Down Expand Up @@ -857,7 +857,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(namcos21_state::screen_scanline)
int scanline = param;
// int cur_posirq = get_posirq_scanline()*2;

if (scanline == 240 * 2)
if (scanline == (240 * 2))
{
m_master_intc->vblank_irq_trigger();
m_slave_intc->vblank_irq_trigger();
Expand Down
Loading
Loading