From b5d825c2c7e133c3fe07d9c12895f24f4c714721 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 28 Aug 2006 20:07:22 +0000 Subject: Initial GEMMA files --- Makefile | 33 ++++++-- callbacks.c | 10 +++ callbacks.h | 2 + gemma.glade | 251 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gemma.gladep | 10 +++ main.c | 49 ++++++++++++ support.c | 144 ++++++++++++++++++++++++++++++++++ support.h | 69 ++++++++++++++++ 8 files changed, 562 insertions(+), 6 deletions(-) create mode 100644 callbacks.c create mode 100644 callbacks.h create mode 100644 gemma.glade create mode 100644 gemma.gladep create mode 100644 main.c create mode 100644 support.c create mode 100644 support.h diff --git a/Makefile b/Makefile index 3d861e0..160355c 100644 --- a/Makefile +++ b/Makefile @@ -18,9 +18,14 @@ # # ------------------------------------------------------------------------- # -# $Id: Makefile,v 1.9 2006-08-28 19:14:59 ianc Exp $ +# $Id: Makefile,v 1.10 2006-08-28 20:07:22 ianc Exp $ # +# +# CONFIGUATION +# ============ +# + # This CFLAGS assumes that gcc is being used. # Simply comment out if not, and replace as needed. # Other CFLAGS lines *are* required. @@ -33,9 +38,13 @@ CFLAGS = -g -Wall -Werror -pedantic -ansi -O2 -finline-functions # test - Tests built from source using tpasm. # TARGETS = emma -#TARGETS += gemma +TARGETS += gemma TARGETS += tests +# If you're building GEMMA, you need this. +# +CFLAGS += `pkg-config --cflags gtk+-2.0` + # Remove this to disable the disassembler (saving some memory) # CFLAGS += -DENABLE_DISASSEM @@ -46,11 +55,21 @@ CFLAGS += -DENABLE_READLINE LIBS += -lreadline +# +# END OF CONFIGUATION +# =================== +# + + SOURCE = z80.c \ z80_decode.c \ z80_dis.c \ expr.c \ - emma.c + emma.c \ + main.c \ + support.c \ + callbacks.c \ + interface.c BASE_O = z80.o \ z80_decode.o \ @@ -59,7 +78,10 @@ BASE_O = z80.o \ EMMA_O = emma.o -GEMMA_O = gemma.o +GEMMA_O = main.o \ + support.o \ + callbacks.o \ + interface.o all: $(TARGETS) @@ -67,8 +89,7 @@ emma: $(BASE_O) $(EMMA_O) cc -o emma $(BASE_O) $(EMMA_O) $(LIBS) gemma: $(BASE_O) $(GEMMA_O) - cc `pkg-config --cflags gtk+-2.0` -o gemma $(GBASE_O) $(GEMMA_O) \ - `pkg-config --libs gtk+-2.0` + cc -o gemma $(GBASE_O) $(GEMMA_O) `pkg-config --libs gtk+-2.0` tests: emucpm.hex zexdoc.hex zexall.hex diff --git a/callbacks.c b/callbacks.c new file mode 100644 index 0000000..019fde9 --- /dev/null +++ b/callbacks.c @@ -0,0 +1,10 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include "callbacks.h" +#include "interface.h" +#include "support.h" + diff --git a/callbacks.h b/callbacks.h new file mode 100644 index 0000000..6fefc7c --- /dev/null +++ b/callbacks.h @@ -0,0 +1,2 @@ +#include + diff --git a/gemma.glade b/gemma.glade new file mode 100644 index 0000000..3e944ac --- /dev/null +++ b/gemma.glade @@ -0,0 +1,251 @@ + + + + + + + True + GEMMA + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 770 + 640 + True + True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + + + + True + False + 0 + + + + 3 + True + False + 0 + + + + True + True + 0 + + + + True + True + 0 + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + False + False + True + False + False + + + + + True + False + + + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + False + False + True + False + False + + + + + True + True + + + + + True + False + + + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + 1 + True + True + False + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_CHAR + False + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + True + True + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_START + 10 + + + + True + True + True + Run + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + Step + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + Step Over + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + Stop + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + Load HEX + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + Quit + True + GTK_RELIEF_NORMAL + True + + + + + 7 + False + True + + + + + 0 + True + True + + + + + + + diff --git a/gemma.gladep b/gemma.gladep new file mode 100644 index 0000000..6b08f7f --- /dev/null +++ b/gemma.gladep @@ -0,0 +1,10 @@ + + + + + GEMMA + gemma + . + FALSE + FALSE + diff --git a/main.c b/main.c new file mode 100644 index 0000000..f4f66a4 --- /dev/null +++ b/main.c @@ -0,0 +1,49 @@ +/* + + z80 - Z80 emulation + + Copyright (C) 2006 Ian Cowburn + + Some of the opcode routines are based on the Z80 emulation from YAZE, + Copyright (c) 1995 Frank D. Cringle. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------- + + $Id$ + +*/ +static const char ident[]="$Id$"; + +#include + +#include "interface.h" +#include "support.h" + +int main (int argc, char *argv[]) +{ + GtkWidget *top_window; + + gtk_set_locale (); + gtk_init (&argc, &argv); + + top_window = create_top_window (); + gtk_widget_show (top_window); + + gtk_main (); + return 0; +} + diff --git a/support.c b/support.c new file mode 100644 index 0000000..00aff29 --- /dev/null +++ b/support.c @@ -0,0 +1,144 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include + +#include + +#include "support.h" + +GtkWidget* +lookup_widget (GtkWidget *widget, + const gchar *widget_name) +{ + GtkWidget *parent, *found_widget; + + for (;;) + { + if (GTK_IS_MENU (widget)) + parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); + else + parent = widget->parent; + if (!parent) + parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); + if (parent == NULL) + break; + widget = parent; + } + + found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), + widget_name); + if (!found_widget) + g_warning ("Widget not found: %s", widget_name); + return found_widget; +} + +static GList *pixmaps_directories = NULL; + +/* Use this function to set the directory containing installed pixmaps. */ +void +add_pixmap_directory (const gchar *directory) +{ + pixmaps_directories = g_list_prepend (pixmaps_directories, + g_strdup (directory)); +} + +/* This is an internally used function to find pixmap files. */ +static gchar* +find_pixmap_file (const gchar *filename) +{ + GList *elem; + + /* We step through each of the pixmaps directory to find it. */ + elem = pixmaps_directories; + while (elem) + { + gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, + G_DIR_SEPARATOR_S, filename); + if (g_file_test (pathname, G_FILE_TEST_EXISTS)) + return pathname; + g_free (pathname); + elem = elem->next; + } + return NULL; +} + +/* This is an internally used function to create pixmaps. */ +GtkWidget* +create_pixmap (GtkWidget *widget, + const gchar *filename) +{ + gchar *pathname = NULL; + GtkWidget *pixmap; + + if (!filename || !filename[0]) + return gtk_image_new (); + + pathname = find_pixmap_file (filename); + + if (!pathname) + { + g_warning (_("Couldn't find pixmap file: %s"), filename); + return gtk_image_new (); + } + + pixmap = gtk_image_new_from_file (pathname); + g_free (pathname); + return pixmap; +} + +/* This is an internally used function to create pixmaps. */ +GdkPixbuf* +create_pixbuf (const gchar *filename) +{ + gchar *pathname = NULL; + GdkPixbuf *pixbuf; + GError *error = NULL; + + if (!filename || !filename[0]) + return NULL; + + pathname = find_pixmap_file (filename); + + if (!pathname) + { + g_warning (_("Couldn't find pixmap file: %s"), filename); + return NULL; + } + + pixbuf = gdk_pixbuf_new_from_file (pathname, &error); + if (!pixbuf) + { + fprintf (stderr, "Failed to load pixbuf file: %s: %s\n", + pathname, error->message); + g_error_free (error); + } + g_free (pathname); + return pixbuf; +} + +/* This is used to set ATK action descriptions. */ +void +glade_set_atk_action_description (AtkAction *action, + const gchar *action_name, + const gchar *description) +{ + gint n_actions, i; + + n_actions = atk_action_get_n_actions (action); + for (i = 0; i < n_actions; i++) + { + if (!strcmp (atk_action_get_name (action, i), action_name)) + atk_action_set_description (action, i, description); + } +} + diff --git a/support.h b/support.h new file mode 100644 index 0000000..a32649e --- /dev/null +++ b/support.h @@ -0,0 +1,69 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +/* + * Standard gettext macros. + */ +#ifdef ENABLE_NLS +# include +# undef _ +# define _(String) dgettext (PACKAGE, String) +# define Q_(String) g_strip_context ((String), gettext (String)) +# ifdef gettext_noop +# define N_(String) gettext_noop (String) +# else +# define N_(String) (String) +# endif +#else +# define textdomain(String) (String) +# define gettext(String) (String) +# define dgettext(Domain,Message) (Message) +# define dcgettext(Domain,Message,Type) (Message) +# define bindtextdomain(Domain,Directory) (Domain) +# define _(String) (String) +# define Q_(String) g_strip_context ((String), (String)) +# define N_(String) (String) +#endif + + +/* + * Public Functions. + */ + +/* + * This function returns a widget in a component created by Glade. + * Call it with the toplevel widget in the component (i.e. a window/dialog), + * or alternatively any widget in the component, and the name of the widget + * you want returned. + */ +GtkWidget* lookup_widget (GtkWidget *widget, + const gchar *widget_name); + + +/* Use this function to set the directory containing installed pixmaps. */ +void add_pixmap_directory (const gchar *directory); + + +/* + * Private Functions. + */ + +/* This is used to create the pixmaps used in the interface. */ +GtkWidget* create_pixmap (GtkWidget *widget, + const gchar *filename); + +/* This is used to create the pixbufs used in the interface. */ +GdkPixbuf* create_pixbuf (const gchar *filename); + +/* This is used to set ATK action descriptions. */ +void glade_set_atk_action_description (AtkAction *action, + const gchar *action_name, + const gchar *description); + -- cgit v1.2.3