diff options
Diffstat (limited to 'source/zx81.c')
-rw-r--r-- | source/zx81.c | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/source/zx81.c b/source/zx81.c index 9a053b5..7964ed1 100644 --- a/source/zx81.c +++ b/source/zx81.c @@ -41,9 +41,6 @@ #define FALSE 0 #endif -#define MAX_FNAME_LEN 30 - - /* ---------------------------------------- STATICS */ #define ROMLEN 0x2000 @@ -99,6 +96,8 @@ static int enable_filesystem; static const Z80Byte *tape_image; static int tape_len; +static char last_dir[FILENAME_MAX] = "/"; + /* GFX vars */ static uint16 *txt_screen; @@ -259,58 +258,58 @@ static Z80Byte FromASCII(char c) */ static FILE *OpenTapeFile(Z80Word addr) { + static const char zx_chars[] = "\"#$:?()><=+-*/;,." + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; FILE *fp; - char fn[MAX_FNAME_LEN]; + char fn[FILENAME_MAX]; int f; int done; - f=0; - done=FALSE; + fp = NULL; + f = 0; + done = FALSE; - while(f<(MAX_FNAME_LEN-3) && !done) + while(f<(FILENAME_MAX-3) && !done) { int ch; - ch=mem[addr++]; + ch = mem[addr++]; if (ch&0x80) { - done=TRUE; - ch&=0x7f; + done = TRUE; + ch &= 0x7f; } - switch(ch) + if (ch>=11 && ch<=63) { - case 22: - fn[f++]='-'; - break; - - case 27: - fn[f++]='.'; - - default: - if (ch>=28 && ch<=37) - { - fn[f++]='0'+(ch-28); - } - else if (ch>=38 && ch<=63) - { - fn[f++]='A'+(ch-38); - } - break; + fn[f++] = zx_chars[ch-11]; } } - fn[f++]='.'; - fn[f++]='P'; - fn[f]=0; + if (fn[0] == '*') + { + if (GUI_FileSelect(last_dir,fn,".P")) + { + fp = fopen(fn,"rb"); + } - if (!(fp=fopen(fn,"rb"))) + SK_DisplayKeyboard(BG_GFX_SUB); + } + else { - char full_fn[MAX_FNAME_LEN+11]="\\ZX81SNAP\\"; + fn[f++] = '.'; + fn[f++] = 'P'; + fn[f] = 0; - strcat(full_fn,fn); - fp=fopen(full_fn,"rb"); + if (!(fp = fopen(fn,"rb"))) + { + char full_fn[FILENAME_MAX+11] = "/ZX81SNAP/"; + + strcat(full_fn,fn); + fp = fopen(full_fn,"rb"); + } } return fp; @@ -378,7 +377,7 @@ static void DrawScreen_HIRES(Z80 *z80) bmp = bmp_screen; table = z80->I << 8; - /* scr is increment in both loops so that it can skip of the end-of-line + /* scr is increment in both loops so that it can skip the end-of-line character */ for(y=0; y<192; y++) |