src/mame/drivers/megadriv.c
| r9279 | r9280 | |
| 638 | 638 | { |
| 639 | 639 | source -= 2; // the SVP introduces some kind of DMA 'lag', which we have to compensate for, this is obvious even on gfx DMAd from ROM (the Speedometer) |
| 640 | 640 | } |
| 641 | | |
| 641 | |
| 642 | 642 | return space68k->read_word(source); |
| 643 | 643 | } |
| 644 | 644 | else if (( source >= 0xe00000 ) && ( source <= 0xffffff )) |
| r9279 | r9280 | |
| 2368 | 2368 | // incase we have a stalled DMA in progress, let the SH2 know there is data available |
| 2369 | 2369 | sh2_notify_dma_data_available(space->machine->device("32x_master_sh2")); |
| 2370 | 2370 | sh2_notify_dma_data_available(space->machine->device("32x_slave_sh2")); |
| 2371 | | |
| 2371 | |
| 2372 | 2372 | } |
| 2373 | 2373 | current_fifo_write_pos = 0; |
| 2374 | 2374 | } |
| r9279 | r9280 | |
| 2428 | 2428 | |
| 2429 | 2429 | if (a15106_reg & 0x1) /* NBA Jam TE relies on this */ |
| 2430 | 2430 | { |
| 2431 | | |
| 2431 | |
| 2432 | 2432 | // install the game rom in the normal 0x000000-0x03fffff space used by the genesis - this allows VDP DMA operations to work as they have to be from this area or RAM |
| 2433 | 2433 | // it should also UNMAP the banked rom area... |
| 2434 | 2434 | memory_install_rom(space, 0x0000100, 0x03fffff, 0, 0, memory_region(space->machine, "gamecart") + 0x100); |
| r9279 | r9280 | |
| 2436 | 2436 | else |
| 2437 | 2437 | { |
| 2438 | 2438 | // we should be careful and map back any rom overlay (hint) and backup ram too I think... |
| 2439 | | |
| 2439 | |
| 2440 | 2440 | // this is actually blank / nop area |
| 2441 | 2441 | // we should also map the banked area back (we don't currently unmap it tho) |
| 2442 | 2442 | memory_install_rom(space, 0x0000100, 0x03fffff, 0, 0, memory_region(space->machine, "maincpu")+0x100); |
| 2443 | 2443 | } |
| 2444 | | |
| 2444 | |
| 2445 | 2445 | //printf("_32x_68k_a15106_w %04x\n", data); |
| 2446 | 2446 | /* |
| 2447 | 2447 | if (a15106_reg & 0x4) |
| r9279 | r9280 | |
| 2583 | 2583 | memory_install_rom(space, 0x0880000, 0x08fffff, 0, 0, memory_region(space->machine, "gamecart")); // 'fixed' 512kb rom bank |
| 2584 | 2584 | |
| 2585 | 2585 | memory_install_read_bank(space, 0x0900000, 0x09fffff, 0, 0, "bank12"); // 'bankable' 1024kb rom bank |
| 2586 | | memory_set_bankptr(space->machine, "bank12", memory_region(space->machine, "gamecart") ); |
| 2586 | memory_set_bankptr(space->machine, "bank12", memory_region(space->machine, "gamecart")+((_32x_68k_a15104_reg&0x3)*0x100000) ); |
| 2587 | 2587 | |
| 2588 | 2588 | memory_install_rom(space, 0x0000000, 0x03fffff, 0, 0, memory_region(space->machine, "32x_68k_bios")); |
| 2589 | 2589 | |
| r9279 | r9280 | |
| 2778 | 2778 | |
| 2779 | 2779 | |
| 2780 | 2780 | // printf("_32x_68k_a15180_r (a15180) %04x\n",mem_mask); |
| 2781 | | |
| 2781 | |
| 2782 | 2782 | // read needs authorization too I think, undefined behavior otherwise |
| 2783 | 2783 | switch (offset) |
| 2784 | 2784 | { |
| 2785 | 2785 | case 0x00: |
| 2786 | | |
| 2786 | |
| 2787 | 2787 | // the flag is inverted compared to the megadrive |
| 2788 | 2788 | int ntsc; |
| 2789 | 2789 | if (megadrive_region_pal) ntsc = 0; |
| r9279 | r9280 | |
| 2793 | 2793 | (_32x_videopriority << 7 ) | |
| 2794 | 2794 | ( _32x_240mode << 6 ) | |
| 2795 | 2795 | ( _32x_displaymode << 0 ); |
| 2796 | | |
| 2797 | | |
| 2798 | | |
| 2796 | |
| 2797 | |
| 2798 | |
| 2799 | 2799 | case 0x02/2: |
| 2800 | 2800 | return _32x_screenshift; |
| 2801 | | |
| 2801 | |
| 2802 | 2802 | case 0x04/2: |
| 2803 | 2803 | return _32x_autofill_length; |
| 2804 | | |
| 2804 | |
| 2805 | 2805 | case 0x06/2: |
| 2806 | 2806 | return _32x_autofill_address; |
| 2807 | | |
| 2807 | |
| 2808 | 2808 | case 0x08/2: |
| 2809 | 2809 | return _32x_autofill_data; |
| 2810 | | |
| 2810 | |
| 2811 | 2811 | case 0x0a/2: |
| 2812 | 2812 | UINT16 retdata = _32x_a1518a_reg; |
| 2813 | 2813 | UINT16 hpos = get_hposition(); |
| r9279 | r9280 | |
| 2826 | 2826 | |
| 2827 | 2827 | return retdata; |
| 2828 | 2828 | } |
| 2829 | | |
| 2829 | |
| 2830 | 2830 | return 0x0000; |
| 2831 | 2831 | } |
| 2832 | 2832 | |
| r9279 | r9280 | |
| 2835 | 2835 | static WRITE16_HANDLER( _32x_common_vdp_regs_w ) |
| 2836 | 2836 | { |
| 2837 | 2837 | // what happens if the z80 accesses it, what authorization do we use? which address space do we get?? the z80 *can* write here and to the framebuffer via the window |
| 2838 | | |
| 2838 | |
| 2839 | 2839 | address_space* _68kspace = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 2840 | 2840 | |
| 2841 | 2841 | if (space!= _68kspace) |
| r9279 | r9280 | |
| 2849 | 2849 | if (_32x_access_auth!=0) |
| 2850 | 2850 | return; |
| 2851 | 2851 | } |
| 2852 | | |
| 2853 | | |
| 2852 | |
| 2853 | |
| 2854 | 2854 | switch (offset) |
| 2855 | 2855 | { |
| 2856 | | |
| 2857 | | case 0x00: |
| 2856 | |
| 2857 | case 0x00: |
| 2858 | 2858 | printf("_32x_68k_a15180_w (a15180) %04x %04x source _32x_access_auth %04x\n",data,mem_mask, _32x_access_auth); |
| 2859 | | |
| 2859 | |
| 2860 | 2860 | if (ACCESSING_BITS_0_7) |
| 2861 | 2861 | { |
| 2862 | 2862 | _32x_videopriority = (data & 0x80) >> 7; |
| r9279 | r9280 | |
| 2864 | 2864 | _32x_displaymode = (data & 0x03) >> 0; |
| 2865 | 2865 | } |
| 2866 | 2866 | break; |
| 2867 | | |
| 2867 | |
| 2868 | 2868 | case 0x02/2: |
| 2869 | 2869 | if (ACCESSING_BITS_0_7) |
| 2870 | 2870 | { |
| r9279 | r9280 | |
| 2875 | 2875 | |
| 2876 | 2876 | } |
| 2877 | 2877 | break; |
| 2878 | | |
| 2878 | |
| 2879 | 2879 | case 0x04/2: |
| 2880 | 2880 | if (ACCESSING_BITS_0_7) |
| 2881 | 2881 | { |
| r9279 | r9280 | |
| 2887 | 2887 | |
| 2888 | 2888 | } |
| 2889 | 2889 | break; |
| 2890 | | |
| 2890 | |
| 2891 | 2891 | case 0x06/2: |
| 2892 | 2892 | if (ACCESSING_BITS_0_7) |
| 2893 | 2893 | { |
| r9279 | r9280 | |
| 2899 | 2899 | _32x_autofill_address = (_32x_autofill_address & 0x00ff) | (data & 0xff00); |
| 2900 | 2900 | } |
| 2901 | 2901 | break; |
| 2902 | | |
| 2902 | |
| 2903 | 2903 | case 0x08/2: |
| 2904 | 2904 | if (ACCESSING_BITS_0_7) |
| 2905 | 2905 | { |
| r9279 | r9280 | |
| 2921 | 2921 | } |
| 2922 | 2922 | } |
| 2923 | 2923 | break; |
| 2924 | | |
| 2924 | |
| 2925 | 2925 | case 0x0a/2: |
| 2926 | 2926 | // bit 0 is the framebuffer select; |
| 2927 | 2927 | _32x_a1518a_reg = (_32x_a1518a_reg & 0xfffe) | (data & 1); |
| r9279 | r9280 | |
| 2937 | 2937 | _32x_access_dram = _32x_dram1; |
| 2938 | 2938 | } |
| 2939 | 2939 | break; |
| 2940 | | |
| 2941 | | |
| 2940 | |
| 2941 | |
| 2942 | 2942 | } |
| 2943 | | |
| 2944 | | |
| 2943 | |
| 2944 | |
| 2945 | 2945 | } |
| 2946 | 2946 | |
| 2947 | 2947 | |
| r9279 | r9280 | |
| 2999 | 2999 | |
| 3000 | 3000 | if (sh2_master_hint_enable) printf("sh2_master_hint_enable enable!\n"); |
| 3001 | 3001 | //if (sh2_master_pwmint_enable) printf("sh2_master_pwn_enable enable!\n"); |
| 3002 | | |
| 3002 | |
| 3003 | 3003 | _32x_check_irqs(space->machine); |
| 3004 | 3004 | } |
| 3005 | 3005 | } |
| r9279 | r9280 | |
| 5354 | 5354 | { |
| 5355 | 5355 | lineptr[x] = _32x_linerender[x]&0x7fff; |
| 5356 | 5356 | drawn = 1; |
| 5357 | | } |
| 5357 | } |
| 5358 | 5358 | } |
| 5359 | | } |
| 5359 | } |
| 5360 | 5360 | |
| 5361 | | |
| 5361 | |
| 5362 | 5362 | if (drawn==0) |
| 5363 | 5363 | { |
| 5364 | 5364 | if (dat&0x10000) |
| r9279 | r9280 | |
| 5366 | 5366 | else |
| 5367 | 5367 | lineptr[x] = megadrive_vdp_palette_lookup[(dat&0x0f) | segac2_bg_pal_lookup[(dat&0x30)>>4]]; |
| 5368 | 5368 | } |
| 5369 | | |
| 5370 | 5369 | |
| 5371 | | |
| 5370 | |
| 5371 | |
| 5372 | 5372 | } |
| 5373 | 5373 | } |
| 5374 | 5374 | else |
| 5375 | 5375 | { |
| 5376 | | |
| 5376 | |
| 5377 | 5377 | for (x=0;x<320;x++) |
| 5378 | 5378 | { |
| 5379 | 5379 | UINT32 dat; |
| r9279 | r9280 | |
| 5398 | 5398 | { |
| 5399 | 5399 | lineptr[x] = _32x_linerender[x]&0x7fff; |
| 5400 | 5400 | drawn = 1; |
| 5401 | | } |
| 5401 | } |
| 5402 | 5402 | } |
| 5403 | | } |
| 5403 | } |
| 5404 | 5404 | |
| 5405 | | |
| 5405 | |
| 5406 | 5406 | if (drawn==0) |
| 5407 | 5407 | { |
| 5408 | 5408 | /* Verify my handling.. I'm not sure all cases are correct */ |
| r9279 | r9280 | |
| 5442 | 5442 | break; |
| 5443 | 5443 | } |
| 5444 | 5444 | } |
| 5445 | | |
| 5446 | | |
| 5447 | | |
| 5445 | |
| 5446 | |
| 5447 | |
| 5448 | 5448 | } |
| 5449 | 5449 | |
| 5450 | 5450 | } |
| r9279 | r9280 | |
| 5790 | 5790 | else cpu_set_input_line(_32x_master_cpu,SH2_VINT_IRQ_LEVEL,CLEAR_LINE); |
| 5791 | 5791 | |
| 5792 | 5792 | if (sh2_slave_vint_enable && sh2_slave_vint_pending) cpu_set_input_line(_32x_slave_cpu,SH2_VINT_IRQ_LEVEL,ASSERT_LINE); |
| 5793 | | else cpu_set_input_line(_32x_slave_cpu,SH2_VINT_IRQ_LEVEL,CLEAR_LINE); |
| 5793 | else cpu_set_input_line(_32x_slave_cpu,SH2_VINT_IRQ_LEVEL,CLEAR_LINE); |
| 5794 | 5794 | } |
| 5795 | 5795 | |
| 5796 | 5796 | |
| r9279 | r9280 | |
| 5825 | 5825 | // 32x interrupt! |
| 5826 | 5826 | if (_32x_is_connected) |
| 5827 | 5827 | { |
| 5828 | | sh2_master_vint_pending = 1; |
| 5828 | sh2_master_vint_pending = 1; |
| 5829 | 5829 | sh2_slave_vint_pending = 1; |
| 5830 | | _32x_check_irqs(timer.machine); |
| 5830 | _32x_check_irqs(timer.machine); |
| 5831 | 5831 | } |
| 5832 | 5832 | |
| 5833 | 5833 | } |