├── .gitattributes ├── .github ├── FUNDING.yml ├── actions │ ├── LICENSE │ ├── cgb-acid2.gbc │ ├── cgb_sound.gb │ ├── dmg-acid2.gb │ ├── dmg_sound-2.gb │ ├── install_deps.sh │ ├── oam_bug-2.gb │ ├── sanity_tests.sh │ └── update_libretro.sh └── workflows │ ├── libretro.yml │ └── sanity.yml ├── .gitignore ├── AppleCommon ├── GBAudioClient.h ├── GBAudioClient.m ├── GBViewBase.h ├── GBViewBase.m ├── GBViewMetal.h └── GBViewMetal.m ├── BESS.md ├── BootROMs ├── SameBoyLogo.png ├── agb_boot.asm ├── cgb0_boot.asm ├── cgb_boot.asm ├── cgb_boot_fast.asm ├── dmg_boot.asm ├── hardware.inc ├── mgb_boot.asm ├── pb12.c ├── sameboot.inc ├── sgb2_boot.asm └── sgb_boot.asm ├── CHANGES.md ├── CONTRIBUTING.md ├── Cocoa ├── AppIcon.icns ├── AudioRecordingAccessoryView.xib ├── BackstepTemplate.png ├── BackstepTemplate@2x.png ├── BigSurToolbar.h ├── CPU.png ├── CPU@2x.png ├── CPU~solid.png ├── CPU~solid@2x.png ├── CPU~solid~dark.png ├── CPU~solid~dark@2x.png ├── Cartridge.icns ├── CheatSearch.xib ├── ColorCartridge.icns ├── ContinueTemplate.png ├── ContinueTemplate@2x.png ├── Display.png ├── Display@2x.png ├── Display~solid.png ├── Display~solid@2x.png ├── Display~solid~dark.png ├── Display~solid~dark@2x.png ├── Document.h ├── Document.m ├── Document.xib ├── FinishTemplate.png ├── FinishTemplate@2x.png ├── GBApp.h ├── GBApp.m ├── GBBorderView.h ├── GBBorderView.m ├── GBButtons.h ├── GBButtons.m ├── GBCenteredTextCell.h ├── GBCenteredTextCell.m ├── GBCheatSearchController.h ├── GBCheatSearchController.m ├── GBCheatTextFieldCell.h ├── GBCheatTextFieldCell.m ├── GBCheatWindowController.h ├── GBCheatWindowController.m ├── GBCompleteByteSlice.h ├── GBCompleteByteSlice.m ├── GBDebuggerButton.h ├── GBDebuggerButton.m ├── GBDeleteButtonCell.h ├── GBDeleteButtonCell.m ├── GBGLShader.h ├── GBGLShader.m ├── GBHexStatusBarRepresenter.h ├── GBHexStatusBarRepresenter.m ├── GBHueSliderCell.h ├── GBHueSliderCell.m ├── GBImageView.h ├── GBImageView.m ├── GBJoyConManager.h ├── GBJoyConManager.m ├── GBMemoryByteArray.h ├── GBMemoryByteArray.m ├── GBOSDView.h ├── GBOSDView.m ├── GBObjectView.h ├── GBObjectView.m ├── GBObjectViewItem.xib ├── GBOpenGLView.h ├── GBOpenGLView.m ├── GBOptionalVisualEffectView.h ├── GBOptionalVisualEffectView.m ├── GBPaletteEditorController.h ├── GBPaletteEditorController.m ├── GBPaletteView.h ├── GBPaletteView.m ├── GBPaletteViewRow.xib ├── GBPanel.h ├── GBPanel.m ├── GBPreferenceButton.h ├── GBPreferenceButton.m ├── GBPreferencePopUpButton.h ├── GBPreferencePopUpButton.m ├── GBPreferencesSlider.h ├── GBPreferencesSlider.m ├── GBPreferencesWindow.h ├── GBPreferencesWindow.m ├── GBS.xib ├── GBS11.xib ├── GBSplitView.h ├── GBSplitView.m ├── GBTerminalTextFieldCell.h ├── GBTerminalTextFieldCell.m ├── GBTintedImageCell.h ├── GBTintedImageCell.m ├── GBTitledPopUpButton.h ├── GBTitledPopUpButton.m ├── GBView.h ├── GBView.m ├── GBViewGL.h ├── GBViewGL.m ├── GBVisualizerView.h ├── GBVisualizerView.m ├── GBWarningPopover.h ├── GBWarningPopover.m ├── HelpTemplate.png ├── HelpTemplate@2x.png ├── HorizontalJoyConLeftTemplate.png ├── HorizontalJoyConLeftTemplate@2x.png ├── HorizontalJoyConRightTemplate.png ├── HorizontalJoyConRightTemplate@2x.png ├── Icon.png ├── Icon@2x.png ├── Info.plist ├── InterruptTemplate.png ├── InterruptTemplate@2x.png ├── JoyConDualTemplate.png ├── JoyConDualTemplate@2x.png ├── JoyConLeftTemplate.png ├── JoyConLeftTemplate@2x.png ├── JoyConRightTemplate.png ├── JoyConRightTemplate@2x.png ├── Joypad.png ├── Joypad@2x.png ├── Joypad~dark.png ├── Joypad~dark@2x.png ├── Joypad~solid.png ├── Joypad~solid@2x.png ├── KeyboardShortcutPrivateAPIs.h ├── License.html ├── MainMenu.xib ├── NSImageNamedDarkSupport.m ├── NSObject+DefaultsObserver.h ├── NSObject+DefaultsObserver.m ├── NSObject+MavericksCompat.m ├── NSString+StringForKey.h ├── NSString+StringForKey.m ├── NSTextFieldCell+Inset.h ├── NSTextFieldCell+Inset.m ├── NSToolbarItem+NoOverflow.m ├── Next.png ├── Next@2x.png ├── NextTemplate.png ├── NextTemplate@2x.png ├── Pause.png ├── Pause@2x.png ├── PkgInfo ├── Play.png ├── Play@2x.png ├── PopoverView.xib ├── Preferences.xib ├── Previous.png ├── Previous@2x.png ├── Rewind.png ├── Rewind@2x.png ├── Speaker.png ├── Speaker@2x.png ├── Speaker~dark.png ├── Speaker~dark@2x.png ├── Speaker~solid.png ├── Speaker~solid@2x.png ├── StepTemplate.png ├── StepTemplate@2x.png ├── UpdateWindow.xib ├── Updates.png ├── Updates@2x.png ├── Updates~solid.png ├── Updates~solid@2x.png ├── Updates~solid~dark.png ├── Updates~solid~dark@2x.png └── main.m ├── Core ├── apu.c ├── apu.h ├── camera.c ├── camera.h ├── cheat_search.c ├── cheat_search.h ├── cheats.c ├── cheats.h ├── debugger.c ├── debugger.h ├── defs.h ├── display.c ├── display.h ├── gb.c ├── gb.h ├── graphics │ ├── agb_border.inc │ ├── cgb_border.inc │ ├── dmg_border.inc │ ├── mgb_border.inc │ ├── sgb_animation_logo.inc │ └── sgb_border.inc ├── joypad.c ├── joypad.h ├── mbc.c ├── mbc.h ├── memory.c ├── memory.h ├── model.h ├── printer.c ├── printer.h ├── random.c ├── random.h ├── rewind.c ├── rewind.h ├── rumble.c ├── rumble.h ├── save_state.c ├── save_state.h ├── sgb.c ├── sgb.h ├── sm83_cpu.c ├── sm83_cpu.h ├── sm83_disassembler.c ├── symbol_hash.c ├── symbol_hash.h ├── timing.c ├── timing.h ├── workboy.c └── workboy.h ├── FreeDesktop ├── AppIcon │ ├── 128x128.png │ ├── 16x16.png │ ├── 256x256.png │ ├── 32x32.png │ ├── 512x512.png │ └── 64x64.png ├── Cartridge │ ├── 128x128.png │ ├── 16x16.png │ ├── 256x256.png │ ├── 32x32.png │ ├── 512x512.png │ └── 64x64.png ├── ColorCartridge │ ├── 128x128.png │ ├── 16x16.png │ ├── 256x256.png │ ├── 32x32.png │ ├── 512x512.png │ └── 64x64.png ├── sameboy.desktop └── sameboy.xml ├── HexFiend ├── HFAnnotatedTree.h ├── HFAnnotatedTree.m ├── HFBTree.h ├── HFBTree.m ├── HFBTreeByteArray.h ├── HFBTreeByteArray.m ├── HFByteArray.h ├── HFByteArray.m ├── HFByteArray_Internal.h ├── HFByteSlice.h ├── HFByteSlice.m ├── HFByteSlice_Private.h ├── HFController.h ├── HFController.m ├── HFFullMemoryByteArray.h ├── HFFullMemoryByteArray.m ├── HFFullMemoryByteSlice.h ├── HFFullMemoryByteSlice.m ├── HFFunctions.h ├── HFFunctions.m ├── HFFunctions_Private.h ├── HFGlyphTrie.h ├── HFGlyphTrie.m ├── HFHexTextRepresenter.h ├── HFHexTextRepresenter.m ├── HFLayoutRepresenter.h ├── HFLayoutRepresenter.m ├── HFLineCountingRepresenter.h ├── HFLineCountingRepresenter.m ├── HFLineCountingView.h ├── HFLineCountingView.m ├── HFPasteboardOwner.h ├── HFPasteboardOwner.m ├── HFPrivilegedHelperConnection.h ├── HFRepresenter.h ├── HFRepresenter.m ├── HFRepresenterHexTextView.h ├── HFRepresenterHexTextView.m ├── HFRepresenterStringEncodingTextView.h ├── HFRepresenterStringEncodingTextView.m ├── HFRepresenterTextView.h ├── HFRepresenterTextView.m ├── HFRepresenterTextViewCallout.h ├── HFRepresenterTextViewCallout.m ├── HFRepresenterTextView_Internal.h ├── HFRepresenter_Internal.h ├── HFSharedMemoryByteSlice.h ├── HFSharedMemoryByteSlice.m ├── HFStringEncodingTextRepresenter.h ├── HFStringEncodingTextRepresenter.m ├── HFTextRepresenter.h ├── HFTextRepresenter.m ├── HFTextRepresenter_Internal.h ├── HFTextRepresenter_KeyBinding.m ├── HFTextVisualStyleRun.h ├── HFTextVisualStyleRun.m ├── HFTypes.h ├── HFVerticalScrollerRepresenter.h ├── HFVerticalScrollerRepresenter.m ├── HexFiend.h ├── HexFiend_2_Framework_Prefix.pch └── License.txt ├── JoyKit ├── ControllerConfiguration.inc ├── JOYAxes2D.h ├── JOYAxes2D.m ├── JOYAxes3D.h ├── JOYAxes3D.m ├── JOYAxis.h ├── JOYAxis.m ├── JOYButton.h ├── JOYButton.m ├── JOYController.h ├── JOYController.m ├── JOYElement.h ├── JOYElement.m ├── JOYEmulatedButton.h ├── JOYEmulatedButton.m ├── JOYFullReportElement.h ├── JOYFullReportElement.m ├── JOYHat.h ├── JOYHat.m ├── JOYInput.h ├── JOYInput.m ├── JOYMultiplayerController.h ├── JOYMultiplayerController.m ├── JOYSubElement.h ├── JOYSubElement.m └── JoyKit.h ├── LICENSE ├── Makefile ├── Misc ├── Palettes │ ├── Canyon.sbp │ ├── Desert.sbp │ ├── Evening.sbp │ ├── Fog.sbp │ ├── Green Slate.sbp │ ├── Green Tea.sbp │ ├── Lavender.sbp │ ├── Magic Eggplant.sbp │ ├── Mystic Blue.sbp │ ├── Pink Pop.sbp │ ├── Radioactive Pea.sbp │ ├── Rose.sbp │ ├── Seaweed.sbp │ └── Twilight.sbp └── registers.sym ├── OpenDialog ├── cocoa.m ├── gtk.c ├── open_dialog.h └── windows.c ├── QuickLook ├── CartridgeTemplate.png ├── ColorCartridgeTemplate.png ├── GBPreviewProvider.h ├── GBPreviewProvider.m ├── GBThumbnailProvider.h ├── GBThumbnailProvider.m ├── Info.plist ├── Previewer.plist ├── Thumbnailer.plist ├── UniversalCartridgeTemplate.png ├── exports.sym ├── generator.m ├── get_image_for_rom.c ├── get_image_for_rom.h ├── main.c └── plugin.entitlements ├── README.md ├── SDL ├── audio.c ├── audio │ ├── audio.h │ ├── openal.c │ ├── sdl.c │ └── xaudio2.c ├── background.bmp ├── configuration.c ├── configuration.h ├── console.c ├── console.h ├── font.c ├── font.h ├── gui.c ├── gui.h ├── main.c ├── opengl_compat.c ├── opengl_compat.h ├── shader.c ├── shader.h ├── utils.c ├── utils.h ├── windows_associations.c └── windows_associations.h ├── Shaders ├── AAOmniScaleLegacy.fsh ├── AAScale2x.fsh ├── AAScale4x.fsh ├── Bilinear.fsh ├── CRT.fsh ├── FlatCRT.fsh ├── HQ2x.fsh ├── LCD.fsh ├── MasterShader.fsh ├── MasterShader.metal ├── MonoLCD.fsh ├── NearestNeighbor.fsh ├── OmniScale.fsh ├── OmniScaleLegacy.fsh ├── Scale2x.fsh ├── Scale4x.fsh └── SmoothBilinear.fsh ├── Tester └── main.c ├── Windows ├── Cartridge.ico ├── ColorCartridge.ico ├── crt.c ├── dirent.c ├── dirent.h ├── inttypes.h ├── limits.h ├── manifest.xml ├── math.c ├── msvcrt.def ├── pthread.h ├── resources.rc ├── sameboy.ico ├── stdint.h ├── stdio.c ├── stdio.h ├── stdlib.h ├── string.h ├── unistd.h └── utf8_compat.c ├── XdgThumbnailer ├── emulate.c ├── emulate.h ├── main.c ├── resources.gresource.xml └── sameboy.thumbnailer ├── build-faq.md ├── iOS ├── AppIcon60x60@2x.png ├── AppIcon76x76@2x.png ├── Assets.car ├── CameraRotateTemplate@2x.png ├── CameraRotateTemplate@3x.png ├── Cartridge.png ├── CheatsTemplate@2x.png ├── CheatsTemplate@3x.png ├── ColorCartridge.png ├── FolderTemplate@2x.png ├── FolderTemplate@3x.png ├── GBAboutController.h ├── GBAboutController.m ├── GBActivityViewController.h ├── GBActivityViewController.m ├── GBBackgroundView.h ├── GBBackgroundView.m ├── GBCheatsController.h ├── GBCheatsController.m ├── GBCheckableAlertController.h ├── GBCheckableAlertController.m ├── GBColorWell.h ├── GBColorWell.m ├── GBHapticManager.h ├── GBHapticManager.m ├── GBHapticManagerLegacy.h ├── GBHapticManagerLegacy.m ├── GBHorizontalLayout.h ├── GBHorizontalLayout.m ├── GBLayout.h ├── GBLayout.m ├── GBLibraryViewController.h ├── GBLibraryViewController.m ├── GBMenuButton.h ├── GBMenuButton.m ├── GBMenuViewController.h ├── GBMenuViewController.m ├── GBOptionViewController.h ├── GBOptionViewController.m ├── GBPaletteEditor.h ├── GBPaletteEditor.m ├── GBPalettePicker.h ├── GBPalettePicker.m ├── GBPrinterFeedController.h ├── GBPrinterFeedController.m ├── GBROMManager.h ├── GBROMManager.m ├── GBROMViewController.h ├── GBROMViewController.m ├── GBSettingsViewController.h ├── GBSettingsViewController.m ├── GBSlider.h ├── GBSlider.m ├── GBSlotButton.h ├── GBSlotButton.m ├── GBStatesViewController.h ├── GBStatesViewController.m ├── GBTheme.h ├── GBTheme.m ├── GBThemePreviewController.h ├── GBThemePreviewController.m ├── GBThemesViewController.h ├── GBThemesViewController.m ├── GBVerticalLayout.h ├── GBVerticalLayout.m ├── GBView.h ├── GBView.m ├── GBViewController.h ├── GBViewController.m ├── GBZipReader.h ├── GBZipReader.m ├── GCExtendedGamepad+AllElements.h ├── GCExtendedGamepad+AllElements.m ├── Info.plist ├── LaunchScreen.storyboard ├── License.html ├── LinkCableTemplate@2x.png ├── LinkCableTemplate@3x.png ├── ModelTemplate@2x.png ├── ModelTemplate@3x.png ├── PrinterTemplate@2x.png ├── PrinterTemplate@3x.png ├── UILabel+TapLocation.h ├── UILabel+TapLocation.m ├── UIToolbar+disableCompact.h ├── UIToolbar+disableCompact.m ├── audioSettings@2x.png ├── audioSettings@3x.png ├── button2-tint@2x.png ├── button2-tint@3x.png ├── button2@2x.png ├── button2@3x.png ├── button2Pressed-tint@2x.png ├── button2Pressed-tint@3x.png ├── button2Pressed@2x.png ├── button2Pressed@3x.png ├── button@2x.png ├── button@3x.png ├── buttonPressed@2x.png ├── buttonPressed@3x.png ├── controlsSettings@2x.png ├── controlsSettings@3x.png ├── deb-control ├── deb-postinst ├── deb-prerm ├── dpad-tint@2x.png ├── dpad-tint@3x.png ├── dpad@2x.png ├── dpad@3x.png ├── dpadShadow@2x.png ├── dpadShadow@3x.png ├── dpadShadowDiagonal@2x.png ├── dpadShadowDiagonal@3x.png ├── emulationSettings@2x.png ├── emulationSettings@3x.png ├── installer.entitlements ├── installer.m ├── jailbreak.entitlements ├── logo@2x.png ├── logo@3x.png ├── main.m ├── sideload.entitlements ├── swipepad-tint@2x.png ├── swipepad-tint@3x.png ├── swipepad@2x.png ├── swipepad@3x.png ├── swipepadShadow@2x.png ├── swipepadShadow@3x.png ├── swipepadShadowDiagonal@2x.png ├── swipepadShadowDiagonal@3x.png ├── themeSettings@2x.png ├── themeSettings@3x.png ├── videoSettings@2x.png ├── videoSettings@3x.png ├── waveform.weak@2x.png └── waveform.weak@3x.png ├── libretro ├── Makefile ├── Makefile.common ├── gitlab-ci.yml ├── jni │ ├── Android.mk │ └── Application.mk ├── libretro.c ├── libretro.h ├── libretro_core_options.inc ├── link.T └── retro_inline.h ├── sameboy.pc.in └── version.mk /.gitattributes: -------------------------------------------------------------------------------- 1 | # Always use LF line endings for shaders 2 | *.fsh text eol=lf 3 | *.metal text eol=lf 4 | 5 | HexFiend/* linguist-vendored 6 | *.inc linguist-language=C 7 | Core/*.h linguist-language=C 8 | SDL/*.h linguist-language=C 9 | Windows/*.h linguist-language=C 10 | XdgThumbnailer/*.h linguist-language=C 11 | Cocoa/*.h linguist-language=Objective-C 12 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: LIJI32 4 | -------------------------------------------------------------------------------- /.github/actions/LICENSE: -------------------------------------------------------------------------------- 1 | Blargg's Test ROMs by Shay Green 2 | 3 | Acid2 tests by Matt Currie under MIT: 4 | 5 | MIT License 6 | 7 | Copyright (c) 2020 Matt Currie 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. -------------------------------------------------------------------------------- /.github/actions/cgb-acid2.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/.github/actions/cgb-acid2.gbc -------------------------------------------------------------------------------- /.github/actions/cgb_sound.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/.github/actions/cgb_sound.gb -------------------------------------------------------------------------------- /.github/actions/dmg-acid2.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/.github/actions/dmg-acid2.gb -------------------------------------------------------------------------------- /.github/actions/dmg_sound-2.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/.github/actions/dmg_sound-2.gb -------------------------------------------------------------------------------- /.github/actions/install_deps.sh: -------------------------------------------------------------------------------- 1 | case `echo $1 | cut -d '-' -f 1` in 2 | ubuntu) 3 | sudo apt-get -qq update 4 | sudo apt-get install -yq bison libpng-dev pkg-config libsdl2-dev libgdk-pixbuf2.0-dev 5 | ( 6 | cd `mktemp -d` 7 | curl -L https://github.com/rednex/rgbds/archive/v0.6.0.zip > rgbds.zip 8 | unzip rgbds.zip 9 | cd rgbds-* 10 | make -sj 11 | sudo make install 12 | cd .. 13 | rm -rf * 14 | ) 15 | 16 | ( 17 | cd `mktemp -d` 18 | curl -L https://github.com/BR903/cppp/archive/refs/heads/master.zip > cppp.zip 19 | unzip cppp.zip 20 | cd cppp-* 21 | make -sj 22 | sudo make install 23 | cd .. 24 | rm -rf * 25 | ) 26 | 27 | 28 | ;; 29 | macos) 30 | brew install rgbds sdl2 cppp 31 | ;; 32 | *) 33 | echo "Unsupported OS" 34 | exit 1 35 | ;; 36 | esac -------------------------------------------------------------------------------- /.github/actions/oam_bug-2.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/.github/actions/oam_bug-2.gb -------------------------------------------------------------------------------- /.github/actions/sanity_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | ./build/bin/tester/sameboy_tester --jobs 5 \ 6 | --length 45 .github/actions/cgb_sound.gb \ 7 | --length 10 .github/actions/cgb-acid2.gbc \ 8 | --length 10 .github/actions/dmg-acid2.gb \ 9 | --dmg --length 45 .github/actions/dmg_sound-2.gb \ 10 | --dmg --length 20 .github/actions/oam_bug-2.gb 11 | 12 | mv .github/actions/dmg-acid2.bmp .github/actions/dmg-mode-acid2.bmp 13 | 14 | ./build/bin/tester/sameboy_tester \ 15 | --dmg --length 10 .github/actions/dmg-acid2.gb 16 | 17 | set +e 18 | 19 | FAILED_TESTS=` 20 | shasum .github/actions/*.bmp | grep -E -v \(\ 21 | 64c3fd9a5fe9aee40fe15f3371029c0d2f20f5bc\ \ .github/actions/cgb-acid2.bmp\|\ 22 | dbcc438dcea13b5d1b80c5cd06bda2592cc5d9e0\ \ .github/actions/cgb_sound.bmp\|\ 23 | 0caadf9634e40247ae9c15ff71992e8f77bbf89e\ \ .github/actions/dmg-acid2.bmp\|\ 24 | fbdb5e342bfdd2edda3ea5601d35d0ca60d18034\ \ .github/actions/dmg-mode-acid2.bmp\|\ 25 | c9e944b7e01078bdeba1819bc2fa9372b111f52d\ \ .github/actions/dmg_sound-2.bmp\|\ 26 | f0172cc91867d3343fbd113a2bb98100074be0de\ \ .github/actions/oam_bug-2.bmp\ 27 | \)` 28 | 29 | if [ -n "$FAILED_TESTS" ] ; then 30 | echo "Failed the following tests:" 31 | echo $FAILED_TESTS | tr " " "\n" | grep -o -E "[^/]+\.bmp" | sed s/.bmp// | sort 32 | exit 1 33 | fi 34 | 35 | echo Passed all tests -------------------------------------------------------------------------------- /.github/actions/update_libretro.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | 3 | git fetch --tags 4 | LATEST=$(git tag --sort=-creatordate | grep "^v" | grep -v libretro | head -n 1) 5 | 6 | if [ $(git tag -l "$LATEST"-libretro) ]; then 7 | echo "The libretro branch is already up-to-date" 8 | exit 0 9 | fi 10 | 11 | git config --global --add --bool push.autoSetupRemote true 12 | git config --global user.name 'Libretro Updater' 13 | git config --global user.email '<>' 14 | 15 | cp libretro/gitlab-ci.yml .gitlab-ci.yml 16 | 17 | echo "Switching to tag $LATEST" 18 | git branch --delete libretro || true 19 | git checkout tags/$LATEST -b libretro 20 | 21 | echo "Building boot ROMs..." 22 | make -j bootroms 23 | 24 | echo "Updating branch" 25 | mv build/bin/BootROMs BootROMs/prebuilt 26 | git add BootROMs/prebuilt/* .gitlab-ci.yml 27 | git commit -m "Update libretro branch to $LATEST" 28 | git tag "$LATEST"-libretro 29 | git push --force 30 | git push --tags 31 | -------------------------------------------------------------------------------- /.github/workflows/libretro.yml: -------------------------------------------------------------------------------- 1 | name: "libretro branch update" 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | libretro-prebuilt-update: 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | os: [ubuntu-latest] 14 | runs-on: ${{ matrix.os }} 15 | steps: 16 | - uses: actions/checkout@v3 17 | name: Checkout 18 | with: 19 | repository: LIJI32/SameBoy 20 | token: ${{ secrets.WEBSITETOKEN }} 21 | submodules: false 22 | - name: Install Deps 23 | shell: bash 24 | run: | 25 | ./.github/actions/install_deps.sh ${{ matrix.os }} 26 | - name: Build Boot ROMs and Push 27 | run: | 28 | ./.github/actions/update_libretro.sh 29 | -------------------------------------------------------------------------------- /.github/workflows/sanity.yml: -------------------------------------------------------------------------------- 1 | name: "Bulidability and Sanity" 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - '*' 7 | - '!libretro' 8 | 9 | jobs: 10 | sanity: 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | os: [macos-latest, ubuntu-latest, ubuntu-22.04] 15 | cc: [gcc, clang] 16 | include: 17 | - os: macos-latest 18 | cc: clang 19 | extra_targets: cocoa ios-ipa ios-deb 20 | exclude: 21 | - os: macos-latest 22 | cc: gcc 23 | runs-on: ${{ matrix.os }} 24 | steps: 25 | - uses: actions/checkout@v3 26 | - name: Install deps 27 | shell: bash 28 | run: | 29 | ./.github/actions/install_deps.sh ${{ matrix.os }} 30 | - name: Build 31 | run: | 32 | ${{ matrix.cc }} -v; (make -j all CONF=release CC=${{ matrix.cc }} || (echo "==== Build Failed ==="; make all CONF=release CC=${{ matrix.cc }})) 33 | - name: Sanity tests 34 | shell: bash 35 | run: | 36 | ./.github/actions/sanity_tests.sh 37 | - name: Upload binaries 38 | uses: actions/upload-artifact@v4 39 | with: 40 | name: sameboy-canary-${{ matrix.os }}-${{ matrix.cc }} 41 | path: | 42 | build/bin 43 | build/lib 44 | build/include 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build -------------------------------------------------------------------------------- /AppleCommon/GBAudioClient.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface GBAudioClient : NSObject 5 | @property (nonatomic, strong) void (^renderBlock)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer); 6 | @property (nonatomic, readonly) UInt32 rate; 7 | @property (nonatomic, readonly, getter=isPlaying) bool playing; 8 | - (void)start; 9 | - (void)stop; 10 | - (id)initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block 11 | andSampleRate:(UInt32) rate; 12 | @end 13 | -------------------------------------------------------------------------------- /AppleCommon/GBViewBase.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #if TARGET_OS_IPHONE 4 | #define NSView UIView 5 | #import 6 | #else 7 | #import 8 | #endif 9 | 10 | #import 11 | 12 | typedef enum { 13 | GB_FRAME_BLENDING_MODE_DISABLED, 14 | GB_FRAME_BLENDING_MODE_SIMPLE, 15 | GB_FRAME_BLENDING_MODE_ACCURATE, 16 | GB_FRAME_BLENDING_MODE_ACCURATE_EVEN = GB_FRAME_BLENDING_MODE_ACCURATE, 17 | GB_FRAME_BLENDING_MODE_ACCURATE_ODD, 18 | } GB_frame_blending_mode_t; 19 | 20 | @interface GBViewBase : NSView 21 | { 22 | @public 23 | GB_gameboy_t *_gb; 24 | } 25 | 26 | @property (nonatomic) GB_gameboy_t *gb; 27 | @property (nonatomic) GB_frame_blending_mode_t frameBlendingMode; 28 | @property (nonatomic, strong) NSView *internalView; 29 | - (void) flip; 30 | - (uint32_t *) pixels; 31 | - (void)screenSizeChanged; 32 | - (void) createInternalView; 33 | - (uint32_t *)currentBuffer; 34 | - (uint32_t *)previousBuffer; 35 | - (instancetype)mirroredView; 36 | @end 37 | -------------------------------------------------------------------------------- /AppleCommon/GBViewMetal.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #if TARGET_OS_IPHONE 4 | #import "../iOS/GBView.h" 5 | #else 6 | #import "../Cocoa/GBView.h" 7 | #endif 8 | 9 | @interface GBViewMetal : GBView 10 | + (bool) isSupported; 11 | @end 12 | -------------------------------------------------------------------------------- /BootROMs/SameBoyLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/BootROMs/SameBoyLogo.png -------------------------------------------------------------------------------- /BootROMs/agb_boot.asm: -------------------------------------------------------------------------------- 1 | DEF AGB = 1 2 | include "cgb_boot.asm" 3 | -------------------------------------------------------------------------------- /BootROMs/cgb0_boot.asm: -------------------------------------------------------------------------------- 1 | DEF CGB0 = 1 2 | include "cgb_boot.asm" 3 | -------------------------------------------------------------------------------- /BootROMs/cgb_boot_fast.asm: -------------------------------------------------------------------------------- 1 | DEF FAST = 1 2 | include "cgb_boot.asm" 3 | -------------------------------------------------------------------------------- /BootROMs/mgb_boot.asm: -------------------------------------------------------------------------------- 1 | DEF MGB = 1 2 | include "dmg_boot.asm" 3 | -------------------------------------------------------------------------------- /BootROMs/sameboot.inc: -------------------------------------------------------------------------------- 1 | IF !DEF(SAMEBOY_INC) 2 | DEF SAMEBOY_INC EQU 1 3 | 4 | include "hardware.inc" 5 | 6 | DEF rKEY0 EQU $FF4C 7 | DEF rBANK EQU $FF50 8 | 9 | DEF rJOYP EQU rP1 10 | 11 | 12 | MACRO lb ; r16, high, low 13 | ld \1, LOW(\2) << 8 | LOW(\3) 14 | ENDM 15 | 16 | 17 | MACRO header_section ; name, address 18 | PUSHS 19 | SECTION "\1", ROM0[\2] 20 | \1: 21 | POPS 22 | ENDM 23 | header_section EntryPoint, $0100 24 | header_section NintendoLogo, $0104 25 | header_section NintendoLogoEnd, $0134 26 | header_section Title, $0134 27 | header_section ManufacturerCode, $013F 28 | header_section CGBFlag, $0143 29 | header_section NewLicenseeCode, $0144 30 | header_section SGBFlag, $0146 31 | header_section CartridgeType, $0147 32 | header_section ROMSize, $0148 33 | header_section RAMSize, $0149 34 | header_section DestinationCode, $014A 35 | header_section OldLicenseeCode, $014B 36 | header_section MaskRomVersion, $014C 37 | header_section HeaderChecksum, $014D 38 | header_section GlobalChecksum, $014E 39 | 40 | ENDC 41 | -------------------------------------------------------------------------------- /BootROMs/sgb2_boot.asm: -------------------------------------------------------------------------------- 1 | DEF SGB2 = 1 2 | include "sgb_boot.asm" 3 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | See https://sameboy.github.io/changelog/ -------------------------------------------------------------------------------- /Cocoa/AppIcon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/AppIcon.icns -------------------------------------------------------------------------------- /Cocoa/BackstepTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/BackstepTemplate.png -------------------------------------------------------------------------------- /Cocoa/BackstepTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/BackstepTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/BigSurToolbar.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /* Backport the toolbarStyle property to allow compilation with older SDKs*/ 4 | #ifndef __MAC_10_16 5 | typedef NS_ENUM(NSInteger, NSWindowToolbarStyle) { 6 | // The default value. The style will be determined by the window's given configuration 7 | NSWindowToolbarStyleAutomatic, 8 | // The toolbar will appear below the window title 9 | NSWindowToolbarStyleExpanded, 10 | // The toolbar will appear below the window title and the items in the toolbar will attempt to have equal widths when possible 11 | NSWindowToolbarStylePreference, 12 | // The window title will appear inline with the toolbar when visible 13 | NSWindowToolbarStyleUnified, 14 | // Same as NSWindowToolbarStyleUnified, but with reduced margins in the toolbar allowing more focus to be on the contents of the window 15 | NSWindowToolbarStyleUnifiedCompact 16 | } API_AVAILABLE(macos(11.0)); 17 | 18 | @interface NSWindow (toolbarStyle) 19 | @property (nonatomic) NSWindowToolbarStyle toolbarStyle API_AVAILABLE(macos(11.0)); 20 | @end 21 | 22 | @interface NSImage (SFSymbols) 23 | + (instancetype)imageWithSystemSymbolName:(NSString *)symbolName accessibilityDescription:(NSString *)description API_AVAILABLE(macos(11.0)); 24 | @end 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /Cocoa/CPU.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/CPU.png -------------------------------------------------------------------------------- /Cocoa/CPU@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/CPU@2x.png -------------------------------------------------------------------------------- /Cocoa/CPU~solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/CPU~solid.png -------------------------------------------------------------------------------- /Cocoa/CPU~solid@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/CPU~solid@2x.png -------------------------------------------------------------------------------- /Cocoa/CPU~solid~dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/CPU~solid~dark.png -------------------------------------------------------------------------------- /Cocoa/CPU~solid~dark@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/CPU~solid~dark@2x.png -------------------------------------------------------------------------------- /Cocoa/Cartridge.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Cartridge.icns -------------------------------------------------------------------------------- /Cocoa/ColorCartridge.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/ColorCartridge.icns -------------------------------------------------------------------------------- /Cocoa/ContinueTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/ContinueTemplate.png -------------------------------------------------------------------------------- /Cocoa/ContinueTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/ContinueTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/Display.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Display.png -------------------------------------------------------------------------------- /Cocoa/Display@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Display@2x.png -------------------------------------------------------------------------------- /Cocoa/Display~solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Display~solid.png -------------------------------------------------------------------------------- /Cocoa/Display~solid@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Display~solid@2x.png -------------------------------------------------------------------------------- /Cocoa/Display~solid~dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Display~solid~dark.png -------------------------------------------------------------------------------- /Cocoa/Display~solid~dark@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Display~solid~dark@2x.png -------------------------------------------------------------------------------- /Cocoa/FinishTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/FinishTemplate.png -------------------------------------------------------------------------------- /Cocoa/FinishTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/FinishTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/GBApp.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface GBApp : NSApplication 6 | 7 | @property (nonatomic, strong) IBOutlet NSWindow *preferencesWindow; 8 | @property (nonatomic, strong) IBOutlet NSView *graphicsTab; 9 | @property (nonatomic, strong) IBOutlet NSView *emulationTab; 10 | @property (nonatomic, strong) IBOutlet NSView *audioTab; 11 | @property (nonatomic, strong) IBOutlet NSView *controlsTab; 12 | @property (nonatomic, strong) IBOutlet NSView *updatesTab; 13 | - (IBAction)showPreferences: (id) sender; 14 | - (IBAction)toggleDeveloperMode:(id)sender; 15 | - (IBAction)switchPreferencesTab:(id)sender; 16 | @property (nonatomic, weak) IBOutlet NSMenuItem *linkCableMenuItem; 17 | @property (nonatomic, strong) IBOutlet NSWindow *updateWindow; 18 | @property (nonatomic, strong) IBOutlet WebView *updateChanges; 19 | @property (nonatomic, strong) IBOutlet NSProgressIndicator *updatesSpinner; 20 | @property (strong) IBOutlet NSButton *updatesButton; 21 | @property (strong) IBOutlet NSTextField *updateProgressLabel; 22 | @property (strong) IBOutlet NSButton *updateProgressButton; 23 | @property (strong) IBOutlet NSWindow *updateProgressWindow; 24 | @property (strong) IBOutlet NSProgressIndicator *updateProgressSpinner; 25 | - (void)updateThemesDefault:(bool)overwrite; 26 | @end 27 | 28 | -------------------------------------------------------------------------------- /Cocoa/GBBorderView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBBorderView : NSView 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /Cocoa/GBBorderView.m: -------------------------------------------------------------------------------- 1 | #import "GBBorderView.h" 2 | 3 | @implementation GBBorderView 4 | 5 | 6 | - (void)awakeFromNib 7 | { 8 | self.wantsLayer = true; 9 | } 10 | 11 | - (BOOL)wantsUpdateLayer 12 | { 13 | return true; 14 | } 15 | 16 | - (void)updateLayer 17 | { 18 | /* Wonderful, wonderful windowserver(?) bug. Using 0,0,0 here would cause it to render garbage 19 | on fullscreen windows on some High Sierra machines. Any other value, including the one used 20 | here (which is rendered exactly the same due to rounding) works around this bug. */ 21 | self.layer.backgroundColor = [NSColor colorWithCalibratedRed:0 22 | green:0 23 | blue:1.0 / 1024.0 24 | alpha:1.0].CGColor; 25 | } 26 | @end 27 | -------------------------------------------------------------------------------- /Cocoa/GBButtons.h: -------------------------------------------------------------------------------- 1 | typedef enum { 2 | GBRight, 3 | GBLeft, 4 | GBUp, 5 | GBDown, 6 | GBA, 7 | GBB, 8 | GBSelect, 9 | GBStart, 10 | GBRapidA, 11 | GBRapidB, 12 | GBTurbo, 13 | GBRewind, 14 | GBUnderclock, 15 | GBHotkey1, 16 | GBHotkey2, 17 | GBTotalButtonCount, 18 | GBKeyboardButtonCount = GBUnderclock + 1, 19 | GBPerPlayerButtonCount = GBRapidB + 1, 20 | } GBButton; 21 | 22 | #define GBJoyKitHotkey1 JOYButtonUsageGeneric0 + 0x100 23 | #define GBJoyKitHotkey2 JOYButtonUsageGeneric0 + 0x101 24 | #define GBJoyKitRapidA JOYButtonUsageGeneric0 + 0x102 25 | #define GBJoyKitRapidB JOYButtonUsageGeneric0 + 0x103 26 | 27 | extern NSString const *GBButtonNames[GBTotalButtonCount]; 28 | 29 | static inline NSString *n2s(uint64_t number) 30 | { 31 | return [NSString stringWithFormat:@"%llx", number]; 32 | } 33 | 34 | static inline NSString *button_to_preference_name(GBButton button, unsigned player) 35 | { 36 | if (player) { 37 | return [NSString stringWithFormat:@"GBPlayer%d%@", player + 1, GBButtonNames[button]]; 38 | } 39 | return [NSString stringWithFormat:@"GB%@", GBButtonNames[button]]; 40 | } 41 | -------------------------------------------------------------------------------- /Cocoa/GBButtons.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GBButtons.h" 3 | 4 | NSString const *GBButtonNames[] = {@"Right", @"Left", @"Up", @"Down", @"A", @"B", @"Select", @"Start", @"Rapid A", @"Rapid B", @"Turbo", @"Rewind", @"Slow-Motion", @"Hotkey 1", @"Hotkey 2"}; 5 | -------------------------------------------------------------------------------- /Cocoa/GBCenteredTextCell.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBCenteredTextCell : NSTextFieldCell 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /Cocoa/GBCenteredTextCell.m: -------------------------------------------------------------------------------- 1 | #import "GBCenteredTextCell.h" 2 | 3 | @implementation GBCenteredTextCell 4 | - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView 5 | { 6 | double height = round([self.attributedStringValue size].height); 7 | cellFrame.origin.y += (cellFrame.size.height - height) / 2; 8 | cellFrame.size.height = height; 9 | [super drawInteriorWithFrame:cellFrame inView:controlView]; 10 | } 11 | 12 | 13 | - (void)selectWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate start:(NSInteger)selStart length:(NSInteger)selLength 14 | { 15 | double height = round([self.attributedStringValue size].height); 16 | rect.origin.y += (rect.size.height - height) / 2; 17 | rect.size.height = height; 18 | [super selectWithFrame:rect inView:controlView editor:textObj delegate:delegate start:selStart length:selLength]; 19 | } 20 | 21 | - (void)editWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate event:(NSEvent *)event 22 | { 23 | double height = round([self.attributedStringValue size].height); 24 | rect.origin.y += (rect.size.height - height) / 2; 25 | rect.size.height = height; 26 | [super editWithFrame:rect inView:controlView editor:textObj delegate:delegate event:event]; 27 | 28 | } 29 | @end 30 | -------------------------------------------------------------------------------- /Cocoa/GBCheatSearchController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Document.h" 3 | 4 | @interface GBCheatSearchController : NSObject 5 | @property IBOutlet NSWindow *window; 6 | @property IBOutlet NSTableView *tableView; 7 | + (instancetype)controllerWithDocument:(Document *)document; 8 | @end 9 | -------------------------------------------------------------------------------- /Cocoa/GBCheatTextFieldCell.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBCheatTextFieldCell : NSTextFieldCell 4 | @property (nonatomic) bool usesAddressFormat; 5 | @end 6 | -------------------------------------------------------------------------------- /Cocoa/GBCheatWindowController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "Document.h" 4 | 5 | @interface GBCheatWindowController : NSObject 6 | @property (nonatomic, weak) IBOutlet NSTableView *cheatsTable; 7 | @property (nonatomic, weak) IBOutlet NSTextField *addressField; 8 | @property (nonatomic, weak) IBOutlet NSTextField *valueField; 9 | @property (nonatomic, weak) IBOutlet NSTextField *oldValueField; 10 | @property (nonatomic, weak) IBOutlet NSButton *oldValueCheckbox; 11 | @property (nonatomic, weak) IBOutlet NSTextField *descriptionField; 12 | @property (nonatomic, weak) IBOutlet NSTextField *importCodeField; 13 | @property (nonatomic, weak) IBOutlet NSTextField *importDescriptionField; 14 | @property (nonatomic, weak) IBOutlet Document *document; 15 | - (void)cheatsUpdated; 16 | @end 17 | -------------------------------------------------------------------------------- /Cocoa/GBCompleteByteSlice.h: -------------------------------------------------------------------------------- 1 | #import "Document.h" 2 | #import "HexFiend/HexFiend.h" 3 | #import "HexFiend/HFByteSlice.h" 4 | 5 | @interface GBCompleteByteSlice : HFByteSlice 6 | - (instancetype) initWithByteArray:(HFByteArray *)array; 7 | @end 8 | -------------------------------------------------------------------------------- /Cocoa/GBCompleteByteSlice.m: -------------------------------------------------------------------------------- 1 | #import "GBCompleteByteSlice.h" 2 | 3 | @implementation GBCompleteByteSlice 4 | { 5 | HFByteArray *_array; 6 | } 7 | 8 | - (instancetype) initWithByteArray:(HFByteArray *)array 9 | { 10 | if ((self = [super init])) { 11 | _array = array; 12 | } 13 | return self; 14 | } 15 | 16 | - (unsigned long long)length 17 | { 18 | return [_array length]; 19 | } 20 | 21 | - (void)copyBytes:(unsigned char *)dst range:(HFRange)range 22 | { 23 | [_array copyBytes:dst range:range]; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Cocoa/GBDebuggerButton.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class GBDocument; 4 | @interface GBDebuggerButton : NSButton 5 | @property (weak) IBOutlet NSTextField *textField; 6 | @end 7 | 8 | -------------------------------------------------------------------------------- /Cocoa/GBDebuggerButton.m: -------------------------------------------------------------------------------- 1 | #import "GBDebuggerButton.h" 2 | 3 | @implementation GBDebuggerButton 4 | { 5 | NSTrackingArea *_trackingArea; 6 | } 7 | - (instancetype)initWithCoder:(NSCoder *)coder 8 | { 9 | self = [super initWithCoder:coder]; 10 | self.toolTip = self.title; 11 | self.imagePosition = NSImageOnly; // Newer versions of AppKit refuse to respect the value from the nib file 12 | return self; 13 | } 14 | 15 | - (void)mouseEntered:(NSEvent *)event 16 | { 17 | if (@available(macOS 10.10, *)) { 18 | NSDictionary *attributes = @{ 19 | NSForegroundColorAttributeName: [NSColor colorWithWhite:1.0 alpha:0.5], 20 | NSFontAttributeName: self.textField.font 21 | }; 22 | self.textField.placeholderAttributedString = 23 | [[NSAttributedString alloc] initWithString:self.alternateTitle attributes:attributes]; 24 | } 25 | } 26 | 27 | - (void)mouseExited:(NSEvent *)event 28 | { 29 | if (@available(macOS 10.10, *)) { 30 | if ([self.textField.placeholderAttributedString.string isEqualToString:self.alternateTitle]) { 31 | self.textField.placeholderAttributedString = nil; 32 | } 33 | } 34 | } 35 | 36 | - (void)updateTrackingAreas 37 | { 38 | [super updateTrackingAreas]; 39 | if (_trackingArea) { 40 | [self removeTrackingArea:_trackingArea]; 41 | } 42 | 43 | _trackingArea = [ [NSTrackingArea alloc] initWithRect:[self bounds] 44 | options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways 45 | owner:self 46 | userInfo:nil]; 47 | [self addTrackingArea:_trackingArea]; 48 | } 49 | @end 50 | -------------------------------------------------------------------------------- /Cocoa/GBDeleteButtonCell.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBDeleteButtonCell : NSButtonCell 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /Cocoa/GBDeleteButtonCell.m: -------------------------------------------------------------------------------- 1 | #import "GBDeleteButtonCell.h" 2 | 3 | @implementation GBDeleteButtonCell 4 | 5 | // Image scaling is broken on some older macOS versions 6 | - (void)drawImage:(NSImage *)image withFrame:(NSRect)frame inView:(NSView *)controlView 7 | { 8 | double size = 13; 9 | unsigned offset = 1; 10 | if (@available(macOS 10.10, *)) { 11 | size = 15; 12 | offset = 0; 13 | } 14 | frame.origin.x += round((frame.size.width - size) / 2) + offset; 15 | frame.origin.y += round((frame.size.height - size) / 2) - offset; 16 | frame.size.width = frame.size.height = size; 17 | [super drawImage:image withFrame:frame inView:controlView]; 18 | } 19 | 20 | - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView 21 | { 22 | [self drawImage:self.image withFrame:cellFrame inView:controlView]; 23 | } 24 | 25 | -(void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView 26 | { 27 | 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Cocoa/GBGLShader.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GBView.h" 3 | 4 | @interface GBGLShader : NSObject 5 | - (instancetype)initWithName:(NSString *) shaderName; 6 | - (void) renderBitmap: (void *)bitmap previous:(void*) previous sized:(NSSize)srcSize inSize:(NSSize)dstSize scale: (double) scale withBlendingMode: (GB_frame_blending_mode_t)blendingMode; 7 | @end 8 | -------------------------------------------------------------------------------- /Cocoa/GBHexStatusBarRepresenter.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | 5 | @interface GBHexStatusBarRepresenter : HFRepresenter 6 | @property GB_gameboy_t *gb; 7 | @property (nonatomic) bool useDecimalLength; 8 | @property (nonatomic) uint16_t bankForDescription; 9 | @property (nonatomic) uint16_t baseAddress; 10 | @end 11 | -------------------------------------------------------------------------------- /Cocoa/GBHueSliderCell.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSSlider (GBHueSlider) 4 | -(NSColor *)colorValue; 5 | @end 6 | 7 | @interface GBHueSliderCell : NSSliderCell 8 | -(NSColor *)colorValue; 9 | @end 10 | -------------------------------------------------------------------------------- /Cocoa/GBImageView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @protocol GBImageViewDelegate; 4 | 5 | @interface GBImageViewGridConfiguration : NSObject 6 | @property (nonatomic, strong) NSColor *color; 7 | @property (nonatomic) NSUInteger size; 8 | - (instancetype) initWithColor: (NSColor *) color size: (NSUInteger) size; 9 | @end 10 | 11 | @interface GBImageView : NSImageView 12 | @property (nonatomic, strong) NSArray *horizontalGrids; 13 | @property (nonatomic, strong) NSArray *verticalGrids; 14 | @property (nonatomic) bool displayScrollRect; 15 | @property NSRect scrollRect; 16 | @property (nonatomic, weak) IBOutlet id delegate; 17 | @end 18 | 19 | @protocol GBImageViewDelegate 20 | @optional 21 | - (void) mouseDidLeaveImageView: (GBImageView *)view; 22 | - (void) imageView: (GBImageView *)view mouseMovedToX:(NSUInteger) x Y:(NSUInteger) y; 23 | @end 24 | -------------------------------------------------------------------------------- /Cocoa/GBJoyConManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface GBJoyConManager : NSObject 6 | + (instancetype)sharedInstance; 7 | - (IBAction)autopair:(id)sender; 8 | 9 | @property (nonatomic) bool arrangementMode; 10 | @property (weak) IBOutlet NSTableView *tableView; 11 | @end 12 | 13 | -------------------------------------------------------------------------------- /Cocoa/GBMemoryByteArray.h: -------------------------------------------------------------------------------- 1 | #import "Document.h" 2 | #import "HexFiend/HexFiend.h" 3 | #import "HexFiend/HFByteArray.h" 4 | 5 | typedef enum { 6 | GBMemoryEntireSpace, 7 | GBMemoryROM, 8 | GBMemoryVRAM, 9 | GBMemoryExternalRAM, 10 | GBMemoryRAM 11 | } GB_memory_mode_t; 12 | 13 | @interface GBMemoryByteArray : HFByteArray 14 | - (instancetype) initWithDocument:(Document *)document; 15 | @property (nonatomic) uint16_t selectedBank; 16 | @property (nonatomic) GB_memory_mode_t mode; 17 | @end 18 | -------------------------------------------------------------------------------- /Cocoa/GBOSDView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBOSDView : NSView 4 | @property bool usesSGBScale; 5 | - (void)displayText:(NSString *)text; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/GBObjectView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Document.h" 3 | 4 | @interface GBObjectView : NSView 5 | - (void)reloadData:(Document *)document; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/GBOpenGLView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GBGLShader.h" 3 | 4 | @interface GBOpenGLView : NSOpenGLView 5 | @property (nonatomic) GBGLShader *shader; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/GBOpenGLView.m: -------------------------------------------------------------------------------- 1 | #import "GBOpenGLView.h" 2 | #import "GBView.h" 3 | #import "NSObject+DefaultsObserver.h" 4 | #import 5 | 6 | @implementation GBOpenGLView 7 | 8 | - (void)drawRect:(NSRect)dirtyRect 9 | { 10 | if (!self.shader) { 11 | self.shader = [[GBGLShader alloc] initWithName:[[NSUserDefaults standardUserDefaults] objectForKey:@"GBFilter"]]; 12 | } 13 | 14 | GBView *gbview = (GBView *)self.superview; 15 | double scale = self.window.backingScaleFactor; 16 | glViewport(0, 0, self.bounds.size.width * scale, self.bounds.size.height * scale); 17 | 18 | if (gbview.gb) { 19 | [self.shader renderBitmap:gbview.currentBuffer 20 | previous:gbview.frameBlendingMode? gbview.previousBuffer : NULL 21 | sized:NSMakeSize(GB_get_screen_width(gbview.gb), GB_get_screen_height(gbview.gb)) 22 | inSize:self.bounds.size 23 | scale:scale 24 | withBlendingMode:gbview.frameBlendingMode]; 25 | } 26 | glFlush(); 27 | } 28 | 29 | - (instancetype)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat *)format 30 | { 31 | __unsafe_unretained GBOpenGLView *weakSelf = self; 32 | self = [super initWithFrame:frameRect pixelFormat:format]; 33 | [self observeStandardDefaultsKey:@"GBFilter" withBlock:^(id newValue) { 34 | weakSelf.shader = nil; 35 | [weakSelf setNeedsDisplay:true]; 36 | 37 | }]; 38 | return self; 39 | } 40 | @end 41 | -------------------------------------------------------------------------------- /Cocoa/GBOptionalVisualEffectView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /* Fake interface so the compiler assumes it conforms to NSVisualEffectView */ 4 | @interface GBOptionalVisualEffectView : NSVisualEffectView 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/GBOptionalVisualEffectView.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBOptionalVisualEffectView : NSView 4 | 5 | @end 6 | 7 | @implementation GBOptionalVisualEffectView 8 | 9 | + (instancetype)allocWithZone:(struct _NSZone *)zone 10 | { 11 | Class NSVisualEffectView = NSClassFromString(@"NSVisualEffectView"); 12 | if (NSVisualEffectView) { 13 | return (id)[NSVisualEffectView alloc]; 14 | } 15 | return [super allocWithZone:zone]; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Cocoa/GBPaletteEditorController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface GBPaletteEditorController : NSObject 5 | @property (weak) IBOutlet NSColorWell *colorWell0; 6 | @property (weak) IBOutlet NSColorWell *colorWell1; 7 | @property (weak) IBOutlet NSColorWell *colorWell2; 8 | @property (weak) IBOutlet NSColorWell *colorWell3; 9 | @property (weak) IBOutlet NSColorWell *colorWell4; 10 | @property (weak) IBOutlet NSButton *disableLCDColorCheckbox; 11 | @property (weak) IBOutlet NSButton *manualModeCheckbox; 12 | @property (weak) IBOutlet NSSlider *brightnessSlider; 13 | @property (weak) IBOutlet NSSlider *hueSlider; 14 | @property (weak) IBOutlet NSSlider *hueStrengthSlider; 15 | @property (weak) IBOutlet NSTableView *themesList; 16 | @property (weak) IBOutlet NSMenu *menu; 17 | @property (weak) IBOutlet NSSegmentedControl *segmentControl; 18 | @property IBOutlet NSMenu *segmentMenu; 19 | + (const GB_palette_t *)userPalette; 20 | @end 21 | -------------------------------------------------------------------------------- /Cocoa/GBPaletteView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "Document.h" 3 | 4 | @interface GBPaletteView : NSView 5 | - (void)reloadData:(Document *)document; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/GBPanel.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBPanel : NSPanel 4 | @property (weak) IBOutlet NSWindow *ownerWindow; 5 | @end 6 | -------------------------------------------------------------------------------- /Cocoa/GBPanel.m: -------------------------------------------------------------------------------- 1 | #import "GBPanel.h" 2 | 3 | @implementation GBPanel 4 | - (void)becomeKeyWindow 5 | { 6 | if ([_ownerWindow canBecomeMainWindow]) { 7 | [_ownerWindow makeMainWindow]; 8 | } 9 | [super becomeKeyWindow]; 10 | } 11 | @end 12 | -------------------------------------------------------------------------------- /Cocoa/GBPreferenceButton.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBPreferenceButton : NSButton 4 | @property (nonatomic) IBInspectable NSString *preferenceName; 5 | @property IBInspectable BOOL invertValue; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/GBPreferenceButton.m: -------------------------------------------------------------------------------- 1 | #import "GBPreferenceButton.h" 2 | #import "NSObject+DefaultsObserver.h" 3 | 4 | @implementation GBPreferenceButton 5 | 6 | - (BOOL)sendAction:(SEL)action to:(id)target 7 | { 8 | [[NSUserDefaults standardUserDefaults] setBool:self.state ^ self.invertValue forKey:_preferenceName]; 9 | return [super sendAction:action to:target]; 10 | } 11 | 12 | - (void)updateValue 13 | { 14 | if (!_preferenceName) return; 15 | self.state = [[NSUserDefaults standardUserDefaults] boolForKey:_preferenceName] ^ self.invertValue; 16 | } 17 | 18 | - (void)setPreferenceName:(NSString *)preferenceName 19 | { 20 | _preferenceName = preferenceName; 21 | [self observeStandardDefaultsKey:_preferenceName selector:@selector(updateValue)]; 22 | } 23 | 24 | - (void)viewDidMoveToWindow 25 | { 26 | [super viewDidMoveToWindow]; 27 | [self updateValue]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Cocoa/GBPreferencePopUpButton.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBPreferenceMenuItem : NSMenuItem 4 | @property (nonatomic) IBInspectable NSString *preferenceValue; 5 | @end 6 | 7 | @interface GBPreferencePopUpButton : NSPopUpButton 8 | @property (nonatomic) IBInspectable NSString *preferenceName; 9 | @end 10 | -------------------------------------------------------------------------------- /Cocoa/GBPreferencePopUpButton.m: -------------------------------------------------------------------------------- 1 | #import "GBPreferencePopUpButton.h" 2 | #import "NSObject+DefaultsObserver.h" 3 | 4 | @implementation GBPreferenceMenuItem 5 | @end 6 | 7 | @implementation GBPreferencePopUpButton 8 | 9 | - (BOOL)sendAction:(SEL)action to:(id)target 10 | { 11 | GBPreferenceMenuItem *item = (GBPreferenceMenuItem *)self.selectedItem; 12 | if ([item isKindOfClass:[GBPreferenceMenuItem class]]) { 13 | [[NSUserDefaults standardUserDefaults] setObject:item.preferenceValue forKey:_preferenceName]; 14 | } 15 | else { 16 | [[NSUserDefaults standardUserDefaults] setInteger:item.tag forKey:_preferenceName]; 17 | } 18 | return [super sendAction:action to:target]; 19 | } 20 | 21 | - (void)updateValue 22 | { 23 | if (!_preferenceName) return; 24 | NSString *stringValue = [[NSUserDefaults standardUserDefaults] objectForKey:_preferenceName]; 25 | if ([stringValue isKindOfClass:[NSString class]]) { 26 | for (GBPreferenceMenuItem *item in self.menu.itemArray) { 27 | if ([item isKindOfClass:[GBPreferenceMenuItem class]] && 28 | [item.preferenceValue isEqualToString:stringValue]) { 29 | [self selectItem:item]; 30 | return; 31 | } 32 | } 33 | } 34 | else { 35 | [self selectItemWithTag:[[NSUserDefaults standardUserDefaults] integerForKey:_preferenceName]]; 36 | } 37 | } 38 | 39 | - (void)setPreferenceName:(NSString *)preferenceName 40 | { 41 | _preferenceName = preferenceName; 42 | [self observeStandardDefaultsKey:_preferenceName selector:@selector(updateValue)]; 43 | } 44 | 45 | - (void)viewDidMoveToWindow 46 | { 47 | [super viewDidMoveToWindow]; 48 | [self updateValue]; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Cocoa/GBPreferencesSlider.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBPreferencesSlider : NSSlider 4 | @property (nonatomic) IBInspectable NSString *preferenceName; 5 | @property IBInspectable unsigned denominator; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/GBPreferencesSlider.m: -------------------------------------------------------------------------------- 1 | #import "GBPreferencesSlider.h" 2 | #import "NSObject+DefaultsObserver.h" 3 | 4 | @implementation GBPreferencesSlider 5 | 6 | - (BOOL)sendAction:(SEL)action to:(id)target 7 | { 8 | [[NSUserDefaults standardUserDefaults] setDouble:self.doubleValue / (self.denominator ?: 1) forKey:_preferenceName]; 9 | return [super sendAction:action to:target]; 10 | } 11 | 12 | - (void)updateValue 13 | { 14 | if (!_preferenceName) return; 15 | self.doubleValue = [[NSUserDefaults standardUserDefaults] doubleForKey:_preferenceName] * (self.denominator ?: 1); 16 | } 17 | 18 | - (void)setPreferenceName:(NSString *)preferenceName 19 | { 20 | _preferenceName = preferenceName; 21 | [self observeStandardDefaultsKey:_preferenceName selector:@selector(updateValue)]; 22 | } 23 | 24 | - (void)viewDidMoveToWindow 25 | { 26 | [super viewDidMoveToWindow]; 27 | [self updateValue]; 28 | } 29 | @end 30 | -------------------------------------------------------------------------------- /Cocoa/GBPreferencesWindow.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "GBPaletteEditorController.h" 4 | #import "GBTitledPopUpButton.h" 5 | 6 | @interface GBPreferencesWindow : NSWindow 7 | @property IBOutlet NSTableView *controlsTableView; 8 | @property IBOutlet NSButton *configureJoypadButton; 9 | @property IBOutlet NSButton *skipButton; 10 | @property IBOutlet NSMenuItem *bootROMsFolderItem; 11 | @property IBOutlet NSPopUpButtonCell *bootROMsButton; 12 | @property IBOutlet NSPopUpButton *preferredJoypadButton; 13 | @property IBOutlet NSPopUpButton *playerListButton; 14 | @property IBOutlet GBPaletteEditorController *paletteEditorController; 15 | @property IBOutlet NSWindow *paletteEditor; 16 | @property IBOutlet NSWindow *joyconsSheet; 17 | @property IBOutlet NSPopUpButton *colorCorrectionPopupButton; 18 | @property IBOutlet NSPopUpButton *highpassFilterPopupButton; 19 | @property IBOutlet NSPopUpButton *colorPalettePopupButton; 20 | @property IBOutlet NSPopUpButton *hotkey1PopupButton; 21 | @property IBOutlet NSPopUpButton *hotkey2PopupButton; 22 | 23 | @property IBOutlet GBTitledPopUpButton *fontPopupButton; 24 | @property IBOutlet NSStepper *fontSizeStepper; 25 | @end 26 | -------------------------------------------------------------------------------- /Cocoa/GBSplitView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBSplitView : NSSplitView 4 | 5 | -(void) setDividerColor:(NSColor *)color; 6 | - (NSArray *)arrangedSubviews; 7 | @end 8 | -------------------------------------------------------------------------------- /Cocoa/GBSplitView.m: -------------------------------------------------------------------------------- 1 | #import "GBSplitView.h" 2 | 3 | @implementation GBSplitView 4 | { 5 | NSColor *_dividerColor; 6 | } 7 | 8 | - (void)setDividerColor:(NSColor *)color 9 | { 10 | _dividerColor = color; 11 | [self setNeedsDisplay:true]; 12 | } 13 | 14 | - (NSColor *)dividerColor 15 | { 16 | if (_dividerColor) { 17 | return _dividerColor; 18 | } 19 | return [super dividerColor]; 20 | } 21 | 22 | - (void)drawDividerInRect:(NSRect)rect 23 | { 24 | [self.dividerColor set]; 25 | NSRectFill(rect); 26 | } 27 | 28 | /* Mavericks comaptibility */ 29 | - (NSArray *)arrangedSubviews 30 | { 31 | if (@available(macOS 10.11, *)) { 32 | return [super arrangedSubviews]; 33 | } 34 | else { 35 | return [self subviews]; 36 | } 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Cocoa/GBTerminalTextFieldCell.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface GBTerminalTextFieldCell : NSTextFieldCell 5 | @property (nonatomic) GB_gameboy_t *gb; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/GBTintedImageCell.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBTintedImageCell : NSImageCell 4 | @property NSColor *tint; 5 | @end 6 | -------------------------------------------------------------------------------- /Cocoa/GBTintedImageCell.m: -------------------------------------------------------------------------------- 1 | #import "GBTintedImageCell.h" 2 | 3 | @implementation GBTintedImageCell 4 | 5 | - (NSImage *)image 6 | { 7 | if (!self.tint || !super.image.isTemplate) { 8 | return [super image]; 9 | } 10 | 11 | NSImage *tinted = [super.image copy]; 12 | [tinted lockFocus]; 13 | [self.tint set]; 14 | NSRectFillUsingOperation((NSRect){.size = tinted.size}, NSCompositeSourceIn); 15 | [tinted unlockFocus]; 16 | tinted.template = false; 17 | return tinted; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Cocoa/GBTitledPopUpButton.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBTitledPopUpButton : NSPopUpButton 4 | @property NSString *displayTitle; 5 | @end 6 | -------------------------------------------------------------------------------- /Cocoa/GBTitledPopUpButton.m: -------------------------------------------------------------------------------- 1 | #import "GBTitledPopUpButton.h" 2 | 3 | @implementation GBTitledPopUpButton 4 | 5 | - (void)setDisplayTitle:(NSString *)displayTitle 6 | { 7 | if (!displayTitle) { 8 | ((NSPopUpButtonCell *)self.cell).usesItemFromMenu = true; 9 | ((NSPopUpButtonCell *)self.cell).menuItem = nil; 10 | return; 11 | } 12 | ((NSPopUpButtonCell *)self.cell).usesItemFromMenu = false; 13 | ((NSPopUpButtonCell *)self.cell).menuItem = [[NSMenuItem alloc] initWithTitle:displayTitle action:nil keyEquivalent:@""]; 14 | } 15 | 16 | 17 | - (NSString *)displayTitle 18 | { 19 | return ((NSPopUpButtonCell *)self.cell).menuItem.title; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Cocoa/GBView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "GBOSDView.h" 4 | #import "GBViewBase.h" 5 | 6 | 7 | @class Document; 8 | 9 | @interface GBView : GBViewBase 10 | @property (nonatomic, weak) IBOutlet Document *document; 11 | @property (nonatomic, getter=isMouseHidingEnabled) bool mouseHidingEnabled; 12 | @property (nonatomic) bool isRewinding; 13 | @property (weak) GBOSDView *osdView; 14 | - (NSImage *)renderToImage; 15 | - (void)setRumble: (double)amp; 16 | @end 17 | -------------------------------------------------------------------------------- /Cocoa/GBViewGL.h: -------------------------------------------------------------------------------- 1 | #import "GBView.h" 2 | 3 | @interface GBViewGL : GBView 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /Cocoa/GBViewGL.m: -------------------------------------------------------------------------------- 1 | #import "GBViewGL.h" 2 | #import "GBOpenGLView.h" 3 | 4 | @implementation GBViewGL 5 | 6 | - (void)createInternalView 7 | { 8 | NSOpenGLPixelFormatAttribute attrs[] = 9 | { 10 | NSOpenGLPFAOpenGLProfile, 11 | NSOpenGLProfileVersion3_2Core, 12 | 0 13 | }; 14 | 15 | NSOpenGLPixelFormat *pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; 16 | 17 | assert(pf); 18 | 19 | NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pf shareContext:nil]; 20 | 21 | self.internalView = [[GBOpenGLView alloc] initWithFrame:self.frame pixelFormat:pf]; 22 | ((GBOpenGLView *)self.internalView).wantsBestResolutionOpenGLSurface = true; 23 | ((GBOpenGLView *)self.internalView).openGLContext = context; 24 | } 25 | 26 | - (void)flip 27 | { 28 | [super flip]; 29 | dispatch_async(dispatch_get_main_queue(), ^{ 30 | [self.internalView setNeedsDisplay:true]; 31 | [self setNeedsDisplay:true]; 32 | }); 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Cocoa/GBVisualizerView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface GBVisualizerView : NSView 5 | - (void)addSample:(GB_sample_t *)sample; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/GBWarningPopover.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBWarningPopover : NSPopover 4 | 5 | + (GBWarningPopover *) popoverWithContents:(NSString *)contents onView:(NSView *)view; 6 | + (GBWarningPopover *) popoverWithContents:(NSString *)contents onWindow:(NSWindow *)window; 7 | + (GBWarningPopover *) popoverWithContents:(NSString *)contents title:(NSString *)title onView:(NSView *)view timeout:(double)seconds preferredEdge:(NSRectEdge)preferredEdge; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /Cocoa/HelpTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/HelpTemplate.png -------------------------------------------------------------------------------- /Cocoa/HelpTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/HelpTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/HorizontalJoyConLeftTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/HorizontalJoyConLeftTemplate.png -------------------------------------------------------------------------------- /Cocoa/HorizontalJoyConLeftTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/HorizontalJoyConLeftTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/HorizontalJoyConRightTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/HorizontalJoyConRightTemplate.png -------------------------------------------------------------------------------- /Cocoa/HorizontalJoyConRightTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/HorizontalJoyConRightTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Icon.png -------------------------------------------------------------------------------- /Cocoa/Icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Icon@2x.png -------------------------------------------------------------------------------- /Cocoa/InterruptTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/InterruptTemplate.png -------------------------------------------------------------------------------- /Cocoa/InterruptTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/InterruptTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/JoyConDualTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/JoyConDualTemplate.png -------------------------------------------------------------------------------- /Cocoa/JoyConDualTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/JoyConDualTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/JoyConLeftTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/JoyConLeftTemplate.png -------------------------------------------------------------------------------- /Cocoa/JoyConLeftTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/JoyConLeftTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/JoyConRightTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/JoyConRightTemplate.png -------------------------------------------------------------------------------- /Cocoa/JoyConRightTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/JoyConRightTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/Joypad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Joypad.png -------------------------------------------------------------------------------- /Cocoa/Joypad@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Joypad@2x.png -------------------------------------------------------------------------------- /Cocoa/Joypad~dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Joypad~dark.png -------------------------------------------------------------------------------- /Cocoa/Joypad~dark@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Joypad~dark@2x.png -------------------------------------------------------------------------------- /Cocoa/Joypad~solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Joypad~solid.png -------------------------------------------------------------------------------- /Cocoa/Joypad~solid@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Joypad~solid@2x.png -------------------------------------------------------------------------------- /Cocoa/KeyboardShortcutPrivateAPIs.h: -------------------------------------------------------------------------------- 1 | /* These are private APIs, but they are a very simple and comprehensive way 2 | to convert a key equivalent to its display name. */ 3 | 4 | @interface NSKeyboardShortcut : NSObject 5 | 6 | + (id)shortcutWithPreferencesEncoding:(NSString *)encoding; 7 | + (id)shortcutWithKeyEquivalent:(NSString *)key_equivalent modifierMask:(NSUInteger)mask; 8 | - (id)initWithKeyEquivalent:(NSString *)key_equivalent modifierMask:(NSUInteger)mask; 9 | 10 | @property(readonly) NSUInteger modifierMask; 11 | @property(readonly) NSString *keyEquivalent; 12 | @property(readonly) NSString *preferencesEncoding; 13 | @property(readonly) NSString *localizedModifierMaskDisplayName; 14 | @property(readonly) NSString *localizedKeyEquivalentDisplayName; 15 | @property(readonly) NSString *localizedDisplayName; 16 | 17 | @end 18 | 19 | @interface NSPrefPaneUtils : NSObject 20 | + (id)stringForVirtualKey:(unsigned int)key modifiers:(unsigned int)flags; 21 | @end 22 | -------------------------------------------------------------------------------- /Cocoa/NSImageNamedDarkSupport.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface NSImageRep(PrivateAPI) 5 | @property(setter=_setAppearanceName:) NSString *_appearanceName; 6 | @end 7 | 8 | static NSImage * (*imageNamed)(Class self, SEL _cmd, NSString *name); 9 | 10 | @implementation NSImage(DarkHooks) 11 | 12 | + (NSImage *)imageNamedWithDark:(NSImageName)name 13 | { 14 | if (@available(macOS 11.0, *)) { 15 | if (![name containsString:@"~solid"]) { 16 | NSImage *solid = [self imageNamed:[name stringByAppendingString:@"~solid"]]; 17 | [solid setTemplate:true]; 18 | if (solid) return solid; 19 | } 20 | } 21 | NSImage *light = imageNamed(self, _cmd, name); 22 | if (@available(macOS 10.14, *)) { 23 | NSImage *dark = imageNamed(self, _cmd, [name stringByAppendingString:@"~dark"]); 24 | if (!dark) { 25 | return light; 26 | } 27 | NSImage *ret = [[NSImage alloc] initWithSize:light.size]; 28 | for (NSImageRep *rep in light.representations) { 29 | [rep _setAppearanceName:NSAppearanceNameAqua]; 30 | [ret addRepresentation:rep]; 31 | } 32 | for (NSImageRep *rep in dark.representations) { 33 | [rep _setAppearanceName:NSAppearanceNameDarkAqua]; 34 | [ret addRepresentation:rep]; 35 | } 36 | return ret; 37 | } 38 | return light; 39 | } 40 | 41 | +(void)load 42 | { 43 | if (@available(macOS 10.14, *)) { 44 | imageNamed = (void *)[self methodForSelector:@selector(imageNamed:)]; 45 | method_setImplementation(class_getClassMethod(self, @selector(imageNamed:)), 46 | [self methodForSelector:@selector(imageNamedWithDark:)]); 47 | } 48 | } 49 | @end 50 | -------------------------------------------------------------------------------- /Cocoa/NSObject+DefaultsObserver.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSObject (DefaultsObserver) 4 | - (void)observeStandardDefaultsKey:(NSString *)key withBlock:(void(^)(id newValue))block; 5 | - (void)observeStandardDefaultsKey:(NSString *)key selector:(SEL)selector; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/NSObject+MavericksCompat.m: -------------------------------------------------------------------------------- 1 | #import 2 | @implementation NSObject (MavericksCompat) 3 | - (instancetype)initWithCoder:(NSCoder *)coder 4 | { 5 | return [self init]; 6 | } 7 | @end 8 | -------------------------------------------------------------------------------- /Cocoa/NSString+StringForKey.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSString (StringForKey) 4 | + (NSString *) displayStringForKeyString: (NSString *)key_string; 5 | + (NSString *) displayStringForKeyCode:(unsigned short) keyCode; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/NSTextFieldCell+Inset.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface NSTextFieldCell (Inset) 5 | @property NSSize textInset; 6 | @end 7 | -------------------------------------------------------------------------------- /Cocoa/NSTextFieldCell+Inset.m: -------------------------------------------------------------------------------- 1 | #import "NSTextFieldCell+Inset.h" 2 | #import 3 | #import 4 | 5 | @interface NSTextFieldCell () 6 | - (CGRect)_textLayerDrawingRectForCellFrame:(CGRect)rect; 7 | @property NSSize textInset; 8 | @end 9 | 10 | @implementation NSTextFieldCell (Inset) 11 | 12 | - (void)setTextInset:(NSSize)textInset 13 | { 14 | objc_setAssociatedObject(self, @selector(textInset), @(textInset), OBJC_ASSOCIATION_RETAIN); 15 | } 16 | 17 | - (NSSize)textInset 18 | { 19 | return [objc_getAssociatedObject(self, _cmd) sizeValue]; 20 | } 21 | 22 | - (CGRect)_textLayerDrawingRectForCellFrameHook:(CGRect)rect 23 | { 24 | CGRect ret = [self _textLayerDrawingRectForCellFrameHook:rect]; 25 | NSSize inset = self.textInset; 26 | ret.origin.x += inset.width; 27 | ret.origin.y += inset.height; 28 | ret.size.width -= inset.width; 29 | ret.size.height -= inset.height; 30 | return ret; 31 | } 32 | 33 | + (void)load 34 | { 35 | method_exchangeImplementations(class_getInstanceMethod(self, @selector(_textLayerDrawingRectForCellFrame:)), 36 | class_getInstanceMethod(self, @selector(_textLayerDrawingRectForCellFrameHook:))); 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Cocoa/NSToolbarItem+NoOverflow.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | static id nop(id self, SEL _cmd) 5 | { 6 | return nil; 7 | } 8 | 9 | static double minSize(id self, SEL _cmd) 10 | { 11 | return 80.0; 12 | } 13 | 14 | @implementation NSToolbarItem (NoOverflow) 15 | 16 | + (void)load 17 | { 18 | // Prevent collapsing toolbar items into menu items, they don't work in that form 19 | method_setImplementation(class_getInstanceMethod(self, @selector(menuFormRepresentation)), (IMP)nop); 20 | // Prevent over-agressive collapsing of the Printer Feed menu 21 | method_setImplementation(class_getInstanceMethod(NSClassFromString(@"NSToolbarTitleView"), @selector(minSize)), (IMP)minSize); 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Cocoa/Next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Next.png -------------------------------------------------------------------------------- /Cocoa/Next@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Next@2x.png -------------------------------------------------------------------------------- /Cocoa/NextTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/NextTemplate.png -------------------------------------------------------------------------------- /Cocoa/NextTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/NextTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/Pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Pause.png -------------------------------------------------------------------------------- /Cocoa/Pause@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Pause@2x.png -------------------------------------------------------------------------------- /Cocoa/PkgInfo: -------------------------------------------------------------------------------- 1 | APPL???? -------------------------------------------------------------------------------- /Cocoa/Play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Play.png -------------------------------------------------------------------------------- /Cocoa/Play@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Play@2x.png -------------------------------------------------------------------------------- /Cocoa/PopoverView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Cocoa/Previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Previous.png -------------------------------------------------------------------------------- /Cocoa/Previous@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Previous@2x.png -------------------------------------------------------------------------------- /Cocoa/Rewind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Rewind.png -------------------------------------------------------------------------------- /Cocoa/Rewind@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Rewind@2x.png -------------------------------------------------------------------------------- /Cocoa/Speaker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Speaker.png -------------------------------------------------------------------------------- /Cocoa/Speaker@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Speaker@2x.png -------------------------------------------------------------------------------- /Cocoa/Speaker~dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Speaker~dark.png -------------------------------------------------------------------------------- /Cocoa/Speaker~dark@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Speaker~dark@2x.png -------------------------------------------------------------------------------- /Cocoa/Speaker~solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Speaker~solid.png -------------------------------------------------------------------------------- /Cocoa/Speaker~solid@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Speaker~solid@2x.png -------------------------------------------------------------------------------- /Cocoa/StepTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/StepTemplate.png -------------------------------------------------------------------------------- /Cocoa/StepTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/StepTemplate@2x.png -------------------------------------------------------------------------------- /Cocoa/Updates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Updates.png -------------------------------------------------------------------------------- /Cocoa/Updates@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Updates@2x.png -------------------------------------------------------------------------------- /Cocoa/Updates~solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Updates~solid.png -------------------------------------------------------------------------------- /Cocoa/Updates~solid@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Updates~solid@2x.png -------------------------------------------------------------------------------- /Cocoa/Updates~solid~dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Updates~solid~dark.png -------------------------------------------------------------------------------- /Cocoa/Updates~solid~dark@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Cocoa/Updates~solid~dark@2x.png -------------------------------------------------------------------------------- /Cocoa/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, const char * argv[]) 4 | { 5 | return NSApplicationMain(argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /Core/camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "defs.h" 4 | 5 | typedef uint8_t (*GB_camera_get_pixel_callback_t)(GB_gameboy_t *gb, uint8_t x, uint8_t y); 6 | typedef void (*GB_camera_update_request_callback_t)(GB_gameboy_t *gb); 7 | 8 | void GB_set_camera_get_pixel_callback(GB_gameboy_t *gb, GB_camera_get_pixel_callback_t callback); 9 | void GB_set_camera_update_request_callback(GB_gameboy_t *gb, GB_camera_update_request_callback_t callback); 10 | void GB_camera_updated(GB_gameboy_t *gb); 11 | 12 | #ifdef GB_INTERNAL 13 | internal uint8_t GB_camera_read_image(GB_gameboy_t *gb, uint16_t addr); 14 | internal void GB_camera_write_register(GB_gameboy_t *gb, uint16_t addr, uint8_t value); 15 | internal uint8_t GB_camera_read_register(GB_gameboy_t *gb, uint16_t addr); 16 | 17 | enum { 18 | GB_CAMERA_SHOOT_AND_1D_FLAGS = 0, 19 | GB_CAMERA_GAIN_AND_EDGE_ENHACEMENT_FLAGS = 1, 20 | GB_CAMERA_EXPOSURE_HIGH = 2, 21 | GB_CAMERA_EXPOSURE_LOW = 3, 22 | GB_CAMERA_EDGE_ENHANCEMENT_INVERT_AND_VOLTAGE = 4, 23 | GB_CAMERA_DITHERING_PATTERN_START = 6, 24 | GB_CAMERA_DITHERING_PATTERN_END = 0x35, 25 | }; 26 | #endif 27 | -------------------------------------------------------------------------------- /Core/cheat_search.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef GB_DISABLE_CHEAT_SEARCH 3 | #include "defs.h" 4 | #include 5 | #include 6 | #include 7 | 8 | typedef struct { 9 | uint16_t addr; 10 | uint16_t bank; 11 | uint16_t value; 12 | } GB_cheat_search_result_t; 13 | 14 | typedef enum { 15 | GB_CHEAT_SEARCH_DATA_TYPE_8BIT = 0, 16 | GB_CHEAT_SEARCH_DATA_TYPE_16BIT = 1, 17 | GB_CHEAT_SEARCH_DATA_TYPE_BE_BIT = 2, // Not used alone 18 | GB_CHEAT_SEARCH_DATA_TYPE_16BIT_BE = GB_CHEAT_SEARCH_DATA_TYPE_16BIT | GB_CHEAT_SEARCH_DATA_TYPE_BE_BIT, 19 | } GB_cheat_search_data_type_t; 20 | 21 | void GB_cheat_search_reset(GB_gameboy_t *gb); 22 | bool GB_cheat_search_filter(GB_gameboy_t *gb, const char *expression, GB_cheat_search_data_type_t data_type); 23 | size_t GB_cheat_search_result_count(GB_gameboy_t *gb); 24 | void GB_cheat_search_get_results(GB_gameboy_t *gb, GB_cheat_search_result_t *results); 25 | #endif 26 | -------------------------------------------------------------------------------- /Core/cheats.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef GB_DISABLE_CHEATS 3 | #include "defs.h" 4 | 5 | #define GB_CHEAT_ANY_BANK 0xFFFF 6 | 7 | typedef struct GB_cheat_s GB_cheat_t; 8 | 9 | const GB_cheat_t *GB_add_cheat(GB_gameboy_t *gb, const char *description, uint16_t address, uint16_t bank, uint8_t value, uint8_t old_value, bool use_old_value, bool enabled); 10 | void GB_update_cheat(GB_gameboy_t *gb, const GB_cheat_t *cheat, const char *description, uint16_t address, uint16_t bank, uint8_t value, uint8_t old_value, bool use_old_value, bool enabled); 11 | const GB_cheat_t *GB_import_cheat(GB_gameboy_t *gb, const char *cheat, const char *description, bool enabled); 12 | const GB_cheat_t *const *GB_get_cheats(GB_gameboy_t *gb, size_t *size); 13 | void GB_remove_cheat(GB_gameboy_t *gb, const GB_cheat_t *cheat); 14 | void GB_remove_all_cheats(GB_gameboy_t *gb); 15 | bool GB_cheats_enabled(GB_gameboy_t *gb); 16 | void GB_set_cheats_enabled(GB_gameboy_t *gb, bool enabled); 17 | int GB_load_cheats(GB_gameboy_t *gb, const char *path, bool replace_existing); 18 | int GB_save_cheats(GB_gameboy_t *gb, const char *path); 19 | 20 | #ifdef GB_INTERNAL 21 | internal void GB_apply_cheat(GB_gameboy_t *gb, uint16_t address, uint8_t *value); 22 | #endif 23 | 24 | typedef struct { 25 | size_t size; 26 | GB_cheat_t *cheats[]; 27 | } GB_cheat_hash_t; 28 | 29 | struct GB_cheat_s { 30 | uint16_t address; 31 | uint16_t bank; 32 | uint8_t value; 33 | uint8_t old_value; 34 | bool use_old_value; 35 | bool enabled; 36 | char description[128]; 37 | }; 38 | #else 39 | #ifdef GB_INTERNAL 40 | #define GB_apply_cheat(...) 41 | #endif // GB_INTERNAL 42 | #endif // GB_DISABLE_CHEATS 43 | -------------------------------------------------------------------------------- /Core/joypad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "defs.h" 3 | #include 4 | 5 | typedef enum { 6 | GB_KEY_RIGHT, 7 | GB_KEY_LEFT, 8 | GB_KEY_UP, 9 | GB_KEY_DOWN, 10 | GB_KEY_A, 11 | GB_KEY_B, 12 | GB_KEY_SELECT, 13 | GB_KEY_START, 14 | GB_KEY_MAX 15 | } GB_key_t; 16 | 17 | typedef enum { 18 | GB_KEY_RIGHT_MASK = 1 << GB_KEY_RIGHT, 19 | GB_KEY_LEFT_MASK = 1 << GB_KEY_LEFT, 20 | GB_KEY_UP_MASK = 1 << GB_KEY_UP, 21 | GB_KEY_DOWN_MASK = 1 << GB_KEY_DOWN, 22 | GB_KEY_A_MASK = 1 << GB_KEY_A, 23 | GB_KEY_B_MASK = 1 << GB_KEY_B, 24 | GB_KEY_SELECT_MASK = 1 << GB_KEY_SELECT, 25 | GB_KEY_START_MASK = 1 << GB_KEY_START, 26 | } GB_key_mask_t; 27 | 28 | typedef void (*GB_update_input_hint_callback_t)(GB_gameboy_t *gb); 29 | 30 | void GB_set_key_state(GB_gameboy_t *gb, GB_key_t index, bool pressed); 31 | void GB_set_key_state_for_player(GB_gameboy_t *gb, GB_key_t index, unsigned player, bool pressed); 32 | void GB_set_key_mask(GB_gameboy_t *gb, GB_key_mask_t mask); 33 | void GB_set_key_mask_for_player(GB_gameboy_t *gb, GB_key_mask_t mask, unsigned player); 34 | void GB_icd_set_joyp(GB_gameboy_t *gb, uint8_t value); 35 | bool GB_get_joyp_accessed(GB_gameboy_t *gb); 36 | void GB_clear_joyp_accessed(GB_gameboy_t *gb); 37 | void GB_set_allow_illegal_inputs(GB_gameboy_t *gb, bool allow); 38 | void GB_set_emulate_joypad_bouncing(GB_gameboy_t *gb, bool emulate); 39 | void GB_set_update_input_hint_callback(GB_gameboy_t *gb, GB_update_input_hint_callback_t callback); 40 | void GB_set_use_faux_analog_inputs(GB_gameboy_t *gb, unsigned player, bool use); 41 | void GB_set_faux_analog_inputs(GB_gameboy_t *gb, unsigned player, double x, double y); 42 | 43 | #ifdef GB_INTERNAL 44 | internal void GB_update_joyp(GB_gameboy_t *gb); 45 | internal void GB_joypad_run(GB_gameboy_t *gb, unsigned cycles); 46 | internal void GB_update_faux_analog(GB_gameboy_t *gb); 47 | #endif 48 | -------------------------------------------------------------------------------- /Core/mbc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "defs.h" 3 | #include 4 | 5 | typedef struct { 6 | enum { 7 | GB_NO_MBC, 8 | GB_MBC1, 9 | GB_MBC2, 10 | GB_MBC3, 11 | GB_MBC5, 12 | GB_MBC7, 13 | GB_MMM01, 14 | GB_HUC1, 15 | GB_HUC3, 16 | GB_TPP1, 17 | GB_CAMERA, 18 | } mbc_type; 19 | bool has_ram; 20 | bool has_battery; 21 | bool has_rtc; 22 | bool has_rumble; 23 | } GB_cartridge_t; 24 | 25 | #ifdef GB_INTERNAL 26 | internal extern const GB_cartridge_t GB_cart_defs[256]; 27 | internal void GB_update_mbc_mappings(GB_gameboy_t *gb); 28 | internal void GB_configure_cart(GB_gameboy_t *gb); 29 | internal void GB_reset_mbc(GB_gameboy_t *gb); 30 | #endif 31 | -------------------------------------------------------------------------------- /Core/memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "defs.h" 3 | #include 4 | 5 | typedef uint8_t (*GB_read_memory_callback_t)(GB_gameboy_t *gb, uint16_t addr, uint8_t data); 6 | typedef bool (*GB_write_memory_callback_t)(GB_gameboy_t *gb, uint16_t addr, uint8_t data); // Return false to prevent the write 7 | void GB_set_read_memory_callback(GB_gameboy_t *gb, GB_read_memory_callback_t callback); 8 | void GB_set_write_memory_callback(GB_gameboy_t *gb, GB_write_memory_callback_t callback); 9 | 10 | uint8_t GB_read_memory(GB_gameboy_t *gb, uint16_t addr); 11 | uint8_t GB_safe_read_memory(GB_gameboy_t *gb, uint16_t addr); // Without side effects 12 | void GB_write_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value); 13 | #ifdef GB_INTERNAL 14 | internal void GB_dma_run(GB_gameboy_t *gb); 15 | internal bool GB_is_dma_active(GB_gameboy_t *gb); 16 | internal void GB_hdma_run(GB_gameboy_t *gb); 17 | internal void GB_trigger_oam_bug(GB_gameboy_t *gb, uint16_t address); 18 | internal uint8_t GB_read_oam(GB_gameboy_t *gb, uint8_t addr); 19 | #endif 20 | -------------------------------------------------------------------------------- /Core/model.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define GB_MODEL_FAMILY_MASK 0xF00 4 | #define GB_MODEL_DMG_FAMILY 0x000 5 | #define GB_MODEL_MGB_FAMILY 0x100 6 | #define GB_MODEL_CGB_FAMILY 0x200 7 | #define GB_MODEL_GBP_BIT 0x20 8 | #define GB_MODEL_PAL_BIT 0x40 9 | #define GB_MODEL_NO_SFC_BIT 0x80 10 | 11 | typedef enum { 12 | // GB_MODEL_DMG_0 = 0x000, 13 | // GB_MODEL_DMG_A = 0x001, 14 | GB_MODEL_DMG_B = 0x002, 15 | // GB_MODEL_DMG_C = 0x003, 16 | GB_MODEL_SGB = 0x004, 17 | GB_MODEL_SGB_NTSC = GB_MODEL_SGB, 18 | GB_MODEL_SGB_PAL = GB_MODEL_SGB | GB_MODEL_PAL_BIT, 19 | GB_MODEL_SGB_NTSC_NO_SFC = GB_MODEL_SGB | GB_MODEL_NO_SFC_BIT, 20 | GB_MODEL_SGB_NO_SFC = GB_MODEL_SGB_NTSC_NO_SFC, 21 | GB_MODEL_SGB_PAL_NO_SFC = GB_MODEL_SGB | GB_MODEL_NO_SFC_BIT | GB_MODEL_PAL_BIT, 22 | GB_MODEL_MGB = 0x100, 23 | GB_MODEL_SGB2 = 0x101, 24 | GB_MODEL_SGB2_NO_SFC = GB_MODEL_SGB2 | GB_MODEL_NO_SFC_BIT, 25 | GB_MODEL_CGB_0 = 0x200, 26 | GB_MODEL_CGB_A = 0x201, 27 | GB_MODEL_CGB_B = 0x202, 28 | GB_MODEL_CGB_C = 0x203, 29 | GB_MODEL_CGB_D = 0x204, 30 | GB_MODEL_CGB_E = 0x205, 31 | // GB_MODEL_AGB_0 = 0x206, 32 | GB_MODEL_AGB_A = 0x207, 33 | GB_MODEL_GBP_A = GB_MODEL_AGB_A | GB_MODEL_GBP_BIT, // AGB-A inside a Game Boy Player 34 | GB_MODEL_AGB = GB_MODEL_AGB_A, 35 | GB_MODEL_GBP = GB_MODEL_GBP_A, 36 | //GB_MODEL_AGB_B = 0x208 37 | //GB_MODEL_AGB_E = 0x209 38 | //GB_MODEL_GBP_E = GB_MODEL_AGB_E | GB_MODEL_GBP_BIT, // AGB-E inside a Game Boy Player 39 | } GB_model_t; 40 | -------------------------------------------------------------------------------- /Core/random.c: -------------------------------------------------------------------------------- 1 | #include "random.h" 2 | #include 3 | 4 | static uint64_t seed; 5 | static bool enabled = true; 6 | 7 | uint8_t GB_random(void) 8 | { 9 | if (!enabled) return 0; 10 | 11 | seed *= 0x27BB2EE687B0B0FDL; 12 | seed += 0xB504F32D; 13 | return seed >> 56; 14 | } 15 | 16 | uint32_t GB_random32(void) 17 | { 18 | GB_random(); 19 | return seed >> 32; 20 | } 21 | 22 | void GB_random_seed(uint64_t new_seed) 23 | { 24 | seed = new_seed; 25 | } 26 | 27 | void GB_random_set_enabled(bool enable) 28 | { 29 | enabled = enable; 30 | } 31 | 32 | static void __attribute__((constructor)) init_seed(void) 33 | { 34 | seed = time(NULL); 35 | for (unsigned i = 64; i--;) { 36 | GB_random(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "defs.h" 6 | 7 | #ifdef GB_INTERNAL 8 | internal uint8_t GB_random(void); 9 | internal uint32_t GB_random32(void); 10 | #endif 11 | void GB_random_seed(uint64_t seed); 12 | void GB_random_set_enabled(bool enable); 13 | -------------------------------------------------------------------------------- /Core/rewind.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef GB_DISABLE_REWIND 4 | #include 5 | #include "defs.h" 6 | 7 | #ifdef GB_INTERNAL 8 | internal void GB_rewind_push(GB_gameboy_t *gb); 9 | internal void GB_rewind_invalidate_for_backstepping(GB_gameboy_t *gb); 10 | #endif 11 | bool GB_rewind_pop(GB_gameboy_t *gb); 12 | void GB_set_rewind_length(GB_gameboy_t *gb, double seconds); 13 | void GB_rewind_reset(GB_gameboy_t *gb); 14 | #endif 15 | -------------------------------------------------------------------------------- /Core/rumble.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "defs.h" 4 | 5 | typedef enum { 6 | GB_RUMBLE_DISABLED, 7 | GB_RUMBLE_CARTRIDGE_ONLY, 8 | GB_RUMBLE_ALL_GAMES 9 | } GB_rumble_mode_t; 10 | 11 | #ifdef GB_INTERNAL 12 | internal void GB_handle_rumble(GB_gameboy_t *gb); 13 | #endif 14 | void GB_set_rumble_mode(GB_gameboy_t *gb, GB_rumble_mode_t mode); 15 | -------------------------------------------------------------------------------- /Core/sm83_cpu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "defs.h" 3 | #include 4 | 5 | #ifndef GB_DISABLE_DEBUGGER 6 | void GB_cpu_disassemble(GB_gameboy_t *gb, uint16_t pc, uint16_t count); 7 | #endif 8 | #ifdef GB_INTERNAL 9 | internal void GB_cpu_run(GB_gameboy_t *gb); 10 | #endif 11 | -------------------------------------------------------------------------------- /Core/symbol_hash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef GB_DISABLE_DEBUGGER 4 | #include 5 | #include 6 | #include 7 | 8 | typedef struct { 9 | char *name; 10 | uint16_t addr; 11 | bool is_local; 12 | } GB_bank_symbol_t; 13 | 14 | typedef struct GB_symbol_s { 15 | struct GB_symbol_s *next; 16 | const char *name; 17 | uint16_t bank; 18 | uint16_t addr; 19 | } GB_symbol_t; 20 | 21 | typedef struct { 22 | GB_bank_symbol_t *symbols; 23 | size_t n_symbols; 24 | } GB_symbol_map_t; 25 | 26 | typedef struct { 27 | GB_symbol_t *buckets[0x2000]; 28 | } GB_reversed_symbol_map_t; 29 | 30 | #ifdef GB_INTERNAL 31 | internal void GB_reversed_map_add_symbol(GB_reversed_symbol_map_t *map, uint16_t bank, GB_bank_symbol_t *symbol); 32 | internal const GB_symbol_t *GB_reversed_map_find_symbol(GB_reversed_symbol_map_t *map, const char *name); 33 | internal GB_bank_symbol_t *GB_map_add_symbol(GB_symbol_map_t *map, uint16_t addr, const char *name); 34 | internal const GB_bank_symbol_t *GB_map_find_symbol(GB_symbol_map_t *map, uint16_t addr, bool prefer_local); 35 | internal GB_symbol_map_t *GB_map_alloc(void); 36 | internal void GB_map_free(GB_symbol_map_t *map); 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /FreeDesktop/AppIcon/128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/AppIcon/128x128.png -------------------------------------------------------------------------------- /FreeDesktop/AppIcon/16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/AppIcon/16x16.png -------------------------------------------------------------------------------- /FreeDesktop/AppIcon/256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/AppIcon/256x256.png -------------------------------------------------------------------------------- /FreeDesktop/AppIcon/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/AppIcon/32x32.png -------------------------------------------------------------------------------- /FreeDesktop/AppIcon/512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/AppIcon/512x512.png -------------------------------------------------------------------------------- /FreeDesktop/AppIcon/64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/AppIcon/64x64.png -------------------------------------------------------------------------------- /FreeDesktop/Cartridge/128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/Cartridge/128x128.png -------------------------------------------------------------------------------- /FreeDesktop/Cartridge/16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/Cartridge/16x16.png -------------------------------------------------------------------------------- /FreeDesktop/Cartridge/256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/Cartridge/256x256.png -------------------------------------------------------------------------------- /FreeDesktop/Cartridge/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/Cartridge/32x32.png -------------------------------------------------------------------------------- /FreeDesktop/Cartridge/512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/Cartridge/512x512.png -------------------------------------------------------------------------------- /FreeDesktop/Cartridge/64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/Cartridge/64x64.png -------------------------------------------------------------------------------- /FreeDesktop/ColorCartridge/128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/ColorCartridge/128x128.png -------------------------------------------------------------------------------- /FreeDesktop/ColorCartridge/16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/ColorCartridge/16x16.png -------------------------------------------------------------------------------- /FreeDesktop/ColorCartridge/256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/ColorCartridge/256x256.png -------------------------------------------------------------------------------- /FreeDesktop/ColorCartridge/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/ColorCartridge/32x32.png -------------------------------------------------------------------------------- /FreeDesktop/ColorCartridge/512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/ColorCartridge/512x512.png -------------------------------------------------------------------------------- /FreeDesktop/ColorCartridge/64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/FreeDesktop/ColorCartridge/64x64.png -------------------------------------------------------------------------------- /FreeDesktop/sameboy.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Icon=sameboy 5 | Exec=sameboy 6 | Name=SameBoy 7 | Comment=Game Boy and Game Boy Color emulator 8 | Keywords=game;boy;gameboy;color;emulator 9 | Terminal=false 10 | StartupNotify=false 11 | Categories=Game;Emulator; 12 | MimeType=application/x-gameboy-rom;application/x-gameboy-color-rom;application/x-gameboy-isx 13 | -------------------------------------------------------------------------------- /FreeDesktop/sameboy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Game Boy ROM 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Game Boy Color ROM 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Game Boy ISX binary 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /HexFiend/HFAnnotatedTree.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFAnnotatedTree.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2010 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | typedef unsigned long long (*HFAnnotatedTreeAnnotaterFunction_t)(id left, id right); 11 | 12 | 13 | @interface HFAnnotatedTreeNode : NSObject { 14 | HFAnnotatedTreeNode *left; 15 | HFAnnotatedTreeNode *right; 16 | HFAnnotatedTreeNode *parent; 17 | uint32_t level; 18 | @public 19 | unsigned long long annotation; 20 | } 21 | 22 | /* Pure virtual method, which must be overridden. */ 23 | - (NSComparisonResult)compare:(HFAnnotatedTreeNode *)node; 24 | 25 | /* Returns the next in-order node. */ 26 | - (id)nextNode; 27 | 28 | - (id)leftNode; 29 | - (id)rightNode; 30 | - (id)parentNode; 31 | 32 | #if ! NDEBUG 33 | - (void)verifyIntegrity; 34 | - (void)verifyAnnotation:(HFAnnotatedTreeAnnotaterFunction_t)annotater; 35 | #endif 36 | 37 | 38 | @end 39 | 40 | 41 | @interface HFAnnotatedTree : NSObject { 42 | HFAnnotatedTreeAnnotaterFunction_t annotater; 43 | HFAnnotatedTreeNode *root; 44 | } 45 | 46 | - (instancetype)initWithAnnotater:(HFAnnotatedTreeAnnotaterFunction_t)annotater; 47 | - (void)insertNode:(HFAnnotatedTreeNode *)node; 48 | - (void)removeNode:(HFAnnotatedTreeNode *)node; 49 | - (id)rootNode; 50 | - (id)firstNode; 51 | - (BOOL)isEmpty; 52 | 53 | #if ! NDEBUG 54 | - (void)verifyIntegrity; 55 | #endif 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /HexFiend/HFBTree.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFBTree.h 3 | // HexFiend 4 | // 5 | // 6 | 7 | #import 8 | 9 | typedef unsigned long long HFBTreeIndex; 10 | 11 | @class HFBTreeNode; 12 | 13 | @protocol HFBTreeEntry 14 | - (unsigned long long)length; 15 | @end 16 | 17 | @interface HFBTree : NSObject { 18 | unsigned int depth; 19 | HFBTreeNode *root; 20 | } 21 | 22 | - (void)insertEntry:(id)entry atOffset:(HFBTreeIndex)offset; 23 | - (id)entryContainingOffset:(HFBTreeIndex)offset beginningOffset:(HFBTreeIndex *)outBeginningOffset; 24 | - (void)removeEntryAtOffset:(HFBTreeIndex)offset; 25 | - (void)removeAllEntries; 26 | 27 | #if HFUNIT_TESTS 28 | - (void)checkIntegrityOfCachedLengths; 29 | - (void)checkIntegrityOfBTreeStructure; 30 | #endif 31 | 32 | - (NSEnumerator *)entryEnumerator; 33 | - (NSArray *)allEntries; 34 | 35 | - (HFBTreeIndex)length; 36 | 37 | /* Applies the given function to the entry at the given offset, continuing with subsequent entries until the function returns NO. Do not modify the tree from within this function. */ 38 | - (void)applyFunction:(BOOL (*)(id entry, HFBTreeIndex offset, void *userInfo))func toEntriesStartingAtOffset:(HFBTreeIndex)offset withUserInfo:(void *)userInfo; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /HexFiend/HFBTreeByteArray.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFBTreeByteArray.h 3 | // HexFiend_2 4 | // 5 | // Created by peter on 4/28/09. 6 | // Copyright 2009 ridiculous_fish. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class HFBTree; 12 | 13 | /*! @class HFBTreeByteArray 14 | @brief The principal efficient implementation of HFByteArray. 15 | 16 | HFBTreeByteArray is an efficient subclass of HFByteArray that stores @link HFByteSlice HFByteSlices@endlink, using a 10-way B+ tree. This allows for insertion, deletion, and searching in approximately log-base-10 time. 17 | 18 | Create an HFBTreeByteArray via \c -init. It has no methods other than those on HFByteArray. 19 | */ 20 | 21 | @interface HFBTreeByteArray : HFByteArray { 22 | @private 23 | HFBTree *btree; 24 | } 25 | 26 | /*! Designated initializer for HFBTreeByteArray. 27 | */ 28 | - (instancetype)init; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /HexFiend/HFByteArray_Internal.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface HFByteArray (HFInternal) 4 | 5 | - (BOOL)_debugIsEqual:(HFByteArray *)val; 6 | - (BOOL)_debugIsEqualToData:(NSData *)val; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /HexFiend/HFByteSlice_Private.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface HFByteSlice (HFByteSlice_Private) 4 | 5 | - (void)constructNewByteSlicesAboutRange:(HFRange)range first:(HFByteSlice **)first second:(HFByteSlice **)second; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /HexFiend/HFFullMemoryByteArray.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFFullMemoryByteArray.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2007 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /*! 11 | @class HFFullMemoryByteArray 12 | @brief A naive subclass of HFByteArray suitable mainly for testing. Use HFBTreeByteArray instead. 13 | 14 | HFFullMemoryByteArray is a simple subclass of HFByteArray that does not store any byte slices. Because it stores all data in an NSMutableData, it is not efficient. It is mainly useful as a naive implementation for testing. Use HFBTreeByteArray instead. 15 | */ 16 | @interface HFFullMemoryByteArray : HFByteArray { 17 | NSMutableData *data; 18 | } 19 | 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HexFiend/HFFullMemoryByteSlice.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFFullMemoryByteSlice.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2007 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /*! @class HFFullMemoryByteSlice 11 | 12 | @brief A simple subclass of HFByteSlice that wraps an NSData. For most uses, prefer HFSharedMemoryByteSlice. 13 | */ 14 | @interface HFFullMemoryByteSlice : HFByteSlice { 15 | NSData *data; 16 | } 17 | 18 | /*! Init with a given NSData, which is copied via the \c -copy message. */ 19 | - (instancetype)initWithData:(NSData *)val; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HexFiend/HFFullMemoryByteSlice.m: -------------------------------------------------------------------------------- 1 | // 2 | // HFFullMemoryByteSlice.m 3 | // HexFiend_2 4 | // 5 | // Copyright 2007 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import "HFFullMemoryByteSlice.h" 9 | 10 | 11 | @implementation HFFullMemoryByteSlice 12 | 13 | - (instancetype)initWithData:(NSData *)val { 14 | REQUIRE_NOT_NULL(val); 15 | self = [super init]; 16 | data = [val copy]; 17 | return self; 18 | } 19 | 20 | - (void)dealloc { 21 | [data release]; 22 | [super dealloc]; 23 | } 24 | 25 | - (unsigned long long)length { return [data length]; } 26 | 27 | - (void)copyBytes:(unsigned char *)dst range:(HFRange)lrange { 28 | NSRange range; 29 | HFASSERT(lrange.location <= NSUIntegerMax); 30 | HFASSERT(lrange.length <= NSUIntegerMax); 31 | HFASSERT(lrange.location + lrange.length >= lrange.location); 32 | range.location = ll2l(lrange.location); 33 | range.length = ll2l(lrange.length); 34 | [data getBytes:dst range:range]; 35 | } 36 | 37 | - (HFByteSlice *)subsliceWithRange:(HFRange)range { 38 | HFASSERT(range.length > 0); 39 | HFASSERT(range.location < [self length]); 40 | HFASSERT([self length] - range.location >= range.length); 41 | HFASSERT(range.location <= NSUIntegerMax); 42 | HFASSERT(range.length <= NSUIntegerMax); 43 | return [[[[self class] alloc] initWithData:[data subdataWithRange:NSMakeRange(ll2l(range.location), ll2l(range.length))]] autorelease]; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /HexFiend/HFHexTextRepresenter.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFHexTextRepresenter.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2007 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /*! @class HFHexTextRepresenter 11 | 12 | @brief HFHexTextRepresenter is an HFRepresenter responsible for showing data in hexadecimal form. 13 | 14 | HFHexTextRepresenter is an HFRepresenter responsible for showing data in hexadecimal form. It has no methods except those inherited from HFTextRepresenter. 15 | */ 16 | @interface HFHexTextRepresenter : HFTextRepresenter { 17 | unsigned long long omittedNybbleLocation; 18 | unsigned char unpartneredLastNybble; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HexFiend/HFLineCountingView.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFLineCountingView.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2007 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface HFLineCountingView : NSView { 12 | NSLayoutManager *layoutManager; 13 | NSTextStorage *textStorage; 14 | NSTextContainer *textContainer; 15 | NSDictionary *textAttributes; 16 | 17 | unsigned long long storedLineIndex; 18 | NSUInteger storedLineCount; 19 | BOOL useStringDrawingPath; 20 | BOOL registeredForAppNotifications; 21 | } 22 | 23 | @property (nonatomic, copy) NSFont *font; 24 | @property (nonatomic) CGFloat lineHeight; 25 | @property (nonatomic) HFFPRange lineRangeToDraw; 26 | @property (nonatomic) NSUInteger bytesPerLine; 27 | @property (nonatomic) HFLineNumberFormat lineNumberFormat; 28 | @property (nonatomic, assign) HFLineCountingRepresenter *representer; 29 | 30 | + (NSUInteger)digitsRequiredToDisplayLineNumber:(unsigned long long)lineNumber inFormat:(HFLineNumberFormat)format; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /HexFiend/HFPrivilegedHelperConnection.h: -------------------------------------------------------------------------------- 1 | #ifndef HF_NO_PRIVILEGED_FILE_OPERATIONS 2 | #define HF_NO_PRIVILEGED_FILE_OPERATIONS 3 | #endif -------------------------------------------------------------------------------- /HexFiend/HFRepresenterHexTextView.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFRepresenterHexTextView.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2007 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | 11 | @interface HFRepresenterHexTextView : HFRepresenterTextView { 12 | CGGlyph glyphTable[17]; 13 | CGFloat glyphAdvancement; 14 | CGFloat spaceAdvancement; 15 | 16 | BOOL hidesNullBytes; 17 | } 18 | 19 | @property(nonatomic) BOOL hidesNullBytes; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HexFiend/HFRepresenterStringEncodingTextView.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFRepresenterStringEncodingTextView.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2007 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface HFRepresenterStringEncodingTextView : HFRepresenterTextView { 12 | /* Tier 0 data (always up to date) */ 13 | NSStringEncoding encoding; 14 | uint8_t bytesPerChar; 15 | 16 | /* Tier 1 data (computed synchronously on-demand) */ 17 | BOOL tier1DataIsStale; 18 | struct HFGlyph_t replacementGlyph; 19 | CGFloat glyphAdvancement; 20 | 21 | /* Tier 2 data (computed asynchronously on-demand) */ 22 | struct HFGlyphTrie_t glyphTable; 23 | 24 | NSArray *fontCache; 25 | 26 | /* Background thread */ 27 | OSSpinLock glyphLoadLock; 28 | BOOL requestedCancel; 29 | NSMutableArray *fonts; 30 | NSMutableIndexSet *requestedCharacters; 31 | NSOperationQueue *glyphLoader; 32 | } 33 | 34 | /// Set and get the NSStringEncoding that is used 35 | @property (nonatomic) NSStringEncoding encoding; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /HexFiend/HFRepresenterTextViewCallout.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFRepresenterTextViewCallout.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2011 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @class HFRepresenterTextView; 11 | 12 | #define kHFRepresenterTextViewCalloutMaxGlyphCount 2u 13 | 14 | @interface HFRepresenterTextViewCallout : NSObject { 15 | CGFloat rotation; 16 | NSPoint tipOrigin; 17 | NSPoint pinStart, pinEnd; 18 | } 19 | 20 | @property(nonatomic) NSInteger byteOffset; 21 | @property(nonatomic, copy) NSColor *color; 22 | @property(nonatomic, copy) NSString *label; 23 | @property(nonatomic, retain) id representedObject; 24 | @property(readonly) NSRect rect; 25 | 26 | + (void)layoutCallouts:(NSArray *)callouts inView:(HFRepresenterTextView *)textView; 27 | 28 | - (void)drawShadowWithClip:(NSRect)clip; 29 | - (void)drawWithClip:(NSRect)clip; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /HexFiend/HFRepresenterTextView_Internal.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #define GLYPH_BUFFER_SIZE 16u 4 | 5 | @interface HFRepresenterTextView (HFInternal) 6 | 7 | - (NSUInteger)_glyphsForString:(NSString *)string withGeneratingLayoutManager:(NSLayoutManager *)textView glyphs:(CGGlyph *)glyphs; 8 | - (NSUInteger)_glyphsForString:(NSString *)string withGeneratingTextView:(NSTextView *)textView glyphs:(CGGlyph *)glyphs; 9 | - (NSUInteger)_getGlyphs:(CGGlyph *)glyphs forString:(NSString *)string font:(NSFont *)font; //uses CoreText. Here glyphs must have space for [string length] glyphs. 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /HexFiend/HFRepresenter_Internal.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface HFRepresenter (HFInternalStuff) 4 | 5 | - (void)_setController:(HFController *)controller; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /HexFiend/HFSharedMemoryByteSlice.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFSharedMemoryByteSlice.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2008 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /*! @class HFSharedMemoryByteSlice 11 | @brief A subclass of HFByteSlice for working with data stored in memory. 12 | 13 | HFSharedMemoryByteSlice is a subclass of HFByteSlice that represents a portion of data from memory, e.g. typed or pasted in by the user. The term "shared" refers to the ability for mutiple HFSharedMemoryByteSlices to reference the same NSData; it does not mean that the data is in shared memory or shared between processes. 14 | 15 | Instances of HFSharedMemoryByteSlice are immutable (like all instances of HFByteSlice). However, to support efficient typing, the backing data is an instance of NSMutableData that may be grown. A referenced range of the NSMutableData will never have its contents changed, but it may be allowed to grow larger, so that the data does not have to be copied merely to append a single byte. This is implemented by overriding the -byteSliceByAppendingSlice: method of HFByteSlice. 16 | */ 17 | @interface HFSharedMemoryByteSlice : HFByteSlice { 18 | NSMutableData *data; 19 | NSUInteger offset; 20 | NSUInteger length; 21 | unsigned char inlineTailLength; 22 | unsigned char inlineTail[15]; //size chosen to exhaust padding of 32-byte allocator 23 | } 24 | 25 | // copies the data 26 | - (instancetype)initWithUnsharedData:(NSData *)data; 27 | 28 | // retains, does not copy 29 | - (instancetype)initWithData:(NSMutableData *)data; 30 | - (instancetype)initWithData:(NSMutableData *)data offset:(NSUInteger)offset length:(NSUInteger)length; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /HexFiend/HFStringEncodingTextRepresenter.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFASCIITextRepresenter.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2007 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /*! @class HFStringEncodingTextRepresenter 11 | 12 | @brief An HFRepresenter responsible for showing data interpreted via an NSStringEncoding. 13 | 14 | HFHexTextRepresenter is an HFRepresenter responsible for showing and editing data interpreted via an NSStringEncoding. Currently only supersets of ASCII are supported. 15 | */ 16 | @interface HFStringEncodingTextRepresenter : HFTextRepresenter { 17 | NSStringEncoding stringEncoding; 18 | 19 | } 20 | 21 | /*! Get the string encoding for this representer. The default encoding is [NSString defaultCStringEncoding]. */ 22 | @property (nonatomic) NSStringEncoding encoding; 23 | 24 | /*! Set the string encoding for this representer. */ 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /HexFiend/HFTextRepresenter_Internal.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface HFTextRepresenter (HFInternal) 4 | 5 | - (NSArray *)displayedSelectedContentsRanges; //returns an array of NSValues representing the selected ranges (as NSRanges) clipped to the displayed range. 6 | 7 | - (NSDictionary *)displayedBookmarkLocations; //returns an dictionary mapping bookmark names to bookmark locations. Bookmark locations may be negative. 8 | 9 | - (void)beginSelectionWithEvent:(NSEvent *)event forCharacterIndex:(NSUInteger)characterIndex; 10 | - (void)continueSelectionWithEvent:(NSEvent *)event forCharacterIndex:(NSUInteger)characterIndex; 11 | - (void)endSelectionWithEvent:(NSEvent *)event forCharacterIndex:(NSUInteger)characterIndex; 12 | 13 | // Copy/Paste methods 14 | - (void)copySelectedBytesToPasteboard:(NSPasteboard *)pb; 15 | - (void)cutSelectedBytesToPasteboard:(NSPasteboard *)pb; 16 | - (BOOL)canPasteFromPasteboard:(NSPasteboard *)pb; 17 | - (BOOL)canCut; 18 | - (BOOL)pasteBytesFromPasteboard:(NSPasteboard *)pb; 19 | 20 | // Must be implemented by subclasses 21 | - (void)insertText:(NSString *)text; 22 | 23 | // Must be implemented by subclasses. Return NSData representing the string value. 24 | - (NSData *)dataFromPasteboardString:(NSString *)string; 25 | 26 | // Value between [0, 1] 27 | - (double)selectionPulseAmount; 28 | 29 | - (void)scrollWheel:(NSEvent *)event; 30 | 31 | - (void)selectAll:(id)sender; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /HexFiend/HFTextVisualStyleRun.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFTextVisualStyle.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2009 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface HFTextVisualStyleRun : NSObject {} 11 | 12 | @property (nonatomic, copy) NSColor *foregroundColor; 13 | @property (nonatomic, copy) NSColor *backgroundColor; 14 | @property (nonatomic) NSRange range; 15 | @property (nonatomic) BOOL shouldDraw; 16 | @property (nonatomic) CGFloat scale; 17 | @property (nonatomic, copy) NSIndexSet *bookmarkStarts; 18 | @property (nonatomic, copy) NSIndexSet *bookmarkExtents; 19 | @property (nonatomic, copy) NSIndexSet *bookmarkEnds; 20 | 21 | - (void)set; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /HexFiend/HFTypes.h: -------------------------------------------------------------------------------- 1 | /*! @brief HFRange is the 64 bit analog of NSRange, containing a 64 bit location and length. */ 2 | typedef struct { 3 | unsigned long long location; 4 | unsigned long long length; 5 | } HFRange; 6 | 7 | /*! @brief HFFPRange is a struct used for representing floating point ranges, similar to NSRange. It contains two long doubles. 8 | 9 | This is useful for (for example) showing the range of visible lines. A double-precision value has 53 significant bits in the mantissa - so we would start to have precision problems at the high end of the range we can represent. Long double has a 64 bit mantissa on Intel, which means that we would start to run into trouble at the very very end of our range - barely acceptable. */ 10 | typedef struct { 11 | long double location; 12 | long double length; 13 | } HFFPRange; 14 | -------------------------------------------------------------------------------- /HexFiend/HFVerticalScrollerRepresenter.h: -------------------------------------------------------------------------------- 1 | // 2 | // HFRepresenterVerticalScroller.h 3 | // HexFiend_2 4 | // 5 | // Copyright 2007 ridiculous_fish. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | /*! @class HFVerticalScrollerRepresenter 11 | @brief An HFRepresenter responsible for showing a vertical scroll bar. 12 | 13 | HFVerticalScrollerRepresenter is an HFRepresenter whose view is a vertical NSScroller, that represents the current position within an HFController "document." It has no methods beyond those of HFRepresenter. 14 | 15 | As HFVerticalScrollerRepresenter is an especially simple representer, it makes for good sample code. 16 | */ 17 | @interface HFVerticalScrollerRepresenter : HFRepresenter { 18 | 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HexFiend/License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2009, Peter Ammon 2 | * All rights reserved. 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are met: 5 | * 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * 12 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY 13 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY 16 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 19 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | -------------------------------------------------------------------------------- /JoyKit/JOYAxes2D.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "JOYInput.h" 3 | 4 | typedef enum { 5 | JOYAxes2DUsageNone, 6 | JOYAxes2DUsageLeftStick, 7 | JOYAxes2DUsageRightStick, 8 | JOYAxes2DUsageMiddleStick, 9 | JOYAxes2DUsagePointer, 10 | JOYAxes2DUsageNonGenericMax, 11 | 12 | JOYAxes2DUsageGeneric0 = 0x10000, 13 | } JOYAxes2DUsage; 14 | 15 | @interface JOYAxes2D : JOYInput 16 | + (NSString *)usageToString: (JOYAxes2DUsage) usage; 17 | - (double)distance; 18 | - (double)angle; 19 | - (NSPoint)value; 20 | @property JOYAxes2DUsage usage; 21 | @end 22 | 23 | 24 | -------------------------------------------------------------------------------- /JoyKit/JOYAxes3D.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "JOYInput.h" 3 | 4 | typedef enum { 5 | JOYAxes3DUsageNone, 6 | JOYAxes3DUsageAcceleration, 7 | JOYAxes3DUsageOrientation, 8 | JOYAxes3DUsageGyroscope, 9 | JOYAxes3DUsageNonGenericMax, 10 | 11 | JOYAxes3DUsageGeneric0 = 0x10000, 12 | } JOYAxes3DUsage; 13 | 14 | typedef struct { 15 | double x, y, z; 16 | } JOYPoint3D; 17 | 18 | @interface JOYAxes3D : JOYInput 19 | + (NSString *)usageToString: (JOYAxes3DUsage) usage; 20 | - (JOYPoint3D)rawValue; 21 | - (JOYPoint3D)normalizedValue; // For orientation 22 | - (JOYPoint3D)gUnitsValue; // For acceleration 23 | @property JOYAxes3DUsage usage; 24 | @end 25 | 26 | 27 | -------------------------------------------------------------------------------- /JoyKit/JOYAxis.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "JOYButton.h" 3 | #import "JOYInput.h" 4 | 5 | typedef enum { 6 | JOYAxisUsageNone, 7 | JOYAxisUsageL1, 8 | JOYAxisUsageL2, 9 | JOYAxisUsageL3, 10 | JOYAxisUsageR1, 11 | JOYAxisUsageR2, 12 | JOYAxisUsageR3, 13 | 14 | JOYAxisUsageSlider, 15 | JOYAxisUsageDial, 16 | JOYAxisUsageWheel, 17 | 18 | JOYAxisUsageRudder, 19 | JOYAxisUsageThrottle, 20 | JOYAxisUsageAccelerator, 21 | JOYAxisUsageBrake, 22 | 23 | JOYAxisUsageNonGenericMax, 24 | 25 | JOYAxisUsageGeneric0 = 0x10000, 26 | } JOYAxisUsage; 27 | 28 | @interface JOYAxis : JOYInput 29 | + (NSString *)usageToString: (JOYAxisUsage) usage; 30 | - (double)value; 31 | - (JOYButtonUsage)equivalentButtonUsage; 32 | @property JOYAxisUsage usage; 33 | @end 34 | 35 | 36 | -------------------------------------------------------------------------------- /JoyKit/JOYButton.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "JOYInput.h" 3 | 4 | typedef enum { 5 | JOYButtonUsageNone, 6 | JOYButtonUsageA, 7 | JOYButtonUsageB, 8 | JOYButtonUsageC, 9 | JOYButtonUsageX, 10 | JOYButtonUsageY, 11 | JOYButtonUsageZ, 12 | JOYButtonUsageStart, 13 | JOYButtonUsageSelect, 14 | JOYButtonUsageHome, 15 | JOYButtonUsageMisc, 16 | JOYButtonUsageLStick, 17 | JOYButtonUsageRStick, 18 | JOYButtonUsageL1, 19 | JOYButtonUsageL2, 20 | JOYButtonUsageL3, 21 | JOYButtonUsageR1, 22 | JOYButtonUsageR2, 23 | JOYButtonUsageR3, 24 | JOYButtonUsageDPadLeft, 25 | JOYButtonUsageDPadRight, 26 | JOYButtonUsageDPadUp, 27 | JOYButtonUsageDPadDown, 28 | 29 | JOYButtonUsageSlider, 30 | JOYButtonUsageDial, 31 | JOYButtonUsageWheel, 32 | 33 | JOYButtonUsageRudder, 34 | JOYButtonUsageThrottle, 35 | JOYButtonUsageAccelerator, 36 | JOYButtonUsageBrake, 37 | 38 | JOYButtonUsageNonGenericMax, 39 | 40 | JOYButtonUsageGeneric0 = 0x10000, 41 | } JOYButtonUsage; 42 | 43 | typedef enum { 44 | JOYButtonTypeNormal, 45 | JOYButtonTypeAxisEmulated, 46 | JOYButtonTypeAxes2DEmulated, 47 | JOYButtonTypeHatEmulated, 48 | } JOYButtonType; 49 | 50 | @interface JOYButton : JOYInput 51 | + (NSString *)usageToString: (JOYButtonUsage) usage; 52 | - (bool) isPressed; 53 | @property JOYButtonUsage usage; 54 | @property (readonly) JOYButtonType type; 55 | @end 56 | 57 | 58 | -------------------------------------------------------------------------------- /JoyKit/JOYElement.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #define inline_const(type, ...) (*({static const typeof(type) _= __VA_ARGS__; &_;})) 5 | 6 | @interface JOYElement : NSObject 7 | - (instancetype)initWithElement:(IOHIDElementRef)element; 8 | - (int32_t)value; 9 | - (NSData *)dataValue; 10 | - (IOReturn)setValue:(uint32_t)value; 11 | - (IOReturn)setDataValue:(NSData *)value; 12 | @property (readonly) uint16_t usage; 13 | @property (readonly) uint16_t usagePage; 14 | @property (readonly) uint32_t uniqueID; 15 | @property int32_t min; 16 | @property int32_t max; 17 | @property (readonly) int32_t reportID; 18 | @property (readonly) int32_t parentID; 19 | 20 | @end 21 | 22 | 23 | -------------------------------------------------------------------------------- /JoyKit/JOYEmulatedButton.h: -------------------------------------------------------------------------------- 1 | #import "JOYButton.h" 2 | #import "JOYAxis.h" 3 | #import "JOYAxes2D.h" 4 | #import "JOYHat.h" 5 | 6 | @interface JOYEmulatedButton : JOYButton 7 | - (instancetype)initWithUsage:(JOYButtonUsage)usage type:(JOYButtonType)type uniqueID:(uint64_t)uniqueID; 8 | - (bool)updateStateFromAxis:(JOYAxis *)axis; 9 | - (bool)updateStateFromAxes2D:(JOYAxes2D *)axes; 10 | - (bool)updateStateFromHat:(JOYHat *)hat; 11 | @end 12 | -------------------------------------------------------------------------------- /JoyKit/JOYFullReportElement.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "JOYElement.h" 4 | 5 | @interface JOYFullReportElement : JOYElement 6 | - (instancetype)initWithDevice:(IOHIDDeviceRef) device reportID:(unsigned)reportID; 7 | - (void)updateValue:(NSData *)value; 8 | @end 9 | 10 | 11 | -------------------------------------------------------------------------------- /JoyKit/JOYFullReportElement.m: -------------------------------------------------------------------------------- 1 | #import "JOYFullReportElement.h" 2 | #import 3 | 4 | @implementation JOYFullReportElement 5 | { 6 | IOHIDDeviceRef _device; 7 | NSData *_data; 8 | unsigned _reportID; 9 | size_t _capacity; 10 | } 11 | 12 | - (uint32_t)uniqueID 13 | { 14 | return _reportID ^ 0xFFFF; 15 | } 16 | 17 | - (instancetype)initWithDevice:(IOHIDDeviceRef) device reportID:(unsigned)reportID 18 | { 19 | if ((self = [super init])) { 20 | _data = [[NSMutableData alloc] initWithLength:[(__bridge NSNumber *)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDMaxOutputReportSizeKey)) unsignedIntValue]]; 21 | *(uint8_t *)(((NSMutableData *)_data).mutableBytes) = reportID; 22 | _reportID = reportID; 23 | _device = device; 24 | } 25 | return self; 26 | } 27 | 28 | - (int32_t)value 29 | { 30 | [self doesNotRecognizeSelector:_cmd]; 31 | return 0; 32 | } 33 | 34 | - (NSData *)dataValue 35 | { 36 | return _data; 37 | } 38 | 39 | - (IOReturn)setValue:(uint32_t)value 40 | { 41 | [self doesNotRecognizeSelector:_cmd]; 42 | return -1; 43 | } 44 | 45 | - (IOReturn)setDataValue:(NSData *)value 46 | { 47 | 48 | [self updateValue:value]; 49 | return IOHIDDeviceSetReport(_device, kIOHIDReportTypeOutput, _reportID, [_data bytes], [_data length]); 50 | } 51 | 52 | - (void)updateValue:(NSData *)value 53 | { 54 | _data = [value copy]; 55 | } 56 | 57 | /* For use as a dictionary key */ 58 | 59 | - (NSUInteger)hash 60 | { 61 | return self.uniqueID; 62 | } 63 | 64 | - (BOOL)isEqual:(JOYFullReportElement *)object 65 | { 66 | if ([object isKindOfClass:self.class]) return false; 67 | return self.uniqueID == object.uniqueID; 68 | } 69 | 70 | - (id)copyWithZone:(NSZone *)zone; 71 | { 72 | return self; 73 | } 74 | @end 75 | -------------------------------------------------------------------------------- /JoyKit/JOYHat.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "JOYInput.h" 3 | 4 | @interface JOYHat : JOYInput 5 | - (double)angle; 6 | - (unsigned)resolution; 7 | @property (readonly, getter=isPressed) bool pressed; 8 | 9 | @end 10 | 11 | 12 | -------------------------------------------------------------------------------- /JoyKit/JOYHat.m: -------------------------------------------------------------------------------- 1 | #import "JOYHat.h" 2 | #import "JOYElement.h" 3 | #import 4 | 5 | @implementation JOYHat 6 | { 7 | JOYElement *_element; 8 | double _state; 9 | } 10 | 11 | - (uint64_t)uniqueID 12 | { 13 | return _element.uniqueID | (uint64_t)self.combinedIndex << 32; 14 | } 15 | 16 | - (NSString *)description 17 | { 18 | if (self.isPressed) { 19 | return [NSString stringWithFormat:@"<%@: %p (%llx); State: %f degrees>", self.className, self, self.uniqueID, self.angle]; 20 | } 21 | return [NSString stringWithFormat:@"<%@: %p (%llx); State: released>", self.className, self, self.uniqueID]; 22 | 23 | } 24 | 25 | - (instancetype)initWithElement:(JOYElement *)element 26 | { 27 | self = [super init]; 28 | if (!self) return self; 29 | 30 | _element = element; 31 | _state = -1; 32 | 33 | return self; 34 | } 35 | 36 | - (bool)isPressed 37 | { 38 | return _state >= 0 && _state < 360; 39 | } 40 | 41 | - (double)angle 42 | { 43 | if (self.isPressed) return fmod((_state + 270), 360); 44 | return -1; 45 | } 46 | 47 | - (unsigned)resolution 48 | { 49 | return _element.max - _element.min + 1; 50 | } 51 | 52 | - (bool)updateState 53 | { 54 | signed state = ([_element value] - _element.min) * 360.0 / self.resolution; 55 | if (_state != state) { 56 | _state = state; 57 | return true; 58 | } 59 | return false; 60 | } 61 | 62 | - (NSString *)usageString 63 | { 64 | return @"Hat switch"; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /JoyKit/JOYInput.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface JOYInput : NSObject 4 | @property (readonly) unsigned combinedIndex; 5 | - (NSString *)usageString; 6 | - (uint64_t)uniqueID; 7 | @end 8 | 9 | -------------------------------------------------------------------------------- /JoyKit/JOYInput.m: -------------------------------------------------------------------------------- 1 | #import "JOYInput.h" 2 | 3 | @interface JOYInput () 4 | @property unsigned combinedIndex; 5 | @end 6 | 7 | @implementation JOYInput 8 | 9 | - (uint64_t)uniqueID 10 | { 11 | [self doesNotRecognizeSelector:_cmd]; 12 | __builtin_unreachable(); 13 | } 14 | 15 | - (NSString *)usageString 16 | { 17 | [self doesNotRecognizeSelector:_cmd]; 18 | __builtin_unreachable(); 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /JoyKit/JOYMultiplayerController.h: -------------------------------------------------------------------------------- 1 | #import "JOYController.h" 2 | #import 3 | 4 | @interface JOYMultiplayerController : JOYController 5 | - (instancetype)initWithDevice:(IOHIDDeviceRef) device reportIDFilters:(NSArray *>*) reportIDFilters hacks:hacks; 6 | @end 7 | 8 | 9 | -------------------------------------------------------------------------------- /JoyKit/JOYMultiplayerController.m: -------------------------------------------------------------------------------- 1 | #import "JOYMultiplayerController.h" 2 | 3 | @interface JOYController () 4 | - (instancetype)initWithDevice:(IOHIDDeviceRef)device reportIDFilter:(NSArray *) filter serialSuffix:(NSString *)suffix hacks:(NSDictionary *)hacks; 5 | - (void)elementChanged:(IOHIDElementRef) element toValue:(IOHIDValueRef) value; 6 | - (void)disconnected; 7 | - (void)sendReport:(NSData *)report; 8 | @end 9 | 10 | @implementation JOYMultiplayerController 11 | { 12 | NSMutableArray *_children; 13 | } 14 | 15 | - (instancetype)initWithDevice:(IOHIDDeviceRef) device reportIDFilters:(NSArray *>*) reportIDFilters hacks:(NSDictionary *)hacks; 16 | { 17 | self = [super init]; 18 | if (!self) return self; 19 | 20 | _children = [NSMutableArray array]; 21 | 22 | unsigned index = 1; 23 | for (NSArray *filter in reportIDFilters) { 24 | JOYController *controller = [[JOYController alloc] initWithDevice:device reportIDFilter:filter serialSuffix:[NSString stringWithFormat:@"%d", index] hacks:hacks]; 25 | [_children addObject:controller]; 26 | index++; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)elementChanged:(IOHIDElementRef) element toValue:(IOHIDValueRef) value 32 | { 33 | for (JOYController *child in _children) { 34 | [child elementChanged:element toValue:value]; 35 | } 36 | } 37 | 38 | - (void)disconnected 39 | { 40 | for (JOYController *child in _children) { 41 | [child disconnected]; 42 | } 43 | } 44 | 45 | - (void)sendReport:(NSData *)report 46 | { 47 | [[_children firstObject] sendReport:report]; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /JoyKit/JOYSubElement.h: -------------------------------------------------------------------------------- 1 | #import "JOYElement.h" 2 | 3 | @interface JOYSubElement : JOYElement 4 | - (instancetype)initWithRealElement:(JOYElement *)element 5 | size:(size_t) size // in bits 6 | offset:(size_t) offset // in bits 7 | usagePage:(uint16_t)usagePage 8 | usage:(uint16_t)usage 9 | min:(int32_t)min 10 | max:(int32_t)max; 11 | 12 | @end 13 | 14 | 15 | -------------------------------------------------------------------------------- /JoyKit/JoyKit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #import "JOYController.h" 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | All files and directories in this repository, except for the iOS and HexFiend 2 | directories, are licensed under the Expat License: 3 | 4 | Expat License 5 | 6 | Copyright (c) 2015-2025 Lior Halphon 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | 26 | The files contained under the iOS directory in this repository are subject to 27 | this addition condition: 28 | 29 | A written permission from Lior Halphon is required to distribute copies or 30 | substantial portions of the Software in a digital marketplace, such as 31 | Apple's App Store. -------------------------------------------------------------------------------- /Misc/Palettes/Canyon.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Canyon.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Desert.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Desert.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Evening.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Evening.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Fog.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Fog.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Green Slate.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Green Slate.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Green Tea.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Green Tea.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Lavender.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Lavender.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Magic Eggplant.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Magic Eggplant.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Mystic Blue.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Mystic Blue.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Pink Pop.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Pink Pop.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Radioactive Pea.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Radioactive Pea.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Rose.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Rose.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Seaweed.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Seaweed.sbp -------------------------------------------------------------------------------- /Misc/Palettes/Twilight.sbp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Misc/Palettes/Twilight.sbp -------------------------------------------------------------------------------- /Misc/registers.sym: -------------------------------------------------------------------------------- 1 | 00:FF00 rJOYP 2 | 00:FF01 rSB 3 | 00:FF02 rSC 4 | 00:FF04 rDIV 5 | 00:FF05 rTIMA 6 | 00:FF06 rTMA 7 | 00:FF07 rTAC 8 | 00:FF0F rIF 9 | 00:FF10 rNR10 10 | 00:FF11 rNR11 11 | 00:FF12 rNR12 12 | 00:FF13 rNR13 13 | 00:FF14 rNR14 14 | 00:FF16 rNR21 15 | 00:FF17 rNR22 16 | 00:FF18 rNR23 17 | 00:FF19 rNR24 18 | 00:FF1A rNR30 19 | 00:FF1B rNR31 20 | 00:FF1C rNR32 21 | 00:FF1D rNR33 22 | 00:FF1E rNR34 23 | 00:FF20 rNR41 24 | 00:FF21 rNR42 25 | 00:FF22 rNR43 26 | 00:FF23 rNR44 27 | 00:FF24 rNR50 28 | 00:FF25 rNR51 29 | 00:FF26 rNR52 30 | 00:FF30 rWAV 31 | 00:FF40 rWAV.end 32 | 00:FF40 rLCDC 33 | 00:FF41 rSTAT 34 | 00:FF42 rSCY 35 | 00:FF43 rSCX 36 | 00:FF44 rLY 37 | 00:FF45 rLYC 38 | 00:FF46 rDMA 39 | 00:FF47 rBGP 40 | 00:FF48 rOBP0 41 | 00:FF49 rOBP1 42 | 00:FF4A rWY 43 | 00:FF4B rWX 44 | 00:FF4C rKEY0 45 | 00:FF4D rKEY1 46 | 00:FF4F rVBK 47 | 00:FF50 rBANK 48 | 00:FF51 rHDMA1 49 | 00:FF52 rHDMA2 50 | 00:FF53 rHDMA3 51 | 00:FF54 rHDMA4 52 | 00:FF55 rHDMA5 53 | 00:FF56 rRP 54 | 00:FF68 rBGPI 55 | 00:FF69 rBGPD 56 | 00:FF6A rOBPI 57 | 00:FF6B rOBPD 58 | 00:FF6C rOPRI 59 | 00:FF70 rSVBK 60 | 00:FF71 rPSM 61 | 00:FF72 rPSWX 62 | 00:FF73 rPSWY 63 | 00:FF74 rPSW 64 | 00:FF75 rPGB 65 | 00:FF76 rPCM12 66 | 00:FF77 rPCM34 67 | 00:FFFF rIE 68 | -------------------------------------------------------------------------------- /OpenDialog/open_dialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | char *do_open_rom_dialog(void); 4 | char *do_open_folder_dialog(void); 5 | char *do_save_recording_dialog(unsigned frequency); 6 | -------------------------------------------------------------------------------- /QuickLook/CartridgeTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/QuickLook/CartridgeTemplate.png -------------------------------------------------------------------------------- /QuickLook/ColorCartridgeTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/QuickLook/ColorCartridgeTemplate.png -------------------------------------------------------------------------------- /QuickLook/GBPreviewProvider.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | API_AVAILABLE(macos(12.0)) 5 | @interface GBPreviewProvider : QLPreviewProvider 6 | @end 7 | -------------------------------------------------------------------------------- /QuickLook/GBPreviewProvider.m: -------------------------------------------------------------------------------- 1 | #import "GBPreviewProvider.h" 2 | 3 | extern OSStatus GBQuickLookRender(CGContextRef cgContext, CFURLRef url, bool showBorder); 4 | 5 | @implementation GBPreviewProvider 6 | 7 | - (void)providePreviewForFileRequest:(QLFilePreviewRequest *)request completionHandler:(void (^)(QLPreviewReply *reply, NSError *error))handler 8 | { 9 | QLPreviewReply* reply = [[QLPreviewReply alloc] initWithContextSize:CGSizeMake(640, 576) 10 | isBitmap:true 11 | drawingBlock:^BOOL (CGContextRef context, QLPreviewReply *reply, NSError **error) { 12 | return !GBQuickLookRender(context, (__bridge CFURLRef)request.fileURL, false); 13 | 14 | }]; 15 | 16 | handler(reply, nil); 17 | } 18 | 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /QuickLook/GBThumbnailProvider.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | API_AVAILABLE(macos(10.15)) 4 | @interface GBThumbnailProvider : QLThumbnailProvider 5 | @end 6 | -------------------------------------------------------------------------------- /QuickLook/GBThumbnailProvider.m: -------------------------------------------------------------------------------- 1 | #import "GBThumbnailProvider.h" 2 | 3 | extern OSStatus GBQuickLookRender(CGContextRef cgContext, CFURLRef url, bool showBorder); 4 | 5 | @interface QLThumbnailReply (private) 6 | @property unsigned iconFlavor; 7 | @end 8 | 9 | @implementation GBThumbnailProvider 10 | 11 | - (void)provideThumbnailForFileRequest:(QLFileThumbnailRequest *)request completionHandler:(void (^)(QLThumbnailReply *, NSError *))handler 12 | { 13 | CGSize size = {64, 64}; 14 | CGSize maximumSize = request.maximumSize; 15 | while (size.width <= maximumSize.width / 2 && 16 | size.width <= maximumSize.height / 2) { 17 | size.width *= 2; 18 | } 19 | size.height = size.width; 20 | QLThumbnailReply *reply = [QLThumbnailReply replyWithContextSize:size drawingBlock: ^BOOL(CGContextRef context) { 21 | return !GBQuickLookRender(context, (__bridge CFURLRef)request.fileURL, true); 22 | }]; 23 | reply.iconFlavor = 0; 24 | handler(reply, nil); 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /QuickLook/Previewer.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDisplayName 6 | Previewer 7 | CFBundleExecutable 8 | Previewer 9 | CFBundleIdentifier 10 | com.github.liji32.sameboy.ios.Previewer 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | Previewer 15 | CFBundlePackageType 16 | XPC! 17 | CFBundleShortVersionString 18 | @VERSION 19 | CFBundleSupportedPlatforms 20 | 21 | MacOSX 22 | 23 | LSMinimumSystemVersion 24 | 12.0 25 | NSExtension 26 | 27 | NSExtensionAttributes 28 | 29 | QLSupportedContentTypes 30 | 31 | com.github.liji32.sameboy.gb 32 | com.github.liji32.sameboy.gbc 33 | com.github.liji32.sameboy.isx 34 | public.gbrom 35 | 36 | QLIsDataBasedPreview 37 | 38 | 39 | NSExtensionPointIdentifier 40 | com.apple.quicklook.preview 41 | NSExtensionPrincipalClass 42 | GBPreviewProvider 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /QuickLook/Thumbnailer.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDisplayName 6 | Thumbnailer 7 | CFBundleExecutable 8 | Thumbnailer 9 | CFBundleIdentifier 10 | com.github.liji32.sameboy.ios.Thumbnailer 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | Thumbnailer 15 | CFBundlePackageType 16 | XPC! 17 | CFBundleShortVersionString 18 | @VERSION 19 | CFBundleSupportedPlatforms 20 | 21 | MacOSX 22 | 23 | LSMinimumSystemVersion 24 | 12.0 25 | NSExtension 26 | 27 | NSExtensionAttributes 28 | 29 | QLSupportedContentTypes 30 | 31 | com.github.liji32.sameboy.gb 32 | com.github.liji32.sameboy.gbc 33 | com.github.liji32.sameboy.isx 34 | public.gbrom 35 | 36 | QLThumbnailMinimumDimension 37 | 64 38 | 39 | NSExtensionPointIdentifier 40 | com.apple.quicklook.thumbnail 41 | NSExtensionPrincipalClass 42 | GBThumbnailProvider 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /QuickLook/UniversalCartridgeTemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/QuickLook/UniversalCartridgeTemplate.png -------------------------------------------------------------------------------- /QuickLook/exports.sym: -------------------------------------------------------------------------------- 1 | _QuickLookGeneratorPluginFactory 2 | -------------------------------------------------------------------------------- /QuickLook/get_image_for_rom.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef bool (*cancel_callback_t)(void*); 6 | int get_image_for_rom(const char *filename, const char *boot_path, uint32_t *output, uint8_t *cgb_flag); 7 | -------------------------------------------------------------------------------- /QuickLook/plugin.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SDL/audio/audio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | bool GB_audio_is_playing(void); 8 | void GB_audio_set_paused(bool paused); 9 | void GB_audio_clear_queue(void); 10 | unsigned GB_audio_get_frequency(void); 11 | size_t GB_audio_get_queue_length(void); 12 | void GB_audio_queue_sample(GB_sample_t *sample); 13 | bool GB_audio_init(void); 14 | void GB_audio_deinit(void); 15 | const char *GB_audio_driver_name(void); 16 | const char *GB_audio_driver_name_at_index(unsigned index); 17 | 18 | typedef struct { 19 | typeof(GB_audio_is_playing) *audio_is_playing; 20 | typeof(GB_audio_set_paused) *audio_set_paused; 21 | typeof(GB_audio_clear_queue) *audio_clear_queue; 22 | typeof(GB_audio_get_frequency) *audio_get_frequency; 23 | typeof(GB_audio_get_queue_length) *audio_get_queue_length; 24 | typeof(GB_audio_queue_sample) *audio_queue_sample; 25 | typeof(GB_audio_init) *audio_init; 26 | typeof(GB_audio_deinit) *audio_deinit; 27 | const char *name; 28 | } GB_audio_driver_t; 29 | 30 | #define GB_AUDIO_DRIVER(_name) const GB_audio_driver_t _name##driver = { \ 31 | .audio_is_playing = _audio_is_playing, \ 32 | .audio_set_paused = _audio_set_paused, \ 33 | .audio_clear_queue = _audio_clear_queue, \ 34 | .audio_get_frequency = _audio_get_frequency, \ 35 | .audio_get_queue_length = _audio_get_queue_length, \ 36 | .audio_queue_sample = _audio_queue_sample, \ 37 | .audio_init = _audio_init, \ 38 | .audio_deinit = _audio_deinit, \ 39 | .name = #_name, \ 40 | } 41 | 42 | #define GB_AUDIO_DRIVER_REF(name) ({extern const GB_audio_driver_t name##driver; &name##driver;}) 43 | -------------------------------------------------------------------------------- /SDL/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/SDL/background.bmp -------------------------------------------------------------------------------- /SDL/configuration.c: -------------------------------------------------------------------------------- 1 | #include "configuration.h" 2 | 3 | configuration_t configuration = 4 | { 5 | .keys = { 6 | SDL_SCANCODE_RIGHT, 7 | SDL_SCANCODE_LEFT, 8 | SDL_SCANCODE_UP, 9 | SDL_SCANCODE_DOWN, 10 | SDL_SCANCODE_X, 11 | SDL_SCANCODE_Z, 12 | SDL_SCANCODE_BACKSPACE, 13 | SDL_SCANCODE_RETURN, 14 | SDL_SCANCODE_SPACE 15 | }, 16 | .keys_2 = { 17 | SDL_SCANCODE_TAB, 18 | SDL_SCANCODE_LSHIFT, 19 | }, 20 | .joypad_configuration = { 21 | 13, 22 | 14, 23 | 11, 24 | 12, 25 | 0, 26 | 1, 27 | 9, 28 | 8, 29 | 10, 30 | 4, 31 | -1, 32 | 5, 33 | // The rest are unmapped by default 34 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36 | }, 37 | .joypad_axises = { 38 | 0, 39 | 1, 40 | }, 41 | .color_correction_mode = GB_COLOR_CORRECTION_MODERN_BALANCED, 42 | .highpass_mode = GB_HIGHPASS_ACCURATE, 43 | .scaling_mode = GB_SDL_SCALING_INTEGER_FACTOR, 44 | .blending_mode = GB_FRAME_BLENDING_MODE_ACCURATE, 45 | .rewind_length = 60 * 2, 46 | .model = MODEL_AUTO, 47 | .volume = 100, 48 | .rumble_mode = GB_RUMBLE_CARTRIDGE_ONLY, 49 | .default_scale = 2, 50 | .color_temperature = 10, 51 | .cgb_revision = GB_MODEL_CGB_E - GB_MODEL_CGB_0, 52 | .dmg_palette = 1, // Replacing the old default (0) as of 0.15.2 53 | .agb_revision = GB_MODEL_AGB_A, 54 | }; 55 | -------------------------------------------------------------------------------- /SDL/font.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | extern uint8_t font[]; 5 | extern const uint8_t font_max; 6 | #define GLYPH_HEIGHT 8 7 | #define GLYPH_WIDTH 6 8 | #define LEFT_ARROW_STRING "\x86" 9 | #define RIGHT_ARROW_STRING "\x7F" 10 | #define SELECTION_STRING RIGHT_ARROW_STRING 11 | #define CTRL_STRING "\x80\x81\x82" 12 | #define SHIFT_STRING "\x83" 13 | #define ALT_STRING "\x91\x92" 14 | #define CMD_STRING "\x84\x85" 15 | #define ELLIPSIS_STRING "\x87" 16 | #define MOJIBAKE_STRING "\x88" 17 | #define SLIDER_STRING "\x89\x8A\x8A\x8A\x8A\x8A\x8A\x8A\x8A\x8A\x8F\x8A\x8A\x8A\x8A\x8A\x8A\x8A\x8A\x8A\x8B" 18 | #define SELECTED_SLIDER_STRING "\x8C\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8D\x8E" 19 | #define COPYRIGHT_STRING "\x90" 20 | #define CHECKBOX_OFF_STRING "\x93" 21 | #define CHECKBOX_ON_STRING "\x94" 22 | -------------------------------------------------------------------------------- /SDL/opengl_compat.c: -------------------------------------------------------------------------------- 1 | #define GL_GLEXT_PROTOTYPES 2 | #include 3 | 4 | #ifndef __APPLE__ 5 | #define GL_COMPAT_NAME(func) gl_compat_##func 6 | #define GL_COMPAT_VAR(func) typeof(func) *GL_COMPAT_NAME(func) 7 | 8 | GL_COMPAT_VAR(glCreateShader); 9 | GL_COMPAT_VAR(glGetAttribLocation); 10 | GL_COMPAT_VAR(glGetUniformLocation); 11 | GL_COMPAT_VAR(glUseProgram); 12 | GL_COMPAT_VAR(glGenVertexArrays); 13 | GL_COMPAT_VAR(glBindVertexArray); 14 | GL_COMPAT_VAR(glGenBuffers); 15 | GL_COMPAT_VAR(glBindBuffer); 16 | GL_COMPAT_VAR(glBufferData); 17 | GL_COMPAT_VAR(glEnableVertexAttribArray); 18 | GL_COMPAT_VAR(glVertexAttribPointer); 19 | GL_COMPAT_VAR(glCreateProgram); 20 | GL_COMPAT_VAR(glAttachShader); 21 | GL_COMPAT_VAR(glLinkProgram); 22 | GL_COMPAT_VAR(glGetProgramiv); 23 | GL_COMPAT_VAR(glGetProgramInfoLog); 24 | GL_COMPAT_VAR(glDeleteShader); 25 | GL_COMPAT_VAR(glUniform2f); 26 | GL_COMPAT_VAR(glActiveTexture); 27 | GL_COMPAT_VAR(glUniform1i); 28 | GL_COMPAT_VAR(glBindFragDataLocation); 29 | GL_COMPAT_VAR(glDeleteProgram); 30 | GL_COMPAT_VAR(glShaderSource); 31 | GL_COMPAT_VAR(glCompileShader); 32 | GL_COMPAT_VAR(glGetShaderiv); 33 | GL_COMPAT_VAR(glGetShaderInfoLog); 34 | #endif 35 | -------------------------------------------------------------------------------- /SDL/shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "opengl_compat.h" 4 | #include 5 | 6 | typedef struct shader_s { 7 | GLuint resolution_uniform; 8 | GLuint origin_uniform; 9 | GLuint texture_uniform; 10 | GLuint previous_texture_uniform; 11 | GLuint blending_mode_uniform; 12 | 13 | GLuint position_attribute; 14 | GLuint texture; 15 | GLuint previous_texture; 16 | GLuint program; 17 | } shader_t; 18 | 19 | typedef enum { 20 | GB_FRAME_BLENDING_MODE_DISABLED, 21 | GB_FRAME_BLENDING_MODE_SIMPLE, 22 | GB_FRAME_BLENDING_MODE_ACCURATE, 23 | GB_FRAME_BLENDING_MODE_ACCURATE_EVEN = GB_FRAME_BLENDING_MODE_ACCURATE, 24 | GB_FRAME_BLENDING_MODE_ACCURATE_ODD, 25 | } GB_frame_blending_mode_t; 26 | 27 | bool init_shader_with_name(shader_t *shader, const char *name); 28 | void render_bitmap_with_shader(shader_t *shader, void *bitmap, void *previous, 29 | unsigned source_width, unsigned source_height, 30 | unsigned x, unsigned y, unsigned w, unsigned h, 31 | GB_frame_blending_mode_t blending_mode); 32 | void free_shader(struct shader_s *shader); 33 | -------------------------------------------------------------------------------- /SDL/utils.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "utils.h" 7 | 8 | static const char *resource_folder(void) 9 | { 10 | static const char *ret = NULL; 11 | if (!ret) { 12 | ret = SDL_GetBasePath(); 13 | if (!ret) { 14 | ret = "./"; 15 | } 16 | } 17 | return ret; 18 | } 19 | 20 | char *resource_path(const char *filename) 21 | { 22 | static char path[PATH_MAX + 1]; 23 | 24 | snprintf(path, sizeof(path), "%s%s", resource_folder(), filename); 25 | #ifdef DATA_DIR 26 | if (access(path, F_OK) == 0) { 27 | return path; 28 | } 29 | snprintf(path, sizeof(path), "%s%s", DATA_DIR, filename); 30 | #endif 31 | return path; 32 | } 33 | 34 | 35 | void replace_extension(const char *src, size_t length, char *dest, const char *ext) 36 | { 37 | memcpy(dest, src, length); 38 | dest[length] = 0; 39 | 40 | /* Remove extension */ 41 | for (size_t i = length; i--;) { 42 | if (dest[i] == '/') break; 43 | if (dest[i] == '.') { 44 | dest[i] = 0; 45 | break; 46 | } 47 | } 48 | 49 | /* Add new extension */ 50 | strcat(dest, ext); 51 | } 52 | -------------------------------------------------------------------------------- /SDL/utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | char *resource_path(const char *filename); 6 | void replace_extension(const char *src, size_t length, char *dest, const char *ext); 7 | -------------------------------------------------------------------------------- /SDL/windows_associations.h: -------------------------------------------------------------------------------- 1 | #ifndef _WIN32 2 | #error windows_associations.h included while building for a different platform 3 | #endif 4 | #include 5 | bool GB_do_windows_association(void); 6 | -------------------------------------------------------------------------------- /Shaders/AAScale2x.fsh: -------------------------------------------------------------------------------- 1 | STATIC vec4 scale2x(sampler2D image, vec2 position, vec2 input_resolution, vec2 output_resolution) 2 | { 3 | // texel arrangement 4 | // A B C 5 | // D E F 6 | // G H I 7 | // vec4 A = texture(image, position + vec2( -o.x, o.y)); 8 | vec4 B = texture_relative(image, position, vec2( 0, 1)); 9 | vec4 D = texture_relative(image, position, vec2( -1, 0)); 10 | vec4 E = texture_relative(image, position, vec2( 0, 0)); 11 | vec4 F = texture_relative(image, position, vec2( 1, 0)); 12 | vec4 H = texture_relative(image, position, vec2( 0, -1)); 13 | vec2 p = position * input_resolution; 14 | // p = the position within a pixel [0...1] 15 | p = fract(p); 16 | if (p.x > .5) { 17 | if (p.y > .5) { 18 | // Top Right 19 | return equal(B, F) && inequal(B, D) && inequal(F, H) ? F : E; 20 | } else { 21 | // Bottom Right 22 | return equal(H, F) && inequal(D, H) && inequal(B, F) ? F : E; 23 | } 24 | } else { 25 | if (p.y > .5) { 26 | // Top Left 27 | return equal(D, B) && inequal(B, F) && inequal(D, H) ? D : E; 28 | } else { 29 | // Bottom Left 30 | return equal(D, H) && inequal(D, B) && inequal(H, F) ? D : E; 31 | } 32 | } 33 | } 34 | 35 | STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 output_resolution) 36 | { 37 | return mix(texture(image, position), scale2x(image, position, input_resolution, output_resolution), 0.5); 38 | } 39 | -------------------------------------------------------------------------------- /Shaders/Bilinear.fsh: -------------------------------------------------------------------------------- 1 | STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 output_resolution) 2 | { 3 | vec2 pixel = position * input_resolution - vec2(0.5, 0.5); 4 | 5 | vec4 q11 = texture(image, (floor(pixel) + 0.5) / input_resolution); 6 | vec4 q12 = texture(image, (vec2(floor(pixel.x), ceil(pixel.y)) + 0.5) / input_resolution); 7 | vec4 q21 = texture(image, (vec2(ceil(pixel.x), floor(pixel.y)) + 0.5) / input_resolution); 8 | vec4 q22 = texture(image, (ceil(pixel) + 0.5) / input_resolution); 9 | 10 | vec4 r1 = mix(q11, q21, fract(pixel.x)); 11 | vec4 r2 = mix(q12, q22, fract(pixel.x)); 12 | 13 | return mix (r1, r2, fract(pixel.y)); 14 | } 15 | -------------------------------------------------------------------------------- /Shaders/NearestNeighbor.fsh: -------------------------------------------------------------------------------- 1 | STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 output_resolution) 2 | { 3 | return texture(image, position); 4 | } 5 | -------------------------------------------------------------------------------- /Shaders/Scale2x.fsh: -------------------------------------------------------------------------------- 1 | /* Shader implementation of Scale2x is adapted from https://gist.github.com/singron/3161079 */ 2 | 3 | STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 output_resolution) 4 | { 5 | // texel arrangement 6 | // A B C 7 | // D E F 8 | // G H I 9 | 10 | vec4 B = texture_relative(image, position, vec2( 0, 1)); 11 | vec4 D = texture_relative(image, position, vec2( -1, 0)); 12 | vec4 E = texture_relative(image, position, vec2( 0, 0)); 13 | vec4 F = texture_relative(image, position, vec2( 1, 0)); 14 | vec4 H = texture_relative(image, position, vec2( 0, -1)); 15 | vec2 p = position * input_resolution; 16 | // p = the position within a pixel [0...1] 17 | p = fract(p); 18 | if (p.x > .5) { 19 | if (p.y > .5) { 20 | // Top Right 21 | return equal(B, F) && inequal(B, D) && inequal(F, H) ? F : E; 22 | } else { 23 | // Bottom Right 24 | return equal(H, F) && inequal(D, H) && inequal(B, F) ? F : E; 25 | } 26 | } else { 27 | if (p.y > .5) { 28 | // Top Left 29 | return equal(D, B) && inequal(B, F) && inequal(D, H) ? D : E; 30 | } else { 31 | // Bottom Left 32 | return equal(D, H) && inequal(D, B) && inequal(H, F) ? D : E; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Shaders/SmoothBilinear.fsh: -------------------------------------------------------------------------------- 1 | STATIC vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 output_resolution) 2 | { 3 | vec2 pixel = position * input_resolution - vec2(0.5, 0.5); 4 | 5 | vec4 q11 = texture(image, (floor(pixel) + 0.5) / input_resolution); 6 | vec4 q12 = texture(image, (vec2(floor(pixel.x), ceil(pixel.y)) + 0.5) / input_resolution); 7 | vec4 q21 = texture(image, (vec2(ceil(pixel.x), floor(pixel.y)) + 0.5) / input_resolution); 8 | vec4 q22 = texture(image, (ceil(pixel) + 0.5) / input_resolution); 9 | 10 | vec2 s = smoothstep(0., 1., fract(pixel)); 11 | 12 | vec4 r1 = mix(q11, q21, s.x); 13 | vec4 r2 = mix(q12, q22, s.x); 14 | 15 | return mix (r1, r2, s.y); 16 | } 17 | -------------------------------------------------------------------------------- /Windows/Cartridge.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Windows/Cartridge.ico -------------------------------------------------------------------------------- /Windows/ColorCartridge.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Windows/ColorCartridge.ico -------------------------------------------------------------------------------- /Windows/dirent.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "dirent.h" 6 | 7 | DIR *opendir(const char *filename) 8 | { 9 | wchar_t w_filename[MAX_PATH + 3] = {0,}; 10 | unsigned length = MultiByteToWideChar(CP_UTF8, 0, filename, -1, w_filename, MAX_PATH); 11 | if (length) { 12 | w_filename[length - 1] = L'/'; 13 | w_filename[length] = L'*'; 14 | w_filename[length + 1] = 0; 15 | } 16 | DIR *ret = malloc(sizeof(*ret)); 17 | ret->handle = FindFirstFileW(w_filename, &ret->entry); 18 | if (ret->handle == INVALID_HANDLE_VALUE) { 19 | free(ret); 20 | return NULL; 21 | } 22 | 23 | return ret; 24 | } 25 | 26 | int closedir(DIR *dir) 27 | { 28 | if (dir->handle != INVALID_HANDLE_VALUE) { 29 | FindClose(dir->handle); 30 | } 31 | free(dir); 32 | return 0; 33 | } 34 | 35 | struct dirent *readdir(DIR *dir) 36 | { 37 | if (dir->handle == INVALID_HANDLE_VALUE) { 38 | return NULL; 39 | } 40 | 41 | WideCharToMultiByte(CP_UTF8, 0, dir->entry.cFileName, -1, 42 | dir->out_entry.d_name, sizeof(dir->out_entry.d_name), 43 | NULL, NULL); 44 | 45 | if (!FindNextFileW(dir->handle, &dir->entry)) { 46 | FindClose(dir->handle); 47 | dir->handle = INVALID_HANDLE_VALUE; 48 | } 49 | 50 | return &dir->out_entry; 51 | } 52 | -------------------------------------------------------------------------------- /Windows/dirent.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct dirent { 4 | char d_name[MAX_PATH + 1]; 5 | }; 6 | 7 | typedef struct { 8 | HANDLE handle; 9 | WIN32_FIND_DATAW entry; 10 | struct dirent out_entry; 11 | } DIR; 12 | 13 | DIR *opendir(const char *filename); 14 | int closedir(DIR *dir); 15 | struct dirent *readdir(DIR *dir); 16 | -------------------------------------------------------------------------------- /Windows/inttypes.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /Windows/limits.h: -------------------------------------------------------------------------------- 1 | #include_next 2 | #define PATH_MAX 1024 3 | -------------------------------------------------------------------------------- /Windows/manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | SameBoy 10 | 11 | 12 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Windows/math.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef USE_MSVCRT_DLL 4 | 5 | /* "Old" (Pre-2015) Windows headers/libc don't have round and exp2. */ 6 | 7 | __attribute__((no_builtin)) double round(double f) 8 | { 9 | return f >= 0? (int)(f + 0.5) : (int)(f - 0.5); 10 | } 11 | 12 | 13 | __attribute__((no_builtin)) double exp2(double f) 14 | { 15 | return pow(2, f); 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /Windows/resources.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Windows/resources.rc -------------------------------------------------------------------------------- /Windows/sameboy.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/Windows/sameboy.ico -------------------------------------------------------------------------------- /Windows/stdint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include_next 3 | typedef intptr_t ssize_t; -------------------------------------------------------------------------------- /Windows/stdio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef noinline 4 | #undef noinline 5 | #include_next 6 | #define noinline __attribute__((noinline)) 7 | #else 8 | #include_next 9 | #endif 10 | 11 | #include 12 | #include 13 | 14 | #if _WIN64 15 | #define fseek(...) _fseeki64(__VA_ARGS__) 16 | #endif 17 | 18 | int access(const char *filename, int mode); 19 | #define R_OK 4 20 | #define W_OK 2 21 | 22 | #ifndef __MINGW32__ 23 | #ifndef __LIBRETRO__ 24 | int vasprintf(char **str, const char *fmt, va_list args); 25 | int asprintf(char **strp, const char *fmt, ...); 26 | #endif 27 | #endif 28 | 29 | intptr_t getline(char **lineptr, size_t *n, FILE *stream); 30 | 31 | #define snprintf _snprintf 32 | #define printf(...) fprintf(stdout, __VA_ARGS__) 33 | -------------------------------------------------------------------------------- /Windows/stdlib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include_next 3 | #define alloca _alloca 4 | -------------------------------------------------------------------------------- /Windows/string.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include_next 3 | #define strdup _strdup 4 | #define strcasecmp _stricmp 5 | -------------------------------------------------------------------------------- /Windows/unistd.h: -------------------------------------------------------------------------------- 1 | #include 2 | #define STDIN_FILENO 0 3 | #define STDOUT_FILENO 1 4 | #define STDERR_FILENO 2 5 | 6 | #define read(...) _read(__VA_ARGS__) 7 | #define write(...) _write(__VA_ARGS__) 8 | #define isatty(...) _isatty(__VA_ARGS__) 9 | #define close(...) _close(__VA_ARGS__) 10 | #define creat(...) _creat(__VA_ARGS__) 11 | -------------------------------------------------------------------------------- /Windows/utf8_compat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | FILE *fopen(const char *filename, const char *mode) 7 | { 8 | wchar_t w_filename[MAX_PATH] = {0,}; 9 | MultiByteToWideChar(CP_UTF8, 0, filename, -1, w_filename, sizeof(w_filename) / sizeof(w_filename[0])); 10 | 11 | wchar_t w_mode[8] = {0,}; 12 | MultiByteToWideChar(CP_UTF8, 0, mode, -1, w_mode, sizeof(w_mode) / sizeof(w_mode[0])); 13 | 14 | return _wfopen(w_filename, w_mode); 15 | } 16 | 17 | int access(const char *filename, int mode) 18 | { 19 | wchar_t w_filename[MAX_PATH] = {0,}; 20 | MultiByteToWideChar(CP_UTF8, 0, filename, -1, w_filename, sizeof(w_filename) / sizeof(w_filename[0])); 21 | 22 | return _waccess(w_filename, mode); 23 | } 24 | 25 | int _creat(const char *filename, int mode) 26 | { 27 | wchar_t w_filename[MAX_PATH] = {0,}; 28 | MultiByteToWideChar(CP_UTF8, 0, filename, -1, w_filename, sizeof(w_filename) / sizeof(w_filename[0])); 29 | return _wcreat(w_filename, mode & 0700); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /XdgThumbnailer/emulate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define GB_SCREEN_WIDTH 160 6 | #define GB_SCREEN_HEIGHT 144 7 | 8 | uint8_t emulate(const char *path, uint32_t screen[static GB_SCREEN_WIDTH * GB_SCREEN_HEIGHT]); 9 | -------------------------------------------------------------------------------- /XdgThumbnailer/resources.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | QuickLook/CartridgeTemplate.png 5 | QuickLook/ColorCartridgeTemplate.png 6 | QuickLook/UniversalCartridgeTemplate.png 7 | build/bin/BootROMs/cgb_boot_fast.bin 8 | 9 | 10 | -------------------------------------------------------------------------------- /XdgThumbnailer/sameboy.thumbnailer: -------------------------------------------------------------------------------- 1 | [Thumbnailer Entry] 2 | TryExec=sameboy-thumbnailer 3 | Exec=sameboy-thumbnailer %i %o %s 4 | MimeType=application/x-gameboy-rom;application/x-gameboy-color-rom;application/x-gameboy-isx 5 | -------------------------------------------------------------------------------- /iOS/AppIcon60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/AppIcon60x60@2x.png -------------------------------------------------------------------------------- /iOS/AppIcon76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/AppIcon76x76@2x.png -------------------------------------------------------------------------------- /iOS/Assets.car: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/Assets.car -------------------------------------------------------------------------------- /iOS/CameraRotateTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/CameraRotateTemplate@2x.png -------------------------------------------------------------------------------- /iOS/CameraRotateTemplate@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/CameraRotateTemplate@3x.png -------------------------------------------------------------------------------- /iOS/Cartridge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/Cartridge.png -------------------------------------------------------------------------------- /iOS/CheatsTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/CheatsTemplate@2x.png -------------------------------------------------------------------------------- /iOS/CheatsTemplate@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/CheatsTemplate@3x.png -------------------------------------------------------------------------------- /iOS/ColorCartridge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/ColorCartridge.png -------------------------------------------------------------------------------- /iOS/FolderTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/FolderTemplate@2x.png -------------------------------------------------------------------------------- /iOS/FolderTemplate@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/FolderTemplate@3x.png -------------------------------------------------------------------------------- /iOS/GBAboutController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBAboutController : UIViewController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/GBActivityViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBActivityViewController : UIActivityViewController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/GBActivityViewController.m: -------------------------------------------------------------------------------- 1 | #import "GBActivityViewController.h" 2 | 3 | @implementation GBActivityViewController 4 | 5 | - (UIModalPresentationStyle)modalPresentationStyle 6 | { 7 | return UIModalPresentationFormSheet; 8 | } 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /iOS/GBBackgroundView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GBLayout.h" 3 | #import "GBView.h" 4 | 5 | @interface GBBackgroundView : UIImageView 6 | - (instancetype)initWithLayout:(GBLayout *)layout; 7 | 8 | @property (readonly) GBView *gbView; 9 | @property (nonatomic) GBLayout *layout; 10 | @property (nonatomic) bool usesSwipePad; 11 | @property (nonatomic) bool fullScreenMode; 12 | 13 | - (void)enterPreviewMode:(bool)showLabel; 14 | - (void)reloadThemeImages; 15 | - (void)fadeOverlayOut; 16 | @end 17 | -------------------------------------------------------------------------------- /iOS/GBCheatsController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface GBCheatsController : UITableViewController 5 | - (instancetype)initWithGameBoy:(GB_gameboy_t *)gb; 6 | @end 7 | 8 | -------------------------------------------------------------------------------- /iOS/GBCheckableAlertController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBCheckableAlertController : UIAlertController 4 | @property UIAlertAction *selectedAction; 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/GBCheckableAlertController.m: -------------------------------------------------------------------------------- 1 | #import "GBCheckableAlertController.h" 2 | 3 | /* Private API */ 4 | @interface UIAlertAction() 5 | - (bool)_isChecked; 6 | - (void)_setChecked:(bool)checked; 7 | @end 8 | 9 | @implementation GBCheckableAlertController 10 | { 11 | bool _addedChecks; 12 | } 13 | 14 | - (void)viewWillAppear:(BOOL)animated 15 | { 16 | if (@available(iOS 13.0, *)) { 17 | if (!_addedChecks && _selectedAction) { 18 | _addedChecks = true; 19 | NSMutableSet *set = [NSMutableSet setWithObject:self.view]; 20 | while (set.count) { 21 | UIView *view = [set anyObject]; 22 | [set removeObject:view]; 23 | if ([view.debugDescription containsString:_selectedAction.debugDescription]) { 24 | UIImageView *checkImage = [[UIImageView alloc] initWithImage:[UIImage systemImageNamed:@"checkmark"]]; 25 | CGRect bounds = view.bounds; 26 | CGRect frame = checkImage.frame; 27 | frame.origin.x = bounds.size.width - frame.size.width - 12; 28 | frame.origin.y = round((bounds.size.height - frame.size.height) / 2); 29 | checkImage.frame = frame; 30 | [view addSubview:checkImage]; 31 | break; 32 | } 33 | [set addObjectsFromArray:view.subviews]; 34 | } 35 | } 36 | } 37 | else { 38 | [_selectedAction _setChecked:true]; 39 | } 40 | [super viewWillAppear:animated]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /iOS/GBColorWell.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | API_AVAILABLE(ios(14.0)) 4 | @interface GBColorWell : UIColorWell 5 | 6 | @end 7 | 8 | -------------------------------------------------------------------------------- /iOS/GBHapticManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface GBHapticManager : NSObject 5 | + (instancetype)sharedManager; 6 | - (void)doTapHaptic; 7 | - (void)setRumbleStrength:(double)rumble; 8 | @property (weak) GCController *controller; 9 | @end 10 | -------------------------------------------------------------------------------- /iOS/GBHapticManagerLegacy.h: -------------------------------------------------------------------------------- 1 | #import "GBHapticManager.h" 2 | 3 | @interface GBHapticManagerLegacy : GBHapticManager 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/GBHapticManagerLegacy.m: -------------------------------------------------------------------------------- 1 | #import "GBHapticManagerLegacy.h" 2 | #import 3 | #import 4 | 5 | @implementation GBHapticManagerLegacy 6 | 7 | - (void)doTapHaptic 8 | { 9 | [[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] impactOccurred]; 10 | } 11 | 12 | - (void)setRumbleStrength:(double)rumble 13 | { 14 | void AudioServicesStopSystemSound(SystemSoundID inSystemSoundID); 15 | void AudioServicesPlaySystemSoundWithVibration(SystemSoundID inSystemSoundID, id arg, NSDictionary* vibratePattern); 16 | if (rumble) { 17 | AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate, nil, @{@"Intensity": @(rumble), 18 | @"OffDuration": @0, 19 | @"OnDuration": @100, 20 | @"VibePattern": @[@YES, @1000], 21 | }); 22 | } 23 | else { 24 | AudioServicesStopSystemSound(kSystemSoundID_Vibrate); 25 | } 26 | } 27 | @end 28 | -------------------------------------------------------------------------------- /iOS/GBHorizontalLayout.h: -------------------------------------------------------------------------------- 1 | #import "GBLayout.h" 2 | 3 | @interface GBHorizontalLayout : GBLayout 4 | - (instancetype)initWithTheme:(GBTheme *)theme cutoutOnRight:(bool)cutoutOnRight; 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/GBLayout.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GBTheme.h" 3 | 4 | @interface GBLayout : NSObject 5 | - (instancetype)initWithTheme:(GBTheme *)theme; 6 | @property (readonly) GBTheme *theme; 7 | 8 | @property (readonly) UIImage *background; 9 | @property (readonly) CGRect screenRect; 10 | @property (readonly) CGRect fullScreenRect; 11 | @property (readonly) CGRect logoRect; 12 | @property (readonly) CGPoint dpadLocation; 13 | @property (readonly) CGPoint aLocation; 14 | @property (readonly) CGPoint bLocation; 15 | @property (readonly) CGPoint abComboLocation; 16 | @property (readonly) CGPoint startLocation; 17 | @property (readonly) CGPoint selectLocation; 18 | @property (readonly) unsigned cutout; 19 | 20 | - (CGRect)viewRectForOrientation:(UIInterfaceOrientation)orientation; 21 | @end 22 | 23 | #ifdef GBLayoutInternal 24 | 25 | @interface GBLayout() 26 | @property UIImage *background; 27 | @property CGRect screenRect; 28 | @property CGRect fullScreenRect; 29 | @property CGPoint dpadLocation; 30 | @property CGPoint aLocation; 31 | @property CGPoint bLocation; 32 | @property CGPoint abComboLocation; 33 | @property CGPoint startLocation; 34 | @property CGPoint selectLocation; 35 | @property (readonly) CGSize resolution; // Always vertical 36 | @property (readonly) CGSize size; // Size in pixels, override to make horizontal 37 | @property (readonly) unsigned factor; 38 | @property (readonly) unsigned minY; 39 | @property (readonly) unsigned homeBar; 40 | @property (readonly) bool hasFractionalPixels; 41 | 42 | - (void)drawBackground; 43 | - (void)drawScreenBezels; 44 | - (void)drawLogoInVerticalRange:(NSRange)range controlPadding:(double)padding; 45 | - (void)drawLabels; 46 | - (void)drawThemedLabelsWithBlock:(void (^)(void))block; 47 | 48 | - (CGSize)buttonDeltaForMaxHorizontalDistance:(double)distance; 49 | @end 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /iOS/GBLibraryViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBLibraryViewController : UITabBarController 4 | @end 5 | 6 | 7 | -------------------------------------------------------------------------------- /iOS/GBLibraryViewController.m: -------------------------------------------------------------------------------- 1 | #import "GBLibraryViewController.h" 2 | #import "GBROMViewController.h" 3 | #import "GBViewController.h" 4 | #import "GBROMManager.h" 5 | 6 | 7 | @implementation GBLibraryViewController 8 | 9 | + (UIViewController *)wrapViewController:(UIViewController *)controller 10 | { 11 | UINavigationController *ret = [[UINavigationController alloc] initWithRootViewController:controller]; 12 | UIBarButtonItem *close = [[UIBarButtonItem alloc] initWithTitle:@"Close" 13 | style:UIBarButtonItemStylePlain 14 | target:[UIApplication sharedApplication].delegate 15 | action:@selector(dismissViewController)]; 16 | [ret.visibleViewController.navigationItem setLeftBarButtonItem:close]; 17 | return ret; 18 | } 19 | 20 | 21 | - (instancetype)init 22 | { 23 | return (GBLibraryViewController *)[self.class wrapViewController:[[GBROMViewController alloc] init]]; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /iOS/GBMenuButton.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBMenuButton : UIButton 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/GBMenuButton.m: -------------------------------------------------------------------------------- 1 | #import "GBMenuButton.h" 2 | 3 | @implementation GBMenuButton 4 | 5 | - (void)setFrame:(CGRect)frame 6 | { 7 | [super setFrame:frame]; 8 | if (!self.imageView.image) return; 9 | CGSize imageSize = self.imageView.frame.size; 10 | CGSize titleSize = self.titleLabel.frame.size; 11 | 12 | self.imageEdgeInsets = UIEdgeInsetsMake(0, 13 | 0, 14 | 28, 15 | -titleSize.width); 16 | 17 | self.titleEdgeInsets = UIEdgeInsetsMake(36, 18 | -imageSize.width, 19 | 0, 20 | 0); 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /iOS/GBMenuViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBMenuViewController : UIAlertController 4 | + (instancetype)menu; 5 | @property (nonatomic) NSInteger selectedButtonIndex; 6 | @property (nonatomic, strong) NSArray *menuButtons; 7 | @end 8 | -------------------------------------------------------------------------------- /iOS/GBOptionViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBOptionViewController : UITableViewController 4 | - (instancetype)initWithHeader:(NSString *)header; 5 | @property NSString *header; 6 | @property NSString *footer; 7 | @property (getter=isModal) bool modal; 8 | - (void)addOption:(NSString *)title 9 | withCheckmark:(bool)checked 10 | action:(void (^)(void))block; 11 | @end 12 | -------------------------------------------------------------------------------- /iOS/GBPaletteEditor.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | API_AVAILABLE(ios(14.0)) 4 | @interface GBPaletteEditor : UITableViewController 5 | - (instancetype)initForPalette:(NSString *)name; 6 | @end 7 | 8 | -------------------------------------------------------------------------------- /iOS/GBPalettePicker.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface GBPalettePicker : UITableViewController 5 | + (const GB_palette_t *)paletteForTheme:(NSString *)theme; 6 | + (bool)importPalette:(NSString *)path; 7 | + (NSString *)makeUnique:(NSString *)name; 8 | @end 9 | -------------------------------------------------------------------------------- /iOS/GBPrinterFeedController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBPrinterFeedController : UINavigationController 4 | - (instancetype)initWithImage:(UIImage *)image; 5 | @end 6 | 7 | -------------------------------------------------------------------------------- /iOS/GBROMManager.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBROMManager : NSObject 4 | + (instancetype) sharedManager; 5 | 6 | @property (readonly) NSArray *allROMs; 7 | @property (nonatomic) NSString *currentROM; 8 | 9 | @property (readonly) NSString *romFile; 10 | @property (readonly) NSString *batterySaveFile; 11 | @property (readonly) NSString *autosaveStateFile; 12 | @property (readonly) NSString *cheatsFile; 13 | 14 | @property (readonly) NSString *localRoot; 15 | - (NSString *)stateFile:(unsigned)index; 16 | 17 | - (NSString *)romFileForROM:(NSString *)rom; 18 | - (NSString *)batterySaveFileForROM:(NSString *)rom; 19 | - (NSString *)autosaveStateFileForROM:(NSString *)rom; 20 | - (NSString *)stateFile:(unsigned)index forROM:(NSString *)rom; 21 | - (NSString *)importROM:(NSString *)romFile keepOriginal:(bool)keep; 22 | - (NSString *)importROM:(NSString *)romFile withName:(NSString *)friendlyName keepOriginal:(bool)keep; 23 | - (NSString *)renameROM:(NSString *)rom toName:(NSString *)newName; 24 | - (NSString *)duplicateROM:(NSString *)rom; 25 | - (void)deleteROM:(NSString *)rom; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /iOS/GBROMViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBROMViewController : UITableViewController 4 | 5 | /* For inheritance */ 6 | - (void)romSelectedAtIndex:(unsigned)index; 7 | - (void)deleteROMAtIndex:(unsigned)index; 8 | - (void)renameROM:(NSString *)oldName toName:(NSString *)newName; 9 | - (void)duplicateROMAtIndex:(unsigned)index; 10 | - (NSString *)rootPath; 11 | 12 | /* To be used by subclasses */ 13 | - (UITableViewCell *)cellForROM:(NSString *)rom; 14 | @end 15 | -------------------------------------------------------------------------------- /iOS/GBSettingsViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "GCExtendedGamepad+AllElements.h" 4 | #import "GBTheme.h" 5 | 6 | typedef enum { 7 | GBRight, 8 | GBLeft, 9 | GBUp, 10 | GBDown, 11 | GBA, 12 | GBB, 13 | GBSelect, 14 | GBStart, 15 | GBTurbo, 16 | GBRewind, 17 | GBUnderclock, 18 | // GBHotkey1, // Todo 19 | // GBHotkey2, // Todo 20 | GBTotalButtonCount, 21 | GBKeyboardButtonCount = GBUnderclock + 1, 22 | GBPerPlayerButtonCount = GBStart + 1, 23 | GBUnusedButton = 0xFF, 24 | } GBButton; 25 | 26 | @interface GBSettingsViewController : UITableViewController 27 | + (UIViewController *)settingsViewControllerWithLeftButton:(UIBarButtonItem *)button; 28 | + (GBButton)controller:(GCController *)controller convertUsageToButton:(GBControllerUsage)usage; 29 | + (GBTheme *)themeNamed:(NSString *)name; 30 | @end 31 | -------------------------------------------------------------------------------- /iOS/GBSlider.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | typedef enum { 4 | GBSliderStyleTemperature, 5 | GBSliderStyleHue, 6 | GBSliderStyleTicks, 7 | } GBSliderStyle; 8 | 9 | @interface GBSlider : UISlider 10 | @property GBSliderStyle style; 11 | @end 12 | -------------------------------------------------------------------------------- /iOS/GBSlotButton.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBSlotButton : UIButton 4 | + (instancetype)buttonWithLabelText:(NSString *)label; 5 | @property (readonly) UILabel *label; 6 | @property (readonly) UILabel *slotSubtitleLabel; 7 | @property (nonatomic, getter=isShowingMenu) bool showingMenu; 8 | @end 9 | -------------------------------------------------------------------------------- /iOS/GBStatesViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBStatesViewController : UIViewController 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/GBTheme.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBTheme : NSObject 4 | @property (readonly, direct) UIColor *brandColor; 5 | @property (readonly, direct) UIColor *buttonColor; 6 | @property (readonly, direct) UIColor *backgroundGradientTop; 7 | @property (readonly, direct) UIColor *backgroundGradientBottom; 8 | @property (readonly, direct) UIColor *bezelsGradientTop; 9 | @property (readonly, direct) UIColor *bezelsGradientBottom; 10 | 11 | 12 | @property (readonly, direct) NSString *name; 13 | 14 | @property (readonly, direct) bool renderingPreview; // Kind of a hack 15 | 16 | @property (readonly, direct) UIImage *horizontalPreview; 17 | @property (readonly, direct) UIImage *verticalPreview; 18 | 19 | @property (readonly, direct) bool isDark; 20 | 21 | - (instancetype)initDefaultTheme __attribute__((objc_direct)); 22 | - (instancetype)initDarkTheme __attribute__((objc_direct)); 23 | 24 | 25 | - (UIImage *)imageNamed:(NSString *)name __attribute__((objc_direct)); 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /iOS/GBThemePreviewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GBTheme.h" 3 | 4 | @interface GBThemePreviewController : UIViewController 5 | - (instancetype)initWithTheme:(GBTheme *)theme; 6 | @end 7 | 8 | -------------------------------------------------------------------------------- /iOS/GBThemesViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "GBTheme.h" 3 | 4 | @interface GBThemesViewController : UITableViewController 5 | + (NSArray *> *)themes; 6 | @end 7 | 8 | -------------------------------------------------------------------------------- /iOS/GBVerticalLayout.h: -------------------------------------------------------------------------------- 1 | #import "GBLayout.h" 2 | 3 | @interface GBVerticalLayout : GBLayout 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/GBView.h: -------------------------------------------------------------------------------- 1 | #import "GBViewBase.h" 2 | 3 | @interface GBView : GBViewBase 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/GBView.m: -------------------------------------------------------------------------------- 1 | #import "GBView.h" 2 | 3 | @implementation GBView 4 | - (instancetype)initWithFrame:(CGRect)frame 5 | { 6 | self = [super initWithFrame:frame]; 7 | [self createInternalView]; 8 | [self addSubview:self.internalView]; 9 | self.internalView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 10 | return self; 11 | } 12 | @end 13 | -------------------------------------------------------------------------------- /iOS/GBViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | typedef enum { 6 | GBRunModeNormal, 7 | GBRunModeTurbo, 8 | GBRunModeRewind, 9 | GBRunModePaused, 10 | GBRunModeUnderclock, 11 | } GBRunMode; 12 | 13 | @interface GBViewController : UIViewController 16 | @property (nonatomic, strong) UIWindow *window; 17 | - (void)reset; 18 | - (void)openLibrary; 19 | - (void)start; 20 | - (void)stop; 21 | - (void)changeModel; 22 | - (void)openStates; 23 | - (void)openSettings; 24 | - (void)showAbout; 25 | - (void)openConnectMenu; 26 | - (void)openCheats; 27 | - (void)emptyPrinterFeed; 28 | - (void)saveStateToFile:(NSString *)file; 29 | - (bool)loadStateFromFile:(NSString *)file; 30 | - (bool)handleOpenURLs:(NSArray *)urls 31 | openInPlace:(bool)inPlace; 32 | - (void)dismissViewController; 33 | @property (nonatomic) GBRunMode runMode; 34 | @end 35 | -------------------------------------------------------------------------------- /iOS/GBZipReader.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GBZipReader : NSObject 4 | - (instancetype)initWithBuffer:(const void *)buffer size:(size_t)size free:(void (^)(void))callback; 5 | - (instancetype)initWithPath:(NSString *)path; 6 | - (void)iterateFiles:(bool (^)(NSString *filename, size_t uncompressedSize, bool (^getData)(void *), bool (^writeToPath)(NSString *)))callback; 7 | @end 8 | -------------------------------------------------------------------------------- /iOS/GCExtendedGamepad+AllElements.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | typedef enum { 4 | GBUsageDpad, 5 | GBUsageButtonA, 6 | GBUsageButtonB, 7 | GBUsageButtonX, 8 | GBUsageButtonY, 9 | GBUsageButtonMenu, 10 | GBUsageButtonOptions, 11 | GBUsageButtonHome, 12 | GBUsageLeftThumbstick, 13 | GBUsageRightThumbstick, 14 | GBUsageLeftShoulder, 15 | GBUsageRightShoulder, 16 | GBUsageLeftTrigger, 17 | GBUsageRightTrigger, 18 | GBUsageLeftThumbstickButton, 19 | GBUsageRightThumbstickButton, 20 | GBUsageTouchpadButton, 21 | } GBControllerUsage; 22 | 23 | @interface GCExtendedGamepad (AllElements) 24 | - (NSDictionary *)elementsDictionary; 25 | @end 26 | -------------------------------------------------------------------------------- /iOS/LinkCableTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/LinkCableTemplate@2x.png -------------------------------------------------------------------------------- /iOS/LinkCableTemplate@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/LinkCableTemplate@3x.png -------------------------------------------------------------------------------- /iOS/ModelTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/ModelTemplate@2x.png -------------------------------------------------------------------------------- /iOS/ModelTemplate@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/ModelTemplate@3x.png -------------------------------------------------------------------------------- /iOS/PrinterTemplate@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/PrinterTemplate@2x.png -------------------------------------------------------------------------------- /iOS/PrinterTemplate@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/PrinterTemplate@3x.png -------------------------------------------------------------------------------- /iOS/UILabel+TapLocation.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface UILabel (TapLocation) 4 | - (unsigned)characterAtTap:(UITapGestureRecognizer *)tap; 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/UILabel+TapLocation.m: -------------------------------------------------------------------------------- 1 | #import "UILabel+TapLocation.h" 2 | 3 | @implementation UILabel (TapLocation) 4 | 5 | - (unsigned)characterAtTap:(UITapGestureRecognizer *)tap 6 | { 7 | CGPoint tapLocation = [tap locationInView:self]; 8 | 9 | NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:self.attributedText]; 10 | NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; 11 | [textStorage addLayoutManager:layoutManager]; 12 | 13 | NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:CGSizeMake(self.frame.size.width, 14 | self.frame.size.height + 256)]; 15 | textContainer.lineFragmentPadding = 0; 16 | textContainer.maximumNumberOfLines = 256; 17 | textContainer.lineBreakMode = self.lineBreakMode; 18 | 19 | [layoutManager addTextContainer:textContainer]; 20 | 21 | return [layoutManager characterIndexForPoint:tapLocation 22 | inTextContainer:textContainer 23 | fractionOfDistanceBetweenInsertionPoints:NULL]; 24 | 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /iOS/UIToolbar+disableCompact.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface UIToolbar (disableCompact) 4 | @property bool disableCompactLayout; 5 | @end 6 | -------------------------------------------------------------------------------- /iOS/UIToolbar+disableCompact.m: -------------------------------------------------------------------------------- 1 | #import "UIToolbar+disableCompact.h" 2 | #import 3 | 4 | @implementation UIToolbar (disableCompact) 5 | 6 | - (void)setDisableCompactLayout:(bool)disableCompactLayout 7 | { 8 | objc_setAssociatedObject(self, @selector(disableCompactLayout), @(disableCompactLayout), OBJC_ASSOCIATION_RETAIN); 9 | } 10 | 11 | - (bool)disableCompactLayout 12 | { 13 | return [objc_getAssociatedObject(self, _cmd) boolValue]; 14 | } 15 | 16 | - (CGSize)sizeThatFitsHook:(CGSize)size 17 | { 18 | CGSize ret = [self sizeThatFitsHook:size]; 19 | if (!self.disableCompactLayout) return ret; 20 | if (ret.height < 44) { 21 | ret.height = 44; 22 | } 23 | return ret; 24 | } 25 | 26 | + (void)load 27 | { 28 | method_exchangeImplementations(class_getInstanceMethod(self, @selector(sizeThatFitsHook:)), 29 | class_getInstanceMethod(self, @selector(sizeThatFits:))); 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /iOS/audioSettings@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/audioSettings@2x.png -------------------------------------------------------------------------------- /iOS/audioSettings@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/audioSettings@3x.png -------------------------------------------------------------------------------- /iOS/button2-tint@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/button2-tint@2x.png -------------------------------------------------------------------------------- /iOS/button2-tint@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/button2-tint@3x.png -------------------------------------------------------------------------------- /iOS/button2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/button2@2x.png -------------------------------------------------------------------------------- /iOS/button2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/button2@3x.png -------------------------------------------------------------------------------- /iOS/button2Pressed-tint@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/button2Pressed-tint@2x.png -------------------------------------------------------------------------------- /iOS/button2Pressed-tint@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/button2Pressed-tint@3x.png -------------------------------------------------------------------------------- /iOS/button2Pressed@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/button2Pressed@2x.png -------------------------------------------------------------------------------- /iOS/button2Pressed@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/button2Pressed@3x.png -------------------------------------------------------------------------------- /iOS/button@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/button@2x.png -------------------------------------------------------------------------------- /iOS/button@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/button@3x.png -------------------------------------------------------------------------------- /iOS/buttonPressed@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/buttonPressed@2x.png -------------------------------------------------------------------------------- /iOS/buttonPressed@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/buttonPressed@3x.png -------------------------------------------------------------------------------- /iOS/controlsSettings@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/controlsSettings@2x.png -------------------------------------------------------------------------------- /iOS/controlsSettings@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/controlsSettings@3x.png -------------------------------------------------------------------------------- /iOS/deb-control: -------------------------------------------------------------------------------- 1 | Package: com.github.liji32.sameboy.ios 2 | Name: SameBoy 3 | Depends: firmware (>= 11.0) 4 | Architecture: all 5 | Description: A Game Boy emulator for iOS 6 | Maintainer: Lior Halphon 7 | Author: Lior Halphon 8 | Section: Games 9 | Icon: file:///Applications/SameBoy-iOS.app/AppIcon60x60@2x.png 10 | Version: @VERSION 11 | -------------------------------------------------------------------------------- /iOS/deb-postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | /private/var/containers/SameBoy-iOS.app/installer install 3 | -------------------------------------------------------------------------------- /iOS/deb-prerm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | /Applications/SameBoy-iOS.app/installer uninstall || /var/jb/Applications/SameBoy-iOS.app/installer uninstall 3 | -------------------------------------------------------------------------------- /iOS/dpad-tint@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/dpad-tint@2x.png -------------------------------------------------------------------------------- /iOS/dpad-tint@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/dpad-tint@3x.png -------------------------------------------------------------------------------- /iOS/dpad@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/dpad@2x.png -------------------------------------------------------------------------------- /iOS/dpad@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/dpad@3x.png -------------------------------------------------------------------------------- /iOS/dpadShadow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/dpadShadow@2x.png -------------------------------------------------------------------------------- /iOS/dpadShadow@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/dpadShadow@3x.png -------------------------------------------------------------------------------- /iOS/dpadShadowDiagonal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/dpadShadowDiagonal@2x.png -------------------------------------------------------------------------------- /iOS/dpadShadowDiagonal@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/dpadShadowDiagonal@3x.png -------------------------------------------------------------------------------- /iOS/emulationSettings@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/emulationSettings@2x.png -------------------------------------------------------------------------------- /iOS/emulationSettings@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/emulationSettings@3x.png -------------------------------------------------------------------------------- /iOS/installer.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.private.mobileinstall.allowedSPI 6 | 7 | InstallForLaunchServices 8 | UninstallForLaunchServices 9 | 10 | com.apple.lsapplicationworkspace.rebuildappdatabases 11 | 12 | com.apple.private.MobileContainerManager.allowed 13 | 14 | com.apple.frontboard.launchapplications 15 | 16 | platform-application 17 | 18 | com.apple.private.security.no-container 19 | 20 | 21 | -------------------------------------------------------------------------------- /iOS/jailbreak.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.private.security.container-required 6 | 7 | 8 | -------------------------------------------------------------------------------- /iOS/logo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/logo@2x.png -------------------------------------------------------------------------------- /iOS/logo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/logo@3x.png -------------------------------------------------------------------------------- /iOS/sideload.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | application-identifier 6 | SAMEBOY.com.github.liji32.sameboy.ios 7 | com.apple.developer.team-identifier 8 | SAMEBOY 9 | com.apple.private.security.container-required 10 | com.github.liji32.sameboy.ios 11 | 12 | -------------------------------------------------------------------------------- /iOS/swipepad-tint@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/swipepad-tint@2x.png -------------------------------------------------------------------------------- /iOS/swipepad-tint@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/swipepad-tint@3x.png -------------------------------------------------------------------------------- /iOS/swipepad@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/swipepad@2x.png -------------------------------------------------------------------------------- /iOS/swipepad@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/swipepad@3x.png -------------------------------------------------------------------------------- /iOS/swipepadShadow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/swipepadShadow@2x.png -------------------------------------------------------------------------------- /iOS/swipepadShadow@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/swipepadShadow@3x.png -------------------------------------------------------------------------------- /iOS/swipepadShadowDiagonal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/swipepadShadowDiagonal@2x.png -------------------------------------------------------------------------------- /iOS/swipepadShadowDiagonal@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/swipepadShadowDiagonal@3x.png -------------------------------------------------------------------------------- /iOS/themeSettings@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/themeSettings@2x.png -------------------------------------------------------------------------------- /iOS/themeSettings@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/themeSettings@3x.png -------------------------------------------------------------------------------- /iOS/videoSettings@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/videoSettings@2x.png -------------------------------------------------------------------------------- /iOS/videoSettings@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/videoSettings@3x.png -------------------------------------------------------------------------------- /iOS/waveform.weak@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/waveform.weak@2x.png -------------------------------------------------------------------------------- /iOS/waveform.weak@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LIJI32/SameBoy/63a02d90bc6dd057a213ad078367a10b4242e59e/iOS/waveform.weak@3x.png -------------------------------------------------------------------------------- /libretro/Makefile.common: -------------------------------------------------------------------------------- 1 | include $(CORE_DIR)/version.mk 2 | 3 | INCFLAGS := -I$(CORE_DIR) 4 | 5 | SOURCES_C := $(CORE_DIR)/Core/gb.c \ 6 | $(CORE_DIR)/Core/sgb.c \ 7 | $(CORE_DIR)/Core/apu.c \ 8 | $(CORE_DIR)/Core/memory.c \ 9 | $(CORE_DIR)/Core/mbc.c \ 10 | $(CORE_DIR)/Core/timing.c \ 11 | $(CORE_DIR)/Core/display.c \ 12 | $(CORE_DIR)/Core/camera.c \ 13 | $(CORE_DIR)/Core/sm83_cpu.c \ 14 | $(CORE_DIR)/Core/joypad.c \ 15 | $(CORE_DIR)/Core/save_state.c \ 16 | $(CORE_DIR)/Core/random.c \ 17 | $(CORE_DIR)/Core/rumble.c \ 18 | $(CORE_DIR)/libretro/agb_boot.c \ 19 | $(CORE_DIR)/libretro/cgb_boot.c \ 20 | $(CORE_DIR)/libretro/cgb0_boot.c \ 21 | $(CORE_DIR)/libretro/mgb_boot.c \ 22 | $(CORE_DIR)/libretro/dmg_boot.c \ 23 | $(CORE_DIR)/libretro/sgb_boot.c \ 24 | $(CORE_DIR)/libretro/sgb2_boot.c \ 25 | $(CORE_DIR)/libretro/libretro.c 26 | 27 | CFLAGS += -DGB_DISABLE_TIMEKEEPING -DGB_DISABLE_REWIND -DGB_DISABLE_DEBUGGER -DGB_DISABLE_CHEATS 28 | 29 | 30 | SOURCES_CXX := 31 | -------------------------------------------------------------------------------- /libretro/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | CORE_DIR := $(LOCAL_PATH)/../.. 4 | 5 | CFLAGS := 6 | 7 | include $(CORE_DIR)/libretro/Makefile.common 8 | 9 | GENERATED_SOURCES := $(filter %_boot.c,$(SOURCES_C)) 10 | 11 | COREFLAGS := -DINLINE=inline -D__LIBRETRO__ -DGB_INTERNAL $(INCFLAGS) -DGB_VERSION=\"$(VERSION)\" -Wno-multichar -DANDROID 12 | 13 | GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)" 14 | ifneq ($(GIT_VERSION)," unknown") 15 | COREFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" 16 | endif 17 | 18 | include $(CLEAR_VARS) 19 | LOCAL_MODULE := retro 20 | LOCAL_SRC_FILES := $(SOURCES_C) 21 | LOCAL_CFLAGS := -std=c99 $(COREFLAGS) $(CFLAGS) 22 | LOCAL_LDFLAGS := -Wl,-version-script=$(CORE_DIR)/libretro/link.T 23 | include $(BUILD_SHARED_LIBRARY) 24 | 25 | override BOOTROMS_DIR := $(shell cd ../.. && realpath -m $(BOOTROMS_DIR)) 26 | 27 | $(CORE_DIR)/libretro/%_boot.c: $(BOOTROMS_DIR)/%_boot.bin 28 | echo "/* AUTO-GENERATED */" > $@ 29 | echo "const unsigned char $(notdir $(@:%.c=%))[] = {" >> $@ 30 | hexdump -v -e '/1 "0x%02x, "' $< >> $@ 31 | echo "};" >> $@ 32 | echo "const unsigned $(notdir $(@:%.c=%))_length = sizeof($(notdir $(@:%.c=%)));" >> $@ 33 | 34 | .INTERMEDIATE: $(GENERATED_SOURCES) 35 | -------------------------------------------------------------------------------- /libretro/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := all 2 | -------------------------------------------------------------------------------- /libretro/link.T: -------------------------------------------------------------------------------- 1 | { 2 | global: retro_*; 3 | local: *; 4 | }; 5 | 6 | -------------------------------------------------------------------------------- /libretro/retro_inline.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_inline.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_INLINE_H 24 | #define __LIBRETRO_SDK_INLINE_H 25 | 26 | #ifndef INLINE 27 | 28 | #if defined(_WIN32) || defined(__INTEL_COMPILER) 29 | #define INLINE __inline 30 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 31 | #define INLINE inline 32 | #elif defined(__GNUC__) 33 | #define INLINE __inline__ 34 | #else 35 | #define INLINE 36 | #endif 37 | 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /sameboy.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=${prefix} 3 | includedir=${prefix}/include 4 | libdir=${prefix}/lib 5 | 6 | Name: sameboy 7 | Description: SameBoy's emulation core as a library 8 | Version: @version@ 9 | Cflags: -I${includedir} 10 | Libs: -L${libdir} -lsameboy 11 | Libs.private: -lm -lc -------------------------------------------------------------------------------- /version.mk: -------------------------------------------------------------------------------- 1 | VERSION := 1.0.1 --------------------------------------------------------------------------------