Previous 199869 Revisions Next

r30642 Sunday 25th May, 2014 at 00:53:59 UTC by Alex Jackson
Partially revert r30524 screen.c changes; bring back the separate timer for resetting partial updates, but ensure that the vblank timer and the partial-update-reset timer always fire in the correct order when vblank starts on scanline 0 [Alex Jackson]
[src/emu]screen.c screen.h

trunk/src/emu/screen.c
r30641r30642
7171      m_vblank_end_time(attotime::zero),
7272      m_vblank_begin_timer(NULL),
7373      m_vblank_end_timer(NULL),
74      m_scanline0_timer(NULL),
7475      m_scanline_timer(NULL),
7576      m_frame_number(0),
7677      m_partial_updates_this_frame(0)
r30641r30642
313314   m_vblank_begin_timer = timer_alloc(TID_VBLANK_START);
314315   m_vblank_end_timer = timer_alloc(TID_VBLANK_END);
315316
317   // allocate a timer to reset partial updates
318   m_scanline0_timer = timer_alloc(TID_SCANLINE0);
319
316320   // allocate a timer to generate per-scanline updates
317321   if ((m_video_attributes & VIDEO_UPDATE_SCANLINE) != 0)
318322      m_scanline_timer = timer_alloc(TID_SCANLINE);
r30641r30642
405409         vblank_end();
406410         break;
407411
412      // first scanline
413      case TID_SCANLINE0:
414         reset_partial_updates();
415         break;
416
408417      // subsequent scanlines when scanline updates are enabled
409418      case TID_SCANLINE:
410419
r30641r30642
451460   m_scantime = frame_period / height;
452461   m_pixeltime = frame_period / (height * width);
453462
454   // if there has been no VBLANK time specified in the MACHINE_DRIVER, compute it now
455   // from the visible area, otherwise just used the supplied value
463   // if an old style VBLANK_TIME was specified in the MACHINE_CONFIG,
464   // use it; otherwise calculate the VBLANK period from the visible area
456465   if (m_oldstyle_vblank_supplied)
457466      m_vblank_period = m_vblank;
458467   else
459468      m_vblank_period = m_scantime * (height - visarea.height());
460469
461   // start the VBLANK timer
462   m_vblank_begin_timer->adjust(time_until_vblank_start());
470   // we are now fully configured with the new parameters
471   // and can safely call time_until_pos(), etc.
463472
473   // if the frame period was reduced so that we are now past the end of the frame,
474   // call the VBLANK start timer now; otherwise, adjust it for the future
475   attoseconds_t delta = (machine().time() - m_vblank_start_time).as_attoseconds();
476   if (delta >= m_frame_period)
477      vblank_begin();
478   else
479      m_vblank_begin_timer->adjust(time_until_vblank_start());
480
481   // if we are on scanline 0 already, call the scanline 0 timer
482   // by hand now; otherwise, adjust it for the future
483   if (vpos() == 0)
484      reset_partial_updates();
485   else
486      m_scanline0_timer->adjust(time_until_pos(0));
487
464488   // adjust speed if necessary
465489   machine().video().update_refresh_speed();
466490}
r30641r30642
479503   m_vblank_start_time = m_vblank_end_time - attotime(0, m_vblank_period);
480504
481505   // if we are resetting relative to (0,0) == VBLANK end, call the
482   // scanline 0 timer by hand now
506   // scanline 0 timer by hand now; otherwise, adjust it for the future
483507   if (beamy == 0 && beamx == 0)
484508      reset_partial_updates();
509   else
510      m_scanline0_timer->adjust(time_until_pos(0));
485511
486512   // if we are resetting relative to (visarea.max_y + 1, 0) == VBLANK start,
487513   // call the VBLANK start timer now; otherwise, adjust it for the future
r30641r30642
645671{
646672   m_last_partial_scan = 0;
647673   m_partial_updates_this_frame = 0;
674   m_scanline0_timer->adjust(time_until_pos(0));
648675}
649676
650677
r30641r30642
830857
831858   // increment the frame number counter
832859   m_frame_number++;
833
834   reset_partial_updates();
835860}
836861
837862
trunk/src/emu/screen.h
r30641r30642
232232   {
233233      TID_VBLANK_START,
234234      TID_VBLANK_END,
235      TID_SCANLINE0,
235236      TID_SCANLINE
236237   };
237238
r30641r30642
293294   attotime            m_vblank_end_time;          // time of last VBLANK end
294295   emu_timer *         m_vblank_begin_timer;       // timer to signal VBLANK start
295296   emu_timer *         m_vblank_end_timer;         // timer to signal VBLANK end
297   emu_timer *         m_scanline0_timer;          // scanline 0 timer
296298   emu_timer *         m_scanline_timer;           // scanline timer
297299   UINT64              m_frame_number;             // the current frame number
298300   UINT32              m_partial_updates_this_frame;// partial update counter this frame

Previous 199869 Revisions Next


© 1997-2024 The MAME Team