diff options
author | Ian C <ianc@noddybox.co.uk> | 2004-01-04 23:28:26 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2004-01-04 23:28:26 +0000 |
commit | a08ee7dc825192d933d836514252e09bbcf313dc (patch) | |
tree | 0392c028a3fcb2595bf5a90d52f7adc71983eb9b /src/memmenu.c | |
parent | 6a86fc4668ce7e213330bb78aff45c578e159f54 (diff) |
Devel snapshot - still doesn't work
Diffstat (limited to 'src/memmenu.c')
-rw-r--r-- | src/memmenu.c | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/src/memmenu.c b/src/memmenu.c index 516bd36..9e1726b 100644 --- a/src/memmenu.c +++ b/src/memmenu.c @@ -26,6 +26,7 @@ static const char ident[]="$Id$"; #include <stdlib.h> +#include <stdio.h> #include <string.h> #include <ctype.h> @@ -66,7 +67,8 @@ static void DisplayMenu(void) static const char *menu[]= { "1. Disassemble/Hex dump", - "2. Return ", + "2. Disassemble to file ", + "3. Return ", NULL }; @@ -145,12 +147,12 @@ static Z80Word Address(Z80 *z80, const char *p) } -static int EnterAddress(Z80 *z80, Z80Word *w) +static int EnterAddress(const char *prompt, Z80 *z80, Z80Word *w) { unsigned long ul; const char *p; - p=GUIInputString("Address?",""); + p=GUIInputString(prompt ? prompt : "Address?",""); if (*p) { @@ -254,7 +256,7 @@ static void DoDisassem(Z80 *z80, const Z80State *s) case SDLK_RETURN: case SDLK_KP_ENTER: - EnterAddress(z80,&pc); + EnterAddress(NULL,z80,&pc); break; case SDLK_UP: @@ -294,6 +296,46 @@ static void DoDisassem(Z80 *z80, const Z80State *s) } +static void DoDisassemFile(Z80 *z80, const Z80State *s) +{ + static char fname[FILENAME_MAX]=""; + FILE *fp; + Z80Word start; + Z80Word len; + Z80Word prev; + const char *p; + + EnterAddress("Disassemble from?",z80,&start); + EnterAddress("For how many bytes?",z80,&len); + + p=GUIInputString("To file?",fname); + + if (!strlen(p)) + return; + + strcpy(fname,p); + + if (!(fp=fopen(fname,"w"))) + { + GUIMessage("ERROR","Couldn't create file:\n%s",fname); + return; + } + + prev=len; + + while(len<=prev) + { + Z80Word orig=start; + + fprintf(fp,"%4.4x: %s\n",orig,Z80Disassemble(z80,&start)); + prev=len; + len-=(start-orig); + } + + fclose(fp); +} + + /* ---------------------------------------- EXPORTED INTERFACES */ void MemoryMenu(Z80 *z80) @@ -320,8 +362,12 @@ void MemoryMenu(Z80 *z80) DoDisassem(z80,&s); break; - case SDLK_ESCAPE: case SDLK_2: + DoDisassemFile(z80,&s); + break; + + case SDLK_ESCAPE: + case SDLK_3: quit=TRUE; break; |