trunk/src/emu/screen.c
| r30641 | r30642 | |
| 71 | 71 | m_vblank_end_time(attotime::zero), |
| 72 | 72 | m_vblank_begin_timer(NULL), |
| 73 | 73 | m_vblank_end_timer(NULL), |
| 74 | m_scanline0_timer(NULL), |
| 74 | 75 | m_scanline_timer(NULL), |
| 75 | 76 | m_frame_number(0), |
| 76 | 77 | m_partial_updates_this_frame(0) |
| r30641 | r30642 | |
| 313 | 314 | m_vblank_begin_timer = timer_alloc(TID_VBLANK_START); |
| 314 | 315 | m_vblank_end_timer = timer_alloc(TID_VBLANK_END); |
| 315 | 316 | |
| 317 | // allocate a timer to reset partial updates |
| 318 | m_scanline0_timer = timer_alloc(TID_SCANLINE0); |
| 319 | |
| 316 | 320 | // allocate a timer to generate per-scanline updates |
| 317 | 321 | if ((m_video_attributes & VIDEO_UPDATE_SCANLINE) != 0) |
| 318 | 322 | m_scanline_timer = timer_alloc(TID_SCANLINE); |
| r30641 | r30642 | |
| 405 | 409 | vblank_end(); |
| 406 | 410 | break; |
| 407 | 411 | |
| 412 | // first scanline |
| 413 | case TID_SCANLINE0: |
| 414 | reset_partial_updates(); |
| 415 | break; |
| 416 | |
| 408 | 417 | // subsequent scanlines when scanline updates are enabled |
| 409 | 418 | case TID_SCANLINE: |
| 410 | 419 | |
| r30641 | r30642 | |
| 451 | 460 | m_scantime = frame_period / height; |
| 452 | 461 | m_pixeltime = frame_period / (height * width); |
| 453 | 462 | |
| 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 |
| 456 | 465 | if (m_oldstyle_vblank_supplied) |
| 457 | 466 | m_vblank_period = m_vblank; |
| 458 | 467 | else |
| 459 | 468 | m_vblank_period = m_scantime * (height - visarea.height()); |
| 460 | 469 | |
| 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. |
| 463 | 472 | |
| 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 | |
| 464 | 488 | // adjust speed if necessary |
| 465 | 489 | machine().video().update_refresh_speed(); |
| 466 | 490 | } |
| r30641 | r30642 | |
| 479 | 503 | m_vblank_start_time = m_vblank_end_time - attotime(0, m_vblank_period); |
| 480 | 504 | |
| 481 | 505 | // 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 |
| 483 | 507 | if (beamy == 0 && beamx == 0) |
| 484 | 508 | reset_partial_updates(); |
| 509 | else |
| 510 | m_scanline0_timer->adjust(time_until_pos(0)); |
| 485 | 511 | |
| 486 | 512 | // if we are resetting relative to (visarea.max_y + 1, 0) == VBLANK start, |
| 487 | 513 | // call the VBLANK start timer now; otherwise, adjust it for the future |
| r30641 | r30642 | |
| 645 | 671 | { |
| 646 | 672 | m_last_partial_scan = 0; |
| 647 | 673 | m_partial_updates_this_frame = 0; |
| 674 | m_scanline0_timer->adjust(time_until_pos(0)); |
| 648 | 675 | } |
| 649 | 676 | |
| 650 | 677 | |
| r30641 | r30642 | |
| 830 | 857 | |
| 831 | 858 | // increment the frame number counter |
| 832 | 859 | m_frame_number++; |
| 833 | | |
| 834 | | reset_partial_updates(); |
| 835 | 860 | } |
| 836 | 861 | |
| 837 | 862 | |