From c1d084c70d3fa63eb787b57c5c6c3f511c95a357 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 16 Jan 2004 02:28:10 +0000 Subject: Added options to toggle individual breakpoints --- src/gfx.h | 6 -- src/gui.c | 220 ++++++++++++++++++++++++++++++++++++++-------------------- src/gui.h | 8 +++ src/main.c | 12 ++-- src/memmenu.c | 158 ++++++++++++++++++++++++++--------------- src/memmenu.h | 4 +- 6 files changed, 263 insertions(+), 145 deletions(-) diff --git a/src/gfx.h b/src/gfx.h index 9b35868..6d051d8 100644 --- a/src/gfx.h +++ b/src/gfx.h @@ -55,12 +55,6 @@ void GFXInit(void); -/* Size of the screen -*/ -int GFXHeight(void); -int GFXWidth(void); - - /* Get the SDL_Surface for the screen */ SDL_Surface *GFXGetSurface(void); diff --git a/src/gui.c b/src/gui.c index c922aba..05ebc49 100644 --- a/src/gui.c +++ b/src/gui.c @@ -98,6 +98,133 @@ static void Box(const char *title, int x, int y, int width, int height) } +static int DoList(const char *title, int no, char * const list[], int *option) +{ + static const int max=GFX_HEIGHT/8-8; + SDL_Event *e; + int top; + int cur; + int done; + int f; + + if (no==0) + return -1; + + top=0; + cur=0; + + done=FALSE; + + while(!done) + { + Box(title,7,7,GFX_WIDTH-14,GFX_HEIGHT-14); + + if (option) + { + Centre("Cursors to move, RETURN to accept", + GFX_HEIGHT-44,WHITE); + Centre("SPACE toggles, I inverts all", + GFX_HEIGHT-36,WHITE); + Centre("S select all, C clear all", + GFX_HEIGHT-28,WHITE); + } + else + Centre("Cursors and RETURN to select",GFX_HEIGHT-28,WHITE); + + Centre("ESCAPE to cancel",GFX_HEIGHT-20,WHITE); + + for(f=0;fkey.keysym.sym) + { + case SDLK_RETURN: + done=TRUE; + break; + + case SDLK_SPACE: + if (option) + option[cur]=!option[cur]; + break; + + case SDLK_i: + if (option) + for(f=0;f0) + { + cur--; + + if (curtop+max-2) + top=cur-max+2; + } + break; + + default: + break; + } + } + + return cur; +} + + /* ---------------------------------------- EXPORTED INTERFACES */ int GUIMessage(GUIBoxType type, const char *title, const char *format,...) @@ -265,90 +392,33 @@ const char *GUIInputString(const char *prompt, const char *orig) int GUIListSelect(const char *title, int no, char * const list[]) { - static const int max=GFX_HEIGHT/8-8; - SDL_Event *e; - int top; - int cur; - int done; - int f; - - if (no==0) - return -1; - - top=0; - cur=0; - - done=FALSE; - - while(!done) - { - Box(title,7,7,GFX_WIDTH-14,GFX_HEIGHT-14); - - Centre("Cursors and RETURN to select",GFX_HEIGHT-40,WHITE); - Centre("ESCAPE to cancel",GFX_HEIGHT-32,WHITE); - - for(f=0;fkey.keysym.sym) - { - case SDLK_RETURN: - done=TRUE; - break; + if (no==0) + return FALSE; - case SDLK_ESCAPE: - cur=-1; - done=TRUE; - break; + o=Malloc(no * sizeof *o); - case SDLK_UP: - if (cur>0) - { - cur--; + for(f=0;ftop+max-2) - top=cur-max+2; - } - break; - - default: - break; - } - } + free(o); - return cur; + return sel!=-1; } diff --git a/src/gui.h b/src/gui.h index e1ad43a..efbb40c 100644 --- a/src/gui.h +++ b/src/gui.h @@ -58,6 +58,14 @@ const char *GUIInputString(const char *prompt, const char *orig); int GUIListSelect(const char *title, int no, char * const list[]); +/* Allows options to be toggled in a list. Returns FALSE for cancelled (in + which case option will be as it was. TRUE if accepted, and option will be + updated. +*/ +int GUIListOption(const char *title, + int no, char * const list[], int option[]); + + /* Select a file from the given directory. If load is TRUE then a new name cannot be entered. diff --git a/src/main.c b/src/main.c index a79464c..587e657 100644 --- a/src/main.c +++ b/src/main.c @@ -36,6 +36,7 @@ static const char id[]="$Id$"; #include "memmenu.h" #include "config.h" #include "exit.h" +#include "util.h" /* ---------------------------------------- MACROS @@ -102,7 +103,7 @@ int main(int argc, char *argv[]) TODO: Proper switch handling */ if (argc>1 && strcmp(argv[1],"-m")==0) - MemoryMenu(z80); + quit=MemoryMenu(z80); while(!quit) { @@ -129,16 +130,16 @@ int main(int argc, char *argv[]) if ((brk=Break())) { GUIMessage(eMessageBox,"BREAKPOINT","%s",brk); - MemoryMenu(z80); + quit=MemoryMenu(z80); } - while((e=GFXGetKey())) + while(!quit && (e=GFXGetKey())) { switch (e->key.keysym.sym) { case SDLK_ESCAPE: if (e->key.state==SDL_PRESSED) - quit=TRUE; + quit=GUIMessage(eYesNoBox,"QUIT","Sure?"); break; case SDLK_F1: @@ -214,7 +215,8 @@ int main(int argc, char *argv[]) case SDLK_F11: if (e->key.state==SDL_PRESSED) - MemoryMenu(z80); + quit=MemoryMenu(z80); + Debug("quit=%d\n"); break; case SDLK_F12: diff --git a/src/memmenu.c b/src/memmenu.c index 41a18b3..0d5053f 100644 --- a/src/memmenu.c +++ b/src/memmenu.c @@ -63,6 +63,7 @@ static const char ident_h[]=ESPEC_MEMMENU_H; typedef struct { int no; + int *active; char **expr; } Breakpoint; @@ -86,7 +87,7 @@ typedef struct /* ---------------------------------------- STATIC DATA */ static FILE *trace=NULL; -static Breakpoint bpoint={0,NULL}; +static Breakpoint bpoint={0,NULL,NULL}; static const char *brk=NULL; static int lodged=FALSE; @@ -98,9 +99,21 @@ static int Instruction(Z80 *z80, Z80Val data); /* ---------------------------------------- PRIVATE FUNCTIONS */ +static int BreaksActive(void) +{ + int f; + int ret=FALSE; + + for(f=0;f