From 902f673ab4cac37192250ad951768c643bfa8a5f Mon Sep 17 00:00:00 2001 From: damdoum Date: Mon, 12 Feb 2007 20:12:33 +0000 Subject: [PATCH] misc. function changes (to be a little more generic to claim a GL context) added tile viewer backbone --- desmume/src/gtk-glade/Makefile.am | 3 +- desmume/src/gtk-glade/callbacks.c | 10 +- desmume/src/gtk-glade/callbacks.h | 2 + .../gtk-glade/dTools/callbacks_3_palview.c | 72 +++-- .../gtk-glade/dTools/callbacks_4_tileview.c | 290 ++++++++++++++++++ .../src/gtk-glade/dTools/callbacks_dtools.h | 19 +- desmume/src/gtk-glade/gdk_gl.c | 83 ++--- desmume/src/gtk-glade/gdk_gl.h | 8 +- desmume/src/gtk-glade/glade/DeSmuMe.glade | 41 +-- .../src/gtk-glade/glade/DeSmuMe_Dtools.glade | 204 +++++++++++- desmume/src/gtk-glade/globals.h | 2 +- desmume/src/gtk-glade/main.c | 5 +- 12 files changed, 623 insertions(+), 116 deletions(-) create mode 100755 desmume/src/gtk-glade/dTools/callbacks_4_tileview.c diff --git a/desmume/src/gtk-glade/Makefile.am b/desmume/src/gtk-glade/Makefile.am index 11a1edae8..c757d43d5 100644 --- a/desmume/src/gtk-glade/Makefile.am +++ b/desmume/src/gtk-glade/Makefile.am @@ -8,7 +8,8 @@ desmume_glade_SOURCES = \ callbacks.c callbacks.h callbacks_IO.c callbacks_IO.h desmume.c desmume.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/callbacks_3_palview.c dTools/callbacks_4_tileview.c \ + dTools/callbacks_dtools.h \ dTools/dTools_display.h \ ../sndsdl.h ../sndsdl.c ../ctrlssdl.h ../ctrlssdl.c diff --git a/desmume/src/gtk-glade/callbacks.c b/desmume/src/gtk-glade/callbacks.c index e92092d49..2b9a4d8f1 100755 --- a/desmume/src/gtk-glade/callbacks.c +++ b/desmume/src/gtk-glade/callbacks.c @@ -345,16 +345,22 @@ void on_menu_IO_regs_activate (GtkMenuItem *menuitem, gpointer user_data) GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_1_IOregs"); gtk_widget_show(dlg); } - void on_menu_memview_activate (GtkMenuItem *menuitem, gpointer user_data) { GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_2_MemView"); gtk_widget_show(dlg); } - void on_menu_palview_activate (GtkMenuItem *menuitem, gpointer user_data) { GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_3_PalView"); gtk_widget_show(dlg); } +void on_menu_tileview_activate (GtkMenuItem *menuitem, gpointer user_data) { + GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_4_TileView"); + gtk_widget_show(dlg); +} +void on_menu_wtoolsXX_activate (GtkMenuItem *menuitem, gpointer user_data) { + GtkWidget * w = user_data; + gtk_widget_show(w); +} diff --git a/desmume/src/gtk-glade/callbacks.h b/desmume/src/gtk-glade/callbacks.h index 03ba6743a..4372128b0 100755 --- a/desmume/src/gtk-glade/callbacks.h +++ b/desmume/src/gtk-glade/callbacks.h @@ -48,9 +48,11 @@ G_MODULE_EXPORT void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpoi G_MODULE_EXPORT void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data); /* MENU TOOLS */ +G_MODULE_EXPORT void on_menu_wtoolsXX_activate (GtkMenuItem *menuitem, gpointer user_data); 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); G_MODULE_EXPORT void on_menu_palview_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_tileview_activate (GtkMenuItem *menuitem, gpointer user_data); /* MENU ? */ G_MODULE_EXPORT void on_menu_apropos_activate (GtkMenuItem *menuitem, gpointer user_data); diff --git a/desmume/src/gtk-glade/dTools/callbacks_3_palview.c b/desmume/src/gtk-glade/dTools/callbacks_3_palview.c index 626a58ede..9f950d5c1 100755 --- a/desmume/src/gtk-glade/dTools/callbacks_3_palview.c +++ b/desmume/src/gtk-glade/dTools/callbacks_3_palview.c @@ -21,6 +21,42 @@ #include "callbacks_dtools.h" +void init_combo_palette(GtkComboBox *combo, u16 ** addresses) { + GtkTreeIter iter; + GtkListStore* model = gtk_list_store_new(1, G_TYPE_STRING); + gtk_combo_box_set_model(combo, model); + + int i=0; + +#define DO(str,addr,r) \ + gtk_list_store_append (model, &iter); \ + gtk_list_store_set (model, &iter, 0, str,-1); \ + addresses[i]=((u16*)(addr) r); i++; + + DO("Main screen BG PAL", ARM9Mem.ARM9_VMEM,) + DO("Main screen SPR PAL", ARM9Mem.ARM9_VMEM,+0x100) + DO("Sub screen BG PAL", ARM9Mem.ARM9_VMEM,+0x200) + DO("Sub screen SPR PAL", ARM9Mem.ARM9_VMEM,+0x300) + DO("Main screen ExtPAL 0", ARM9Mem.ExtPal[0][0],) + DO("Main screen ExtPAL 1", ARM9Mem.ExtPal[0][1],) + DO("Main screen ExtPAL 2", ARM9Mem.ExtPal[0][2],) + DO("Main screen ExtPAL 3", ARM9Mem.ExtPal[0][3],) + DO("Sub screen ExtPAL 0", ARM9Mem.ExtPal[1][0],) + DO("Sub screen ExtPAL 1", ARM9Mem.ExtPal[1][1],) + DO("Sub screen ExtPAL 2", ARM9Mem.ExtPal[1][2],) + DO("Sub screen ExtPAL 3", ARM9Mem.ExtPal[1][3],) + DO("Main screen SPR ExtPAL 0", ARM9Mem.ObjExtPal[0][0],) + DO("Main screen SPR ExtPAL 1", ARM9Mem.ObjExtPal[0][1],) + DO("Sub screen SPR ExtPAL 0", ARM9Mem.ObjExtPal[1][0],) + DO("Sub screen SPR ExtPAL 1", ARM9Mem.ObjExtPal[1][1],) + DO("Texture PAL 0", ARM9Mem.texPalSlot[0],) + DO("Texture PAL 1", ARM9Mem.texPalSlot[1],) + DO("Texture PAL 2", ARM9Mem.texPalSlot[2],) + DO("Texture PAL 3", ARM9Mem.texPalSlot[3],) +#undef DO + gtk_combo_box_set_active(combo,0); +} + static u16* base_addr[20]; static BOOL init=FALSE; static int palnum=0; @@ -91,47 +127,17 @@ static void refresh() { g_object_unref(gdkGC); } - static void initialize() { GtkComboBox * combo; - GtkTreeIter iter, *parent=NULL; - GtkListStore* model; - int i=0; if (init) return; - combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_3_palette"); - model = (GtkListStore*)gtk_combo_box_get_model(combo); wPaint= glade_xml_get_widget(xml_tools, "wtools_3_draw"); wSpin = (GtkSpinButton*)glade_xml_get_widget(xml_tools, "wtools_3_palnum"); + combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_3_palette"); + + init_combo_palette(combo, base_addr); -#define DO(str,addr,r) \ - gtk_list_store_append (model, &iter); \ - gtk_list_store_set (model, &iter, 0, str,-1); \ - base_addr[i]=((u16*)(addr) r); i++; - - DO("Main screen BG PAL", ARM9Mem.ARM9_VMEM,) - DO("Main screen SPR PAL", ARM9Mem.ARM9_VMEM,+0x100) - DO("Sub screen BG PAL", ARM9Mem.ARM9_VMEM,+0x200) - DO("Sub screen SPR PAL", ARM9Mem.ARM9_VMEM,+0x300) - DO("Main screen ExtPAL 0", ARM9Mem.ExtPal[0][0],) - DO("Main screen ExtPAL 1", ARM9Mem.ExtPal[0][1],) - DO("Main screen ExtPAL 2", ARM9Mem.ExtPal[0][2],) - DO("Main screen ExtPAL 3", ARM9Mem.ExtPal[0][3],) - DO("Sub screen ExtPAL 0", ARM9Mem.ExtPal[1][0],) - DO("Sub screen ExtPAL 1", ARM9Mem.ExtPal[1][1],) - DO("Sub screen ExtPAL 2", ARM9Mem.ExtPal[1][2],) - DO("Sub screen ExtPAL 3", ARM9Mem.ExtPal[1][3],) - DO("Main screen SPR ExtPAL 0", ARM9Mem.ObjExtPal[0][0],) - DO("Main screen SPR ExtPAL 1", ARM9Mem.ObjExtPal[0][1],) - DO("Sub screen SPR ExtPAL 0", ARM9Mem.ObjExtPal[1][0],) - DO("Sub screen SPR ExtPAL 1", ARM9Mem.ObjExtPal[1][1],) - DO("Texture PAL 0", ARM9Mem.texPalSlot[0],) - DO("Texture PAL 1", ARM9Mem.texPalSlot[1],) - DO("Texture PAL 2", ARM9Mem.texPalSlot[2],) - DO("Texture PAL 3", ARM9Mem.texPalSlot[3],) -#undef DO init=TRUE; - gtk_combo_box_set_active(combo,0); } diff --git a/desmume/src/gtk-glade/dTools/callbacks_4_tileview.c b/desmume/src/gtk-glade/dTools/callbacks_4_tileview.c new file mode 100755 index 000000000..91cf801c9 --- /dev/null +++ b/desmume/src/gtk-glade/dTools/callbacks_4_tileview.c @@ -0,0 +1,290 @@ +/* callbacks_3_palview.c - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * 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 "callbacks_dtools.h" + +void init_combo_memory(GtkComboBox *combo, u8 ** addresses) { + GtkTreeIter iter; + GtkListStore* model = gtk_list_store_new(1, G_TYPE_STRING); + gtk_combo_box_set_model(combo, model); + int i=0; + +#define DO(str,addr,r) \ + gtk_list_store_append (model, &iter); \ + gtk_list_store_set (model, &iter, 0, str,-1); \ + addresses[i]=(addr r); i++; + + DO("A-BG - 0x6000000",ARM9Mem.ARM9_ABG,) + DO("A-BG - 0x6010000",ARM9Mem.ARM9_ABG,+0x10000) + DO("A-BG - 0x6020000",ARM9Mem.ARM9_ABG,+0x20000) + DO("A-BG - 0x6030000",ARM9Mem.ARM9_ABG,+0x30000) + DO("A-BG - 0x6040000",ARM9Mem.ARM9_ABG,+0x40000) + DO("A-BG - 0x6050000",ARM9Mem.ARM9_ABG,+0x50000) + DO("A-BG - 0x6060000",ARM9Mem.ARM9_ABG,+0x60000) + DO("A-BG - 0x6070000",ARM9Mem.ARM9_ABG,+0x70000) + + DO("B-BG - 0x6200000",ARM9Mem.ARM9_BBG,) + DO("B-BG - 0x6210000",ARM9Mem.ARM9_BBG,+0x10000) + + DO("A-OBJ- 0x6400000",ARM9Mem.ARM9_AOBJ,) + DO("A-OBJ- 0x6410000",ARM9Mem.ARM9_AOBJ,+0x10000) + DO("A-OBJ- 0x6420000",ARM9Mem.ARM9_AOBJ,+0x20000) + DO("A-OBJ- 0x6430000",ARM9Mem.ARM9_AOBJ,+0x30000) + + DO("B-OBJ- 0x6600000",ARM9Mem.ARM9_BOBJ,) + DO("B-OBJ- 0x6610000",ARM9Mem.ARM9_BOBJ,+0x10000) + + DO("LCD - 0x6800000",ARM9Mem.ARM9_LCD,) + DO("LCD - 0x6810000",ARM9Mem.ARM9_LCD,+0x10000) + DO("LCD - 0x6820000",ARM9Mem.ARM9_LCD,+0x20000) + DO("LCD - 0x6830000",ARM9Mem.ARM9_LCD,+0x30000) + DO("LCD - 0x6840000",ARM9Mem.ARM9_LCD,+0x40000) + DO("LCD - 0x6850000",ARM9Mem.ARM9_LCD,+0x50000) + DO("LCD - 0x6860000",ARM9Mem.ARM9_LCD,+0x60000) + DO("LCD - 0x6870000",ARM9Mem.ARM9_LCD,+0x70000) + DO("LCD - 0x6880000",ARM9Mem.ARM9_LCD,+0x80000) + DO("LCD - 0x6890000",ARM9Mem.ARM9_LCD,+0x90000) +#undef DO + gtk_combo_box_set_active(combo,0); +} + +static u16* pal_addr[20]; +static u8* mem_addr[26]; +static BOOL init=FALSE; +static int palnum=0; +static int palindex=0; +static int memnum=0; +static int colnum=0; +static void refresh(); +static GtkWidget * wPaint; +static GtkSpinButton * wSpin; +static u16 mem[0x100]; + + +static COLOR c; +static COLOR32 c32; +static GdkGC * gdkGC; + + + +static void wtools_4_update() { + +} + + +static void refresh() { + +} + +static void initialize() { + GtkComboBox * combo; + if (init) return; + + wPaint= glade_xml_get_widget(xml_tools, "wDraw_Tile"); + wSpin = (GtkSpinButton*)glade_xml_get_widget(xml_tools, "wtools_4_palnum"); + combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_palette"); + init_combo_palette(combo, pal_addr); + combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_memory"); + init_combo_memory(combo, mem_addr); + init=TRUE; +} + + +void on_wtools_4_TileView_show (GtkWidget *widget, gpointer data) { + initialize(); + register_Tool(wtools_4_update); +} +gboolean on_wtools_4_TileView_close (GtkWidget *widget, ...) { + unregister_Tool(wtools_4_update); + gtk_widget_hide(widget); + return TRUE; +} + +void on_wtools_4_palette_changed (GtkComboBox *combo, gpointer user_data) { + palindex = gtk_combo_box_get_active(combo); + gtk_widget_set_sensitive((GtkWidget*)wSpin,(palindex >=4)); + gtk_spin_button_set_value(wSpin,0); + refresh(); +} +void on_wtools_4_palnum_value_changed (GtkSpinButton *spin, gpointer user_data) { + palnum = gtk_spin_button_get_value_as_int(spin); + refresh(); +} +void on_wtools_4_memory_changed (GtkComboBox *combo, gpointer user_data) { + memnum = gtk_combo_box_get_active(combo); + refresh(); +} +void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) { + colnum = dyn_CAST(int,user_data); + refresh(); +} + + + +#if 0 + +void other_screen (GtkWidget * widget, int screen) { + if (!my_gl_Begin(screen)) return; + + my_gl_Identity(); + glClear( GL_COLOR_BUFFER_BIT ); + + GPU * gpu = &SubScreen; + _OAM_ * spriteInfo = (_OAM_*)(gpu->oam + 127);// + 127; + u16 i; int mode; + u8 prioTab[256]; + +#define MODE_IDX_16 1 +#define MODE_IDX_256 2 +#define MODE_BMP 3 + + for(i = 0; i<127; ++i, --spriteInfo) + { + size sprSize; + s32 sprX, sprY, x, y, lg; + int xdir; + u8 prio, * src; + u16 * pal; + u16 i,j; + u16 rotScaleA,rotScaleB,rotScaleC,rotScaleD; + int block; + + prio = spriteInfo->Priority; + + // get sprite location and size + sprX = (spriteInfo->X<<23)>>23; + sprY = spriteInfo->Y; + sprSize = sprSizeTab[spriteInfo->Size][spriteInfo->Shape]; + + lg = sprSize.x; + + if (spriteInfo->RotScale == 2) continue; +#if 0 + // switch TOP<-->BOTTOM + if (spriteInfo->VFlip); + // switch LEFT<-->RIGHT + if (spriteInfo->HFlip); + + { + u16 rotScaleIndex; + // index from 0 to 31 + rotScaleIndex = spriteInfo->RotScalIndex + (spriteInfo->HFlip<<1) + (spriteInfo->VFlip << 2); + rotScaleA = T1ReadWord((u8*)(gpu->oam + rotScaleIndex*0x20 + 0x06),0) ; + rotScaleB = T1ReadWord((u8*)(gpu->oam + rotScaleIndex*0x20 + 0x0E),0) ; + rotScaleC = T1ReadWord((u8*)(gpu->oam + rotScaleIndex*0x20 + 0x16),0) ; + rotScaleD = T1ReadWord((u8*)(gpu->oam + rotScaleIndex*0x20 + 0x1E),0) ; + } + + if (spriteInfo->Mode == 2) { + src = gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10); + continue; + } + + if (spriteInfo->Mode == 3) /* sprite is in BMP format */ + { + src = (gpu->sprMem) + (spriteInfo->TileIndex<<4) + (y<sprBMPBoundary); + + if (gpu->dispCnt.bits.OBJ_BMP_2D_dim) // 256*256 + src = (gpu->sprMem) + (((spriteInfo->TileIndex&0x3F0) * 64 + (spriteInfo->TileIndex&0x0F) *8) << 1); + else // 128 * 512 + src = (gpu->sprMem) + (((spriteInfo->TileIndex&0x3E0) * 64 + (spriteInfo->TileIndex&0x1F) *8) << 1); + continue; + } + + + if(gpu->dispCnt.bits.OBJ_Tile_1D) + + if (spriteInfo->Depth) { + //256 colors + glColorTable(GL_TEXTURE_COLOR_TABLE_EXT, + GL_RGBA, 256, GL_RGBA, + GL_UNSIGNED_SHORT_1_5_5_5_REV, pal); + } else { + pal += (spriteInfo->PaletteIndex<<4); + glColorTable(GL_TEXTURE_COLOR_TABLE_EXT, + GL_RGBA, 16, GL_RGBA, + GL_UNSIGNED_SHORT_1_5_5_5_REV, pal); + } + glTexImage2D(GL_TEXTURE_2D, 0, COLOR_INDEX4_EXT, + 16, 16, 0, + GL_COLOR_INDEX, GL_UNSIGNED_BYTE, src); + src = gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10); + pal = (u16*)(ARM9Mem.ARM9_VMEM + 0x200 + gpu->core *0x400); +#endif + } + struct _DISPCNT * dispcnt = &(gpu->dispCnt.bits); + + int boundary = 32; + if (dispcnt->OBJ_Tile_1D) + boundary <<= dispcnt->OBJ_Tile_1D_Bound; + + int bmpboundary = 128; + bmpboundary <<= (dispcnt->OBJ_BMP_mapping & dispcnt->OBJ_BMP_1D_Bound); + + guint Textures[3]; + glGenTextures(3, Textures); + glBindTexture(GL_TEXTURE_2D, Textures[0]); + //proxy + glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA, + 256, 256, 0, + GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL); + + u16 * pal = (u16*)(ARM9Mem.ARM9_VMEM + 0x200 + gpu->core *0x400); + + u8 palette_16[1024][64]; + u8 palette_256[1024][64]; +// u16 tile_BMP[1024][64]; + u8 * index16 = gpu->sprMem; + u8 * index256 = gpu->sprMem; + u16 * indexBMP = gpu->sprMem; + int tile_n, index; + if (gpu->sprMem != NULL) + for (tile_n=0; tile_n<1024; tile_n++) { + for (index=0; index<64; index++) { +// tile_BMP[tile_n][index]=*indexBMP; +// indexBMP++; + palette_256[tile_n][index]=pal[*index256]; + index256++; + + if (index & 1) continue; + palette_16[tile_n][index] =pal[*index16 & 15]; + palette_16[tile_n][index+1]=pal[*index16 >> 4]; + index16++; + } + glBindTexture(GL_TEXTURE_2D, Textures[0]); + glTexSubImage2D(GL_TEXTURE_2D, 0, + (tile_n & 0x1F)<<3, (tile_n >> 5)<<3, + 8, 8, GL_RGBA, + GL_UNSIGNED_SHORT_1_5_5_5_REV, indexBMP); + } + + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex2d(-1.0, 1.0); + glTexCoord2f(0.0, 1.0); glVertex2d(-1.0,-1.0); + glTexCoord2f(1.0, 1.0); glVertex2d( 1.0,-1.0); + glTexCoord2f(1.0, 0.0); glVertex2d( 1.0, 1.0); + glEnd(); + + my_gl_End(screen); + glDeleteTextures(3, &Textures); +} + +#endif diff --git a/desmume/src/gtk-glade/dTools/callbacks_dtools.h b/desmume/src/gtk-glade/dTools/callbacks_dtools.h index ee7bb8626..5e52bd132 100755 --- a/desmume/src/gtk-glade/dTools/callbacks_dtools.h +++ b/desmume/src/gtk-glade/dTools/callbacks_dtools.h @@ -45,10 +45,27 @@ G_MODULE_EXPORT gboolean on_wtools_2_draw_expose_event (GtkWidget *, GdkE G_MODULE_EXPORT gboolean on_wtools_2_draw_scroll_event (GtkWidget *, GdkEventScroll *, gpointer ); /* ***** ***** PALETTE VIEWER ***** ***** */ +// initialise combo box for all palettes +void init_combo_palette(GtkComboBox *combo, u16 ** addresses); + G_MODULE_EXPORT void on_wtools_3_PalView_show (GtkWidget *, gpointer ); G_MODULE_EXPORT gboolean on_wtools_3_PalView_close (GtkWidget *, ...); - G_MODULE_EXPORT gboolean on_wtools_3_PalView_delete_event (GtkWidget *, GdkEvent *, gpointer ); G_MODULE_EXPORT gboolean on_wtools_3_draw_expose_event (GtkWidget *, GdkEventExpose *, gpointer ); G_MODULE_EXPORT void on_wtools_3_palette_changed (GtkComboBox *, gpointer ); G_MODULE_EXPORT void on_wtools_3_palnum_value_changed (GtkSpinButton *, gpointer ); + + +/* ***** ***** TILE VIEWER ***** ***** */ +// initialise combo box for all palettes +void init_combo_memory(GtkComboBox *combo, u8 ** addresses); + +G_MODULE_EXPORT void on_wtools_4_TileView_show (GtkWidget *, gpointer ); +G_MODULE_EXPORT gboolean on_wtools_4_TileView_close (GtkWidget *, ...); +G_MODULE_EXPORT gboolean on_wtools_4_TileView_delete_event (GtkWidget *, GdkEvent *, gpointer ); +G_MODULE_EXPORT void on_wtools_4_memory_changed (GtkComboBox *, gpointer ); +G_MODULE_EXPORT void on_wtools_4_palette_changed (GtkComboBox *, gpointer ); +G_MODULE_EXPORT void on_wtools_4_palnum_value_changed (GtkSpinButton *, gpointer ); +G_MODULE_EXPORT void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data); + + diff --git a/desmume/src/gtk-glade/gdk_gl.c b/desmume/src/gtk-glade/gdk_gl.c index 54c4058db..4bdf8c121 100755 --- a/desmume/src/gtk-glade/gdk_gl.c +++ b/desmume/src/gtk-glade/gdk_gl.c @@ -23,13 +23,22 @@ #ifdef HAVE_LIBGDKGLEXT_X11_1_0 +#define _DUP8(a) a,a,a,a, a,a,a,a +#define _DUP4(a) a,a,a,a +#define _DUP2(a) a,a GLuint Textures[2]; +// free number we can use in tools 0-1 reserved for screens +int free_gl_drawable=2; GdkGLConfig *my_glConfig=NULL; -GdkGLContext *my_glContext[3]={NULL,NULL,NULL}; -GdkGLDrawable *my_glDrawable[3]={NULL,NULL,NULL}; +GdkGLContext *my_glContext[8]={ _DUP8(NULL) }; +GdkGLDrawable *my_glDrawable[8]={ _DUP8(NULL) }; GtkWidget *pDrawingTexArea; +#undef _DUP8 +#undef _DUP4 +#undef _DUP2 + INLINE void my_gl_Identity() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -61,6 +70,18 @@ void my_gl_End (int screen) { gdk_gl_drawable_gl_end(my_glDrawable[screen]); } +void my_gl_Clear(int screen) { + if (!my_gl_Begin(screen)) return; + + /* Set the background black */ + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + my_gl_DrawBeautifulQuad(); + + my_gl_End(screen); +} + void init_GL(GtkWidget * widget, int screen, int share_num) { // init GL capability if (!gtk_widget_set_gl_capability( @@ -74,8 +95,8 @@ void init_GL(GtkWidget * widget, int screen, int share_num) { gtk_widget_realize(widget); // make sure we realize while (gtk_events_pending()) gtk_main_iteration(); - my_glDrawable[screen] = gtk_widget_get_gl_drawable(widget); + if (screen == share_num) { my_glContext[screen] = gtk_widget_get_gl_context(widget); } else { @@ -83,22 +104,21 @@ void init_GL(GtkWidget * widget, int screen, int share_num) { return; } - if (!my_gl_Begin(screen)) return; - - /* Set the background black */ - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - - my_gl_DrawBeautifulQuad(); - - // generate ONE texture (display) - glEnable(GL_TEXTURE_2D); - glGenTextures(2, Textures); - - my_gl_End(screen); reshape(widget, screen); } +int init_GL_free_s(GtkWidget * widget, int share_num) { + int r = free_gl_drawable; free_gl_drawable++; + init_GL(widget, r, share_num); + return r; +} + +int init_GL_free(GtkWidget * widget) { + int r = free_gl_drawable; free_gl_drawable++; + init_GL(widget, r, r); + return r; +} + void init_GL_capabilities() { my_glConfig = gdk_gl_config_new_by_mode ( GDK_GL_MODE_RGB @@ -107,10 +127,17 @@ void init_GL_capabilities() { ); // initialize 1st drawing area init_GL(pDrawingArea,0,0); + my_gl_Clear(0); + + if (!my_gl_Begin(0)) return; + // generate ONE texture (display) + glEnable(GL_TEXTURE_2D); + glGenTextures(2, Textures); + my_gl_End(0); + // initialize 2nd drawing area (sharing context) init_GL(pDrawingArea2,1,0); - - init_GL(pDrawingAreaTex,2,2); + my_gl_Clear(1); } void reshape (GtkWidget * widget, int screen) { @@ -151,29 +178,9 @@ void my_gl_ScreenTexApply(int screen) { glEnd(); } -void other_screen (GtkWidget * widget, int screen) { - if (!my_gl_Begin(screen)) return TRUE; - - my_gl_Identity(); - glClear( GL_COLOR_BUFFER_BIT ); - - glBegin(GL_QUADS); - glColor3ub(255,0,0); glVertex2d(-0.75,-0.75); - glColor3ub(128,255,0); glVertex2d(-0.75, 0.75); - glColor3ub(0,255,128); glVertex2d( 0.75, 0.75); - glColor3ub(0,0,255); glVertex2d( 0.75,-0.75); - glEnd(); - my_gl_End(screen); -} - gboolean screen (GtkWidget * widget, int viewportscreen) { int H,W,screen; - if (viewportscreen > 1) { - other_screen(widget,viewportscreen); - return TRUE; - } - // 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; diff --git a/desmume/src/gtk-glade/gdk_gl.h b/desmume/src/gtk-glade/gdk_gl.h index efc4d4aa6..d740b49bb 100755 --- a/desmume/src/gtk-glade/gdk_gl.h +++ b/desmume/src/gtk-glade/gdk_gl.h @@ -23,8 +23,8 @@ // comment for GL :D //#undef HAVE_LIBGDKGLEXT_X11_1_0 #ifdef HAVE_LIBGDKGLEXT_X11_1_0 - #include - #include + #include + #include #include #include #endif @@ -32,8 +32,12 @@ BOOL my_gl_Begin (int screen); void my_gl_End (int screen); +void my_gl_Clear(int screen); void init_GL_capabilities(); void init_GL(GtkWidget * widget, int screen, int share_num); +int init_GL_free_s(GtkWidget * widget, int share_num); +int init_GL_free(GtkWidget * widget); + void reshape (GtkWidget * widget, int screen); gboolean screen (GtkWidget * widget, int off); diff --git a/desmume/src/gtk-glade/glade/DeSmuMe.glade b/desmume/src/gtk-glade/glade/DeSmuMe.glade index 96d960c5b..d6282651f 100755 --- a/desmume/src/gtk-glade/glade/DeSmuMe.glade +++ b/desmume/src/gtk-glade/glade/DeSmuMe.glade @@ -820,6 +820,28 @@ + + + + True + View Tiles + True + + + + + True + gtk-properties + 1 + 0.5 + 0.5 + 0 + 0 + + + + + @@ -1271,25 +1293,6 @@ - - - - False - 256 - 192 - GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK - - - - - 3 - 4 - 2 - 3 - - - - 0 diff --git a/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade b/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade index bf1c1ef69..767357a3a 100755 --- a/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade +++ b/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade @@ -434,8 +434,8 @@ ARM7 cpu True - False + True @@ -525,14 +525,14 @@ ARM7 cpu - + diff --git a/desmume/src/gtk-glade/globals.h b/desmume/src/gtk-glade/globals.h index f8cae7914..f1b1d4c8a 100755 --- a/desmume/src/gtk-glade/globals.h +++ b/desmume/src/gtk-glade/globals.h @@ -105,7 +105,7 @@ u16 Keypad_Temp[NB_KEYS]; /* main.c */ GtkWidget * pWindow; -GtkWidget * pDrawingArea, * pDrawingArea2, * pDrawingAreaTex; +GtkWidget * pDrawingArea, * pDrawingArea2; GladeXML * xml, * xml_tools; typedef void (*VoidFunPtr)(); diff --git a/desmume/src/gtk-glade/main.c b/desmume/src/gtk-glade/main.c index ada42bd6a..ffcc58f2f 100755 --- a/desmume/src/gtk-glade/main.c +++ b/desmume/src/gtk-glade/main.c @@ -26,7 +26,7 @@ #include "globals.h" GtkWidget * pWindow; -GtkWidget * pDrawingArea, * pDrawingArea2, * pDrawingAreaTex; +GtkWidget * pDrawingArea, * pDrawingArea2; GladeXML * xml, * xml_tools; SoundInterface_struct *SNDCoreList[] = { @@ -251,8 +251,6 @@ int main(int argc, char *argv[]) { pDrawingArea = glade_xml_get_widget(xml, "wDraw_Main"); pDrawingArea2 = glade_xml_get_widget(xml, "wDraw_Sub"); - pDrawingAreaTex = glade_xml_get_widget(xml, "wDraw_Tex"); - /* connect the signals in the interface */ glade_xml_signal_autoconnect_StringObject(xml); glade_xml_signal_autoconnect_StringObject(xml_tools); @@ -277,7 +275,6 @@ int main(int argc, char *argv[]) { gtk_widget_show(pDrawingArea); gtk_widget_show(pDrawingArea2); - //gtk_widget_show(pDrawingAreaTex); /* start event loop */ gtk_main();