trunk/src/mame/video/stvvdp2.c
| r20772 | r20773 | |
| 2490 | 2490 | *rgb = MAKE_RGB(_r, _g, _b); |
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | | static void stv_vdp2_drawgfxzoom_rgb555( |
| 2494 | | bitmap_rgb32 &dest_bmp,const rectangle &clip,running_machine &machine, |
| 2493 | static void stv_vdp2_drawgfxzoom( |
| 2494 | bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, |
| 2495 | 2495 | UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, |
| 2496 | 2496 | int transparency,int transparent_color,int scalex, int scaley, |
| 2497 | 2497 | int sprite_screen_width, int sprite_screen_height, int alpha) |
| 2498 | 2498 | { |
| 2499 | | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2500 | 2499 | rectangle myclip; |
| 2501 | | UINT8* gfxdata; |
| 2502 | 2500 | |
| 2503 | | gfxdata = state->m_vdp2.gfx_decode + code * 0x20; |
| 2504 | | |
| 2505 | 2501 | if (!scalex || !scaley) return; |
| 2506 | 2502 | |
| 2507 | | #if 0 |
| 2508 | 2503 | if (gfx->has_pen_usage() && transparency == STV_TRANSPARENCY_PEN) |
| 2509 | 2504 | { |
| 2510 | 2505 | int transmask = 0; |
| r20772 | r20773 | |
| 2518 | 2513 | /* character is totally opaque, can disable transparency */ |
| 2519 | 2514 | transparency = STV_TRANSPARENCY_NONE; |
| 2520 | 2515 | } |
| 2521 | | #endif |
| 2522 | 2516 | |
| 2523 | 2517 | /* |
| 2524 | 2518 | scalex and scaley are 16.16 fixed point numbers |
| r20772 | r20773 | |
| 2532 | 2526 | myclip = clip; |
| 2533 | 2527 | myclip &= dest_bmp.cliprect(); |
| 2534 | 2528 | |
| 2535 | | // if( gfx ) |
| 2529 | if( gfx ) |
| 2536 | 2530 | { |
| 2537 | | // const UINT8 *source_base = gfx->get_data(code % gfx->elements()); |
| 2531 | const pen_t *pal = &gfx->machine().pens[gfx->colorbase() + gfx->granularity() * (color % gfx->colors())]; |
| 2532 | const UINT8 *source_base = gfx->get_data(code % gfx->elements()); |
| 2538 | 2533 | |
| 2539 | 2534 | //int sprite_screen_height = (scaley*gfx->height()+0x8000)>>16; |
| 2540 | 2535 | //int sprite_screen_width = (scalex*gfx->width()+0x8000)>>16; |
| r20772 | r20773 | |
| 2606 | 2601 | { |
| 2607 | 2602 | for( y=sy; y<ey; y++ ) |
| 2608 | 2603 | { |
| 2609 | | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2604 | const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes(); |
| 2610 | 2605 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2611 | | int r,g,b,data; |
| 2612 | 2606 | |
| 2613 | 2607 | int x, x_index = x_index_base; |
| 2614 | 2608 | for( x=sx; x<ex; x++ ) |
| 2615 | 2609 | { |
| 2616 | | data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1]; |
| 2617 | | b = pal5bit((data & 0x7c00) >> 10); |
| 2618 | | g = pal5bit((data & 0x03e0) >> 5); |
| 2619 | | r = pal5bit( data & 0x001f); |
| 2620 | | if(stv2_current_tilemap.fade_control & 1) |
| 2621 | | stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 2622 | | |
| 2623 | | dest[x] = MAKE_RGB(r, g, b); |
| 2610 | dest[x] = pal[source[x_index>>16]]; |
| 2624 | 2611 | x_index += dx; |
| 2625 | 2612 | } |
| 2626 | 2613 | |
| r20772 | r20773 | |
| 2633 | 2620 | { |
| 2634 | 2621 | for( y=sy; y<ey; y++ ) |
| 2635 | 2622 | { |
| 2636 | | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2623 | const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes(); |
| 2637 | 2624 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2638 | | int r,g,b,data; |
| 2639 | 2625 | |
| 2640 | 2626 | int x, x_index = x_index_base; |
| 2641 | 2627 | for( x=sx; x<ex; x++ ) |
| 2642 | 2628 | { |
| 2643 | | data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1]; |
| 2644 | | b = pal5bit((data & 0x7c00) >> 10); |
| 2645 | | g = pal5bit((data & 0x03e0) >> 5); |
| 2646 | | r = pal5bit( data & 0x001f); |
| 2647 | | if(stv2_current_tilemap.fade_control & 1) |
| 2648 | | stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 2649 | | |
| 2650 | | if( data ) dest[x] = MAKE_RGB(r, g, b); |
| 2629 | int c = source[x_index>>16]; |
| 2630 | if( c != transparent_color ) dest[x] = pal[c]; |
| 2651 | 2631 | x_index += dx; |
| 2652 | 2632 | } |
| 2653 | 2633 | |
| r20772 | r20773 | |
| 2660 | 2640 | { |
| 2661 | 2641 | for( y=sy; y<ey; y++ ) |
| 2662 | 2642 | { |
| 2663 | | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2643 | const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes(); |
| 2664 | 2644 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2665 | | int r,g,b,data; |
| 2666 | 2645 | |
| 2667 | 2646 | int x, x_index = x_index_base; |
| 2668 | 2647 | for( x=sx; x<ex; x++ ) |
| 2669 | 2648 | { |
| 2670 | | data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1]; |
| 2671 | | b = pal5bit((data & 0x7c00) >> 10); |
| 2672 | | g = pal5bit((data & 0x03e0) >> 5); |
| 2673 | | r = pal5bit( data & 0x001f); |
| 2674 | | if(stv2_current_tilemap.fade_control & 1) |
| 2675 | | stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 2676 | | |
| 2677 | | if( data ) dest[x] = alpha_blend_r32(dest[x], MAKE_RGB(r, g, b), alpha); |
| 2649 | int c = source[x_index>>16]; |
| 2650 | if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha); |
| 2678 | 2651 | x_index += dx; |
| 2679 | 2652 | } |
| 2680 | 2653 | |
| r20772 | r20773 | |
| 2687 | 2660 | { |
| 2688 | 2661 | for( y=sy; y<ey; y++ ) |
| 2689 | 2662 | { |
| 2690 | | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2663 | const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes(); |
| 2691 | 2664 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2692 | | int r,g,b,data; |
| 2693 | 2665 | |
| 2694 | 2666 | int x, x_index = x_index_base; |
| 2695 | 2667 | for( x=sx; x<ex; x++ ) |
| 2696 | 2668 | { |
| 2697 | | data = (source[(x_index*2+0)>>16]<<0)|(source[(x_index*2+1)>>16]<<8); |
| 2698 | | b = pal5bit((data & 0x7c00) >> 10); |
| 2699 | | g = pal5bit((data & 0x03e0) >> 5); |
| 2700 | | r = pal5bit( data & 0x001f); |
| 2701 | | if(stv2_current_tilemap.fade_control & 1) |
| 2702 | | stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 2703 | | |
| 2704 | | if( data ) dest[x] = stv_add_blend(dest[x], MAKE_RGB(r, g, b)); |
| 2669 | int c = source[x_index>>16]; |
| 2670 | if( c != transparent_color ) dest[x] = stv_add_blend(dest[x],pal[c]); |
| 2705 | 2671 | x_index += dx; |
| 2706 | 2672 | } |
| 2707 | 2673 | |
| r20772 | r20773 | |
| 2715 | 2681 | |
| 2716 | 2682 | } |
| 2717 | 2683 | |
| 2718 | | static void stv_vdp2_drawgfxzoom( |
| 2719 | | bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, |
| 2684 | static void stv_vdp2_drawgfxzoom_rgb555( |
| 2685 | bitmap_rgb32 &dest_bmp,const rectangle &clip,running_machine &machine, |
| 2720 | 2686 | UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, |
| 2721 | 2687 | int transparency,int transparent_color,int scalex, int scaley, |
| 2722 | 2688 | int sprite_screen_width, int sprite_screen_height, int alpha) |
| 2723 | 2689 | { |
| 2690 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2724 | 2691 | rectangle myclip; |
| 2692 | UINT8* gfxdata; |
| 2725 | 2693 | |
| 2694 | gfxdata = state->m_vdp2.gfx_decode + code * 0x20; |
| 2695 | |
| 2726 | 2696 | if (!scalex || !scaley) return; |
| 2727 | 2697 | |
| 2698 | #if 0 |
| 2728 | 2699 | if (gfx->has_pen_usage() && transparency == STV_TRANSPARENCY_PEN) |
| 2729 | 2700 | { |
| 2730 | 2701 | int transmask = 0; |
| r20772 | r20773 | |
| 2738 | 2709 | /* character is totally opaque, can disable transparency */ |
| 2739 | 2710 | transparency = STV_TRANSPARENCY_NONE; |
| 2740 | 2711 | } |
| 2712 | #endif |
| 2741 | 2713 | |
| 2742 | 2714 | /* |
| 2743 | 2715 | scalex and scaley are 16.16 fixed point numbers |
| r20772 | r20773 | |
| 2751 | 2723 | myclip = clip; |
| 2752 | 2724 | myclip &= dest_bmp.cliprect(); |
| 2753 | 2725 | |
| 2754 | | if( gfx ) |
| 2726 | // if( gfx ) |
| 2755 | 2727 | { |
| 2756 | | const pen_t *pal = &gfx->machine().pens[gfx->colorbase() + gfx->granularity() * (color % gfx->colors())]; |
| 2757 | | const UINT8 *source_base = gfx->get_data(code % gfx->elements()); |
| 2728 | // const UINT8 *source_base = gfx->get_data(code % gfx->elements()); |
| 2758 | 2729 | |
| 2759 | 2730 | //int sprite_screen_height = (scaley*gfx->height()+0x8000)>>16; |
| 2760 | 2731 | //int sprite_screen_width = (scalex*gfx->width()+0x8000)>>16; |
| r20772 | r20773 | |
| 2826 | 2797 | { |
| 2827 | 2798 | for( y=sy; y<ey; y++ ) |
| 2828 | 2799 | { |
| 2829 | | const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes(); |
| 2800 | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2830 | 2801 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2802 | int r,g,b,data; |
| 2831 | 2803 | |
| 2832 | 2804 | int x, x_index = x_index_base; |
| 2833 | 2805 | for( x=sx; x<ex; x++ ) |
| 2834 | 2806 | { |
| 2835 | | dest[x] = pal[source[x_index>>16]]; |
| 2807 | data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1]; |
| 2808 | b = pal5bit((data & 0x7c00) >> 10); |
| 2809 | g = pal5bit((data & 0x03e0) >> 5); |
| 2810 | r = pal5bit( data & 0x001f); |
| 2811 | if(stv2_current_tilemap.fade_control & 1) |
| 2812 | stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 2813 | |
| 2814 | dest[x] = MAKE_RGB(r, g, b); |
| 2836 | 2815 | x_index += dx; |
| 2837 | 2816 | } |
| 2838 | 2817 | |
| r20772 | r20773 | |
| 2845 | 2824 | { |
| 2846 | 2825 | for( y=sy; y<ey; y++ ) |
| 2847 | 2826 | { |
| 2848 | | const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes(); |
| 2827 | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2849 | 2828 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2829 | int r,g,b,data; |
| 2850 | 2830 | |
| 2851 | 2831 | int x, x_index = x_index_base; |
| 2852 | 2832 | for( x=sx; x<ex; x++ ) |
| 2853 | 2833 | { |
| 2854 | | int c = source[x_index>>16]; |
| 2855 | | if( c != transparent_color ) dest[x] = pal[c]; |
| 2834 | data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1]; |
| 2835 | b = pal5bit((data & 0x7c00) >> 10); |
| 2836 | g = pal5bit((data & 0x03e0) >> 5); |
| 2837 | r = pal5bit( data & 0x001f); |
| 2838 | if(stv2_current_tilemap.fade_control & 1) |
| 2839 | stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 2840 | |
| 2841 | if( data ) dest[x] = MAKE_RGB(r, g, b); |
| 2856 | 2842 | x_index += dx; |
| 2857 | 2843 | } |
| 2858 | 2844 | |
| r20772 | r20773 | |
| 2865 | 2851 | { |
| 2866 | 2852 | for( y=sy; y<ey; y++ ) |
| 2867 | 2853 | { |
| 2868 | | const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes(); |
| 2854 | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2869 | 2855 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2856 | int r,g,b,data; |
| 2870 | 2857 | |
| 2871 | 2858 | int x, x_index = x_index_base; |
| 2872 | 2859 | for( x=sx; x<ex; x++ ) |
| 2873 | 2860 | { |
| 2874 | | int c = source[x_index>>16]; |
| 2875 | | if( c != transparent_color ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha); |
| 2861 | data = (source[(x_index>>16)*2] << 8) | source[(x_index>>16)*2+1]; |
| 2862 | b = pal5bit((data & 0x7c00) >> 10); |
| 2863 | g = pal5bit((data & 0x03e0) >> 5); |
| 2864 | r = pal5bit( data & 0x001f); |
| 2865 | if(stv2_current_tilemap.fade_control & 1) |
| 2866 | stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 2867 | |
| 2868 | if( data ) dest[x] = alpha_blend_r32(dest[x], MAKE_RGB(r, g, b), alpha); |
| 2876 | 2869 | x_index += dx; |
| 2877 | 2870 | } |
| 2878 | 2871 | |
| r20772 | r20773 | |
| 2885 | 2878 | { |
| 2886 | 2879 | for( y=sy; y<ey; y++ ) |
| 2887 | 2880 | { |
| 2888 | | const UINT8 *source = source_base + (y_index>>16) * gfx->rowbytes(); |
| 2881 | const UINT8 *source = gfxdata + (y_index>>16)*16; |
| 2889 | 2882 | UINT32 *dest = &dest_bmp.pix32(y); |
| 2883 | int r,g,b,data; |
| 2890 | 2884 | |
| 2891 | 2885 | int x, x_index = x_index_base; |
| 2892 | 2886 | for( x=sx; x<ex; x++ ) |
| 2893 | 2887 | { |
| 2894 | | int c = source[x_index>>16]; |
| 2895 | | if( c != transparent_color ) dest[x] = stv_add_blend(dest[x],pal[c]); |
| 2888 | data = (source[(x_index*2+0)>>16]<<0)|(source[(x_index*2+1)>>16]<<8); |
| 2889 | b = pal5bit((data & 0x7c00) >> 10); |
| 2890 | g = pal5bit((data & 0x03e0) >> 5); |
| 2891 | r = pal5bit( data & 0x001f); |
| 2892 | if(stv2_current_tilemap.fade_control & 1) |
| 2893 | stv_vdp2_compute_color_offset(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 2894 | |
| 2895 | if( data ) dest[x] = stv_add_blend(dest[x], MAKE_RGB(r, g, b)); |
| 2896 | 2896 | x_index += dx; |
| 2897 | 2897 | } |
| 2898 | 2898 | |
| r20772 | r20773 | |
| 6419 | 6419 | UINT8 ccr = 0; |
| 6420 | 6420 | UINT8 sprite_priorities[8]; |
| 6421 | 6421 | UINT8 sprite_ccr[8]; |
| 6422 | | int sprite_color_mode = STV_VDP2_SPCLMD; |
| 6422 | int sprite_color_mode = STV_VDP2_SPCLMD; |
| 6423 | 6423 | rectangle mycliprect; |
| 6424 | 6424 | |
| 6425 | 6425 | if ( (stv_sprite_priorities_usage_valid == 1) && (stv_sprite_priorities_used[pri] == 0) ) |
| r20772 | r20773 | |
| 6805 | 6805 | { |
| 6806 | 6806 | if ( pix & ~sprite_shadow ) |
| 6807 | 6807 | { |
| 6808 | | UINT32 p = bitmap_line[x]; |
| 6809 | | bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1); |
| 6808 | UINT32 p; //= bitmap_line[x]; |
| 6809 | if(double_x) |
| 6810 | { |
| 6811 | p = bitmap_line[x*2]; |
| 6812 | bitmap_line[x*2] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1); |
| 6813 | p = bitmap_line[x*2+1]; |
| 6814 | bitmap_line[x*2+1] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1); |
| 6815 | } |
| 6816 | else |
| 6817 | bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1); |
| 6810 | 6818 | } |
| 6811 | 6819 | } |
| 6812 | 6820 | else |
| r20772 | r20773 | |
| 6817 | 6825 | /*shadow - in reality, we should check from what layer pixel beneath comes...*/ |
| 6818 | 6826 | if ( STV_VDP2_SDCTL & 0x3f ) |
| 6819 | 6827 | { |
| 6820 | | UINT32 p = bitmap_line[x]; |
| 6821 | | bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1); |
| 6828 | UINT32 p;// = bitmap_line[x]; |
| 6829 | if(double_x) |
| 6830 | { |
| 6831 | p = bitmap_line[x*2]; |
| 6832 | bitmap_line[x*2] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1); |
| 6833 | p = bitmap_line[x*2+1]; |
| 6834 | bitmap_line[x*2+1] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1); |
| 6835 | } |
| 6836 | else |
| 6837 | bitmap_line[x] = MAKE_RGB(RGB_RED(p) >> 1, RGB_GREEN(p) >> 1, RGB_BLUE(p) >> 1); |
| 6822 | 6838 | } |
| 6823 | 6839 | /* note that when shadows are disabled, "shadow" palette entries are not drawn */ |
| 6824 | 6840 | } else if ( pix ) |