trunk/src/mame/video/tecmo_spr.c
| r30575 | r30576 | |
| 19 | 19 | tecmo_spr_device::tecmo_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 20 | 20 | : device_t(mconfig, TECMO_SPRITE, "Teccmo 16-bit Sprite", tag, owner, clock, "tecmo_spr", __FILE__), |
| 21 | 21 | device_video_interface(mconfig, *this), |
| 22 | | m_gfxregion(0) |
| 22 | m_gfxregion(0), |
| 23 | m_altformat(0) |
| 23 | 24 | { |
| 24 | 25 | } |
| 25 | 26 | |
| r30575 | r30576 | |
| 37 | 38 | { |
| 38 | 39 | tecmo_spr_device &dev = downcast<tecmo_spr_device &>(device); |
| 39 | 40 | dev.m_gfxregion = gfxregion; |
| 40 | | // printf("decospr_device::set_gfx_region()\n"); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | void tecmo_spr_device::set_alt_format(device_t &device) |
| 44 | { |
| 45 | tecmo_spr_device &dev = downcast<tecmo_spr_device &>(device); |
| 46 | dev.m_altformat = 1; |
| 47 | } |
| 43 | 48 | |
| 49 | |
| 44 | 50 | static const UINT8 layout[8][8] = |
| 45 | 51 | { |
| 46 | 52 | { 0, 1, 4, 5,16,17,20,21}, |
| r30575 | r30576 | |
| 73 | 79 | * 5,6,7| | unused |
| 74 | 80 | */ |
| 75 | 81 | |
| 76 | | /* sprite format (galspnbl): |
| 77 | | * |
| 78 | | * word bit usage |
| 79 | | * --------+-fedcba9876543210-+---------------- |
| 80 | | * 0 | ---------------x | flip x |
| 81 | | * | --------------x- | flip y |
| 82 | | * | -------------x-- | enable |
| 83 | | * | ----------xx---- | priority? |
| 84 | | * | ---------x------ | flicker? |
| 85 | | * 1 | xxxxxxxxxxxxxxxx | code |
| 86 | | * 2 | --------xxxx---- | color |
| 87 | | * | --------------xx | size: 8x8, 16x16, 32x32, 64x64 |
| 88 | | * 3 | xxxxxxxxxxxxxxxx | y position |
| 89 | | * 4 | xxxxxxxxxxxxxxxx | x position |
| 90 | | * 5,6,7| | unused |
| 91 | | */ |
| 82 | #define NUM_SPRITES 256 |
| 92 | 83 | |
| 93 | | |
| 94 | | /* from gals pinball (which was in turn from ninja gaiden) */ |
| 95 | | 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) |
| 84 | 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 ) |
| 96 | 85 | { |
| 97 | | int count = 0; |
| 98 | | int offs; |
| 86 | gfx_element *gfx = gfxdecode->gfx(m_gfxregion); |
| 87 | const UINT16 *source = (NUM_SPRITES - 1) * 8 + spriteram; |
| 88 | int count = NUM_SPRITES; |
| 89 | int drawn = 0; |
| 90 | int screenwidth = screen.width(); |
| 99 | 91 | |
| 100 | | for (offs = (0x1000 - 16) / 2; offs >= 0; offs -= 8) |
| 101 | | { |
| 102 | | int sx, sy, code, color, size, attr, flipx, flipy; |
| 103 | | int col, row; |
| 104 | 92 | |
| 105 | | attr = spriteram[offs]; |
| 93 | int attributes_word = 0; |
| 94 | int tilenumber_word = 1; |
| 95 | int colour_word = 2; |
| 96 | int yposition_word = 3; |
| 97 | int xposition_word = 4; |
| 98 | int enable_word = attributes_word; |
| 106 | 99 | |
| 107 | | int pri = (spriteram[offs] & 0x0030); |
| 108 | | // int pri = (spriteram[offs+2] & 0x0030); |
| 109 | | |
| 110 | | |
| 111 | | if ((attr & 0x0004) && |
| 112 | | ((pri & 0x0030) >> 4) == priority) |
| 113 | | { |
| 114 | | flipx = attr & 0x0001; |
| 115 | | flipy = attr & 0x0002; |
| 116 | | |
| 117 | | code = spriteram[offs + 1]; |
| 118 | | |
| 119 | | if (alt_sprites) |
| 120 | | { |
| 121 | | color = spriteram[offs + 0]; |
| 122 | | } |
| 123 | | else |
| 124 | | { |
| 125 | | color = spriteram[offs + 2]; |
| 126 | | } |
| 127 | | |
| 128 | | size = 1 << (spriteram[offs + 2] & 0x0003); /* 1,2,4,8 */ |
| 129 | | color = (color & 0x00f0) >> 4; |
| 130 | | |
| 131 | | sx = spriteram[offs + 4]; |
| 132 | | sy = spriteram[offs + 3]; |
| 133 | | |
| 134 | | attr &= ~0x0040; /* !!! */ |
| 135 | | |
| 136 | | if (attr & 0x0040) |
| 137 | | color |= 0x0180; |
| 138 | | else |
| 139 | | color |= 0x0080; |
| 140 | | |
| 141 | | |
| 142 | | for (row = 0; row < size; row++) |
| 143 | | { |
| 144 | | for (col = 0; col < size; col++) |
| 145 | | { |
| 146 | | int x = sx + 8 * (flipx ? (size - 1 - col) : col); |
| 147 | | int y = sy + 8 * (flipy ? (size - 1 - row) : row); |
| 148 | | |
| 149 | | gfxdecode->gfx(m_gfxregion)->transpen_raw(bitmap,cliprect, |
| 150 | | code + layout[row][col], |
| 151 | | gfxdecode->gfx(m_gfxregion)->colorbase() + color * gfxdecode->gfx(2)->granularity(), |
| 152 | | flipx, flipy, |
| 153 | | x, y, |
| 154 | | 0); |
| 155 | | } |
| 156 | | } |
| 157 | | |
| 158 | | count++; |
| 159 | | } |
| 100 | if (m_altformat) // spbactn proto, this isn't right.. there are more changes I think |
| 101 | { |
| 102 | colour_word = 0; |
| 103 | attributes_word = 2; |
| 160 | 104 | } |
| 161 | 105 | |
| 162 | | return count; |
| 163 | | } |
| 106 | int xmask; |
| 164 | 107 | |
| 108 | if (screenwidth == 512) |
| 109 | xmask = 512; |
| 110 | else |
| 111 | xmask = 256; |
| 165 | 112 | |
| 166 | | |
| 167 | | #define NUM_SPRITES 256 |
| 168 | | |
| 169 | | 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 ) |
| 170 | | { |
| 171 | | gfx_element *gfx = gfxdecode->gfx(m_gfxregion); |
| 172 | | const UINT16 *source = (NUM_SPRITES - 1) * 8 + spriteram; |
| 173 | | int count = NUM_SPRITES; |
| 174 | | |
| 175 | 113 | /* draw all sprites from front to back */ |
| 176 | 114 | while (count--) |
| 177 | 115 | { |
| 178 | | UINT32 attributes = source[0]; |
| 116 | UINT32 attributes = source[attributes_word]; |
| 179 | 117 | UINT32 priority_mask; |
| 180 | 118 | int col,row; |
| 181 | 119 | |
| 182 | | if (attributes & 0x04) |
| 120 | if (source[enable_word] & 0x04) |
| 183 | 121 | { |
| 184 | 122 | UINT32 priority = (attributes >> 6) & 3; |
| 123 | |
| 124 | // hack for spbactn which still calls us multi-pass (and uses different bits into the mixer as priority?) |
| 125 | if (pri_hack != -1) |
| 126 | { |
| 127 | int alt_pri; |
| 128 | alt_pri = (source[0] & 0x0030)>>4; |
| 129 | if (alt_pri != pri_hack) |
| 130 | { |
| 131 | source -= 8; |
| 132 | continue; |
| 133 | } |
| 134 | } |
| 135 | |
| 185 | 136 | UINT32 flipx = (attributes & 1); |
| 186 | 137 | UINT32 flipy = (attributes & 2); |
| 187 | 138 | |
| 188 | | UINT32 color = source[2]; |
| 139 | UINT32 color = source[colour_word]; |
| 189 | 140 | UINT32 sizex = 1 << ((color >> 0) & 3); /* 1,2,4,8 */ |
| 190 | 141 | UINT32 sizey = 1 << ((color >> sprite_sizey) & 3); /* 1,2,4,8 */ |
| 191 | 142 | |
| 192 | | /* raiga needs something like this */ |
| 193 | | UINT32 number = (source[1]); |
| 143 | /* raiga & fstarfrc need something like this */ |
| 144 | UINT32 number = (source[tilenumber_word]); |
| 194 | 145 | |
| 195 | 146 | if (sizex >= 2) number &= ~0x01; |
| 196 | 147 | if (sizey >= 2) number &= ~0x02; |
| r30575 | r30576 | |
| 199 | 150 | if (sizex >= 8) number &= ~0x10; |
| 200 | 151 | if (sizey >= 8) number &= ~0x20; |
| 201 | 152 | |
| 202 | | int ypos = (source[3] + spr_offset_y) & 0x01ff; |
| 203 | | int xpos = source[4] & 0x01ff; |
| 153 | int ypos = (source[yposition_word] + spr_offset_y) & 0x01ff; |
| 154 | int xpos = source[xposition_word] & ((xmask*2)-1); |
| 204 | 155 | |
| 205 | 156 | color = (color >> 4) & 0x0f; |
| 206 | 157 | |
| 207 | 158 | /* wraparound */ |
| 208 | | if (xpos >= 256) |
| 209 | | xpos -= 512; |
| 159 | if (xpos >= xmask) |
| 160 | xpos -= (xmask*2); |
| 210 | 161 | if (ypos >= 256) |
| 211 | 162 | ypos -= 512; |
| 212 | 163 | |
| r30575 | r30576 | |
| 234 | 185 | case 0x3: priority_mask = 0xf0 | 0xcc | 0xaa; break; /* obscured by bg and fg */ |
| 235 | 186 | } |
| 236 | 187 | |
| 188 | bitmap_ind16* bitmap; |
| 237 | 189 | |
| 238 | | /* blending */ |
| 239 | | if (attributes & 0x20) |
| 190 | |
| 191 | |
| 192 | if (pri_hack == -1) |
| 240 | 193 | { |
| 241 | | color |= 0x80; |
| 194 | /* blending */ |
| 195 | if (attributes & 0x20) |
| 196 | { |
| 197 | color |= 0x80; |
| 198 | bitmap = &bitmap_sp; |
| 199 | } |
| 200 | else |
| 201 | { |
| 202 | bitmap = (priority >= 2) ? &bitmap_bg : &bitmap_fg; |
| 203 | } |
| 204 | } |
| 205 | else // spbactn |
| 206 | { |
| 207 | // this is nonsense |
| 208 | attributes &= ~0x0040; /* !!! */ |
| 242 | 209 | |
| 243 | | for (row = 0; row < sizey; row++) |
| 210 | if (attributes & 0x0040) |
| 211 | color |= 0x0180; |
| 212 | else |
| 213 | color |= 0x0080; |
| 214 | |
| 215 | bitmap = &bitmap_prihack; |
| 216 | } |
| 217 | |
| 218 | for (row = 0; row < sizey; row++) |
| 219 | { |
| 220 | for (col = 0; col < sizex; col++) |
| 244 | 221 | { |
| 245 | | for (col = 0; col < sizex; col++) |
| 246 | | { |
| 247 | | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 248 | | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 222 | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 223 | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 249 | 224 | |
| 250 | | gfx->prio_transpen_raw(bitmap_sp,cliprect, |
| 225 | if (pri_hack == -1) |
| 226 | { |
| 227 | gfx->prio_transpen_raw(*bitmap, cliprect, |
| 251 | 228 | number + layout[row][col], |
| 252 | 229 | gfx->colorbase() + color * gfx->granularity(), |
| 253 | 230 | flipx, flipy, |
| 254 | 231 | sx, sy, |
| 255 | 232 | screen.priority(), priority_mask, 0); |
| 256 | 233 | } |
| 257 | | } |
| 258 | | } |
| 259 | | else |
| 260 | | { |
| 261 | | bitmap_ind16 &bitmap = (priority >= 2) ? bitmap_bg : bitmap_fg; |
| 262 | | |
| 263 | | for (row = 0; row < sizey; row++) |
| 264 | | { |
| 265 | | for (col = 0; col < sizex; col++) |
| 234 | else // spbactn |
| 266 | 235 | { |
| 267 | | int sx = xpos + 8 * (flipx ? (sizex - 1 - col) : col); |
| 268 | | int sy = ypos + 8 * (flipy ? (sizey - 1 - row) : row); |
| 269 | | |
| 270 | | gfx->prio_transpen_raw(bitmap,cliprect, |
| 236 | gfx->transpen_raw(*bitmap, cliprect, |
| 271 | 237 | number + layout[row][col], |
| 272 | 238 | gfx->colorbase() + color * gfx->granularity(), |
| 273 | 239 | flipx, flipy, |
| 274 | 240 | sx, sy, |
| 275 | | screen.priority(), priority_mask, 0); |
| 241 | 0); |
| 276 | 242 | } |
| 277 | 243 | } |
| 278 | | } |
| 244 | } |
| 245 | |
| 246 | drawn++; |
| 247 | |
| 279 | 248 | } |
| 280 | 249 | source -= 8; |
| 281 | 250 | } |
| 251 | |
| 252 | return drawn; |
| 282 | 253 | } |
| 283 | 254 | |
| 255 | // comad bootleg of spbactn |
| 284 | 256 | |
| 257 | /* sprite format (galspnbl): |
| 258 | * |
| 259 | * word bit usage |
| 260 | * --------+-fedcba9876543210-+---------------- |
| 261 | * 0 | ---------------x | flip x |
| 262 | * | --------------x- | flip y |
| 263 | * | -------------x-- | enable |
| 264 | * | ----------xx---- | priority? |
| 265 | * | ---------x------ | flicker? |
| 266 | * 1 | xxxxxxxxxxxxxxxx | code |
| 267 | * 2 | --------xxxx---- | color |
| 268 | * | --------------xx | size: 8x8, 16x16, 32x32, 64x64 |
| 269 | * 3 | xxxxxxxxxxxxxxxx | y position |
| 270 | * 4 | xxxxxxxxxxxxxxxx | x position |
| 271 | * 5,6,7| | unused |
| 272 | */ |
| 285 | 273 | |
| 286 | | |
| 287 | | // comad bootleg of spbactn |
| 288 | 274 | 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 ) |
| 289 | 275 | { |
| 290 | 276 | int offs; |
| r30575 | r30576 | |
| 321 | 307 | color, |
| 322 | 308 | flipx,flipy, |
| 323 | 309 | x,y,0); |
| 310 | |
| 324 | 311 | } |
| 325 | 312 | } |
| 326 | 313 | } |
trunk/src/mame/video/spbactn.c
| r30575 | r30576 | |
| 153 | 153 | m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 154 | 154 | |
| 155 | 155 | |
| 156 | | |
| 157 | | if (m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, cliprect, 0, alt_sprites, m_spvideoram)) |
| 156 | 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)) |
| 158 | 157 | { |
| 159 | 158 | m_bg_tilemap->draw(screen, m_tile_bitmap_bg, cliprect, 0, 0); |
| 160 | 159 | } |
| 161 | 160 | |
| 162 | | m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_bg, cliprect, 1, alt_sprites, m_spvideoram); |
| 163 | | |
| 161 | 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); |
| 162 | |
| 164 | 163 | m_fg_tilemap->draw(screen, m_tile_bitmap_fg, cliprect, 0, 0); |
| 165 | 164 | |
| 165 | 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); |
| 166 | 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); |
| 166 | 167 | |
| 167 | | m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_fg, cliprect, 2, alt_sprites, m_spvideoram); |
| 168 | | m_sprgen->spbactn_draw_sprites(screen, m_gfxdecode, m_tile_bitmap_fg, cliprect, 3, alt_sprites, m_spvideoram); |
| 169 | | |
| 170 | 168 | /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ |
| 171 | 169 | blendbitmaps(m_palette, bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, cliprect); |
| 172 | 170 | return 0; |
trunk/src/mame/video/gaiden.c
| r30575 | r30576 | |
| 377 | 377 | m_text_layer->draw(screen, m_tile_bitmap_fg, cliprect, 0, 4); |
| 378 | 378 | |
| 379 | 379 | /* draw sprites into a 16-bit bitmap */ |
| 380 | | 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()); |
| 380 | 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); |
| 381 | 381 | |
| 382 | 382 | /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ |
| 383 | 383 | blendbitmaps(bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect); |
| r30575 | r30576 | |
| 402 | 402 | m_text_layer->draw(screen, m_tile_bitmap_fg, cliprect, 0, 4); |
| 403 | 403 | |
| 404 | 404 | /* draw sprites into a 16-bit bitmap */ |
| 405 | | 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()); |
| 405 | 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); |
| 406 | 406 | |
| 407 | 407 | /* mix & blend the tilemaps and sprites into a 32-bit bitmap */ |
| 408 | 408 | blendbitmaps(bitmap, m_tile_bitmap_bg, m_tile_bitmap_fg, m_sprite_bitmap, 0, 0, cliprect); |