Syncing with the App Store branch

This commit is contained in:
Lior Halphon 2024-11-08 14:53:16 +02:00
parent 6efefab526
commit 2dfde867a9
18 changed files with 56 additions and 36 deletions

View File

@ -5,8 +5,8 @@
@property (nonatomic, strong) void (^renderBlock)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer);
@property (nonatomic, readonly) UInt32 rate;
@property (nonatomic, readonly, getter=isPlaying) bool playing;
-(void) start;
-(void) stop;
-(id) initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block
- (void)start;
- (void)stop;
- (id)initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block
andSampleRate:(UInt32) rate;
@end

View File

@ -23,7 +23,7 @@ static OSStatus render(
AudioComponentInstance audioUnit;
}
-(id) initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block
- (id)initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block
andSampleRate:(UInt32) rate
{
if (!(self = [super init])) {

View File

@ -225,7 +225,7 @@
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="onn-R8-3vg" customClass="GBDebuggerButton">
<rect key="frame" x="102" y="26" width="26" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="bevel" title="Step Backwards" alternateTitle="backstep" bezelStyle="rounded" image="BackstepTemplate" imagePosition="only" alignment="center" enabled="NO" imageScaling="proportionallyDown" inset="2" id="WtK-kD-bf6">
<buttonCell key="cell" type="bevel" title="Step Backward" alternateTitle="backstep" bezelStyle="rounded" image="BackstepTemplate" imagePosition="only" alignment="center" enabled="NO" imageScaling="proportionallyDown" inset="2" id="WtK-kD-bf6">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>

View File

@ -2144,7 +2144,7 @@ static const debugger_command_t commands[] = {
{"step", 1, step, "Run the next instruction, stepping into function calls"},
{"finish", 1, finish, "Run until the current function returns"},
#ifndef DISABLE_REWIND
{"backstep", 5, backstep, "Step one instruction backwards, assuming constant inputs"},
{"backstep", 5, backstep, "Step one instruction backward, assuming constant inputs"},
{"bs", 2, }, /* Alias */
#endif
{"undo", 1, undo, "Revert the last command"},

View File

@ -1065,13 +1065,13 @@ exit:
}
/* Loading will silently stop if the format is incomplete */
void GB_load_battery(GB_gameboy_t *gb, const char *path)
int GB_load_battery(GB_gameboy_t *gb, const char *path)
{
GB_ASSERT_NOT_RUNNING_OTHER_THREAD(gb)
FILE *f = fopen(path, "rb");
if (!f) {
return;
return errno;
}
if (fread(gb->mbc_ram, 1, gb->mbc_ram_size, f) != gb->mbc_ram_size) {
@ -1090,7 +1090,7 @@ void GB_load_battery(GB_gameboy_t *gb, const char *path)
/* We must reset RTC here, or it will not advance. */
goto reset_rtc;
}
return;
return 0;
}
if (gb->cartridge_type->mbc_type == GB_HUC3) {
@ -1109,7 +1109,7 @@ void GB_load_battery(GB_gameboy_t *gb, const char *path)
/* We must reset RTC here, or it will not advance. */
goto reset_rtc;
}
return;
return 0;
}
rtc_save_t rtc_save;
@ -1174,7 +1174,7 @@ reset_rtc:
}
exit:
fclose(f);
return;
return 0;
}
unsigned GB_run(GB_gameboy_t *gb)

View File

@ -956,7 +956,7 @@ int GB_save_battery_to_buffer(GB_gameboy_t *gb, uint8_t *buffer, size_t size);
int GB_save_battery(GB_gameboy_t *gb, const char *path);
void GB_load_battery_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t size);
void GB_load_battery(GB_gameboy_t *gb, const char *path);
int GB_load_battery(GB_gameboy_t *gb, const char *path);
void GB_set_turbo_mode(GB_gameboy_t *gb, bool on, bool no_frame_skip);
void GB_set_rendering_disabled(GB_gameboy_t *gb, bool disabled);

View File

@ -1450,7 +1450,7 @@ typedef union {
}
}
- (uint8_t)LEDMaskForPlayer:(unsigned int)player
- (uint8_t)LEDMaskForPlayer:(unsigned)player
{
return player;
}

View File

@ -181,7 +181,7 @@ endif
# These must come before the -Wno- flags
WARNINGS += -Werror -Wall -Wno-unknown-warning -Wno-unknown-warning-option -Wno-missing-braces
WARNINGS += -Wno-nonnull -Wno-unused-result -Wno-multichar -Wno-int-in-bool-context -Wno-format-truncation
WARNINGS += -Wno-nonnull -Wno-unused-result -Wno-multichar -Wno-int-in-bool-context -Wno-format-truncation -Wno-nullability-completeness
# Only add this flag if the compiler supports it
ifeq ($(shell $(CC) -x c -c $(NULL) -o $(NULL) -Werror -Wpartial-availability 2> $(NULL); echo $$?),0)
@ -787,7 +787,7 @@ $(OBJ)/debian-binary:
$(LIBDIR)/libsameboy.o: $(CORE_OBJECTS)
-@$(MKDIR) -p $(dir $@)
@# This is a somewhat simple hack to force Clang and GCC to build a native object file out of one or many LTO objects
echo "static const char __attribute__((used)) x=0;"| $(CC) $(filter-out -flto,$(CFLAGS)) -c -x c - -o $(OBJ)/lto_hack.o
echo "static const char __attribute__((used)) x=0;"| $(CC) $(filter-out -flto,$(CFLAGS)) $(FAT_FLAGS) -c -x c - -o $(OBJ)/lto_hack.o
@# And this is a somewhat complicated hack to invoke the correct LTO-enabled LD command in a mostly cross-platform nature
$(CC) $(FAT_FLAGS) $(CFLAGS) $(LIBFLAGS) $^ $(OBJ)/lto_hack.o -o $@
-@rm $(OBJ)/lto_hack.o

View File

@ -151,7 +151,7 @@ typedef struct {
char audio_driver[16];
/* v0.15.2 */
bool allow_background_controllers;
bool gui_pallete_enabled; // Change the GUI palette only once the user changed the DMG palette
bool gui_palette_enabled; // Change the GUI palette only once the user changed the DMG palette
char dmg_palette_name[25];
hotkey_action_t hotkey_actions[2];
uint16_t agb_revision;

View File

@ -1383,7 +1383,7 @@ static void cycle_palette(unsigned index)
else {
configuration.dmg_palette++;
}
configuration.gui_pallete_enabled = true;
configuration.gui_palette_enabled = true;
update_gui_palette();
}
@ -1414,7 +1414,7 @@ static void cycle_palette_backwards(unsigned index)
else {
configuration.dmg_palette--;
}
configuration.gui_pallete_enabled = true;
configuration.gui_palette_enabled = true;
update_gui_palette();
}
@ -2164,7 +2164,7 @@ void run_gui(bool is_running)
/* Draw the background screen */
if (!converted_background) {
if (configuration.gui_pallete_enabled) {
if (configuration.gui_palette_enabled) {
update_gui_palette();
}
else {

View File

@ -1169,7 +1169,7 @@ int main(int argc, char **argv)
configuration.sgb_revision %= SGB_MAX;
configuration.dmg_palette %= 5;
if (configuration.dmg_palette) {
configuration.gui_pallete_enabled = true;
configuration.gui_palette_enabled = true;
}
configuration.border_mode %= GB_BORDER_ALWAYS + 1;
configuration.rumble_mode %= GB_RUMBLE_ALL_GAMES + 1;

View File

@ -5,14 +5,14 @@
#import "GBViewController.h"
#import "GBROMManager.h"
double CGPointSquaredDistance(CGPoint a, CGPoint b)
static double CGPointSquaredDistance(CGPoint a, CGPoint b)
{
double deltaX = a.x - b.x;
double deltaY = a.y - b.y;
return deltaX * deltaX + deltaY * deltaY;
}
double CGPointAngle(CGPoint a, CGPoint b)
static double CGPointAngle(CGPoint a, CGPoint b)
{
double deltaX = a.x - b.x;
double deltaY = a.y - b.y;
@ -117,6 +117,12 @@ static GB_key_mask_t angleToKeyMask(double angle)
self.usesSwipePad = self.usesSwipePad;
}
- (void)setDefaultScreenLabel
{
_screenLabel.text = @"Tap the Game Boy screen to open the menu and load a ROM from the library.";
}
- (instancetype)initWithLayout:(GBLayout *)layout;
{
self = [super initWithImage:nil];
@ -126,12 +132,12 @@ static GB_key_mask_t angleToKeyMask(double angle)
_touches = [NSMutableSet set];
_screenLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_screenLabel.text = @"Tap the Game Boy screen to open the menu and load a ROM from the library.";
_screenLabel.font = [UIFont systemFontOfSize:20 weight:UIFontWeightMedium];
_screenLabel.textAlignment = NSTextAlignmentCenter;
_screenLabel.textColor = [UIColor whiteColor];
_screenLabel.lineBreakMode = NSLineBreakByWordWrapping;
_screenLabel.numberOfLines = 0;
[self setDefaultScreenLabel];
[self addSubview:_screenLabel];
_dpadView = [[UIImageView alloc] initWithImage:[_layout.theme imageNamed:@"dpad"]];

View File

@ -291,7 +291,7 @@ static NSURL *StringToWebURL(NSString *string)
}] resume];
}
- (unsigned int)countForTag:(NSString *)tag
- (unsigned)countForTag:(NSString *)tag
{
return _tags[tag].unsignedIntValue;
}

View File

@ -1,5 +1,6 @@
#import "GBROMManager.h"
#import <copyfile.h>
#import <sys/stat.h>
@implementation GBROMManager
{

View File

@ -38,7 +38,9 @@
{
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.textLabel.text = rom.lastPathComponent;
cell.accessoryType = [rom isEqualToString:[GBROMManager sharedManager].currentROM]? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
bool isCurrentROM = [rom isEqualToString:[GBROMManager sharedManager].currentROM];
bool checkmark = isCurrentROM;
cell.accessoryType = checkmark? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
NSString *pngPath = [[[GBROMManager sharedManager] autosaveStateFileForROM:rom] stringByAppendingPathExtension:@"png"];
UIGraphicsBeginImageContextWithOptions((CGSize){60, 60}, false, self.view.window.screen.scale);
@ -94,7 +96,8 @@
- (void)romSelectedAtIndex:(unsigned)index
{
[GBROMManager sharedManager].currentROM = [GBROMManager sharedManager].allROMs[index];
NSString *rom = [GBROMManager sharedManager].allROMs[index];
[GBROMManager sharedManager].currentROM = rom;
[self.presentingViewController dismissViewControllerAnimated:true completion:nil];
}
@ -286,7 +289,7 @@ contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath
forRowAtIndexPath:indexPath];
}];
deleteAction.attributes = UIMenuElementAttributesDestructive;
return [UIMenu menuWithTitle:nil children:@[
NSMutableArray *items = @[
[UIAction actionWithTitle:@"Rename"
image:[UIImage systemImageNamed:@"pencil"]
identifier:nil
@ -299,8 +302,9 @@ contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath
handler:^(__kindof UIAction *action) {
[self duplicateROMAtIndex:indexPath.row];
}],
deleteAction,
]];
].mutableCopy;
[items addObject:deleteAction];
return [UIMenu menuWithTitle:nil children:items];
}];
}

View File

@ -351,9 +351,8 @@ static NSString const *typeLightTemp = @"typeLightTemp";
},
];
return @[
@{
@"items": @[
NSArray *rootItems = @[
@{
@"title": @"Emulation",
@"type": typeSubmenu,
@ -384,7 +383,12 @@ static NSString const *typeLightTemp = @"typeLightTemp";
@"class": [GBThemesViewController class],
@"image": [UIImage imageNamed:@"themeSettings"],
},
]
];
return @[
@{
@"items": rootItems,
}
];
}
@ -716,7 +720,9 @@ static id ValueForItem(NSDictionary *item)
}
}
else if (item[@"type"] == typeRadio) {
if ([ValueForItem(item) isEqual:item[@"value"]]) {
id settingValue = ValueForItem(item);
id itemValue = item[@"value"];
if (settingValue == itemValue || [settingValue isEqual:itemValue]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}

View File

@ -640,7 +640,10 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
- (void)saveStateToFile:(NSString *)file
{
GB_save_state(&_gb, file.fileSystemRepresentation);
NSString *tempPath = [file stringByAppendingPathExtension:@"tmp"];
if (!GB_save_state(&_gb, tempPath.UTF8String)) {
rename(tempPath.UTF8String, file.UTF8String);
}
NSData *data = [NSData dataWithBytes:_gbView.previousBuffer
length:GB_get_screen_width(&_gb) *
GB_get_screen_height(&_gb) *

View File

@ -11,7 +11,7 @@ int main(int argc, char * argv[])
@"GBColorCorrection": @(GB_COLOR_CORRECTION_MODERN_BALANCED),
@"GBAudioMode": @"switch",
@"GBHighpassFilter": @(GB_HIGHPASS_ACCURATE),
@"GBRewindLength": @(120),
@"GBRewindLength": @120,
@"GBFrameBlendingMode": @(GB_FRAME_BLENDING_MODE_ACCURATE),
@"GBDMGModel": @(GB_MODEL_DMG_B),