Some minimal fixes and clean-ups.
This commit is contained in:
parent
153a3d6f23
commit
ce8c18789f
|
@ -357,47 +357,51 @@ void SaveStrippedRom(){ //this is based off of iNesSave()
|
|||
|
||||
fp = fopen(sromfilename,"wb");
|
||||
|
||||
if(GameInfo->type==GIT_NSF)
|
||||
{
|
||||
//Not used because if bankswitching, the addresses involved
|
||||
//could still end up being used through writes
|
||||
//static uint16 LoadAddr;
|
||||
//LoadAddr=NSFHeader.LoadAddressLow;
|
||||
//LoadAddr|=(NSFHeader.LoadAddressHigh&0x7F)<<8;
|
||||
|
||||
//Simple store/restore for writing a working NSF header
|
||||
NSFLoadLow = NSFHeader.LoadAddressLow;
|
||||
NSFLoadHigh = NSFHeader.LoadAddressHigh;
|
||||
NSFHeader.LoadAddressLow=0;
|
||||
NSFHeader.LoadAddressHigh&=0xF0;
|
||||
fwrite(&NSFHeader,1,0x8,fp);
|
||||
NSFHeader.LoadAddressLow = NSFLoadLow;
|
||||
NSFHeader.LoadAddressHigh = NSFLoadHigh;
|
||||
|
||||
fseek(fp,0x8,SEEK_SET);
|
||||
for(i = 0;i < ((NSFMaxBank+1)*4096);i++){
|
||||
if(cdloggerdata[i] & 3)fputc(NSFDATA[i],fp);
|
||||
else fputc(0,fp);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fwrite(&head,1,16,fp)!=16)return;
|
||||
|
||||
if(head.ROM_type&4) /* Trainer */
|
||||
if(GameInfo->type==GIT_NSF)
|
||||
{
|
||||
fwrite(trainerpoo,512,1,fp);
|
||||
}
|
||||
//Not used because if bankswitching, the addresses involved
|
||||
//could still end up being used through writes
|
||||
//static uint16 LoadAddr;
|
||||
//LoadAddr=NSFHeader.LoadAddressLow;
|
||||
//LoadAddr|=(NSFHeader.LoadAddressHigh&0x7F)<<8;
|
||||
|
||||
//Simple store/restore for writing a working NSF header
|
||||
NSFLoadLow = NSFHeader.LoadAddressLow;
|
||||
NSFLoadHigh = NSFHeader.LoadAddressHigh;
|
||||
NSFHeader.LoadAddressLow=0;
|
||||
NSFHeader.LoadAddressHigh&=0xF0;
|
||||
fwrite(&NSFHeader,1,0x8,fp);
|
||||
NSFHeader.LoadAddressLow = NSFLoadLow;
|
||||
NSFHeader.LoadAddressHigh = NSFLoadHigh;
|
||||
|
||||
fseek(fp,0x8,SEEK_SET);
|
||||
for(i = 0;i < ((NSFMaxBank+1)*4096);i++){
|
||||
if(cdloggerdata[i] & 3)fputc(NSFDATA[i],fp);
|
||||
else fputc(0,fp);
|
||||
}
|
||||
|
||||
for(i = 0;i < head.ROM_size*0x4000;i++){
|
||||
if(cdloggerdata[i] & 3)fputc(ROM[i],fp);
|
||||
else fputc(0,fp);
|
||||
}
|
||||
//fwrite(ROM,0x4000,head.ROM_size,fp);
|
||||
else
|
||||
{
|
||||
if(fwrite(&head,1,16,fp)!=16)
|
||||
{
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(head.VROM_size)fwrite(VROM,0x2000,head.VROM_size,fp);
|
||||
}
|
||||
if(head.ROM_type&4) /* Trainer */
|
||||
{
|
||||
fwrite(trainerpoo,512,1,fp);
|
||||
}
|
||||
|
||||
for(i = 0;i < head.ROM_size*0x4000;i++){
|
||||
if(cdloggerdata[i] & 3)fputc(ROM[i],fp);
|
||||
else fputc(0,fp);
|
||||
}
|
||||
//fwrite(ROM,0x4000,head.ROM_size,fp);
|
||||
|
||||
if(head.VROM_size)fwrite(VROM,0x2000,head.VROM_size,fp);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
|
|
@ -585,8 +585,8 @@ BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
ArchiveScanRecord asr = FCEUD_ScanArchive(filename);
|
||||
if(!asr.isArchive()) {
|
||||
FCEUFILE* fp = FCEU_fopen(filename,0,"rb",0);
|
||||
fp->stream = fp->stream->memwrap();
|
||||
if(fp) {
|
||||
fp->stream = fp->stream->memwrap();
|
||||
HandleScan(hwndDlg,fp ,items);
|
||||
delete fp;
|
||||
}
|
||||
|
@ -787,11 +787,11 @@ static void UpdateRecordDialog(HWND hwndDlg)
|
|||
|
||||
static void UpdateRecordDialogPath(HWND hwndDlg, const std::string &fname)
|
||||
{
|
||||
char* baseMovieDir = strdup(FCEU_GetPath(FCEUMKF_MOVIE).c_str());
|
||||
const std::string &baseMovieDir = FCEU_GetPath(FCEUMKF_MOVIE);
|
||||
char* fn=0;
|
||||
|
||||
// display a shortened filename if the file exists in the base movie directory
|
||||
if(!strncmp(fname.c_str(), baseMovieDir, strlen(baseMovieDir)))
|
||||
if(!strncmp(fname.c_str(), baseMovieDir.c_str(), baseMovieDir.size()))
|
||||
{
|
||||
char szDrive[MAX_PATH]={0};
|
||||
char szDirectory[MAX_PATH]={0};
|
||||
|
|
|
@ -705,7 +705,7 @@ int TextHookerSaveTableFile(){
|
|||
FP = fopen(nameo,"wb");
|
||||
line = 0; //init the line counter
|
||||
|
||||
char hex[] = { 0 ,0 };
|
||||
char hex[3] = { 0, 0, 0 };
|
||||
|
||||
//write the table file to the file
|
||||
for ( i = 0; i < 256; i++ ) { //go through each possible hex value
|
||||
|
|
|
@ -409,17 +409,13 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode)
|
|||
|
||||
const char* romextensions[] = {"nes","fds",0};
|
||||
fp=FCEU_fopen(name,0,"rb",0,-1,romextensions);
|
||||
if(!fp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetFileBase(fp->filename.c_str());
|
||||
|
||||
if(!fp) {
|
||||
FCEU_PrintError("Error opening \"%s\"!",name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetFileBase(fp->filename.c_str());
|
||||
//---------
|
||||
|
||||
//file opened ok. start loading.
|
||||
|
|
|
@ -890,16 +890,14 @@ void FDSClose(void)
|
|||
FILE *fp;
|
||||
int x;
|
||||
isFDS = false;
|
||||
char *fn=strdup(FCEU_MakeFName(FCEUMKF_FDS,0,0).c_str());
|
||||
|
||||
if(!DiskWritten) return;
|
||||
|
||||
if(!(fp=FCEUD_UTF8fopen(fn,"wb")))
|
||||
const std::string &fn = FCEU_MakeFName(FCEUMKF_FDS,0,0);
|
||||
if(!(fp=FCEUD_UTF8fopen(fn.c_str(),"wb")))
|
||||
{
|
||||
free(fn);
|
||||
return;
|
||||
}
|
||||
free(fn);
|
||||
|
||||
for(x=0;x<TotalSides;x++)
|
||||
{
|
||||
|
|
|
@ -106,43 +106,43 @@ int32 NeoFilterSound(int32 *in, int32 *out, uint32 inlen, int32 *leftover)
|
|||
max=(inlen-1)<<16;
|
||||
|
||||
if(FSettings.soundq==2)
|
||||
for(x=mrindex;x<max;x+=mrratio)
|
||||
{
|
||||
int32 acc=0,acc2=0;
|
||||
unsigned int c;
|
||||
int32 *S,*D;
|
||||
for(x=mrindex;x<max;x+=mrratio)
|
||||
{
|
||||
int32 acc=0,acc2=0;
|
||||
unsigned int c;
|
||||
int32 *S,*D;
|
||||
|
||||
for(c=SQ2NCOEFFS,S=&in[(x>>16)-SQ2NCOEFFS],D=sq2coeffs;c;c--,D++)
|
||||
{
|
||||
acc+=(S[c]**D)>>6;
|
||||
acc2+=(S[1+c]**D)>>6;
|
||||
}
|
||||
for(c=SQ2NCOEFFS,S=&in[(x>>16)-SQ2NCOEFFS],D=sq2coeffs;c;c--,D++)
|
||||
{
|
||||
acc+=(S[c]**D)>>6;
|
||||
acc2+=(S[1+c]**D)>>6;
|
||||
}
|
||||
|
||||
acc=((int64)acc*(65536-(x&65535))+(int64)acc2*(x&65535))>>(16+11);
|
||||
*out=acc;
|
||||
out++;
|
||||
count++;
|
||||
}
|
||||
acc=((int64)acc*(65536-(x&65535))+(int64)acc2*(x&65535))>>(16+11);
|
||||
*out=acc;
|
||||
out++;
|
||||
count++;
|
||||
}
|
||||
else
|
||||
for(x=mrindex;x<max;x+=mrratio)
|
||||
{
|
||||
int32 acc=0,acc2=0;
|
||||
unsigned int c;
|
||||
const int32 *S,*D;
|
||||
for(x=mrindex;x<max;x+=mrratio)
|
||||
{
|
||||
int32 acc=0,acc2=0;
|
||||
unsigned int c;
|
||||
const int32 *S,*D;
|
||||
|
||||
for(c=NCOEFFS,S=&in[(x>>16)-NCOEFFS],D=coeffs;c;c--,D++)
|
||||
{
|
||||
acc+=(S[c]**D)>>6;
|
||||
acc2+=(S[1+c]**D)>>6;
|
||||
}
|
||||
for(c=NCOEFFS,S=&in[(x>>16)-NCOEFFS],D=coeffs;c;c--,D++)
|
||||
{
|
||||
acc+=(S[c]**D)>>6;
|
||||
acc2+=(S[1+c]**D)>>6;
|
||||
}
|
||||
|
||||
acc=((int64)acc*(65536-(x&65535))+(int64)acc2*(x&65535))>>(16+11);
|
||||
*out=acc;
|
||||
out++;
|
||||
count++;
|
||||
}
|
||||
acc=((int64)acc*(65536-(x&65535))+(int64)acc2*(x&65535))>>(16+11);
|
||||
*out=acc;
|
||||
out++;
|
||||
count++;
|
||||
}
|
||||
|
||||
mrindex=x-max;
|
||||
mrindex=x-max;
|
||||
|
||||
if(FSettings.soundq==2)
|
||||
{
|
||||
|
|
12
src/ines.cpp
12
src/ines.cpp
|
@ -845,7 +845,11 @@ int iNesSave(){
|
|||
|
||||
fp = fopen(name,"wb");
|
||||
|
||||
if(fwrite(&head,1,16,fp)!=16)return 0;
|
||||
if(fwrite(&head,1,16,fp)!=16)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(head.ROM_type&4) /* Trainer */
|
||||
{
|
||||
|
@ -872,7 +876,11 @@ int iNesSaveAs(char* name)
|
|||
int x = 0;
|
||||
if (!fp)
|
||||
int x = 1;
|
||||
if(fwrite(&head,1,16,fp)!=16)return 0;
|
||||
if(fwrite(&head,1,16,fp)!=16)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(head.ROM_type&4) /* Trainer */
|
||||
{
|
||||
|
|
|
@ -531,7 +531,6 @@ int SaveSnapshot(void)
|
|||
{
|
||||
unsigned int lastu=0;
|
||||
|
||||
char *fn=0;
|
||||
int totallines=FSettings.LastSLine-FSettings.FirstSLine+1;
|
||||
int x,u,y;
|
||||
FILE *pp=NULL;
|
||||
|
@ -543,20 +542,19 @@ int SaveSnapshot(void)
|
|||
|
||||
for(u=lastu;u<99999;u++)
|
||||
{
|
||||
pp=FCEUD_UTF8fopen((fn=strdup(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str())),"rb");
|
||||
pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"rb");
|
||||
if(pp==NULL) break;
|
||||
fclose(pp);
|
||||
}
|
||||
|
||||
lastu=u;
|
||||
|
||||
if(!(pp=FCEUD_UTF8fopen(fn,"wb")))
|
||||
if(!(pp=FCEUD_UTF8fopen(FCEU_MakeFName(FCEUMKF_SNAP,u,"png").c_str(),"wb")))
|
||||
{
|
||||
free(fn);
|
||||
free(compmem);
|
||||
return 0;
|
||||
}
|
||||
free(fn);
|
||||
|
||||
{
|
||||
static uint8 header[8]={137,80,78,71,13,10,26,10};
|
||||
if(fwrite(header,8,1,pp)!=1)
|
||||
|
@ -644,8 +642,6 @@ int SaveSnapshot(char fileName[512])
|
|||
if(!(compmem=(uint8 *)FCEU_malloc(compmemsize)))
|
||||
return 0;
|
||||
|
||||
pp = fopen(fileName, "w");
|
||||
|
||||
if(!(pp=FCEUD_UTF8fopen(fileName,"wb")))
|
||||
{
|
||||
free(compmem);
|
||||
|
|
Loading…
Reference in New Issue