Merge pull request #6255 from cam900/twin16_clip

twin16.cpp : Restrict sprite drawing routine into screen cliprect
This commit is contained in:
R. Belmont 2020-02-04 13:03:23 -05:00 committed by GitHub
commit e2cc495dd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -106,7 +106,7 @@ protected:
int set_sprite_timer(); int set_sprite_timer();
void spriteram_process(); void spriteram_process();
void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap ); void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
int spriteram_process_enable(); int spriteram_process_enable();
void twin16_postload(); void twin16_postload();
}; };

View File

@ -260,7 +260,7 @@ void twin16_state::spriteram_process( )
m_need_process_spriteram = 0; m_need_process_spriteram = 0;
} }
void twin16_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap ) void twin16_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
{ {
const uint16_t *source = 0x1800+m_spriteram->buffer() + 0x800 - 4; const uint16_t *source = 0x1800+m_spriteram->buffer() + 0x800 - 4;
const uint16_t *finish = 0x1800+m_spriteram->buffer(); const uint16_t *finish = 0x1800+m_spriteram->buffer();
@ -331,14 +331,14 @@ void twin16_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap )
xpos = 320-xpos-width; xpos = 320-xpos-width;
flipx = !flipx; flipx = !flipx;
} }
if( xpos>=320 ) xpos -= 65536; if( xpos>cliprect.max_x ) xpos -= 65536;
if( ypos>=256 ) ypos -= 65536; if( ypos>cliprect.max_y ) ypos -= 65536;
/* slow slow slow, but it's ok for now */ /* slow slow slow, but it's ok for now */
for( y=0; y<height; y++, pen_data += width/4 ) for( y=0; y<height; y++, pen_data += width/4 )
{ {
int sy = (flipy)?(ypos+height-1-y):(ypos+y); int sy = (flipy)?(ypos+height-1-y):(ypos+y);
if( sy>=16 && sy<256-16 ) if( sy>=cliprect.min_y && sy<=cliprect.max_y )
{ {
uint16_t *dest = &bitmap.pix16(sy); uint16_t *dest = &bitmap.pix16(sy);
uint8_t *pdest = &screen.priority().pix8(sy); uint8_t *pdest = &screen.priority().pix8(sy);
@ -346,7 +346,7 @@ void twin16_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap )
for( x=0; x<width; x++ ) for( x=0; x<width; x++ )
{ {
int sx = (flipx)?(xpos+width-1-x):(xpos+x); int sx = (flipx)?(xpos+width-1-x):(xpos+x);
if( sx>=0 && sx<320 ) if( sx>=cliprect.min_x && sx<=cliprect.max_x )
{ {
uint16_t pen = pen_data[x>>2]>>((~x&3)<<2)&0xf; uint16_t pen = pen_data[x>>2]>>((~x&3)<<2)&0xf;
@ -538,7 +538,7 @@ uint32_t twin16_state::screen_update_twin16(screen_device &screen, bitmap_ind16
break; break;
} }
draw_sprites( screen, bitmap ); draw_sprites( screen, bitmap, cliprect );
m_fixed_tmap->draw(screen, bitmap, cliprect, 0); m_fixed_tmap->draw(screen, bitmap, cliprect, 0);
return 0; return 0;