X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Fmemwin.c;h=135588a26c55bd2b298d0e26ba2de1897d35a70d;hb=refs%2Ftags%2Fv1.1.2;hp=4387f4661ea40ef4f53a32a191c7ce5b48485b30;hpb=fb3b3529579773b8a14959cc6bc5bb2096fd0fe8;p=emu8051.git diff --git a/src/memwin.c b/src/memwin.c index 4387f46..135588a 100644 --- a/src/memwin.c +++ b/src/memwin.c @@ -29,103 +29,101 @@ #include "memory.h" #include "hexfile.h" #include "cpu8051.h" +#include "gtksizes.h" #include "memwin.h" static GtkWidget *memclist; GtkWidget * -memwin_init( int width, int height ) +memwin_init(int width, int height) { - int i; - GtkWidget *fixed_frame; - - fixed_frame = gtk_frame_new(0); - gtk_frame_set_shadow_type( GTK_FRAME( fixed_frame ), GTK_SHADOW_ETCHED_OUT ); - gtk_widget_set_usize( GTK_WIDGET( fixed_frame ), width, height ); - - memclist = gtk_clist_new( 18 ); - gtk_clist_set_selection_mode( GTK_CLIST( memclist ), GTK_SELECTION_SINGLE ); - gtk_widget_set_usize( GTK_WIDGET( memclist ), 620, 250 ); - - for( i = 0; i < 18; i++ ) { - gtk_clist_set_column_justification( GTK_CLIST( memclist ), i, GTK_JUSTIFY_LEFT ); - } - - gtk_clist_set_column_width( GTK_CLIST( memclist ), 0, 5*8 ); - - for( i = 1; i < 17; i++ ) { - gtk_clist_set_column_width( GTK_CLIST( memclist ), i, 2*8 ); - } - - gtk_clist_set_column_width( GTK_CLIST( memclist ), 17, 16*8 ); - -#if ( GTK_MAJOR_VERSION == 2) - PangoFontDescription *pango_font; - pango_font = pango_font_description_from_string( FIXED_FONT ); - gtk_widget_modify_font( memclist, pango_font ); -#else - { - GtkStyle *style; - /* Setting font for the widget. */ - style = gtk_style_new(); - gdk_font_unref( style->font ); - - /* Load a fixed font */ - style->font = gdk_font_load( FIXED_FONT ); - gtk_widget_set_style( GTK_WIDGET( memclist ), style ); - } -#endif + int i; + GtkWidget *fixed_frame; + PangoFontDescription *pango_font; + char *memdummy[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - char *memdummy[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; - for( i = 0; i < 16; i++ ) { - gtk_clist_append( GTK_CLIST( memclist ), memdummy ); - } + fixed_frame = gtk_frame_new(0); + gtk_frame_set_shadow_type(GTK_FRAME(fixed_frame), + GTK_SHADOW_ETCHED_OUT); + gtk_widget_set_usize(GTK_WIDGET(fixed_frame), width, height); - gtk_container_add( GTK_CONTAINER( fixed_frame ), memclist ); + memclist = gtk_clist_new(18); + gtk_clist_set_selection_mode(GTK_CLIST(memclist), GTK_SELECTION_SINGLE); + gtk_widget_set_usize(GTK_WIDGET(memclist), 620, 250); - return fixed_frame; -} + for (i = 0; i < 18; i++) { + gtk_clist_set_column_justification( + GTK_CLIST(memclist), i, GTK_JUSTIFY_LEFT); + } + + gtk_clist_set_column_width(GTK_CLIST(memclist), 0, + 5 * FIXED_FONT_SYMBOL_WIDTH); + + for (i = 1; i < 17; i++) + gtk_clist_set_column_width(GTK_CLIST(memclist), i, + 2 * FIXED_FONT_SYMBOL_WIDTH); + + gtk_clist_set_column_width(GTK_CLIST(memclist), 17, + 16 * FIXED_FONT_SYMBOL_WIDTH); + pango_font = pango_font_description_from_string(FIXED_FONT); + gtk_widget_modify_font(memclist, pango_font); + + for (i = 0; i < 16; i++) + gtk_clist_append(GTK_CLIST(memclist), memdummy); + + gtk_container_add(GTK_CONTAINER(fixed_frame), memclist); + + return fixed_frame; +} /* Dump 16 rows of 16 bytes from Address in Memory (direct addressing) */ void memwin_DumpD(char *MemAddress) { - char TextTmp[1024]; - int row, column, TextLength; - unsigned int Address; - - if (strlen(MemAddress) != 0) { - if (STREQ(MemAddress, "PC")) - Address = cpu8051.pc; - else - Address = Ascii2Hex(MemAddress, strlen(MemAddress)); - } else { - Address = 0; - } - - gtk_clist_freeze( GTK_CLIST( memclist ) ); - - for ( row = 0; row < 16; row++ ) { - sprintf( TextTmp, "%.4X", Address ); - gtk_clist_set_text( GTK_CLIST( memclist ), row, 0, TextTmp ); - - for ( column = 0; column < 16; column++ ) { - sprintf( TextTmp, "%.2X", ( int ) cpu8051_ReadD( Address + column ) ); - gtk_clist_set_text( GTK_CLIST( memclist ), row, column + 1, TextTmp ); - } - - TextLength = 0; - for ( column = 0; column < 16; column++ ) { - if ( ( ( int ) cpu8051_ReadD( Address + column ) >= 32 ) && ( ( int ) cpu8051_ReadD( Address + column ) <= 126 ) ) - TextLength += sprintf( &TextTmp[ TextLength ], "%c", cpu8051_ReadD( Address + column ) ); - else TextLength += sprintf( &TextTmp[ TextLength ], "." ); - } - gtk_clist_set_text( GTK_CLIST( memclist ), row, 17, TextTmp ); - - Address += 16; - } - - gtk_clist_select_row( GTK_CLIST( memclist ), 0, 0 ); - gtk_clist_thaw( GTK_CLIST( memclist ) ); + char TextTmp[1024]; + int row, column, TextLength; + unsigned int Address; + + if (strlen(MemAddress) != 0) { + if (STREQ(MemAddress, "PC")) + Address = cpu8051.pc; + else + Address = Ascii2Hex(MemAddress, strlen(MemAddress)); + } else { + Address = 0; + } + + gtk_clist_freeze(GTK_CLIST(memclist)); + + for (row = 0; row < 16; row++) { + sprintf(TextTmp, "%.4X", Address); + gtk_clist_set_text(GTK_CLIST(memclist), row, 0, TextTmp); + + for (column = 0; column < 16; column++) { + sprintf(TextTmp, "%.2X", + (int) cpu8051_ReadD(Address + column)); + gtk_clist_set_text(GTK_CLIST(memclist), row, + column + 1, TextTmp); + } + + TextLength = 0; + for (column = 0; column < 16; column++) { + if (((int) cpu8051_ReadD(Address + column) >= 32) && + ((int) cpu8051_ReadD(Address + column) <= 126)) + TextLength += sprintf( + &TextTmp[TextLength], + "%c", cpu8051_ReadD(Address + column)); + else + TextLength += + sprintf(&TextTmp[TextLength], "."); + } + gtk_clist_set_text(GTK_CLIST(memclist), row, 17, TextTmp); + + Address += 16; + } + + gtk_clist_select_row(GTK_CLIST(memclist), 0, 0); + gtk_clist_thaw(GTK_CLIST(memclist)); }