trunk/src/mame/drivers/coolridr.c
| r21469 | r21470 | |
| 417 | 417 | UINT32 m_blitterClearMode; |
| 418 | 418 | INT16 m_blitterClearCount; |
| 419 | 419 | pen_t m_tilepals[0x10000]; |
| 420 | pen_t m_fadedpals[0x8000]; |
| 420 | 421 | |
| 421 | 422 | // store the blit params here |
| 422 | 423 | UINT32 m_spriteblit[12]; |
| r21469 | r21470 | |
| 522 | 523 | UINT16 *m_h1_vram; |
| 523 | 524 | UINT8 *m_h1_pcg; |
| 524 | 525 | UINT16 *m_h1_pal; |
| 525 | | void flush_pal_data( UINT16 offset ); |
| 526 | | void apply_rgb_control(int screen_num,int *r, int *g, int *b); |
| 527 | 526 | int m_gfx_index; |
| 528 | 527 | int m_color_bank; |
| 529 | 528 | struct { |
| r21469 | r21470 | |
| 886 | 885 | bg_r = (VREG(0x3c) >> 10) & 0x1f; |
| 887 | 886 | bg_g = (VREG(0x3c) >> 5) & 0x1f; |
| 888 | 887 | bg_b = (VREG(0x3c) >> 0) & 0x1f; |
| 889 | | apply_rgb_control(which,&bg_r,&bg_g,&bg_b); |
| 890 | 888 | |
| 891 | 889 | bitmap.fill(VREG(0x3c),cliprect); |
| 892 | 890 | |
| r21469 | r21470 | |
| 915 | 913 | |
| 916 | 914 | UINT32 coolridr_state::screen_update_coolridr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int which) |
| 917 | 915 | { |
| 916 | if(m_rgb_ctrl[which].gradient) |
| 917 | { |
| 918 | if( (m_rgb_ctrl[which].setting == 0x1240) || (m_rgb_ctrl[which].setting == 0x920) || (m_rgb_ctrl[which].setting == 0x800) ) |
| 919 | { |
| 920 | } |
| 921 | else |
| 922 | { |
| 923 | popmessage("%08x %08x",m_rgb_ctrl[which].setting,m_rgb_ctrl[which].gradient); |
| 924 | } |
| 925 | } |
| 918 | 926 | |
| 927 | // there are probably better ways to do this |
| 928 | for (int i = 0; i < 0x8000; i++) |
| 929 | { |
| 930 | int r = (i >> 10)&0x1f; |
| 931 | int g = (i >> 5)&0x1f; |
| 932 | int b = (i >> 0)&0x1f; |
| 933 | |
| 934 | if(m_rgb_ctrl[which].gradient) |
| 935 | { |
| 936 | /* fade-in / outs */ |
| 937 | if(m_rgb_ctrl[which].setting == 0x1240) |
| 938 | { |
| 939 | r -= m_rgb_ctrl[which].gradient; |
| 940 | g -= m_rgb_ctrl[which].gradient; |
| 941 | b -= m_rgb_ctrl[which].gradient; |
| 942 | if(r < 0) { r = 0; } |
| 943 | if(g < 0) { g = 0; } |
| 944 | if(b < 0) { b = 0; } |
| 945 | } |
| 946 | else if(m_rgb_ctrl[which].setting == 0x920) /* at bike select / outside tunnels, addition */ |
| 947 | { |
| 948 | r += m_rgb_ctrl[which].gradient; |
| 949 | g += m_rgb_ctrl[which].gradient; |
| 950 | b += m_rgb_ctrl[which].gradient; |
| 951 | if(r > 0x1f) { r = 0x1f; } |
| 952 | if(g > 0x1f) { g = 0x1f; } |
| 953 | if(b > 0x1f) { b = 0x1f; } |
| 954 | } |
| 955 | else if(m_rgb_ctrl[which].setting == 0x800) /* when you get hit TODO: algo might be different. */ |
| 956 | { |
| 957 | r += m_rgb_ctrl[which].gradient; |
| 958 | g -= m_rgb_ctrl[which].gradient; |
| 959 | b -= m_rgb_ctrl[which].gradient; |
| 960 | if(r > 0x1f) { r = 0x1f; } |
| 961 | if(g < 0) { g = 0; } |
| 962 | if(b < 0) { b = 0; } |
| 963 | } |
| 964 | } |
| 965 | m_fadedpals[i] = (r<<10|g<<5|b); |
| 966 | } |
| 967 | |
| 968 | |
| 969 | |
| 919 | 970 | if (which==0) |
| 920 | 971 | { |
| 921 | | // will probably need a custom function |
| 922 | | copybitmap_trans(bitmap, m_screen1_bitmap, 0, 0, 0, 0, cliprect, 0x8000); |
| 972 | for (int y=0;y<384;y++) |
| 973 | { |
| 974 | UINT16* linesrc = &m_screen1_bitmap.pix16(y); |
| 975 | UINT16* linedest = &bitmap.pix16(y); |
| 976 | |
| 977 | for (int x=0;x<496;x++) |
| 978 | { |
| 979 | linedest[x] = m_fadedpals[linesrc[x]]; |
| 980 | } |
| 981 | } |
| 923 | 982 | } |
| 924 | 983 | else |
| 925 | 984 | { |
| 926 | | // will probably need a custom function |
| 927 | | copybitmap_trans(bitmap, m_screen2_bitmap, 0, 0, 0, 0, cliprect, 0x8000); |
| 985 | for (int y=0;y<384;y++) |
| 986 | { |
| 987 | UINT16* linesrc = &m_screen2_bitmap.pix16(y); |
| 988 | UINT16* linedest = &bitmap.pix16(y); |
| 989 | |
| 990 | for (int x=0;x<496;x++) |
| 991 | { |
| 992 | linedest[x] = m_fadedpals[linesrc[x]]; |
| 993 | } |
| 994 | } |
| 928 | 995 | } |
| 929 | 996 | |
| 930 | 997 | return 0; |
| r21469 | r21470 | |
| 2652 | 2719 | } |
| 2653 | 2720 | } |
| 2654 | 2721 | |
| 2655 | | void coolridr_state::apply_rgb_control(int screen_num,int *r, int *g, int *b) |
| 2656 | | { |
| 2657 | | if(!m_rgb_ctrl[screen_num].gradient) |
| 2658 | | return; |
| 2659 | 2722 | |
| 2660 | | if(m_rgb_ctrl[screen_num].setting == 0x1240) /* fade-in / outs */ |
| 2661 | | { |
| 2662 | | *r -= m_rgb_ctrl[screen_num].gradient; |
| 2663 | | *g -= m_rgb_ctrl[screen_num].gradient; |
| 2664 | | *b -= m_rgb_ctrl[screen_num].gradient; |
| 2665 | | if(*r < 0) { *r = 0; } |
| 2666 | | if(*g < 0) { *g = 0; } |
| 2667 | | if(*b < 0) { *b = 0; } |
| 2668 | | } |
| 2669 | | else if(m_rgb_ctrl[screen_num].setting == 0x920) /* at bike select / outside tunnels, addition */ |
| 2670 | | { |
| 2671 | | *r += m_rgb_ctrl[screen_num].gradient; |
| 2672 | | *g += m_rgb_ctrl[screen_num].gradient; |
| 2673 | | *b += m_rgb_ctrl[screen_num].gradient; |
| 2674 | | if(*r > 0x1f) { *r = 0x1f; } |
| 2675 | | if(*g > 0x1f) { *g = 0x1f; } |
| 2676 | | if(*b > 0x1f) { *b = 0x1f; } |
| 2677 | | } |
| 2678 | | else if(m_rgb_ctrl[screen_num].setting == 0x800) /* when you get hit TODO: algo might be different. */ |
| 2679 | | { |
| 2680 | | *r += m_rgb_ctrl[screen_num].gradient; |
| 2681 | | *g -= m_rgb_ctrl[screen_num].gradient; |
| 2682 | | *b -= m_rgb_ctrl[screen_num].gradient; |
| 2683 | | if(*r > 0x1f) { *r = 0x1f; } |
| 2684 | | if(*g < 0) { *g = 0; } |
| 2685 | | if(*b < 0) { *b = 0; } |
| 2686 | | } |
| 2687 | | else |
| 2688 | | { |
| 2689 | | popmessage("%08x %08x",m_rgb_ctrl[screen_num].setting,m_rgb_ctrl[screen_num].gradient); |
| 2690 | | } |
| 2691 | | } |
| 2692 | 2723 | |
| 2693 | | void coolridr_state::flush_pal_data( UINT16 offset ) |
| 2694 | | { |
| 2695 | | int r,g,b; |
| 2696 | | int screen_type = (offset & 0x200) >> 9; |
| 2697 | | |
| 2698 | | r = ((m_h1_pal[offset] & 0x7c00) >> 10); |
| 2699 | | g = ((m_h1_pal[offset] & 0x03e0) >> 5); |
| 2700 | | b = ((m_h1_pal[offset] & 0x001f) >> 0); |
| 2701 | | apply_rgb_control(screen_type,&r,&g,&b); |
| 2702 | | |
| 2703 | | // palette_set_color_rgb(machine(),offset,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 2704 | | m_tilepals[offset&0xffff] = (r<<10) | (g<<5) | b; |
| 2705 | | } |
| 2706 | | |
| 2707 | 2724 | void coolridr_state::sysh1_dma_transfer( address_space &space, UINT16 dma_index ) |
| 2708 | 2725 | { |
| 2709 | 2726 | UINT32 src = 0,dst = 0,size = 0; |
| r21469 | r21470 | |
| 2773 | 2790 | for(int i=0;i<size;i+=2) |
| 2774 | 2791 | { |
| 2775 | 2792 | m_h1_pal[dst] = space.read_word(src); |
| 2776 | | flush_pal_data(dst); |
| 2793 | m_tilepals[dst&0xffff] = m_h1_pal[dst]; |
| 2777 | 2794 | dst++; |
| 2778 | 2795 | src+=2; |
| 2779 | 2796 | } |
| r21469 | r21470 | |
| 2799 | 2816 | m_rgb_ctrl[(cmd & 4) >> 2].setting = m_framebuffer_vram[(0+dma_index)/4] & 0xffffe0; |
| 2800 | 2817 | m_rgb_ctrl[(cmd & 4) >> 2].gradient = m_framebuffer_vram[(0+dma_index)/4] & 0x1f; |
| 2801 | 2818 | |
| 2802 | | /* 0x000-0x1ff - 0x400-0x5ff screen 1 */ |
| 2803 | | /* 0x200-0x3ff - 0x600-0x7ff screen 2 */ |
| 2804 | | for(int i=((cmd & 4) << 7);i<((cmd & 4) << 7)+0x200;i++) |
| 2805 | | { |
| 2806 | | flush_pal_data( i ); |
| 2807 | | flush_pal_data( i + 0x400 ); |
| 2808 | | } |
| 2809 | 2819 | |
| 2810 | 2820 | dma_index+=4; |
| 2811 | 2821 | break; |
| r21469 | r21470 | |
| 3597 | 3607 | DEVCB_DRIVER_LINE_MEMBER(coolridr_state, scsp2_to_sh1_irq) |
| 3598 | 3608 | }; |
| 3599 | 3609 | |
| 3610 | |
| 3611 | PALETTE_INIT( RRRRR_GGGGG_BBBBB_double ) |
| 3612 | { |
| 3613 | int i; |
| 3614 | |
| 3615 | for (i = 0; i < 0x10000; i++) |
| 3616 | palette_set_color(machine, i, MAKE_RGB( pal5bit((i >> 10)&0x1f), pal5bit(((i >> 5))&0x1f), pal5bit((i >> 0)&0x1f))); |
| 3617 | } |
| 3618 | |
| 3619 | |
| 3600 | 3620 | #define MAIN_CLOCK XTAL_28_63636MHz |
| 3601 | 3621 | |
| 3602 | 3622 | static MACHINE_CONFIG_START( coolridr, coolridr_state ) |