From 1a8ffd75606e69c6f766188f2ab424cc53782a52 Mon Sep 17 00:00:00 2001 From: Ian C Date: Thu, 15 Jan 2004 18:53:52 +0000 Subject: Changes from work --- src/Makefile | 13 +++--- src/memmenu.c | 142 +++++++++++++++++++++++++++++++++++++++++++++------------- src/spec.c | 13 ++++++ src/spec.h | 4 ++ src/util.c | 17 +++++++ src/util.h | 7 +++ 6 files changed, 158 insertions(+), 38 deletions(-) diff --git a/src/Makefile b/src/Makefile index 5d98ed7..ffb9c8f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,7 +18,7 @@ # # ------------------------------------------------------------------------- # -# $Id: Makefile,v 1.6 2004-01-14 01:50:20 ianc Exp $ +# $Id: Makefile,v 1.7 2004-01-15 18:53:51 ianc Exp $ # @@ -56,7 +56,6 @@ CFLAGS += -Iz80 `sdl-config --cflags` LIBS = $(Z80LIB) `sdl-config --libs` - $(TARGET): $(OBJECTS) $(Z80LIB) $(CC) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) @@ -117,7 +116,7 @@ spec.o: /usr/local/include/SDL/SDL_keysym.h spec.o: /usr/local/include/SDL/SDL_mouse.h /usr/local/include/SDL/SDL_video.h spec.o: /usr/local/include/SDL/SDL_mutex.h /usr/local/include/SDL/SDL_quit.h spec.o: /usr/local/include/SDL/SDL_version.h snap.h gfx.h gui.h config.h -spec.o: exit.h +spec.o: exit.h util.h snap.o: snap.h /usr/include/stdlib.h /usr/include/sys/cdefs.h snap.o: /usr/include/sys/_types.h /usr/include/machine/_types.h snap.o: /usr/include/stdio.h z80/z80.h @@ -163,7 +162,7 @@ gui.o: /usr/local/include/SDL/SDL_keyboard.h gui.o: /usr/local/include/SDL/SDL_keysym.h /usr/local/include/SDL/SDL_mouse.h gui.o: /usr/local/include/SDL/SDL_video.h /usr/local/include/SDL/SDL_mutex.h gui.o: /usr/local/include/SDL/SDL_quit.h /usr/local/include/SDL/SDL_version.h -gui.o: exit.h +gui.o: exit.h util.h memmenu.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h memmenu.o: /usr/include/sys/_types.h /usr/include/machine/_types.h memmenu.o: /usr/include/stdio.h /usr/include/string.h /usr/include/strings.h @@ -189,11 +188,11 @@ memmenu.o: /usr/local/include/SDL/SDL_mouse.h memmenu.o: /usr/local/include/SDL/SDL_video.h memmenu.o: /usr/local/include/SDL/SDL_mutex.h memmenu.o: /usr/local/include/SDL/SDL_quit.h -memmenu.o: /usr/local/include/SDL/SDL_version.h gfx.h gui.h +memmenu.o: /usr/local/include/SDL/SDL_version.h gfx.h gui.h util.h util.o: /usr/include/stdio.h /usr/include/sys/cdefs.h util.o: /usr/include/sys/_types.h /usr/include/machine/_types.h -util.o: /usr/include/string.h /usr/include/strings.h util.h -util.o: /usr/include/stdlib.h exit.h +util.o: /usr/include/string.h /usr/include/strings.h /usr/include/stdarg.h +util.o: util.h /usr/include/stdlib.h exit.h exit.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h exit.o: /usr/include/sys/_types.h /usr/include/machine/_types.h exit.o: /usr/include/stdarg.h exit.h /usr/local/include/SDL/SDL.h diff --git a/src/memmenu.c b/src/memmenu.c index dfce66d..41a18b3 100644 --- a/src/memmenu.c +++ b/src/memmenu.c @@ -41,20 +41,21 @@ static const char ident[]="$Id$"; static const char ident_h[]=ESPEC_MEMMENU_H; #ifndef TRUE -#define TRUE 1 +#define TRUE 1 #endif #ifndef FALSE -#define FALSE 0 +#define FALSE 0 #endif -#define WHITE GFXRGB(255,255,255) -#define BLACK GFXRGB(0,0,0) -#define RED GFXRGB(255,100,100) -#define GREEN GFXRGB(100,255,100) -#define BLUE GFXRGB(100,100,255) +#define WHITE GFXRGB(255,255,255) +#define BLACK GFXRGB(0,0,0) +#define RED GFXRGB(255,100,100) +#define GREEN GFXRGB(100,255,100) +#define BLUE GFXRGB(100,100,255) -#define TRACE "trace" +#define TRACE "trace" +#define TRACEMEM_WIN 10 /* ---------------------------------------- TYPES @@ -66,10 +67,26 @@ typedef struct } Breakpoint; +typedef struct +{ + Z80Word addr; + Z80Word val; +} MemTrace; + + +typedef struct +{ + Z80State s; + MemTrace hl[TRACEMEM_WIN]; + MemTrace de[TRACEMEM_WIN]; + MemTrace sp[TRACEMEM_WIN]; +} Trace; + + /* ---------------------------------------- STATIC DATA */ static FILE *trace=NULL; -static Breakpoint bpoint={NULL,0}; +static Breakpoint bpoint={0,NULL}; static const char *brk=NULL; static int lodged=FALSE; @@ -111,15 +128,16 @@ static void DisplayMenu(void) { static const char *menu[]= { - "1. Disassemble/Hex dump ", - "2. Disassemble to file ", - "3. Start/Stop trace log ", - "4. Playback trace log ", - "5. Add a new breakpoint ", - "6. Clear a breakpoint ", - "7. Display breakpoints ", - "8. Clear all breakpoints", - "9. Return ", + "1 - Disassemble/Hex dump ", + "2 - Disassemble to file ", + "3 - Start/Stop trace log ", + "4 - Playback trace log ", + "5 - Add a new breakpoint ", + "6 -Clear a breakpoint ", + "7 - Display breakpoints ", + "8 - Clear all breakpoints", + "R - Reset ", + "ESC - Return ", NULL }; @@ -170,6 +188,10 @@ void DisplayZ80State(Z80State *s, int y, Uint32 col) "IX=%4.4x IY=%4.4x SP=%4.4x", s->IX,s->IY,s->SP); y+=8; + GFXPrintPaper(0,y,col,BLACK, + "AF'=%4.4x BC'=%4.4x DE'=%4.4x HL'=%4.4x", + s->AF_,s->BC_,s->DE_,s->HL_); + y+=8; GFXPrintPaper(0,y,col,BLACK, "I=%2.2x IM=%2.2x R=%2.2x", s->I,s->IM,s->R); @@ -396,17 +418,43 @@ static void DoDisassemFile(Z80 *z80, const Z80State *s) } +static void GetMemTrace(Z80 *z80, MemTrace *t, Z80Word from, int count) +{ + int f; + + f=0; + + while(f=ROMLEN) mem[addr]=val&0xff; @@ -822,6 +830,11 @@ const char *SPECInfo(Z80 *z80) } +void SPECReset(Z80 *z80) +{ +} + + void SPECMount(SPECMountType type, const char *path) { switch(type) diff --git a/src/spec.h b/src/spec.h index 0dae7e7..69a19d1 100644 --- a/src/spec.h +++ b/src/spec.h @@ -57,6 +57,10 @@ const Z80Label *SPECGetLabel(void); */ const char *SPECInfo(Z80 *z80); +/* Called when the machine is reset +*/ +void SPECReset(Z80 *z80); + /* Interfaces for snapshot and device control */ diff --git a/src/util.c b/src/util.c index a8a037d..49b4e2d 100644 --- a/src/util.c +++ b/src/util.c @@ -27,6 +27,7 @@ static const char ident[]="$Id$"; #include #include +#include #include "util.h" #include "exit.h" @@ -108,4 +109,20 @@ const char *Dirname(const char *path) } +void Debug(const char *format, ...) +{ + static FILE *fp=NULL; + va_list ap; + + if (!fp) + fp=fopen("debug.txt","w"); + + if (!fp) + return; + + va_start(ap,format); + vfprintf(fp,format,ap); + va_end(ap); +} + /* END OF FILE */ diff --git a/src/util.h b/src/util.h index 6930b8a..922f641 100644 --- a/src/util.h +++ b/src/util.h @@ -60,6 +60,13 @@ const char *Basename(const char *path); const char *Dirname(const char *path); +/* Writes the passed text to debug.txt. Note this is interface is not + able to be switched on/off, so debug is only used in a transient way + (once the bug is fixed, calls to this should be removed). +*/ +void Debug(const char *format,...); + + #endif -- cgit v1.2.3