diff options
author | 2015-01-28 09:20:10 +0100 | |
---|---|---|
committer | 2015-01-28 09:20:10 +0100 | |
commit | 26e7a17b6326aa5a75a6276e52cf84a94c16d7a0 (patch) | |
tree | bab4468226c59d590688e0ece892f5bfbca58736 /src/osd/modules/lib | |
parent | 13b862c4fae88f0f819c2c4416d49249e4de45b9 (diff) |
Cleanups and version bumpmame0158
Diffstat (limited to 'src/osd/modules/lib')
-rw-r--r-- | src/osd/modules/lib/osdlib_macosx.c | 160 | ||||
-rw-r--r-- | src/osd/modules/lib/osdlib_os2.c | 199 | ||||
-rw-r--r-- | src/osd/modules/lib/osdlib_unix.c | 80 | ||||
-rw-r--r-- | src/osd/modules/lib/osdlib_win32.c | 268 | ||||
-rw-r--r-- | src/osd/modules/lib/osdobj_common.c | 279 | ||||
-rw-r--r-- | src/osd/modules/lib/osdobj_common.h | 172 |
6 files changed, 577 insertions, 581 deletions
diff --git a/src/osd/modules/lib/osdlib_macosx.c b/src/osd/modules/lib/osdlib_macosx.c index 5d6233bce25..088cbd969df 100644 --- a/src/osd/modules/lib/osdlib_macosx.c +++ b/src/osd/modules/lib/osdlib_macosx.c @@ -34,7 +34,7 @@ const char *osd_getenv(const char *name) { - return getenv(name); + return getenv(name); } //============================================================ @@ -43,7 +43,7 @@ const char *osd_getenv(const char *name) int osd_setenv(const char *name, const char *value, int overwrite) { - return setenv(name, value, overwrite); + return setenv(name, value, overwrite); } //============================================================ @@ -52,7 +52,7 @@ int osd_setenv(const char *name, const char *value, int overwrite) void osd_process_kill(void) { - kill(getpid(), SIGKILL); + kill(getpid(), SIGKILL); } //============================================================ @@ -61,22 +61,22 @@ void osd_process_kill(void) int osd_get_num_processors(void) { - int processors = 1; - - struct host_basic_info host_basic_info; - unsigned int count; - kern_return_t r; - mach_port_t my_mach_host_self; - - count = HOST_BASIC_INFO_COUNT; - my_mach_host_self = mach_host_self(); - if ( ( r = host_info(my_mach_host_self, HOST_BASIC_INFO, (host_info_t)(&host_basic_info), &count)) == KERN_SUCCESS ) - { - processors = host_basic_info.avail_cpus; - } - mach_port_deallocate(mach_task_self(), my_mach_host_self); - - return processors; + int processors = 1; + + struct host_basic_info host_basic_info; + unsigned int count; + kern_return_t r; + mach_port_t my_mach_host_self; + + count = HOST_BASIC_INFO_COUNT; + my_mach_host_self = mach_host_self(); + if ( ( r = host_info(my_mach_host_self, HOST_BASIC_INFO, (host_info_t)(&host_basic_info), &count)) == KERN_SUCCESS ) + { + processors = host_basic_info.avail_cpus; + } + mach_port_deallocate(mach_task_self(), my_mach_host_self); + + return processors; } //============================================================ @@ -86,7 +86,7 @@ int osd_get_num_processors(void) void *osd_malloc(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -100,7 +100,7 @@ void *osd_malloc(size_t size) void *osd_malloc_array(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -114,7 +114,7 @@ void *osd_malloc_array(size_t size) void osd_free(void *ptr) { #ifndef MALLOC_DEBUG - free(ptr); + free(ptr); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -131,9 +131,9 @@ void osd_free(void *ptr) void *osd_alloc_executable(size_t size) { #if defined(SDLMAME_BSD) || defined(SDLMAME_MACOSX) - return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); + return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); #elif defined(SDLMAME_UNIX) - return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0); + return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0); #endif } @@ -146,9 +146,9 @@ void *osd_alloc_executable(size_t size) void osd_free_executable(void *ptr, size_t size) { #ifdef SDLMAME_SOLARIS - munmap((char *)ptr, size); + munmap((char *)ptr, size); #else - munmap(ptr, size); + munmap(ptr, size); #endif } @@ -158,13 +158,13 @@ void osd_free_executable(void *ptr, size_t size) void osd_break_into_debugger(const char *message) { - #ifdef MAME_DEBUG - printf("MAME exception: %s\n", message); - printf("Attempting to fall into debugger\n"); - kill(getpid(), SIGTRAP); - #else - printf("Ignoring MAME exception: %s\n", message); - #endif + #ifdef MAME_DEBUG + printf("MAME exception: %s\n", message); + printf("Attempting to fall into debugger\n"); + kill(getpid(), SIGTRAP); + #else + printf("Ignoring MAME exception: %s\n", message); + #endif } @@ -191,36 +191,36 @@ static osd_ticks_t ticks_per_second; static osd_ticks_t init_cycle_counter(void) { - osd_ticks_t start, end; - osd_ticks_t a, b; + osd_ticks_t start, end; + osd_ticks_t a, b; - cycle_counter = mach_cycle_counter; - ticks_counter = mach_cycle_counter; + cycle_counter = mach_cycle_counter; + ticks_counter = mach_cycle_counter; - // wait for an edge on the timeGetTime call - a = SDL_GetTicks(); - do - { - b = SDL_GetTicks(); - } while (a == b); + // wait for an edge on the timeGetTime call + a = SDL_GetTicks(); + do + { + b = SDL_GetTicks(); + } while (a == b); - // get the starting cycle count - start = (*cycle_counter)(); + // get the starting cycle count + start = (*cycle_counter)(); - // now wait for 1/4 second total - do - { - a = SDL_GetTicks(); - } while (a - b < 250); + // now wait for 1/4 second total + do + { + a = SDL_GetTicks(); + } while (a - b < 250); - // get the ending cycle count - end = (*cycle_counter)(); + // get the ending cycle count + end = (*cycle_counter)(); - // compute ticks_per_sec - ticks_per_second = (end - start) * 4; + // compute ticks_per_sec + ticks_per_second = (end - start) * 4; - // return the current cycle count - return (*cycle_counter)(); + // return the current cycle count + return (*cycle_counter)(); } //============================================================ @@ -232,7 +232,7 @@ static osd_ticks_t init_cycle_counter(void) //============================================================ static osd_ticks_t mach_cycle_counter(void) { - return mach_absolute_time(); + return mach_absolute_time(); } //============================================================ @@ -241,7 +241,7 @@ static osd_ticks_t mach_cycle_counter(void) osd_ticks_t osd_ticks(void) { - return (*cycle_counter)(); + return (*cycle_counter)(); } @@ -251,12 +251,12 @@ osd_ticks_t osd_ticks(void) osd_ticks_t osd_ticks_per_second(void) { - if (ticks_per_second == 0) - { - // if we haven't computed the value yet, there's no time like the present - init_cycle_counter(); - } - return ticks_per_second; + if (ticks_per_second == 0) + { + // if we haven't computed the value yet, there's no time like the present + init_cycle_counter(); + } + return ticks_per_second; } @@ -267,20 +267,20 @@ osd_ticks_t osd_ticks_per_second(void) void osd_sleep(osd_ticks_t duration) { - UINT32 msec; - - // make sure we've computed ticks_per_second - if (ticks_per_second == 0) - (void)osd_ticks(); - - // convert to milliseconds, rounding down - msec = (UINT32)(duration * 1000 / ticks_per_second); - - // only sleep if at least 2 full milliseconds - if (msec >= 2) - { - // take a couple of msecs off the top for good measure - msec -= 2; - usleep(msec*1000); - } + UINT32 msec; + + // make sure we've computed ticks_per_second + if (ticks_per_second == 0) + (void)osd_ticks(); + + // convert to milliseconds, rounding down + msec = (UINT32)(duration * 1000 / ticks_per_second); + + // only sleep if at least 2 full milliseconds + if (msec >= 2) + { + // take a couple of msecs off the top for good measure + msec -= 2; + usleep(msec*1000); + } } diff --git a/src/osd/modules/lib/osdlib_os2.c b/src/osd/modules/lib/osdlib_os2.c index d852ea5ce93..9e1ab8fd52d 100644 --- a/src/osd/modules/lib/osdlib_os2.c +++ b/src/osd/modules/lib/osdlib_os2.c @@ -31,7 +31,7 @@ const char *osd_getenv(const char *name) { - return getenv(name); + return getenv(name); } //============================================================ @@ -40,7 +40,7 @@ const char *osd_getenv(const char *name) int osd_setenv(const char *name, const char *value, int overwrite) { - return setenv(name, value, overwrite); + return setenv(name, value, overwrite); } //============================================================ @@ -49,7 +49,7 @@ int osd_setenv(const char *name, const char *value, int overwrite) void osd_process_kill(void) { - fprintf(stderr,"osd_process_kill missing in OS/2 build\n"); + fprintf(stderr,"osd_process_kill missing in OS/2 build\n"); } //============================================================ @@ -58,11 +58,11 @@ void osd_process_kill(void) int osd_get_num_processors(void) { - ULONG numprocs = 1; + ULONG numprocs = 1; - DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &numprocs, sizeof(numprocs)); + DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &numprocs, sizeof(numprocs)); - return numprocs; + return numprocs; } //============================================================ @@ -72,7 +72,7 @@ int osd_get_num_processors(void) void *osd_malloc(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -86,7 +86,7 @@ void *osd_malloc(size_t size) void *osd_malloc_array(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -100,7 +100,7 @@ void *osd_malloc_array(size_t size) void osd_free(void *ptr) { #ifndef MALLOC_DEBUG - free(ptr); + free(ptr); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -116,10 +116,10 @@ void osd_free(void *ptr) void *osd_alloc_executable(size_t size) { - void *p; + void *p; - DosAllocMem( &p, size, fALLOC ); - return p; + DosAllocMem( &p, size, fALLOC ); + return p; } //============================================================ @@ -130,7 +130,7 @@ void *osd_alloc_executable(size_t size) void osd_free_executable(void *ptr, size_t size) { - DosFreeMem( ptr ); + DosFreeMem( ptr ); } //============================================================ @@ -139,7 +139,7 @@ void osd_free_executable(void *ptr, size_t size) void osd_break_into_debugger(const char *message) { - printf("Ignoring MAME exception: %s\n", message); + printf("Ignoring MAME exception: %s\n", message); } //============================================================ @@ -167,65 +167,65 @@ static osd_ticks_t ticks_per_second; static osd_ticks_t init_cycle_counter(void) { - osd_ticks_t start, end; - osd_ticks_t a, b; - - ULONG frequency; - PTIB ptib; - ULONG ulClass; - ULONG ulDelta; - - DosGetInfoBlocks( &ptib, NULL ); - ulClass = HIBYTE( ptib->tib_ptib2->tib2_ulpri ); - ulDelta = LOBYTE( ptib->tib_ptib2->tib2_ulpri ); - - if ( DosTmrQueryFreq( &frequency ) == 0 ) - { - // use performance counter if available as it is constant - cycle_counter = performance_cycle_counter; - ticks_counter = performance_cycle_counter; - - ticks_per_second = frequency; - - // return the current cycle count - return (*cycle_counter)(); - } - else - { - fprintf(stderr, "No Timer available!\n"); - exit(-1); - } - - // temporarily set our priority higher - DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, 0 ); - - // wait for an edge on the timeGetTime call - a = SDL_GetTicks(); - do - { - b = SDL_GetTicks(); - } while (a == b); - - // get the starting cycle count - start = (*cycle_counter)(); - - // now wait for 1/4 second total - do - { - a = SDL_GetTicks(); - } while (a - b < 250); - - // get the ending cycle count - end = (*cycle_counter)(); - - // compute ticks_per_sec - ticks_per_second = (end - start) * 4; - - // restore our priority - DosSetPriority( PRTYS_THREAD, ulClass, ulDelta, 0 ); - - // return the current cycle count - return (*cycle_counter)(); + osd_ticks_t start, end; + osd_ticks_t a, b; + + ULONG frequency; + PTIB ptib; + ULONG ulClass; + ULONG ulDelta; + + DosGetInfoBlocks( &ptib, NULL ); + ulClass = HIBYTE( ptib->tib_ptib2->tib2_ulpri ); + ulDelta = LOBYTE( ptib->tib_ptib2->tib2_ulpri ); + + if ( DosTmrQueryFreq( &frequency ) == 0 ) + { + // use performance counter if available as it is constant + cycle_counter = performance_cycle_counter; + ticks_counter = performance_cycle_counter; + + ticks_per_second = frequency; + + // return the current cycle count + return (*cycle_counter)(); + } + else + { + fprintf(stderr, "No Timer available!\n"); + exit(-1); + } + + // temporarily set our priority higher + DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, 0 ); + + // wait for an edge on the timeGetTime call + a = SDL_GetTicks(); + do + { + b = SDL_GetTicks(); + } while (a == b); + + // get the starting cycle count + start = (*cycle_counter)(); + + // now wait for 1/4 second total + do + { + a = SDL_GetTicks(); + } while (a - b < 250); + + // get the ending cycle count + end = (*cycle_counter)(); + + // compute ticks_per_sec + ticks_per_second = (end - start) * 4; + + // restore our priority + DosSetPriority( PRTYS_THREAD, ulClass, ulDelta, 0 ); + + // return the current cycle count + return (*cycle_counter)(); } //============================================================ @@ -234,10 +234,10 @@ static osd_ticks_t init_cycle_counter(void) static osd_ticks_t performance_cycle_counter(void) { - QWORD qwTime; + QWORD qwTime; - DosTmrQueryTime( &qwTime ); - return (osd_ticks_t)qwTime.ulLo; + DosTmrQueryTime( &qwTime ); + return (osd_ticks_t)qwTime.ulLo; } //============================================================ @@ -246,7 +246,7 @@ static osd_ticks_t performance_cycle_counter(void) osd_ticks_t osd_ticks(void) { - return (*cycle_counter)(); + return (*cycle_counter)(); } @@ -256,12 +256,12 @@ osd_ticks_t osd_ticks(void) osd_ticks_t osd_ticks_per_second(void) { - if (ticks_per_second == 0) - { - // if we haven't computed the value yet, there's no time like the present - init_cycle_counter(); - } - return ticks_per_second; + if (ticks_per_second == 0) + { + // if we haven't computed the value yet, there's no time like the present + init_cycle_counter(); + } + return ticks_per_second; } @@ -271,21 +271,20 @@ osd_ticks_t osd_ticks_per_second(void) void osd_sleep(osd_ticks_t duration) { - UINT32 msec; - - // make sure we've computed ticks_per_second - if (ticks_per_second == 0) - (void)osd_ticks(); - - // convert to milliseconds, rounding down - msec = (UINT32)(duration * 1000 / ticks_per_second); - - // only sleep if at least 2 full milliseconds - if (msec >= 2) - { - // take a couple of msecs off the top for good measure - msec -= 2; - usleep(msec*1000); - } + UINT32 msec; + + // make sure we've computed ticks_per_second + if (ticks_per_second == 0) + (void)osd_ticks(); + + // convert to milliseconds, rounding down + msec = (UINT32)(duration * 1000 / ticks_per_second); + + // only sleep if at least 2 full milliseconds + if (msec >= 2) + { + // take a couple of msecs off the top for good measure + msec -= 2; + usleep(msec*1000); + } } - diff --git a/src/osd/modules/lib/osdlib_unix.c b/src/osd/modules/lib/osdlib_unix.c index 39eed83b918..7fe3c37988d 100644 --- a/src/osd/modules/lib/osdlib_unix.c +++ b/src/osd/modules/lib/osdlib_unix.c @@ -30,7 +30,7 @@ const char *osd_getenv(const char *name) { - return getenv(name); + return getenv(name); } //============================================================ @@ -39,7 +39,7 @@ const char *osd_getenv(const char *name) int osd_setenv(const char *name, const char *value, int overwrite) { - return setenv(name, value, overwrite); + return setenv(name, value, overwrite); } //============================================================ @@ -48,7 +48,7 @@ int osd_setenv(const char *name, const char *value, int overwrite) void osd_process_kill(void) { - kill(getpid(), SIGKILL); + kill(getpid(), SIGKILL); } //============================================================ @@ -57,12 +57,12 @@ void osd_process_kill(void) int osd_get_num_processors(void) { - int processors = 1; + int processors = 1; #if defined(_SC_NPROCESSORS_ONLN) - processors = sysconf(_SC_NPROCESSORS_ONLN); + processors = sysconf(_SC_NPROCESSORS_ONLN); #endif - return processors; + return processors; } //============================================================ @@ -72,7 +72,7 @@ int osd_get_num_processors(void) void *osd_malloc(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -86,7 +86,7 @@ void *osd_malloc(size_t size) void *osd_malloc_array(size_t size) { #ifndef MALLOC_DEBUG - return malloc(size); + return malloc(size); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -100,7 +100,7 @@ void *osd_malloc_array(size_t size) void osd_free(void *ptr) { #ifndef MALLOC_DEBUG - free(ptr); + free(ptr); #else #error "MALLOC_DEBUG not yet supported" #endif @@ -116,9 +116,9 @@ void osd_free(void *ptr) void *osd_alloc_executable(size_t size) { #if defined(SDLMAME_BSD) || defined(SDLMAME_MACOSX) - return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); + return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); #elif defined(SDLMAME_UNIX) - return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0); + return (void *)mmap(0, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, 0, 0); #endif } @@ -131,9 +131,9 @@ void *osd_alloc_executable(size_t size) void osd_free_executable(void *ptr, size_t size) { #ifdef SDLMAME_SOLARIS - munmap((char *)ptr, size); + munmap((char *)ptr, size); #else - munmap(ptr, size); + munmap(ptr, size); #endif } @@ -143,13 +143,13 @@ void osd_free_executable(void *ptr, size_t size) void osd_break_into_debugger(const char *message) { - #ifdef MAME_DEBUG - printf("MAME exception: %s\n", message); - printf("Attempting to fall into debugger\n"); - kill(getpid(), SIGTRAP); - #else - printf("Ignoring MAME exception: %s\n", message); - #endif + #ifdef MAME_DEBUG + printf("MAME exception: %s\n", message); + printf("Attempting to fall into debugger\n"); + kill(getpid(), SIGTRAP); + #else + printf("Ignoring MAME exception: %s\n", message); + #endif } @@ -160,15 +160,15 @@ void osd_break_into_debugger(const char *message) osd_ticks_t osd_ticks(void) { #ifdef SDLMAME_EMSCRIPTEN - return (osd_ticks_t)(emscripten_get_now() * 1000.0); + return (osd_ticks_t)(emscripten_get_now() * 1000.0); #else - struct timeval tp; - static osd_ticks_t start_sec = 0; + 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; + 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 } @@ -179,7 +179,7 @@ osd_ticks_t osd_ticks(void) osd_ticks_t osd_ticks_per_second(void) { - return (osd_ticks_t) 1000000; + return (osd_ticks_t) 1000000; } //============================================================ @@ -188,16 +188,16 @@ osd_ticks_t osd_ticks_per_second(void) void osd_sleep(osd_ticks_t duration) { - UINT32 msec; - - // convert to milliseconds, rounding down - msec = (UINT32)(duration * 1000 / osd_ticks_per_second()); - - // only sleep if at least 2 full milliseconds - if (msec >= 2) - { - // take a couple of msecs off the top for good measure - msec -= 2; - usleep(msec*1000); - } + UINT32 msec; + + // convert to milliseconds, rounding down + msec = (UINT32)(duration * 1000 / osd_ticks_per_second()); + + // only sleep if at least 2 full milliseconds + if (msec >= 2) + { + // take a couple of msecs off the top for good measure + msec -= 2; + usleep(msec*1000); + } } diff --git a/src/osd/modules/lib/osdlib_win32.c b/src/osd/modules/lib/osdlib_win32.c index 4d78820f7d6..3150cdafc97 100644 --- a/src/osd/modules/lib/osdlib_win32.c +++ b/src/osd/modules/lib/osdlib_win32.c @@ -53,7 +53,7 @@ void (*s_debugger_stack_crawler)() = NULL; const char *osd_getenv(const char *name) { - return getenv(name); + return getenv(name); } @@ -63,23 +63,23 @@ const char *osd_getenv(const char *name) int osd_setenv(const char *name, const char *value, int overwrite) { - char *buf; - int result; - - if (!overwrite) - { - if (osd_getenv(name) != NULL) - return 0; - } - buf = (char *) osd_malloc_array(strlen(name)+strlen(value)+2); - sprintf(buf, "%s=%s", name, value); - result = putenv(buf); - - /* will be referenced by environment - * Therefore it is not freed here - */ - - return result; + char *buf; + int result; + + if (!overwrite) + { + if (osd_getenv(name) != NULL) + return 0; + } + buf = (char *) osd_malloc_array(strlen(name)+strlen(value)+2); + sprintf(buf, "%s=%s", name, value); + result = putenv(buf); + + /* will be referenced by environment + * Therefore it is not freed here + */ + + return result; } //============================================================ @@ -88,7 +88,7 @@ int osd_setenv(const char *name, const char *value, int overwrite) void osd_process_kill(void) { - TerminateProcess(GetCurrentProcess(), -1); + TerminateProcess(GetCurrentProcess(), -1); } //============================================================ @@ -97,13 +97,13 @@ void osd_process_kill(void) int osd_get_num_processors(void) { - SYSTEM_INFO info; + SYSTEM_INFO info; - // otherwise, fetch the info from the system - GetSystemInfo(&info); + // otherwise, fetch the info from the system + GetSystemInfo(&info); - // max out at 4 for now since scaling above that seems to do poorly - return MIN(info.dwNumberOfProcessors, 4); + // max out at 4 for now since scaling above that seems to do poorly + return MIN(info.dwNumberOfProcessors, 4); } //============================================================ @@ -113,17 +113,17 @@ int osd_get_num_processors(void) void *osd_malloc(size_t size) { #ifndef MALLOC_DEBUG - return HeapAlloc(GetProcessHeap(), 0, size); + return HeapAlloc(GetProcessHeap(), 0, size); #else - // add in space for the size - size += sizeof(size_t); + // add in space for the size + size += sizeof(size_t); - // basic objects just come from the heap - void *result = HeapAlloc(GetProcessHeap(), 0, size); + // basic objects just come from the heap + void *result = HeapAlloc(GetProcessHeap(), 0, size); - // store the size and return and pointer to the data afterward - *reinterpret_cast<size_t *>(result) = size; - return reinterpret_cast<UINT8 *>(result) + sizeof(size_t); + // store the size and return and pointer to the data afterward + *reinterpret_cast<size_t *>(result) = size; + return reinterpret_cast<UINT8 *>(result) + sizeof(size_t); #endif } @@ -135,30 +135,30 @@ void *osd_malloc(size_t size) void *osd_malloc_array(size_t size) { #ifndef MALLOC_DEBUG - return HeapAlloc(GetProcessHeap(), 0, size); + return HeapAlloc(GetProcessHeap(), 0, size); #else - // add in space for the size - size += sizeof(size_t); + // add in space for the size + size += sizeof(size_t); - // round the size up to a page boundary - size_t rounded_size = ((size + sizeof(void *) + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; + // round the size up to a page boundary + size_t rounded_size = ((size + sizeof(void *) + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; - // reserve that much memory, plus two guard pages - void *page_base = VirtualAlloc(NULL, rounded_size + 2 * PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS); - if (page_base == NULL) - return NULL; + // reserve that much memory, plus two guard pages + void *page_base = VirtualAlloc(NULL, rounded_size + 2 * PAGE_SIZE, MEM_RESERVE, PAGE_NOACCESS); + if (page_base == NULL) + return NULL; - // now allow access to everything but the first and last pages - page_base = VirtualAlloc(reinterpret_cast<UINT8 *>(page_base) + PAGE_SIZE, rounded_size, MEM_COMMIT, PAGE_READWRITE); - if (page_base == NULL) - return NULL; + // now allow access to everything but the first and last pages + page_base = VirtualAlloc(reinterpret_cast<UINT8 *>(page_base) + PAGE_SIZE, rounded_size, MEM_COMMIT, PAGE_READWRITE); + if (page_base == NULL) + return NULL; - // work backwards from the page base to get to the block base - void *result = GUARD_ALIGN_START ? page_base : (reinterpret_cast<UINT8 *>(page_base) + rounded_size - size); + // work backwards from the page base to get to the block base + void *result = GUARD_ALIGN_START ? page_base : (reinterpret_cast<UINT8 *>(page_base) + rounded_size - size); - // store the size at the start with a flag indicating it has a guard page - *reinterpret_cast<size_t *>(result) = size | 0x80000000; - return reinterpret_cast<UINT8 *>(result) + sizeof(size_t); + // store the size at the start with a flag indicating it has a guard page + *reinterpret_cast<size_t *>(result) = size | 0x80000000; + return reinterpret_cast<UINT8 *>(result) + sizeof(size_t); #endif } @@ -170,20 +170,20 @@ void *osd_malloc_array(size_t size) void osd_free(void *ptr) { #ifndef MALLOC_DEBUG - HeapFree(GetProcessHeap(), 0, ptr); + HeapFree(GetProcessHeap(), 0, ptr); #else - size_t size = reinterpret_cast<size_t *>(ptr)[-1]; - - // if no guard page, just free the pointer - if ((size & 0x80000000) == 0) - HeapFree(GetProcessHeap(), 0, reinterpret_cast<UINT8 *>(ptr) - sizeof(size_t)); - - // large items need more care - else - { - ULONG_PTR page_base = (reinterpret_cast<ULONG_PTR>(ptr) - sizeof(size_t)) & ~(PAGE_SIZE - 1); - VirtualFree(reinterpret_cast<void *>(page_base - PAGE_SIZE), 0, MEM_RELEASE); - } + size_t size = reinterpret_cast<size_t *>(ptr)[-1]; + + // if no guard page, just free the pointer + if ((size & 0x80000000) == 0) + HeapFree(GetProcessHeap(), 0, reinterpret_cast<UINT8 *>(ptr) - sizeof(size_t)); + + // large items need more care + else + { + ULONG_PTR page_base = (reinterpret_cast<ULONG_PTR>(ptr) - sizeof(size_t)) & ~(PAGE_SIZE - 1); + VirtualFree(reinterpret_cast<void *>(page_base - PAGE_SIZE), 0, MEM_RELEASE); + } #endif } @@ -197,7 +197,7 @@ void osd_free(void *ptr) void *osd_alloc_executable(size_t size) { - return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); } @@ -209,7 +209,7 @@ void *osd_alloc_executable(size_t size) void osd_free_executable(void *ptr, size_t size) { - VirtualFree(ptr, 0, MEM_RELEASE); + VirtualFree(ptr, 0, MEM_RELEASE); } @@ -220,19 +220,19 @@ void osd_free_executable(void *ptr, size_t size) void osd_break_into_debugger(const char *message) { #ifdef OSD_WINDOWS - if (IsDebuggerPresent()) - { - win_output_debug_string_utf8(message); - DebugBreak(); - } - else if (s_debugger_stack_crawler != NULL) - (*s_debugger_stack_crawler)(); + if (IsDebuggerPresent()) + { + win_output_debug_string_utf8(message); + DebugBreak(); + } + else if (s_debugger_stack_crawler != NULL) + (*s_debugger_stack_crawler)(); #else - if (IsDebuggerPresent()) - { - OutputDebugStringA(message); - DebugBreak(); - } + if (IsDebuggerPresent()) + { + OutputDebugStringA(message); + DebugBreak(); + } #endif } @@ -252,36 +252,36 @@ static BOOL using_qpc = TRUE; 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(); + 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(); } @@ -291,9 +291,9 @@ osd_ticks_t osd_ticks(void) osd_ticks_t osd_ticks_per_second(void) { - if (ticks_per_second == 0) - osd_ticks(); - return ticks_per_second; + if (ticks_per_second == 0) + osd_ticks(); + return ticks_per_second; } //============================================================ @@ -302,28 +302,28 @@ osd_ticks_t osd_ticks_per_second(void) 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); - } + 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); + } } diff --git a/src/osd/modules/lib/osdobj_common.c b/src/osd/modules/lib/osdobj_common.c index 73580dba2fd..57731edc591 100644 --- a/src/osd/modules/lib/osdobj_common.c +++ b/src/osd/modules/lib/osdobj_common.c @@ -17,79 +17,79 @@ extern bool g_print_verbose; const options_entry osd_options::s_option_entries[] = { - { NULL, NULL, OPTION_HEADER, "OSD FONT OPTIONS" }, - { OSD_FONT_PROVIDER, "auto", OPTION_STRING, "provider for ui font: " }, - - { NULL, NULL, OPTION_HEADER, "OSD CLI OPTIONS" }, - { OSDCOMMAND_LIST_MIDI_DEVICES ";mlist", "0", OPTION_COMMAND, "list available MIDI I/O devices" }, - { OSDCOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0", OPTION_COMMAND, "list available network adapters" }, - - // debugging options - { NULL, NULL, OPTION_HEADER, "OSD DEBUGGING OPTIONS" }, - { OSDOPTION_DEBUGGER, OSDOPTVAL_AUTO, OPTION_STRING, "debugger used : " }, - { OSDOPTION_WATCHDOG ";wdog", "0", OPTION_INTEGER, "force the program to terminate if no updates within specified number of seconds" }, - - // performance options - { NULL, NULL, OPTION_HEADER, "OSD PERFORMANCE OPTIONS" }, - { OSDOPTION_MULTITHREADING ";mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" }, - { OSDOPTION_NUMPROCESSORS ";np", OSDOPTVAL_AUTO, OPTION_STRING, "number of processors; this overrides the number the system reports" }, - { OSDOPTION_BENCH, "0", OPTION_INTEGER, "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" }, - // video options - { NULL, NULL, OPTION_HEADER, "OSD VIDEO OPTIONS" }, + { NULL, NULL, OPTION_HEADER, "OSD FONT OPTIONS" }, + { OSD_FONT_PROVIDER, "auto", OPTION_STRING, "provider for ui font: " }, + + { NULL, NULL, OPTION_HEADER, "OSD CLI OPTIONS" }, + { OSDCOMMAND_LIST_MIDI_DEVICES ";mlist", "0", OPTION_COMMAND, "list available MIDI I/O devices" }, + { OSDCOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0", OPTION_COMMAND, "list available network adapters" }, + + // debugging options + { NULL, NULL, OPTION_HEADER, "OSD DEBUGGING OPTIONS" }, + { OSDOPTION_DEBUGGER, OSDOPTVAL_AUTO, OPTION_STRING, "debugger used : " }, + { OSDOPTION_WATCHDOG ";wdog", "0", OPTION_INTEGER, "force the program to terminate if no updates within specified number of seconds" }, + + // performance options + { NULL, NULL, OPTION_HEADER, "OSD PERFORMANCE OPTIONS" }, + { OSDOPTION_MULTITHREADING ";mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" }, + { OSDOPTION_NUMPROCESSORS ";np", OSDOPTVAL_AUTO, OPTION_STRING, "number of processors; this overrides the number the system reports" }, + { OSDOPTION_BENCH, "0", OPTION_INTEGER, "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" }, + // video options + { NULL, NULL, OPTION_HEADER, "OSD VIDEO OPTIONS" }, // OS X can be trusted to have working hardware OpenGL, so default to it on for the best user experience - { OSDOPTION_VIDEO, OSDOPTVAL_AUTO, OPTION_STRING, "video output method: " }, - { OSDOPTION_NUMSCREENS "(1-4)", "1", OPTION_INTEGER, "number of screens to create; usually, you want just one" }, - { OSDOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" }, - { OSDOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" }, - { OSDOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, - { OSDOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, - { OSDOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" }, - { OSDOPTION_SYNCREFRESH ";srf", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" }, - - // per-window options - { NULL, NULL, OPTION_HEADER, "OSD PER-WINDOW VIDEO OPTIONS" }, - { OSDOPTION_SCREEN, OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_ASPECT ";screen_aspect", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio for all screens; 'auto' here will try to make a best guess" }, - { OSDOPTION_RESOLUTION ";r", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" }, - { OSDOPTION_VIEW, OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for all screens" }, - - { OSDOPTION_SCREEN "0", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_ASPECT "0", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the first screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_RESOLUTION "0;r0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, - { OSDOPTION_VIEW "0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the first screen" }, - - { OSDOPTION_SCREEN "1", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the second screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_ASPECT "1", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the second screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_RESOLUTION "1;r1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, - { OSDOPTION_VIEW "1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the second screen" }, - - { OSDOPTION_SCREEN "2", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the third screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_ASPECT "2", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the third screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_RESOLUTION "2;r2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, - { OSDOPTION_VIEW "2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the third screen" }, - - { OSDOPTION_SCREEN "3", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the fourth screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_ASPECT "3", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" }, - { OSDOPTION_RESOLUTION "3;r3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, - { OSDOPTION_VIEW "3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the fourth screen" }, - - // full screen options - { NULL, NULL, OPTION_HEADER, "OSD FULL SCREEN OPTIONS" }, - { OSDOPTION_SWITCHRES, "0", OPTION_BOOLEAN, "enable resolution switching" }, - - // sound options - { NULL, NULL, OPTION_HEADER, "OSD SOUND OPTIONS" }, - { OSDOPTION_SOUND, OSDOPTVAL_AUTO, OPTION_STRING, "sound output method: " }, - { OSDOPTION_AUDIO_LATENCY "(1-5)", "2", OPTION_INTEGER, "set audio latency (increase to reduce glitches, decrease for responsiveness)" }, - - // End of list - { NULL } + { OSDOPTION_VIDEO, OSDOPTVAL_AUTO, OPTION_STRING, "video output method: " }, + { OSDOPTION_NUMSCREENS "(1-4)", "1", OPTION_INTEGER, "number of screens to create; usually, you want just one" }, + { OSDOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" }, + { OSDOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" }, + { OSDOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, + { OSDOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, + { OSDOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" }, + { OSDOPTION_SYNCREFRESH ";srf", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" }, + + // per-window options + { NULL, NULL, OPTION_HEADER, "OSD PER-WINDOW VIDEO OPTIONS" }, + { OSDOPTION_SCREEN, OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_ASPECT ";screen_aspect", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio for all screens; 'auto' here will try to make a best guess" }, + { OSDOPTION_RESOLUTION ";r", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" }, + { OSDOPTION_VIEW, OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for all screens" }, + + { OSDOPTION_SCREEN "0", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_ASPECT "0", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the first screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_RESOLUTION "0;r0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, + { OSDOPTION_VIEW "0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the first screen" }, + + { OSDOPTION_SCREEN "1", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the second screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_ASPECT "1", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the second screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_RESOLUTION "1;r1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, + { OSDOPTION_VIEW "1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the second screen" }, + + { OSDOPTION_SCREEN "2", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the third screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_ASPECT "2", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the third screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_RESOLUTION "2;r2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, + { OSDOPTION_VIEW "2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the third screen" }, + + { OSDOPTION_SCREEN "3", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the fourth screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_ASPECT "3", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" }, + { OSDOPTION_RESOLUTION "3;r3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" }, + { OSDOPTION_VIEW "3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the fourth screen" }, + + // full screen options + { NULL, NULL, OPTION_HEADER, "OSD FULL SCREEN OPTIONS" }, + { OSDOPTION_SWITCHRES, "0", OPTION_BOOLEAN, "enable resolution switching" }, + + // sound options + { NULL, NULL, OPTION_HEADER, "OSD SOUND OPTIONS" }, + { OSDOPTION_SOUND, OSDOPTVAL_AUTO, OPTION_STRING, "sound output method: " }, + { OSDOPTION_AUDIO_LATENCY "(1-5)", "2", OPTION_INTEGER, "set audio latency (increase to reduce glitches, decrease for responsiveness)" }, + + // End of list + { NULL } }; osd_options::osd_options() : cli_options() { - add_entries(osd_options::s_option_entries); + add_entries(osd_options::s_option_entries); }; @@ -99,9 +99,9 @@ osd_options::osd_options() osd_common_t::osd_common_t(osd_options &options) : m_machine(NULL), - m_options(options), - m_sound(NULL), - m_debugger(NULL) + m_options(options), + m_sound(NULL), + m_debugger(NULL) { } @@ -110,52 +110,51 @@ osd_common_t::osd_common_t(osd_options &options) void osd_common_t::register_options() { + REGISTER_MODULE(m_mod_man, FONT_OSX); + REGISTER_MODULE(m_mod_man, FONT_WINDOWS); + REGISTER_MODULE(m_mod_man, FONT_SDL); + REGISTER_MODULE(m_mod_man, FONT_NONE); - REGISTER_MODULE(m_mod_man, FONT_OSX); - REGISTER_MODULE(m_mod_man, FONT_WINDOWS); - REGISTER_MODULE(m_mod_man, FONT_SDL); - REGISTER_MODULE(m_mod_man, FONT_NONE); - - REGISTER_MODULE(m_mod_man, SOUND_DSOUND); - REGISTER_MODULE(m_mod_man, SOUND_JS); - REGISTER_MODULE(m_mod_man, SOUND_SDL); - REGISTER_MODULE(m_mod_man, SOUND_NONE); + REGISTER_MODULE(m_mod_man, SOUND_DSOUND); + REGISTER_MODULE(m_mod_man, SOUND_JS); + REGISTER_MODULE(m_mod_man, SOUND_SDL); + REGISTER_MODULE(m_mod_man, SOUND_NONE); #ifdef SDLMAME_MACOSX - REGISTER_MODULE(m_mod_man, DEBUG_OSX); + REGISTER_MODULE(m_mod_man, DEBUG_OSX); #endif - REGISTER_MODULE(m_mod_man, DEBUG_WINDOWS); - REGISTER_MODULE(m_mod_man, DEBUG_QT); - REGISTER_MODULE(m_mod_man, DEBUG_INTERNAL); - REGISTER_MODULE(m_mod_man, DEBUG_NONE); - - // after initialization we know which modules are supported - - const char *names[20]; - int num; - m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names); - dynamic_array<const char *> dnames; - for (int i = 0; i < num; i++) - dnames.append(names[i]); - update_option(OSD_FONT_PROVIDER, dnames); - - m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, &num, names); - dnames.reset(); - for (int i = 0; i < num; i++) - dnames.append(names[i]); - update_option(OSD_SOUND_PROVIDER, dnames); - - // Register debugger options and update options - m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, &num, names); - dnames.reset(); - for (int i = 0; i < num; i++) - dnames.append(names[i]); - update_option(OSD_DEBUG_PROVIDER, dnames); - - // Register video options and update options - video_options_add("none", NULL); - video_register(); - update_option(OSDOPTION_VIDEO, m_video_names); + REGISTER_MODULE(m_mod_man, DEBUG_WINDOWS); + REGISTER_MODULE(m_mod_man, DEBUG_QT); + REGISTER_MODULE(m_mod_man, DEBUG_INTERNAL); + REGISTER_MODULE(m_mod_man, DEBUG_NONE); + + // after initialization we know which modules are supported + + const char *names[20]; + int num; + m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names); + dynamic_array<const char *> dnames; + for (int i = 0; i < num; i++) + dnames.append(names[i]); + update_option(OSD_FONT_PROVIDER, dnames); + + m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, &num, names); + dnames.reset(); + for (int i = 0; i < num; i++) + dnames.append(names[i]); + update_option(OSD_SOUND_PROVIDER, dnames); + + // Register debugger options and update options + m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, &num, names); + dnames.reset(); + for (int i = 0; i < num; i++) + dnames.append(names[i]); + update_option(OSD_DEBUG_PROVIDER, dnames); + + // Register video options and update options + video_options_add("none", NULL); + video_register(); + update_option(OSDOPTION_VIDEO, m_video_names); } void osd_common_t::update_option(const char * key, dynamic_array<const char *> &values) @@ -305,7 +304,7 @@ void osd_common_t::update_audio_stream(const INT16 *buffer, int samples_this_fra // It provides an array of stereo samples in L-R order which should be // output at the configured sample_rate. // - m_sound->update_audio_stream(m_machine->video().throttled(), buffer,samples_this_frame); + m_sound->update_audio_stream(m_machine->video().throttled(), buffer,samples_this_frame); } @@ -322,8 +321,8 @@ void osd_common_t::set_mastervolume(int attenuation) // while (attenuation++ < 0) // volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB // - if (m_sound != NULL) - m_sound->set_mastervolume(attenuation); + if (m_sound != NULL) + m_sound->set_mastervolume(attenuation); } @@ -398,20 +397,20 @@ void *osd_common_t::get_slider_list() bool osd_common_t::execute_command(const char *command) { - if (strcmp(command, OSDCOMMAND_LIST_NETWORK_ADAPTERS) == 0) - { - network_init(); - osd_list_network_adapters(); - network_exit(); - return true; - } - else if (strcmp(command, OSDCOMMAND_LIST_MIDI_DEVICES) == 0) - { - osd_list_midi_devices(); - return true; - } + if (strcmp(command, OSDCOMMAND_LIST_NETWORK_ADAPTERS) == 0) + { + network_init(); + osd_list_network_adapters(); + network_exit(); + return true; + } + else if (strcmp(command, OSDCOMMAND_LIST_MIDI_DEVICES) == 0) + { + osd_list_midi_devices(); + return true; + } - return false; + return false; } @@ -437,15 +436,15 @@ void osd_common_t::init_subsystems() #endif midi_init(); - m_font_module = select_module_options<font_module *>(options(), OSD_FONT_PROVIDER); + m_font_module = select_module_options<font_module *>(options(), OSD_FONT_PROVIDER); - m_sound = select_module_options<sound_module *>(options(), OSD_SOUND_PROVIDER); - m_sound->m_sample_rate = options().sample_rate(); - m_sound->m_audio_latency = options().audio_latency(); + m_sound = select_module_options<sound_module *>(options(), OSD_SOUND_PROVIDER); + m_sound->m_sample_rate = options().sample_rate(); + m_sound->m_audio_latency = options().audio_latency(); - m_debugger = select_module_options<debug_module *>(options(), OSD_DEBUG_PROVIDER); + m_debugger = select_module_options<debug_module *>(options(), OSD_DEBUG_PROVIDER); - m_mod_man.init(); + m_mod_man.init(); } @@ -524,9 +523,9 @@ void osd_common_t::network_exit() void osd_common_t::osd_exit() { - m_mod_man.exit(); + m_mod_man.exit(); - exit_subsystems(); + exit_subsystems(); } void osd_common_t::video_options_add(const char *name, void *type) @@ -537,13 +536,11 @@ void osd_common_t::video_options_add(const char *name, void *type) bool osd_common_t::midi_init() { - // this should be done on the OS_level - return osd_midi_init(); + // this should be done on the OS_level + return osd_midi_init(); } void osd_common_t::midi_exit() { - osd_midi_exit(); + osd_midi_exit(); } - - diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index 3ea631a4495..322bcadf682 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -62,47 +62,47 @@ class osd_options : public cli_options { public: - // construction/destruction - osd_options(); - - // debugging options - const char *debugger() const { return value(OSDOPTION_DEBUGGER); } - int watchdog() const { return int_value(OSDOPTION_WATCHDOG); } - - // performance options - bool multithreading() const { return bool_value(OSDOPTION_MULTITHREADING); } - const char *numprocessors() const { return value(OSDOPTION_NUMPROCESSORS); } - int bench() const { return int_value(OSDOPTION_BENCH); } - - // video options - const char *video() const { return value(OSDOPTION_VIDEO); } - int numscreens() const { return int_value(OSDOPTION_NUMSCREENS); } - bool window() const { return bool_value(OSDOPTION_WINDOW); } - bool maximize() const { return bool_value(OSDOPTION_MAXIMIZE); } - bool keep_aspect() const { return bool_value(OSDOPTION_KEEPASPECT); } - bool uneven_stretch() const { return bool_value(OSDOPTION_UNEVENSTRETCH); } - bool wait_vsync() const { return bool_value(OSDOPTION_WAITVSYNC); } - bool sync_refresh() const { return bool_value(OSDOPTION_SYNCREFRESH); } - - // per-window options - const char *screen() const { return value(OSDOPTION_SCREEN); } - const char *aspect() const { return value(OSDOPTION_ASPECT); } - const char *resolution() const { return value(OSDOPTION_RESOLUTION); } - const char *view() const { return value(OSDOPTION_VIEW); } - const char *screen(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_SCREEN, index)); } - const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_ASPECT, index)); } - const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_RESOLUTION, index)); } - const char *view(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_VIEW, index)); } - - // full screen options - bool switch_res() const { return bool_value(OSDOPTION_SWITCHRES); } - - // sound options - const char *sound() const { return value(OSDOPTION_SOUND); } - int audio_latency() const { return int_value(OSDOPTION_AUDIO_LATENCY); } + // construction/destruction + osd_options(); + + // debugging options + const char *debugger() const { return value(OSDOPTION_DEBUGGER); } + int watchdog() const { return int_value(OSDOPTION_WATCHDOG); } + + // performance options + bool multithreading() const { return bool_value(OSDOPTION_MULTITHREADING); } + const char *numprocessors() const { return value(OSDOPTION_NUMPROCESSORS); } + int bench() const { return int_value(OSDOPTION_BENCH); } + + // video options + const char *video() const { return value(OSDOPTION_VIDEO); } + int numscreens() const { return int_value(OSDOPTION_NUMSCREENS); } + bool window() const { return bool_value(OSDOPTION_WINDOW); } + bool maximize() const { return bool_value(OSDOPTION_MAXIMIZE); } + bool keep_aspect() const { return bool_value(OSDOPTION_KEEPASPECT); } + bool uneven_stretch() const { return bool_value(OSDOPTION_UNEVENSTRETCH); } + bool wait_vsync() const { return bool_value(OSDOPTION_WAITVSYNC); } + bool sync_refresh() const { return bool_value(OSDOPTION_SYNCREFRESH); } + + // per-window options + const char *screen() const { return value(OSDOPTION_SCREEN); } + const char *aspect() const { return value(OSDOPTION_ASPECT); } + const char *resolution() const { return value(OSDOPTION_RESOLUTION); } + const char *view() const { return value(OSDOPTION_VIEW); } + const char *screen(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_SCREEN, index)); } + const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_ASPECT, index)); } + const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_RESOLUTION, index)); } + const char *view(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_VIEW, index)); } + + // full screen options + bool switch_res() const { return bool_value(OSDOPTION_SWITCHRES); } + + // sound options + const char *sound() const { return value(OSDOPTION_SOUND); } + int audio_latency() const { return int_value(OSDOPTION_AUDIO_LATENCY); } private: - static const options_entry s_option_entries[]; + static const options_entry s_option_entries[]; }; // ======================> osd_interface @@ -142,77 +142,77 @@ public: // video overridables virtual void *get_slider_list(); - // command option overrides - virtual bool execute_command(const char *command); + // command option overrides + virtual bool execute_command(const char *command); - osd_font *font_alloc() { return m_font_module->font_alloc(); } + osd_font *font_alloc() { return m_font_module->font_alloc(); } // FIXME: everything below seems to be osd specific and not part of // this INTERFACE but part of the osd IMPLEMENTATION - // getters - running_machine &machine() { assert(m_machine != NULL); return *m_machine; } + // getters + running_machine &machine() { assert(m_machine != NULL); return *m_machine; } - virtual void debugger_update(); + virtual void debugger_update(); - virtual void init_subsystems(); + virtual void init_subsystems(); - virtual bool video_init(); - virtual void video_register(); - virtual bool window_init(); + virtual bool video_init(); + virtual void video_register(); + virtual bool window_init(); - virtual void input_resume(); - virtual bool output_init(); - virtual bool network_init(); - virtual bool midi_init(); + virtual void input_resume(); + virtual bool output_init(); + virtual bool network_init(); + virtual bool midi_init(); - virtual void exit_subsystems(); - virtual void video_exit(); - virtual void window_exit(); - virtual void input_exit(); - virtual void output_exit(); - virtual void network_exit(); - virtual void midi_exit(); + virtual void exit_subsystems(); + virtual void video_exit(); + virtual void window_exit(); + virtual void input_exit(); + virtual void output_exit(); + virtual void network_exit(); + virtual void midi_exit(); - virtual void osd_exit(); + virtual void osd_exit(); - virtual void video_options_add(const char *name, void *type); + virtual void video_options_add(const char *name, void *type); - osd_options &options() { return m_options; } + osd_options &options() { return m_options; } protected: - virtual bool input_init(); - virtual void input_pause(); + virtual bool input_init(); + virtual void input_pause(); private: // internal state running_machine * m_machine; osd_options& m_options; - osd_module_manager m_mod_man; - font_module *m_font_module; + osd_module_manager m_mod_man; + font_module *m_font_module; void update_option(const char * key, dynamic_array<const char *> &values); - // FIXME: should be elsewhere - osd_module *select_module_options(const core_options &opts, const astring &opt_name) - { - astring opt_val = opts.value(opt_name); - if (opt_val == "auto") - opt_val = ""; - else if (!m_mod_man.type_has_name(opt_name, opt_val)) - { - osd_printf_warning("Value %s not supported for option %s - falling back to auto\n", opt_val.cstr(), opt_name.cstr()); - opt_val = ""; - } - return m_mod_man.select_module(opt_name, opt_val); - } - - template<class C> - C select_module_options(const core_options &opts, const astring &opt_name) - { - return dynamic_cast<C>(select_module_options(opts, opt_name)); - } + // FIXME: should be elsewhere + osd_module *select_module_options(const core_options &opts, const astring &opt_name) + { + astring opt_val = opts.value(opt_name); + if (opt_val == "auto") + opt_val = ""; + else if (!m_mod_man.type_has_name(opt_name, opt_val)) + { + osd_printf_warning("Value %s not supported for option %s - falling back to auto\n", opt_val.cstr(), opt_name.cstr()); + opt_val = ""; + } + return m_mod_man.select_module(opt_name, opt_val); + } + + template<class C> + C select_module_options(const core_options &opts, const astring &opt_name) + { + return dynamic_cast<C>(select_module_options(opts, opt_name)); + } protected: sound_module* m_sound; |