trunk/src/mame/machine/megavdp.c
| r22030 | r22031 | |
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | /* external gunk still has dependencies on these */ |
| 19 | | int megadriv_framerate; |
| 20 | 19 | int megadrive_total_scanlines; |
| 21 | 20 | int megadrive_vblank_flag = 0; |
| 22 | | int genesis_scanline_counter = 0; |
| 23 | 21 | |
| 24 | 22 | |
| 25 | | // hacks for C2 |
| 26 | | int genvdp_use_cram = 0; // c2 uses it's own palette ram |
| 27 | | |
| 28 | | |
| 29 | | int megadrive_region_export; |
| 30 | | int megadrive_region_pal; |
| 31 | | |
| 32 | | |
| 33 | | |
| 34 | | |
| 35 | | |
| 36 | 23 | void genesis_vdp_sndirqline_callback_default(running_machine &machine, bool state) |
| 37 | 24 | { |
| 38 | 25 | // if you haven't actually hooked this up.... |
| r22030 | r22031 | |
| 163 | 150 | save_item(NAME(megadrive_imode)); |
| 164 | 151 | save_item(NAME(megadrive_irq6_pending)); |
| 165 | 152 | save_item(NAME(megadrive_irq4_pending)); |
| 166 | | save_item(NAME(megadrive_visible_scanlines)); |
| 167 | | save_item(NAME(megadrive_irq6_scanline)); |
| 168 | | save_item(NAME(megadrive_z80irq_scanline)); |
| 153 | save_item(NAME(m_visible_scanlines)); |
| 154 | save_item(NAME(m_irq6_scanline)); |
| 155 | save_item(NAME(m_z80irq_scanline)); |
| 156 | // save_item(NAME(m_total_scanlines)); |
| 157 | save_item(NAME(m_scanline_counter)); |
| 169 | 158 | |
| 170 | 159 | m_sprite_renderline = auto_alloc_array(machine(), UINT8, 1024); |
| 171 | 160 | m_highpri_renderline = auto_alloc_array(machine(), UINT8, 320); |
| r22030 | r22031 | |
| 218 | 207 | megadrive_imode = 0; |
| 219 | 208 | megadrive_irq6_pending = 0; |
| 220 | 209 | megadrive_irq4_pending = 0; |
| 210 | m_scanline_counter = 0; |
| 221 | 211 | } |
| 222 | 212 | |
| 223 | 213 | void sega_genesis_vdp_device::device_reset_old() |
| r22030 | r22031 | |
| 225 | 215 | // other stuff, are we sure we want to set some of these every reset? |
| 226 | 216 | // it's called from MACHINE_RESET( megadriv ) |
| 227 | 217 | megadrive_total_scanlines = 262; |
| 228 | | megadrive_visible_scanlines = 224; |
| 229 | | megadrive_irq6_scanline = 224; |
| 230 | | megadrive_z80irq_scanline = 226; |
| 218 | m_visible_scanlines = 224; |
| 219 | m_irq6_scanline = 224; |
| 220 | m_z80irq_scanline = 226; |
| 231 | 221 | } |
| 232 | 222 | |
| 233 | 223 | |
| r22030 | r22031 | |
| 277 | 267 | m_cram[offset] = data; |
| 278 | 268 | |
| 279 | 269 | //logerror("Wrote to CRAM addr %04x data %04x\n",m_vdp_address&0xfffe,m_cram[m_vdp_address>>1]); |
| 280 | | if (genvdp_use_cram) |
| 270 | if (m_vdp_use_cram) |
| 281 | 271 | { |
| 282 | 272 | int r,g,b; |
| 283 | 273 | r = ((data >> 1)&0x07); |
| r22030 | r22031 | |
| 1047 | 1037 | (vblank << 3) | |
| 1048 | 1038 | (megadrive_hblank_flag << 2) | |
| 1049 | 1039 | (megadrive_dma_active << 1 ) | |
| 1050 | | (megadrive_region_pal<<0); // PAL MODE FLAG checked by striker for region prot.. |
| 1040 | (m_vdp_pal << 0); // PAL MODE FLAG checked by striker for region prot.. |
| 1051 | 1041 | } |
| 1052 | 1042 | |
| 1053 | 1043 | static const UINT8 vc_ntsc_224[] = |
| r22030 | r22031 | |
| 1151 | 1141 | |
| 1152 | 1142 | time_elapsed_since_megadriv_scanline_timer = megadriv_scanline_timer->time_elapsed(); |
| 1153 | 1143 | |
| 1154 | | if (time_elapsed_since_megadriv_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines)) |
| 1144 | if (time_elapsed_since_megadriv_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/m_framerate /megadrive_total_scanlines)) |
| 1155 | 1145 | { |
| 1156 | | value4 = (UINT16)(MAX_HPOSITION*((double)(time_elapsed_since_megadriv_scanline_timer.attoseconds) / (double)(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines))); |
| 1146 | value4 = (UINT16)(MAX_HPOSITION*((double)(time_elapsed_since_megadriv_scanline_timer.attoseconds) / (double)(ATTOSECONDS_PER_SECOND/m_framerate /megadrive_total_scanlines))); |
| 1157 | 1147 | } |
| 1158 | 1148 | else /* in some cases (probably due to rounding errors) we get some stupid results (the odd huge value where the time elapsed is much higher than the scanline time??!).. hopefully by clamping the result to the maximum we limit errors */ |
| 1159 | 1149 | { |
| r22030 | r22031 | |
| 1172 | 1162 | int sega_genesis_vdp_device::genesis_get_scanline_counter(running_machine &machine) |
| 1173 | 1163 | { |
| 1174 | 1164 | if (!m_use_alt_timing) |
| 1175 | | return genesis_scanline_counter; |
| 1165 | return m_scanline_counter; |
| 1176 | 1166 | else |
| 1177 | 1167 | return machine.primary_screen->vpos(); |
| 1178 | 1168 | } |
| r22030 | r22031 | |
| 1198 | 1188 | } |
| 1199 | 1189 | |
| 1200 | 1190 | if (MEGADRIVE_REG01_240_LINE) |
| 1201 | | { |
| 1202 | | if (!megadrive_region_pal) |
| 1203 | | { |
| 1204 | | vpos = vc_ntsc_240[vpos%megadrive_total_scanlines]; |
| 1205 | | } |
| 1206 | | else |
| 1207 | | { |
| 1208 | | vpos = vc_pal_240[vpos%megadrive_total_scanlines]; |
| 1209 | | } |
| 1210 | | |
| 1211 | | } |
| 1191 | vpos = m_vdp_pal ? vc_pal_240[vpos % megadrive_total_scanlines] : vc_ntsc_240[vpos % megadrive_total_scanlines]; |
| 1212 | 1192 | else |
| 1213 | | { |
| 1214 | | if (!megadrive_region_pal) |
| 1215 | | { |
| 1216 | | vpos = vc_ntsc_224[vpos%megadrive_total_scanlines]; |
| 1217 | | } |
| 1218 | | else |
| 1219 | | { |
| 1220 | | vpos = vc_pal_224[vpos%megadrive_total_scanlines]; |
| 1221 | | } |
| 1222 | | } |
| 1193 | vpos = m_vdp_pal ? vc_pal_224[vpos % megadrive_total_scanlines] : vc_ntsc_224[vpos % megadrive_total_scanlines]; |
| 1223 | 1194 | |
| 1224 | 1195 | if (hpos>0xf7) hpos -=0x49; |
| 1225 | 1196 | |
| r22030 | r22031 | |
| 2718 | 2689 | void sega_genesis_vdp_device::genesis_render_scanline(running_machine &machine) |
| 2719 | 2690 | { |
| 2720 | 2691 | int scanline = genesis_get_scanline_counter(machine); |
| 2721 | | if (scanline>=0 && scanline<megadrive_visible_scanlines) |
| 2692 | if (scanline >= 0 && scanline < m_visible_scanlines) |
| 2722 | 2693 | { |
| 2723 | 2694 | //if (MEGADRIVE_REG01_DMA_ENABLE==0) mame_printf_debug("off\n"); |
| 2724 | 2695 | genesis_render_spriteline_to_spritebuffer(genesis_get_scanline_counter(machine)); |
| r22030 | r22031 | |
| 2744 | 2715 | sega_32x_device *_32xdev = machine.device<sega_32x_device>("sega32x"); // take this out of the VDP eventually |
| 2745 | 2716 | |
| 2746 | 2717 | |
| 2747 | | if (genesis_get_scanline_counter(machine)!=(megadrive_total_scanlines-1)) |
| 2718 | if (genesis_get_scanline_counter(machine) != (megadrive_total_scanlines - 1)) |
| 2748 | 2719 | { |
| 2749 | | if (!m_use_alt_timing) genesis_scanline_counter++; |
| 2720 | if (!m_use_alt_timing) m_scanline_counter++; |
| 2750 | 2721 | // mame_printf_debug("scanline %d\n",genesis_get_scanline_counter(machine)); |
| 2751 | 2722 | megadriv_render_timer->adjust(attotime::from_usec(1)); |
| 2752 | 2723 | |
| 2753 | | if (genesis_get_scanline_counter(machine)==megadrive_irq6_scanline ) |
| 2724 | if (genesis_get_scanline_counter(machine) == m_irq6_scanline) |
| 2754 | 2725 | { |
| 2755 | 2726 | // mame_printf_debug("x %d",genesis_get_scanline_counter(machine)); |
| 2756 | 2727 | irq6_on_timer->adjust(attotime::from_usec(6)); |
| r22030 | r22031 | |
| 2758 | 2729 | megadrive_vblank_flag = 1; |
| 2759 | 2730 | |
| 2760 | 2731 | // 32x interrupt! |
| 2761 | | if (_32xdev) _32xdev->_32x_scanline_cb0(machine); |
| 2732 | if (_32xdev) _32xdev->_32x_scanline_cb0(); |
| 2762 | 2733 | |
| 2763 | 2734 | } |
| 2764 | 2735 | |
| 2765 | 2736 | |
| 2766 | 2737 | |
| 2767 | | if (_32xdev) _32xdev->_32x_check_framebuffer_swap(); |
| 2738 | if (_32xdev) _32xdev->_32x_check_framebuffer_swap(m_scanline_counter >= m_irq6_scanline); |
| 2768 | 2739 | |
| 2769 | 2740 | |
| 2770 | 2741 | // if (genesis_get_scanline_counter(machine)==0) m_irq4counter = MEGADRIVE_REG0A_HINT_VALUE; |
| r22030 | r22031 | |
| 2797 | 2768 | //if (genesis_get_scanline_counter(machine)==0) irq4_on_timer->adjust(attotime::from_usec(2)); |
| 2798 | 2769 | |
| 2799 | 2770 | |
| 2800 | | if (_32xdev) _32xdev->_32x_scanline_cb1(); |
| 2771 | if (_32xdev) _32xdev->_32x_scanline_cb1(m_scanline_counter); |
| 2801 | 2772 | |
| 2802 | 2773 | |
| 2803 | | if (genesis_get_scanline_counter(machine) == megadrive_z80irq_scanline) |
| 2774 | if (genesis_get_scanline_counter(machine) == m_z80irq_scanline) |
| 2804 | 2775 | { |
| 2805 | 2776 | m_genesis_vdp_sndirqline_callback(machine, true); |
| 2806 | 2777 | } |
| 2807 | | if (genesis_get_scanline_counter(machine) == megadrive_z80irq_scanline + 1) |
| 2778 | if (genesis_get_scanline_counter(machine) == m_z80irq_scanline + 1) |
| 2808 | 2779 | { |
| 2809 | 2780 | m_genesis_vdp_sndirqline_callback(machine, false); |
| 2810 | 2781 | } |
| 2811 | 2782 | } |
| 2812 | 2783 | else /* pretend we're still on the same scanline to compensate for rounding errors */ |
| 2813 | 2784 | { |
| 2814 | | if (!m_use_alt_timing) genesis_scanline_counter = megadrive_total_scanlines - 1; |
| 2785 | if (!m_use_alt_timing) m_scanline_counter = megadrive_total_scanlines - 1; |
| 2815 | 2786 | } |
| 2816 | 2787 | |
| 2817 | 2788 | } |
| r22030 | r22031 | |
| 2830 | 2801 | //megadrive_irq6_pending = 0; /* NO! (breaks warlock) */ |
| 2831 | 2802 | |
| 2832 | 2803 | /* Set it to -1 here, so it becomes 0 when the first timer kicks in */ |
| 2833 | | if (!m_use_alt_timing) genesis_scanline_counter = -1; |
| 2804 | if (!m_use_alt_timing) m_scanline_counter = -1; |
| 2834 | 2805 | m_sprite_collision=0;//? when to reset this .. |
| 2835 | 2806 | megadrive_imode = MEGADRIVE_REG0C_INTERLEAVE; // can't change mid-frame.. |
| 2836 | 2807 | m_imode_odd_frame^=1; |
| 2837 | 2808 | // machine.device("genesis_snd_z80")->execute().set_input_line(0, CLEAR_LINE); // if the z80 interrupt hasn't happened by now, clear it.. |
| 2838 | 2809 | |
| 2839 | | |
| 2840 | | |
| 2841 | 2810 | if (MEGADRIVE_REG01_240_LINE) |
| 2842 | 2811 | { |
| 2843 | | if (!megadrive_region_pal) |
| 2844 | | { |
| 2845 | | /* this is invalid! */ |
| 2846 | | megadrive_visible_scanlines = 240; |
| 2847 | | megadrive_total_scanlines = 262; |
| 2848 | | megadrive_irq6_scanline = 240; |
| 2849 | | megadrive_z80irq_scanline = 240; |
| 2850 | | } |
| 2851 | | else |
| 2852 | | { |
| 2853 | | megadrive_visible_scanlines = 240; |
| 2854 | | megadrive_total_scanlines = 313; |
| 2855 | | megadrive_irq6_scanline = 240; |
| 2856 | | megadrive_z80irq_scanline = 240; |
| 2857 | | } |
| 2812 | /* this is invalid in PAL! */ |
| 2813 | megadrive_total_scanlines = m_base_total_scanlines; |
| 2814 | m_visible_scanlines = 240; |
| 2815 | m_irq6_scanline = 240; |
| 2816 | m_z80irq_scanline = 240; |
| 2858 | 2817 | } |
| 2859 | 2818 | else |
| 2860 | 2819 | { |
| 2861 | | if (!megadrive_region_pal) |
| 2862 | | { |
| 2863 | | megadrive_visible_scanlines = 224; |
| 2864 | | megadrive_total_scanlines=262; |
| 2865 | | megadrive_irq6_scanline = 224; |
| 2866 | | megadrive_z80irq_scanline = 224; |
| 2867 | | } |
| 2868 | | else |
| 2869 | | { |
| 2870 | | megadrive_visible_scanlines = 224; |
| 2871 | | megadrive_total_scanlines=313; |
| 2872 | | megadrive_irq6_scanline = 224; |
| 2873 | | megadrive_z80irq_scanline = 224; |
| 2874 | | } |
| 2820 | megadrive_total_scanlines = m_base_total_scanlines; |
| 2821 | m_visible_scanlines = 224; |
| 2822 | m_irq6_scanline = 224; |
| 2823 | m_z80irq_scanline = 224; |
| 2875 | 2824 | } |
| 2876 | 2825 | |
| 2877 | | if (megadrive_imode==3) |
| 2826 | if (megadrive_imode == 3) |
| 2878 | 2827 | { |
| 2879 | | megadrive_visible_scanlines<<=1; |
| 2880 | | megadrive_total_scanlines<<=1; |
| 2881 | | megadrive_irq6_scanline <<=1; |
| 2882 | | megadrive_z80irq_scanline <<=1; |
| 2828 | m_visible_scanlines <<= 1; |
| 2829 | megadrive_total_scanlines <<= 1; |
| 2830 | m_irq6_scanline <<= 1; |
| 2831 | m_z80irq_scanline <<= 1; |
| 2883 | 2832 | } |
| 2884 | 2833 | |
| 2885 | 2834 | |
| r22030 | r22031 | |
| 2893 | 2842 | } |
| 2894 | 2843 | // mame_printf_debug("my mode %02x", m_vdp_regs[0x0c]); |
| 2895 | 2844 | |
| 2896 | | visarea.set(0, scr_width-1, 0, megadrive_visible_scanlines-1); |
| 2845 | visarea.set(0, scr_width - 1, 0, m_visible_scanlines - 1); |
| 2897 | 2846 | |
| 2898 | 2847 | machine.primary_screen->configure(480, megadrive_total_scanlines, visarea, machine.primary_screen->frame_period().attoseconds); |
| 2899 | 2848 | |
| r22030 | r22031 | |
| 2923 | 2872 | timer.machine().scheduler().synchronize(); |
| 2924 | 2873 | vdp->vdp_handle_scanline_callback(timer.machine(), param); |
| 2925 | 2874 | |
| 2926 | | megadriv_scanline_timer->adjust(attotime::from_hz(megadriv_framerate) / megadrive_total_scanlines); |
| 2875 | megadriv_scanline_timer->adjust(attotime::from_hz(vdp->get_framerate()) / megadrive_total_scanlines); |
| 2927 | 2876 | } |
| 2928 | 2877 | else |
| 2929 | 2878 | { |
trunk/src/mame/machine/mega32x.c
| r22030 | r22031 | |
| 956 | 956 | |
| 957 | 957 | time_elapsed_since_megadriv_scanline_timer = megadriv_scanline_timer->time_elapsed(); |
| 958 | 958 | |
| 959 | | if (time_elapsed_since_megadriv_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines)) |
| 959 | if (time_elapsed_since_megadriv_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/m_framerate /megadrive_total_scanlines)) |
| 960 | 960 | { |
| 961 | | value4 = (UINT16)(MAX_HPOSITION*((double)(time_elapsed_since_megadriv_scanline_timer.attoseconds) / (double)(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines))); |
| 961 | value4 = (UINT16)(MAX_HPOSITION*((double)(time_elapsed_since_megadriv_scanline_timer.attoseconds) / (double)(ATTOSECONDS_PER_SECOND/m_framerate /megadrive_total_scanlines))); |
| 962 | 962 | } |
| 963 | 963 | else /* in some cases (probably due to rounding errors) we get some stupid results (the odd huge value where the time elapsed is much higher than the scanline time??!).. hopefully by clamping the result to the maximum we limit errors */ |
| 964 | 964 | { |
| r22030 | r22031 | |
| 972 | 972 | { |
| 973 | 973 | // what happens if the z80 accesses it, what authorization do we use? |
| 974 | 974 | |
| 975 | int ntsc; |
| 975 | 976 | |
| 976 | | |
| 977 | 977 | // printf("_32x_68k_a15180_r (a15180) %04x\n",mem_mask); |
| 978 | 978 | |
| 979 | 979 | // read needs authorization too I think, undefined behavior otherwise |
| r22030 | r22031 | |
| 982 | 982 | case 0x00: |
| 983 | 983 | |
| 984 | 984 | // the flag is inverted compared to the megadrive |
| 985 | | int ntsc; |
| 986 | | if (megadrive_region_pal) ntsc = 0; |
| 987 | | else ntsc = 1; |
| 985 | ntsc = m_32x_pal ? 0 : 1; |
| 988 | 986 | |
| 989 | 987 | return (ntsc << 15) | |
| 990 | | (m_32x_videopriority << 7 ) | |
| 991 | | ( m_32x_240mode << 6 ) | |
| 992 | | ( m_32x_displaymode << 0 ); |
| 988 | (m_32x_videopriority << 7) | |
| 989 | (m_32x_240mode << 6) | |
| 990 | (m_32x_displaymode << 0); |
| 993 | 991 | |
| 994 | | |
| 995 | | |
| 996 | 992 | case 0x02/2: |
| 997 | 993 | return m_32x_screenshift; |
| 998 | 994 | |
| r22030 | r22031 | |
| 1028 | 1024 | } |
| 1029 | 1025 | |
| 1030 | 1026 | |
| 1031 | | void sega_32x_device::_32x_check_framebuffer_swap(void) |
| 1027 | void sega_32x_device::_32x_check_framebuffer_swap(bool enabled) |
| 1032 | 1028 | { |
| 1033 | 1029 | // this logic should be correct, but makes things worse? |
| 1034 | | //if (genesis_scanline_counter >= megadrive_irq6_scanline) |
| 1030 | // enabled = (genesis_scanline_counter >= megadrive_irq6_scanline) from megavdp.c |
| 1031 | //if (enabled) |
| 1035 | 1032 | { |
| 1036 | 1033 | m_32x_a1518a_reg = m_32x_fb_swap & 1; |
| 1037 | 1034 | |
| r22030 | r22031 | |
| 1145 | 1142 | { |
| 1146 | 1143 | m_32x_fb_swap = data & 1; |
| 1147 | 1144 | |
| 1148 | | _32x_check_framebuffer_swap(); |
| 1145 | _32x_check_framebuffer_swap(TRUE); |
| 1149 | 1146 | } |
| 1150 | 1147 | |
| 1151 | 1148 | break; |
| r22030 | r22031 | |
| 1212 | 1209 | //if (m_sh2_master_hint_enable) printf("m_sh2_master_hint_enable enable!\n"); |
| 1213 | 1210 | //if (sh2_master_pwmint_enable) printf("sh2_master_pwn_enable enable!\n"); |
| 1214 | 1211 | |
| 1215 | | _32x_check_irqs(space.machine()); |
| 1212 | _32x_check_irqs(); |
| 1216 | 1213 | } |
| 1217 | 1214 | } |
| 1218 | 1215 | |
| r22030 | r22031 | |
| 1250 | 1247 | //if (m_sh2_slave_hint_enable) printf("m_sh2_slave_hint_enable enable!\n"); |
| 1251 | 1248 | //if (sh2_slave_pwmint_enable) printf("sh2_slave_pwm_enable enable!\n"); |
| 1252 | 1249 | |
| 1253 | | _32x_check_irqs(space.machine()); |
| 1254 | | |
| 1250 | _32x_check_irqs(); |
| 1255 | 1251 | } |
| 1256 | 1252 | } |
| 1257 | 1253 | |
| r22030 | r22031 | |
| 1319 | 1315 | // VINT (vertical interrupt) clear |
| 1320 | 1316 | /**********************************************************************************************/ |
| 1321 | 1317 | |
| 1322 | | WRITE16_MEMBER( sega_32x_device::_32x_sh2_master_4016_w ){ m_sh2_master_vint_pending = 0; _32x_check_irqs(space.machine()); } |
| 1323 | | WRITE16_MEMBER( sega_32x_device::_32x_sh2_slave_4016_w ) { m_sh2_slave_vint_pending = 0; _32x_check_irqs(space.machine()); } |
| 1318 | WRITE16_MEMBER( sega_32x_device::_32x_sh2_master_4016_w ){ m_sh2_master_vint_pending = 0; _32x_check_irqs(); } |
| 1319 | WRITE16_MEMBER( sega_32x_device::_32x_sh2_slave_4016_w ) { m_sh2_slave_vint_pending = 0; _32x_check_irqs(); } |
| 1324 | 1320 | |
| 1325 | 1321 | /**********************************************************************************************/ |
| 1326 | 1322 | // SH2 side 4018 |
| r22030 | r22031 | |
| 1553 | 1549 | |
| 1554 | 1550 | |
| 1555 | 1551 | |
| 1556 | | void sega_32x_device::_32x_check_irqs(running_machine& machine) |
| 1552 | void sega_32x_device::_32x_check_irqs() |
| 1557 | 1553 | { |
| 1558 | 1554 | if (m_sh2_master_vint_enable && m_sh2_master_vint_pending) m_master_cpu->set_input_line(SH2_VINT_IRQ_LEVEL,ASSERT_LINE); |
| 1559 | 1555 | else m_master_cpu->set_input_line(SH2_VINT_IRQ_LEVEL,CLEAR_LINE); |
| r22030 | r22031 | |
| 1562 | 1558 | else m_slave_cpu->set_input_line(SH2_VINT_IRQ_LEVEL,CLEAR_LINE); |
| 1563 | 1559 | } |
| 1564 | 1560 | |
| 1565 | | void sega_32x_device::_32x_scanline_cb0(running_machine& machine) |
| 1561 | void sega_32x_device::_32x_scanline_cb0() |
| 1566 | 1562 | { |
| 1567 | 1563 | m_sh2_master_vint_pending = 1; |
| 1568 | 1564 | m_sh2_slave_vint_pending = 1; |
| 1569 | | _32x_check_irqs(machine); |
| 1565 | _32x_check_irqs(); |
| 1570 | 1566 | } |
| 1571 | 1567 | |
| 1572 | 1568 | |
| 1573 | | void sega_32x_device::_32x_scanline_cb1() |
| 1569 | void sega_32x_device::_32x_scanline_cb1(int scanline) |
| 1574 | 1570 | { |
| 1575 | 1571 | m_32x_hcount_compare_val++; |
| 1576 | 1572 | |
| 1577 | | if(m_32x_hcount_compare_val >= m_32x_hcount_reg) |
| 1573 | if (m_32x_hcount_compare_val >= m_32x_hcount_reg) |
| 1578 | 1574 | { |
| 1579 | 1575 | m_32x_hcount_compare_val = -1; |
| 1580 | 1576 | |
| 1581 | | if(genesis_scanline_counter < 224 || m_sh2_hint_in_vbl) |
| 1577 | if (scanline < 224 || m_sh2_hint_in_vbl) |
| 1582 | 1578 | { |
| 1583 | | if(m_sh2_master_hint_enable) { m_master_cpu->set_input_line(SH2_HINT_IRQ_LEVEL,ASSERT_LINE); } |
| 1584 | | if(m_sh2_slave_hint_enable) { m_slave_cpu->set_input_line(SH2_HINT_IRQ_LEVEL,ASSERT_LINE); } |
| 1579 | if (m_sh2_master_hint_enable) { m_master_cpu->set_input_line(SH2_HINT_IRQ_LEVEL,ASSERT_LINE); } |
| 1580 | if (m_sh2_slave_hint_enable) { m_slave_cpu->set_input_line(SH2_HINT_IRQ_LEVEL,ASSERT_LINE); } |
| 1585 | 1581 | } |
| 1586 | 1582 | } |
| 1587 | 1583 | } |
trunk/src/mame/machine/megadriv.c
| r22030 | r22031 | |
| 389 | 389 | { |
| 390 | 390 | case 0: |
| 391 | 391 | logerror("%06x read version register\n", space.device().safe_pc()); |
| 392 | | retdata = megadrive_region_export<<7 | // Export |
| 393 | | megadrive_region_pal<<6 | // NTSC |
| 392 | retdata = state->m_export << 7 | // Export |
| 393 | state->m_pal << 6 | // NTSC or PAL? |
| 394 | 394 | (state->m_segacd ? 0x00 : 0x20) | // 0x20 = no sega cd |
| 395 | 395 | 0x00 | // Unused (Always 0) |
| 396 | 396 | 0x00 | // Bit 3 of Version Number |
| r22030 | r22031 | |
| 866 | 866 | |
| 867 | 867 | |
| 868 | 868 | |
| 869 | | |
| 870 | | |
| 871 | | |
| 872 | 869 | SCREEN_UPDATE_RGB32(megadriv) |
| 873 | 870 | { |
| 874 | 871 | sega_genesis_vdp_device *vdp = screen.machine().device<sega_genesis_vdp_device>("gen_vdp"); // yuck |
| r22030 | r22031 | |
| 900 | 897 | |
| 901 | 898 | |
| 902 | 899 | |
| 903 | | |
| 904 | | |
| 905 | | |
| 906 | | |
| 907 | | |
| 908 | | |
| 909 | | |
| 910 | | |
| 911 | 900 | /*****************************************************************************************/ |
| 912 | 901 | |
| 913 | 902 | |
| r22030 | r22031 | |
| 929 | 918 | state->m_genz80.z80_is_reset = 1; |
| 930 | 919 | state->m_genz80.z80_has_bus = 1; |
| 931 | 920 | state->m_genz80.z80_bank_addr = 0; |
| 932 | | genesis_scanline_counter = -1; |
| 921 | state->m_vdp->set_scanline_counter(-1); |
| 933 | 922 | machine.scheduler().timer_set(attotime::zero, FUNC(megadriv_z80_run_state)); |
| 934 | 923 | } |
| 935 | 924 | |
| r22030 | r22031 | |
| 943 | 932 | |
| 944 | 933 | if (state->m_other_hacks) |
| 945 | 934 | { |
| 946 | | // set_refresh_rate(megadriv_framerate); |
| 947 | 935 | // machine.device("maincpu")->set_clock_scale(0.9950f); /* Fatal Rewind is very fussy... (and doesn't work now anyway, so don't bother with this) */ |
| 948 | 936 | if (state->m_megadrive_ram) |
| 949 | 937 | memset(state->m_megadrive_ram,0x00,0x10000); |
| r22030 | r22031 | |
| 1193 | 1181 | { |
| 1194 | 1182 | if (source <= 0x3fffff) |
| 1195 | 1183 | { |
| 1196 | | source -= 2; // compensate DMA lag |
| 1184 | source -= 2; // compensate DMA lag |
| 1197 | 1185 | return space68k.read_word(source); |
| 1198 | 1186 | } |
| 1199 | 1187 | else if ((source >= 0xe00000) && (source <= 0xffffff)) |
| r22030 | r22031 | |
| 1229 | 1217 | vdp_get_word_from_68k_mem = vdp_get_word_from_68k_mem_delayed; |
| 1230 | 1218 | } |
| 1231 | 1219 | if (machine().device("segacd")) |
| 1232 | | { |
| 1220 | { |
| 1233 | 1221 | printf("SegaCD found 'segacd'\n"); |
| 1234 | 1222 | vdp_get_word_from_68k_mem = vdp_get_word_from_68k_mem_delayed; |
| 1235 | | } |
| 1223 | } |
| 1236 | 1224 | |
| 1237 | 1225 | m68k_set_tas_callback(machine().device("maincpu"), megadriv_tas_callback); |
| 1238 | 1226 | |
| r22030 | r22031 | |
| 1268 | 1256 | } |
| 1269 | 1257 | mame_printf_debug("\n"); |
| 1270 | 1258 | } |
| 1259 | |
| 1260 | m_export = 0; |
| 1261 | m_pal = 0; |
| 1271 | 1262 | } |
| 1272 | 1263 | |
| 1273 | 1264 | DRIVER_INIT_MEMBER(md_base_state,megadriv_c2) |
| 1274 | 1265 | { |
| 1275 | | genvdp_use_cram = 0; |
| 1276 | 1266 | m_other_hacks = 0; |
| 1277 | 1267 | |
| 1278 | 1268 | megadriv_init_common(); |
| 1279 | | megadriv_framerate = 60; |
| 1269 | |
| 1270 | m_vdp->set_use_cram(0); // C2 uses its own palette ram |
| 1271 | m_vdp->set_vdp_pal(FALSE); |
| 1272 | m_vdp->set_framerate(60); |
| 1273 | m_vdp->set_total_scanlines(313); |
| 1280 | 1274 | } |
| 1281 | 1275 | |
| 1282 | 1276 | |
| 1283 | 1277 | |
| 1284 | 1278 | DRIVER_INIT_MEMBER(md_base_state,megadriv) |
| 1285 | 1279 | { |
| 1286 | | genvdp_use_cram = 1; |
| 1287 | 1280 | m_other_hacks = 1; |
| 1288 | 1281 | |
| 1289 | 1282 | megadriv_init_common(); |
| 1290 | | megadriv_framerate = 60; |
| 1283 | |
| 1284 | // todo: move this to the device interface? |
| 1285 | m_vdp->set_use_cram(1); |
| 1286 | m_vdp->set_vdp_pal(FALSE); |
| 1287 | m_vdp->set_framerate(60); |
| 1288 | m_vdp->set_total_scanlines(313); |
| 1289 | if (m_32x) |
| 1290 | { |
| 1291 | m_32x->set_framerate(60); |
| 1292 | m_32x->set_32x_pal(FALSE); |
| 1293 | } |
| 1294 | if (m_segacd) |
| 1295 | m_segacd->set_framerate(60); |
| 1296 | |
| 1297 | m_export = 1; |
| 1298 | m_pal = 0; |
| 1291 | 1299 | } |
| 1292 | 1300 | |
| 1293 | 1301 | DRIVER_INIT_MEMBER(md_base_state,megadrij) |
| 1294 | 1302 | { |
| 1295 | | genvdp_use_cram = 1; |
| 1296 | 1303 | m_other_hacks = 1; |
| 1297 | 1304 | |
| 1298 | 1305 | megadriv_init_common(); |
| 1299 | | megadriv_framerate = 60; |
| 1306 | |
| 1307 | // todo: move this to the device interface? |
| 1308 | m_vdp->set_use_cram(1); |
| 1309 | m_vdp->set_vdp_pal(FALSE); |
| 1310 | m_vdp->set_framerate(60); |
| 1311 | m_vdp->set_total_scanlines(313); |
| 1312 | if (m_32x) |
| 1313 | { |
| 1314 | m_32x->set_framerate(60); |
| 1315 | m_32x->set_32x_pal(FALSE); |
| 1316 | } |
| 1317 | if (m_segacd) |
| 1318 | m_segacd->set_framerate(60); |
| 1319 | |
| 1320 | m_export = 0; |
| 1321 | m_pal = 0; |
| 1300 | 1322 | } |
| 1301 | 1323 | |
| 1302 | 1324 | DRIVER_INIT_MEMBER(md_base_state,megadrie) |
| 1303 | 1325 | { |
| 1304 | | genvdp_use_cram = 1; |
| 1305 | 1326 | m_other_hacks = 1; |
| 1306 | 1327 | |
| 1307 | 1328 | megadriv_init_common(); |
| 1308 | | megadriv_framerate = 50; |
| 1329 | |
| 1330 | // todo: move this to the device interface? |
| 1331 | m_vdp->set_use_cram(1); |
| 1332 | m_vdp->set_vdp_pal(TRUE); |
| 1333 | m_vdp->set_framerate(50); |
| 1334 | m_vdp->set_total_scanlines(262); |
| 1335 | if (m_32x) |
| 1336 | { |
| 1337 | m_32x->set_framerate(50); |
| 1338 | m_32x->set_32x_pal(TRUE); |
| 1339 | } |
| 1340 | if (m_segacd) |
| 1341 | m_segacd->set_framerate(50); |
| 1342 | |
| 1343 | m_export = 1; |
| 1344 | m_pal = 1; |
| 1309 | 1345 | } |
| 1310 | 1346 | |
| 1311 | 1347 | DRIVER_INIT_MEMBER(md_base_state,mpnew) |
| r22030 | r22031 | |
| 1369 | 1405 | |
| 1370 | 1406 | |
| 1371 | 1407 | |
| 1372 | | |
| 1373 | | |
| 1374 | 1408 | SCREEN_VBLANK(megadriv) |
| 1375 | 1409 | { |
| 1376 | 1410 | md_base_state *state = screen.machine().driver_data<md_base_state>(); |