From: <ya...@us...> - 2008-09-08 14:29:26
|
Revision: 924 http://desmume.svn.sourceforge.net/desmume/?rev=924&view=rev Author: yabause Date: 2008-09-08 14:29:21 +0000 (Mon, 08 Sep 2008) Log Message: ----------- Commited patch by Orphis so gtk port build again. Modified Paths: -------------- trunk/desmume/INSTALL trunk/desmume/src/gtk/Makefile.am Added Paths: ----------- trunk/desmume/src/gtk/dToolsList.cpp trunk/desmume/src/gtk/desmume.cpp trunk/desmume/src/gtk/gdk_3Demu.cpp trunk/desmume/src/gtk/gtk-compat.cpp trunk/desmume/src/gtk/main.cpp trunk/desmume/src/gtk/tools/ioregsView.cpp Removed Paths: ------------- trunk/desmume/src/gtk/dToolsList.c trunk/desmume/src/gtk/desmume.c trunk/desmume/src/gtk/gdk_3Demu.c trunk/desmume/src/gtk/gtk-compat.c trunk/desmume/src/gtk/main.c trunk/desmume/src/gtk/tools/ioregsView.c Modified: trunk/desmume/INSTALL =================================================================== --- trunk/desmume/INSTALL 2008-09-08 09:50:43 UTC (rev 923) +++ trunk/desmume/INSTALL 2008-09-08 14:29:21 UTC (rev 924) @@ -2,7 +2,7 @@ ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006 Free Software Foundation, Inc. +2006, 2007 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. @@ -67,6 +67,9 @@ all sorts of other programs in order to regenerate files that came with the distribution. + 6. Often, you can also type `make uninstall' to remove the installed + files again. + Compilers and Options ===================== Modified: trunk/desmume/src/gtk/Makefile.am =================================================================== --- trunk/desmume/src/gtk/Makefile.am 2008-09-08 09:50:43 UTC (rev 923) +++ trunk/desmume/src/gtk/Makefile.am 2008-09-08 14:29:21 UTC (rev 924) @@ -11,14 +11,14 @@ dev-cpp/semaphore.h desmume.desktop bin_PROGRAMS = desmume desmume_SOURCES = \ - gtk-compat.c gtk-compat.h \ - desmume.h desmume.c \ - dTool.h dToolsList.c \ - tools/ioregsView.c tools/ioregsView.h \ + gtk-compat.cpp gtk-compat.h \ + desmume.h desmume.cpp \ + dTool.h dToolsList.cpp \ + tools/ioregsView.cpp tools/ioregsView.h \ globals.h \ - ../sndsdl.c \ - ../ctrlssdl.h ../ctrlssdl.c \ - gdk_3Demu.c gdk_3Demu.h \ - main.c + ../sndsdl.cpp \ + ../ctrlssdl.h ../ctrlssdl.cpp \ + gdk_3Demu.cpp gdk_3Demu.h \ + main.cpp desmume_LDADD = ../libdesmume.a ../gdbstub/libgdbstub.a \ $(SDL_LIBS) $(GTK_LIBS) $(GTKGLEXT_LIBS) $(GTHREAD_LIBS) Deleted: trunk/desmume/src/gtk/dToolsList.c =================================================================== --- trunk/desmume/src/gtk/dToolsList.c 2008-09-08 09:50:43 UTC (rev 923) +++ trunk/desmume/src/gtk/dToolsList.c 2008-09-08 14:29:21 UTC (rev 924) @@ -1,10 +0,0 @@ -#include "dTool.h" -#include "tools/ioregsView.h" - -dTool_t *dTools_list[] = -{ - &dTool_ioregsView -}; - -int dTools_list_size = 1; - Copied: trunk/desmume/src/gtk/dToolsList.cpp (from rev 923, trunk/desmume/src/gtk/dToolsList.c) =================================================================== --- trunk/desmume/src/gtk/dToolsList.cpp (rev 0) +++ trunk/desmume/src/gtk/dToolsList.cpp 2008-09-08 14:29:21 UTC (rev 924) @@ -0,0 +1,10 @@ +#include "dTool.h" +#include "tools/ioregsView.h" + +dTool_t *dTools_list[] = +{ + &dTool_ioregsView +}; + +int dTools_list_size = 1; + Deleted: trunk/desmume/src/gtk/desmume.c =================================================================== --- trunk/desmume/src/gtk/desmume.c 2008-09-08 09:50:43 UTC (rev 923) +++ trunk/desmume/src/gtk/desmume.c 2008-09-08 14:29:21 UTC (rev 924) @@ -1,87 +0,0 @@ -/* desmume.c - this file is part of DeSmuME - * - * Copyright (C) 2006,2007 DeSmuME Team - * Copyright (C) 2007 Pascal Giard (evilynux) - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "desmume.h" - -volatile BOOL execute = FALSE; -BOOL click = FALSE; -BOOL fini = FALSE; -unsigned long glock = 0; - -u8 *desmume_rom_data = NULL; -u32 desmume_last_cycle; - -void desmume_init( struct armcpu_memory_iface *arm9_mem_if, - struct armcpu_ctrl_iface **arm9_ctrl_iface, - struct armcpu_memory_iface *arm7_mem_if, - struct armcpu_ctrl_iface **arm7_ctrl_iface, - int disable_sound) -{ -#ifdef GDB_STUB - NDS_Init( arm9_mem_if, arm9_ctrl_iface, - arm7_mem_if, arm7_ctrl_iface); -#else - NDS_Init(); -#endif - if ( !disable_sound) { - SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); - } - execute = FALSE; -} - -void desmume_free( void) -{ - execute = FALSE; - NDS_DeInit(); -} - -void desmume_pause( void) -{ - execute = FALSE; -} -void desmume_resume( void) -{ - execute = TRUE; -} -void desmume_toggle( void) -{ - execute = (execute) ? FALSE : TRUE; -} -BOOL desmume_running( void) -{ - return execute; -} - -void desmume_cycle( void) -{ - u16 keypad; - /* Joystick events */ - /* Retrieve old value: can use joysticks w/ another device (from our side) */ - keypad = get_keypad(); - /* Look for queued events */ - process_joystick_events( &keypad); - /* Update keypad value */ - update_keypad(keypad); - - desmume_last_cycle = NDS_exec((560190 << 1) - desmume_last_cycle, FALSE); - SPU_Emulate(); -} - Copied: trunk/desmume/src/gtk/desmume.cpp (from rev 923, trunk/desmume/src/gtk/desmume.c) =================================================================== --- trunk/desmume/src/gtk/desmume.cpp (rev 0) +++ trunk/desmume/src/gtk/desmume.cpp 2008-09-08 14:29:21 UTC (rev 924) @@ -0,0 +1,87 @@ +/* desmume.c - this file is part of DeSmuME + * + * Copyright (C) 2006,2007 DeSmuME Team + * Copyright (C) 2007 Pascal Giard (evilynux) + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "desmume.h" + +volatile BOOL execute = FALSE; +BOOL click = FALSE; +BOOL fini = FALSE; +unsigned long glock = 0; + +u8 *desmume_rom_data = NULL; +u32 desmume_last_cycle; + +void desmume_init( struct armcpu_memory_iface *arm9_mem_if, + struct armcpu_ctrl_iface **arm9_ctrl_iface, + struct armcpu_memory_iface *arm7_mem_if, + struct armcpu_ctrl_iface **arm7_ctrl_iface, + int disable_sound) +{ +#ifdef GDB_STUB + NDS_Init( arm9_mem_if, arm9_ctrl_iface, + arm7_mem_if, arm7_ctrl_iface); +#else + NDS_Init(); +#endif + if ( !disable_sound) { + SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); + } + execute = FALSE; +} + +void desmume_free( void) +{ + execute = FALSE; + NDS_DeInit(); +} + +void desmume_pause( void) +{ + execute = FALSE; +} +void desmume_resume( void) +{ + execute = TRUE; +} +void desmume_toggle( void) +{ + execute = (execute) ? FALSE : TRUE; +} +BOOL desmume_running( void) +{ + return execute; +} + +void desmume_cycle( void) +{ + u16 keypad; + /* Joystick events */ + /* Retrieve old value: can use joysticks w/ another device (from our side) */ + keypad = get_keypad(); + /* Look for queued events */ + process_joystick_events( &keypad); + /* Update keypad value */ + update_keypad(keypad); + + desmume_last_cycle = NDS_exec((560190 << 1) - desmume_last_cycle, FALSE); + SPU_Emulate(); +} + Deleted: trunk/desmume/src/gtk/gdk_3Demu.c =================================================================== --- trunk/desmume/src/gtk/gdk_3Demu.c 2008-09-08 09:50:43 UTC (rev 923) +++ trunk/desmume/src/gtk/gdk_3Demu.c 2008-09-08 14:29:21 UTC (rev 924) @@ -1,199 +0,0 @@ -/* $Id: gdk_3Demu.c,v 1.3 2007-06-27 14:44:40 masscat Exp $ - */ -/* - Copyright (C) 2006-2007 Ben Jaques - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifdef GTKGLEXT_AVAILABLE - -#include <gdk/gdkgl.h> - -#include "../types.h" -#include "../render3D.h" -#include "../opengl_collector_3Demu.h" -#include "gdk_3Demu.h" - -/* - * The GDK 3D emulation. - * This uses the OpenGL Collector plugin, using gdkGLext for the platform - * specific helper functions. - */ - - -static GdkPixmap *target_pixmap; -static GdkGLContext *glcontext = NULL; -static GdkGLDrawable *gldrawable; - - -static void -print_gl_config_attrib (GdkGLConfig *glconfig, - const gchar *attrib_str, - int attrib, - gboolean is_boolean) -{ - int value; - - g_print ("%s = ", attrib_str); - if (gdk_gl_config_get_attrib (glconfig, attrib, &value)) - { - if (is_boolean) - g_print ("%s\n", value == TRUE ? "TRUE" : "FALSE"); - else - g_print ("%d\n", value); - } - else - g_print ("*** Cannot get %s attribute value\n", attrib_str); -} - - -static void -examine_gl_config_attrib (GdkGLConfig *glconfig) -{ - g_print ("\nOpenGL visual configurations :\n\n"); - - g_print ("gdk_gl_config_is_rgba (glconfig) = %s\n", - gdk_gl_config_is_rgba (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_is_double_buffered (glconfig) = %s\n", - gdk_gl_config_is_double_buffered (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_is_stereo (glconfig) = %s\n", - gdk_gl_config_is_stereo (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_alpha (glconfig) = %s\n", - gdk_gl_config_has_alpha (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_depth_buffer (glconfig) = %s\n", - gdk_gl_config_has_depth_buffer (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_stencil_buffer (glconfig) = %s\n", - gdk_gl_config_has_stencil_buffer (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_accum_buffer (glconfig) = %s\n", - gdk_gl_config_has_accum_buffer (glconfig) ? "TRUE" : "FALSE"); - - g_print ("\n"); - - print_gl_config_attrib (glconfig, "GDK_GL_USE_GL", - GDK_GL_USE_GL, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_BUFFER_SIZE", - GDK_GL_BUFFER_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_LEVEL", - GDK_GL_LEVEL, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_RGBA", - GDK_GL_RGBA, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_DOUBLEBUFFER", - GDK_GL_DOUBLEBUFFER, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_STEREO", - GDK_GL_STEREO, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_AUX_BUFFERS", - GDK_GL_AUX_BUFFERS, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_RED_SIZE", - GDK_GL_RED_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_GREEN_SIZE", - GDK_GL_GREEN_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_BLUE_SIZE", - GDK_GL_BLUE_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ALPHA_SIZE", - GDK_GL_ALPHA_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_DEPTH_SIZE", - GDK_GL_DEPTH_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_STENCIL_SIZE", - GDK_GL_STENCIL_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_RED_SIZE", - GDK_GL_ACCUM_RED_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_GREEN_SIZE", - GDK_GL_ACCUM_GREEN_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_BLUE_SIZE", - GDK_GL_ACCUM_BLUE_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_ALPHA_SIZE", - GDK_GL_ACCUM_ALPHA_SIZE, FALSE); - - g_print ("\n"); -} - - -static int -begin_opengl_region_gdk_3d( void) { - - if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) { - return 0; - } - - return 1; -} - -static void -end_opengl_region_gdk_3d( void) { - gdk_gl_drawable_gl_end (gldrawable); -} - -static int -initialise_gdk_3d( void) { - /* this does nothing */ - return 1; -} - -int -init_opengl_gdk_3Demu( void) { - GdkGLConfig *glconfig; - - /* create the off screen pixmap */ - target_pixmap = gdk_pixmap_new ( NULL, 256, 192, 24); - - if ( target_pixmap == NULL) { - g_print ("*** Failed to create pixmap.\n"); - return 0; - } - - glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGBA | - GDK_GL_MODE_DEPTH | - GDK_GL_MODE_STENCIL | - GDK_GL_MODE_SINGLE); - if (glconfig == NULL) - { - g_print ("*** No appropriate OpenGL-capable visual found.\n"); - return 0; - } - - /* - * Set OpenGL-capability to the pixmap - */ - - gldrawable = GDK_GL_DRAWABLE (gdk_pixmap_set_gl_capability (target_pixmap, - glconfig, - NULL)); - - if ( gldrawable == NULL) { - g_print ("Failed to create the GdkGLPixmap\n"); - return 0; - } - - glcontext = gdk_gl_context_new (gldrawable, - NULL, - FALSE, - GDK_GL_RGBA_TYPE); - if (glcontext == NULL) - { - g_print ("Connot create the OpenGL rendering context\n"); - return 0; - } - - begin_opengl_ogl_collector_platform = begin_opengl_region_gdk_3d; - end_opengl_ogl_collector_platform = end_opengl_region_gdk_3d; - initialise_ogl_collector_platform = initialise_gdk_3d; - - - return 1; -} - -#endif Copied: trunk/desmume/src/gtk/gdk_3Demu.cpp (from rev 923, trunk/desmume/src/gtk/gdk_3Demu.c) =================================================================== --- trunk/desmume/src/gtk/gdk_3Demu.cpp (rev 0) +++ trunk/desmume/src/gtk/gdk_3Demu.cpp 2008-09-08 14:29:21 UTC (rev 924) @@ -0,0 +1,199 @@ +/* $Id: gdk_3Demu.c,v 1.3 2007-06-27 14:44:40 masscat Exp $ + */ +/* + Copyright (C) 2006-2007 Ben Jaques + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifdef GTKGLEXT_AVAILABLE + +#include <gdk/gdkgl.h> + +#include "../types.h" +#include "../render3D.h" +#include "../opengl_collector_3Demu.h" +#include "gdk_3Demu.h" + +/* + * The GDK 3D emulation. + * This uses the OpenGL Collector plugin, using gdkGLext for the platform + * specific helper functions. + */ + + +static GdkPixmap *target_pixmap; +static GdkGLContext *glcontext = NULL; +static GdkGLDrawable *gldrawable; + + +static void +print_gl_config_attrib (GdkGLConfig *glconfig, + const gchar *attrib_str, + int attrib, + gboolean is_boolean) +{ + int value; + + g_print ("%s = ", attrib_str); + if (gdk_gl_config_get_attrib (glconfig, attrib, &value)) + { + if (is_boolean) + g_print ("%s\n", value == TRUE ? "TRUE" : "FALSE"); + else + g_print ("%d\n", value); + } + else + g_print ("*** Cannot get %s attribute value\n", attrib_str); +} + + +static void +examine_gl_config_attrib (GdkGLConfig *glconfig) +{ + g_print ("\nOpenGL visual configurations :\n\n"); + + g_print ("gdk_gl_config_is_rgba (glconfig) = %s\n", + gdk_gl_config_is_rgba (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_is_double_buffered (glconfig) = %s\n", + gdk_gl_config_is_double_buffered (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_is_stereo (glconfig) = %s\n", + gdk_gl_config_is_stereo (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_has_alpha (glconfig) = %s\n", + gdk_gl_config_has_alpha (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_has_depth_buffer (glconfig) = %s\n", + gdk_gl_config_has_depth_buffer (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_has_stencil_buffer (glconfig) = %s\n", + gdk_gl_config_has_stencil_buffer (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_has_accum_buffer (glconfig) = %s\n", + gdk_gl_config_has_accum_buffer (glconfig) ? "TRUE" : "FALSE"); + + g_print ("\n"); + + print_gl_config_attrib (glconfig, "GDK_GL_USE_GL", + GDK_GL_USE_GL, TRUE); + print_gl_config_attrib (glconfig, "GDK_GL_BUFFER_SIZE", + GDK_GL_BUFFER_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_LEVEL", + GDK_GL_LEVEL, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_RGBA", + GDK_GL_RGBA, TRUE); + print_gl_config_attrib (glconfig, "GDK_GL_DOUBLEBUFFER", + GDK_GL_DOUBLEBUFFER, TRUE); + print_gl_config_attrib (glconfig, "GDK_GL_STEREO", + GDK_GL_STEREO, TRUE); + print_gl_config_attrib (glconfig, "GDK_GL_AUX_BUFFERS", + GDK_GL_AUX_BUFFERS, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_RED_SIZE", + GDK_GL_RED_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_GREEN_SIZE", + GDK_GL_GREEN_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_BLUE_SIZE", + GDK_GL_BLUE_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_ALPHA_SIZE", + GDK_GL_ALPHA_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_DEPTH_SIZE", + GDK_GL_DEPTH_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_STENCIL_SIZE", + GDK_GL_STENCIL_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_RED_SIZE", + GDK_GL_ACCUM_RED_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_GREEN_SIZE", + GDK_GL_ACCUM_GREEN_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_BLUE_SIZE", + GDK_GL_ACCUM_BLUE_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_ALPHA_SIZE", + GDK_GL_ACCUM_ALPHA_SIZE, FALSE); + + g_print ("\n"); +} + + +static int +begin_opengl_region_gdk_3d( void) { + + if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) { + return 0; + } + + return 1; +} + +static void +end_opengl_region_gdk_3d( void) { + gdk_gl_drawable_gl_end (gldrawable); +} + +static int +initialise_gdk_3d( void) { + /* this does nothing */ + return 1; +} + +int +init_opengl_gdk_3Demu( void) { + GdkGLConfig *glconfig; + + /* create the off screen pixmap */ + target_pixmap = gdk_pixmap_new ( NULL, 256, 192, 24); + + if ( target_pixmap == NULL) { + g_print ("*** Failed to create pixmap.\n"); + return 0; + } + + glconfig = gdk_gl_config_new_by_mode ((GdkGLConfigMode)(GDK_GL_MODE_RGBA | + GDK_GL_MODE_DEPTH | + GDK_GL_MODE_STENCIL | + GDK_GL_MODE_SINGLE)); + if (glconfig == NULL) + { + g_print ("*** No appropriate OpenGL-capable visual found.\n"); + return 0; + } + + /* + * Set OpenGL-capability to the pixmap + */ + + gldrawable = GDK_GL_DRAWABLE (gdk_pixmap_set_gl_capability (target_pixmap, + glconfig, + NULL)); + + if ( gldrawable == NULL) { + g_print ("Failed to create the GdkGLPixmap\n"); + return 0; + } + + glcontext = gdk_gl_context_new (gldrawable, + NULL, + FALSE, + GDK_GL_RGBA_TYPE); + if (glcontext == NULL) + { + g_print ("Connot create the OpenGL rendering context\n"); + return 0; + } + + begin_opengl_ogl_collector_platform = begin_opengl_region_gdk_3d; + end_opengl_ogl_collector_platform = end_opengl_region_gdk_3d; + initialise_ogl_collector_platform = initialise_gdk_3d; + + + return 1; +} + +#endif Deleted: trunk/desmume/src/gtk/gtk-compat.c =================================================================== --- trunk/desmume/src/gtk/gtk-compat.c 2008-09-08 09:50:43 UTC (rev 923) +++ trunk/desmume/src/gtk/gtk-compat.c 2008-09-08 14:29:21 UTC (rev 924) @@ -1,33 +0,0 @@ -/* Copyright 2006 Guillaume Duhamel - - This file is part of DeSmuME. - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "gtk-compat.h" - -#if !GLIB_CHECK_VERSION(2, 8, 0) -gboolean g_file_set_contents(const gchar * filename, const gchar * contents, gssize len, GError ** error) { - FILE * file = fopen(filename, "w"); - - if (len == -1) - fprintf(file, "%s", contents); - else - fwrite(contents, 1, len, file); - - fclose(file); -} -#endif Copied: trunk/desmume/src/gtk/gtk-compat.cpp (from rev 923, trunk/desmume/src/gtk/gtk-compat.c) =================================================================== --- trunk/desmume/src/gtk/gtk-compat.cpp (rev 0) +++ trunk/desmume/src/gtk/gtk-compat.cpp 2008-09-08 14:29:21 UTC (rev 924) @@ -0,0 +1,33 @@ +/* Copyright 2006 Guillaume Duhamel + + This file is part of DeSmuME. + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "gtk-compat.h" + +#if !GLIB_CHECK_VERSION(2, 8, 0) +gboolean g_file_set_contents(const gchar * filename, const gchar * contents, gssize len, GError ** error) { + FILE * file = fopen(filename, "w"); + + if (len == -1) + fprintf(file, "%s", contents); + else + fwrite(contents, 1, len, file); + + fclose(file); +} +#endif Deleted: trunk/desmume/src/gtk/main.c =================================================================== --- trunk/desmume/src/gtk/main.c 2008-09-08 09:50:43 UTC (rev 923) +++ trunk/desmume/src/gtk/main.c 2008-09-08 14:29:21 UTC (rev 924) @@ -1,2127 +0,0 @@ -/* main.c - this file is part of DeSmuME - * - * Copyright (C) 2006,2007 DeSmuME Team - * Copyright (C) 2007 Pascal Giard (evilynux) - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifdef GTKGLEXT_AVAILABLE -#include <GL/gl.h> -#include <GL/glu.h> -#include <gtk/gtkgl.h> -#endif - -#include "globals.h" -#include "../debug.h" - -#include "../gdbstub.h" - -#ifdef GTKGLEXT_AVAILABLE -#include "../opengl_collector_3Demu.h" -#include "gdk_3Demu.h" -#endif - -#include "DeSmuME.xpm" - -#define EMULOOP_PRIO (G_PRIORITY_HIGH_IDLE + 20) - - -#define ENABLE_MEMORY_PROFILING 1 - -#ifdef ENABLE_MEMORY_PROFILING -#include <gdk/gdkkeysyms.h> - -void -print_memory_profiling( void); -#endif - -static const char *bad_glob_cflash_disk_image_file; - - -#define FPS_LIMITER_FRAME_PERIOD 8 -static SDL_sem *fps_limiter_semaphore; -static int gtk_fps_limiter_disabled = 0; - - -/************************ CONFIG FILE *****************************/ - -// extern char FirmwareFile[256]; -// int LoadFirmware(const char *filename); - -static void *Open_Select(GtkWidget* widget, gpointer data); -static void Launch(); -static void Pause(); -static void Printscreen(); -static void Reset(); - -static GtkActionEntry action_entries[] = { - { "open", "gtk-open", "Open", "<Ctrl>o", NULL, G_CALLBACK(Open_Select) }, - { "run", "gtk-media-play", "Run", "<Ctrl>r", NULL, G_CALLBACK(Launch) }, - { "pause", "gtk-media-pause", "Pause", "<Ctrl>p", NULL, G_CALLBACK(Pause) }, - { "quit", "gtk-quit", "Quit", "<Ctrl>q", NULL, G_CALLBACK(gtk_main_quit) }, - { "printscreen",NULL, "Printscreen", NULL, NULL, G_CALLBACK(Printscreen) }, - { "reset", "gtk-refresh", "Reset", NULL, NULL, G_CALLBACK(Reset) } -}; - -GtkActionGroup * action_group; - -char * CONFIG_FILE; - -SoundInterface_struct *SNDCoreList[] = { -&SNDDummy, -&SNDFile, -&SNDSDL, -NULL -}; - -GPU3DInterface *core3DList[] = { - &gpu3DNull -#ifdef GTKGLEXT_AVAILABLE - , - &gpu3D_opengl_collector -#endif -}; - - -struct screen_render_config { - int opengl; - int soft_colour; -}; - - -struct configured_features { - struct screen_render_config screen; - - int disable_sound; - int disable_3d; - int disable_limiter; - - u16 arm9_gdb_port; - u16 arm7_gdb_port; - - int firmware_language; - - const char *nds_file; - const char *cflash_disk_image_file; -}; - -static void -init_configured_features( struct configured_features *config) { - config->arm9_gdb_port = 0; - config->arm7_gdb_port = 0; - - config->disable_sound = 0; - - config->screen.opengl = 0; - config->screen.soft_colour = 0; - - config->disable_3d = 0; - - config->disable_limiter = 0; - - config->nds_file = NULL; - - config->cflash_disk_image_file = NULL; - - /* use the default language */ - config->firmware_language = -1; -} - -static int -fill_configured_features( struct configured_features *config, - int argc, char ** argv) { - int good_args = 1; - int print_usage = 0; - int i; - - for ( i = 1; i < argc && good_args; i++) { - if ( strcmp( argv[i], "--help") == 0) { - printf( "USAGE: %s [OPTIONS] [nds-file]\n", argv[0]); - printf( "OPTIONS:\n"); -#ifdef GTKGLEXT_AVAILABLE - printf( " --opengl-2d Enables using OpenGL for screen rendering\n"); - printf( " --soft-convert Use software colour conversion during OpenGL\n"); - printf( " screen rendering. May produce better or worse\n"); - printf( " frame rates depending on hardware.\n"); - printf( "\n"); - printf( " --disable-3d Disables the 3D emulation\n"); - printf( "\n"); -#endif - printf( " --disable-sound Disables the sound emulation\n"); - printf( " --disable-limiter Disables the 60 fps limiter\n"); - printf( "\n"); - printf( " --fwlang=LANG Set the language in the firmware, LANG as follows:\n"); - printf( " 0 = Japanese\n"); - printf( " 1 = English\n"); - printf( " 2 = French\n"); - printf( " 3 = German\n"); - printf( " 4 = Italian\n"); - printf( " 5 = Spanish\n"); - printf( "\n"); - printf( " --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n"); - printf( " --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n"); - //printf( " --sticky Enable sticky keys and stylus\n"); - printf( "\n"); - printf( " --cflash=PATH_TO_DISK_IMAGE\n"); - printf( " Enable disk image GBAMP compact flash emulation\n"); - printf( "\n"); - printf( " --help Display this message\n"); - good_args = 0; - } - else if ( strcmp( argv[i], "--disable-sound") == 0) { - config->disable_sound = 1; - } -#ifdef GTKGLEXT_AVAILABLE - else if ( strcmp( argv[i], "--opengl-2d") == 0) { - config->screen.opengl = 1; - } - else if ( strcmp( argv[i], "--soft-convert") == 0) { - config->screen.soft_colour = 1; - } - else if ( strcmp( argv[i], "--disable-3d") == 0) { - config->disable_3d = 1; - } -#endif - else if ( strcmp( argv[i], "--disable-limiter") == 0) { - config->disable_limiter = 1; - } - else if ( strncmp( argv[i], "--fwlang=", 9) == 0) { - char *end_char; - int lang = strtoul( &argv[i][9], &end_char, 10); - - if ( lang >= 0 && lang <= 5) { - config->firmware_language = lang; - } - else { - fprintf( stderr, "Firmware language must be set to a value from 0 to 5.\n"); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) { - char *end_char; - unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); - - if ( port_num > 0 && port_num < 65536) { - config->arm9_gdb_port = port_num; - } - else { - fprintf( stderr, "ARM9 GDB stub port must be in the range 1 to 65535\n"); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--arm7gdb=", 10) == 0) { - char *end_char; - unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); - - if ( port_num > 0 && port_num < 65536) { - config->arm7_gdb_port = port_num; - } - else { - fprintf( stderr, "ARM7 GDB stub port must be in the range 1 to 65535\n"); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--cflash=", 9) == 0) { - if ( config->cflash_disk_image_file == NULL) { - config->cflash_disk_image_file = &argv[i][9]; - } - else { - fprintf( stderr, "CFlash disk image file (\"%s\") already set\n", - config->cflash_disk_image_file); - good_args = 0; - } - } - else { - if ( config->nds_file == NULL) { - config->nds_file = argv[i]; - } - else { - fprintf( stderr, "NDS file (\"%s\") already set\n", config->nds_file); - good_args = 0; - } - } - } - - if ( good_args) { - /* - * check if the configured features are consistant - */ - } - - if ( print_usage) { - fprintf( stderr, "USAGE: %s [options] [nds-file]\n", argv[0]); - fprintf( stderr, "USAGE: %s --help - for help\n", argv[0]); - } - - return good_args; -} - - -/* - * The thread handling functions needed by the GDB stub code. - */ -void * -createThread_gdb( void (*thread_function)( void *data), - void *thread_data) { - GThread *new_thread = g_thread_create( (GThreadFunc)thread_function, - thread_data, - TRUE, - NULL); - - return new_thread; -} - -void -joinThread_gdb( void *thread_handle) { - g_thread_join( thread_handle); -} - - - - -u16 Keypad_Temp[NB_KEYS]; - -int Write_ConfigFile() -{ - int i; - GKeyFile * keyfile; - - keyfile = g_key_file_new(); - - for(i = 0; i < NB_KEYS; i++) - { - g_key_file_set_integer(keyfile, "KEYS", key_names[i], keyboard_cfg[i]); - g_key_file_set_integer(keyfile, "JOYKEYS", key_names[i], joypad_cfg[i]); - } - -// if(FirmwareFile[0]) -// { -// ini_add_section(ini, "FIRMWARE"); -// ini_add_value(ini, "FIRMWARE", "FILE", FirmwareFile); -// } - - g_file_set_contents(CONFIG_FILE, g_key_file_to_data(keyfile, 0, 0), -1, 0); - - g_key_file_free(keyfile); - - return 0; -} - -int Read_ConfigFile() -{ - int i, tmp; - GKeyFile * keyfile = g_key_file_new(); - GError * error = NULL; - - load_default_config(); - - g_key_file_load_from_file(keyfile, CONFIG_FILE, G_KEY_FILE_NONE, 0); - - const char *c; - - /* Load keyboard keys */ - for(i = 0; i < NB_KEYS; i++) - { - tmp = g_key_file_get_integer(keyfile, "KEYS", key_names[i], &error); - if (error != NULL) { - g_error_free(error); - error = NULL; - } else { - keyboard_cfg[i] = tmp; - } - } - - /* Load joystick keys */ - for(i = 0; i < NB_KEYS; i++) - { - tmp = g_key_file_get_integer(keyfile, "JOYKEYS", key_names[i], &error); - if (error != NULL) { - g_error_free(error); - error = NULL; - } else { - joypad_cfg[i] = tmp; - } - } - - g_key_file_free(keyfile); - - return 0; -} - -/************************ GTK *******************************/ - -uint Frameskip = 0; - -//const gint StaCounter[20] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; - -static SDL_Surface *SDL_Screenbuf; -static GdkPixmap *pPixmap; - -static GtkWidget *pWindow; -static GtkWidget *pStatusBar; -static GtkWidget *pToolbar; -static GtkWidget *pDrawingArea; - -/** The target for the expose event */ -static GtkWidget *nds_screen_widget; - -#ifdef GTKGLEXT_AVAILABLE -static GtkWidget *top_screen_widget; -static GtkWidget *bottom_screen_widget; - -GLuint screen_texture[1]; -#endif - -float nds_screen_size_ratio = 1.0f; - - -static BOOL regMainLoop = FALSE; - -static gint pStatusBar_Ctx; -#define pStatusBar_Change(t) gtk_statusbar_pop(GTK_STATUSBAR(pStatusBar), pStatusBar_Ctx); gtk_statusbar_push(GTK_STATUSBAR(pStatusBar), pStatusBar_Ctx, t); - -gboolean EmuLoop(gpointer data); - -void About(GtkWidget* widget, gpointer data) -{ - GdkPixbuf * pixbuf = gdk_pixbuf_new_from_xpm_data(DeSmuME_xpm); - - gtk_show_about_dialog(GTK_WINDOW(pWindow), - "name", "DeSmuME", - "version", VERSION, - "website", "http://desmume.org", - "logo", pixbuf, - "comments", "Nintendo DS emulator based on work by Yopyop", - NULL); - - g_object_unref(pixbuf); -} - -static int Open(const char *filename, const char *cflash_disk_image) -{ - int i = NDS_LoadROM( filename, MC_TYPE_AUTODETECT, 1, - cflash_disk_image); - return i; -} - -static void Launch() -{ - desmume_resume(); - - if(!regMainLoop) - { - g_idle_add_full(EMULOOP_PRIO, &EmuLoop, pWindow, NULL); regMainLoop = TRUE; - } - - pStatusBar_Change("Running ..."); - - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "pause"), TRUE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), FALSE); -} - -static void Pause() -{ - desmume_pause(); - pStatusBar_Change("Paused"); - - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "pause"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); -} - -/* Choose a file then load it */ -static void *Open_Select(GtkWidget* widget, gpointer data) -{ - Pause(); - - GtkFileFilter *pFilter_nds, *pFilter_dsgba, *pFilter_any; - GtkWidget *pFileSelection; - GtkWidget *pParent; - gchar *sChemin; - - pParent = GTK_WIDGET(data); - - pFilter_nds = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_nds, "*.nds"); -#ifdef HAVE_LIBZ - gtk_file_filter_add_pattern(pFilter_nds, "*.nds.gz"); -#endif -#ifdef HAVE_LIBZZIP - gtk_file_filter_add_pattern(pFilter_nds, "*.nds.zip"); -#endif - gtk_file_filter_set_name(pFilter_nds, "Nds binary (.nds)"); - - pFilter_dsgba = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_dsgba, "*.ds.gba"); - gtk_file_filter_set_name(pFilter_dsgba, "Nds binary with loader (.ds.gba)"); - - pFilter_any = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_any, "*"); - gtk_file_filter_set_name(pFilter_any, "All files"); - - /* Creating the selection window */ - pFileSelection = gtk_file_chooser_dialog_new("Open...", - GTK_WINDOW(pParent), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_OK, - NULL); - /* On limite les actions a cette fenetre */ - gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsgba); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); - - /* Affichage fenetre */ - switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) - { - case GTK_RESPONSE_OK: - /* Recuperation du chemin */ - sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); - if(Open((const char*)sChemin, bad_glob_cflash_disk_image_file) < 0) - { - GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - "Unable to load :\n%s", sChemin); - gtk_dialog_run(GTK_DIALOG(pDialog)); - gtk_widget_destroy(pDialog); - } - - //Launch(NULL, pWindow); - - g_free(sChemin); - break; - default: - break; - } - gtk_widget_destroy(pFileSelection); - - // FIXME: should be set sensitive only if a file was really loaded - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "reset"), TRUE); -} - -static void Close() -{ -} - -static void Reset() -{ - NDS_Reset(); - desmume_resume(); - - pStatusBar_Change("Running ..."); -} - -int ScreenCoeff_Size; - - -#ifdef GTKGLEXT_AVAILABLE -static void -gtk_init_main_gl_area(GtkWidget *widget, - gpointer data) -{ - GLenum errCode; - int i; - GdkGLContext *glcontext; - GdkGLDrawable *gldrawable; - GtkWidget *other_drawing_area = (GtkWidget *)data; - glcontext = gtk_widget_get_gl_context (widget); - gldrawable = gtk_widget_get_gl_drawable (widget); - uint16_t blank_texture[256 * 512]; - - /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) - return; - - //printf("Doing GL init\n"); - - for ( i = 0; i < 256 * 512; i++) { - blank_texture[i] = 0x001f; - } - - /* Enable Texture Mapping */ - glEnable( GL_TEXTURE_2D ); - - /* Set the background black */ - glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); - - /* Create The Texture */ - glGenTextures( 1, &screen_texture[0]); - - glBindTexture( GL_TEXTURE_2D, screen_texture[0]); - - /* Generate The Texture */ - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 256, 512, - 0, GL_RGBA, - GL_UNSIGNED_SHORT_1_5_5_5_REV, - blank_texture); - - /* Linear Filtering */ - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - - if ((errCode = glGetError()) != GL_NO_ERROR) { - const GLubyte *errString; - - errString = gluErrorString(errCode); - fprintf( stderr, "Failed to init GL: %s\n", errString); - } - - gdk_gl_drawable_gl_end (gldrawable); - /*** OpenGL END ***/ -} - -static void -gtk_init_sub_gl_area(GtkWidget *widget, - gpointer data) -{ - GLenum errCode; - GdkGLContext *glcontext; - GdkGLDrawable *gldrawable; - glcontext = gtk_widget_get_gl_context (widget); - gldrawable = gtk_widget_get_gl_drawable (widget); - - - /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) - return; - - /* Enable Texture Mapping */ - glEnable( GL_TEXTURE_2D ); - - /* Set the background black */ - glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); - - glBindTexture( GL_TEXTURE_2D, screen_texture[0]); - - if ((errCode = glGetError()) != GL_NO_ERROR) { - const GLubyte *errString; - - errString = gluErrorString(errCode); - fprintf( stderr, "Failed to init GL: %s\n", errString); - } - - gdk_gl_drawable_gl_end (gldrawable); - /*** OpenGL END ***/ -} -#endif - - -/////////////////////////////// DRAWING SCREEN ////////////////////////////////// - -#ifdef GTKGLEXT_AVAILABLE -static int -top_screen_expose_fn( GtkWidget *widget, GdkEventExpose *event, gpointer data) { - GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); - int software_convert = *((int *)data); - - /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) - return FALSE; - - GLenum errCode; - - /* Clear The Screen And The Depth Buffer */ - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - - /* Move Into The Screen 5 Units */ - //glLoadIdentity( ); - - /* Select screen Texture */ - glBindTexture( GL_TEXTURE_2D, screen_texture[0]); - - if ( software_convert) { - int i; - u8 converted[256 * 384 * 3]; - - for ( i = 0; i < (256 * 384); i++) { - converted[(i * 3) + 0] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 0) & 0x1f) << 3; - converted[(i * 3) + 1] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 5) & 0x1f) << 3; - converted[(i * 3) + 2] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 10) & 0x1f) << 3; - } - - glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384, - GL_RGB, - GL_UNSIGNED_BYTE, - converted); - } - else { - glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384, - GL_RGBA, - GL_UNSIGNED_SHORT_1_5_5_5_REV, - &GPU_screen); - } - - - if ((errCode = glGetError()) != GL_NO_ERROR) { - const GLubyte *errString; - - errString = gluErrorString(errCode); - fprintf( stderr, "GL subimage failed: %s\n", errString); - } - - - glBegin( GL_QUADS); - - /* Top screen */ - glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0.0f, 0.0f, 0.0f ); - glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 256.0f, 0.0f, 0.0f ); - glTexCoord2f( 1.0f, 0.375f ); glVertex3f( 256.0f, 192.0f, 0.0f ); - glTexCoord2f( 0.0f, 0.375f ); glVertex3f( 0.0f, 192.0f, 0.0f ); - glEnd( ); - - if ((errCode = glGetError()) != GL_NO_ERROR) { - const GLubyte *errString; - - errString = gluErrorString(errCode); - fprintf( stderr, "GL draw failed: %s\n", errString); - } - - if (gdk_gl_drawable_is_double_buffered (gldrawable)) - gdk_gl_drawable_swap_buffers (gldrawable); - else - glFlush (); - - - gdk_gl_drawable_gl_end (gldrawable); - /*** OpenGL END ***/ - - gtk_widget_queue_draw( bottom_screen_widget); -} - -static int -bottom_screen_expose_fn(GtkWidget *widget, GdkEventExpose *event, gpointer data) -{ - GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); - - //g_print("Sub Expose\n"); - - /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) { - g_print("begin failed\n"); - return FALSE; - } - //g_print("begin\n"); - - GLenum errCode; - - /* Clear The Screen */ - glClear( GL_COLOR_BUFFER_BIT); - - //glBindTexture( GL_TEXTURE_2D, screen_texture[0]); - - glBegin( GL_QUADS); - - /* Bottom screen */ - glTexCoord2f( 0.0f, 0.375f ); glVertex2f( 0.0f, 0.0f); - glTexCoord2f( 1.0f, 0.375f ); glVertex2f( 256.0f, 0.0f); - glTexCoord2f( 1.0f, 0.75f ); glVertex2f( 256.0f, 192.0f); - glTexCoord2f( 0.0f, 0.75f ); glVertex2f( 0.0f, 192.0f); - glEnd( ); - - if (gdk_gl_drawable_is_double_buffered (gldrawable)) - gdk_gl_drawable_swap_buffers (gldrawable); - else - glFlush (); - - - if ((errCode = glGetError()) != GL_NO_ERROR) { - const GLubyte *errString; - - errString = gluErrorString(errCode); - fprintf( stderr, "sub GL draw failed: %s\n", errString); - } - - gdk_gl_drawable_gl_end (gldrawable); - /*** OpenGL END ***/ - - return 1; -} - -static gboolean -common_configure_fn( GtkWidget *widget, - GdkEventConfigure *event ) { - if ( gtk_widget_is_gl_capable( widget) == FALSE) - return TRUE; - - GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); - GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); - - int comp_width = 3 * event->width; - int comp_height = 4 * event->height; - int use_width = 1; - GLenum errCode; - - /* Height / width ration */ - GLfloat ratio; - - //g_print("wdith %d, height %d\n", event->width, event->height); - - /*** OpenGL BEGIN ***/ - if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) - return FALSE; - - if ( comp_width > comp_height) { - use_width = 0; - } - - /* Protect against a divide by zero */ - if ( event->height == 0 ) - event->height = 1; - if ( event->width == 0) - event->width = 1; - - ratio = ( GLfloat )event->width / ( GLfloat )event->height; - - /* Setup our viewport. */ - glViewport( 0, 0, ( GLint )event->width, ( GLint )event->height ); - - /* - * change to the projection matrix and set - * our viewing volume. - */ - glMatrixMode( GL_PROJECTION ); - glLoadIdentity( ); - - { - double left; - double right; - double bottom; - double top; - double other_dimen; - - if ( use_width) { - left = 0.0; - right = 256.0; - - nds_screen_size_ratio = 256.0 / (double)event->width; - - other_dimen = (double)event->width * 3.0 / 4.0; - - top = 0.0; - bottom = 192.0 * ((double)event->height / other_dimen); - } - else { - top = 0.0; - bottom = 192.0; - - nds_screen_size_ratio = 192.0 / (double)event->height; - - other_dimen = (double)event->height * 4.0 / 3.0; - - left = 0.0; - right = 256.0 * ((double)event->width / other_dimen); - } - - /* - printf("%d,%d\n", width, height); - printf("l %lf, r %lf, t %lf, b %lf, other dimen %lf\n", - left, right, top, bottom, other_dimen); - */ - - /* get the area (0,0) to (256,384) into the middle of the viewport */ - gluOrtho2D( left, right, bottom, top); - } - - /* Make sure we're chaning the model view and not the projection */ - glMatrixMode( GL_MODELVIEW ); - - /* Reset The View */ - glLoadIdentity( ); - - if ((errCode = glGetError()) != GL_NO_ERROR) { - const GLubyte *errString; - - errString = gluErrorString(errCode); - fprintf( stderr, "GL resie failed: %s\n", errString); - } - - gdk_gl_drawable_gl_end (gldrawable); - /*** OpenGL END ***/ - - return TRUE; -} - -#endif - - - -/* Drawing callback */ -int gtkFloatExposeEvent (GtkWidget *widget, GdkEventExpose *event, gpointer data) -{ - SDL_PixelFormat screenPixFormat; - SDL_Surface *rawImage, *screenImage; - - rawImage = SDL_CreateRGBSurfaceFrom((void*)&GPU_screen, 256, 192*2, 16, 512, 0x001F, 0x03E0, 0x7C00, 0); - if(rawImage == NULL) return 1; - - memcpy(&screenPixFormat, rawImage->format, sizeof(SDL_PixelFormat)); - - screenPixFormat.BitsPerPixel = 24; - screenPixFormat.BytesPerPixel = 3; - screenPixFormat.Rshift = 0; - screenPixFormat.Gshift = 8; - screenPixFormat.Bshift = 16; - screenPixFormat.Rmask = 0x0000FF; - screenPixFormat.Gmask = 0x00FF00; - screenPixFormat.Bmask = 0xFF0000; - - screenImage = SDL_ConvertSurface(rawImage, &screenPixFormat, 0); - - gdk_draw_rgb_image (widget->window, - widget->style->fg_gc[widget->state],0,0,screenImage->w, screenImage->h, - GDK_RGB_DITHER_NONE,(guchar*)screenImage->pixels,screenImage->pitch); - SDL_FreeSurface(screenImage); - SDL_FreeSurface(rawImage); - - return 1; -} - -static void Draw() -{ -} - -/////////////////////////////// KEYS AND STYLUS UPDATE /////////////////////////////////////// - -static gboolean Stylus_Move(GtkWidget *w, GdkEventMotion *e, gpointer data) -{ - GdkModifierType state; - gint x,y; - s32 EmuX, EmuY; - const int *opengl = (const int *)data; - - - if(click) - { - int scaled_x, scaled_y; - if(e->is_hint) - gdk_window_get_pointer(w->window, &x, &y, &state); - else - { - x= (gint)e->x; - y= (gint)e->y; - state=(GdkModifierType)e->state; - } - - scaled_x = x * nds_screen_size_ratio; - scaled_y = y * nds_screen_size_ratio; - - // fprintf(stderr,"X=%d, Y=%d, S&1=%d\n", x,y,state&GDK_BUTTON1_MASK); - - if ( !(*opengl)) { - scaled_y -= 192; - } - if(scaled_y >= 0 && (state & GDK_BUTTON1_MASK)) - { - EmuX = scaled_x; - EmuY = scaled_y; - if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255; - if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192; - NDS_setTouchPos(EmuX, EmuY); - } - } - - return TRUE; -} -static gboolean Stylus_Press(GtkWidget *w, GdkEventButton *e, gpointer data) -{ - GdkModifierType state; - gint x,y; - s32 EmuX, EmuY; - const int *opengl = (const int *)data; - - if(desmume_running()) - { - if(e->button == 1) - { - int scaled_x, scaled_y; - click = TRUE; - - gdk_window_get_pointer(w->window, &x, &y, &state); - - scaled_x = x * nds_screen_size_ratio; - scaled_y = y * nds_screen_size_ratio; - - if ( !(*opengl)) { - scaled_y -= 192; - } - if(scaled_y >= 0 && (state & GDK_BUTTON1_MASK)) - { - EmuX = scaled_x; - EmuY = scaled_y; - if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255; - if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192; - NDS_setTouchPos(EmuX, EmuY); - } - } - } - - return TRUE; -} -static gboolean Stylus_Release(GtkWidget *w, GdkEventButton *e, gpointer data) -{ - if(click) NDS_releasTouch(); - click = FALSE; - return TRUE; -} - -static u16 Cur_Keypad = 0; - -static gint Key_Press(GtkWidget *w, GdkEventKey *e) -{ - u16 Key = lookup_key(e->keyval); - ADD_KEY( Cur_Keypad, Key ); - if(desmume_running()) update_keypad(Cur_Keypad); - -#ifdef ENABLE_MEMORY_PROFILING - if ( e->keyval == GDK_Tab) { - print_memory_profiling(); - } -#endif - return 1; -} - -static gint Key_Release(GtkWidget *w, GdkEventKey *e) -{ - u16 Key = lookup_key(e->keyval); - RM_KEY( Cur_Keypad, Key ); - if(desmume_running()) update_keypad(Cur_Keypad); - return 1; -} - -/////////////////////////////// CONTROLS EDIT ////////////////////////////////////// - -GtkWidget *mkLabel; -gint Modify_Key_Chosen = 0; - -void Modify_Key_Press(GtkWidget *w, GdkEventKey *e) -{ - char YouPressed[128]; - Modify_Key_Chosen = e->keyval; - sprintf(YouPressed, "You pressed : %d\nClick OK to keep this key.", e->keyval); - gtk_label_set(GTK_LABEL(mkLabel), YouPressed); -} - -void Modify_Key(GtkWidget* widget, gpointer data) -{ - gint Key = GPOINTER_TO_INT(data); - char Title[64]; - char Key_Label[64]; - - GtkWidget *mkDialog; - - sprintf(Title, "Press \"%s\" key ...\n", key_names[Key]); - mkDialog = gtk_dialog_new_with_buttons(Title, - GTK_WINDOW(pWindow), - GTK_DIALOG_MODAL, - GTK_STOCK_OK,GTK_RESPONSE_OK, - GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, - NULL); - - g_signal_connect(G_OBJECT(mkDialog), "key_press_event", G_CALLBACK(Modify_Key_Press), NULL); - - mkLabel = gtk_label_new(Title); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mkDialog)->vbox), mkLabel,TRUE, FALSE, 0); - - gtk_widget_show_all(GTK_DIALOG(mkDialog)->vbox); - - switch(gtk_dialog_run(GTK_DIALOG(mkDialog))) - { - case GTK_RESPONSE_OK: - - Keypad_Temp[Key] = Modify_Key_Chosen; - sprintf(Key_Label, "%s (%d)", key_names[Key], Keypad_Temp[Key]); - gtk_button_set_label(GTK_BUTTON(widget), Key_Label); - - break; - case GTK_RESPONSE_CANCEL: - case GTK_RESPONSE_NONE: - Modify_Key_Chosen = 0; - break; - } - - gtk_widget_destroy(mkDialog); - -} - -void Edit_Controls(GtkWidget* widget, gpointer data) -{ - char Key_Label[64]; - int i; - GtkWidget *ecDialog; - GtkWidget *ecKey; - - memcpy(&Keypad_Temp, &keyboard_cfg, sizeof(keyboard_cfg)); - - ecDialog = gtk_dialog_new_with_buttons("Edit controls", - GTK_WINDOW(pWindow), - GTK_DIALOG_MODAL, - GTK_STOCK_OK,GTK_RESPONSE_OK, - GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, - NULL); - - - for(i = 0; i < NB_KEYS; i++) - { - sprintf(Key_Label, "%s (%d)", key_names[i], Keypad_Temp[i]); - ecKey = gtk_button_new_with_label(Key_Label); - g_signal_connect(G_OBJECT(ecKey), "clicked", G_CALLBACK(Modify_Key), GINT_TO_POINTER(i)); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(ecDialog)->vbox), ecKey,TRUE, FALSE, 0); - } - - gtk_widget_show_all(GTK_DIALOG(ecDialog)->vbox); - - switch (gtk_dialog_run(GTK_DIALOG(ecDialog))) - { - case GTK_RESPONSE_OK: - memcpy(&keyboard_cfg, &Keypad_Temp, sizeof(keyboard_cfg)); - case GTK_RESPONSE_CANCEL: - case GTK_RESPONSE_NONE: - break; - } - gtk_widget_destroy(ecDialog); - -} - -///////////////////////////////// SCREEN SCALING ////////////////////////////// - -#define MAX_SCREENCOEFF 4 - -void Modify_ScreenCoeff(GtkWidget* widget, gpointer data) -{ - int Size = GPOINTER_TO_INT(data); - - gtk_drawing_area_size(GTK_DRAWING_AREA(pDrawingArea), 256 * Size, 384 * Size); - gtk_widget_set_usize (pDrawingArea, 256 * Size, 384 * Size); - - ScreenCoeff_Size = Size; - -} - -/////////////////////////////// LAYER HIDING ///////////////////////////////// - -void Modify_Layer(GtkWidget* widget, gpointer data) -{ - int i; - gchar *Layer = (gchar*)data; - - if(!desmume_running()) - { - return; - } - - if(memcmp(Layer, "Sub", 3) == 0) - { - if(memcmp(Layer, "Sub BG", 6) == 0) - { - i = atoi(Layer + strlen("Sub BG ")); - if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)) == TRUE) { - if(!SubScreen.gpu->dispBG[i]) GPU_addBack(SubScreen.gpu, i); - } else { - if(SubScreen.gpu->dispBG[i]) GPU_remove(SubScreen.gpu, i); } - } - else - { - /* TODO: Disable sprites */ - } - } - else - { - if(memcmp(Layer, "Main BG", 7) == 0) - { - i = atoi(Layer + strlen("Main BG ")); - if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)) == TRUE) { - if(!MainScreen.gpu->dispBG[i]) GPU_addBack(MainScreen.gpu, i); - } else { - if(MainScreen.gpu->dispBG[i]) GPU_remove(MainScreen.gpu, i); } - } - else - { - /* TODO: Disable sprites */ - } - } - //fprintf(stderr,"Changed %s to %d\n",Layer,gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); -} - -const char *Layers_Menu[10] = -{ - "Main BG 0", - "Main BG 1", - "Main BG 2", - "Main BG 3", - "Main OBJ", - "SUB BG 0", - "SUB BG 1", - "SUB BG 2", - "SUB BG 3", - "SUB OBJ", -}; - -/////////////////////////////// PRINTSCREEN ///////////////////////////////// -// TODO: improve (let choose filename, and use png) - -typedef struct -{ - u32 header_size; - s32 width; - s32 height; - u16 r1; - u16 depth; - u32 r2; - u32 size; - s32 r3,r4; - u32 r5,r6; -}BmpImageHeader; - -typedef struct -{ - u16 type; - u32 size; - u16 r1, r2; - u32 data_offset; -}BmpFileHeader; - - -int WriteBMP(const char *filename,u16 *bmp){ - BmpFileHeader fileheader; - BmpImageHeader imageheader; - fileheader.size = 14; - fileheader.type = 0x4D42; - fileheader.r1 = 0; - fileheader.r2=0; - fileheader.data_offset = 14+40; - - imageheader.header_size = 40; - imageheader.r1 = 1; - imageheader.depth = 24; - imageheader.r2 = 0; - imageheader.size = 256 * 192*2 * 3; - imageheader.r3 = 0; - imageheader.r4 = 0; - imageheader.r5 = 0; - imageheader.r6 = 0; - imageheader.width = 256; - imageheader.height = 192*2; - - FILE *fichier = fopen(filename,"wb"); - //fwrite(&fileheader, 1, 14, fichier); - - //fwrite(&imageheader, 1, 40, fichier); - fwrite( &fileheader.type, sizeof(fileheader.type), 1, fichier); - fwrite( &fileheader.size, sizeof(fileheader.size), 1, fichier); - fwrite( &fileheader.r1, sizeof(fileheader.r1), 1, fichier); - fwrite( &fileheader.r2, sizeof(fileheader.r2), 1, fichier); - fwrite( &fileheader.data_offset, sizeof(fileheader.data_offset), 1, fichier); - fwrite( &imageheader.header_size, sizeof(imageheader.header_size), 1, fichier); - fwrite( &imageheader.width, sizeof(imageheader.width), 1, fichier); - fwrite( &imageheader.height, sizeof(imageheader.height), 1, fichier); - fwrite( &imageheader.r1, sizeof(imageheader.r1), 1, fichier); - fwrite( &imageheader.depth, sizeof(imageheader.depth), 1, fichier); - fwrite( &imageheader.r2, sizeof(imageheader.r2), 1, fichier); - fwrite( &imageheader.size, sizeof(imageheader.size), 1, fichier); - fwrite( &imageheader.r3, sizeof(imageheader.r3), 1, fichier); - fwrite( &imageheader.r4, sizeof(imageheader.r4), 1, fichier); - fwrite( &imageheader.r5, sizeof(imageheader.r5), 1, fichier); - fwrite( &imageheader.r6, sizeof(imageheader.r6), 1, fichier); - int i,j,k; - for(j=0;j<192*2;j++)for(i=0;i<256;i++){ - u8 r,g,b; - u16 pixel = bmp[i+(192*2-j)*256]; - r = pixel>>10; - pixel-=r<<10; - g = pixel>>5; - pixel-=g<<5; - b = pixel; - r*=255/31; - g*=255/31; - b*=255/31; - fwrite(&r, 1, sizeof(char), fichier); - fwrite(&g, 1, sizeof(char), fichier); - fwrite(&b, 1, sizeof(char), fichier); -} - fclose(fichier); -return 1; -} - -static void Printscreen() -{ - WriteBMP("./test.bmp",(u16 *)GPU_screen); -} - -/////////////////////////////// DS CONFIGURATION ////////////////////////////////// - -#if 0 - -char Firmwa... [truncated message content] |