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 ebx,LoadDir
mov edx,LoadDrive mov edx,LoadDrive
call Get_Dir call Get_Dir
%ifndef __LINUX__
cmp byte[cfgloadsdir],0 cmp byte[cfgloadsdir],0
jne .nosdrive jne .nosdrive
mov ebx,SRAMDir mov ebx,SRAMDir
mov edx,SRAMDrive mov edx,SRAMDrive
call Get_Dir call Get_Dir
%endif
.nosdrive .nosdrive
; create .srm header ; create .srm header

View File

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

View File

@@ -451,4 +451,38 @@ int _getdrive( void )
{ {
// STUB_FUNCTION; // 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 #endif

View File

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