diff options
author | 2011-02-03 07:52:45 +0000 | |
---|---|---|
committer | 2011-02-03 07:52:45 +0000 | |
commit | 1e88333178b63ee0d5b914e181b19b3b161f807b (patch) | |
tree | ff1d59069ab151d3ea122c8a26931305157f9d17 /src/emu/screen.c | |
parent | 78005b8ffeaf34d10565466d794debf7f5d2ff73 (diff) |
Converted attotime to a class, with proper operators. Removed old
global functions which are now superceded by the operators and
methods on the class. [Aaron Giles]
Required mappings are:
attotime_make(a,b) => attotime(a,b)
attotime_to_double(t) => t.as_double()
double_to_attotime(d) => attotime::from_double(d)
attotime_to_attoseconds(t) => t.as_attoseconds()
attotime_to_ticks(t,f) => t.as_ticks(f)
ticks_to_attotime(t,f) => attotime::from_ticks(t,f)
attotime_add(a,b) => a + b
attotime_add_attoseconds(a,b) => a + attotime(0, b)
attotime_sub(a,b) => a - b
attotime_sub_attoseconds(a,b) => a - attotime(0, b)
attotime_compare(a,b) == 0 => a == b
attotime_compare(a,b) != 0 => a != b
attotime_compare(a,b) < 0 => a < b
attotime_compare(a,b) <= 0 => a <= b
attotime_compare(a,b) > 0 => a > b
attotime_compare(a,b) >= 0 => a >= b
attotime_mul(a,f) => a * f
attotime_div(a,f) => a / f
attotime_min(a,b) => min(a,b)
attotime_max(a,b) => max(a,b)
attotime_is_never(t) => t.is_never()
attotime_string(t,p) => t.as_string(p)
In addition, some existing #defines still exist but will go away:
attotime_zero => attotime::zero
attotime_never => attotime::never
ATTOTIME_IN_SEC(s) => attotime::from_seconds(s)
ATTOTIME_IN_MSEC(m) => attotime::from_msec(m)
ATTOTIME_IN_USEC(u) => attotime::from_usec(u)
ATTOTIME_IN_NSEC(n) => attotime::from_nsec(n)
ATTOTIME_IN_HZ(h) => attotime::from_hz(h)
Diffstat (limited to 'src/emu/screen.c')
-rw-r--r-- | src/emu/screen.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/emu/screen.c b/src/emu/screen.c index 6ff3088f95e..d61fe083acf 100644 --- a/src/emu/screen.c +++ b/src/emu/screen.c @@ -59,7 +59,7 @@ const device_type SCREEN = screen_device_config::static_alloc_device_config; -const attotime screen_device::DEFAULT_FRAME_PERIOD = STATIC_ATTOTIME_IN_HZ(DEFAULT_FRAME_RATE); +const attotime screen_device::DEFAULT_FRAME_PERIOD(attotime::from_hz(DEFAULT_FRAME_RATE)); @@ -355,8 +355,8 @@ void screen_device::device_start() configure(m_config.m_width, m_config.m_height, m_config.m_visarea, m_config.m_refresh); // reset VBLANK timing - m_vblank_start_time = attotime_zero; - m_vblank_end_time = attotime_make(0, m_vblank_period); + m_vblank_start_time = attotime::zero; + m_vblank_end_time = attotime(0, m_vblank_period); // start the timer to generate per-scanline updates if ((machine->config->m_video_attributes & VIDEO_UPDATE_SCANLINE) != 0) @@ -468,8 +468,8 @@ void screen_device::reset_origin(int beamy, int beamx) { // compute the effective VBLANK start/end times attotime curtime = timer_get_time(machine); - m_vblank_end_time = attotime_sub_attoseconds(curtime, beamy * m_scantime + beamx * m_pixeltime); - m_vblank_start_time = attotime_sub_attoseconds(m_vblank_end_time, m_vblank_period); + m_vblank_end_time = curtime - attotime(0, beamy * m_scantime + beamx * m_pixeltime); + m_vblank_start_time = m_vblank_end_time - attotime(0, m_vblank_period); // if we are resetting relative to (0,0) == VBLANK end, call the // scanline 0 timer by hand now; otherwise, adjust it for the future @@ -667,7 +667,7 @@ void screen_device::update_now() int screen_device::vpos() const { - attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(machine), m_vblank_start_time)); + attoseconds_t delta = (timer_get_time(machine) - m_vblank_start_time).as_attoseconds(); int vpos; // round to the nearest pixel @@ -688,7 +688,7 @@ int screen_device::vpos() const int screen_device::hpos() const { - attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(machine), m_vblank_start_time)); + attoseconds_t delta = (timer_get_time(machine) - m_vblank_start_time).as_attoseconds(); // round to the nearest pixel delta += m_pixeltime / 2; @@ -724,14 +724,14 @@ attotime screen_device::time_until_pos(int vpos, int hpos) const attoseconds_t targetdelta = (attoseconds_t)vpos * m_scantime + (attoseconds_t)hpos * m_pixeltime; // if we're past that time (within 1/2 of a pixel), head to the next frame - attoseconds_t curdelta = attotime_to_attoseconds(attotime_sub(timer_get_time(machine), m_vblank_start_time)); + attoseconds_t curdelta = (timer_get_time(machine) - m_vblank_start_time).as_attoseconds(); if (targetdelta <= curdelta + m_pixeltime / 2) targetdelta += m_frame_period; while (targetdelta <= curdelta) targetdelta += m_frame_period; // return the difference - return attotime_make(0, targetdelta - curdelta); + return attotime(0, targetdelta - curdelta); } @@ -747,8 +747,8 @@ attotime screen_device::time_until_vblank_end() const // if we are in the VBLANK region, compute the time until the end of the current VBLANK period attotime target_time = m_vblank_end_time; if (!vblank()) - target_time = attotime_add_attoseconds(target_time, m_frame_period); - return attotime_sub(target_time, timer_get_time(machine)); + target_time += attotime(0, m_frame_period); + return target_time - timer_get_time(machine); } @@ -788,7 +788,7 @@ void screen_device::vblank_begin_callback() { // reset the starting VBLANK time m_vblank_start_time = timer_get_time(machine); - m_vblank_end_time = attotime_add_attoseconds(m_vblank_start_time, m_vblank_period); + m_vblank_end_time = m_vblank_start_time + attotime(0, m_vblank_period); // call the screen specific callbacks for (callback_item *item = m_callback_list; item != NULL; item = item->m_next) |