From 7c734d3e4cae59688f78f76661d0c707aa6dc059 Mon Sep 17 00:00:00 2001 From: David Haywood Date: Tue, 20 May 2014 21:54:03 +0000 Subject: [PATCH] more function collapse adjustments prior to trying to proper refactoring (nw) --- src/mame/drivers/spbactn.c | 1 + src/mame/video/gaiden.c | 4 +- src/mame/video/spbactn.c | 12 +- src/mame/video/tecmo16.c | 4 +- src/mame/video/tecmo_spr.c | 249 ++++++++++++++++++------------------- src/mame/video/tecmo_spr.h | 8 +- 6 files changed, 134 insertions(+), 144 deletions(-) diff --git a/src/mame/drivers/spbactn.c b/src/mame/drivers/spbactn.c index 4b674baafc4..683924a531b 100644 --- a/src/mame/drivers/spbactn.c +++ b/src/mame/drivers/spbactn.c @@ -477,6 +477,7 @@ static MACHINE_CONFIG_START( spbactnp, spbactn_state ) MCFG_DEVICE_ADD("spritegen", TECMO_SPRITE, 0) MCFG_TECMO_SPRITE_GFX_REGION(2) + MCFG_TECMO_SPRITE_ALT_FORMAT /* sound hardware - different? */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/video/gaiden.c b/src/mame/video/gaiden.c index dd977beb257..6706fa5bf87 100644 --- a/src/mame/video/gaiden.c +++ b/src/mame/video/gaiden.c @@ -377,7 +377,7 @@ UINT32 gaiden_state::screen_update_gaiden(screen_device &screen, bitmap_rgb32 &b m_text_layer->draw(screen, m_tile_bitmap_fg, cliprect, 0, 4); /* draw sprites into a 16-bit bitmap */ - m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen()); + m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen(), -1, m_sprite_bitmap); /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ blendbitmaps(bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect); @@ -402,7 +402,7 @@ UINT32 gaiden_state::screen_update_raiga(screen_device &screen, bitmap_rgb32 &bi m_text_layer->draw(screen, m_tile_bitmap_fg, cliprect, 0, 4); /* draw sprites into a 16-bit bitmap */ - m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen()); + m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, m_sprite_sizey, m_spr_offset_y, flip_screen(), -1, m_sprite_bitmap); /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ blendbitmaps(bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect); diff --git a/src/mame/video/spbactn.c b/src/mame/video/spbactn.c index 405e360e2b6..8d70f667f0a 100644 --- a/src/mame/video/spbactn.c +++ b/src/mame/video/spbactn.c @@ -153,19 +153,17 @@ int spbactn_state::draw_video(screen_device &screen, bitmap_rgb32 &bitmap, const m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, TILEMAP_DRAW_OPAQUE, 0); - - if (m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, cliprect, 0, alt_sprites, m_spvideoram)) + if (m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_tile_bitmap_fg, cliprect, m_spvideoram, 0, 0, flip_screen(), 0, m_tile_bitmap_bg)) { m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, 0, 0); } - m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, cliprect, 1, alt_sprites, m_spvideoram); - + m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_tile_bitmap_fg, cliprect, m_spvideoram, 0, 0, flip_screen(), 1, m_tile_bitmap_bg); + m_fg_tilemap->draw(screen, m_tile_bitmap_fg, cliprect, 0, 0); - - m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_fg, cliprect, 2, alt_sprites, m_spvideoram); - m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_fg, cliprect, 3, alt_sprites, m_spvideoram); + m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_tile_bitmap_fg, cliprect, m_spvideoram, 0, 0, flip_screen(), 2, m_tile_bitmap_fg); + m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_tile_bitmap_fg, cliprect, m_spvideoram, 0, 0, flip_screen(), 3, m_tile_bitmap_fg); /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ blendbitmaps(m_palette, bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, cliprect); diff --git a/src/mame/video/tecmo16.c b/src/mame/video/tecmo16.c index 131d4f053c9..e35d14cbd42 100644 --- a/src/mame/video/tecmo16.c +++ b/src/mame/video/tecmo16.c @@ -250,8 +250,8 @@ UINT32 tecmo16_state::screen_update_tecmo16(screen_device &screen, bitmap_rgb32 m_tx_tilemap->draw(screen, m_tile_bitmap_fg, cliprect, 0, 4); /* draw sprites into a 16-bit bitmap */ - if (m_game_is_riot) m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, 0, 0, flip_screen()); - else m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, 2, 0, flip_screen()); + if (m_game_is_riot) m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, 0, 0, flip_screen(), -1, m_sprite_bitmap); + else m_sprgen->gaiden_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, cliprect, m_spriteram, 2, 0, flip_screen(), -1, m_sprite_bitmap); /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ diff --git a/src/mame/video/tecmo_spr.c b/src/mame/video/tecmo_spr.c index a379c76882d..7fdc287a9e8 100644 --- a/src/mame/video/tecmo_spr.c +++ b/src/mame/video/tecmo_spr.c @@ -19,7 +19,8 @@ const device_type TECMO_SPRITE = &device_creator; tecmo_spr_device::tecmo_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, TECMO_SPRITE, "Teccmo 16-bit Sprite", tag, owner, clock, "tecmo_spr", __FILE__), device_video_interface(mconfig, *this), - m_gfxregion(0) + m_gfxregion(0), + m_altformat(0) { } @@ -37,7 +38,12 @@ void tecmo_spr_device::set_gfx_region(device_t &device, int gfxregion) { tecmo_spr_device &dev = downcast(device); dev.m_gfxregion = gfxregion; -// printf("decospr_device::set_gfx_region()\n"); +} + +void tecmo_spr_device::set_alt_format(device_t &device) +{ + tecmo_spr_device &dev = downcast(device); + dev.m_altformat = 1; } @@ -73,124 +79,69 @@ static const UINT8 layout[8][8] = * 5,6,7| | unused */ -/* sprite format (galspnbl): - * - * word bit usage - * --------+-fedcba9876543210-+---------------- - * 0 | ---------------x | flip x - * | --------------x- | flip y - * | -------------x-- | enable - * | ----------xx---- | priority? - * | ---------x------ | flicker? - * 1 | xxxxxxxxxxxxxxxx | code - * 2 | --------xxxx---- | color - * | --------------xx | size: 8x8, 16x16, 32x32, 64x64 - * 3 | xxxxxxxxxxxxxxxx | y position - * 4 | xxxxxxxxxxxxxxxx | x position - * 5,6,7| | unused - */ - - -/* from gals pinball (which was in turn from ninja gaiden) */ -int tecmo_spr_device::spbactn_draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, bool alt_sprites, UINT16* spriteram) -{ - int count = 0; - int offs; - - for (offs = (0x1000 - 16) / 2; offs >= 0; offs -= 8) - { - int sx, sy, code, color, size, attr, flipx, flipy; - int col, row; - - attr = spriteram[offs]; - - int pri = (spriteram[offs] & 0x0030); -// int pri = (spriteram[offs+2] & 0x0030); - - - if ((attr & 0x0004) && - ((pri & 0x0030) >> 4) == priority) - { - flipx = attr & 0x0001; - flipy = attr & 0x0002; - - code = spriteram[offs + 1]; - - if (alt_sprites) - { - color = spriteram[offs + 0]; - } - else - { - color = spriteram[offs + 2]; - } - - size = 1 << (spriteram[offs + 2] & 0x0003); /* 1,2,4,8 */ - color = (color & 0x00f0) >> 4; - - sx = spriteram[offs + 4]; - sy = spriteram[offs + 3]; - - attr &= ~0x0040; /* !!! */ - - if (attr & 0x0040) - color |= 0x0180; - else - color |= 0x0080; - - - for (row = 0; row < size; row++) - { - for (col = 0; col < size; col++) - { - int x = sx + 8 * (flipx ? (size - 1 - col) : col); - int y = sy + 8 * (flipy ? (size - 1 - row) : row); - - gfxdecode->gfx(m_gfxregion)->transpen_raw(bitmap,cliprect, - code + layout[row][col], - gfxdecode->gfx(m_gfxregion)->colorbase() + color * gfxdecode->gfx(2)->granularity(), - flipx, flipy, - x, y, - 0); - } - } - - count++; - } - } - - return count; -} - - - #define NUM_SPRITES 256 -void tecmo_spr_device::gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen ) +int tecmo_spr_device::gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flip_screen, int pri_hack, bitmap_ind16 &bitmap_prihack ) { gfx_element *gfx = gfxdecode->gfx(m_gfxregion); const UINT16 *source = (NUM_SPRITES - 1) * 8 + spriteram; int count = NUM_SPRITES; + int drawn = 0; + int screenwidth = screen.width(); + + + int attributes_word = 0; + int tilenumber_word = 1; + int colour_word = 2; + int yposition_word = 3; + int xposition_word = 4; + int enable_word = attributes_word; + + if (m_altformat) // spbactn proto, this isn't right.. there are more changes I think + { + colour_word = 0; + attributes_word = 2; + } + + int xmask; + + if (screenwidth == 512) + xmask = 512; + else + xmask = 256; /* draw all sprites from front to back */ while (count--) { - UINT32 attributes = source[0]; + UINT32 attributes = source[attributes_word]; UINT32 priority_mask; int col,row; - if (attributes & 0x04) + if (source[enable_word] & 0x04) { UINT32 priority = (attributes >> 6) & 3; + + // hack for spbactn which still calls us multi-pass (and uses different bits into the mixer as priority?) + if (pri_hack != -1) + { + int alt_pri; + alt_pri = (source[0] & 0x0030)>>4; + if (alt_pri != pri_hack) + { + source -= 8; + continue; + } + } + UINT32 flipx = (attributes & 1); UINT32 flipy = (attributes & 2); - UINT32 color = source[2]; + UINT32 color = source[colour_word]; UINT32 sizex = 1 << ((color >> 0) & 3); /* 1,2,4,8 */ UINT32 sizey = 1 << ((color >> sprite_sizey) & 3); /* 1,2,4,8 */ - /* raiga needs something like this */ - UINT32 number = (source[1]); + /* raiga & fstarfrc need something like this */ + UINT32 number = (source[tilenumber_word]); if (sizex >= 2) number &= ~0x01; if (sizey >= 2) number &= ~0x02; @@ -199,14 +150,14 @@ void tecmo_spr_device::gaiden_draw_sprites( screen_device &screen, gfxdecode_dev if (sizex >= 8) number &= ~0x10; if (sizey >= 8) number &= ~0x20; - int ypos = (source[3] + spr_offset_y) & 0x01ff; - int xpos = source[4] & 0x01ff; + int ypos = (source[yposition_word] + spr_offset_y) & 0x01ff; + int xpos = source[xposition_word] & ((xmask*2)-1); color = (color >> 4) & 0x0f; /* wraparound */ - if (xpos >= 256) - xpos -= 512; + if (xpos >= xmask) + xpos -= (xmask*2); if (ypos >= 256) ypos -= 512; @@ -234,57 +185,92 @@ void tecmo_spr_device::gaiden_draw_sprites( screen_device &screen, gfxdecode_dev case 0x3: priority_mask = 0xf0 | 0xcc | 0xaa; break; /* obscured by bg and fg */ } + bitmap_ind16* bitmap; - /* blending */ - if (attributes & 0x20) + + + if (pri_hack == -1) { - color |= 0x80; - - for (row = 0; row < sizey; row++) + /* blending */ + if (attributes & 0x20) { - for (col = 0; col < sizex; col++) - { - int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); - int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); + color |= 0x80; + bitmap = &bitmap_sp; + } + else + { + bitmap = (priority >= 2) ? &bitmap_bg : &bitmap_fg; + } + } + else // spbactn + { + // this is nonsense + attributes &= ~0x0040; /* !!! */ - gfx->prio_transpen_raw(bitmap_sp,cliprect, + if (attributes & 0x0040) + color |= 0x0180; + else + color |= 0x0080; + + bitmap = &bitmap_prihack; + } + + for (row = 0; row < sizey; row++) + { + for (col = 0; col < sizex; col++) + { + int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); + int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); + + if (pri_hack == -1) + { + gfx->prio_transpen_raw(*bitmap, cliprect, number + layout[row][col], gfx->colorbase() + color * gfx->granularity(), flipx, flipy, sx, sy, screen.priority(), priority_mask, 0); } - } - } - else - { - bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg; - - for (row = 0; row < sizey; row++) - { - for (col = 0; col < sizex; col++) + else // spbactn { - int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); - int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); - - gfx->prio_transpen_raw(bitmap,cliprect, + gfx->transpen_raw(*bitmap, cliprect, number + layout[row][col], gfx->colorbase() + color * gfx->granularity(), flipx, flipy, sx, sy, - screen.priority(), priority_mask, 0); + 0); } } - } + } + + drawn++; + } source -= 8; } + + return drawn; } - - - // comad bootleg of spbactn + +/* sprite format (galspnbl): + * + * word bit usage + * --------+-fedcba9876543210-+---------------- + * 0 | ---------------x | flip x + * | --------------x- | flip y + * | -------------x-- | enable + * | ----------xx---- | priority? + * | ---------x------ | flicker? + * 1 | xxxxxxxxxxxxxxxx | code + * 2 | --------xxxx---- | color + * | --------------xx | size: 8x8, 16x16, 32x32, 64x64 + * 3 | xxxxxxxxxxxxxxxx | y position + * 4 | xxxxxxxxxxxxxxxx | x position + * 5,6,7| | unused + */ + void tecmo_spr_device::galspnbl_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes ) { int offs; @@ -321,6 +307,7 @@ void tecmo_spr_device::galspnbl_draw_sprites( screen_device &screen, gfxdecode_d color, flipx,flipy, x,y,0); + } } } diff --git a/src/mame/video/tecmo_spr.h b/src/mame/video/tecmo_spr.h index dcbd44c2b10..c48ccbff211 100644 --- a/src/mame/video/tecmo_spr.h +++ b/src/mame/video/tecmo_spr.h @@ -8,10 +8,10 @@ class tecmo_spr_device : public device_t, public: tecmo_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); static void set_gfx_region(device_t &device, int gfxregion); + static void set_alt_format(device_t &device); void galspnbl_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, UINT16* spriteram, int spriteram_bytes ); - void gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flipscreen ); - int spbactn_draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority, bool alt_sprites, UINT16* spriteram); + int gaiden_draw_sprites( screen_device &screen, gfxdecode_device *gfxdecode, bitmap_ind16 &bitmap_bg, bitmap_ind16 &bitmap_fg, bitmap_ind16 &bitmap_sp, const rectangle &cliprect, UINT16* spriteram, int sprite_sizey, int spr_offset_y, int flipscreen, int pri_hack, bitmap_ind16 &bitmap_prihack ); protected: @@ -19,6 +19,8 @@ protected: virtual void device_reset(); UINT8 m_gfxregion; + int m_altformat; // the super pinball action proto has some differences + private: }; @@ -28,3 +30,5 @@ extern const device_type TECMO_SPRITE; #define MCFG_TECMO_SPRITE_GFX_REGION(_region) \ tecmo_spr_device::set_gfx_region(*device, _region); +#define MCFG_TECMO_SPRITE_ALT_FORMAT \ + tecmo_spr_device::set_alt_format(*device);