Skip to content

Commit

Permalink
Syncing with the App Store branch
Browse files Browse the repository at this point in the history
  • Loading branch information
LIJI32 committed Nov 8, 2024
1 parent 6efefab commit 2dfde86
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 36 deletions.
6 changes: 3 additions & 3 deletions AppleCommon/GBAudioClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion AppleCommon/GBAudioClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ @implementation GBAudioClient
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])) {
Expand Down
2 changes: 1 addition & 1 deletion Cocoa/Document.xib
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion Core/debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
10 changes: 5 additions & 5 deletions Core/gb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,13 +1065,13 @@ void GB_load_battery_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t
}

/* 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) {
Expand All @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -1174,7 +1174,7 @@ void GB_load_battery(GB_gameboy_t *gb, const char *path)
}
exit:
fclose(f);
return;
return 0;
}

unsigned GB_run(GB_gameboy_t *gb)
Expand Down
2 changes: 1 addition & 1 deletion Core/gb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion JoyKit/JOYController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ - (void)setPlayerLEDs:(uint8_t)mask
}
}

- (uint8_t)LEDMaskForPlayer:(unsigned int)player
- (uint8_t)LEDMaskForPlayer:(unsigned)player
{
return player;
}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion SDL/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions SDL/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion SDL/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 9 additions & 3 deletions iOS/GBBackgroundView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -117,6 +117,12 @@ - (void)reloadThemeImages
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];
Expand All @@ -126,12 +132,12 @@ - (instancetype)initWithLayout:(GBLayout *)layout;
_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"]];
Expand Down
2 changes: 1 addition & 1 deletion iOS/GBHub.m
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ - (void)addGamesForURL:(NSString *)url completion:(void(^)(GBHubStatus))completi
}] resume];
}

- (unsigned int)countForTag:(NSString *)tag
- (unsigned)countForTag:(NSString *)tag
{
return _tags[tag].unsignedIntValue;
}
Expand Down
1 change: 1 addition & 0 deletions iOS/GBROMManager.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "GBROMManager.h"
#import <copyfile.h>
#import <sys/stat.h>

@implementation GBROMManager
{
Expand Down
14 changes: 9 additions & 5 deletions iOS/GBROMViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ - (UITableViewCell *)cellForROM:(NSString *)rom
{
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);
Expand Down Expand Up @@ -94,7 +96,8 @@ - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInte

- (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];
}

Expand Down Expand Up @@ -286,7 +289,7 @@ - (UIContextMenuConfiguration *)tableView:(UITableView *)tableView
forRowAtIndexPath:indexPath];
}];
deleteAction.attributes = UIMenuElementAttributesDestructive;
return [UIMenu menuWithTitle:nil children:@[
NSMutableArray *items = @[
[UIAction actionWithTitle:@"Rename"
image:[UIImage systemImageNamed:@"pencil"]
identifier:nil
Expand All @@ -299,8 +302,9 @@ - (UIContextMenuConfiguration *)tableView:(UITableView *)tableView
handler:^(__kindof UIAction *action) {
[self duplicateROMAtIndex:indexPath.row];
}],
deleteAction,
]];
].mutableCopy;
[items addObject:deleteAction];
return [UIMenu menuWithTitle:nil children:items];
}];
}

Expand Down
16 changes: 11 additions & 5 deletions iOS/GBSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,8 @@ @implementation GBSettingsViewController
},
];

return @[
@{
@"items": @[

NSArray *rootItems = @[
@{
@"title": @"Emulation",
@"type": typeSubmenu,
Expand Down Expand Up @@ -384,7 +383,12 @@ @implementation GBSettingsViewController
@"class": [GBThemesViewController class],
@"image": [UIImage imageNamed:@"themeSettings"],
},
]
];


return @[
@{
@"items": rootItems,
}
];
}
Expand Down Expand Up @@ -716,7 +720,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}
}
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;
}
}
Expand Down
5 changes: 4 additions & 1 deletion iOS/GBViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,10 @@ - (void)verifyEntitlements

- (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) *
Expand Down
2 changes: 1 addition & 1 deletion iOS/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 2dfde86

Please sign in to comment.