diff --git a/desmume/src/gtk-glade/Makefile.am b/desmume/src/gtk-glade/Makefile.am index 73da41b9d..226e7afe5 100644 --- a/desmume/src/gtk-glade/Makefile.am +++ b/desmume/src/gtk-glade/Makefile.am @@ -1,7 +1,8 @@ bin_PROGRAMS = desmume-glade desmume_glade_SOURCES = \ + globals.h glade-xml.c \ callbacks.c callbacks.h callbacks_IO.c callbacks_IO.h desmume.c desmume.h \ - globals.h keyval_names.c main.c printscreen.c gdk_gl.c gdk_gl.h \ + keyval_names.c main.c printscreen.c gdk_gl.c gdk_gl.h \ dTools/callbacks_1_ioregs.c dTools/callbacks_2_memview.c \ dTools/callbacks_3_palview.c dTools/callbacks_dtools.h \ dTools/dTools_display.h \ diff --git a/desmume/src/gtk-glade/callbacks.c b/desmume/src/gtk-glade/callbacks.c index cb754a73e..0479a685d 100755 --- a/desmume/src/gtk-glade/callbacks.c +++ b/desmume/src/gtk-glade/callbacks.c @@ -26,6 +26,7 @@ int Frameskip = 0; gboolean ScreenRight=FALSE; gboolean ScreenGap=FALSE; +gboolean ScreenInvert=FALSE; /* inline & protos */ @@ -48,12 +49,13 @@ void MAINWINDOW_RESIZE() { GtkWidget * spacer1 = glade_xml_get_widget(xml, "misc_sep3"); GtkWidget * spacer2 = glade_xml_get_widget(xml, "misc_sep4"); int dim = 66 * ScreenCoeff_Size[0]; - + BOOL rotate = (ScreenRotate==90.0 || ScreenRotate==270.0 ); + /* sees whether we want a gap */ if (!ScreenGap) dim = -1; - if (ScreenRight && ScreenRotate) { + if (ScreenRight && rotate) { gtk_widget_set_usize(spacer1, dim, -1); - } else if (!ScreenRight && !ScreenRotate) { + } else if (!ScreenRight && !rotate) { gtk_widget_set_usize(spacer2, -1, dim); } else { gtk_widget_set_usize(spacer1, -1, -1); @@ -130,34 +132,18 @@ void on_menu_quit_activate (GtkMenuItem *menuitem, gpointer user_data) { gtk /* MENU SAVES ***** ***** ***** ***** */ -void on_loadstate1_activate (GtkMenuItem *m, gpointer d) { loadstate_slot(1); } -void on_loadstate2_activate (GtkMenuItem *m, gpointer d) { loadstate_slot(2); } -void on_loadstate3_activate (GtkMenuItem *m, gpointer d) { loadstate_slot(3); } -void on_loadstate4_activate (GtkMenuItem *m, gpointer d) { loadstate_slot(4); } -void on_loadstate5_activate (GtkMenuItem *m, gpointer d) { loadstate_slot(5); } -void on_loadstate6_activate (GtkMenuItem *m, gpointer d) { loadstate_slot(6); } -void on_loadstate7_activate (GtkMenuItem *m, gpointer d) { loadstate_slot(7); } -void on_loadstate8_activate (GtkMenuItem *m, gpointer d) { loadstate_slot(8); } -void on_loadstate9_activate (GtkMenuItem *m, gpointer d) { loadstate_slot(9); } -void on_loadstate10_activate(GtkMenuItem *m, gpointer d) { loadstate_slot(10); } - -void on_savestate1_activate (GtkMenuItem *m, gpointer d) { update_savestate(1); } -void on_savestate2_activate (GtkMenuItem *m, gpointer d) { update_savestate(2); } -void on_savestate3_activate (GtkMenuItem *m, gpointer d) { update_savestate(3); } -void on_savestate4_activate (GtkMenuItem *m, gpointer d) { update_savestate(4); } -void on_savestate5_activate (GtkMenuItem *m, gpointer d) { update_savestate(5); } -void on_savestate6_activate (GtkMenuItem *m, gpointer d) { update_savestate(6); } -void on_savestate7_activate (GtkMenuItem *m, gpointer d) { update_savestate(7); } -void on_savestate8_activate (GtkMenuItem *m, gpointer d) { update_savestate(8); } -void on_savestate9_activate (GtkMenuItem *m, gpointer d) { update_savestate(9); } -void on_savestate10_activate(GtkMenuItem *m, gpointer d) { update_savestate(10); } - -void on_savetype1_activate (GtkMenuItem *m, gpointer d) { desmume_savetype(1); } -void on_savetype2_activate (GtkMenuItem *m, gpointer d) { desmume_savetype(2); } -void on_savetype3_activate (GtkMenuItem *m, gpointer d) { desmume_savetype(3); } -void on_savetype4_activate (GtkMenuItem *m, gpointer d) { desmume_savetype(4); } -void on_savetype5_activate (GtkMenuItem *m, gpointer d) { desmume_savetype(5); } -void on_savetype6_activate (GtkMenuItem *m, gpointer d) { desmume_savetype(6); } +void on_loadstateXX_activate (GtkMenuItem *m, gpointer d) { + int slot = dyn_CAST(int,d); + loadstate_slot(slot); +} +void on_savestateXX_activate (GtkMenuItem *m, gpointer d) { + int slot = dyn_CAST(int,d); + update_savestate(slot); +} +void on_savetypeXX_activate (GtkMenuItem *m, gpointer d) { + int type = dyn_CAST(int,d); + desmume_savetype(type); +} /* MENU EMULATION ***** ***** ***** ***** */ @@ -179,21 +165,32 @@ void on_menu_layers_activate (GtkMenuItem *menuitem, gpointer user_data) { MAINWINDOW_RESIZE(); } - /* SUBMENU FRAMESKIP ***** ***** ***** ***** */ -void on_fs0_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = 0; } -void on_fs1_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = 1; } -void on_fs2_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = 2; } -void on_fs3_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = 3; } -void on_fs4_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = 4; } -void on_fs5_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = 5; } -void on_fs6_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = 6; } -void on_fs7_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = 7; } -void on_fs8_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = 8; } -void on_fs9_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip = 9; } +void on_fsXX_activate (GtkMenuItem *menuitem,gpointer 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 */ + if (apply) { + gtk_box_reorder_child(sbox,w,-1); + gtk_widget_reparent((GtkWidget*)sbox,mbox); + } 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); + } + /* pack the window */ + MAINWINDOW_RESIZE(); +} int H=192, W=256; void resize (float Size1, float Size2) { // not ready yet to handle different zoom factors @@ -208,10 +205,27 @@ void resize (float Size1, float Size2) { /* pack the window */ MAINWINDOW_RESIZE(); } +void rotate(float angle) { + BOOL rotated; + if (angle >= 360.0) angle -= 360.0; + ScreenRotate = angle; + rotated = (ScreenRotate==90.0 || ScreenRotate==270.0); + ScreenInvert = (ScreenRotate >= 180.0); + if (rotated) { + H=256; W=192; + } else { + W=256; H=192; + } + rightscreen(rotated); + resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); +} + +void on_sizeXX_activate (GtkMenuItem *menuitem, gpointer user_data) { + float f = dyn_CAST(float,user_data); +// printf("setting ZOOM %f\n",f); + resize(f,f); +} -void on_size1x_activate (GtkMenuItem *menuitem, gpointer user_data) { resize(1.0,1.0); } -void on_size2x_activate (GtkMenuItem *menuitem, gpointer user_data) { resize(2.0,2.0); } -void on_size3x_activate (GtkMenuItem *menuitem, gpointer user_data) { resize(3.0,3.0); } /* MENU CONFIG ***** ***** ***** ***** */ @@ -277,34 +291,14 @@ void on_menu_gapscreen_activate (GtkMenuItem *menuitem, gpointer user_data) { } void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpointer user_data) { - 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"); - ScreenRight=gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem); - /* we want to change the layout, lower screen goes left */ - if (ScreenRight) { - gtk_box_reorder_child(sbox,w,-1); - gtk_widget_reparent((GtkWidget*)sbox,mbox); - } else { - /* we want to change the layout, lower screen goes down */ - gtk_box_reorder_child(sbox,w,0); - gtk_widget_reparent((GtkWidget*)sbox,vbox); - } - /* pack the window */ - MAINWINDOW_RESIZE(); + rightscreen(ScreenRight); } void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data) { /* we want to rotate the screen */ - ScreenRotate = gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem); - if (ScreenRotate) { - H=256; W=192; - } else { - W=256; H=192; - } - resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); + float angle = dyn_CAST(float,user_data); + rotate(angle); } /* MENU TOOLS ***** ***** ***** ***** */ @@ -362,28 +356,11 @@ void change_bgx_layer(int layer, gboolean state, NDS_Screen scr) { } //fprintf(stderr,"Changed Layer %s to %d\n",layer,state); } - - -/* LAYERS MAIN SCREEN ***** ***** ***** ***** */ -void on_wc_1_BG0_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - change_bgx_layer(0, gtk_toggle_button_get_active(togglebutton), MainScreen); } -void on_wc_1_BG1_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - change_bgx_layer(1, gtk_toggle_button_get_active(togglebutton), MainScreen); } -void on_wc_1_BG2_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - change_bgx_layer(2, gtk_toggle_button_get_active(togglebutton), MainScreen); } -void on_wc_1_BG3_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - change_bgx_layer(3, gtk_toggle_button_get_active(togglebutton), MainScreen); } -void on_wc_1_OBJ_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - change_bgx_layer(4, gtk_toggle_button_get_active(togglebutton), MainScreen); } - -/* LAYERS SECOND SCREEN ***** ***** ***** ***** */ -void on_wc_2b_BG0_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - change_bgx_layer(0, gtk_toggle_button_get_active(togglebutton), SubScreen); } -void on_wc_2b_BG1_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - change_bgx_layer(1, gtk_toggle_button_get_active(togglebutton), SubScreen); } -void on_wc_2b_BG2_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - change_bgx_layer(2, gtk_toggle_button_get_active(togglebutton), SubScreen); } -void on_wc_2b_BG3_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - change_bgx_layer(3, gtk_toggle_button_get_active(togglebutton), SubScreen); } -void on_wc_2b_OBJ_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - change_bgx_layer(4, gtk_toggle_button_get_active(togglebutton), SubScreen); } +void on_wc_1_BGXX_toggled (GtkToggleButton *togglebutton, gpointer 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 = dyn_CAST(int,user_data); + change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), SubScreen); +} diff --git a/desmume/src/gtk-glade/callbacks.h b/desmume/src/gtk-glade/callbacks.h index 2597626bc..03ba6743a 100755 --- a/desmume/src/gtk-glade/callbacks.h +++ b/desmume/src/gtk-glade/callbacks.h @@ -27,59 +27,17 @@ G_MODULE_EXPORT void on_menu_pscreen_activate (GtkMenuItem *menuitem, gpointer G_MODULE_EXPORT void on_menu_quit_activate (GtkMenuItem *menuitem, gpointer user_data); /* MENU SAVES */ -G_MODULE_EXPORT void on_loadstate1_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_loadstate2_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_loadstate3_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_loadstate4_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_loadstate5_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_loadstate6_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_loadstate7_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_loadstate8_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_loadstate9_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_loadstate10_activate(GtkMenuItem *, gpointer ); - -G_MODULE_EXPORT void on_savestate1_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savestate2_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savestate3_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savestate4_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savestate5_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savestate6_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savestate7_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savestate8_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savestate9_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savestate10_activate(GtkMenuItem *, gpointer ); - -G_MODULE_EXPORT void on_savetype1_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savetype2_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savetype3_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savetype4_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savetype5_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savetype6_activate (GtkMenuItem *, gpointer ); - - +G_MODULE_EXPORT void on_loadstateXX_activate (GtkMenuItem *, gpointer ); +G_MODULE_EXPORT void on_savestateXX_activate (GtkMenuItem *, gpointer ); +G_MODULE_EXPORT void on_savetypeXX_activate (GtkMenuItem *, gpointer ); /* MENU EMULATION */ G_MODULE_EXPORT void on_menu_exec_activate (GtkMenuItem *menuitem, gpointer user_data); G_MODULE_EXPORT void on_menu_pause_activate (GtkMenuItem *menuitem, gpointer user_data); G_MODULE_EXPORT void on_menu_reset_activate (GtkMenuItem *menuitem, gpointer user_data); G_MODULE_EXPORT void on_menu_layers_activate (GtkMenuItem *menuitem, gpointer user_data); -/* SUBMENU FRAMESKIP */ -G_MODULE_EXPORT void on_fsXX_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fs0_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fs1_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fs2_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fs3_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fs4_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fs5_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fs6_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fs7_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fs8_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fs9_activate (GtkMenuItem *menuitem, gpointer user_data); -/* SUBMENU SIZE */ -G_MODULE_EXPORT void on_size1x_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_size2x_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_size3x_activate (GtkMenuItem *menuitem, gpointer user_data); - +G_MODULE_EXPORT void on_fsXX_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_sizeXX_activate (GtkMenuItem *menuitem, gpointer user_data); /* MENU CONFIG */ G_MODULE_EXPORT void on_menu_controls_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -88,6 +46,7 @@ G_MODULE_EXPORT void on_menu_audio_on_activate (GtkMenuItem *menuitem, gpoi G_MODULE_EXPORT void on_menu_gapscreen_activate (GtkMenuItem *menuitem, gpointer user_data); G_MODULE_EXPORT void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpointer user_data); G_MODULE_EXPORT void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data); + /* MENU TOOLS */ G_MODULE_EXPORT void on_menu_IO_regs_activate (GtkMenuItem *menuitem, gpointer user_data); G_MODULE_EXPORT void on_menu_memview_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -104,17 +63,6 @@ G_MODULE_EXPORT void on_wgt_Exec_toggled (GtkToggleToolButton *toggletoolbutto G_MODULE_EXPORT void on_wgt_Reset_clicked (GtkToolButton *toolbutton, gpointer user_data); G_MODULE_EXPORT void on_wgt_Quit_clicked (GtkToolButton *toolbutton, gpointer user_data); - -/* LAYERS MAIN SCREEN */ -G_MODULE_EXPORT void on_wc_1_BG0_toggled (GtkToggleButton *togglebutton, gpointer user_data); -G_MODULE_EXPORT void on_wc_1_BG1_toggled (GtkToggleButton *togglebutton, gpointer user_data); -G_MODULE_EXPORT void on_wc_1_BG2_toggled (GtkToggleButton *togglebutton, gpointer user_data); -G_MODULE_EXPORT void on_wc_1_BG3_toggled (GtkToggleButton *togglebutton, gpointer user_data); -G_MODULE_EXPORT void on_wc_1_OBJ_toggled (GtkToggleButton *togglebutton, gpointer user_data); - -/* LAYERS SECOND SCREEN */ -G_MODULE_EXPORT void on_wc_2b_BG0_toggled (GtkToggleButton *togglebutton, gpointer user_data); -G_MODULE_EXPORT void on_wc_2b_BG1_toggled (GtkToggleButton *togglebutton, gpointer user_data); -G_MODULE_EXPORT void on_wc_2b_BG2_toggled (GtkToggleButton *togglebutton, gpointer user_data); -G_MODULE_EXPORT void on_wc_2b_BG3_toggled (GtkToggleButton *togglebutton, gpointer user_data); -G_MODULE_EXPORT void on_wc_2b_OBJ_toggled (GtkToggleButton *togglebutton, gpointer user_data); +/* LAYERS TOGGLE */ +G_MODULE_EXPORT void on_wc_1_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data); +G_MODULE_EXPORT void on_wc_2_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data); diff --git a/desmume/src/gtk-glade/callbacks_IO.c b/desmume/src/gtk-glade/callbacks_IO.c index c24e44d60..31ef9913a 100755 --- a/desmume/src/gtk-glade/callbacks_IO.c +++ b/desmume/src/gtk-glade/callbacks_IO.c @@ -24,7 +24,7 @@ static u16 Cur_Keypad = 0; float ScreenCoeff_Size[2]={1.0,1.0}; -gboolean ScreenRotate=FALSE; +float ScreenRotate=0.0; gboolean Boost=FALSE; int BoostFS=20; int saveFS; @@ -56,26 +56,6 @@ gboolean on_wMainW_key_release_event (GtkWidget *widget, GdkEventKey *event, g /* ***** ***** SCREEN DRAWING ***** ***** */ -int has_pix_col_map=0; -u32 pix_col_map[0x8000]; - -void init_pix_col_map() { - /* precalc colors so we get some fps */ - int a,b,c,A,B,C,rA,rB,rC; - if (has_pix_col_map) return; - for (a=0; a<0x20; a++) { - A=a<<10; rA=A<<9; - for (b=0; b<0x20; b++) { - B=b<<5; rB=B<<6; - for (c=0; c<0x20; c++) { - C=c; rC=C<<3; - pix_col_map[A|B|C]=rA|rB|rC; - } - } - } - has_pix_col_map=1; -} - #define RAW_W 256 #define RAW_H 192 #define RAW_OFFSET 256*192*sizeof(u16) @@ -95,6 +75,35 @@ void black_screen () { memset(on_screen_image32,0,screen_size()); } +#ifndef HAVE_LIBGDKGLEXT_X11_1_0 +// they are empty if no opengl +// else see gdk_gl.c / gdk_gl.h +BOOL my_gl_Begin (int screen) { return FALSE; } +void my_gl_End (int screen) {} +void init_GL_capabilities() {} +void init_GL(GtkWidget * widget, int screen) {} +void reshape (GtkWidget * widget, int screen) {} + +int has_pix_col_map=0; +u32 pix_col_map[0x8000]; + +void init_pix_col_map() { + // precalc factors + int a,b,c,A,B,C,rA,rB,rC; + if (has_pix_col_map) return; + for (a=0; a<0x20; a++) { + A=a<<10; rA=A<<9; + for (b=0; b<0x20; b++) { + B=b<<5; rB=B<<6; + for (c=0; c<0x20; c++) { + C=c; rC=C<<3; + pix_col_map[A|B|C]=rA|rB|rC; + } + } + } + has_pix_col_map=1; +} + void decode_screen () { int x,y, m, W,H,L,BL; @@ -137,15 +146,6 @@ void decode_screen () { } } -#ifndef HAVE_LIBGDKGLEXT_X11_1_0 -// they are empty if no opengl -// else see gdk_gl.c / gdk_gl.h -BOOL my_gl_Begin (int screen) { return FALSE; } -void my_gl_End (int screen) {} -void init_GL_capabilities() {} -void init_GL(GtkWidget * widget, int screen) {} -void reshape (GtkWidget * widget, int screen) {} - gboolean screen (GtkWidget * widget, int off) { int H,W,L; if (off==0) @@ -168,93 +168,22 @@ gboolean screen (GtkWidget * widget, int off) { #endif /* if HAVE_LIBGDKGLEXT_X11_1_0 */ -/* OUTPUT UPPER SCREEN */ -/* OUTPUT LOWER SCREEN */ -void on_wDraw_Main_realize (GtkWidget *widget, gpointer user_data) { - init_GL(widget, 0); +/* OUTPUT SCREENS */ +gboolean on_wDrawScreen_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + return screen(widget, scr); } -void on_wDraw_Sub_realize (GtkWidget *widget, gpointer user_data) { - init_GL(widget, 1); +gboolean on_wDrawScreen_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + reshape(widget, scr); return TRUE; } -gboolean on_wDraw_Main_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { - return screen(widget, 0); -} -gboolean on_wDraw_Sub_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { - return screen(widget, 1); -} - -gboolean on_wDraw_Main_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) { - reshape(widget, 0); return TRUE; -} -gboolean on_wDraw_Sub_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) { - reshape(widget, 1); return TRUE; -} - - - - - - /* ***** ***** INPUT STYLUS / MOUSE ***** ***** */ -void set_touch_pos (int x, int y) { - s32 EmuX, EmuY; - x /= ScreenCoeff_Size[1]; - y /= ScreenCoeff_Size[1]; - EmuX = x; EmuY = y; - if (ScreenRotate) { EmuX = 256-y; EmuY = x; } - 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); -} - -gboolean on_wDraw_Main_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - switch (event->button) { - case 1: break; - case 3: break; - case 2: ScreenCoeff_Size[0]=1.0; - resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); break; - } - return TRUE; -} - -gboolean on_wDraw_Main_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - return TRUE; -} - -gboolean on_wDraw_Sub_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - GdkModifierType state; - gint x,y; - - switch (event->button) { - case 1: - if(desmume_running()) { - click = TRUE; - gdk_window_get_pointer(widget->window, &x, &y, &state); - if (state & GDK_BUTTON1_MASK) - set_touch_pos(x,y); - } - break; - case 3: break; - case 2: - ScreenCoeff_Size[0]=1.0; - //ScreenCoeff_Size[1]=1.0; // separate zoom factors - resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); break; - } - return TRUE; -} - -gboolean on_wDraw_Sub_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - if(click) NDS_releasTouch(); - click = FALSE; - return TRUE; -} - static void resize_incremental(int i, GdkEventScroll *event) { #ifdef HAVE_LIBGDKGLEXT_X11_1_0 float zoom_inc=.125, zoom_min=0.25, zoom_max=5.0; @@ -273,22 +202,63 @@ static void resize_incremental(int i, GdkEventScroll *event) { resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); } -gboolean on_wDraw_Main_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { - resize_incremental(0,event); -} -gboolean on_wDraw_Sub_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { - // using separate zoom factors is bad for now - resize_incremental(0,event); -// resize_incremental(1,event); +gboolean on_wDrawScreen_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + // separate zoom factors not supported yet + scr = 0; + resize_incremental(scr,event); } +void set_touch_pos (int x, int y) { + s32 EmuX, EmuY; + x /= ScreenCoeff_Size[1]; + y /= ScreenCoeff_Size[1]; + EmuX = x; EmuY = y; + if (ScreenRotate==90.0 || ScreenRotate==270.0) { EmuX = 256-y; EmuY = x; } + if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255; + if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192; + if (ScreenInvert) { + EmuX = 255-EmuX; + EmuY = 192-EmuY; + } + NDS_setTouchPos(EmuX, EmuY); +} - -gboolean on_wDraw_Sub_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { +gboolean on_wDrawScreen_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); GdkModifierType state; gint x,y; - if(click) + switch (event->button) { + case 1: + if (((scr==1) ^ ScreenInvert) && desmume_running()) { + click = TRUE; + gdk_window_get_pointer(widget->window, &x, &y, &state); + if (state & GDK_BUTTON1_MASK) + set_touch_pos(x,y); + } + break; + case 3: break; + case 2: rotate(ScreenRotate + 90.0); break; + } + return TRUE; +} + +gboolean on_wDrawScreen_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + if ((scr==1) ^ ScreenInvert) { + if (click) NDS_releasTouch(); + click = FALSE; + } + return TRUE; +} + +gboolean on_wDrawScreen_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + GdkModifierType state; + gint x,y; + + if (((scr==1) ^ ScreenInvert) && click) { if(event->is_hint) gdk_window_get_pointer(widget->window, &x, &y, &state); @@ -297,20 +267,18 @@ gboolean on_wDraw_Sub_motion_notify_event (GtkWidget *widget, GdkEventMotion x= (gint)event->x; y= (gint)event->y; state=(GdkModifierType)event->state; - } - + } // fprintf(stderr,"X=%d, Y=%d, S&1=%d\n", x,y,state&GDK_BUTTON1_MASK); - if(state & GDK_BUTTON1_MASK) set_touch_pos(x,y); } - return TRUE; } + /* ***** ***** KEYBOARD CONFIG / KEY DEFINITION ***** ***** */ u16 Keypad_Temp[NB_KEYS]; guint temp_Key=0; diff --git a/desmume/src/gtk-glade/callbacks_IO.h b/desmume/src/gtk-glade/callbacks_IO.h index 57494443d..dc37a6a06 100755 --- a/desmume/src/gtk-glade/callbacks_IO.h +++ b/desmume/src/gtk-glade/callbacks_IO.h @@ -26,25 +26,16 @@ G_MODULE_EXPORT gboolean on_wMainW_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data); G_MODULE_EXPORT gboolean on_wMainW_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data); -/* OUTPUT UPPER SCREEN */ -G_MODULE_EXPORT void on_wDraw_Main_realize (GtkWidget *widget, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Main_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Main_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); +/* OUTPUT SCREENS */ +G_MODULE_EXPORT gboolean on_wDrawScreen_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDrawScreen_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); -/* OUTPUT LOWER SCREEN */ -G_MODULE_EXPORT void on_wDraw_Sub_realize (GtkWidget *widget, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Sub_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Sub_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); /* INPUT STYLUS / MOUSE */ -G_MODULE_EXPORT gboolean on_wDraw_Sub_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); - -G_MODULE_EXPORT gboolean on_wDraw_Main_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Main_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Sub_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Sub_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Main_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Sub_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDrawScreen_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDrawScreen_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDrawScreen_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDrawScreen_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); diff --git a/desmume/src/gtk-glade/gdk_gl.c b/desmume/src/gtk-glade/gdk_gl.c index 4f8ae29e8..5d7e17917 100755 --- a/desmume/src/gtk-glade/gdk_gl.c +++ b/desmume/src/gtk-glade/gdk_gl.c @@ -116,8 +116,11 @@ void reshape (GtkWidget * widget, int screen) { INLINE void my_gl_Texture2D() { glBindTexture(GL_TEXTURE_2D, Textures[0]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +#define MyFILTER GL_LINEAR +//#define MyFILTER GL_NEAREST + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MyFILTER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MyFILTER); +#undef MyFILTER } INLINE void my_gl_ScreenTex() { @@ -139,23 +142,27 @@ void my_gl_ScreenTexApply(int screen) { glEnd(); } -gboolean screen (GtkWidget * widget, int screen) { - int H,W; - if (!my_gl_Begin(screen)) return TRUE; +gboolean screen (GtkWidget * widget, int viewportscreen) { + int H,W,screen; + // we take care to draw the right thing the right place + // we need to rearrange widgets not to use this trick + screen = (ScreenInvert)?1-viewportscreen:viewportscreen; +// screen = viewportscreen; + if (!my_gl_Begin(viewportscreen)) return TRUE; glLoadIdentity(); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); my_gl_DrawBeautifulQuad(); // rotate - if (ScreenRotate) glRotatef(90.0, 0.0, 0.0, 1.0); + glRotatef(ScreenRotate, 0.0, 0.0, 1.0); // draw screen my_gl_Texture2D(); - if (screen==0) my_gl_ScreenTex(); + if (viewportscreen==0) my_gl_ScreenTex(); my_gl_ScreenTexApply(screen); - my_gl_End(screen); + my_gl_End(viewportscreen); return TRUE; } diff --git a/desmume/src/gtk-glade/glade/DeSmuMe.glade b/desmume/src/gtk-glade/glade/DeSmuMe.glade index bea9d4906..9bcc1cb38 100755 --- a/desmume/src/gtk-glade/glade/DeSmuMe.glade +++ b/desmume/src/gtk-glade/glade/DeSmuMe.glade @@ -102,7 +102,7 @@ True State 1 True - + @@ -112,7 +112,7 @@ True State 2 True - + @@ -122,7 +122,7 @@ True State 3 True - + @@ -132,7 +132,7 @@ True State 4 True - + @@ -142,7 +142,7 @@ True State 5 True - + @@ -152,7 +152,7 @@ True State 6 True - + @@ -162,7 +162,7 @@ True State 7 True - + @@ -172,7 +172,7 @@ True State 8 True - + @@ -182,7 +182,7 @@ True State 9 True - + @@ -192,7 +192,7 @@ True State 10 True - + @@ -215,7 +215,7 @@ True State 1 True - + @@ -225,7 +225,7 @@ True State 2 True - + @@ -235,7 +235,7 @@ True State 3 True - + @@ -245,7 +245,7 @@ True State 4 True - + @@ -255,7 +255,7 @@ True State 5 True - + @@ -265,7 +265,7 @@ True State 6 True - + @@ -275,7 +275,7 @@ True State 7 True - + @@ -285,7 +285,7 @@ True State 8 True - + @@ -295,7 +295,7 @@ True State 9 True - + @@ -305,7 +305,7 @@ True State 10 True - + @@ -326,7 +326,7 @@ TYPE: Auto (1B) True True - + @@ -337,7 +337,7 @@ True False savetype1 - + @@ -348,7 +348,7 @@ True False savetype1 - + @@ -359,7 +359,7 @@ True False savetype1 - + @@ -370,7 +370,7 @@ True False savetype1 - + @@ -381,7 +381,7 @@ True False savetype1 - + @@ -465,7 +465,7 @@ 0 True True - + @@ -476,7 +476,7 @@ True False fs0 - + @@ -487,7 +487,7 @@ True False fs0 - + @@ -498,7 +498,7 @@ True False fs0 - + @@ -509,7 +509,7 @@ True False fs0 - + @@ -520,7 +520,7 @@ True False fs0 - + @@ -531,7 +531,7 @@ True False fs0 - + @@ -542,7 +542,7 @@ True False fs0 - + @@ -553,7 +553,7 @@ True False fs0 - + @@ -564,7 +564,7 @@ True False fs0 - + @@ -587,7 +587,7 @@ 1x True True - + @@ -598,7 +598,7 @@ True False size1x - + @@ -609,7 +609,7 @@ True False size1x - + @@ -703,12 +703,45 @@ - + True - Rotate Screen + Rotate Screen 0 + True + True + + + + + + + True + Rotate Screen 90 True False - + menu_rotatescreen0 + + + + + + + True + Rotate Screen 180 + True + False + menu_rotatescreen0 + + + + + + + True + Rotate Screen 270 + True + False + menu_rotatescreen0 + @@ -955,7 +988,7 @@ True False True - + 0 @@ -975,7 +1008,7 @@ True False True - + 0 @@ -995,7 +1028,7 @@ True False True - + 0 @@ -1015,7 +1048,7 @@ True False True - + 0 @@ -1035,7 +1068,7 @@ True False True - + 0 @@ -1055,12 +1088,13 @@ 256 192 - GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK - - - - - + GDK_EXPOSURE_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK + + + + + + 0 @@ -1111,7 +1145,7 @@ 0 - + True True BG0 @@ -1121,7 +1155,7 @@ True False True - + 0 @@ -1131,7 +1165,7 @@ - + True True BG1 @@ -1141,7 +1175,7 @@ True False True - + 0 @@ -1151,7 +1185,7 @@ - + True True BG2 @@ -1161,7 +1195,7 @@ True False True - + 0 @@ -1171,7 +1205,7 @@ - + True True BG3 @@ -1181,7 +1215,7 @@ True False True - + 0 @@ -1191,7 +1225,7 @@ - + True True OBJ @@ -1201,7 +1235,7 @@ True False True - + 0 @@ -1221,13 +1255,13 @@ 256 192 - GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK - - - - - - + GDK_EXPOSURE_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK + + + + + + 0 @@ -2180,7 +2214,7 @@ - + diff --git a/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade b/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade index 1569a794f..bf1c1ef69 100755 --- a/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade +++ b/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade @@ -525,7 +525,7 @@ ARM7 cpu - + diff --git a/desmume/src/gtk-glade/globals.h b/desmume/src/gtk-glade/globals.h index bce84a5b7..49f5bffa9 100755 --- a/desmume/src/gtk-glade/globals.h +++ b/desmume/src/gtk-glade/globals.h @@ -46,7 +46,7 @@ // comment for GL :D -#undef HAVE_LIBGDKGLEXT_X11_1_0 +//#undef HAVE_LIBGDKGLEXT_X11_1_0 #ifdef HAVE_LIBGDKGLEXT_X11_1_0 #include #include @@ -56,6 +56,9 @@ #include #include #include +#include + +#define dyn_CAST(type,var) (*((type*)(&var))) #include "../MMU.h" #include "../registers.h" @@ -69,6 +72,13 @@ #include "desmume.h" #include "gdk_gl.h" +// autoconnect with strings as user_data + +void +glade_xml_signal_autoconnect_StringObject (GladeXML *self); + +//--- + int Frameskip; u16 Keypad_Temp[NB_KEYS]; @@ -86,12 +96,14 @@ void unregister_Tool(VoidFunPtr fun); /* callbacks.c */ void enable_rom_features(); void resize (float Size1, float Size2); +void rotate(float angle); +gboolean ScreenInvert; +gboolean ScreenGap; +gboolean ScreenRight; /* callbacks_IO.c */ float ScreenCoeff_Size[2]; -gboolean ScreenRotate; -gboolean ScreenRight; -gboolean ScreenGap; +float ScreenRotate; void black_screen (); void edit_controls(); diff --git a/desmume/src/gtk-glade/main.c b/desmume/src/gtk-glade/main.c index 371a3673f..d07c40d8a 100755 --- a/desmume/src/gtk-glade/main.c +++ b/desmume/src/gtk-glade/main.c @@ -253,8 +253,8 @@ int main(int argc, char *argv[]) { pDrawingArea2 = glade_xml_get_widget(xml, "wDraw_Sub"); /* connect the signals in the interface */ - glade_xml_signal_autoconnect(xml); - glade_xml_signal_autoconnect(xml_tools); + glade_xml_signal_autoconnect_StringObject(xml); + glade_xml_signal_autoconnect_StringObject(xml_tools); init_GL_capabilities();