本文整理汇总了C++中osd_ticks函数的典型用法代码示例。如果您正苦于以下问题:C++ osd_ticks函数的具体用法?C++ osd_ticks怎么用?C++ osd_ticks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osd_ticks函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: spin_while
static void spin_while(const volatile _AtomType * volatile atom, const _MainType val, const osd_ticks_t timeout, const int invert = 0)
{
osd_ticks_t stopspin = osd_ticks() + timeout;
do {
int spin = 10000;
while (--spin)
{
if ((*atom != val) ^ invert)
return;
}
} while (((*atom == val) ^ invert) && osd_ticks() < stopspin);
}
开发者ID:goofwear,项目名称:mame,代码行数:13,代码来源:osdsync.cpp
示例2: spin_while
static void spin_while(const volatile _PtrType * volatile ptr, const _PtrType val, const osd_ticks_t timeout, const int invert = 0)
{
osd_ticks_t stopspin = osd_ticks() + timeout;
do {
int spin = 10000;
while (--spin)
{
if ((*ptr != val) ^ invert)
return;
}
} while (((*ptr == val) ^ invert) && osd_ticks() < stopspin);
}
开发者ID:MisterTea,项目名称:MAMEHub,代码行数:13,代码来源:work_osd.c
示例3: osd_ticks_per_second
osd_ticks_t video_manager::throttle_until_ticks(osd_ticks_t target_ticks)
{
// we're allowed to sleep via the OSD code only if we're configured to do so
// and we're not frameskipping due to autoframeskip, or if we're paused
bool allowed_to_sleep = false;
if (machine().options().sleep() && (!effective_autoframeskip() || effective_frameskip() == 0))
allowed_to_sleep = true;
if (machine().paused())
allowed_to_sleep = true;
// loop until we reach our target
g_profiler.start(PROFILER_IDLE);
osd_ticks_t minimum_sleep = osd_ticks_per_second() / 1000;
osd_ticks_t current_ticks = osd_ticks();
while (current_ticks < target_ticks)
{
// compute how much time to sleep for, taking into account the average oversleep
osd_ticks_t delta = (target_ticks - current_ticks) * 1000 / (1000 + m_average_oversleep);
// see if we can sleep
bool slept = false;
if (allowed_to_sleep && delta >= minimum_sleep)
{
osd_sleep(delta);
slept = true;
}
// read the new value
osd_ticks_t new_ticks = osd_ticks();
// keep some metrics on the sleeping patterns of the OSD layer
if (slept)
{
// if we overslept, keep an average of the amount
osd_ticks_t actual_ticks = new_ticks - current_ticks;
if (actual_ticks > delta)
{
// take 90% of the previous average plus 10% of the new value
osd_ticks_t oversleep_milliticks = 1000 * (actual_ticks - delta) / delta;
m_average_oversleep = (m_average_oversleep * 99 + oversleep_milliticks) / 100;
if (LOG_THROTTLE)
machine().logerror("Slept for %d ticks, got %d ticks, avgover = %d\n", (int)delta, (int)actual_ticks, (int)m_average_oversleep);
}
}
current_ticks = new_ticks;
}
g_profiler.stop();
return current_ticks;
}
开发者ID:kaspal,项目名称:mame,代码行数:51,代码来源:video.cpp
示例4: osd_work_queue_wait
int osd_work_queue_wait(osd_work_queue *queue, osd_ticks_t timeout)
{
// if no threads, no waiting
if (queue->threads == 0)
return TRUE;
// if no items, we're done
if (queue->items == 0)
return TRUE;
// if this is a multi queue, help out rather than doing nothing
if (queue->flags & WORK_QUEUE_FLAG_MULTI)
{
work_thread_info *thread = &queue->thread[queue->threads];
end_timing(thread->waittime);
// process what we can as a worker thread
worker_thread_process(queue, thread);
// if we're a high frequency queue, spin until done
if (queue->flags & WORK_QUEUE_FLAG_HIGH_FREQ && queue->items != 0)
{
osd_ticks_t stopspin = osd_ticks() + timeout;
// spin until we're done
begin_timing(thread->spintime);
do {
int spin = 10000;
while (--spin && queue->items != 0)
osd_yield_processor();
} while (queue->items != 0 && osd_ticks() < stopspin);
end_timing(thread->spintime);
begin_timing(thread->waittime);
return (queue->items == 0);
}
begin_timing(thread->waittime);
}
// reset our done event and double-check the items before waiting
osd_event_reset(queue->doneevent);
atomic_exchange32(&queue->waiting, TRUE);
if (queue->items != 0)
osd_event_wait(queue->doneevent, timeout);
atomic_exchange32(&queue->waiting, FALSE);
// return TRUE if we actually hit 0
return (queue->items == 0);
}
开发者ID:Archlogic,项目名称:libretro-mame,代码行数:51,代码来源:retrowork.c
示例5: render_quad
INLINE void render_quad(sdl_info *sdl, texture_info *texture, render_primitive *prim, int x, int y)
{
SDL_Texture *texture_id;
SDL_Rect target_rect;
target_rect.x = x;
target_rect.y = y;
target_rect.w = round_nearest(prim->bounds.x1 - prim->bounds.x0);
target_rect.h = round_nearest(prim->bounds.y1 - prim->bounds.y0);
if (texture)
{
texture_id = texture->texture_id;
texture->copyinfo->time -= osd_ticks();
#if 0
if ((PRIMFLAG_GET_SCREENTEX(prim->flags)) && video_config.filter)
{
SDL_SetTextureScaleMode(texture->texture_id, DRAW2_SCALEMODE_BEST);
}
else
{
SDL_SetTextureScaleMode(texture->texture_id, DRAW2_SCALEMODE_NEAREST);
}
#endif
SDL_SetTextureBlendMode(texture_id, texture->sdl_blendmode);
set_coloralphamode(texture_id, &prim->color);
SDL_RenderCopy(sdl->sdl_renderer, texture_id, NULL, &target_rect);
texture->copyinfo->time += osd_ticks();
texture->copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->rawwidth * texture->rawheight));
if (sdl->last_blit_pixels)
{
texture->copyinfo->time += (sdl->last_blit_time * (INT64) (texture->rawwidth * texture->rawheight)) / (INT64) sdl->last_blit_pixels;
}
texture->copyinfo->samples++;
texture->copyinfo->perf = ( texture->copyinfo->pixel_count * (osd_ticks_per_second()/1000)) / texture->copyinfo->time;
}
else
{
UINT32 sr = (UINT32)(255.0f * prim->color.r);
UINT32 sg = (UINT32)(255.0f * prim->color.g);
UINT32 sb = (UINT32)(255.0f * prim->color.b);
UINT32 sa = (UINT32)(255.0f * prim->color.a);
SDL_SetRenderDrawBlendMode(sdl->sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
SDL_SetRenderDrawColor(sdl->sdl_renderer, sr, sg, sb, sa);
SDL_RenderFillRect(sdl->sdl_renderer, &target_rect);
}
}
开发者ID:kleopatra999,项目名称:mess-svn,代码行数:50,代码来源:draw13.c
示例6: osd_lock_acquire
void osd_lock_acquire(osd_lock *lock)
{
#if DEBUG_SLOW_LOCKS
osd_ticks_t ticks = osd_ticks();
#endif
// block until we can acquire the lock
EnterCriticalSection(&lock->critsect);
#if DEBUG_SLOW_LOCKS
// log any locks that take more than 1ms
ticks = osd_ticks() - ticks;
if (ticks > osd_ticks_per_second() / 1000) mame_printf_debug("Blocked %d ticks on lock acquire\n", (int)ticks);
#endif
}
开发者ID:cdenix,项目名称:ps3-mame-0125,代码行数:15,代码来源:winsync.c
示例7: texture_compute_hash
texture_info *renderer_sdl2::texture_find(const render_primitive &prim, const quad_setup_data &setup)
{
HashT texhash = texture_compute_hash(prim.texture, prim.flags);
texture_info *texture;
osd_ticks_t now = osd_ticks();
// find a match
for (texture = m_texlist.first(); texture != nullptr; )
if (texture->hash() == texhash &&
texture->matches(prim, setup))
{
/* would we choose another blitter based on performance ? */
if ((texture->m_copyinfo->samples & 0x7f) == 0x7f)
{
if (texture->m_copyinfo != texture->compute_size_type())
return nullptr;
}
texture->m_last_access = now;
return texture;
}
else
{
/* free resources not needed any longer? */
texture_info *expire = texture;
texture = texture->next();
if (now - expire->m_last_access > osd_ticks_per_second())
m_texlist.remove(*expire);
}
// nothing found
return nullptr;
}
开发者ID:bradhugh,项目名称:mame,代码行数:32,代码来源:draw13.cpp
示例8: osd_ticks
osd_ticks_t osd_ticks(void)
{
#ifdef _WIN32
LARGE_INTEGER performance_count;
// if we're suspended, just return that
if (suspend_ticks != 0)
return suspend_ticks;
// if we have a per second count, just go for it
if (ticks_per_second != 0)
{
QueryPerformanceCounter(&performance_count);
return (osd_ticks_t)performance_count.QuadPart - suspend_ticks;
}
// if not, we have to determine it
QueryPerformanceFrequency(&performance_count) && (performance_count.QuadPart != 0);
ticks_per_second = (osd_ticks_t)performance_count.QuadPart;
// call ourselves to get the first value
return osd_ticks();
#else
struct timeval tp;
static osd_ticks_t start_sec = 0;
gettimeofday(&tp, NULL);
if (start_sec==0)
start_sec = tp.tv_sec;
return (tp.tv_sec - start_sec) * (osd_ticks_t) 1000000 + tp.tv_usec;
#endif
}
开发者ID:Archlogic,项目名称:libretro-mame,代码行数:32,代码来源:retroos.c
示例9: osd_sleep
void osd_sleep(osd_ticks_t duration)
{
DWORD msec;
// make sure we've computed ticks_per_second
if (ticks_per_second == 0)
(void)osd_ticks();
// convert to milliseconds, rounding down
msec = (DWORD)(duration * 1000 / ticks_per_second);
// only sleep if at least 2 full milliseconds
if (msec >= 2)
{
HANDLE current_thread = GetCurrentThread();
int old_priority = GetThreadPriority(current_thread);
// take a couple of msecs off the top for good measure
msec -= 2;
// bump our thread priority super high so that we get
// priority when we need it
SetThreadPriority(current_thread, THREAD_PRIORITY_TIME_CRITICAL);
Sleep(msec);
SetThreadPriority(current_thread, old_priority);
}
}
开发者ID:gbraad,项目名称:mame,代码行数:27,代码来源:osdlib_win32.c
示例10: osd_ticks
osd_ticks_t osd_ticks(void)
{
LARGE_INTEGER performance_count;
// if we're suspended, just return that
if (suspend_ticks != 0)
return suspend_ticks;
// if we have a per second count, just go for it
if (ticks_per_second != 0)
{
// QueryPerformanceCounter if we can
if (using_qpc)
{
QueryPerformanceCounter(&performance_count);
return (osd_ticks_t)performance_count.QuadPart - suspend_ticks;
}
// otherwise, fall back to timeGetTime
else
return (osd_ticks_t)timeGetTime() - suspend_ticks;
}
// if not, we have to determine it
using_qpc = QueryPerformanceFrequency(&performance_count) && (performance_count.QuadPart != 0);
if (using_qpc)
ticks_per_second = (osd_ticks_t)performance_count.QuadPart;
else
ticks_per_second = 1000;
// call ourselves to get the first value
return osd_ticks();
}
开发者ID:gbraad,项目名称:mame,代码行数:33,代码来源:osdlib_win32.c
示例11: osd_work_queue_wait
int osd_work_queue_wait(osd_work_queue *queue, osd_ticks_t timeout)
{
// if no threads, no waiting
if (queue->threads == 0)
return TRUE;
// if no items, we're done
if (queue->items == 0)
return TRUE;
// if this is a multi queue, help out rather than doing nothing
if (queue->flags & WORK_QUEUE_FLAG_MULTI)
{
work_thread_info *thread = &queue->thread[queue->threads];
osd_ticks_t stopspin = osd_ticks() + timeout;
end_timing(thread->waittime);
// process what we can as a worker thread
worker_thread_process(queue, thread);
// if we're a high frequency queue, spin until done
if (queue->flags & WORK_QUEUE_FLAG_HIGH_FREQ)
{
// spin until we're done
begin_timing(thread->spintime);
while (queue->items != 0 && osd_ticks() < stopspin)
YieldProcessor();
end_timing(thread->spintime);
begin_timing(thread->waittime);
return (queue->items == 0);
}
begin_timing(thread->waittime);
}
// reset our done event and double-check the items before waiting
ResetEvent(queue->doneevent);
interlocked_exchange32(&queue->waiting, TRUE);
if (queue->items != 0)
WaitForSingleObject(queue->doneevent, timeout * 1000 / osd_ticks_per_second());
interlocked_exchange32(&queue->waiting, FALSE);
// return TRUE if we actually hit 0
return (queue->items == 0);
}
开发者ID:cdenix,项目名称:ps3-mame-0125,代码行数:46,代码来源:winwork.c
示例12: mtlog_add
void mtlog_add(const char *event)
{
int index = InterlockedIncrement((LONG *) &mtlogindex) - 1;
if (index < ARRAY_LENGTH(mtlog))
{
mtlog[index].timestamp = osd_ticks();
mtlog[index].event = event;
}
}
开发者ID:broftkd,项目名称:mess-cvs,代码行数:9,代码来源:window.c
示例13: osd_ticks_per_second
osd_ticks_t osd_ticks_per_second(void)
{
#ifdef WIN32
if (ticks_per_second == 0)
osd_ticks();
return ticks_per_second;
#else
return (osd_ticks_t) 1000000;
#endif
}
开发者ID:Archlogic,项目名称:libretro-mame,代码行数:10,代码来源:retroos.c
示例14: run
static void run(core_options &opts)
{
netlist_tool_t nt;
osd_ticks_t t = osd_ticks();
nt.init();
nt.m_logs = opts.value("l");
nt.read_netlist(filetobuf(opts.value("f")));
double ttr = opts.float_value("t");
printf("startup time ==> %5.3f\n", (double) (osd_ticks() - t) / (double) osd_ticks_per_second() );
printf("runnning ...\n");
t = osd_ticks();
nt.process_queue(netlist_time::from_double(ttr));
double emutime = (double) (osd_ticks() - t) / (double) osd_ticks_per_second();
printf("%f seconds emulation took %f real time ==> %5.2f%%\n", ttr, emutime, ttr/emutime*100.0);
}
开发者ID:ef1105,项目名称:mameplus,代码行数:19,代码来源:nltool.c
示例15: assert
bool ui_input_manager::pressed_repeat(int code, int speed)
{
bool pressed;
g_profiler.start(PROFILER_INPUT);
/* get the status of this key (assumed to be only in the defaults) */
assert(code >= IPT_UI_CONFIGURE && code <= IPT_OSD_16);
pressed = (m_seqpressed[code] == SEQ_PRESSED_TRUE);
/* if down, handle it specially */
if (pressed)
{
osd_ticks_t tps = osd_ticks_per_second();
/* if this is the first press, set a 3x delay and leave pressed = 1 */
if (m_next_repeat[code] == 0)
m_next_repeat[code] = osd_ticks() + 3 * speed * tps / 60;
/* if this is an autorepeat case, set a 1x delay and leave pressed = 1 */
else if (speed > 0 && (osd_ticks() + tps - m_next_repeat[code]) >= tps)
{
// In the autorepeatcase, we need to double check the key is still pressed
// as there can be a delay between the key polling and our processing of the event
m_seqpressed[code] = machine().ioport().type_pressed(ioport_type(code));
pressed = (m_seqpressed[code] == SEQ_PRESSED_TRUE);
if (pressed)
m_next_repeat[code] += 1 * speed * tps / 60;
}
/* otherwise, reset pressed = 0 */
else
pressed = false;
}
/* if we're not pressed, reset the memory field */
else
m_next_repeat[code] = 0;
g_profiler.stop();
return pressed;
}
开发者ID:Robbbert,项目名称:store1,代码行数:43,代码来源:uiinput.cpp
示例16: measure_fps
static void measure_fps(sdl_window_info *window, UINT32 dc, int update)
{
const unsigned long frames_skip4fps = 100;
static int64_t lastTime=0, sumdt=0, startTime=0;
static unsigned long frames = 0;
int64_t currentTime, t0;
double dt;
double tps;
osd_ticks_t tps_t;
tps_t = osd_ticks_per_second();
tps = (double) tps_t;
t0 = osd_ticks();
window->draw(window, dc, update);
frames++;
currentTime = osd_ticks();
if(startTime==0||frames==frames_skip4fps)
startTime=currentTime;
if( frames>=frames_skip4fps )
sumdt+=currentTime-t0;
if( (currentTime-lastTime)>1L*osd_ticks_per_second() && frames>frames_skip4fps )
{
dt = (double) (currentTime-startTime) / tps; // in decimale sec.
mame_printf_info("%6.2lfs, %4lu F, "
"avrg game: %5.2lf FPS %.2lf ms/f, "
"avrg video: %5.2lf FPS %.2lf ms/f, "
"last video: %5.2lf FPS %.2lf ms/f\n",
dt, frames-frames_skip4fps,
(double)(frames-frames_skip4fps)/dt, // avrg game fps
( (currentTime-startTime) / ((frames-frames_skip4fps)) ) * 1000.0 / osd_ticks_per_second(),
(double)(frames-frames_skip4fps)/((double)(sumdt) / tps), // avrg vid fps
( sumdt / ((frames-frames_skip4fps)) ) * 1000.0 / tps,
1.0/((currentTime-t0) / osd_ticks_per_second()), // this vid fps
(currentTime-t0) * 1000.0 / tps
);
lastTime = currentTime;
}
}
开发者ID:clobber,项目名称:UME,代码行数:41,代码来源:window.c
示例17: winwindow_process_events_periodic
void winwindow_process_events_periodic(void)
{
osd_ticks_t curr;
assert(GetCurrentThreadId() == main_threadid);
// update once every 1/8th of a second
curr = osd_ticks();
if (curr - last_event_check < osd_ticks_per_second() / 8)
return;
winwindow_process_events(TRUE);
}
开发者ID:broftkd,项目名称:mess-cvs,代码行数:12,代码来源:window.c
示例18: run
static void run(tool_options_t &opts)
{
netlist_tool_t nt;
osd_ticks_t t = osd_ticks();
nt.init();
nt.m_logs = opts.opt_logs();
nt.m_verbose = opts.opt_verb();
nt.read_netlist(filetobuf(opts.opt_file()), opts.opt_name());
double ttr = opts.opt_ttr();
printf("startup time ==> %5.3f\n", (double) (osd_ticks() - t) / (double) osd_ticks_per_second() );
printf("runnning ...\n");
t = osd_ticks();
nt.process_queue(netlist::netlist_time::from_double(ttr));
nt.stop();
double emutime = (double) (osd_ticks() - t) / (double) osd_ticks_per_second();
printf("%f seconds emulation took %f real time ==> %5.2f%%\n", ttr, emutime, ttr/emutime*100.0);
}
开发者ID:dinkc64,项目名称:mame,代码行数:21,代码来源:nltool.c
示例19: texture_set_data
static void texture_set_data(sdl_info *sdl, texture_info *texture, const render_texinfo *texsource, UINT32 flags)
{
texture->copyinfo->time -= osd_ticks();
if (texture->sdl_access == SDL_TEXTUREACCESS_STATIC)
{
if ( texture->copyinfo->func )
{
texture->pitch = texture->setup.rotwidth * texture->copyinfo->dst_bpp;
texture->copyinfo->func(texture, texsource);
}
else
{
texture->pixels = texsource->base;
texture->pitch = texture->texinfo.rowpixels * texture->copyinfo->dst_bpp;
}
SDL_UpdateTexture(texture->texture_id, NULL, texture->pixels, texture->pitch);
}
else
{
SDL_LockTexture(texture->texture_id, NULL, (void **) &texture->pixels, &texture->pitch);
if ( texture->copyinfo->func )
texture->copyinfo->func(texture, texsource);
else
{
UINT8 *src = (UINT8 *) texsource->base;
UINT8 *dst = (UINT8 *) texture->pixels;
int spitch = texsource->rowpixels * texture->copyinfo->dst_bpp;
int num = texsource->width * texture->copyinfo->dst_bpp;
int h = texsource->height;
while (h--) {
memcpy(dst, src, num);
src += spitch;
dst += texture->pitch;
}
}
SDL_UnlockTexture(texture->texture_id);
}
texture->copyinfo->time += osd_ticks();
}
开发者ID:kleopatra999,项目名称:mess-svn,代码行数:39,代码来源:draw13.c
示例20: osd_ticks
void texture_info::set_data(const render_texinfo &texsource, const UINT32 flags)
{
m_copyinfo->time -= osd_ticks();
if (m_sdl_access == SDL_TEXTUREACCESS_STATIC)
{
if ( m_copyinfo->blitter->m_is_passthrough )
{
m_pixels = texsource.base;
m_pitch = m_texinfo.rowpixels * m_copyinfo->blitter->m_dest_bpp;
}
else
{
m_pitch = m_setup.rotwidth * m_copyinfo->blitter->m_dest_bpp;
m_copyinfo->blitter->texop(this, &texsource);
}
SDL_UpdateTexture(m_texture_id, nullptr, m_pixels, m_pitch);
}
else
{
SDL_LockTexture(m_texture_id, nullptr, (void **) &m_pixels, &m_pitch);
if ( m_copyinfo->blitter->m_is_passthrough )
{
UINT8 *src = (UINT8 *) texsource.base;
UINT8 *dst = (UINT8 *) m_pixels;
int spitch = texsource.rowpixels * m_copyinfo->blitter->m_dest_bpp;
int num = texsource.width * m_copyinfo->blitter->m_dest_bpp;
int h = texsource.height;
while (h--) {
memcpy(dst, src, num);
src += spitch;
dst += m_pitch;
}
}
else
m_copyinfo->blitter->texop(this, &texsource);
SDL_UnlockTexture(m_texture_id);
}
m_copyinfo->time += osd_ticks();
}
开发者ID:bradhugh,项目名称:mame,代码行数:39,代码来源:draw13.cpp
注:本文中的osd_ticks函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论