src/mame/drivers/megadriv.c
| r9265 | r9266 | |
| 117 | 117 | static int sh2_master_pwmint_enable, sh2_slave_pwmint_enable; |
| 118 | 118 | static int sh2_hint_in_vbl; |
| 119 | 119 | |
| 120 | static int sh2_master_vint_pending; |
| 121 | static int sh2_slave_vint_pending; |
| 122 | |
| 123 | void _32x_check_irqs(running_machine* machine); |
| 124 | |
| 120 | 125 | #define SH2_VRES_IRQ_LEVEL 14 |
| 121 | 126 | #define SH2_VINT_IRQ_LEVEL 12 |
| 122 | 127 | #define SH2_HINT_IRQ_LEVEL 10 |
| r9265 | r9266 | |
| 2643 | 2648 | if (data&0x1) |
| 2644 | 2649 | { |
| 2645 | 2650 | if (sh2_master_cmdint_enable) cpu_set_input_line(_32x_master_cpu,SH2_CINT_IRQ_LEVEL,ASSERT_LINE); |
| 2651 | else printf("master cmdint when masked!\n"); |
| 2646 | 2652 | } |
| 2647 | 2653 | |
| 2648 | 2654 | if (data&0x2) |
| 2649 | 2655 | { |
| 2650 | 2656 | if (sh2_slave_cmdint_enable) cpu_set_input_line(_32x_slave_cpu,SH2_CINT_IRQ_LEVEL,ASSERT_LINE); |
| 2657 | else printf("slave cmdint when masked!\n"); |
| 2651 | 2658 | } |
| 2652 | 2659 | } |
| 2653 | 2660 | } |
| r9265 | r9266 | |
| 3028 | 3035 | |
| 3029 | 3036 | if (sh2_master_hint_enable) printf("sh2_master_hint_enable enable!\n"); |
| 3030 | 3037 | //if (sh2_master_pwmint_enable) printf("sh2_master_pwn_enable enable!\n"); |
| 3038 | |
| 3039 | _32x_check_irqs(space->machine); |
| 3031 | 3040 | } |
| 3032 | 3041 | } |
| 3033 | 3042 | |
| r9265 | r9266 | |
| 3065 | 3074 | if (sh2_slave_hint_enable) printf("sh2_slave_hint_enable enable!\n"); |
| 3066 | 3075 | //if (sh2_slave_pwmint_enable) printf("sh2_slave_pwm_enable enable!\n"); |
| 3067 | 3076 | |
| 3077 | _32x_check_irqs(space->machine); |
| 3078 | |
| 3068 | 3079 | } |
| 3069 | 3080 | } |
| 3070 | 3081 | |
| r9265 | r9266 | |
| 3217 | 3228 | // VINT (vertical interrupt) clear |
| 3218 | 3229 | /**********************************************************************************************/ |
| 3219 | 3230 | |
| 3220 | | static WRITE16_HANDLER( _32x_sh2_master_4016_w ){cpu_set_input_line(_32x_master_cpu,SH2_VINT_IRQ_LEVEL,CLEAR_LINE);} |
| 3221 | | static WRITE16_HANDLER( _32x_sh2_slave_4016_w ) { cpu_set_input_line(_32x_slave_cpu, SH2_VINT_IRQ_LEVEL,CLEAR_LINE);} |
| 3231 | static WRITE16_HANDLER( _32x_sh2_master_4016_w ){ sh2_master_vint_pending = 0; _32x_check_irqs(space->machine); } |
| 3232 | static WRITE16_HANDLER( _32x_sh2_slave_4016_w ) { sh2_slave_vint_pending = 0; _32x_check_irqs(space->machine); } |
| 3222 | 3233 | |
| 3223 | 3234 | /**********************************************************************************************/ |
| 3224 | 3235 | // SH2 side 4018 |
| r9265 | r9266 | |
| 5876 | 5887 | } |
| 5877 | 5888 | } |
| 5878 | 5889 | |
| 5890 | void _32x_check_irqs(running_machine* machine) |
| 5891 | { |
| 5879 | 5892 | |
| 5893 | if (sh2_master_vint_enable && sh2_master_vint_pending) cpu_set_input_line(_32x_master_cpu,SH2_VINT_IRQ_LEVEL,ASSERT_LINE); |
| 5894 | else cpu_set_input_line(_32x_master_cpu,SH2_VINT_IRQ_LEVEL,CLEAR_LINE); |
| 5895 | |
| 5896 | if (sh2_slave_vint_enable && sh2_slave_vint_pending) cpu_set_input_line(_32x_slave_cpu,SH2_VINT_IRQ_LEVEL,ASSERT_LINE); |
| 5897 | else cpu_set_input_line(_32x_slave_cpu,SH2_VINT_IRQ_LEVEL,CLEAR_LINE); |
| 5898 | } |
| 5899 | |
| 5900 | |
| 5880 | 5901 | static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) |
| 5881 | 5902 | { |
| 5882 | 5903 | /* This function is called at the very start of every scanline starting at the very |
| r9265 | r9266 | |
| 5908 | 5929 | // 32x interrupt! |
| 5909 | 5930 | if (_32x_is_connected) |
| 5910 | 5931 | { |
| 5911 | | if (sh2_master_vint_enable) cpu_set_input_line(_32x_master_cpu,SH2_VINT_IRQ_LEVEL,ASSERT_LINE); |
| 5912 | | if (sh2_slave_vint_enable) cpu_set_input_line(_32x_slave_cpu,SH2_VINT_IRQ_LEVEL,ASSERT_LINE); |
| 5932 | sh2_master_vint_pending = 1; |
| 5933 | sh2_slave_vint_pending = 1; |
| 5934 | _32x_check_irqs(timer.machine); |
| 5913 | 5935 | } |
| 5914 | 5936 | |
| 5915 | 5937 | } |
| r9265 | r9266 | |
| 6721 | 6743 | sh2_master_hint_enable = sh2_slave_hint_enable = 0; |
| 6722 | 6744 | sh2_master_cmdint_enable = sh2_slave_cmdint_enable = 0; |
| 6723 | 6745 | sh2_master_pwmint_enable = sh2_slave_pwmint_enable = 0; |
| 6746 | sh2_master_vint_pending = sh2_slave_vint_pending = 0; |
| 6724 | 6747 | |
| 6725 | 6748 | // start in a reset state |
| 6726 | 6749 | sh2_are_running = 0; |