Skip to content

Commit b15b702

Browse files
authored
Merge pull request #1596 from Provenance-Emu/feature/SecondRunCrashFix
fixes #1586 Re-running core crashes
2 parents eecf237 + 039453c commit b15b702

File tree

43 files changed

+508
-1830
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+508
-1830
lines changed

.swift-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.0.2] - 2020-09-14
9+
10+
More Bug fixes mostly.
11+
12+
### Added
13+
14+
- XCode will detect missing git submodules and auto-clone recursive before building the rest of the project
15+
16+
### Fixed
17+
18+
- #1586 Running same care twice in a row would crash
19+
- #1593 Cheat codes menu crash fixes and other cheat code quality improvements
20+
21+
### Updated
22+
23+
- #1564 SteamController native SPM package port
24+
- Jaguar core updated with libretro upstream + my performance hacks. PR made https://github.com/libretro/virtualjaguar-libretro/pull/53#issuecomment-919242560
25+
- Fix many static analyzer warnigns about possible nil pointer/un-malloc'd memory usage, now we check and log nils or early exit where applicable
26+
- SQLite.swift updated
27+
- RxRealm updated from 5.0.2 to 5.0.3
28+
- realm-cocoa updated from 10.14.0 to 10.15.0
29+
830
## [2.0.1] - 2020-09-09
931

1032
Bug fixes mostly.

Cores/Atari800/Atari800Core/Source/ATR800GameCore.m

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -237,19 +237,20 @@ - (BOOL)loadFileAtPath:(NSString *)path error:(NSError *__autoreleasing *)error
237237
// Open and try to automatically detect file type, not 100% accurate
238238
if(!AFILE_OpenFile([path UTF8String], 1, 1, FALSE))
239239
{
240-
NSLog(@"Failed to open file");
241-
NSDictionary *userInfo = @{
242-
NSLocalizedDescriptionKey: @"Failed to load game.",
243-
NSLocalizedFailureReasonErrorKey: @"atari800 failed to load ROM.",
244-
NSLocalizedRecoverySuggestionErrorKey: @"Check that file isn't corrupt and in format atari800 supports."
245-
};
246-
247-
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
248-
code:PVEmulatorCoreErrorCodeCouldNotLoadRom
249-
userInfo:userInfo];
250-
251-
*error = newError;
252-
240+
ELOG(@"Failed to open file");
241+
if(error != NULL) {
242+
NSDictionary *userInfo = @{
243+
NSLocalizedDescriptionKey: @"Failed to load game.",
244+
NSLocalizedFailureReasonErrorKey: @"atari800 failed to load ROM.",
245+
NSLocalizedRecoverySuggestionErrorKey: @"Check that file isn't corrupt and in format atari800 supports."
246+
};
247+
248+
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
249+
code:PVEmulatorCoreErrorCodeCouldNotLoadRom
250+
userInfo:userInfo];
251+
252+
*error = newError;
253+
}
253254
return NO;
254255
}
255256

@@ -885,8 +886,10 @@ int UI_SelectCartType(int k)
885886
// Determine if 16KB cart is one-chip (NS_16) or two-chip (EE_16)
886887
if([One_Chip_16KB containsObject:[_currentCore.romMD5 lowercaseString]])
887888
return CARTRIDGE_5200_NS_16;
888-
else
889+
else if([Two_Chip_16KB containsObject:[_currentCore.romMD5 lowercaseString]])
889890
return CARTRIDGE_5200_EE_16;
891+
else // Maybe an error condition since it should have been in two chip?
892+
return CARTRIDGE_5200_EE_16;
890893
case 32: return CARTRIDGE_5200_32;
891894
case 40: return CARTRIDGE_5200_40; // Bounty Bob Strikes Back
892895
default:

Cores/FCEU/FCEU/fceu.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern int normalscanlines;
1515
extern int totalscanlines;
1616
extern int postrenderscanlines;
1717
extern int vblankscanlines;
18-
extern int pal_emulation;
18+
extern int pal_emulation;
1919

2020
extern bool AutoResumePlay;
2121
extern char romNameWhenClosingEmulator[];
@@ -150,14 +150,14 @@ extern uint8 vsdip;
150150

151151
//#define FCEUDEF_DEBUGGER //mbg merge 7/17/06 - cleaning out conditional compiles
152152

153-
#define JOY_A 1
154-
#define JOY_B 2
155-
#define JOY_SELECT 4
156-
#define JOY_START 8
157-
#define JOY_UP 0x10
158-
#define JOY_DOWN 0x20
159-
#define JOY_LEFT 0x40
160-
#define JOY_RIGHT 0x80
153+
#define JOY_A 1u
154+
#define JOY_B 2u
155+
#define JOY_SELECT 4u
156+
#define JOY_START 8u
157+
#define JOY_UP 0x10u
158+
#define JOY_DOWN 0x20u
159+
#define JOY_LEFT 0x40u
160+
#define JOY_RIGHT 0x80u
161161
#endif
162162

163163
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))

Cores/FCEU/PVFCEUEmulatorCore.mm

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,19 @@ - (BOOL)loadFileAtPath:(NSString *)path error:(NSError**)error
121121
FCEUGameInfo = FCEUI_LoadGame([path UTF8String], 1, false);
122122

123123
if(!FCEUGameInfo) {
124-
NSDictionary *userInfo = @{
125-
NSLocalizedDescriptionKey: @"Failed to load game.",
126-
NSLocalizedFailureReasonErrorKey: @"FCEUI failed to load game.",
127-
NSLocalizedRecoverySuggestionErrorKey: @"Check the file isn't corrupt and supported FCEUI ROM format."
128-
};
129-
130-
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
131-
code:PVEmulatorCoreErrorCodeCouldNotLoadRom
132-
userInfo:userInfo];
133-
134-
*error = newError;
124+
if(error != NULL) {
125+
NSDictionary *userInfo = @{
126+
NSLocalizedDescriptionKey: @"Failed to load game.",
127+
NSLocalizedFailureReasonErrorKey: @"FCEUI failed to load game.",
128+
NSLocalizedRecoverySuggestionErrorKey: @"Check the file isn't corrupt and supported FCEUI ROM format."
129+
};
130+
131+
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
132+
code:PVEmulatorCoreErrorCodeCouldNotLoadRom
133+
userInfo:userInfo];
134+
135+
*error = newError;
136+
}
135137
return NO;
136138
}
137139

@@ -258,17 +260,19 @@ - (BOOL)loadStateFromFileAtPath:(NSString *)fileName error:(NSError**)error
258260
@synchronized(self) {
259261
BOOL success = FCEUSS_Load([fileName UTF8String], false);
260262
if (!success) {
261-
NSDictionary *userInfo = @{
262-
NSLocalizedDescriptionKey: @"Failed to save state.",
263-
NSLocalizedFailureReasonErrorKey: @"Core failed to load save state.",
264-
NSLocalizedRecoverySuggestionErrorKey: @""
265-
};
266-
267-
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
268-
code:PVEmulatorCoreErrorCodeCouldNotLoadState
269-
userInfo:userInfo];
270-
271-
*error = newError;
263+
if(error != NULL) {
264+
NSDictionary *userInfo = @{
265+
NSLocalizedDescriptionKey: @"Failed to save state.",
266+
NSLocalizedFailureReasonErrorKey: @"Core failed to load save state.",
267+
NSLocalizedRecoverySuggestionErrorKey: @""
268+
};
269+
270+
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
271+
code:PVEmulatorCoreErrorCodeCouldNotLoadState
272+
userInfo:userInfo];
273+
274+
*error = newError;
275+
}
272276
}
273277
return success;
274278
}
@@ -330,7 +334,8 @@ void FCEUD_GetPalette(unsigned char i, unsigned char *r, unsigned char *g, unsig
330334
}
331335
EMUFILE_FILE *FCEUD_UTF8_fstream(const char *fn, const char *m)
332336
{
333-
std::ios_base::openmode mode = std::ios_base::binary;
337+
#if 0
338+
std::ios_base::openmode mode = std::ios_base::binary;
334339
if(!strcmp(m,"r") || !strcmp(m,"rb"))
335340
mode |= std::ios_base::in;
336341
else if(!strcmp(m,"w") || !strcmp(m,"wb"))
@@ -343,8 +348,10 @@ void FCEUD_GetPalette(unsigned char i, unsigned char *r, unsigned char *g, unsig
343348
mode |= std::ios_base::in | std::ios_base::out | std::ios_base::trunc;
344349
else if(!strcmp(m,"a+") || !strcmp(m,"a+b"))
345350
mode |= std::ios_base::in | std::ios_base::out | std::ios_base::app;
351+
return new std::fstream(fn,mode);
352+
#else
346353
return new EMUFILE_FILE(fn, m);
347-
//return new std::fstream(fn,mode);
354+
#endif
348355
}
349356
void FCEUD_NetplayText(uint8 *text) {}
350357
void FCEUD_NetworkClose(void) {}

Cores/Genesis-Plus-GX/PVGenesis/Genesis/PVGenesisEmulatorCore.m

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,19 @@ - (BOOL)loadFileAtPath:(NSString*)path error:(NSError**)error
240240
NSData* dataObj = [NSData dataWithContentsOfFile:[path stringByStandardizingPath]];
241241
if (dataObj == nil)
242242
{
243-
NSDictionary *userInfo = @{
244-
NSLocalizedDescriptionKey: @"Failed to load game.",
245-
NSLocalizedFailureReasonErrorKey: @"File was unreadble.",
246-
NSLocalizedRecoverySuggestionErrorKey: @"Check the file isn't corrupt and exists."
247-
};
248-
249-
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
250-
code:PVEmulatorCoreErrorCodeCouldNotLoadRom
251-
userInfo:userInfo];
252-
253-
*error = newError;
243+
if(error != NULL) {
244+
NSDictionary *userInfo = @{
245+
NSLocalizedDescriptionKey: @"Failed to load game.",
246+
NSLocalizedFailureReasonErrorKey: @"File was unreadble.",
247+
NSLocalizedRecoverySuggestionErrorKey: @"Check the file isn't corrupt and exists."
248+
};
249+
250+
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
251+
code:PVEmulatorCoreErrorCodeCouldNotLoadRom
252+
userInfo:userInfo];
253+
254+
*error = newError;
255+
}
254256
return false;
255257
}
256258
size = [dataObj length];
@@ -314,19 +316,21 @@ - (BOOL)loadFileAtPath:(NSString*)path error:(NSError**)error
314316

315317
return YES;
316318
}
317-
318-
NSDictionary *userInfo = @{
319-
NSLocalizedDescriptionKey: @"Failed to load game.",
320-
NSLocalizedFailureReasonErrorKey: @"GenPlusGX failed to load game.",
321-
NSLocalizedRecoverySuggestionErrorKey: @"Check the file isn't corrupt and supported GenPlusGX ROM format."
322-
};
323-
324-
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
325-
code:PVEmulatorCoreErrorCodeCouldNotLoadRom
326-
userInfo:userInfo];
327-
328-
*error = newError;
329-
319+
320+
if(error != NULL) {
321+
NSDictionary *userInfo = @{
322+
NSLocalizedDescriptionKey: @"Failed to load game.",
323+
NSLocalizedFailureReasonErrorKey: @"GenPlusGX failed to load game.",
324+
NSLocalizedRecoverySuggestionErrorKey: @"Check the file isn't corrupt and supported GenPlusGX ROM format."
325+
};
326+
327+
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
328+
code:PVEmulatorCoreErrorCodeCouldNotLoadRom
329+
userInfo:userInfo];
330+
331+
*error = newError;
332+
}
333+
330334
return NO;
331335
}
332336

@@ -884,32 +888,36 @@ - (BOOL)loadStateFromFileAtPath:(NSString *)path error:(NSError *__autoreleasing
884888
NSData *saveStateData = [NSData dataWithContentsOfFile:path];
885889
if (!saveStateData)
886890
{
887-
NSDictionary *userInfo = @{
888-
NSLocalizedDescriptionKey: @"Failed to load save state.",
889-
NSLocalizedFailureReasonErrorKey: @"Genesis failed to read savestate data.",
890-
NSLocalizedRecoverySuggestionErrorKey: @"Check that the path is correct and file exists."
891-
};
892-
893-
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
894-
code:PVEmulatorCoreErrorCodeCouldNotLoadState
895-
userInfo:userInfo];
896-
*error = newError;
891+
if(error != NULL) {
892+
NSDictionary *userInfo = @{
893+
NSLocalizedDescriptionKey: @"Failed to load save state.",
894+
NSLocalizedFailureReasonErrorKey: @"Genesis failed to read savestate data.",
895+
NSLocalizedRecoverySuggestionErrorKey: @"Check that the path is correct and file exists."
896+
};
897+
898+
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
899+
code:PVEmulatorCoreErrorCodeCouldNotLoadState
900+
userInfo:userInfo];
901+
*error = newError;
902+
}
897903
ELOG(@"Unable to load save state from path: %@", path);
898904
return NO;
899905
}
900906

901907
if (!retro_unserialize([saveStateData bytes], [saveStateData length]))
902908
{
903-
NSDictionary *userInfo = @{
904-
NSLocalizedDescriptionKey: @"Failed to load save state.",
905-
NSLocalizedFailureReasonErrorKey: @"Genesis failed to load savestate data.",
906-
NSLocalizedRecoverySuggestionErrorKey: @"Check that the path is correct and file exists."
907-
};
908-
909-
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
910-
code:PVEmulatorCoreErrorCodeCouldNotLoadState
911-
userInfo:userInfo];
912-
*error = newError;
909+
if(error != NULL) {
910+
NSDictionary *userInfo = @{
911+
NSLocalizedDescriptionKey: @"Failed to load save state.",
912+
NSLocalizedFailureReasonErrorKey: @"Genesis failed to load savestate data.",
913+
NSLocalizedRecoverySuggestionErrorKey: @"Check that the path is correct and file exists."
914+
};
915+
916+
NSError *newError = [NSError errorWithDomain:PVEmulatorCoreErrorDomain
917+
code:PVEmulatorCoreErrorCodeCouldNotLoadState
918+
userInfo:userInfo];
919+
*error = newError;
920+
}
913921
DLOG(@"Unable to load save state");
914922
return NO;
915923
}

0 commit comments

Comments
 (0)