git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit 9577cbce85bd8233bbd422855e9e60bd0d6f73ba
parent 6dd2f609f2f2e35d73ba5d55aada45d4ef5c851a
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Sun,  8 Jun 2025 11:51:34 +0300

Added the option to force integer scaling to the Cocoa port (SDL had it for ages), closes #699

Diffstat:
MCocoa/GBView.m16++++++++++++++++
MCocoa/Preferences.xib54+++++++++++++++++++++++++++++++++---------------------
2 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/Cocoa/GBView.m b/Cocoa/GBView.m @@ -148,6 +148,9 @@ static const uint8_t workboy_vk_to_key[] = { [self observeStandardDefaultsKey:@"GBAspectRatioUnkept" withBlock:^(id newValue) { [weakSelf setFrame:weakSelf.superview.frame]; }]; + [self observeStandardDefaultsKey:@"GBForceIntegerScale" withBlock:^(id newValue) { + [weakSelf setFrame:weakSelf.superview.frame]; + }]; [self observeStandardDefaultsKey:@"JoyKitDefaultControllers" withBlock:^(id newValue) { [weakSelf reassignControllers]; }]; @@ -300,6 +303,19 @@ static const uint8_t workboy_vk_to_key[] = { frame.origin.x = 0; } } + + if (_gb && [[NSUserDefaults standardUserDefaults] boolForKey:@"GBForceIntegerScale"]) { + double factor = self.window.backingScaleFactor; + double width = GB_get_screen_width(_gb) / factor; + double height = GB_get_screen_height(_gb) / factor; + + double new_width = floor(frame.size.width / width) * width; + double new_height = floor(frame.size.height / height) * height; + frame.origin.x += floor((frame.size.width - new_width) / 2); + frame.origin.y += floor((frame.size.height - new_height) / 2); + frame.size.width = new_width; + frame.size.height = new_height; + } [super setFrame:frame]; } diff --git a/Cocoa/Preferences.xib b/Cocoa/Preferences.xib @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23727" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <dependencies> <deployment identifier="macosx"/> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23727"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> @@ -98,11 +98,11 @@ <point key="canvasLocation" x="183" y="354"/> </window> <customView id="sRK-wO-K6R"> - <rect key="frame" x="0.0" y="0.0" width="320" height="545"/> + <rect key="frame" x="0.0" y="0.0" width="320" height="569"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <subviews> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="T91-rh-rRp"> - <rect key="frame" x="18" y="508" width="280" height="17"/> + <rect key="frame" x="18" y="532" width="280" height="17"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Scaling filter:" id="pXg-WY-8Q5"> <font key="font" metaFont="system"/> @@ -111,7 +111,7 @@ </textFieldCell> </textField> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6pP-kK-EEC" customClass="GBPreferencePopUpButton"> - <rect key="frame" x="30" y="475" width="262" height="26"/> + <rect key="frame" x="30" y="499" width="262" height="26"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <popUpButtonCell key="cell" type="push" title="Nearest neighbor (Pixelated)" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="neN-eo-LA7" id="I1w-05-lGl"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> @@ -205,7 +205,7 @@ </userDefinedRuntimeAttributes> </popUpButton> <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="spQ-Md-OFi" customClass="GBPreferenceButton"> - <rect key="frame" x="18" y="400" width="276" height="18"/> + <rect key="frame" x="18" y="424" width="276" height="18"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <buttonCell key="cell" type="check" title="Apply filters to screenshots" bezelStyle="regularSquare" imagePosition="left" inset="2" id="JbP-bE-w8A"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> @@ -216,7 +216,7 @@ </userDefinedRuntimeAttributes> </button> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wc3-2K-6CD"> - <rect key="frame" x="18" y="351" width="280" height="17"/> + <rect key="frame" x="18" y="375" width="280" height="17"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Color correction:" id="5Si-hz-EK3"> <font key="font" metaFont="system"/> @@ -225,7 +225,7 @@ </textFieldCell> </textField> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VEz-N4-uP6" customClass="GBPreferencePopUpButton"> - <rect key="frame" x="30" y="318" width="229" height="26"/> + <rect key="frame" x="30" y="342" width="229" height="26"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <popUpButtonCell key="cell" type="push" title="Disabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="D2J-wV-1vu" id="fNJ-Fi-yOm"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> @@ -251,7 +251,7 @@ </userDefinedRuntimeAttributes> </popUpButton> <slider verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NuA-mL-AJZ" customClass="GBPreferencesSlider"> - <rect key="frame" x="32" y="262" width="259" height="28"/> + <rect key="frame" x="32" y="286" width="259" height="28"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <sliderCell key="cell" continuous="YES" state="on" alignment="left" minValue="-256" maxValue="256" tickMarkPosition="below" numberOfTickMarks="3" sliderType="linear" id="KX7-G9-k0O"/> <userDefinedRuntimeAttributes> @@ -262,7 +262,7 @@ </userDefinedRuntimeAttributes> </slider> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cCm-Oa-FbN"> - <rect key="frame" x="18" y="296" width="280" height="17"/> + <rect key="frame" x="18" y="320" width="280" height="17"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Ambient light temperature:" id="Lso-GQ-pBl"> <font key="font" metaFont="system"/> @@ -271,7 +271,7 @@ </textFieldCell> </textField> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MLC-Rx-FgO"> - <rect key="frame" x="18" y="454" width="280" height="17"/> + <rect key="frame" x="18" y="478" width="280" height="17"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Frame blending:" id="UCa-EO-tzh"> <font key="font" metaFont="system"/> @@ -280,7 +280,7 @@ </textFieldCell> </textField> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lxk-db-Sxv" customClass="GBPreferencePopUpButton"> - <rect key="frame" x="30" y="421" width="262" height="26"/> + <rect key="frame" x="30" y="445" width="262" height="26"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <popUpButtonCell key="cell" type="push" title="Disabled" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="iHP-Yz-fiH" id="aQ6-HN-7Aj"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> @@ -300,7 +300,7 @@ </userDefinedRuntimeAttributes> </popUpButton> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8fG-zm-hpr"> - <rect key="frame" x="18" y="243" width="280" height="17"/> + <rect key="frame" x="18" y="267" width="280" height="17"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Color palette for monochrome models:" id="LAN-8Y-T7H"> <font key="font" metaFont="system"/> @@ -309,7 +309,7 @@ </textFieldCell> </textField> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Iwr-eI-SD1"> - <rect key="frame" x="30" y="210" width="262" height="26"/> + <rect key="frame" x="30" y="234" width="262" height="26"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <popUpButtonCell key="cell" type="push" title="Greyscale" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Ajr-5r-iIk" id="rEU-jh-m3j"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> @@ -330,7 +330,7 @@ </connections> </popUpButton> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Kz-cf-5X6"> - <rect key="frame" x="18" y="172" width="280" height="17"/> + <rect key="frame" x="18" y="196" width="280" height="17"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Display border:" id="HZd-qi-yyk"> <font key="font" metaFont="system"/> @@ -348,7 +348,7 @@ </textFieldCell> </textField> <popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="R9D-FV-bpd" customClass="GBPreferencePopUpButton"> - <rect key="frame" x="30" y="139" width="262" height="26"/> + <rect key="frame" x="30" y="163" width="262" height="26"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <popUpButtonCell key="cell" type="push" title="Never" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="1" imageScaling="proportionallyDown" inset="2" selectedItem="heL-AV-0az" id="DY9-2D-h1L"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> @@ -386,7 +386,7 @@ </connections> </popUpButton> <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Vfj-tg-7OP" customClass="GBPreferenceButton"> - <rect key="frame" x="18" y="118" width="286" height="18"/> + <rect key="frame" x="18" y="142" width="286" height="18"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> <buttonCell key="cell" type="check" title="Keep aspect ratio" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="lsj-rC-Eo6"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> @@ -397,8 +397,20 @@ <userDefinedRuntimeAttribute type="boolean" keyPath="invertValue" value="YES"/> </userDefinedRuntimeAttributes> </button> + <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="efH-Ad-A5M" customClass="GBPreferenceButton"> + <rect key="frame" x="18" y="120" width="286" height="18"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> + <buttonCell key="cell" type="check" title="Force integer scale" bezelStyle="regularSquare" imagePosition="left" inset="2" id="HLq-1D-th9"> + <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> + <font key="font" metaFont="system"/> + </buttonCell> + <userDefinedRuntimeAttributes> + <userDefinedRuntimeAttribute type="string" keyPath="preferenceName" value="GBForceIntegerScale"/> + <userDefinedRuntimeAttribute type="boolean" keyPath="invertValue" value="NO"/> + </userDefinedRuntimeAttributes> + </button> <button horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qCy-Se-vsG"> - <rect key="frame" x="266" y="319" width="25" height="25"/> + <rect key="frame" x="266" y="343" width="25" height="25"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <buttonCell key="cell" type="help" bezelStyle="helpButton" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="tAH-Lp-v24"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> @@ -420,11 +432,11 @@ </userDefinedRuntimeAttributes> </button> <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="EC8-82-Xxo"> - <rect key="frame" x="11" y="382" width="296" height="5"/> + <rect key="frame" x="11" y="406" width="296" height="5"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> </box> <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="eYo-73-EkT"> - <rect key="frame" x="8" y="195" width="296" height="5"/> + <rect key="frame" x="8" y="219" width="296" height="5"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> </box> <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="Snt-cX-yDv"> @@ -432,7 +444,7 @@ <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> </box> <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="O9O-Eq-PZb"> - <rect key="frame" x="273" y="15" width="17" height="28"/> + <rect key="frame" x="273" y="16" width="17" height="28"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <stepperCell key="cell" controlSize="small" continuous="YES" alignment="left" minValue="8" maxValue="64" doubleValue="12" id="E76-1u-cJx"> <connections>

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.