src/mame/drivers/megadriv.c
| r9343 | r9344 | |
| 74 | 74 | vdp line state change, which can be configured in the init |
| 75 | 75 | rather than hardcoding them. |
| 76 | 76 | |
| 77 | | 32x Marsch tests documentation: |
| 77 | 32x Marsch tests documentation (keep start pressed at start-up for individual tests): |
| 78 | 78 | |
| 79 | 79 | MD side check: |
| 80 | 80 | #1 Communication Check |
| r9343 | r9344 | |
| 117 | 117 | #37 SH-2 Slave ROM Read Check |
| 118 | 118 | #38 SH-2 Serial Communication (ERROR - returns a Timeout Error) |
| 119 | 119 | MD & 32x check: |
| 120 | | #39 MD&SH-2 Master Communication (ERROR) |
| 121 | | #40 MD&SH-2 Slave Communication (STALLS) |
| 120 | #39 MD&SH-2 Master Communication |
| 121 | #40 MD&SH-2 Slave Communication |
| 122 | 122 | #41 MD&SH-2 Master FM Bit R/W |
| 123 | 123 | #42 MD&SH-2 Slave FM Bit R/W |
| 124 | | #43 MD&SH-2 Master DREQ CTL (ERROR) |
| 125 | | #44 MD&SH-2 Slave DREQ CTL (ERROR) |
| 124 | #43 MD&SH-2 Master DREQ CTL |
| 125 | #44 MD&SH-2 Slave DREQ CTL |
| 126 | 126 | #45 MD&SH-2 Master DREQ SRC address |
| 127 | 127 | #46 MD&SH-2 Slave DREQ SRC address |
| 128 | 128 | #47 MD&SH-2 Master DREQ DST address |
| r9343 | r9344 | |
| 131 | 131 | #50 MD&SH-2 Slave DREQ SIZE address |
| 132 | 132 | #51 SH-2 Master V IRQ |
| 133 | 133 | #52 SH-2 Slave V IRQ |
| 134 | | #53 SH2 Master H IRQ (MD 0) (ERROR) |
| 135 | | #54 SH2 Slave H IRQ (MD 0) (ERROR) |
| 136 | | #55 SH2 Master H IRQ (MD 1) (ERROR) |
| 137 | | #56 SH2 Slave H IRQ (MD 1) (ERROR) |
| 138 | | #57 SH2 Master H IRQ (MD 2) (ERROR) |
| 139 | | #58 SH2 Slave H IRQ (MD 2) (ERROR) |
| 134 | #53 SH2 Master H IRQ (MD 0) |
| 135 | #54 SH2 Slave H IRQ (MD 0) |
| 136 | #55 SH2 Master H IRQ (MD 1) |
| 137 | #56 SH2 Slave H IRQ (MD 1) |
| 138 | #57 SH2 Master H IRQ (MD 2) |
| 139 | #58 SH2 Slave H IRQ (MD 2) |
| 140 | 140 | MD VDP check: |
| 141 | 141 | #59 Bitmap Mode Register |
| 142 | 142 | #60 Shift Register |
| r9343 | r9344 | |
| 304 | 304 | static int sh2_master_vint_pending; |
| 305 | 305 | static int sh2_slave_vint_pending; |
| 306 | 306 | static int _32x_fb_swap; |
| 307 | static int _32x_hcount_reg,_32x_hcount_compare_val; |
| 307 | 308 | |
| 308 | 309 | void _32x_check_irqs(running_machine* machine); |
| 309 | 310 | |
| r9343 | r9344 | |
| 2985 | 2986 | */ |
| 2986 | 2987 | |
| 2987 | 2988 | #define PWM_FIFO_SIZE pwm_tm_reg // guess, Marsch calls this register as FIFO width |
| 2989 | #define PWM_CLOCK megadrive_region_pal ? ((MASTER_CLOCK_PAL*3) / 7) : ((MASTER_CLOCK_NTSC*3) / 7) |
| 2988 | 2990 | |
| 2989 | 2991 | static UINT16 pwm_ctrl,pwm_cycle,pwm_tm_reg; |
| 2990 | 2992 | static UINT16 cur_lch[0x10],cur_rch[0x10]; |
| r9343 | r9344 | |
| 3009 | 3011 | lch_fifo_state = rch_fifo_state = 0x4000; |
| 3010 | 3012 | lch_index_r = rch_index_r = 0; |
| 3011 | 3013 | lch_index_w = rch_index_w = 0; |
| 3012 | | timer_adjust_oneshot(_32x_pwm_timer, ATTOTIME_IN_HZ(((MASTER_CLOCK_NTSC*3 / 7) / (pwm_cycle - 1))), 0); |
| 3014 | timer_adjust_oneshot(_32x_pwm_timer, ATTOTIME_IN_HZ((PWM_CLOCK) / (pwm_cycle - 1)), 0); |
| 3013 | 3015 | } |
| 3014 | 3016 | } |
| 3015 | 3017 | |
| r9343 | r9344 | |
| 3054 | 3056 | if(sh2_slave_pwmint_enable) { cpu_set_input_line(_32x_slave_cpu, SH2_PINT_IRQ_LEVEL,ASSERT_LINE); } |
| 3055 | 3057 | } |
| 3056 | 3058 | |
| 3057 | | timer_adjust_oneshot(_32x_pwm_timer, ATTOTIME_IN_HZ(((MASTER_CLOCK_NTSC*3 / 7) / (pwm_cycle - 1))), 0); |
| 3059 | timer_adjust_oneshot(_32x_pwm_timer, ATTOTIME_IN_HZ((PWM_CLOCK) / (pwm_cycle - 1)), 0); |
| 3058 | 3060 | } |
| 3059 | 3061 | |
| 3060 | 3062 | static READ16_HANDLER( _32x_pwm_r ) |
| r9343 | r9344 | |
| 3392 | 3394 | sh2_master_cmdint_enable = data & 0x2; |
| 3393 | 3395 | sh2_master_pwmint_enable = data & 0x1; |
| 3394 | 3396 | |
| 3395 | | if (sh2_master_hint_enable) printf("sh2_master_hint_enable enable!\n"); |
| 3397 | //if (sh2_master_hint_enable) printf("sh2_master_hint_enable enable!\n"); |
| 3396 | 3398 | //if (sh2_master_pwmint_enable) printf("sh2_master_pwn_enable enable!\n"); |
| 3397 | 3399 | |
| 3398 | 3400 | _32x_check_irqs(space->machine); |
| r9343 | r9344 | |
| 3430 | 3432 | sh2_slave_cmdint_enable = data & 0x2; |
| 3431 | 3433 | sh2_slave_pwmint_enable = data & 0x1; |
| 3432 | 3434 | |
| 3433 | | if (sh2_slave_hint_enable) printf("sh2_slave_hint_enable enable!\n"); |
| 3435 | //if (sh2_slave_hint_enable) printf("sh2_slave_hint_enable enable!\n"); |
| 3434 | 3436 | //if (sh2_slave_pwmint_enable) printf("sh2_slave_pwm_enable enable!\n"); |
| 3435 | 3437 | |
| 3436 | 3438 | _32x_check_irqs(space->machine); |
| r9343 | r9344 | |
| 3461 | 3463 | // H Count Register (H Interrupt) |
| 3462 | 3464 | // 0 = every line |
| 3463 | 3465 | /**********************************************************************************************/ |
| 3464 | | static UINT16 hcount; |
| 3465 | | |
| 3466 | 3466 | static READ16_HANDLER( _32x_sh2_common_4004_r ) |
| 3467 | 3467 | { |
| 3468 | | return hcount; |
| 3468 | return _32x_hcount_reg; |
| 3469 | 3469 | } |
| 3470 | 3470 | |
| 3471 | 3471 | static WRITE16_HANDLER( _32x_sh2_common_4004_w ) |
| 3472 | 3472 | { |
| 3473 | | hcount = data & 0xff; |
| 3473 | _32x_hcount_reg = data & 0xff; |
| 3474 | 3474 | } |
| 3475 | 3475 | |
| 3476 | 3476 | |
| r9343 | r9344 | |
| 6780 | 6780 | // if (genesis_scanline_counter==0) irq4counter = MEGADRIVE_REG0A_HINT_VALUE; |
| 6781 | 6781 | // irq4counter = MEGADRIVE_REG0A_HINT_VALUE; |
| 6782 | 6782 | |
| 6783 | | |
| 6784 | | |
| 6785 | 6783 | if (genesis_scanline_counter<=224) |
| 6786 | 6784 | { |
| 6787 | 6785 | irq4counter--; |
| r9343 | r9344 | |
| 6808 | 6806 | |
| 6809 | 6807 | //if (genesis_scanline_counter==0) irq4_on_timer->adjust(ATTOTIME_IN_USEC(2)); |
| 6810 | 6808 | |
| 6809 | if(_32x_is_connected) |
| 6810 | { |
| 6811 | _32x_hcount_compare_val++; |
| 6811 | 6812 | |
| 6813 | if(_32x_hcount_compare_val >= _32x_hcount_reg) |
| 6814 | { |
| 6815 | _32x_hcount_compare_val = -1; |
| 6812 | 6816 | |
| 6817 | if(genesis_scanline_counter < 224 || sh2_hint_in_vbl) |
| 6818 | { |
| 6819 | if(sh2_master_hint_enable) { cpu_set_input_line(_32x_master_cpu,SH2_HINT_IRQ_LEVEL,ASSERT_LINE); } |
| 6820 | if(sh2_slave_hint_enable) { cpu_set_input_line(_32x_slave_cpu,SH2_HINT_IRQ_LEVEL,ASSERT_LINE); } |
| 6821 | } |
| 6822 | } |
| 6823 | } |
| 6813 | 6824 | |
| 6825 | |
| 6814 | 6826 | if (timer.machine->device("genesis_snd_z80") != NULL) |
| 6815 | 6827 | { |
| 6816 | 6828 | if (genesis_scanline_counter == megadrive_z80irq_scanline) |
| r9343 | r9344 | |
| 6955 | 6967 | } |
| 6956 | 6968 | |
| 6957 | 6969 | |
| 6958 | | current_fifo_block = fifo_block_a; |
| 6959 | | current_fifo_readblock = fifo_block_b; |
| 6960 | | current_fifo_write_pos = 0; |
| 6961 | | current_fifo_read_pos = 0; |
| 6962 | | fifo_block_a_full = 0; |
| 6963 | | fifo_block_b_full = 0; |
| 6970 | if(_32x_is_connected) |
| 6971 | { |
| 6972 | current_fifo_block = fifo_block_a; |
| 6973 | current_fifo_readblock = fifo_block_b; |
| 6974 | current_fifo_write_pos = 0; |
| 6975 | current_fifo_read_pos = 0; |
| 6976 | fifo_block_a_full = 0; |
| 6977 | fifo_block_b_full = 0; |
| 6964 | 6978 | |
| 6979 | _32x_hcount_compare_val = -1; |
| 6980 | } |
| 6965 | 6981 | } |
| 6966 | 6982 | |
| 6967 | 6983 | void megadriv_stop_scanline_timer(void) |
| r9343 | r9344 | |
| 7087 | 7103 | |
| 7088 | 7104 | scanline_timer->adjust(attotime_zero); |
| 7089 | 7105 | |
| 7106 | if(_32x_is_connected) |
| 7107 | _32x_hcount_compare_val = -1; |
| 7090 | 7108 | } |
| 7091 | 7109 | |
| 7092 | 7110 | |