completely remove paletted color support
[drnoksnes] / memmap.cpp
index 7eedcd8..9113f41 100644 (file)
@@ -41,9 +41,7 @@
 #include <string.h>
 #include <ctype.h>
 
-#ifdef __linux
-//#include <unistd.h>
-#endif
+/* Do not reencode this file. There are special chars on it. */
 
 #include "snes9x.h"
 #include "memmap.h"
@@ -55,6 +53,7 @@
 #include "sa1.h"
 #include "srtc.h"
 #include "sdd1.h"
+#include "dsp1.h"
 
 #ifndef ZSNES_FX
 #include "fxemu.h"
@@ -339,17 +338,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 +383,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 +394,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 +635,7 @@ again:
     FreeSDD1Data ();
     InitROM (Tales);
        
-    S9xLoadCheatFile (S9xGetFilename(".cht"));
+    S9xLoadCheatFile (S9xGetFilename(FILE_CHT));
     S9xInitCheatData ();
     S9xApplyCheats ();
 
@@ -1028,34 +1006,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 ()
@@ -2599,7 +2577,7 @@ void CMemory::CheckForIPSPatch (const char *rom_filename, bool8_32 header,
     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)
     {