From 3e2e62d3966f4620674e51a424c7c2e734e05235 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 6 Sep 2006 23:35:58 +0000 Subject: Updated to use a function-based memory interface. --- Makefile | 347 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- emma.c | 46 ++++++-- gemma.c | 17 ++- z80.c | 24 ++-- z80.h | 20 ++-- z80_decode.c | 117 ++++++++++++-------- z80_dis.c | 8 +- z80_private.h | 60 ++++------ 8 files changed, 511 insertions(+), 128 deletions(-) diff --git a/Makefile b/Makefile index 4ede2a0..6b0f880 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ # # ------------------------------------------------------------------------- # -# $Id: Makefile,v 1.14 2006-09-03 01:15:46 ianc Exp $ +# $Id: Makefile,v 1.15 2006-09-06 23:35:58 ianc Exp $ # # @@ -131,7 +131,9 @@ z80.o: /usr/include/machine/_types.h /usr/include/string.h z80.o: /usr/include/strings.h z80.h z80_private.h z80_decode.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h z80_decode.o: /usr/include/sys/_null.h /usr/include/sys/_types.h -z80_decode.o: /usr/include/machine/_types.h z80.h z80_private.h +z80_decode.o: /usr/include/machine/_types.h /usr/include/limits.h +z80_decode.o: /usr/include/sys/limits.h /usr/include/machine/_limits.h +z80_decode.o: /usr/include/sys/syslimits.h z80.h z80_private.h z80_dis.o: /usr/include/stdio.h /usr/include/sys/cdefs.h z80_dis.o: /usr/include/sys/_null.h /usr/include/sys/_types.h z80_dis.o: /usr/include/machine/_types.h /usr/include/string.h @@ -484,7 +486,7 @@ main.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvpaned.h main.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvruler.h main.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvscale.h main.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvseparator.h interface.h support.h -main.o: gtkutil.h +main.o: gtkutil.h gemma.h z80.h support.o: /usr/include/sys/types.h /usr/include/sys/cdefs.h support.o: /usr/include/machine/endian.h /usr/include/sys/_types.h support.o: /usr/include/machine/_types.h /usr/include/sys/_pthreadtypes.h @@ -1155,7 +1157,7 @@ callbacks.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvpaned.h callbacks.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvruler.h callbacks.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvscale.h callbacks.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvseparator.h callbacks.h -callbacks.o: interface.h support.h gtkutil.h +callbacks.o: interface.h support.h gtkutil.h gemma.h z80.h interface.o: /usr/include/sys/types.h /usr/include/sys/cdefs.h interface.o: /usr/include/machine/endian.h /usr/include/sys/_types.h interface.o: /usr/include/machine/_types.h /usr/include/sys/_pthreadtypes.h @@ -1830,3 +1832,340 @@ gtkutil.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvpaned.h gtkutil.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvruler.h gtkutil.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvscale.h gtkutil.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvseparator.h +gemma.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h +gemma.o: /usr/include/sys/_null.h /usr/include/sys/_types.h +gemma.o: /usr/include/machine/_types.h /usr/include/stdio.h +gemma.o: /usr/include/signal.h /usr/include/sys/signal.h +gemma.o: /usr/include/sys/_sigset.h /usr/include/machine/signal.h +gemma.o: /usr/include/machine/trap.h /usr/include/string.h +gemma.o: /usr/include/strings.h /usr/include/ctype.h /usr/include/_ctype.h +gemma.o: /usr/include/runetype.h gemma.h /usr/X11R6/include/gtk-2.0/gtk/gtk.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdk.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkcairo.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkcolor.h +gemma.o: /usr/local/include/cairo/cairo.h +gemma.o: /usr/local/include/cairo/cairo-features.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdktypes.h +gemma.o: /usr/local/include/glib-2.0/glib.h +gemma.o: /usr/local/include/glib-2.0/glib/galloca.h +gemma.o: /usr/local/include/glib-2.0/glib/gtypes.h +gemma.o: /usr/local/include/glib-2.0/glibconfig.h +gemma.o: /usr/local/include/glib-2.0/glib/gmacros.h /usr/include/stddef.h +gemma.o: /usr/include/limits.h /usr/include/sys/limits.h +gemma.o: /usr/include/machine/_limits.h /usr/include/sys/syslimits.h +gemma.o: /usr/include/float.h /usr/local/include/glib-2.0/glib/garray.h +gemma.o: /usr/local/include/glib-2.0/glib/gasyncqueue.h +gemma.o: /usr/local/include/glib-2.0/glib/gthread.h +gemma.o: /usr/local/include/glib-2.0/glib/gerror.h +gemma.o: /usr/local/include/glib-2.0/glib/gquark.h +gemma.o: /usr/local/include/glib-2.0/glib/gatomic.h +gemma.o: /usr/local/include/glib-2.0/glib/gbacktrace.h +gemma.o: /usr/local/include/glib-2.0/glib/gcache.h +gemma.o: /usr/local/include/glib-2.0/glib/glist.h +gemma.o: /usr/local/include/glib-2.0/glib/gmem.h +gemma.o: /usr/local/include/glib-2.0/glib/gslice.h +gemma.o: /usr/local/include/glib-2.0/glib/gcompletion.h +gemma.o: /usr/local/include/glib-2.0/glib/gconvert.h +gemma.o: /usr/local/include/glib-2.0/glib/gdataset.h +gemma.o: /usr/local/include/glib-2.0/glib/gdate.h /usr/include/time.h +gemma.o: /usr/include/sys/timespec.h /usr/local/include/glib-2.0/glib/gdir.h +gemma.o: /usr/local/include/glib-2.0/glib/gfileutils.h +gemma.o: /usr/local/include/glib-2.0/glib/ghash.h +gemma.o: /usr/local/include/glib-2.0/glib/ghook.h +gemma.o: /usr/local/include/glib-2.0/glib/giochannel.h +gemma.o: /usr/local/include/glib-2.0/glib/gmain.h +gemma.o: /usr/local/include/glib-2.0/glib/gslist.h +gemma.o: /usr/local/include/glib-2.0/glib/gstring.h +gemma.o: /usr/local/include/glib-2.0/glib/gunicode.h +gemma.o: /usr/local/include/glib-2.0/glib/gutils.h /usr/include/stdarg.h +gemma.o: /usr/local/include/glib-2.0/glib/gkeyfile.h +gemma.o: /usr/local/include/glib-2.0/glib/gmappedfile.h +gemma.o: /usr/local/include/glib-2.0/glib/gmarkup.h +gemma.o: /usr/local/include/glib-2.0/glib/gmessages.h +gemma.o: /usr/local/include/glib-2.0/glib/gnode.h +gemma.o: /usr/local/include/glib-2.0/glib/goption.h +gemma.o: /usr/local/include/glib-2.0/glib/gpattern.h +gemma.o: /usr/local/include/glib-2.0/glib/gprimes.h +gemma.o: /usr/local/include/glib-2.0/glib/gqsort.h +gemma.o: /usr/local/include/glib-2.0/glib/gqueue.h +gemma.o: /usr/local/include/glib-2.0/glib/grand.h +gemma.o: /usr/local/include/glib-2.0/glib/grel.h +gemma.o: /usr/local/include/glib-2.0/glib/gscanner.h +gemma.o: /usr/local/include/glib-2.0/glib/gshell.h +gemma.o: /usr/local/include/glib-2.0/glib/gspawn.h +gemma.o: /usr/local/include/glib-2.0/glib/gstrfuncs.h +gemma.o: /usr/local/include/glib-2.0/glib/gthreadpool.h +gemma.o: /usr/local/include/glib-2.0/glib/gtimer.h +gemma.o: /usr/local/include/glib-2.0/glib/gtree.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-attributes.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-font.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-coverage.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-types.h +gemma.o: /usr/local/include/glib-2.0/glib-object.h +gemma.o: /usr/local/include/glib-2.0/gobject/gboxed.h +gemma.o: /usr/local/include/glib-2.0/gobject/gtype.h +gemma.o: /usr/local/include/glib-2.0/gobject/genums.h +gemma.o: /usr/local/include/glib-2.0/gobject/gobject.h +gemma.o: /usr/local/include/glib-2.0/gobject/gvalue.h +gemma.o: /usr/local/include/glib-2.0/gobject/gparam.h +gemma.o: /usr/local/include/glib-2.0/gobject/gclosure.h +gemma.o: /usr/local/include/glib-2.0/gobject/gsignal.h +gemma.o: /usr/local/include/glib-2.0/gobject/gmarshal.h +gemma.o: /usr/local/include/glib-2.0/gobject/gparamspecs.h +gemma.o: /usr/local/include/glib-2.0/gobject/gsourceclosure.h +gemma.o: /usr/local/include/glib-2.0/gobject/gtypemodule.h +gemma.o: /usr/local/include/glib-2.0/gobject/gtypeplugin.h +gemma.o: /usr/local/include/glib-2.0/gobject/gvaluearray.h +gemma.o: /usr/local/include/glib-2.0/gobject/gvaluetypes.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-break.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-item.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-context.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-fontmap.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-fontset.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-engine.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-glyph.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-script.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-enum-types.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-layout.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-glyph-item.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-tabs.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pango-renderer.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdkconfig.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkpixbuf.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkrgb.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk-pixbuf/gdk-pixbuf.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk-pixbuf/gdk-pixbuf-features.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk-pixbuf/gdk-pixbuf-core.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk-pixbuf/gdk-pixbuf-transform.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk-pixbuf/gdk-pixbuf-animation.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk-pixbuf/gdk-pixbuf-simple-anim.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk-pixbuf/gdk-pixbuf-io.h +gemma.o: /usr/local/include/glib-2.0/gmodule.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk-pixbuf/gdk-pixbuf-loader.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk-pixbuf/gdk-pixbuf-enum-types.h +gemma.o: /usr/X11R6/include/pango-1.0/pango/pangocairo.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkcursor.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkdisplay.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkevents.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkdnd.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkinput.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkdrawable.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkgc.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkenumtypes.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkfont.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkimage.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkkeys.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkdisplaymanager.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkpango.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkpixmap.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkproperty.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkregion.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkscreen.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkselection.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkspawn.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkvisual.h +gemma.o: /usr/X11R6/include/gtk-2.0/gdk/gdkwindow.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkaboutdialog.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkdialog.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkwindow.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkaccelgroup.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkenums.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkbin.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcontainer.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkwidget.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkobject.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktypeutils.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktypebuiltins.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkdebug.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkadjustment.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkstyle.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtksettings.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkrc.h +gemma.o: /usr/local/include/atk-1.0/atk/atkobject.h +gemma.o: /usr/local/include/atk-1.0/atk/atkstate.h +gemma.o: /usr/local/include/atk-1.0/atk/atkrelationtype.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkaccellabel.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtklabel.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmisc.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmenu.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmenushell.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkaccelmap.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkaccessible.h +gemma.o: /usr/local/include/atk-1.0/atk/atk.h +gemma.o: /usr/local/include/atk-1.0/atk/atkaction.h +gemma.o: /usr/local/include/atk-1.0/atk/atkcomponent.h +gemma.o: /usr/local/include/atk-1.0/atk/atkutil.h +gemma.o: /usr/local/include/atk-1.0/atk/atkdocument.h +gemma.o: /usr/local/include/atk-1.0/atk/atkeditabletext.h +gemma.o: /usr/local/include/atk-1.0/atk/atktext.h +gemma.o: /usr/local/include/atk-1.0/atk/atkgobjectaccessible.h +gemma.o: /usr/local/include/atk-1.0/atk/atkhyperlink.h +gemma.o: /usr/local/include/atk-1.0/atk/atkhypertext.h +gemma.o: /usr/local/include/atk-1.0/atk/atkimage.h +gemma.o: /usr/local/include/atk-1.0/atk/atknoopobject.h +gemma.o: /usr/local/include/atk-1.0/atk/atknoopobjectfactory.h +gemma.o: /usr/local/include/atk-1.0/atk/atkobjectfactory.h +gemma.o: /usr/local/include/atk-1.0/atk/atkregistry.h +gemma.o: /usr/local/include/atk-1.0/atk/atkobjectfactory.h +gemma.o: /usr/local/include/atk-1.0/atk/atkrelation.h +gemma.o: /usr/local/include/atk-1.0/atk/atkrelationset.h +gemma.o: /usr/local/include/atk-1.0/atk/atkselection.h +gemma.o: /usr/local/include/atk-1.0/atk/atkstateset.h +gemma.o: /usr/local/include/atk-1.0/atk/atkstreamablecontent.h +gemma.o: /usr/local/include/atk-1.0/atk/atktable.h +gemma.o: /usr/local/include/atk-1.0/atk/atkvalue.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkaction.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkactiongroup.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkitemfactory.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkalignment.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkarrow.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkaspectframe.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkframe.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkbbox.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkbox.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkbindings.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkimage.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcalendar.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtksignal.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmarshal.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcelllayout.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcellrenderer.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcelleditable.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktreeviewcolumn.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktreemodel.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktreesortable.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcellrenderercombo.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcellrenderertext.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcellrendererpixbuf.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcellrendererprogress.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcellrenderertoggle.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcellview.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcheckbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktogglebutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcheckmenuitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmenuitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkclipboard.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkselection.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkclist.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkhscrollbar.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkscrollbar.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkrange.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvscrollbar.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcolorbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcolorsel.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvbox.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcolorseldialog.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcombo.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkhbox.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcombobox.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktreeview.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkdnd.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcomboboxentry.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkctree.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkcurve.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkdrawingarea.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkeditable.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkentry.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkimcontext.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkentrycompletion.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkliststore.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktreemodelfilter.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkeventbox.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkexpander.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkfilesel.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkfixed.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkfilechooserbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkfilechooser.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkfilefilter.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkfilechooserdialog.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkfilechooser.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkfilechooserwidget.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkfontbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkfontsel.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkgamma.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkgc.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkhandlebox.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkhbbox.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkhpaned.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkpaned.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkhruler.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkruler.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkhscale.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkscale.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkhseparator.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkseparator.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkiconfactory.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkicontheme.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkiconview.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkimagemenuitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkimcontextsimple.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkimmulticontext.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkinputdialog.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkinvisible.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtklayout.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtklist.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtklistitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmain.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmenubar.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmenutoolbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmenu.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktoolbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktoolitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktooltips.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmessagedialog.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkmodules.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtknotebook.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkoldeditable.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkoptionmenu.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkpixmap.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkplug.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtksocket.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkpreview.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkprogress.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkprogressbar.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkradioaction.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktoggleaction.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkradiobutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkradiomenuitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkradiotoolbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktoggletoolbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktoolbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkscrolledwindow.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkviewport.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkseparatormenuitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkseparatortoolitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtksizegroup.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkspinbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkstatusbar.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkstock.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktable.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktearoffmenuitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktext.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktextbuffer.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktexttagtable.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktexttag.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktextiter.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktextchild.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktextmark.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktextview.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktipsquery.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktoggletoolbutton.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktoolbar.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktoolitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktree.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktreednd.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktreeitem.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktreemodelsort.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktreeselection.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtktreestore.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkuimanager.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvbbox.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkversion.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvpaned.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvruler.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvscale.h +gemma.o: /usr/X11R6/include/gtk-2.0/gtk/gtkvseparator.h z80.h expr.h +gemma.o: gtkutil.h support.h diff --git a/emma.c b/emma.c index 8737d87..b38a3ee 100644 --- a/emma.c +++ b/emma.c @@ -50,7 +50,6 @@ static const char id[]="$Id$"; */ static Z80 *z80; static Z80Byte mem[0x10000]; -static int memctl[256]; static sig_atomic_t stop=FALSE; static int quit=FALSE; @@ -86,6 +85,39 @@ static void SigInt(int sig) } +/* ---------------------------------------- MEMORY +*/ +static Z80Byte Peek(Z80 *cpu, Z80Word addr) +{ + if (mem_trace) + { + Log("Read %2.2x from %4.4x\n",mem[addr],addr); + } + + return mem[addr]; +} + + +static Z80Byte DisPeek(Z80 *cpu, Z80Word addr) +{ + return mem[addr]; +} + + +static void Poke(Z80 *cpu, Z80Word addr, Z80Byte b) +{ + if (addr>=bottom && addr<=top) + { + if (mem_trace) + { + Log("Wrote %2.2x to %4.4x\n",b,addr); + } + + mem[addr]=b; + } +} + + /* ---------------------------------------- COMMANDS AND ASSOC UTILS */ static void Log(const char *format, ...) @@ -783,8 +815,6 @@ static void DoSilent(int no, const char *arg[]) static void DoRange(int no, const char *arg[]) { - int f; - if (no<3) { Log("Missing arguments\n"); @@ -794,11 +824,6 @@ static void DoRange(int no, const char *arg[]) bottom=(Address(arg[1]))/256; top=Address(arg[2])/256; - for(f=0;f<256;f++) - { - memctl[f]=(f>=bottom && f<=top); - } - Log("Writable memory between 0x%4.4x and 0x%4.4x\n",bottom*256,top*256); } @@ -1083,11 +1108,8 @@ static int IntCheck(Z80 *z80, Z80Val v) int main(int argc, char *argv[]) { const char *autoarg[2]={".","auto"}; - int f; - - for(f=0;f<256;f++) memctl[f]=1; - z80=Z80Init(mem,memctl,WritePort,ReadPort); + z80=Z80Init(Peek,Poke,ReadPort,WritePort,DisPeek); if (!z80) { diff --git a/gemma.c b/gemma.c index fbf72fc..1074860 100644 --- a/gemma.c +++ b/gemma.c @@ -42,7 +42,6 @@ static const char id[]="$Id$"; */ static Z80 *z80; static Z80Byte mem[0x10000]; -static int memctl[256]; static sig_atomic_t stop=FALSE; @@ -413,6 +412,16 @@ static void DisplayState(DString s, const char *label, /* ---------------------------------------- MEMORY */ +static Z80Byte Peek(Z80 *z80, Z80Word addr) +{ + return mem[addr]; +} + +static void Poke(Z80 *z80, Z80Word addr, Z80Byte b) +{ + mem[addr]=b; +} + static Z80Byte ReadPort(Z80 *z80, Z80Word addr) { Z80Byte b=0xff; @@ -970,11 +979,7 @@ void GEMMA_Stop(void) void GEMMA_Init(GtkWidget *top) { - int f; - - for(f=0;f<256;f++) memctl[f]=1; - - z80=Z80Init(mem,memctl,WritePort,ReadPort); + z80=Z80Init(Peek,Poke,ReadPort,WritePort,Peek); Z80SetPC(z80,0x100); if (!z80) diff --git a/z80.c b/z80.c index 64ec504..60dbca4 100644 --- a/z80.c +++ b/z80.c @@ -112,10 +112,11 @@ static void Z80_CheckInterrupt(Z80 *cpu) /* ---------------------------------------- INTERFACES */ -Z80 *Z80Init(Z80Memory memory, - Z80MemoryControl memcontrol, +Z80 *Z80Init(Z80ReadMemory read_memory, + Z80WriteMemory write_memory, + Z80ReadPort read_port, Z80WritePort write_port, - Z80ReadPort read_port) + Z80ReadMemory read_disassem) { Z80 *cpu; int f; @@ -123,17 +124,18 @@ Z80 *Z80Init(Z80Memory memory, InitTables(); - if (!memory || !memcontrol) + if (!read_memory || !write_memory) return NULL; cpu=malloc(sizeof *cpu); if (cpu) { - cpu->memory=memory; - cpu->memctrl=memcontrol; + cpu->mread=read_memory; + cpu->mwrite=write_memory; cpu->pread=read_port; cpu->pwrite=write_port; + cpu->disread=read_disassem; for(f=0;fcallback[reason][f]) { cpu->callback[reason][f]=callback; return TRUE; } + } return FALSE; } @@ -236,6 +240,8 @@ void Z80NMI(Z80 *cpu) int Z80SingleStep(Z80 *cpu) { + Z80Byte opcode; + cpu->last_cb=TRUE; cpu->shift=0; @@ -245,7 +251,9 @@ int Z80SingleStep(Z80 *cpu) INC_R; - Z80_Decode(cpu,cpu->memory[cpu->PC++]); + opcode=FETCH_BYTE; + + Z80_Decode(cpu,opcode); return cpu->last_cb; } @@ -342,7 +350,7 @@ const char *Z80Disassemble(Z80 *cpu, Z80Word *pc) strcat(s,Z80_Dis_Printf("%-40s ;",Z80_Dis_GetArg())); for(f=0;f<5 && opc!=npc;f++) - strcat(s,Z80_Dis_Printf(" %.2x",(int)cpu->memory[opc++])); + strcat(s,Z80_Dis_Printf(" %.2x",(int)cpu->disread(cpu,opc++))); if (opc!=npc) for(f=1;f<3;f++) diff --git a/z80.h b/z80.h index b6dd902..0b7424b 100644 --- a/z80.h +++ b/z80.h @@ -56,14 +56,10 @@ typedef signed char Z80Relative; typedef unsigned short Z80Word; -/* Memory +/* Interfaces used to handle memory */ -typedef Z80Byte Z80Memory[0x10000]; - - -/* Memory control - a TRUE indicates that the 256-byte page is writeable. -*/ -typedef int Z80MemoryControl[256]; +typedef Z80Byte (*Z80ReadMemory)(Z80 *cpu, Z80Word address); +typedef void (*Z80WriteMemory)(Z80 *cpu, Z80Word address, Z80Byte value); /* Interfaces needed to handle ports (IN/OUT commands) @@ -161,10 +157,11 @@ typedef struct /* Initialises the processor. */ -Z80 *Z80Init(Z80Memory memory, - Z80MemoryControl memcontrol, +Z80 *Z80Init(Z80ReadMemory read_memory, + Z80WriteMemory write_memory, + Z80ReadPort read_port, Z80WritePort write_port, - Z80ReadPort read_port); + Z80ReadMemory read_for_disassem); /* Resets the processor. @@ -238,7 +235,8 @@ void Z80SetState(Z80 *cpu, const Z80State *state); void Z80SetLabels(Z80Label labels[]); -/* Simple disassembly. addr is updated on exit. +/* Simple disassembly of memory accessed through read_for_disassem. + addr is updated on exit. */ const char *Z80Disassemble(Z80 *cpu, Z80Word *addr); diff --git a/z80_decode.c b/z80_decode.c index c94f092..e78206c 100644 --- a/z80_decode.c +++ b/z80_decode.c @@ -124,6 +124,13 @@ static Z80Word FPEEKW(Z80 *cpu, Z80Word addr) } +static void FPOKEW(Z80 *cpu, Z80Word addr, Z80Word val) +{ + cpu->mwrite(cpu,addr,val); + cpu->mwrite(cpu,addr+1,val>>8); +} + + /* ---------------------------------------- GENERAL MACROS */ #define SWAP(A,B) \ @@ -265,6 +272,40 @@ do { \ } while(0) +#define OP_ON_MEM(OP,addr) \ +do { \ + Z80Byte memop=cpu->mread(cpu,addr); \ + OP(memop); \ + cpu->mwrite(cpu,addr,memop); \ +} while(0) + + +#define OP_ON_MEM_WITH_ARG(OP,addr,arg) \ +do { \ + Z80Byte memop=cpu->mread(cpu,addr); \ + OP(memop,arg); \ + cpu->mwrite(cpu,addr,memop); \ +} while(0) + + +#define OP_ON_MEM_WITH_COPY(OP,addr,copy) \ +do { \ + Z80Byte memop=cpu->mread(cpu,addr); \ + OP(memop); \ + copy=memop; \ + cpu->mwrite(cpu,addr,memop); \ +} while(0) + + +#define OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,arg,copy) \ +do { \ + Z80Byte memop=cpu->mread(cpu,addr); \ + OP(memop,arg); \ + copy=memop; \ + cpu->mwrite(cpu,addr,memop); \ +} while(0) + + /* ---------------------------------------- ROTATE AND SHIFT OPS */ #define RRCA \ @@ -707,7 +748,7 @@ do { \ case BASE+6: /* LD DEST,(HL) */ \ TSTATE(7); \ OFFSET(off); \ - DEST2=cpu->memory[*HL+off]; \ + DEST2=cpu->mread(cpu,*HL+off); \ break; \ \ case BASE+7: /* LD DEST,A */ \ @@ -749,7 +790,7 @@ do { \ case BASE+6: /* OP A,(HL) */ \ TSTATE(7); \ OFFSET(off); \ - OP(cpu->memory[*HL+off]); \ + OP_ON_MEM(OP,*HL+off); \ break; \ \ case BASE+7: /* OP A,A */ \ @@ -794,7 +835,7 @@ do { \ \ case BASE+6: /* OP (HL) */ \ TSTATE(15); \ - OP(cpu->memory[cpu->HL.w]); \ + OP_ON_MEM(OP,cpu->HL.w); \ break; \ \ case BASE+7: /* OP A */ \ @@ -835,7 +876,7 @@ do { \ \ case BASE+6: /* OP (HL) */ \ TSTATE(12); \ - OP(cpu->memory[cpu->HL.w],BIT_NO); \ + OP_ON_MEM_WITH_ARG(OP,cpu->HL.w,BIT_NO); \ break; \ \ case BASE+7: /* OP A */ \ @@ -849,97 +890,83 @@ do { \ #define SHIFTED_CB_ALU_BLOCK(BASE,OP) \ case BASE: /* OP B */ \ TSTATE(8); \ - OP(cpu->memory[addr]); \ - cpu->BC.b[HI]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_COPY(OP,addr,cpu->BC.b[HI]); \ break; \ \ case BASE+1: /* OP C */ \ TSTATE(8); \ - OP(cpu->memory[addr]); \ - cpu->BC.b[LO]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_COPY(OP,addr,cpu->BC.b[LO]); \ break; \ \ case BASE+2: /* OP D */ \ TSTATE(8); \ - OP(cpu->memory[addr]); \ - cpu->DE.b[HI]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_COPY(OP,addr,cpu->DE.b[HI]); \ break; \ \ case BASE+3: /* OP E */ \ TSTATE(8); \ - OP(cpu->memory[addr]); \ - cpu->DE.b[LO]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_COPY(OP,addr,cpu->DE.b[LO]); \ break; \ \ case BASE+4: /* OP H */ \ TSTATE(8); \ - OP(cpu->memory[addr]); \ - cpu->HL.b[HI]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_COPY(OP,addr,cpu->HL.b[HI]); \ break; \ \ case BASE+5: /* OP L */ \ TSTATE(8); \ - OP(cpu->memory[addr]); \ - cpu->HL.b[LO]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_COPY(OP,addr,cpu->HL.b[LO]); \ break; \ \ case BASE+6: /* OP (HL) */ \ TSTATE(15); \ - OP(cpu->memory[addr]); \ + OP_ON_MEM(OP,addr); \ break; \ \ case BASE+7: /* OP A */ \ TSTATE(8); \ - OP(cpu->memory[addr]); \ - cpu->AF.b[HI]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_COPY(OP,addr,cpu->AF.b[HI]); \ break; #define SHIFTED_CB_BITMANIP_BLOCK(BASE,OP,BIT_NO) \ case BASE: /* OP B */ \ TSTATE(8); \ - OP(cpu->memory[addr],BIT_NO); \ - cpu->BC.b[HI]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->BC.b[HI]); \ break; \ \ case BASE+1: /* OP C */ \ TSTATE(8); \ - OP(cpu->memory[addr],BIT_NO); \ - cpu->BC.b[LO]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->BC.b[LO]); \ break; \ \ case BASE+2: /* OP D */ \ TSTATE(8); \ - OP(cpu->memory[addr],BIT_NO); \ - cpu->DE.b[HI]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->DE.b[HI]); \ break; \ \ case BASE+3: /* OP E */ \ TSTATE(8); \ - OP(cpu->memory[addr],BIT_NO); \ - cpu->DE.b[LO]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->DE.b[LO]); \ break; \ \ case BASE+4: /* OP H */ \ TSTATE(8); \ - OP(cpu->memory[addr],BIT_NO); \ - cpu->HL.b[HI]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->HL.b[HI]); \ break; \ \ case BASE+5: /* OP L */ \ TSTATE(8); \ - OP(cpu->memory[addr],BIT_NO); \ - cpu->HL.b[LO]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->HL.b[LO]); \ break; \ \ case BASE+6: /* OP (HL) */ \ TSTATE(12); \ - OP(cpu->memory[addr],BIT_NO); \ + OP_ON_MEM_WITH_ARG(OP,addr,BIT_NO); \ break; \ \ case BASE+7: /* OP A */ \ TSTATE(8); \ - OP(cpu->memory[addr],BIT_NO); \ - cpu->AF.b[HI]=cpu->memory[addr]; \ + OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->AF.b[HI]); \ break; /* ---------------------------------------- DAA @@ -2024,19 +2051,19 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode) case 0x34: /* INC (HL) */ TSTATE(11); OFFSET(off); - INC8(cpu->memory[*HL+off]); + OP_ON_MEM(INC8,*HL+off); break; case 0x35: /* DEC (HL) */ TSTATE(11); OFFSET(off); - DEC8(cpu->memory[*HL+off]); + OP_ON_MEM(DEC8,*HL+off); break; case 0x36: /* LD (HL),n */ TSTATE(10); OFFSET(off); - cpu->memory[*HL+off]=FETCH_BYTE; + cpu->mwrite(cpu,*HL+off,FETCH_BYTE); break; case 0x37: /* SCF */ @@ -2057,7 +2084,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode) case 0x3a: /* LD A,(nnnn) */ TSTATE(13); - cpu->AF.b[HI]=cpu->memory[FETCH_WORD]; + cpu->AF.b[HI]=cpu->mread(cpu,FETCH_WORD); break; case 0x3b: /* DEC SP */ @@ -2102,37 +2129,37 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode) case 0x70: /* LD (HL),B */ TSTATE(7); OFFSET(off); - cpu->memory[*HL+off]=cpu->BC.b[HI]; + cpu->mwrite(cpu,*HL+off,cpu->BC.b[HI]); break; case 0x71: /* LD (HL),C */ TSTATE(7); OFFSET(off); - cpu->memory[*HL+off]=cpu->BC.b[LO]; + cpu->mwrite(cpu,*HL+off,cpu->BC.b[LO]); break; case 0x72: /* LD (HL),D */ TSTATE(7); OFFSET(off); - cpu->memory[*HL+off]=cpu->DE.b[HI]; + cpu->mwrite(cpu,*HL+off,cpu->DE.b[HI]); break; case 0x73: /* LD (HL),E */ TSTATE(7); OFFSET(off); - cpu->memory[*HL+off]=cpu->DE.b[LO]; + cpu->mwrite(cpu,*HL+off,cpu->DE.b[LO]); break; case 0x74: /* LD (HL),H */ TSTATE(7); OFFSET(off); - cpu->memory[*HL+off]=cpu->HL.b[HI]; + cpu->mwrite(cpu,*HL+off,cpu->HL.b[HI]); break; case 0x75: /* LD (HL),L */ TSTATE(7); OFFSET(off); - cpu->memory[*HL+off]=cpu->HL.b[LO]; + cpu->mwrite(cpu,*HL+off,cpu->HL.b[LO]); break; case 0x76: /* HALT */ @@ -2148,7 +2175,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode) case 0x77: /* LD (HL),A */ TSTATE(7); OFFSET(off); - cpu->memory[*HL+off]=cpu->AF.b[HI]; + cpu->mwrite(cpu,*HL+off,cpu->AF.b[HI]); break; LD_BLOCK(0x78,cpu->AF.b[HI],cpu->AF.b[HI]) diff --git a/z80_dis.c b/z80_dis.c index 2fcdf4b..9d42829 100644 --- a/z80_dis.c +++ b/z80_dis.c @@ -62,7 +62,7 @@ const char *Z80_Dis_Printf(const char *format, ...) Z80Byte Z80_Dis_FetchByte(Z80 *cpu, Z80Word *pc) { - return cpu->memory[(*pc)++]; + return cpu->disread(cpu,(*pc)++); } @@ -1454,7 +1454,7 @@ static void DIS_DJNZ (Z80 *z80, Z80Byte op, Z80Word *pc) { Z80Word new; - new=*pc+(Z80Relative)z80->memory[*pc]+1; + new=*pc+(Z80Relative)z80->disread(z80,*pc)+1; (*pc)++; Z80_Dis_Set("djnz",Z80_Dis_Printf("$%.4x",new)); } @@ -1469,7 +1469,7 @@ static void DIS_JR (Z80 *z80, Z80Byte op, Z80Word *pc) Z80Word new; const char *p; - new=*pc+(Z80Relative)z80->memory[*pc]+1; + new=*pc+(Z80Relative)z80->disread(z80,*pc)+1; (*pc)++; if ((p=GetLabel(new))) @@ -1490,7 +1490,7 @@ static void DIS_JR_CO (Z80 *z80, Z80Byte op, Z80Word *pc) const char *p; con=z80_dis_condition[(op-0x20)/8]; - new=*pc+(Z80Relative)z80->memory[*pc]+1; + new=*pc+(Z80Relative)z80->disread(z80,*pc)+1; (*pc)++; if ((p=GetLabel(new))) diff --git a/z80_private.h b/z80_private.h index 7a23d36..6675c12 100644 --- a/z80_private.h +++ b/z80_private.h @@ -85,8 +85,10 @@ struct Z80 Z80Byte devbyte; int nmi; - Z80Byte *memory; - int *memctrl; + Z80ReadMemory disread; + + Z80ReadMemory mread; + Z80WriteMemory mwrite; Z80ReadPort pread; Z80WritePort pwrite; @@ -105,13 +107,6 @@ struct Z80 */ -/* HI/LO -*/ -#define SET_HI(reg,v) reg = (reg & 0x00ff) | ((v) << 8) -#define SET_LO(reg,v) reg = (reg & 0xff00) | ((v) & 0xff) -#define GET_HI(reg,v) ((reg & 0xff00) >> 8) -#define GET_LO(reg,v) (reg & 0xff) - /* Invoke a callback class */ #define CALLBACK(r,d) do \ @@ -143,30 +138,14 @@ struct Z80 #define SETFLAG(f) SET(cpu->AF.b[LO],f) #define CLRFLAG(f) CLR(cpu->AF.b[LO],f) -#define PEEK(addr) (cpu->memory[addr]) +#define PEEK(addr) (cpu->mread(cpu,addr)) #define PEEKW(addr) FPEEKW(cpu,addr) -#define POKE(addr,val) do \ - { \ - Z80Word ba=addr; \ - Z80Word bv=val; \ - if (cpu->memctrl[(ba)/256]) \ - { \ - cpu->memory[ba]=bv; \ - } \ - } while (0) -#define POKEW(addr,val) do \ - { \ - Z80Word wa=addr; \ - Z80Word wv=val; \ - POKE(wa,wv); \ - POKE(wa+1,wv>>8); \ - } while(0) +#define POKE(addr,val) cpu->mwrite(cpu,addr,val) +#define POKEW(addr,val) FPOKEW(cpu,addr,val) -#define FETCH_BYTE (cpu->memory[cpu->PC++]) -#define FETCH_WORD (cpu->PC+=2, \ - cpu->memory[cpu->PC-2]| \ - ((Z80Word)cpu->memory[cpu->PC-1]<<8)) +#define FETCH_BYTE (cpu->mread(cpu,cpu->PC++)) +#define FETCH_WORD (cpu->PC+=2,FPEEKW(cpu,cpu->PC-2)) #define IS_C (cpu->AF.b[LO]&C_Z80) #define IS_N (cpu->AF.b[LO]&N_Z80) @@ -185,15 +164,19 @@ struct Z80 #define ADD_R(v) cpu->R=((cpu->R&0x80)|((cpu->R+(v))&0x7f)) #define INC_R ADD_R(1) -#define PUSH(REG) do \ - { \ - cpu->SP-=2; \ - POKEW(cpu->SP,REG); \ +#define PUSH(REG) do \ + { \ + Z80Word pushv=REG; \ + cpu->SP-=2; \ + cpu->mwrite(cpu,cpu->SP,pushv); \ + cpu->mwrite(cpu,cpu->SP+1,pushv>>8);\ } while(0) -#define POP(REG) do \ - { \ - REG=PEEKW(cpu->SP); \ - cpu->SP+=2; \ + +#define POP(REG) do \ + { \ + REG=PEEK(cpu->SP) | \ + (Z80Word)PEEK(cpu->SP+1)<<8; \ + cpu->SP+=2; \ } while(0) #define SETHIDDEN(res) cpu->AF.b[LO]=(cpu->AF.b[LO]&~(B3_Z80|B5_Z80))|\ @@ -204,6 +187,7 @@ struct Z80 PUSH(cpu->PC+2); \ cpu->PC=PEEKW(cpu->PC); \ } while(0) + #define NOCALL cpu->PC+=2 #define JP cpu->PC=PEEKW(cpu->PC) #define NOJP cpu->PC+=2 -- cgit v1.2.3