trunk/src/mame/machine/seicop.c
| r31832 | r31833 | |
| 2279 | 2279 | break; |
| 2280 | 2280 | |
| 2281 | 2281 | /* triggered before 0x6200 in Seibu Cup, looks like an angle value ... */ |
| 2282 | | case (0x01c/2): m_cop_angle_compare = INT8(m_cop_mcu_ram[0x1c/2]); break; |
| 2283 | | case (0x01e/2): m_cop_angle_mod_val = INT8(m_cop_mcu_ram[0x1e/2]); break; |
| 2282 | case (0x01c/2): m_cop_angle_compare = UINT16(m_cop_mcu_ram[0x1c/2]); break; |
| 2283 | case (0x01e/2): m_cop_angle_mod_val = UINT16(m_cop_mcu_ram[0x1e/2]); break; |
| 2284 | 2284 | |
| 2285 | 2285 | /* BCD Protection */ |
| 2286 | 2286 | case (0x020/2): |
| r31832 | r31833 | |
| 2810 | 2810 | //(cupsoc) | 8 | f3e7 | 6200 | 3a0 3a6 380 aa0 2a6 |
| 2811 | 2811 | if(COP_CMD(0x3a0,0x3a6,0x380,0xaa0,0x2a6,0x000,0x000,0x000,8,0xf3e7)) |
| 2812 | 2812 | { |
| 2813 | | INT8 cur_angle; |
| 2814 | | |
| 2813 | UINT8 cur_angle; |
| 2814 | UINT16 flags; |
| 2815 | |
| 2815 | 2816 | /* 0 [1] */ |
| 2816 | 2817 | /* 0xc [1] */ |
| 2817 | 2818 | /* 0 [0] */ |
| r31832 | r31833 | |
| 2819 | 2820 | /* 0xc [1] */ |
| 2820 | 2821 | |
| 2821 | 2822 | cur_angle = space.read_byte(m_cop_register[1] + (0xc ^ 3)); |
| 2823 | flags = space.read_word(m_cop_register[1]); |
| 2822 | 2824 | //space.write_byte(m_cop_register[1] + (0^3),space.read_byte(m_cop_register[1] + (0^3)) & 0xfb); //correct? |
| 2823 | 2825 | |
| 2824 | | if(cur_angle >= m_cop_angle_compare) |
| 2826 | m_cop_angle_compare &= 0xff; |
| 2827 | m_cop_angle_mod_val &= 0xff; |
| 2828 | flags &= 0x04; |
| 2829 | |
| 2830 | int delta = cur_angle - m_cop_angle_compare; |
| 2831 | if(delta >= 128) |
| 2832 | delta -= 256; |
| 2833 | else if(delta < -128) |
| 2834 | delta += 256; |
| 2835 | if(delta < 0) |
| 2825 | 2836 | { |
| 2826 | | cur_angle -= m_cop_angle_mod_val; |
| 2827 | | if(cur_angle <= m_cop_angle_compare) |
| 2837 | if(delta >= -m_cop_angle_mod_val) |
| 2828 | 2838 | { |
| 2829 | 2839 | cur_angle = m_cop_angle_compare; |
| 2830 | | //space.write_byte(m_cop_register[1] + (0^3),space.read_byte(m_cop_register[1] + (0^3)) | 2); |
| 2831 | | } |
| 2832 | | } |
| 2833 | | else if(cur_angle <= m_cop_angle_compare) |
| 2840 | flags |= 0x0004; |
| 2841 | } |
| 2842 | else |
| 2843 | cur_angle += m_cop_angle_mod_val; |
| 2844 | } |
| 2845 | else |
| 2834 | 2846 | { |
| 2835 | | cur_angle += m_cop_angle_mod_val; |
| 2836 | | if(cur_angle >= m_cop_angle_compare) |
| 2847 | if(delta <= m_cop_angle_mod_val) |
| 2837 | 2848 | { |
| 2838 | 2849 | cur_angle = m_cop_angle_compare; |
| 2839 | | //space.write_byte(m_cop_register[1] + (0^3),space.read_byte(m_cop_register[1] + (0^3)) | 2); |
| 2840 | | } |
| 2850 | flags |= 0x0004; |
| 2851 | } |
| 2852 | else |
| 2853 | cur_angle -= m_cop_angle_mod_val; |
| 2841 | 2854 | } |
| 2842 | 2855 | |
| 2856 | space.write_byte(m_cop_register[1] + (0 ^ 2),flags); |
| 2843 | 2857 | space.write_byte(m_cop_register[1] + (0xc ^ 3),cur_angle); |
| 2844 | 2858 | return; |
| 2845 | 2859 | } |
| r31832 | r31833 | |
| 2849 | 2863 | /* FIXME: still doesn't work ... */ |
| 2850 | 2864 | if(COP_CMD(0x380,0x39a,0x380,0xa80,0x29a,0x000,0x000,0x000,8,0xf3e7)) |
| 2851 | 2865 | { |
| 2852 | | INT8 cur_angle; |
| 2866 | UINT8 cur_angle; |
| 2867 | UINT16 flags; |
| 2868 | |
| 2869 | cur_angle = space.read_byte(m_cop_register[0] + (0x34 ^ 3)); |
| 2870 | flags = space.read_word(m_cop_register[0] + (0 ^ 2)); |
| 2871 | //space.write_byte(m_cop_register[1] + (0^3),space.read_byte(m_cop_register[1] + (0^3)) & 0xfb); //correct? |
| 2853 | 2872 | |
| 2854 | | cur_angle = INT8(space.read_byte(m_cop_register[0] + (0x34 ^ 3))); |
| 2855 | | //space.write_byte(m_cop_register[0] + (0^3),space.read_byte(m_cop_register[0] + (0^3)) & 0xfb); //correct? |
| 2856 | | /* |
| 2857 | | 0x00 0x00 0x60 0x00 |
| 2858 | | 0x00 0x20 0x60 0x20 |
| 2859 | | 0x00 0x40 0x60 0x60 |
| 2860 | | 0x00 0x60 0x60 0x60 |
| 2861 | | 0x00 0x80 0x60 0xa0 |
| 2862 | | 0x00 0xa0 0x60 0xa0 |
| 2863 | | 0x00 0xc0 0x60 0xc0 |
| 2864 | | 0x00 0xe0 0x60 0xe0 |
| 2865 | | */ |
| 2866 | | |
| 2867 | | if(cur_angle > m_cop_angle_compare) |
| 2873 | m_cop_angle_compare &= 0xff; |
| 2874 | m_cop_angle_mod_val &= 0xff; |
| 2875 | flags &= 0x04; |
| 2876 | |
| 2877 | int delta = cur_angle - m_cop_angle_compare; |
| 2878 | if(delta >= 128) |
| 2879 | delta -= 256; |
| 2880 | else if(delta < -128) |
| 2881 | delta += 256; |
| 2882 | if(delta < 0) |
| 2868 | 2883 | { |
| 2869 | | cur_angle -= m_cop_angle_mod_val; |
| 2870 | | |
| 2871 | | if(cur_angle < m_cop_angle_compare) |
| 2884 | if(delta >= -m_cop_angle_mod_val) |
| 2885 | { |
| 2872 | 2886 | cur_angle = m_cop_angle_compare; |
| 2873 | | } |
| 2874 | | else if(cur_angle < m_cop_angle_compare) |
| 2887 | flags |= 0x0004; |
| 2888 | } |
| 2889 | else |
| 2890 | cur_angle += m_cop_angle_mod_val; |
| 2891 | } |
| 2892 | else |
| 2875 | 2893 | { |
| 2876 | | cur_angle += m_cop_angle_mod_val; |
| 2877 | | |
| 2878 | | if(cur_angle > m_cop_angle_compare) |
| 2894 | if(delta <= m_cop_angle_mod_val) |
| 2895 | { |
| 2879 | 2896 | cur_angle = m_cop_angle_compare; |
| 2897 | flags |= 0x0004; |
| 2898 | } |
| 2899 | else |
| 2900 | cur_angle -= m_cop_angle_mod_val; |
| 2880 | 2901 | } |
| 2881 | 2902 | |
| 2882 | | space.write_byte(m_cop_register[0] + (0x34 ^ 3),cur_angle); |
| 2903 | space.write_byte(m_cop_register[0] + (0 ^ 3),flags); |
| 2904 | space.write_word(m_cop_register[0] + (0x34 ^ 3),cur_angle); |
| 2883 | 2905 | return; |
| 2884 | 2906 | } |
| 2885 | 2907 | |