diff --git a/desmume/src/gtk-glade/callbacks.c b/desmume/src/gtk-glade/callbacks.c
index 156aef2f5..637453ac0 100755
--- a/desmume/src/gtk-glade/callbacks.c
+++ b/desmume/src/gtk-glade/callbacks.c
@@ -133,15 +133,15 @@ void on_menu_quit_activate (GtkMenuItem *menuitem, gpointer user_data) { gtk
/* MENU SAVES ***** ***** ***** ***** */
void on_loadstateXX_activate (GtkMenuItem *m, gpointer d) {
- int slot = (int)d;
+ int slot = dyn_CAST(int,d);
loadstate_slot(slot);
}
void on_savestateXX_activate (GtkMenuItem *m, gpointer d) {
- int slot = (int)d;
+ int slot = dyn_CAST(int,d);
update_savestate(slot);
}
void on_savetypeXX_activate (GtkMenuItem *m, gpointer d) {
- int type = (int)d;
+ int type = dyn_CAST(int,d);
desmume_savetype(type);
}
@@ -167,27 +167,58 @@ void on_menu_layers_activate (GtkMenuItem *menuitem, gpointer user_data) {
/* SUBMENU FRAMESKIP ***** ***** ***** ***** */
void on_fsXX_activate (GtkMenuItem *menuitem,gpointer user_data) {
- Frameskip = (int)user_data;
+ Frameskip = dyn_CAST(int,user_data);
// printf ("setting FS %d %d\n", Frameskip, user_data);
}
/* SUBMENU SIZE ***** ***** ***** ***** */
-void rightscreen(BOOL apply) {
- GtkBox * sbox = (GtkBox*)glade_xml_get_widget(xml, "whb_Sub");
- GtkWidget * mbox = glade_xml_get_widget(xml, "whb_Main");
- GtkWidget * vbox = glade_xml_get_widget(xml, "wvb_Layout");
- GtkWidget * w = glade_xml_get_widget(xml, "wvb_2_Sub");
- /* we want to change the layout, lower screen goes right */
+void gtk_table_reattach(GtkTable * table, GtkWidget * w,
+ guint left_attach, guint right_attach, guint top_attach, guint bottom_attach,
+ GtkAttachOptions xoptions, GtkAttachOptions yoptions,
+ guint xpadding, guint ypadding) {
+ GList *list;
+ for (list = table->children; list; list = list->next)
+ {
+ GtkTableChild *table_child;
+ table_child = list->data;
+ if (table_child->widget == w) {
+ table_child->left_attach = left_attach;
+ table_child->right_attach = right_attach;
+ table_child->top_attach = top_attach;
+ table_child->bottom_attach = bottom_attach;
+ table_child->xexpand = (xoptions & GTK_EXPAND) != 0;
+ table_child->xshrink = (xoptions & GTK_SHRINK) != 0;
+ table_child->xfill = (xoptions & GTK_FILL) != 0;
+ table_child->xpadding = xpadding;
+ table_child->yexpand = (yoptions & GTK_EXPAND) != 0;
+ table_child->yshrink = (yoptions & GTK_SHRINK) != 0;
+ table_child->yfill = (yoptions & GTK_FILL) != 0;
+ table_child->ypadding = ypadding;
+ break;
+ }
+ }
+}
+
+void rightscreen(BOOL apply) {
+ GtkWidget *chk = glade_xml_get_widget(xml, "wvb_2_Sub");
+ GtkTable *table = glade_xml_get_widget(xml, "table_layout");
+
if (apply) {
- gtk_box_reorder_child(sbox,w,-1);
- gtk_widget_reparent((GtkWidget*)sbox,mbox);
+ /* we want to change the layout, lower screen goes right */
+ gtk_table_reattach(table, pDrawingArea2,
+ 3,4, 0,1, 0,0, 0,0);
+ gtk_table_reattach(table, chk,
+ 4,5, 0,1, 0,0, 0,0);
} else if (!ScreenRight) {
/* we want to change the layout, lower screen goes down */
- gtk_box_reorder_child(sbox,w,0);
- gtk_widget_reparent((GtkWidget*)sbox,vbox);
+ gtk_table_reattach(table, pDrawingArea2,
+ 1,2, 2,3, 0,0, 0,0);
+ gtk_table_reattach(table, chk,
+ 0,1, 2,3, 0,0, 0,0);
}
+
/* pack the window */
MAINWINDOW_RESIZE();
}
@@ -220,7 +251,6 @@ void rotate(float angle) {
resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]);
}
-/* FIXME: Totally broken for 64bit; dyn_CAST won't work. */
void on_sizeXX_activate (GtkMenuItem *menuitem, gpointer user_data) {
float f = dyn_CAST(float,user_data);
// printf("setting ZOOM %f\n",f);
@@ -296,7 +326,6 @@ void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpointer user_data)
rightscreen(ScreenRight);
}
-/* FIXME: Totally broken for 64bit; dyn_CAST won't work. */
void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data) {
/* we want to rotate the screen */
float angle = dyn_CAST(float,user_data);
@@ -359,10 +388,10 @@ void change_bgx_layer(int layer, gboolean state, NDS_Screen scr) {
//fprintf(stderr,"Changed Layer %s to %d\n",layer,state);
}
void on_wc_1_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) {
- int layer = (int)user_data;
+ int layer = dyn_CAST(int,user_data);
change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), MainScreen);
}
void on_wc_2_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) {
- int layer = (int)user_data;
+ int layer = dyn_CAST(int,user_data);
change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), SubScreen);
}
diff --git a/desmume/src/gtk-glade/callbacks_IO.c b/desmume/src/gtk-glade/callbacks_IO.c
index 0eea9661f..932d8e568 100755
--- a/desmume/src/gtk-glade/callbacks_IO.c
+++ b/desmume/src/gtk-glade/callbacks_IO.c
@@ -170,11 +170,11 @@ gboolean screen (GtkWidget * widget, int off) {
/* OUTPUT SCREENS */
gboolean on_wDrawScreen_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) {
- int scr = (int)user_data;
+ int scr = dyn_CAST(int,user_data);
return screen(widget, scr);
}
gboolean on_wDrawScreen_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) {
- int scr = (int)user_data;
+ int scr = dyn_CAST(int,user_data);
reshape(widget, scr); return TRUE;
}
@@ -203,7 +203,7 @@ static void resize_incremental(int i, GdkEventScroll *event) {
}
gboolean on_wDrawScreen_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) {
- int scr = (int)user_data;
+ int scr = dyn_CAST(int,user_data);
// separate zoom factors not supported yet
scr = 0;
resize_incremental(scr,event);
@@ -225,7 +225,7 @@ void set_touch_pos (int x, int y) {
}
gboolean on_wDrawScreen_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
- int scr = (int)user_data;
+ int scr = dyn_CAST(int,user_data);
GdkModifierType state;
gint x,y;
@@ -239,13 +239,16 @@ gboolean on_wDrawScreen_button_press_event (GtkWidget *widget, GdkEventButton
}
break;
case 3: break;
- case 2: rotate(ScreenRotate + 90.0); break;
+ case 2:
+ // filter out 2x / 3x clicks
+ if (event->type==GDK_BUTTON_PRESS)
+ rotate(ScreenRotate + 90.0); break;
}
return TRUE;
}
gboolean on_wDrawScreen_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
- int scr = (int)user_data;
+ int scr = dyn_CAST(int,user_data);
if ((scr==1) ^ ScreenInvert) {
if (click) NDS_releasTouch();
click = FALSE;
@@ -254,7 +257,7 @@ gboolean on_wDrawScreen_button_release_event (GtkWidget *widget, GdkEventButton
}
gboolean on_wDrawScreen_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) {
- int scr = (int)user_data;
+ int scr = dyn_CAST(int,user_data);
GdkModifierType state;
gint x,y;
diff --git a/desmume/src/gtk-glade/desmume.c b/desmume/src/gtk-glade/desmume.c
index d1e275a25..f95c8c29b 100755
--- a/desmume/src/gtk-glade/desmume.c
+++ b/desmume/src/gtk-glade/desmume.c
@@ -143,10 +143,9 @@ gboolean EmuLoop(gpointer data)
notify_Tools();
gtk_widget_queue_draw(pDrawingArea);
gtk_widget_queue_draw(pDrawingArea2);
-
return TRUE;
}
-
+
regMainLoop = FALSE;
return FALSE;
}
diff --git a/desmume/src/gtk-glade/gdk_gl.c b/desmume/src/gtk-glade/gdk_gl.c
index 048e6e83b..db0f0aa0a 100755
--- a/desmume/src/gtk-glade/gdk_gl.c
+++ b/desmume/src/gtk-glade/gdk_gl.c
@@ -39,6 +39,7 @@ INLINE void my_gl_Identity() {
INLINE void my_gl_DrawBeautifulQuad() {
// beautiful quad
+ glColor4ub(255,255,255,128);
glBegin(GL_QUADS);
glColor3ub(255,0,0); glVertex2d(-0.75,-0.75);
glColor3ub(128,255,0); glVertex2d(-0.75, 0.75);
@@ -53,9 +54,10 @@ BOOL my_gl_Begin (int screen) {
}
void my_gl_End (int screen) {
- glFlush ();
if (gdk_gl_drawable_is_double_buffered (my_glDrawable[screen]))
gdk_gl_drawable_swap_buffers (my_glDrawable[screen]);
+ else
+ glFlush ();
gdk_gl_drawable_gl_end(my_glDrawable[screen]);
}
@@ -71,7 +73,7 @@ void init_GL(GtkWidget * widget, int screen) {
// realize so that we get a GdkWindow
gtk_widget_realize(widget);
// make sure we realize
- gtk_events_pending();
+ while (gtk_events_pending()) gtk_main_iteration();
my_glDrawable[screen] = gtk_widget_get_gl_drawable(widget);
// shared context
@@ -81,11 +83,9 @@ void init_GL(GtkWidget * widget, int screen) {
if (!my_gl_Begin(screen)) return;
/* Set the background black */
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
- my_gl_DrawBeautifulQuad();
-
// generated ONE texture (display)
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &Textures[0]);
@@ -112,7 +112,8 @@ void reshape (GtkWidget * widget, int screen) {
!my_gl_Begin(screen)) return;
glViewport (0, 0, widget->allocation.width, widget->allocation.height);
-
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
my_gl_End(screen);
}
@@ -154,16 +155,18 @@ gboolean screen (GtkWidget * widget, int viewportscreen) {
glLoadIdentity();
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ if (desmume_running()) {
+ // rotate
+ glRotatef(ScreenRotate, 0.0, 0.0, 1.0);
+ // draw screen
+ my_gl_Texture2D();
+ if (viewportscreen==0) my_gl_ScreenTex();
+ my_gl_ScreenTexApply(screen);
+ }
+
my_gl_DrawBeautifulQuad();
- // rotate
- glRotatef(ScreenRotate, 0.0, 0.0, 1.0);
-
- // draw screen
- my_gl_Texture2D();
- if (viewportscreen==0) my_gl_ScreenTex();
- my_gl_ScreenTexApply(screen);
-
my_gl_End(viewportscreen);
return TRUE;
}
diff --git a/desmume/src/gtk-glade/glade-xml.c b/desmume/src/gtk-glade/glade-xml.c
index 613384f83..64703e5a5 100755
--- a/desmume/src/gtk-glade/glade-xml.c
+++ b/desmume/src/gtk-glade/glade-xml.c
@@ -63,15 +63,18 @@ autoconnect_foreach_StringObject(const char *signal_handler, GList *signals,
GTK_WIDGET(data->signal_object));
char format[]="%_\0\0";
if (sscanf(data->connect_object,"%%%c:", &format[1])) {
- float obj;
- sscanf(data->connect_object+3,format, &obj);
+ // this should solve 64bit problems but now memory gets
+ // (it should get) deallocated when program is destroyed
+ gpointer argument = g_malloc(sizeof(callback_arg));
+ sscanf(data->connect_object+3,format, argument);
+
// printf ("%f \n",obj);
if (data->signal_after)
g_signal_connect_after(data->signal_object, data->signal_name,
- func, dyn_CAST(gpointer,obj));
+ func, argument);
else
g_signal_connect(data->signal_object, data->signal_name,
- func, dyn_CAST(gpointer,obj));
+ func, argument);
} else {
GObject *other = g_hash_table_lookup(self->priv->name_hash,
diff --git a/desmume/src/gtk-glade/glade/DeSmuMe.glade b/desmume/src/gtk-glade/glade/DeSmuMe.glade
index 9bcc1cb38..17685bd95 100755
--- a/desmume/src/gtk-glade/glade/DeSmuMe.glade
+++ b/desmume/src/gtk-glade/glade/DeSmuMe.glade
@@ -960,122 +960,76 @@
-
+
True
+ 3
+ 5
False
- 0
+ 0
+ 0
-
+
+ 256
+ 192
+ GDK_EXPOSURE_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK
+
+
+
+
+
+
+
+
+ 1
+ 2
+ 0
+ 1
+
+
+
+
+
+
+
+ 256
+ 192
+ GDK_EXPOSURE_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK
+
+
+
+
+
+
+
+
+ 1
+ 2
+ 2
+ 3
+
+
+
+
+
+
+
True
False
0
-
+
True
- False
- 0
-
-
-
- True
- True
- BG0
- True
- GTK_RELIEF_NORMAL
- True
- True
- False
- True
-
-
-
- 0
- False
- False
-
-
-
-
-
- True
- True
- BG1
- True
- GTK_RELIEF_NORMAL
- True
- True
- False
- True
-
-
-
- 0
- False
- False
-
-
-
-
-
- True
- True
- BG2
- True
- GTK_RELIEF_NORMAL
- True
- True
- False
- True
-
-
-
- 0
- False
- False
-
-
-
-
-
- True
- True
- BG3
- True
- GTK_RELIEF_NORMAL
- True
- True
- False
- True
-
-
-
- 0
- False
- False
-
-
-
-
-
- True
- True
- OBJ
- True
- GTK_RELIEF_NORMAL
- True
- True
- False
- True
-
-
-
- 0
- False
- False
-
-
+ True
+ BG0
+ True
+ GTK_RELIEF_NORMAL
+ True
+ True
+ False
+ True
+
0
@@ -1085,16 +1039,17 @@
-
- 256
- 192
- GDK_EXPOSURE_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK
-
-
-
-
-
-
+
+ True
+ True
+ BG1
+ True
+ GTK_RELIEF_NORMAL
+ True
+ True
+ False
+ True
+
0
@@ -1104,8 +1059,57 @@
-
+
True
+ True
+ BG2
+ True
+ GTK_RELIEF_NORMAL
+ True
+ True
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ True
+ BG3
+ True
+ GTK_RELIEF_NORMAL
+ True
+ True
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ True
+ OBJ
+ True
+ GTK_RELIEF_NORMAL
+ True
+ True
+ False
+ True
+
0
@@ -1115,9 +1119,142 @@
- 0
- True
- True
+ 0
+ 1
+ 2
+ 3
+
+
+
+
+
+
+
+ True
+ False
+ 0
+
+
+
+ True
+ True
+ BG0
+ True
+ GTK_RELIEF_NORMAL
+ True
+ True
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ True
+ BG1
+ True
+ GTK_RELIEF_NORMAL
+ True
+ True
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ True
+ BG2
+ True
+ GTK_RELIEF_NORMAL
+ True
+ True
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ True
+ BG3
+ True
+ GTK_RELIEF_NORMAL
+ True
+ True
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ True
+ OBJ
+ True
+ GTK_RELIEF_NORMAL
+ True
+ True
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
+
+
+ 0
+ 1
+ 0
+ 1
+
+
+
+
+
+
+
+ True
+
+
+ 2
+ 3
+ 0
+ 1
+
+ fill
@@ -1126,154 +1263,12 @@
True
- 0
- False
- False
-
-
-
-
-
- True
- False
- 0
-
-
-
- True
- False
- 0
-
-
-
- True
- True
- BG0
- True
- GTK_RELIEF_NORMAL
- True
- True
- False
- True
-
-
-
- 0
- False
- False
-
-
-
-
-
- True
- True
- BG1
- True
- GTK_RELIEF_NORMAL
- True
- True
- False
- True
-
-
-
- 0
- False
- False
-
-
-
-
-
- True
- True
- BG2
- True
- GTK_RELIEF_NORMAL
- True
- True
- False
- True
-
-
-
- 0
- False
- False
-
-
-
-
-
- True
- True
- BG3
- True
- GTK_RELIEF_NORMAL
- True
- True
- False
- True
-
-
-
- 0
- False
- False
-
-
-
-
-
- True
- True
- OBJ
- True
- GTK_RELIEF_NORMAL
- True
- True
- False
- True
-
-
-
- 0
- False
- False
-
-
-
-
- 0
- False
- False
-
-
-
-
-
- 256
- 192
- GDK_EXPOSURE_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK
-
-
-
-
-
-
-
-
- 0
- False
- False
-
-
-
-
- 0
- False
- False
+ 1
+ 2
+ 1
+ 2
+ fill
+
@@ -2214,110 +2209,5 @@
-
diff --git a/desmume/src/gtk-glade/globals.h b/desmume/src/gtk-glade/globals.h
index 966107b00..c8c57aabd 100755
--- a/desmume/src/gtk-glade/globals.h
+++ b/desmume/src/gtk-glade/globals.h
@@ -49,7 +49,37 @@
#include
#include
-#define dyn_CAST(type,var) (*((type*)(&var)))
+
+typedef union _callback_arg{
+ gpointer my_pointer;
+ gconstpointer my_constpointer;
+
+ gfloat my_float;
+ gdouble my_double;
+ gsize my_size;
+ gssize my_ssize;
+
+ gboolean my_boolean;
+
+ guchar my_uchar;
+ guint my_uint;
+ guint8 my_uint8;
+ guint16 my_uint16;
+ guint32 my_uint32;
+ guint64 my_uint64;
+ gushort my_ushort;
+ gulong my_ulong;
+
+ gchar my_char;
+ gint my_int;
+ gint8 my_int8;
+ gint16 my_int16;
+ gint32 my_int32;
+ gint64 my_int64;
+ gshort my_short;
+ glong my_long;
+} callback_arg;
+#define dyn_CAST(gtype,var) (((callback_arg*)var)->my_##gtype)
#include "../MMU.h"
#include "../registers.h"