diff --git a/zsnes/src/gui/guiload.inc b/zsnes/src/gui/guiload.inc index 37b414e6..96c20655 100644 --- a/zsnes/src/gui/guiload.inc +++ b/zsnes/src/gui/guiload.inc @@ -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 diff --git a/zsnes/src/linux/winintrf.asm b/zsnes/src/linux/winintrf.asm index eb1aa540..814407bf 100644 --- a/zsnes/src/linux/winintrf.asm +++ b/zsnes/src/linux/winintrf.asm @@ -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 diff --git a/zsnes/src/linux/zfilew.c b/zsnes/src/linux/zfilew.c index b2728074..f0e997bc 100644 --- a/zsnes/src/linux/zfilew.c +++ b/zsnes/src/linux/zfilew.c @@ -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 diff --git a/zsnes/src/macros.mac b/zsnes/src/macros.mac index 7026c96e..eba9ac69 100644 --- a/zsnes/src/macros.mac +++ b/zsnes/src/macros.mac @@ -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 diff --git a/zsnes/src/ui.asm b/zsnes/src/ui.asm index 7ef7c434..d6017804 100644 --- a/zsnes/src/ui.asm +++ b/zsnes/src/ui.asm @@ -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