Skip to content

Commit

Permalink
namcona1.cpp: Added dynamic screen visible area change effect, used m…
Browse files Browse the repository at this point in the history
…ostly by Numan Athletics on transitions [Angelo Salese]
  • Loading branch information
angelosa committed Feb 2, 2018
1 parent 5fea8cc commit 266c662
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 18 deletions.
11 changes: 6 additions & 5 deletions src/mame/drivers/namcona1.cpp
Expand Up @@ -954,7 +954,8 @@ MACHINE_CONFIG_START(namcona1_state::namcona1)
MCFG_SCREEN_REFRESH_RATE(60)
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
MCFG_SCREEN_SIZE(40*8, 32*8)
MCFG_SCREEN_VISIBLE_AREA(8, 38*8-1-8, 4*8, 32*8-1)
// MCFG_SCREEN_VISIBLE_AREA(8, 38*8-1-8, 4*8, 32*8-1)
MCFG_SCREEN_VISIBLE_AREA(0, 38*8-1, 4*8, 32*8-1)
MCFG_SCREEN_UPDATE_DRIVER(namcona1_state, screen_update)
MCFG_SCREEN_PALETTE("palette")

Expand All @@ -977,8 +978,8 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_DERIVED(namcona1_state::namcona1w, namcona1)

/* video hardware */
MCFG_SCREEN_MODIFY("screen")
MCFG_SCREEN_VISIBLE_AREA(0, 38*8-1-0, 4*8, 32*8-1)
// MCFG_SCREEN_MODIFY("screen")
// MCFG_SCREEN_VISIBLE_AREA(0, 38*8-1, 4*8, 32*8-1)
MACHINE_CONFIG_END


Expand All @@ -996,8 +997,8 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_DERIVED(namcona1_state::namcona2w, namcona2)

/* video hardware */
MCFG_SCREEN_MODIFY("screen")
MCFG_SCREEN_VISIBLE_AREA(0, 38*8-1-0, 4*8, 32*8-1)
// MCFG_SCREEN_MODIFY("screen")
// MCFG_SCREEN_VISIBLE_AREA(0, 38*8-1, 4*8, 32*8-1)
MACHINE_CONFIG_END

/* NA-1 Hardware */
Expand Down
3 changes: 2 additions & 1 deletion src/mame/includes/namcona1.h
Expand Up @@ -152,7 +152,8 @@ class namcona1_state : public driver_device
void draw_background(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int which, int primask );
void tilemap_get_info(tile_data &tileinfo, int tile_index, const uint16_t *tilemap_videoram, bool use_4bpp_gfx);
void blit_setup( int format, int *bytes_per_row, int *pitch, int mode );
void draw_pixel_line( uint16_t *pDest, uint8_t *pPri, uint16_t *pSource, const pen_t *paldata );
void draw_pixel_line( const rectangle &cliprect, uint16_t *pDest, uint8_t *pPri, uint16_t *pSource, const pen_t *paldata );
bool screen_enabled( const rectangle &cliprect);
TILE_GET_INFO_MEMBER(tilemap_get_info0);
TILE_GET_INFO_MEMBER(tilemap_get_info1);
TILE_GET_INFO_MEMBER(tilemap_get_info2);
Expand Down
55 changes: 43 additions & 12 deletions src/mame/video/namcona1.cpp
Expand Up @@ -3,8 +3,11 @@
/* Namco System NA1/2 Video Hardware */

/*
TODO:
- dynamic screen resolution (changes between emeralda test mode and normal game)
Notes:
- fa/fghtatck: Global screen window effect cut one line from top/bottom of screen, especially noticeable with credit display.
It's a btanb according to a PCB video I've seen -AS.
TODO:
- non-shadow pixels for sprites flagged to enable shadows have bad colors
*/

Expand Down Expand Up @@ -428,16 +431,18 @@ void namcona1_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, c
}
} /* draw_sprites */

void namcona1_state::draw_pixel_line( uint16_t *pDest, uint8_t *pPri, uint16_t *pSource, const pen_t *paldata )
void namcona1_state::draw_pixel_line( const rectangle &cliprect, uint16_t *pDest, uint8_t *pPri, uint16_t *pSource, const pen_t *paldata )
{
int x;
for( x=0; x<38*8; x+=2 )
{
{
uint16_t data = *pSource++;
pPri[x+0] = 0xff;
pPri[x+1] = 0xff;
pDest[x+0] = paldata[data>>8];
pDest[x+1] = paldata[data&0xff];
if(x >= cliprect.min_x && x <= cliprect.max_x)
pDest[x+0] = paldata[data>>8];
if(x+1 >= cliprect.min_x && x+1 <= cliprect.max_x)
pDest[x+1] = paldata[data&0xff];
} /* next x */
} /* draw_pixel_line */

Expand Down Expand Up @@ -497,15 +502,15 @@ void namcona1_state::draw_background(screen_device &screen, bitmap_ind16 &bitmap
{
// TODO: not convinced about this trigger
if( xdata == 0xc001 )
{
{
/* This is a simplification, but produces the correct behavior for the only game that uses this
* feature, Numan Athletics.
*/
// TODO: with this it breaks colors in VS Express event, likely pal bank is somewhere else in this mode, assuming it has one anyway?
//const pen_t *paldata = &m_palette->pen(m_bg_tilemap[which]->palette_offset());
const pen_t *paldata = &m_palette->pen(0);

draw_pixel_line(&bitmap.pix16(line),
draw_pixel_line(cliprect, &bitmap.pix16(line),
&screen.priority().pix8(line),
m_videoram + ydata + 25,
paldata );
Expand All @@ -521,19 +526,45 @@ void namcona1_state::draw_background(screen_device &screen, bitmap_ind16 &bitmap
}
} /* draw_background */

// CRTC safety checks
bool namcona1_state::screen_enabled(const rectangle &cliprect)
{
if(cliprect.min_x < 0)
return false;

if(cliprect.max_x < 0)
return false;

if(cliprect.min_x > cliprect.max_x)
return false;

if(cliprect.min_y > cliprect.max_y)
return false;

return true;
}

uint32_t namcona1_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int which;
int priority;
// CRTC visible area parameters
// (used mostly by Numan Athletics for global screen window effects, cfr. start of events/title screen to demo mode transitions)
rectangle display_rect;
display_rect.min_x = m_vreg[0x80/2]-0x48;
display_rect.max_x = m_vreg[0x82/2]-0x48-1;
display_rect.min_y = std::max((int)m_vreg[0x84/2], cliprect.min_y);
display_rect.max_y = std::min((int)m_vreg[0x86/2]-1, cliprect.max_y);

/* int flipscreen = m_vreg[0x98/2]; (TBA) */

screen.priority().fill(0, cliprect );

bitmap.fill(0xff, cliprect ); /* background color? */

if( m_vreg[0x8e/2] )
{ /* gfx enabled */
if( m_vreg[0x8e/2] && screen_enabled(display_rect) == true)
{
/* gfx enabled */
if( m_palette_is_dirty )
{
/* palette updates are delayed when graphics are disabled */
Expand Down Expand Up @@ -564,12 +595,12 @@ uint32_t namcona1_state::screen_update(screen_device &screen, bitmap_ind16 &bitm
}
if( pri == priority )
{
draw_background(screen,bitmap,cliprect,which,priority);
draw_background(screen,bitmap,display_rect,which,priority);
}
} /* next tilemap */
} /* next priority level */

draw_sprites(screen,bitmap,cliprect);
draw_sprites(screen,bitmap,display_rect);
} /* gfx enabled */
return 0;
}
Expand Down

0 comments on commit 266c662

Please sign in to comment.