src/mess/drivers/saturn.c
| r6768 | r6769 | |
| 2042 | 2042 | |
| 2043 | 2043 | /* to do, update bios idle skips so they work better with this arrangement.. */ |
| 2044 | 2044 | |
| 2045 | | static emu_timer *vblank_out_timer,*scan_timer,*t1_timer; |
| 2045 | static const device_config *vblank_out_timer,*scan_timer,*t1_timer; |
| 2046 | 2046 | static int h_sync,v_sync; |
| 2047 | 2047 | static int cur_scan; |
| 2048 | 2048 | |
| r6768 | r6769 | |
| 2050 | 2050 | timer_0 = 0; \ |
| 2051 | 2051 | { \ |
| 2052 | 2052 | /*if(LOG_IRQ) logerror ("Interrupt: VBlank-OUT Vector 0x41 Level 0x0e\n");*/ \ |
| 2053 | | cputag_set_input_line_and_vector(machine, "maincpu", 0xe, (stv_irq.vblank_out) ? HOLD_LINE : CLEAR_LINE , 0x41); \ |
| 2053 | cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xe, (stv_irq.vblank_out) ? HOLD_LINE : CLEAR_LINE , 0x41); \ |
| 2054 | 2054 | } \ |
| 2055 | 2055 | |
| 2056 | 2056 | #define VBLANK_IN_IRQ \ |
| r6768 | r6769 | |
| 2063 | 2063 | timer_1 = stv_scu[37] & 0x1ff; \ |
| 2064 | 2064 | { \ |
| 2065 | 2065 | /*if(LOG_IRQ) logerror ("Interrupt: HBlank-In at scanline %04x, Vector 0x42 Level 0x0d\n",scanline);*/ \ |
| 2066 | | cputag_set_input_line_and_vector(machine, "maincpu", 0xd, (stv_irq.hblank_in) ? HOLD_LINE : CLEAR_LINE, 0x42); \ |
| 2066 | cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xd, (stv_irq.hblank_in) ? HOLD_LINE : CLEAR_LINE, 0x42); \ |
| 2067 | 2067 | } \ |
| 2068 | 2068 | |
| 2069 | 2069 | #define TIMER_0_IRQ \ |
| 2070 | 2070 | if(timer_0 == (stv_scu[36] & 0x3ff)) \ |
| 2071 | 2071 | { \ |
| 2072 | 2072 | /*if(LOG_IRQ) logerror ("Interrupt: Timer 0 at scanline %04x, Vector 0x43 Level 0x0c\n",scanline);*/ \ |
| 2073 | | cputag_set_input_line_and_vector(machine, "maincpu", 0xc, (stv_irq.timer_0) ? HOLD_LINE : CLEAR_LINE, 0x43 ); \ |
| 2073 | cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xc, (stv_irq.timer_0) ? HOLD_LINE : CLEAR_LINE, 0x43 ); \ |
| 2074 | 2074 | } \ |
| 2075 | 2075 | |
| 2076 | 2076 | #define TIMER_1_IRQ \ |
| r6768 | r6769 | |
| 2079 | 2079 | if(!(stv_scu[38] & 0x80)) \ |
| 2080 | 2080 | { \ |
| 2081 | 2081 | /*if(LOG_IRQ) logerror ("Interrupt: Timer 1 at point %04x, Vector 0x44 Level 0x0b\n",point);*/ \ |
| 2082 | | cputag_set_input_line_and_vector(machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ |
| 2082 | cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ |
| 2083 | 2083 | } \ |
| 2084 | 2084 | else \ |
| 2085 | 2085 | { \ |
| 2086 | 2086 | if((timer_0) == (stv_scu[36] & 0x3ff)) \ |
| 2087 | 2087 | { \ |
| 2088 | 2088 | /*if(LOG_IRQ) logerror ("Interrupt: Timer 1 at point %04x, Vector 0x44 Level 0x0b\n",point);*/ \ |
| 2089 | | cputag_set_input_line_and_vector(machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ |
| 2089 | cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ |
| 2090 | 2090 | } \ |
| 2091 | 2091 | } \ |
| 2092 | 2092 | } \ |
| r6768 | r6769 | |
| 2096 | 2096 | cputag_set_input_line_and_vector(machine, "maincpu", 2, (stv_irq.vdp1_end) ? HOLD_LINE : CLEAR_LINE, 0x4d); \ |
| 2097 | 2097 | } \ |
| 2098 | 2098 | |
| 2099 | | static TIMER_CALLBACK( hblank_in_irq ) |
| 2099 | static TIMER_DEVICE_CALLBACK( hblank_in_irq ) |
| 2100 | 2100 | { |
| 2101 | 2101 | int scanline = param; |
| 2102 | 2102 | |
| 2103 | | // h = video_screen_get_height(machine->primary_screen); |
| 2104 | | // w = video_screen_get_width(machine->primary_screen); |
| 2103 | // h = video_screen_get_height(timer->machine->primary_screen); |
| 2104 | // w = video_screen_get_width(timer->machine->primary_screen); |
| 2105 | 2105 | |
| 2106 | 2106 | HBLANK_IN_IRQ; |
| 2107 | 2107 | TIMER_0_IRQ; |
| r6768 | r6769 | |
| 2109 | 2109 | if(scanline+1 < v_sync) |
| 2110 | 2110 | { |
| 2111 | 2111 | if(stv_irq.hblank_in || stv_irq.timer_0) |
| 2112 | | timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline+1, h_sync), scanline+1); |
| 2112 | timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, h_sync), scanline+1); |
| 2113 | 2113 | /*set the first Timer-1 event*/ |
| 2114 | 2114 | cur_scan = scanline+1; |
| 2115 | 2115 | if(stv_irq.timer_1) |
| 2116 | | timer_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline+1, 0), 0); |
| 2116 | timer_device_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, 0), 0); |
| 2117 | 2117 | } |
| 2118 | 2118 | |
| 2119 | 2119 | timer_0++; |
| 2120 | 2120 | } |
| 2121 | 2121 | |
| 2122 | | static TIMER_CALLBACK( timer1_irq ) |
| 2122 | static TIMER_DEVICE_CALLBACK( timer1_irq ) |
| 2123 | 2123 | { |
| 2124 | 2124 | int cur_point = param; |
| 2125 | 2125 | |
| r6768 | r6769 | |
| 2127 | 2127 | |
| 2128 | 2128 | if((cur_point+1) < h_sync && stv_irq.timer_1) |
| 2129 | 2129 | { |
| 2130 | | timer_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(machine->primary_screen, cur_scan, cur_point+1), cur_point+1); |
| 2130 | timer_device_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, cur_scan, cur_point+1), cur_point+1); |
| 2131 | 2131 | } |
| 2132 | 2132 | |
| 2133 | 2133 | if(timer_1 > 0) timer_1--; |
| r6768 | r6769 | |
| 2138 | 2138 | VDP1_IRQ; |
| 2139 | 2139 | } |
| 2140 | 2140 | |
| 2141 | | static TIMER_CALLBACK( vblank_out_irq ) |
| 2141 | static TIMER_DEVICE_CALLBACK( vblank_out_irq ) |
| 2142 | 2142 | { |
| 2143 | 2143 | VBLANK_OUT_IRQ; |
| 2144 | 2144 | } |
| r6768 | r6769 | |
| 2156 | 2156 | |
| 2157 | 2157 | /*Next V-Blank-OUT event*/ |
| 2158 | 2158 | if(stv_irq.vblank_out) |
| 2159 | | timer_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(device->machine->primary_screen, 0, 0), 0); |
| 2159 | timer_device_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(device->machine->primary_screen, 0, 0), 0); |
| 2160 | 2160 | /*Set the first Hblank-IN event*/ |
| 2161 | 2161 | if(stv_irq.hblank_in || stv_irq.timer_0 || stv_irq.timer_1) |
| 2162 | | timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(device->machine->primary_screen, 0, h_sync), 0); |
| 2162 | timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(device->machine->primary_screen, 0, h_sync), 0); |
| 2163 | 2163 | |
| 2164 | 2164 | /*TODO: timing of this one (related to the VDP1 speed)*/ |
| 2165 | 2165 | /* (NOTE: value shouldn't be at h_sync/v_sync position (will break shienryu))*/ |
| r6768 | r6769 | |
| 2278 | 2278 | stvcd_reset( machine ); |
| 2279 | 2279 | |
| 2280 | 2280 | /* set the first scanline 0 timer to go off */ |
| 2281 | | scan_timer = timer_alloc(machine, hblank_in_irq, NULL); |
| 2282 | | t1_timer = timer_alloc(machine, timer1_irq,NULL); |
| 2283 | | vblank_out_timer = timer_alloc(machine, vblank_out_irq,NULL); |
| 2284 | | timer_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); |
| 2285 | | timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 224, 352), 0); |
| 2281 | scan_timer = devtag_get_device(machine, "scan_timer"); |
| 2282 | t1_timer = devtag_get_device(machine, "t1_timer"); |
| 2283 | vblank_out_timer = devtag_get_device(machine, "vbout_timer"); |
| 2284 | timer_device_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); |
| 2285 | timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 224, 352), 0); |
| 2286 | 2286 | } |
| 2287 | 2287 | |
| 2288 | 2288 | static const gfx_layout tiles8x8x4_layout = |
| r6768 | r6769 | |
| 2400 | 2400 | MDRV_CPU_ADD("audiocpu", M68000, MASTER_CLOCK_352/5) //11.46 MHz |
| 2401 | 2401 | MDRV_CPU_PROGRAM_MAP(sound_mem) |
| 2402 | 2402 | |
| 2403 | | MDRV_SCREEN_ADD("screen", RASTER) |
| 2404 | | MDRV_SCREEN_REFRESH_RATE(60) |
| 2405 | | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(192)) // guess, needed to force video update after V-Blank OUT interrupt |
| 2406 | | |
| 2407 | 2403 | MDRV_MACHINE_START(saturn) |
| 2408 | 2404 | MDRV_MACHINE_RESET(saturn) |
| 2409 | 2405 | |
| 2410 | 2406 | MDRV_NVRAM_HANDLER(saturn) |
| 2411 | 2407 | |
| 2408 | MDRV_TIMER_ADD("scan_timer", hblank_in_irq) |
| 2409 | MDRV_TIMER_ADD("t1_timer", timer1_irq) |
| 2410 | MDRV_TIMER_ADD("vbout_timer", vblank_out_irq) |
| 2411 | MDRV_TIMER_ADD("sector_timer", stv_sector_cb) |
| 2412 | |
| 2412 | 2413 | /* video hardware */ |
| 2414 | MDRV_SCREEN_ADD("screen", RASTER) |
| 2415 | MDRV_SCREEN_REFRESH_RATE(60) |
| 2416 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(192)) // guess, needed to force video update after V-Blank OUT interrupt |
| 2413 | 2417 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB15) |
| 2414 | 2418 | MDRV_SCREEN_SIZE(704*2, 512*2) |
| 2415 | 2419 | MDRV_SCREEN_VISIBLE_AREA(0*8, 703, 0*8, 511) // we need to use a resolution as high as the max size it can change to |