X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Femugtk.c;h=45448a2f13db05a2ccb31f264b2a01ef556dc454;hb=fb3b3529579773b8a14959cc6bc5bb2096fd0fe8;hp=3d5cccded2ac17e54f3d66d41d74fc3bb5d02b72;hpb=b1fbb635cdd64e96bf36a62dc6b59d6724f5ad57;p=emu8051.git diff --git a/src/emugtk.c b/src/emugtk.c index 3d5cccd..45448a2 100644 --- a/src/emugtk.c +++ b/src/emugtk.c @@ -1,20 +1,39 @@ -/* emugtk.c */ - +/* + * emugtk.c + * + * Copyright (C) 1999 Jonathan St-André + * Copyright (C) 1999 Hugo Villeneuve + * + * This program 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. + * + * This program 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; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ #include #include "config.h" #include -#include "emugtk.h" -#include "reset.xpm" -#include "run.xpm" -#include "stop.xpm" -#include "step.xpm" #include "common.h" #include "cpu8051.h" #include "options.h" #include "hexfile.h" + +#include "emugtk.h" +#include "reset.xpm" +#include "run.xpm" +#include "stop.xpm" +#include "step.xpm" #include "filemenu.h" #include "viewmenu.h" #include "helpmenu.h" @@ -22,41 +41,17 @@ #include "pgmwin.h" #include "memwin.h" - static int RunningState; static int RunFuncTag; - - static GtkWidget *mainwin; - -/* In options.c */ -extern char *hex_file; - - -/* Signal DeleteEvent */ -/* If you return FALSE in the "delete_event" signal handler, - * GTK will emit the "destroy" signal. Returning TRUE means - * you don't want the window to be destroyed. - * This is useful for popping up 'are you sure you want to quit?' - * type dialogs. - */ -static gboolean -WindowDeleteEvent( GtkWidget *widget, GdkEvent *event, gpointer data ) -{ - g_print( "emugtk_DeleteEvent(...)\n" ); - - emugtk_StopRunning( ); - - return FALSE; -} - - /* Signal DestroyEvent */ static void WindowDestroyEvent( GtkWidget *widget, gpointer data ) { +#ifdef EMU8051_DEBUG g_print( "emugtk_DestroyEvent(...)\n" ); +#endif gtk_main_quit(); } @@ -77,7 +72,7 @@ AddPixButton( GtkWidget *box, gchar **pixmap_array ) icon = gtk_pixmap_new( image, transparent ); gtk_container_add( GTK_CONTAINER(button), icon ); - gtk_box_pack_start( GTK_BOX(box), button, FALSE, FALSE, 2 ); + gtk_box_pack_start( GTK_BOX(box), button, FALSE, FALSE, 0 ); return button; } @@ -91,7 +86,7 @@ AddButtons( void ) GtkWidget *button; /* The buttons of the hbox are NOT given equal space in the box. */ - button_hbox = gtk_hbox_new( FALSE, 5 ); + button_hbox = gtk_hbox_new( FALSE, 0 ); /* Creating the RESET button. */ button = AddPixButton( button_hbox, reset_xpm ); @@ -162,10 +157,6 @@ emugtk_window_init( void ) gtk_signal_connect( GTK_OBJECT(mainwin), "destroy", GTK_SIGNAL_FUNC(WindowDestroyEvent), NULL ); - /* Window DELETE event. */ - gtk_signal_connect( GTK_OBJECT(mainwin), "delete_event", GTK_SIGNAL_FUNC(WindowDeleteEvent), - NULL ); - /* Setting main window geometry based on command line options (if specified). */ /*MainWindowSetGeometry();*/ @@ -212,6 +203,8 @@ emugtk_window_init( void ) int main( int argc, char **argv ) { + char *hex_file; + ParseCommandLineOptions( argc, argv ); cpu8051_init(); @@ -222,6 +215,8 @@ main( int argc, char **argv ) emugtk_window_init(); + hex_file = get_hex_filename(); + if( hex_file != NULL ) { emugtk_new_file( hex_file ); } @@ -263,11 +258,13 @@ AddMenuSeparator( GtkWidget *menu ) void emugtk_UpdateDisplay( void ) { +#ifdef EMU8051_DEBUG g_print( "emugtk_UpdateDisplay()\n" ); +#endif regwin_Show(); pgmwin_Disasm(); - memwin_DumpD( 0 ); + memwin_DumpD("0x00"); } @@ -291,7 +288,7 @@ emugtk_Reset( void ) cpu8051_Reset( ); regwin_Show(); pgmwin_Disasm(); - memwin_DumpD( 0 ); + memwin_DumpD("0x00"); } @@ -304,7 +301,7 @@ emugtk_Step( void ) cpu8051_Exec(); regwin_Show(); pgmwin_Disasm(); - memwin_DumpD( 0 ); + memwin_DumpD("0x00"); } @@ -314,7 +311,9 @@ emugtk_Step( void ) void emugtk_ResetEvent( GtkWidget *widget, GdkEvent *event, gpointer data ) { +#ifdef EMU8051_DEBUG g_print( "emugtk_ResetEvent(...)\n" ); +#endif emugtk_StopRunning( ); emugtk_Reset( ); } @@ -326,7 +325,9 @@ emugtk_ResetEvent( GtkWidget *widget, GdkEvent *event, gpointer data ) void emugtk_RunEvent( GtkWidget *widget, GdkEvent *event, gpointer data ) { +#ifdef EMU8051_DEBUG g_print( "emugtk_RunEvent(...)\n" ); +#endif if ( RunningState ) { // g_print( "Getting out of RunningState! \n" ); emugtk_StopRunning( ); @@ -344,7 +345,9 @@ emugtk_RunEvent( GtkWidget *widget, GdkEvent *event, gpointer data ) void emugtk_StopEvent( GtkWidget *widget, GdkEvent *event, gpointer data ) { +#ifdef EMU8051_DEBUG g_print( "emugtk_StopEvent(...)\n" ); +#endif emugtk_StopRunning( ); } @@ -355,7 +358,9 @@ emugtk_StopEvent( GtkWidget *widget, GdkEvent *event, gpointer data ) void emugtk_StepEvent( GtkWidget *widget, GdkEvent *event, gpointer data ) { +#ifdef EMU8051_DEBUG g_print( "emugtk_StepEvent(...)\n" ); +#endif emugtk_StopRunning( ); emugtk_Step(); } @@ -369,7 +374,9 @@ emugtk_Running( ) { cpu8051_Exec( ); if( pgmwin_IsBreakpoint( cpu8051.pc ) ) { +#ifdef EMU8051_DEBUG g_print( "Breakpoint Hit, stopping!\n" ); +#endif emugtk_StopRunning( ); } } @@ -393,17 +400,12 @@ void emugtk_StartRunning( void ) { if ( !RunningState ) { - +#ifdef EMU8051_DEBUG printf( "emugtk_StartRunning( )\n" ); - - /*RunFuncTag = gtk_idle_add( GtkFunction( RunningFunction ), 0 );*/ +#endif RunFuncTag = gtk_idle_add( RunningFunction, 0 ); RunningState = 1; - - // gtk_widget_hide( GTK_WIDGET( ButtonRun ) ); - // gtk_widget_show_now( GTK_WIDGET( ButtonStop ) ); - // gtk_table_attach_defaults( GTK_TABLE( ButtonTable ), ButtonStop, 3, 4, 0, 1); } } @@ -415,14 +417,13 @@ void emugtk_StopRunning( ) { if (RunningState) { +#ifdef EMU8051_DEBUG printf( "emugtk_StopRunning( )\n" ); +#endif gtk_idle_remove( RunFuncTag ); RunningState = 0; - //gtk_widget_hide( GTK_WIDGET( ButtonStop ) ); - //gtk_widget_show( GTK_WIDGET( ButtonRun ) ); - // gtk_table_attach_defaults( GTK_TABLE( ButtonTable ), ButtonRun, 3, 4, 0, 1); regwin_Show(); pgmwin_Disasm(); - memwin_DumpD( 0 ); + memwin_DumpD("0x00"); } }