trunk/src/mame/video/tecmo_spr.c
| r30710 | r30711 | |
| 1 | 1 | /* Various Tecmo Sprite implementations |
| 2 | 2 | |
| 3 | | - check wc90.c, tecmo.c, tbowl.c others? - they seem more significantly different but are they close to each other |
| 4 | | (but at the same time use the same 'layout' table as this implementation) |
| 3 | - the various sprite implementations here are slightly different but can clearly be refactored to use |
| 4 | a common base class for the chained drawing even if the position of the attributes etc. varies between |
| 5 | PCB / chip. |
| 5 | 6 | |
| 6 | | - is there a single chip responsible for these, or is it just a family of closely connected implementations? |
| 7 | | (because we seem to need some per-game code right now) |
| 7 | - what chips are involved in implementing these schemes? ttl logic on early ones? customs on later? |
| 8 | 8 | |
| 9 | 9 | */ |
| 10 | 10 | |
| r30710 | r30711 | |
| 16 | 16 | const device_type TECMO_SPRITE = &device_creator<tecmo_spr_device>; |
| 17 | 17 | |
| 18 | 18 | tecmo_spr_device::tecmo_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 19 | | : device_t(mconfig, TECMO_SPRITE, "Teccmo 16-bit Sprite", tag, owner, clock, "tecmo_spr", __FILE__), |
| 20 | | device_video_interface(mconfig, *this), |
| 19 | : device_t(mconfig, TECMO_SPRITE, "Teccmo Chained Sprites", tag, owner, clock, "tecmo_spr", __FILE__), |
| 21 | 20 | m_gfxregion(0), |
| 22 | 21 | m_bootleg(0) |
| 23 | 22 | { |
| r30710 | r30711 | |
| 207 | 206 | } |
| 208 | 207 | } |
| 209 | 208 | |
| 209 | |
| 210 | /* NOT identical to the version above */ |
| 211 | |
| 212 | /* sprite format (tecmo.c): |
| 213 | * |
| 214 | * byte bit usage |
| 215 | * --------+-76543210-+---------------- |
| 216 | 0 | xxxxx--- | bank / upper tile bits |
| 217 | | -----x-- | enable |
| 218 | | ------x- | flip y |
| 219 | | -------x | flip x |
| 220 | 1 | xxxxxxxx | tile number (low bits) |
| 221 | 2 | ------xx | size |
| 222 | 3 | xx-------| priority |
| 223 | | --x----- | upper y co-ord |
| 224 | | ---x---- | upper x co-ord |
| 225 | | ----xxxx | colour |
| 226 | 4 | xxxxxxxx | ypos |
| 227 | 5 | xxxxxxxx | xpos |
| 228 | 6 | -------- | |
| 229 | 7 | -------- | |
| 230 | |
| 231 | */ |
| 232 | |
| 233 | |
| 234 | |
| 235 | void tecmo_spr_device::draw_sprites_8bit(screen_device &screen, bitmap_ind16 &bitmap, gfxdecode_device *gfxdecode, const rectangle &cliprect, UINT8* spriteram, int size, int video_type, int flip_screen) |
| 236 | { |
| 237 | int offs; |
| 238 | |
| 239 | for (offs = size-8;offs >= 0;offs -= 8) |
| 240 | { |
| 241 | int flags = spriteram[offs+3]; |
| 242 | int priority = flags>>6; |
| 243 | int bank = spriteram[offs+0]; |
| 244 | if (bank & 4) |
| 245 | { /* visible */ |
| 246 | int which = spriteram[offs+1]; |
| 247 | int code,xpos,ypos,flipx,flipy,priority_mask,x,y; |
| 248 | int size = spriteram[offs + 2] & 3; |
| 249 | |
| 250 | if (video_type != 0) /* gemini, silkworm */ |
| 251 | code = which + ((bank & 0xf8) << 5); |
| 252 | else /* rygar */ |
| 253 | code = which + ((bank & 0xf0) << 4); |
| 254 | |
| 255 | code &= ~((1 << (size*2)) - 1); |
| 256 | size = 1 << size; |
| 257 | |
| 258 | xpos = spriteram[offs + 5] - ((flags & 0x10) << 4); |
| 259 | ypos = spriteram[offs + 4] - ((flags & 0x20) << 3); |
| 260 | flipx = bank & 1; |
| 261 | flipy = bank & 2; |
| 262 | |
| 263 | if (flip_screen) |
| 264 | { |
| 265 | xpos = 256 - (8 * size) - xpos; |
| 266 | ypos = 256 - (8 * size) - ypos; |
| 267 | flipx = !flipx; |
| 268 | flipy = !flipy; |
| 269 | } |
| 270 | |
| 271 | /* bg: 1; fg:2; text: 4 */ |
| 272 | switch (priority) |
| 273 | { |
| 274 | default: |
| 275 | case 0x0: priority_mask = 0; break; |
| 276 | case 0x1: priority_mask = 0xf0; break; /* obscured by text layer */ |
| 277 | case 0x2: priority_mask = 0xf0|0xcc; break; /* obscured by foreground */ |
| 278 | case 0x3: priority_mask = 0xf0|0xcc|0xaa; break; /* obscured by bg and fg */ |
| 279 | } |
| 280 | |
| 281 | for (y = 0;y < size;y++) |
| 282 | { |
| 283 | for (x = 0;x < size;x++) |
| 284 | { |
| 285 | int sx = xpos + 8*(flipx?(size-1-x):x); |
| 286 | int sy = ypos + 8*(flipy?(size-1-y):y); |
| 287 | gfxdecode->gfx(1)->prio_transpen(bitmap,cliprect, |
| 288 | code + layout[y][x], |
| 289 | flags & 0xf, |
| 290 | flipx,flipy, |
| 291 | sx,sy, |
| 292 | screen.priority(), |
| 293 | priority_mask,0); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | |
| 301 | /* sprite format (wc90.c): |
| 302 | * |
| 303 | * byte bit usage |
| 304 | * --------+-76543210-+---------------- |
| 305 | 0 | xxxxx--- | bank / upper tile bits |
| 306 | |
| 307 | |
| 308 | */ |
| 309 | |
| 310 | |
| 311 | #define WC90_DRAW_SPRITE( code, sx, sy ) \ |
| 312 | gfxdecode->gfx(3)->transpen(bitmap,cliprect, code, flags >> 4, \ |
| 313 | bank&1, bank&2, sx, sy, 0 ) |
| 314 | |
| 315 | static const char p32x32[4][4] = { |
| 316 | { 0, 1, 2, 3 }, |
| 317 | { 1, 0, 3, 2 }, |
| 318 | { 2, 3, 0, 1 }, |
| 319 | { 3, 2, 1, 0 } |
| 320 | }; |
| 321 | |
| 322 | static const char p32x64[4][8] = { |
| 323 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 324 | { 5, 4, 7, 6, 1, 0, 3, 2 }, |
| 325 | { 2, 3, 0, 1, 6, 7, 4, 5 }, |
| 326 | { 7, 6, 5, 4, 3, 2, 1, 0 } |
| 327 | }; |
| 328 | |
| 329 | static const char p64x32[4][8] = { |
| 330 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 331 | { 1, 0, 3, 2, 5, 4, 7, 6 }, |
| 332 | { 6, 7, 4, 5, 2, 3, 0, 1 }, |
| 333 | { 7, 6, 5, 4, 3, 2, 1, 0 } |
| 334 | }; |
| 335 | |
| 336 | static const char p64x64[4][16] = { |
| 337 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, |
| 338 | { 5, 4, 7, 6, 1, 0, 3, 2, 13, 12, 15, 14, 9, 8, 11, 10 }, |
| 339 | { 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5 }, |
| 340 | { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } |
| 341 | }; |
| 342 | |
| 343 | void tecmo_spr_device::draw_wc90_sprite_16x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags ) |
| 344 | { |
| 345 | WC90_DRAW_SPRITE( code, sx, sy ); |
| 346 | } |
| 347 | |
| 348 | void tecmo_spr_device::draw_wc90_sprite_16x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags ) |
| 349 | { |
| 350 | if ( bank & 2 ) { |
| 351 | WC90_DRAW_SPRITE( code+1, sx, sy+16 ); |
| 352 | WC90_DRAW_SPRITE( code, sx, sy ); |
| 353 | } else { |
| 354 | WC90_DRAW_SPRITE( code, sx, sy ); |
| 355 | WC90_DRAW_SPRITE( code+1, sx, sy+16 ); |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | void tecmo_spr_device::draw_wc90_sprite_16x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags ) |
| 360 | { |
| 361 | if ( bank & 2 ) { |
| 362 | WC90_DRAW_SPRITE( code+3, sx, sy+48 ); |
| 363 | WC90_DRAW_SPRITE( code+2, sx, sy+32 ); |
| 364 | WC90_DRAW_SPRITE( code+1, sx, sy+16 ); |
| 365 | WC90_DRAW_SPRITE( code, sx, sy ); |
| 366 | } else { |
| 367 | WC90_DRAW_SPRITE( code, sx, sy ); |
| 368 | WC90_DRAW_SPRITE( code+1, sx, sy+16 ); |
| 369 | WC90_DRAW_SPRITE( code+2, sx, sy+32 ); |
| 370 | WC90_DRAW_SPRITE( code+3, sx, sy+48 ); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | void tecmo_spr_device::draw_wc90_sprite_32x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags ) |
| 375 | { |
| 376 | if ( bank & 1 ) { |
| 377 | WC90_DRAW_SPRITE( code+1, sx+16, sy ); |
| 378 | WC90_DRAW_SPRITE( code, sx, sy ); |
| 379 | } else { |
| 380 | WC90_DRAW_SPRITE( code, sx, sy ); |
| 381 | WC90_DRAW_SPRITE( code+1, sx+16, sy ); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | void tecmo_spr_device::draw_wc90_sprite_32x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags ) |
| 386 | { |
| 387 | const char *p = p32x32[ bank&3 ]; |
| 388 | |
| 389 | WC90_DRAW_SPRITE( code+p[0], sx, sy ); |
| 390 | WC90_DRAW_SPRITE( code+p[1], sx+16, sy ); |
| 391 | WC90_DRAW_SPRITE( code+p[2], sx, sy+16 ); |
| 392 | WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 ); |
| 393 | } |
| 394 | |
| 395 | void tecmo_spr_device::draw_wc90_sprite_32x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code, int sx, int sy, int bank, int flags ) |
| 396 | { |
| 397 | const char *p = p32x64[ bank&3 ]; |
| 398 | |
| 399 | WC90_DRAW_SPRITE( code+p[0], sx, sy ); |
| 400 | WC90_DRAW_SPRITE( code+p[1], sx+16, sy ); |
| 401 | WC90_DRAW_SPRITE( code+p[2], sx, sy+16 ); |
| 402 | WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 ); |
| 403 | WC90_DRAW_SPRITE( code+p[4], sx, sy+32 ); |
| 404 | WC90_DRAW_SPRITE( code+p[5], sx+16, sy+32 ); |
| 405 | WC90_DRAW_SPRITE( code+p[6], sx, sy+48 ); |
| 406 | WC90_DRAW_SPRITE( code+p[7], sx+16, sy+48 ); |
| 407 | } |
| 408 | |
| 409 | void tecmo_spr_device::draw_wc90_sprite_64x16(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags ) |
| 410 | { |
| 411 | if ( bank & 1 ) { |
| 412 | WC90_DRAW_SPRITE( code+3, sx+48, sy ); |
| 413 | WC90_DRAW_SPRITE( code+2, sx+32, sy ); |
| 414 | WC90_DRAW_SPRITE( code+1, sx+16, sy ); |
| 415 | WC90_DRAW_SPRITE( code, sx, sy ); |
| 416 | } else { |
| 417 | WC90_DRAW_SPRITE( code, sx, sy ); |
| 418 | WC90_DRAW_SPRITE( code+1, sx+16, sy ); |
| 419 | WC90_DRAW_SPRITE( code+2, sx+32, sy ); |
| 420 | WC90_DRAW_SPRITE( code+3, sx+48, sy ); |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | void tecmo_spr_device::draw_wc90_sprite_64x32(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags ) |
| 425 | { |
| 426 | const char *p = p64x32[ bank&3 ]; |
| 427 | |
| 428 | WC90_DRAW_SPRITE( code+p[0], sx, sy ); |
| 429 | WC90_DRAW_SPRITE( code+p[1], sx+16, sy ); |
| 430 | WC90_DRAW_SPRITE( code+p[2], sx, sy+16 ); |
| 431 | WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 ); |
| 432 | WC90_DRAW_SPRITE( code+p[4], sx+32, sy ); |
| 433 | WC90_DRAW_SPRITE( code+p[5], sx+48, sy ); |
| 434 | WC90_DRAW_SPRITE( code+p[6], sx+32, sy+16 ); |
| 435 | WC90_DRAW_SPRITE( code+p[7], sx+48, sy+16 ); |
| 436 | } |
| 437 | |
| 438 | void tecmo_spr_device::draw_wc90_sprite_64x64(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code,int sx, int sy, int bank, int flags ) |
| 439 | { |
| 440 | const char *p = p64x64[ bank&3 ]; |
| 441 | |
| 442 | WC90_DRAW_SPRITE( code+p[0], sx, sy ); |
| 443 | WC90_DRAW_SPRITE( code+p[1], sx+16, sy ); |
| 444 | WC90_DRAW_SPRITE( code+p[2], sx, sy+16 ); |
| 445 | WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 ); |
| 446 | WC90_DRAW_SPRITE( code+p[4], sx+32, sy ); |
| 447 | WC90_DRAW_SPRITE( code+p[5], sx+48, sy ); |
| 448 | WC90_DRAW_SPRITE( code+p[6], sx+32, sy+16 ); |
| 449 | WC90_DRAW_SPRITE( code+p[7], sx+48, sy+16 ); |
| 450 | |
| 451 | WC90_DRAW_SPRITE( code+p[8], sx, sy+32 ); |
| 452 | WC90_DRAW_SPRITE( code+p[9], sx+16, sy+32 ); |
| 453 | WC90_DRAW_SPRITE( code+p[10], sx, sy+48 ); |
| 454 | WC90_DRAW_SPRITE( code+p[11], sx+16, sy+48 ); |
| 455 | WC90_DRAW_SPRITE( code+p[12], sx+32, sy+32 ); |
| 456 | WC90_DRAW_SPRITE( code+p[13], sx+48, sy+32 ); |
| 457 | WC90_DRAW_SPRITE( code+p[14], sx+32, sy+48 ); |
| 458 | WC90_DRAW_SPRITE( code+p[15], sx+48, sy+48 ); |
| 459 | } |
| 460 | |
| 461 | void tecmo_spr_device::draw_wc90_sprite_invalid(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int code, int sx, int sy, int bank, int flags ) |
| 462 | { |
| 463 | logerror("8 pixel sprite size not supported\n" ); |
| 464 | } |
| 465 | |
| 466 | static const tecmo_spr_device::draw_wc90_sprites_func draw_wc90_sprites_proc[16] = { |
| 467 | &tecmo_spr_device::draw_wc90_sprite_invalid, /* 0000 = 08x08 */ |
| 468 | &tecmo_spr_device::draw_wc90_sprite_invalid, /* 0001 = 16x08 */ |
| 469 | &tecmo_spr_device::draw_wc90_sprite_invalid, /* 0010 = 32x08 */ |
| 470 | &tecmo_spr_device::draw_wc90_sprite_invalid, /* 0011 = 64x08 */ |
| 471 | &tecmo_spr_device::draw_wc90_sprite_invalid, /* 0100 = 08x16 */ |
| 472 | &tecmo_spr_device::draw_wc90_sprite_16x16, /* 0101 = 16x16 */ |
| 473 | &tecmo_spr_device::draw_wc90_sprite_32x16, /* 0110 = 32x16 */ |
| 474 | &tecmo_spr_device::draw_wc90_sprite_64x16, /* 0111 = 64x16 */ |
| 475 | &tecmo_spr_device::draw_wc90_sprite_invalid, /* 1000 = 08x32 */ |
| 476 | &tecmo_spr_device::draw_wc90_sprite_16x32, /* 1001 = 16x32 */ |
| 477 | &tecmo_spr_device::draw_wc90_sprite_32x32, /* 1010 = 32x32 */ |
| 478 | &tecmo_spr_device::draw_wc90_sprite_64x32, /* 1011 = 64x32 */ |
| 479 | &tecmo_spr_device::draw_wc90_sprite_invalid, /* 1100 = 08x64 */ |
| 480 | &tecmo_spr_device::draw_wc90_sprite_16x64, /* 1101 = 16x64 */ |
| 481 | &tecmo_spr_device::draw_wc90_sprite_32x64, /* 1110 = 32x64 */ |
| 482 | &tecmo_spr_device::draw_wc90_sprite_64x64 /* 1111 = 64x64 */ |
| 483 | }; |
| 484 | |
| 485 | void tecmo_spr_device::draw_wc90_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, UINT8* spriteram, int size, int priority ) |
| 486 | { |
| 487 | int offs, sx,sy, flags, which; |
| 488 | |
| 489 | /* draw all visible sprites of specified priority */ |
| 490 | for (offs = 0;offs < size;offs += 16){ |
| 491 | int bank = spriteram[offs+0]; |
| 492 | |
| 493 | if ( ( bank >> 4 ) == priority ) { |
| 494 | if ( bank & 4 ) { /* visible */ |
| 495 | which = ( spriteram[offs+2] >> 2 ) + ( spriteram[offs+3] << 6 ); |
| 496 | |
| 497 | sx = spriteram[offs + 8] + ( (spriteram[offs + 9] & 3 ) << 8 ); |
| 498 | sy = spriteram[offs + 6] + ( (spriteram[offs + 7] & 1 ) << 8 ); |
| 499 | |
| 500 | if (sx >= 0x0300) sx -= 0x0400; |
| 501 | |
| 502 | flags = spriteram[offs+4]; |
| 503 | (this->*( draw_wc90_sprites_proc[ flags & 0x0f ] ) )(bitmap,cliprect, gfxdecode, which, sx, sy, bank, flags ); |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | #undef WC90_DRAW_SPRITE |
| 510 | |
| 511 | |
| 512 | |
| 513 | void tecmo_spr_device::tbowl_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect, gfxdecode_device *gfxdecode, int xscroll, UINT8* spriteram) |
| 514 | { |
| 515 | int offs; |
| 516 | static const UINT8 layout[8][8] = |
| 517 | { |
| 518 | {0,1,4,5,16,17,20,21}, |
| 519 | {2,3,6,7,18,19,22,23}, |
| 520 | {8,9,12,13,24,25,28,29}, |
| 521 | {10,11,14,15,26,27,30,31}, |
| 522 | {32,33,36,37,48,49,52,53}, |
| 523 | {34,35,38,39,50,51,54,55}, |
| 524 | {40,41,44,45,56,57,60,61}, |
| 525 | {42,43,46,47,58,59,62,63} |
| 526 | }; |
| 527 | |
| 528 | for (offs = 0;offs < 0x800;offs += 8) |
| 529 | { |
| 530 | if (spriteram[offs+0] & 0x80) /* enable */ |
| 531 | { |
| 532 | int code,color,sizex,sizey,flipx,flipy,xpos,ypos; |
| 533 | int x,y;//,priority,priority_mask; |
| 534 | |
| 535 | code = (spriteram[offs+2])+(spriteram[offs+1]<<8); |
| 536 | color = (spriteram[offs+3])&0x1f; |
| 537 | sizex = 1 << ((spriteram[offs+0] & 0x03) >> 0); |
| 538 | sizey = 1 << ((spriteram[offs+0] & 0x0c) >> 2); |
| 539 | |
| 540 | flipx = (spriteram[offs+0])&0x20; |
| 541 | flipy = 0; |
| 542 | xpos = (spriteram[offs+6])+((spriteram[offs+4]&0x03)<<8); |
| 543 | ypos = (spriteram[offs+5])+((spriteram[offs+4]&0x10)<<4); |
| 544 | |
| 545 | /* bg: 1; fg:2; text: 4 */ |
| 546 | |
| 547 | for (y = 0;y < sizey;y++) |
| 548 | { |
| 549 | for (x = 0;x < sizex;x++) |
| 550 | { |
| 551 | int sx = xpos + 8*(flipx?(sizex-1-x):x); |
| 552 | int sy = ypos + 8*(flipy?(sizey-1-y):y); |
| 553 | |
| 554 | sx -= xscroll; |
| 555 | |
| 556 | gfxdecode->gfx(3)->transpen(bitmap,cliprect, |
| 557 | code + layout[y][x], |
| 558 | color, |
| 559 | flipx,flipy, |
| 560 | sx,sy,0 ); |
| 561 | |
| 562 | /* wraparound */ |
| 563 | gfxdecode->gfx(3)->transpen(bitmap,cliprect, |
| 564 | code + layout[y][x], |
| 565 | color, |
| 566 | flipx,flipy, |
| 567 | sx,sy-0x200,0 ); |
| 568 | |
| 569 | /* wraparound */ |
| 570 | gfxdecode->gfx(3)->transpen(bitmap,cliprect, |
| 571 | code + layout[y][x], |
| 572 | color, |
| 573 | flipx,flipy, |
| 574 | sx-0x400,sy,0 ); |
| 575 | |
| 576 | /* wraparound */ |
| 577 | gfxdecode->gfx(3)->transpen(bitmap,cliprect, |
| 578 | code + layout[y][x], |
| 579 | color, |
| 580 | flipx,flipy, |
| 581 | sx-0x400,sy-0x200,0 ); |
| 582 | |
| 583 | |
| 584 | |
| 585 | } |
| 586 | } |
| 587 | } |
| 588 | } |
| 589 | } |
| | No newline at end of file |
trunk/src/mame/video/tbowl.c
| r30710 | r30711 | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
| 122 | | void tbowl_state::tbowl_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect, int xscroll, UINT8* spriteram) |
| 123 | | { |
| 124 | | int offs; |
| 125 | | static const UINT8 layout[8][8] = |
| 126 | | { |
| 127 | | {0,1,4,5,16,17,20,21}, |
| 128 | | {2,3,6,7,18,19,22,23}, |
| 129 | | {8,9,12,13,24,25,28,29}, |
| 130 | | {10,11,14,15,26,27,30,31}, |
| 131 | | {32,33,36,37,48,49,52,53}, |
| 132 | | {34,35,38,39,50,51,54,55}, |
| 133 | | {40,41,44,45,56,57,60,61}, |
| 134 | | {42,43,46,47,58,59,62,63} |
| 135 | | }; |
| 136 | 122 | |
| 137 | | for (offs = 0;offs < 0x800;offs += 8) |
| 138 | | { |
| 139 | | if (spriteram[offs+0] & 0x80) /* enable */ |
| 140 | | { |
| 141 | | int code,color,sizex,sizey,flipx,flipy,xpos,ypos; |
| 142 | | int x,y;//,priority,priority_mask; |
| 143 | | |
| 144 | | code = (spriteram[offs+2])+(spriteram[offs+1]<<8); |
| 145 | | color = (spriteram[offs+3])&0x1f; |
| 146 | | sizex = 1 << ((spriteram[offs+0] & 0x03) >> 0); |
| 147 | | sizey = 1 << ((spriteram[offs+0] & 0x0c) >> 2); |
| 148 | | |
| 149 | | flipx = (spriteram[offs+0])&0x20; |
| 150 | | flipy = 0; |
| 151 | | xpos = (spriteram[offs+6])+((spriteram[offs+4]&0x03)<<8); |
| 152 | | ypos = (spriteram[offs+5])+((spriteram[offs+4]&0x10)<<4); |
| 153 | | |
| 154 | | /* bg: 1; fg:2; text: 4 */ |
| 155 | | |
| 156 | | for (y = 0;y < sizey;y++) |
| 157 | | { |
| 158 | | for (x = 0;x < sizex;x++) |
| 159 | | { |
| 160 | | int sx = xpos + 8*(flipx?(sizex-1-x):x); |
| 161 | | int sy = ypos + 8*(flipy?(sizey-1-y):y); |
| 162 | | |
| 163 | | sx -= xscroll; |
| 164 | | |
| 165 | | m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, |
| 166 | | code + layout[y][x], |
| 167 | | color, |
| 168 | | flipx,flipy, |
| 169 | | sx,sy,0 ); |
| 170 | | |
| 171 | | /* wraparound */ |
| 172 | | m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, |
| 173 | | code + layout[y][x], |
| 174 | | color, |
| 175 | | flipx,flipy, |
| 176 | | sx,sy-0x200,0 ); |
| 177 | | |
| 178 | | /* wraparound */ |
| 179 | | m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, |
| 180 | | code + layout[y][x], |
| 181 | | color, |
| 182 | | flipx,flipy, |
| 183 | | sx-0x400,sy,0 ); |
| 184 | | |
| 185 | | /* wraparound */ |
| 186 | | m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, |
| 187 | | code + layout[y][x], |
| 188 | | color, |
| 189 | | flipx,flipy, |
| 190 | | sx-0x400,sy-0x200,0 ); |
| 191 | | |
| 192 | | |
| 193 | | |
| 194 | | } |
| 195 | | } |
| 196 | | } |
| 197 | | } |
| 198 | | } |
| 199 | | |
| 200 | 123 | UINT32 tbowl_state::screen_update_tbowl_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 201 | 124 | { |
| 202 | 125 | m_bg_tilemap->set_scrollx(0, m_xscroll ); |
| r30710 | r30711 | |
| 208 | 131 | |
| 209 | 132 | bitmap.fill(0x100, cliprect); /* is there a register controling the colour? looks odd when screen is blank */ |
| 210 | 133 | m_bg_tilemap->draw(screen, bitmap, cliprect, 0,0); |
| 211 | | tbowl_draw_sprites(bitmap,cliprect, 0, m_spriteram); |
| 134 | m_sprgen->tbowl_draw_sprites(bitmap,cliprect, m_gfxdecode, 0, m_spriteram); |
| 212 | 135 | m_bg2_tilemap->draw(screen, bitmap, cliprect, 0,0); |
| 213 | 136 | m_tx_tilemap->draw(screen, bitmap, cliprect, 0,0); |
| 214 | 137 | |
| r30710 | r30711 | |
| 226 | 149 | |
| 227 | 150 | bitmap.fill(0x100, cliprect); /* is there a register controling the colour? looks odd when screen is blank */ |
| 228 | 151 | m_bg_tilemap->draw(screen, bitmap, cliprect, 0,0); |
| 229 | | tbowl_draw_sprites(bitmap,cliprect, 32*8, m_spriteram); |
| 152 | m_sprgen->tbowl_draw_sprites(bitmap,cliprect, m_gfxdecode, 32*8, m_spriteram); |
| 230 | 153 | m_bg2_tilemap->draw(screen, bitmap, cliprect, 0,0); |
| 231 | 154 | m_tx_tilemap->draw(screen, bitmap, cliprect, 0,0); |
| 232 | 155 | |
trunk/src/mame/video/wc90.c
| r30710 | r30711 | |
| 120 | 120 | |
| 121 | 121 | ***************************************************************************/ |
| 122 | 122 | |
| 123 | | #define WC90_DRAW_SPRITE( code, sx, sy ) \ |
| 124 | | m_gfxdecode->gfx(3)->transpen(bitmap,cliprect, code, flags >> 4, \ |
| 125 | | bank&1, bank&2, sx, sy, 0 ) |
| 126 | 123 | |
| 127 | | static const char p32x32[4][4] = { |
| 128 | | { 0, 1, 2, 3 }, |
| 129 | | { 1, 0, 3, 2 }, |
| 130 | | { 2, 3, 0, 1 }, |
| 131 | | { 3, 2, 1, 0 } |
| 132 | | }; |
| 133 | | |
| 134 | | static const char p32x64[4][8] = { |
| 135 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 136 | | { 5, 4, 7, 6, 1, 0, 3, 2 }, |
| 137 | | { 2, 3, 0, 1, 6, 7, 4, 5 }, |
| 138 | | { 7, 6, 5, 4, 3, 2, 1, 0 } |
| 139 | | }; |
| 140 | | |
| 141 | | static const char p64x32[4][8] = { |
| 142 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 143 | | { 1, 0, 3, 2, 5, 4, 7, 6 }, |
| 144 | | { 6, 7, 4, 5, 2, 3, 0, 1 }, |
| 145 | | { 7, 6, 5, 4, 3, 2, 1, 0 } |
| 146 | | }; |
| 147 | | |
| 148 | | static const char p64x64[4][16] = { |
| 149 | | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, |
| 150 | | { 5, 4, 7, 6, 1, 0, 3, 2, 13, 12, 15, 14, 9, 8, 11, 10 }, |
| 151 | | { 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5 }, |
| 152 | | { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } |
| 153 | | }; |
| 154 | | |
| 155 | | void wc90_state::draw_sprite_16x16(bitmap_ind16 &bitmap, const rectangle &cliprect, int code,int sx, int sy, int bank, int flags ) |
| 156 | | { |
| 157 | | WC90_DRAW_SPRITE( code, sx, sy ); |
| 158 | | } |
| 159 | | |
| 160 | | void wc90_state::draw_sprite_16x32(bitmap_ind16 &bitmap, const rectangle &cliprect, int code,int sx, int sy, int bank, int flags ) |
| 161 | | { |
| 162 | | if ( bank & 2 ) { |
| 163 | | WC90_DRAW_SPRITE( code+1, sx, sy+16 ); |
| 164 | | WC90_DRAW_SPRITE( code, sx, sy ); |
| 165 | | } else { |
| 166 | | WC90_DRAW_SPRITE( code, sx, sy ); |
| 167 | | WC90_DRAW_SPRITE( code+1, sx, sy+16 ); |
| 168 | | } |
| 169 | | } |
| 170 | | |
| 171 | | void wc90_state::draw_sprite_16x64(bitmap_ind16 &bitmap, const rectangle &cliprect, int code,int sx, int sy, int bank, int flags ) |
| 172 | | { |
| 173 | | if ( bank & 2 ) { |
| 174 | | WC90_DRAW_SPRITE( code+3, sx, sy+48 ); |
| 175 | | WC90_DRAW_SPRITE( code+2, sx, sy+32 ); |
| 176 | | WC90_DRAW_SPRITE( code+1, sx, sy+16 ); |
| 177 | | WC90_DRAW_SPRITE( code, sx, sy ); |
| 178 | | } else { |
| 179 | | WC90_DRAW_SPRITE( code, sx, sy ); |
| 180 | | WC90_DRAW_SPRITE( code+1, sx, sy+16 ); |
| 181 | | WC90_DRAW_SPRITE( code+2, sx, sy+32 ); |
| 182 | | WC90_DRAW_SPRITE( code+3, sx, sy+48 ); |
| 183 | | } |
| 184 | | } |
| 185 | | |
| 186 | | void wc90_state::draw_sprite_32x16(bitmap_ind16 &bitmap, const rectangle &cliprect, int code,int sx, int sy, int bank, int flags ) |
| 187 | | { |
| 188 | | if ( bank & 1 ) { |
| 189 | | WC90_DRAW_SPRITE( code+1, sx+16, sy ); |
| 190 | | WC90_DRAW_SPRITE( code, sx, sy ); |
| 191 | | } else { |
| 192 | | WC90_DRAW_SPRITE( code, sx, sy ); |
| 193 | | WC90_DRAW_SPRITE( code+1, sx+16, sy ); |
| 194 | | } |
| 195 | | } |
| 196 | | |
| 197 | | void wc90_state::draw_sprite_32x32(bitmap_ind16 &bitmap, const rectangle &cliprect, int code,int sx, int sy, int bank, int flags ) |
| 198 | | { |
| 199 | | const char *p = p32x32[ bank&3 ]; |
| 200 | | |
| 201 | | WC90_DRAW_SPRITE( code+p[0], sx, sy ); |
| 202 | | WC90_DRAW_SPRITE( code+p[1], sx+16, sy ); |
| 203 | | WC90_DRAW_SPRITE( code+p[2], sx, sy+16 ); |
| 204 | | WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 ); |
| 205 | | } |
| 206 | | |
| 207 | | void wc90_state::draw_sprite_32x64(bitmap_ind16 &bitmap, const rectangle &cliprect, int code, int sx, int sy, int bank, int flags ) |
| 208 | | { |
| 209 | | const char *p = p32x64[ bank&3 ]; |
| 210 | | |
| 211 | | WC90_DRAW_SPRITE( code+p[0], sx, sy ); |
| 212 | | WC90_DRAW_SPRITE( code+p[1], sx+16, sy ); |
| 213 | | WC90_DRAW_SPRITE( code+p[2], sx, sy+16 ); |
| 214 | | WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 ); |
| 215 | | WC90_DRAW_SPRITE( code+p[4], sx, sy+32 ); |
| 216 | | WC90_DRAW_SPRITE( code+p[5], sx+16, sy+32 ); |
| 217 | | WC90_DRAW_SPRITE( code+p[6], sx, sy+48 ); |
| 218 | | WC90_DRAW_SPRITE( code+p[7], sx+16, sy+48 ); |
| 219 | | } |
| 220 | | |
| 221 | | void wc90_state::draw_sprite_64x16(bitmap_ind16 &bitmap, const rectangle &cliprect, int code,int sx, int sy, int bank, int flags ) |
| 222 | | { |
| 223 | | if ( bank & 1 ) { |
| 224 | | WC90_DRAW_SPRITE( code+3, sx+48, sy ); |
| 225 | | WC90_DRAW_SPRITE( code+2, sx+32, sy ); |
| 226 | | WC90_DRAW_SPRITE( code+1, sx+16, sy ); |
| 227 | | WC90_DRAW_SPRITE( code, sx, sy ); |
| 228 | | } else { |
| 229 | | WC90_DRAW_SPRITE( code, sx, sy ); |
| 230 | | WC90_DRAW_SPRITE( code+1, sx+16, sy ); |
| 231 | | WC90_DRAW_SPRITE( code+2, sx+32, sy ); |
| 232 | | WC90_DRAW_SPRITE( code+3, sx+48, sy ); |
| 233 | | } |
| 234 | | } |
| 235 | | |
| 236 | | void wc90_state::draw_sprite_64x32(bitmap_ind16 &bitmap, const rectangle &cliprect, int code,int sx, int sy, int bank, int flags ) |
| 237 | | { |
| 238 | | const char *p = p64x32[ bank&3 ]; |
| 239 | | |
| 240 | | WC90_DRAW_SPRITE( code+p[0], sx, sy ); |
| 241 | | WC90_DRAW_SPRITE( code+p[1], sx+16, sy ); |
| 242 | | WC90_DRAW_SPRITE( code+p[2], sx, sy+16 ); |
| 243 | | WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 ); |
| 244 | | WC90_DRAW_SPRITE( code+p[4], sx+32, sy ); |
| 245 | | WC90_DRAW_SPRITE( code+p[5], sx+48, sy ); |
| 246 | | WC90_DRAW_SPRITE( code+p[6], sx+32, sy+16 ); |
| 247 | | WC90_DRAW_SPRITE( code+p[7], sx+48, sy+16 ); |
| 248 | | } |
| 249 | | |
| 250 | | void wc90_state::draw_sprite_64x64(bitmap_ind16 &bitmap, const rectangle &cliprect, int code,int sx, int sy, int bank, int flags ) |
| 251 | | { |
| 252 | | const char *p = p64x64[ bank&3 ]; |
| 253 | | |
| 254 | | WC90_DRAW_SPRITE( code+p[0], sx, sy ); |
| 255 | | WC90_DRAW_SPRITE( code+p[1], sx+16, sy ); |
| 256 | | WC90_DRAW_SPRITE( code+p[2], sx, sy+16 ); |
| 257 | | WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 ); |
| 258 | | WC90_DRAW_SPRITE( code+p[4], sx+32, sy ); |
| 259 | | WC90_DRAW_SPRITE( code+p[5], sx+48, sy ); |
| 260 | | WC90_DRAW_SPRITE( code+p[6], sx+32, sy+16 ); |
| 261 | | WC90_DRAW_SPRITE( code+p[7], sx+48, sy+16 ); |
| 262 | | |
| 263 | | WC90_DRAW_SPRITE( code+p[8], sx, sy+32 ); |
| 264 | | WC90_DRAW_SPRITE( code+p[9], sx+16, sy+32 ); |
| 265 | | WC90_DRAW_SPRITE( code+p[10], sx, sy+48 ); |
| 266 | | WC90_DRAW_SPRITE( code+p[11], sx+16, sy+48 ); |
| 267 | | WC90_DRAW_SPRITE( code+p[12], sx+32, sy+32 ); |
| 268 | | WC90_DRAW_SPRITE( code+p[13], sx+48, sy+32 ); |
| 269 | | WC90_DRAW_SPRITE( code+p[14], sx+32, sy+48 ); |
| 270 | | WC90_DRAW_SPRITE( code+p[15], sx+48, sy+48 ); |
| 271 | | } |
| 272 | | |
| 273 | | void wc90_state::draw_sprite_invalid(bitmap_ind16 &bitmap, const rectangle &cliprect, int code, int sx, int sy, int bank, int flags ) |
| 274 | | { |
| 275 | | logerror("8 pixel sprite size not supported\n" ); |
| 276 | | } |
| 277 | | |
| 278 | | static const wc90_state::draw_sprites_func draw_sprites_proc[16] = { |
| 279 | | &wc90_state::draw_sprite_invalid, /* 0000 = 08x08 */ |
| 280 | | &wc90_state::draw_sprite_invalid, /* 0001 = 16x08 */ |
| 281 | | &wc90_state::draw_sprite_invalid, /* 0010 = 32x08 */ |
| 282 | | &wc90_state::draw_sprite_invalid, /* 0011 = 64x08 */ |
| 283 | | &wc90_state::draw_sprite_invalid, /* 0100 = 08x16 */ |
| 284 | | &wc90_state::draw_sprite_16x16, /* 0101 = 16x16 */ |
| 285 | | &wc90_state::draw_sprite_32x16, /* 0110 = 32x16 */ |
| 286 | | &wc90_state::draw_sprite_64x16, /* 0111 = 64x16 */ |
| 287 | | &wc90_state::draw_sprite_invalid, /* 1000 = 08x32 */ |
| 288 | | &wc90_state::draw_sprite_16x32, /* 1001 = 16x32 */ |
| 289 | | &wc90_state::draw_sprite_32x32, /* 1010 = 32x32 */ |
| 290 | | &wc90_state::draw_sprite_64x32, /* 1011 = 64x32 */ |
| 291 | | &wc90_state::draw_sprite_invalid, /* 1100 = 08x64 */ |
| 292 | | &wc90_state::draw_sprite_16x64, /* 1101 = 16x64 */ |
| 293 | | &wc90_state::draw_sprite_32x64, /* 1110 = 32x64 */ |
| 294 | | &wc90_state::draw_sprite_64x64 /* 1111 = 64x64 */ |
| 295 | | }; |
| 296 | | |
| 297 | | void wc90_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority ) |
| 298 | | { |
| 299 | | UINT8 *spriteram = m_spriteram; |
| 300 | | int offs, sx,sy, flags, which; |
| 301 | | |
| 302 | | /* draw all visible sprites of specified priority */ |
| 303 | | for (offs = 0;offs < m_spriteram.bytes();offs += 16){ |
| 304 | | int bank = spriteram[offs+0]; |
| 305 | | |
| 306 | | if ( ( bank >> 4 ) == priority ) { |
| 307 | | if ( bank & 4 ) { /* visible */ |
| 308 | | which = ( spriteram[offs+2] >> 2 ) + ( spriteram[offs+3] << 6 ); |
| 309 | | |
| 310 | | sx = spriteram[offs + 8] + ( (spriteram[offs + 9] & 3 ) << 8 ); |
| 311 | | sy = spriteram[offs + 6] + ( (spriteram[offs + 7] & 1 ) << 8 ); |
| 312 | | |
| 313 | | if (sx >= 0x0300) sx -= 0x0400; |
| 314 | | |
| 315 | | flags = spriteram[offs+4]; |
| 316 | | (this->*( draw_sprites_proc[ flags & 0x0f ] ) )(bitmap,cliprect, which, sx, sy, bank, flags ); |
| 317 | | } |
| 318 | | } |
| 319 | | } |
| 320 | | } |
| 321 | | |
| 322 | | #undef WC90_DRAW_SPRITE |
| 323 | | |
| 324 | | |
| 325 | 124 | UINT32 wc90_state::screen_update_wc90(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 326 | 125 | { |
| 327 | 126 | m_bg_tilemap->set_scrollx(0,m_scroll2xlo[0] + 256 * m_scroll2xhi[0]); |
| r30710 | r30711 | |
| 331 | 130 | m_tx_tilemap->set_scrollx(0,m_scroll0xlo[0] + 256 * m_scroll0xhi[0]); |
| 332 | 131 | m_tx_tilemap->set_scrolly(0,m_scroll0ylo[0] + 256 * m_scroll0yhi[0]); |
| 333 | 132 | |
| 334 | | // draw_sprites(bitmap,cliprect, 3 ); |
| 133 | // m_sprgen->draw_sprites(bitmap,cliprect, m_gfxdecode, m_spriteram, m_spriteram.bytes(), 3); // unused |
| 335 | 134 | m_bg_tilemap->draw(screen, bitmap, cliprect, 0,0); |
| 336 | | draw_sprites(bitmap,cliprect, 2 ); |
| 135 | m_sprgen->draw_wc90_sprites(bitmap,cliprect, m_gfxdecode, m_spriteram, m_spriteram.bytes(), 2); |
| 337 | 136 | m_fg_tilemap->draw(screen, bitmap, cliprect, 0,0); |
| 338 | | draw_sprites(bitmap,cliprect, 1 ); |
| 137 | m_sprgen->draw_wc90_sprites(bitmap,cliprect, m_gfxdecode, m_spriteram, m_spriteram.bytes(), 1); |
| 339 | 138 | m_tx_tilemap->draw(screen, bitmap, cliprect, 0,0); |
| 340 | | draw_sprites(bitmap,cliprect, 0 ); |
| 139 | m_sprgen->draw_wc90_sprites(bitmap,cliprect, m_gfxdecode, m_spriteram, m_spriteram.bytes(), 0); |
| 341 | 140 | return 0; |
| 342 | 141 | } |