diff --git a/src/SConscript b/src/SConscript index 3ec2d4e0..d636a5e8 100644 --- a/src/SConscript +++ b/src/SConscript @@ -2,19 +2,14 @@ file_list = Split(""" asm.cpp cart.cpp cheat.cpp -crc32.cpp config.cpp debug.cpp -endian.cpp fceu.cpp fds.cpp file.cpp filter.cpp -general.cpp ines.cpp input.cpp -md5.cpp -memory.cpp netplay.cpp nsf.cpp palette.cpp @@ -26,9 +21,8 @@ video.cpp vsuni.cpp wave.cpp x6502.cpp -xstring.cpp movie.cpp -unzip.c""") +""") subdirs = Split(""" boards @@ -36,6 +30,7 @@ drivers/common drivers/sdl fir input +utils mappers""") #palettes diff --git a/src/asm.cpp b/src/asm.cpp index df4ab57d..ed97968f 100644 --- a/src/asm.cpp +++ b/src/asm.cpp @@ -5,7 +5,7 @@ #include #include #include "types.h" -#include "xstring.h" +#include "utils/xstring.h" #include "debug.h" #include "asm.h" #include "x6502.h" @@ -519,4 +519,4 @@ char *Disassemble(int addr, uint8 *opcode) { } return str; -} \ No newline at end of file +} diff --git a/src/asm.h b/src/asm.h index 0bb3f476..5dff9f32 100644 --- a/src/asm.h +++ b/src/asm.h @@ -1,2 +1,2 @@ int Assemble(unsigned char *output, int addr, char *str); -char *Disassemble(int addr, uint8 *opcode); \ No newline at end of file +char *Disassemble(int addr, uint8 *opcode); diff --git a/src/boards/mapinc.h b/src/boards/mapinc.h index eef1b4a2..92a8291d 100644 --- a/src/boards/mapinc.h +++ b/src/boards/mapinc.h @@ -1,8 +1,8 @@ #include "../types.h" +#include "../utils/memory.h" #include "../x6502.h" #include "../fceu.h" #include "../ppu.h" -#include "../memory.h" #include "../sound.h" #include "../state.h" #include "../cart.h" diff --git a/src/cart.cpp b/src/cart.cpp index 27e3ab1f..47e83c17 100644 --- a/src/cart.cpp +++ b/src/cart.cpp @@ -30,10 +30,11 @@ #include "ppu.h" #include "cart.h" -#include "memory.h" #include "x6502.h" -#include "general.h" +#include "file.h" +#include "utils/memory.h" + uint8 *Page[32],*VPage[8]; uint8 **VPageR=VPage; diff --git a/src/cheat.cpp b/src/cheat.cpp index dbe11610..68913985 100644 --- a/src/cheat.cpp +++ b/src/cheat.cpp @@ -27,7 +27,7 @@ #include "x6502.h" #include "cheat.h" #include "fceu.h" -#include "general.h" +#include "file.h" #include "cart.h" #include "memory.h" diff --git a/src/driver.h b/src/driver.h index 900d29cc..b8d14efa 100644 --- a/src/driver.h +++ b/src/driver.h @@ -315,18 +315,21 @@ void FCEUD_CmdOpen(void); //new merge-era driver routines here: -//signals that the cpu core hit a breakpoint -//this function should not return until the core is ready for the next cycle +///signals that the cpu core hit a breakpoint. this function should not return until the core is ready for the next cycle void FCEUD_DebugBreakpoint(); -//the driver should log the current instruction, if it wants -//(we should move the code in the win driver that does this to the shared area) +///the driver should log the current instruction, if it wants (we should move the code in the win driver that does this to the shared area) void FCEUD_TraceInstruction(); -//the driver might should update its NTView (only used if debugging support is compiled in) +///the driver might should update its NTView (only used if debugging support is compiled in) void FCEUD_UpdateNTView(int scanline, int drawall); -//the driver might should update its PPUView (only used if debugging support is compiled in) +///the driver might should update its PPUView (only used if debugging support is compiled in) void FCEUD_UpdatePPUView(int scanline, int drawall); +#ifdef __cplusplus +extern "C" +#endif +FILE *FCEUI_UTF8fopen_C(const char *n, const char *m); + #endif /* __DRIVER_H_ */ diff --git a/src/drivers/sdl/unix-netplay.cpp b/src/drivers/sdl/unix-netplay.cpp index 18573ec1..7b6970b2 100644 --- a/src/drivers/sdl/unix-netplay.cpp +++ b/src/drivers/sdl/unix-netplay.cpp @@ -45,7 +45,7 @@ #include #endif -#include "../../md5.h" +#include "../../utils/md5.h" #ifndef socklen_t #define socklen_t int diff --git a/src/drivers/win/common.h b/src/drivers/win/common.h index bb3110d6..2012290f 100644 --- a/src/drivers/win/common.h +++ b/src/drivers/win/common.h @@ -14,7 +14,7 @@ #define DIRECTINPUT_VERSION 0x700 //#define FCEUDEF_DEBUGGER //mbg merge 7/17/06 removing conditional compiles #include "../../types.h" -#include "../../general.h" +#include "../../file.h" #include "../../driver.h" #include "../common/vidblit.h" //mbg merge 7/17/06 added #include "../common/config.h" diff --git a/src/drivers/win/debugger.cpp b/src/drivers/win/debugger.cpp index f2f905ca..59bbaa1a 100644 --- a/src/drivers/win/debugger.cpp +++ b/src/drivers/win/debugger.cpp @@ -19,7 +19,7 @@ */ #include "common.h" -#include "..\..\xstring.h" +#include "..\..\utils/xstring.h" #include "debugger.h" #include "..\..\x6502.h" #include "..\..\fceu.h" diff --git a/src/drivers/win/netplay.cpp b/src/drivers/win/netplay.cpp index 6dca8957..a8da2a9b 100644 --- a/src/drivers/win/netplay.cpp +++ b/src/drivers/win/netplay.cpp @@ -19,7 +19,7 @@ */ #include "common.h" -#include "../../md5.h" +#include "../../utils/md5.h" static int recv_tcpwrap(uint8 *buf, int len); static void NetStatAdd(char *text); diff --git a/src/fceu.cpp b/src/fceu.cpp index 067e80ea..8377164e 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -28,9 +28,10 @@ #include "ppu.h" #include "sound.h" #include "netplay.h" -#include "general.h" -#include "endian.h" -#include "memory.h" +#include "file.h" +#include "utils/endian.h" +#include "utils/memory.h" +#include "utils/crc32.h" #include "cart.h" #include "nsf.h" @@ -41,10 +42,9 @@ #include "palette.h" #include "state.h" #include "movie.h" -#include "video.h" +#include "video.h" #include "input.h" #include "file.h" -#include "crc32.h" #include "vsuni.h" @@ -71,7 +71,7 @@ static int RewindStatus[4] = {0, 0, 0, 0}; //is it safe to load rewind state static int RewindIndex = 0; //which rewind state we're on int EnableRewind = 0; //is rewind enabled -//a wrapper for unzip.c +///a wrapper for unzip.c extern "C" FILE *FCEUI_UTF8fopen_C(const char *n, const char *m) { return ::FCEUD_UTF8fopen(n,m); } static DECLFW(BNull) diff --git a/src/fds.cpp b/src/fds.cpp index 3d28bd30..b74df7d7 100644 --- a/src/fds.cpp +++ b/src/fds.cpp @@ -27,12 +27,12 @@ #include "fceu.h" #include "fds.h" #include "sound.h" -#include "general.h" +#include "file.h" +#include "utils/md5.h" +#include "utils/memory.h" #include "state.h" #include "file.h" -#include "memory.h" #include "cart.h" -#include "md5.h" #include "netplay.h" /* TODO: Add code to put a delay in between the time a disk is inserted diff --git a/src/file.cpp b/src/file.cpp index 66cdb6e4..2afdf168 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -21,17 +21,24 @@ #include #include #include -//#include //mbg merge 7/17/06 - removed +#include +#include +#include #include -#include "unzip.h" #include "types.h" #include "file.h" -#include "endian.h" -#include "memory.h" +#include "utils/endian.h" +#include "utils/memory.h" +#include "utils/md5.h" +#include "utils/unzip.h" +#include "driver.h" +#include "types.h" +#include "fceu.h" +#include "state.h" +#include "movie.h" #include "driver.h" -#include "general.h" typedef struct { uint8 *data; @@ -572,3 +579,265 @@ int FCEU_fisarchive(FCEUFILE *fp) return 1; return 0; } + + + +static char BaseDirectory[2048]; +char FileBase[2048]; +static char FileExt[2048]; /* Includes the . character, as in ".nes" */ + +static char FileBaseDirectory[2048]; + +void FCEUI_SetBaseDirectory(char *dir) +{ + strncpy(BaseDirectory,dir,2047); + BaseDirectory[2047]=0; +} + +static char *odirs[FCEUIOD__COUNT]={0,0,0,0,0}; // odirs, odors. ^_^ + +void FCEUI_SetDirOverride(int which, char *n) +{ +// FCEU_PrintError("odirs[%d]=%s->%s", which, odirs[which], n); +if(which < FCEUIOD__COUNT) + odirs[which]=n; + + if(FCEUGameInfo) /* Rebuild cache of present states/movies. */ + { + if(which==FCEUIOD_STATE) + FCEUSS_CheckStates(); + else if(which == FCEUIOD_MISC) + FCEUMOV_CheckMovies(); + } +} + + #ifndef HAVE_ASPRINTF + static int asprintf(char **strp, const char *fmt, ...) + { + va_list ap; + int ret; + + va_start(ap,fmt); + if(!(*strp=(char*)malloc(2048))) //mbg merge 7/17/06 cast to char* + return(0); + ret=vsnprintf(*strp,2048,fmt,ap); + va_end(ap); + return(ret); + } + #endif + +char* FCEU_GetPath(int type) +{ + char *ret=0; + switch(type) + { + case FCEUMKF_STATE:if(odirs[FCEUIOD_STATE]) + ret=strdup(odirs[FCEUIOD_STATE]); + else + asprintf(&ret,"%s"PSS"movie",BaseDirectory); + break; + case FCEUMKF_MOVIE:if(odirs[FCEUIOD_MISC]) + ret=strdup(odirs[FCEUIOD_MISC]); + else + asprintf(&ret,"%s"PSS"movie",BaseDirectory); + break; + } + return(ret); +} + +char *FCEU_MakePath(int type, const char* filebase) +{ + char *ret=0; + + switch(type) + { + case FCEUMKF_MOVIE:if(odirs[FCEUIOD_MISC]) + asprintf(&ret,"%s"PSS"%s",odirs[FCEUIOD_MISC],filebase); + else + asprintf(&ret,"%s"PSS"movie"PSS"%s",BaseDirectory,filebase); + break; + } + return(ret); +} + +char *FCEU_MakeFName(int type, int id1, char *cd1) +{ + char *ret=0; + struct stat tmpstat; + + switch(type) + { + case FCEUMKF_NPTEMP: asprintf(&ret,"%s"PSS"m590plqd94fo.tmp",BaseDirectory);break; + case FCEUMKF_MOVIE:if(id1>=0) + { + if(odirs[FCEUIOD_MISC]) + asprintf(&ret,"%s"PSS"%s.%d.fcm",odirs[FCEUIOD_MISC],FileBase,id1); + else + asprintf(&ret,"%s"PSS"movie"PSS"%s.%d.fcm",BaseDirectory,FileBase,id1); + if(stat(ret,&tmpstat)==-1) + { + if(odirs[FCEUIOD_MISC]) + asprintf(&ret,"%s"PSS"%s.%d.fcm",odirs[FCEUIOD_MISC],FileBase,id1); + else + asprintf(&ret,"%s"PSS"movie"PSS"%s.%d.fcm",BaseDirectory,FileBase,id1); + } + } + else + { + if(odirs[FCEUIOD_MISC]) + asprintf(&ret,"%s"PSS"%s.fcm",odirs[FCEUIOD_MISC],FileBase); + else + asprintf(&ret,"%s"PSS"movie"PSS"%s.fcm",BaseDirectory,FileBase); + } + break; + case FCEUMKF_STATE: + if(odirs[FCEUIOD_STATE]) + { + asprintf(&ret,"%s"PSS"%s.fc%d",odirs[FCEUIOD_STATE],FileBase,id1); + } + else + { + asprintf(&ret,"%s"PSS"fcs"PSS"%s.fc%d",BaseDirectory,FileBase,id1); + } + if(stat(ret,&tmpstat)==-1) + { + if(odirs[FCEUIOD_STATE]) + { + asprintf(&ret,"%s"PSS"%s.fc%d",odirs[FCEUIOD_STATE],FileBase,id1); + } + else + { + asprintf(&ret,"%s"PSS"fcs"PSS"%s.fc%d",BaseDirectory,FileBase,id1); + } + } + break; + case FCEUMKF_SNAP: + if(FSettings.SnapName) + { + if(odirs[FCEUIOD_SNAPS]) + asprintf(&ret,"%s"PSS"%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1); + else + asprintf(&ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory,FileBase,id1,cd1); + } + else + { + if(odirs[FCEUIOD_SNAPS]) + asprintf(&ret,"%s"PSS"%d.%s",odirs[FCEUIOD_SNAPS],id1,cd1); + else + asprintf(&ret,"%s"PSS"snaps"PSS"%d.%s",BaseDirectory,id1,cd1); + } + break; + case FCEUMKF_FDS:if(odirs[FCEUIOD_NV]) + asprintf(&ret,"%s"PSS"%s.fds",odirs[FCEUIOD_NV],FileBase); + else + asprintf(&ret,"%s"PSS"sav"PSS"%s.fds",BaseDirectory,FileBase); + break; + case FCEUMKF_SAV:if(odirs[FCEUIOD_NV]) + asprintf(&ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1); + else + asprintf(&ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1); + if(stat(ret,&tmpstat)==-1) + { + if(odirs[FCEUIOD_NV]) + asprintf(&ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1); + else + asprintf(&ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1); + } + break; + case FCEUMKF_REWINDSTATE: + if(odirs[FCEUIOD_STATE]) + { + asprintf(&ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATE],id1); + } + else + { + asprintf(&ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1); + } + if(stat(ret,&tmpstat)==-1) + { + if(odirs[FCEUIOD_STATE]) + { + asprintf(&ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATE],id1); + } + else + { + asprintf(&ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1); + } + } + break; + case FCEUMKF_CHEAT: + if(odirs[FCEUIOD_CHEATS]) + asprintf(&ret,"%s"PSS"%s.cht",odirs[FCEUIOD_CHEATS],FileBase); + else + asprintf(&ret,"%s"PSS"cheats"PSS"%s.cht",BaseDirectory,FileBase); + break; + case FCEUMKF_IPS: asprintf(&ret,"%s"PSS"%s%s.ips",FileBaseDirectory,FileBase,FileExt); + break; + case FCEUMKF_GGROM:asprintf(&ret,"%s"PSS"gg.rom",BaseDirectory);break; + case FCEUMKF_FDSROM:asprintf(&ret,"%s"PSS"disksys.rom",BaseDirectory);break; + case FCEUMKF_PALETTE: + if(odirs[FCEUIOD_MISC]) + asprintf(&ret,"%s"PSS"%s.pal",odirs[FCEUIOD_MISC],FileBase); + else + asprintf(&ret,"%s"PSS"%s.pal",BaseDirectory,FileBase); + break; + case FCEUMKF_MOVIEGLOB: + if(odirs[FCEUIOD_MISC]) +// asprintf(&ret,"%s"PSS"%s*.fcm",odirs[FCEUIOD_MISC],FileBase); + asprintf(&ret,"%s"PSS"*.???",odirs[FCEUIOD_MISC]); + else +// asprintf(&ret,"%s"PSS"fcs"PSS"%s*.fcm",BaseDirectory,FileBase); + asprintf(&ret,"%s"PSS"movie"PSS"*.???",BaseDirectory); + break; + case FCEUMKF_MOVIEGLOB2: + asprintf(&ret,"%s"PSS"*.???",BaseDirectory); + break; + case FCEUMKF_STATEGLOB: + if(odirs[FCEUIOD_STATE]) + asprintf(&ret,"%s"PSS"%s*.fc?",odirs[FCEUIOD_STATE],FileBase); + else + asprintf(&ret,"%s"PSS"fcs"PSS"%s*.fc?",BaseDirectory,FileBase); + break; + } + return(ret); +} + +void GetFileBase(const char *f) +{ + const char *tp1,*tp3; + + #if PSS_STYLE==4 + tp1=((char *)strrchr(f,':')); + #elif PSS_STYLE==1 + tp1=((char *)strrchr(f,'/')); + #else + tp1=((char *)strrchr(f,'\\')); + #if PSS_STYLE!=3 + tp3=((char *)strrchr(f,'/')); + if(tp1tp1)) + { + memcpy(FileBase,tp1,tp3-tp1); + FileBase[tp3-tp1]=0; + strcpy(FileExt,tp3); + } + else + { + strcpy(FileBase,tp1); + FileExt[0]=0; + } +} \ No newline at end of file diff --git a/src/file.h b/src/file.h index 8d473f9f..afa43b30 100644 --- a/src/file.h +++ b/src/file.h @@ -1,3 +1,6 @@ +#ifndef _FCEU_FILE_H_ +#define _FCEU_FILE_H_ + typedef struct { void *fp; // FILE* or ptr to ZIPWRAP uint32 type; // 0=normal file, 1=gzip, 2=zip @@ -16,3 +19,27 @@ int FCEU_fgetc(FCEUFILE*); uint64 FCEU_fgetsize(FCEUFILE*); int FCEU_fisarchive(FCEUFILE*); + + +void GetFileBase(const char *f); +char* FCEU_GetPath(int type); +char *FCEU_MakePath(int type, const char* filebase); +char *FCEU_MakeFName(int type, int id1, char *cd1); + +#define FCEUMKF_STATE 1 +#define FCEUMKF_SNAP 2 +#define FCEUMKF_SAV 3 +#define FCEUMKF_CHEAT 4 +#define FCEUMKF_FDSROM 5 +#define FCEUMKF_PALETTE 6 +#define FCEUMKF_GGROM 7 +#define FCEUMKF_IPS 8 +#define FCEUMKF_FDS 9 +#define FCEUMKF_MOVIE 10 +#define FCEUMKF_NPTEMP 11 +#define FCEUMKF_MOVIEGLOB 12 +#define FCEUMKF_STATEGLOB 13 +#define FCEUMKF_MOVIEGLOB2 14 +#define FCEUMKF_REWINDSTATE 15 + +#endif diff --git a/src/general.cpp b/src/general.cpp deleted file mode 100644 index c8343429..00000000 --- a/src/general.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include -#include -//#include //mbg merge 7/17/06 - removed - -#include "types.h" -#include "fceu.h" - -#include "general.h" -#include "state.h" -#include "movie.h" - -#include "driver.h" - -#include "md5.h" - -static char BaseDirectory[2048]; -char FileBase[2048]; -static char FileExt[2048]; /* Includes the . character, as in ".nes" */ - -static char FileBaseDirectory[2048]; - -void FCEUI_SetBaseDirectory(char *dir) -{ - strncpy(BaseDirectory,dir,2047); - BaseDirectory[2047]=0; -} - -static char *odirs[FCEUIOD__COUNT]={0,0,0,0,0}; // odirs, odors. ^_^ - -void FCEUI_SetDirOverride(int which, char *n) -{ -// FCEU_PrintError("odirs[%d]=%s->%s", which, odirs[which], n); -if(which < FCEUIOD__COUNT) - odirs[which]=n; - - if(FCEUGameInfo) /* Rebuild cache of present states/movies. */ - { - if(which==FCEUIOD_STATE) - FCEUSS_CheckStates(); - else if(which == FCEUIOD_MISC) - FCEUMOV_CheckMovies(); - } -} - - #ifndef HAVE_ASPRINTF - static int asprintf(char **strp, const char *fmt, ...) - { - va_list ap; - int ret; - - va_start(ap,fmt); - if(!(*strp=(char*)malloc(2048))) //mbg merge 7/17/06 cast to char* - return(0); - ret=vsnprintf(*strp,2048,fmt,ap); - va_end(ap); - return(ret); - } - #endif - -char* FCEU_GetPath(int type) -{ - char *ret=0; - switch(type) - { - case FCEUMKF_STATE:if(odirs[FCEUIOD_STATE]) - ret=strdup(odirs[FCEUIOD_STATE]); - else - asprintf(&ret,"%s"PSS"movie",BaseDirectory); - break; - case FCEUMKF_MOVIE:if(odirs[FCEUIOD_MISC]) - ret=strdup(odirs[FCEUIOD_MISC]); - else - asprintf(&ret,"%s"PSS"movie",BaseDirectory); - break; - } - return(ret); -} - -char *FCEU_MakePath(int type, const char* filebase) -{ - char *ret=0; - - switch(type) - { - case FCEUMKF_MOVIE:if(odirs[FCEUIOD_MISC]) - asprintf(&ret,"%s"PSS"%s",odirs[FCEUIOD_MISC],filebase); - else - asprintf(&ret,"%s"PSS"movie"PSS"%s",BaseDirectory,filebase); - break; - } - return(ret); -} - -char *FCEU_MakeFName(int type, int id1, char *cd1) -{ - char *ret=0; - struct stat tmpstat; - - switch(type) - { - case FCEUMKF_NPTEMP: asprintf(&ret,"%s"PSS"m590plqd94fo.tmp",BaseDirectory);break; - case FCEUMKF_MOVIE:if(id1>=0) - { - if(odirs[FCEUIOD_MISC]) - asprintf(&ret,"%s"PSS"%s.%d.fcm",odirs[FCEUIOD_MISC],FileBase,id1); - else - asprintf(&ret,"%s"PSS"movie"PSS"%s.%d.fcm",BaseDirectory,FileBase,id1); - if(stat(ret,&tmpstat)==-1) - { - if(odirs[FCEUIOD_MISC]) - asprintf(&ret,"%s"PSS"%s.%d.fcm",odirs[FCEUIOD_MISC],FileBase,id1); - else - asprintf(&ret,"%s"PSS"movie"PSS"%s.%d.fcm",BaseDirectory,FileBase,id1); - } - } - else - { - if(odirs[FCEUIOD_MISC]) - asprintf(&ret,"%s"PSS"%s.fcm",odirs[FCEUIOD_MISC],FileBase); - else - asprintf(&ret,"%s"PSS"movie"PSS"%s.fcm",BaseDirectory,FileBase); - } - break; - case FCEUMKF_STATE: - if(odirs[FCEUIOD_STATE]) - { - asprintf(&ret,"%s"PSS"%s.fc%d",odirs[FCEUIOD_STATE],FileBase,id1); - } - else - { - asprintf(&ret,"%s"PSS"fcs"PSS"%s.fc%d",BaseDirectory,FileBase,id1); - } - if(stat(ret,&tmpstat)==-1) - { - if(odirs[FCEUIOD_STATE]) - { - asprintf(&ret,"%s"PSS"%s.fc%d",odirs[FCEUIOD_STATE],FileBase,id1); - } - else - { - asprintf(&ret,"%s"PSS"fcs"PSS"%s.fc%d",BaseDirectory,FileBase,id1); - } - } - break; - case FCEUMKF_SNAP: - if(FSettings.SnapName) - { - if(odirs[FCEUIOD_SNAPS]) - asprintf(&ret,"%s"PSS"%s-%d.%s",odirs[FCEUIOD_SNAPS],FileBase,id1,cd1); - else - asprintf(&ret,"%s"PSS"snaps"PSS"%s-%d.%s",BaseDirectory,FileBase,id1,cd1); - } - else - { - if(odirs[FCEUIOD_SNAPS]) - asprintf(&ret,"%s"PSS"%d.%s",odirs[FCEUIOD_SNAPS],id1,cd1); - else - asprintf(&ret,"%s"PSS"snaps"PSS"%d.%s",BaseDirectory,id1,cd1); - } - break; - case FCEUMKF_FDS:if(odirs[FCEUIOD_NV]) - asprintf(&ret,"%s"PSS"%s.fds",odirs[FCEUIOD_NV],FileBase); - else - asprintf(&ret,"%s"PSS"sav"PSS"%s.fds",BaseDirectory,FileBase); - break; - case FCEUMKF_SAV:if(odirs[FCEUIOD_NV]) - asprintf(&ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1); - else - asprintf(&ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1); - if(stat(ret,&tmpstat)==-1) - { - if(odirs[FCEUIOD_NV]) - asprintf(&ret,"%s"PSS"%s.%s",odirs[FCEUIOD_NV],FileBase,cd1); - else - asprintf(&ret,"%s"PSS"sav"PSS"%s.%s",BaseDirectory,FileBase,cd1); - } - break; - case FCEUMKF_REWINDSTATE: - if(odirs[FCEUIOD_STATE]) - { - asprintf(&ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATE],id1); - } - else - { - asprintf(&ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1); - } - if(stat(ret,&tmpstat)==-1) - { - if(odirs[FCEUIOD_STATE]) - { - asprintf(&ret,"%s"PSS"rewind%d.fcs",odirs[FCEUIOD_STATE],id1); - } - else - { - asprintf(&ret,"%s"PSS"fcs"PSS"rewind%d.fcs",BaseDirectory,id1); - } - } - break; - case FCEUMKF_CHEAT: - if(odirs[FCEUIOD_CHEATS]) - asprintf(&ret,"%s"PSS"%s.cht",odirs[FCEUIOD_CHEATS],FileBase); - else - asprintf(&ret,"%s"PSS"cheats"PSS"%s.cht",BaseDirectory,FileBase); - break; - case FCEUMKF_IPS: asprintf(&ret,"%s"PSS"%s%s.ips",FileBaseDirectory,FileBase,FileExt); - break; - case FCEUMKF_GGROM:asprintf(&ret,"%s"PSS"gg.rom",BaseDirectory);break; - case FCEUMKF_FDSROM:asprintf(&ret,"%s"PSS"disksys.rom",BaseDirectory);break; - case FCEUMKF_PALETTE: - if(odirs[FCEUIOD_MISC]) - asprintf(&ret,"%s"PSS"%s.pal",odirs[FCEUIOD_MISC],FileBase); - else - asprintf(&ret,"%s"PSS"%s.pal",BaseDirectory,FileBase); - break; - case FCEUMKF_MOVIEGLOB: - if(odirs[FCEUIOD_MISC]) -// asprintf(&ret,"%s"PSS"%s*.fcm",odirs[FCEUIOD_MISC],FileBase); - asprintf(&ret,"%s"PSS"*.???",odirs[FCEUIOD_MISC]); - else -// asprintf(&ret,"%s"PSS"fcs"PSS"%s*.fcm",BaseDirectory,FileBase); - asprintf(&ret,"%s"PSS"movie"PSS"*.???",BaseDirectory); - break; - case FCEUMKF_MOVIEGLOB2: - asprintf(&ret,"%s"PSS"*.???",BaseDirectory); - break; - case FCEUMKF_STATEGLOB: - if(odirs[FCEUIOD_STATE]) - asprintf(&ret,"%s"PSS"%s*.fc?",odirs[FCEUIOD_STATE],FileBase); - else - asprintf(&ret,"%s"PSS"fcs"PSS"%s*.fc?",BaseDirectory,FileBase); - break; - } - return(ret); -} - -void GetFileBase(const char *f) -{ - const char *tp1,*tp3; - - #if PSS_STYLE==4 - tp1=((char *)strrchr(f,':')); - #elif PSS_STYLE==1 - tp1=((char *)strrchr(f,'/')); - #else - tp1=((char *)strrchr(f,'\\')); - #if PSS_STYLE!=3 - tp3=((char *)strrchr(f,'/')); - if(tp1tp1)) - { - memcpy(FileBase,tp1,tp3-tp1); - FileBase[tp3-tp1]=0; - strcpy(FileExt,tp3); - } - else - { - strcpy(FileBase,tp1); - FileExt[0]=0; - } -} - -uint32 uppow2(uint32 n) -{ - int x; - - for(x=31;x>=0;x--) - if(n&(1< diff --git a/src/movie.cpp b/src/movie.cpp index aa0393fc..a2578c37 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -7,16 +7,16 @@ #endif #include "types.h" -#include "endian.h" +#include "utils/endian.h" #include "palette.h" #include "input.h" #include "fceu.h" #include "driver.h" #include "state.h" -#include "general.h" +#include "file.h" #include "video.h" #include "movie.h" -#include "memory.h" //mbg merge 7/17/06 added +#include "utils/memory.h" //mbg merge 7/17/06 added #define MOVIE_MAGIC 0x1a4d4346 // FCM\x1a #define MOVIE_VERSION 2 // still at 2 since the format itself is still compatible - to detect which version the movie was made with, check the fceu version stored in the movie header (e.g against FCEU_VERSION_NUMERIC) diff --git a/src/netplay.cpp b/src/netplay.cpp index 61f4dbe5..72623503 100644 --- a/src/netplay.cpp +++ b/src/netplay.cpp @@ -28,13 +28,13 @@ #include #include "types.h" +#include "file.h" +#include "utils/endian.h" #include "netplay.h" -#include "fceu.h" -#include "general.h" +#include "fceu.h" #include "state.h" #include "cheat.h" #include "input.h" -#include "endian.h" int FCEUnetplay=0; diff --git a/src/nsf.cpp b/src/nsf.cpp index c5fe1ccd..ff979f43 100644 --- a/src/nsf.cpp +++ b/src/nsf.cpp @@ -32,8 +32,8 @@ #include "video.h" #include "sound.h" #include "nsf.h" -#include "general.h" -#include "memory.h" +#include "utils/general.h" +#include "utils/memory.h" #include "file.h" #include "fds.h" #include "cart.h" diff --git a/src/palette.cpp b/src/palette.cpp index 3e5b23ce..a73b5f56 100644 --- a/src/palette.cpp +++ b/src/palette.cpp @@ -23,8 +23,8 @@ #include #include "types.h" +#include "file.h" #include "fceu.h" -#include "general.h" #include "driver.h" #include "palette.h" diff --git a/src/ppu.cpp b/src/ppu.cpp index 0b7f4ae8..b2c28db4 100644 --- a/src/ppu.cpp +++ b/src/ppu.cpp @@ -29,9 +29,9 @@ #include "ppu.h" #include "nsf.h" #include "sound.h" -#include "general.h" -#include "endian.h" -#include "memory.h" +#include "file.h" +#include "utils/endian.h" +#include "utils/memory.h" #include "cart.h" #include "palette.h" diff --git a/src/state.cpp b/src/state.cpp index 1a703977..939ccf09 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -30,12 +30,12 @@ #include "x6502.h" #include "fceu.h" #include "sound.h" -#include "endian.h" +#include "utils/endian.h" +#include "utils/memory.h" +#include "file.h" #include "fds.h" -#include "general.h" #include "state.h" #include "movie.h" -#include "memory.h" #include "ppu.h" #include "netplay.h" #include "video.h" diff --git a/src/unif.cpp b/src/unif.cpp index d1642e5c..144f10b8 100644 --- a/src/unif.cpp +++ b/src/unif.cpp @@ -32,13 +32,12 @@ #include "cart.h" #include "unif.h" #include "ines.h" -#include "general.h" +#include "utils/endian.h" +#include "utils/memory.h" +#include "utils/md5.h" #include "state.h" -#include "endian.h" #include "file.h" -#include "memory.h" #include "input.h" -#include "md5.h" typedef struct { char ID[4]; @@ -385,38 +384,38 @@ static BMAPPING bmap[] = { { "CC-21", UNLCC21_Init,0}, - { "H2288", UNLH2288_Init,0}, - { "KOF97", UNLKOF97_Init,0}, - { "SL1632", UNLSL1632_Init,0}, - { "SHERO", UNLSHeroes_Init,0}, - { "8237", UNL8237_Init,0}, - { "8157", UNL8157_Init,0}, - { "T-262", BMCT262_Init,0}, - { "FK23C", BMCFK23C_Init,0}, - { "A65AS", BMCA65AS_Init,0}, - { "C-N22M", UNLCN22M_Init,0}, - { "EDU2000", UNLEDU2000_Init,0}, - { "603-5052", UNL6035052_Init,0}, - { "Supervision16in1", Supervision16_Init,0}, - { "NovelDiamond9999999in1", Novel_Init,0}, - { "Super24in1SC03", Super24_Init,0}, - { "42in1ResetSwitch", BMC42in1r_Init, 0}, - { "64in1NoRepeat", BMC64in1nr_Init, 0}, - { "13in1JY110", BMC13in1JY110_Init, 0}, - { "70in1", BMC70in1_Init, 0}, - { "70in1B", BMC70in1B_Init, 0}, - { "D1038", BMCD1038_Init, 0}, - { "GK-192", BMCGK192_Init, 0}, - { "SuperHIK8in1", Mapper45_Init,0}, - { "22211", UNL22211_Init,0}, - - { "DREAMTECH01", DreamTech01_Init,0}, - { "KONAMI-QTAI", Mapper190_Init,0}, - - { "TEK90", Mapper90_Init,0}, - - {0,0,0} -}; + { "H2288", UNLH2288_Init,0}, + { "KOF97", UNLKOF97_Init,0}, + { "SL1632", UNLSL1632_Init,0}, + { "SHERO", UNLSHeroes_Init,0}, + { "8237", UNL8237_Init,0}, + { "8157", UNL8157_Init,0}, + { "T-262", BMCT262_Init,0}, + { "FK23C", BMCFK23C_Init,0}, + { "A65AS", BMCA65AS_Init,0}, + { "C-N22M", UNLCN22M_Init,0}, + { "EDU2000", UNLEDU2000_Init,0}, + { "603-5052", UNL6035052_Init,0}, + { "Supervision16in1", Supervision16_Init,0}, + { "NovelDiamond9999999in1", Novel_Init,0}, + { "Super24in1SC03", Super24_Init,0}, + { "42in1ResetSwitch", BMC42in1r_Init, 0}, + { "64in1NoRepeat", BMC64in1nr_Init, 0}, + { "13in1JY110", BMC13in1JY110_Init, 0}, + { "70in1", BMC70in1_Init, 0}, + { "70in1B", BMC70in1B_Init, 0}, + { "D1038", BMCD1038_Init, 0}, + { "GK-192", BMCGK192_Init, 0}, + { "SuperHIK8in1", Mapper45_Init,0}, + { "22211", UNL22211_Init,0}, + + { "DREAMTECH01", DreamTech01_Init,0}, + { "KONAMI-QTAI", Mapper190_Init,0}, + + { "TEK90", Mapper90_Init,0}, + + {0,0,0} +}; static BFMAPPING bfunc[] = { { "CTRL", CTRL }, { "TVCI", TVCI }, diff --git a/src/crc32.cpp b/src/utils/crc32.cpp similarity index 94% rename from src/crc32.cpp rename to src/utils/crc32.cpp index df15801e..53ae7e7e 100644 --- a/src/crc32.cpp +++ b/src/utils/crc32.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "types.h" +#include "../types.h" #include "crc32.h" #include diff --git a/src/crc32.h b/src/utils/crc32.h similarity index 100% rename from src/crc32.h rename to src/utils/crc32.h diff --git a/src/endian.cpp b/src/utils/endian.cpp similarity index 95% rename from src/endian.cpp rename to src/utils/endian.cpp index 43c9dcd7..7762721f 100644 --- a/src/endian.cpp +++ b/src/utils/endian.cpp @@ -22,7 +22,7 @@ /// \brief contains file I/O functions that write/read data LSB first. #include -#include "types.h" +#include "../types.h" #include "endian.h" ///endian-flips count bytes. count should be even and nonzero. diff --git a/src/endian.h b/src/utils/endian.h similarity index 100% rename from src/endian.h rename to src/utils/endian.h diff --git a/src/utils/general.cpp b/src/utils/general.cpp new file mode 100644 index 00000000..16d3dd56 --- /dev/null +++ b/src/utils/general.cpp @@ -0,0 +1,39 @@ +/* FCE Ultra - NES/Famicom Emulator + * + * Copyright notice for this file: + * Copyright (C) 2002 Xodnizel + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include "../types.h" + +uint32 uppow2(uint32 n) +{ + int x; + + for(x=31;x>=0;x--) + if(n&(1< -#include "types.h" +#include "../types.h" #include "md5.h" #define GET_UINT32(n,b,i) \ diff --git a/src/md5.h b/src/utils/md5.h similarity index 100% rename from src/md5.h rename to src/utils/md5.h diff --git a/src/memory.cpp b/src/utils/memory.cpp similarity index 92% rename from src/memory.cpp rename to src/utils/memory.cpp index 9e85b742..b8f36a66 100644 --- a/src/memory.cpp +++ b/src/utils/memory.cpp @@ -22,10 +22,9 @@ /// \brief memory management services provided by FCEU core #include -#include "types.h" -#include "fceu.h" +#include "../types.h" +#include "../fceu.h" #include "memory.h" -#include "general.h" ///allocates the specified number of bytes. exits process if this fails void *FCEU_gmalloc(uint32 size) @@ -63,4 +62,4 @@ void FCEU_gfree(void *ptr) void FCEU_free(void *ptr) // Might do something with this and FCEU_malloc later... { free(ptr); -} \ No newline at end of file +} diff --git a/src/memory.h b/src/utils/memory.h similarity index 100% rename from src/memory.h rename to src/utils/memory.h diff --git a/src/unzip.c b/src/utils/unzip.c similarity index 96% rename from src/unzip.c rename to src/utils/unzip.c index 61d2bbfe..d70ba3fa 100644 --- a/src/unzip.c +++ b/src/utils/unzip.c @@ -22,7 +22,7 @@ # include #endif -#include "driver.h" +#include "../driver.h" #ifndef local # define local static diff --git a/src/unzip.h b/src/utils/unzip.h similarity index 100% rename from src/unzip.h rename to src/utils/unzip.h diff --git a/src/xstring.cpp b/src/utils/xstring.cpp similarity index 100% rename from src/xstring.cpp rename to src/utils/xstring.cpp diff --git a/src/xstring.h b/src/utils/xstring.h similarity index 100% rename from src/xstring.h rename to src/utils/xstring.h diff --git a/src/video.cpp b/src/video.cpp index 90323b18..a2bb03d5 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -31,9 +31,9 @@ #include "types.h" #include "video.h" #include "fceu.h" -#include "general.h" -#include "memory.h" -#include "crc32.h" +#include "file.h" +#include "utils/memory.h" +#include "utils/crc32.h" #include "state.h" #include "movie.h" #include "palette.h"