Previous 15994 Revisions Next

r6769 Saturday 26th December, 2009 at 11:12:24 UTC by Robbbert
[SATURN] Applied mame changes to fix timer issues.
[src/mess/drivers]saturn.c

src/mess/drivers/saturn.c
r6768r6769
20422042
20432043/* to do, update bios idle skips so they work better with this arrangement.. */
20442044
2045static emu_timer *vblank_out_timer,*scan_timer,*t1_timer;
2045static const device_config *vblank_out_timer,*scan_timer,*t1_timer;
20462046static int h_sync,v_sync;
20472047static int cur_scan;
20482048
r6768r6769
20502050timer_0 = 0; \
20512051{ \
20522052   /*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); \
20542054} \
20552055
20562056#define VBLANK_IN_IRQ \
r6768r6769
20632063timer_1 = stv_scu[37] & 0x1ff; \
20642064{ \
20652065   /*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); \
20672067} \
20682068
20692069#define TIMER_0_IRQ \
20702070if(timer_0 == (stv_scu[36] & 0x3ff)) \
20712071{ \
20722072   /*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 ); \
20742074} \
20752075
20762076#define TIMER_1_IRQ   \
r6768r6769
20792079   if(!(stv_scu[38] & 0x80)) \
20802080   { \
20812081      /*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 ); \
20832083   } \
20842084   else \
20852085   { \
20862086      if((timer_0) == (stv_scu[36] & 0x3ff)) \
20872087      { \
20882088         /*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 ); \
20902090      } \
20912091   } \
20922092} \
r6768r6769
20962096   cputag_set_input_line_and_vector(machine, "maincpu", 2, (stv_irq.vdp1_end) ? HOLD_LINE : CLEAR_LINE, 0x4d); \
20972097} \
20982098
2099static TIMER_CALLBACK( hblank_in_irq )
2099static TIMER_DEVICE_CALLBACK( hblank_in_irq )
21002100{
21012101   int scanline = param;
21022102
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);
21052105
21062106   HBLANK_IN_IRQ;
21072107   TIMER_0_IRQ;
r6768r6769
21092109   if(scanline+1 < v_sync)
21102110   {
21112111      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);
21132113      /*set the first Timer-1 event*/
21142114      cur_scan = scanline+1;
21152115      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);
21172117   }
21182118
21192119   timer_0++;
21202120}
21212121
2122static TIMER_CALLBACK( timer1_irq )
2122static TIMER_DEVICE_CALLBACK( timer1_irq )
21232123{
21242124   int cur_point = param;
21252125
r6768r6769
21272127
21282128   if((cur_point+1) < h_sync && stv_irq.timer_1)
21292129   {
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);
21312131   }
21322132
21332133   if(timer_1 > 0) timer_1--;
r6768r6769
21382138   VDP1_IRQ;
21392139}
21402140
2141static TIMER_CALLBACK( vblank_out_irq )
2141static TIMER_DEVICE_CALLBACK( vblank_out_irq )
21422142{
21432143   VBLANK_OUT_IRQ;
21442144}
r6768r6769
21562156
21572157   /*Next V-Blank-OUT event*/
21582158   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);
21602160   /*Set the first Hblank-IN event*/
21612161   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);
21632163
21642164   /*TODO: timing of this one (related to the VDP1 speed)*/
21652165   /*      (NOTE: value shouldn't be at h_sync/v_sync position (will break shienryu))*/
r6768r6769
22782278   stvcd_reset( machine );
22792279
22802280   /* 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);
22862286}
22872287
22882288static const gfx_layout tiles8x8x4_layout =
r6768r6769
24002400   MDRV_CPU_ADD("audiocpu", M68000, MASTER_CLOCK_352/5) //11.46 MHz
24012401   MDRV_CPU_PROGRAM_MAP(sound_mem)
24022402
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
24072403   MDRV_MACHINE_START(saturn)
24082404   MDRV_MACHINE_RESET(saturn)
24092405
24102406   MDRV_NVRAM_HANDLER(saturn)
24112407
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
24122413   /* 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
24132417   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB15)
24142418   MDRV_SCREEN_SIZE(704*2, 512*2)
24152419   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

Previous 15994 Revisions Next


© 1998-2018 The MESS Team