diff options
Diffstat (limited to 'src/osd/sdl/sdlmain.c')
-rw-r--r-- | src/osd/sdl/sdlmain.c | 246 |
1 files changed, 123 insertions, 123 deletions
diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index a42089a4217..b0a53d451f8 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -95,7 +95,7 @@ const options_entry sdl_options::s_option_entries[] = // performance options { NULL, NULL, OPTION_HEADER, "PERFORMANCE OPTIONS" }, { SDLOPTION_MULTITHREADING ";mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" }, - { SDLOPTION_NUMPROCESSORS ";np", "auto", OPTION_STRING, "number of processors; this overrides the number the system reports" }, + { SDLOPTION_NUMPROCESSORS ";np", "auto", OPTION_STRING, "number of processors; this overrides the number the system reports" }, { SDLOPTION_SDLVIDEOFPS, "0", OPTION_BOOLEAN, "show sdl video performance" }, { SDLOPTION_BENCH, "0", OPTION_INTEGER, "benchmark for the given number of emulated seconds; implies -video none -nosound -nothrottle" }, // video options @@ -132,7 +132,7 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_GL_VBO, "1", OPTION_BOOLEAN, "enable OpenGL VBO, if available (default on)" }, { SDLOPTION_GL_PBO, "1", OPTION_BOOLEAN, "enable OpenGL PBO, if available (default on)" }, { SDLOPTION_GL_GLSL, "0", OPTION_BOOLEAN, "enable OpenGL GLSL, if available (default off)" }, - { SDLOPTION_GLSL_FILTER, "1", OPTION_STRING, "enable OpenGL GLSL filtering instead of FF filtering 0-plain, 1-bilinear (default)" }, + { SDLOPTION_GLSL_FILTER, "1", OPTION_STRING, "enable OpenGL GLSL filtering instead of FF filtering 0-plain, 1-bilinear (default)" }, { SDLOPTION_SHADER_MAME "0", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 0" }, { SDLOPTION_SHADER_MAME "1", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 1" }, { SDLOPTION_SHADER_MAME "2", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 2" }, @@ -153,7 +153,7 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_SHADER_SCREEN "7", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 7" }, { SDLOPTION_SHADER_SCREEN "8", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 8" }, { SDLOPTION_SHADER_SCREEN "9", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 9" }, - { SDLOPTION_GL_GLSL_VID_ATTR, "1", OPTION_BOOLEAN, "enable OpenGL GLSL handling of brightness and contrast. Better RGB game performance for free. (default)" }, + { SDLOPTION_GL_GLSL_VID_ATTR, "1", OPTION_BOOLEAN, "enable OpenGL GLSL handling of brightness and contrast. Better RGB game performance for free. (default)" }, #endif // per-window options @@ -187,7 +187,7 @@ const options_entry sdl_options::s_option_entries[] = { NULL, NULL, OPTION_HEADER, "FULL SCREEN OPTIONS" }, { SDLOPTION_SWITCHRES, "0", OPTION_BOOLEAN, "enable resolution switching" }, #ifdef SDLMAME_X11 - { SDLOPTION_USEALLHEADS, "0", OPTION_BOOLEAN, "split full screen image across monitors" }, + { SDLOPTION_USEALLHEADS, "0", OPTION_BOOLEAN, "split full screen image across monitors" }, #endif // sound options @@ -195,17 +195,17 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_AUDIO_LATENCY, "2", OPTION_INTEGER, "set audio latency (increase to reduce glitches, decrease for responsiveness)" }, // keyboard mapping - { NULL, NULL, OPTION_HEADER, "SDL KEYBOARD MAPPING" }, + { NULL, NULL, OPTION_HEADER, "SDL KEYBOARD MAPPING" }, { SDLOPTION_KEYMAP, "0", OPTION_BOOLEAN, "enable keymap" }, { SDLOPTION_KEYMAP_FILE, "keymap.dat", OPTION_STRING, "keymap filename" }, #ifdef SDLMAME_MACOSX - { SDLOPTION_UIMODEKEY, "DEL", OPTION_STRING, "Key to toggle keyboard mode" }, + { SDLOPTION_UIMODEKEY, "DEL", OPTION_STRING, "Key to toggle keyboard mode" }, #else - { SDLOPTION_UIMODEKEY, "SCRLOCK", OPTION_STRING, "Key to toggle keyboard mode" }, -#endif // SDLMAME_MACOSX + { SDLOPTION_UIMODEKEY, "SCRLOCK", OPTION_STRING, "Key to toggle keyboard mode" }, +#endif // SDLMAME_MACOSX // joystick mapping - { NULL, NULL, OPTION_HEADER, "SDL JOYSTICK MAPPING" }, + { NULL, NULL, OPTION_HEADER, "SDL JOYSTICK MAPPING" }, { SDLOPTION_JOYINDEX "1", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #1" }, { SDLOPTION_JOYINDEX "2", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #2" }, { SDLOPTION_JOYINDEX "3", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #3" }, @@ -214,7 +214,7 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_JOYINDEX "6", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #6" }, { SDLOPTION_JOYINDEX "7", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #7" }, { SDLOPTION_JOYINDEX "8", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #8" }, - { SDLOPTION_SIXAXIS, "0", OPTION_BOOLEAN, "Use special handling for PS3 Sixaxis controllers" }, + { SDLOPTION_SIXAXIS, "0", OPTION_BOOLEAN, "Use special handling for PS3 Sixaxis controllers" }, #if (USE_XINPUT) // lightgun mapping @@ -230,7 +230,7 @@ const options_entry sdl_options::s_option_entries[] = #endif #if (SDLMAME_SDL2) - { NULL, NULL, OPTION_HEADER, "SDL MOUSE MAPPING" }, + { NULL, NULL, OPTION_HEADER, "SDL MOUSE MAPPING" }, { SDLOPTION_MOUSEINDEX "1", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #1" }, { SDLOPTION_MOUSEINDEX "2", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #2" }, { SDLOPTION_MOUSEINDEX "3", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #3" }, @@ -240,7 +240,7 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_MOUSEINDEX "7", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #7" }, { SDLOPTION_MOUSEINDEX "8", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #8" }, - { NULL, NULL, OPTION_HEADER, "SDL KEYBOARD MAPPING" }, + { NULL, NULL, OPTION_HEADER, "SDL KEYBOARD MAPPING" }, { SDLOPTION_KEYBINDEX "1", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #1" }, { SDLOPTION_KEYBINDEX "2", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #2" }, { SDLOPTION_KEYBINDEX "3", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #3" }, @@ -251,7 +251,7 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_KEYBINDEX "8", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #8" }, #endif // SDL low level driver options - { NULL, NULL, OPTION_HEADER, "SDL LOWLEVEL DRIVER OPTIONS" }, + { NULL, NULL, OPTION_HEADER, "SDL LOWLEVEL DRIVER OPTIONS" }, { SDLOPTION_VIDEODRIVER ";vd", SDLOPTVAL_AUTO, OPTION_STRING, "sdl video driver to use ('x11', 'directfb', ... or 'auto' for SDL default" }, #if (SDLMAME_SDL2) { SDLOPTION_RENDERDRIVER ";rd", SDLOPTVAL_AUTO, OPTION_STRING, "sdl render driver to use ('software', 'opengl', 'directfb' ... or 'auto' for SDL default" }, @@ -272,13 +272,13 @@ const options_entry sdl_options::s_option_entries[] = #ifdef SDLMAME_OS2 void MorphToPM() { - PPIB pib; - PTIB tib; + PPIB pib; + PTIB tib; - DosGetInfoBlocks(&tib, &pib); + DosGetInfoBlocks(&tib, &pib); - // Change flag from VIO to PM: - if (pib->pib_ultype==2) pib->pib_ultype = 3; + // Change flag from VIO to PM: + if (pib->pib_ultype==2) pib->pib_ultype = 3; } #endif @@ -316,7 +316,7 @@ int main(int argc, char *argv[]) { int res = 0; -#if !(SDLMAME_SDL2) +#if !(SDLMAME_SDL2) /* Load SDL dynamic link library */ if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) { fprintf(stderr, "WinMain() error: %s", SDL_GetError()); @@ -362,7 +362,7 @@ int main(int argc, char *argv[]) } #endif - osd_init_midi(); // this is a blues riff in B, watch me for the changes and try to keep up... + osd_init_midi(); // this is a blues riff in B, watch me for the changes and try to keep up... { sdl_osd_interface osd; @@ -612,8 +612,8 @@ void sdl_osd_interface::init(running_machine &machine) #endif /* Set the SDL environment variable for drivers wanting to load the - * lib at startup. - */ + * lib at startup. + */ #if USE_OPENGL /* FIXME: move lib loading code from drawogl.c here */ @@ -628,7 +628,7 @@ void sdl_osd_interface::init(running_machine &machine) /* get number of processors */ stemp = options.numprocessors(); - osd_num_processors = 0; + osd_num_processors = 0; if (strcmp(stemp, "auto") != 0) { @@ -742,37 +742,37 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height) if( font_name != NULL ) { - font_descriptor = CTFontDescriptorCreateWithNameAndSize( font_name, POINT_SIZE ); + font_descriptor = CTFontDescriptorCreateWithNameAndSize( font_name, POINT_SIZE ); - if( font_descriptor != NULL ) - { - ct_font = CTFontCreateWithFontDescriptor( font_descriptor, POINT_SIZE, &affine_transform ); + if( font_descriptor != NULL ) + { + ct_font = CTFontCreateWithFontDescriptor( font_descriptor, POINT_SIZE, &affine_transform ); - CFRelease( font_descriptor ); - } - } + CFRelease( font_descriptor ); + } + } - CFRelease( font_name ); + CFRelease( font_name ); - if (!ct_font) + if (!ct_font) { printf("WARNING: Couldn't find/open font %s, using MAME default\n", name.cstr()); return NULL; } - CFStringRef real_name = CTFontCopyPostScriptName( ct_font ); - char real_name_c_string[255]; - CFStringGetCString ( real_name, real_name_c_string, 255, kCFStringEncodingUTF8 ); - mame_printf_verbose("Matching font: %s\n", real_name_c_string); - CFRelease( real_name ); + CFStringRef real_name = CTFontCopyPostScriptName( ct_font ); + char real_name_c_string[255]; + CFStringGetCString ( real_name, real_name_c_string, 255, kCFStringEncodingUTF8 ); + mame_printf_verbose("Matching font: %s\n", real_name_c_string); + CFRelease( real_name ); - CGFloat line_height = 0.0; - line_height += CTFontGetAscent(ct_font); - line_height += CTFontGetDescent(ct_font); - line_height += CTFontGetLeading(ct_font); - height = ceilf(line_height * EXTRA_HEIGHT); + CGFloat line_height = 0.0; + line_height += CTFontGetAscent(ct_font); + line_height += CTFontGetDescent(ct_font); + line_height += CTFontGetLeading(ct_font); + height = ceilf(line_height * EXTRA_HEIGHT); - return (osd_font)ct_font; + return (osd_font)ct_font; } //------------------------------------------------- @@ -782,12 +782,12 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height) void sdl_osd_interface::font_close(osd_font font) { - CTFontRef ct_font = (CTFontRef)font; + CTFontRef ct_font = (CTFontRef)font; - if( ct_font != NULL ) - { - CFRelease( ct_font ); - } + if( ct_font != NULL ) + { + CFRelease( ct_font ); + } } //------------------------------------------------- @@ -800,69 +800,69 @@ void sdl_osd_interface::font_close(osd_font font) bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) { - UniChar uni_char; - CGGlyph glyph; - CTFontRef ct_font = (CTFontRef)font; - const CFIndex count = 1; - CGRect bounding_rect, success_rect; - CGContextRef context_ref; - - if( chnum == ' ' ) - { - uni_char = 'n'; - CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); - success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count ); - uni_char = chnum; - CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); - } - else - { - uni_char = chnum; - CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); - success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count ); - } - - if( CGRectEqualToRect( success_rect, CGRectNull ) == false ) - { - size_t bitmap_width; - size_t bitmap_height; - - bitmap_width = ceilf(bounding_rect.size.width * EXTRA_WIDTH); - bitmap_width = bitmap_width == 0 ? 1 : bitmap_width; - - bitmap_height = ceilf( (CTFontGetAscent(ct_font) + CTFontGetDescent(ct_font) + CTFontGetLeading(ct_font)) * EXTRA_HEIGHT); - - xoffs = yoffs = 0; - width = bitmap_width; - - size_t bits_per_component; - CGColorSpaceRef color_space; - CGBitmapInfo bitmap_info = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst; - - color_space = CGColorSpaceCreateDeviceRGB(); - bits_per_component = 8; - - bitmap.allocate(bitmap_width, bitmap_height); - - context_ref = CGBitmapContextCreate( bitmap.raw_pixptr(0), bitmap_width, bitmap_height, bits_per_component, bitmap.rowpixels()*4, color_space, bitmap_info ); - - if( context_ref != NULL ) - { - CGFontRef font_ref; - font_ref = CTFontCopyGraphicsFont( ct_font, NULL ); - CGContextSetTextPosition(context_ref, -bounding_rect.origin.x*EXTRA_WIDTH, CTFontGetDescent(ct_font)+CTFontGetLeading(ct_font) ); - CGContextSetRGBFillColor(context_ref, 1.0, 1.0, 1.0, 1.0); - CGContextSetFont( context_ref, font_ref ); - CGContextSetFontSize( context_ref, POINT_SIZE ); - CGContextShowGlyphs( context_ref, &glyph, count ); - CGFontRelease( font_ref ); - CGContextRelease( context_ref ); - } - - CGColorSpaceRelease( color_space ); - } - - return bitmap.valid(); + UniChar uni_char; + CGGlyph glyph; + CTFontRef ct_font = (CTFontRef)font; + const CFIndex count = 1; + CGRect bounding_rect, success_rect; + CGContextRef context_ref; + + if( chnum == ' ' ) + { + uni_char = 'n'; + CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); + success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count ); + uni_char = chnum; + CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); + } + else + { + uni_char = chnum; + CTFontGetGlyphsForCharacters( ct_font, &uni_char, &glyph, count ); + success_rect = CTFontGetBoundingRectsForGlyphs( ct_font, kCTFontDefaultOrientation, &glyph, &bounding_rect, count ); + } + + if( CGRectEqualToRect( success_rect, CGRectNull ) == false ) + { + size_t bitmap_width; + size_t bitmap_height; + + bitmap_width = ceilf(bounding_rect.size.width * EXTRA_WIDTH); + bitmap_width = bitmap_width == 0 ? 1 : bitmap_width; + + bitmap_height = ceilf( (CTFontGetAscent(ct_font) + CTFontGetDescent(ct_font) + CTFontGetLeading(ct_font)) * EXTRA_HEIGHT); + + xoffs = yoffs = 0; + width = bitmap_width; + + size_t bits_per_component; + CGColorSpaceRef color_space; + CGBitmapInfo bitmap_info = kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst; + + color_space = CGColorSpaceCreateDeviceRGB(); + bits_per_component = 8; + + bitmap.allocate(bitmap_width, bitmap_height); + + context_ref = CGBitmapContextCreate( bitmap.raw_pixptr(0), bitmap_width, bitmap_height, bits_per_component, bitmap.rowpixels()*4, color_space, bitmap_info ); + + if( context_ref != NULL ) + { + CGFontRef font_ref; + font_ref = CTFontCopyGraphicsFont( ct_font, NULL ); + CGContextSetTextPosition(context_ref, -bounding_rect.origin.x*EXTRA_WIDTH, CTFontGetDescent(ct_font)+CTFontGetLeading(ct_font) ); + CGContextSetRGBFillColor(context_ref, 1.0, 1.0, 1.0, 1.0); + CGContextSetFont( context_ref, font_ref ); + CGContextSetFontSize( context_ref, POINT_SIZE ); + CGContextShowGlyphs( context_ref, &glyph, count ); + CGFontRelease( font_ref ); + CGContextRelease( context_ref ); + } + + CGColorSpaceRelease( color_space ); + } + + return bitmap.valid(); } #else // UNIX but not OSX @@ -882,18 +882,18 @@ static TTF_Font * TTF_OpenFont_Magic(astring name, int fsize) static bool BDF_Check_Magic(astring name) { - emu_file file(OPEN_FLAG_READ); - if (file.open(name) == FILERR_NONE) - { + emu_file file(OPEN_FLAG_READ); + if (file.open(name) == FILERR_NONE) + { unsigned char buffer[9]; unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' }; file.read(buffer, 9); - file.close(); + file.close(); if (!memcmp(buffer, magic, 9)) return true; - } + } - return false; + return false; } #ifndef SDLMAME_HAIKU @@ -1058,10 +1058,10 @@ osd_font sdl_osd_interface::font_open(const char *_name, int &height) if (!font) { - if (!BDF_Check_Magic(name)) - { - printf("WARNING: font %s, is not TrueType or BDF, using MAME default\n", name.cstr()); - } + if (!BDF_Check_Magic(name)) + { + printf("WARNING: font %s, is not TrueType or BDF, using MAME default\n", name.cstr()); + } return NULL; } @@ -1150,8 +1150,8 @@ bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitma return bitmap.valid(); } -#endif // not OSX -#else // not UNIX +#endif // not OSX +#else // not UNIX //------------------------------------------------- // font_open - attempt to "open" a handle to the // font with the given name |