From 2332fb591b005da0a8a498b2e6d82c00bc00ae9d Mon Sep 17 00:00:00 2001 From: theoddone33 <> Date: Tue, 17 Apr 2001 03:06:23 +0000 Subject: [PATCH] Load dialog fixed up, big thanks to relnev Remaining keys fixed in dialog --- zsnes/src/gui/guiload.inc | 10 ++++++ zsnes/src/linux/sdllink.c | 14 ++++----- zsnes/src/linux/winintrf.asm | 39 ++++++++++++------------ zsnes/src/linux/zfilew.c | 59 ++++++++++++++++++++++++------------ zsnes/src/ui.asm | 6 +++- 5 files changed, 81 insertions(+), 47 deletions(-) diff --git a/zsnes/src/gui/guiload.inc b/zsnes/src/gui/guiload.inc index b564dfc8..15be3a09 100644 --- a/zsnes/src/gui/guiload.inc +++ b/zsnes/src/gui/guiload.inc @@ -1076,13 +1076,21 @@ Win95Failed db 0 NEWSYM GetCurDir ; get Drive/Dir +%ifndef __LINUX__ mov ebx,GUIcurrentdir+3 +%else + mov ebx,GUIcurrentdir +%endif mov edx,GUIcurrentdir call Get_Dir + +%ifndef __LINUX__ add byte[GUIcurrentdir],65 mov byte[GUIcurrentdir+1],':' mov byte[GUIcurrentdir+2],'\' +%endif + cmp byte[GUIcurrentdir+35],0 je .nodotend mov byte[GUIcurrentdir+35],'.' @@ -1341,6 +1349,7 @@ GUIGetDirs: je near .sortagain pop edi .nodirs +%ifndef __LINUX__ cmp byte[GUIloadfntype],0 je near .drive2 mov esi,[GUInumentries] @@ -1368,6 +1377,7 @@ GUIGetDirs: dec ecx jnz .nextdriveb .nodrive +%endif ret BubbleSorted db 0 diff --git a/zsnes/src/linux/sdllink.c b/zsnes/src/linux/sdllink.c index 7ad036b6..c2ce2c5b 100644 --- a/zsnes/src/linux/sdllink.c +++ b/zsnes/src/linux/sdllink.c @@ -280,15 +280,15 @@ void ProcessKeyBuf(int scancode) } else { switch (scancode) { // Fix these for proper SDL usage - DDOI - case SDLK_UNDERSCORE: vkeyval='_'; accept=true; break; - case SDLK_PLUS: vkeyval='+'; accept=true; break; + case SDLK_MINUS: vkeyval='_'; accept=true; break; + case SDLK_EQUALS: vkeyval='+'; accept=true; break; case SDLK_LEFTBRACKET: vkeyval='{'; accept=true; break; case SDLK_RIGHTBRACKET: vkeyval='}'; accept=true; break; - case SDLK_COLON: vkeyval=':'; accept=true; break; - case SDLK_QUOTEDBL: vkeyval='"'; accept=true; break; - case SDLK_LESS: vkeyval='<'; accept=true; break; - case SDLK_GREATER: vkeyval='>'; accept=true; break; - case SDLK_QUESTION: vkeyval='?'; accept=true; break; + case SDLK_SEMICOLON: vkeyval=':'; accept=true; break; + case SDLK_QUOTE: vkeyval='"'; accept=true; break; + case SDLK_COMMA: vkeyval='<'; accept=true; break; + case SDLK_PERIOD: vkeyval='>'; accept=true; break; + case SDLK_SLASH: vkeyval='?'; accept=true; break; case SDLK_BACKQUOTE: vkeyval='~'; accept=true; break; case SDLK_BACKSLASH: vkeyval='|'; accept=true; break; } diff --git a/zsnes/src/linux/winintrf.asm b/zsnes/src/linux/winintrf.asm index 2ee51400..45751174 100644 --- a/zsnes/src/linux/winintrf.asm +++ b/zsnes/src/linux/winintrf.asm @@ -846,22 +846,23 @@ NEWSYM Remove_Dir ; mov ebx,LoadDir ; call Change_Dir NEWSYM Change_Dir - pushad + ;pushad - and edx,0FFh - add edx,1 - push edx - call _chdrive - pop edx + ; Not needed for Linux - DDOI + ;and edx,0FFh + ;add edx,1 + ;push edx + ;call _chdrive + ;pop edx ; mov ah,0Eh ; int 21h ; jc .fail - mov dword[CHPath],gotoroot - call ZFileCHDir - or eax,eax - jnz .fail - popad + ;mov dword[CHPath],gotoroot + ;call ZFileCHDir + ;or eax,eax + ;jnz .fail + ;popad mov [CHPath],ebx cmp byte[ebx],0 je .nocdir @@ -903,9 +904,9 @@ NEWSYM Get_Dir call ZFileGetDir mov eax,[DirName] mov ebx,eax - mov ecx,125 + mov ecx,128 .loop - mov dl,[eax+3] + mov dl,[eax] cmp dl,'/' jne .noslash ;mov dl,'\' @@ -914,13 +915,13 @@ NEWSYM Get_Dir inc eax loop .loop popad - push edx - call _getdrive +; push edx +; call _getdrive ; mov ah,19h ; int 21h - sub al,1 - pop edx - mov [edx],al +; sub al,1 +; pop edx +; mov [edx],al ret push edx @@ -1459,7 +1460,7 @@ cpuidtext db 'NOTE: If ZSNES crashes here, then please re-run. ',0 cpuidtext2 db 13,' ',13,0 YesMMX db 'MMX support enabled.',13,10,13,10,0 TempVarSeek dd 0 -gotoroot db '\',0 +gotoroot db '/',0 SECTION .text ; **************************** diff --git a/zsnes/src/linux/zfilew.c b/zsnes/src/linux/zfilew.c index 1d8ce7bb..0e4f952b 100644 --- a/zsnes/src/linux/zfilew.c +++ b/zsnes/src/linux/zfilew.c @@ -24,6 +24,7 @@ #include #include #include +#include #else #include #include @@ -226,9 +227,9 @@ int TempFind; int FindFirstHandle; struct _finddata_t FindDataStruct; #else -struct dirent *next; -DIR *FindFirstHandle; int ignoredirs=0; +glob_t globbuf; +int globcur; #endif DWORD ZFileFindNext() @@ -237,17 +238,32 @@ DWORD ZFileFindNext() //STUB_FUNCTION; struct stat filetype; - next = readdir (FindFirstHandle ); - if ( next == NULL ) return -1; - + if (globcur == -1) + return -1; + + globcur++; + if (globcur > globbuf.gl_pathc) /* >= */ + return -1; + + if (globcur == globbuf.gl_pathc) { + /* this is the end, so just add it ourselves */ + *(char *)(DTALocPos + 0x15) = 0x10; + strcpy((char *)DTALocPos + 0x1E, ".."); + return 0; + } + *(char *)(DTALocPos + 0x15) = 0; - stat ( next->d_name, &filetype ); + stat ( globbuf.gl_pathv[globcur], &filetype ); + if(ZFileFindATTRIB&0x10 && !S_ISDIR ( filetype.st_mode )) return(ZFileFindNext()); if((ZFileFindATTRIB&0x10==0) && S_ISDIR ( filetype.st_mode )) return(ZFileFindNext()); + if ( S_ISDIR ( filetype.st_mode )) *(char *)(DTALocPos + 0x15) = 0x10; - strcpy((char *)DTALocPos + 0x1E, next->d_name); + + strcpy((char *)DTALocPos + 0x1E, globbuf.gl_pathv[globcur]); + #else TempFind=_findnext(FindFirstHandle,&FindDataStruct); if(TempFind==-1) return(-1); @@ -270,26 +286,26 @@ DWORD ZFileFindFirst() //STUB_FUNCTION; struct stat filetype; - FindFirstHandle = opendir ( ZFileFindPATH ); + if (globcur != -1) { + globfree(&globbuf); + globcur = -1; + } + + if (glob(ZFileFindPATH, 0, NULL, &globbuf)) + return -1; + globcur = 0; *(char *)(DTALocPos + 0x15) = 0; - TempFind = 0; - - if ( FindFirstHandle==NULL ) return -1; - - next = readdir ( FindFirstHandle ); - if (next == NULL) return -1; - - stat ( next->d_name, &filetype ); - + stat ( globbuf.gl_pathv[globcur], &filetype ); + if(ZFileFindATTRIB&0x10 && !S_ISDIR ( filetype.st_mode )) return(ZFileFindNext()); if((ZFileFindATTRIB&0x10==0) && S_ISDIR ( filetype.st_mode )) return(ZFileFindNext()); - + if ( S_ISDIR ( filetype.st_mode )) *(char *)(DTALocPos + 0x15) = 0x10; - strcpy ((char *) DTALocPos + 0x1E, next->d_name); + strcpy((char *)DTALocPos + 0x1E, globbuf.gl_pathv[globcur]); #else FindFirstHandle=_findfirst(ZFileFindPATH,&FindDataStruct); @@ -311,7 +327,10 @@ DWORD ZFileFindEnd() // for compatibility with windows later { #ifdef __LINUX__ //STUB_FUNCTION; - closedir(FindFirstHandle); + if (globcur != -1) { + globfree(&globbuf); + globcur = -1; + } #else _findclose(FindFirstHandle); #endif diff --git a/zsnes/src/ui.asm b/zsnes/src/ui.asm index e3eb8a8b..9862aa60 100644 --- a/zsnes/src/ui.asm +++ b/zsnes/src/ui.asm @@ -341,8 +341,12 @@ NEWSYM getcmdline .next2 cmp eax,edi je .nomore + %ifdef __LINUX__ + cmp byte[eax],'/' +%else cmp byte[eax],'\' je .found +%endif cmp byte[eax],':' jne .next .found @@ -493,7 +497,7 @@ NEWSYM getcmdline SECTION .data .string2s db 'CMDLINE',0 -.stringnf db 'SET CMDLINE LINE NOT FOUND!',13,10,0 +.stringnf db 'SET CMDLINE LINE NOT FOUND!',13,0 NEWSYM CMDLineStr, times 256 db 0 NEWSYM GUIFName, times 256 db 0