Change debugger's log folder to LOG_DIR. / Mac: Add frame advance, change the timing of .srm save.

This commit is contained in:
zones 2011-01-24 23:27:57 +09:00
parent 7c6a0f58d1
commit bd1c44b8e6
14 changed files with 195 additions and 88 deletions

View File

@ -600,6 +600,9 @@ void S9xAPUTimingSetSpeedup (int ticks)
void S9xAPUAllowTimeOverflow (bool allow)
{
if (allow)
printf("APU time overflow allowed\n");
spc_core->spc_allow_time_overflow(allow);
}

View File

@ -3509,7 +3509,7 @@ static void Op42 (void)
S9xMessage(S9X_DEBUG, S9X_DEBUG_OUTPUT, buf);
if (trace != NULL)
fclose(trace);
ENSURE_TRACE_OPEN(trace,"WDMtrace.log","ab")
ENSURE_TRACE_OPEN(trace, "WDMtrace.log", "ab")
}
break;

View File

@ -1532,7 +1532,7 @@ static void debug_process_command (char *Line)
if (SA1.Flags & TRACE_FLAG)
{
printf("SA1 CPU instruction tracing enabled.\n");
ENSURE_TRACE_OPEN(trace2,"trace_sa1.log","wb")
ENSURE_TRACE_OPEN(trace2, "trace_sa1.log", "wb")
}
else
{
@ -1548,7 +1548,7 @@ static void debug_process_command (char *Line)
if (CPU.Flags & TRACE_FLAG)
{
printf("CPU instruction tracing enabled.\n");
ENSURE_TRACE_OPEN(trace,"trace.log","wb")
ENSURE_TRACE_OPEN(trace, "trace.log", "wb")
}
else
{
@ -2578,7 +2578,7 @@ void S9xTrace (void)
{
char msg[512];
ENSURE_TRACE_OPEN(trace,"trace.log","a")
ENSURE_TRACE_OPEN(trace, "trace.log", "a")
debug_cpu_op_print(msg, Registers.PB, Registers.PCw);
fprintf(trace, "%s\n", msg);
@ -2588,7 +2588,7 @@ void S9xSA1Trace (void)
{
char msg[512];
ENSURE_TRACE_OPEN(trace2,"trace_sa1.log","a")
ENSURE_TRACE_OPEN(trace2, "trace_sa1.log", "a")
debug_sa1_op_print(msg, SA1Registers.PB, SA1Registers.PCw);
fprintf(trace2, "%s\n", msg);

View File

@ -189,8 +189,13 @@ struct SBreakPoint
uint16 Address;
};
#define ENSURE_TRACE_OPEN(fp,file,mode) \
if(!fp) {std::string fn=S9xGetDirectory(DEFAULT_DIR);fn+=SLASH_STR file;fp=fopen(fn.c_str(),mode);}
#define ENSURE_TRACE_OPEN(fp, file, mode) \
if (!fp) \
{ \
std::string fn = S9xGetDirectory(LOG_DIR); \
fn += SLASH_STR file; \
fp = fopen(fn.c_str(), mode); \
}
extern struct SBreakPoint S9xBreakpoint[6];

View File

@ -30,8 +30,10 @@
"NPConnecting" = "Connecting";
"NPServerName" = "Server";
"AlertMes_03" = "The folders for saving files could not be created.";
"AlertMes_04" = "Some features will not work properly without these folders.";
"AlertMes_01" = "The folder for saving files is not found.";
"AlertMes_02" = "Application Support folder will be used instead.";
"AlertMes_03" = "The folder for saving files is not writable.";
"AlertMes_04" = "Application Support folder will be used instead.";
"AlertMes_05" = "This ROM image has bad checksum, so might not work properly.";
"AlertMes_06" = "Or failed to detect map / interleave.";
"AlertMes_07" = "No enough space in Cheat Entry.";

View File

@ -1278,7 +1278,7 @@ static void CheatFinderHandleAddEntryButton (WindowData *cf)
PlayAlertSound();
else
if (Cheat.num_cheats + cfViewNumBytes > MAX_CHEATS)
AppearanceAlert(kAlertCautionAlert, kCFCantAddWarning, kCFCantAddHint);
AppearanceAlert(kAlertCautionAlert, kS9xMacAlertCFCantAddEntry, kS9xMacAlertCFCantAddEntryHint);
else
CheatFinderBeginAddEntrySheet(cf);
}

View File

@ -922,11 +922,10 @@ static bool8 NPClientBeginOpenROMImage (WindowRef window)
static bool8 NPClientEndOpenROMImage (void)
{
OSStatus err;
FSCatalogInfo info;
FSRef cartRef;
char filename[PATH_MAX + 1];
bool8 r;
OSStatus err;
FSRef cartRef;
char filename[PATH_MAX + 1];
bool8 r;
r = NavEndOpenROMImageSheet(&cartRef);
if (!r)
@ -935,8 +934,7 @@ static bool8 NPClientEndOpenROMImage (void)
return (false);
}
err = FSGetCatalogInfo(&cartRef, kFSCatInfoVolume, &info, NULL, NULL, NULL);
lockedROMMedia = IsLockedMedia(info.volume);
CheckSaveFolder(&cartRef);
Settings.ForceLoROM = (romDetect == kLoROMForce );
Settings.ForceHiROM = (romDetect == kHiROMForce );

18
macosx/mac-dialog.h Normal file → Executable file
View File

@ -193,14 +193,16 @@
enum
{
kFolderFail = 3,
kFolderHint,
kBadRomWarning,
kBadRomHint,
kCFCantAddWarning,
kCFCantAddHint,
kRequiredSystemWarning,
kRequiredSystemHint
kS9xMacAlertFolderNotFound = 1,
kS9xMacAlertFolderNotFoundHint,
kS9xMacAlertFolderFailToCreate,
kS9xMacAlertFolderFailToCreateHint,
kS9xMacAlertkBadRom,
kS9xMacAlertkBadRomHint,
kS9xMacAlertCFCantAddEntry,
kS9xMacAlertCFCantAddEntryHint,
kS9xMacAlertRequiredSystem,
kS9xMacAlertRequiredSystemHint
};
extern int autofireLastTabIndex;

View File

@ -207,6 +207,78 @@ static OSStatus FindApplicationSupportFolder (FSRef *, char *, const char *);
static OSStatus FindCustomFolder (FSRef *, char *, const char *);
void CheckSaveFolder (FSRef *cartRef)
{
OSStatus err;
Boolean r;
FSCatalogInfo finfo;
FSVolumeInfo vinfo;
FSRef ref;
CFURLRef burl, purl;
char s[PATH_MAX + 1];
switch (saveInROMFolder)
{
case 0: // Snes9x folder
burl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
purl = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, burl);
r = CFURLGetFSRef(purl, &ref);
CFRelease(purl);
CFRelease(burl);
break;
case 1: // ROM folder
err = FSGetCatalogInfo(cartRef, kFSCatInfoNone, NULL, NULL, NULL, &ref);
break;
case 2: // Application Support folder
return;
case 4: // Custom folder
if (saveFolderPath == NULL)
{
saveInROMFolder = 2;
return;
}
r = CFStringGetCString(saveFolderPath, s, PATH_MAX, kCFStringEncodingUTF8);
err = FSPathMakeRef((unsigned char *) s, &ref, NULL);
if (err)
{
AppearanceAlert(kAlertCautionAlert, kS9xMacAlertFolderNotFound, kS9xMacAlertFolderNotFoundHint);
saveInROMFolder = 2;
return;
}
break;
}
err = FSGetCatalogInfo(&ref, kFSCatInfoUserPrivs | kFSCatInfoVolume, &finfo, NULL, NULL, NULL);
if (err == noErr)
{
if (finfo.userPrivileges & kioACUserNoMakeChangesMask)
{
AppearanceAlert(kAlertCautionAlert, kS9xMacAlertFolderFailToCreate, kS9xMacAlertFolderFailToCreateHint);
saveInROMFolder = 2;
return;
}
err = FSGetVolumeInfo(finfo.volume, 0, NULL, kFSVolInfoFlags, &vinfo, NULL, NULL);
if (err == noErr)
{
if ((vinfo.flags & kFSVolFlagHardwareLockedMask) || (vinfo.flags & kFSVolFlagSoftwareLockedMask))
{
AppearanceAlert(kAlertCautionAlert, kS9xMacAlertFolderFailToCreate, kS9xMacAlertFolderFailToCreateHint);
saveInROMFolder = 2;
return;
}
}
}
if (err)
saveInROMFolder = 2;
}
static OSStatus FindSNESFolder (FSRef *folderRef, char *folderPath, const char *folderName)
{
OSStatus err;
@ -231,15 +303,7 @@ static OSStatus FindSNESFolder (FSRef *folderRef, char *folderPath, const char *
AddFolderIcon(folderRef, folderName);
}
if (err)
{
if (!folderWarning)
{
AppearanceAlert(kAlertCautionAlert, kFolderFail, kFolderHint);
folderWarning = true;
}
}
else
if (err == noErr)
err = FSRefMakePath(folderRef, (unsigned char *) folderPath, PATH_MAX);
CFRelease(purl);
@ -284,15 +348,7 @@ static OSStatus FindApplicationSupportFolder (FSRef *folderRef, char *folderPath
AddFolderIcon(folderRef, folderName);
}
if (err)
{
if (!folderWarning)
{
AppearanceAlert(kAlertCautionAlert, kFolderFail, kFolderHint);
folderWarning = true;
}
}
else
if (err == noErr)
err = FSRefMakePath(folderRef, (unsigned char *) folderPath, PATH_MAX);
CFRelease(fstr);
@ -308,6 +364,9 @@ static OSStatus FindCustomFolder (FSRef *folderRef, char *folderPath, const char
UniChar buffer[PATH_MAX + 1];
char s[PATH_MAX + 1];
if (saveFolderPath == NULL)
return (-1);
err = CFStringGetCString(saveFolderPath, s, PATH_MAX, kCFStringEncodingUTF8) ? noErr : -1;
if (err == noErr)
err = FSPathMakeRef((unsigned char *) s, &pref, NULL);
@ -326,15 +385,7 @@ static OSStatus FindCustomFolder (FSRef *folderRef, char *folderPath, const char
AddFolderIcon(folderRef, folderName);
}
if (err)
{
if (!folderWarning)
{
AppearanceAlert(kAlertCautionAlert, kFolderFail, kFolderHint);
folderWarning = true;
}
}
else
if (err == noErr)
err = FSRefMakePath(folderRef, (unsigned char *) folderPath, PATH_MAX);
CFRelease(fstr);
@ -437,21 +488,6 @@ static void AddFolderIcon (FSRef *fref, const char *folderName)
}
}
Boolean IsLockedMedia (FSVolumeRefNum volume)
{
OSStatus err;
FSVolumeInfo info;
err = FSGetVolumeInfo(volume, 0, NULL, kFSVolInfoFlags, &info, NULL, NULL);
if (err == noErr)
{
if ((info.flags & kFSVolFlagHardwareLockedMask) || (info.flags & kFSVolFlagSoftwareLockedMask))
return (true);
}
return (false);
}
const char * S9xGetFilename (const char *inExt, enum s9x_getdirtype dirtype)
{
static int index = 0;
@ -506,6 +542,7 @@ const char * S9xGetFilename (const char *inExt, enum s9x_getdirtype dirtype)
case '.dat':
case '.out':
case '.log':
strcpy(folderName, "Logs");
break;
@ -514,18 +551,29 @@ const char * S9xGetFilename (const char *inExt, enum s9x_getdirtype dirtype)
break;
}
if (folderName[0] && ((saveInROMFolder != 1) || lockedROMMedia))
if (folderName[0] && (saveInROMFolder != 1))
{
char s[PATH_MAX + 1];
s[0] = 0;
err = -1;
if (saveInROMFolder == 0)
{
err = FindSNESFolder(&ref, s, folderName);
else
if (saveFolderPath && (saveInROMFolder == 4))
if (err)
saveInROMFolder = 2;
}
if (saveInROMFolder == 4)
{
err = FindCustomFolder(&ref, s, folderName);
else
if (err)
saveInROMFolder = 2;
}
if (saveInROMFolder == 2)
err = FindApplicationSupportFolder(&ref, s, folderName);
if (err == noErr)
@ -675,6 +723,7 @@ const char * S9xGetDirectory (enum s9x_getdirtype dirtype)
case SPC_DIR: strcpy(inExt, ".spc"); break;
case CHEAT_DIR: strcpy(inExt, ".cht"); break;
case BIOS_DIR: strcpy(inExt, ".bio"); break;
case LOG_DIR: strcpy(inExt, ".log"); break;
default: strcpy(inExt, ".xxx"); break;
}

View File

@ -191,8 +191,8 @@
#ifndef _mac_file_h_
#define _mac_file_h_
void CheckSaveFolder (FSRef *);
void ChangeTypeAndCreator (const char *, OSType, OSType);
Boolean IsLockedMedia (FSVolumeRefNum);
const char * S9xGetSPCFilename (void);
const char * S9xGetPNGFilename (void);
const char * S9xGetFreezeFilename (int);

View File

@ -296,7 +296,7 @@ extern int64 lastFrame;
extern unsigned long spcFileCount, pngFileCount;
extern SInt32 systemVersion;
extern bool8 finished, cartOpen,
autofire, hidExist, folderWarning, lockedROMMedia, directDisplay;
autofire, hidExist, directDisplay;
extern bool8 fullscreen, autoRes,
glstretch, gl32bit, vsync, drawoverscan, lastoverscan, screencurvature,
multiprocessor, ciFilterEnable;

View File

@ -195,6 +195,7 @@
#import "crosshairs.h"
#import "cheats.h"
#import "movie.h"
#import "snapshot.h"
#import "display.h"
#import "blit.h"
@ -280,8 +281,6 @@ bool8 finished = false,
cartOpen = false,
autofire = false,
hidExist = true,
folderWarning = false,
lockedROMMedia = false,
directDisplay = false;
bool8 fullscreen = false,
@ -433,7 +432,9 @@ enum
kmCtrKey = 0x3B,
kmMinusKey = 0x1B,
kmQKey = 0x0C,
kmWKey = 0x0D
kmWKey = 0x0D,
kmOKey = 0x1F,
kmPKey = 0x23
};
struct ButtonCommand
@ -453,6 +454,9 @@ struct GameViewInfo
static volatile bool8 rejectinput = false;
static bool8 pauseEmulation = false,
frameAdvance = false;
static pthread_t s9xthread;
static MenuRef recentMenu;
@ -493,7 +497,9 @@ static ButtonCommand btncmd[] =
{ "_mac1", km0Key, false },
{ "_mac2", kmMinusKey, false },
{ "_mac3", kmQKey, false },
{ "_mac4", kmWKey, false }
{ "_mac4", kmWKey, false },
{ "_mac5", kmOKey, false },
{ "_mac6", kmPKey, false }
};
#define kCommandListSize (sizeof(btncmd) / sizeof(btncmd[0]))
@ -598,6 +604,13 @@ int main (int argc, char **argv)
pthread_join(s9xthread, NULL);
if (!Settings.NetPlay || Settings.NetPlayServer)
{
SNES9X_SaveSRAM();
S9xResetSaveTimer(false);
S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
}
S9xDeinitDisplay();
if (Settings.NetPlay)
@ -657,6 +670,10 @@ static void * MacSnes9xThread (void *)
static inline void EmulationLoop (void)
{
bool8 olddisplayframerate = false;
int storedMacFrameSkip = macFrameSkip;
pauseEmulation = false;
frameAdvance = false;
if (macQTRecord)
{
@ -704,7 +721,22 @@ static inline void EmulationLoop (void)
while (running)
{
ProcessInput();
S9xMainLoop();
if (!pauseEmulation)
S9xMainLoop();
else
{
if (frameAdvance)
{
macFrameSkip = 1;
skipFrames = 1;
frameAdvance = false;
S9xMainLoop();
macFrameSkip = storedMacFrameSkip;
}
usleep(Settings.FrameTime);
}
}
}
@ -2767,6 +2799,14 @@ static void ProcessInput (void)
sprintf(msg, "Emulation Speed: 100/%d", macFrameAdvanceRate / 10000);
S9xSetInfoString(msg);
break;
case 5:
pauseEmulation = !pauseEmulation;
break;
case 6:
frameAdvance = true;
break;
}
}
else
@ -3123,7 +3163,7 @@ static void Initialize (void)
if ((systemVersion < 0x1039) || (qtVersion < 0x07008000))
{
AppearanceAlert(kAlertStopAlert, kRequiredSystemWarning, kRequiredSystemHint);
AppearanceAlert(kAlertStopAlert, kS9xMacAlertRequiredSystem, kS9xMacAlertRequiredSystemHint);
QuitWithFatalError(0, "os 09");
}
@ -3427,7 +3467,7 @@ void S9xMessage (int type, int number, const char *message)
if ((type == S9X_INFO) && (number == S9X_ROM_INFO))
if (strstr(message, "checksum ok") == NULL)
AppearanceAlert(kAlertCautionAlert, kBadRomWarning, kBadRomHint);
AppearanceAlert(kAlertCautionAlert, kS9xMacAlertkBadRom, kS9xMacAlertkBadRomHint);
}
else
{

View File

@ -189,8 +189,7 @@
#include "snes9x.h"
#include "apu.h"
#include "gfx.h"
#include "memmap.h"
#include "blit.h"
#include <OpenGL/OpenGL.h>
@ -202,6 +201,7 @@
#include "mac-cart.h"
#include "mac-coreimage.h"
#include "mac-dialog.h"
#include "mac-file.h"
#include "mac-keyboard.h"
#include "mac-os.h"
#include "mac-render.h"
@ -1280,6 +1280,15 @@ void ConfigurePreferences (void)
InitGameWindow();
ShowWindow(gWindow);
}
if (cartOpen)
{
FSRef ref;
err = FSPathMakeRef((unsigned char *) Memory.ROMFilename, &ref, NULL);
if (err == noErr)
CheckSaveFolder(&ref);
}
}
}

View File

@ -222,10 +222,9 @@ void SNES9X_Go (void)
bool8 SNES9X_OpenCart (FSRef *inRef)
{
OSStatus err;
FSCatalogInfo info;
FSRef cartRef;
char filename[PATH_MAX + 1];
OSStatus err;
FSRef cartRef;
char filename[PATH_MAX + 1];
DeinitGameWindow();
@ -251,8 +250,7 @@ bool8 SNES9X_OpenCart (FSRef *inRef)
spcFileCount = pngFileCount = 0;
err = FSGetCatalogInfo(&cartRef, kFSCatInfoVolume, &info, NULL, NULL, NULL);
lockedROMMedia = IsLockedMedia(info.volume);
CheckSaveFolder(&cartRef);
Settings.ForceLoROM = (romDetect == kLoROMForce );
Settings.ForceHiROM = (romDetect == kHiROMForce );
@ -623,6 +621,7 @@ void SNES9X_Quit (void)
if (cartOpen)
{
SNES9X_SaveSRAM();
S9xResetSaveTimer(false);
S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
}