Config files and save states are now stored in ~/.zsnes

This commit is contained in:
teuf
2001-04-22 17:49:49 +00:00
parent 23742cd694
commit 26dc931297
5 changed files with 116 additions and 2 deletions

View File

@@ -241,11 +241,13 @@ GUIloadfilename:
mov ebx,LoadDir
mov edx,LoadDrive
call Get_Dir
%ifndef __LINUX__
cmp byte[cfgloadsdir],0
jne .nosdrive
mov ebx,SRAMDir
mov edx,SRAMDrive
call Get_Dir
%endif
.nosdrive
; create .srm header

View File

@@ -20,6 +20,7 @@
EXTSYM dssel, selcA000, selcB800, selc0040, previdmode, DosExit, ZFileSystemInit
EXTSYM getcmdline,GUIRestoreVars,getcfg,obtaindir,ConvertJoyMap,tparms
EXTSYM preparedir,getblaster,Force8b,SBHDMA
EXTSYM SRAMDir
EXTSYM ccmdline
EXTSYM FilenameStart
EXTSYM spcon
@@ -249,20 +250,33 @@ NEWSYM SystemInit
mov byte[cfgsoundon],1
; Get and set the initial directory
%ifdef __LINUX__
call obtaindir
%else
mov ebx,InitDir
mov edx,InitDrive
call Get_Dir
%endif
mov dl,[InitDrive]
mov ebx,InitDir
call Change_Dir
call GUIRestoreVars ; Load GUI stuff
call getcfg ; Load cfg stuff
call obtaindir ; Get Save/Init Directories
call ConvertJoyMap ; Mini joystick init
call ccmdline
call tparms
%ifndef __LINUX__
call preparedir
%else
mov ebx,SRAMDir
call Change_Dir
%endif
mov byte[soundon],0
; call getblaster ; get set blaster environment
; cmp byte[Force8b],1

View File

@@ -451,4 +451,38 @@ int _getdrive( void )
{
// STUB_FUNCTION;
}
extern char SRAMDir;
extern char InitDir;
extern char LoadDir;
void obtaindir()
{
char *cfgdir = NULL;
char *homedir = NULL;
DIR *tmp;
if ((homedir = (char *)getenv("HOME"))==NULL) {
homedir = (char *)malloc(128);
getcwd(homedir, 128);
}
cfgdir = (char *)malloc(strlen(homedir)+strlen("/.zsnes"));
strcpy(cfgdir, homedir);
strcat(cfgdir, "/.zsnes");
tmp = opendir(cfgdir);
if (tmp == NULL) {
MKPath = cfgdir;
ZFileMKDir();
} else {
closedir(tmp);
}
strcpy(&InitDir, cfgdir);
if (SRAMDir == 0){
strcpy(&SRAMDir, cfgdir);
}
free(cfgdir);
if (LoadDir == 0) {
getcwd(&LoadDir, 128);
}
}
#endif

View File

@@ -102,3 +102,65 @@ call fflush
add esp, 20
popad
%endmacro
; same as above but prints the string
; whose address is the argument to the macros
%macro STUB_ASM_STR 1
%ifndef __PRINTF__
%define __PRINTF__
EXTSYM printf
EXTSYM fflush
EXTSYM stdout
%endif
[section .data]
%%strformat: db '%s in %s line %u',13, 10,0
%%filename: db __FILE__, 0
__SECT__
;stubasm:
pushad
mov eax, __LINE__
push eax
mov eax, %%filename
push eax
mov eax, %1
push eax
mov eax, %%strformat
push eax
call printf
mov eax, [stdout]
push eax
call fflush
add esp, 20
popad
%endmacro
; same as above but prints a number
%macro STUB_ASM_INT 1
%ifndef __PRINTF__
%define __PRINTF__
EXTSYM printf
EXTSYM fflush
EXTSYM stdout
%endif
[section .data]
%%strformat: db '%x in %s line %u',13, 10,0
%%filename: db __FILE__, 0
__SECT__
;stubasm:
pushad
mov eax, __LINE__
push eax
mov eax, %%filename
push eax
mov eax, %1
push eax
mov eax, %%strformat
push eax
call printf
mov eax, [stdout]
push eax
call fflush
add esp, 20
popad
%endmacro

View File

@@ -1369,8 +1369,8 @@ SECTION .data
SECTION .text
NEWSYM obtaindir
%ifndef __LINUX__
NEWSYM obtaindir
cmp byte[cfgloadsdir],1
je .nosdriveb
mov ebx,SRAMDir
@@ -1383,8 +1383,9 @@ NEWSYM obtaindir
mov edx,LoadDrive
call Get_Dir
.noldriveb
%endif
ret
%endif
NEWSYM preparedir
;Function 47h - Get current directory
@@ -1435,6 +1436,7 @@ NEWSYM preparedir
%endif
ret
SECTION .data
.sramerrorm db 'Invalid SRAM Directory in ZSNES.CFG!',13,10,13,10
db 'Press any key to continue.',0