From afcb7b8579da645608dc97ef3476edda44db5146 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Tue, 10 Jul 2018 20:28:36 +0300 Subject: [PATCH 1/5] Fixed a regression where DMG mode on CGB would not activate on most DMG games. Fixes #98 --- BootROMs/cgb_boot.asm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BootROMs/cgb_boot.asm b/BootROMs/cgb_boot.asm index 77a25bc..ba13913 100644 --- a/BootROMs/cgb_boot.asm +++ b/BootROMs/cgb_boot.asm @@ -732,12 +732,11 @@ Preboot: ld a, [$143] bit 7, a - call z, EmulateDMG + ldh [$4C], a ldh a, [TitleChecksum] ld b, a - ldh [$4C], a ; One day, I will know what this switch does and how it differs from FF6C ldh a, [InputPalette] and a jr nz, .emulateDMGForCGBGame From dc4c23c0da1f86f04bc6e8ce62c9732de4675a70 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Tue, 10 Jul 2018 20:35:07 +0300 Subject: [PATCH 2/5] Worked around a macOS bug where fullscreen-mode SameBoy would render garbage on High Sierra. Fixed titlebar color when using the ugly Yosemite theme. --- Cocoa/Document.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cocoa/Document.m b/Cocoa/Document.m index 7cb0eea..c9205ce 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -334,7 +334,7 @@ static void printImage(GB_gameboy_t *gb, uint32_t *image, uint8_t height, NSMutableParagraphStyle *paragraph_style = [[NSMutableParagraphStyle alloc] init]; [paragraph_style setLineSpacing:2]; - self.mainWindow.backgroundColor = [NSColor blackColor]; + self.mainWindow.contentView.layer.backgroundColor = [[NSColor blackColor] CGColor]; self.debuggerSideViewInput.font = [NSFont userFixedPitchFontOfSize:12]; self.debuggerSideViewInput.textColor = [NSColor whiteColor]; From 5f58323c017fbbec292bcb5e922e8bfe950a2bd7 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Tue, 10 Jul 2018 21:33:03 +0300 Subject: [PATCH 3/5] Attempt to improve audio quality on frontend with big audio buffers --- Core/apu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Core/apu.c b/Core/apu.c index b5574c9..dee4c00 100644 --- a/Core/apu.c +++ b/Core/apu.c @@ -417,6 +417,14 @@ void GB_apu_copy_buffer(GB_gameboy_t *gb, GB_sample_t *dest, size_t count) dest[gb->apu_output.buffer_position + i] = output; } + if (gb->apu_output.buffer_position) { + if (gb->apu_output.buffer_size + (count - gb->apu_output.buffer_position) < count * 3) { + gb->apu_output.buffer_size += count - gb->apu_output.buffer_position; + gb->apu_output.buffer = realloc(gb->apu_output.buffer, + gb->apu_output.buffer_size * sizeof(*gb->apu_output.buffer)); + gb->apu_output.stream_started = false; + } + } count = gb->apu_output.buffer_position; } memcpy(dest, gb->apu_output.buffer, count * sizeof(*gb->apu_output.buffer)); From e5f4495ca0a57c438391308752d9354cef9472f8 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Wed, 11 Jul 2018 19:46:27 +0300 Subject: [PATCH 4/5] Turns out the last Cocoa fix was neither reliable or actually working. --- Cocoa/Document.m | 4 +--- Cocoa/Document.xib | 10 ++++++++-- Cocoa/GBBorderView.h | 5 +++++ Cocoa/GBBorderView.m | 26 ++++++++++++++++++++++++++ Cocoa/GBViewMetal.m | 7 ------- 5 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 Cocoa/GBBorderView.h create mode 100644 Cocoa/GBBorderView.m diff --git a/Cocoa/Document.m b/Cocoa/Document.m index c9205ce..9866064 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -333,9 +333,7 @@ static void printImage(GB_gameboy_t *gb, uint32_t *image, uint8_t height, NSMutableParagraphStyle *paragraph_style = [[NSMutableParagraphStyle alloc] init]; [paragraph_style setLineSpacing:2]; - - self.mainWindow.contentView.layer.backgroundColor = [[NSColor blackColor] CGColor]; - + self.debuggerSideViewInput.font = [NSFont userFixedPitchFontOfSize:12]; self.debuggerSideViewInput.textColor = [NSColor whiteColor]; self.debuggerSideViewInput.defaultParagraphStyle = paragraph_style; diff --git a/Cocoa/Document.xib b/Cocoa/Document.xib index 5694ecd..88c5275 100644 --- a/Cocoa/Document.xib +++ b/Cocoa/Document.xib @@ -50,10 +50,16 @@ - + - + + + + + + + diff --git a/Cocoa/GBBorderView.h b/Cocoa/GBBorderView.h new file mode 100644 index 0000000..477add1 --- /dev/null +++ b/Cocoa/GBBorderView.h @@ -0,0 +1,5 @@ +#import + +@interface GBBorderView : NSView + +@end diff --git a/Cocoa/GBBorderView.m b/Cocoa/GBBorderView.m new file mode 100644 index 0000000..a5f5e81 --- /dev/null +++ b/Cocoa/GBBorderView.m @@ -0,0 +1,26 @@ +#import "GBBorderView.h" + +@implementation GBBorderView + + +- (void)awakeFromNib +{ + self.wantsLayer = YES; +} + +- (BOOL)wantsUpdateLayer +{ + return YES; +} + +- (void)updateLayer +{ + /* Wonderful, wonderful windowserver(?) bug. Using 0,0,0 here would cause it to render garbage + on fullscreen windows on some High Sierra machines. Any other value, including the one used + here (which is rendered exactly the same due to rounding) works around this bug. */ + self.layer.backgroundColor = [NSColor colorWithCalibratedRed:0 + green:0 + blue:1.0 / 1024.0 + alpha:1.0].CGColor; +} +@end diff --git a/Cocoa/GBViewMetal.m b/Cocoa/GBViewMetal.m index 1c0a86f..34cd50b 100644 --- a/Cocoa/GBViewMetal.m +++ b/Cocoa/GBViewMetal.m @@ -71,13 +71,6 @@ static const vector_float2 rect[] = [self loadShader]; } -- (void)addSubview:(NSView *)view -{ - /* Fixes rounded corners */ - [super addSubview:view]; - [self setWantsLayer:YES]; -} - - (void) loadShader { NSError *error = nil; From 0783f131b85b96220ab1b211eda600e229ace6d7 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Wed, 11 Jul 2018 20:07:54 +0300 Subject: [PATCH 5/5] Update version to v0.11.1 --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 45e3b29..d81c774 100755 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ ifeq ($(MAKECMDGOALS),) MAKECMDGOALS := $(DEFAULT) endif -VERSION := 0.11 +VERSION := 0.11.1 export VERSION CONF ?= debug @@ -306,4 +306,4 @@ libretro: clean: rm -rf build -.PHONY: libretro \ No newline at end of file +.PHONY: libretro