#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"
#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"
extern char *rom_filename;
extern bool8 LoadZip(const char* , int32 *, int32 *);
-bool8_32 CMemory::AllASCII (uint8 *b, int size)
+bool CMemory::AllASCII (uint8 *b, int size)
{
for (int i = 0; i < size; i++)
{
if (b[i] < 32 || b[i] > 126)
- return (FALSE);
+ return false;
}
- return (TRUE);
+ return true;
}
-int CMemory::ScoreHiROM (bool8_32 skip_header)
+int CMemory::ScoreHiROM (bool skip_header)
{
int score = 0;
int o = skip_header ? 0xff00 + 0x200 : 0xff00;
return (score);
}
-int CMemory::ScoreLoROM (bool8_32 skip_header)
+int CMemory::ScoreLoROM (bool skip_header)
{
int score = 0;
int o = skip_header ? 0x7f00 + 0x200 : 0x7f00;
/* Init() */
/* This function allocates all the memory needed by the emulator */
/**********************************************************************************************/
-bool8_32 CMemory::Init ()
+bool CMemory::Init ()
{
RAM = (uint8 *) malloc (0x20000);
SRAM = (uint8 *) malloc (0x20000);
!IPPU.TileCached [TILE_4BIT] || !IPPU.TileCached [TILE_8BIT])
{
Deinit ();
- return (FALSE);
+ return false;
}
// FillRAM uses first 32K of ROM image area, otherwise space just
SDD1Data = NULL;
SDD1Index = NULL;
- return (TRUE);
+ return true;
}
void CMemory::Deinit ()
#pragma warning(disable : 4101)
#pragma warning(disable : 4700)
#endif
-bool8_32 CMemory::LoadROM (const char *filename)
+bool CMemory::LoadROM (const char *filename)
{
unsigned long FileSize = 0;
int retry_count = 0;
STREAM ROMFile;
- bool8_32 Interleaved = FALSE;
- bool8_32 Tales = FALSE;
+ bool Interleaved = FALSE;
+ bool Tales = FALSE;
char dir [_MAX_DIR + 1];
char drive [_MAX_DRIVE + 1];
char name [_MAX_FNAME + 1];
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;
HeaderCount = 0;
uint8 *ptr = ROM;
- bool8_32 more = FALSE;
+ bool more = FALSE;
do
{
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 &&
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);
}
}
else
{
- bool8_32 t = LoROM;
+ bool8 t = LoROM;
LoROM = HiROM;
HiROM = t;
FreeSDD1Data ();
InitROM (Tales);
- S9xLoadCheatFile (S9xGetFilename(".cht"));
+ S9xLoadCheatFile (S9xGetFilename(FILE_CHT));
S9xInitCheatData ();
S9xApplyCheats ();
S9xReset ();
- return (TRUE);
+ return true;
}
void S9xDeinterleaveMode2 ()
}
free ((char *) tmp);
}
- Memory.InitROM (FALSE);
+ Memory.InitROM (false);
S9xReset ();
}
-void CMemory::InitROM (bool8_32 Interleaved)
+void CMemory::InitROM (bool Interleaved)
{
#ifndef ZSNES_FX
SuperFX.nRomBanks = CalculatedSize >> 15;
S9xMessage (S9X_INFO, S9X_ROM_INFO, String);
}
-bool8_32 CMemory::LoadSRAM (const char *filename)
+bool CMemory::LoadSRAM (const char *filename)
{
int size = Memory.SRAMSize ?
(1 << (Memory.SRAMSize + 3)) * 128 : 0;
else
S9xHardResetSRTC ();
- return (TRUE);
+ return true;
}
S9xHardResetSRTC ();
- return (FALSE);
+ return false;
}
if (Settings.SDD1)
S9xSDD1LoadLoggedData ();
- return (TRUE);
+ return true;
}
-bool8_32 CMemory::SaveSRAM (const char *filename)
+bool 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 true;
}
void CMemory::FixROMSpeed ()
WriteProtectROM ();
}
-void CMemory::TalesROMMap (bool8_32 Interleaved)
+void CMemory::TalesROMMap (bool Interleaved)
{
int c;
int i;
#define IPS_EOF 0x00454F46l
-void CMemory::CheckForIPSPatch (const char *rom_filename, bool8_32 header,
+void CMemory::CheckForIPSPatch (const char *rom_filename, bool header,
int32 &rom_size)
{
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)
{