Code cleanup. Save location can now be edited in GUI. *nix can now correctly save in a location other than ~/.zsnes

This commit is contained in:
n-a-c-h
2005-01-10 02:21:51 +00:00
parent bcff1629aa
commit 1b62e9286f
16 changed files with 154 additions and 169 deletions

View File

@@ -28,6 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "gblhdr.h" #include "gblhdr.h"
#else #else
#include <string.h> #include <string.h>
#include <unistd.h>
#endif #endif
#define StringA "FRAMESKIP" #define StringA "FRAMESKIP"
@@ -48,8 +49,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define StringI "VIDEOMODEDOS" #define StringI "VIDEOMODEDOS"
#endif #endif
#define StringJ "EXECUTE" #define StringJ "EXECUTE"
/* StringK is unused */
#define StringK "SOUNDBUFDISABLE"
#define StringM "STEREO" #define StringM "STEREO"
#define StringN "GUIDISABLE" #define StringN "GUIDISABLE"
#define StringO "SCANLINES" #define StringO "SCANLINES"
@@ -120,7 +119,6 @@ extern unsigned char cvidmode;
extern unsigned char antienab; extern unsigned char antienab;
extern unsigned char StereoSound; extern unsigned char StereoSound;
extern unsigned int SoundQuality; extern unsigned int SoundQuality;
extern char SRAMDir[512];
extern unsigned char MusicRelVol; extern unsigned char MusicRelVol;
extern unsigned char Force8b; extern unsigned char Force8b;
extern unsigned char scanlines; extern unsigned char scanlines;
@@ -143,13 +141,11 @@ extern unsigned int ZOpenFile(); //Create_File. Open_File
extern unsigned int ZFileWrite(); //Write_File(); extern unsigned int ZFileWrite(); //Write_File();
extern unsigned int ZCloseFile(); //Close_File extern unsigned int ZCloseFile(); //Close_File
#ifdef __LINUX__ #ifdef __LINUX__
/* if TextFile==0, zlib functions aren't used extern char zcfgdir[1024];
useful to save the config file*/
extern char *InitDir; /* 512 unsigned chars */
extern char *InitDrive; /* 2 unsigned chars */
#endif #endif
char SRAMDir[1024];
char LoadDriveB[2]; char LoadDriveB[2];
char LoadDirB[128]; char LoadDirB[128];
@@ -375,7 +371,7 @@ void DOScreatenewcfg()
} }
#ifdef __LINUX__ #ifdef __LINUX__
chdir(SRAMDir); chdir(zcfgdir);
#endif #endif
ZOpenFileName = CMDLineStr; ZOpenFileName = CMDLineStr;
@@ -571,18 +567,7 @@ void DOScreatenewcfg()
WRITE_LINE("; Savefile directory. Leave it blank if you want the save files to be in the\r\n"); WRITE_LINE("; Savefile directory. Leave it blank if you want the save files to be in the\r\n");
WRITE_LINE("; same directory as the games. It should be in a format like : C:\\dir\\dir\r\n\r\n"); WRITE_LINE("; same directory as the games. It should be in a format like : C:\\dir\\dir\r\n\r\n");
if (cfgloadsdir == 1) sprintf(buffer, "SaveDirectory = %s\r\n\r\n", SRAMDir);
{
#ifdef __LINUX__
sprintf(buffer, "SaveDirectory = %s\r\n\r\n", SRAMDir);
#else
sprintf(buffer, "SaveDirectory = %c:\\%s\r\n\r\n", (char) (*SRAMDrive + 65), SRAMDir);
#endif
}
else
{
sprintf(buffer, "SaveDirectory = \r\n\r\n");
}
SAVE_LINE(buffer); SAVE_LINE(buffer);
WRITE_LINE("; Game directory. This is the directory where the GUI starts at.\r\n"); WRITE_LINE("; Game directory. This is the directory where the GUI starts at.\r\n");
@@ -1250,22 +1235,11 @@ void getcfg()
{ {
if (!strcmp(_stringa, StringS)) if (!strcmp(_stringa, StringS))
{ {
if (_strlenb >= 3) if (_strlenb >= 1)
{ {
#ifndef __LINUX__
if (_stringb[1] == ':' && _stringb[2] == '\\')
{
cfgloadsdir = 1;
SRAMDrive[0] = _stringb[0] - 65;
strncpy(SRAMDir, _stringb + 3, _strlenb - 3);
SRAMDir[_strlenb - 3] = '\0';
}
#else
cfgloadsdir = 1; cfgloadsdir = 1;
strncpy(SRAMDir, _stringb, _strlenb); strncpy(SRAMDir, _stringb, _strlenb);
SRAMDir[_strlenb]='\0'; SRAMDir[_strlenb]='\0';
#endif
} }
} }
} }
@@ -1515,3 +1489,23 @@ void getcfg()
DOScreatenewcfg(); DOScreatenewcfg();
} }
} }
unsigned char SRAMChdirFail = 0;
void SRAMChdir()
{
if (!chdir(SRAMDir))
{
SRAMChdirFail = 0;
}
else
{
SRAMChdirFail = 1;
}
}
void SRAMDirCurDir()
{
getcwd(SRAMDir,1024);
}

View File

@@ -54,7 +54,7 @@ EXTSYM nextmenupopup
EXTSYM MovieProcessing EXTSYM MovieProcessing
EXTSYM MovieFileHand, PrintStr EXTSYM MovieFileHand, PrintStr
EXTSYM OSExit,DosExit,InitDir,InitDrive,createnewcfg,fnames,gotoroot,previdmode EXTSYM OSExit,DosExit,InitDir,InitDrive,createnewcfg,fnames,gotoroot,previdmode
EXTSYM ramsize,sfxramdata,setaramdata,SETAEnable,sram,SRAMDrive,SRAMDir,welcome EXTSYM ramsize,sfxramdata,setaramdata,SETAEnable,sram,SRAMChdir,welcome
; EXTSYM tempstore ; EXTSYM tempstore
EXTSYM printhex EXTSYM printhex
%ifdef __MSDOS__ %ifdef __MSDOS__
@@ -1429,9 +1429,9 @@ NEWSYM statesaver
; jmp .skipsaves ; jmp .skipsaves
; Save State ; Save State
%ifdef __LINUX__ %ifdef __LINUX__
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
%endif %endif
mov edx,fnamest+1 mov edx,fnamest+1
call Create_File call Create_File
@@ -1831,9 +1831,9 @@ NEWSYM loadstate
mov byte[multchange],1 mov byte[multchange],1
clim clim
%ifdef __LINUX__ %ifdef __LINUX__
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
%endif %endif
; Get the state number ; Get the state number
mov ebx,[statefileloc] mov ebx,[statefileloc]

View File

@@ -463,10 +463,6 @@ NEWSYM Get_Key
int 21h int 21h
ret ret
; mov dl,[SRAMDrive]
; mov ebx,SRAMDir
; call Change_Dir
NEWSYM Change_Drive NEWSYM Change_Drive
; change to drive in dl (0 = A, 1 = B, etc.) ; change to drive in dl (0 = A, 1 = B, etc.)
mov ah,0Eh mov ah,0Eh

View File

@@ -73,7 +73,7 @@ EXTSYM curblank, vidpastecopyscr, frameskip, newengen, vsyncon
EXTSYM cvidmode, antienab, smallscreenon, smallscreence,NetQuit EXTSYM cvidmode, antienab, smallscreenon, smallscreence,NetQuit
EXTSYM soundon, StereoSound, SoundQuality, MusicRelVol EXTSYM soundon, StereoSound, SoundQuality, MusicRelVol
EXTSYM endprog, continueprog, spcBuffera, spcRamcmp, cbitmode, makepal EXTSYM endprog, continueprog, spcBuffera, spcRamcmp, cbitmode, makepal
EXTSYM t1cc, LoadDir, SRAMDir, LoadDrive,SRAMDrive, initsnes, romloadskip EXTSYM t1cc, LoadDir, LoadDrive, SRAMDir, SRAMChdir, SRAMDirCurDir, initsnes, romloadskip
EXTSYM fname, makeextension, sram, loadfileGUI, GUIloadfailed EXTSYM fname, makeextension, sram, loadfileGUI, GUIloadfailed
EXTSYM SetupROM,CheckROMType, romdata, ForcePal, ramsize, ramsizeand, curromsize EXTSYM SetupROM,CheckROMType, romdata, ForcePal, ramsize, ramsizeand, curromsize
EXTSYM romispal, totlines, cfgloadsdir, init65816, procexecloop EXTSYM romispal, totlines, cfgloadsdir, init65816, procexecloop
@@ -630,7 +630,6 @@ NEWSYM hqFilter, db 0
NEWSYM reserved, db 0 NEWSYM reserved, db 0
NEWSYM scale2xFilter, db 0 NEWSYM scale2xFilter, db 0
NEWSYM st010difficulty, db 0 ; place holder till we commit the other Seta 10 file NEWSYM st010difficulty, db 0 ; place holder till we commit the other Seta 10 file
NEWSYM SRAMPath, times 1024 db 0
NEWSYM SnapPath, times 1024 db 0 NEWSYM SnapPath, times 1024 db 0
NEWSYM SPCPath, times 1024 db 0 NEWSYM SPCPath, times 1024 db 0
NEWSYM BSXPath, times 1024 db 0 NEWSYM BSXPath, times 1024 db 0
@@ -1473,9 +1472,9 @@ SECTION .text
NEWSYM SaveSramData NEWSYM SaveSramData
; change to sram dir ; change to sram dir
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
cmp byte[sramsavedis],1 cmp byte[sramsavedis],1
je .savesramdone je .savesramdone
@@ -1834,9 +1833,9 @@ NEWSYM StartGUI
call SaveSramData call SaveSramData
; change to sram dir ; change to sram dir
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
call GUIQuickLoadUpdate call GUIQuickLoadUpdate
call LoadDetermine call LoadDetermine
@@ -2060,9 +2059,9 @@ NEWSYM StartGUI
cmp byte[CheatWinMode],0 cmp byte[CheatWinMode],0
je near .csskip je near .csskip
; change to sram dir ; change to sram dir
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
; Load Cheat Search File ; Load Cheat Search File
mov edx,cstempfname mov edx,cstempfname
@@ -2488,9 +2487,9 @@ NEWSYM StartGUI
call GUISaveVars call GUISaveVars
; change dir to SRAMDrive/SRAMDir ; change dir to SRAMDrive/SRAMDir
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
mov byte[MousePRClick],1 mov byte[MousePRClick],1
mov byte[prevbright],0 mov byte[prevbright],0
@@ -2587,9 +2586,9 @@ SRAMDirc:
mov edx,LoadDrive mov edx,LoadDrive
call Get_Dir call Get_Dir
; change to sram dir ; change to sram dir
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
ret ret
LOADDir: LOADDir:
@@ -3123,7 +3122,9 @@ MoviePlay:
mov dword[fnamest+ebx-3],'.zmv' mov dword[fnamest+ebx-3],'.zmv'
mov al,[CMovieExt] mov al,[CMovieExt]
mov byte[fnamest+ebx],al mov byte[fnamest+ebx],al
call ChangetoSRAMdir pushad
call SRAMChdir
popad
mov dword[Totalbyteloaded],0 mov dword[Totalbyteloaded],0
call loadstate2 call loadstate2
mov edx,fnamest+1 mov edx,fnamest+1
@@ -3644,14 +3645,6 @@ DisplayBoxes:
.nomore .nomore
ret ret
ChangetoSRAMdir:
mov dl,[SRAMDrive]
mov ebx,SRAMDir
call Change_Dir
ret
ChangetoLOADdir: ChangetoLOADdir:
mov dl,[LoadDrive] mov dl,[LoadDrive]
mov ebx,LoadDir mov ebx,LoadDir
@@ -3671,8 +3664,9 @@ GUIProcStates:
ret ret
.yesstate .yesstate
mov byte[GUICBHold],0 mov byte[GUICBHold],0
; change dir to SRAMDrive/SRAMDir pushad
call ChangetoSRAMdir call SRAMChdir
popad
cmp byte[GUIStatesText5],1 cmp byte[GUIStatesText5],1
je .loadstate je .loadstate
call statesaver call statesaver
@@ -3690,8 +3684,9 @@ GUIProcStates:
ret ret
SaveSecondState: SaveSecondState:
; change dir to SRAMDrive/SRAMDir pushad
call ChangetoSRAMdir call SRAMChdir
popad
mov ebx,[statefileloc] mov ebx,[statefileloc]
mov al,[fnamest+ebx] mov al,[fnamest+ebx]
mov byte[fnamest+ebx],'s' mov byte[fnamest+ebx],'s'
@@ -3704,7 +3699,9 @@ SaveSecondState:
ret ret
LoadSecondState: LoadSecondState:
call ChangetoSRAMdir pushad
call SRAMChdir
popad
mov ebx,[statefileloc] mov ebx,[statefileloc]
mov al,[fnamest+ebx] mov al,[fnamest+ebx]
mov byte[fnamest+ebx],'s' mov byte[fnamest+ebx],'s'

View File

@@ -1651,7 +1651,7 @@ GUIPathKeys:
cmp dword[GUIInputBox],1 cmp dword[GUIInputBox],1
jne .notBox1 jne .notBox1
mov eax,SRAMPath mov eax,SRAMDir
jmp .boxselected jmp .boxselected
.notBox1 .notBox1
cmp dword[GUIInputBox],2 cmp dword[GUIInputBox],2

View File

@@ -248,9 +248,9 @@ GUIloadfilename:
%ifndef __LINUX__ %ifndef __LINUX__
cmp byte[cfgloadsdir],0 cmp byte[cfgloadsdir],0
jne .nosdrive jne .nosdrive
mov ebx,SRAMDir pushad
mov edx,SRAMDrive call SRAMDirCurDir
call Get_Dir popad
%endif %endif
.nosdrive .nosdrive

View File

@@ -58,7 +58,9 @@ MovieRecord:
mov dword[CFWriteStart],64 mov dword[CFWriteStart],64
.nocheckit .nocheckit
mov byte[MovieRecordWinVal],0 mov byte[MovieRecordWinVal],0
call ChangetoSRAMdir pushad
call SRAMChdir
popad
mov byte[NoPictureSave],1 mov byte[NoPictureSave],1
cmp byte[MovieProcessing],0 cmp byte[MovieProcessing],0
jne .nostatesaver jne .nostatesaver

View File

@@ -3241,7 +3241,7 @@ DisplayGUIChipClick
ret ret
DisplayGUIPathsClick DisplayGUIPathsClick
GUITextBoxInputNach 75,15,230,25,1,1024 ;SRAMPath GUITextBoxInputNach 75,15,230,25,1,1024 ;SRAMDir
GUITextBoxInputNach 75,35,230,45,2,1024 ;SnapPath GUITextBoxInputNach 75,35,230,45,2,1024 ;SnapPath
GUITextBoxInputNach 75,55,230,65,3,1024 ;SPCPath GUITextBoxInputNach 75,55,230,65,3,1024 ;SPCPath
GUITextBoxInputNach 8,95,100,105,4,1024 ;BSXPath GUITextBoxInputNach 8,95,100,105,4,1024 ;BSXPath

View File

@@ -1661,7 +1661,9 @@ NetLoadStuff:
mov al,[NetStateSize+2] mov al,[NetStateSize+2]
call RemoteSendChar call RemoteSendChar
call SendPacket call SendPacket
call ChangetoSRAMdir pushad
call SRAMChdir
popad
mov edx,fnamest+1 mov edx,fnamest+1
call Open_File call Open_File
mov [NetLoadHandle],ax mov [NetLoadHandle],ax
@@ -1690,7 +1692,9 @@ loadstaterecvinit:
cmp dh,0 cmp dh,0
je .noreceive2 je .noreceive2
mov [NetStateSize+2],dl mov [NetStateSize+2],dl
call ChangetoSRAMdir pushad
call SRAMChdir
popad
mov edx,Netfname mov edx,Netfname
call Create_File call Create_File
mov edx,[NetStateSize] mov edx,[NetStateSize]
@@ -1827,7 +1831,9 @@ loadstaterecv:
pushad pushad
mov bx,[NetLoadHandle] mov bx,[NetLoadHandle]
call Close_File call Close_File
call ChangetoSRAMdir pushad
call SRAMChdir
popad
mov edx,Netfname mov edx,Netfname
mov byte[RestoreValues],0 mov byte[RestoreValues],0
call loadstate3 call loadstate3

View File

@@ -6322,7 +6322,7 @@ BlinkCursorCheck:
.checkboxes .checkboxes
cmp dword[GUIInputBox],1 cmp dword[GUIInputBox],1
jne .notBox1 jne .notBox1
mov ebx,SRAMPath mov ebx,SRAMDir
ret ret
.notBox1 .notBox1
cmp dword[GUIInputBox],2 cmp dword[GUIInputBox],2
@@ -6380,7 +6380,7 @@ BlinkCursorCheck:
DisplayGUIPaths: DisplayGUIPaths:
GUIDrawWindowBox 19,GUIPathsDisp GUIDrawWindowBox 19,GUIPathsDisp
sub byte[GUItextcolor],15 sub byte[GUItextcolor],15
;GUIOuttextwin2 19,8,18,GUIPathsText1 GUIOuttextwin2 19,8,18,GUIPathsText1
GUIOuttextwin2 19,8,38,GUIPathsText2 GUIOuttextwin2 19,8,38,GUIPathsText2
GUIOuttextwin2 19,8,58,GUIPathsText3 GUIOuttextwin2 19,8,58,GUIPathsText3
GUIOuttextwin2 19,60,78,GUIPathsText4 GUIOuttextwin2 19,60,78,GUIPathsText4
@@ -6395,7 +6395,7 @@ DisplayGUIPaths:
GUIOuttextwin2 19,135,173,GUIPathsTextD GUIOuttextwin2 19,135,173,GUIPathsTextD
add byte[GUItextcolor],15 add byte[GUItextcolor],15
;GUIOuttextwin2 19,7,17,GUIPathsText1 GUIOuttextwin2 19,7,17,GUIPathsText1
GUIOuttextwin2 19,7,37,GUIPathsText2 GUIOuttextwin2 19,7,37,GUIPathsText2
GUIOuttextwin2 19,7,57,GUIPathsText3 GUIOuttextwin2 19,7,57,GUIPathsText3
GUIOuttextwin2 19,59,77,GUIPathsText4 GUIOuttextwin2 19,59,77,GUIPathsText4
@@ -6410,7 +6410,7 @@ DisplayGUIPaths:
GUIOuttextwin2 19,134,172,GUIPathsTextD GUIOuttextwin2 19,134,172,GUIPathsTextD
;Input boxes - alternate color ;Input boxes - alternate color
;DrawGUIWinBox 19,74,14,232,26,177 DrawGUIWinBox 19,74,14,232,26,177
DrawGUIWinBox 19,74,34,232,46,177 DrawGUIWinBox 19,74,34,232,46,177
DrawGUIWinBox 19,74,54,232,66,177 DrawGUIWinBox 19,74,54,232,66,177
DrawGUIWinBox 19,7,94,107,106,177 DrawGUIWinBox 19,7,94,107,106,177
@@ -6423,7 +6423,7 @@ DisplayGUIPaths:
DrawGUIWinBox 19,134,179,236,191,177 DrawGUIWinBox 19,134,179,236,191,177
;Input boxes ;Input boxes
;DrawGUIWinBox 19,75,15,231,25,167 DrawGUIWinBox 19,75,15,231,25,167
DrawGUIWinBox 19,75,35,231,45,167 DrawGUIWinBox 19,75,35,231,45,167
DrawGUIWinBox 19,75,55,231,65,167 DrawGUIWinBox 19,75,55,231,65,167
DrawGUIWinBox 19,8,95,106,105,167 DrawGUIWinBox 19,8,95,106,105,167
@@ -6435,7 +6435,7 @@ DisplayGUIPaths:
DrawGUIWinBox 19,135,155,235,165,167 DrawGUIWinBox 19,135,155,235,165,167
DrawGUIWinBox 19,135,180,235,190,167 DrawGUIWinBox 19,135,180,235,190,167
;GUIOuttextwin2d 19,77,19,SRAMPath,25 GUIOuttextwin2d 19,77,19,SRAMDir,25
GUIOuttextwin2d 19,77,39,SnapPath,25 GUIOuttextwin2d 19,77,39,SnapPath,25
GUIOuttextwin2d 19,77,59,SPCPath,25 GUIOuttextwin2d 19,77,59,SPCPath,25
GUIOuttextwin2d 19,10,99,BSXPath,15 GUIOuttextwin2d 19,10,99,BSXPath,15

View File

@@ -38,7 +38,7 @@ EXTSYM Clear2xSaIBuffer
EXTSYM romdata,romtype,ScreenShotFormat EXTSYM romdata,romtype,ScreenShotFormat
EXTSYM Voice0Disable,Voice1Disable,Voice2Disable,Voice3Disable EXTSYM Voice0Disable,Voice1Disable,Voice2Disable,Voice3Disable
EXTSYM Voice4Disable,Voice5Disable,Voice6Disable,Voice7Disable EXTSYM Voice4Disable,Voice5Disable,Voice6Disable,Voice7Disable
EXTSYM SRAMDrive, SRAMDir, SPCPath, SnapPath, Change_Dir, CHPath, ZFileCHDir EXTSYM SRAMChdir, SPCPath, SnapPath, Change_Dir, CHPath, ZFileCHDir
%ifndef NO_PNG %ifndef NO_PNG
EXTSYM Grab_PNG_Data EXTSYM Grab_PNG_Data
%endif %endif
@@ -56,9 +56,7 @@ EXTSYM Grab_PNG_Data
%macro ChangeDirSRAM 0 %macro ChangeDirSRAM 0
pushad pushad
mov dl,[SRAMDrive] call SRAMChdir
mov ebx,SRAMDir
call Change_Dir
popad popad
%endmacro %endmacro

View File

@@ -29,7 +29,7 @@ EXTSYM MovieFileHand,filefound,inittable,SA1inittable
EXTSYM MessageOn,Msgptr,MsgCount,sndrot,GenerateBank0Table,SnowTimer EXTSYM MessageOn,Msgptr,MsgCount,sndrot,GenerateBank0Table,SnowTimer
EXTSYM inittableb,inittablec,newgfx16b,cfgreinittime,EndMessage EXTSYM inittableb,inittablec,newgfx16b,cfgreinittime,EndMessage
EXTSYM Open_File,Read_File,Write_File,Close_File,Output_Text,Get_Key,CNetType EXTSYM Open_File,Read_File,Write_File,Close_File,Output_Text,Get_Key,CNetType
EXTSYM Delete_File,Get_First_Entry,Get_Next_Entry,Change_Dir,Get_Dir,InitDSP EXTSYM Delete_File,Get_First_Entry,Get_Next_Entry,Change_Dir,InitDSP
EXTSYM Remove_Dir,Change_Single_Dir,Create_Dir,Get_Memfree,Create_File EXTSYM Remove_Dir,Change_Single_Dir,Create_Dir,Get_Memfree,Create_File
EXTSYM SPCDisable,osm2dis,CurRecv,BackupSystemVars EXTSYM SPCDisable,osm2dis,CurRecv,BackupSystemVars
EXTSYM SnowData,SnowVelDist EXTSYM SnowData,SnowVelDist
@@ -93,7 +93,7 @@ EXTSYM GUIcurrentdir,PrintStr
;EXTSYM GUIcurrentdir, PrintStr ;EXTSYM GUIcurrentdir, PrintStr
EXTSYM DTALoc EXTSYM DTALoc
EXTSYM spc7110romptr,allocspc7110 EXTSYM spc7110romptr,allocspc7110
EXTSYM SRAMDir,SRAMDrive,cfgloadsdir,fnamest,statefileloc EXTSYM SRAMChdir,cfgloadsdir,fnamest,statefileloc
EXTSYM ForcePal,ForceROMTiming,ForceHiLoROM,InitDir,InitDrive,enterpress,frameskip EXTSYM ForcePal,ForceROMTiming,ForceHiLoROM,InitDir,InitDrive,enterpress,frameskip
EXTSYM maxromspace,curromspace,infoloc, patchfile EXTSYM maxromspace,curromspace,infoloc, patchfile
EXTSYM gotoroot,headdata,printnum,romispal EXTSYM gotoroot,headdata,printnum,romispal
@@ -2722,9 +2722,9 @@ NEWSYM loadfileGUI
mov byte[SramExists],0 mov byte[SramExists],0
; change to sram dir ; change to sram dir
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
; open .srm file ; open .srm file
mov edx,fnames+1 mov edx,fnames+1
@@ -2880,9 +2880,9 @@ NEWSYM convertsram
jne .next2b jne .next2b
.nocutoffb .nocutoffb
; change to sram directory ; change to sram directory
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
ret ret
SECTION .data SECTION .data

View File

@@ -24,14 +24,14 @@
EXTSYM DosExit,ZFileSystemInit EXTSYM DosExit,ZFileSystemInit
EXTSYM getcmdline,GUIRestoreVars,getcfg,obtaindir,ConvertJoyMap,tparms EXTSYM getcmdline,GUIRestoreVars,getcfg,obtaindir,ConvertJoyMap,tparms
EXTSYM preparedir,SBHDMA EXTSYM SBHDMA
EXTSYM ccmdline EXTSYM ccmdline
EXTSYM FilenameStart EXTSYM FilenameStart
EXTSYM spcon EXTSYM spcon
EXTSYM cfgsoundon EXTSYM cfgsoundon
EXTSYM cfgcvidmode EXTSYM cfgcvidmode
EXTSYM pl1contrl,pl2contrl EXTSYM pl1contrl,pl2contrl
EXTSYM InitDir,InitDrive, SRAMDir, SRAMDrive EXTSYM InitDir,InitDrive,SRAMChdir
EXTSYM DOScreatenewcfg,ExecGUISaveVars EXTSYM DOScreatenewcfg,ExecGUISaveVars
EXTSYM allocptr EXTSYM allocptr
EXTSYM putchar EXTSYM putchar
@@ -182,9 +182,9 @@ NEWSYM SystemInit
mov edx,InitDrive mov edx,InitDrive
call Get_Dir call Get_Dir
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
%else %else
mov ebx,InitDir mov ebx,InitDir
mov edx,InitDrive mov edx,InitDrive
@@ -205,17 +205,10 @@ NEWSYM SystemInit
call ConvertJoyMap ; Mini joystick init call ConvertJoyMap ; Mini joystick init
call ccmdline call ccmdline
call tparms call tparms
%ifndef __LINUX__ pushad
call preparedir call SRAMChdir
%else popad
mov ebx,SRAMDir
call Change_Dir
%endif
; call getblaster ; get set blaster environment
; cmp byte[Force8b],1
; jne .noforce8b
mov byte[SBHDMA],1 mov byte[SBHDMA],1
;.noforce8b
pop es pop es
ret ret

View File

@@ -269,10 +269,6 @@ DWORD ZFileMKDir()
#endif #endif
} }
extern char SRAMDir;
extern char InitDir;
extern char LoadDir;
DWORD ZFileCHDir() DWORD ZFileCHDir()
{ {
@@ -464,39 +460,46 @@ DWORD GetDate()
return(value); return(value);
} }
extern char SRAMDir[1024];
extern char LoadDir[512];
#ifdef __LINUX__ #ifdef __LINUX__
char zcfgdir[1024];
#define ZCFG_DIR "/.zsnes"
#define ZCFG_DIR_LEN (1023-strlen(ZCFG_DIR))
void obtaindir() void obtaindir()
{ {
char *cfgdir = NULL; char *homedir = 0;
char *homedir = NULL; DIR *tmp;
DIR *tmp;
if ((homedir = (char *)getenv("HOME"))==NULL) { if ((homedir = (char *)getenv("HOME")) == 0)
homedir = (char *)malloc(128); {
getcwd(homedir, 128); homedir = (char *)malloc(ZCFG_DIR_LEN);
} getcwd(homedir, ZCFG_DIR_LEN);
cfgdir = (char *)malloc(strlen(homedir)+strlen("/.zsnes")+1); }
strcpy(cfgdir, homedir); strcpy(zcfgdir, homedir);
free(homedir); free(homedir);
strcat(cfgdir, "/.zsnes"); strcat(zcfgdir, ZCFG_DIR);
tmp = opendir(cfgdir); tmp = opendir(zcfgdir);
if (tmp == NULL) { if (tmp == NULL)
MKPath = cfgdir; {
ZFileMKDir(); MKPath = zcfgdir;
} else { ZFileMKDir();
closedir(tmp); }
} else
// strcpy(&InitDir, cfgdir); {
// getcwd(&InitDir, 128); closedir(tmp);
if (SRAMDir == 0){ }
strcpy(&SRAMDir, cfgdir); if (*SRAMDir == 0)
} {
free(cfgdir); strcpy(SRAMDir, zcfgdir);
if (LoadDir == 0) { }
getcwd(&LoadDir, 128); if (*LoadDir == 0)
} {
getcwd(LoadDir, 512);
}
} }
extern char fnamest, fnames; extern char fnamest, fnames;

View File

@@ -40,6 +40,8 @@ EXTSYM romloadskip
EXTSYM cfgloadgdir,cfgloadsdir EXTSYM cfgloadgdir,cfgloadsdir
EXTSYM init18_2hz EXTSYM init18_2hz
EXTSYM OSExit,GUIOn2 EXTSYM OSExit,GUIOn2
EXTSYM SRAMDirCurDir,SRAMChdir,SRAMChdirFail
%ifdef __LINUX__ %ifdef __LINUX__
EXTSYM LinuxExit EXTSYM LinuxExit
EXTSYM GetFilename EXTSYM GetFilename
@@ -921,9 +923,9 @@ NEWSYM makeextension
ret ret
.latestsave .latestsave
; change dir to Save Dir ; change dir to Save Dir
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
call DetermineNewest call DetermineNewest
@@ -1157,9 +1159,9 @@ SECTION .text
NEWSYM obtaindir NEWSYM obtaindir
cmp byte[cfgloadsdir],1 cmp byte[cfgloadsdir],1
je .nosdriveb je .nosdriveb
mov ebx,SRAMDir pushad
mov edx,SRAMDrive call SRAMDirCurDir
call Get_Dir popad
.nosdriveb .nosdriveb
cmp byte[cfgloadgdir],1 cmp byte[cfgloadgdir],1
je .noldriveb je .noldriveb
@@ -1185,21 +1187,21 @@ NEWSYM preparedir
je near .nosdrivec je near .nosdrivec
; verify sram drive/directory exists ; verify sram drive/directory exists
; change dir to SRAMDrive/SRAMDir ; change dir to SRAMDrive/SRAMDir
mov dl,[SRAMDrive] pushad
mov ebx,SRAMDir call SRAMChdir
call Change_Dir popad
jc .sramerror cmp byte[SRAMChdirFail],0
jmp .yessdrive je .yessdrive
.sramerror
mov dl,[InitDrive] mov dl,[InitDrive]
mov ebx,InitDir mov ebx,InitDir
call Change_Dir call Change_Dir
mov byte[cfgloadsdir],0 mov byte[cfgloadsdir],0
; Get drive/dir ; Get drive/dir
mov ebx,SRAMDir pushad
mov edx,SRAMDrive call SRAMDirCurDir
call Get_Dir popad
mov edx,.sramerrorm mov edx,.sramerrorm
call PrintStr call PrintStr
@@ -1227,7 +1229,6 @@ SECTION .data
.enter db 13,10,0 .enter db 13,10,0
NEWSYM InitDrive, db 2 NEWSYM InitDrive, db 2
NEWSYM SRAMDrive, db 2
NEWSYM LoadDrive, db 2 NEWSYM LoadDrive, db 2
%ifdef __LINUX__ %ifdef __LINUX__
@@ -1238,7 +1239,6 @@ NEWSYM gotoroot, db '\',0
SECTION .bss SECTION .bss
NEWSYM InitDir, resb 512 NEWSYM InitDir, resb 512
NEWSYM SRAMDir, resb 512
NEWSYM LoadDir, resb 512 NEWSYM LoadDir, resb 512
SECTION .text SECTION .text

View File

@@ -688,10 +688,6 @@ KeyConvTableS
db 208,209,210,211,255,255,255,255 ; 50h db 208,209,210,211,255,255,255,255 ; 50h
SECTION .text SECTION .text
; mov dl,[SRAMDrive]
; mov ebx,SRAMDir
; call Change_Dir
NEWSYM Change_Drive NEWSYM Change_Drive
; change to drive in dl (0 = A, 1 = B, etc.) ; change to drive in dl (0 = A, 1 = B, etc.)
and edx,0FFh and edx,0FFh