diff options
author | Ian C <ianc@noddybox.co.uk> | 2004-08-27 23:55:16 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2004-08-27 23:55:16 +0000 |
commit | 0922b7993ce1d18de8fe975b17fd33cd3841ae9c (patch) | |
tree | 429f1e7314a10bebd0634f87c3d25d58647e9c4f /src | |
parent | b219c3580da55f3396a2d8df8301a777b783d833 (diff) |
Updates
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 279 | ||||
-rw-r--r-- | src/main.c | 83 | ||||
-rw-r--r-- | src/memmenu.c | 260 | ||||
-rw-r--r-- | src/snap.c | 8 | ||||
-rw-r--r-- | src/spec.c | 20 | ||||
-rw-r--r-- | src/util.c | 3 |
6 files changed, 422 insertions, 231 deletions
diff --git a/src/Makefile b/src/Makefile index 003f717..a0c3354 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,7 +18,7 @@ # # ------------------------------------------------------------------------- # -# $Id: Makefile,v 1.10 2004-01-24 02:17:57 ianc Exp $ +# $Id: Makefile,v 1.11 2004-08-27 23:55:16 ianc Exp $ # @@ -26,7 +26,8 @@ # Simply comment out if not, and replace as needed. # Other CFLAGS lines *are* required. # -CFLAGS = -g -Wall -Werror -pedantic -ansi +CFLAGS = -g -Wall -Werror -pedantic -ansi -O2 +#CFLAGS = -g -Wall -Werror -pedantic -ansi -O2 -pg TARGET = espec @@ -57,6 +58,7 @@ OBJECTS = main.o \ CFLAGS += -Iz80 `sdl-config --cflags` LIBS = $(Z80LIB) `sdl-config --libs` +#LIBS = $(Z80LIB) `sdl-config --static-libs` -lncurses -lX11 $(TARGET): $(OBJECTS) $(Z80LIB) $(CC) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) @@ -65,7 +67,7 @@ $(Z80LIB): z80/*.[ch] cd z80; make "EXTERNAL_CFLAGS=`sdl-config --cflags`" ; cd .. clean: - rm -f $(TARGET) $(OBJECTS) core + rm -f $(TARGET) $(TARGET).exe $(OBJECTS) core cd z80; make clean; cd .. depend: @@ -76,143 +78,158 @@ depend: # DO NOT DELETE THIS LINE -- make depend depends on it main.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h -main.o: /usr/include/sys/_types.h /usr/include/machine/_types.h -main.o: /usr/include/stdio.h /usr/include/string.h /usr/include/strings.h -main.o: /usr/local/include/SDL/SDL.h /usr/local/include/SDL/SDL_main.h -main.o: /usr/local/include/SDL/SDL_types.h -main.o: /usr/local/include/SDL/SDL_getenv.h -main.o: /usr/local/include/SDL/SDL_error.h -main.o: /usr/local/include/SDL/begin_code.h -main.o: /usr/local/include/SDL/close_code.h -main.o: /usr/local/include/SDL/SDL_rwops.h /usr/local/include/SDL/SDL_timer.h -main.o: /usr/local/include/SDL/SDL_audio.h -main.o: /usr/local/include/SDL/SDL_byteorder.h -main.o: /usr/local/include/SDL/SDL_cdrom.h -main.o: /usr/local/include/SDL/SDL_joystick.h -main.o: /usr/local/include/SDL/SDL_events.h -main.o: /usr/local/include/SDL/SDL_active.h -main.o: /usr/local/include/SDL/SDL_keyboard.h -main.o: /usr/local/include/SDL/SDL_keysym.h -main.o: /usr/local/include/SDL/SDL_mouse.h /usr/local/include/SDL/SDL_video.h -main.o: /usr/local/include/SDL/SDL_mutex.h /usr/local/include/SDL/SDL_quit.h -main.o: /usr/local/include/SDL/SDL_version.h z80/z80.h spec.h gfx.h gui.h +main.o: /usr/include/machine/ansi.h /usr/include/stdio.h +main.o: /usr/include/string.h /usr/local/include/SDL11/SDL.h +main.o: /usr/local/include/SDL11/SDL_main.h +main.o: /usr/local/include/SDL11/SDL_types.h +main.o: /usr/local/include/SDL11/SDL_getenv.h +main.o: /usr/local/include/SDL11/SDL_error.h +main.o: /usr/local/include/SDL11/begin_code.h +main.o: /usr/local/include/SDL11/close_code.h +main.o: /usr/local/include/SDL11/SDL_rwops.h +main.o: /usr/local/include/SDL11/SDL_timer.h +main.o: /usr/local/include/SDL11/SDL_audio.h +main.o: /usr/local/include/SDL11/SDL_byteorder.h +main.o: /usr/local/include/SDL11/SDL_cdrom.h +main.o: /usr/local/include/SDL11/SDL_joystick.h +main.o: /usr/local/include/SDL11/SDL_events.h +main.o: /usr/local/include/SDL11/SDL_active.h +main.o: /usr/local/include/SDL11/SDL_keyboard.h +main.o: /usr/local/include/SDL11/SDL_keysym.h +main.o: /usr/local/include/SDL11/SDL_mouse.h +main.o: /usr/local/include/SDL11/SDL_video.h +main.o: /usr/local/include/SDL11/SDL_mutex.h +main.o: /usr/local/include/SDL11/SDL_quit.h +main.o: /usr/local/include/SDL11/SDL_version.h z80/z80.h spec.h gfx.h gui.h main.o: memmenu.h config.h kbbmp.h exit.h util.h spec.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h -spec.o: /usr/include/sys/_types.h /usr/include/machine/_types.h -spec.o: /usr/include/stdio.h /usr/include/string.h /usr/include/strings.h -spec.o: spec.h z80/z80.h /usr/local/include/SDL/SDL.h -spec.o: /usr/local/include/SDL/SDL_main.h /usr/local/include/SDL/SDL_types.h -spec.o: /usr/local/include/SDL/SDL_getenv.h -spec.o: /usr/local/include/SDL/SDL_error.h -spec.o: /usr/local/include/SDL/begin_code.h -spec.o: /usr/local/include/SDL/close_code.h -spec.o: /usr/local/include/SDL/SDL_rwops.h /usr/local/include/SDL/SDL_timer.h -spec.o: /usr/local/include/SDL/SDL_audio.h -spec.o: /usr/local/include/SDL/SDL_byteorder.h -spec.o: /usr/local/include/SDL/SDL_cdrom.h -spec.o: /usr/local/include/SDL/SDL_joystick.h -spec.o: /usr/local/include/SDL/SDL_events.h -spec.o: /usr/local/include/SDL/SDL_active.h -spec.o: /usr/local/include/SDL/SDL_keyboard.h -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: /usr/include/machine/ansi.h /usr/include/stdio.h +spec.o: /usr/include/string.h spec.h z80/z80.h /usr/local/include/SDL11/SDL.h +spec.o: /usr/local/include/SDL11/SDL_main.h +spec.o: /usr/local/include/SDL11/SDL_types.h +spec.o: /usr/local/include/SDL11/SDL_getenv.h +spec.o: /usr/local/include/SDL11/SDL_error.h +spec.o: /usr/local/include/SDL11/begin_code.h +spec.o: /usr/local/include/SDL11/close_code.h +spec.o: /usr/local/include/SDL11/SDL_rwops.h +spec.o: /usr/local/include/SDL11/SDL_timer.h +spec.o: /usr/local/include/SDL11/SDL_audio.h +spec.o: /usr/local/include/SDL11/SDL_byteorder.h +spec.o: /usr/local/include/SDL11/SDL_cdrom.h +spec.o: /usr/local/include/SDL11/SDL_joystick.h +spec.o: /usr/local/include/SDL11/SDL_events.h +spec.o: /usr/local/include/SDL11/SDL_active.h +spec.o: /usr/local/include/SDL11/SDL_keyboard.h +spec.o: /usr/local/include/SDL11/SDL_keysym.h +spec.o: /usr/local/include/SDL11/SDL_mouse.h +spec.o: /usr/local/include/SDL11/SDL_video.h +spec.o: /usr/local/include/SDL11/SDL_mutex.h +spec.o: /usr/local/include/SDL11/SDL_quit.h +spec.o: /usr/local/include/SDL11/SDL_version.h snap.h gfx.h gui.h config.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 +snap.o: /usr/include/machine/ansi.h /usr/include/stdio.h z80/z80.h util.h config.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h -config.o: /usr/include/sys/_types.h /usr/include/machine/_types.h -config.o: /usr/include/stdio.h /usr/include/string.h /usr/include/strings.h -config.o: exit.h config.h +config.o: /usr/include/machine/ansi.h /usr/include/stdio.h +config.o: /usr/include/string.h exit.h config.h gfx.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h -gfx.o: /usr/include/sys/_types.h /usr/include/machine/_types.h -gfx.o: /usr/include/stdio.h /usr/include/string.h /usr/include/strings.h -gfx.o: /usr/include/stdarg.h gfx.h /usr/local/include/SDL/SDL.h -gfx.o: /usr/local/include/SDL/SDL_main.h /usr/local/include/SDL/SDL_types.h -gfx.o: /usr/local/include/SDL/SDL_getenv.h /usr/local/include/SDL/SDL_error.h -gfx.o: /usr/local/include/SDL/begin_code.h -gfx.o: /usr/local/include/SDL/close_code.h /usr/local/include/SDL/SDL_rwops.h -gfx.o: /usr/local/include/SDL/SDL_timer.h /usr/local/include/SDL/SDL_audio.h -gfx.o: /usr/local/include/SDL/SDL_byteorder.h -gfx.o: /usr/local/include/SDL/SDL_cdrom.h -gfx.o: /usr/local/include/SDL/SDL_joystick.h -gfx.o: /usr/local/include/SDL/SDL_events.h -gfx.o: /usr/local/include/SDL/SDL_active.h -gfx.o: /usr/local/include/SDL/SDL_keyboard.h -gfx.o: /usr/local/include/SDL/SDL_keysym.h /usr/local/include/SDL/SDL_mouse.h -gfx.o: /usr/local/include/SDL/SDL_video.h /usr/local/include/SDL/SDL_mutex.h -gfx.o: /usr/local/include/SDL/SDL_quit.h /usr/local/include/SDL/SDL_version.h -gfx.o: exit.h config.h font.h +gfx.o: /usr/include/machine/ansi.h /usr/include/stdio.h /usr/include/string.h +gfx.o: /usr/include/stdarg.h gfx.h /usr/local/include/SDL11/SDL.h +gfx.o: /usr/local/include/SDL11/SDL_main.h +gfx.o: /usr/local/include/SDL11/SDL_types.h +gfx.o: /usr/local/include/SDL11/SDL_getenv.h +gfx.o: /usr/local/include/SDL11/SDL_error.h +gfx.o: /usr/local/include/SDL11/begin_code.h +gfx.o: /usr/local/include/SDL11/close_code.h +gfx.o: /usr/local/include/SDL11/SDL_rwops.h +gfx.o: /usr/local/include/SDL11/SDL_timer.h +gfx.o: /usr/local/include/SDL11/SDL_audio.h +gfx.o: /usr/local/include/SDL11/SDL_byteorder.h +gfx.o: /usr/local/include/SDL11/SDL_cdrom.h +gfx.o: /usr/local/include/SDL11/SDL_joystick.h +gfx.o: /usr/local/include/SDL11/SDL_events.h +gfx.o: /usr/local/include/SDL11/SDL_active.h +gfx.o: /usr/local/include/SDL11/SDL_keyboard.h +gfx.o: /usr/local/include/SDL11/SDL_keysym.h +gfx.o: /usr/local/include/SDL11/SDL_mouse.h +gfx.o: /usr/local/include/SDL11/SDL_video.h +gfx.o: /usr/local/include/SDL11/SDL_mutex.h +gfx.o: /usr/local/include/SDL11/SDL_quit.h +gfx.o: /usr/local/include/SDL11/SDL_version.h exit.h config.h font.h gui.o: /usr/include/stdlib.h /usr/include/sys/cdefs.h -gui.o: /usr/include/sys/_types.h /usr/include/machine/_types.h -gui.o: /usr/include/stdio.h /usr/include/string.h /usr/include/strings.h +gui.o: /usr/include/machine/ansi.h /usr/include/stdio.h /usr/include/string.h gui.o: /usr/include/stdarg.h /usr/include/ctype.h /usr/include/runetype.h -gui.o: gui.h gfx.h /usr/local/include/SDL/SDL.h -gui.o: /usr/local/include/SDL/SDL_main.h /usr/local/include/SDL/SDL_types.h -gui.o: /usr/local/include/SDL/SDL_getenv.h /usr/local/include/SDL/SDL_error.h -gui.o: /usr/local/include/SDL/begin_code.h -gui.o: /usr/local/include/SDL/close_code.h /usr/local/include/SDL/SDL_rwops.h -gui.o: /usr/local/include/SDL/SDL_timer.h /usr/local/include/SDL/SDL_audio.h -gui.o: /usr/local/include/SDL/SDL_byteorder.h -gui.o: /usr/local/include/SDL/SDL_cdrom.h -gui.o: /usr/local/include/SDL/SDL_joystick.h -gui.o: /usr/local/include/SDL/SDL_events.h -gui.o: /usr/local/include/SDL/SDL_active.h -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 util.h +gui.o: gui.h gfx.h /usr/local/include/SDL11/SDL.h +gui.o: /usr/local/include/SDL11/SDL_main.h +gui.o: /usr/local/include/SDL11/SDL_types.h +gui.o: /usr/local/include/SDL11/SDL_getenv.h +gui.o: /usr/local/include/SDL11/SDL_error.h +gui.o: /usr/local/include/SDL11/begin_code.h +gui.o: /usr/local/include/SDL11/close_code.h +gui.o: /usr/local/include/SDL11/SDL_rwops.h +gui.o: /usr/local/include/SDL11/SDL_timer.h +gui.o: /usr/local/include/SDL11/SDL_audio.h +gui.o: /usr/local/include/SDL11/SDL_byteorder.h +gui.o: /usr/local/include/SDL11/SDL_cdrom.h +gui.o: /usr/local/include/SDL11/SDL_joystick.h +gui.o: /usr/local/include/SDL11/SDL_events.h +gui.o: /usr/local/include/SDL11/SDL_active.h +gui.o: /usr/local/include/SDL11/SDL_keyboard.h +gui.o: /usr/local/include/SDL11/SDL_keysym.h +gui.o: /usr/local/include/SDL11/SDL_mouse.h +gui.o: /usr/local/include/SDL11/SDL_video.h +gui.o: /usr/local/include/SDL11/SDL_mutex.h +gui.o: /usr/local/include/SDL11/SDL_quit.h +gui.o: /usr/local/include/SDL11/SDL_version.h 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 -memmenu.o: /usr/include/ctype.h /usr/include/runetype.h memmenu.h z80/z80.h -memmenu.o: spec.h /usr/local/include/SDL/SDL.h -memmenu.o: /usr/local/include/SDL/SDL_main.h -memmenu.o: /usr/local/include/SDL/SDL_types.h -memmenu.o: /usr/local/include/SDL/SDL_getenv.h -memmenu.o: /usr/local/include/SDL/SDL_error.h -memmenu.o: /usr/local/include/SDL/begin_code.h -memmenu.o: /usr/local/include/SDL/close_code.h -memmenu.o: /usr/local/include/SDL/SDL_rwops.h -memmenu.o: /usr/local/include/SDL/SDL_timer.h -memmenu.o: /usr/local/include/SDL/SDL_audio.h -memmenu.o: /usr/local/include/SDL/SDL_byteorder.h -memmenu.o: /usr/local/include/SDL/SDL_cdrom.h -memmenu.o: /usr/local/include/SDL/SDL_joystick.h -memmenu.o: /usr/local/include/SDL/SDL_events.h -memmenu.o: /usr/local/include/SDL/SDL_active.h -memmenu.o: /usr/local/include/SDL/SDL_keyboard.h -memmenu.o: /usr/local/include/SDL/SDL_keysym.h -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 util.h +memmenu.o: /usr/include/machine/ansi.h /usr/include/stdio.h +memmenu.o: /usr/include/string.h /usr/include/ctype.h /usr/include/runetype.h +memmenu.o: memmenu.h z80/z80.h spec.h /usr/local/include/SDL11/SDL.h +memmenu.o: /usr/local/include/SDL11/SDL_main.h +memmenu.o: /usr/local/include/SDL11/SDL_types.h +memmenu.o: /usr/local/include/SDL11/SDL_getenv.h +memmenu.o: /usr/local/include/SDL11/SDL_error.h +memmenu.o: /usr/local/include/SDL11/begin_code.h +memmenu.o: /usr/local/include/SDL11/close_code.h +memmenu.o: /usr/local/include/SDL11/SDL_rwops.h +memmenu.o: /usr/local/include/SDL11/SDL_timer.h +memmenu.o: /usr/local/include/SDL11/SDL_audio.h +memmenu.o: /usr/local/include/SDL11/SDL_byteorder.h +memmenu.o: /usr/local/include/SDL11/SDL_cdrom.h +memmenu.o: /usr/local/include/SDL11/SDL_joystick.h +memmenu.o: /usr/local/include/SDL11/SDL_events.h +memmenu.o: /usr/local/include/SDL11/SDL_active.h +memmenu.o: /usr/local/include/SDL11/SDL_keyboard.h +memmenu.o: /usr/local/include/SDL11/SDL_keysym.h +memmenu.o: /usr/local/include/SDL11/SDL_mouse.h +memmenu.o: /usr/local/include/SDL11/SDL_video.h +memmenu.o: /usr/local/include/SDL11/SDL_mutex.h +memmenu.o: /usr/local/include/SDL11/SDL_quit.h +memmenu.o: /usr/local/include/SDL11/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 /usr/include/stdarg.h -util.o: util.h /usr/include/stdlib.h exit.h +util.o: /usr/include/machine/ansi.h /usr/include/string.h +util.o: /usr/include/stdarg.h util.h /usr/include/stdlib.h exit.h kbbmp.o: kbbmp.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 -exit.o: /usr/local/include/SDL/SDL_main.h /usr/local/include/SDL/SDL_types.h -exit.o: /usr/local/include/SDL/SDL_getenv.h -exit.o: /usr/local/include/SDL/SDL_error.h -exit.o: /usr/local/include/SDL/begin_code.h -exit.o: /usr/local/include/SDL/close_code.h -exit.o: /usr/local/include/SDL/SDL_rwops.h /usr/include/stdio.h -exit.o: /usr/local/include/SDL/SDL_timer.h /usr/local/include/SDL/SDL_audio.h -exit.o: /usr/local/include/SDL/SDL_byteorder.h -exit.o: /usr/local/include/SDL/SDL_cdrom.h -exit.o: /usr/local/include/SDL/SDL_joystick.h -exit.o: /usr/local/include/SDL/SDL_events.h -exit.o: /usr/local/include/SDL/SDL_active.h -exit.o: /usr/local/include/SDL/SDL_keyboard.h -exit.o: /usr/local/include/SDL/SDL_keysym.h -exit.o: /usr/local/include/SDL/SDL_mouse.h /usr/local/include/SDL/SDL_video.h -exit.o: /usr/local/include/SDL/SDL_mutex.h /usr/local/include/SDL/SDL_quit.h -exit.o: /usr/local/include/SDL/SDL_version.h +exit.o: /usr/include/machine/ansi.h /usr/include/stdarg.h exit.h +exit.o: /usr/local/include/SDL11/SDL.h /usr/local/include/SDL11/SDL_main.h +exit.o: /usr/local/include/SDL11/SDL_types.h +exit.o: /usr/local/include/SDL11/SDL_getenv.h +exit.o: /usr/local/include/SDL11/SDL_error.h +exit.o: /usr/local/include/SDL11/begin_code.h +exit.o: /usr/local/include/SDL11/close_code.h +exit.o: /usr/local/include/SDL11/SDL_rwops.h /usr/include/stdio.h +exit.o: /usr/local/include/SDL11/SDL_timer.h +exit.o: /usr/local/include/SDL11/SDL_audio.h +exit.o: /usr/local/include/SDL11/SDL_byteorder.h +exit.o: /usr/local/include/SDL11/SDL_cdrom.h +exit.o: /usr/local/include/SDL11/SDL_joystick.h +exit.o: /usr/local/include/SDL11/SDL_events.h +exit.o: /usr/local/include/SDL11/SDL_active.h +exit.o: /usr/local/include/SDL11/SDL_keyboard.h +exit.o: /usr/local/include/SDL11/SDL_keysym.h +exit.o: /usr/local/include/SDL11/SDL_mouse.h +exit.o: /usr/local/include/SDL11/SDL_video.h +exit.o: /usr/local/include/SDL11/SDL_mutex.h +exit.o: /usr/local/include/SDL11/SDL_quit.h +exit.o: /usr/local/include/SDL11/SDL_version.h @@ -58,8 +58,13 @@ static Uint32 black; static Uint32 grey; -/* ---------------------------------------- PROTOS +/* ---------------------------------------- PRIVATE FUNCTIONS */ +static void Usage(void) +{ + fprintf(stderr,"usage: espec [-m] [-l tape_file] [-s tape_file]\n"); + exit(EXIT_FAILURE); +} /* ---------------------------------------- MAIN @@ -72,6 +77,8 @@ int main(int argc, char *argv[]) SDL_Event *e; int quit; int trace; + int inital_menu; + int f; ConfigRead(); @@ -100,12 +107,65 @@ int main(int argc, char *argv[]) quit=FALSE; - /* Check for initial memory menu usage - TODO: Proper switch handling + /* Parse switches */ - if (argc>1 && strcmp(argv[1],"-m")==0) + inital_menu=FALSE; + tape_in[0]=0; + tape_out[0]=0; + + f=1; + + while(f<argc && argv[f][0]=='-') + { + switch(argv[f][1]) + { + case 'm': + inital_menu=TRUE; + break; + + case 'l': + if (f>argc-2) + { + Usage(); + } + + strcpy(tape_in,argv[++f]); + break; + + case 's': + if (f>argc-2) + { + Usage(); + } + + strcpy(tape_out,argv[++f]); + break; + + default: + Usage(); + break; + } + + f++; + } + + if (inital_menu) + { quit=MemoryMenu(z80); + } + if (tape_in[0]) + { + SPECMount(SPEC_TAPE_IN,tape_in); + } + + if (tape_out[0]) + { + SPECMount(SPEC_TAPE_IN,tape_out); + } + + /* Main loop + */ while(!quit) { const char *brk; @@ -150,6 +210,7 @@ int main(int argc, char *argv[]) "F1 - Help \n" "F2 - About \n" "F3 - View Spectrum keyboad \n" + "F4 - View mounted tapes \n" "F8 - Select tape file for loading\n" "F9 - Select tape file for saving \n" "F10 - Close all open tape files \n" @@ -191,6 +252,16 @@ int main(int argc, char *argv[]) } break; + case SDLK_F4: + if (e->key.state==SDL_PRESSED) + GUIMessage(eMessageBox, + "Mounted Tape Files", + "In: %-20.20s\nOut: %-20.20s", + tape_in[0] ? Basename(tape_in):"None", + tape_out[0] ? Basename(tape_out):"None"); + break; + + case SDLK_F8: if (e->key.state==SDL_PRESSED) { @@ -242,8 +313,4 @@ int main(int argc, char *argv[]) } -/* ---------------------------------------- PRIVATE FUNCTIONS -*/ - - /* END OF FILE */ diff --git a/src/memmenu.c b/src/memmenu.c index ccb065c..a194e55 100644 --- a/src/memmenu.c +++ b/src/memmenu.c @@ -104,7 +104,7 @@ static int BreaksActive(void) int f; int ret=FALSE; - for(f=0;f<bpoint.no;f++) + for(f=0;f<bpoint.no && !ret;f++) ret|=bpoint.active[f]; return ret; @@ -131,6 +131,56 @@ static void ClearCallback(Z80 *z80) } +static int AddBreak(Z80 *z80, const char *expr) +{ + bpoint.no++; + bpoint.expr=Realloc(bpoint.expr,bpoint.no * sizeof(*bpoint.expr)); + bpoint.active=Realloc(bpoint.active,bpoint.no * sizeof(*bpoint.active)); + + bpoint.expr[bpoint.no-1]=StrCopy(expr); + bpoint.active[bpoint.no-1]=TRUE; + + SetCallback(z80); + + return bpoint.no-1; +} + + +static void DeleteBreak(Z80 *z80, int no) +{ + int f; + + if (no>=bpoint.no) + return; + + free(bpoint.expr[no]); + + for(f=no;f<bpoint.no-1;f++) + { + bpoint.expr[f]=bpoint.expr[f+1]; + bpoint.active[f]=bpoint.active[f+1]; + } + + bpoint.no--; + + if (bpoint.no==0) + { + free(bpoint.expr); + bpoint.expr=NULL; + bpoint.active=NULL; + } + else + { + bpoint.expr=Realloc(bpoint.expr, + bpoint.no * sizeof(*bpoint.expr)); + bpoint.active=Realloc(bpoint.active, + bpoint.no * sizeof(*bpoint.active)); + } + + ClearCallback(z80); +} + + static void Centre(const char *p, int y, Uint32 col) { GFXPrint((GFX_WIDTH-strlen(p)*8)/2,y,col,"%s",p); @@ -271,8 +321,8 @@ static void DoDisassem(Z80 *z80, const Z80State *s) while(!quit) { SDL_Event *e; - Z80Word curr; - Z80Word next; + Z80Word curr=0; + Z80Word next=0; int f; GFXClear(BLACK); @@ -716,7 +766,7 @@ static void PlaybackTrace(Z80 *z80) } -static void DoAddBreakpoint(Z80 *z80) +static int DoAddBreakpoint(Z80 *z80) { const char *expr; char *error; @@ -725,7 +775,7 @@ static void DoAddBreakpoint(Z80 *z80) expr=GUIInputString("Expression?",""); if (!*expr) - return; + return -1; if (!Z80Expression(z80,expr,&l,&error)) { @@ -739,17 +789,12 @@ static void DoAddBreakpoint(Z80 *z80) GUIMessage(eMessageBox,"ERROR","Expression is invalid"); free(error); } + + return -1; } else { - bpoint.no++; - bpoint.expr=Realloc(bpoint.expr,bpoint.no * sizeof(*bpoint.expr)); - bpoint.active=Realloc(bpoint.active,bpoint.no * sizeof(*bpoint.active)); - - bpoint.expr[bpoint.no-1]=StrCopy(expr); - bpoint.active[bpoint.no-1]=TRUE; - - SetCallback(z80); + return AddBreak(z80,expr); } } @@ -785,34 +830,7 @@ static void DoRemoveBreakpoint(Z80 *z80) while (sel!=-1) { - int f; - - free(bpoint.expr[sel]); - - for(f=sel;f<bpoint.no-1;f++) - { - bpoint.expr[f]=bpoint.expr[f+1]; - bpoint.active[f]=bpoint.active[f+1]; - } - - bpoint.no--; - - if (bpoint.no==0) - { - free(bpoint.expr); - bpoint.expr=NULL; - bpoint.active=NULL; - } - else - { - bpoint.expr=Realloc(bpoint.expr, - bpoint.no * sizeof(*bpoint.expr)); - bpoint.active=Realloc(bpoint.active, - bpoint.no * sizeof(*bpoint.active)); - } - - ClearCallback(z80); - + DeleteBreak(z80,sel); sel=GUIListSelect("BREAKPOINT TO DELETE",bpoint.no,bpoint.expr); } } @@ -841,7 +859,10 @@ static void DoMonitor(Z80 *z80) static int overlay=FALSE; int quit=FALSE; int running=FALSE; + int update=TRUE; int step=FALSE; + int trigger=-1; + int regdisp=0; SPECEnableScreen(FALSE); @@ -855,47 +876,68 @@ static void DoMonitor(Z80 *z80) step=FALSE; - if (overlay) - SPECShowScreen(); - else - GFXClear(BLACK); + if (update) + { + if (overlay) + SPECShowScreen(); + else + GFXClear(BLACK); - CentrePaper("MONITOR",0,WHITE,BLACK); - CentrePaper("Press F1 for help",9,RED,BLACK); + CentrePaper("MONITOR",0,WHITE,BLACK); + CentrePaper("Press F1 for help",9,RED,BLACK); - Z80GetState(z80,&s); + Z80GetState(z80,&s); - DisplayZ80State(&s,136,WHITE); + DisplayZ80State(&s,136,WHITE); - GetMemTrace(z80,mt,s.SP-(TRACEMEM_WIN/2+1),TRACEMEM_WIN); - DisplayTraceMem(0,192,"MEM (SP)",mt,s.SP); - GetMemTrace(z80,mt,s.HL-(TRACEMEM_WIN/2+1),TRACEMEM_WIN); - DisplayTraceMem(100,192,"MEM (HL)",mt,s.HL); - GetMemTrace(z80,mt,s.DE-(TRACEMEM_WIN/2+1),TRACEMEM_WIN); - DisplayTraceMem(200,192,"MEM (DE)",mt,s.DE); + GetMemTrace(z80,mt,s.SP-(TRACEMEM_WIN/2+1),TRACEMEM_WIN); + DisplayTraceMem(0,192,"MEM (SP)",mt,s.SP); + GetMemTrace(z80,mt,s.HL-(TRACEMEM_WIN/2+1),TRACEMEM_WIN); + DisplayTraceMem(100,192,"MEM (HL)",mt,s.HL); - for(f=0;f<10;f++) - { - char str[80]; - char *p; - int paper; - int y; + switch(regdisp) + { + case 0: + GetMemTrace(z80,mt,s.DE-(TRACEMEM_WIN/2+1),TRACEMEM_WIN); + DisplayTraceMem(200,192,"MEM (DE)",mt,s.DE); + break; + case 1: + GetMemTrace(z80,mt,s.IX-(TRACEMEM_WIN/2+1),TRACEMEM_WIN); + DisplayTraceMem(200,192,"MEM (IX)",mt,s.IX); + break; + case 2: + GetMemTrace(z80,mt,s.IY-(TRACEMEM_WIN/2+1),TRACEMEM_WIN); + DisplayTraceMem(200,192,"MEM (IY)",mt,s.IY); + break; + case 3: + GetMemTrace(z80,mt,s.BC-(TRACEMEM_WIN/2+1),TRACEMEM_WIN); + DisplayTraceMem(200,192,"MEM (BC)",mt,s.BC); + break; + } - y=24+f*8; + for(f=0;f<10;f++) + { + char str[80]; + char *p; + int paper; + int y; - if (f==0) - paper=RED; - else - paper=BLACK; + y=24+f*8; - GFXPrintPaper(0,y,GREEN,paper,"%4.4x ",s.PC); + if (f==0) + paper=RED; + else + paper=BLACK; - strcpy(str,Z80Disassemble(z80,&s.PC)); - p=strtok(str,";"); - GFXPrintPaper(40,y,WHITE,paper,"%s",str); - } + GFXPrintPaper(0,y,GREEN,paper,"%4.4x ",s.PC); - GFXEndFrame(FALSE); + strcpy(str,Z80Disassemble(z80,&s.PC)); + p=strtok(str,";"); + GFXPrintPaper(40,y,WHITE,paper,"%s",str); + } + + GFXEndFrame(FALSE); + } if (running) { @@ -914,16 +956,19 @@ static void DoMonitor(Z80 *z80) case SDLK_F1: GUIMessage (eMessageBox,"PLAYBACK HELP","%s", - "ESC - Exit \n" - "ENTER - Single step processor \n" - "R - Run till break or stop \n" - "SPACE - Stop running \n" - "O - Toggle overlay mode \n" - "5 - Add a new breakpoint \n" - "6 - Set active breakpoints \n" - "7 - Remove a breakpoint \n" - "8 - Clear all breakpoints \n" - "S - Display current screen "); + "ESC - Exit \n" + "ENTER - Single step processor \n" + "R - Run till break or stop \n" + "W - Watch till break or stop\n" + "T - Add temp breakpoint \n" + "SPACE - Stop running \n" + "O - Toggle overlay mode \n" + "5 - Add a new breakpoint \n" + "6 - Set active breakpoints \n" + "7 - Remove a breakpoint \n" + "8 - Clear all breakpoints \n" + "H - Alter reg index display \n" + "S - Display current screen "); break; case SDLK_RETURN: @@ -937,14 +982,28 @@ static void DoMonitor(Z80 *z80) case SDLK_r: running=TRUE; + update=FALSE; + GFXClear(BLACK); + CentrePaper("MONITOR",0,WHITE,BLACK); + CentrePaper("Press F1 for help",9,RED,BLACK); + CentrePaper("Running...",27,RED,BLACK); + GFXEndFrame(FALSE); + break; + + case SDLK_w: + running=TRUE; break; case SDLK_SPACE: running=FALSE; + update=TRUE; break; case SDLK_o: - overlay=!overlay; + if (update) + { + overlay=!overlay; + } break; case SDLK_5: @@ -964,9 +1023,26 @@ static void DoMonitor(Z80 *z80) break; case SDLK_s: - SPECShowScreen(); - GFXEndFrame(FALSE); - GFXWaitKey(); + if (update) + { + SPECShowScreen(); + GFXEndFrame(FALSE); + GFXWaitKey(); + } + break; + + case SDLK_h: + regdisp=(regdisp+1)%4; + break; + + case SDLK_t: + if (trigger!=-1) + { + DeleteBreak(z80,trigger); + trigger=-1; + } + + trigger=DoAddBreakpoint(z80); break; default: @@ -981,9 +1057,21 @@ static void DoMonitor(Z80 *z80) { GUIMessage(eMessageBox,"BREAKPOINT","%s",brk); running=FALSE; + update=TRUE; + + if (trigger!=-1) + { + DeleteBreak(z80,trigger); + trigger=-1; + } } } + if (trigger!=-1) + { + DeleteBreak(z80,trigger); + } + SPECEnableScreen(TRUE); } @@ -100,8 +100,13 @@ int TAPLoad(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, SNAP_Poke poke) Z80Word blen; Z80Byte type,b,csum,tape_csum; + b=0; + if (!fp) + { + Debug("No file to load!\n"); return FALSE; + } /* Get length (wrapping file if at eof) */ @@ -113,6 +118,8 @@ int TAPLoad(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, SNAP_Poke poke) blen=GetLSBWord(fp); } + Debug("blen=%u type=%u\n",id); + type=GetByte(fp); csum=id; @@ -120,6 +127,7 @@ int TAPLoad(FILE *fp, Z80Byte id, Z80Word *addr, Z80Word *len, SNAP_Poke poke) */ if (id==type) { + Debug("Matched type\n"); /* Knock of block type */ blen--; @@ -209,6 +209,7 @@ static const MatrixMap keymap[]= /* ---------------------------------------- DEBUG FUNCTIONS +*/ static const char *FlagString(Z80Byte flag) { static char s[]="76543210"; @@ -239,7 +240,6 @@ static void DumpZ80(Z80 *z80) printf("IFF1=%2.2x IFF2=%2.2x\n",s.IFF1,s.IFF2); printf("%s\n",Z80Disassemble(z80,&s.PC)); } -*/ /* ---------------------------------------- PRIVATE FUNCTIONS @@ -341,11 +341,11 @@ static int EDCallback(Z80 *z80, Z80Val data) { Z80State state; - Z80GetState(z80,&state); - switch((Z80Byte)data) { case SAVE_PATCH: + Z80GetState(z80,&state); + if (!tape_out) { state.AF|=eZ80_Carry; @@ -361,9 +361,15 @@ static int EDCallback(Z80 *z80, Z80Val data) state.AF&=~eZ80_Carry; } } + + DumpZ80(z80); + Z80SetState(z80,&state); + break; case LOAD_PATCH: + Z80GetState(z80,&state); + if (!tape_in) { state.AF|=eZ80_Carry; @@ -379,14 +385,16 @@ static int EDCallback(Z80 *z80, Z80Val data) state.AF&=~eZ80_Carry; } } + + DumpZ80(z80); + Z80SetState(z80,&state); + break; default: break; } - Z80SetState(z80,&state); - return TRUE; } @@ -458,7 +466,7 @@ void SPECInit(Z80 *z80) fclose(fp); GUIMessage(eMessageBox, "ERROR", - "ROM file must be %d bytes long\n", + "ROM file must be %d bytes long", ROMLEN); Exit(""); } @@ -116,8 +116,11 @@ void Debug(const char *format, ...) if (!fp) { + /* fp=fopen("debug.txt","w"); setbuf(fp,NULL); + */ + fp=stderr; } if (!fp) |