src/mame/video/jagobj.c
| r5453 | r5454 | |
| 80 | 80 | { |
| 81 | 81 | if (firstpix & 7) |
| 82 | 82 | { |
| 83 | | UINT32 pixsrc = src[firstpix / 8]; |
| 83 | UINT32 pixsrc = src[firstpix >> 3]; |
| 84 | 84 | while (firstpix & 7) |
| 85 | 85 | { |
| 86 | | int pix = (pixsrc >> (4 * (~firstpix & 7))) & 0x0f; |
| 86 | int pix = (pixsrc >> ((~firstpix & 7) << 2)) & 0x0f; |
| 87 | 87 | if ((!(flags & 4) || pix) && (UINT32)xpos < 760) |
| 88 | 88 | { |
| 89 | 89 | if (!(flags & 2)) |
| r5453 | r5454 | |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | | firstpix /= 8; |
| 100 | | iwidth /= 8; |
| 99 | firstpix >>= 3; |
| 100 | iwidth >>= 3; |
| 101 | 101 | iwidth -= firstpix; |
| 102 | 102 | |
| 103 | 103 | while (iwidth-- > 0) |
| r5453 | r5454 | |
| 178 | 178 | xpos += dxpos; |
| 179 | 179 | } |
| 180 | 180 | else |
| 181 | | xpos += 8 * dxpos; |
| 181 | xpos += dxpos << 3; |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| r5453 | r5454 | |
| 246 | 246 | { |
| 247 | 247 | if (firstpix & 3) |
| 248 | 248 | { |
| 249 | | UINT32 pixsrc = src[firstpix / 4]; |
| 249 | UINT32 pixsrc = src[firstpix >> 2]; |
| 250 | 250 | while (firstpix & 3) |
| 251 | 251 | { |
| 252 | | UINT8 pix = pixsrc >> (8 * (~firstpix & 3)); |
| 252 | UINT8 pix = pixsrc >> ((~firstpix & 3) << 3); |
| 253 | 253 | if ((!(flags & 4) || pix) && (UINT32)xpos < 760) |
| 254 | 254 | { |
| 255 | 255 | if (!(flags & 2)) |
| r5453 | r5454 | |
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | | firstpix /= 4; |
| 266 | | iwidth /= 4; |
| 265 | firstpix >>= 2; |
| 266 | iwidth >>= 2; |
| 267 | 267 | iwidth -= firstpix; |
| 268 | 268 | |
| 269 | 269 | while (iwidth-- > 0) |
| r5453 | r5454 | |
| 308 | 308 | xpos += dxpos; |
| 309 | 309 | } |
| 310 | 310 | else |
| 311 | | xpos += 4 * dxpos; |
| 311 | xpos += dxpos << 2; |
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
| r5453 | r5454 | |
| 376 | 376 | { |
| 377 | 377 | if (firstpix & 1) |
| 378 | 378 | { |
| 379 | | UINT16 pix = src[firstpix / 2]; |
| 379 | UINT16 pix = src[firstpix >> 1]; |
| 380 | 380 | if ((!(flags & 4) || pix) && (UINT32)xpos < 760) |
| 381 | 381 | { |
| 382 | 382 | if (!(flags & 2)) |
| r5453 | r5454 | |
| 387 | 387 | xpos += dxpos; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | | firstpix /= 2; |
| 391 | | iwidth /= 2; |
| 390 | firstpix >>= 1; |
| 391 | iwidth >>= 1; |
| 392 | 392 | iwidth -= firstpix; |
| 393 | 393 | |
| 394 | 394 | while (iwidth-- > 0) |
| r5453 | r5454 | |
| 415 | 415 | xpos += dxpos; |
| 416 | 416 | } |
| 417 | 417 | else |
| 418 | | xpos += 2 * dxpos; |
| 418 | xpos += dxpos << 1; |
| 419 | 419 | } |
| 420 | 420 | } |
| 421 | 421 | |
| r5453 | r5454 | |
| 473 | 473 | |
| 474 | 474 | |
| 475 | 475 | |
| 476 | |
| 477 | |
| 478 | /************************************* |
| 479 | * |
| 480 | * 32bpp bitmap renderers - needs to be verified |
| 481 | * |
| 482 | *************************************/ |
| 483 | |
| 484 | INLINE void bitmap_32_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos) |
| 485 | { |
| 486 | iwidth -= firstpix; |
| 487 | |
| 488 | while (iwidth-- > 0) |
| 489 | { |
| 490 | UINT32 pix = src[firstpix++]; |
| 491 | |
| 492 | if (xpos < 760) |
| 493 | { |
| 494 | scanline[xpos++] = (pix&0xffff0000)>>16; |
| 495 | scanline[xpos++] = pix&0xffff; |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | static void bitmap_32_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 501 | { |
| 502 | bitmap_32_draw(firstpix, iwidth, src, xpos, 0, 1); |
| 503 | } |
| 504 | |
| 505 | static void bitmap_32_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 506 | { |
| 507 | bitmap_32_draw(firstpix, iwidth, src, xpos, 1, -1); |
| 508 | } |
| 509 | |
| 510 | static void bitmap_32_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 511 | { |
| 512 | bitmap_32_draw(firstpix, iwidth, src, xpos, 2, 1); |
| 513 | } |
| 514 | |
| 515 | static void bitmap_32_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 516 | { |
| 517 | bitmap_32_draw(firstpix, iwidth, src, xpos, 3, -1); |
| 518 | } |
| 519 | |
| 520 | static void bitmap_32_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 521 | { |
| 522 | bitmap_32_draw(firstpix, iwidth, src, xpos, 4, 1); |
| 523 | } |
| 524 | |
| 525 | static void bitmap_32_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 526 | { |
| 527 | bitmap_32_draw(firstpix, iwidth, src, xpos, 5, -1); |
| 528 | } |
| 529 | |
| 530 | static void bitmap_32_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 531 | { |
| 532 | bitmap_32_draw(firstpix, iwidth, src, xpos, 6, 1); |
| 533 | } |
| 534 | |
| 535 | static void bitmap_32_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos) |
| 536 | { |
| 537 | bitmap_32_draw(firstpix, iwidth, src, xpos, 7, -1); |
| 538 | } |
| 539 | |
| 540 | static void (*const bitmap32[8])(INT32, INT32, UINT32 *, INT32) = |
| 541 | { |
| 542 | bitmap_32_0, |
| 543 | bitmap_32_1, |
| 544 | bitmap_32_2, |
| 545 | bitmap_32_3, |
| 546 | bitmap_32_4, |
| 547 | bitmap_32_5, |
| 548 | bitmap_32_6, |
| 549 | bitmap_32_7 |
| 550 | }; |
| 551 | |
| 552 | |
| 553 | |
| 476 | 554 | INLINE UINT8 lookup_pixel(const UINT32 *src, int i, int pitch, int depth) |
| 477 | 555 | { |
| 478 | 556 | int ppl = 32 / depth; |
| 479 | | UINT32 data = src[((i & ppl) / ppl) + ((i / (ppl*2)) * 2 * pitch)]; |
| 557 | UINT32 data = src[((i & ppl) / ppl) + ((i / (ppl<<1)) * (pitch<<1))]; |
| 480 | 558 | UINT8 pix = (data >> ((~i & (ppl-1)) * depth)) & ((1 << depth) - 1); |
| 481 | 559 | return pix; |
| 482 | 560 | } |
| r5453 | r5454 | |
| 641 | 719 | (*bitmap16[flags & 7])(firstpix, iwidth, src, xpos); |
| 642 | 720 | break; |
| 643 | 721 | |
| 722 | /* 32bpp case */ |
| 723 | case 5: |
| 724 | /* only handle pitch=1 for now */ |
| 725 | if (pitch != 1) |
| 726 | logerror("Unhandled pitch = %d\n", pitch); |
| 727 | |
| 728 | (*bitmap32[flags & 7])(firstpix, iwidth, src, xpos); |
| 729 | break; |
| 730 | |
| 644 | 731 | default: |
| 645 | 732 | fprintf(stderr, "Unhandled bitmap source depth = %d\n", depthlog); |
| 646 | 733 | break; |
| r5453 | r5454 | |
| 724 | 811 | int dxpos = (flags & 1) ? -1 : 1; |
| 725 | 812 | int xpix = firstpix, yinc; |
| 726 | 813 | |
| 727 | | /* only handle pitch=0 for now */ |
| 814 | /* only handle pitch=1 (sequential data) for now */ |
| 728 | 815 | if (pitch != 1) |
| 729 | 816 | logerror("Unhandled pitch = %d\n", pitch); |
| 730 | 817 | if (flags & 2) |
| r5453 | r5454 | |
| 742 | 829 | /* switch off the depth */ |
| 743 | 830 | switch (depthlog) |
| 744 | 831 | { |
| 832 | case 0: /* needs to be verified */ |
| 833 | { |
| 834 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut; |
| 835 | clut += _index & 0x01; |
| 836 | |
| 837 | /* render in phrases */ |
| 838 | while (xpix < iwidth) |
| 839 | { |
| 840 | UINT16 pix = (src[xpix >> 5] >> (~xpix & 31)) & 0x01; |
| 841 | |
| 842 | while (xleft > 0) |
| 843 | { |
| 844 | if (xpos >= 0 && xpos < 760 && (pix || !(flags & 4))) |
| 845 | scanline[xpos] = clut[BYTE_XOR_BE(pix)]; |
| 846 | xpos += dxpos; |
| 847 | xleft -= 0x20; |
| 848 | } |
| 849 | while (xleft <= 0) |
| 850 | xleft += hscale, xpix++; |
| 851 | } |
| 852 | break; |
| 853 | } |
| 854 | |
| 855 | case 1: /* needs to be verified */ |
| 856 | { |
| 857 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut; |
| 858 | clut += _index & 0x0f; |
| 859 | |
| 860 | /* render in phrases */ |
| 861 | while (xpix < iwidth) |
| 862 | { |
| 863 | UINT16 pix = (src[xpix >> 4] >> ((~xpix & 15) << 1)) & 0x03; |
| 864 | |
| 865 | while (xleft > 0) |
| 866 | { |
| 867 | if (xpos >= 0 && xpos < 760 && (pix || !(flags & 4))) |
| 868 | scanline[xpos] = clut[BYTE_XOR_BE(pix)]; |
| 869 | xpos += dxpos; |
| 870 | xleft -= 0x20; |
| 871 | } |
| 872 | while (xleft <= 0) |
| 873 | xleft += hscale, xpix++; |
| 874 | } |
| 875 | break; |
| 876 | } |
| 877 | |
| 745 | 878 | case 2: |
| 746 | 879 | { |
| 747 | 880 | UINT16 *clut = (UINT16 *)jaguar_gpu_clut; |
| r5453 | r5454 | |
| 750 | 883 | /* render in phrases */ |
| 751 | 884 | while (xpix < iwidth) |
| 752 | 885 | { |
| 753 | | UINT16 pix = (src[xpix / 8] >> ((~xpix & 7) * 4)) & 0x0f; |
| 886 | UINT16 pix = (src[xpix >> 3] >> ((~xpix & 7) << 2)) & 0x0f; |
| 754 | 887 | |
| 755 | 888 | while (xleft > 0) |
| 756 | 889 | { |
| r5453 | r5454 | |
| 772 | 905 | /* render in phrases */ |
| 773 | 906 | while (xpix < iwidth) |
| 774 | 907 | { |
| 775 | | UINT16 pix = (src[xpix / 4] >> ((~xpix & 3) * 8)) & 0xff; |
| 908 | UINT16 pix = (src[xpix >> 2] >> ((~xpix & 3) << 3)) & 0xff; |
| 776 | 909 | |
| 777 | 910 | while (xleft > 0) |
| 778 | 911 | { |
| r5453 | r5454 | |
| 790 | 923 | case 4: |
| 791 | 924 | while (xpix < iwidth) |
| 792 | 925 | { |
| 793 | | UINT16 pix = src[xpix / 2] >> ((~xpix & 1) * 16); |
| 926 | UINT16 pix = src[xpix >> 1] >> ((~xpix & 1) << 4); |
| 794 | 927 | |
| 795 | 928 | while (xleft > 0) |
| 796 | 929 | { |
src/mame/video/jaguar.c
| r5453 | r5454 | |
| 424 | 424 | { |
| 425 | 425 | /* YCC full */ |
| 426 | 426 | case 0x000: |
| 427 | /* RGB24 */ |
| 428 | case 0x002: |
| 427 | 429 | for (i = 0; i < 65536; i++) |
| 428 | 430 | { |
| 429 | 431 | UINT8 r = (red_lookup[i >> 8] * (i & 0xff)) >> 8; |
| r5453 | r5454 | |
| 465 | 467 | /* others */ |
| 466 | 468 | default: |
| 467 | 469 | logerror("Can't handle mode %X\n", vmode); |
| 470 | fprintf(stderr, "Can't handle mode %X\n", vmode); |
| 468 | 471 | break; |
| 469 | 472 | } |
| 470 | 473 | } |
| r5453 | r5454 | |
| 687 | 690 | int hbend = effective_hvalue(ENABLE_BORDERS ? gpu_regs[HBE] : MIN(gpu_regs[HDB1], gpu_regs[HDB2])); |
| 688 | 691 | int hbstart = effective_hvalue(gpu_regs[ENABLE_BORDERS ? HBB : HDE]); |
| 689 | 692 | int vperiod = (gpu_regs[VP] & 0x7ff) + 1; |
| 690 | | int vbend = gpu_regs[VBE] & 0x7ff; |
| 693 | int vbend = MAX(gpu_regs[VBE],gpu_regs[VDB]) & 0x7ff; |
| 691 | 694 | int vbstart = gpu_regs[VBB] & 0x7ff; |
| 692 | 695 | |
| 693 | 696 | /* adjust for the half-lines */ |
| r5453 | r5454 | |
| 774 | 777 | /* only run if video is enabled and we are past the "display begin" */ |
| 775 | 778 | if ((gpu_regs[VMODE] & 1) && vc >= (gpu_regs[VDB] & 0x7ff)) |
| 776 | 779 | { |
| 777 | | UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc / 2, 0); |
| 780 | UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc >> 1, 0); |
| 778 | 781 | int maxx = visarea->max_x; |
| 779 | | int hde = effective_hvalue(gpu_regs[HDE]) / 2; |
| 782 | int hde = effective_hvalue(gpu_regs[HDE]) >> 1; |
| 780 | 783 | UINT16 x,scanline[760]; |
| 781 | 784 | UINT8 y,pixel_width = ((gpu_regs[VMODE]>>10)&3)+1; |
| 782 | 785 | |
| r5453 | r5454 | |
| 792 | 795 | process_object_list(machine, vc, scanline); |
| 793 | 796 | |
| 794 | 797 | /* copy the data to the target, clipping */ |
| 795 | | for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x++) |
| 796 | | for (y = 0; y < pixel_width; y++) |
| 797 | | dest[hdb++] = pen_table[scanline[x]]; |
| 798 | if ((gpu_regs[VMODE] & 0x106) == 0x002) /* RGB24 */ |
| 799 | { |
| 800 | for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x+=2) |
| 801 | for (y = 0; y < pixel_width; y++) |
| 802 | { |
| 803 | UINT8 r = pen_table[(scanline[x]&0xff)|256]; |
| 804 | UINT8 g = pen_table[(scanline[x]>>8)|512]; |
| 805 | UINT8 b = pen_table[scanline[x+1]&0xff]; |
| 806 | dest[hdb++] = MAKE_RGB(r, g, b); |
| 807 | } |
| 808 | } |
| 809 | else |
| 810 | { |
| 811 | for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x++) |
| 812 | for (y = 0; y < pixel_width; y++) |
| 813 | dest[hdb++] = pen_table[scanline[x]]; |
| 814 | } |
| 798 | 815 | } |
| 799 | 816 | |
| 800 | 817 | /* adjust the timer in a loop, to handle missed cases */ |