diff options
Diffstat (limited to 'src/osd')
38 files changed, 1251 insertions, 1251 deletions
diff --git a/src/osd/sdl/SDL1211_opengl.h b/src/osd/sdl/SDL1211_opengl.h index aba8e602890..5e163d8027d 100644 --- a/src/osd/sdl/SDL1211_opengl.h +++ b/src/osd/sdl/SDL1211_opengl.h @@ -21,7 +21,7 @@ */ /* This is a simple file to encapsulate the OpenGL API headers */ - + #include <SDL/SDL_config.h> #ifdef __WIN32__ @@ -68,21 +68,21 @@ extern "C" { ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** +** ** http://oss.sgi.com/projects/FreeB -** +** ** Note that, as provided in the License, the Software is distributed on an ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** +** ** Original Code. The Original Code is: OpenGL Sample Implementation, ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, ** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. ** Copyright in any portions created by third parties is as indicated ** elsewhere herein. All Rights Reserved. -** +** ** Additional Notice Provisions: This software was created using the ** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has ** not been independently verified as being compliant with the OpenGL(R) diff --git a/src/osd/sdl/blit13.h b/src/osd/sdl/blit13.h index c40aa319b04..12b45d2269d 100644 --- a/src/osd/sdl/blit13.h +++ b/src/osd/sdl/blit13.h @@ -11,10 +11,10 @@ INLINE UINT32 premult32(UINT32 pixel) UINT8 r = (pixel >> 16) & 0xff; UINT8 g = (pixel >> 8) & 0xff; UINT8 b = (pixel >> 0) & 0xff; - + return 0xFF000000 | (((UINT16)r * (UINT16)a) / 255) << 16 | - (((UINT16)g * (UINT16)a) / 255) << 8 | + (((UINT16)g * (UINT16)a) / 255) << 8 | (((UINT16)b * (UINT16)a) / 255); } @@ -85,9 +85,9 @@ INLINE UINT32 pixel_ycc_to_rgb_pal(UINT16 *pixel, const rgb_t *palette) #define OP_YUV16PAL_UYVY(_src) ((texsource->palette[((_src) >> 8) & 0xff] << 8) | ((_src) & 0x00ff)) -#define OP_YUV16PAL_YVYU(_src) ((texsource->palette[((_src) >> 8) & 0xff] & 0xff) | ((_src & 0xff) << 8)) +#define OP_YUV16PAL_YVYU(_src) ((texsource->palette[((_src) >> 8) & 0xff] & 0xff) | ((_src & 0xff) << 8)) -#define OP_YUV16_YVYU(_src) ((((_src) >> 8) & 0xff) | ((_src & 0xff) << 8)) +#define OP_YUV16_YVYU(_src) ((((_src) >> 8) & 0xff) | ((_src & 0xff) << 8)) #define OP_YUV16_YUY2(_src) ( ((_src) & 0xff00ff00) | \ (((_src)>>16)&0xff) | (((_src)<<16)&0xff0000) ) diff --git a/src/osd/sdl/debugwin.c b/src/osd/sdl/debugwin.c index c4fade92030..f44fb75926a 100644 --- a/src/osd/sdl/debugwin.c +++ b/src/osd/sdl/debugwin.c @@ -80,7 +80,7 @@ typedef struct memorycombo_item char name[256]; UINT8 prefsize; running_machine *machine; // machine - const memory_subview_item *subview; // subview + const memory_subview_item *subview; // subview const device_config *device; // CPU device } memorycombo_item; @@ -102,7 +102,7 @@ static void debugwin_show(int show) void (*f)(GtkWidget *widget) = show ? gtk_widget_show : gtk_widget_hide; if(dmain) { f(dmain->win); - // dview_set_updatable(dmain->console_w, show); + // dview_set_updatable(dmain->console_w, show); } for(p1 = memorywin_list; p1; p1 = p1->next) f(p1->win); @@ -146,7 +146,7 @@ static void edit_activate(GtkEntry *item, gpointer user_data) edit_add_hist(e, text); e->cb(e->machine, text, e->cbp); edit_set_field(e); - + } static void edit_hist_back(edit *e) @@ -283,14 +283,14 @@ void debugmain_comments_activate(GtkMenuItem *item, gpointer user_data) static void debugmain_set_cpu(const device_config *cpu) { - if (cpu != dmain->cpu) + if (cpu != dmain->cpu) { char title[256]; const registers_subview_item *regsubitem; const disasm_subview_item *dasmsubitem; dmain->cpu = cpu; - + // first set all the views to the new cpu for (dasmsubitem = disasm_view_get_subview_list(dmain->disasm); dasmsubitem != NULL; dasmsubitem = dasmsubitem->next) if (dasmsubitem->space->cpu == cpu) @@ -318,7 +318,7 @@ static void debugmain_set_cpu(const device_config *cpu) void osd_wait_for_debugger(const device_config *device, int firststop) { // create a console window - if(!dmain) + if(!dmain) { // GTK init should probably be done earlier gtk_init(0, 0); @@ -375,7 +375,7 @@ static void debugmain_init(running_machine *machine) debug_view_begin_update(dmain->disasm); disasm_view_set_expression(dmain->disasm, "curpc"); -// debug_view_set_property_UINT32(dmain->disasm, DVP_DASM_TRACK_LIVE, 1); +// debug_view_set_property_UINT32(dmain->disasm, DVP_DASM_TRACK_LIVE, 1); debug_view_end_update(dmain->disasm); g_signal_connect(dmain->win, "destroy", G_CALLBACK(debugmain_destroy), dmain); @@ -409,7 +409,7 @@ static void memorywin_zone_changed(GtkComboBox *zone_w, memorywin_i *mem) memorywin_update_checks(mem); // update the window title - subview = memory_view_get_current_subview(mem->memory); + subview = memory_view_get_current_subview(mem->memory); sprintf(title, "Memory: %s", subview->name); gtk_window_set_title(GTK_WINDOW(mem->win), title); @@ -507,7 +507,7 @@ static void disasmwin_cpu_changed(GtkComboBox *cpu_w, disasmwin_i *dis) disasmwin_update_checks(dis); - subview = disasm_view_get_current_subview(dis->disasm); + subview = disasm_view_get_current_subview(dis->disasm); sprintf(title, "Disassembly: %s", subview->name); gtk_window_set_title(GTK_WINDOW(dis->win), title); } @@ -587,7 +587,7 @@ static void disasmwin_new(running_machine *machine) debug_view_begin_update(dis->disasm); disasm_view_set_expression(dis->disasm, "curpc"); -// debug_view_set_property_UINT32(dis->disasm, DVP_DASM_TRACK_LIVE, 1); +// debug_view_set_property_UINT32(dis->disasm, DVP_DASM_TRACK_LIVE, 1); debug_view_end_update(dis->disasm); // populate the combobox @@ -604,7 +604,7 @@ static void disasmwin_new(running_machine *machine) gtk_combo_box_set_active(dis->cpu_w, cursel); disasm_view_set_subview(dis->disasm, cursel); - subview = disasm_view_get_current_subview(dis->disasm); + subview = disasm_view_get_current_subview(dis->disasm); sprintf(title, "Disassembly: %s", subview->name); gtk_window_set_title(GTK_WINDOW(dis->win), title); @@ -613,7 +613,7 @@ static void disasmwin_new(running_machine *machine) g_signal_connect(lookup_widget(dis->win, "enc_opcodes"), "activate", G_CALLBACK(disasmwin_enc_opcodes_activate), dis); g_signal_connect(lookup_widget(dis->win, "comments"), "activate", G_CALLBACK(disasmwin_comments_activate), dis); - // g_signal_connect(dis->edit_w, "activate", G_CALLBACK(disasmwin_process_string), dis); + // g_signal_connect(dis->edit_w, "activate", G_CALLBACK(disasmwin_process_string), dis); g_signal_connect(dis->win, "destroy", G_CALLBACK(disasmwin_destroy), dis); gtk_widget_show_all(dis->win); } @@ -757,7 +757,7 @@ void on_reverse_activate(GtkMenuItem *item, gpointer user_data) memorywin_i *info = (memorywin_i *) user_data; debug_view_begin_update(info->memory); memory_view_set_reverse(info->memory, gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(lookup_widget(info->win, "reverse")))); - + debug_view_end_update(info->memory); } diff --git a/src/osd/sdl/draw13.c b/src/osd/sdl/draw13.c index fc49eed1693..ebfed185525 100644 --- a/src/osd/sdl/draw13.c +++ b/src/osd/sdl/draw13.c @@ -1,5 +1,5 @@ //============================================================ -// +// // draw13.c - SDL 1.3 drawing implementation // // Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. @@ -97,11 +97,11 @@ struct _copy_info { struct _texture_info { texture_info * next; // next texture in the list - + HashT hash; // hash value for the texture (must be >= pointer size) UINT32 flags; // rendering flags render_texinfo texinfo; // copy of the texture info - + int rawwidth, rawheight;// raw width/height of the texture int format; // texture format @@ -110,13 +110,13 @@ struct _texture_info int pixels_own; // do we own / allocated it ? SDL_TextureID texture_id; - + copy_info *copyinfo; Uint32 sdl_access; Uint32 sdl_blendmode; quad_setup_data setup; int is_rotated; - + osd_ticks_t last_access; }; @@ -124,16 +124,16 @@ struct _texture_info typedef struct _sdl_info sdl_info; struct _sdl_info { - INT32 blittimer; + INT32 blittimer; UINT32 extra_flags; texture_info * texlist; // list of active textures - INT32 texture_max_width; // texture maximum width - INT32 texture_max_height; // texture maximum height + INT32 texture_max_width; // texture maximum width + INT32 texture_max_height; // texture maximum height float last_hofs; float last_vofs; - + // Stats INT64 last_blit_time; INT64 last_blit_pixels; @@ -178,7 +178,7 @@ static texture_info * texture_update(sdl_window_info *window, const render_primi //============================================================ #define SDL_TEXFORMAT_LAST SDL_TEXFORMAT_PALETTE16A -#define BM_ALL (-1) +#define BM_ALL (-1) //( SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD) #define texcopy_NULL NULL @@ -186,107 +186,107 @@ static texture_info * texture_update(sdl_window_info *window, const render_primi #define ENTRY_BM(a,b,c,d,f,bm) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, c, d, texcopy_ ## f, bm, #a, #b, 0, 0, 0, 0} #define ENTRY_LR(a,b,c,d,f) { SDL_TEXFORMAT_ ## a, SDL_PIXELFORMAT_ ## b, c, d, texcopy_ ## f, BM_ALL, #a, #b, 0, 0, 0, -1} -static copy_info blit_info_default[] = +static copy_info blit_info_default[] = { /* no rotation */ - ENTRY(ARGB32, ARGB8888, 4, 0, NULL), - ENTRY_LR(ARGB32, RGB888, 4, 0, argb32_rgb32), + ENTRY(ARGB32, ARGB8888, 4, 0, NULL), + ENTRY_LR(ARGB32, RGB888, 4, 0, argb32_rgb32), /* Entry for primarily for directfb */ - ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_ADD), - ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_MOD), - ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_NONE), + ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_ADD), + ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_MOD), + ENTRY_BM(ARGB32, RGB888, 4, 0, argb32_rgb32, SDL_BLENDMODE_NONE), - ENTRY(RGB32, ARGB8888, 4, 0, rgb32_argb32), - ENTRY(RGB32, RGB888, 4, 0, NULL), + ENTRY(RGB32, ARGB8888, 4, 0, rgb32_argb32), + ENTRY(RGB32, RGB888, 4, 0, NULL), - ENTRY(RGB32_PALETTED, ARGB8888, 4, 0, rgb32pal_argb32), + ENTRY(RGB32_PALETTED, ARGB8888, 4, 0, rgb32pal_argb32), ENTRY(RGB32_PALETTED, RGB888, 4, 0, rgb32pal_argb32), - ENTRY(YUY16, UYVY, 2, 0, NULL /* yuv16_uyvy*/), - ENTRY(YUY16, YUY2, 2, 0, yuv16_yuy2), - ENTRY(YUY16, YVYU, 2, 0, yuv16_yvyu), - ENTRY(YUY16, ARGB8888, 4, 0, yuv16_argb32), - ENTRY(YUY16, RGB888, 4, 0, yuv16pal_argb32), - - ENTRY(YUY16_PALETTED, UYVY, 2, 0, yuv16pal_uyvy), - ENTRY(YUY16_PALETTED, YUY2, 2, 0, yuv16pal_yuy2), - ENTRY(YUY16_PALETTED, YVYU, 2, 0, yuv16pal_yvyu), - ENTRY(YUY16_PALETTED, ARGB8888, 4, 0, yuv16pal_argb32), - ENTRY(YUY16_PALETTED, RGB888, 4, 0, yuv16pal_argb32), + ENTRY(YUY16, UYVY, 2, 0, NULL /* yuv16_uyvy*/), + ENTRY(YUY16, YUY2, 2, 0, yuv16_yuy2), + ENTRY(YUY16, YVYU, 2, 0, yuv16_yvyu), + ENTRY(YUY16, ARGB8888, 4, 0, yuv16_argb32), + ENTRY(YUY16, RGB888, 4, 0, yuv16pal_argb32), - ENTRY(PALETTE16, ARGB8888, 4, 0, pal16_argb32), - ENTRY(PALETTE16, RGB888, 4, 0, pal16_argb32), + ENTRY(YUY16_PALETTED, UYVY, 2, 0, yuv16pal_uyvy), + ENTRY(YUY16_PALETTED, YUY2, 2, 0, yuv16pal_yuy2), + ENTRY(YUY16_PALETTED, YVYU, 2, 0, yuv16pal_yvyu), + ENTRY(YUY16_PALETTED, ARGB8888, 4, 0, yuv16pal_argb32), + ENTRY(YUY16_PALETTED, RGB888, 4, 0, yuv16pal_argb32), - ENTRY(RGB15, RGB555, 2, 0, NULL /* rgb15_argb1555 */), - ENTRY(RGB15, ARGB1555, 2, 0, rgb15_argb1555), - ENTRY(RGB15, ARGB8888, 4, 0, rgb15_argb32), - ENTRY(RGB15, RGB888, 4, 0, rgb15_argb32), + ENTRY(PALETTE16, ARGB8888, 4, 0, pal16_argb32), + ENTRY(PALETTE16, RGB888, 4, 0, pal16_argb32), - ENTRY(RGB15_PALETTED, ARGB8888, 4, 0, rgb15pal_argb32), - ENTRY(RGB15_PALETTED, RGB888, 4, 0, rgb15pal_argb32), + ENTRY(RGB15, RGB555, 2, 0, NULL /* rgb15_argb1555 */), + ENTRY(RGB15, ARGB1555, 2, 0, rgb15_argb1555), + ENTRY(RGB15, ARGB8888, 4, 0, rgb15_argb32), + ENTRY(RGB15, RGB888, 4, 0, rgb15_argb32), - ENTRY(PALETTE16A, ARGB8888, 4, 0, pal16a_argb32), - ENTRY(PALETTE16A, RGB888, 4, 0, pal16a_rgb32), + ENTRY(RGB15_PALETTED, ARGB8888, 4, 0, rgb15pal_argb32), + ENTRY(RGB15_PALETTED, RGB888, 4, 0, rgb15pal_argb32), + + ENTRY(PALETTE16A, ARGB8888, 4, 0, pal16a_argb32), + ENTRY(PALETTE16A, RGB888, 4, 0, pal16a_rgb32), /* rotation */ - ENTRY(ARGB32, ARGB8888, 4, 1, rot_argb32_argb32), - ENTRY_LR(ARGB32, RGB888, 4, 1, rot_argb32_rgb32), + ENTRY(ARGB32, ARGB8888, 4, 1, rot_argb32_argb32), + ENTRY_LR(ARGB32, RGB888, 4, 1, rot_argb32_rgb32), /* Entry for primarily for directfb */ - ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_ADD), - ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_MOD), - ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_NONE), + ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_ADD), + ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_MOD), + ENTRY_BM(ARGB32, RGB888, 4, 1, rot_argb32_rgb32, SDL_BLENDMODE_NONE), - ENTRY(RGB32, ARGB8888, 4, 1, rot_rgb32_argb32), - ENTRY(RGB32, RGB888, 4, 1, rot_argb32_argb32), + ENTRY(RGB32, ARGB8888, 4, 1, rot_rgb32_argb32), + ENTRY(RGB32, RGB888, 4, 1, rot_argb32_argb32), - ENTRY(RGB32_PALETTED, ARGB8888, 4, 1, rot_rgb32pal_argb32), + ENTRY(RGB32_PALETTED, ARGB8888, 4, 1, rot_rgb32pal_argb32), ENTRY(RGB32_PALETTED, RGB888, 4, 1, rot_rgb32pal_argb32), - ENTRY(YUY16, ARGB8888, 4, 1, rot_yuv16_argb32), - ENTRY(YUY16, RGB888, 4, 1, rot_yuv16_argb32), - - ENTRY(YUY16_PALETTED, ARGB8888, 4, 1, rot_yuv16pal_argb32), - ENTRY(YUY16_PALETTED, RGB888, 4, 1, rot_yuv16pal_argb32), + ENTRY(YUY16, ARGB8888, 4, 1, rot_yuv16_argb32), + ENTRY(YUY16, RGB888, 4, 1, rot_yuv16_argb32), + + ENTRY(YUY16_PALETTED, ARGB8888, 4, 1, rot_yuv16pal_argb32), + ENTRY(YUY16_PALETTED, RGB888, 4, 1, rot_yuv16pal_argb32), - ENTRY(PALETTE16, ARGB8888, 4, 1, rot_pal16_argb32), - ENTRY(PALETTE16, RGB888, 4, 1, rot_pal16_argb32), + ENTRY(PALETTE16, ARGB8888, 4, 1, rot_pal16_argb32), + ENTRY(PALETTE16, RGB888, 4, 1, rot_pal16_argb32), - ENTRY(RGB15, RGB555, 2, 1, rot_rgb15_argb1555), - ENTRY(RGB15, ARGB1555, 2, 1, rot_rgb15_argb1555), - ENTRY(RGB15, ARGB8888, 4, 1, rot_rgb15_argb32), - ENTRY(RGB15, RGB888, 4, 1, rot_rgb15_argb32), + ENTRY(RGB15, RGB555, 2, 1, rot_rgb15_argb1555), + ENTRY(RGB15, ARGB1555, 2, 1, rot_rgb15_argb1555), + ENTRY(RGB15, ARGB8888, 4, 1, rot_rgb15_argb32), + ENTRY(RGB15, RGB888, 4, 1, rot_rgb15_argb32), - ENTRY(RGB15_PALETTED, ARGB8888, 4, 1, rot_rgb15pal_argb32), - ENTRY(RGB15_PALETTED, RGB888, 4, 1, rot_rgb15pal_argb32), + ENTRY(RGB15_PALETTED, ARGB8888, 4, 1, rot_rgb15pal_argb32), + ENTRY(RGB15_PALETTED, RGB888, 4, 1, rot_rgb15pal_argb32), - ENTRY(PALETTE16A, ARGB8888, 4, 1, rot_pal16a_argb32), - ENTRY(PALETTE16A, RGB888, 4, 1, rot_pal16a_rgb32), + ENTRY(PALETTE16A, ARGB8888, 4, 1, rot_pal16a_argb32), + ENTRY(PALETTE16A, RGB888, 4, 1, rot_pal16a_rgb32), { -1 }, }; -static copy_info blit_info_16bpp[] = +static copy_info blit_info_16bpp[] = { /* no rotation */ - ENTRY(PALETTE16, RGB555, 2, 0, pal16_argb1555), - ENTRY(PALETTE16, ARGB1555, 2, 0, pal16_argb1555), + ENTRY(PALETTE16, RGB555, 2, 0, pal16_argb1555), + ENTRY(PALETTE16, ARGB1555, 2, 0, pal16_argb1555), - ENTRY(RGB15_PALETTED, RGB555, 2, 0, rgb15pal_argb1555), - ENTRY(RGB15_PALETTED, ARGB1555, 2, 0, rgb15pal_argb1555), + ENTRY(RGB15_PALETTED, RGB555, 2, 0, rgb15pal_argb1555), + ENTRY(RGB15_PALETTED, ARGB1555, 2, 0, rgb15pal_argb1555), /* rotation */ - ENTRY(PALETTE16, RGB555, 2, 1, rot_pal16_argb1555), - ENTRY(PALETTE16, ARGB1555, 2, 1, rot_pal16_argb1555), + ENTRY(PALETTE16, RGB555, 2, 1, rot_pal16_argb1555), + ENTRY(PALETTE16, ARGB1555, 2, 1, rot_pal16_argb1555), - ENTRY(RGB15_PALETTED, RGB555, 2, 1, rot_rgb15pal_argb1555), - ENTRY(RGB15_PALETTED, ARGB1555, 2, 1, rot_rgb15pal_argb1555), + ENTRY(RGB15_PALETTED, RGB555, 2, 1, rot_rgb15pal_argb1555), + ENTRY(RGB15_PALETTED, ARGB1555, 2, 1, rot_rgb15pal_argb1555), { -1 }, }; static copy_info *blit_info[SDL_TEXFORMAT_LAST+1]; -static struct +static struct { Uint32 format; int status; @@ -314,15 +314,15 @@ INLINE Uint32 map_blendmode(int blendmode) { case BLENDMODE_NONE: return SDL_BLENDMODE_NONE; - case BLENDMODE_ALPHA: + case BLENDMODE_ALPHA: return SDL_BLENDMODE_BLEND; - case BLENDMODE_RGB_MULTIPLY: + case BLENDMODE_RGB_MULTIPLY: return SDL_BLENDMODE_MOD; - case BLENDMODE_ADD: + case BLENDMODE_ADD: return SDL_BLENDMODE_ADD; default: mame_printf_warning("Unknown Blendmode %d", blendmode); - } + } return SDL_BLENDMODE_NONE; } @@ -332,29 +332,29 @@ INLINE void set_coloralphamode(SDL_TextureID texture_id, const render_color *col UINT32 sg = (UINT32)(255.0f * color->g); UINT32 sb = (UINT32)(255.0f * color->b); UINT32 sa = (UINT32)(255.0f * color->a); - - + + if (color->r >= 1.0f && color->g >= 1.0f && color->b >= 1.0f && IS_OPAQUE(color->a)) { SDL_SetTextureColorMod(texture_id, 0xFF, 0xFF, 0xFF); - SDL_SetTextureAlphaMod(texture_id, 0xFF); + SDL_SetTextureAlphaMod(texture_id, 0xFF); } /* coloring-only case */ else if (IS_OPAQUE(color->a)) { SDL_SetTextureColorMod(texture_id, sr, sg, sb); - SDL_SetTextureAlphaMod(texture_id, 0xFF); + SDL_SetTextureAlphaMod(texture_id, 0xFF); } /* alpha and/or coloring case */ else if (!IS_TRANSPARENT(color->a)) { SDL_SetTextureColorMod(texture_id, sr, sg, sb); - SDL_SetTextureAlphaMod(texture_id, sa); + SDL_SetTextureAlphaMod(texture_id, sa); } - else + else { SDL_SetTextureColorMod(texture_id, 0xFF, 0xFF, 0xFF); - SDL_SetTextureAlphaMod(texture_id, 0xFF); + SDL_SetTextureAlphaMod(texture_id, 0xFF); } } @@ -362,12 +362,12 @@ INLINE void render_quad(sdl_info *sdl, texture_info *texture, render_primitive * { SDL_TextureID 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; @@ -383,7 +383,7 @@ INLINE void render_quad(sdl_info *sdl, texture_info *texture, render_primitive * } SDL_SetTextureBlendMode(texture_id, texture->sdl_blendmode); set_coloralphamode(texture_id, &prim->color); - SDL_RenderCopy(texture_id, NULL, &target_rect); + SDL_RenderCopy(texture_id, NULL, &target_rect); texture->copyinfo->time += osd_ticks(); texture->copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->rawwidth * texture->rawheight)); @@ -412,9 +412,9 @@ static int RendererSupportsFormat(Uint32 format, Uint32 access, const char *sfor { struct SDL_RendererInfo render_info; int i; - + SDL_GetRendererInfo(&render_info); - + for (i=0; i < render_info.num_texture_formats; i++) { if (format == render_info.texture_formats[i]) @@ -445,11 +445,11 @@ static int RendererSupportsFormat(Uint32 format, Uint32 access, const char *sfor SDL_DestroyTexture(texid); return 1; } - mame_printf_verbose("Pixelformat <%s> error %s \n", sformat, SDL_GetError()); + mame_printf_verbose("Pixelformat <%s> error %s \n", sformat, SDL_GetError()); mame_printf_verbose("Pixelformat <%s> not supported\n", sformat); fmt_support[i].status = 0; return 0; -} +} #endif //============================================================ @@ -469,7 +469,7 @@ static void add_list(copy_info **head, copy_info *element, Uint32 bm) static void expand_copy_info(copy_info *list) { copy_info *bi; - + for (bi = list; bi->src_fmt != -1; bi++) { if (bi->bm_mask == BM_ALL) @@ -487,13 +487,13 @@ static void expand_copy_info(copy_info *list) int draw13_init(sdl_draw_info *callbacks) { const char *stemp; - + // fill in the callbacks callbacks->exit = draw13_exit; callbacks->attach = draw13_attach; mame_printf_verbose("Using SDL native texturing driver (SDL 1.3+)\n"); - + expand_copy_info(blit_info_default); //FIXME: -opengl16 should be -opengl -prefer16bpp //if (video_config.prefer16bpp_tex) @@ -510,7 +510,7 @@ int draw13_init(sdl_draw_info *callbacks) mame_printf_verbose("Warning: Unable to load opengl library: %s\n", stemp ? stemp : "<default>"); else mame_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>"); - + return 0; } @@ -527,7 +527,7 @@ static void draw13_exit(void) for (bi = blit_info[i]; bi != NULL; ) { if (bi->pixel_count) - mame_printf_verbose("%s -> %s %s blendmode 0x%02x, %d samples: %d KPixel/sec\n", bi->srcname, bi->dstname, + mame_printf_verbose("%s -> %s %s blendmode 0x%02x, %d samples: %d KPixel/sec\n", bi->srcname, bi->dstname, bi->rotate ? "rot" : "norot", bi->bm_mask, bi->samples, (int) bi->perf); freeme = bi; @@ -569,13 +569,13 @@ static int draw13_window_create(sdl_window_info *window, int width, int height) window->dxdata = sdl; - sdl->extra_flags = (window->fullscreen ? + sdl->extra_flags = (window->fullscreen ? SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN: SDL_WINDOW_RESIZABLE); // create the SDL window SDL_SelectVideoDisplay(window->monitor->handle); - if (window->fullscreen && video_config.switchres) + if (window->fullscreen && video_config.switchres) { SDL_DisplayMode mode; SDL_GetCurrentDisplayMode(&mode); @@ -607,7 +607,7 @@ static int draw13_window_create(sdl_window_info *window, int width, int height) } else SDL_SetWindowDisplayMode(window->window_id, NULL); // Use desktop - + window->window_id = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, sdl->extra_flags); @@ -615,21 +615,21 @@ static int draw13_window_create(sdl_window_info *window, int width, int height) //SDL_SetWindowFullscreen(window->window_id, window->fullscreen); SDL_RaiseWindow(window->window_id); SDL_GetWindowSize(window->window_id, &window->width, &window->height); - + // create renderer - - if (video_config.waitvsync) + + if (video_config.waitvsync) result = SDL_CreateRenderer(window->window_id, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC); else result = SDL_CreateRenderer(window->window_id, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD); - + if (result) { fatalerror("Error on creating renderer: %s \n", SDL_GetError()); } - + SDL_SelectRenderer(window->window_id); - + sdl->blittimer = 3; // in case any textures try to come up before these are validated, @@ -652,7 +652,7 @@ static void draw13_window_resize(sdl_window_info *window, int width, int height) SDL_SetWindowSize(window->window_id, width, height); SDL_GetWindowSize(window->window_id, &window->width, &window->height); sdl->blittimer = 3; - + } //============================================================ @@ -748,7 +748,7 @@ static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update) sdl->last_hofs = hofs; sdl->last_vofs = vofs; - + osd_lock_acquire(window->primlist->lock); // now draw @@ -773,7 +773,7 @@ static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update) texture = texture_update(window, prim); if (texture) blit_pixels += (texture->rawheight * texture->rawwidth); - render_quad(sdl, texture, prim, + render_quad(sdl, texture, prim, round_nearest(hofs + prim->bounds.x0), round_nearest(vofs + prim->bounds.y0)); break; @@ -839,13 +839,13 @@ static copy_info *texture_compute_size_type(const render_texinfo *texsource, tex copy_info *result = NULL; int maxperf = 0; //int bm = PRIMFLAG_GET_BLENDMODE(flags); - + for (bi = blit_info[texture->format]; bi != NULL; bi = bi->next) { - if ((texture->is_rotated == bi->rotate) + if ((texture->is_rotated == bi->rotate) && (texture->sdl_blendmode == bi->bm_mask)) { - if (RendererSupportsFormat(bi->dst_fmt, texture->sdl_access, bi->dstname)) + if (RendererSupportsFormat(bi->dst_fmt, texture->sdl_access, bi->dstname)) { if (bi->perf == 0) return bi; @@ -862,9 +862,9 @@ static copy_info *texture_compute_size_type(const render_texinfo *texsource, tex /* try last resort handlers */ for (bi = blit_info[texture->format]; bi != NULL; bi = bi->next) { - if ((texture->is_rotated == bi->rotate) + if ((texture->is_rotated == bi->rotate) && (texture->sdl_blendmode == bi->bm_mask)) - if (RendererSupportsFormat(bi->dst_fmt, texture->sdl_access, bi->dstname)) + if (RendererSupportsFormat(bi->dst_fmt, texture->sdl_access, bi->dstname)) return bi; } //FIXME: crash implement a -do nothing handler */ @@ -879,7 +879,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf { sdl_info *sdl = (sdl_info *) window->dxdata; texture_info *texture; - + // allocate a new texture texture = (texture_info *) osd_malloc(sizeof(*texture)); memset(texture, 0, sizeof(*texture)); @@ -892,7 +892,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf texture->is_rotated = FALSE; texture->setup = *setup; texture->sdl_blendmode = map_blendmode(PRIMFLAG_GET_BLENDMODE(flags)); - + switch (PRIMFLAG_GET_TEXFORMAT(flags)) { case TEXFORMAT_ARGB32: @@ -925,24 +925,24 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf texture->is_rotated = TRUE; else texture->is_rotated = FALSE; - + //texture->sdl_access = SDL_TEXTUREACCESS_STATIC; texture->sdl_access = SDL_TEXTUREACCESS_STREAMING; // Watch out for 0x0 textures ... if (!texture->setup.rotwidth || !texture->setup.rotheight) mame_printf_warning("Trying to create texture with zero dim\n"); - + // compute the size texture->copyinfo = texture_compute_size_type(texsource, texture, flags); - texture->texture_id = SDL_CreateTexture(texture->copyinfo->dst_fmt, texture->sdl_access, + texture->texture_id = SDL_CreateTexture(texture->copyinfo->dst_fmt, texture->sdl_access, texture->setup.rotwidth, texture->setup.rotheight); - + if (!texture->texture_id) mame_printf_error("Error creating texture: %d x %d, pixelformat %s error: %s\n", texture->setup.rotwidth, texture->setup.rotheight, texture->copyinfo->dstname, SDL_GetError()); - + if ( (texture->copyinfo->func != NULL) && (texture->sdl_access == SDL_TEXTUREACCESS_STATIC)) { texture->pixels = osd_malloc(texture->setup.rotwidth * texture->setup.rotheight * texture->copyinfo->dst_bpp); @@ -970,8 +970,8 @@ static void texture_set_data(sdl_info *sdl, texture_info *texture, const render_ { texture->pitch = texture->setup.rotwidth * texture->copyinfo->dst_bpp; texture->copyinfo->func(texture, texsource); - } - else + } + else { texture->pixels = texsource->base; texture->pitch = texture->texinfo.rowpixels * texture->copyinfo->dst_bpp; @@ -983,7 +983,7 @@ static void texture_set_data(sdl_info *sdl, texture_info *texture, const render_ SDL_LockTexture(texture->texture_id, NULL, 1, (void **) &texture->pixels, &texture->pitch); if ( texture->copyinfo->func ) texture->copyinfo->func(texture, texsource); - else + else { UINT8 *src = (UINT8 *) texsource->base; UINT8 *dst = (UINT8 *) texture->pixels; @@ -1009,7 +1009,7 @@ static void compute_setup(sdl_info *sdl, const render_primitive *prim, quad_setu { const render_quad_texuv *texcoords = &prim->texcoords; int texwidth = prim->texture.width; - int texheight = prim->texture.height; + int texheight = prim->texture.height; float fdudx, fdvdx, fdudy, fdvdy; float width, height; float fscale; @@ -1023,9 +1023,9 @@ static void compute_setup(sdl_info *sdl, const render_primitive *prim, quad_setu fdvdx = (texcoords->tr.v - texcoords->tl.v) / fscale; // c a21 fdudy = (texcoords->bl.u - texcoords->tl.u) / fscale; // b a12 fdvdy = (texcoords->bl.v - texcoords->tl.v) / fscale; // d a22 - + /* compute start and delta U,V coordinates now */ - + setup->dudx = round_nearest(65536.0f * fdudx); setup->dvdx = round_nearest(65536.0f * fdvdx); setup->dudy = round_nearest(65536.0f * fdudy); @@ -1043,7 +1043,7 @@ static void compute_setup(sdl_info *sdl, const render_primitive *prim, quad_setu setup->startu += (setup->dudx + setup->dudy) / 2; setup->startv += (setup->dvdx + setup->dvdy) / 2; - + } //============================================================ @@ -1109,7 +1109,7 @@ static texture_info * texture_update(sdl_window_info *window, const render_primi sdl_info *sdl = (sdl_info *) window->dxdata; quad_setup_data setup; texture_info *texture; - + compute_setup(sdl, prim, &setup, prim->flags); texture = texture_find(sdl, prim, &setup); @@ -1117,8 +1117,8 @@ static texture_info * texture_update(sdl_window_info *window, const render_primi // if we didn't find one, create a new texture if (texture == NULL && prim->texture.base != NULL) { - texture = texture_create(window, &prim->texture, &setup, prim->flags); - } + texture = texture_create(window, &prim->texture, &setup, prim->flags); + } if (texture != NULL) { @@ -1129,14 +1129,14 @@ static texture_info * texture_update(sdl_window_info *window, const render_primi texture_set_data(sdl, texture, &prim->texture, prim->flags); } - } + } return texture; } static void draw13_destroy_texture(sdl_info *sdl, texture_info *texture) { texture_info *p; - + SDL_DestroyTexture(texture->texture_id); if ( texture->pixels_own ) { @@ -1144,7 +1144,7 @@ static void draw13_destroy_texture(sdl_info *sdl, texture_info *texture) texture->pixels=NULL; texture->pixels_own=FALSE; } - + for (p=sdl->texlist; p != NULL; p = p->next) if (p->next == texture) break; @@ -1165,9 +1165,9 @@ static void draw13_destroy_all_textures(sdl_window_info *window) return; if(window->primlist && window->primlist->lock) - { - lock=TRUE; - osd_lock_acquire(window->primlist->lock); + { + lock=TRUE; + osd_lock_acquire(window->primlist->lock); } texture = sdl->texlist; diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c index 9969db22e22..cd8c9ce0501 100644 --- a/src/osd/sdl/drawogl.c +++ b/src/osd/sdl/drawogl.c @@ -1,5 +1,5 @@ //============================================================ -// +// // drawogl.c - SDL software and OpenGL implementation // // Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. @@ -156,7 +156,7 @@ typedef struct _texture_info texture_info; #if USE_OPENGL typedef void (*texture_copy_func)(texture_info *texture, const render_texinfo *texsource); #endif - + /* texture_info holds information about a texture */ struct _texture_info { @@ -173,26 +173,26 @@ struct _texture_info int xprescale; // what is our X prescale factor? int yprescale; // what is our Y prescale factor? int nocopy; // must the texture date be copied? - + UINT32 texture; // OpenGL texture "name"/ID const GLint * texProperties; // texture properties texture_copy_func texCopyFn; // texture copy function, !=NULL if !nocopy GLenum texTarget; // OpenGL texture target int texpow2; // Is this texture pow2 - + UINT32 mpass_dest_idx; // Multipass dest idx [0..1] UINT32 mpass_textureunit[2]; // texture unit names for GLSL - + UINT32 mpass_texture_mamebm[2];// Multipass OpenGL texture "name"/ID for the shader UINT32 mpass_fbo_mamebm[2]; // framebuffer object for this texture, multipass UINT32 mpass_texture_scrn[2]; // Multipass OpenGL texture "name"/ID for the shader UINT32 mpass_fbo_scrn[2]; // framebuffer object for this texture, multipass - + UINT32 lut_texture; // LUT OpenGL texture "name"/ID for the shader - int lut_table_width; // LUT table width + int lut_table_width; // LUT table width int lut_table_height; // LUT table height - + UINT32 pbo; // pixel buffer object for this texture (DYNAMIC only!) UINT32 *data; // pixels for the texture int data_own; // do we own / allocated it ? @@ -205,7 +205,7 @@ struct _texture_info typedef struct _sdl_info sdl_info; struct _sdl_info { - INT32 blittimer; + INT32 blittimer; UINT32 extra_flags; #if (SDL_VERSION_ATLEAST(1,3,0)) @@ -219,19 +219,19 @@ struct _sdl_info // 3D info (GL mode only) texture_info * texlist; // list of active textures int last_blendmode; // previous blendmode - INT32 texture_max_width; // texture maximum width - INT32 texture_max_height; // texture maximum height + INT32 texture_max_width; // texture maximum width + INT32 texture_max_height; // texture maximum height int texpoweroftwo; // must textures be power-of-2 sized? int usevbo; // runtime check if VBO is available int usepbo; // runtime check if PBO is available int usefbo; // runtime check if FBO is available int useglsl; // runtime check if GLSL is available - + glsl_shader_info *glsl; // glsl_shader_info - + GLhandleARB glsl_program[2*GLSL_SHADER_MAX]; // GLSL programs, or 0 int glsl_program_num; // number of GLSL programs - int glsl_program_mb2sc; // GLSL program idx, which transforms + int glsl_program_mb2sc; // GLSL program idx, which transforms // the mame-bitmap -> screen-bitmap (size/rotation/..) // All progs <= glsl_program_mb2sc using the mame bitmap // as input, otherwise the screen bitmap. @@ -246,10 +246,10 @@ struct _sdl_info float last_hofs; float last_vofs; - + // Static vars from draogl_window_dra - INT32 surf_w; - INT32 surf_h; + INT32 surf_w; + INT32 surf_h; GLfloat texVerticex[8]; }; @@ -295,19 +295,19 @@ INLINE void set_blendmode(sdl_info *sdl, int blendmode) case BLENDMODE_NONE: glDisable(GL_BLEND); break; - case BLENDMODE_ALPHA: + case BLENDMODE_ALPHA: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; - case BLENDMODE_RGB_MULTIPLY: + case BLENDMODE_RGB_MULTIPLY: glEnable(GL_BLEND); glBlendFunc(GL_DST_COLOR, GL_ZERO); break; - case BLENDMODE_ADD: + case BLENDMODE_ADD: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); break; - } + } sdl->last_blendmode = blendmode; } @@ -335,7 +335,7 @@ static void load_gl_lib(void); // OGL 1.3 #ifdef GL_ARB_multitexture -static PFNGLACTIVETEXTUREARBPROC pfn_glActiveTexture = NULL; +static PFNGLACTIVETEXTUREARBPROC pfn_glActiveTexture = NULL; #else static PFNGLACTIVETEXTUREPROC pfn_glActiveTexture = NULL; #endif @@ -455,8 +455,8 @@ static void loadgl_functions(void) int err_count = 0; /* the following is tricky ... #func will be expanded to glBegin - * while func will be expanded to disp_p->glBegin - */ + * while func will be expanded to disp_p->glBegin + */ #define OSD_GL(ret,func,params) \ if (!( func = (ret (APIENTRY *)params) SDL_GL_GetProcAddress( #func ) )) \ @@ -467,11 +467,11 @@ static void loadgl_functions(void) #define GET_GLFUNC 1 #include "osd_opengl.h" #undef GET_GLFUNC - + if (err_count) fatalerror("Error loading GL library functions, giving up\n"); -#endif +#endif } //============================================================ @@ -484,9 +484,9 @@ static void load_gl_lib(void) if (!dll_loaded) { /* - * directfb and and x11 use this env var - * SDL_VIDEO_GL_DRIVER - */ + * directfb and and x11 use this env var + * SDL_VIDEO_GL_DRIVER + */ const char *stemp; stemp = options_get_string(mame_options(), SDLOPTION_GL_LIB); @@ -497,8 +497,8 @@ static void load_gl_lib(void) { fatalerror("Unable to load opengl library: %s\n", stemp ? stemp : "<default>"); } - mame_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>"); - /* FIXME: must be freed as well */ + mame_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>"); + /* FIXME: must be freed as well */ gl_dispatch = (osd_gl_dispatch *) osd_malloc(sizeof(osd_gl_dispatch)); dll_loaded=1; } @@ -523,7 +523,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) window->dxdata = sdl; #if (SDL_VERSION_ATLEAST(1,3,0)) - sdl->extra_flags = (window->fullscreen ? + sdl->extra_flags = (window->fullscreen ? SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE); sdl->extra_flags |= SDL_WINDOW_OPENGL; @@ -534,7 +534,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) // create the SDL window SDL_SelectVideoDisplay(window->monitor->handle); - if (window->fullscreen && video_config.switchres) + if (window->fullscreen && video_config.switchres) { SDL_DisplayMode mode; SDL_GetCurrentDisplayMode(&mode); @@ -546,7 +546,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) } else SDL_SetWindowDisplayMode(window->window_id, NULL); // Use desktop - + window->window_id = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, sdl->extra_flags); @@ -560,7 +560,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) //SDL_SetWindowFullscreen(window->window_id, window->fullscreen); SDL_RaiseWindow(window->window_id); SDL_GetWindowSize(window->window_id, &window->width, &window->height); - + sdl->gl_context_id = SDL_GL_CreateContext(window->window_id); if (!sdl->gl_context_id) { @@ -569,7 +569,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) } SDL_GL_SetSwapInterval(video_config.waitvsync ? 2 : 0); - + #else sdl->extra_flags = (window->fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE); sdl->extra_flags |= SDL_OPENGL | SDL_DOUBLEBUF; @@ -578,11 +578,11 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) #if (SDL_VERSION_ATLEAST(1,2,10)) SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, video_config.waitvsync ? 1 : 0); #endif - + load_gl_lib(); // create the SDL surface (which creates the window in windowed mode) - sdl->sdlsurf = SDL_SetVideoMode(width, height, + sdl->sdlsurf = SDL_SetVideoMode(width, height, 0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags); if (!sdl->sdlsurf) @@ -590,7 +590,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) window->width = sdl->sdlsurf->w; window->height = sdl->sdlsurf->h; - + if ( (video_config.mode == VIDEO_MODE_OPENGL) && !(sdl->sdlsurf->flags & SDL_OPENGL) ) { mame_printf_error("OpenGL not supported on this driver!\n"); @@ -600,7 +600,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) // set the window title SDL_WM_SetCaption(window->title, "SDLMAME"); -#endif +#endif sdl->totalColors = window->totalColors; sdl->blittimer = 0; sdl->surf_w = 0; @@ -614,8 +614,8 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) sdl->texture_max_height = 64; /* load any GL function addresses - * this must be done here because we need a context - */ + * this must be done here because we need a context + */ loadgl_functions(); extstr = (char *)glGetString(GL_EXTENSIONS); @@ -712,7 +712,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) mame_printf_verbose("OpenGL: pixel buffers not supported\n"); } } - + if (strstr(extstr, "GL_EXT_framebuffer_object")) { sdl->usefbo = 1; @@ -728,7 +728,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) if (strstr(extstr, "GL_ARB_shader_objects") && strstr(extstr, "GL_ARB_shading_language_100") && strstr(extstr, "GL_ARB_vertex_shader") && - strstr(extstr, "GL_ARB_fragment_shader") + strstr(extstr, "GL_ARB_fragment_shader") ) { sdl->useglsl = video_config.glsl; @@ -763,7 +763,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) shown_video_info = 1; sdl->init_context = 0; - + return 0; } @@ -783,13 +783,13 @@ static void drawogl_window_resize(sdl_window_info *window, int width, int height #else SDL_FreeSurface(sdl->sdlsurf); - sdl->sdlsurf = SDL_SetVideoMode(width, height, 0, + sdl->sdlsurf = SDL_SetVideoMode(width, height, 0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags); window->width = sdl->sdlsurf->w; window->height = sdl->sdlsurf->h; #endif sdl->init_context = 1; - + } //============================================================ @@ -946,7 +946,7 @@ static void loadGLExtensions(sdl_window_info *window) } } - if ( sdl->usefbo && + if ( sdl->usefbo && ( !pfn_glIsFramebuffer || !pfn_glBindFramebuffer || !pfn_glDeleteFramebuffers || !pfn_glGenFramebuffers || !pfn_glCheckFramebufferStatus || !pfn_glFramebufferTexture2D )) @@ -1012,10 +1012,10 @@ static void loadGLExtensions(sdl_window_info *window) mame_printf_warning("OpenGL: FBO not supported\n"); } } - + if ( sdl->useglsl ) { - #ifdef GL_ARB_multitexture + #ifdef GL_ARB_multitexture pfn_glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glActiveTextureARB"); #else pfn_glActiveTexture = (PFNGLACTIVETEXTUREPROC) SDL_GL_GetProcAddress("glActiveTexture"); @@ -1041,8 +1041,8 @@ static void loadGLExtensions(sdl_window_info *window) { mame_printf_warning("OpenGL: GLSL supported, but shader instantiation failed - disabled\n"); } - } - } + } + } if ( sdl->useglsl ) { @@ -1083,13 +1083,13 @@ static void loadGLExtensions(sdl_window_info *window) glsl_shader_feature = GLSL_SHADER_FEAT_CUSTOM; if (_once) { - mame_printf_verbose("OpenGL: GLSL using mame bitmap shader filter %d: '%s'\n", + mame_printf_verbose("OpenGL: GLSL using mame bitmap shader filter %d: '%s'\n", sdl->glsl_program_num, video_config.glsl_shader_mamebm[i]); } sdl->glsl_program_mb2sc = sdl->glsl_program_num; // the last mame_bitmap (mb) shader does it. sdl->glsl_program_num++; } - } + } if ( video_config.glsl_shader_scrn_num > 0 && sdl->glsl_program_num==0 ) { @@ -1106,12 +1106,12 @@ static void loadGLExtensions(sdl_window_info *window) } else { if (_once) { - mame_printf_verbose("OpenGL: GLSL using screen bitmap shader filter %d: '%s'\n", + mame_printf_verbose("OpenGL: GLSL using screen bitmap shader filter %d: '%s'\n", sdl->glsl_program_num, video_config.glsl_shader_scrn[i]); } sdl->glsl_program_num++; } - } + } if ( 0==sdl->glsl_program_num && 0 <= video_config.glsl_filter && video_config.glsl_filter < GLSL_SHADER_FEAT_INT_NUMBER ) @@ -1122,7 +1122,7 @@ static void loadGLExtensions(sdl_window_info *window) if (_once) { - mame_printf_verbose("OpenGL: GLSL using shader filter '%s', idx: %d, num %d (vid filter: %d)\n", + mame_printf_verbose("OpenGL: GLSL using shader filter '%s', idx: %d, num %d (vid filter: %d)\n", glsl_shader_get_filter_name_mamebm(glsl_shader_feature), glsl_shader_feature, sdl->glsl_program_num, video_config.filter); } @@ -1212,7 +1212,7 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update) { loadGLExtensions(window); } - + sdl->surf_w=window->width; sdl->surf_h=window->height; @@ -1235,38 +1235,38 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update) glDisable(GL_LINE_SMOOTH); glDisable(GL_POINT_SMOOTH); } - + // enable blending glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); sdl->last_blendmode = BLENDMODE_ALPHA; - + // set lines and points just barely above normal size to get proper results glLineWidth(video_config.beamwidth); glPointSize(video_config.beamwidth); - + // set up a nice simple 2D coordinate system, so GL behaves exactly how we'd like. // // (0,0) (w,0) // |~~~~~~~~~| - // | | - // | | - // | | + // | | + // | | + // | | // |_________| // (0,h) (w,h) - + glViewport(0.0, 0.0, (GLsizei)window->width, (GLsizei)window->height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, (GLdouble)window->width, (GLdouble)window->height, 0.0, 0.0, -1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - + if ( ! sdl->initialized ) { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, sdl->texVerticex); // no VBO, since it's too volatile - + sdl->initialized = 1; } } @@ -1301,7 +1301,7 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update) sdl->last_hofs = hofs; sdl->last_vofs = vofs; - + osd_lock_acquire(window->primlist->lock); // now draw @@ -1312,9 +1312,9 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update) switch (prim->type) { /** - * Try to stay in one Begin/End block as long as possible, - * since entering and leaving one is most expensive.. - */ + * Try to stay in one Begin/End block as long as possible, + * since entering and leaving one is most expensive.. + */ case RENDER_PRIMITIVE_LINE: #if !USE_WIN32_STYLE_LINES // check if it's really a point @@ -1416,8 +1416,8 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update) if (a > 1.0) a = 1.0; glColor4f(r, g, b, a); -// texture = texture_update(window, prim, 0); -// if (texture) printf("line has texture!\n"); +// texture = texture_update(window, prim, 0); +// if (texture) printf("line has texture!\n"); // if we have a texture to use for the vectors, use it here #if 0 @@ -1716,7 +1716,7 @@ static void drawogl_window_destroy(sdl_window_info *window) //============================================================ // -// glBufferData to push a nocopy texture to the GPU is slower than TexSubImage2D, +// glBufferData to push a nocopy texture to the GPU is slower than TexSubImage2D, // so don't use PBO here // // we also don't want to use PBO's in the case of nocopy==TRUE, @@ -1733,14 +1733,14 @@ static void texture_compute_type_subroutine(sdl_info *sdl, const render_texinfo texture->type = TEXTURE_TYPE_PLAIN; texture->texTarget = (sdl->usetexturerect)?GL_TEXTURE_RECTANGLE_ARB:GL_TEXTURE_2D; texture->texpow2 = (sdl->usetexturerect)?0:sdl->texpoweroftwo; - } + } // currently glsl supports idx and rgb palette lookups, // no special quality scaling, so we could drop the prescale criteria below .. if ( texture->type == TEXTURE_TYPE_NONE && - sdl->useglsl && + sdl->useglsl && ( - texture->format==SDL_TEXFORMAT_PALETTE16 || // glsl idx16 lut + texture->format==SDL_TEXFORMAT_PALETTE16 || // glsl idx16 lut texture->format==SDL_TEXFORMAT_RGB32_PALETTED || // glsl rgb32 lut/direct texture->format==SDL_TEXFORMAT_RGB15_PALETTED // glsl rgb15 lut/direct ) && @@ -1750,13 +1750,13 @@ static void texture_compute_type_subroutine(sdl_info *sdl, const render_texinfo { texture->type = TEXTURE_TYPE_SHADER; texture->nocopy = TRUE; - texture->texTarget = GL_TEXTURE_2D; + texture->texTarget = GL_TEXTURE_2D; texture->texpow2 = sdl->texpoweroftwo; } // determine if we can skip the copy step // if this was not already decided by the shader condition above - if ( !texture->nocopy && + if ( !texture->nocopy && texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_EQUALS_DEST] && !texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_HAS_PALETTE] && texture->xprescale == 1 && texture->yprescale == 1 && @@ -1764,7 +1764,7 @@ static void texture_compute_type_subroutine(sdl_info *sdl, const render_texinfo texsource->rowpixels <= sdl->texture_max_width ) { texture->nocopy = TRUE; - } + } if( texture->type == TEXTURE_TYPE_NONE && sdl->usepbo && !texture->nocopy ) @@ -1773,7 +1773,7 @@ static void texture_compute_type_subroutine(sdl_info *sdl, const render_texinfo texture->type = TEXTURE_TYPE_DYNAMIC; texture->texTarget = (sdl->usetexturerect)?GL_TEXTURE_RECTANGLE_ARB:GL_TEXTURE_2D; texture->texpow2 = (sdl->usetexturerect)?0:sdl->texpoweroftwo; - } + } if( texture->type == TEXTURE_TYPE_NONE ) { @@ -1803,17 +1803,17 @@ INLINE int get_valid_pow2_value(int v, int needPow2) static void texture_compute_size_subroutine(sdl_window_info *window, texture_info *texture, UINT32 flags, UINT32 width, UINT32 height, - int* p_width, int* p_height, int* p_width_create, int* p_height_create) + int* p_width, int* p_height, int* p_width_create, int* p_height_create) { sdl_info *sdl = (sdl_info *) window->dxdata; int width_create; int height_create; - if ( texture->texpow2 ) + if ( texture->texpow2 ) { width_create = gl_round_to_pow2 (width); height_create = gl_round_to_pow2 (height); - } else if ( texture->type==TEXTURE_TYPE_SHADER ) + } else if ( texture->type==TEXTURE_TYPE_SHADER ) { /** * at least use a multiple of 8 for shader .. just in case @@ -1867,8 +1867,8 @@ static void texture_compute_size_type(sdl_window_info *window, const render_texi } texture_compute_type_subroutine(sdl, texsource, texture, flags); - - texture_compute_size_subroutine(window, texture, flags, texsource->width, texsource->height, + + texture_compute_size_subroutine(window, texture, flags, texsource->width, texsource->height, &finalwidth, &finalheight, &finalwidth_create, &finalheight_create); // if we added pixels for the border, and that just barely pushed us over, take it back @@ -1879,8 +1879,8 @@ static void texture_compute_size_type(sdl_window_info *window, const render_texi texture->borderpix = FALSE; texture_compute_type_subroutine(sdl, texsource, texture, flags); - - texture_compute_size_subroutine(window, texture, flags, texsource->width, texsource->height, + + texture_compute_size_subroutine(window, texture, flags, texsource->width, texsource->height, &finalwidth, &finalheight, &finalwidth_create, &finalheight_create); } @@ -1888,7 +1888,7 @@ static void texture_compute_size_type(sdl_window_info *window, const render_texi if (finalwidth_create > sdl->texture_max_width || finalheight_create > sdl->texture_max_height) { static int printed = FALSE; - if (!printed) + if (!printed) mame_printf_warning("Texture too big! (wanted: %dx%d, max is %dx%d)\n", finalwidth_create, finalheight_create, sdl->texture_max_width, sdl->texture_max_height); printed = TRUE; } @@ -1906,8 +1906,8 @@ static void texture_compute_size_type(sdl_window_info *window, const render_texi mame_printf_verbose("GL texture: copy %d, shader %d, dynamic %d, %dx%d %dx%d [%s, Equal: %d, Palette: %d,\n" " scale %dx%d, border %d, pitch %d,%d/%d], colors: %d, bytes/pix %d\n", !texture->nocopy, texture->type==TEXTURE_TYPE_SHADER, texture->type==TEXTURE_TYPE_DYNAMIC, - finalwidth, finalheight, finalwidth_create, finalheight_create, - texfmt_to_string[texture->format], + finalwidth, finalheight, finalwidth_create, finalheight_create, + texfmt_to_string[texture->format], (int)texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_EQUALS_DEST], (int)texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_HAS_PALETTE], texture->xprescale, texture->yprescale, @@ -1927,7 +1927,7 @@ static void texture_compute_size_type(sdl_window_info *window, const render_texi // texture_create //============================================================ -static int gl_checkFramebufferStatus(void) +static int gl_checkFramebufferStatus(void) { GLenum status; status=(GLenum)pfn_glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT); @@ -1955,7 +1955,7 @@ static int gl_checkFramebufferStatus(void) case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: mame_printf_error("GL FBO: incomplete,missing read buffer\n"); return -1; -#ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT +#ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: mame_printf_error("GL FBO: incomplete, duplicate attachment\n"); return -1; @@ -1977,7 +1977,7 @@ static int texture_fbo_create(UINT32 text_unit, UINT32 text_name, UINT32 fbo_nam glBindTexture(GL_TEXTURE_2D, text_name); { GLint _width, _height; - if ( gl_texture_check_size(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, + if ( gl_texture_check_size(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, &_width, &_height, 1) ) { mame_printf_error("cannot create fbo texture, req: %dx%d, avail: %dx%d - bail out\n", @@ -1985,7 +1985,7 @@ static int texture_fbo_create(UINT32 text_unit, UINT32 text_name, UINT32 fbo_nam return -1; } - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL ); } // non-screen textures will never be filtered @@ -1995,7 +1995,7 @@ static int texture_fbo_create(UINT32 text_unit, UINT32 text_name, UINT32 fbo_nam glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - pfn_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + pfn_glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, text_name, 0); if ( gl_checkFramebufferStatus() ) @@ -2007,7 +2007,7 @@ static int texture_fbo_create(UINT32 text_unit, UINT32 text_name, UINT32 fbo_nam return 0; } -static int texture_shader_create(sdl_window_info *window, +static int texture_shader_create(sdl_window_info *window, const render_texinfo *texsource, texture_info *texture, UINT32 flags) { sdl_info *sdl = (sdl_info *) window->dxdata; @@ -2050,18 +2050,18 @@ static int texture_shader_create(sdl_window_info *window, } /** - * We experience some GLSL LUT calculation inaccuracy on some GL drivers. - * while using the correct lut calculations. - * This error is due to the color index value to GLSL/texture passing process: - * mame:uint16_t -> OpenGL: GLfloat(alpha texture) -> GLSL:uint16_t (value regeneration) - * The latter inaccurate uint16_t value regeneration is buggy on some drivers/cards, - * therefor we always widen the lut size to pow2, - * and shape it equaly into 2D space (max texture size restriction). - * This is a practical GL driver workaround to minimize the chance for - * floating point arithmetic errors in the GLSL engine. - * - * Shape the lut texture to achieve texture max size compliance and equal 2D partitioning - */ + * We experience some GLSL LUT calculation inaccuracy on some GL drivers. + * while using the correct lut calculations. + * This error is due to the color index value to GLSL/texture passing process: + * mame:uint16_t -> OpenGL: GLfloat(alpha texture) -> GLSL:uint16_t (value regeneration) + * The latter inaccurate uint16_t value regeneration is buggy on some drivers/cards, + * therefor we always widen the lut size to pow2, + * and shape it equaly into 2D space (max texture size restriction). + * This is a practical GL driver workaround to minimize the chance for + * floating point arithmetic errors in the GLSL engine. + * + * Shape the lut texture to achieve texture max size compliance and equal 2D partitioning + */ lut_texture_width = sqrt((double)(texture->lut_table_width)); lut_texture_width = get_valid_pow2_value (lut_texture_width, 1); @@ -2075,9 +2075,9 @@ static int texture_shader_create(sdl_window_info *window, texture->lut_table_width = lut_texture_width; /** - * always use pow2 for LUT, to minimize the chance for floating point arithmetic errors - * (->buggy GLSL engine) - */ + * always use pow2 for LUT, to minimize the chance for floating point arithmetic errors + * (->buggy GLSL engine) + */ lut_table_height_pow2 = get_valid_pow2_value (texture->lut_table_height, 1 /* texture->texpow2 */); lut_table_width_pow2 = get_valid_pow2_value (texture->lut_table_width, 1 /* texture->texpow2 */); @@ -2104,7 +2104,7 @@ static int texture_shader_create(sdl_window_info *window, // multipass mode assert(sdl->usefbo); - // GL_TEXTURE3 GLSL Uniforms + // GL_TEXTURE3 GLSL Uniforms texture->mpass_dest_idx = 0; texture->mpass_textureunit[0] = GL_TEXTURE3; texture->mpass_textureunit[1] = GL_TEXTURE2; @@ -2192,7 +2192,7 @@ static int texture_shader_create(sdl_window_info *window, for (i=0; i<2; i++) { - if ( texture_fbo_create(texture->mpass_textureunit[i], + if ( texture_fbo_create(texture->mpass_textureunit[i], texture->mpass_texture_mamebm[i], texture->mpass_fbo_mamebm[i], texture->rawwidth_create, texture->rawheight_create) ) @@ -2216,7 +2216,7 @@ static int texture_shader_create(sdl_window_info *window, for (i=0; i<2; i++) { - if ( texture_fbo_create(texture->mpass_textureunit[i], + if ( texture_fbo_create(texture->mpass_textureunit[i], texture->mpass_texture_scrn[i], texture->mpass_fbo_scrn[i], surf_w_pow2, surf_h_pow2) ) @@ -2231,7 +2231,7 @@ static int texture_shader_create(sdl_window_info *window, if ( !(sdl->glsl_vid_attributes && texture->format!=SDL_TEXFORMAT_PALETTE16) ) { - // GL_TEXTURE1 + // GL_TEXTURE1 glGenTextures(1, (GLuint *)&texture->lut_texture); pfn_glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texture->lut_texture); @@ -2273,7 +2273,7 @@ static int texture_shader_create(sdl_window_info *window, assert ( texture->lut_texture ); } - // GL_TEXTURE0 + // GL_TEXTURE0 // get a name for this texture glGenTextures(1, (GLuint *)&texture->texture); pfn_glActiveTexture(GL_TEXTURE0); @@ -2286,10 +2286,10 @@ static int texture_shader_create(sdl_window_info *window, UINT32 * dummy = NULL; GLint _width, _height; if ( gl_texture_check_size(GL_TEXTURE_2D, 0, texture->texProperties[SDL_TEXFORMAT_INTERNAL], - texture->rawwidth_create, texture->rawheight_create, + texture->rawwidth_create, texture->rawheight_create, 0, - texture->texProperties[SDL_TEXFORMAT_FORMAT], - texture->texProperties[SDL_TEXFORMAT_TYPE], + texture->texProperties[SDL_TEXFORMAT_FORMAT], + texture->texProperties[SDL_TEXFORMAT_TYPE], &_width, &_height, 1) ) { mame_printf_error("cannot create bitmap texture, req: %dx%d, avail: %dx%d - bail out\n", @@ -2301,10 +2301,10 @@ static int texture_shader_create(sdl_window_info *window, texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]); memset(dummy, 0, texture->rawwidth_create * texture->rawheight_create * texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]); - glTexImage2D(GL_TEXTURE_2D, 0, texture->texProperties[SDL_TEXFORMAT_INTERNAL], - texture->rawwidth_create, texture->rawheight_create, + glTexImage2D(GL_TEXTURE_2D, 0, texture->texProperties[SDL_TEXFORMAT_INTERNAL], + texture->rawwidth_create, texture->rawheight_create, 0, - texture->texProperties[SDL_TEXFORMAT_FORMAT], + texture->texProperties[SDL_TEXFORMAT_FORMAT], texture->texProperties[SDL_TEXFORMAT_TYPE], dummy); glFinish(); // should not be necessary, .. but make sure we won't access the memory after free free(dummy); @@ -2349,7 +2349,7 @@ static int texture_shader_create(sdl_window_info *window, dummy = (UINT32 *) malloc(texture->rawwidth_create * texture->rawheight_create * sizeof(UINT16)); memset(dummy, 0, texture->rawwidth_create * texture->rawheight_create * sizeof(UINT16)); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA16, - texture->rawwidth_create, texture->rawheight_create, + texture->rawwidth_create, texture->rawheight_create, 0, GL_ALPHA, GL_UNSIGNED_SHORT, dummy); glFinish(); // should not be necessary, .. but make sure we won't access the memory after free @@ -2377,7 +2377,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf { sdl_info *sdl = (sdl_info *) window->dxdata; texture_info *texture; - + // allocate a new texture texture = (texture_info *) malloc(sizeof(*texture)); memset(texture, 0, sizeof(*texture)); @@ -2399,15 +2399,15 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf } // set the texture_format - // - // src/emu/validity.c:validate_display() states, + // + // src/emu/validity.c:validate_display() states, // an emulated driver can only produce // BITMAP_FORMAT_INDEXED16, BITMAP_FORMAT_RGB15 and BITMAP_FORMAT_RGB32 // where only the first original paletted. // // other paletted formats, i.e.: // SDL_TEXFORMAT_RGB32_PALETTED, SDL_TEXFORMAT_RGB15_PALETTED and SDL_TEXFORMAT_YUY16_PALETTED - // add features like brightness etc by the mame core + // add features like brightness etc by the mame core // // all palette lookup may be implemented using shaders later on .. // that's why we keep the EQUAL flag TRUE, for all original true color bitmaps. @@ -2463,8 +2463,8 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf free(texture); return NULL; } - } - else + } + else { // get a name for this texture glGenTextures(1, (GLuint *)&texture->texture); @@ -2473,12 +2473,12 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf // make sure we're operating on *this* texture glBindTexture(texture->texTarget, texture->texture); - + // this doesn't actually upload, it just sets up the PBO's parameters - glTexImage2D(texture->texTarget, 0, texture->texProperties[SDL_TEXFORMAT_INTERNAL], - texture->rawwidth_create, texture->rawheight_create, - texture->borderpix ? 1 : 0, - texture->texProperties[SDL_TEXFORMAT_FORMAT], + glTexImage2D(texture->texTarget, 0, texture->texProperties[SDL_TEXFORMAT_INTERNAL], + texture->rawwidth_create, texture->rawheight_create, + texture->borderpix ? 1 : 0, + texture->texProperties[SDL_TEXFORMAT_FORMAT], texture->texProperties[SDL_TEXFORMAT_TYPE], NULL); if ((PRIMFLAG_GET_SCREENTEX(flags)) && video_config.filter) @@ -2524,10 +2524,10 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf pfn_glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, texture->pbo); // set up the PBO dimension, .. - pfn_glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, + pfn_glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, texture->rawwidth * texture->rawheight * texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE], NULL, GL_STREAM_DRAW); - } + } if ( !texture->nocopy && texture->type!=TEXTURE_TYPE_DYNAMIC ) { @@ -2579,9 +2579,9 @@ static void texture_set_data(texture_info *texture, const render_texinfo *texsou // always fill non-wrapping textures with an extra pixel on the top if (texture->borderpix) { - memset(texture->data, 0, + memset(texture->data, 0, (texsource->width * texture->xprescale + 2) * texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]); - } + } // when nescesarry copy (and convert) the data if (!texture->nocopy) @@ -2593,8 +2593,8 @@ static void texture_set_data(texture_info *texture, const render_texinfo *texsou // always fill non-wrapping textures with an extra pixel on the bottom if (texture->borderpix) { - memset((UINT8 *)texture->data + - (texsource->height + 1) * texture->rawwidth * texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE], + memset((UINT8 *)texture->data + + (texsource->height + 1) * texture->rawwidth * texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE], 0, (texsource->width * texture->xprescale + 2) * texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]); } @@ -2617,19 +2617,19 @@ static void texture_set_data(texture_info *texture, const render_texinfo *texsou glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->texinfo.rowpixels); - // and upload the image + // and upload the image if(texture->format!=SDL_TEXFORMAT_PALETTE16) { - glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, - texture->texProperties[SDL_TEXFORMAT_FORMAT], + glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, + texture->texProperties[SDL_TEXFORMAT_FORMAT], texture->texProperties[SDL_TEXFORMAT_TYPE], texture->data); } else { - glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, + glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, GL_ALPHA, GL_UNSIGNED_SHORT, texture->data); } - } + } else if ( texture->type == TEXTURE_TYPE_DYNAMIC ) { glBindTexture(texture->texTarget, texture->texture); @@ -2640,10 +2640,10 @@ static void texture_set_data(texture_info *texture, const render_texinfo *texsou pfn_glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB); // kick off the DMA - glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, - texture->texProperties[SDL_TEXFORMAT_FORMAT], + glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, + texture->texProperties[SDL_TEXFORMAT_FORMAT], texture->texProperties[SDL_TEXFORMAT_TYPE], NULL); - } + } else { glBindTexture(texture->texTarget, texture->texture); @@ -2654,9 +2654,9 @@ static void texture_set_data(texture_info *texture, const render_texinfo *texsou else glPixelStorei(GL_UNPACK_ROW_LENGTH, texture->rawwidth); - // and upload the image - glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, - texture->texProperties[SDL_TEXFORMAT_FORMAT], + // and upload the image + glTexSubImage2D(texture->texTarget, 0, 0, 0, texture->rawwidth, texture->rawheight, + texture->texProperties[SDL_TEXFORMAT_FORMAT], texture->texProperties[SDL_TEXFORMAT_TYPE], texture->data); } } @@ -2688,7 +2688,7 @@ static texture_info *texture_find(sdl_info *sdl, const render_primitive *prim) // texture_update //============================================================ -static void texture_coord_update(sdl_window_info *window, +static void texture_coord_update(sdl_window_info *window, texture_info *texture, const render_primitive *prim, int shaderIdx) { sdl_info *sdl = (sdl_info *) window->dxdata; @@ -2813,7 +2813,7 @@ static void texture_mpass_flip(sdl_info *sdl, texture_info *texture, int shaderI if ( shaderIdx==0 ) { - glPushAttrib(GL_VIEWPORT_BIT); + glPushAttrib(GL_VIEWPORT_BIT); GL_CHECK_ERROR_NORMAL(); glViewport(0.0, 0.0, (GLsizei)texture->rawwidth, (GLsizei)texture->rawheight); } @@ -2825,7 +2825,7 @@ static void texture_mpass_flip(sdl_info *sdl, texture_info *texture, int shaderI } glClear(GL_COLOR_BUFFER_BIT); // make sure the whole texture is redrawn .. } - else + else { glBindTexture(texture->texTarget, 0); pfn_glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); @@ -2859,7 +2859,7 @@ static void texture_shader_update(sdl_window_info *window, texture_info *texture { if (scrnum == window->start_viewscreen) { - container = render_container_get_screen(screen); + container = render_container_get_screen(screen); } scrnum++; @@ -2902,9 +2902,9 @@ static texture_info * texture_update(sdl_window_info *window, const render_primi // if we didn't find one, create a new texture if (texture == NULL && prim->texture.base != NULL) { - texture = texture_create(window, &prim->texture, prim->flags); + texture = texture_create(window, &prim->texture, prim->flags); - } + } else if (texture != NULL) { if ( texture->type == TEXTURE_TYPE_SHADER ) @@ -2914,11 +2914,11 @@ static texture_info * texture_update(sdl_window_info *window, const render_primi else if ( texture->type == TEXTURE_TYPE_DYNAMIC ) { assert ( sdl->usepbo ) ; - pfn_glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, texture->pbo); + pfn_glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, texture->pbo); glEnable(texture->texTarget); - } - else - { + } + else + { glEnable(texture->texTarget); } } @@ -2944,7 +2944,7 @@ static texture_info * texture_update(sdl_window_info *window, const render_primi texture_set_data(texture, &prim->texture); texBound=1; } - } + } if (!texBound) { glBindTexture(texture->texTarget, texture->texture); @@ -2957,13 +2957,13 @@ static texture_info * texture_update(sdl_window_info *window, const render_primi pfn_glBindBuffer( GL_ARRAY_BUFFER_ARB, texture->texCoordBufferName ); // Load The Data pfn_glBufferSubData( GL_ARRAY_BUFFER_ARB, 0, 4*2*sizeof(GLfloat), texture->texCoord ); - glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL ); // we are using ARB VBO buffers + glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL ); // we are using ARB VBO buffers } else { glTexCoordPointer(2, GL_FLOAT, 0, texture->texCoord); } - } + } return texture; } @@ -2974,7 +2974,7 @@ static void texture_disable(sdl_info *sdl, texture_info * texture) { assert ( sdl->useglsl ); pfn_glUseProgramObjectARB(0); // back to fixed function pipeline - } else if ( texture->type == TEXTURE_TYPE_DYNAMIC ) + } else if ( texture->type == TEXTURE_TYPE_DYNAMIC ) { pfn_glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0); glDisable(texture->texTarget); @@ -3036,11 +3036,11 @@ static void drawogl_destroy_all_textures(sdl_window_info *window) #if (SDL_VERSION_ATLEAST(1,3,0)) SDL_GL_MakeCurrent(window->window_id, sdl->gl_context_id); #endif - + if(window->primlist && window->primlist->lock) - { - lock=TRUE; - osd_lock_acquire(window->primlist->lock); + { + lock=TRUE; + osd_lock_acquire(window->primlist->lock); } texture = sdl->texlist; @@ -3059,20 +3059,20 @@ static void drawogl_destroy_all_textures(sdl_window_info *window) pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) ); texture->texCoordBufferName=0; } - + if(sdl->usepbo && texture->pbo) { pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) ); texture->pbo=0; } - + if( sdl->glsl_program_num > 1 ) { assert(sdl->usefbo); pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]); glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]); } - + if ( sdl->glsl_program_mb2sc < sdl->glsl_program_num - 1 ) { assert(sdl->usefbo); @@ -3097,10 +3097,10 @@ static void drawogl_destroy_all_textures(sdl_window_info *window) if ( sdl->useglsl ) { - glsl_shader_free(sdl->glsl); + glsl_shader_free(sdl->glsl); sdl->glsl = NULL; } - + sdl->initialized = 0; if (lock) diff --git a/src/osd/sdl/drawsdl.c b/src/osd/sdl/drawsdl.c index 230715f40de..ff22e49c1d1 100644 --- a/src/osd/sdl/drawsdl.c +++ b/src/osd/sdl/drawsdl.c @@ -1,5 +1,5 @@ //============================================================ -// +// // drawsdl.c - SDL software and OpenGL implementation // // Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. @@ -42,7 +42,7 @@ typedef struct _sdl_scale_mode sdl_scale_mode; typedef struct _sdl_info sdl_info; struct _sdl_info { - INT32 blittimer; + INT32 blittimer; UINT32 extra_flags; #if (SDL_VERSION_ATLEAST(1,3,0)) @@ -54,12 +54,12 @@ struct _sdl_info #endif // YUV overlay - UINT32 *yuv_lookup; + UINT32 *yuv_lookup; UINT16 *yuv_bitmap; - - // if we leave scaling to SDL and the underlying driver, this + + // if we leave scaling to SDL and the underlying driver, this // is the render_target_width/height to use - + int hw_scale_width; int hw_scale_height; int last_hofs; @@ -68,7 +68,7 @@ struct _sdl_info int old_blitheight; // shortcut to scale mode info - + const sdl_scale_mode *scale_mode; }; @@ -163,7 +163,7 @@ static const sdl_scale_mode scale_modes[] = const char *drawsdl_scale_mode_str(int index) { const sdl_scale_mode *sm = scale_modes; - + while (index>0) { if (sm->name == NULL) @@ -178,7 +178,7 @@ int drawsdl_scale_mode(const char *s) { const sdl_scale_mode *sm = scale_modes; int index; - + index = 0; while (sm->name != NULL) { @@ -253,17 +253,17 @@ static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight const sdl_scale_mode *sdl_sm = sdl->scale_mode; SDL_DisplayMode mode; UINT32 fmt; - + // Determine preferred pixelformat and set up yuv if necessary SDL_GetCurrentDisplayMode(&mode); - + if (sdl->yuv_bitmap) { global_free(sdl->yuv_bitmap); - sdl->yuv_bitmap = NULL; + sdl->yuv_bitmap = NULL; } - if (sdl_sm->is_scale) + if (sdl_sm->is_scale) { render_target_get_minimum_size(window->target, &sdl->hw_scale_width, &sdl->hw_scale_height); if (video_config.prescale) @@ -282,13 +282,13 @@ static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight { int w = sdl->hw_scale_width * sdl_sm->mult_w; int h = sdl->hw_scale_height * sdl_sm->mult_h; - + sdl->texture_id = SDL_CreateTexture(fmt, SDL_TEXTUREACCESS_STREAMING, w, h); - + } else { - sdl->texture_id = SDL_CreateTexture(fmt, SDL_TEXTUREACCESS_STREAMING, + sdl->texture_id = SDL_CreateTexture(fmt, SDL_TEXTUREACCESS_STREAMING, tempwidth, tempheight); } @@ -315,18 +315,18 @@ static void yuv_overlay_init(sdl_window_info *window) minimum_width *= video_config.prescale; minimum_height *= video_config.prescale; } - + if (sdl->yuvsurf != NULL) { SDL_FreeYUVOverlay(sdl->yuvsurf); sdl->yuvsurf = NULL; } - + if (sdl->yuv_bitmap != NULL) { global_free(sdl->yuv_bitmap); } - + mame_printf_verbose("SDL: Creating %d x %d YUV-Overlay ...\n", minimum_width, minimum_height); sdl->yuv_bitmap = global_alloc_array(UINT16, minimum_width*minimum_height); @@ -338,7 +338,7 @@ static void yuv_overlay_init(sdl_window_info *window) mame_printf_error("SDL: Couldn't create SDL_yuv_overlay: %s\n", SDL_GetError()); //return 1; } - + sdl->hw_scale_width = minimum_width; sdl->hw_scale_height = minimum_height; @@ -363,7 +363,7 @@ static void drawsdl_show_info(sdl_window_info *window, struct SDL_RendererInfo * static struct { int flag; const char *name; - } rflist[] = + } rflist[] = { RF_ENTRY(SDL_RENDERER_SINGLEBUFFER), RF_ENTRY(SDL_RENDERER_PRESENTCOPY), @@ -375,7 +375,7 @@ static void drawsdl_show_info(sdl_window_info *window, struct SDL_RendererInfo * {-1, NULL} }; int i; - + mame_printf_verbose("window: using renderer %s\n", render_info->name ? render_info->name : "<unknown>"); for (i = 0; rflist[i].name != NULL; i++) if (render_info->flags & rflist[i].flag) @@ -396,17 +396,17 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height) memset(sdl, 0, sizeof(sdl_info)); window->dxdata = sdl; - + sdl->scale_mode = &scale_modes[window->scale_mode]; - + #if (SDL_VERSION_ATLEAST(1,3,0)) - sdl->extra_flags = (window->fullscreen ? + sdl->extra_flags = (window->fullscreen ? SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_INPUT_GRABBED : SDL_WINDOW_RESIZABLE); SDL_SelectVideoDisplay(window->monitor->handle); - if (window->fullscreen && video_config.switchres) + if (window->fullscreen && video_config.switchres) { SDL_DisplayMode mode; SDL_GetCurrentDisplayMode(&mode); @@ -418,45 +418,45 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height) } else SDL_SetWindowDisplayMode(window->window_id, NULL); // Use desktop - + window->window_id = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, sdl->extra_flags); SDL_ShowWindow(window->window_id); - + SDL_SetWindowFullscreen(window->window_id, window->fullscreen); - SDL_GetWindowSize(window->window_id, &window->width, &window->height); + SDL_GetWindowSize(window->window_id, &window->width, &window->height); SDL_RaiseWindow(window->window_id); - + /* FIXME: Bug in SDL 1.3 */ if (window->fullscreen) SDL_SetWindowGrab(window->window_id, 1); // create a texture - - if (video_config.waitvsync) + + if (video_config.waitvsync) SDL_CreateRenderer(window->window_id, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC); else SDL_CreateRenderer(window->window_id, -1, SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD); - + SDL_SelectRenderer(window->window_id); - + { struct SDL_RendererInfo render_info; SDL_GetRendererInfo(&render_info); - + drawsdl_show_info(window, &render_info); // Check scale mode - + if (sdl->scale_mode->pixel_format) { int i; int found = 0; - + for (i=0; i < render_info.num_texture_formats; i++) if (sdl->scale_mode->pixel_format == render_info.texture_formats[i]) found = 1; - + if (!found) { mame_printf_verbose("window: Scale mode %s not supported! Using default.\n", sdl->scale_mode->name); @@ -465,14 +465,14 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height) } } } - + setup_texture(window, width, height); #else sdl->extra_flags = (window->fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE); sdl->extra_flags |= sdl->scale_mode->extra_flags; - sdl->sdlsurf = SDL_SetVideoMode(width, height, + sdl->sdlsurf = SDL_SetVideoMode(width, height, 0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags); if (!sdl->sdlsurf) @@ -480,7 +480,7 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height) window->width = sdl->sdlsurf->w; window->height = sdl->sdlsurf->h; - + if (sdl->scale_mode->is_yuv) yuv_overlay_init(window); @@ -489,7 +489,7 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height) #endif sdl->yuv_lookup = NULL; sdl->blittimer = 0; - + drawsdl_yuv_init(sdl); return 0; } @@ -516,7 +516,7 @@ static void drawsdl_window_resize(sdl_window_info *window, int width, int height SDL_FreeSurface(sdl->sdlsurf); //printf("SetVideoMode %d %d\n", wp->resize_new_width, wp->resize_new_height); - sdl->sdlsurf = SDL_SetVideoMode(width, height, 0, + sdl->sdlsurf = SDL_SetVideoMode(width, height, 0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags); window->width = sdl->sdlsurf->w; window->height = sdl->sdlsurf->h; @@ -525,7 +525,7 @@ static void drawsdl_window_resize(sdl_window_info *window, int width, int height { yuv_overlay_init(window); } - + #endif } @@ -583,7 +583,7 @@ static void drawsdl_window_destroy(sdl_window_info *window) static void drawsdl_window_clear(sdl_window_info *window) { sdl_info *sdl = (sdl_info *) window->dxdata; - + sdl->blittimer = 3; } @@ -618,7 +618,7 @@ static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, in static const render_primitive_list *drawsdl_window_get_primitives(sdl_window_info *window) { sdl_info *sdl = (sdl_info *) window->dxdata; - + if ((!window->fullscreen) || (video_config.switchres)) { sdlwindow_blit_surface_size(window, window->width, window->height); @@ -665,7 +665,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) gmask = sdl->sdlsurf->format->Gmask; bmask = sdl->sdlsurf->format->Bmask; amask = sdl->sdlsurf->format->Amask; - + if (window->blitwidth != sdl->old_blitwidth || window->blitheight != sdl->old_blitheight) { if (sdl->scale_mode->is_yuv) @@ -684,7 +684,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) sdl->blittimer--; } - + if (sdl->scale_mode->is_yuv) { SDL_LockYUVOverlay(sdl->yuvsurf); @@ -704,11 +704,11 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) sdl->old_blitheight = window->blitheight; sdl->blittimer = 3; } - + { Uint32 format; int access, w, h; - + SDL_QueryTexture(sdl->texture_id, &format, &access, &w, &h); SDL_PixelFormatEnumToMasks(format, &bpp, &rmask, &gmask, &bmask, &amask); bpp = bpp / 8; /* convert to bytes per pixels */ @@ -723,7 +723,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) //SDL_RenderFill(0,0,0,0 /*255*/,NULL); sdl->blittimer--; } - + SDL_LockTexture(sdl->texture_id, NULL, 1, (void **) &surfptr, &pitch); #endif @@ -749,7 +749,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) // do not crash if the window's smaller than the blit area if (blitheight > ch) { - blitheight = ch; + blitheight = ch; } else if (video_config.centerv) { @@ -758,7 +758,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) if (blitwidth > cw) { - blitwidth = cw; + blitwidth = cw; } else if (video_config.centerh) { @@ -767,14 +767,14 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) sdl->last_hofs = hofs; sdl->last_vofs = vofs; - + osd_lock_acquire(window->primlist->lock); // render to it if (!sdl->scale_mode->is_yuv) { int mamewidth, mameheight; - + if (!sdl->scale_mode->is_scale) { mamewidth = blitwidth; @@ -814,7 +814,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) mame_printf_error("SDL: ERROR! Unknown video mode: R=%08X G=%08X B=%08X\n", rmask, gmask, bmask); break; } - } + } else { assert (sdl->yuv_bitmap != NULL); @@ -938,7 +938,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) (u) = (( -4878*(r) - 9578*(g) + 14456*(b) + 4210688) >> 15); \ (v) = (( 14456*(r) - 12105*(g) - 2351*(b) + 4210688) >> 15) -#ifdef LSB_FIRST +#ifdef LSB_FIRST #define Y1MASK 0x000000FF #define UMASK 0x0000FF00 #define Y2MASK 0x00FF0000 @@ -961,7 +961,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) #define YMASK (Y1MASK|Y2MASK) #define UVMASK (UMASK|VMASK) -static void yuv_lookup_set(sdl_info *sdl, unsigned int pen, unsigned char red, +static void yuv_lookup_set(sdl_info *sdl, unsigned int pen, unsigned char red, unsigned char green, unsigned char blue) { UINT32 y,u,v; @@ -969,7 +969,7 @@ static void yuv_lookup_set(sdl_info *sdl, unsigned int pen, unsigned char red, RGB2YUV(red,green,blue,y,u,v); /* Storing this data in YUYV order simplifies using the data for - YUY2, both with and without smoothing... */ + YUY2, both with and without smoothing... */ sdl->yuv_lookup[pen]=(y<<Y1SHIFT)|(u<<USHIFT)|(y<<Y2SHIFT)|(v<<VSHIFT); } @@ -983,7 +983,7 @@ static void drawsdl_yuv_init(sdl_info *sdl) for (b = 0; b < 32; b++) { int idx = (r << 10) | (g << 5) | b; - yuv_lookup_set(sdl, idx, + yuv_lookup_set(sdl, idx, (r << 3) | (r >> 2), (g << 3) | (g >> 2), (b << 3) | (b >> 2)); @@ -996,16 +996,16 @@ static void yuv_RGB_to_YV12(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch UINT8 *dest_y; UINT8 *dest_u; UINT8 *dest_v; - UINT16 *src; + UINT16 *src; UINT16 *src2; UINT32 *lookup = sdl->yuv_lookup; UINT8 *pixels[3]; int u1,v1,y1,u2,v2,y2,u3,v3,y3,u4,v4,y4; /* 12 */ - + pixels[0] = ptr; pixels[1] = ptr + pitch * sdl->hw_scale_height; pixels[2] = pixels[1] + pitch * sdl->hw_scale_height / 4; - + for(y=0;y<sdl->hw_scale_height;y+=2) { src=bitmap + (y * sdl->hw_scale_width) ; @@ -1044,13 +1044,13 @@ static void yuv_RGB_to_YV12(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch dest_u[x>>1] = (u1+u2+u3+u4)/4; dest_v[x>>1] = (v1+v2+v3+v4)/4; - + } } } static void yuv_RGB_to_YV12X2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch) -{ +{ /* this one is used when scale==2 */ unsigned int x,y; UINT16 *dest_y; @@ -1087,7 +1087,7 @@ static void yuv_RGB_to_YV12X2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pit } static void yuv_RGB_to_YUY2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch) -{ +{ /* this one is used when scale==2 */ unsigned int y; UINT32 *dest; @@ -1116,7 +1116,7 @@ static void yuv_RGB_to_YUY2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch } static void yuv_RGB_to_YUY2X2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch) -{ +{ /* this one is used when scale==2 */ unsigned int y; UINT32 *dest; diff --git a/src/osd/sdl/dview.c b/src/osd/sdl/dview.c index 43991824706..37b917150ff 100644 --- a/src/osd/sdl/dview.c +++ b/src/osd/sdl/dview.c @@ -104,9 +104,9 @@ static void dview_hadj_changed(GtkAdjustment *adj, DView *dv) debug_view_xy pos; UINT32 v = (UINT32)(adj->value); - pos = debug_view_get_visible_position(dv->dw); + pos = debug_view_get_visible_position(dv->dw); - if (v != pos.x) + if (v != pos.x) { pos.x = v; debug_view_set_visible_position(dv->dw, pos); @@ -119,9 +119,9 @@ static void dview_vadj_changed(GtkAdjustment *adj, DView *dv) debug_view_xy pos; UINT32 v = (UINT32)(adj->value); - pos = debug_view_get_visible_position(dv->dw); + pos = debug_view_get_visible_position(dv->dw); - if (v != pos.y) + if (v != pos.y) { pos.y = v; debug_view_set_visible_position(dv->dw, pos); @@ -147,7 +147,7 @@ static void dview_realize(GtkWidget *wdv) attributes.visual = gtk_widget_get_visual(wdv); attributes.colormap = gtk_widget_get_colormap(wdv); attributes.event_mask = gtk_widget_get_events(wdv) | GDK_EXPOSURE_MASK; - + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; wdv->window = gdk_window_new(gtk_widget_get_parent_window(wdv), &attributes, attributes_mask); @@ -166,7 +166,7 @@ static void dview_size_allocate(GtkWidget *wdv, GtkAllocation *allocation) int ovs = dv->vs; debug_view_xy size, pos, col, vsize; - pos = debug_view_get_visible_position(dv->dw); + pos = debug_view_get_visible_position(dv->dw); size = debug_view_get_total_size(dv->dw); dv->tr = size.y; @@ -210,7 +210,7 @@ static void dview_size_allocate(GtkWidget *wdv, GtkAllocation *allocation) vsize.x = size.x-pos.x; } - debug_view_set_visible_position(dv->dw, pos); + debug_view_set_visible_position(dv->dw, pos); debug_view_set_visible_size(dv->dw, vsize); if(GTK_WIDGET_REALIZED(wdv)) @@ -240,7 +240,7 @@ static void dview_size_allocate(GtkWidget *wdv, GtkAllocation *allocation) dv->hadj->page_increment = span; dv->hadj->page_size = span; gtk_adjustment_changed(dv->hadj); - debug_view_set_visible_position(dv->dw, pos); + debug_view_set_visible_position(dv->dw, pos); } else { if(ohs) gtk_widget_hide(dv->hscrollbar); @@ -268,7 +268,7 @@ static void dview_size_allocate(GtkWidget *wdv, GtkAllocation *allocation) dv->vadj->page_increment = span; dv->vadj->page_size = span; gtk_adjustment_changed(dv->vadj); - debug_view_set_visible_position(dv->dw, pos); + debug_view_set_visible_position(dv->dw, pos); } else { if(ovs) gtk_widget_hide(dv->vscrollbar); @@ -334,7 +334,7 @@ static void dview_class_init(DViewClass *dvc) if(!dvc->fixedfont) dvc->fixedfont = pango_font_description_from_string("Monospace 10"); - + if(!dvc->fixedfont) { mame_printf_error("Couldn't find a monospace font, aborting\n"); abort(); @@ -357,7 +357,7 @@ static void dview_init(DView *dv) if(!dvc->fixedfont_width) { PangoFontMetrics *metrics; metrics = pango_context_get_metrics(gtk_widget_get_pango_context(GTK_WIDGET(dv)), dvc->fixedfont, 0); - + dvc->fixedfont_width = PANGO_PIXELS(pango_font_metrics_get_approximate_char_width(metrics)); dvc->fixedfont_height = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics) + pango_font_metrics_get_descent(metrics)); diff --git a/src/osd/sdl/gl_shader_mgr.c b/src/osd/sdl/gl_shader_mgr.c index 0707ed47656..fa0915c3ab1 100644 --- a/src/osd/sdl/gl_shader_mgr.c +++ b/src/osd/sdl/gl_shader_mgr.c @@ -75,9 +75,9 @@ static const char * glsl_mamebm_filter_names [GLSL_SHADER_FEAT_MAX_NUMBER] = static GLhandleARB glsl_mamebm_programs [GLSL_SHADER_TYPE_NUMBER][GLSL_SHADER_FEAT_MAX_NUMBER+9] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* idx16 lut: plain, bilinear, custom0-9, .. */ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 lut: plain, bilinear, custom0-9, .. */ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 dir: plain, bilinear, custom0-9, .. */ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* idx16 lut: plain, bilinear, custom0-9, .. */ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 lut: plain, bilinear, custom0-9, .. */ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 dir: plain, bilinear, custom0-9, .. */ }; /** @@ -85,31 +85,31 @@ static GLhandleARB glsl_mamebm_programs [GLSL_SHADER_TYPE_NUMBER][GLSL_SHADER_FE */ static int glsl_mamebm_fsh2vsh[GLSL_SHADER_FEAT_MAX_NUMBER] = { - 0, // plain -> general - 0, // bilinear -> general + 0, // plain -> general + 0, // bilinear -> general 1, // custom -> custom }; -static GLhandleARB glsl_mamebm_vsh_shader[GLSL_VERTEX_SHADER_MAX_NUMBER+9] = +static GLhandleARB glsl_mamebm_vsh_shader[GLSL_VERTEX_SHADER_MAX_NUMBER+9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* general, custom0-9 */ static GLhandleARB glsl_mamebm_fsh_shader [GLSL_SHADER_TYPE_NUMBER][GLSL_SHADER_FEAT_MAX_NUMBER+9] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* idx16 lut: plain, bilinear, custom0-9 */ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 lut: plain, bilinear, custom0-9 */ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 dir: plain, bilinear, custom0-9 */ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* idx16 lut: plain, bilinear, custom0-9 */ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 lut: plain, bilinear, custom0-9 */ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* rgb32 dir: plain, bilinear, custom0-9 */ }; static GLhandleARB glsl_scrn_programs [10] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* rgb32: custom0-9, .. */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* rgb32: custom0-9, .. */ }; -static GLhandleARB glsl_scrn_vsh_shader[10] = +static GLhandleARB glsl_scrn_vsh_shader[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* custom0-9 */ static GLhandleARB glsl_scrn_fsh_shader [10] = -{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* rgb32: custom0-9 */ +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* rgb32: custom0-9 */ const char * glsl_shader_get_filter_name_mamebm(int glslShaderFeature) { @@ -144,16 +144,16 @@ glsl_shader_info *glsl_shader_init(void) err = gl_shader_loadExtention((PFNGLGETPROCADDRESSOS)SDL_GL_GetProcAddress); if(err) return NULL; - + for (i=0; !err && i<GLSL_VERTEX_SHADER_INT_NUMBER; i++) { #ifdef GLSL_SOURCE_ON_DISK if(glsl_mamebm_vsh_files[i]) - err = gl_compile_shader_file ( &glsl_mamebm_vsh_shader[i], GL_VERTEX_SHADER_ARB, + err = gl_compile_shader_file ( &glsl_mamebm_vsh_shader[i], GL_VERTEX_SHADER_ARB, glsl_mamebm_vsh_files[i], 0); #else if(glsl_mamebm_vsh_sources[i]) - err = gl_compile_shader_source( &glsl_mamebm_vsh_shader[i], GL_VERTEX_SHADER_ARB, + err = gl_compile_shader_source( &glsl_mamebm_vsh_shader[i], GL_VERTEX_SHADER_ARB, glsl_mamebm_vsh_sources[i], 0); #endif } @@ -166,14 +166,14 @@ glsl_shader_info *glsl_shader_init(void) { #ifdef GLSL_SOURCE_ON_DISK if(glsl_mamebm_fsh_files[i][j]) - err = gl_compile_shader_files (&glsl_mamebm_programs[i][j], - &glsl_mamebm_vsh_shader[glsl_mamebm_fsh2vsh[j]], + err = gl_compile_shader_files (&glsl_mamebm_programs[i][j], + &glsl_mamebm_vsh_shader[glsl_mamebm_fsh2vsh[j]], &glsl_mamebmfsh_shader[i][j], NULL /*precompiled*/, glsl_mamebm_fsh_files[i][j], 0); #else if(glsl_mamebm_fsh_sources[i][j]) - err = gl_compile_shader_sources(&glsl_mamebm_programs[i][j], - &glsl_mamebm_vsh_shader[glsl_mamebm_fsh2vsh[j]], + err = gl_compile_shader_sources(&glsl_mamebm_programs[i][j], + &glsl_mamebm_vsh_shader[glsl_mamebm_fsh2vsh[j]], &glsl_mamebm_fsh_shader[i][j], NULL /*precompiled*/, glsl_mamebm_fsh_sources[i][j]); #endif @@ -193,7 +193,7 @@ int glsl_shader_free(glsl_shader_info *shinfo) for (i=0; i<GLSL_VERTEX_SHADER_MAX_NUMBER+9; i++) { if ( glsl_mamebm_vsh_shader[i] ) - (void) gl_delete_shader( NULL, &glsl_mamebm_vsh_shader[i], NULL); + (void) gl_delete_shader( NULL, &glsl_mamebm_vsh_shader[i], NULL); } for (i=0; i<GLSL_SHADER_TYPE_NUMBER; i++) @@ -217,7 +217,7 @@ int glsl_shader_free(glsl_shader_info *shinfo) for (i=0; i<10; i++) { if ( glsl_scrn_vsh_shader[i] ) - (void) gl_delete_shader( NULL, &glsl_scrn_vsh_shader[i], NULL); + (void) gl_delete_shader( NULL, &glsl_scrn_vsh_shader[i], NULL); if ( glsl_scrn_fsh_shader[i] ) (void) gl_delete_shader( NULL, NULL, &glsl_scrn_fsh_shader[i]); if ( glsl_scrn_programs[i] ) @@ -253,7 +253,7 @@ int glsl_shader_add_mamebm(glsl_shader_info *shinfo, const char * custShaderPref break; } - err = gl_compile_shader_files (&glsl_mamebm_programs[i][GLSL_SHADER_FEAT_CUSTOM+idx], + err = gl_compile_shader_files (&glsl_mamebm_programs[i][GLSL_SHADER_FEAT_CUSTOM+idx], &glsl_mamebm_vsh_shader[GLSL_VERTEX_SHADER_CUSTOM+idx], &glsl_mamebm_fsh_shader[i][GLSL_SHADER_FEAT_CUSTOM+idx], NULL /*precompiled*/, fname, 0); @@ -273,7 +273,7 @@ int glsl_shader_add_scrn(glsl_shader_info *shinfo, const char * custShaderPrefix snprintf(fname, 8192, "%s.fsh", custShaderPrefix); fname[8191]=0; - err = gl_compile_shader_files (&glsl_scrn_programs[idx], + err = gl_compile_shader_files (&glsl_scrn_programs[idx], &glsl_scrn_vsh_shader[idx], &glsl_scrn_fsh_shader[idx], NULL /*precompiled*/, fname, 0); diff --git a/src/osd/sdl/gl_shader_tool.c b/src/osd/sdl/gl_shader_tool.c index e3e8e1fb8e9..6c501a456bd 100644 --- a/src/osd/sdl/gl_shader_tool.c +++ b/src/osd/sdl/gl_shader_tool.c @@ -8,22 +8,22 @@ * Dual license: MAME and GPL version 2 * * This module has a dual license, i.e. it is compatible to MAME, - * but I like to reserve my rights to use this module under + * but I like to reserve my rights to use this module under * the GPL as well. * * GPL license: * Visit http://www.gnu.org/copyleft/gpl.html * * MAME license: - * Visit http://mamedev.org for licensing and usage restrictions. + * Visit http://mamedev.org for licensing and usage restrictions. * * * OpenGL GLSL ARB extentions: * - * GL_ARB_shader_objects - * GL_ARB_shading_language_100 - * GL_ARB_vertex_shader - * GL_ARB_fragment_shader + * GL_ARB_shader_objects + * GL_ARB_shading_language_100 + * GL_ARB_vertex_shader + * GL_ARB_fragment_shader * */ @@ -86,9 +86,9 @@ int gl_shader_loadExtention(PFNGLGETPROCADDRESSOS GetProcAddress) if ( pfn_glGetObjectParameterivARB && pfn_glGetInfoLogARB && pfn_glDeleteObjectARB && pfn_glCreateShaderObjectARB && pfn_glShaderSourceARB && pfn_glCompileShaderARB && pfn_glCreateProgramObjectARB && pfn_glAttachObjectARB && pfn_glLinkProgramARB && pfn_glValidateProgramARB && pfn_glUseProgramObjectARB && pfn_glGetUniformLocationARB && - pfn_glGetUniformLocationARB && pfn_glUniform1fARB && pfn_glUniform1iARB && - pfn_glUniform1fvARB && pfn_glUniform2fvARB && pfn_glUniform3fvARB && pfn_glUniform4fvARB && - pfn_glUniform1ivARB && pfn_glUniform2ivARB && pfn_glUniform3ivARB && pfn_glUniform4ivARB + pfn_glGetUniformLocationARB && pfn_glUniform1fARB && pfn_glUniform1iARB && + pfn_glUniform1fvARB && pfn_glUniform2fvARB && pfn_glUniform3fvARB && pfn_glUniform4fvARB && + pfn_glUniform1ivARB && pfn_glUniform2ivARB && pfn_glUniform3ivARB && pfn_glUniform4ivARB ) { return 0; @@ -170,7 +170,7 @@ int gl_shader_check_error(GLhandleARB obj, GLenum obj_query, GLSLCheckMode m, co if ( CHECK_VERBOSE <= m ) mame_printf_warning("%s:%d: GL Error: object type 0x%X generation failed\n", file, line, (unsigned int)obj); res=-1; - } else if ( CHECK_ALWAYS_VERBOSE <= m ) + } else if ( CHECK_ALWAYS_VERBOSE <= m ) { if(param==GL_PROGRAM_OBJECT_ARB) mame_printf_warning("%s:%d: GL Error: object type 0x%X is PROGRAM, successful\n", file, line, (unsigned int)obj); @@ -183,7 +183,7 @@ int gl_shader_check_error(GLhandleARB obj, GLenum obj_query, GLSLCheckMode m, co { if ( CHECK_ALWAYS_VERBOSE <= m ) mame_printf_warning("%s:%d: GL Info: object 0x%X not yet marked for deletion\n", file, line, (unsigned int)obj); - } else if ( CHECK_ALWAYS_VERBOSE <= m ) + } else if ( CHECK_ALWAYS_VERBOSE <= m ) { mame_printf_warning("%s:%d: GL Info: object 0x%X deletion successful\n", file, line, (unsigned int)obj); } @@ -194,7 +194,7 @@ int gl_shader_check_error(GLhandleARB obj, GLenum obj_query, GLSLCheckMode m, co if ( CHECK_VERBOSE <= m ) mame_printf_warning("%s:%d: GL Error: object 0x%X compilation failed\n", file, line, (unsigned int)obj); res=-1; - } else if ( CHECK_ALWAYS_VERBOSE <= m ) + } else if ( CHECK_ALWAYS_VERBOSE <= m ) { mame_printf_warning("%s:%d: GL Info: object 0x%X compiled successful\n", file, line, (unsigned int)obj); } @@ -205,7 +205,7 @@ int gl_shader_check_error(GLhandleARB obj, GLenum obj_query, GLSLCheckMode m, co if ( CHECK_VERBOSE <= m ) mame_printf_warning("%s:%d: GL Error: object 0x%X linking failed\n", file, line, (unsigned int)obj); res=-1; - } else if ( CHECK_ALWAYS_VERBOSE <= m ) + } else if ( CHECK_ALWAYS_VERBOSE <= m ) { mame_printf_warning("%s:%d: GL Info: object 0x%X linked successful\n", file, line, (unsigned int)obj); } @@ -216,7 +216,7 @@ int gl_shader_check_error(GLhandleARB obj, GLenum obj_query, GLSLCheckMode m, co if ( CHECK_VERBOSE <= m ) mame_printf_warning("%s:%d: GL Error: object 0x%X validation failed\n", file, line, (unsigned int)obj); res=-1; - } else if ( CHECK_ALWAYS_VERBOSE <= m ) + } else if ( CHECK_ALWAYS_VERBOSE <= m ) { mame_printf_warning("%s:%d: GL Info: object 0x%X validation successful\n", file, line, (unsigned int)obj); } @@ -250,8 +250,8 @@ int gl_round_to_pow2(int v) return v; } -int gl_texture_check_size(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, - GLint border, GLenum format, GLenum type, +int gl_texture_check_size(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, GLint *avail_width, GLint *avail_height, int verbose) { @@ -265,7 +265,7 @@ int gl_texture_check_size(GLenum target, GLint level, GLint internalFormat, GLsi *avail_height = 0; GL_CHECK_ERROR_QUIET(); - + /* Test the max texture size */ while(err && width>=1 && height>=1 /* && width>=64 && height>=64 */) { @@ -275,8 +275,8 @@ int gl_texture_check_size(GLenum target, GLint level, GLint internalFormat, GLsi border, format, type, NULL); if ( 0!=(err=GL_CHECK_ERROR_NORMAL() )) return err; - glGetTexLevelParameteriv( texTargetProxy, level, GL_TEXTURE_WIDTH, avail_width); - glGetTexLevelParameteriv( texTargetProxy, level, GL_TEXTURE_HEIGHT, avail_height); + glGetTexLevelParameteriv( texTargetProxy, level, GL_TEXTURE_WIDTH, avail_width); + glGetTexLevelParameteriv( texTargetProxy, level, GL_TEXTURE_HEIGHT, avail_height); if ( 0!=(err=GL_CHECK_ERROR_NORMAL() )) return err; if ( (*avail_width) != width || (*avail_height) != height ) @@ -286,9 +286,9 @@ int gl_texture_check_size(GLenum target, GLint level, GLint internalFormat, GLsi if(verbose) { mame_printf_warning("gl_texture_size_check: " - "TexImage2D(0x%X, %d, 0x%X, %d, %d, %d, 0x%X, 0x%X): returned size does not match: %dx%d\n", - (unsigned int)target, (int)level, (int)internalFormat, - (int)width, (int)height, (int)border, (unsigned int)format, (unsigned int)type, + "TexImage2D(0x%X, %d, 0x%X, %d, %d, %d, 0x%X, 0x%X): returned size does not match: %dx%d\n", + (unsigned int)target, (int)level, (int)internalFormat, + (int)width, (int)height, (int)border, (unsigned int)format, (unsigned int)type, (int)*avail_width, (int)*avail_height); } @@ -351,7 +351,7 @@ static int delete_shader_tool( GLhandleARB *program, GLhandleARB *vertex_shader, return 0; } - + int gl_compile_shader_source( GLhandleARB *shader, GLenum type, const char * shader_source, int verbose ) { int err = 0; diff --git a/src/osd/sdl/gl_shader_tool.h b/src/osd/sdl/gl_shader_tool.h index 50700457abb..dd59906ae1e 100644 --- a/src/osd/sdl/gl_shader_tool.h +++ b/src/osd/sdl/gl_shader_tool.h @@ -8,22 +8,22 @@ * Dual license: MAME and GPL version 2 * * This module has a dual license, i.e. it is compatible to MAME, - * but I like to reserve my rights to use this module under + * but I like to reserve my rights to use this module under * the GPL as well. * * GPL license: * Visit http://www.gnu.org/copyleft/gpl.html * * MAME license: - * Visit http://mamedev.org for licensing and usage restrictions. + * Visit http://mamedev.org for licensing and usage restrictions. * * * OpenGL GLSL ARB extentions: * - * GL_ARB_shader_objects - * GL_ARB_shading_language_100 - * GL_ARB_vertex_shader - * GL_ARB_fragment_shader + * GL_ARB_shader_objects + * GL_ARB_shading_language_100 + * GL_ARB_vertex_shader + * GL_ARB_fragment_shader * */ @@ -99,18 +99,18 @@ typedef enum { int gl_check_error(GLSLCheckMode m, const char *file, const int line); -int gl_texture_check_size(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, - GLint border, GLenum format, GLenum type, +int gl_texture_check_size(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, GLsizei *avail_width, GLsizei *avail_height, int verbose); int gl_round_to_pow2(int v); /** - * @param obj_query Can be either GL_OBJECT_TYPE_ARB, GL_OBJECT_DELETE_STATUS_ARB, GL_OBJECT_COMPILE_STATUS_ARB, + * @param obj_query Can be either GL_OBJECT_TYPE_ARB, GL_OBJECT_DELETE_STATUS_ARB, GL_OBJECT_COMPILE_STATUS_ARB, * GL_OBJECT_LINK_STATUS_ARB, GL_OBJECT_VALIDATE_STATUS_ARB - * Should be used after the refering action, i.e. GL_OBJECT_DELETE_STATUS_ARB after a - * glDeleteObjectARB call, etc. + * Should be used after the refering action, i.e. GL_OBJECT_DELETE_STATUS_ARB after a + * glDeleteObjectARB call, etc. */ int gl_shader_check_error(GLhandleARB obj, GLenum obj_query, GLSLCheckMode m, const char *file, const int line); @@ -138,7 +138,7 @@ int gl_compile_shader_sources( GLhandleARB *program, GLhandleARB *vertex_shader, int gl_delete_shader( GLhandleARB *program, GLhandleARB *vertex_shader, GLhandleARB *fragment_shader ); -#if defined(SDLMAME_MACOSX) +#if defined(SDLMAME_MACOSX) #ifndef GL_ARB_shader_objects typedef char GLcharARB; typedef unsigned int GLhandleARB; diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c index 4442993bee5..d196f44415b 100644 --- a/src/osd/sdl/input.c +++ b/src/osd/sdl/input.c @@ -7,7 +7,7 @@ // // SDLMAME by Olivier Galibert and R. Belmont // -// SixAxis info: left analog is axes 0 & 1, right analog is axes 2 & 3, +// SixAxis info: left analog is axes 0 & 1, right analog is axes 2 & 3, // analog L2 is axis 12 and analog L3 is axis 13 // //============================================================ @@ -74,7 +74,7 @@ enum typedef struct _keyboard_state keyboard_state; struct _keyboard_state { - INT32 state[0x3ff]; // must be INT32! + INT32 state[0x3ff]; // must be INT32! INT8 oldkey[MAX_KEYS]; INT8 currkey[MAX_KEYS]; }; @@ -106,8 +106,8 @@ struct _device_info // device information device_info ** head; device_info * next; - char * name; - + char * name; + // MAME information input_device * device; @@ -132,7 +132,7 @@ static UINT8 input_paused; static sdl_window_info * focus_window = NULL; // input buffer - only for SDLMAME_EVENTS_IN_WORKER_THREAD -#define MAX_BUF_EVENTS (500) /* 100 not enough for SDL 1.3 */ +#define MAX_BUF_EVENTS (500) /* 100 not enough for SDL 1.3 */ static SDL_Event event_buf[MAX_BUF_EVENTS]; static int event_buf_count; @@ -154,7 +154,7 @@ static device_info * joystick_list; // joystick mapper typedef struct _device_map_t device_map_t; -struct _device_map_t +struct _device_map_t { struct { char *name; @@ -201,10 +201,10 @@ typedef struct _kt_table kt_table; struct _kt_table { INT32 mame_key; INT32 sdl_key; - //const char * vkey; - //const char * ascii; - const char * mame_key_name; - char * ui_name; + //const char * vkey; + //const char * ascii; + const char * mame_key_name; + char * ui_name; }; #if (SDL_VERSION_ATLEAST(1,3,0)) @@ -226,18 +226,18 @@ struct _kt_table { static kt_table sdl_key_trans_table[] = { - // MAME key SDL key vkey ascii + // MAME key SDL key vkey ascii KTT_ENTRY0( ESC, ESCAPE, 0x1b, 0x1b, "ESC" ), - KTT_ENTRY1( 1, 1 ), - KTT_ENTRY1( 2, 2 ), - KTT_ENTRY1( 3, 3 ), - KTT_ENTRY1( 4, 4 ), - KTT_ENTRY1( 5, 5 ), - KTT_ENTRY1( 6, 6 ), - KTT_ENTRY1( 7, 7 ), - KTT_ENTRY1( 8, 8 ), - KTT_ENTRY1( 9, 9 ), - KTT_ENTRY1( 0, 0 ), + KTT_ENTRY1( 1, 1 ), + KTT_ENTRY1( 2, 2 ), + KTT_ENTRY1( 3, 3 ), + KTT_ENTRY1( 4, 4 ), + KTT_ENTRY1( 5, 5 ), + KTT_ENTRY1( 6, 6 ), + KTT_ENTRY1( 7, 7 ), + KTT_ENTRY1( 8, 8 ), + KTT_ENTRY1( 9, 9 ), + KTT_ENTRY1( 0, 0 ), KTT_ENTRY0( MINUS, MINUS, 0xbd, '-', "MINUS" ), KTT_ENTRY0( EQUALS, EQUALS, 0xbb, '=', "EQUALS" ), KTT_ENTRY0( BACKSPACE, BACKSPACE, 0x08, 0x08, "BACKSPACE" ), @@ -252,9 +252,9 @@ static kt_table sdl_key_trans_table[] = KTT_ENTRY1( I, I ), KTT_ENTRY1( O, O ), KTT_ENTRY1( P, P ), - KTT_ENTRY0( OPENBRACE, LEFTBRACKET, 0xdb, '[', "OPENBRACE" ), - KTT_ENTRY0( CLOSEBRACE,RIGHTBRACKET, 0xdd, ']', "CLOSEBRACE" ), - KTT_ENTRY0( ENTER, RETURN, 0x0d, 0x0d, "RETURN" ), + KTT_ENTRY0( OPENBRACE, LEFTBRACKET, 0xdb, '[', "OPENBRACE" ), + KTT_ENTRY0( CLOSEBRACE,RIGHTBRACKET, 0xdd, ']', "CLOSEBRACE" ), + KTT_ENTRY0( ENTER, RETURN, 0x0d, 0x0d, "RETURN" ), KTT_ENTRY2( LCONTROL, LCTRL ), KTT_ENTRY1( A, A ), KTT_ENTRY1( S, S ), @@ -267,8 +267,8 @@ static kt_table sdl_key_trans_table[] = KTT_ENTRY1( L, L ), KTT_ENTRY0( COLON, SEMICOLON, 0xba, ';', "COLON" ), KTT_ENTRY0( QUOTE, APOSTROPHE, 0xde, '\'', "QUOTE" ), - KTT_ENTRY2( LSHIFT, LSHIFT ), - KTT_ENTRY0( BACKSLASH, BACKSLASH, 0xdc, '\\', "BACKSLASH" ), + KTT_ENTRY2( LSHIFT, LSHIFT ), + KTT_ENTRY0( BACKSLASH, BACKSLASH, 0xdc, '\\', "BACKSLASH" ), KTT_ENTRY1( Z, Z ), KTT_ENTRY1( X, X ), KTT_ENTRY1( C, C ), @@ -276,26 +276,26 @@ static kt_table sdl_key_trans_table[] = KTT_ENTRY1( B, B ), KTT_ENTRY1( N, N ), KTT_ENTRY1( M, M ), - KTT_ENTRY0( COMMA, COMMA, 0xbc, ',', "COMMA" ), - KTT_ENTRY0( STOP, PERIOD, 0xbe, '.', "STOP" ), - KTT_ENTRY0( SLASH, SLASH, 0xbf, '/', "SLASH" ), - KTT_ENTRY2( RSHIFT, RSHIFT ), - KTT_ENTRY0( ASTERISK, KP_MULTIPLY, '*', '*', "ASTERIX" ), - KTT_ENTRY2( LALT, LALT ), - KTT_ENTRY0( SPACE, SPACE, ' ', ' ', "SPACE" ), - KTT_ENTRY2( CAPSLOCK, CAPSLOCK ), - KTT_ENTRY2( F1, F1 ), - KTT_ENTRY2( F2, F2 ), - KTT_ENTRY2( F3, F3 ), - KTT_ENTRY2( F4, F4 ), - KTT_ENTRY2( F5, F5 ), - KTT_ENTRY2( F6, F6 ), - KTT_ENTRY2( F7, F7 ), - KTT_ENTRY2( F8, F8 ), - KTT_ENTRY2( F9, F9 ), - KTT_ENTRY2( F10, F10 ), - KTT_ENTRY2( NUMLOCK, NUMLOCKCLEAR ), - KTT_ENTRY2( SCRLOCK, SCROLLLOCK ), + KTT_ENTRY0( COMMA, COMMA, 0xbc, ',', "COMMA" ), + KTT_ENTRY0( STOP, PERIOD, 0xbe, '.', "STOP" ), + KTT_ENTRY0( SLASH, SLASH, 0xbf, '/', "SLASH" ), + KTT_ENTRY2( RSHIFT, RSHIFT ), + KTT_ENTRY0( ASTERISK, KP_MULTIPLY, '*', '*', "ASTERIX" ), + KTT_ENTRY2( LALT, LALT ), + KTT_ENTRY0( SPACE, SPACE, ' ', ' ', "SPACE" ), + KTT_ENTRY2( CAPSLOCK, CAPSLOCK ), + KTT_ENTRY2( F1, F1 ), + KTT_ENTRY2( F2, F2 ), + KTT_ENTRY2( F3, F3 ), + KTT_ENTRY2( F4, F4 ), + KTT_ENTRY2( F5, F5 ), + KTT_ENTRY2( F6, F6 ), + KTT_ENTRY2( F7, F7 ), + KTT_ENTRY2( F8, F8 ), + KTT_ENTRY2( F9, F9 ), + KTT_ENTRY2( F10, F10 ), + KTT_ENTRY2( NUMLOCK, NUMLOCKCLEAR ), + KTT_ENTRY2( SCRLOCK, SCROLLLOCK ), KTT_ENTRY2( 7_PAD, KP_7 ), KTT_ENTRY2( 8_PAD, KP_8 ), KTT_ENTRY2( 9_PAD, KP_9 ), @@ -303,35 +303,35 @@ static kt_table sdl_key_trans_table[] = KTT_ENTRY2( 4_PAD, KP_4 ), KTT_ENTRY2( 5_PAD, KP_5 ), KTT_ENTRY2( 6_PAD, KP_6 ), - KTT_ENTRY2( PLUS_PAD, KP_PLUS ), + KTT_ENTRY2( PLUS_PAD, KP_PLUS ), KTT_ENTRY2( 1_PAD, KP_1 ), KTT_ENTRY2( 2_PAD, KP_2 ), KTT_ENTRY2( 3_PAD, KP_3 ), KTT_ENTRY2( 0_PAD, KP_0 ), - KTT_ENTRY2( DEL_PAD, KP_PERIOD ), - KTT_ENTRY2( F11, F11 ), - KTT_ENTRY2( F12, F12 ), - KTT_ENTRY2( F13, F13 ), - KTT_ENTRY2( F14, F14 ), - KTT_ENTRY2( F15, F15 ), + KTT_ENTRY2( DEL_PAD, KP_PERIOD ), + KTT_ENTRY2( F11, F11 ), + KTT_ENTRY2( F12, F12 ), + KTT_ENTRY2( F13, F13 ), + KTT_ENTRY2( F14, F14 ), + KTT_ENTRY2( F15, F15 ), KTT_ENTRY2( ENTER_PAD, KP_ENTER ), - KTT_ENTRY2( RCONTROL, RCTRL ), + KTT_ENTRY2( RCONTROL, RCTRL ), KTT_ENTRY2( SLASH_PAD, KP_DIVIDE ), - KTT_ENTRY2( PRTSCR, PRINTSCREEN ), - KTT_ENTRY2( RALT, RALT ), - KTT_ENTRY2( HOME, HOME ), - KTT_ENTRY2( UP, UP ), - KTT_ENTRY2( PGUP, PAGEUP ), - KTT_ENTRY2( LEFT, LEFT ), + KTT_ENTRY2( PRTSCR, PRINTSCREEN ), + KTT_ENTRY2( RALT, RALT ), + KTT_ENTRY2( HOME, HOME ), + KTT_ENTRY2( UP, UP ), + KTT_ENTRY2( PGUP, PAGEUP ), + KTT_ENTRY2( LEFT, LEFT ), KTT_ENTRY2( RIGHT, RIGHT ), - KTT_ENTRY2( END, END ), - KTT_ENTRY2( DOWN, DOWN ), - KTT_ENTRY2( PGDN, PAGEDOWN ), - KTT_ENTRY2( INSERT, INSERT ), + KTT_ENTRY2( END, END ), + KTT_ENTRY2( DOWN, DOWN ), + KTT_ENTRY2( PGDN, PAGEDOWN ), + KTT_ENTRY2( INSERT, INSERT ), { ITEM_ID_DEL, SDL_SCANCODE_DELETE, "ITEM_ID_DEL", (char *)"DELETE" }, - KTT_ENTRY2( LWIN, LGUI ), - KTT_ENTRY2( RWIN, RGUI ), - KTT_ENTRY2( MENU, MENU ), + KTT_ENTRY2( LWIN, LGUI ), + KTT_ENTRY2( RWIN, RGUI ), + KTT_ENTRY2( MENU, MENU ), KTT_ENTRY0( TILDE, GRAVE, 0xc0, '`', "TILDE" ), KTT_ENTRY0( BACKSLASH2, NONUSBACKSLASH, 0xdc, '\\', "BACKSLASH2" ), { -1 } @@ -351,18 +351,18 @@ static kt_table sdl_key_trans_table[] = static kt_table sdl_key_trans_table[] = { - // MAME key SDL key vkey ascii + // MAME key SDL key vkey ascii KTT_ENTRY0( ESC, ESCAPE, 0x1b, 0x1b, "ESC" ), - KTT_ENTRY1( 1, 1 ), - KTT_ENTRY1( 2, 2 ), - KTT_ENTRY1( 3, 3 ), - KTT_ENTRY1( 4, 4 ), - KTT_ENTRY1( 5, 5 ), - KTT_ENTRY1( 6, 6 ), - KTT_ENTRY1( 7, 7 ), - KTT_ENTRY1( 8, 8 ), - KTT_ENTRY1( 9, 9 ), - KTT_ENTRY1( 0, 0 ), + KTT_ENTRY1( 1, 1 ), + KTT_ENTRY1( 2, 2 ), + KTT_ENTRY1( 3, 3 ), + KTT_ENTRY1( 4, 4 ), + KTT_ENTRY1( 5, 5 ), + KTT_ENTRY1( 6, 6 ), + KTT_ENTRY1( 7, 7 ), + KTT_ENTRY1( 8, 8 ), + KTT_ENTRY1( 9, 9 ), + KTT_ENTRY1( 0, 0 ), KTT_ENTRY0( MINUS, MINUS, 0xbd, '-', "MINUS" ), KTT_ENTRY0( EQUALS, EQUALS, 0xbb, '=', "EQUALS" ), KTT_ENTRY0( BACKSPACE, BACKSPACE, 0x08, 0x08, "BACKSPACE" ), @@ -377,9 +377,9 @@ static kt_table sdl_key_trans_table[] = KTT_ENTRY1( I, i ), KTT_ENTRY1( O, o ), KTT_ENTRY1( P, p ), - KTT_ENTRY0( OPENBRACE, LEFTBRACKET, 0xdb, '[', "OPENBRACE" ), - KTT_ENTRY0( CLOSEBRACE,RIGHTBRACKET, 0xdd, ']', "CLOSEBRACE" ), - KTT_ENTRY0( ENTER, RETURN, 0x0d, 0x0d, "RETURN" ), + KTT_ENTRY0( OPENBRACE, LEFTBRACKET, 0xdb, '[', "OPENBRACE" ), + KTT_ENTRY0( CLOSEBRACE,RIGHTBRACKET, 0xdd, ']', "CLOSEBRACE" ), + KTT_ENTRY0( ENTER, RETURN, 0x0d, 0x0d, "RETURN" ), KTT_ENTRY2( LCONTROL, LCTRL ), KTT_ENTRY1( A, a ), KTT_ENTRY1( S, s ), @@ -392,8 +392,8 @@ static kt_table sdl_key_trans_table[] = KTT_ENTRY1( L, l ), KTT_ENTRY0( COLON, SEMICOLON, 0xba, ';', "COLON" ), KTT_ENTRY0( QUOTE, QUOTE, 0xde, '\'', "QUOTE" ), - KTT_ENTRY2( LSHIFT, LSHIFT ), - KTT_ENTRY0( BACKSLASH, BACKSLASH, 0xdc, '\\', "BACKSLASH" ), + KTT_ENTRY2( LSHIFT, LSHIFT ), + KTT_ENTRY0( BACKSLASH, BACKSLASH, 0xdc, '\\', "BACKSLASH" ), KTT_ENTRY1( Z, z ), KTT_ENTRY1( X, x ), KTT_ENTRY1( C, c ), @@ -401,26 +401,26 @@ static kt_table sdl_key_trans_table[] = KTT_ENTRY1( B, b ), KTT_ENTRY1( N, n ), KTT_ENTRY1( M, m ), - KTT_ENTRY0( COMMA, COMMA, 0xbc, ',', "COMMA" ), - KTT_ENTRY0( STOP, PERIOD, 0xbe, '.', "STOP" ), - KTT_ENTRY0( SLASH, SLASH, 0xbf, '/', "SLASH" ), - KTT_ENTRY2( RSHIFT, RSHIFT ), - KTT_ENTRY0( ASTERISK, KP_MULTIPLY, '*', '*', "ASTERIX" ), - KTT_ENTRY2( LALT, LALT ), - KTT_ENTRY0( SPACE, SPACE, ' ', ' ', "SPACE" ), - KTT_ENTRY2( CAPSLOCK, CAPSLOCK ), - KTT_ENTRY2( F1, F1 ), - KTT_ENTRY2( F2, F2 ), - KTT_ENTRY2( F3, F3 ), - KTT_ENTRY2( F4, F4 ), - KTT_ENTRY2( F5, F5 ), - KTT_ENTRY2( F6, F6 ), - KTT_ENTRY2( F7, F7 ), - KTT_ENTRY2( F8, F8 ), - KTT_ENTRY2( F9, F9 ), - KTT_ENTRY2( F10, F10 ), - KTT_ENTRY2( NUMLOCK, NUMLOCK ), - KTT_ENTRY2( SCRLOCK, SCROLLOCK ), + KTT_ENTRY0( COMMA, COMMA, 0xbc, ',', "COMMA" ), + KTT_ENTRY0( STOP, PERIOD, 0xbe, '.', "STOP" ), + KTT_ENTRY0( SLASH, SLASH, 0xbf, '/', "SLASH" ), + KTT_ENTRY2( RSHIFT, RSHIFT ), + KTT_ENTRY0( ASTERISK, KP_MULTIPLY, '*', '*', "ASTERIX" ), + KTT_ENTRY2( LALT, LALT ), + KTT_ENTRY0( SPACE, SPACE, ' ', ' ', "SPACE" ), + KTT_ENTRY2( CAPSLOCK, CAPSLOCK ), + KTT_ENTRY2( F1, F1 ), + KTT_ENTRY2( F2, F2 ), + KTT_ENTRY2( F3, F3 ), + KTT_ENTRY2( F4, F4 ), + KTT_ENTRY2( F5, F5 ), + KTT_ENTRY2( F6, F6 ), + KTT_ENTRY2( F7, F7 ), + KTT_ENTRY2( F8, F8 ), + KTT_ENTRY2( F9, F9 ), + KTT_ENTRY2( F10, F10 ), + KTT_ENTRY2( NUMLOCK, NUMLOCK ), + KTT_ENTRY2( SCRLOCK, SCROLLOCK ), KTT_ENTRY2( 7_PAD, KP7 ), KTT_ENTRY2( 8_PAD, KP8 ), KTT_ENTRY2( 9_PAD, KP9 ), @@ -428,35 +428,35 @@ static kt_table sdl_key_trans_table[] = KTT_ENTRY2( 4_PAD, KP4 ), KTT_ENTRY2( 5_PAD, KP5 ), KTT_ENTRY2( 6_PAD, KP6 ), - KTT_ENTRY2( PLUS_PAD, KP_PLUS ), + KTT_ENTRY2( PLUS_PAD, KP_PLUS ), KTT_ENTRY2( 1_PAD, KP1 ), KTT_ENTRY2( 2_PAD, KP2 ), KTT_ENTRY2( 3_PAD, KP3 ), KTT_ENTRY2( 0_PAD, KP0 ), - KTT_ENTRY2( DEL_PAD, KP_PERIOD ), - KTT_ENTRY2( F11, F11 ), - KTT_ENTRY2( F12, F12 ), - KTT_ENTRY2( F13, F13 ), - KTT_ENTRY2( F14, F14 ), - KTT_ENTRY2( F15, F15 ), + KTT_ENTRY2( DEL_PAD, KP_PERIOD ), + KTT_ENTRY2( F11, F11 ), + KTT_ENTRY2( F12, F12 ), + KTT_ENTRY2( F13, F13 ), + KTT_ENTRY2( F14, F14 ), + KTT_ENTRY2( F15, F15 ), KTT_ENTRY2( ENTER_PAD, KP_ENTER ), - KTT_ENTRY2( RCONTROL, RCTRL ), + KTT_ENTRY2( RCONTROL, RCTRL ), KTT_ENTRY2( SLASH_PAD, KP_DIVIDE ), - KTT_ENTRY2( PRTSCR, PRINT ), - KTT_ENTRY2( RALT, RALT ), - KTT_ENTRY2( HOME, HOME ), - KTT_ENTRY2( UP, UP ), - KTT_ENTRY2( PGUP, PAGEUP ), - KTT_ENTRY2( LEFT, LEFT ), + KTT_ENTRY2( PRTSCR, PRINT ), + KTT_ENTRY2( RALT, RALT ), + KTT_ENTRY2( HOME, HOME ), + KTT_ENTRY2( UP, UP ), + KTT_ENTRY2( PGUP, PAGEUP ), + KTT_ENTRY2( LEFT, LEFT ), KTT_ENTRY2( RIGHT, RIGHT ), - KTT_ENTRY2( END, END ), - KTT_ENTRY2( DOWN, DOWN ), - KTT_ENTRY2( PGDN, PAGEDOWN ), - KTT_ENTRY2( INSERT, INSERT ), + KTT_ENTRY2( END, END ), + KTT_ENTRY2( DOWN, DOWN ), + KTT_ENTRY2( PGDN, PAGEDOWN ), + KTT_ENTRY2( INSERT, INSERT ), { ITEM_ID_DEL, SDLK_DELETE, "ITEM_ID_DEL", (char *)"DELETE" }, - KTT_ENTRY2( LWIN, LSUPER ), - KTT_ENTRY2( RWIN, RSUPER ), - KTT_ENTRY2( MENU, MENU ), + KTT_ENTRY2( LWIN, LSUPER ), + KTT_ENTRY2( RWIN, RSUPER ), + KTT_ENTRY2( MENU, MENU ), KTT_ENTRY0( TILDE, BACKQUOTE, 0xc0, '`', "TILDE" ), KTT_ENTRY0( BACKSLASH2, HASH, 0xdc, '\\', "BACKSLASH2" ), { -1 } @@ -464,7 +464,7 @@ static kt_table sdl_key_trans_table[] = #endif typedef struct _key_lookup_table key_lookup_table; -struct _key_lookup_table +struct _key_lookup_table { int code; const char *name; @@ -472,10 +472,10 @@ struct _key_lookup_table #if (SDL_VERSION_ATLEAST(1,3,0)) #define KE(x) { SDL_SCANCODE_ ## x, "SDL_SCANCODE_" #x }, -#define KE8(A, B, C, D, E, F, G, H) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) KE(H) +#define KE8(A, B, C, D, E, F, G, H) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) KE(H) #define KE7(A, B, C, D, E, F, G) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) #define KE5(A, B, C, D, E) KE(A) KE(B) KE(C) KE(D) KE(E) -#define KE3(A, B, C) KE(A) KE(B) KE(C) +#define KE3(A, B, C) KE(A) KE(B) KE(C) static key_lookup_table sdl_lookup_table[] = { @@ -502,7 +502,7 @@ static key_lookup_table sdl_lookup_table[] = }; #else #define KE(x) { SDLK_ ## x, "SDLK_" #x }, -#define KE8(A, B, C, D, E, F, G, H) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) KE(H) +#define KE8(A, B, C, D, E, F, G, H) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) KE(H) static key_lookup_table sdl_lookup_table[] = { @@ -536,7 +536,7 @@ static key_lookup_table sdl_lookup_table[] = KE8(LCTRL, RALT, LALT, RMETA, LMETA, LSUPER, RSUPER, MODE ) KE8(COMPOSE, HELP, PRINT, SYSREQ, BREAK, MENU, POWER, EURO ) KE(UNDO) - KE(LAST) + KE(LAST) {-1, ""} }; #endif @@ -611,7 +611,7 @@ static void devmap_register(device_map_t *devmap, int physical_idx, char *name) devmap->map[stick].name = name; devmap->logical[physical_idx] = stick; } - + } //============================================================ @@ -622,9 +622,9 @@ static void devmap_init(running_machine *machine, device_map_t *devmap, const ch { int dev; char defname[20]; - - assert(max_devices <= MAX_DEVMAP_ENTRIES); - + + assert(max_devices <= MAX_DEVMAP_ENTRIES); + for (dev = 0; dev < MAX_DEVMAP_ENTRIES; dev++) { devmap->map[dev].name = (char *)""; @@ -632,7 +632,7 @@ static void devmap_init(running_machine *machine, device_map_t *devmap, const ch devmap->logical[dev] = -1; } devmap->initialized = 0; - + for (dev = 0; dev < max_devices; dev++) { const char *dev_name; @@ -648,7 +648,7 @@ static void devmap_init(running_machine *machine, device_map_t *devmap, const ch } } -static device_info *devmap_class_register(running_machine *machine, device_map_t *devmap, +static device_info *devmap_class_register(running_machine *machine, device_map_t *devmap, int index, device_info **devlist, input_device_class devclass) { device_info *devinfo = NULL; @@ -691,7 +691,7 @@ static void sdlinput_register_joysticks(running_machine *machine) for (physical_stick = 0; physical_stick < SDL_NumJoysticks(); physical_stick++) { char *joy_name = remove_spaces(machine, SDL_JoystickName(physical_stick)); - + devmap_register(&joy_map, physical_stick, joy_name); } @@ -701,9 +701,9 @@ static void sdlinput_register_joysticks(running_machine *machine) if (devinfo == NULL) continue; - + physical_stick = joy_map.map[stick].physical; - + joy = SDL_JoystickOpen(physical_stick); devinfo->joystick.device = joy; @@ -716,7 +716,7 @@ static void sdlinput_register_joysticks(running_machine *machine) for (axis = 0; axis < SDL_JoystickNumAxes(joy); axis++) { input_item_id itemid; - + if (axis < INPUT_MAX_AXIS) itemid = (input_item_id) (ITEM_ID_XAXIS + axis); else if (axis < INPUT_MAX_AXIS + INPUT_MAX_ADD_ABSOLUTE) @@ -727,12 +727,12 @@ static void sdlinput_register_joysticks(running_machine *machine) sprintf(tempname, "A%d %s", axis, devinfo->name); input_device_item_add(devinfo->device, tempname, &devinfo->joystick.axes[axis], itemid, generic_axis_get_state); } - + // loop over all buttons for (button = 0; button < SDL_JoystickNumButtons(joy); button++) { input_item_id itemid; - + devinfo->joystick.buttons[button] = 0; if (button < INPUT_MAX_BUTTONS) @@ -750,7 +750,7 @@ static void sdlinput_register_joysticks(running_machine *machine) for (hat = 0; hat < SDL_JoystickNumHats(joy); hat++) { input_item_id itemid; - + sprintf(tempname, "hat %d Up", hat); itemid = (input_item_id) ((hat < INPUT_MAX_HATS) ? ITEM_ID_HAT1UP + 4 * hat : ITEM_ID_OTHER_SWITCH); input_device_item_add(devinfo->device, tempname, &devinfo->joystick.hatsU[hat], itemid, generic_button_get_state); @@ -794,7 +794,7 @@ static void sdlinput_deregister_joysticks(running_machine *machine) static void sdlinput_register_mice(running_machine *machine) { int index, physical_mouse; - + mouse_enabled = options_get_bool(mame_options(), OPTION_MOUSE); devmap_init(machine, &mouse_map, SDLOPTION_MOUSEINDEX, 8, "Mouse mapping"); @@ -802,7 +802,7 @@ static void sdlinput_register_mice(running_machine *machine) for (physical_mouse = 0; physical_mouse < SDL_GetNumMice(); physical_mouse++) { char *mouse_name = remove_spaces(machine, SDL_GetMouseName(physical_mouse)); - + devmap_register(&mouse_map, physical_mouse, mouse_name); } @@ -817,23 +817,23 @@ static void sdlinput_register_mice(running_machine *machine) if (devinfo == NULL) continue; - + // add the axes sprintf(defname, "X %s", devinfo->name); input_device_item_add(devinfo->device, defname, &devinfo->mouse.lX, ITEM_ID_XAXIS, generic_axis_get_state); sprintf(defname, "Y %s", devinfo->name); input_device_item_add(devinfo->device, defname, &devinfo->mouse.lY, ITEM_ID_YAXIS, generic_axis_get_state); - + for (button = 0; button < 4; button++) { input_item_id itemid; - + sprintf(defname, "B%d", button + 1); itemid = (input_item_id) (ITEM_ID_BUTTON1+button); - + input_device_item_add(devinfo->device, defname, &devinfo->mouse.buttons[button], itemid, generic_button_get_state); } - + if (0 && mouse_enabled) SDL_SetRelativeMouseMode(index, SDL_TRUE); mame_printf_verbose("Mouse: Registered %s\n", devinfo->name); @@ -846,7 +846,7 @@ static void sdlinput_register_mice(running_machine *machine) device_info *devinfo; char defname[20]; int button; - + mame_printf_verbose("Mouse: Start initialization\n"); mouse_map.logical[0] = 0; @@ -856,7 +856,7 @@ static void sdlinput_register_mice(running_machine *machine) devinfo->device = input_device_add(machine, DEVICE_CLASS_MOUSE, devinfo->name, devinfo); mouse_enabled = options_get_bool(mame_options(), OPTION_MOUSE); - + // add the axes input_device_item_add(devinfo->device, "X", &devinfo->mouse.lX, ITEM_ID_XAXIS, generic_axis_get_state); input_device_item_add(devinfo->device, "Y", &devinfo->mouse.lY, ITEM_ID_YAXIS, generic_axis_get_state); @@ -900,7 +900,7 @@ static int lookup_sdl_code(const char *scode) static int lookup_mame_index(const char *scode) { int index, i; - + index=-1; i=0; while (sdl_key_trans_table[i].mame_key >= 0) @@ -910,7 +910,7 @@ static int lookup_mame_index(const char *scode) index=i; break; } - i++; + i++; } return index; } @@ -921,7 +921,7 @@ static int lookup_mame_code(const char *scode) int index; index = lookup_mame_index(scode); if (index >= 0) - return sdl_key_trans_table[index].mame_key; + return sdl_key_trans_table[index].mame_key; else return -1; } @@ -959,7 +959,7 @@ static kt_table * sdlinput_read_keymap(running_machine *machine) key_trans_table = auto_alloc_array(machine, kt_table, ARRAY_LENGTH(sdl_key_trans_table)); memcpy((void *) key_trans_table, sdl_key_trans_table, sizeof(sdl_key_trans_table)); - + while (!feof(keymap_file)) { fgets(buf, 255, keymap_file); @@ -974,11 +974,11 @@ static kt_table * sdlinput_read_keymap(running_machine *machine) memset(kns, 0, 21); sscanf(buf, "%20s %20s %x %x %20c\n", mks, sks, &vk, &ak, kns); - + index=lookup_mame_index(mks); sk = lookup_sdl_code(sks); - if ( sk >= 0 && index >=0) + if ( sk >= 0 && index >=0) { key_trans_table[index].sdl_key = sk; // vk and ak are not really needed @@ -995,7 +995,7 @@ static kt_table * sdlinput_read_keymap(running_machine *machine) } fclose(keymap_file); mame_printf_verbose("Keymap: Processed %d lines\n", line); - + return key_trans_table; } @@ -1019,7 +1019,7 @@ static void sdlinput_register_keyboards(running_machine *machine) { char defname[90]; snprintf(defname, sizeof(defname)-1, "Keyboard #%d", physical_keyboard + 1); - + devmap_register(&keyboard_map, physical_keyboard, defname); } @@ -1034,17 +1034,17 @@ static void sdlinput_register_keyboards(running_machine *machine) if (devinfo == NULL) continue; - + // populate it for (keynum = 0; sdl_key_trans_table[keynum].mame_key >= 0; keynum++) { input_item_id itemid; - + itemid = (input_item_id) key_trans_table[keynum].mame_key; // generate the default / modified name snprintf(defname, sizeof(defname)-1, "%s", key_trans_table[keynum].ui_name); - + // add the item to the device input_device_item_add(devinfo->device, defname, &devinfo->keyboard.state[OSD_SDL_INDEX(key_trans_table[keynum].sdl_key)], itemid, generic_button_get_state); } @@ -1064,7 +1064,7 @@ static void sdlinput_register_keyboards(running_machine *machine) key_trans_table = sdlinput_read_keymap(machine); keyboard_map.logical[0] = 0; - + mame_printf_verbose("Keyboard: Start initialization\n"); // SDL 1.2 only has 1 keyboard (1.3+ will have multiple, this must be revisited then) @@ -1076,12 +1076,12 @@ static void sdlinput_register_keyboards(running_machine *machine) for (keynum = 0; sdl_key_trans_table[keynum].mame_key >= 0; keynum++) { input_item_id itemid; - + itemid = (input_item_id) key_trans_table[keynum].mame_key; // generate the default / modified name snprintf(defname, sizeof(defname)-1, "%s", key_trans_table[keynum].ui_name); - + // add the item to the device //printf("Test %d\n", OSD_SDL_INDEX(key_trans_table[keynum].sdl_key) ); input_device_item_add(devinfo->device, defname, &devinfo->keyboard.state[OSD_SDL_INDEX(key_trans_table[keynum].sdl_key)], itemid, generic_button_get_state); @@ -1102,7 +1102,7 @@ void sdlinput_init(running_machine *machine) joystick_list = NULL; mouse_list = NULL; lightgun_list = NULL; - + app_has_mouse_focus = 1; // we need pause and exit callbacks @@ -1135,7 +1135,7 @@ void sdlinput_init(running_machine *machine) device_list_reset_devices(keyboard_list); device_list_reset_devices(mouse_list); device_list_reset_devices(joystick_list); - + } @@ -1191,7 +1191,7 @@ sdl_window_info *sdlinput_get_focus_window(running_machine *machine) INLINE sdl_window_info * window_from_id(SDL_WindowID windowID) { sdl_window_info *w; - + for (w = sdl_window_list; w != NULL; w = w->next) { //printf("w->window_id: %d\n", w->window_id); @@ -1207,7 +1207,7 @@ INLINE void resize_all_windows(void) { sdl_window_info *w; osd_ticks_t now = osd_ticks(); - + if (SDL13_COMBINE_RESIZE) { for (w = sdl_window_list; w != NULL; w = w->next) @@ -1235,12 +1235,12 @@ void sdlinput_process_events_buf(running_machine *machine) /* Make sure we get all pending events */ SDL_PumpEvents(); #endif - while(SDL_PollEvent(&event)) + while(SDL_PollEvent(&event)) { if (event_buf_count < MAX_BUF_EVENTS) event_buf[event_buf_count++] = event; else - mame_printf_warning("Event Buffer Overflow!\n"); + mame_printf_warning("Event Buffer Overflow!\n"); } osd_lock_release(input_lock); } @@ -1276,8 +1276,8 @@ void sdlinput_poll(running_machine *machine) osd_lock_release(input_lock); bufp = 0; } - - while (TRUE) + + while (TRUE) { if (SDLMAME_EVENTS_IN_WORKER_THREAD) { @@ -1291,7 +1291,7 @@ void sdlinput_poll(running_machine *machine) break; } - if (event.type == SDL_KEYUP && + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_CAPSLOCK) { /* more caps-lock hack */ @@ -1320,7 +1320,7 @@ void sdlinput_poll(running_machine *machine) if (axis <= 3) { - devinfo->joystick.axes[event.jaxis.axis] = (event.jaxis.value * 2); + devinfo->joystick.axes[event.jaxis.axis] = (event.jaxis.value * 2); } else { @@ -1331,7 +1331,7 @@ void sdlinput_poll(running_machine *machine) } else { - devinfo->joystick.axes[event.jaxis.axis] = (event.jaxis.value * 2); + devinfo->joystick.axes[event.jaxis.axis] = (event.jaxis.value * 2); } } break; @@ -1378,12 +1378,12 @@ void sdlinput_poll(running_machine *machine) devinfo = generic_device_find_index(joystick_list, joy_map.logical[event.jbutton.which]); if (devinfo) { - devinfo->joystick.buttons[event.jbutton.button] = (event.jbutton.state == SDL_PRESSED) ? 0x80 : 0; + devinfo->joystick.buttons[event.jbutton.button] = (event.jbutton.state == SDL_PRESSED) ? 0x80 : 0; } break; case SDL_MOUSEBUTTONDOWN: devinfo = generic_device_find_index(mouse_list, mouse_map.logical[event.button.which]); - devinfo->mouse.buttons[event.button.button-1] = 0x80; + devinfo->mouse.buttons[event.button.button-1] = 0x80; //printf("But down %d %d %d %d %s\n", event.button.which, event.button.button, event.button.x, event.button.y, devinfo->name); if (event.button.button == 1) { @@ -1396,9 +1396,9 @@ void sdlinput_poll(running_machine *machine) sdl_window_info *window = GET_FOCUS_WINDOW(&event.button); if (window != NULL && window->xy_to_render_target(window, event.button.x,event.button.y, &cx, &cy) ) { - ui_input_push_mouse_down_event(machine, window->target, cx, cy); + ui_input_push_mouse_down_event(machine, window->target, cx, cy); // FIXME Parameter ? - if ((click-last_click < 250) + if ((click-last_click < 250) && (cx >= last_x - 4 && cx <= last_x + 4) && (cy >= last_y - 4 && cy <= last_y + 4) ) { @@ -1416,17 +1416,17 @@ void sdlinput_poll(running_machine *machine) break; case SDL_MOUSEBUTTONUP: devinfo = generic_device_find_index(mouse_list, mouse_map.logical[event.button.which]); - devinfo->mouse.buttons[event.button.button-1] = 0; + devinfo->mouse.buttons[event.button.button-1] = 0; //printf("But up %d %d %d %d\n", event.button.which, event.button.button, event.button.x, event.button.y); if (event.button.button == 1) { int cx, cy; sdl_window_info *window = GET_FOCUS_WINDOW(&event.button); - + if (window != NULL && window->xy_to_render_target(window, event.button.x,event.button.y, &cx, &cy) ) { - ui_input_push_mouse_up_event(machine, window->target, cx, cy); + ui_input_push_mouse_up_event(machine, window->target, cx, cy); } } break; @@ -1435,10 +1435,10 @@ void sdlinput_poll(running_machine *machine) #if (SDL_VERSION_ATLEAST(1,3,0)) // FIXME: may apply to 1.2 as well ... //printf("Motion %d %d %d %s\n", event.motion.which, event.motion.x, event.motion.y, devinfo->name); - devinfo->mouse.lX += event.motion.xrel * INPUT_RELATIVE_PER_PIXEL; + devinfo->mouse.lX += event.motion.xrel * INPUT_RELATIVE_PER_PIXEL; devinfo->mouse.lY += event.motion.yrel * INPUT_RELATIVE_PER_PIXEL; #else - devinfo->mouse.lX = event.motion.xrel * INPUT_RELATIVE_PER_PIXEL; + devinfo->mouse.lX = event.motion.xrel * INPUT_RELATIVE_PER_PIXEL; devinfo->mouse.lY = event.motion.yrel * INPUT_RELATIVE_PER_PIXEL; #endif { @@ -1446,7 +1446,7 @@ void sdlinput_poll(running_machine *machine) sdl_window_info *window = GET_FOCUS_WINDOW(&event.motion); if (window != NULL && window->xy_to_render_target(window, event.motion.x, event.motion.y, &cx, &cy) ) - ui_input_push_mouse_move_event(machine, window->target, cx, cy); + ui_input_push_mouse_move_event(machine, window->target, cx, cy); } break; #if (!SDL_VERSION_ATLEAST(1,3,0)) @@ -1480,10 +1480,10 @@ void sdlinput_poll(running_machine *machine) case SDL_WINDOWEVENT: { sdl_window_info *window = GET_WINDOW(&event.window); - + if (window == NULL) break; - + switch (event.window.event) { case SDL_WINDOWEVENT_CLOSE: @@ -1498,7 +1498,7 @@ void sdlinput_poll(running_machine *machine) focus_window = window; break; case SDL_WINDOWEVENT_RESIZED: - if (SDL13_COMBINE_RESIZE) + if (SDL13_COMBINE_RESIZE) { window->resize_width = event.window.data1; window->resize_height = event.window.data2; @@ -1516,7 +1516,7 @@ void sdlinput_poll(running_machine *machine) /* fall through */ case SDL_WINDOWEVENT_FOCUS_GAINED: case SDL_WINDOWEVENT_EXPOSED: - case SDL_WINDOWEVENT_MAXIMIZED: + case SDL_WINDOWEVENT_MAXIMIZED: case SDL_WINDOWEVENT_RESTORED: focus_window = window; break; @@ -1531,7 +1531,7 @@ void sdlinput_poll(running_machine *machine) #endif } - + //============================================================ // sdlinput_release_keys //============================================================ @@ -1553,7 +1553,7 @@ void sdlinput_release_keys(running_machine *machine) break; memset(&devinfo->keyboard.state, 0, sizeof(devinfo->keyboard.state)); } -#endif +#endif } @@ -1566,14 +1566,14 @@ int sdlinput_should_hide_mouse(running_machine *machine) // if we are paused, no if (input_paused) return FALSE; - + // if neither mice nor lightguns enabled in the core, then no if (!mouse_enabled && !lightgun_enabled) return FALSE; - + if (!app_has_mouse_focus) return FALSE; - + // otherwise, yes return TRUE; } @@ -1589,7 +1589,7 @@ void osd_customize_input_type_list(input_type_desc *typelist) int mameid_code ,ui_code; #endif input_type_desc *typedesc; - + // loop over the defaults for (typedesc = typelist; typedesc != NULL; typedesc = typedesc->next) { @@ -1612,9 +1612,9 @@ void osd_customize_input_type_list(input_type_desc *typelist) // disable UI_SELECT when LALT is down, this stops selecting // things in the menu when toggling fullscreen with LALT+ENTER -/* case IPT_UI_SELECT: - input_seq_set_3(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_ENTER, SEQCODE_NOT, KEYCODE_LALT); - break;*/ +/* case IPT_UI_SELECT: + input_seq_set_3(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_ENTER, SEQCODE_NOT, KEYCODE_LALT); + break;*/ // page down for fastforward (must be OSD_3 as per src/emu/ui.c) case IPT_UI_FAST_FORWARD: @@ -1622,7 +1622,7 @@ void osd_customize_input_type_list(input_type_desc *typelist) typedesc->name = "Fast Forward"; input_seq_set_1(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_PGDN); break; - + // OSD hotkeys use LCTRL and start at F3, they start at // F3 because F1-F2 are hardcoded into many drivers to // various dipswitches, and pressing them together with @@ -1638,7 +1638,7 @@ void osd_customize_input_type_list(input_type_desc *typelist) case IPT_UI_SOFT_RESET: input_seq_set_5(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_F3, SEQCODE_NOT, KEYCODE_LCONTROL, SEQCODE_NOT, KEYCODE_LSHIFT); break; - + // LCTRL-F4 to toggle keep aspect case IPT_OSD_4: typedesc->token = "TOGGLE_KEEP_ASPECT"; @@ -1649,7 +1649,7 @@ void osd_customize_input_type_list(input_type_desc *typelist) case IPT_UI_SHOW_GFX: input_seq_set_3(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_F4, SEQCODE_NOT, KEYCODE_LCONTROL); break; - + // LCTRL-F5 to toggle OpenGL filtering case IPT_OSD_5: typedesc->token = "TOGGLE_FILTER"; @@ -1660,7 +1660,7 @@ void osd_customize_input_type_list(input_type_desc *typelist) case IPT_UI_TOGGLE_DEBUG: input_seq_set_3(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_F5, SEQCODE_NOT, KEYCODE_LCONTROL); break; - + // LCTRL-F6 to decrease OpenGL prescaling case IPT_OSD_6: typedesc->token = "DECREASE_PRESCALE"; @@ -1671,7 +1671,7 @@ void osd_customize_input_type_list(input_type_desc *typelist) case IPT_UI_TOGGLE_CHEAT: input_seq_set_3(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_F6, SEQCODE_NOT, KEYCODE_LCONTROL); break; - + // LCTRL-F7 to increase OpenGL prescaling case IPT_OSD_7: typedesc->token = "INCREASE_PRESCALE"; @@ -1682,7 +1682,7 @@ void osd_customize_input_type_list(input_type_desc *typelist) case IPT_UI_LOAD_STATE: input_seq_set_5(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_F7, SEQCODE_NOT, KEYCODE_LCONTROL, SEQCODE_NOT, KEYCODE_LSHIFT); break; - + // LCTRL-F10 to toggle the renderer (software vs opengl) case IPT_OSD_10: typedesc->token = "TOGGLE_RENDERER"; @@ -1693,7 +1693,7 @@ void osd_customize_input_type_list(input_type_desc *typelist) case IPT_UI_THROTTLE: input_seq_set_3(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_F10, SEQCODE_NOT, KEYCODE_LCONTROL); break; - + // disable the config menu if the ALT key is down // (allows ALT-TAB to switch between apps) case IPT_UI_CONFIGURE: @@ -1711,7 +1711,7 @@ void osd_customize_input_type_list(input_type_desc *typelist) static void device_list_reset_devices(device_info *devlist_head) { device_info *curdev; - + for (curdev = devlist_head; curdev != NULL; curdev = curdev->next) generic_device_reset(curdev); } @@ -1724,7 +1724,7 @@ static void device_list_reset_devices(device_info *devlist_head) static void device_list_free_devices(device_info **devlist_head) { device_info *curdev, *next; - + for (curdev = *devlist_head; curdev != NULL; ) { next = curdev->next; @@ -1747,17 +1747,17 @@ static device_info *generic_device_alloc(device_info **devlist_head_ptr, const c // allocate memory for the device object devinfo = global_alloc_clear(device_info); devinfo->head = devlist_head_ptr; - + // allocate a UTF8 copy of the name devinfo->name = (char *) global_alloc_array(char, strlen(name)+1); if (devinfo->name == NULL) goto error; strcpy(devinfo->name, (char *)name); - + // append us to the list for (curdev_ptr = devinfo->head; *curdev_ptr != NULL; curdev_ptr = &(*curdev_ptr)->next) ; *curdev_ptr = devinfo; - + return devinfo; error: @@ -1778,7 +1778,7 @@ static void generic_device_free(device_info *devinfo) for (curdev_ptr = devinfo->head; *curdev_ptr != devinfo && *curdev_ptr != NULL; curdev_ptr = &(*curdev_ptr)->next) ; if (*curdev_ptr == devinfo) *curdev_ptr = devinfo->next; - + // free the copy of the name if present if (devinfo->name != NULL) { @@ -1835,11 +1835,11 @@ static void generic_device_reset(device_info *devinfo) // keyboard case if (devinfo->head == &keyboard_list) memset(&devinfo->keyboard, 0, sizeof(devinfo->keyboard)); - + // mouse/lightgun case else if (devinfo->head == &mouse_list || devinfo->head == &lightgun_list) memset(&devinfo->mouse, 0, sizeof(devinfo->mouse)); - + // joystick case else if (devinfo->head == &joystick_list) { @@ -1855,7 +1855,7 @@ static void generic_device_reset(device_info *devinfo) static INT32 generic_button_get_state(void *device_internal, void *item_internal) { INT32 *itemdata = (INT32 *) item_internal; - + // return the current state return *itemdata >> 7; } @@ -1868,7 +1868,7 @@ static INT32 generic_button_get_state(void *device_internal, void *item_internal static INT32 generic_axis_get_state(void *device_internal, void *item_internal) { INT32 *axisdata = (INT32 *) item_internal; - + // return the current state return *axisdata; } diff --git a/src/osd/sdl/main.c b/src/osd/sdl/main.c index ca1a305dd4d..1e047108306 100644 --- a/src/osd/sdl/main.c +++ b/src/osd/sdl/main.c @@ -5,7 +5,7 @@ // Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. // -// SDLMAME by Olivier Galibert and R. Belmont +// SDLMAME by Olivier Galibert and R. Belmont // //============================================================ diff --git a/src/osd/sdl/osd_opengl.h b/src/osd/sdl/osd_opengl.h index c835fdbca11..655ac01f0ad 100644 --- a/src/osd/sdl/osd_opengl.h +++ b/src/osd/sdl/osd_opengl.h @@ -2,21 +2,21 @@ #ifndef MANGLE /*************************************************************** - * + * * Standard Header - * + * ***************************************************************/ #ifndef _OSD_OPENGL_H #define _OSD_OPENGL_H - + #if USE_OPENGL - + /* equivalent to #include <GL/gl.h> - * #include <GL/glext.h> - */ + * #include <GL/glext.h> + */ #include <SDL/SDL_version.h> - + #if (SDL_VERSION_ATLEAST(1,2,10)) #if defined(SDLMAME_WIN32) // Avoid that winnt.h (included via sdl_opengl.h, windows.h, windef.h includes intrin.h @@ -25,51 +25,51 @@ #include <SDL/SDL_opengl.h> #else /* - * SDL 1.2.9 does not provide everything we need - * We therefore distribute it ourselves - */ + * SDL 1.2.9 does not provide everything we need + * We therefore distribute it ourselves + */ #include "SDL1211_opengl.h" -#endif +#endif #ifdef USE_DISPATCH_GL #define OSD_GL(ret,func,params) ret (APIENTRY *func) params; #define OSD_GL_UNUSED(ret,func,params) - + typedef struct _osd_gl_dispatch osd_gl_dispatch; - - struct _osd_gl_dispatch + + struct _osd_gl_dispatch { #define GET_GLFUNC 1 #include "osd_opengl.h" #undef GET_GLFUNC }; - + #undef OSD_GL #undef OSD_GL_UNUSED - + extern osd_gl_dispatch *gl_dispatch; - + /* - * Use gl_mangle to map function names - */ - + * Use gl_mangle to map function names + */ + #define MANGLE(x) gl_dispatch->gl ## x #include "osd_opengl.h" - + #endif /* USE_DISPATCH_GL */ - + #endif /* USE_OPENGL */ - + #endif /* _OSD_OPENGL_H */ #else /* MANGLE */ /*************************************************************** - * - * Used to redefine opengl functions - * - * Credits: taken from gl_mangle.h - * - ***************************************************************/ + * + * Used to redefine opengl functions + * + * Credits: taken from gl_mangle.h + * + ***************************************************************/ #define glAccum MANGLE(Accum) #define glActiveStencilFaceEXT MANGLE(ActiveStencilFaceEXT) @@ -1517,13 +1517,13 @@ #endif /* MANGLE */ #else /* GET_GLFUNC */ /*************************************************************** - * - * Used recursively for prototyping and function assignment - * - * Credits: taken from sdl_glfuncs.h - * - ***************************************************************/ - + * + * Used recursively for prototyping and function assignment + * + * Credits: taken from sdl_glfuncs.h + * + ***************************************************************/ + OSD_GL_UNUSED(void,glAccum,(GLenum,GLfloat)) OSD_GL_UNUSED(void,glAlphaFunc,(GLenum,GLclampf)) OSD_GL_UNUSED(GLboolean,glAreTexturesResident,(GLsizei,const GLuint*,GLboolean*)) diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index 4aae58b7644..d8508934871 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -3,204 +3,204 @@ /* Notes - - Known bugs: - - * SDL1.3/X11: Some compound keys, e.g. "'" are not supported by SDL driver - * SDL1.3: sdlvideofps does not take -numscreens>1 into account. - * SDL1.3/WIN32: crashes with -rd d3d - * SDL1.3/WIN32: resizing does not work - - - fixed returning (w,h) = (0,0) in get_max_bounds - - new video driver "sdl13" utilitizing SDL texture and line - drawing support. Accelerated drivers like directfb now - may attain opengl speed. DirectFB does with a radeon card. - The driver determines which pixel formats perform best and - converts textures to these pixel formats. - Supported options: - -waitvsync - -filter - -prescale - Supported renderdrivers: - X11: opengl, software, x11 (no artwork!) - DirectFB: directfb, software, opengl (special setup, slow) - Windows: software, gdi (no artwork) - - SDL1.3: Clear bck when moving - - SDL1.3: now compiles on win32 - - SDL1.3: Support screen refresh rates, provided the sdl video - layer supports them (e.g. X11). - - Use video_config.waitvsync (previously option was queried) - - -video soft / -sm now supports -prescale - - removed reqwidth, reqheight from sdl_monitor_info; not used anywhere - - removed layerconfig from sdl_video_config; not used anywhere - - - fixed yuv issues (firefox) / this was a bug I introduced - - removed deprecat.h from output.c - - Separated keyboard and mouse initialization into separate functions - - added _FORTIFY_SOURCE to verbose compiler define output. - - remove MAX_CPU from debugwin.c - - fixed vsync handling in SDL1.3 in soft/opengl drivers - - "waitvsync" also supported by "soft" driver in SDL1.3 - - multiple mice and keyboards supported in SDL1.3 - - support for DISTRO= make option - - got rid of "-joymap" and "-joymap_file" - - add -joy_idx[0-7] -keyb_idx[0-7] -mouse_idx[0-7] which - specify, which device is allocated to to e.g. Mouse 1, Mouse 2, ... - - moved define of THREAD_COOPERATIVE into sdl.mak and renamed to - NO_THREAD_COOPERATIVE. Changed references to #ifndef - - define NO_DEBUGGER in sdl.mak - - Solaris now uses -DNO_AFFINITY_NP - - added machine to window_info, removed deprecat.h from drawogl.c - - - For DEBUG=1 builds, disable input grapping while windowed - - Fixed WIN32 compile - Wrote setenv function since mingw does not provide one. - Implemented osd_event_* as inline functions for win32 build. - We should at some point merge sdlwork.c and winwork.c and push it - to the core, letting sdlsync.c provide the necessary details. - - Removed keybled.c and references - - Added output.c and output.h. These will look for a fifo or file - /tmp/sdlmame_out and write output notifiers to it. - Added a sample client ledutil.sh to src/osd/sdl which turns - leds on and off and provides a debug (log) facility. - - removed os2work.c - - - replaced window->render_lock with event window->rendered_event - For multiple windows and "-mt", the old code would allow filling up - the workqueue with 1000s of entries, since the lock would not block while - another window is rendered. The osd_event establishes a barrier which - is only freed if the last window blit operation has finished. - - Set SDL_VIDEO_GL_DRIVER if -gl_lib is given. The SDL directfb driver is picky about - this. Added reminder: FIXME: move lib loading code from drawogl.c here. This may be - used to disable opengl if no library was loaded. - - SDL1.3/video=opengl: Fixed windows not being updated after another window was resized - - for -verbose, output some information about renderer (-video soft) - - initialize mouse_enabled with option "-mouse". Affects both SDL1.2 and SDL1.3 - This will hide the mouse if you specify "-mouse". - - SDL1.2: added blitmode "async" which sets SDL_ASYNCBLIT - - SDL1.2: removed blitmodes "hwbest" and "hwblit" - - added blitmode "hwbest" for antialiased and smoothed scaling now that the - directfb driver supports it. This is also supported by the 1.3 opengl - render backend - - added sdlinput_release_keys to cope with lost keyboard events in SDL1.3 - - some identing in drawogl.c - - rename SDL_* macros to SDLMAME_* (avoid name clashes) - - got rid of VIDEO_SCALE_MODE constants. Scale modes are now handled in drawsdl.c. - Starting mame with eg. -video soft -sm yuy2 on X11 no longer crashes. - - some more changes to input.c to avoid resize loops (issue for directfb) - - - working ui mouse inputs for SDL1.2 and SDL1.3 incl. yuv modes - - added blitmode "hwblit" (SDL1.3) for rgb hardware scaling - - rename "-yuvmode" option to "-scalemode" - - rename yuv_mode and derivatives to scale_mode - - moved extra_flags into sdl_info - - moved callbacks indow sdl_window_info - - made a number of flags (e.g. yuvmode) window relative + - Known bugs: + + * SDL1.3/X11: Some compound keys, e.g. "'" are not supported by SDL driver + * SDL1.3: sdlvideofps does not take -numscreens>1 into account. + * SDL1.3/WIN32: crashes with -rd d3d + * SDL1.3/WIN32: resizing does not work + + - fixed returning (w,h) = (0,0) in get_max_bounds + - new video driver "sdl13" utilitizing SDL texture and line + drawing support. Accelerated drivers like directfb now + may attain opengl speed. DirectFB does with a radeon card. + The driver determines which pixel formats perform best and + converts textures to these pixel formats. + Supported options: + -waitvsync + -filter + -prescale + Supported renderdrivers: + X11: opengl, software, x11 (no artwork!) + DirectFB: directfb, software, opengl (special setup, slow) + Windows: software, gdi (no artwork) + - SDL1.3: Clear bck when moving + - SDL1.3: now compiles on win32 + - SDL1.3: Support screen refresh rates, provided the sdl video + layer supports them (e.g. X11). + - Use video_config.waitvsync (previously option was queried) + - -video soft / -sm now supports -prescale + - removed reqwidth, reqheight from sdl_monitor_info; not used anywhere + - removed layerconfig from sdl_video_config; not used anywhere + + - fixed yuv issues (firefox) / this was a bug I introduced + - removed deprecat.h from output.c + - Separated keyboard and mouse initialization into separate functions + - added _FORTIFY_SOURCE to verbose compiler define output. + - remove MAX_CPU from debugwin.c + - fixed vsync handling in SDL1.3 in soft/opengl drivers + - "waitvsync" also supported by "soft" driver in SDL1.3 + - multiple mice and keyboards supported in SDL1.3 + - support for DISTRO= make option + - got rid of "-joymap" and "-joymap_file" + - add -joy_idx[0-7] -keyb_idx[0-7] -mouse_idx[0-7] which + specify, which device is allocated to to e.g. Mouse 1, Mouse 2, ... + - moved define of THREAD_COOPERATIVE into sdl.mak and renamed to + NO_THREAD_COOPERATIVE. Changed references to #ifndef + - define NO_DEBUGGER in sdl.mak + - Solaris now uses -DNO_AFFINITY_NP + - added machine to window_info, removed deprecat.h from drawogl.c + + - For DEBUG=1 builds, disable input grapping while windowed + - Fixed WIN32 compile + Wrote setenv function since mingw does not provide one. + Implemented osd_event_* as inline functions for win32 build. + We should at some point merge sdlwork.c and winwork.c and push it + to the core, letting sdlsync.c provide the necessary details. + - Removed keybled.c and references + - Added output.c and output.h. These will look for a fifo or file + /tmp/sdlmame_out and write output notifiers to it. + Added a sample client ledutil.sh to src/osd/sdl which turns + leds on and off and provides a debug (log) facility. + - removed os2work.c + + - replaced window->render_lock with event window->rendered_event + For multiple windows and "-mt", the old code would allow filling up + the workqueue with 1000s of entries, since the lock would not block while + another window is rendered. The osd_event establishes a barrier which + is only freed if the last window blit operation has finished. + - Set SDL_VIDEO_GL_DRIVER if -gl_lib is given. The SDL directfb driver is picky about + this. Added reminder: FIXME: move lib loading code from drawogl.c here. This may be + used to disable opengl if no library was loaded. + - SDL1.3/video=opengl: Fixed windows not being updated after another window was resized + - for -verbose, output some information about renderer (-video soft) + - initialize mouse_enabled with option "-mouse". Affects both SDL1.2 and SDL1.3 + This will hide the mouse if you specify "-mouse". + - SDL1.2: added blitmode "async" which sets SDL_ASYNCBLIT + - SDL1.2: removed blitmodes "hwbest" and "hwblit" + - added blitmode "hwbest" for antialiased and smoothed scaling now that the + directfb driver supports it. This is also supported by the 1.3 opengl + render backend + - added sdlinput_release_keys to cope with lost keyboard events in SDL1.3 + - some identing in drawogl.c + - rename SDL_* macros to SDLMAME_* (avoid name clashes) + - got rid of VIDEO_SCALE_MODE constants. Scale modes are now handled in drawsdl.c. + Starting mame with eg. -video soft -sm yuy2 on X11 no longer crashes. + - some more changes to input.c to avoid resize loops (issue for directfb) + + - working ui mouse inputs for SDL1.2 and SDL1.3 incl. yuv modes + - added blitmode "hwblit" (SDL1.3) for rgb hardware scaling + - rename "-yuvmode" option to "-scalemode" + - rename yuv_mode and derivatives to scale_mode + - moved extra_flags into sdl_info + - moved callbacks indow sdl_window_info + - made a number of flags (e.g. yuvmode) window relative - changing of yuvmodes and opengl scale effects is working with SDL 1.3 - - improved fullscreen handling - - removed HAS_WINDOW_MENU - this has no effect nowhere - - removed underscores in header defines, e.g. __SDL_SYNC__ ==> __SDLSYNC__ - - added SDLMAME_HAS_DEBUGGER define - - removed #if 0 inw window.c - - added option "-audiodriver" to specify the SDL audio driver - - added option "-videodriver" to specify the SDL video driver - - added option "-renderdriver" to specify the SDL renderer driver - - changed environment SDLMAME_GL_LIB into option -gl_lib - - added some more SDL_ENV defines - - move keymap reading into separate function - - SDL_EnableUNICODE for all builds (not only MESS) - - SDL1.3 : Mouse & text input for ui - - - removed osd_event_wait_multiple from sdlsync.h - - removed some includes not needed - - reorganized texcopy/scale2x - - removed effect.h - - removed effect_func.h - - indenting - - put osd_copyfile, osd_stat into #ifdef MESS - - added code which implements events without the need - for pthreads. This is commented out, since - owever, it horribly fails, if - threads > num processors as is the case if you - enable "-mt" - - rename mame_bitmap to bitmap_t - - introduced define OSDWORK_CALLBACK to prototype and - define functions to be passed to sdlwork.c - - - fixes from judge for warnings / may reappear (glade) - - more warnings fixed / may reappear (glade) - - moved osdefs.h into sdlprefix.h - - removed osdefs.h - - finally removed sdlmisc.h - - - create drawogl.c and moved ogl relevant stuff there - - draw.window_init() now called after window creation - - removed window.opengl flag - - added sdl_window_info as parameter to all functions in window.h - - rename SDL_VERSIONNUM to SDL_VERSION_ATLEAST - - removed all uclock stuff in sdlmisc.[ch] - - minor cleanups - - - fixed compile issues against SDL13 - - fixed input issues with SDL13 - - stricter checks for USE_OPENGL, e.g. for options - - move sdlvideo_loadgl to window.c, rename it to sdlwindow_loadgl and make it static - - moved yuv_blit.c into drawsdl.c - - renamed compute_blit_surface_size to sdlwindow_blit_surface_size - - renamed drawsdl_destroy_all_textures to drawogl_destroy_all_textures and - moved it to _sdl_draw_callbacks - - removed print_colums - - rename misc.h to sdlmisc.h - - moved some includes from .h to .c - - rename led_init to sdlled_init for consistency - - rename sdl_init_audio to sdlaudio_init for consistency - - fixed some indentation issues - - removed ticker.h & dirty.h - - - changed all [f]printf to mame_printf_verbose|error|warning - - removed obsolete frameskipping code - - removed obsolete throttle code - - removed fastforward - - removed framestorun - - introduced SDLOPTION constants for a number of options - - add more verbose info for YUV - - - removed dirty.h - - removed ticker.h - - - remove win_trying_to_quit - - changed win_use_mouse to static use_mouse - - removed win_key_trans_table - - removed keyboard typematic definitions from input.h - - made sdl_monitor_list static - - removed hwstretch (sdl_video_config) - - removed syncrefresh (sdl_video_config) - - removed triplebuf (sdl_video_config) - - removed sdl_has_menu - - fixed memory_leak (window.c) - - - moved prototypes from drawsdl.c to window.h - - removed joystick calibration code - - "#if 0" code which is unreachable - - "#if 0" code which is never used - - moved pick_best_mode to window.c - - removed pause_brightness option - - added more SDLOPTION_ defines - - - renamed void yuv_lookup_init to drawsdl_yuv_init (global namespace) - - rmoved some obsolete code - - add SDL1.3 compatibility - - - fixed some compile issues - - moved clear_surface into window thread - - got SDL1.3 -mt working - still crashing on exit - - - removed "digital" option - - removed device selection options - - added more SDLOPTION defines + - improved fullscreen handling + - removed HAS_WINDOW_MENU - this has no effect nowhere + - removed underscores in header defines, e.g. __SDL_SYNC__ ==> __SDLSYNC__ + - added SDLMAME_HAS_DEBUGGER define + - removed #if 0 inw window.c + - added option "-audiodriver" to specify the SDL audio driver + - added option "-videodriver" to specify the SDL video driver + - added option "-renderdriver" to specify the SDL renderer driver + - changed environment SDLMAME_GL_LIB into option -gl_lib + - added some more SDL_ENV defines + - move keymap reading into separate function + - SDL_EnableUNICODE for all builds (not only MESS) + - SDL1.3 : Mouse & text input for ui + + - removed osd_event_wait_multiple from sdlsync.h + - removed some includes not needed + - reorganized texcopy/scale2x + - removed effect.h + - removed effect_func.h + - indenting + - put osd_copyfile, osd_stat into #ifdef MESS + - added code which implements events without the need + for pthreads. This is commented out, since + owever, it horribly fails, if + threads > num processors as is the case if you + enable "-mt" + - rename mame_bitmap to bitmap_t + - introduced define OSDWORK_CALLBACK to prototype and + define functions to be passed to sdlwork.c + + - fixes from judge for warnings / may reappear (glade) + - more warnings fixed / may reappear (glade) + - moved osdefs.h into sdlprefix.h + - removed osdefs.h + - finally removed sdlmisc.h + + - create drawogl.c and moved ogl relevant stuff there + - draw.window_init() now called after window creation + - removed window.opengl flag + - added sdl_window_info as parameter to all functions in window.h + - rename SDL_VERSIONNUM to SDL_VERSION_ATLEAST + - removed all uclock stuff in sdlmisc.[ch] + - minor cleanups + + - fixed compile issues against SDL13 + - fixed input issues with SDL13 + - stricter checks for USE_OPENGL, e.g. for options + - move sdlvideo_loadgl to window.c, rename it to sdlwindow_loadgl and make it static + - moved yuv_blit.c into drawsdl.c + - renamed compute_blit_surface_size to sdlwindow_blit_surface_size + - renamed drawsdl_destroy_all_textures to drawogl_destroy_all_textures and + moved it to _sdl_draw_callbacks + - removed print_colums + - rename misc.h to sdlmisc.h + - moved some includes from .h to .c + - rename led_init to sdlled_init for consistency + - rename sdl_init_audio to sdlaudio_init for consistency + - fixed some indentation issues + - removed ticker.h & dirty.h + + - changed all [f]printf to mame_printf_verbose|error|warning + - removed obsolete frameskipping code + - removed obsolete throttle code + - removed fastforward + - removed framestorun + - introduced SDLOPTION constants for a number of options + - add more verbose info for YUV + + - removed dirty.h + - removed ticker.h + + - remove win_trying_to_quit + - changed win_use_mouse to static use_mouse + - removed win_key_trans_table + - removed keyboard typematic definitions from input.h + - made sdl_monitor_list static + - removed hwstretch (sdl_video_config) + - removed syncrefresh (sdl_video_config) + - removed triplebuf (sdl_video_config) + - removed sdl_has_menu + - fixed memory_leak (window.c) + + - moved prototypes from drawsdl.c to window.h + - removed joystick calibration code + - "#if 0" code which is unreachable + - "#if 0" code which is never used + - moved pick_best_mode to window.c + - removed pause_brightness option + - added more SDLOPTION_ defines + + - renamed void yuv_lookup_init to drawsdl_yuv_init (global namespace) + - rmoved some obsolete code + - add SDL1.3 compatibility + + - fixed some compile issues + - moved clear_surface into window thread + - got SDL1.3 -mt working - still crashing on exit + + - removed "digital" option + - removed device selection options + - added more SDLOPTION defines */ //============================================================ -// System dependent defines +// System dependent defines //============================================================ // Process events in worker thread @@ -224,13 +224,13 @@ #endif #if defined(NO_DEBUGGER) -#define SDLMAME_HAS_DEBUGGER (0) +#define SDLMAME_HAS_DEBUGGER (0) #else -#define SDLMAME_HAS_DEBUGGER (1) +#define SDLMAME_HAS_DEBUGGER (1) #endif //============================================================ -// Defines +// Defines //============================================================ #define SDLOPTION_INIPATH "inipath" @@ -238,7 +238,7 @@ #define SDLOPTION_SCREEN(x) "screen" x #define SDLOPTION_ASPECT(x) "aspect" x #define SDLOPTION_RESOLUTION(x) "resolution" x -#define SDLOPTION_VIEW(x) "view" x +#define SDLOPTION_VIEW(x) "view" x #define SDLOPTION_SDLVIDEOFPS "sdlvideofps" #define SDLOPTION_KEEPASPECT "keepaspect" #define SDLOPTION_WINDOW "window" @@ -264,9 +264,9 @@ #define SDLOPTION_OSLOG "oslog" #define SDLOPTION_SIXAXIS "sixaxis" -#define SDLOPTION_JOYINDEX "joy_idx" -#define SDLOPTION_KEYBINDEX "keyb_idx" -#define SDLOPTION_MOUSEINDEX "mouse_index" +#define SDLOPTION_JOYINDEX "joy_idx" +#define SDLOPTION_KEYBINDEX "keyb_idx" +#define SDLOPTION_MOUSEINDEX "mouse_index" #define SDLOPTION_SHADER_MAME(x) "glsl_shader_mame" x #define SDLOPTION_SHADER_SCREEN(x) "glsl_shader_screen" x @@ -316,13 +316,13 @@ //============================================================ -// sound.c +// sound.c //============================================================ void sdlaudio_init(running_machine *machine); //============================================================ -// sdlwork.c +// sdlwork.c //============================================================ extern int sdl_num_processors; diff --git a/src/osd/sdl/osinline.h b/src/osd/sdl/osinline.h index d020e89a912..0a9c6f428a8 100644 --- a/src/osd/sdl/osinline.h +++ b/src/osd/sdl/osinline.h @@ -1,6 +1,6 @@ //============================================================ // -// osinline.h - GNU C inline functions +// osinline.h - GNU C inline functions // //============================================================ @@ -11,7 +11,7 @@ //============================================================ -// INLINE FUNCTIONS +// INLINE FUNCTIONS //============================================================ #if defined(__i386__) || defined(__x86_64__) diff --git a/src/osd/sdl/output.c b/src/osd/sdl/output.c index c33b88cb1a7..3fe9efab05f 100644 --- a/src/osd/sdl/output.c +++ b/src/osd/sdl/output.c @@ -29,7 +29,7 @@ /* * Using long/int should be sufficient on all - * architectures. + * architectures. */ @@ -74,11 +74,11 @@ PID_CAST osd_getpid(void) void sdloutput_init(running_machine *machine) { int fildes; - + add_exit_callback(machine, sdloutput_exit); fildes = open(SDLMAME_OUTPUT, O_RDWR | O_NONBLOCK); - + if (fildes < 0) { output = NULL; @@ -87,12 +87,12 @@ void sdloutput_init(running_machine *machine) else { output = fdopen(fildes, "w"); - + mame_printf_verbose("ouput: opened output notifier file %s\n", SDLMAME_OUTPUT); fprintf(output, "MAME " PID_FMT " START %s\n", osd_getpid(), machine->gamedrv->name); fflush(output); } - + output_set_notifier(NULL, notifier_callback, NULL); } diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index 027b36aed61..ccec6f91edb 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -7,7 +7,7 @@ # Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. # Visit http://mamedev.org for licensing and usage restrictions. # -# SDLMAME by Olivier Galibert and R. Belmont +# SDLMAME by Olivier Galibert and R. Belmont # ########################################################################### @@ -41,8 +41,8 @@ # this will also add a rpath to the executable # MESA_INSTALL_ROOT = /usr/local/dfb_GL -# uncomment the next line to build a binary using -# GL-dispatching. +# uncomment the next line to build a binary using +# GL-dispatching. # This option takes precedence over MESA_INSTALL_ROOT USE_DISPATCH_GL = 1 @@ -73,19 +73,19 @@ CCOMFLAGS += $(OPT_FLAGS) #------------------------------------------------- # distribution may change things #------------------------------------------------- - + ifeq ($(DISTRO),) DISTRO = generic -else +else ifeq ($(DISTRO),debian-stable) DEFS += -DNO_AFFINITY_NP -else +else ifeq ($(DISTRO),ubuntu-intrepid) # Force gcc-4.2 on ubuntu-intrepid CC = @gcc -V 4.2 LD = g++-4.2 #LDFLAGS += -lsupc++ -static-libgcc -else +else ifeq ($(DISTRO),gcc44-generic) CC = @gcc -V 4.4 LD = @g++ -V 4.4 @@ -151,7 +151,7 @@ SYNC_IMPLEMENTATION = tc endif ifeq ($(TARGETOS),unix) -DEFS += -DSDLMAME_UNIX +DEFS += -DSDLMAME_UNIX ifndef NO_X11 DEFS += -DSDLMAME_X11 else @@ -160,7 +160,7 @@ endif endif ifeq ($(TARGETOS),macosx) -DEFS += -DSDLMAME_UNIX -DSDLMAME_MACOSX +DEFS += -DSDLMAME_UNIX -DSDLMAME_MACOSX SYNC_IMPLEMENTATION = ntc MAINLDFLAGS = -Xlinker -all_load ifdef BIGENDIAN @@ -215,10 +215,10 @@ SDLMAIN = OSDCOREOBJS = \ $(SDLOBJ)/strconv.o \ $(SDLOBJ)/sdldir.o \ - $(SDLOBJ)/sdlfile.o \ + $(SDLOBJ)/sdlfile.o \ $(SDLOBJ)/sdlos_$(TARGETOS).o \ $(SDLOBJ)/sdlsync_$(SYNC_IMPLEMENTATION).o \ - $(SDLOBJ)/sdlwork.o + $(SDLOBJ)/sdlwork.o # any "main" must be in LIBOSD or else the build will fail! # for the windows build, we just add it to libocore as well. @@ -296,7 +296,7 @@ endif # Non-X11 builds can not use the debugger ifndef NO_X11 OSDCOREOBJS += $(SDLOBJ)/debugwin.o $(SDLOBJ)/dview.o $(SDLOBJ)/debug-sup.o $(SDLOBJ)/debug-intf.o -CCOMFLAGS += `pkg-config --cflags gtk+-2.0` `pkg-config --cflags gconf-2.0` +CCOMFLAGS += `pkg-config --cflags gtk+-2.0` `pkg-config --cflags gconf-2.0` LIBS += `pkg-config --libs gtk+-2.0` `pkg-config --libs gconf-2.0` CCOMFLAGS += -DGTK_DISABLE_DEPRECATED else @@ -324,7 +324,7 @@ ifeq ($(TARGETOS),win32) ifdef SDL_INSTALL_ROOT CCOMFLAGS += -I$(SDL_INSTALL_ROOT)/include -LIBS += -L$(SDL_INSTALL_ROOT)/lib +LIBS += -L$(SDL_INSTALL_ROOT)/lib # -Wl,-rpath,$(SDL_INSTALL_ROOT)/lib -lSDL $(LIBGL) endif @@ -342,7 +342,7 @@ OSDCOREOBJS += $(SDLOBJ)/debugwin.o LDFLAGS += -static-libgcc # Static linking of SDL -LIBS += -Wl,-Bstatic -lSDL -Wl,-Bdynamic +LIBS += -Wl,-Bstatic -lSDL -Wl,-Bdynamic LIBS += -lopengl32 -luser32 -lgdi32 -lddraw -ldsound -ldxguid -lwinmm -ladvapi32 -lcomctl32 -lshlwapi endif # Win32 @@ -354,7 +354,7 @@ OSDOBJS += $(SDLOBJ)/SDLMain_tmpl.o ifndef MACOSX_USE_LIBSDL # Compile using framework (compile using libSDL is the exception) -LIBS += -framework SDL -framework Cocoa -framework OpenGL -lpthread +LIBS += -framework SDL -framework Cocoa -framework OpenGL -lpthread else # Compile using installed libSDL (Fink or MacPorts): # @@ -407,10 +407,10 @@ $(LIBOSD): $(OSDOBJS) # testkeys #------------------------------------------------- -$(SDLOBJ)/testkeys.o: $(SDLSRC)/testkeys.c +$(SDLOBJ)/testkeys.o: $(SDLSRC)/testkeys.c @echo Compiling $<... $(CC) $(CFLAGS) $(DEFS) -c $< -o $@ - + TESTKEYSOBJS = \ $(SDLOBJ)/testkeys.o \ @@ -420,12 +420,12 @@ testkeys$(EXE): $(TESTKEYSOBJS) $(LIBUTIL) $(LIBOCORE) sdlclean: rm -f .depend - + testlib: -echo LIBS: $(LIBS) -echo DEFS: $(DEFS) -echo CORE: $(OSDCOREOBJS) - + ifneq ($(TARGETOS),win32) depend: rm -f .depend diff --git a/src/osd/sdl/sdldir.c b/src/osd/sdl/sdldir.c index d0edea43ba7..0236f769036 100644 --- a/src/osd/sdl/sdldir.c +++ b/src/osd/sdl/sdldir.c @@ -120,7 +120,7 @@ osd_directory *osd_opendir(const char *dirname) if (tmpstr[0] == '$') { char *envval; - envstr = (char *) malloc(strlen(tmpstr)+1); + envstr = (char *) malloc(strlen(tmpstr)+1); strcpy(envstr, tmpstr); @@ -138,7 +138,7 @@ osd_directory *osd_opendir(const char *dirname) j = strlen(envval) + strlen(tmpstr) + 1; free(tmpstr); tmpstr = (char *) malloc(j); - + // start with the value of $HOME strcpy(tmpstr, envval); // replace the null with a path separator again diff --git a/src/osd/sdl/sdlfile.c b/src/osd/sdl/sdlfile.c index acc52d6d8f9..40dab6a040c 100644 --- a/src/osd/sdl/sdlfile.c +++ b/src/osd/sdl/sdlfile.c @@ -49,7 +49,7 @@ static UINT32 create_path_recursive(char *path); struct _osd_file { int handle; - char filename[1]; + char filename[1]; }; @@ -136,7 +136,7 @@ file_error osd_open(const char *path, UINT32 openflags, osd_file **file, UINT64 filerr = FILERR_INVALID_ACCESS; goto error; } - + tmpstr = (char *) malloc(strlen((*file)->filename)+1); strcpy(tmpstr, (*file)->filename); @@ -144,7 +144,7 @@ file_error osd_open(const char *path, UINT32 openflags, osd_file **file, UINT64 if (tmpstr[0] == '$') { char *envval; - envstr = (char *) malloc(strlen(tmpstr)+1); + envstr = (char *) malloc(strlen(tmpstr)+1); strcpy(envstr, tmpstr); @@ -162,7 +162,7 @@ file_error osd_open(const char *path, UINT32 openflags, osd_file **file, UINT64 j = strlen(envval) + strlen(tmpstr) + 1; free(tmpstr); tmpstr = (char *) malloc(j); - + // start with the value of $HOME strcpy(tmpstr, envval); // replace the null with a path separator again @@ -258,7 +258,7 @@ file_error osd_read(osd_file *file, void *buffer, UINT64 offset, UINT32 count, U if (result < 0) #elif defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_OS2) lseek(file->handle, (UINT32)offset&0xffffffff, SEEK_SET); - result = read(file->handle, buffer, count); + result = read(file->handle, buffer, count); if (result < 0) #elif defined(SDLMAME_UNIX) result = pread64(file->handle, buffer, count, offset); @@ -286,7 +286,7 @@ file_error osd_write(osd_file *file, const void *buffer, UINT64 offset, UINT32 c if (!result) #elif defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_OS2) lseek(file->handle, (UINT32)offset&0xffffffff, SEEK_SET); - result = write(file->handle, buffer, count); + result = write(file->handle, buffer, count); if (!result) #elif defined(SDLMAME_UNIX) result = pwrite64(file->handle, buffer, count, offset); @@ -322,7 +322,7 @@ file_error osd_rmfile(const char *filename) { if (unlink(filename) == -1) { - return error_to_file_error(errno); + return error_to_file_error(errno); } return FILERR_NONE; @@ -374,7 +374,7 @@ int osd_get_physical_drive_geometry(const char *filename, UINT32 *cylinders, UIN /*============================================================ */ /* osd_is_path_separator */ /*============================================================ */ - + static int osd_is_path_separator(char c) { return (c == '/') || (c == '\\'); @@ -386,7 +386,7 @@ static int osd_is_path_separator(char c) int osd_is_absolute_path(const char *path) { int result; - + if (osd_is_path_separator(path[0])) result = TRUE; #if !defined(SDLMAME_WIN32) && !defined(SDLMAME_OS2) @@ -401,12 +401,12 @@ int osd_is_absolute_path(const char *path) else result = FALSE; return result; -} +} /* not used anywhere */ -#if 0 +#if 0 //============================================================ -// osd_mkdir +// osd_mkdir //============================================================ file_error osd_mkdir(const char *dir) @@ -424,7 +424,7 @@ file_error osd_mkdir(const char *dir) } //============================================================ -// osd_rmdir +// osd_rmdir //============================================================ static file_error osd_rmdir(const char *dir) @@ -442,7 +442,7 @@ static file_error osd_rmdir(const char *dir) #ifdef MESS //============================================================ -// osd_copyfile +// osd_copyfile // FIXME: this will not work with blanks in filename ... //============================================================ @@ -470,7 +470,7 @@ osd_directory_entry *osd_stat(const char *path) #else struct stat64 st; #endif - + #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_OS2) err = stat(path, &st); #else @@ -486,7 +486,7 @@ osd_directory_entry *osd_stat(const char *path) result->name = ((char *) result) + sizeof(*result); result->type = S_ISDIR(st.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE; result->size = (UINT64)st.st_size; - + return result; } #endif diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index b08b73969ed..a3e9077fcaa 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -60,7 +60,7 @@ void MorphToPM() #endif //============================================================ -// LOCAL VARIABLES +// LOCAL VARIABLES //============================================================ #ifdef MESS @@ -85,7 +85,7 @@ static char cwd[512]; static const options_entry mame_sdl_options[] = { - { SDLOPTION_INIPATH, INI_PATH, 0, "path to ini files" }, + { SDLOPTION_INIPATH, INI_PATH, 0, "path to ini files" }, // debugging options { NULL, NULL, OPTION_HEADER, "DEBUGGING OPTIONS" }, @@ -126,30 +126,30 @@ static const options_entry mame_sdl_options[] = { 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", 0, "enable OpenGL GLSL filtering instead of FF filtering 0-plain, 1-bilinear (default)" }, - { SDLOPTION_SHADER_MAME("0"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 0" }, - { SDLOPTION_SHADER_MAME("1"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 1" }, - { SDLOPTION_SHADER_MAME("2"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 2" }, - { SDLOPTION_SHADER_MAME("3"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 3" }, - { SDLOPTION_SHADER_MAME("4"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 4" }, - { SDLOPTION_SHADER_MAME("5"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 5" }, - { SDLOPTION_SHADER_MAME("6"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 6" }, - { SDLOPTION_SHADER_MAME("7"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 7" }, - { SDLOPTION_SHADER_MAME("8"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 8" }, - { SDLOPTION_SHADER_MAME("9"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 9" }, - { SDLOPTION_SHADER_SCREEN("0"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 0" }, - { SDLOPTION_SHADER_SCREEN("1"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 1" }, - { SDLOPTION_SHADER_SCREEN("2"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 2" }, - { SDLOPTION_SHADER_SCREEN("3"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 3" }, - { SDLOPTION_SHADER_SCREEN("4"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 4" }, - { SDLOPTION_SHADER_SCREEN("5"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 5" }, - { SDLOPTION_SHADER_SCREEN("6"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 6" }, - { SDLOPTION_SHADER_SCREEN("7"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 7" }, - { SDLOPTION_SHADER_SCREEN("8"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 8" }, - { SDLOPTION_SHADER_SCREEN("9"), SDLOPTVAL_NONE, 0, "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_GLSL_FILTER, "1", 0, "enable OpenGL GLSL filtering instead of FF filtering 0-plain, 1-bilinear (default)" }, + { SDLOPTION_SHADER_MAME("0"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 0" }, + { SDLOPTION_SHADER_MAME("1"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 1" }, + { SDLOPTION_SHADER_MAME("2"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 2" }, + { SDLOPTION_SHADER_MAME("3"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 3" }, + { SDLOPTION_SHADER_MAME("4"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 4" }, + { SDLOPTION_SHADER_MAME("5"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 5" }, + { SDLOPTION_SHADER_MAME("6"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 6" }, + { SDLOPTION_SHADER_MAME("7"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 7" }, + { SDLOPTION_SHADER_MAME("8"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 8" }, + { SDLOPTION_SHADER_MAME("9"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader set mame bitmap 9" }, + { SDLOPTION_SHADER_SCREEN("0"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 0" }, + { SDLOPTION_SHADER_SCREEN("1"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 1" }, + { SDLOPTION_SHADER_SCREEN("2"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 2" }, + { SDLOPTION_SHADER_SCREEN("3"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 3" }, + { SDLOPTION_SHADER_SCREEN("4"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 4" }, + { SDLOPTION_SHADER_SCREEN("5"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 5" }, + { SDLOPTION_SHADER_SCREEN("6"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 6" }, + { SDLOPTION_SHADER_SCREEN("7"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 7" }, + { SDLOPTION_SHADER_SCREEN("8"), SDLOPTVAL_NONE, 0, "custom OpenGL GLSL shader screen bitmap 8" }, + { SDLOPTION_SHADER_SCREEN("9"), SDLOPTVAL_NONE, 0, "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)" }, #endif - + // per-window options { NULL, NULL, OPTION_HEADER, "PER-WINDOW VIDEO OPTIONS" }, { SDLOPTION_SCREEN(""), SDLOPTVAL_AUTO, 0, "explicit name of the first screen; 'auto' here will try to make a best guess" }, @@ -241,7 +241,7 @@ static const options_entry mame_sdl_options[] = #endif { SDLOPTION_AUDIODRIVER ";ad", SDLOPTVAL_AUTO, 0, "sdl audio driver to use ('alsa', 'arts', ... or 'auto' for SDL default" }, #if USE_OPENGL - { SDLOPTION_GL_LIB, SDLOPTVAL_GLLIB, 0, "alternative libGL.so to use; 'auto' for system default" }, + { SDLOPTION_GL_LIB, SDLOPTVAL_GLLIB, 0, "alternative libGL.so to use; 'auto' for system default" }, #endif // End of list @@ -256,7 +256,7 @@ static int setenv(const char *name, const char *value, int overwrite) { char *buf; int result; - + if (!overwrite) { if (getenv(name) != NULL) @@ -265,18 +265,18 @@ static int setenv(const char *name, const char *value, int overwrite) buf = (char *) malloc(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 - */ - + + /* will be referenced by environment + * Therefore it is not freed here + */ + return result; } #endif //============================================================ -// main +// main //============================================================ // we do some special sauce on Win32... @@ -287,7 +287,7 @@ int main(int argc, char **argv) int res = 0; #else - + /* gee */ extern "C" DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); @@ -334,7 +334,7 @@ int main(int argc, char *argv[]) if (display) XCloseDisplay(display); } -#endif +#endif res = cli_execute(argc, argv, mame_sdl_options); @@ -347,7 +347,7 @@ int main(int argc, char *argv[]) // already called... //SDL_Quit(); - + exit(res); return res; @@ -367,7 +367,7 @@ static void output_oslog(running_machine *machine, const char *buffer) //============================================================ -// osd_exit +// osd_exit //============================================================ static void osd_exit(running_machine *machine) @@ -378,10 +378,10 @@ static void osd_exit(running_machine *machine) } //============================================================ -// defines_verbose +// defines_verbose //============================================================ -#define MAC_EXPAND_STR(_m) #_m +#define MAC_EXPAND_STR(_m) #_m #define MACRO_VERBOSE(_mac) \ do { \ if (strcmp(MAC_EXPAND_STR(_mac), #_mac) != 0) \ @@ -445,14 +445,14 @@ static void defines_verbose(void) } //============================================================ -// osd_sdl_info +// osd_sdl_info //============================================================ static void osd_sdl_info(void) { #if SDL_VERSION_ATLEAST(1,3,0) int i, cur, num = SDL_GetNumVideoDrivers(); - + mame_printf_verbose("Available videodrivers: "); for (i=0;i<num;i++) { @@ -467,7 +467,7 @@ static void osd_sdl_info(void) { SDL_DisplayMode mode; int j; - + SDL_SelectVideoDisplay(i); mame_printf_verbose("\tDisplay #%d\n", i); if (SDL_GetDesktopDisplayMode(&mode)); @@ -495,7 +495,7 @@ static void osd_sdl_info(void) //============================================================ -// osd_init +// osd_init //============================================================ void osd_init(running_machine *machine) @@ -528,8 +528,8 @@ void osd_init(running_machine *machine) } /* Set the SDL environment variable for drivers wanting to load the - * lib at startup. - */ + * lib at startup. + */ /* FIXME: move lib loading code from drawogl.c here */ stemp = options_get_string(mame_options(), SDLOPTION_GL_LIB); @@ -578,9 +578,9 @@ void osd_init(running_machine *machine) { mame_printf_error("sdlmame: -debug not supported on X11-less builds\n\n"); osd_exit(machine); - exit(-1); + exit(-1); } - + if (sdlvideo_init(machine)) { osd_exit(machine); @@ -591,11 +591,11 @@ void osd_init(running_machine *machine) } sdlinput_init(machine); - + sdlaudio_init(machine); sdloutput_init(machine); - + if (options_get_bool(mame_options(), SDLOPTION_OSLOG)) add_logerror_callback(machine, output_oslog); diff --git a/src/osd/sdl/sdlos_macosx.c b/src/osd/sdl/sdlos_macosx.c index 5ce21f87573..eb6bf195fdc 100644 --- a/src/osd/sdl/sdlos_macosx.c +++ b/src/osd/sdl/sdlos_macosx.c @@ -156,7 +156,7 @@ int osd_num_processors(void) 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 ) @@ -164,7 +164,7 @@ int osd_num_processors(void) processors = host_basic_info.avail_cpus; } mach_port_deallocate(mach_task_self(), my_mach_host_self); - + return processors; } @@ -200,7 +200,7 @@ 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); + kill(getpid(), SIGTRAP); #else printf("Ignoring MAME exception: %s\n", message); #endif diff --git a/src/osd/sdl/sdlos_os2.c b/src/osd/sdl/sdlos_os2.c index 113f74de82d..4c20ae815d0 100644 --- a/src/osd/sdl/sdlos_os2.c +++ b/src/osd/sdl/sdlos_os2.c @@ -196,7 +196,7 @@ int osd_num_processors(void) void *osd_alloc_executable(size_t size) { void *p; - + DosAllocMem( &p, size, fALLOC ); return p; } diff --git a/src/osd/sdl/sdlos_unix.c b/src/osd/sdl/sdlos_unix.c index 610d63b3237..e38111bc28c 100644 --- a/src/osd/sdl/sdlos_unix.c +++ b/src/osd/sdl/sdlos_unix.c @@ -30,7 +30,7 @@ osd_ticks_t osd_ticks(void) { struct timeval tp; static osd_ticks_t start_sec = 0; - + gettimeofday(&tp, NULL); if (start_sec==0) start_sec = tp.tv_sec; @@ -49,7 +49,7 @@ 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()); @@ -139,7 +139,7 @@ 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); + kill(getpid(), SIGTRAP); #else printf("Ignoring MAME exception: %s\n", message); #endif diff --git a/src/osd/sdl/sdlsync.h b/src/osd/sdl/sdlsync.h index 82fec017d72..691497456a5 100644 --- a/src/osd/sdl/sdlsync.h +++ b/src/osd/sdl/sdlsync.h @@ -51,7 +51,7 @@ osd_event *osd_event_alloc(int manualreset, int initialstate); Return value: TRUE: The event was signalled - FALSE: A timeout occurred + FALSE: A timeout occurred -----------------------------------------------------------------------------*/ int osd_event_wait(osd_event *event, osd_ticks_t timeout); @@ -65,7 +65,7 @@ int osd_event_wait(osd_event *event, osd_ticks_t timeout); Return value: - None + None -----------------------------------------------------------------------------*/ void osd_event_reset(osd_event *event); @@ -79,11 +79,11 @@ void osd_event_reset(osd_event *event); Return value: - None - - Notes: - - All threads waiting for the event will be signalled. + None + + Notes: + + All threads waiting for the event will be signalled. -----------------------------------------------------------------------------*/ void osd_event_set(osd_event *event); @@ -149,10 +149,10 @@ int osd_thread_adjust_priority(osd_thread *thread, int adjust); Parameters: - thread - A pointer to a previously created thread + thread - A pointer to a previously created thread or NULL for main thread mask - bitmask to which cpus to bind - i.e. 0x01 1st cpu, 0x02, 2nd cpu, 0x04 3rd cpu + i.e. 0x01 1st cpu, 0x02, 2nd cpu, 0x04 3rd cpu Return value: diff --git a/src/osd/sdl/sdlsync_ntc.c b/src/osd/sdl/sdlsync_ntc.c index a99f50fdd20..95297340a44 100644 --- a/src/osd/sdl/sdlsync_ntc.c +++ b/src/osd/sdl/sdlsync_ntc.c @@ -35,7 +35,7 @@ #include <sys/time.h> struct _osd_lock { - volatile pthread_t holder; + volatile pthread_t holder; INT32 count; #ifdef PTR64 INT8 padding[52]; // Fill a 64-byte cache line @@ -43,10 +43,10 @@ struct _osd_lock { INT8 padding[56]; // A bit more padding #endif }; - + struct _osd_event { pthread_mutex_t mutex; - pthread_cond_t cond; + pthread_cond_t cond; volatile INT32 autoreset; volatile INT32 signalled; #ifdef PTR64 @@ -69,10 +69,10 @@ struct _osd_scalable_lock { struct { - volatile INT32 haslock; // do we have the lock? - INT32 filler[64/4-1]; // assumes a 64-byte cache line + volatile INT32 haslock; // do we have the lock? + INT32 filler[64/4-1]; // assumes a 64-byte cache line } slot[WORK_MAX_THREADS]; // one slot per thread - volatile INT32 nextindex; // index of next slot to use + volatile INT32 nextindex; // index of next slot to use }; @@ -83,7 +83,7 @@ struct _osd_scalable_lock osd_scalable_lock *osd_scalable_lock_alloc(void) { osd_scalable_lock *lock; - + lock = (osd_scalable_lock *)calloc(1, sizeof(*lock)); memset(lock, 0, sizeof(*lock)); @@ -171,7 +171,7 @@ void osd_scalable_lock_free(osd_scalable_lock *lock) { free(lock); } - + INLINE pthread_t osd_compare_exchange_pthread_t(pthread_t volatile *ptr, pthread_t compare, pthread_t exchange) { #ifdef PTR64 @@ -265,9 +265,9 @@ void osd_lock_acquire(osd_lock *lock) #endif #if 0 /* If you mean to use locks as a blocking mechanism for extended - * periods of time, you should do something like this. However, - * it kills the performance of gaelco3d. - */ + * periods of time, you should do something like this. However, + * it kills the performance of gaelco3d. + */ if (spin == 0) { struct timespec sleep = { 0, 100000 }, remaining; @@ -319,7 +319,7 @@ void osd_lock_release(osd_lock *lock) } // trying to release a lock you don't hold is bad! -// assert(lock->holder == pthread_self()); +// assert(lock->holder == pthread_self()); } //============================================================ @@ -347,7 +347,7 @@ osd_event *osd_event_alloc(int manualreset, int initialstate) pthread_cond_init(&ev->cond, NULL); ev->signalled = initialstate; ev->autoreset = !manualreset; - + return ev; } @@ -414,9 +414,9 @@ int osd_event_wait(osd_event *event, osd_ticks_t timeout) struct timeval tp; UINT64 msec = timeout * 1000 / osd_ticks_per_second(); UINT64 nsec; - + gettimeofday(&tp, NULL); - + ts.tv_sec = tp.tv_sec; nsec = (UINT64) tp.tv_usec * (UINT64) 1000 + (msec * (UINT64) 1000000); ts.tv_nsec = nsec % (UINT64) 1000000000; @@ -440,7 +440,7 @@ int osd_event_wait(osd_event *event, osd_ticks_t timeout) { printf("Error %d while waiting for pthread_cond_timedwait: %s\n", ret, strerror(ret)); } - + } while (TRUE); } } @@ -481,7 +481,7 @@ int osd_thread_adjust_priority(osd_thread *thread, int adjust) { struct sched_param sched; int policy; - + if ( pthread_getschedparam( thread->thread, &policy, &sched ) == 0 ) { sched.sched_priority += adjust; diff --git a/src/osd/sdl/sdlsync_os2.c b/src/osd/sdl/sdlsync_os2.c index cbc1fe878af..f3271e154e0 100644 --- a/src/osd/sdl/sdlsync_os2.c +++ b/src/osd/sdl/sdlsync_os2.c @@ -34,7 +34,7 @@ #define pthread_self _gettid struct _osd_lock { - volatile pthread_t holder; + volatile pthread_t holder; INT32 count; #ifdef PTR64 INT8 padding[52]; // Fill a 64-byte cache line @@ -62,10 +62,10 @@ struct _osd_scalable_lock { struct { - volatile INT32 haslock; // do we have the lock? - INT32 filler[64/4-1]; // assumes a 64-byte cache line + volatile INT32 haslock; // do we have the lock? + INT32 filler[64/4-1]; // assumes a 64-byte cache line } slot[WORK_MAX_THREADS]; // one slot per thread - volatile INT32 nextindex; // index of next slot to use + volatile INT32 nextindex; // index of next slot to use }; @@ -76,7 +76,7 @@ struct _osd_scalable_lock osd_scalable_lock *osd_scalable_lock_alloc(void) { osd_scalable_lock *lock; - + lock = (osd_scalable_lock *)calloc(1, sizeof(*lock)); memset(lock, 0, sizeof(*lock)); @@ -258,9 +258,9 @@ void osd_lock_acquire(osd_lock *lock) #endif #if 0 /* If you mean to use locks as a blocking mechanism for extended - * periods of time, you should do something like this. However, - * it kills the performance of gaelco3d. - */ + * periods of time, you should do something like this. However, + * it kills the performance of gaelco3d. + */ if (spin == 0) { struct timespec sleep = { 0, 100000 }, remaining; @@ -312,7 +312,7 @@ void osd_lock_release(osd_lock *lock) } // trying to release a lock you don't hold is bad! -// assert(lock->holder == pthread_self()); +// assert(lock->holder == pthread_self()); } //============================================================ diff --git a/src/osd/sdl/sdlsync_sdl.c b/src/osd/sdl/sdlsync_sdl.c index d728aea9392..382e2c8139d 100644 --- a/src/osd/sdl/sdlsync_sdl.c +++ b/src/osd/sdl/sdlsync_sdl.c @@ -26,7 +26,7 @@ #if VERBOSE #define LOG( x ) do { printf x; printf("\n"); } while (0) #else -#define LOG( x ) +#define LOG( x ) #endif typedef struct _hidden_mutex_t hidden_mutex_t; struct _hidden_mutex_t { @@ -34,10 +34,10 @@ struct _hidden_mutex_t { volatile INT32 locked; volatile INT32 threadid; }; - + struct _osd_event { - SDL_mutex * mutex; - SDL_cond * cond; + SDL_mutex * mutex; + SDL_cond * cond; volatile INT32 autoreset; volatile INT32 signalled; }; @@ -54,7 +54,7 @@ struct _osd_thread { struct _osd_scalable_lock { - SDL_mutex * mutex; + SDL_mutex * mutex; }; //============================================================ @@ -64,7 +64,7 @@ struct _osd_scalable_lock osd_scalable_lock *osd_scalable_lock_alloc(void) { osd_scalable_lock *lock; - + lock = (osd_scalable_lock *)calloc(1, sizeof(*lock)); lock->mutex = SDL_CreateMutex(); @@ -195,7 +195,7 @@ osd_event *osd_event_alloc(int manualreset, int initialstate) ev->cond = SDL_CreateCond(); ev->signalled = initialstate; ev->autoreset = !manualreset; - + return ev; } @@ -262,7 +262,7 @@ int osd_event_wait(osd_event *event, osd_ticks_t timeout) if (!event->signalled) { UINT64 msec = (timeout * 1000) / osd_ticks_per_second(); - + do { int ret = SDL_CondWaitTimeout(event->cond, event->mutex, msec); if ( ret == SDL_MUTEX_TIMEDOUT ) diff --git a/src/osd/sdl/sdlsync_tc.c b/src/osd/sdl/sdlsync_tc.c index 34100c09135..eeddfef0bcb 100644 --- a/src/osd/sdl/sdlsync_tc.c +++ b/src/osd/sdl/sdlsync_tc.c @@ -36,10 +36,10 @@ typedef struct _hidden_mutex_t hidden_mutex_t; struct _hidden_mutex_t { pthread_mutex_t id; }; - + struct _osd_event { pthread_mutex_t mutex; - pthread_cond_t cond; + pthread_cond_t cond; volatile INT32 autoreset; volatile INT32 signalled; #ifdef PTR64 @@ -69,7 +69,7 @@ struct _osd_scalable_lock osd_scalable_lock *osd_scalable_lock_alloc(void) { osd_scalable_lock *lock; - + lock = (osd_scalable_lock *)calloc(1, sizeof(*lock)); lock->lock = osd_lock_alloc(); @@ -122,7 +122,7 @@ void osd_lock_acquire(osd_lock *lock) { hidden_mutex_t *mutex = (hidden_mutex_t *) lock; int r; - + r = pthread_mutex_lock(&mutex->id); if (r==0) return; @@ -137,12 +137,12 @@ int osd_lock_try(osd_lock *lock) { hidden_mutex_t *mutex = (hidden_mutex_t *) lock; int r; - + r = pthread_mutex_trylock(&mutex->id); if (r==0) return 1; //if (r!=EBUSY) - // mame_printf_error("Error on trylock: %d: %s\n", r, strerror(r)); + // mame_printf_error("Error on trylock: %d: %s\n", r, strerror(r)); return 0; } @@ -186,7 +186,7 @@ osd_event *osd_event_alloc(int manualreset, int initialstate) pthread_cond_init(&ev->cond, NULL); ev->signalled = initialstate; ev->autoreset = !manualreset; - + return ev; } @@ -253,9 +253,9 @@ int osd_event_wait(osd_event *event, osd_ticks_t timeout) struct timeval tp; UINT64 msec = timeout * 1000 / osd_ticks_per_second(); UINT64 nsec; - + gettimeofday(&tp, NULL); - + ts.tv_sec = tp.tv_sec; nsec = (UINT64) tp.tv_usec * (UINT64) 1000 + (msec * (UINT64) 1000000); ts.tv_nsec = nsec % (UINT64) 1000000000; @@ -279,7 +279,7 @@ int osd_event_wait(osd_event *event, osd_ticks_t timeout) { printf("Error %d while waiting for pthread_cond_timedwait: %s\n", ret, strerror(ret)); } - + } while (TRUE); } } @@ -320,7 +320,7 @@ int osd_thread_adjust_priority(osd_thread *thread, int adjust) { struct sched_param sched; int policy; - + if ( pthread_getschedparam( thread->thread, &policy, &sched ) == 0 ) { sched.sched_priority += adjust; @@ -348,12 +348,12 @@ int osd_thread_cpu_affinity(osd_thread *thread, UINT32 mask) for (bitnum=0; bitnum<32; bitnum++) if (mask & (1<<bitnum)) CPU_SET(bitnum, &cmask); - + if (thread == NULL) lthread = pthread_self(); else lthread = thread->thread; - + if (pthread_setaffinity_np(lthread, sizeof(cmask), &cmask) <0) { /* Not available during link in all targets */ diff --git a/src/osd/sdl/sdlsync_win32.c b/src/osd/sdl/sdlsync_win32.c index 051921ae282..cc89609b529 100644 --- a/src/osd/sdl/sdlsync_win32.c +++ b/src/osd/sdl/sdlsync_win32.c @@ -98,10 +98,10 @@ struct _osd_scalable_lock #if USE_SCALABLE_LOCKS struct { - volatile INT32 haslock; // do we have the lock? + volatile INT32 haslock; // do we have the lock? INT32 filler[64/4-1]; // assumes a 64-byte cache line } slot[WORK_MAX_THREADS]; // one slot per thread - volatile INT32 nextindex; // index of next slot to use + volatile INT32 nextindex; // index of next slot to use #else CRITICAL_SECTION section; #endif @@ -110,9 +110,9 @@ struct _osd_scalable_lock osd_scalable_lock *osd_scalable_lock_alloc(void) { osd_scalable_lock *lock; - + lock = (osd_scalable_lock *)calloc(1, sizeof(*lock)); - + memset(lock, 0, sizeof(*lock)); #if USE_SCALABLE_LOCKS lock->slot[0].haslock = TRUE; @@ -179,7 +179,7 @@ osd_thread *osd_thread_create(osd_thread_callback callback, void *cbparam) { osd_thread *thread; uintptr_t handle; - + thread = (osd_thread *)calloc(1, sizeof(osd_thread)); thread->callback = callback; thread->param = cbparam; diff --git a/src/osd/sdl/sdlwork.c b/src/osd/sdl/sdlwork.c index 7d71141bc48..ce0920cab55 100644 --- a/src/osd/sdl/sdlwork.c +++ b/src/osd/sdl/sdlwork.c @@ -114,7 +114,7 @@ struct _osd_work_item { osd_work_item * next; // pointer to next item osd_work_queue * queue; // pointer back to the owning queue - osd_work_callback callback; // callback function + osd_work_callback callback; // callback function void * param; // callback parameter void * result; // callback result osd_event * event; // event signalled when complete @@ -209,13 +209,13 @@ osd_work_queue *osd_work_queue_alloc(int flags) // set its priority: I/O threads get high priority because they are assumed to be // blocked most of the time; other threads just match the creator's priority if (flags & WORK_QUEUE_FLAG_IO) - osd_thread_adjust_priority(thread->handle, 1); + osd_thread_adjust_priority(thread->handle, 1); else - osd_thread_adjust_priority(thread->handle, 0); + osd_thread_adjust_priority(thread->handle, 0); // Bind main thread to cpu 0 osd_thread_cpu_affinity(NULL, effective_cpu_mask(0)); - + if (flags & WORK_QUEUE_FLAG_IO) osd_thread_cpu_affinity(thread->handle, effective_cpu_mask(1)); else @@ -274,7 +274,7 @@ int osd_work_queue_wait(osd_work_queue *queue, osd_ticks_t timeout) // spin until we're done begin_timing(thread->spintime); - + do { int spin = 10000; while (--spin && queue->items != 0) @@ -586,7 +586,7 @@ static int effective_num_processors(void) static UINT32 effective_cpu_mask(int index) { - char *s; + char *s; char buf[5]; UINT32 mask = 0xFFFF; @@ -659,7 +659,7 @@ static void *worker_thread_entry(void *param) // spin for a while looking for more work begin_timing(thread->spintime); stopspin = osd_ticks() + SPIN_LOOP_TIME; - + do { int spin = 10000; while (--spin && queue->list == NULL) diff --git a/src/osd/sdl/sound.c b/src/osd/sdl/sound.c index 5296cb18f37..99395100bb2 100644 --- a/src/osd/sdl/sound.c +++ b/src/osd/sdl/sound.c @@ -23,13 +23,13 @@ #include "osdsdl.h" //============================================================ -// DEBUGGING +// DEBUGGING //============================================================ #define LOG_SOUND 0 //============================================================ -// PARAMETERS +// PARAMETERS //============================================================ // number of samples per SDL callback @@ -43,10 +43,10 @@ static int stream_loop = 0; #define MAX_AUDIO_LATENCY 10 //============================================================ -// LOCAL VARIABLES +// LOCAL VARIABLES //============================================================ -static int attenuation = 0; +static int attenuation = 0; static int initialized_audio = 0; static int buf_locked; @@ -69,7 +69,7 @@ static FILE *sound_log; static int snd_enabled; //============================================================ -// PROTOTYPES +// PROTOTYPES //============================================================ static int sdl_init(running_machine *machine); @@ -82,7 +82,7 @@ static void sdl_callback(void *userdata, Uint8 *stream, int len); //============================================================ -// osd_start_audio_stream +// osd_start_audio_stream //============================================================ void sdlaudio_init(running_machine *machine) { @@ -106,7 +106,7 @@ void sdlaudio_init(running_machine *machine) //============================================================ -// osd_stop_audio_stream +// osd_stop_audio_stream //============================================================ static void sdl_cleanup_audio(running_machine *machine) @@ -114,11 +114,11 @@ static void sdl_cleanup_audio(running_machine *machine) // if nothing to do, don't do it if (machine->sample_rate == 0) return; - + // kill the buffers and dsound sdl_kill(machine); sdl_destroy_buffers(); - + // print out over/underflow stats if (buffer_overflows || buffer_underflows) mame_printf_verbose("Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows); @@ -131,7 +131,7 @@ static void sdl_cleanup_audio(running_machine *machine) } //============================================================ -// lock_buffer +// lock_buffer //============================================================ static int lock_buffer(long offset, long size, void **buffer1, long *length1, void **buffer2, long *length2) { @@ -183,7 +183,7 @@ static int lock_buffer(long offset, long size, void **buffer1, long *length1, vo } //============================================================ -// unlock_buffer +// unlock_buffer //============================================================ static void unlock_buffer(void) { @@ -197,23 +197,23 @@ static void unlock_buffer(void) } //============================================================ -// Apply attenuation +// Apply attenuation //============================================================ static void att_memcpy(void *dest, INT16 *data, int bytes_to_copy) -{ +{ int level= (int) (pow(10.0, (float) attenuation / 20.0) * 128.0); INT16 *d = (INT16 *) dest; int count = bytes_to_copy/2; while (count>0) - { + { *d++ = (*data++ * level) >> 7; /* / 128 */ count--; } } //============================================================ -// copy_sample_data +// copy_sample_data //============================================================ static void copy_sample_data(INT16 *data, int bytes_to_copy) @@ -261,7 +261,7 @@ static void copy_sample_data(INT16 *data, int bytes_to_copy) //============================================================ -// osd_update_audio_stream +// osd_update_audio_stream //============================================================ void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int samples_this_frame) @@ -272,7 +272,7 @@ void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int sample int bytes_this_frame = samples_this_frame * sizeof(INT16) * 2; int play_position, write_position, stream_in; int orig_write; // used in LOG - + play_position = stream_playpos; write_position = stream_playpos + ((machine->sample_rate / 50) * sizeof(INT16) * 2); @@ -328,7 +328,7 @@ void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int sample { stream_in -= stream_buffer_size; stream_loop = 1; - + if (LOG_SOUND) fprintf(sound_log, "stream_loop set to 1 (stream_in looped)\n"); @@ -343,7 +343,7 @@ void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int sample //============================================================ -// osd_set_mastervolume +// osd_set_mastervolume //============================================================ void osd_set_mastervolume(int _attenuation) @@ -358,7 +358,7 @@ void osd_set_mastervolume(int _attenuation) } //============================================================ -// sdl_callback +// sdl_callback //============================================================ static void sdl_callback(void *userdata, Uint8 *stream, int len) { @@ -408,7 +408,7 @@ static void sdl_callback(void *userdata, Uint8 *stream, int len) { stream_playpos -= stream_buffer_size; stream_loop = 0; - + if (LOG_SOUND) fprintf(sound_log, "stream_loop set to 0 (stream_playpos looped)\n"); } @@ -420,13 +420,13 @@ static void sdl_callback(void *userdata, Uint8 *stream, int len) //============================================================ -// sdl_init +// sdl_init //============================================================ static int sdl_init(running_machine *machine) { int n_channels = 2; int audio_latency; - SDL_AudioSpec aspec, obtained; + SDL_AudioSpec aspec, obtained; char audio_driver[16] = ""; if (initialized_audio) @@ -450,7 +450,7 @@ static int sdl_init(running_machine *machine) // set up the audio specs aspec.freq = machine->sample_rate; - aspec.format = AUDIO_S16SYS; // keep endian independant + aspec.format = AUDIO_S16SYS; // keep endian independant aspec.channels = n_channels; aspec.samples = sdl_xfer_samples; aspec.callback = sdl_callback; @@ -503,7 +503,7 @@ cant_start_audio: //============================================================ -// sdl_kill +// sdl_kill //============================================================ static void sdl_kill(running_machine *machine) @@ -519,7 +519,7 @@ static void sdl_kill(running_machine *machine) //============================================================ -// dsound_create_buffers +// dsound_create_buffers //============================================================ static int sdl_create_buffers(void) @@ -535,7 +535,7 @@ static int sdl_create_buffers(void) //============================================================ -// sdl_destroy_buffers +// sdl_destroy_buffers //============================================================ static void sdl_destroy_buffers(void) diff --git a/src/osd/sdl/testkeys.c b/src/osd/sdl/testkeys.c index 7b75fbd82c4..f757ebb9dbb 100644 --- a/src/osd/sdl/testkeys.c +++ b/src/osd/sdl/testkeys.c @@ -22,14 +22,14 @@ // Check whether SDL has compat interface #if defined(SDL_AllocSurface) || (!SDL_VERSION_ATLEAST(1,3,0)) -#define SDL_HAS_COMPAT 1 +#define SDL_HAS_COMPAT 1 #else -#define SDL_HAS_COMPAT 0 +#define SDL_HAS_COMPAT 0 #endif typedef struct _key_lookup_table key_lookup_table; -struct _key_lookup_table +struct _key_lookup_table { int code; const char *name; @@ -38,10 +38,10 @@ struct _key_lookup_table #if SDL_HAS_COMPAT #if (SDL_VERSION_ATLEAST(1,3,0)) #define KE(x) { SDL_SCANCODE_ ## x, "SDL_SCANCODE_" #x }, -#define KE8(A, B, C, D, E, F, G, H) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) KE(H) +#define KE8(A, B, C, D, E, F, G, H) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) KE(H) #define KE7(A, B, C, D, E, F, G) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) #define KE5(A, B, C, D, E) KE(A) KE(B) KE(C) KE(D) KE(E) -#define KE3(A, B, C) KE(A) KE(B) KE(C) +#define KE3(A, B, C) KE(A) KE(B) KE(C) static key_lookup_table sdl_lookup[] = @@ -67,7 +67,7 @@ static key_lookup_table sdl_lookup[] = }; #else #define KE(x) { SDLK_ ## x, "SDLK_" #x }, -#define KE8(A, B, C, D, E, F, G, H) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) KE(H) +#define KE8(A, B, C, D, E, F, G, H) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) KE(H) static key_lookup_table sdl_lookup[] = { @@ -101,7 +101,7 @@ static key_lookup_table sdl_lookup[] = KE8(LCTRL, RALT, LALT, RMETA, LMETA, LSUPER, RSUPER, MODE ) KE8(COMPOSE, HELP, PRINT, SYSREQ, BREAK, MENU, POWER, EURO ) KE(UNDO) - KE(LAST) + KE(LAST) {-1, ""} }; #endif @@ -155,8 +155,8 @@ int main(int argc, char *argv[]) #else lookup_key_name(sdl_lookup, event.key.keysym.sym), #endif - (int) event.key.keysym.scancode, - (int) event.key.keysym.unicode, + (int) event.key.keysym.scancode, + (int) event.key.keysym.unicode, buf); } break; @@ -169,8 +169,8 @@ int main(int argc, char *argv[]) #else lookup_key_name(sdl_lookup, event.key.keysym.sym), #endif - (int) event.key.keysym.scancode, - (int) event.key.keysym.unicode, + (int) event.key.keysym.scancode, + (int) event.key.keysym.unicode, buf); break; } diff --git a/src/osd/sdl/texcopy.c b/src/osd/sdl/texcopy.c index 16e32687a1d..bcaf0b21dfb 100644 --- a/src/osd/sdl/texcopy.c +++ b/src/osd/sdl/texcopy.c @@ -60,7 +60,7 @@ static void init_clamp(void) for (i=0;i<256;i++) { clamp[i + 128] = i; - + coff_cr[i][0] = + 409 * i - 56992; coff_cr[i][1] = - 208 * i; coff_cb[i][0] = - 100 * i /* - 208 * cr */ + 34784; @@ -124,7 +124,7 @@ INLINE UINT32 ycc_to_rgb(unsigned y, unsigned cb, unsigned cr) #endif //============================================================ -// MANUAL TEXCOPY FUNCS +// MANUAL TEXCOPY FUNCS // (YUY format is weird and doesn't fit the assumptions of the // standard macros so we handle it here //============================================================ @@ -155,13 +155,13 @@ static void texcopy_yuv16(texture_info *texture, const render_texinfo *texsource UINT16 srcpix1 = *src++; UINT8 cb = srcpix0 & 0xff; UINT8 cr = srcpix1 & 0xff; - + *dst++ = ycc_to_rgb(srcpix0 >> 8, cb, cr); *dst++ = ycc_to_rgb(srcpix1 >> 8, cb, cr); } - + // always fill non-wrapping textures with an extra pixel on the right - #if 0 + #if 0 if (texture->borderpix) *dst++ = 0; #endif @@ -175,14 +175,14 @@ static void texcopy_yuv16_paletted(texture_info *texture, const render_texinfo * UINT32 *dst; UINT16 *src; int lookup[256]; - + if (clamp[0]>0) init_clamp(); /* preprocess lookup */ for (x=0; x<256; x++) lookup[x] = texsource->palette[x] * 298; - + // loop over Y for (y = 0; y < texsource->height; y++) { @@ -200,23 +200,23 @@ static void texcopy_yuv16_paletted(texture_info *texture, const render_texinfo * UINT16 srcpix1 = *src++; UINT8 cb = srcpix0 & 0xff; UINT8 cr = srcpix1 & 0xff; - + #if 0 *dst++ = ycc_to_rgb(texsource->palette[0x000 + (srcpix0 >> 8)], cb, cr); *dst++ = ycc_to_rgb(texsource->palette[0x000 + (srcpix1 >> 8)], cb, cr); #else - int r = (const int) coff_cr[cr][0]; - int g = (const int) coff_cb[cb][0] + (const int) coff_cr[cr][1]; + int r = (const int) coff_cr[cr][0]; + int g = (const int) coff_cb[cb][0] + (const int) coff_cr[cr][1]; int b = (const int) coff_cb[cb][1]; int y1 = (const int) lookup[(srcpix0 >> 8)]; int y2 = (const int) lookup[(srcpix1 >> 8)]; - + *dst++ = 0xff000000 | (CLSH(r + y1)<<16) | (CLSH(g + y1)<<8) | (CLSH(b + y1)); *dst++ = 0xff000000 | (CLSH(r + y2)<<16) | (CLSH(g + y2)<<8) | (CLSH(b + y2)); #endif } - + // always fill non-wrapping textures with an extra pixel on the right #if 0 if (texture->borderpix) @@ -277,11 +277,11 @@ static void FUNC_NAME(texcopy)(texture_info *texture, const render_texinfo *texs } break; } - + // always fill non-wrapping textures with an extra pixel on the right if (texture->borderpix) *dst++ = 0; - + /* abuse x var to act as line counter while copying */ for (x = 1; x < texture->yprescale; x++) { diff --git a/src/osd/sdl/video.c b/src/osd/sdl/video.c index cd89fe955ef..97d360dbb64 100644 --- a/src/osd/sdl/video.c +++ b/src/osd/sdl/video.c @@ -179,7 +179,7 @@ void sdlvideo_monitor_refresh(sdl_monitor_info *monitor) { #if (SDL_VERSION_ATLEAST(1,3,0)) SDL_DisplayMode dmode; - + SDL_SelectVideoDisplay(monitor->handle); SDL_GetDesktopDisplayMode(&dmode); monitor->monitor_width = dmode.w; @@ -189,7 +189,7 @@ void sdlvideo_monitor_refresh(sdl_monitor_info *monitor) #else #if defined(SDLMAME_WIN32) // Win32 version MONITORINFOEX info; - info.cbSize = sizeof(info); + info.cbSize = sizeof(info); GetMonitorInfo((HMONITOR)monitor->handle, (LPMONITORINFO)&info); monitor->center_width = monitor->monitor_width = info.rcMonitor.right - info.rcMonitor.left; monitor->center_height = monitor->monitor_height = info.rcMonitor.bottom - info.rcMonitor.top; @@ -212,7 +212,7 @@ void sdlvideo_monitor_refresh(sdl_monitor_info *monitor) int screen; SDL_SysWMinfo info; SDL_VERSION(&info.version); - + if ( SDL_GetWMInfo(&info) && (info.subsystem == SDL_SYSWM_X11) ) { screen = DefaultScreen(info.info.x11.display); @@ -225,8 +225,8 @@ void sdlvideo_monitor_refresh(sdl_monitor_info *monitor) XineramaScreenInfo *xineinfo; int numscreens; - xineinfo = XineramaQueryScreens(info.info.x11.display, &numscreens); - + xineinfo = XineramaQueryScreens(info.info.x11.display, &numscreens); + monitor->center_width = xineinfo[0].width; monitor->center_height = xineinfo[0].height; @@ -238,18 +238,18 @@ void sdlvideo_monitor_refresh(sdl_monitor_info *monitor) monitor->center_height = monitor->monitor_height; } } - else + else #endif // defined(SDLMAME_X11) { static int first_call=0; static int cw, ch; - + SDL_VideoDriverName(monitor->monitor_device, sizeof(monitor->monitor_device)-1); - if (first_call==0) + if (first_call==0) { char *dimstr = getenv(SDLENV_DESKTOPDIM); const SDL_VideoInfo *sdl_vi; - + sdl_vi = SDL_GetVideoInfo(); #if (SDL_VERSION_ATLEAST(1,2,10)) cw = sdl_vi->current_w; @@ -277,9 +277,9 @@ void sdlvideo_monitor_refresh(sdl_monitor_info *monitor) monitor->monitor_height = ch; monitor->center_width = cw; monitor->center_height = ch; - } + } } - #elif defined(SDLMAME_OS2) // OS2 version + #elif defined(SDLMAME_OS2) // OS2 version monitor->center_width = monitor->monitor_width = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); monitor->center_height = monitor->monitor_height = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); strcpy(monitor->monitor_device, "OS/2 display"); @@ -289,7 +289,7 @@ void sdlvideo_monitor_refresh(sdl_monitor_info *monitor) { static int info_shown=0; - if (!info_shown) + if (!info_shown) { mame_printf_verbose("SDL Device Driver : %s\n", monitor->monitor_device); mame_printf_verbose("SDL Monitor Dimensions: %d x %d\n", monitor->monitor_width, monitor->monitor_height); @@ -345,10 +345,10 @@ void osd_update(running_machine *machine, int skip_redraw) // if we're not skipping this redraw, update all windows if (!skip_redraw) { -// profiler_mark(PROFILER_BLIT); +// profiler_mark(PROFILER_BLIT); for (window = sdl_window_list; window != NULL; window = window->next) sdlwindow_video_window_update(machine, window); -// profiler_mark(PROFILER_END); +// profiler_mark(PROFILER_END); } // poll the joystick values here @@ -387,7 +387,7 @@ static void add_primary_monitor(void *data) // hook us into the list **tailptr = monitor; *tailptr = &monitor->next; -} +} #endif @@ -424,12 +424,12 @@ static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, // guess the aspect ratio assuming square pixels monitor->aspect = (float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top); - + // SDL will crash if monitors are queried here // This will be done in window.c (Ughh, ugly) - + monitor->modes = NULL; - + // save the primary monitor handle if (info.dwFlags & MONITORINFOF_PRIMARY) primary_monitor = monitor; @@ -466,13 +466,13 @@ static void init_monitors(void) for (i = 0; i < SDL_GetNumVideoDisplays(); i++) { sdl_monitor_info *monitor; - SDL_DisplayMode dmode; + SDL_DisplayMode dmode; // allocate a new monitor info monitor = global_alloc_clear(sdl_monitor_info); snprintf(monitor->monitor_device, sizeof(monitor->monitor_device)-1, "%s%d", SDLOPTION_SCREEN(""),i); - + SDL_SelectVideoDisplay(i); SDL_GetDesktopDisplayMode(&dmode); monitor->monitor_width = dmode.w; @@ -528,7 +528,7 @@ static sdl_monitor_info *pick_monitor(int index) // look for a match in the name first if (scrname != NULL) for (monitor = sdl_monitor_list; monitor != NULL; monitor = monitor->next) - { + { moncount++; if (strcmp(scrname, monitor->monitor_device) == 0) goto finishit; @@ -584,21 +584,21 @@ static void check_osd_inputs(running_machine *machine) // check for toggling fullscreen mode if (ui_input_pressed(machine, IPT_OSD_1)) sdlwindow_toggle_full_screen(machine, window); - + if (ui_input_pressed(machine, IPT_OSD_2)) { //FIXME: on a per window basis video_config.fullstretch = !video_config.fullstretch; ui_popup_time(1, "Uneven stretch %s", video_config.fullstretch? "enabled":"disabled"); } - + if (ui_input_pressed(machine, IPT_OSD_4)) { //FIXME: on a per window basis video_config.keepaspect = !video_config.keepaspect; ui_popup_time(1, "Keepaspect %s", video_config.keepaspect? "enabled":"disabled"); } - + if (USE_OPENGL || SDL_VERSION_ATLEAST(1,3,0)) { //FIXME: on a per window basis @@ -672,20 +672,20 @@ static void extract_video_config(running_machine *machine) video_config.mode = VIDEO_MODE_OPENGL; else if (USE_OPENGL && (strcmp(stemp, SDLOPTVAL_OPENGL16) == 0)) { - video_config.mode = VIDEO_MODE_OPENGL; - video_config.prefer16bpp_tex = 1; + video_config.mode = VIDEO_MODE_OPENGL; + video_config.prefer16bpp_tex = 1; } else if (SDL_VERSION_ATLEAST(1,3,0) && (strcmp(stemp, SDLOPTVAL_SDL13) == 0)) { - video_config.mode = VIDEO_MODE_SDL13; - video_config.prefer16bpp_tex = 1; + video_config.mode = VIDEO_MODE_SDL13; + video_config.prefer16bpp_tex = 1; } else { mame_printf_warning("Invalid video value %s; reverting to software\n", stemp); video_config.mode = VIDEO_MODE_SOFT; } - + video_config.switchres = options_get_bool(mame_options(), SDLOPTION_SWITCHRES); video_config.centerh = options_get_bool(mame_options(), SDLOPTION_CENTERH); video_config.centerv = options_get_bool(mame_options(), SDLOPTION_CENTERV); @@ -715,15 +715,15 @@ static void extract_video_config(running_machine *machine) { int i; static char buffer[20]; // gl_glsl_filter[0..9]? - + video_config.glsl_filter = options_get_int (mame_options(), SDLOPTION_GLSL_FILTER); - + video_config.glsl_shader_mamebm_num=0; - + for(i=0; i<GLSL_SHADER_MAX; i++) { snprintf(buffer, 18, SDLOPTION_SHADER_MAME("%d"), i); buffer[17]=0; - + stemp = options_get_string(mame_options(), buffer); if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0) { @@ -734,13 +734,13 @@ static void extract_video_config(running_machine *machine) video_config.glsl_shader_mamebm[i] = NULL; } } - + video_config.glsl_shader_scrn_num=0; - + for(i=0; i<GLSL_SHADER_MAX; i++) { snprintf(buffer, 20, SDLOPTION_SHADER_SCREEN("%d"), i); buffer[19]=0; - + stemp = options_get_string(mame_options(), buffer); if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0) { @@ -751,7 +751,7 @@ static void extract_video_config(running_machine *machine) video_config.glsl_shader_scrn[i] = NULL; } } - + video_config.glsl_vid_attributes = options_get_int (mame_options(), SDLOPTION_GL_GLSL_VID_ATTR); { // Disable feature: glsl_vid_attributes, as long we have the gamma calculation @@ -780,7 +780,7 @@ static void extract_video_config(running_machine *machine) } video_config.glsl_vid_attributes = 0; } - + } // misc options: sanity check values @@ -889,7 +889,7 @@ static void get_resolution(const char *name, sdl_window_config *config, int repo data = defdata; } - + if (sscanf(data, "%dx%dx%d@%d", &config->width, &config->height, &config->depth, &config->refresh) < 2 && report_error) mame_printf_error("Illegal resolution value for %s = %s\n", name, data); } diff --git a/src/osd/sdl/video.h b/src/osd/sdl/video.h index b6350c65a34..1e3b7492d42 100644 --- a/src/osd/sdl/video.h +++ b/src/osd/sdl/video.h @@ -94,10 +94,10 @@ struct _sdl_video_config int novideo; // don't draw, for pure CPU benchmarking // global configuration - int windowed; // start windowed? + int windowed; // start windowed? int prescale; // prescale factor (not currently supported) - int keepaspect; // keep aspect ratio? - int numscreens; // number of screens + int keepaspect; // keep aspect ratio? + int numscreens; // number of screens int centerh; int centerv; @@ -136,7 +136,7 @@ struct _sdl_video_config // X11 options int restrictonemonitor; // in fullscreen, confine to Xinerama monitor 0 - // YUV options + // YUV options int scale_mode; }; diff --git a/src/osd/sdl/window.c b/src/osd/sdl/window.c index 8b209f3d7c6..f3da823cb2d 100644 --- a/src/osd/sdl/window.c +++ b/src/osd/sdl/window.c @@ -44,16 +44,16 @@ #define WINDOW_DECORATION_HEIGHT (48) // title bar + bottom drag region #ifdef MAME_DEBUG -//#define ASSERT_USE(x) do { printf("%x %x\n", (int) SDL_ThreadID(), x); assert_always(SDL_ThreadID() == x, "Wrong Thread"); } while (0) +//#define ASSERT_USE(x) do { printf("%x %x\n", (int) SDL_ThreadID(), x); assert_always(SDL_ThreadID() == x, "Wrong Thread"); } while (0) #define ASSERT_USE(x) do { SDL_threadID _thid = SDL_ThreadID(); assert_always( _thid == x, "Wrong Thread"); } while (0) #else #define ASSERT_USE(x) do {} while (0) -//#define ASSERT_USE(x) assert(SDL_ThreadID() == x) +//#define ASSERT_USE(x) assert(SDL_ThreadID() == x) #endif -#define ASSERT_REDRAW_THREAD() ASSERT_USE(window_threadid) -#define ASSERT_WINDOW_THREAD() ASSERT_USE(window_threadid) -#define ASSERT_MAIN_THREAD() ASSERT_USE(main_threadid) +#define ASSERT_REDRAW_THREAD() ASSERT_USE(window_threadid) +#define ASSERT_WINDOW_THREAD() ASSERT_USE(window_threadid) +#define ASSERT_MAIN_THREAD() ASSERT_USE(main_threadid) #define OSDWORK_CALLBACK(name) void *name(void *param, ATTR_UNUSED int threadid) @@ -151,7 +151,7 @@ INLINE void clear_worker_param(worker_param *wp) INLINE void execute_async(osd_work_callback callback, worker_param *wp) { worker_param *wp_temp = NULL; - + if (wp) { wp_temp = (worker_param *) osd_malloc(sizeof(worker_param)); @@ -293,7 +293,7 @@ static OSDWORK_CALLBACK( sdlwindow_exit_wt ) { if (SDLMAME_INIT_IN_WORKER_THREAD) SDL_Quit(); - + if (param) osd_free(param); return NULL; @@ -313,7 +313,7 @@ static void sdlwindow_exit(running_machine *machine) sdl_window_list = temp->next; sdlwindow_video_window_destroy(machine, temp); } - + // if we're multithreaded, clean up the window thread if (multithreading_enabled) { @@ -366,7 +366,7 @@ void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int desired_aspect = (float)target_width / (float)target_height; } - // non-integer scaling - often gives more pleasing results in full screen + // non-integer scaling - often gives more pleasing results in full screen if (!video_config.fullstretch) { // compute maximum integral scaling to fit the window @@ -420,7 +420,7 @@ void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int if ((window->blitwidth != newwidth) || (window->blitheight != newheight)) sdlwindow_clear(window); - + window->blitwidth = newwidth; window->blitheight = newheight; } @@ -437,12 +437,12 @@ static OSDWORK_CALLBACK( sdlwindow_resize_wt ) sdl_window_info * window = wp->window; ASSERT_WINDOW_THREAD(); - + window->destroy_all_textures(window); window->resize(window, wp->resize_new_width, wp->resize_new_height); sdlwindow_blit_surface_size(window, wp->resize_new_width, wp->resize_new_height); - + sdlwindow_clear(window); osd_free(wp); @@ -457,12 +457,12 @@ void sdlwindow_resize(sdl_window_info *window, INT32 width, INT32 height) if (width == window->width && height == window->height) return; - + clear_worker_param(&wp); wp.resize_new_width = width; wp.resize_new_height = height; wp.window = window; - + execute_async_wait(&sdlwindow_resize_wt, &wp); } @@ -490,13 +490,13 @@ void sdlwindow_clear(sdl_window_info *window) clear_worker_param(wp); wp->window = window; - + if (SDL_ThreadID() == main_threadid) { execute_async_wait(&sdlwindow_clear_surface_wt, wp); osd_free(wp); } - else + else sdlwindow_clear_surface_wt( (void *) wp, 0); } @@ -528,7 +528,7 @@ static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ) sdlinput_release_keys(wp->machine); // toggle the window mode - window->fullscreen = !window->fullscreen; + window->fullscreen = !window->fullscreen; complete_create_wt(param, 0); @@ -544,7 +544,7 @@ void sdlwindow_toggle_full_screen(running_machine *machine, sdl_window_info *win clear_worker_param(&wp); wp.window = window; wp.machine = machine; - + execute_async_wait(&sdlwindow_toggle_full_screen_wt, &wp); } @@ -574,13 +574,13 @@ void sdlwindow_modify_prescale(running_machine *machine, sdl_window_info *window new_prescale = window->prescale + 1; if (dir < 0 && window->prescale > 1) new_prescale = window->prescale - 1; - + if (new_prescale != window->prescale) { if (window->fullscreen && video_config.switchres) { execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp); - + window->prescale = new_prescale; execute_async_wait(&complete_create_wt, &wp); @@ -717,7 +717,7 @@ int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monit window->monitor = monitor; window->machine = machine; window->index = index; - + //FIXME: these should be per_window in config-> or even better a bit set window->fullscreen = !video_config.windowed; window->prescale = video_config.prescale; @@ -732,14 +732,14 @@ int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monit window->windowed_width = config->width; window->windowed_height = config->height; } - window->totalColors = config->totalColors; + window->totalColors = config->totalColors; // add us to the list *last_window_ptr = window; last_window_ptr = &window->next; draw.attach(&draw, window); - + // create an event that we can use to skip blitting window->rendered_event = osd_event_alloc(FALSE, TRUE); @@ -748,7 +748,7 @@ int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monit if (window->target == NULL) goto error; - // set the specific view + // set the specific view sprintf(option, SDLOPTION_VIEW("%d"), index); set_starting_view(machine, index, window, options_get_string(mame_options(), option)); @@ -762,13 +762,13 @@ int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monit if (multithreading_enabled) { - osd_work_item *wi; - + osd_work_item *wi; + wi = osd_work_item_queue(work_queue, &complete_create_wt, (void *) wp, 0); sdlwindow_sync(); result = *((int *) (osd_work_item_result)(wi)); osd_work_item_release(wi); - } + } else result = *((int *) complete_create_wt((void *) wp, 0)); @@ -801,7 +801,7 @@ static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt ) // release all keys ... sdlinput_release_keys(wp->machine); - + osd_free(wp); return NULL; @@ -872,7 +872,7 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight) } num = SDL_GetNumDisplayModes(); - + if (num == 0) { mame_printf_error("SDL: No modes available?!\n"); @@ -940,15 +940,15 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight) #if defined(SDLMAME_WIN32) /* - * We need to do this here. If SDL_ListModes is - * called in init_monitors, the call will crash - * on win32 - */ + * We need to do this here. If SDL_ListModes is + * called in init_monitors, the call will crash + * on win32 + */ modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_DOUBLEBUF); #else modes = window->monitor->modes; #endif - + if (modes == (SDL_Rect **)0) { mame_printf_error("SDL: No modes available?!\n"); @@ -1002,7 +1002,7 @@ void sdlwindow_video_window_update(running_machine *machine, sdl_window_info *wi { ASSERT_MAIN_THREAD(); - + // adjust the cursor state sdlwindow_update_cursor_state(machine, window); @@ -1010,7 +1010,7 @@ void sdlwindow_video_window_update(running_machine *machine, sdl_window_info *wi if (window->target != NULL) { int tempwidth, tempheight; - + // see if the games video mode has changed render_target_get_minimum_size(window->target, &tempwidth, &tempheight); if (tempwidth != window->minwidth || tempheight != window->minheight) @@ -1029,7 +1029,7 @@ void sdlwindow_video_window_update(running_machine *machine, sdl_window_info *wi } } - // only render if we have been signalled + // only render if we have been signalled if (osd_event_wait(window->rendered_event, 0)) { worker_param wp; @@ -1086,7 +1086,7 @@ static OSDWORK_CALLBACK( complete_create_wt ) { worker_param * wp = (worker_param *) param; sdl_window_info * window = wp->window; - + int tempwidth, tempheight; static int result[2] = {0,1}; @@ -1119,9 +1119,9 @@ static OSDWORK_CALLBACK( complete_create_wt ) else { /* Create the window directly with the correct aspect - instead of letting sdlwindow_blit_surface_size() resize it - this stops the window from "flashing" from the wrong aspect - size to the right one at startup. */ + instead of letting sdlwindow_blit_surface_size() resize it + this stops the window from "flashing" from the wrong aspect + size to the right one at startup. */ tempwidth = (window->maxwidth != 0) ? window->maxwidth : 640; tempheight = (window->maxheight != 0) ? window->maxheight : 480; @@ -1155,10 +1155,10 @@ static void measure_fps(sdl_window_info *window, UINT32 dc, int update) 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); @@ -1175,8 +1175,8 @@ static void measure_fps(sdl_window_info *window, UINT32 dc, int update) 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, + "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 @@ -1190,13 +1190,13 @@ static void measure_fps(sdl_window_info *window, UINT32 dc, int update) static OSDWORK_CALLBACK( draw_video_contents_wt ) { - UINT32 dc = 0; - int update = 1; + UINT32 dc = 0; + int update = 1; worker_param *wp = (worker_param *) param; sdl_window_info *window = wp->window; - + ASSERT_REDRAW_THREAD(); - + // Some configurations require events to be polled in the worker thread sdlinput_process_events_buf(wp->machine); @@ -1211,14 +1211,14 @@ static OSDWORK_CALLBACK( draw_video_contents_wt ) { if( video_config.perftest ) measure_fps(window, dc, update); - else + else window->draw(window, dc, update); } /* all done, ready for next */ osd_event_set(window->rendered_event); osd_free(wp); - + return NULL; } @@ -1393,7 +1393,7 @@ static void get_max_bounds(sdl_window_info *window, int *window_width, int *wind maxwidth -= WINDOW_DECORATION_WIDTH; maxheight -= WINDOW_DECORATION_HEIGHT; *window_width = maxwidth; - *window_height = maxheight; + *window_height = maxheight; } } diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h index eea5ba4bf4a..96ebc92bc7c 100644 --- a/src/osd/sdl/window.h +++ b/src/osd/sdl/window.h @@ -37,10 +37,10 @@ struct _sdl_window_info { // Pointer to next window sdl_window_info * next; - + // Pointer to machine running_machine * machine; - + // Draw Callbacks int (*create)(sdl_window_info *window, int width, int height); void (*resize)(sdl_window_info *window, int width, int height); @@ -58,7 +58,7 @@ struct _sdl_window_info sdl_monitor_info * monitor; int fullscreen; int index; - + // diverse flags int minwidth, minheight; int maxwidth, maxheight; @@ -86,13 +86,13 @@ struct _sdl_window_info int totalColors; // total colors from machine/sdl_window_config int start_viewscreen; - + // per window modes ... int scale_mode; - + // GL specific int prescale; - + #if (SDL_VERSION_ATLEAST(1,3,0)) // Needs to be here as well so we can identify window SDL_WindowID window_id; diff --git a/src/osd/windows/winmisc.c b/src/osd/windows/winmisc.c index 90c8dad9e9e..0130b2bf2b3 100644 --- a/src/osd/windows/winmisc.c +++ b/src/osd/windows/winmisc.c @@ -78,12 +78,12 @@ void *osd_malloc(size_t size) #else // add in space for the base pointer size += sizeof(size_t); - + // small items just come from the heap void *result; if (size < GUARD_PAGE_THRESH) result = HeapAlloc(GetProcessHeap(), 0, size); - + // large items get guard pages else { @@ -103,7 +103,7 @@ void *osd_malloc(size_t size) // work backwards from the page base to get to the block base result = GUARD_ALIGN_START ? page_base : (reinterpret_cast<UINT8 *>(page_base) + rounded_size - size); } - + // store the page_base at the start *reinterpret_cast<size_t *>(result) = size; return reinterpret_cast<UINT8 *>(result) + sizeof(size_t); @@ -121,11 +121,11 @@ void osd_free(void *ptr) HeapFree(GetProcessHeap(), 0, ptr); #else size_t size = reinterpret_cast<size_t *>(ptr)[-1]; - + // small items just get freed if (size < GUARD_PAGE_THRESH) HeapFree(GetProcessHeap(), 0, ptr); - + // large items need more care else { |