Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PAL/NTSC VDP Mode in Settings / Display Mode #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 49 additions & 8 deletions GenPlusGameCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -691,18 +691,30 @@ - (void)setCheat:(NSString *)code setType:(NSString *)type setEnabled:(BOOL)enab

- (NSArray <NSDictionary <NSString *, id> *> *)displayModes
{
if (![self.systemIdentifier isEqualToString:@"openemu.system.gg"])
return nil;

if (_availableDisplayModes.count == 0)
{
_availableDisplayModes = [NSMutableArray array];

NSArray <NSDictionary <NSString *, id> *> *availableModesWithDefault =
@[
Label(@"Screen"),
OptionToggleable(@"LCD Ghosting", @"ggLCDFilter"),
];
NSArray <NSDictionary <NSString *, id> *> *availableModesWithDefault;

if (![self.systemIdentifier isEqualToString:@"openemu.system.gg"]) {
availableModesWithDefault = @[
Label(@"VDP Mode"),
OptionDefault(@"Auto", @"vdpMode"),
Option(@"PAL", @"vdpMode"),
Option(@"NTSC", @"vdpMode"),
];
} else {
availableModesWithDefault = @[
Label(@"Screen"),
OptionToggleable(@"LCD Ghosting", @"ggLCDFilter"),
SeparatorItem(),
Label(@"VDP Mode"),
OptionDefault(@"Auto", @"vdpMode"),
Option(@"PAL", @"vdpMode"),
Option(@"NTSC", @"vdpMode"),
];
}

// Deep mutable copy
_availableDisplayModes = (NSMutableArray *)CFBridgingRelease(CFPropertyListCreateDeepCopy(kCFAllocatorDefault, (CFArrayRef)availableModesWithDefault, kCFPropertyListMutableContainers));
Expand Down Expand Up @@ -763,6 +775,33 @@ - (void)changeDisplayWithMode:(NSString *)displayMode
else
config.lcd = 0;
}
if ([displayMode isEqualToString:@"Auto"]) {
config.vdp_mode = 0;
vdp_pal = (region_code >> 6) & 0x01;
system_clock = vdp_pal ? MCLOCK_PAL : MCLOCK_NTSC;
audio_init(48000, vdp_pal ? pal_fps : ntsc_fps);
}
if ([displayMode isEqualToString:@"PAL"]) {
config.vdp_mode = 2;
vdp_pal = 1;
system_clock = vdp_pal ? MCLOCK_PAL : MCLOCK_NTSC;
audio_init(48000, vdp_pal ? pal_fps : ntsc_fps);
}
if ([displayMode isEqualToString:@"NTSC"]) {
config.vdp_mode = 1;
vdp_pal = 0;
system_clock = vdp_pal ? MCLOCK_PAL : MCLOCK_NTSC;
audio_init(48000, vdp_pal ? pal_fps : ntsc_fps);
}
}

- (void)loadDisplayModeWithOptions {
if (![self respondsToSelector:@selector(displayModeInfo)]) return;
// Restore vdp mode
NSString *vdpMode = self.displayModeInfo[@"vdpMode"];
if (vdpMode && ![vdpMode isEqualToString:@"Auto"]) {
[self changeDisplayWithMode:vdpMode];
}
}

# pragma mark - Misc Helper Methods
Expand Down Expand Up @@ -849,6 +888,8 @@ - (void)configureOptions
}
else
config.lcd = 0;

[self loadDisplayModeWithOptions];

config.render = 0; /* 1 = double resolution output (only when interlaced mode 2 is enabled) */
config.enhanced_vscroll = 0;
Expand Down
8 changes: 8 additions & 0 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<integer>0</integer>
<key>OEGameCoreSupportsCheatCode</key>
<true/>
<key>OEGameCoreSupportsDisplayModeChange</key>
<true/>
<key>OEGameCoreSupportsRewinding</key>
<true/>
<key>OERequiredFiles</key>
Expand Down Expand Up @@ -93,6 +95,8 @@
<integer>0</integer>
<key>OEGameCoreSupportsCheatCode</key>
<true/>
<key>OEGameCoreSupportsDisplayModeChange</key>
<true/>
<key>OEGameCoreSupportsRewinding</key>
<true/>
</dict>
Expand All @@ -104,6 +108,8 @@
<integer>0</integer>
<key>OEGameCoreSupportsCheatCode</key>
<true/>
<key>OEGameCoreSupportsDisplayModeChange</key>
<true/>
<key>OEGameCoreSupportsRewinding</key>
<true/>
</dict>
Expand All @@ -115,6 +121,8 @@
<integer>0</integer>
<key>OEGameCoreSupportsCheatCode</key>
<true/>
<key>OEGameCoreSupportsDisplayModeChange</key>
<true/>
<key>OEGameCoreSupportsRewinding</key>
<true/>
</dict>
Expand Down