X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=memmap.cpp;h=95bfab2ed6286d837dfffc20297b85ae3a47a689;hb=9902256814785f0b3f08d336a98c481c296ac7e5;hp=25477e50ffe3cf8e3ce6d7653e5041d4f3451e30;hpb=3ddd6d5ea2811b783bf349c8947cf1bbaaf3c8b9;p=drnoksnes diff --git a/memmap.cpp b/memmap.cpp index 25477e5..95bfab2 100644 --- a/memmap.cpp +++ b/memmap.cpp @@ -41,20 +41,18 @@ #include #include -#ifdef __linux -//#include -#endif +/* Do not reencode this file. There are special chars on it. */ #include "snes9x.h" #include "memmap.h" #include "cpuexec.h" #include "ppu.h" -#include "display.h" #include "cheats.h" #include "apu.h" #include "sa1.h" #include "srtc.h" #include "sdd1.h" +#include "dsp1.h" #ifndef ZSNES_FX #include "fxemu.h" @@ -339,17 +337,8 @@ bool8_32 CMemory::LoadROM (const char *filename) CalculatedSize = 0; again: -#ifndef _SNESPPC - _splitpath (filename, drive, dir, name, ext); - _makepath (fname, drive, dir, name, ext); -#else - strcpy(fname, filename); -// strupr(fname); -#endif - -#ifdef __WIN32__ - memmove (&ext [0], &ext[1], 4); -#endif + PathSplit(filename, drive, dir, name, ext); + PathMake(fname, drive, dir, name, ext); int32 TotalFileSize = 0; @@ -393,15 +382,9 @@ again: if (ptr - ROM < MAX_ROM_SIZE + 0x200 && (isdigit (ext [0]) && ext [1] == 0 && ext [0] < '9')) { - more = TRUE; - ext [0]++; -#ifdef __WIN32__ - memmove (&ext [1], &ext [0], 4); - ext [0] = '.'; -#endif -#ifndef _SNESPPC - _makepath (fname, drive, dir, name, ext); -#endif + more = TRUE; + ext [0]++; + PathMake(fname, drive, dir, name, ext); } else if (ptr - ROM < MAX_ROM_SIZE + 0x200 && @@ -410,18 +393,12 @@ again: isdigit (name [2]) && isdigit (name [3]) && isdigit (name [4]) && isdigit (name [5]) && isalpha (name [len - 1]))) { - more = TRUE; - name [len - 1]++; -#ifdef __WIN32__ - memmove (&ext [1], &ext [0], 4); - ext [0] = '.'; -#endif -#ifndef _SNESPPC - _makepath (fname, drive, dir, name, ext); -#endif + more = TRUE; + name [len - 1]++; + PathMake(fname, drive, dir, name, ext); } else - more = FALSE; + more = FALSE; } while (more && (ROMFile = OPEN_STREAM (fname, "rb")) != NULL); } @@ -657,7 +634,7 @@ again: FreeSDD1Data (); InitROM (Tales); - S9xLoadCheatFile (S9xGetFilename(".cht")); + S9xLoadCheatFile (S9xGetFilename(FILE_CHT)); S9xInitCheatData (); S9xApplyCheats (); @@ -1028,34 +1005,34 @@ bool8_32 CMemory::LoadSRAM (const char *filename) bool8_32 CMemory::SaveSRAM (const char *filename) { - int size = Memory.SRAMSize ? - (1 << (Memory.SRAMSize + 3)) * 128 : 0; - if (Settings.SRTC) - { - size += SRTC_SRAM_PAD; - S9xSRTCPreSaveState (); - } + size_t size = Memory.SRAMSize ? + (1 << (Memory.SRAMSize + 3)) * 128 : 0; - if (Settings.SDD1) - S9xSDD1SaveLoggedData (); + if (Settings.SRTC) + { + size += SRTC_SRAM_PAD; + S9xSRTCPreSaveState (); + } - if (size > 0x20000) - size = 0x20000; + if (Settings.SDD1) S9xSDD1SaveLoggedData (); - if (size && *Memory.ROMFilename) - { - FILE *file; - if ((file = fopen (filename, "wb"))) + if (size > 0x20000) size = 0x20000; + + if (size && *Memory.ROMFilename) { - fwrite ((char *) ::SRAM, size, 1, file); - fclose (file); -#if defined(__linux) - chown (filename, getuid (), getgid ()); -#endif - return (TRUE); - } + FILE *file; + if ((file = fopen (filename, "wb"))) + { + if (fwrite((char *) ::SRAM, size, 1, file) == size) { + fclose(file); + return TRUE; + } + fclose(file); + return FALSE; + } } - return (FALSE); + + return FALSE; } void CMemory::FixROMSpeed () @@ -2595,15 +2572,11 @@ static long ReadInt (FILE *f, unsigned nbytes) void CMemory::CheckForIPSPatch (const char *rom_filename, bool8_32 header, int32 &rom_size) { - char dir [_MAX_DIR + 1]; - char drive [_MAX_DRIVE + 1]; - char name [_MAX_FNAME + 1]; - char ext [_MAX_EXT + 1]; char fname [_MAX_PATH + 1]; FILE *patch_file = NULL; long offset = header ? 512 : 0; - if (!(patch_file = fopen(S9xGetFilename (".ips"), "rb"))) return; + if (!(patch_file = fopen(S9xGetFilename(FILE_IPS), "rb"))) return; if (fread (fname, 1, 5, patch_file) != 5 || strncmp (fname, "PATCH", 5) != 0) {