-/* emugtk.c */
-
+/*
+ * emugtk.c
+ *
+ * Copyright (C) 1999 Jonathan St-André
+ * Copyright (C) 1999 Hugo Villeneuve <hugo@hugovil.com>
+ *
+ * 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 <stdio.h>
#include "config.h"
#include <gtk/gtk.h>
-#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"
#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();
}
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;
}
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 );
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();*/
int
main( int argc, char **argv )
{
+ char *hex_file;
+
ParseCommandLineOptions( argc, argv );
cpu8051_init();
emugtk_window_init();
+ hex_file = get_hex_filename();
+
if( hex_file != NULL ) {
emugtk_new_file( hex_file );
}
void
emugtk_UpdateDisplay( void )
{
+#ifdef EMU8051_DEBUG
g_print( "emugtk_UpdateDisplay()\n" );
+#endif
regwin_Show();
pgmwin_Disasm();
- memwin_DumpD( 0 );
+ memwin_DumpD("0x00");
}
cpu8051_Reset( );
regwin_Show();
pgmwin_Disasm();
- memwin_DumpD( 0 );
+ memwin_DumpD("0x00");
}
cpu8051_Exec();
regwin_Show();
pgmwin_Disasm();
- memwin_DumpD( 0 );
+ memwin_DumpD("0x00");
}
void
emugtk_ResetEvent( GtkWidget *widget, GdkEvent *event, gpointer data )
{
+#ifdef EMU8051_DEBUG
g_print( "emugtk_ResetEvent(...)\n" );
+#endif
emugtk_StopRunning( );
emugtk_Reset( );
}
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( );
void
emugtk_StopEvent( GtkWidget *widget, GdkEvent *event, gpointer data )
{
+#ifdef EMU8051_DEBUG
g_print( "emugtk_StopEvent(...)\n" );
+#endif
emugtk_StopRunning( );
}
void
emugtk_StepEvent( GtkWidget *widget, GdkEvent *event, gpointer data )
{
+#ifdef EMU8051_DEBUG
g_print( "emugtk_StepEvent(...)\n" );
+#endif
emugtk_StopRunning( );
emugtk_Step();
}
{
cpu8051_Exec( );
if( pgmwin_IsBreakpoint( cpu8051.pc ) ) {
+#ifdef EMU8051_DEBUG
g_print( "Breakpoint Hit, stopping!\n" );
+#endif
emugtk_StopRunning( );
}
}
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);
}
}
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");
}
}