Compare commits

..

1000 Commits

Author SHA1 Message Date
Lior Halphon
b7f03dea8d Add CGB-A support 2022-01-05 21:55:46 +02:00
Lior Halphon
ab1d4cd26e More DMA write conflicts 2022-01-05 21:40:10 +02:00
Lior Halphon
5e7bb0f891 DMA write conflict revision differences 2022-01-04 19:59:46 +02:00
Lior Halphon
79ec22b28e Clang hates this 2022-01-03 17:55:00 +02:00
Lior Halphon
5c17c0ec3b unreachable fun 2022-01-03 17:17:35 +02:00
Lior Halphon
cd16431699 OMA DMA improvements (WIP) 2022-01-03 16:51:45 +02:00
Lior Halphon
81e45b00b9 Minor Cocoa bug fixes 2022-01-03 16:51:24 +02:00
Lior Halphon
c7298ae5a6 Fix a silly underflow 2022-01-03 16:51:05 +02:00
Lior Halphon
8e675295a8 Enable LTO in Windows builds, fix missing MGB boot in SDL 2021-12-31 00:40:34 +02:00
Lior Halphon
bc073e3d09 Expose PC 2021-12-30 23:53:24 +02:00
Lior Halphon
52c5610528 Cocoa audio driver goes brrrr 2021-12-29 17:21:06 +02:00
Lior Halphon
38eafeb0cf Never deadlock ever again thanks 2021-12-29 17:03:44 +02:00
Lior Halphon
97652b7460 Cocoa audio bugfix 2021-12-29 16:53:28 +02:00
Lior Halphon
59c315a5dd Minor free optimization 2021-12-29 16:33:04 +02:00
Lior Halphon
b72c2ea225 DMG palette getter 2021-12-29 13:08:46 +02:00
Lior Halphon
769aac93c0 Lazy APU, extra ~17% speed up 2021-12-29 00:48:44 +02:00
Lior Halphon
db50462710 More accurate fix 2021-12-26 23:24:08 +02:00
Lior Halphon
59dfb1a85a It's not verified because it's wrong 2021-12-26 21:57:40 +02:00
Lior Halphon
6ffe924637 This is probably better but still wrong 2021-12-26 21:43:54 +02:00
Lior Halphon
d178ece909 Disabled an incorrectly emulated portion of the TILE_SET glitch 2021-12-26 19:57:18 +02:00
Lior Halphon
6e7ba7589c Fixed blurred unfiltered screenshots 2021-12-26 18:38:08 +02:00
Lior Halphon
66f7babe86 Cache the clock rate 2021-12-26 15:50:24 +02:00
Lior Halphon
c53d99dbc4 Abolished slow double use 2021-12-26 15:20:46 +02:00
Lior Halphon
c5f6be1e64 Several likely/unlikely optimization, saving on a memset 2021-12-26 02:38:54 +02:00
Lior Halphon
69de3f0fae Implement a PPU fast path, up to 34% performance boost 2021-12-26 01:47:59 +02:00
Lior Halphon
f3277ab8d3 Sorry C++ users 2021-12-20 18:59:51 +02:00
Lior Halphon
e9906e44cd Sure, why not 2021-12-19 21:46:22 +02:00
Lior Halphon
f866441481 Improved emulation of channel 3 wave RAM read glitch 2021-12-19 19:27:40 +02:00
Lior Halphon
e9629407a5 Fix potential alignment issues 2021-12-19 00:54:29 +02:00
Lior Halphon
cdc3321c36 Add an API to allow illegal inputs 2021-12-19 00:28:24 +02:00
Lior Halphon
eaccd792ed Fixes to safe reads, closes #422 2021-12-18 14:56:33 +02:00
Lior Halphon
5127cb0022 Direct access to registers (#422) 2021-12-18 14:51:14 +02:00
Lior Halphon
c63ddbe771 Lag frame detection API (#422) 2021-12-18 01:25:06 +02:00
Lior Halphon
c3d9141b7c Replace the term sprite with object for consistency 2021-12-17 21:16:23 +02:00
Lior Halphon
c1ae129ed4 Allow hiding background/object "layers" (#422) 2021-12-17 21:12:26 +02:00
Lior Halphon
f78fac12c2 Fixed several issues involving LY change timing, as well as an LYC issue in models prior to CGB-D 2021-12-14 20:27:38 +02:00
Lior Halphon
7e5e672988 RTC speed multiplier, for TAS syncing (#422) 2021-12-11 02:51:21 +02:00
Lior Halphon
a30247cf16 LCD line callback (for #422) 2021-12-10 19:49:52 +02:00
Lior Halphon
7508ddb0cf Execute callback (for #422) 2021-12-10 19:42:47 +02:00
Lior Halphon
e087bd5218 The GBS visualizer should use custom color palettes 2021-12-10 02:06:12 +02:00
Lior Halphon
9e57201b08 Accurate IF clear timing 2021-12-05 16:18:54 +02:00
Lior Halphon
25e3414974 Redesigned vblank callback scheduling scheme, should be more regular and less prune to various sorts of frontend DOS 2021-12-04 15:04:46 +02:00
Lior Halphon
4b3c77bfa5 oops 2021-12-02 11:54:26 +02:00
Lior Halphon
8660e20eeb New inputs API 2021-12-02 11:23:44 +02:00
Lior Halphon
b770bbea2e Fix save state issue that caused vblank callbacks timings to differ 2021-12-02 11:21:12 +02:00
Lior Halphon
486f8a2c10
Merge pull request #420 from SnowyMouse/cgb_mode
Add GB_is_cgb_in_cgb_mode
2021-11-26 14:10:35 +02:00
Lior Halphon
06b744259b Add memory write callback, optimize memory access with likely/unlikely 2021-11-26 14:09:41 +02:00
Lior Halphon
bdbe02b043 Add a safe memory read API 2021-11-26 13:54:28 +02:00
Lior Halphon
33090a5cc0 Fix an oops from the last commit 2021-11-26 13:38:52 +02:00
Snowy
d0a9d2f72a Add GB_is_cgb_in_cgb_mode 2021-11-25 17:16:11 -06:00
Lior Halphon
f1e5e04198 ...even when timekeeping is disabled 2021-11-25 21:46:51 +02:00
Lior Halphon
d0d39015ee Let update_input_hint_callback get called during turbo 2021-11-25 21:17:49 +02:00
Lior Halphon
f08f16346e Fix #293 2021-11-24 23:13:52 +02:00
Lior Halphon
d94c8b9125 Switch Pro Controller motion controls 2021-11-22 23:29:10 +02:00
Lior Halphon
d15eaf4134 Mouse controls for MBC7 2021-11-14 21:43:31 +02:00
Lior Halphon
ae930472f0 Units info 2021-11-14 13:18:58 +02:00
Lior Halphon
7a78649e21 Implement motion controls in JoyKit, implement accel/gyro in DualSense and DualShock 4, implement motion controls in Cocoa 2021-11-13 19:23:45 +02:00
Lior Halphon
06ce30d3a8 Map joysticks to motion controls 2021-11-12 18:10:03 +02:00
Lior Halphon
c6f39bc60b Initial MBC7 support 2021-11-12 17:44:51 +02:00
Lior Halphon
02f55d12d3 Maybe one day GCC will stop being shit at handling __attribute__s 2021-11-07 14:13:52 +02:00
Lior Halphon
1650820edb Clean up endian-related code 2021-11-07 13:57:43 +02:00
Lior Halphon
18e7a3f4fa Cleanup, better symbol handling, improves LTO 2021-11-07 13:39:18 +02:00
Lior Halphon
fbf1bb7f98 Save state compatibility breaking cleanup 2021-11-07 12:56:46 +02:00
Lior Halphon
5565c2540b Register name and info update 2021-11-06 13:34:34 +02:00
Lior Halphon
4a7afb246d Fix some oopsies 2021-11-05 21:45:54 +02:00
Lior Halphon
178860e715 Custom palette and editor 2021-11-05 19:07:27 +02:00
Lior Halphon
f237b1e9b9 CGB-0 support 2021-11-04 00:35:44 +02:00
Lior Halphon
6cd13be624 Add CGB-B support 2021-10-30 20:58:57 +03:00
Lior Halphon
b54365fc40 Merge branch 'v0.14.x' 2021-10-30 18:40:27 +03:00
Lior Halphon
72b6d6c532 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2021-10-30 18:31:47 +03:00
Lior Halphon
43831d0bc1 Update version to 0.14.7 2021-10-30 16:10:26 +03:00
Lior Halphon
0f6a0186cd Cherry picking conflicts 2021-10-30 16:09:13 +03:00
Lior Halphon
deb037d87d Detect missing ANSI support on Windows 2021-10-30 16:08:35 +03:00
Lior Halphon
4498d16bed Improved sanitation for save states for better security and stability 2021-10-30 16:08:35 +03:00
Lior Halphon
8d319c65c2 Use a monospaced font in the palette viewer 2021-10-30 16:08:35 +03:00
Snowy
0d7cc66ffd Change y to a signed value 2021-10-30 16:08:35 +03:00
Lior Halphon
0dcd233cbb Writes to SVBK should work before the boot ROM is disabled 2021-10-30 16:08:35 +03:00
Lior Halphon
fd8c9bba5d Detect missing ANSI support on Windows 2021-10-30 16:03:33 +03:00
Lior Halphon
1f7b20251b Improved sanitation for save states for better security and stability 2021-10-30 16:03:13 +03:00
Lior Halphon
93ef8d7db8
Merge pull request #411 from SnowyMouse/sprite_h
Fix partially offscreen sprites not being returned in GB_get_oam_info
2021-10-27 01:44:26 +03:00
Lior Halphon
739a9eb2bf Use a monospaced font in the palette viewer 2021-10-27 01:43:36 +03:00
Lior Halphon
e6c4ceaf5a Add CGB-D support 2021-10-27 01:40:28 +03:00
Snowy
2ec573c84a Change y to a signed value 2021-10-24 11:15:28 -05:00
Lior Halphon
5b9746084d Writes to SVBK should work before the boot ROM is disabled 2021-10-23 23:51:48 +03:00
Lior Halphon
18007f0e53 MGB support 2021-10-23 23:28:54 +03:00
Lior Halphon
5808d4485f Drop BOOLs 2021-10-23 13:36:58 +03:00
Lior Halphon
fc10a90dec Screenshots in the Cocoa frontend 2021-10-23 13:26:44 +03:00
Lior Halphon
3f954f1d0c Update version 2021-10-20 23:37:16 +03:00
Lior Halphon
0e6b9da42d Merge branch 'master' of https://github.com/LIJI32/SameBoy 2021-10-20 23:36:48 +03:00
Lior Halphon
1376c386a2 Slightly altered merge of #408 2021-10-20 21:49:02 +03:00
Lior Halphon
2f2e469790
Merge pull request #407 from SnowyMouse/master
Handle missing background.bmp
2021-10-20 20:34:13 +03:00
Lior Halphon
e04dcd90d6 Fix APU command 2021-10-19 01:56:10 +03:00
Lior Halphon
94776fcf8c Better (But imperfect) emulation of the wave RAM address bug glitch 2021-10-19 01:53:24 +03:00
Lior Halphon
de16ab5d08 Why was this under APU 2021-10-17 20:05:49 +03:00
Lior Halphon
886363b398 Now this glitch makes more sense 2021-10-17 12:52:08 +03:00
Lior Halphon
7ef198ec50 More accurate channel 3 restarts 2021-10-17 02:06:33 +03:00
Lior Halphon
f1b8164613 Force the user selected model on reset (which can change by a save state) 2021-10-17 02:06:13 +03:00
Lior Halphon
40fc477b56 Fix an oopsie 2021-10-10 20:05:57 +03:00
Lior Halphon
4ce643d5eb Fix timer bug; fixes #409 2021-10-10 16:53:07 +03:00
Lior Halphon
01f80a3f3e Adjust border fade delay to match SGB2 2021-10-10 14:24:14 +03:00
Lior Halphon
8f9365251d Timing adjustments 2021-10-10 13:30:30 +03:00
Lior Halphon
b580e63c37 Fix 7-part SGB commands 2021-10-10 02:55:12 +03:00
Lior Halphon
d263a8f6f8 Fix sanity 2021-10-09 23:12:49 +03:00
Lior Halphon
46e1b79b63 Madden 96 needs even more time 2021-10-09 23:07:15 +03:00
Lior Halphon
6b947c46bc Correct blank image detection on SGB 2021-10-09 22:41:43 +03:00
Lior Halphon
893d7d162a Don't try to render tiles 100-3FF 2021-10-09 22:34:43 +03:00
Lior Halphon
85da5b64d3 Some games like racing the SGB 2021-10-09 22:02:40 +03:00
Lior Halphon
a7c8b702da Some games like to race with the SGB border fade 2021-10-09 21:08:17 +03:00
Lior Halphon
f1761340fc Fix ATTR_SET command 2021-10-09 18:45:08 +03:00
Lior Halphon
3b1094058b Add SGB and CGB flags to the tester 2021-10-09 15:57:15 +03:00
Lior Halphon
004b004f98 Fix inverted key buttons in the SDL menu, fixes #401 2021-10-09 15:27:18 +03:00
Lior Halphon
191f7cee02 Improved emulation of SGB multiplayer, fixes #405 2021-10-09 14:52:28 +03:00
Lior Halphon
164a870189 Cleanup uses of gb->registers 2021-10-09 14:09:51 +03:00
Lior Halphon
24af1c5a31 Newly discovered OAM corruption trigger 2021-10-09 14:05:29 +03:00
Lior Halphon
c05c3c2abd Improved accuracy of mid-line SCX writes 2021-10-08 19:36:05 +03:00
Lior Halphon
d4999fbbdb Give APU tests more time 2021-10-07 18:30:09 +03:00
Lior Halphon
ef053ff113 APU regression fix 2021-10-07 18:25:54 +03:00
Lior Halphon
d1caeafe5e Better handling of tiny ROMs 2021-10-05 19:53:43 +03:00
Lior Halphon
9a957674d9 Fix broken action 2021-10-05 19:53:19 +03:00
Lior Halphon
345e51647f API issue – RTC data should not be wiped after GB_reset 2021-09-30 21:23:52 +03:00
Lior Halphon
8068ff41fb Fix potential future compatibility issue, update workflow environments 2021-09-29 21:57:39 +03:00
Snowy
20d580881a Handle missing background.bmp 2021-09-26 23:08:13 -05:00
Lior Halphon
1050a7a533 More size changes for Big Bloat 2021-09-26 00:10:19 +03:00
Lior Halphon
6e2abe23ef Merge branch 'master' of https://github.com/LIJI32/SameBoy 2021-09-25 21:55:29 +03:00
Lior Halphon
7aca04f4c4 Things need to be slightly bigger in Big Sur 2021-09-25 21:55:12 +03:00
Lior Halphon
24a7467735
Merge pull request #406 from Talkashie/master
Fixed a typo in the debugger
2021-09-24 20:33:56 +03:00
Lior Halphon
84c5f8b92d Fix #402 2021-09-22 20:53:04 +03:00
Lior Halphon
51be70275d Fix broken wave RAM initialization in the boot ROM 2021-09-22 17:59:20 +03:00
Talkashie
2dc0e14d0a Update debugger.c
Fixed a typo
2021-09-13 21:20:19 -05:00
Lior Halphon
c25c94d142 Minor improvements to console behavior on startup 2021-09-10 14:17:07 +03:00
Lior Halphon
c5d91fc448 New console readline-like interface for the SDL port 2021-09-09 00:13:09 +03:00
Lior Halphon
336bc65dbf Remove Cocoa spam from the SDL port 2021-09-09 00:11:49 +03:00
Lior Halphon
d8a9f12a4f Smooth scrolling in the SDL port on macOS 2021-09-06 15:21:02 +03:00
Lior Halphon
b27bd4eed7 Remove redundant condition 2021-09-04 18:15:22 +03:00
Lior Halphon
e5454a39b7 Block wave RAM writes on the AGB 2021-09-04 14:18:46 +03:00
Lior Halphon
0ca1ee6a35 Minor APU clean ups 2021-09-02 01:29:38 +03:00
Lior Halphon
eefaac3d04 NR32 was treated as the wrong value on APU reset 2021-08-31 23:28:05 +03:00
Lior Halphon
3c6d094763 Update version to 0.14.5 2021-08-01 16:19:40 +03:00
Lior Halphon
50bf8c4919 Fixed a bug that sometimes prevented GBS files from being opened 2021-08-01 15:11:33 +03:00
Lior Halphon
de500cd397 Update version to 0.14.4 2021-07-30 19:09:18 +03:00
Lior Halphon
c459058156 That was silly 2021-07-30 14:10:04 +03:00
Lior Halphon
48397683b8
Merge pull request #389 from tommitytom/master
Fix Windows build in clang-cl
2021-07-30 13:50:26 +03:00
Lior Halphon
0b2411ecc6 Merge branch 'libretro-core-options' 2021-07-29 23:29:47 +03:00
Lior Halphon
c7e8d7fa13 Minor cleanup 2021-07-29 23:19:13 +03:00
Lior Halphon
6138833b28 Style fixes 2021-07-29 23:03:36 +03:00
Lior Halphon
690a263648 Major improvements to JoyKit, fixing Xbox and 8BitDo controllers as well as analog mappings in PS controllers in some situations 2021-07-29 22:43:55 +03:00
Lior Halphon
0ff882f3bc Actually do what the previous commit claimed to do 2021-07-28 00:47:19 +03:00
Lior Halphon
b454ee28db Fix an issue where SameBoot gave DMG games the wrong palette and needlessly drew the DMG boot tilemap 2021-07-27 22:18:28 +03:00
Lior Halphon
4d1a28f1d1 Improved OAM bug accuracy in several read edge cases 2021-07-25 16:34:34 +03:00
Lior Halphon
1d7692cff5 Fix blurry VRAM viewer grid lines 2021-07-11 23:12:46 +03:00
Lior Halphon
a5325d3374 Improved ticks command, more accurate speed switch timings, better odd-mode warnings 2021-07-11 21:49:58 +03:00
Lior Halphon
6f6f72dcbd More accurate emulation of STOP 2021-07-11 12:11:12 +03:00
Lior Halphon
efb644bc72 MBC5 RAM enable is 8 bit 2021-07-10 15:02:15 +03:00
Ryunam
75ec1c0334 [Libretro] Fix small typo in palette description 2021-06-27 11:22:27 +02:00
Ryunam
e1453f1961 [Libretro] Upgrade Core Options to v1.3 2021-06-26 23:40:22 +02:00
Lior Halphon
278224299f Fixed double->single speed switch causing misaligned CPU timing 2021-06-26 13:55:34 +03:00
Lior Halphon
94add1d172 Add "Harsh Reality" color correction mode 2021-06-25 19:57:56 +03:00
Lior Halphon
a2d34c9bd9 Add -s/--stop-debugger flag to SDL, closes #392 2021-06-25 17:12:05 +03:00
Lior Halphon
ceacc226bc Fixed Switch Pro Controller in USB mode 2021-06-23 21:21:53 +03:00
Lior Halphon
23e8cc58c5 Vblank should occur 1 T-cycle later 2021-06-19 02:14:16 +03:00
Lior Halphon
b4709fd66b Disabled an accuracy-improvement-attempt that caused audio regressions until the proper behavior is well understood, fixes #390 2021-06-18 01:36:29 +03:00
Lior Halphon
339613263c Fixed a bug that prevented STAT interrupt blocking from functioning correctly in the transition to VBlank while the OAM interrupt was disabled 2021-06-18 01:20:05 +03:00
Tom Yaxley
a12ec3c8c8 Fix Windows build in clang-cl 2021-06-06 12:04:47 +10:00
Lior Halphon
7a6ae2d951 Improved DualSense LEDs, fix several analog controls issues 2021-06-04 22:21:41 +03:00
Lior Halphon
e71d3a7d3c First-tier support for DualSense controllers with rumble and LED support 2021-06-04 18:17:14 +03:00
Lior Halphon
b444ecd1ee Fix configuration of analog shoulder buttons for analog turbo/slow motion when using a PS5 controller 2021-06-01 00:46:06 +03:00
Lior Halphon
1e5e236e84 Correct default mapping for PS5 and PS4 controllers 2021-06-01 00:33:25 +03:00
Lior Halphon
ebb0cb5e81 Added optional OSD (SDL) 2021-05-30 23:39:59 +03:00
Lior Halphon
3ed18a76da Added optional OSD (Cocoa) 2021-05-30 20:55:04 +03:00
Lior Halphon
033f025851 Added volume control to the Cocoa port 2021-05-21 18:12:29 +03:00
Lior Halphon
75d3470d55 That code made very little sense 2021-05-19 00:15:02 +03:00
Lior Halphon
fcbbecea17 Fix #386 2021-05-18 20:21:21 +03:00
Lior Halphon
2afeb7dee3 Place a cap on the GBS file size 2021-05-17 17:11:41 +03:00
Lior Halphon
ea67a7e3f0
Merge pull request #379 from jprjr/gbs-buffer
gbs: function to load from memory buffer
2021-05-17 16:53:12 +03:00
Lior Halphon
9b2dfe7ae2
Style fixes 2021-05-17 16:52:55 +03:00
Lior Halphon
e9ab7fa7df
Merge pull request #382 from Mailaender/patch-1
Fixed the desktop categories
2021-05-17 16:44:53 +03:00
Lior Halphon
c944142b36 Fall back to .snX if no .sX save state found 2021-05-07 00:33:04 +03:00
Lior Halphon
a4a8ad00d5 Display usage on invalid options 2021-05-06 00:26:45 +03:00
Lior Halphon
0dff3ef144 A flag to disable OpenGL, better and more stable handling of no-OpenGL mode 2021-05-06 00:23:46 +03:00
Lior Halphon
1d0366052d Updater support 2021-04-25 22:28:24 +03:00
Matthias Mailänder
898ef2c981
Fix the desktop categories. 2021-04-23 20:43:34 +02:00
Lior Halphon
ea05a0c765 Don't save 0x6000 for MBC3 in BESS 2021-04-23 21:05:33 +03:00
Lior Halphon
ac5b0aca2c RTC accuracy fix 2021-04-23 21:01:17 +03:00
John Regan
0e8d8effdf gbs: function to load from memory buffer 2021-04-20 08:38:53 -04:00
Lior Halphon
a2d3b8c174 Support for non-standard GBS files with a loading address at 0 2021-04-19 20:58:27 +03:00
Lior Halphon
c29edc1963 Handle loading errors 2021-04-19 20:57:28 +03:00
Lior Halphon
2971b17701 Add support for ugetab's GBS extensions, fixes #377 2021-04-19 00:32:10 +03:00
Lior Halphon
5f2e893828 Allow GBS files with loading addresses 0x6E-0x3FF, fixes #376 2021-04-19 00:08:21 +03:00
Lior Halphon
d9b9385eb4 Typo fix 2021-04-17 18:13:19 +03:00
Lior Halphon
939817df73 Update version, finalize BESS 1.0 2021-04-17 16:59:22 +03:00
Lior Halphon
e8158be454 Merge branch 'bess' into gbs 2021-04-17 16:57:05 +03:00
Lior Halphon
9fcdc082d2 Fix an SDL crash, minor tweak to BESS SGB 2021-04-17 16:37:55 +03:00
Lior Halphon
817c4a7752 Merge branch 'bess' into gbs 2021-04-16 16:35:21 +03:00
Lior Halphon
87a2d48675 Redo TPP1 saving, fix RTC and HUC3 in BESS 2021-04-16 00:35:54 +03:00
Lior Halphon
f0a6488546 Added optional INFO block 2021-04-15 21:57:38 +03:00
Lior Halphon
2078c2a8fb Use semantic popup icons instead of always using error 2021-04-15 02:42:31 +03:00
Lior Halphon
98a39ae49a ATTR_CHR does not seem to wrap around screen (only lines/columns) 2021-04-14 23:39:07 +03:00
Lior Halphon
b325148544 Update and clarify specification 2021-04-14 23:37:00 +03:00
Lior Halphon
ba6e22dfc0 Merge branch 'bess' into gbs 2021-04-14 16:44:51 +03:00
Lior Halphon
dd86077410 Use the older, more available API 2021-04-14 15:24:06 +03:00
Lior Halphon
8a84a5897e Allow drag&drop of state files 2021-04-14 15:20:01 +03:00
Lior Halphon
c1509b6339 KEY0 info 2021-04-13 23:34:49 +03:00
Lior Halphon
6f0b640702 More clarifications 2021-04-13 22:32:45 +03:00
Lior Halphon
79f109b463 Clarify MBC block 2021-04-13 22:08:25 +03:00
Lior Halphon
43fb86320e Hard fail on unexpected SGB blocks 2021-04-13 22:05:13 +03:00
Lior Halphon
0af4f1fa4d Clarify SGB multiplayer, handle count = 0 2021-04-13 21:33:13 +03:00
Lior Halphon
24915e41eb TPP1 in BESS 2021-04-13 20:56:09 +03:00
Lior Halphon
976f5e4d02 Merge branch 'master' into bess 2021-04-13 20:50:29 +03:00
Lior Halphon
fada772cb1 Don't use BESS for internal in-memory saves 2021-04-13 20:35:07 +03:00
Lior Halphon
dfdbff7304 Allow writes to the $a000-$bfff range in the MBC block 2021-04-13 16:01:44 +03:00
Lior Halphon
6ee488688b Update spec 2021-04-13 01:11:06 +03:00
Lior Halphon
a3a73602fc ATF is only 0xFD2 bytes, not 0xFE0 2021-04-13 01:09:29 +03:00
Lior Halphon
5b993ed775 Add HuC3 to BESS 2021-04-12 23:36:42 +03:00
Lior Halphon
4346b063f5 Wording 2021-04-12 22:48:05 +03:00
Lior Halphon
9c1889f450 Actually update spec 2021-04-12 22:43:23 +03:00
Lior Halphon
9a1f962281 Spec update 2021-04-12 22:39:13 +03:00
Lior Halphon
251dd15ff9 Fixed a bug where the screen would not redraw when certain controllers are rumbling in specific strengths in the Cocoa port 2021-04-11 23:36:42 +03:00
Lior Halphon
80f422d0ca Respect TPP1 feature flags for rumble and RTC 2021-04-11 23:16:31 +03:00
Lior Halphon
763de9d2e0 Fix Rumble support in TPP1 2021-04-11 22:52:34 +03:00
Lior Halphon
42471095e4 Normalize invalid weekdays only after a $11 command 2021-04-11 22:38:25 +03:00
Lior Halphon
0c5e15b49d Correct emulation of count overflow in ATTR_CHR, fixes #372 2021-04-11 02:38:58 +03:00
Lior Halphon
f24489b983 TPP1 support 2021-04-10 23:56:41 +03:00
Lior Halphon
44c75ae7be Remove commented out code 2021-04-10 18:43:24 +03:00
Lior Halphon
ad05eb6d0a GCC build fix 2021-04-10 16:15:40 +03:00
Lior Halphon
955ef59140 Merge branch 'bess' into gbs 2021-04-10 16:12:35 +03:00
Lior Halphon
f89c80caa5 Merge branch 'master' into bess 2021-04-10 16:12:03 +03:00
Lior Halphon
d0bbf383d6 Another cheat bugfix 2021-04-10 16:10:23 +03:00
Lior Halphon
6ddfcc9725 Added visualizer to the GBS player, various GBS UI improvements 2021-04-10 16:10:10 +03:00
Lior Halphon
77384a5f6a Merge branch 'bess' into gbs 2021-04-09 23:12:03 +03:00
Lior Halphon
20ffa27dd4 Forgot to commit the document update 2021-04-07 21:45:43 +03:00
Lior Halphon
1c31812ffd BESS format updates 2021-04-06 01:02:49 +03:00
Lior Halphon
7a558492b6 Merge branch 'master' into bess 2021-04-05 23:10:00 +03:00
Lior Halphon
e6fa2336da Fix a potential crash/corruption when modifying cheats 2021-04-05 23:09:32 +03:00
Lior Halphon
f67d3947d6 UI Updates 2021-04-05 23:08:43 +03:00
Lior Halphon
bb3a73ff88 Cocoa GBS Player 2021-04-03 01:29:43 +03:00
Lior Halphon
9996c7b4a2 Add GBS APIs 2021-04-03 01:29:06 +03:00
Lior Halphon
39c71b40e7 Fix memory leak 2021-04-02 19:07:28 +03:00
Lior Halphon
328e2d9e40 Merge branch 'master' into gbs 2021-04-02 19:06:15 +03:00
Lior Halphon
6b8eb8063a Fix a bug where SameBoy would start in "faux turbo mode" 2021-04-02 02:54:14 +03:00
Lior Halphon
b7348b5478 Add BESS format documentation 2021-04-01 00:16:28 +03:00
Lior Halphon
e460b0a7b4 Change the border format to SNES-style 2021-03-31 00:54:55 +03:00
Lior Halphon
9314bcf98d
Merge pull request #371 from Jan200101/patch-1
Correct usage of PREFIX with DATA_DIR
2021-03-30 20:45:21 +03:00
Jan
48ec3e6413
Correct usage of PREFIX with DATA_DIR
slipped through in #370
DATA_DIR is not relative to PREFIX so having it is problematic
2021-03-30 17:29:55 +02:00
Lior Halphon
8adaba237e SGB support in BESS, BE fixes, changes to SGB save state format on BE machines 2021-03-29 02:47:57 +03:00
Lior Halphon
b9030bb2d0
Merge pull request #370 from Jan200101/patch-1
replace PREFIX/share/sameboy with DATA_DIR
2021-03-25 20:57:30 +02:00
Jan
aca2fd04b1
replace PREFIX/share/sameboy with DATA_DIR 2021-03-25 19:17:45 +01:00
Lior Halphon
659f954028 RTC support 2021-03-25 00:07:37 +02:00
Lior Halphon
a52302f2f6 Make NAME come before CORE 2021-03-25 00:07:37 +02:00
Lior Halphon
75bc1e9a86 Initial BESS support, no SGB nor RTC yet 2021-03-25 00:07:37 +02:00
Lior Halphon
925bd863c0 Better errnos 2021-03-22 00:18:49 +02:00
Lior Halphon
da1003263f Redo save states to remove severe code duplication between buffers and files 2021-03-21 20:32:30 +02:00
Lior Halphon
ad54dc57b0 Improved time syncing when turning the LCD on and off, fixes #193 2021-03-21 15:15:04 +02:00
Lior Halphon
5c1b89e82d Update version 2021-03-01 23:27:40 +02:00
Lior Halphon
5a966bba91 Register ISX files on FreeDesktop 2021-03-01 23:21:07 +02:00
Lior Halphon
f50d9310a7 This shouldn't have been here 2021-03-01 23:00:11 +02:00
Lior Halphon
4d67fa8e80 Close all related windows when closing a document 2021-03-01 22:58:52 +02:00
Lior Halphon
ea97c1dc0b Fix an APU regression that caused some games in DMG mode to play in the wrong pitch 2021-03-01 21:44:54 +02:00
Lior Halphon
d2ed1343e5 Add missing mkdir 2021-02-28 20:41:58 +02:00
Lior Halphon
c6ea57209f
Merge pull request #356 from RobLoach/libretro-updates
libretro: Sync updates from libretro
2021-02-28 20:14:15 +02:00
Rob Loach
f21fd33cc3
libretro: Remove APP_STL 2021-02-28 13:13:40 -05:00
Rob Loach
975d379d76
libretro: Remove empty CFLAGS 2021-02-28 13:13:12 -05:00
Lior Halphon
2d593a95e3 Update version to 0.14.1 2021-02-28 17:15:19 +02:00
Lior Halphon
57080c48bc No need for -1 2021-02-28 16:50:46 +02:00
Rob Loach
6a995bfe10
libretro: Sync updates from libretro 2021-02-28 09:45:18 -05:00
Lior Halphon
ec7d756e3b
Merge pull request #351 from NieDzejkob/symbol-off-by-one
Fix off-by-one in symbol search
2021-02-28 15:27:50 +02:00
Lior Halphon
0fbd714d4a
Merge pull request #352 from NieDzejkob/value-to-string-oob
value_to_string: use snprintf
2021-02-28 15:23:29 +02:00
Lior Halphon
81bfea9ba2
Coding style, ensuring string termination. 2021-02-28 15:23:14 +02:00
Lior Halphon
d2eb8e0996 Addresses issues mentioned by #355 2021-02-28 15:17:00 +02:00
Lior Halphon
5cc2dcc864 Fix #353 better 2021-02-28 14:55:30 +02:00
Lior Halphon
d50514ede9 Fix #353 2021-02-28 14:51:58 +02:00
Lior Halphon
5cd920d363 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2021-02-28 03:41:13 +02:00
Lior Halphon
1fdb4f09b4 Fix a sweep regression in DMG/SGB mode and CGB-C mode 2021-02-28 03:40:58 +02:00
Jakub Kądziołka
c9665d0449
value_to_string: use snprintf
Currently, value_to_string and debugger_value_to_string use an
error-prone calculation to avoid overflow. This was once adjusted
already, and one of the codepaths is still vulnerable. Put this in a
symfile:

    01:5678 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

and execute `p 1:$5679`. On Linux, the canary terminates the process.
2021-02-27 19:33:31 +01:00
Lior Halphon
ec2661ac03
Merge pull request #350 from NieDzejkob/destdir-mkdir
Fix DESTDIR installation
2021-02-27 20:29:22 +02:00
Jakub Kądziołka
e8bfc4050e
Fix off-by-one in symbol search
Before this commit, printing an address that's after every symbol in a
bank would not show it relative to the last symbol.
2021-02-27 19:29:06 +01:00
Jakub Kądziołka
0a4cb8148f
Fix DESTDIR installation
Installing into a fresh DESTDIR would error out due to non-existent bin
directory
2021-02-27 18:33:22 +01:00
Lior Halphon
54d733f356
Merge pull request #349 from NieDzejkob/memmove-fix
Use memmove for overlapping copy
2021-02-27 19:31:06 +02:00
Jakub Kądziołka
1dae345b24
Use memmove for overlapping copy 2021-02-27 18:29:59 +01:00
Lior Halphon
e57b5dd57e Update version and copyright date 2021-02-27 19:08:32 +02:00
Lior Halphon
a59cd856c7 Fix make install issues 2021-02-27 18:39:14 +02:00
Lior Halphon
cd2e4b3cef Fixes and improvements to XDG installation 2021-02-27 17:34:11 +02:00
Lior Halphon
3c0f4d458d Update Windows icon 2021-02-27 15:51:56 +02:00
Lior Halphon
aebc11744c Update readme 2021-02-27 15:37:40 +02:00
Lior Halphon
2b263937da Allow make install under FreeDesktop 2021-02-27 14:32:07 +02:00
Lior Halphon
0a983b788e Update icon 2021-02-27 04:13:31 +02:00
Lior Halphon
ce44773caa Make the printer not deadlock after a sudden termination 2021-02-26 16:40:35 +02:00
Lior Halphon
cb721dae5d Make the automation use the accurate RTC mode 2021-02-26 01:09:40 +02:00
Lior Halphon
34b0404ffa Add RTC setting to libretro 2021-02-26 01:07:46 +02:00
Lior Halphon
bae91cdb1d Add RTC option to the SDL port, fix a bug where rewind setting didn't update 2021-02-26 01:04:24 +02:00
Lior Halphon
72cb391612 Slightly improve MBC3 accuracy 2021-02-26 00:52:18 +02:00
Lior Halphon
71c6fa45e0 Accurate RTC emulation 2021-02-26 00:40:18 +02:00
Lior Halphon
a13469c4e2 Fix PAL SGB in the Cocoa port 2021-02-25 22:42:02 +02:00
Lior Halphon
e08df2a089 Add accurate RTC emulation mode 2021-02-25 22:12:14 +02:00
Lior Halphon
807712b9c2 Allow creating sav files from the tester (Fixes #311) 2021-02-25 18:04:52 +02:00
Lior Halphon
9fa564f97c Fix #336 2021-02-25 17:12:01 +02:00
Lior Halphon
6ec4583aa0 Tell GCC to calm down 2021-02-25 15:52:48 +02:00
Lior Halphon
fa5420136e I hate the audio thread 2021-02-25 15:43:52 +02:00
Lior Halphon
4c05ebcea6 Redo the volume envelope with better timings, locking emulation and zombie mode edge cases. Fixes #344 2021-02-25 15:43:38 +02:00
Lior Halphon
8809d8ac2f More correct emulation of manual clocking of channels 1 and 2 2021-02-22 15:27:36 +02:00
Lior Halphon
71c88323b7 Rename UNROLL to unrolled (unrolled for) 2021-02-22 14:45:30 +02:00
Lior Halphon
9da0449797 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2021-02-22 13:49:08 +02:00
Lior Halphon
393269ae1f Emulate volume envelope locking 2021-02-22 13:48:56 +02:00
Lior Halphon
d50fdc52ea Further accuracy improvements to the audio envelope 2021-02-22 01:58:43 +02:00
Lior Halphon
6d2d88648e Improved emulation of the volume envelope 2021-02-22 01:10:14 +02:00
Lior Halphon
759ff1927e
Merge pull request #345 from jkotlinski/fail-nicely-on-missing-window
exit with error message instead of crash when a window cannot be opened
2021-02-14 02:33:58 +02:00
Johan Kotlinski
1a87c452b7 exit with error message instead of crash when a window cannot be opened 2021-02-14 01:31:49 +01:00
Lior Halphon
e7a5be70c2 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2021-02-13 23:00:30 +02:00
Lior Halphon
95051d1c1c Improved emulation of the NRx2 write glitch (Zombie mode) on models prior to CGB-D 2021-02-13 23:00:20 +02:00
Lior Halphon
d343f0c969
Merge pull request #330 from jverkoey/array
Add type annotations to GBImageView's grid arrays.
2021-02-13 14:38:07 +02:00
Lior Halphon
3316954d14
Merge pull request #326 from jverkoey/deprecations
Resolve various deprecation warnings.
2021-02-13 14:15:48 +02:00
Lior Halphon
8ad08c1b35 Fix more audio deadlocks 2021-02-01 23:11:42 +02:00
Lior Halphon
301c0f41c2 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2021-01-31 19:17:56 +02:00
Lior Halphon
6798b1f11a Use a slider for temperature in the SDL GUI 2021-01-31 19:17:48 +02:00
Lior Halphon
2d76698279 Emulation of NR43 bit 3 glitch on CGB-C and older 2021-01-31 19:17:26 +02:00
Lior Halphon
d67580c964 Oops, that was reversed 2021-01-31 17:16:59 +02:00
Lior Halphon
fbfa20a2cd
Merge pull request #337 from phobos2390/fix_for_signed_array_index
Fix for tolower extension signed char issue
2021-01-27 22:04:15 +02:00
phobos2390
bbfd16f63d Fix for tolower extension signed char issue 2021-01-25 23:37:46 -07:00
Lior Halphon
ef9671010b More NR43 obscurities 2021-01-24 20:57:46 +02:00
Lior Halphon
8e1e889ce0 Add a TODO 2021-01-16 15:31:09 +02:00
Lior Halphon
aa421258b8 Update the model enum so comparisons work correctly for SGB PAL and no-SFC SGBs 2021-01-16 14:51:06 +02:00
Lior Halphon
13a1e9d332 Timing fix 2021-01-16 14:43:32 +02:00
Lior Halphon
0056cc2d61 Revert "Further NR43 write glitch emulation" for now
This reverts commit e384707615.
2021-01-16 14:42:13 +02:00
Jeff Verkoeyen
557f554270 [Sameboy] Add type annotations to GBImageView's grid arrays. 2021-01-15 13:21:28 -05:00
Jeff Verkoeyen
8f91533a9a Revert nil check changes. 2021-01-15 12:49:24 -05:00
Lior Halphon
931045fd9b
Merge pull request #325 from jverkoey/master
Annotate all Cocoa properties as nonatomic.
2021-01-15 14:15:09 +02:00
Lior Halphon
0b8ee0585a
Merge pull request #329 from jverkoey/spritebug
Fix broken sprite rendering in the VRAM viewer due to mis-calculation of image data size.
2021-01-15 13:39:07 +02:00
Jeff Verkoeyen
1707c8818a Fix broken sprite rendering in the VRAM viewer due to mis-calculation of image data size. 2021-01-15 00:41:21 -05:00
Jeff Verkoeyen
60f226321d Resolve various deprecation warnings. 2021-01-13 14:52:18 -05:00
Jeff Verkoeyen
6dca01ad27 Annotate properties as nonatomic. 2021-01-13 14:12:34 -05:00
Lior Halphon
e384707615 Further NR43 write glitch emulation 2021-01-10 17:20:25 +02:00
Lior Halphon
07e76a4ecf Oh boy, looks like my CGB-B is unique 2021-01-09 23:28:30 +02:00
Lior Halphon
1b3f52e8c0 Improved emulation of NR43 writes on different revisions 2021-01-09 21:21:22 +02:00
Lior Halphon
2aa171e0ea Better sample alignment on pre-CGB-D models 2021-01-09 16:26:56 +02:00
Lior Halphon
96736fe7c5 Fix false positives in odd-mode detection 2021-01-09 00:59:12 +02:00
Lior Halphon
c496797fce Merge branch 'master' of https://github.com/LIJI32/SameBoy 2021-01-09 00:31:26 +02:00
Lior Halphon
c0582fd994 More accurate emulation of NR10 writes 2021-01-09 00:31:16 +02:00
Lior Halphon
8420fb7364
Merge pull request #319 from MaddTheSane/qlTrim
Fix visibility of a few functions in the QuickLook plug-in.
2021-01-05 21:25:08 +02:00
C.W. Betts
e4c7333a1a Fix visibility of a few functions in the QuickLook plug-in. 2021-01-04 01:08:31 -07:00
Lior Halphon
29a3b18186 Better camera noise on frontends without camera support 2021-01-03 16:52:18 +02:00
Lior Halphon
f9b13c66b1 Emulation of a newly discovered revision specific APU quirk 2021-01-03 13:49:36 +02:00
Lior Halphon
ecace40fb0 Minor APU bug fix 2021-01-02 18:27:21 +02:00
Lior Halphon
a9c337264e Fix the last remaining APU test 2021-01-02 16:23:34 +02:00
Lior Halphon
b54a72d9b9 Fixing a bug where where zero-shift sweep wouldn't tick 2021-01-02 14:56:45 +02:00
Lior Halphon
5c854dbdca Interference emulation 2020-12-31 00:07:04 +02:00
Lior Halphon
8e858c1bf1 Capitalization 2020-12-27 01:02:50 +02:00
Lior Halphon
e535d97e84 Fix GCC9 build break 2020-12-27 00:23:16 +02:00
Lior Halphon
9e808b255c Escape now returns to the previous menu if used from a submenu in the SDL port 2020-12-27 00:03:40 +02:00
Lior Halphon
1d34637bda Fix it harder 2020-12-26 23:56:26 +02:00
Lior Halphon
47ebc31733 Fixed a bug where the SDL and libretro frontend would not update the border when loading a new ROM 2020-12-26 23:52:41 +02:00
Lior Halphon
3dbd2eac91 Something went wrong with the color temperature commit somehow 2020-12-26 23:33:01 +02:00
Lior Halphon
7fc59b5cf4 Let the SDL port choose a boot ROMs folder 2020-12-26 15:10:11 +02:00
Lior Halphon
e1f797c212 Improved scrolling 2020-12-26 13:13:43 +02:00
Lior Halphon
c471696fbb Scrollbar and mouse wheel support 2020-12-26 03:20:53 +02:00
Lior Halphon
6d5ce6c54d Better scrolling a spacing in the SDL UI 2020-12-26 01:45:03 +02:00
Lior Halphon
544d39f19d Further improvements to STOP timing 2020-12-26 00:19:48 +02:00
Lior Halphon
4bbd27735f Fix a regression in speed switch timing, reset DIV on speed switch, better odd-mode detection and avoidance 2020-12-25 20:41:00 +02:00
Lior Halphon
159d9d0348 Color temperature control 2020-12-25 14:17:57 +02:00
Lior Halphon
b5a611c5db More accurate color correction curves 2020-12-24 23:17:20 +02:00
Lior Halphon
84b388692a Merge branch 'master' of https://github.com/LIJI32/SameBoy 2020-12-24 23:14:00 +02:00
Lior Halphon
66f62d696c More window fixes 2020-12-24 20:50:47 +02:00
Lior Halphon
aa2bdf2a1c Better support for non-QWERTY Latin layouts 2020-12-23 23:50:19 +02:00
Lior Halphon
8f64f49c3b More accurate emulation of window timing, actual correct fix of #123 2020-12-23 23:49:57 +02:00
Lior Halphon
b0eb87dfab
Merge pull request #315 from messmerd/line_ending_fix
Prevent shader compilation issues due to line endings on Windows machines
2020-12-19 11:36:49 +02:00
Dalton Messmer
8a13b7be24
Add .gitattributes line ending settings
Always use LF line endings for shaders
2020-12-19 00:58:19 -05:00
Lior Halphon
7a3ebb708c LCDC write timing regression fix 2020-12-12 22:55:14 +02:00
Lior Halphon
db483ce95f Warn about potential odd-mode triggers 2020-12-12 20:40:35 +02:00
Lior Halphon
555835549a More accurate pausing behavior, including revision differences 2020-12-12 20:35:18 +02:00
Lior Halphon
770885440f Minor changes to debugger output 2020-12-12 19:09:53 +02:00
Lior Halphon
4f408eae7c Whoops 2020-12-12 18:13:55 +02:00
Lior Halphon
dffc12331b Emulate the delayed NR44 write on the DMG 2020-12-12 18:11:35 +02:00
Lior Halphon
6b30de5fb1 Fixed dark colors on Metal without frame blending 2020-12-12 16:02:46 +02:00
Lior Halphon
7de6194e28 Redo channel 4's timing accurately, emulate NR43 write quirks 2020-12-12 16:02:25 +02:00
Lior Halphon
1baa0446a9 More sweep improvements 2020-12-01 22:37:13 +02:00
Lior Halphon
13bc8679f9 Correct preservation of NRx1's state on pre-CGB models 2020-12-01 14:18:19 +02:00
Lior Halphon
74cf452a48 Further accuracy improvements to sweep; passes Blargg's APU tests again, this time for real 2020-12-01 14:17:35 +02:00
Lior Halphon
0485124076 Redo channel 1 sweep based on DMG schematics; emulates two newly discovered behaviors and also fixes #309 2020-11-28 19:31:25 +02:00
Lior Halphon
67c0e03f3b Fix a window bug in CGB mode, fixes #123 2020-11-22 00:21:19 +02:00
Lior Halphon
bbf609f46b Add TGA output option to the tester, closes #310 2020-11-21 21:05:03 +02:00
Lior Halphon
027cecde24 Added debugger "undo" command. Closes #156 2020-11-21 16:19:58 +02:00
Lior Halphon
bdd27ce50d IR support in the libretro port 2020-11-21 15:36:21 +02:00
Lior Halphon
1d9ac5ccc3 More accurate IR emulation, simplify API 2020-11-21 00:52:54 +02:00
Lior Halphon
b7f3454763 More accurate emulation of the IR port 2020-11-20 22:12:15 +02:00
Lior Halphon
cd2310f0a7 Wave RAM reads 0xFF while active on AGBs 2020-11-20 19:39:54 +02:00
Lior Halphon
7fdc58a07e Implement CGB-mode TILE_SEL mixing, fixes cgb-acid-hell and m3_lcdc_tile_sel_change2, closes #308 2020-11-20 16:24:16 +02:00
Lior Halphon
c36bdc22f6 More accurate interrupt emulation 2020-11-14 13:55:39 +02:00
Lior Halphon
60b8978762 Local link cable and infrared emulation in the Cocoa port 2020-11-13 23:07:35 +02:00
Lior Halphon
88198e64f4 Minor bug fixes 2020-11-13 23:02:17 +02:00
Lior Halphon
03cbab2f85
Windows is no longer officially supported in the standalone builds 2020-10-15 19:21:37 +03:00
Lior Halphon
1936dd7f67
Merge pull request #304 from JL2210/rgbds-link
Update RGBDS links in README and build-faq
2020-10-14 01:22:21 +03:00
James Larrowe
6e0c09f78c Update RGBDS links in README and build-faq
The repo's owner has changed twice since this link was used;
once from bentley to the neutral rednex organization, and then
from rednex to gbdev
2020-10-13 18:19:29 -04:00
Lior Halphon
919a88ec23
Merge pull request #301 from SimpleTease1/patch1
libretro changes
2020-10-11 02:42:02 +03:00
SimpleTease
eb295de218 shared version.mk 2020-10-10 23:33:58 +00:00
SimpleTease
696bebc673 libretro: joypad bitmasks 2020-10-10 17:14:53 +00:00
SimpleTease
714227883f cross-compile friendly 2020-10-10 13:46:44 +00:00
Lior Halphon
526c2e029a
Fix #296 2020-10-10 14:50:11 +03:00
SimpleTease
2bfca48e0f libretro: fix core version 2020-10-10 04:02:21 +00:00
SimpleTease
cd526d960e libretro: changing model requires manual game restart 2020-10-10 04:00:30 +00:00
radius
8dc60d0b87 update makefile 2020-10-10 03:52:22 +00:00
twinaphex
efe8d6b643 Update Makefile 2020-10-10 01:22:51 +00:00
slash0042
faeb1d2e18 Add libnx port 2020-10-10 01:02:22 +00:00
Lior Halphon
8b45c32d77 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2020-10-09 16:40:00 +03:00
Lior Halphon
c35fe8b517 Make gb.h compatible with C++ again for bsnes integration. Fixed #300 2020-10-09 16:39:23 +03:00
Lior Halphon
195329463b
Merge pull request #294 from yo-wotop/master
Windows Updates
2020-10-09 16:03:57 +03:00
Lior Halphon
99ec5b32fc
Update build-faq.md 2020-10-09 16:03:32 +03:00
Lior Halphon
64963e1746
Update README.md 2020-10-09 15:57:23 +03:00
yo
38afb187cf Resolving some comments and clarifying some language 2020-10-06 23:03:39 -07:00
yo
0b5853070a Updated instructions for Windows building 2020-10-05 14:37:49 -07:00
yo
28234da2d2 Updated instructions for Windows building 2020-10-05 14:34:00 -07:00
yo
04e5f1b8cf Updated for Windows clang and SDL2 changes 2020-10-05 14:33:36 -07:00
Lior Halphon
2a5aed626d
Update README.md 2020-09-29 20:50:14 +03:00
Lior Halphon
1e9e961e9c
Create CONTRIBUTING.md 2020-09-29 20:43:47 +03:00
Lior Halphon
7c92845882 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2020-09-19 19:31:31 +03:00
Lior Halphon
7ff3556bc3 Workboy emulation (Cocoa only) 2020-09-19 19:31:24 +03:00
Lior Halphon
e35c22d405 Fix a potential single byte overflow 2020-09-17 23:47:35 +03:00
Lior Halphon
faf91508e2
Yes, I *do* mean -Wno-maybe-uninitialized! 2020-09-17 23:25:56 +03:00
Lior Halphon
abea3888db
Fix compilation under GCC 9 2020-09-17 23:18:16 +03:00
Lior Halphon
e0d6aa59ad
Merge pull request #289 from NieDzejkob/warning-fix
pb12: check the return value of write
2020-09-17 21:22:22 +03:00
Jakub Kądziołka
9c50a992af
pb12: check the return value of write 2020-09-17 20:01:21 +02:00
Lior Halphon
2e4a638077 Update version to 0.13.6 2020-08-22 14:21:54 +03:00
Lior Halphon
abce93640c Set a default value in the struct (instead of just during sanitation) 2020-08-22 14:20:44 +03:00
Lior Halphon
ceec044a22 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2020-08-22 14:17:20 +03:00
Lior Halphon
ebcc0d18ce
Merge pull request #281 from nadiaholmquist/feature/sdl-scale
SDL: Make default window scale configurable
2020-08-22 14:17:09 +03:00
Lior Halphon
e307de8064
Style fixes 2020-08-22 14:16:07 +03:00
Lior Halphon
dab1c1bcfa Fix RTC drift 2020-08-22 14:10:02 +03:00
Lior Halphon
832dc127a4 Fix Quick Look preview on Big Sur 2020-08-22 14:02:41 +03:00
Lior Halphon
c2410a4ffc Update UI for Big Sur 2020-08-22 13:06:27 +03:00
Lior Halphon
5cffdbcd27 Prevent asking for notification permissions until used by an HuC-3 game 2020-08-22 00:56:12 +03:00
Nadia Holmquist Pedersen
cc37632714 Remove printf 2020-08-19 06:15:36 +02:00
Lior Halphon
766529d7be Update version to 0.13.5 2020-08-06 21:01:55 +03:00
Lior Halphon
bce4bfba61 Fix major battery save regressions introduced by the last release, fixes #282 2020-08-06 19:34:57 +03:00
Nadia Holmquist Pedersen
012b9a2ba0 SDL: Make default window scale configurable 2020-08-06 03:08:19 +02:00
Lior Halphon
5b2eec214b Update version to 0.13.4 2020-08-05 21:17:22 +03:00
Lior Halphon
3f97b8eaa8 Even more regressions 2020-08-05 02:10:21 +03:00
Lior Halphon
d3664d5da0 Fix more RTC regressions 2020-08-05 01:39:19 +03:00
Lior Halphon
289853445f Fix long loading times when loading save states with bad local RTC times 2020-08-04 21:32:33 +03:00
Lior Halphon
b0d118f246 Fix broken and regressed MBC3 RTC emulation. Fixes #273, fixes #276, fixes #280 2020-08-04 21:32:27 +03:00
Lior Halphon
68b8d4bb1e
Merge pull request #279 from renatoliveira/cartridge-patch
Cartridge patch
2020-08-01 19:22:34 +03:00
Renato Oliveira
445aa74b14
Fix "cartrdige" to "cartridge" in comments 2020-08-01 12:57:10 -03:00
Renato Oliveira
ac3b09966c
Fix "Cartrdige" to "Cartridge" 2020-08-01 12:55:53 -03:00
Lior Halphon
4248ba8512
Merge pull request #272 from lpla/patch-2
Fix `make: write error` on macOS when `make CONF=native_release`
2020-06-25 20:54:58 +03:00
Leopoldo Pla
44ff0563c0
Fixes #259 2020-06-25 19:50:24 +02:00
Lior Halphon
a7942d6a1f Allow building fat x86-64 and ARM64 macOS binaries 2020-06-25 19:51:58 +03:00
Lior Halphon
64f381fa23 Update version to 0.13.3 2020-06-24 23:34:33 +03:00
Lior Halphon
a2e656a7c2 Fixed boot ROM regression; CGB games were given the wrong palettes 2020-06-24 20:34:52 +03:00
Lior Halphon
92c3eafc72 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2020-06-24 19:15:29 +03:00
Lior Halphon
cfcdce81ba Fix color in OpenGL when frame blending is disabled 2020-06-24 19:15:20 +03:00
Lior Halphon
ac521641ec
Merge pull request #271 from JL2210/old-gcc
Compatibility hacks for old compilers
2020-06-22 23:23:47 +03:00
James Larrowe
87d25c0896 Compatibility hacks for old compilers
GCC versions below 4.8.1 didn't have __builtin_bswap16, so provide
a suitable replacement.
2020-06-22 20:14:32 +00:00
Lior Halphon
e88a48e0a1 Use gamma-corrected mixing in shaders 2020-06-19 23:18:38 +03:00
Lior Halphon
096eb78be7 Update version to 0.13.2 2020-06-11 13:39:25 +03:00
Lior Halphon
4f42f4f718 Minor layout fixes 2020-06-11 00:38:53 +03:00
Lior Halphon
7eb4a92d2a Improve print window, add a button for actual physical printing 2020-06-10 23:28:33 +03:00
Lior Halphon
006ee4f6cb What rhymes with "willows" and breaks when you edit a Makefile? 2020-06-10 23:00:41 +03:00
Lior Halphon
b6b56d0766 Fix various save state compatibility issues between Windows and non-Windows, and a potential crash 2020-06-10 22:46:19 +03:00
Lior Halphon
edf7762408 Improved Dark Mode support, improved Hex Fiend's general system-native appearance 2020-06-10 01:10:11 +03:00
Lior Halphon
4a51f5c956 Cherry-picking libretro memory map bugfix (Closes #227, #205). Fixing libretro build with modern macOS SDKs. 2020-06-09 20:09:50 +03:00
Lior Halphon
c07588e3bd Console auto complete 2020-06-05 02:10:05 +03:00
Lior Halphon
ef203cf0e5 Update version to 0.13.1 2020-06-03 21:18:09 +03:00
Lior Halphon
b7a9039e50 Sanitize SDL preferences for cross-version stability 2020-06-03 21:06:47 +03:00
Lior Halphon
6a3cd371d0 Fix potential memory corruption when execution malformed ROMs 2020-06-03 20:54:06 +03:00
Lior Halphon
9e8b4345c0 Update version to 0.13 2020-05-31 21:55:04 +03:00
Lior Halphon
9521729e4e Fixed Windows build 2020-05-31 21:54:54 +03:00
Lior Halphon
08efb46d41 Made the command line debugger output “>” before inputs, added special magic sequence to break the debugger from stdin 2020-05-31 20:32:00 +03:00
Lior Halphon
0c0ca8e862 Last resort for Macs that can’t send reports to certain devices 2020-05-31 01:41:27 +03:00
Lior Halphon
97e844a0b7 GB_debugger_break is for external APIs, not available on libretro builds 2020-05-31 01:01:06 +03:00
Lior Halphon
5f4aee8ca1
Merge pull request #261 from JL2210/ld-b-b
Add ld b, b breakpoint
2020-05-31 00:55:17 +03:00
Lior Halphon
f1ea39f1c6
Spacing 2020-05-31 00:54:49 +03:00
Lior Halphon
fd97e11919
Spacing 2020-05-31 00:54:13 +03:00
James Larrowe
6fcf77c7f6 Make no argument for softbreak be equivalent to "on" 2020-05-30 16:46:17 -04:00
James Larrowe
abdece7737 add debugger command to enable and disable 2020-05-30 16:35:07 -04:00
James Larrowe
f105f28017 Add ld b,b breakpoint
Signed-off-by: James Larrowe <larrowe.semaj11@gmail.com>
2020-05-30 15:54:51 -04:00
Lior Halphon
83b959c126 Delay requests to show notifications 2020-05-30 22:46:06 +03:00
Lior Halphon
c665fcb2ed Minor fixes 2020-05-30 22:20:45 +03:00
Lior Halphon
c9b401135f Actually, don’t use rumble threads at all, because IOHIDDeviceSetReport seems to queue stuff despite being blocking 2020-05-30 22:18:32 +03:00
Lior Halphon
af5cb72edc Restore Switch LED support 2020-05-30 21:31:00 +03:00
Lior Halphon
e678b50101 Force all controllers to use a rumble thread 2020-05-30 20:15:13 +03:00
Lior Halphon
59b94b92ca Make sure reports are only sent from one thread 2020-05-30 18:43:09 +03:00
Lior Halphon
4d91081046 Do not send LED updates if nothing changed 2020-05-30 17:58:02 +03:00
Lior Halphon
fa7232944f Better emulation of CGB’s first frame behavior 2020-05-30 01:25:21 +03:00
Lior Halphon
ffa569deeb Partial emulation of reading VRAM right after mode 3 2020-05-29 23:10:23 +03:00
Lior Halphon
29b64d7545 Slightly reduce the scanline-ish LCD effect 2020-05-29 16:51:20 +03:00
Lior Halphon
17dfe0dd6a Fix minor CGB-C regression 2020-05-29 16:30:40 +03:00
Lior Halphon
f1442b0ea6 Attempt to add rumble support to SDL. Who knows it might work. 2020-05-24 23:04:36 +03:00
Lior Halphon
7af66387de HuC-3 alarm clock emulation 2020-05-23 14:50:54 +03:00
Lior Halphon
369410f370 Fix HuC-1 regression 2020-05-23 00:09:30 +03:00
Lior Halphon
08ca56eec7 Cleanup 2020-05-23 00:05:43 +03:00
Lior Halphon
ce9114ed55 Fix IR bugs 2020-05-19 01:24:09 +03:00
Lior Halphon
933b622886 Allow more GameShark cheats 2020-05-19 01:24:02 +03:00
Lior Halphon
157123e118 Fix clearing OAM and initializeing wave RAM 2020-05-17 19:24:11 +03:00
Lior Halphon
a588993f28 Add an HuC command required by Pocket Family 2 2020-05-17 00:10:43 +03:00
Lior Halphon
a9023d08c6 Emulate HuC-3’s IR and RTC 2020-05-16 23:27:17 +03:00
Lior Halphon
2cc980755e HuC1 IR support 2020-05-13 22:21:31 +03:00
Lior Halphon
060136306b Merge branch 'sdl_audio_fix' 2020-05-10 22:17:58 +03:00
Lior Halphon
1b7c3c4c7c Minor fixes, style update 2020-05-10 22:16:49 +03:00
Lior Halphon
0200596391 Fix #256 2020-05-10 22:05:47 +03:00
Lior Halphon
ca24f54bee Merge branch 'master' of https://github.com/LIJI32/SameBoy 2020-05-10 00:38:06 +03:00
Lior Halphon
3cba3e8e27 Emulate CGB-C PCM read glitch, fix a potential noise volume envelope bug 2020-05-10 00:37:52 +03:00
Rupert Carmichael
5f2c7b966f Pre-buffer audio samples before passing to SDL's queue 2020-05-09 11:49:20 -04:00
Lior Halphon
e4aa212f9a
Merge pull request #254 from NieDzejkob/bootrom-2bpp
Fix segfault, save some bytes.
2020-05-09 15:32:19 +03:00
Jakub Kądziołka
24220defd6
Save 16 bytes in the CGB boot ROM 2020-05-09 13:11:51 +02:00
Lior Halphon
620ee3cf51 Make the libretro frontend not crash on rumble-less frontends 2020-05-07 23:43:49 +03:00
Lior Halphon
ccc7d2e887 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2020-05-07 22:47:52 +03:00
Lior Halphon
e063671816 No need to use malloc here, the buffer never gets large 2020-05-07 22:46:06 +03:00
Lior Halphon
c4a8669501
Merge pull request #253 from FredrIQ/multiaddr
Allow more than 1 symbol per debug address
2020-05-07 02:09:09 +03:00
Lior Halphon
8625b23c0d Whoops 2020-05-07 01:32:03 +03:00
Fredrik Ljungdahl
99ec31dfdc Allow more than 1 symbol per debug address 2020-05-07 00:12:35 +02:00
Lior Halphon
8f69703726 Merge branch 'bootrom-2bpp' 2020-05-06 23:30:56 +03:00
Lior Halphon
7cff35368d Port to C to remove the Python dep, remove leftovers 2020-05-06 23:30:01 +03:00
Lior Halphon
184743637e Fix silly regression 2020-05-06 01:10:46 +03:00
Lior Halphon
730567dc60 Proper color mixing 2020-05-06 01:06:22 +03:00
Lior Halphon
a3f261184d Optimize more 2020-05-05 01:44:48 +03:00
Lior Halphon
f46f138e9f Clear VRAM correctly 2020-05-04 23:54:43 +03:00
Lior Halphon
260f61f33a This window shouldn’t be resizeable 2020-05-04 22:48:00 +03:00
Lior Halphon
72a90ba91c Hacky color blending 2020-05-04 02:17:03 +03:00
Lior Halphon
2225fd114c Handle 2bpp palettes 2020-05-04 02:07:19 +03:00
Jakub Kądziołka
b057e0d10a
Save 4 more bytes in the CGB boot ROM 2020-05-03 23:07:53 +02:00
Jakub Kądziołka
cb738190be
Add a 2bpp CGB boot ROM logo, pending palettes 2020-05-03 22:45:23 +02:00
Jakub Kądziołka
19126df7f4
Save 8 bytes in the CGB boot ROM 2020-05-03 22:41:56 +02:00
Lior Halphon
6910c3d24b Complete DualShock 3 support 2020-05-03 20:23:37 +03:00
Lior Halphon
bb37f8d2f0 Optimize Joypad initialization 2020-05-02 23:04:12 +03:00
Lior Halphon
9413d68976 Add support for wired Switch Pro Controller 2020-05-02 22:14:53 +03:00
Lior Halphon
78e2b94cb5 Rewrite the "Sub Elements" design into a more powerful Custom Report design that can overwrite an entire report structure of a sepcific report by its ID 2020-05-02 20:55:54 +03:00
Lior Halphon
e5302a9b1e Set sane libretro defaults, add border settings (Closes #203), general libretro cleanup 2020-05-01 23:42:08 +03:00
Lior Halphon
c492022ae6 Fix a deadlock 2020-05-01 19:31:04 +03:00
Lior Halphon
69fb2ad0a3 Fix rumble on WUP-028 on ports other than 1 2020-05-01 18:46:00 +03:00
Lior Halphon
7e124e169e Avoid races 2020-05-01 18:44:26 +03:00
Lior Halphon
2854578527 Less ugly hacks 2020-05-01 18:26:48 +03:00
Lior Halphon
021cdb402d Various hacks for stopping the PWM thread when needed, important if we have a WUP-028 connected with more than one controller 2020-05-01 18:16:33 +03:00
Lior Halphon
4bf252800e Improve PWM quality, fix a crash 2020-05-01 18:08:44 +03:00
Lior Halphon
5a56c3b882 Style fixes 2020-05-01 16:03:26 +03:00
Lior Halphon
ea18ba9335 Add rumble settings to libretro 2020-05-01 15:50:22 +03:00
Lior Halphon
5da80062d9 Fix WUP-028 on Catalina, make controller configuration compatible between macOS versions 2020-05-01 00:34:00 +03:00
Lior Halphon
40562b1c54 Revert "Fix WUP-028 on Catalina, make controller configuration compatible between macOS versions"
This reverts commit 160282c42a.
2020-05-01 00:25:40 +03:00
Lior Halphon
160282c42a Fix WUP-028 on Catalina, make controller configuration compatible between macOS versions 2020-04-30 23:56:14 +03:00
Lior Halphon
60ad3160cf Fix an XIB oops 2020-04-29 23:52:28 +03:00
Lior Halphon
6bcaffe27d Fix sendReport on JOYMultiplayerControlle 2020-04-29 23:47:18 +03:00
Lior Halphon
4c1f073d20 Fix error report 2020-04-29 20:59:19 +03:00
Lior Halphon
0f73282e4e Actually allow it 2020-04-29 20:54:28 +03:00
Lior Halphon
03ea6dc708 Make builds possible without Xcode 2020-04-29 20:44:55 +03:00
Lior Halphon
9f876e380c Offical WUP-028s require an activation sequence 2020-04-29 20:08:00 +03:00
Lior Halphon
66112af37e Fix PWM performence issue 2020-04-29 19:53:47 +03:00
Lior Halphon
5c9d50e25f Fix job 2020-04-29 17:02:20 +03:00
Lior Halphon
05cf3656b8 Fix libretro 2020-04-29 16:58:38 +03:00
Lior Halphon
0c91502859 Remove log 2020-04-29 16:52:32 +03:00
Lior Halphon
4b24178553 Rumble mode selection 2020-04-29 16:50:31 +03:00
Lior Halphon
4c443d51ce Minor JoyKit improvements 2020-04-29 16:06:38 +03:00
Lior Halphon
6448a692e2 Add smart rumble to games without a rumblepak 2020-04-29 16:06:11 +03:00
Lior Halphon
151d58eb60 setRumble should be double 2020-04-29 16:05:31 +03:00
Lior Halphon
5a14eb93c6 Merge branch 'master' into JoyKit
# Conflicts:
#	Cocoa/Document.m
#	Cocoa/GBView.h
#	Cocoa/GBView.m
#	Cocoa/joypad.m
#	Cocoa/main.m
#	Core/display.c
#	Core/gb.h
#	Core/save_state.c
2020-04-29 15:52:03 +03:00
Lior Halphon
8f6047fdca Prevent -Wall from overriding -Wno flags 2020-04-28 21:53:37 +03:00
Lior Halphon
1e54c55c11 Making libretro compile without warnings with GCC 2020-04-28 21:44:29 +03:00
Lior Halphon
c64d5b58b6 Make failed builds easier to read 2020-04-28 20:01:22 +03:00
Lior Halphon
8d016f19d2 Move the audio code to a different file 2020-04-28 20:01:22 +03:00
Lior Halphon
110cedeaac Even better hueristics 2020-04-25 23:26:17 +03:00
Lior Halphon
d1e3ad7790 Better hueristics for wrong MBC type 2020-04-25 23:18:03 +03:00
Lior Halphon
0534b091a5 Fix SDL 2020-04-25 23:11:29 +03:00
Lior Halphon
9e99ce434e Allow loading .RAM files 2020-04-25 23:09:08 +03:00
Lior Halphon
ca567bee79 Fix Linux build break 2020-04-25 22:54:50 +03:00
Lior Halphon
152924e13f Add support to the ISX format, including symbols 2020-04-25 22:48:48 +03:00
Lior Halphon
36aa3f31b9 -q was not enough 2020-04-25 18:11:01 +03:00
Lior Halphon
f65dc73632 -q was not enough 2020-04-25 18:09:04 +03:00
Lior Halphon
9fbafab67f Use grep -q, put macOS first, restore -j 2020-04-25 18:04:27 +03:00
Lior Halphon
65fb6afd60 Make fixes 2020-04-25 17:57:19 +03:00
Lior Halphon
09e7068658 Fixing another duh 2020-04-25 17:22:43 +03:00
Lior Halphon
aa9ccc724f Fixing a duh 2020-04-25 17:20:06 +03:00
Lior Halphon
7760e11544 Better error handling 2020-04-25 17:12:53 +03:00
Lior Halphon
a35164dc0a Fixed unused variable on Linux 2020-04-25 17:06:24 +03:00
Lior Halphon
e819b91a97 Rename job, temporarily disable -j 2020-04-25 17:03:45 +03:00
Lior Halphon
bf67811392 Sanity test against a few test ROMs 2020-04-25 16:59:47 +03:00
Lior Halphon
8e702f1452 Also test libretro's buildability 2020-04-25 15:13:04 +03:00
Lior Halphon
bb5c9f7fc6 Fix libretro build 2020-04-25 15:12:10 +03:00
Lior Halphon
66112f4930 That wasn't enough to fix it, I'll just disable this warning 2020-04-25 14:55:51 +03:00
Lior Halphon
c62704e26b Minor fix for GCC's LTO 2020-04-25 14:51:17 +03:00
Lior Halphon
1e7737a239 Limit unroll to GCC 8 2020-04-25 14:46:01 +03:00
Lior Halphon
c2a395006e Update docs 2020-04-25 14:45:52 +03:00
Lior Halphon
097705456c Show compiler version 2020-04-25 14:05:35 +03:00
Lior Halphon
7e908fef0e The macOS environment doesn't come with GCC, it'll just test Clang again 2020-04-25 14:04:51 +03:00
Lior Halphon
17c97c3c2b Use brew's SDL2 on macOS 2020-04-25 13:59:31 +03:00
Lior Halphon
385cd1b8c7 Fix chmod 2020-04-25 13:52:18 +03:00
Lior Halphon
2df6d266bd Add a GitHub action to avoid breaking builds 2020-04-25 13:50:35 +03:00
Lior Halphon
ddad913e06 OK this time it will work. 2020-04-24 21:59:51 +03:00
Lior Halphon
8ac029d3fe Truly truly fix #249, fix #251 2020-04-24 21:06:44 +03:00
Lior Halphon
198942b273 Truly fix #249, fix #251 2020-04-24 21:00:30 +03:00
Lior Halphon
634dcefd01 Typo 2020-04-24 20:44:25 +03:00
Lior Halphon
0cf168f32b Fixing inconsistent style 2020-04-24 20:37:57 +03:00
Lior Halphon
d38fd41b0e Reorder flags so -Wpartial-availablility is affected by -Wno-unknown-warning -Wno-unknown-warning-option, fixes #249, fixes #251 2020-04-24 20:18:56 +03:00
Lior Halphon
db9410caa5 Minor UI fix 2020-04-11 21:48:47 +03:00
Lior Halphon
32a0dc0e43 Rename the "Developer" menu to "Develop", like first party Mac apps 2020-04-11 20:44:15 +03:00
Lior Halphon
695c6ee943 Don't crash if a naughty frontend runs the boot ROM without a ROM 2020-04-11 19:21:00 +03:00
Lior Halphon
0abd3b2c46 Dump and load cheats 2020-04-11 19:15:40 +03:00
Lior Halphon
5df45417fa Console quirks 2020-04-11 18:27:31 +03:00
Lior Halphon
0c3db932b2 Fix Mavericks compatibility 2020-04-11 18:19:15 +03:00
Lior Halphon
2bc75caf9e Fix CRT shader on OpenGL 2020-04-11 18:03:21 +03:00
Lior Halphon
852a6997ed Add cheats UI to Cocoa 2020-04-11 18:03:10 +03:00
Lior Halphon
337e74352d Add cheats API, with GameShark and GameGenie import 2020-04-09 22:13:09 +03:00
Lior Halphon
1d80c185d8 Remove IDE comment 2020-04-09 17:25:14 +03:00
Lior Halphon
4a21dd3232 The Cocoa sidebar is now resizeable and collapseable 2020-04-09 15:29:49 +03:00
Lior Halphon
a6567d9ee1 Update old coding style 2020-04-09 14:32:52 +03:00
Lior Halphon
a9cd3f2c11 Fix operator priorities, fix parsing debugger bug 2020-04-09 14:21:07 +03:00
Lior Halphon
92d6cc6394 Use official register names 2020-04-09 02:36:27 +03:00
Lior Halphon
d8e89f5114 Fix banked 16-bit assignments; fixes #245 2020-04-08 19:17:45 +03:00
Lior Halphon
0ed5cf6b38 Proper MBC30 support, more accurate MBC3 emulation. Fixes #244 2020-04-08 19:07:29 +03:00
Lior Halphon
d75b7c0023 Feature request; allow loading prefs.bin relatively 2020-03-28 22:56:19 +03:00
Lior Halphon
9f3bffd4dd Add volume control to SDL 2020-03-27 19:10:42 +03:00
Lior Halphon
2f1b8e5b57 IME is now available under the registers command 2020-03-27 18:56:47 +03:00
Lior Halphon
1a3572316f next now skips over halt, closes #233 2020-03-27 17:49:14 +03:00
Lior Halphon
05403d3a56 Fix the Joypad interrupt. Fixes #237 2020-03-27 17:36:55 +03:00
Lior Halphon
876b36ac1c More crash fixes, restore Metal support 2020-03-27 17:26:51 +03:00
Lior Halphon
588c0734a9 Fix a crash 2020-03-27 17:23:33 +03:00
Lior Halphon
4cb56dc76f Improve MBC2 emulation. Fixes #238 2020-03-27 16:35:36 +03:00
Lior Halphon
fa1c84f18f Remove the Blend Frames menu item 2020-03-27 15:43:30 +03:00
Lior Halphon
7a807f5cae Fix #243 2020-03-26 22:18:31 +02:00
Lior Halphon
5ecb845662 Add accurate frame blending option 2020-03-26 20:54:18 +02:00
Lior Halphon
e94e7cc501 Add another color correction mode 2020-03-25 20:33:13 +02:00
Lior Halphon
84e8e45b7b Implement ATTR_CHR 2020-03-13 13:35:54 +02:00
Lior Halphon
e7f6ac8828 Do the same for SGB 2020-03-06 21:19:53 +02:00
Lior Halphon
34cf0f558d It's more reasonable to do it this way 2020-03-06 18:56:51 +02:00
Lior Halphon
fe7667a00c Add drop shadows to the Monochrome LCD shader 2020-03-06 17:37:47 +02:00
Lior Halphon
4963ec4cc4 Gamma correction in the CRT shader 2020-03-06 17:37:29 +02:00
Lior Halphon
ee939a3782 New boot ROM animation in the DMG boot ROM 2020-03-06 17:37:18 +02:00
Lior Halphon
78b552fe82 More attempts to fix this bug 2020-03-06 17:37:04 +02:00
Lior Halphon
c6f9d05124 Emulate LCD-PPU horizontal desync on DMGs 2020-03-06 14:41:13 +02:00
Lior Halphon
4d2f56c42d Minor bug fix 2020-03-04 23:43:05 +02:00
Lior Halphon
1c7351fc85 Missing braces 2020-03-04 23:34:36 +02:00
Lior Halphon
409ab2a6d4 Accurate emulation of tilemap advancement timings 2020-03-03 02:21:19 +02:00
Lior Halphon
e846f4f3b0 Hacky, but correct emulation of WX=166 2020-03-01 23:58:28 +02:00
Lior Halphon
2a8b26d5e6 Add TODO 2020-03-01 00:23:50 +02:00
Lior Halphon
b7194402eb Accurately emulate Window X = Object X 2020-03-01 00:17:45 +02:00
Lior Halphon
5ca602fbd2 WX=0 emulation 2020-02-29 18:26:16 +02:00
Lior Halphon
39b999a68b Emulate the FIFO insertion glitch (WX variant) 2020-02-29 17:06:08 +02:00
Lior Halphon
955860b463 Get rid of the FIFO pause flags 2020-02-28 22:36:51 +02:00
Lior Halphon
e29246fd91 Window tile is reset on WX trigger 2020-02-28 18:28:47 +02:00
Lior Halphon
2a8f15c68b The fetcher pushes pixels to the FIFO as soon as it's empty 2020-02-28 18:10:09 +02:00
Lior Halphon
60f01fe947 Merge branch 'master' into ppu_window 2020-02-28 15:21:38 +02:00
Lior Halphon
40868df759 Fix this bug again 2020-02-28 14:05:29 +02:00
Lior Halphon
0c716bd970 More accurate timing emulation of window-objects interaction 2020-02-27 23:42:16 +02:00
Lior Halphon
52a3bf5f24
Merge pull request #234 from NieDzejkob/spelling
Spell "length" properly
2020-02-27 19:36:20 +02:00
Jakub Kądziołka
67d5a53503
Spell "length" properly 2020-02-27 18:11:10 +01:00
Lior Halphon
89303ab046 WX access conflicts 2020-02-27 00:12:42 +02:00
Lior Halphon
9c7a8fdb1b WY is tested every cycle 2020-02-26 22:24:08 +02:00
Lior Halphon
b37a0b285a Window Y still advances if WX=166 2020-02-24 23:59:18 +02:00
Lior Halphon
7456beb7b9 Better emulation of negative WX positions 2020-02-24 21:23:06 +02:00
Lior Halphon
248e7bc332 Timing improvements 2020-02-24 20:46:00 +02:00
Lior Halphon
25b51362e9 Safety first 2020-02-24 00:33:45 +02:00
Lior Halphon
3864ff37e1 Timing improvements 2020-02-24 00:32:47 +02:00
Lior Halphon
c22611c701 Minor bugfix 2020-02-23 23:48:08 +02:00
Lior Halphon
c0ba898ef2 Basic window implementation 2020-02-23 23:16:45 +02:00
Lior Halphon
2be58439bf Starting over – removing all window related code 2020-02-23 00:38:47 +02:00
Lior Halphon
83ea4edce2 Shut up, annoying log message 2020-02-23 00:16:15 +02:00
Lior Halphon
d8282fe3c9 Please pretend the last commit never happened 2020-02-22 00:45:52 +02:00
Lior Halphon
39b88d546b The upper bits of SCX might mid-line 2020-02-21 21:59:03 +02:00
Lior Halphon
ea2f32b255 The fetcher state machine advances even while handling an object 2020-02-21 21:44:44 +02:00
Lior Halphon
f86e682d2c Fix sign 2020-02-21 17:22:57 +02:00
Lior Halphon
8409d3bcfb Emulate changing sprite height mid-fetch 2020-02-21 16:43:51 +02:00
Lior Halphon
7d51ba3d97 More fixes, SGB emulation of the same quirk 2020-02-21 16:16:02 +02:00
Lior Halphon
91404edd13 Disgusting hacks to emulate disabling objects while an object is being fetched 2020-02-21 15:14:33 +02:00
Lior Halphon
56118d2a67 Move improvements to LCDC conflicts 2020-02-21 14:22:25 +02:00
Lior Halphon
a8f63aea3c Emulate DMG LCDC write conflicts correctly. This might vary between individual units. 2020-02-21 02:55:07 +02:00
Lior Halphon
0290e70445 Improvements to AGB color correction 2020-02-17 23:05:11 +02:00
Lior Halphon
bf32ae66c6 Another attemp to fix Cocoa deadlocking 2020-02-15 19:23:04 +02:00
Lior Halphon
bec09a012c More accurate emulation of STOP mode 2020-02-15 19:21:43 +02:00
Lior Halphon
08eb2f3d98 Correct emulation of FF6C (Turns out it controls object priority) 2020-02-15 15:32:06 +02:00
Lior Halphon
f550360f1a More accurate CGB color correction curve 2020-02-15 13:21:21 +02:00
Lior Halphon
0677b1d099 Update the automation to not use internel APIs for input 2020-02-11 00:11:17 +02:00
Lior Halphon
8b7805b95d Hit ^T 2020-02-10 20:19:37 +02:00
Lior Halphon
804b9bec63 Fixed a bug where HDMA begins in the middle of an instruction while cycles are pending to be flushed. Fixes #230 2020-02-10 00:21:33 +02:00
Lior Halphon
dcb3f6db9e Fix minimum window size in the Cocoa frontend 2020-02-08 14:38:04 +02:00
Lior Halphon
103caa56e1 Allow displaying borders outside of SGB emulation, including borrowing SGB border. Allow not displaying SGB borders. (Todo: libretro support) 2020-02-08 13:28:46 +02:00
Lior Halphon
370f02661d Deadlock fix 2020-02-08 12:31:06 +02:00
Lior Halphon
b806ae4e82 Fix #228 2020-02-01 23:36:16 +02:00
Lior Halphon
38ee020653 Fixed a regression bug that made the first CGB frame blank instead of repeated. 2020-01-31 01:29:59 +02:00
Lior Halphon
ce5153544c Fix menu scrolling in SDL while emulating SGB 2020-01-29 20:55:17 +02:00
Lior Halphon
48d3504de7 Let the core handle boot ROM selection 2020-01-29 20:29:30 +02:00
Lior Halphon
99d2c0258c Add monochrome LCD shader 2020-01-29 15:51:53 +02:00
Lior Halphon
046b09052c Add DMG color palettes (SDL), add scrolling to SDL menus 2020-01-29 15:36:19 +02:00
Lior Halphon
163a5ea20c Add DMG color palettes (Cocoa) 2020-01-29 14:19:11 +02:00
Lior Halphon
0737655753 Merge branch 'master' into JoyKit 2020-01-03 23:42:25 +02:00
Lior Halphon
95af00a752 speling is veri difikult 2020-01-03 21:11:45 +02:00
Lior Halphon
89713521d4
Merge pull request #222 from Pixelnarium/master
fix SDL build -> Windows.h include at the wrong place
2020-01-02 11:54:27 +02:00
Pixelnarium
5a1812f237 fix SDL build 2020-01-02 10:50:55 +01:00
Lior Halphon
23c7fb2885 Update version, update copyright year 2020-01-01 23:43:36 +02:00
Lior Halphon
e9f6667cf5 Minor build cleanup 2020-01-01 23:36:15 +02:00
Lior Halphon
3882b1b4b9 Fix Windows build, hopefully fix High DPI support on Windows 10 (fixes #202) 2020-01-01 00:27:41 +02:00
Lior Halphon
7929573dc1 Refinements to the last commit 2020-01-01 00:17:54 +02:00
Lior Halphon
e434b625ea Allow the fullscreen key combo to work while in the menu 2019-12-30 16:19:06 +01:00
Lior Halphon
4c24323530 Fix Game Boy Camera support in macOS Mojave and newer 2019-12-29 17:34:43 +01:00
Lior Halphon
8a99d41c31 Fix broken SDL builds on macOS and Windows 2019-12-26 02:00:58 +02:00
Anthony J. Bentley
7c9508ae96 Include the canonical SDL2 path, which drops the SDL2/ prefix.
Use pkg-config or sdl2-config to determine SDL and GL compilation flags.
2019-12-10 00:56:34 -07:00
Lior Halphon
0ea361a82f
Merge pull request #207 from libretro/master
Update from downstream
2019-11-22 11:29:10 +02:00
retro-wertz
436dc0b67a Fix GBC memory map and add IO port range for cheevos 2019-11-21 22:53:11 -05:00
Lior Halphon
bd9ac204c2 Allow SameBoy to compile on 4-byte-bools platforms 2019-11-20 22:40:03 +02:00
Lior Halphon
31609319de Fix the set_joyp API 2019-11-09 14:45:38 +02:00
Lior Halphon
c802361800 Whoops, this function was missing 2019-11-08 16:14:16 +02:00
Lior Halphon
143e1f88a8 There’s not reason it must be an integer 2019-11-03 22:02:33 +02:00
Lior Halphon
68187d7c5f
Merge pull request #218 from ZenithMDC/SDL2-hide-mouse-cursor
SDL2: Hide mouse cursor when menu is not active
2019-11-03 21:07:50 +02:00
Lior Halphon
0bfcdafe2d
Merge pull request #217 from ZenithMDC/SDL2-viewport-bugfix
SDL2: Fix fullscreen viewport bug
2019-11-03 21:06:42 +02:00
Lior Halphon
97a2cc2566
Merge pull request #216 from ZenithMDC/SDL2-hot-swap-battery-save
SDL2: Write battery to disk when ROMs are hot-swapped
2019-11-03 21:05:49 +02:00
Lior Halphon
cfc0215089
Merge pull request #204 from f21red/sgb
libretro: sgb updates
2019-11-03 21:05:19 +02:00
Matthew Coppola
2f4a10913b SDL2: Hide mouse cursor when menu is not active 2019-11-03 00:35:56 -04:00
Matthew Coppola
139ae8cc08 SDL2: Write battery to disk when ROMs are hot-swapped 2019-11-02 23:50:29 -04:00
Matthew Coppola
719a92d8a4 SDL2: Fix fullscreen viewport bug 2019-11-02 23:31:23 -04:00
Lior Halphon
70542137f2 Fix #214 2019-10-29 20:31:20 +02:00
Lior Halphon
0ece21bca7 Replace the SDL-derived controller support with my own JoyKit framework. Adds rumble support, LED support, better manual and automatic configurations, analog speed controls. 2019-10-19 19:26:04 +03:00
Lior Halphon
7d6cdf3819 Fix SGB support in SDL’s software rendering. Fixes #208 2019-10-17 21:21:10 +03:00
Lior Halphon
dee29c118c Added GB_set_sample_rate_by_clocks API, split SGB_NO_SFC into PAL and NTSC; now they report the correct clock rate. 2019-10-08 15:10:24 +03:00
f21red
0a7a0ca5fe
libretro: sgb border option 2019-10-05 20:51:59 -05:00
f21red
c50ea6a63f libretro: sgb color correction 2019-10-06 01:35:44 +00:00
Lior Halphon
ca370eee7e A bit more accurate AGB audio rendering 2019-10-01 18:50:59 +03:00
Lior Halphon
ac418b9de1 Pass channel_1_freq_change_timing 2019-09-30 00:09:25 +03:00
Lior Halphon
0c48ecb3f8 Updated version to 0.12.2 2019-09-14 20:06:01 +03:00
Lior Halphon
652e52df3d Pass the SGB multiplayer tests 2019-09-14 12:31:52 +03:00
Lior Halphon
851dbd3ccd SGB and AGB color correction 2019-09-13 17:13:21 +03:00
Lior Halphon
4fcc921b46 Fix SGB multiplayer, improve multiplayer accuracy 2019-09-13 17:10:58 +03:00
Lior Halphon
eaa1c1cd4a Merge bsnes’s changes 2019-08-16 17:38:43 +03:00
Lior Halphon
e3672e8293 Emulate built in SGB palettes 2019-07-20 16:10:24 +03:00
Lior Halphon
17793ef361
Merge pull request #191 from rzumer/gbc_memory_map
Fix libretro GBC memory map and add IO port range for cheevos
2019-07-20 00:04:36 +03:00
Lior Halphon
d2e9025be6 Fixed major performence issues in the Cocoa port that affected some Macs, especially when emulating SGB1 2019-07-19 23:59:25 +03:00
Raphaël Zumer
1a263a3acc Fix GBC memory map and add IO port range for cheevos 2019-07-19 16:55:59 -04:00
Lior Halphon
8c1f76a594 Fix HLE SGB 2019-07-19 20:37:58 +03:00
Lior Halphon
ffb9f1b134 Fix HLE SGB 2019-07-19 20:34:26 +03:00
Lior Halphon
e634019ac9 Fix CGB emulation 2019-07-19 20:27:53 +03:00
Lior Halphon
4f9c8e9374 Match the HLE timings to the LLE timings 2019-07-19 20:19:09 +03:00
Lior Halphon
ea7dec4e88 Merge branch 'master' into bsnes_integration 2019-07-19 15:51:10 +03:00
Lior Halphon
33198fc7b7 Give SGB its own conflict map 2019-07-19 15:50:49 +03:00
Lior Halphon
f0809a667f Fixed a potential Cocoa crash when closing a window 2019-07-19 15:50:36 +03:00
Lior Halphon
df7f7d8171 Fix silly desync inaccuracy 2019-07-18 22:55:11 +03:00
Lior Halphon
772289c545 Fix a silly bug 2019-07-18 00:53:11 +03:00
Lior Halphon
9651f2bb6b Merge branch 'master' of https://github.com/LIJI32/SameBoy 2019-07-18 00:13:54 +03:00
Lior Halphon
597dc72e46 Fix audio issues with some RetroArch audio drivers. Fixes #189 2019-07-18 00:13:41 +03:00
Lior Halphon
ee4864449c
Merge pull request #187 from webgeek1234/master
libretro: Android update
2019-07-17 00:52:27 +03:00
Lior Halphon
23ca397206
Remove unused flag 2019-07-17 00:52:01 +03:00
Lior Halphon
0857abe6a4
Merge pull request #190 from pinobatch/master
cgb_boot: Compress logo with PB8
2019-07-17 00:15:41 +03:00
Damian Yerrick
26cf970713 don't need logo-compress.c anymore 2019-07-16 17:04:23 -04:00
Damian Yerrick
4504de828a cgb_boot: Compress logo with PB8
The logo is compressed using PB8, a form of RLE with unary-coded
run lengths.  Each block representing 8 bytes consists of a control
byte, where each bit (MSB to LSB) is 0 for literal or 1 for repeat
previous, followed by the literals in that block.

PB8 compression is also used in a few NES games.  A variant called
PB16, where 1 means repeat 2 bytes back, is used in the Game Boy
port of 240p Test Suite and in Libbet and the Magic Floor.

Switching from logo-compress RLE to PB8 decreases the compressed
logo data size from 287 bytes to 253 bytes, saving 34 bytes.
The decompression code is also about 10 bytes smaller.
2019-07-16 16:58:16 -04:00
Lior Halphon
1bf5fb208f Silence an unwanted GCC warning 2019-07-16 23:41:05 +03:00
Lior Halphon
9efd20d7cd Revert "Silence some GCC warnings"
This reverts commit 11a9f1df21.
2019-07-16 23:33:07 +03:00
Lior Halphon
11a9f1df21 Silence some GCC warnings 2019-07-16 23:27:35 +03:00
Lior Halphon
eb95f1de55 Fixed a bug where the SDL port loaded the incorrect boot ROM for SGB2. Made SameBoy compatible with older SDL versions. 2019-07-16 23:14:26 +03:00
Lior Halphon
9ba6915c85 ICD JOYP write API 2019-07-16 21:42:57 +03:00
Lior Halphon
2d7f54a775 Load ROM from buffer API 2019-07-16 21:04:29 +03:00
Lior Halphon
ce9ce07817 Make the ICD APIs pixel based 2019-07-16 20:44:27 +03:00
Lior Halphon
346e499602 ICD APIs 2019-07-15 23:02:58 +03:00
Lior Halphon
e1873ad2ec Add JOYP write callback API 2019-07-15 22:35:21 +03:00
Lior Halphon
2bfe922650 Allow emulating an SGB without SFC HLE 2019-07-15 20:47:16 +03:00
Lior Halphon
9f7255cd23 Make the automation results more consistent across revisions, and making use of this change as a chance to add color correction to the automation 2019-07-13 20:29:11 +03:00
Lior Halphon
8c8d5afe62 Make the debugger compatible with more sym formats 2019-07-13 17:17:55 +03:00
Lior Halphon
f55c254959 Fixed a regression that made ly_lyc_0_write and ly_lyc_write fail 2019-07-12 02:18:25 +03:00
Lior Halphon
30a58ecd5c Use color correction in the QL previewer 2019-07-12 01:53:20 +03:00
Lior Halphon
6b06d07bcc More attempts to improve audio in the SDL frontend 2019-07-12 01:53:06 +03:00
Lior Halphon
4541efe86a Fixed a bug that prevented writing to the wave RAM, as well as a bug where the wave RAM was treated as zeros despite not being zero’d out 2019-06-29 14:03:42 +03:00
Aaron Kling
72be66414d libretro: jni: Switch stl to c++ in preparation for ndk r20 2019-06-26 22:05:42 -05:00
Lior Halphon
23229f1118 Update version to 0.12.1 2019-06-22 19:12:12 +03:00
Lior Halphon
080fde08b6 Improve audio quality on the SDL port by being more forgiving to system with bigger buffer sizes 2019-06-22 19:01:35 +03:00
Lior Halphon
970a5f562b Fix #183 2019-06-22 18:16:55 +03:00
Lior Halphon
f1b578fd2e Update version to 0.12, update copyright year 2019-06-21 19:20:51 +03:00
Lior Halphon
b478b5b568 Fix bugged mouse support on some platforms 2019-06-21 17:21:11 +03:00
Lior Halphon
72d1d9b154 Fix Windows build 2019-06-21 17:08:10 +03:00
Lior Halphon
36a87f96bd Formatting 2019-06-21 16:58:56 +03:00
Lior Halphon
24b58da8c6 Minor text change 2019-06-21 14:18:48 +03:00
Lior Halphon
7c61445fe3 Fixed out of bound read in GB_load_state_from_buffer. Closes #104 2019-06-21 03:04:38 +03:00
Lior Halphon
72b1fe0500 Minor Fixes™ 2019-06-21 01:03:52 +03:00
Lior Halphon
50a6a3e35c Fix libretro SGB1 FPS, fix un/serialization memory corruptions in libretro 2019-06-19 23:49:43 +03:00
Lior Halphon
91b0e491c5 Increase the minimum required cycles for a sync, fix SGB jingle audio 2019-06-19 22:44:54 +03:00
Lior Halphon
280f609785 Fix under clock speed (Should have been 0.5, but ended up as ~0.4 due to rounding errors) 2019-06-19 22:25:59 +03:00
Lior Halphon
431f1f8199 Remove redundant calls to display_vblank on non-SGB models and in irregular FPS scenarios. Affects #161 2019-06-18 23:16:28 +03:00
Lior Halphon
e268efefef Redesign and reimplement the audio API, let the frontends handle more stuff. Probably affects #161 2019-06-15 23:22:27 +03:00
Lior Halphon
083b4a2970 Fix joypad hat input in the menu in the SDL port 2019-06-15 12:53:00 +03:00
Lior Halphon
8b7922b679 Fix #144 by ignored malformed commands with 0 length 2019-06-15 03:42:53 +03:00
Lior Halphon
b2397a2e7a Joystick hat support in Cocoa 2019-06-14 18:06:15 +03:00
Lior Halphon
66b814a226 Don’t use libc’s random/rand 2019-06-14 16:49:41 +03:00
Lior Halphon
5a04054145 Style changes 2019-06-14 14:34:02 +03:00
Lior Halphon
8389c6a450 Long overdue capitalization fixes 2019-06-14 14:31:17 +03:00
Lior Halphon
a956d58ea1 Merge commit 'c678407d1eae9fec625a644506b3cd66654d9b1a' 2019-06-14 14:28:36 +03:00
Jakub Kądziołka
c678407d1e
Compress the Sameboy logo. 117 bytes are now free 2019-06-10 17:45:14 +02:00
Lior Halphon
e2ef8dbbe0 Fix the GUI on some Windows 10 machines (Intel HD?). Fixes #112 2019-06-09 18:43:23 +03:00
Lior Halphon
843683a492 Randomize everything! 2019-06-09 18:14:32 +03:00
Jakub Kądziołka
8386aaf12f
Save 20 bytes in the CGB boot ROM 2019-06-09 15:15:08 +02:00
Lior Halphon
8b1c165253 Automation fixes 2019-06-09 13:48:05 +03:00
Lior Halphon
a0c5baecd8 More realistic initial V/RAM values in the boot ROM. Fixes #150 and #91 2019-06-09 00:53:44 +03:00
Lior Halphon
49d8a5cb44 Fixed the parsing of comparison operators as well as their priorities. Fixes #155 2019-06-08 16:08:07 +03:00
Lior Halphon
0da2930109 Fix #175 2019-06-08 14:35:52 +03:00
Lior Halphon
bb7fa95426 Fix incorrect register values when changing the color palette via the boot ROM 2019-06-08 13:37:49 +03:00
Lior Halphon
5cda1f2f5f Fix the last commit 2019-06-08 00:04:58 +03:00
Lior Halphon
d0bd741049 Added SCX/SCY display in the VRAM viewer. Closes #168 2019-06-07 23:38:34 +03:00
Lior Halphon
274760746e Fix #165 2019-06-07 19:18:07 +03:00
Lior Halphon
7fc3de69da Mark CGB-C as experimental 2019-06-07 18:40:54 +03:00
Lior Halphon
9d8adbb581 This is not correct, this bug only affects the PCM registers and not actual output. Currently not emulated at all. 2019-06-07 18:37:19 +03:00
Lior Halphon
2f9de4942c Increase input polling frequency in the Cocoa and SDL frontends, should make inputs look less synthetic and potentially reduce input lag 2019-06-07 18:27:25 +03:00
Lior Halphon
64879f5b02 Accurate emulation of (most aspects of) stop mode 2019-06-07 13:53:50 +03:00
Lior Halphon
4c34e0a6e0 Turns out the AGB inverts Channel 3’s output 2019-06-01 18:22:58 +03:00
Lior Halphon
6888047102 Show flags in the registers command 2019-06-01 16:42:17 +03:00
Lior Halphon
9acb4636db Fix various GTK bugs 2019-06-01 16:19:44 +03:00
Lior Halphon
cdc36f329e Added open dialog to the SDL GUI, misc fixes 2019-06-01 14:29:46 +03:00
Lior Halphon
f9cc7a3b46 Fix SDL mouse support in SGB mode 2019-05-31 18:50:02 +03:00
Lior Halphon
54c353830f SDL GUI mouse support 2019-05-31 18:33:51 +03:00
Lior Halphon
1de34b12ac
Merge pull request #181 from ISSOtm/master
Fix sample lengths for CH1, 2 and 4
2019-05-25 21:09:47 +03:00
Lior Halphon
85c43fa81f Fixed Channel 3’s first sample behavior, update analog characteristic to more realistic values. Fixes #177 2019-05-25 19:12:09 +03:00
Lior Halphon
c29b5b5800 Fixed the CRT shader for OpenGL frontends (SDL and older Macs) 2019-05-18 20:38:10 +03:00
Lior Halphon
e12e03d9c2 SGB revision selection in the SDL port 2019-05-18 20:37:41 +03:00
Lior Halphon
3e724afb0a Basic SGB support in the SDL port 2019-05-18 18:45:31 +03:00
ISSOtm
ec5d1b7b88 Fix sample lengths for CH1, 2 and 4 2019-05-18 03:01:20 +02:00
Lior Halphon
3ee2c64899 Make the apu command a bit safer 2019-05-17 22:03:23 +03:00
Lior Halphon
6648a0a84d Minor adjustments and style fixes to the new APU debug functions 2019-05-17 20:48:49 +03:00
Lior Halphon
8d9149b020
Merge pull request #178 from ISSOtm/master
Add APU-related debugger commands
2019-05-17 20:34:07 +03:00
Lior Halphon
280467ad38
Merge branch 'master' into master 2019-05-17 20:31:52 +03:00
Lior Halphon
0158803bde
Merge pull request #176 from bentley/head-dd
Use dd instead of non-POSIX head(1) options to trim bootroms.
2019-05-17 20:29:32 +03:00
Lior Halphon
91eeb4d9d5 Emulate AGB audio mixing 2019-05-17 00:08:34 +03:00
ISSOtm
40f83c8f25 Add APU-related debugger commands
This change includes making one of the APU functions public
2019-05-15 12:45:51 +02:00
Anthony J. Bentley
07bdc60a49 Use dd instead of non-POSIX head(1) options to trim bootroms. 2019-05-11 21:38:32 -06:00
Lior Halphon
795823e372
Merge pull request #174 from funbars/lib1
fix libretro log interface
2019-05-11 00:17:26 +03:00
funbars
4a54985441
fix libretro log interface 2019-05-10 15:50:16 -05:00
Lior Halphon
ddc4e7484b Fix and restore optimization 2019-05-10 22:29:30 +03:00
Lior Halphon
32361589c9 Fix GCC build 2019-05-10 22:05:03 +03:00
Lior Halphon
06670fc970 Fix #172. Allow unroll optimizations when compiling with GCC. 2019-05-10 21:51:11 +03:00
Lior Halphon
1433c59778
Merge pull request #167 from rzumer/gbc_memory_map
Update libretro GBC memory map
2019-05-10 14:16:21 +03:00
Lior Halphon
aa0309e425
Merge pull request #171 from funbars/t1
libretro windows compiler (random) Fixes #111 #154
2019-05-10 14:15:49 +03:00
Lior Halphon
6ad8e30f88
Merge pull request #173 from orbea/build
Allow building with gcc.
2019-05-10 14:13:55 +03:00
orbea
2bded45397 Disable pragmas for gcc. 2019-05-09 10:55:31 -07:00
orbea
5ce8cf5016 Makefile: Allow setting CC. 2019-05-09 10:55:28 -07:00
funbars
b6e92dc8a7
libretro windows compiler (random) 2019-05-07 12:36:04 -05:00
Lior Halphon
10be34b5b2 Fix the fast CGB boot ROM booting with data on the second VRAM bank 2019-05-04 21:15:23 +03:00
Lior Halphon
2a0e5f667b
Fix build on some Windows machines using non-Latin locales. Fixes #165 2019-05-04 15:35:17 +03:00
Lior Halphon
9e44306c04
Update .gitattributes 2019-04-19 14:49:09 +03:00
Raphaël Zumer
f8244c8119 Update libretro GBC memory map 2019-04-15 16:39:14 -04:00
Lior Halphon
82ce597573 Line breaks 2019-04-12 20:30:02 +03:00
Lior Halphon
05cd81b77c Implemented jump-to breakpoints 2019-04-12 20:29:43 +03:00
Lior Halphon
19f42d5a3a
Merge pull request #159 from rzumer/master
Add static GBC RAM banks to libretro memory map
2019-04-12 17:37:18 +03:00
Raphaël Zumer
b3939e8fdc Add static GBC RAM banks to libretro memory map 2019-04-06 16:58:49 -04:00
Lior Halphon
a62541e577
Merge pull request #158 from trinemark/achievements
Fix libretro achievements
2019-04-06 13:05:22 +03:00
trinemark
d4e8a886c5
Fix libretro achievements
https://github.com/LIJI32/SameBoy/issues/48
https://github.com/LIJI32/SameBoy/issues/157
2019-04-05 22:35:52 -05:00
Lior Halphon
7242ddae64 speling is difikult 2019-03-16 20:56:22 +02:00
Lior Halphon
936afedb4b Merge commit '57b0fe7fed8e8218d7c890cd40dea4fa93f121a5' 2019-03-15 14:36:31 +02:00
Lior Halphon
c342663200 Emulate serial bit shifting, update the serial API to use bits instead of bytes, update printer emulation and libretro to use the new API 2019-03-15 14:36:10 +02:00
radius
57b0fe7fed fix input 2019-03-12 19:54:26 -05:00
Lior Halphon
0b03b61564 Render the first line 0, as required for SGB emulation 2019-02-16 04:19:16 +02:00
Lior Halphon
9d0aadb83f Emulate missing Vreset signal (SGB only for now) and ICD2 desyncing 2019-02-15 17:04:48 +02:00
Lior Halphon
42ef41182d Merge branch 'master' of https://github.com/LIJI32/SameBoy 2019-02-15 14:12:39 +02:00
Lior Halphon
dde06e7cae Work around a crashing race condition, proper fix needed 2019-01-28 20:56:37 +02:00
Lior Halphon
5ead9d49f4
Merge pull request #139 from libretro/master
Ready to merge: SGB in the libretro core
2019-01-25 13:41:33 +02:00
Lior Halphon
b996ed9220 Writing to BGPD/OBPD while it’s blocked still increases BGPI/OBPI if needed. Fixes #145 2019-01-19 23:37:44 +02:00
Lior Halphon
73a54049d2 Accurate PPU access timings 2019-01-19 19:32:26 +02:00
radius
68a72037fa add 4p support too 2019-01-17 20:33:20 -05:00
radius
10547a6d74 hookup up 2 player SGB 2019-01-17 19:44:58 -05:00
Lior Halphon
4536581a6e Fixed a bug where modifying RTC data would corrupt cartridge RAM data. Fixes #136 2019-01-18 02:36:14 +02:00
radius
e2d9a353a0 remove single_dual mode, code cleanup 2019-01-14 23:11:42 -05:00
radius
c266e4045b try to hookup sgb2 2019-01-14 23:11:42 -05:00
radius
ca8426ea60 update libretro core 2019-01-14 23:11:42 -05:00
twinaphex
9fa6a2fe92 Add MSVC2017 target - doesn't work yet 2019-01-14 23:11:42 -05:00
Lior Halphon
312478e509 CGB palettes are not accessible during Mode 3, closes #84 2019-01-14 22:22:46 +02:00
Lior Halphon
879d3b607d Removed verified TODO 2019-01-14 20:32:52 +02:00
Lior Halphon
ba5c07bed9 Correctly emulate speed switch timing 2019-01-13 01:09:41 +02:00
Lior Halphon
c74b39e712 The CPU core of the Game Boy is (most likely) called SM83 2019-01-12 00:42:16 +02:00
Lior Halphon
21d2a59a5f Fixed a very rare edge case where an interrupt occurs when SP=FF11 2019-01-12 00:39:24 +02:00
Lior Halphon
4e2b5bb336 Fix the GB_run_frame API in SGB mode 2019-01-11 21:53:21 +02:00
Lior Halphon
c756861822
Merge pull request #138 from orbea/bootroms
Makefile: Fix typo.
2019-01-06 20:47:45 +02:00
Lior Halphon
9b22224bc4
Merge pull request #133 from aconbere/anders/add-faq
add FAQ file
2019-01-06 20:45:49 +02:00
Lior Halphon
653c7fc1e6
Update and rename FAQ.md to build-faq.md 2019-01-06 20:45:15 +02:00
orbea
de3718c718 Makefile: Fix typo.
Fixes:

make: *** No rule to make target 'build/bin/BootROMs/sgb_boot2.bin', needed by 'bootroms'.  Stop.
2019-01-05 17:54:14 -08:00
Lior Halphon
112a174f4a Proper window minimum size handling 2019-01-05 23:58:18 +02:00
Lior Halphon
7b36ee10a4 Merge branch 'master' into sgb 2019-01-05 19:00:22 +02:00
Lior Halphon
ae959cd878 ATTR_LIN and ATTR_DIV 2019-01-05 18:59:50 +02:00
Lior Halphon
4051f190a5 Cache cycles_per_sample to avoid FP arithmetic 2019-01-01 00:42:40 +02:00
Lior Halphon
9d947c7ce6 Unroll some APU loops 2018-12-31 23:09:56 +02:00
Lior Halphon
af0430dbc5 Unroll some loops in PPU code, more efficient timer handling 2018-12-31 22:06:20 +02:00
Lior Halphon
21eb96a2f5 Joypad multiplayer support (Cocoa) 2018-12-15 18:55:41 +02:00
Lior Halphon
7b02b3cb89 Fix automation 2018-12-15 18:01:30 +02:00
Lior Halphon
612cd07fb3 Fixed emulation of echo RAM 2018-12-12 23:44:00 +02:00
Lior Halphon
e8dfc18d11 Multiplayer SGB support in Cocoa (Keyboard only) 2018-12-05 00:00:16 +02:00
Lior Halphon
ea09dfc888 Fixed multiplayer SGB mode 2018-12-04 23:46:30 +02:00
Lior Halphon
241577a7f1 Merge branch 'master' into sgb 2018-12-02 00:15:07 +02:00
Lior Halphon
b852add773 Minor refinements to the icon 2018-12-01 22:43:35 +02:00
Lior Halphon
a1c39173dd SGB2 boot ROM 2018-12-01 17:28:57 +02:00
Lior Halphon
cbbe3fe207 Revision selection 2018-12-01 17:16:50 +02:00
Lior Halphon
51b7780d83 Redesign the preferences window 2018-12-01 17:16:29 +02:00
Lior Halphon
b1a2e45168 Improvements to the SGB animation 2018-12-01 13:39:43 +02:00
Lior Halphon
6d28e74667 Color 0 must always be shared 2018-11-24 15:53:53 +02:00
Lior Halphon
4b93f89763 Correct emulation of color masks 2018-11-24 15:42:54 +02:00
Lior Halphon
389d8ae045 Halt the CPU while the SGB animation is playing 2018-11-24 13:34:07 +02:00
Lior Halphon
2d6d1e6325 SGB boot animation 2018-11-24 13:21:00 +02:00
Lior Halphon
b3166135eb Clean up that crashing mess I made 2018-11-23 19:59:15 +02:00
Lior Halphon
558f9b9bae Updated SGB border, add “2” to SGB2 2018-11-23 14:16:48 +02:00
Lior Halphon
3ba1364d60 Fixed a boot ROM bug that made a few Nintendo games use incorrect object palettes 2018-11-23 01:09:14 +02:00
Lior Halphon
aaafd482cc Fixed Cocoa OpenGL regression, it was completely broken 2018-11-22 22:59:29 +02:00
Anders Conbere
a7d4c091a0
add FAQ file 2018-11-20 10:04:12 -08:00
Lior Halphon
6160f513aa CRT filter 2018-11-19 18:52:11 +02:00
Lior Halphon
67d52b78b6 Handling interrupted SGB commands 2018-11-17 12:26:07 +02:00
Lior Halphon
af5ef50cf9 Fixing default border 2018-11-17 01:39:38 +02:00
Lior Halphon
deb5e21842 More colorization commands 2018-11-17 00:44:18 +02:00
Lior Halphon
b698ce5d95 Correctly emulate SGB border color 0 2018-11-17 00:44:07 +02:00
Lior Halphon
e5e7ce8203 Basic colorization 2018-11-16 22:05:35 +02:00
Lior Halphon
d42cbcdee2 Palette transfer functions 2018-11-16 19:11:21 +02:00
Lior Halphon
91a3091b2e Build fix 2018-11-16 17:41:23 +02:00
Lior Halphon
2710939e1e That should be an inc file 2018-11-16 17:38:53 +02:00
Lior Halphon
595907cae2 Border fade animation 2018-11-16 17:36:21 +02:00
Lior Halphon
69ac36cca1 Add default SGB border 2018-11-16 17:22:57 +02:00
Lior Halphon
398148f7ea Basic SGB border support 2018-11-16 16:04:40 +02:00
Lior Halphon
382d9f8898 MASK_EN support 2018-11-16 12:42:52 +02:00
Lior Halphon
2f2b792edf SGB save states 2018-11-16 01:53:01 +02:00
Lior Halphon
634a54c046 SGB resolution support (Cocoa only so far) 2018-11-15 00:21:21 +02:00
Lior Halphon
6ba5cfbeef Support for multi-packet SGB commands 2018-11-13 23:45:26 +02:00
Lior Halphon
7735d638c6 Multiplayer SGB APIs/SGB detection 2018-11-12 00:37:06 +02:00
Lior Halphon
5c581651ce Handle the SGB header commands, disable SGB functions if needed. 2018-11-11 22:50:00 +02:00
Lior Halphon
44891d5c4a Initial code to support SGB, command “parsing”, replacement SGB boot ROM 2018-11-11 01:16:32 +02:00
Lior Halphon
a47e3cc62c Remove code duplication in the QL fast boot ROM, should fix some glitched thumbnails 2018-11-10 21:10:09 +02:00
Lior Halphon
7ffed9c43c Reconnect the joypad when SameBoy starts directly to a ROM (fixes #131) 2018-11-10 19:39:57 +02:00
Lior Halphon
94136f5741 Adjust DAC attributes to fix LADX’s crackling audio (Fixes #125) while keeping Cannon Fodder’s buzzing reasonable (Proper audio measurements still required) 2018-11-10 19:14:18 +02:00
Lior Halphon
453673a2a6 Apply the SDL 2.0.6 audio workaround to everything except Windows, check the linked version instead of the headers version. Fixes #130 2018-11-10 18:58:42 +02:00
Lior Halphon
969fb5a9d8 Merge branches 'master' and 'master' of https://github.com/LIJI32/SameBoy 2018-11-10 16:33:04 +02:00
Lior Halphon
bc48c9bc26 Added command line fullscreen flag to the SDL port, closes #126 2018-11-10 16:32:45 +02:00
Lior Halphon
06ff367fdb
Merge pull request #127 from libretro/master
don't reinit on audio filter change or color correction
2018-11-10 16:18:55 +02:00
Lior Halphon
81582574c1
Merge pull request #129 from NieDzejkob/configurable-paths
Add a build-time option to change the resources directory.
2018-11-10 00:25:22 +02:00
NieDzejkob
91904df5e8
Add a build-time option to change the resources directory.
Normally, SameBoy would use executable-relative paths for any
resource files, which posed problems for packaging the software
by distributions, which usually prefer FHS-compliant file locations.

This commit makes it possible to specify an alternative base
directory with a compile-time environment variable.
2018-11-09 23:20:57 +01:00
Lior Halphon
bbffb49b8f
Merge pull request #128 from NieDzejkob/fix-linux-tester
Fix building the tester binary on Linux
2018-11-09 23:20:36 +02:00
NieDzejkob
d05ee826d4
Fix building the tester binary on Linux 2018-11-09 22:20:35 +01:00
radius
792b45d5dd don't reinit on audio filter change or color correction 2018-11-05 18:59:44 -05:00
Lior Halphon
a39b314378 Fixed silly APU regression (Noise volume envelope ran too fast) Fixes #121 2018-11-03 14:37:19 +02:00
Lior Halphon
96e9ea2d1e Fix libretro RTC support. Fixes #41 2018-11-03 13:18:08 +02:00
Lior Halphon
c9d6a1381f Cross emulator compatibility with RTC saves 2018-11-03 01:31:14 +02:00
Lior Halphon
64922fff4b Fixed a bug where channels 1 and 2 would start playing earlier than they should have if NRx4 was written to twice. Fixes #86. 2018-10-29 00:44:43 +02:00
Lior Halphon
9ffeef88d5 Trying to fix libretro achievements (#48) 2018-10-27 17:19:53 +03:00
Lior Halphon
3035f43428 Emulation of DAC charging, Fixes #46, #85, #88 and #89 2018-10-19 23:53:01 +03:00
Lior Halphon
4276549acd Research notes TODOs 2018-10-19 01:02:27 +03:00
Lior Halphon
324201f336 Correct emulation of switching the DACs on and off. Fixes #100 and #87 2018-10-17 20:35:29 +03:00
Lior Halphon
839de39c1f Fix clang build 2018-10-14 14:57:09 +03:00
Lior Halphon
0f19db5e8e
Merge pull request #120 from RobLoach/ignore-warnings
Ignore multichar and int-in-bool-context warnings
2018-10-14 00:25:44 +03:00
Rob Loach
7a6d6c3850
Ignore multichar and int-in-bool-context warnings 2018-10-13 17:19:05 -04:00
Lior Halphon
63fd5b4c10
Merge pull request #113 from RobLoach/patch-1
Use clang only if available
2018-10-13 14:16:51 +03:00
Rob Loach
86005bcfb8
Update Makefile to use clang if it's available 2018-10-12 20:14:34 -04:00
Lior Halphon
e9b78b6370
Merge pull request #114 from RobLoach/patch-2
Fix control reaches end of non-void function
2018-10-12 17:10:11 +03:00
Rob Loach
2da7a3f7fb
Fix the return value of read_lvalue to be 0 2018-10-12 10:09:30 -04:00
Rob Loach
e834d32b8e
Update switch to just return at the end instead 2018-10-12 09:41:25 -04:00
Lior Halphon
f8609e0279
Merge pull request #117 from RobLoach/patch-5
Fix parentheses around ‘+’ in operand of ‘&’
2018-10-12 13:12:13 +03:00
Rob Loach
ec41e87cf1
Update logic behind params 2018-10-11 22:39:43 -04:00
Rob Loach
b8825127fd
Fix parentheses around ‘+’ in operand of ‘&’
```
Core/z80_cpu.c: In function ‘add_hl_rr’:
Core/z80_cpu.c:341:31: error: suggest parentheses around ‘+’ in operand of ‘&’ [-Werror=parentheses]
     if ( ((unsigned long) hl) + ((unsigned long) rr) & 0x10000) {
          ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
```
2018-10-11 22:37:26 -04:00
Rob Loach
f4ee044347
Fix control reaches end of non-void function
This change makes it so that there is a return value when a kind doens't match. Allows -Werror=return-type to pass.

```
Core/debugger.c: In function ‘read_lvalue’:
Core/debugger.c:239:1: error: control reaches end of non-void function [-Werror=return-type]
 }
```
2018-10-11 22:17:16 -04:00
Rob Loach
7854686903
Remove redefinition of CC
Redefining CC isn't a standard thing to do in Makefiles. See more information about this over at:
https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
2018-10-11 21:54:04 -04:00
Lior Halphon
9080a23913 Improved idle performance in the Cocoa port when using Metal 2018-10-11 18:43:31 +03:00
Lior Halphon
1b049b8f75 Fixing UI bugs in the Cocoa debugger. Console windows now display the ROM file name 2018-09-15 17:57:59 +03:00
Lior Halphon
11c148c851 Starting G/HDMA directly takes one more M-cycle (More research required) 2018-09-15 00:48:31 +03:00
Lior Halphon
dbc338a887 Compensate for prefetch in DIV’s initial value 2018-09-15 00:47:26 +03:00
Lior Halphon
629550c30b
Update .gitattributes 2018-09-10 19:02:45 +03:00
Lior Halphon
ec0a879a93 Correct emulation of enabling and disabling the volume envelope. Correct emulation of a glitch where the volume envelope ticks when it usually wouldn’t. 2018-09-10 16:59:59 +03:00
Lior Halphon
3151821e6d Fixed minor APU regression (Channels 1 and 2 were given no delay under certain circumstances) 2018-09-09 12:50:55 +03:00
Lior Halphon
57cc4809ba
Merge pull request #108 from AlvaroBurnett/master
Improve compatibility with the Unix tools included in Git for Windows.
2018-08-19 23:20:44 +03:00
Alvaro Burnett
83ab8efbd7 Improve compatibility with the Unix tools included in Git for Windows.
Previously the Makefile, when run on Windows, expected the uname command to report either "MINGW" or "windows32". This was unfortunate because the uname included in Git for Windows reports "MSYS".

With this change, the Makefile will work properly with any uname, whether it comes from MinGW, GnuWin32 or Git for Windows.
2018-08-19 22:07:16 +02:00
Lior Halphon
737c1e2a4f
Merge pull request #99 from max-m/daa-patch
Rewrite the DAA instruction
2018-07-22 20:07:30 +03:00
a36dd791ec
Rewrite the DAA instruction 2018-07-22 18:37:34 +02:00
Lior Halphon
f7b882f0e8 Whoops 2018-07-22 02:10:26 +03:00
Lior Halphon
b7426f93c0 Randomize object palettes. Slightly more accurate emulation of FF4C. 2018-07-20 23:23:47 +03:00
Lior Halphon
538038e49c Disable randomness in the automation for consistency 2018-07-20 12:35:15 +03:00
Lior Halphon
ce80acc818 Fixed HDMA timing )But still not verified) 2018-07-20 12:34:52 +03:00
Lior Halphon
b1cc55b786 Turns out Left/Right audio channels were flipped 2018-07-19 20:38:11 +03:00
Lior Halphon
c66b6fbafc Fixed an edge case with DAC discharge emulation 2018-07-16 23:08:25 +03:00
Lior Halphon
2e9e3424ec Document some revision differences 2018-07-14 21:52:54 +03:00
Lior Halphon
0145b790a3 Merge branch 'v0.11.x' 2018-07-11 20:08:33 +03:00
Lior Halphon
0783f131b8 Update version to v0.11.1 2018-07-11 20:07:54 +03:00
Lior Halphon
e5f4495ca0 Turns out the last Cocoa fix was neither reliable or actually working. 2018-07-11 19:48:54 +03:00
Lior Halphon
5f58323c01 Attempt to improve audio quality on frontend with big audio buffers 2018-07-10 21:33:03 +03:00
Lior Halphon
dc4c23c0da Worked around a macOS bug where fullscreen-mode SameBoy would render garbage on High Sierra. Fixed titlebar color when using the ugly Yosemite theme. 2018-07-10 20:35:07 +03:00
Lior Halphon
afcb7b8579 Fixed a regression where DMG mode on CGB would not activate on most DMG games. Fixes #98 2018-07-10 20:28:36 +03:00
Lior Halphon
dc5cb71c22 Emulate CGB-C’s quirky LFSR function 2018-07-04 21:55:12 +03:00
Lior Halphon
f3437d7cc0 Added todo 2018-07-03 23:47:50 +03:00
Lior Halphon
b7b35c9b59 CGB-C timing 2018-07-03 22:25:09 +03:00
Lior Halphon
0a78f735d3 Fetcher Y is not cached on CGB-C 2018-07-03 22:14:53 +03:00
Lior Halphon
18ae18a95c LYC bit on CGB-C 2018-07-03 21:56:32 +03:00
Lior Halphon
a7aabca618 Starting to add CGB-C support 2018-07-03 21:43:46 +03:00
Lior Halphon
47a74cb6c3 Randomize initial RAM values. Closes #82 2018-06-30 16:53:28 +03:00
Lior Halphon
d9dfbcd199 Updated version to 0.11, updated README 2018-06-29 13:51:01 +03:00
Lior Halphon
81662e954b Convert the Windows .rc file to UTF-16 (Seems like UTF-8 support is broken in rc) 2018-06-29 13:17:27 +03:00
Lior Halphon
045c863117 Fixed Windows build 2018-06-29 13:05:08 +03:00
Lior Halphon
32443a9675 Improved analog stick controls in both ports. Affects #34? 2018-06-26 19:36:14 +03:00
Lior Halphon
3a4ed6fd40 Made SDL menus more consistent between keyboards and joypads (Closes #35) 2018-06-23 22:36:29 +03:00
Lior Halphon
82436ad838 Added proper joypad configuration in SDL (Closes #33), can now use Rewind/Slow-Motion from the joypad. 2018-06-23 22:27:05 +03:00
Lior Halphon
74abf61a08 Fixed a crash that happened when changing the rewind length in Cocoa 2018-06-23 11:50:08 +03:00
Lior Halphon
1915365b1a Added rewind and underclocking support to the SDL port. Joystick controls to be done. 2018-06-23 00:10:28 +03:00
Lior Halphon
2791775c5d Improvements to the lcd debugger command 2018-06-22 18:38:54 +03:00
Lior Halphon
6b2c25475f Removed limitations around debugger output in the Cocoa frontend 2018-06-21 21:23:57 +03:00
Lior Halphon
0ffb936885 The Cocoa port now allows selecting a folder containing boot ROM files 2018-06-21 00:48:02 +03:00
Lior Halphon
30f13bd28c More accurate CGB initial register values. Closes #80 2018-06-19 23:59:16 +03:00
Lior Halphon
6a7c084177 Fixed window regression 2018-06-18 21:57:01 +03:00
Lior Halphon
70d68a500e Stop annoying exceptions in the preferences window 2018-06-17 23:24:02 +03:00
Lior Halphon
a4bfb026a8 Fixed rounded corners in Metal 2018-06-17 23:16:34 +03:00
Lior Halphon
a37a0b1b00 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2018-06-16 23:52:39 +03:00
Lior Halphon
d81c23cb16 Fixed HDMA regression 2018-06-16 23:52:24 +03:00
Lior Halphon
59c1468e5a
Merge pull request #78 from fr500/master
libretro: allow changing model at runtime again, also do not reset bo…
2018-06-16 20:39:38 +03:00
radius
d6879c4f8a libretro: allow changing model at runtime again, also do not reset both gameboys on model change in dual mode 2018-06-16 11:06:00 -05:00
Lior Halphon
ca9249d4db Prevent memory viewer errors on reset 2018-06-16 14:46:16 +03:00
Lior Halphon
bc876ec30c Whoops 2018-06-16 14:36:06 +03:00
Lior Halphon
45c73e0175 Replaced the is_cgb bool with a more future compatible model enum. Removed the GB_init_cgb API and replaced it with an extended GB_init and GB_switch_model_and_reset APIs that now receive a model parameter. Increased the struct version. 2018-06-16 13:59:33 +03:00
Lior Halphon
c286203640 Fixed potential black screen on Metal 2018-06-16 12:46:57 +03:00
Lior Halphon
968ff4879a Enable fast math 2018-06-16 00:08:24 +03:00
Lior Halphon
1c1cddb53e OpenGL fallback 2018-06-15 20:03:59 +03:00
Lior Halphon
a068b7b09f Fixed Metal warnings, made everything static for performance 2018-06-15 19:18:30 +03:00
Lior Halphon
cd045fde15 Scaling filters in Metal 2018-06-15 19:11:06 +03:00
Lior Halphon
4466a55de6 Output resolution parameter 2018-06-15 18:44:22 +03:00
Lior Halphon
da7c32cb10 No more globals in shaders 2018-06-15 18:22:09 +03:00
Lior Halphon
c6dba26d02 Simplify shaders 2018-06-15 18:08:54 +03:00
Lior Halphon
c1fcd1a0c0 Added frame blending 2018-06-15 13:58:50 +03:00
Lior Halphon
5b39cacc8a Basic Metal support. No OpenGL fallback, no shaders, no blending. 2018-06-15 13:26:53 +03:00
Lior Halphon
9a3d53ae51 Remove OpenGL specific code from GBView 2018-06-11 22:11:33 +03:00
265 changed files with 32792 additions and 7331 deletions

9
.gitattributes vendored
View File

@ -1 +1,10 @@
# Always use LF line endings for shaders
*.fsh text eol=lf
*.metal text eol=lf
HexFiend/* linguist-vendored HexFiend/* linguist-vendored
*.inc linguist-language=C
Core/*.h linguist-language=C
SDL/*.h linguist-language=C
Windows/*.h linguist-language=C
Cocoa/*.h linguist-language=Objective-C

25
.github/actions/LICENSE vendored Normal file
View File

@ -0,0 +1,25 @@
Blargg's Test ROMs by Shay Green <gblargg@gmail.com>
Acid2 tests by Matt Currie under MIT:
MIT License
Copyright (c) 2020 Matt Currie
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

BIN
.github/actions/cgb-acid2.gbc vendored Normal file

Binary file not shown.

BIN
.github/actions/cgb_sound.gb vendored Normal file

Binary file not shown.

BIN
.github/actions/dmg-acid2.gb vendored Normal file

Binary file not shown.

BIN
.github/actions/dmg_sound-2.gb vendored Executable file

Binary file not shown.

23
.github/actions/install_deps.sh vendored Executable file
View File

@ -0,0 +1,23 @@
case `echo $1 | cut -d '-' -f 1` in
ubuntu)
sudo apt-get -qq update
sudo apt-get install -yq bison libpng-dev pkg-config libsdl2-dev
(
cd `mktemp -d`
curl -L https://github.com/rednex/rgbds/archive/v0.4.0.zip > rgbds.zip
unzip rgbds.zip
cd rgbds-*
make -sj
sudo make install
cd ..
rm -rf *
)
;;
macos)
brew install rgbds sdl2
;;
*)
echo "Unsupported OS"
exit 1
;;
esac

BIN
.github/actions/oam_bug-2.gb vendored Executable file

Binary file not shown.

33
.github/actions/sanity_tests.sh vendored Executable file
View File

@ -0,0 +1,33 @@
set -e
./build/bin/tester/sameboy_tester --jobs 5 \
--length 45 .github/actions/cgb_sound.gb \
--length 10 .github/actions/cgb-acid2.gbc \
--length 10 .github/actions/dmg-acid2.gb \
--dmg --length 45 .github/actions/dmg_sound-2.gb \
--dmg --length 20 .github/actions/oam_bug-2.gb
mv .github/actions/dmg{,-mode}-acid2.bmp
./build/bin/tester/sameboy_tester \
--dmg --length 10 .github/actions/dmg-acid2.gb
set +e
FAILED_TESTS=`
shasum .github/actions/*.bmp | grep -E -v \(\
5283564df0cf5bb78a7a90aff026c1a4692fd39e\ \ .github/actions/cgb-acid2.bmp\|\
dbcc438dcea13b5d1b80c5cd06bda2592cc5d9e0\ \ .github/actions/cgb_sound.bmp\|\
0caadf9634e40247ae9c15ff71992e8f77bbf89e\ \ .github/actions/dmg-acid2.bmp\|\
a732077f98f43d9231453b1764d9f797a836924d\ \ .github/actions/dmg-mode-acid2.bmp\|\
c9e944b7e01078bdeba1819bc2fa9372b111f52d\ \ .github/actions/dmg_sound-2.bmp\|\
f0172cc91867d3343fbd113a2bb98100074be0de\ \ .github/actions/oam_bug-2.bmp\
\)`
if [ -n "$FAILED_TESTS" ] ; then
echo "Failed the following tests:"
echo $FAILED_TESTS | tr " " "\n" | grep -o -E "[^/]+\.bmp" | sed s/.bmp// | sort
exit 1
fi
echo Passed all tests

36
.github/workflows/sanity.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: "Bulidability and Sanity"
on: push
jobs:
sanity:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, ubuntu-18.04]
cc: [gcc, clang]
include:
- os: macos-latest
cc: clang
extra_target: cocoa
exclude:
- os: macos-latest
cc: gcc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install deps
shell: bash
run: |
./.github/actions/install_deps.sh ${{ matrix.os }}
- name: Build
run: |
${{ matrix.cc }} -v; (make -j sdl tester libretro ${{ matrix.extra_target }} CONF=release CC=${{ matrix.cc }} || (echo "==== Build Failed ==="; make sdl tester libretro ${{ matrix.extra_target }} CONF=release CC=${{ matrix.cc }}))
- name: Sanity tests
shell: bash
run: |
./.github/actions/sanity_tests.sh
- name: Upload binaries
uses: actions/upload-artifact@v1
with:
name: sameboy-canary-${{ matrix.os }}-${{ matrix.cc }}
path: build/bin

217
BESS.md Normal file
View File

@ -0,0 +1,217 @@
# BESS Best Effort Save State 1.0
## Motivation
BESS is a save state format specification designed to allow different emulators, as well as majorly different versions of the same emulator, to import save states from other BESS-compliant save states. BESS works by appending additional, implementation-agnostic information about the emulation state. This allows a single save state file to be read as both a fully-featured, implementation specific save state which includes detailed timing information; and as a portable "best effort" save state that represents a state accurately enough to be restored in casual use-cases.
## Specification
Every integer used in the BESS specification is stored in Little Endian encoding.
### BESS footer
BESS works by appending a detectable footer at the end of an existing save state format. The footer uses the following format:
| Offset from end of file | Content |
|-------------------------|-------------------------------------------------------|
| -8 | Offset to the first BESS Block, from the file's start |
| -4 | The ASCII string 'BESS' |
### BESS blocks
BESS uses a block format where each block contains the following header:
| Offset | Content |
|--------|---------------------------------------|
| 0 | A four-letter ASCII identifier |
| 4 | Length of the block, excluding header |
Every block is followed by another block, until the END block is reached. If an implementation encounters an unsupported block, it should be completely ignored (Should not have any effect and should not trigger a failure).
#### NAME block
The NAME block uses the `'NAME'` identifier, and is an optional block that contains the name of the emulator that created this save state. While optional, it is highly recommended to be included in every implementation it allows the user to know which emulator and version is compatible with the native save state format contained in this file. When used, this block should come first.
The length of the NAME block is variable, and it only contains the name and version of the originating emulator in ASCII.
#### INFO block
The INFO block uses the `'INFO'` identifier, and is an optional block that contains information about the ROM this save state originates from. When used, this block should come before `CORE` but after `NAME`. This block is 0x12 bytes long, and it follows this structure:
| Offset | Content |
|--------|--------------------------------------------------|
| 0x00 | Bytes 0x134-0x143 from the ROM (Title) |
| 0x10 | Bytes 0x14E-0x14F from the ROM (Global checksum) |
#### CORE block
The CORE block uses the `'CORE'` identifier, and is a required block that contains both core state information, as well as basic information about the BESS version used. This block must be the first block, unless the `NAME` or `INFO` blocks exist then it must come directly after them. An implementation should not enforce block order on blocks unknown to it for future compatibility.
The length of the CORE block is 0xD0 bytes, but implementations are expected to ignore any excess bytes. Following the BESS block header, the structure is as follows:
| Offset | Content |
|--------|----------------------------------------|
| 0x00 | Major BESS version as a 16-bit integer |
| 0x02 | Minor BESS version as a 16-bit integer |
Both major and minor versions should be 1. Implementations are expected to reject incompatible majors, but still attempt to read newer minor versions.
| Offset | Content |
|--------|----------------------------------------|
| 0x04 | A four-character ASCII model identifier |
BESS uses a four-character string to identify Game Boy models:
* The first letter represents mutually-incompatible families of models and is required. The allowed values are `'G'` for the original Game Boy family, `'S'` for the Super Game Boy family, and `'C'` for the Game Boy Color and Advance family.
* The second letter represents a specific model within the family, and is optional (If an implementation does not distinguish between specific models in a family, a space character may be used). The allowed values for family G are `'D'` for DMG and `'M'` for MGB; the allowed values for family S are `'N'` for NTSC, `'P'` for PAL, and `'2'` for SGB2; and the allowed values for family C are `'C'` for CGB, and `'A'` for the various GBA line models.
* The third letter represents a specific CPU revision within a model, and is optional (If an implementation does not distinguish between revisions, a space character may be used). The allowed values for model GD (DMG) are `'0'` and `'A'`, through `'C'`; the allowed values for model CC (CGB) are `'0'` and `'A'`, through `'E'`; the allowed values for model CA (AGB, AGS, GBP) are `'0'`, `'A'` and `'B'`; and for every other model this value must be a space character.
* The last character is used for padding and must be a space character.
For example; `'GD '` represents a DMG of an unspecified revision, `'S '` represents some model of the SGB family, and `'CCE '` represent a CGB using CPU revision E.
| Offset | Content |
|--------|--------------------------------------------------------|
| 0x08 | The value of the PC register |
| 0x0A | The value of the AF register |
| 0x0C | The value of the BC register |
| 0x0E | The value of the DE register |
| 0x10 | The value of the HL register |
| 0x12 | The value of the SP register |
| 0x14 | The value of IME (0 or 1) |
| 0x15 | The value of the IE register |
| 0x16 | Execution state (0 = running; 1 = halted; 2 = stopped) |
| 0x17 | Reserved, must be 0 |
| 0x18 | The values of every memory-mapped register (128 bytes) |
The values of memory-mapped registers should be written 'as-is' to memory as if the actual ROM wrote them, with the following exceptions and note:
* Unused registers have Don't-Care values which should be ignored
* Unused register bits have Don't-Care values which should be ignored
* If the model is CGB or newer, the value of KEY0 (FF4C) must be valid as it determines DMG mode
* Bit 2 determines DMG mode. A value of 0x04 usually denotes DMG mode, while a value of `0x80` usually denotes CGB mode.
* Object priority is derived from KEY0 (FF4C) instead of OPRI (FF6C) because OPRI can be modified after booting, but only the value of OPRI during boot ROM execution takes effect
* If a register doesn't exist on the emulated model (For example, KEY0 (FF4C) on a DMG), its value should be ignored.
* BANK (FF50) should be 0 if the boot ROM is still mapped, and 1 otherwise, and must be valid.
* Implementations should not start a serial transfer when writing the value of SB
* Similarly, no value of NRx4 should trigger a sound pulse on save state load
* And similarly again, implementations should not trigger DMA transfers when writing the values of DMA or HDMA5
* The value store for DIV will be used to set the internal divisor to `DIV << 8`
* Implementation should apply care when ordering the write operations (For example, writes to NR52 must come before writes to the other APU registers)
| Offset | Content |
|--------|--------------------------------------------------------------------|
| 0x98 | The size of RAM (32-bit integer) |
| 0x9C | The offset of RAM from file start (32-bit integer) |
| 0xA0 | The size of VRAM (32-bit integer) |
| 0xA4 | The offset of VRAM from file start (32-bit integer) |
| 0xA8 | The size of MBC RAM (32-bit integer) |
| 0xAC | The offset of MBC RAM from file start (32-bit integer) |
| 0xB0 | The size of OAM (=0xA0, 32-bit integer) |
| 0xB4 | The offset of OAM from file start (32-bit integer) |
| 0xB8 | The size of HRAM (=0x7F, 32-bit integer) |
| 0xBC | The offset of HRAM from file start (32-bit integer) |
| 0xC0 | The size of background palettes (=0x40 or 0, 32-bit integer) |
| 0xC4 | The offset of background palettes from file start (32-bit integer) |
| 0xC8 | The size of object palettes (=0x40 or 0, 32-bit integer) |
| 0xCC | The offset of object palettes from file start (32-bit integer) |
The contents of large buffers are stored outside of BESS structure so data from an implementation's native save state format can be reused. The offsets are absolute offsets from the save state file's start. Background and object palette sizes must be 0 for models prior to Game Boy Color.
An implementation needs handle size mismatches gracefully. For example, if too large MBC RAM size is specified, the superfluous data should be ignored. On the other hand, if a too small VRAM size is specified (For example, if it's a save state from an emulator emulating a CGB in DMG mode, and it didn't save the second CGB VRAM bank), the implementation is expected to set that extra bank to all zeros.
#### XOAM block
The XOAM block uses the `'XOAM'` identifier, and is an optional block that contains the data of extra OAM (addresses `0xFEA0-0xFEFF`). This block length must be `0x60`. Implementations that do not emulate this extra range are free to ignore the excess bytes, and to not create this block.
#### MBC block
The MBC block uses the `'MBC '` identifier, and is an optional block that is only used when saving states of ROMs that use an MBC. The length of this block is variable and must be divisible by 3.
This block contains an MBC-specific number of 3-byte-long pairs that represent the values of each MBC register. For example, for MBC5 the contents would look like:
| Offset | Content |
|--------|---------------------------------------|
| 0x0 | The value 0x0000 as a 16-bit integer |
| 0x2 | 0x0A if RAM is enabled, 0 otherwise |
| 0x3 | The value 0x2000 as a 16-bit integer |
| 0x5 | The lower 8 bits of the ROM bank |
| 0x6 | The value 0x3000 as a 16-bit integer |
| 0x8 | The bit 9 of the ROM bank |
| 0x9 | The value 0x4000 as a 16-bit integer |
| 0xB | The current RAM bank |
An implementation should parse this block as a series of writes to be made. Values outside the `0x0000-0x7FFF` and `0xA000-0xBFFF` ranges are not allowed. Implementations must perform the writes in order (i.e. not reverse, sorted, or any other transformation on their order)
#### RTC block
The RTC block uses the `'RTC '` identifier, and is an optional block that is used while emulating an MBC3 with an RTC. The contents of this block are identical to 64-bit RTC saves from VBA, which are also used by SameBoy and different emulators such as BGB.
The length of this block is 0x30 bytes long and it follows the following structure:
| Offset | Content |
|--------|------------------------------------------------------------------------|
| 0x00 | Current seconds (1 byte), followed by 3 bytes of padding |
| 0x04 | Current minutes (1 byte), followed by 3 bytes of padding |
| 0x08 | Current hours (1 byte), followed by 3 bytes of padding |
| 0x0C | Current days (1 byte), followed by 3 bytes of padding |
| 0x10 | Current high/overflow/running (1 byte), followed by 3 bytes of padding |
| 0x14 | Latched seconds (1 byte), followed by 3 bytes of padding |
| 0x18 | Latched minutes (1 byte), followed by 3 bytes of padding |
| 0x1C | Latched hours (1 byte), followed by 3 bytes of padding |
| 0x20 | Latched days (1 byte), followed by 3 bytes of padding |
| 0x24 | Latched high/overflow/running (1 byte), followed by 3 bytes of padding |
| 0x28 | UNIX timestamp at the time of the save state (64-bit) |
#### HUC3 block
The HUC3 block uses the `'HUC3'` identifier, and is an optional block that is used while emulating an HuC3 cartridge to store RTC and alarm information. The contents of this block are identical to HuC3 RTC saves from SameBoy.
The length of this block is 0x11 bytes long and it follows the following structure:
| Offset | Content |
|--------|-------------------------------------------------------|
| 0x00 | UNIX timestamp at the time of the save state (64-bit) |
| 0x08 | RTC minutes (16-bit) |
| 0x0A | RTC days (16-bit) |
| 0x0C | Scheduled alarm time minutes (16-bit) |
| 0x0E | Scheduled alarm time days (16-bit) |
| 0x10 | Alarm enabled flag (8-bits, either 0 or 1) |
#### SGB block
The SGB block uses the `'SGB '` identifier, and is an optional block that is only used while emulating an SGB or SGB2 *and* SGB commands enabled. Implementations must not save this block on other models or when SGB commands are disabled, and should assume SGB commands are disabled if this block is missing.
The length of this block is 0x39 bytes, but implementations should allow and ignore excess data in this block for extensions. The block follows the following structure:
| Offset | Content |
|--------|--------------------------------------------------------------------------------------------------------------------------|
| 0x00 | The size of the border tile data (=0x2000, 32-bit integer) |
| 0x04 | The offset of the border tile data (SNES tile format, 32-bit integer) |
| 0x08 | The size of the border tilemap (=0x800, 32-bit integer) |
| 0x0C | The offset of the border tilemap (LE 16-bit sequences, 32-bit integer) |
| 0x10 | The size of the border palettes (=0x80, 32-bit integer) |
| 0x14 | The offset of the border palettes (LE 16-bit sequences, 32-bit integer) |
| 0x18 | The size of active colorization palettes (=0x20, 32-bit integer) |
| 0x1C | The offset of the active colorization palettes (LE 16-bit sequences, 32-bit integer) |
| 0x20 | The size of RAM colorization palettes (=0x1000, 32-bit integer) |
| 0x24 | The offset of the RAM colorization palettes (LE 16-bit sequences, 32-bit integer) |
| 0x28 | The size of the attribute map (=0x168, 32-bit integer) |
| 0x2C | The offset of the attribute map (32-bit integer) |
| 0x30 | The size of the attribute files (=0xfd2, 32-bit integer) |
| 0x34 | The offset of the attribute files (32-bit integer) |
| 0x38 | Multiplayer status (1 byte); high nibble is player count (1, 2 or 4), low nibble is current player (Where Player 1 is 0) |
If only some of the size-offset pairs are available (for example, partial HLE SGB implementation), missing fields are allowed to have 0 as their size, and implementations are expected to fall back to a sane default.
#### END block
The END block uses the `'END '` identifier, and is a required block that marks the end of BESS data. Naturally, it must be the last block. The length of the END block must be 0.
## Validation and Failures
Other than previously specified required fail conditions, an implementation is free to decide what format errors should abort the loading of a save file. Structural errors (e.g. a block with an invalid length, a file offset that is outside the file's range, or a missing END block) should be considered as irrecoverable errors. Other errors that are considered fatal by SameBoy's implementation:
* Duplicate CORE block
* A known block, other than NAME, appearing before CORE
* An invalid length for the XOAM, RTC, SGB or HUC3 blocks
* An invalid length of MBC (not a multiple of 3)
* A write outside the $0000-$7FFF and $A000-$BFFF ranges in the MBC block
* An SGB block on a save state targeting another model
* An END block with non-zero length

BIN
BootROMs/SameBoyLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

2
BootROMs/cgb0_boot.asm Normal file
View File

@ -0,0 +1,2 @@
CGB0 EQU 1
include "cgb_boot.asm"

File diff suppressed because it is too large Load Diff

View File

@ -1,782 +1,2 @@
; Sameboy CGB bootstrap ROM FAST EQU 1
; Todo: use friendly names for HW registers instead of magic numbers include "cgb_boot.asm"
; Todo: add support for games that assume DMG boot logo (Such as X), like the
; original boot ROM.
SECTION "BootCode", ROM0[$0]
Start:
; Init stack pointer
ld sp, $fffe
xor a
; Clear memory VRAM
ld hl, $8000
call ClearMemoryPage
ld h, $d0
call ClearMemoryPage
; Clear OAM
ld hl, $fe00
ld c, $a0
xor a
.clearOAMLoop
ldi [hl], a
dec c
jr nz, .clearOAMLoop
; Init Audio
ld a, $80
ldh [$26], a
ldh [$11], a
ld a, $f3
ldh [$12], a
ldh [$25], a
ld a, $77
ldh [$24], a
ld hl, $FF30
; Init waveform
xor a
ld c, $10
.waveformLoop
ldi [hl], a
cpl
dec c
jr nz, .waveformLoop
; Init BG palette
ld a, $fc
ldh [$47], a
; Load logo from ROM.
; A nibble represents a 4-pixels line, 2 bytes represent a 4x4 tile, scaled to 8x8.
; Tiles are ordered left to right, top to bottom.
; These tiles are not used, but are required for DMG compatibility. This is done
; by the original CGB Boot ROM as well.
ld de, $104 ; Logo start
ld hl, $8010 ; This is where we load the tiles in VRAM
.loadLogoLoop
ld a, [de] ; Read 2 rows
ld b, a
call DoubleBitsAndWriteRow
call DoubleBitsAndWriteRow
inc de
ld a, e
xor $34 ; End of logo
jr nz, .loadLogoLoop
call ReadTrademarkSymbol
; Clear the second VRAM bank
ld a, 1
ldh [$4F], a
xor a
ld hl, $8000
call ClearMemoryPage
; Copy (unresized) ROM logo
ld de, $104
ld c, 6
.CGBROMLogoLoop
push bc
call ReadCGBLogoTile
pop bc
dec c
jr nz, .CGBROMLogoLoop
inc hl
call ReadTrademarkSymbol
; Load Tilemap
ld hl, $98C2
ld b, 3
ld a, 8
.tilemapLoop
ld c, $10
.tilemapRowLoop
ld [hl], a
push af
; Switch to second VRAM Bank
ld a, 1
ldh [$4F], a
ld a, 8
ld [hl], a
; Switch to back first VRAM Bank
xor a
ldh [$4F], a
pop af
ldi [hl], a
inc a
dec c
jr nz, .tilemapRowLoop
ld de, $10
add hl, de
dec b
jr nz, .tilemapLoop
cp $38
jr nz, .doneTilemap
ld hl, $99a7
ld b, 1
ld c, 7
jr .tilemapRowLoop
.doneTilemap
; Clear Palettes
ld c, 64
ld hl, BgPalettes
ld a, $FF
.clearPalettesLoop:
ldi [hl], a
dec c
jr nz, .clearPalettesLoop
ld hl, BgPalettes
ld d, 64 ; Length of write
ld e, 0 ; Index of write
call LoadBGPalettes
; Turn on LCD
ld a, $91
ldh [$40], a
call Preboot
; Will be filled with NOPs
SECTION "BootGame", ROM0[$fe]
BootGame:
ldh [$50], a
SECTION "MoreStuff", ROM0[$200]
; Game Palettes Data
TitleChecksums:
db $00 ; Default
db $88 ; ALLEY WAY
db $16 ; YAKUMAN
db $36 ; BASEBALL, (Game and Watch 2)
db $D1 ; TENNIS
db $DB ; TETRIS
db $F2 ; QIX
db $3C ; DR.MARIO
db $8C ; RADARMISSION
db $92 ; F1RACE
db $3D ; YOSSY NO TAMAGO
db $5C ;
db $58 ; X
db $C9 ; MARIOLAND2
db $3E ; YOSSY NO COOKIE
db $70 ; ZELDA
db $1D ;
db $59 ;
db $69 ; TETRIS FLASH
db $19 ; DONKEY KONG
db $35 ; MARIO'S PICROSS
db $A8 ;
db $14 ; POKEMON RED, (GAMEBOYCAMERA G)
db $AA ; POKEMON GREEN
db $75 ; PICROSS 2
db $95 ; YOSSY NO PANEPON
db $99 ; KIRAKIRA KIDS
db $34 ; GAMEBOY GALLERY
db $6F ; POCKETCAMERA
db $15 ;
db $FF ; BALLOON KID
db $97 ; KINGOFTHEZOO
db $4B ; DMG FOOTBALL
db $90 ; WORLD CUP
db $17 ; OTHELLO
db $10 ; SUPER RC PRO-AM
db $39 ; DYNABLASTER
db $F7 ; BOY AND BLOB GB2
db $F6 ; MEGAMAN
db $A2 ; STAR WARS-NOA
db $49 ;
db $4E ; WAVERACE
db $43 | $80 ;
db $68 ; LOLO2
db $E0 ; YOSHI'S COOKIE
db $8B ; MYSTIC QUEST
db $F0 ;
db $CE ; TOPRANKINGTENNIS
db $0C ; MANSELL
db $29 ; MEGAMAN3
db $E8 ; SPACE INVADERS
db $B7 ; GAME&WATCH
db $86 ; DONKEYKONGLAND95
db $9A ; ASTEROIDS/MISCMD
db $52 ; STREET FIGHTER 2
db $01 ; DEFENDER/JOUST
db $9D ; KILLERINSTINCT95
db $71 ; TETRIS BLAST
db $9C ; PINOCCHIO
db $BD ;
db $5D ; BA.TOSHINDEN
db $6D ; NETTOU KOF 95
db $67 ;
db $3F ; TETRIS PLUS
db $6B ; DONKEYKONGLAND 3
; For these games, the 4th letter is taken into account
FirstChecksumWithDuplicate:
; Let's play hangman!
db $B3 ; ???[B]????????
db $46 ; SUP[E]R MARIOLAND
db $28 ; GOL[F]
db $A5 ; SOL[A]RSTRIKER
db $C6 ; GBW[A]RS
db $D3 ; KAE[R]UNOTAMENI
db $27 ; ???[B]????????
db $61 ; POK[E]MON BLUE
db $18 ; DON[K]EYKONGLAND
db $66 ; GAM[E]BOY GALLERY2
db $6A ; DON[K]EYKONGLAND 2
db $BF ; KID[ ]ICARUS
db $0D ; TET[R]IS2
db $F4 ; ???[-]????????
db $B3 ; MOG[U]RANYA
db $46 ; ???[R]????????
db $28 ; GAL[A]GA&GALAXIAN
db $A5 ; BT2[R]AGNAROKWORLD
db $C6 ; KEN[ ]GRIFFEY JR
db $D3 ; ???[I]????????
db $27 ; MAG[N]ETIC SOCCER
db $61 ; VEG[A]S STAKES
db $18 ; ???[I]????????
db $66 ; MIL[L]I/CENTI/PEDE
db $6A ; MAR[I]O & YOSHI
db $BF ; SOC[C]ER
db $0D ; POK[E]BOM
db $F4 ; G&W[ ]GALLERY
db $B3 ; TET[R]IS ATTACK
ChecksumsEnd:
PalettePerChecksum:
; | $80 means game requires DMG boot tilemap
db 0 ; Default Palette
db 4 ; ALLEY WAY
db 5 ; YAKUMAN
db 35 ; BASEBALL, (Game and Watch 2)
db 34 ; TENNIS
db 3 ; TETRIS
db 31 ; QIX
db 15 ; DR.MARIO
db 10 ; RADARMISSION
db 5 ; F1RACE
db 19 ; YOSSY NO TAMAGO
db 36 ;
db 7 | $80 ; X
db 37 ; MARIOLAND2
db 30 ; YOSSY NO COOKIE
db 44 ; ZELDA
db 21 ;
db 32 ;
db 31 ; TETRIS FLASH
db 20 ; DONKEY KONG
db 5 ; MARIO'S PICROSS
db 33 ;
db 13 ; POKEMON RED, (GAMEBOYCAMERA G)
db 14 ; POKEMON GREEN
db 5 ; PICROSS 2
db 29 ; YOSSY NO PANEPON
db 5 ; KIRAKIRA KIDS
db 18 ; GAMEBOY GALLERY
db 9 ; POCKETCAMERA
db 3 ;
db 2 ; BALLOON KID
db 26 ; KINGOFTHEZOO
db 25 ; DMG FOOTBALL
db 25 ; WORLD CUP
db 41 ; OTHELLO
db 42 ; SUPER RC PRO-AM
db 26 ; DYNABLASTER
db 45 ; BOY AND BLOB GB2
db 42 ; MEGAMAN
db 45 ; STAR WARS-NOA
db 36 ;
db 38 ; WAVERACE
db 26 ;
db 42 ; LOLO2
db 30 ; YOSHI'S COOKIE
db 41 ; MYSTIC QUEST
db 34 ;
db 34 ; TOPRANKINGTENNIS
db 5 ; MANSELL
db 42 ; MEGAMAN3
db 6 ; SPACE INVADERS
db 5 ; GAME&WATCH
db 33 ; DONKEYKONGLAND95
db 25 ; ASTEROIDS/MISCMD
db 42 ; STREET FIGHTER 2
db 42 ; DEFENDER/JOUST
db 40 ; KILLERINSTINCT95
db 2 ; TETRIS BLAST
db 16 ; PINOCCHIO
db 25 ;
db 42 ; BA.TOSHINDEN
db 42 ; NETTOU KOF 95
db 5 ;
db 0 ; TETRIS PLUS
db 39 ; DONKEYKONGLAND 3
db 36 ;
db 22 ; SUPER MARIOLAND
db 25 ; GOLF
db 6 ; SOLARSTRIKER
db 32 ; GBWARS
db 12 ; KAERUNOTAMENI
db 36 ;
db 11 ; POKEMON BLUE
db 39 ; DONKEYKONGLAND
db 18 ; GAMEBOY GALLERY2
db 39 ; DONKEYKONGLAND 2
db 24 ; KID ICARUS
db 31 ; TETRIS2
db 50 ;
db 17 ; MOGURANYA
db 46 ;
db 6 ; GALAGA&GALAXIAN
db 27 ; BT2RAGNAROKWORLD
db 0 ; KEN GRIFFEY JR
db 47 ;
db 41 ; MAGNETIC SOCCER
db 41 ; VEGAS STAKES
db 0 ;
db 0 ; MILLI/CENTI/PEDE
db 19 ; MARIO & YOSHI
db 34 ; SOCCER
db 23 ; POKEBOM
db 18 ; G&W GALLERY
db 29 ; TETRIS ATTACK
Dups4thLetterArray:
db "BEFAARBEKEK R-URAR INAILICE R"
; We assume the last three arrays fit in the same $100 byte page!
PaletteCombinations:
palette_comb: MACRO ; Obj0, Obj1, Bg
db \1 * 8, \2 * 8, \3 *8
ENDM
palette_comb 4, 4, 29
palette_comb 18, 18, 18
palette_comb 20, 20, 20
palette_comb 24, 24, 24
palette_comb 9, 9, 9
palette_comb 0, 0, 0
palette_comb 27, 27, 27
palette_comb 5, 5, 5
palette_comb 12, 12, 12
palette_comb 26, 26, 26
palette_comb 16, 8, 8
palette_comb 4, 28, 28
palette_comb 4, 2, 2
palette_comb 3, 4, 4
palette_comb 4, 29, 29
palette_comb 28, 4, 28
palette_comb 2, 17, 2
palette_comb 16, 16, 8
palette_comb 4, 4, 7
palette_comb 4, 4, 18
palette_comb 4, 4, 20
palette_comb 19, 19, 9
palette_comb 3, 3, 11
palette_comb 17, 17, 2
palette_comb 4, 4, 2
palette_comb 4, 4, 3
palette_comb 28, 28, 0
palette_comb 3, 3, 0
palette_comb 0, 0, 1
palette_comb 18, 22, 18
palette_comb 20, 22, 20
palette_comb 24, 22, 24
palette_comb 16, 22, 8
palette_comb 17, 4, 13
palette_comb 27, 0, 14
palette_comb 27, 4, 15
palette_comb 19, 22, 9
palette_comb 16, 28, 10
palette_comb 4, 23, 28
palette_comb 17, 22, 2
palette_comb 4, 0, 2
palette_comb 4, 28, 3
palette_comb 28, 3, 0
palette_comb 3, 28, 4
palette_comb 21, 28, 4
palette_comb 3, 28, 0
palette_comb 25, 3, 28
palette_comb 0, 28, 8
palette_comb 4, 3, 28
palette_comb 28, 3, 6
palette_comb 4, 28, 29
; Sameboy "Exclusives"
palette_comb 30, 30, 30 ; CGA
palette_comb 31, 31, 31 ; DMG LCD
palette_comb 28, 4, 1
palette_comb 0, 0, 2
Palettes:
dw $7FFF, $32BF, $00D0, $0000
dw $639F, $4279, $15B0, $04CB
dw $7FFF, $6E31, $454A, $0000
dw $7FFF, $1BEF, $0200, $0000
dw $7FFF, $421F, $1CF2, $0000
dw $7FFF, $5294, $294A, $0000
dw $7FFF, $03FF, $012F, $0000
dw $7FFF, $03EF, $01D6, $0000
dw $7FFF, $42B5, $3DC8, $0000
dw $7E74, $03FF, $0180, $0000
dw $67FF, $77AC, $1A13, $2D6B
dw $7ED6, $4BFF, $2175, $0000
dw $53FF, $4A5F, $7E52, $0000
dw $4FFF, $7ED2, $3A4C, $1CE0
dw $03ED, $7FFF, $255F, $0000
dw $036A, $021F, $03FF, $7FFF
dw $7FFF, $01DF, $0112, $0000
dw $231F, $035F, $00F2, $0009
dw $7FFF, $03EA, $011F, $0000
dw $299F, $001A, $000C, $0000
dw $7FFF, $027F, $001F, $0000
dw $7FFF, $03E0, $0206, $0120
dw $7FFF, $7EEB, $001F, $7C00
dw $7FFF, $3FFF, $7E00, $001F
dw $7FFF, $03FF, $001F, $0000
dw $03FF, $001F, $000C, $0000
dw $7FFF, $033F, $0193, $0000
dw $0000, $4200, $037F, $7FFF
dw $7FFF, $7E8C, $7C00, $0000
dw $7FFF, $1BEF, $6180, $0000
; Sameboy "Exclusives"
dw $7FFF, $7FEA, $7D5F, $0000 ; CGA 1
dw $1B77, $0AD2, $25E9, $1545 ; DMG LCD
KeyCombinationPalettes
db 1 ; Right
db 48 ; Left
db 5 ; Up
db 8 ; Down
db 0 ; Right + A
db 40 ; Left + A
db 43 ; Up + A
db 3 ; Down + A
db 6 ; Right + B
db 7 ; Left + B
db 28 ; Up + B
db 49 ; Down + B
; Sameboy "Exclusives"
db 51 ; Right + A + B
db 52 ; Left + A + B
db 53 ; Up + A + B
db 54 ; Down + A + B
TrademarkSymbol:
db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c
DMGPalettes:
dw $7FFF, $32BF, $00D0, $0000
; Helper Functions
DoubleBitsAndWriteRow:
; Double the most significant 4 bits, b is shifted by 4
ld a, 4
ld c, 0
.doubleCurrentBit
sla b
push af
rl c
pop af
rl c
dec a
jr nz, .doubleCurrentBit
ld a, c
; Write as two rows
ldi [hl], a
inc hl
ldi [hl], a
inc hl
ret
WaitFrame:
push hl
ld hl, $FF0F
res 0, [hl]
.wait
bit 0, [hl]
jr z, .wait
pop hl
ret
PlaySound:
ldh [$13], a
ld a, $87
ldh [$14], a
ret
; Clear from HL to HL | 0x2000
ClearMemoryPage:
ldi [hl], a
bit 5, h
jr z, ClearMemoryPage
ret
; c = $f0 for even lines, $f for odd lines.
ReadTileLine:
ld a, [de]
and c
ld b, a
inc e
inc e
ld a, [de]
dec e
dec e
and c
swap a
or b
bit 0, c
jr z, .dontSwap
swap a
.dontSwap
inc hl
ldi [hl], a
ret
ReadCGBLogoHalfTile:
ld c, $f0
call ReadTileLine
ld c, $f
call ReadTileLine
inc e
ld c, $f0
call ReadTileLine
ld c, $f
call ReadTileLine
inc e
ret
ReadCGBLogoTile:
call ReadCGBLogoHalfTile
ld a, e
add a, 22
ld e, a
call ReadCGBLogoHalfTile
ld a, e
sub a, 22
ld e, a
ret
ReadTrademarkSymbol:
ld de, TrademarkSymbol
ld c,$08
.loadTrademarkSymbolLoop:
ld a,[de]
inc de
ldi [hl],a
inc hl
dec c
jr nz, .loadTrademarkSymbolLoop
ret
LoadObjPalettes:
ld c, $6A
jr LoadPalettes
LoadBGPalettes:
ld c, $68
LoadPalettes:
ld a, $80
or e
ld [c], a
inc c
.loop
ld a, [hli]
ld [c], a
dec d
jr nz, .loop
ret
Preboot:
call ClearVRAMViaHDMA
; Select the first bank
xor a
ldh [$4F], a
call ClearVRAMViaHDMA
ld a, [$143]
bit 7, a
jr nz, .cgbGame
call EmulateDMG
.cgbGame
ldh [$4C], a ; One day, I will know what this switch does and how it differs from FF6C
ld a, $11
ret
EmulateDMG:
ld a, 1
ldh [$6C], a ; DMG Emulation
call GetPaletteIndex
bit 7, a
call nz, LoadDMGTilemap
and $7F
call WaitFrame
call LoadPalettesFromIndex
ld a, 4
ret
GetPaletteIndex:
ld a, [$14B] ; Old Licensee
cp $33
jr z, .newLicensee
cp 1 ; Nintendo
jr nz, .notNintendo
jr .doChecksum
.newLicensee
ld a, [$144]
cp "0"
jr nz, .notNintendo
ld a, [$145]
cp "1"
jr nz, .notNintendo
.doChecksum
ld hl, $134
ld c, $10
ld b, 0
.checksumLoop
ld a, [hli]
add b
ld b, a
dec c
jr nz, .checksumLoop
; c = 0
ld hl, TitleChecksums
.searchLoop
ld a, l
cp ChecksumsEnd & $FF
jr z, .notNintendo
ld a, [hli]
cp b
jr nz, .searchLoop
; We might have a match, Do duplicate/4th letter check
ld a, l
sub FirstChecksumWithDuplicate - TitleChecksums
jr c, .match ; Does not have a duplicate, must be a match!
; Has a duplicate; check 4th letter
push hl
ld a, l
add Dups4thLetterArray - FirstChecksumWithDuplicate - 1 ; -1 since hl was incremented
ld l, a
ld a, [hl]
pop hl
ld c, a
ld a, [$134 + 3] ; Get 4th letter
cp c
jr nz, .searchLoop ; Not a match, continue
.match
ld a, l
add PalettePerChecksum - TitleChecksums - 1; -1 since hl was incremented
ld l, a
ld a, [hl]
ret
.notNintendo
xor a
ret
LoadPalettesFromIndex: ; a = index of combination
ld b, a
; Multiply by 3
add b
add b
ld hl, PaletteCombinations
ld b, 0
ld c, a
add hl, bc
; Obj Palettes
ld e, 0
.loadObjPalette
ld a, [hli]
push hl
ld hl, Palettes
ld b, 0
ld c, a
add hl, bc
ld d, 8
call LoadObjPalettes
pop hl
bit 3, e
jr nz, .loadBGPalette
ld e, 8
jr .loadObjPalette
.loadBGPalette
;BG Palette
ld a, [hli]
ld hl, Palettes
ld b, 0
ld c, a
add hl, bc
ld d, 8
ld e, 0
call LoadBGPalettes
ret
ClearVRAMViaHDMA:
ld hl, $FF51
; Src
ld a, $D0
ld [hli], a
xor a
ld [hli], a
; Dest
ld a, $98
ld [hli], a
ld a, $A0
ld [hli], a
; Do it
ld a, $12
ld [hli], a
ret
LoadDMGTilemap:
push af
call WaitFrame
ld a,$19 ; Trademark symbol
ld [$9910], a ; ... put in the superscript position
ld hl,$992f ; Bottom right corner of the logo
ld c,$c ; Tiles in a logo row
.tilemapLoop
dec a
jr z, .tilemapDone
ldd [hl], a
dec c
jr nz, .tilemapLoop
ld l,$0f ; Jump to top row
jr .tilemapLoop
.tilemapDone
pop af
ret
SECTION "ROMMax", ROM0[$900]
; Prevent us from overflowing
ds 1
SECTION "RAM", WRAM0[$C000]
BgPalettes:
ds 8 * 4 * 2

View File

@ -1,4 +1,4 @@
; Sameboy CGB bootstrap ROM ; SameBoy DMG bootstrap ROM
; Todo: use friendly names for HW registers instead of magic numbers ; Todo: use friendly names for HW registers instead of magic numbers
SECTION "BootCode", ROM0[$0] SECTION "BootCode", ROM0[$0]
Start: Start:
@ -24,7 +24,7 @@ Start:
ldh [$24], a ldh [$24], a
; Init BG palette ; Init BG palette
ld a, $fc ld a, $54
ldh [$47], a ldh [$47], a
; Load logo from ROM. ; Load logo from ROM.
@ -69,13 +69,35 @@ Start:
jr .tilemapLoop jr .tilemapLoop
.tilemapDone .tilemapDone
ld a, 30
ldh [$ff42], a
; Turn on LCD ; Turn on LCD
ld a, $91 ld a, $91
ldh [$40], a ldh [$40], a
; Wait ~0.75 seconds ld d, (-119) & $FF
ld b, 45 ld c, 15
call WaitBFrames
.animate
call WaitFrame
ld a, d
sra a
sra a
ldh [$ff42], a
ld a, d
add c
ld d, a
ld a, c
cp 8
jr nz, .noPaletteChange
ld a, $A8
ldh [$47], a
.noPaletteChange
dec c
jr nz, .animate
ld a, $fc
ldh [$47], a
; Play first sound ; Play first sound
ld a, $83 ld a, $83
@ -86,12 +108,18 @@ Start:
ld a, $c1 ld a, $c1
call PlaySound call PlaySound
; Wait ~1.15 seconds
ld b, 70
; Wait ~1 second
ld b, 60
call WaitBFrames call WaitBFrames
; Set registers to match the original DMG boot ; Set registers to match the original DMG boot
IF DEF(MGB)
ld hl, $FFB0
ELSE
ld hl, $01B0 ld hl, $01B0
ENDC
push hl push hl
pop af pop af
ld hl, $014D ld hl, $014D

2
BootROMs/mgb_boot.asm Normal file
View File

@ -0,0 +1,2 @@
MGB EQU 1
include "dmg_boot.asm"

102
BootROMs/pb12.c Normal file
View File

@ -0,0 +1,102 @@
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
void opts(uint8_t byte, uint8_t *options)
{
*(options++) = byte | ((byte << 1) & 0xff);
*(options++) = byte & (byte << 1);
*(options++) = byte | ((byte >> 1) & 0xff);
*(options++) = byte & (byte >> 1);
}
void write_all(int fd, const void *buf, size_t count) {
while (count) {
ssize_t written = write(fd, buf, count);
if (written < 0) {
fprintf(stderr, "write");
exit(1);
}
count -= written;
buf += written;
}
}
int main()
{
static uint8_t source[0x4000];
size_t size = read(STDIN_FILENO, &source, sizeof(source));
unsigned pos = 0;
assert(size <= 0x4000);
while (size && source[size - 1] == 0) {
size--;
}
uint8_t literals[8];
size_t literals_size = 0;
unsigned bits = 0;
unsigned control = 0;
unsigned prev[2] = {-1, -1}; // Unsigned to allow "not set" values
while (true) {
uint8_t byte = 0;
if (pos == size){
if (bits == 0) break;
}
else {
byte = source[pos++];
}
if (byte == prev[0] || byte == prev[1]) {
bits += 2;
control <<= 1;
control |= 1;
control <<= 1;
if (byte == prev[1]) {
control |= 1;
}
}
else {
bits += 2;
control <<= 2;
uint8_t options[4];
opts(prev[1], options);
bool found = false;
for (unsigned i = 0; i < 4; i++) {
if (options[i] == byte) {
// 01 = modify
control |= 1;
bits += 2;
control <<= 2;
control |= i;
found = true;
break;
}
}
if (!found) {
literals[literals_size++] = byte;
}
}
prev[0] = prev[1];
prev[1] = byte;
if (bits >= 8) {
uint8_t outctl = control >> (bits - 8);
assert(outctl != 1);
write_all(STDOUT_FILENO, &outctl, 1);
write_all(STDOUT_FILENO, literals, literals_size);
bits -= 8;
control &= (1 << bits) - 1;
literals_size = 0;
}
}
uint8_t end_byte = 1;
write_all(STDOUT_FILENO, &end_byte, 1);
return 0;
}

2
BootROMs/sgb2_boot.asm Normal file
View File

@ -0,0 +1,2 @@
SGB2 EQU 1
include "sgb_boot.asm"

213
BootROMs/sgb_boot.asm Normal file
View File

@ -0,0 +1,213 @@
; SameBoy SGB bootstrap ROM
; Todo: use friendly names for HW registers instead of magic numbers
SECTION "BootCode", ROM0[$0]
Start:
; Init stack pointer
ld sp, $fffe
; Clear memory VRAM
ld hl, $8000
.clearVRAMLoop
ldi [hl], a
bit 5, h
jr z, .clearVRAMLoop
; Init Audio
ld a, $80
ldh [$26], a
ldh [$11], a
ld a, $f3
ldh [$12], a
ldh [$25], a
ld a, $77
ldh [$24], a
; Init BG palette to white
ld a, $0
ldh [$47], a
; Load logo from ROM.
; A nibble represents a 4-pixels line, 2 bytes represent a 4x4 tile, scaled to 8x8.
; Tiles are ordered left to right, top to bottom.
ld de, $104 ; Logo start
ld hl, $8010 ; This is where we load the tiles in VRAM
.loadLogoLoop
ld a, [de] ; Read 2 rows
ld b, a
call DoubleBitsAndWriteRow
call DoubleBitsAndWriteRow
inc de
ld a, e
xor $34 ; End of logo
jr nz, .loadLogoLoop
; Load trademark symbol
ld de, TrademarkSymbol
ld c,$08
.loadTrademarkSymbolLoop:
ld a,[de]
inc de
ldi [hl],a
inc hl
dec c
jr nz, .loadTrademarkSymbolLoop
; Set up tilemap
ld a,$19 ; Trademark symbol
ld [$9910], a ; ... put in the superscript position
ld hl,$992f ; Bottom right corner of the logo
ld c,$c ; Tiles in a logo row
.tilemapLoop
dec a
jr z, .tilemapDone
ldd [hl], a
dec c
jr nz, .tilemapLoop
ld l,$0f ; Jump to top row
jr .tilemapLoop
.tilemapDone
; Turn on LCD
ld a, $91
ldh [$40], a
ld a, $f1 ; Packet magic, increases by 2 for every packet
ldh [$80], a
ld hl, $104 ; Header start
xor a
ld c, a ; JOYP
.sendCommand
xor a
ld [c], a
ld a, $30
ld [c], a
ldh a, [$80]
call SendByte
push hl
ld b, $e
ld d, 0
.checksumLoop
call ReadHeaderByte
add d
ld d, a
dec b
jr nz, .checksumLoop
; Send checksum
call SendByte
pop hl
ld b, $e
.sendLoop
call ReadHeaderByte
call SendByte
dec b
jr nz, .sendLoop
; Done bit
ld a, $20
ld [c], a
ld a, $30
ld [c], a
; Update command
ldh a, [$80]
add 2
ldh [$80], a
ld a, $58
cp l
jr nz, .sendCommand
; Write to sound registers for DMG compatibility
ld c, $13
ld a, $c1
ld [c], a
inc c
ld a, 7
ld [c], a
; Init BG palette
ld a, $fc
ldh [$47], a
; Set registers to match the original SGB boot
IF DEF(SGB2)
ld a, $FF
ELSE
ld a, 1
ENDC
ld hl, $c060
; Boot the game
jp BootGame
ReadHeaderByte:
ld a, $4F
cp l
jr c, .zero
ld a, [hli]
ret
.zero:
inc hl
xor a
ret
SendByte:
ld e, a
ld d, 8
.loop
ld a, $10
rr e
jr c, .zeroBit
add a ; 10 -> 20
.zeroBit
ld [c], a
ld a, $30
ld [c], a
dec d
ret z
jr .loop
DoubleBitsAndWriteRow:
; Double the most significant 4 bits, b is shifted by 4
ld a, 4
ld c, 0
.doubleCurrentBit
sla b
push af
rl c
pop af
rl c
dec a
jr nz, .doubleCurrentBit
ld a, c
; Write as two rows
ldi [hl], a
inc hl
ldi [hl], a
inc hl
ret
WaitFrame:
push hl
ld hl, $FF0F
res 0, [hl]
.wait
bit 0, [hl]
jr z, .wait
pop hl
ret
TrademarkSymbol:
db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c
SECTION "BootGame", ROM0[$fe]
BootGame:
ldh [$50], a

79
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,79 @@
# SameBoy Coding and Contribution Guidelines
## Issues
GitHub Issues are the most effective way to report a bug or request a feature in SameBoy. When reporting a bug, make sure you use the latest stable release, and make sure you mention the SameBoy frontend (Cocoa, SDL, Libretro) and operating system you're using. If you're using Linux/BSD/etc, or you build your own copy of SameBoy for another reason, give as much details as possible on your environment.
If your bug involves a crash, please attach a crash log or a core dump. If you're using Linux/BSD/etc, or if you're using the Libretro core, please attach the `sameboy` binary (or `libretro_sameboy` library) in that case.
If your bug is a regression, it'd be extremely helpful if you can report the the first affected version. You get extra credits if you use `git bisect` to point the exact breaking commit.
If your bug is an emulation bug (Such as a failing test ROM), and you have access to a Game Boy you can test on, please confirm SameBoy is indeed behaving differently from hardware, and report both the emulated model and revision in SameBoy, and the hardware revision you're testing on.
If your issue is a feature request, demonstrating use cases can help me better prioritize it.
## Pull Requests
To allow quicker integration into SameBoy's master branch, contributors are asked to follow SameBoy's style and coding guidelines. Keep in mind that despite the seemingly strict guidelines, all pull requests are welcome not following the guidelines does not mean your pull request will not be accepted, but it will require manual tweaks from my side for integrating.
### Languages and Compilers
SameBoy's core, SDL frontend, Libretro frontend, and automatic tester (Folders `Core`, `SDL` & `OpenDialog`, `libretro`, and `Tester`; respectively) are all written in C11. The Cocoa frontend, SameBoy's fork of Hex Fiend, JoyKit and the Quick Look previewer (Folders `Cocoa`, `HexFiend`, `JoyKit` and `QuickLook`; respectively) are all written in ARC-enabled Objective-C. The SameBoot ROMs (Under `BootROMs`) are written in rgbds-flavor SM83 assembly, with build tools in C11. The shaders (inside `Shaders`) are written in a polyglot GLSL and Metal style, with a few GLSL- and Metal-specific sources. The build system uses standalone Make, in the GNU flavor. Avoid adding new languages (C++, Swift, Python, CMake...) to any of the existing sub-projects.
SameBoy's main target compiler is Clang, but GCC is also supported when targeting Linux and Libretro. Other compilers (e.g. MSVC) are not supported, and unless there's a good reason, there's no need to go out of your way to add specific support for them. Extensions that are supported by both compilers (Such as `typeof`) may be used if it makes sense. It's OK if you can't test one of these compilers yourself; once you push a commit, the CI bot will let you know if you broke something.
### Third Party Libraries and Tools
Avoid adding new required dependencies; run-time and compile-time dependencies alike. Most importantly, avoid linking against GPL licensed libraries (LGPL libraries are fine), so SameBoy can retain its MIT license.
### Spacing, Indentation and Formatting
In all files and languages (Other than Makefiles when required), 4 spaces are used for indentation. Unix line endings (`\n`) are used exclusively, even in Windows-specific source files. (`\r` and `\t` shouldn't appear in any source file). Opening braces belong on the same line as their control flow directive, and on their own line when following a function prototype. The `else` keyword always starts on its own line. The `case` keyword is indented relative to its `switch` block, and the code inside a `case` is indented relative to its label. A control flow keyword should have a space between it and the following `(`, commas should follow a space, and operator (except `.` and `->`) should be surrounded by spaces.
Control flow statements must use `{}`, with the exception of `if` statements that only contain a single `break`, `continue`, or trivial `return` statements. If `{}`s are omitted, the statement must be on the same line as the `if` condition. Functions that do not have any argument must be specified as `(void)`, as mandated by the C standard. The `sizeof` and `typeof` operators should be used as if they're functions (With `()`). `*`, when used to declare pointer types (including functions that return pointers), and when used to dereference a pointer, is attached to the right side (The variable name) not to the left, and not with spaces on both sides.
No strict limitations on a line's maximum width, but use your best judgement if you think a statement would benefit from an additional line break.
Well formatted code example:
```
static void my_function(void)
{
GB_something_t *thing = GB_function(&gb, GB_FLAG_ONE | GB_FLAG_TWO, sizeof(thing));
if (GB_is_thing(thing)) return;
switch (*thing) {
case GB_QUACK:
// Something
case GB_DUCK:
// Something else
}
}
```
Badly formatted code example:
```
static void my_function(){
GB_something_t* thing=GB_function(&gb , GB_FLAG_ONE|GB_FLAG_TWO , sizeof thing);
if( GB_is_thing ( thing ) )
return;
switch(* thing)
{
case GB_QUACK:
// Something
case GB_DUCK:
// Something else
}
}
```
### Other Coding Conventions
The primitive types to be used in SameBoy are `unsigned` and `signed` (Without the `int` keyword), the `(u)int*_t` types, `char *` for UTF-8 strings, `double` for non-integer numbers, and `bool` for booleans (Including in Objective-C code, avoid `BOOL`). As long as it's not mandated by a 3rd-party API (e.g. `int` when using file descriptors), avoid using other primitive types. Use `const` whenever possible.
Most C names should be `lower_case_snake_case`. Constants and macros use `UPPER_CASE_SNAKE_CASE`. Type definitions use a `_t` suffix. Type definitions, as well as non-static (exported) core symbols, should be prefixed with `GB_` (SameBoy's core is intended to be used as a library, so it shouldn't contaminate the global namespace without prefixes). Exported symbols that are only meant to be used by other parts of the core should still get the `GB_` prefix, but their header definition should be inside `#ifdef GB_INTERNAL`.
For Objective-C naming conventions, use Apple's conventions (Some old Objective-C code mixes these with the C naming convention; new code should use Apple's convention exclusively). The name prefix for SameBoy classes and constants is `GB`. JoyKit's prefix is `JOY`, and Hex Fiend's prefix is `HF`.
In all languages, prefer long, unambiguous names over short ambiguous ones.

View File

@ -1,10 +1,25 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface AppDelegate : NSObject <NSApplicationDelegate> @interface AppDelegate : NSObject <NSApplicationDelegate, NSUserNotificationCenterDelegate, NSMenuDelegate, WebUIDelegate, WebPolicyDelegate, WebFrameLoadDelegate>
@property IBOutlet NSWindow *preferencesWindow; @property (nonatomic, strong) IBOutlet NSWindow *preferencesWindow;
@property (nonatomic, strong) IBOutlet NSView *graphicsTab;
@property (nonatomic, strong) IBOutlet NSView *emulationTab;
@property (nonatomic, strong) IBOutlet NSView *audioTab;
@property (nonatomic, strong) IBOutlet NSView *controlsTab;
@property (nonatomic, strong) IBOutlet NSView *updatesTab;
- (IBAction)showPreferences: (id) sender; - (IBAction)showPreferences: (id) sender;
- (IBAction)toggleDeveloperMode:(id)sender; - (IBAction)toggleDeveloperMode:(id)sender;
- (IBAction)switchPreferencesTab:(id)sender;
@property (nonatomic, weak) IBOutlet NSMenuItem *linkCableMenuItem;
@property (nonatomic, strong) IBOutlet NSWindow *updateWindow;
@property (nonatomic, strong) IBOutlet WebView *updateChanges;
@property (nonatomic, strong) IBOutlet NSProgressIndicator *updatesSpinner;
@property (strong) IBOutlet NSButton *updatesButton;
@property (strong) IBOutlet NSTextField *updateProgressLabel;
@property (strong) IBOutlet NSButton *updateProgressButton;
@property (strong) IBOutlet NSWindow *updateProgressWindow;
@property (strong) IBOutlet NSProgressIndicator *updateProgressSpinner;
@end @end

View File

@ -1,19 +1,44 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#include "GBButtons.h" #include "GBButtons.h"
#include "GBView.h"
#include <Core/gb.h> #include <Core/gb.h>
#import <Carbon/Carbon.h> #import <Carbon/Carbon.h>
#import <JoyKit/JoyKit.h>
#import <WebKit/WebKit.h>
#define UPDATE_SERVER "https://sameboy.github.io"
static uint32_t color_to_int(NSColor *color)
{
color = [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
return (((unsigned)(color.redComponent * 0xFF)) << 16) |
(((unsigned)(color.greenComponent * 0xFF)) << 8) |
((unsigned)(color.blueComponent * 0xFF));
}
@implementation AppDelegate @implementation AppDelegate
{ {
NSWindow *preferences_window; NSWindow *preferences_window;
NSArray<NSView *> *preferences_tabs;
NSString *_lastVersion;
NSString *_updateURL;
NSURLSessionDownloadTask *_updateTask;
enum {
UPDATE_DOWNLOADING,
UPDATE_EXTRACTING,
UPDATE_WAIT_INSTALL,
UPDATE_INSTALLING,
UPDATE_FAILED,
} _updateState;
NSString *_downloadDirectory;
} }
- (void) applicationDidFinishLaunching:(NSNotification *)notification - (void) applicationDidFinishLaunching:(NSNotification *)notification
{ {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
for (unsigned i = 0; i < GBButtonCount; i++) { for (unsigned i = 0; i < GBButtonCount; i++) {
if ([[defaults objectForKey:button_to_preference_name(i)] isKindOfClass:[NSString class]]) { if ([[defaults objectForKey:button_to_preference_name(i, 0)] isKindOfClass:[NSString class]]) {
[defaults removeObjectForKey:button_to_preference_name(i)]; [defaults removeObjectForKey:button_to_preference_name(i, 0)];
} }
} }
[[NSUserDefaults standardUserDefaults] registerDefaults:@{ [[NSUserDefaults standardUserDefaults] registerDefaults:@{
@ -34,8 +59,38 @@
@"GBFilter": @"NearestNeighbor", @"GBFilter": @"NearestNeighbor",
@"GBColorCorrection": @(GB_COLOR_CORRECTION_EMULATE_HARDWARE), @"GBColorCorrection": @(GB_COLOR_CORRECTION_EMULATE_HARDWARE),
@"GBHighpassFilter": @(GB_HIGHPASS_REMOVE_DC_OFFSET), @"GBHighpassFilter": @(GB_HIGHPASS_REMOVE_DC_OFFSET),
@"GBRewindLength": @(10) @"GBRewindLength": @(10),
@"GBFrameBlendingMode": @([defaults boolForKey:@"DisableFrameBlending"]? GB_FRAME_BLENDING_MODE_DISABLED : GB_FRAME_BLENDING_MODE_ACCURATE),
@"GBDMGModel": @(GB_MODEL_DMG_B),
@"GBCGBModel": @(GB_MODEL_CGB_E),
@"GBSGBModel": @(GB_MODEL_SGB2),
@"GBRumbleMode": @(GB_RUMBLE_CARTRIDGE_ONLY),
@"GBVolume": @(1.0),
@"GBMBC7JoystickOverride": @NO,
@"GBMBC7AllowMouse": @YES,
}]; }];
[JOYController startOnRunLoop:[NSRunLoop currentRunLoop] withOptions:@{
JOYAxes2DEmulateButtonsKey: @YES,
JOYHatsEmulateButtonsKey: @YES,
}];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"GBNotificationsUsed"]) {
[NSUserNotificationCenter defaultUserNotificationCenter].delegate = self;
}
[self askAutoUpdates];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"GBAutoUpdatesEnabled"]) {
[self checkForUpdates];
}
if ([[NSProcessInfo processInfo].arguments containsObject:@"--update-launch"]) {
[NSApp activateIgnoringOtherApps:true];
}
} }
- (IBAction)toggleDeveloperMode:(id)sender - (IBAction)toggleDeveloperMode:(id)sender
@ -44,28 +99,355 @@
[defaults setBool:![defaults boolForKey:@"DeveloperMode"] forKey:@"DeveloperMode"]; [defaults setBool:![defaults boolForKey:@"DeveloperMode"] forKey:@"DeveloperMode"];
} }
- (IBAction)switchPreferencesTab:(id)sender
{
for (NSView *view in preferences_tabs) {
[view removeFromSuperview];
}
NSView *tab = preferences_tabs[[sender tag]];
NSRect old = [_preferencesWindow frame];
NSRect new = [_preferencesWindow frameRectForContentRect:tab.frame];
new.origin.x = old.origin.x;
new.origin.y = old.origin.y + (old.size.height - new.size.height);
[_preferencesWindow setFrame:new display:true animate:_preferencesWindow.visible];
[_preferencesWindow.contentView addSubview:tab];
}
- (BOOL)validateMenuItem:(NSMenuItem *)anItem - (BOOL)validateMenuItem:(NSMenuItem *)anItem
{ {
if ([anItem action] == @selector(toggleDeveloperMode:)) { if ([anItem action] == @selector(toggleDeveloperMode:)) {
[(NSMenuItem *)anItem setState:[[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]]; [(NSMenuItem *)anItem setState:[[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]];
} }
if (anItem == self.linkCableMenuItem) {
return [[NSDocumentController sharedDocumentController] documents].count > 1;
}
return true; return true;
} }
- (void)menuNeedsUpdate:(NSMenu *)menu
{
NSMutableArray *items = [NSMutableArray array];
NSDocument *currentDocument = [[NSDocumentController sharedDocumentController] currentDocument];
for (NSDocument *document in [[NSDocumentController sharedDocumentController] documents]) {
if (document == currentDocument) continue;
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:document.displayName action:@selector(connectLinkCable:) keyEquivalent:@""];
item.representedObject = document;
item.image = [[NSWorkspace sharedWorkspace] iconForFile:document.fileURL.path];
[item.image setSize:NSMakeSize(16, 16)];
[items addObject:item];
}
menu.itemArray = items;
}
- (IBAction) showPreferences: (id) sender - (IBAction) showPreferences: (id) sender
{ {
NSArray *objects; NSArray *objects;
if (!_preferencesWindow) { if (!_preferencesWindow) {
[[NSBundle mainBundle] loadNibNamed:@"Preferences" owner:self topLevelObjects:&objects]; [[NSBundle mainBundle] loadNibNamed:@"Preferences" owner:self topLevelObjects:&objects];
NSToolbarItem *first_toolbar_item = [_preferencesWindow.toolbar.items firstObject];
_preferencesWindow.toolbar.selectedItemIdentifier = [first_toolbar_item itemIdentifier];
preferences_tabs = @[self.emulationTab, self.graphicsTab, self.audioTab, self.controlsTab, self.updatesTab];
[self switchPreferencesTab:first_toolbar_item];
[_preferencesWindow center];
#ifndef UPDATE_SUPPORT
[_preferencesWindow.toolbar removeItemAtIndex:4];
#endif
} }
[_preferencesWindow makeKeyAndOrderFront:self]; [_preferencesWindow makeKeyAndOrderFront:self];
} }
- (BOOL)applicationOpenUntitledFile:(NSApplication *)sender - (BOOL)applicationOpenUntitledFile:(NSApplication *)sender
{ {
[self askAutoUpdates];
/* Bring an existing panel to the foreground */
for (NSWindow *window in [[NSApplication sharedApplication] windows]) {
if ([window isKindOfClass:[NSOpenPanel class]]) {
[(NSOpenPanel *)window makeKeyAndOrderFront:nil];
return true;
}
}
[[NSDocumentController sharedDocumentController] openDocument:self]; [[NSDocumentController sharedDocumentController] openDocument:self];
return YES; return true;
} }
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfFile:notification.identifier display:true];
}
- (void)updateFound
{
[[[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:@UPDATE_SERVER "/raw_changes"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSColor *linkColor = [NSColor colorWithRed:0.125 green:0.325 blue:1.0 alpha:1.0];
if (@available(macOS 10.10, *)) {
linkColor = [NSColor linkColor];
}
NSString *changes = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSRange cutoffRange = [changes rangeOfString:@"<!--(" GB_VERSION ")-->"];
if (cutoffRange.location != NSNotFound) {
changes = [changes substringToIndex:cutoffRange.location];
}
NSString *html = [NSString stringWithFormat:@"<!DOCTYPE html><html><head><title></title>"
"<style>html {background-color:transparent; color: #%06x; line-height:1.5} a:link, a:visited{color:#%06x; text-decoration:none}</style>"
"</head><body>%@</body></html>",
color_to_int([NSColor textColor]),
color_to_int(linkColor),
changes];
if ([(NSHTTPURLResponse *)response statusCode] == 200) {
dispatch_async(dispatch_get_main_queue(), ^{
NSArray *objects;
[[NSBundle mainBundle] loadNibNamed:@"UpdateWindow" owner:self topLevelObjects:&objects];
self.updateChanges.preferences.standardFontFamily = [NSFont systemFontOfSize:0].familyName;
self.updateChanges.preferences.fixedFontFamily = @"Menlo";
self.updateChanges.drawsBackground = false;
[self.updateChanges.mainFrame loadHTMLString:html baseURL:nil];
});
}
}] resume];
}
- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
{
// Disable reload context menu
if ([defaultMenuItems count] <= 2) {
return nil;
}
return defaultMenuItems;
}
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sender.mainFrame.frameView.documentView.enclosingScrollView.drawsBackground = true;
sender.mainFrame.frameView.documentView.enclosingScrollView.backgroundColor = [NSColor textBackgroundColor];
sender.policyDelegate = self;
[self.updateWindow center];
[self.updateWindow makeKeyAndOrderFront:nil];
});
}
- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener
{
[listener ignore];
[[NSWorkspace sharedWorkspace] openURL:[request URL]];
}
- (void)checkForUpdates
{
#ifdef UPDATE_SUPPORT
[[[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:@UPDATE_SERVER "/latest_version"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.updatesSpinner stopAnimation:nil];
[self.updatesButton setEnabled:true];
});
if ([(NSHTTPURLResponse *)response statusCode] == 200) {
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSArray <NSString *> *components = [string componentsSeparatedByString:@"|"];
if (components.count != 2) return;
_lastVersion = components[0];
_updateURL = components[1];
if (![@GB_VERSION isEqualToString:_lastVersion] &&
![[[NSUserDefaults standardUserDefaults] stringForKey:@"GBSkippedVersion"] isEqualToString:_lastVersion]) {
[self updateFound];
}
}
}] resume];
#endif
}
- (IBAction)userCheckForUpdates:(id)sender
{
if (self.updateWindow) {
[self.updateWindow makeKeyAndOrderFront:sender];
}
else {
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"GBSkippedVersion"];
[self checkForUpdates];
[sender setEnabled:false];
[self.updatesSpinner startAnimation:sender];
}
}
- (void)askAutoUpdates
{
#ifdef UPDATE_SUPPORT
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"GBAskedAutoUpdates"]) {
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"Should SameBoy check for updates when launched?";
alert.informativeText = @"SameBoy is frequently updated with new features, accuracy improvements, and bug fixes. This setting can always be changed in the preferences window.";
[alert addButtonWithTitle:@"Check on Launch"];
[alert addButtonWithTitle:@"Don't Check on Launch"];
[[NSUserDefaults standardUserDefaults] setBool:[alert runModal] == NSAlertFirstButtonReturn forKey:@"GBAutoUpdatesEnabled"];
[[NSUserDefaults standardUserDefaults] setBool:true forKey:@"GBAskedAutoUpdates"];
}
#endif
}
- (IBAction)skipVersion:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:_lastVersion forKey:@"GBSkippedVersion"];
[self.updateWindow performClose:sender];
}
- (IBAction)installUpdate:(id)sender
{
[self.updateProgressSpinner startAnimation:nil];
self.updateProgressButton.title = @"Cancel";
self.updateProgressButton.enabled = true;
self.updateProgressLabel.stringValue = @"Downloading update...";
_updateState = UPDATE_DOWNLOADING;
_updateTask = [[NSURLSession sharedSession] downloadTaskWithURL: [NSURL URLWithString:_updateURL] completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
_updateTask = nil;
dispatch_sync(dispatch_get_main_queue(), ^{
self.updateProgressButton.enabled = false;
self.updateProgressLabel.stringValue = @"Extracting update...";
_updateState = UPDATE_EXTRACTING;
});
_downloadDirectory = [[[NSFileManager defaultManager] URLForDirectory:NSItemReplacementDirectory
inDomain:NSUserDomainMask
appropriateForURL:[[NSBundle mainBundle] bundleURL]
create:true
error:nil] path];
NSTask *unzipTask;
if (!_downloadDirectory) {
dispatch_sync(dispatch_get_main_queue(), ^{
self.updateProgressButton.enabled = false;
self.updateProgressLabel.stringValue = @"Failed to extract update.";
_updateState = UPDATE_FAILED;
self.updateProgressButton.title = @"Close";
self.updateProgressButton.enabled = true;
[self.updateProgressSpinner stopAnimation:nil];
});
return;
}
unzipTask = [[NSTask alloc] init];
unzipTask.launchPath = @"/usr/bin/unzip";
unzipTask.arguments = @[location.path, @"-d", _downloadDirectory];
[unzipTask launch];
[unzipTask waitUntilExit];
if (unzipTask.terminationStatus != 0 || unzipTask.terminationReason != NSTaskTerminationReasonExit) {
[[NSFileManager defaultManager] removeItemAtPath:_downloadDirectory error:nil];
dispatch_sync(dispatch_get_main_queue(), ^{
self.updateProgressButton.enabled = false;
self.updateProgressLabel.stringValue = @"Failed to extract update.";
_updateState = UPDATE_FAILED;
self.updateProgressButton.title = @"Close";
self.updateProgressButton.enabled = true;
[self.updateProgressSpinner stopAnimation:nil];
});
return;
}
dispatch_sync(dispatch_get_main_queue(), ^{
self.updateProgressButton.enabled = false;
self.updateProgressLabel.stringValue = @"Update ready, save your game progress and click Install.";
_updateState = UPDATE_WAIT_INSTALL;
self.updateProgressButton.title = @"Install";
self.updateProgressButton.enabled = true;
[self.updateProgressSpinner stopAnimation:nil];
});
}];
[_updateTask resume];
self.updateProgressWindow.preventsApplicationTerminationWhenModal = false;
[self.updateWindow beginSheet:self.updateProgressWindow completionHandler:^(NSModalResponse returnCode) {
[self.updateWindow close];
}];
}
- (void)performUpgrade
{
self.updateProgressButton.enabled = false;
self.updateProgressLabel.stringValue = @"Instaling update...";
_updateState = UPDATE_INSTALLING;
self.updateProgressButton.enabled = false;
[self.updateProgressSpinner startAnimation:nil];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *executablePath = [[NSBundle mainBundle] executablePath];
NSString *contentsPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Contents"];
NSString *contentsTempPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"TempContents"];
NSString *updateContentsPath = [_downloadDirectory stringByAppendingPathComponent:@"SameBoy.app/Contents"];
NSError *error = nil;
[[NSFileManager defaultManager] moveItemAtPath:contentsPath toPath:contentsTempPath error:&error];
if (error) {
[[NSFileManager defaultManager] removeItemAtPath:_downloadDirectory error:nil];
_downloadDirectory = nil;
dispatch_sync(dispatch_get_main_queue(), ^{
self.updateProgressButton.enabled = false;
self.updateProgressLabel.stringValue = @"Failed to install update.";
_updateState = UPDATE_FAILED;
self.updateProgressButton.title = @"Close";
self.updateProgressButton.enabled = true;
[self.updateProgressSpinner stopAnimation:nil];
});
return;
}
[[NSFileManager defaultManager] moveItemAtPath:updateContentsPath toPath:contentsPath error:&error];
if (error) {
[[NSFileManager defaultManager] moveItemAtPath:contentsTempPath toPath:contentsPath error:nil];
[[NSFileManager defaultManager] removeItemAtPath:_downloadDirectory error:nil];
_downloadDirectory = nil;
dispatch_sync(dispatch_get_main_queue(), ^{
self.updateProgressButton.enabled = false;
self.updateProgressLabel.stringValue = @"Failed to install update.";
_updateState = UPDATE_FAILED;
self.updateProgressButton.title = @"Close";
self.updateProgressButton.enabled = true;
[self.updateProgressSpinner stopAnimation:nil];
});
return;
}
[[NSFileManager defaultManager] removeItemAtPath:_downloadDirectory error:nil];
[[NSFileManager defaultManager] removeItemAtPath:contentsTempPath error:nil];
_downloadDirectory = nil;
atexit_b(^{
execl(executablePath.UTF8String, executablePath.UTF8String, "--update-launch", NULL);
});
dispatch_async(dispatch_get_main_queue(), ^{
[NSApp terminate:nil];
});
});
}
- (IBAction)updateAction:(id)sender
{
switch (_updateState) {
case UPDATE_DOWNLOADING:
[_updateTask cancelByProducingResumeData:nil];
_updateTask = nil;
[self.updateProgressWindow close];
break;
case UPDATE_WAIT_INSTALL:
[self performUpgrade];
break;
case UPDATE_EXTRACTING:
case UPDATE_INSTALLING:
break;
case UPDATE_FAILED:
[self.updateProgressWindow close];
break;
}
}
- (void)dealloc
{
if (_downloadDirectory) {
[[NSFileManager defaultManager] removeItemAtPath:_downloadDirectory error:nil];
}
}
- (IBAction)nop:(id)sender
{
}
@end @end

Binary file not shown.

30
Cocoa/BigSurToolbar.h Normal file
View File

@ -0,0 +1,30 @@
#import <Cocoa/Cocoa.h>
#ifndef BigSurToolbar_h
#define BigSurToolbar_h
/* Backport the toolbarStyle property to allow compilation with older SDKs*/
#ifndef __MAC_10_16
typedef NS_ENUM(NSInteger, NSWindowToolbarStyle) {
// The default value. The style will be determined by the window's given configuration
NSWindowToolbarStyleAutomatic,
// The toolbar will appear below the window title
NSWindowToolbarStyleExpanded,
// The toolbar will appear below the window title and the items in the toolbar will attempt to have equal widths when possible
NSWindowToolbarStylePreference,
// The window title will appear inline with the toolbar when visible
NSWindowToolbarStyleUnified,
// Same as NSWindowToolbarStyleUnified, but with reduced margins in the toolbar allowing more focus to be on the contents of the window
NSWindowToolbarStyleUnifiedCompact
} API_AVAILABLE(macos(11.0));
@interface NSWindow (toolbarStyle)
@property (nonatomic) NSWindowToolbarStyle toolbarStyle API_AVAILABLE(macos(11.0));
@end
@interface NSImage (SFSymbols)
+ (instancetype)imageWithSystemSymbolName:(NSString *)symbolName accessibilityDescription:(NSString *)description API_AVAILABLE(macos(11.0));
@end
#endif
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 18 KiB

BIN
Cocoa/CPU@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
Cocoa/Display.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
Cocoa/Display@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1,39 +1,61 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include "GBView.h" #include "GBView.h"
#include "GBImageView.h" #include "GBImageView.h"
#include "GBSplitView.h"
#include "GBVisualizerView.h"
#include "GBOSDView.h"
@interface Document : NSDocument <NSWindowDelegate, GBImageViewDelegate, NSTableViewDataSource, NSTableViewDelegate> @class GBCheatWindowController;
@property (strong) IBOutlet GBView *view;
@property (strong) IBOutlet NSTextView *consoleOutput; @interface Document : NSDocument <NSWindowDelegate, GBImageViewDelegate, NSTableViewDataSource, NSTableViewDelegate, NSSplitViewDelegate>
@property (strong) IBOutlet NSPanel *consoleWindow; @property (nonatomic, readonly) GB_gameboy_t *gb;
@property (strong) IBOutlet NSTextField *consoleInput; @property (nonatomic, strong) IBOutlet GBView *view;
@property (strong) IBOutlet NSWindow *mainWindow; @property (nonatomic, strong) IBOutlet NSTextView *consoleOutput;
@property (strong) IBOutlet NSView *memoryView; @property (nonatomic, strong) IBOutlet NSPanel *consoleWindow;
@property (strong) IBOutlet NSPanel *memoryWindow; @property (nonatomic, strong) IBOutlet NSTextField *consoleInput;
@property (readonly) GB_gameboy_t *gameboy; @property (nonatomic, strong) IBOutlet NSWindow *mainWindow;
@property (strong) IBOutlet NSTextField *memoryBankInput; @property (nonatomic, strong) IBOutlet NSView *memoryView;
@property (strong) IBOutlet NSToolbarItem *memoryBankItem; @property (nonatomic, strong) IBOutlet NSPanel *memoryWindow;
@property (strong) IBOutlet GBImageView *tilesetImageView; @property (nonatomic, readonly) GB_gameboy_t *gameboy;
@property (strong) IBOutlet NSPopUpButton *tilesetPaletteButton; @property (nonatomic, strong) IBOutlet NSTextField *memoryBankInput;
@property (strong) IBOutlet GBImageView *tilemapImageView; @property (nonatomic, strong) IBOutlet NSToolbarItem *memoryBankItem;
@property (strong) IBOutlet NSPopUpButton *tilemapPaletteButton; @property (nonatomic, strong) IBOutlet GBImageView *tilesetImageView;
@property (strong) IBOutlet NSPopUpButton *tilemapMapButton; @property (nonatomic, strong) IBOutlet NSPopUpButton *tilesetPaletteButton;
@property (strong) IBOutlet NSPopUpButton *TilemapSetButton; @property (nonatomic, strong) IBOutlet GBImageView *tilemapImageView;
@property (strong) IBOutlet NSButton *gridButton; @property (nonatomic, strong) IBOutlet NSPopUpButton *tilemapPaletteButton;
@property (strong) IBOutlet NSTabView *vramTabView; @property (nonatomic, strong) IBOutlet NSPopUpButton *tilemapMapButton;
@property (strong) IBOutlet NSPanel *vramWindow; @property (nonatomic, strong) IBOutlet NSPopUpButton *TilemapSetButton;
@property (strong) IBOutlet NSTextField *vramStatusLabel; @property (nonatomic, strong) IBOutlet NSButton *gridButton;
@property (strong) IBOutlet NSTableView *paletteTableView; @property (nonatomic, strong) IBOutlet NSTabView *vramTabView;
@property (strong) IBOutlet NSTableView *spritesTableView; @property (nonatomic, strong) IBOutlet NSPanel *vramWindow;
@property (strong) IBOutlet NSPanel *printerFeedWindow; @property (nonatomic, strong) IBOutlet NSTextField *vramStatusLabel;
@property (strong) IBOutlet NSImageView *feedImageView; @property (nonatomic, strong) IBOutlet NSTableView *paletteTableView;
@property (strong) IBOutlet NSButton *feedSaveButton; @property (nonatomic, strong) IBOutlet NSTableView *objectsTableView;
@property (strong) IBOutlet NSTextView *debuggerSideViewInput; @property (nonatomic, strong) IBOutlet NSPanel *printerFeedWindow;
@property (strong) IBOutlet NSTextView *debuggerSideView; @property (nonatomic, strong) IBOutlet NSImageView *feedImageView;
@property (nonatomic, strong) IBOutlet NSTextView *debuggerSideViewInput;
@property (nonatomic, strong) IBOutlet NSTextView *debuggerSideView;
@property (nonatomic, strong) IBOutlet GBSplitView *debuggerSplitView;
@property (nonatomic, strong) IBOutlet NSBox *debuggerVerticalLine;
@property (nonatomic, strong) IBOutlet NSPanel *cheatsWindow;
@property (nonatomic, strong) IBOutlet GBCheatWindowController *cheatWindowController;
@property (nonatomic, readonly) Document *partner;
@property (nonatomic, readonly) bool isSlave;
@property (strong) IBOutlet NSView *gbsPlayerView;
@property (strong) IBOutlet NSTextField *gbsTitle;
@property (strong) IBOutlet NSTextField *gbsAuthor;
@property (strong) IBOutlet NSTextField *gbsCopyright;
@property (strong) IBOutlet NSPopUpButton *gbsTracks;
@property (strong) IBOutlet NSButton *gbsPlayPauseButton;
@property (strong) IBOutlet NSButton *gbsRewindButton;
@property (strong) IBOutlet NSSegmentedControl *gbsNextPrevButton;
@property (strong) IBOutlet GBVisualizerView *gbsVisualizer;
@property (strong) IBOutlet GBOSDView *osdView;
-(uint8_t) readMemory:(uint16_t) addr; -(uint8_t) readMemory:(uint16_t) addr;
-(void) writeMemory:(uint16_t) addr value:(uint8_t)value; -(void) writeMemory:(uint16_t) addr value:(uint8_t)value;
-(void) performAtomicBlock: (void (^)())block; -(void) performAtomicBlock: (void (^)())block;
-(void) connectLinkCable:(NSMenuItem *)sender;
-(int)loadStateFile:(const char *)path noErrorOnNotFound:(bool)noErrorOnFileNotFound;
@end @end

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12120" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" customObjectInstantitationMethod="direct"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14868" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12120"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14868"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="Document"> <customObject id="-2" userLabel="File's Owner" customClass="Document">
<connections> <connections>
<outlet property="TilemapSetButton" destination="k4c-Vg-MBu" id="Ak1-6d-B1N"/> <outlet property="TilemapSetButton" destination="k4c-Vg-MBu" id="Ak1-6d-B1N"/>
<outlet property="cheatWindowController" destination="v7q-gT-jHT" id="UNn-g4-2kP"/>
<outlet property="cheatsWindow" destination="4Yb-Np-JrF" id="YCZ-cj-gn5"/>
<outlet property="consoleInput" destination="l22-S8-uji" id="Heu-am-YgB"/> <outlet property="consoleInput" destination="l22-S8-uji" id="Heu-am-YgB"/>
<outlet property="consoleOutput" destination="doS-dM-hnl" id="Gn5-ju-Wb0"/> <outlet property="consoleOutput" destination="doS-dM-hnl" id="Gn5-ju-Wb0"/>
<outlet property="consoleWindow" destination="21F-Ah-yHX" id="eQ4-ug-LsT"/> <outlet property="consoleWindow" destination="21F-Ah-yHX" id="eQ4-ug-LsT"/>
<outlet property="debuggerSideView" destination="JgV-7E-iwp" id="RaA-fw-3i1"/> <outlet property="debuggerSideView" destination="JgV-7E-iwp" id="RaA-fw-3i1"/>
<outlet property="debuggerSideViewInput" destination="w0g-eK-jM4" id="GBf-WK-ryI"/> <outlet property="debuggerSideViewInput" destination="w0g-eK-jM4" id="GBf-WK-ryI"/>
<outlet property="debuggerSplitView" destination="pUc-ZN-vl5" id="0sG-0D-cID"/>
<outlet property="debuggerVerticalLine" destination="7bR-gM-1At" id="rfy-7Z-388"/>
<outlet property="feedImageView" destination="Ar0-nN-eop" id="wHa-St-o4G"/> <outlet property="feedImageView" destination="Ar0-nN-eop" id="wHa-St-o4G"/>
<outlet property="feedSaveButton" destination="RLc-0I-sYZ" id="Yy9-dG-xXY"/>
<outlet property="gridButton" destination="fL6-2S-Rgd" id="jtV-jh-GHC"/> <outlet property="gridButton" destination="fL6-2S-Rgd" id="jtV-jh-GHC"/>
<outlet property="mainWindow" destination="xOd-HO-29H" id="h8M-YB-vcC"/> <outlet property="mainWindow" destination="xOd-HO-29H" id="h8M-YB-vcC"/>
<outlet property="memoryBankInput" destination="rdV-q6-hc6" id="KBx-9T-2mX"/> <outlet property="memoryBankInput" destination="rdV-q6-hc6" id="KBx-9T-2mX"/>
<outlet property="memoryBankItem" destination="bWC-FW-IYP" id="Lf2-dh-z32"/> <outlet property="memoryBankItem" destination="bWC-FW-IYP" id="Lf2-dh-z32"/>
<outlet property="memoryView" destination="8hr-8o-3rN" id="fF0-rh-8ND"/> <outlet property="memoryView" destination="8hr-8o-3rN" id="fF0-rh-8ND"/>
<outlet property="memoryWindow" destination="mRm-dL-mCj" id="VPR-lu-vtI"/> <outlet property="memoryWindow" destination="mRm-dL-mCj" id="VPR-lu-vtI"/>
<outlet property="objectsTableView" destination="TOc-XJ-w9w" id="O4R-4Z-9hU"/>
<outlet property="osdView" destination="MX4-l2-7NE" id="Am7-fq-uvu"/>
<outlet property="paletteTableView" destination="gfC-d3-dmq" id="fTC-eL-Qg3"/> <outlet property="paletteTableView" destination="gfC-d3-dmq" id="fTC-eL-Qg3"/>
<outlet property="printerFeedWindow" destination="NdE-0B-WCf" id="yVK-cS-NOJ"/> <outlet property="printerFeedWindow" destination="NdE-0B-WCf" id="yVK-cS-NOJ"/>
<outlet property="spritesTableView" destination="TOc-XJ-w9w" id="O4R-4Z-9hU"/>
<outlet property="tilemapImageView" destination="LlK-tV-bjv" id="nSY-Xd-BjZ"/> <outlet property="tilemapImageView" destination="LlK-tV-bjv" id="nSY-Xd-BjZ"/>
<outlet property="tilemapMapButton" destination="YIJ-Qc-SIZ" id="BB7-Gg-7XP"/> <outlet property="tilemapMapButton" destination="YIJ-Qc-SIZ" id="BB7-Gg-7XP"/>
<outlet property="tilemapPaletteButton" destination="loB-0k-Qff" id="2Or-7l-6vn"/> <outlet property="tilemapPaletteButton" destination="loB-0k-Qff" id="2Or-7l-6vn"/>
@ -39,27 +43,33 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="xOd-HO-29H" userLabel="Window"> <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="xOd-HO-29H" userLabel="Window">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/> <windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="160" height="144"/>
<rect key="contentRect" x="133" y="235" width="160" height="144"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<value key="minSize" type="size" width="160" height="144"/> <value key="minSize" type="size" width="160" height="144"/>
<view key="contentView" id="gIp-Ho-8D9"> <view key="contentView" id="gIp-Ho-8D9">
<rect key="frame" x="0.0" y="0.0" width="160" height="144"/> <rect key="frame" x="0.0" y="0.0" width="160" height="144"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<customView id="KTk-4M-J7t" customClass="GBBorderView"> <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KTk-4M-J7t" customClass="GBBorderView">
<rect key="frame" x="0.0" y="0.0" width="160" height="144"/> <rect key="frame" x="0.0" y="0.0" width="160" height="144"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<openGLView colorSize="5bit_RGB_8bit_Alpha" useAuxiliaryDepthBufferStencil="NO" allowOffline="YES" wantsBestResolutionOpenGLSurface="YES" id="uqf-pe-VAF" customClass="GBView"> <view fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uqf-pe-VAF" customClass="GBView">
<rect key="frame" x="0.0" y="0.0" width="160" height="144"/> <rect key="frame" x="0.0" y="0.0" width="160" height="144"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</openGLView> <connections>
<outlet property="document" destination="-2" id="Fvh-rD-z4r"/>
</connections>
</view>
</subviews> </subviews>
</customView> </customView>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MX4-l2-7NE" customClass="GBOSDView">
<rect key="frame" x="0.0" y="0.0" width="160" height="144"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</customView>
</subviews> </subviews>
</view> </view>
<connections> <connections>
@ -67,49 +77,17 @@
</connections> </connections>
<point key="canvasLocation" x="293" y="347"/> <point key="canvasLocation" x="293" y="347"/>
</window> </window>
<window title="Debug Console" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="21F-Ah-yHX" customClass="NSPanel"> <window title="Debug Console" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="21F-Ah-yHX" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES" utility="YES" HUD="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES" utility="YES" HUD="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/> <windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="921" height="400"/>
<rect key="contentRect" x="272" y="172" width="921" height="400"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<value key="minSize" type="size" width="921" height="400"/> <value key="minSize" type="size" width="921" height="400"/>
<view key="contentView" id="dCP-E5-7Fi"> <view key="contentView" id="dCP-E5-7Fi">
<rect key="frame" x="0.0" y="0.0" width="921" height="400"/> <rect key="frame" x="0.0" y="0.0" width="921" height="400"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<scrollView misplaced="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="oTo-zx-o6N"> <textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" mirrorLayoutDirectionWhenInternationalizing="never" translatesAutoresizingMaskIntoConstraints="NO" id="l22-S8-uji">
<rect key="frame" x="0.0" y="25" width="600" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="EQe-Ad-L7S">
<rect key="frame" x="0.0" y="0.0" width="600" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" baseWritingDirection="leftToRight" findStyle="bar" allowsNonContiguousLayout="YES" id="doS-dM-hnl">
<rect key="frame" x="0.0" y="0.0" width="600" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.14901960784313725" green="0.14901960784313725" blue="0.14901960784313725" alpha="1" colorSpace="calibratedRGB"/>
<size key="minSize" width="600" height="376"/>
<size key="maxSize" width="1160" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textView>
</subviews>
<color key="backgroundColor" red="0.16470588235294117" green="0.16470588235294117" blue="0.16470588235294117" alpha="1" colorSpace="calibratedRGB"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="3fZ-tl-Zi7">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="cwi-6E-rbh">
<rect key="frame" x="584" y="0.0" width="16" height="376"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<textField focusRingType="none" verticalHuggingPriority="750" mirrorLayoutDirectionWhenInternationalizing="never" allowsCharacterPickerTouchBarItem="NO" id="l22-S8-uji">
<rect key="frame" x="0.0" y="0.0" width="921" height="24"/> <rect key="frame" x="0.0" y="0.0" width="921" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" focusRingType="none" id="p3j-nS-44f" customClass="GBTerminalTextFieldCell"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" focusRingType="none" id="p3j-nS-44f" customClass="GBTerminalTextFieldCell">
@ -124,22 +102,106 @@
<action selector="consoleInput:" target="-2" id="ylQ-vw-ARS"/> <action selector="consoleInput:" target="-2" id="ylQ-vw-ARS"/>
</connections> </connections>
</textField> </textField>
<box verticalHuggingPriority="750" boxType="separator" id="960-dL-7ZY"> <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="960-dL-7ZY">
<rect key="frame" x="0.0" y="23" width="921" height="5"/> <rect key="frame" x="0.0" y="23" width="921" height="5"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</box> </box>
<scrollView misplaced="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="vts-CC-ZjQ"> <box horizontalHuggingPriority="750" boxType="separator" id="7bR-gM-1At">
<rect key="frame" x="601" y="25" width="320" height="328"/> <rect key="frame" x="590" y="25" width="5" height="376"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" heightSizable="YES"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="Cs9-3x-ATg"> </box>
<rect key="frame" x="0.0" y="0.0" width="320" height="328"/> <splitView dividerStyle="thin" vertical="YES" id="pUc-ZN-vl5" customClass="GBSplitView">
<rect key="frame" x="0.0" y="25" width="921" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textView editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" baseWritingDirection="leftToRight" findStyle="bar" allowsNonContiguousLayout="YES" spellingCorrection="YES" id="JgV-7E-iwp"> <customView fixedFrame="YES" id="2rj-7i-kxc">
<rect key="frame" x="0.0" y="0.0" width="320" height="328"/> <rect key="frame" x="0.0" y="0.0" width="591" height="376"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oTo-zx-o6N">
<rect key="frame" x="0.0" y="0.0" width="591" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="EQe-Ad-L7S">
<rect key="frame" x="0.0" y="0.0" width="591" height="376"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView ambiguous="YES" editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" baseWritingDirection="leftToRight" findStyle="bar" allowsNonContiguousLayout="YES" id="doS-dM-hnl">
<rect key="frame" x="0.0" y="0.0" width="591" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.14901960784313725" green="0.14901960784313725" blue="0.14901960784313725" alpha="1" colorSpace="calibratedRGB"/>
<size key="minSize" width="591" height="376"/>
<size key="maxSize" width="1160" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textView>
</subviews>
<color key="backgroundColor" red="0.16470588235294117" green="0.16470588235294117" blue="0.16470588235294117" alpha="1" colorSpace="calibratedRGB"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="3fZ-tl-Zi7">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="cwi-6E-rbh">
<rect key="frame" x="575" y="0.0" width="16" height="376"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
</subviews>
</customView>
<customView fixedFrame="YES" id="4Z2-33-dYY">
<rect key="frame" x="592" y="0.0" width="329" height="376"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" scrollerKnobStyle="dark" translatesAutoresizingMaskIntoConstraints="NO" id="V9U-Ua-F4z">
<rect key="frame" x="0.0" y="329" width="329" height="47"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="YHx-TM-zIC">
<rect key="frame" x="0.0" y="0.0" width="329" height="47"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView ambiguous="YES" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" allowsCharacterPickerTouchBarItem="NO" allowsUndo="YES" allowsNonContiguousLayout="YES" textCompletion="NO" spellingCorrection="YES" id="w0g-eK-jM4">
<rect key="frame" x="0.0" y="0.0" width="329" height="47"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="329" height="47"/>
<size key="maxSize" width="463" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="24d-1i-uBk">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="qgN-F8-fdB">
<rect key="frame" x="313" y="0.0" width="16" height="47"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="5qI-qZ-nkh">
<rect key="frame" x="0.0" y="327" width="327" height="5"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
</box>
<scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vts-CC-ZjQ">
<rect key="frame" x="0.0" y="2" width="329" height="328"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="Cs9-3x-ATg">
<rect key="frame" x="0.0" y="0.0" width="329" height="328"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView ambiguous="YES" editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" baseWritingDirection="leftToRight" findStyle="bar" allowsNonContiguousLayout="YES" spellingCorrection="YES" id="JgV-7E-iwp">
<rect key="frame" x="0.0" y="0.0" width="329" height="328"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" red="0.14901960780000001" green="0.14901960780000001" blue="0.14901960780000001" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.14901960780000001" green="0.14901960780000001" blue="0.14901960780000001" alpha="1" colorSpace="calibratedRGB"/>
<size key="minSize" width="320" height="328"/> <size key="minSize" width="329" height="328"/>
<size key="maxSize" width="1160" height="10000000"/> <size key="maxSize" width="1160" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales> <allowedInputSourceLocales>
@ -149,66 +211,38 @@
</subviews> </subviews>
<color key="backgroundColor" red="0.1647058824" green="0.1647058824" blue="0.1647058824" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.1647058824" green="0.1647058824" blue="0.1647058824" alpha="1" colorSpace="calibratedRGB"/>
</clipView> </clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="J2i-lz-QJW"> <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="J2i-lz-QJW">
<rect key="frame" x="-100" y="-100" width="87" height="18"/> <rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="4jm-Gm-D2R"> <scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="4jm-Gm-D2R">
<rect key="frame" x="304" y="0.0" width="16" height="328"/> <rect key="frame" x="313" y="0.0" width="16" height="328"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
</scrollView> </scrollView>
<scrollView misplaced="YES" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" scrollerKnobStyle="dark" id="V9U-Ua-F4z">
<rect key="frame" x="601" y="354" width="320" height="47"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="YHx-TM-zIC">
<rect key="frame" x="0.0" y="0.0" width="320" height="47"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView drawsBackground="NO" importsGraphics="NO" richText="NO" allowsCharacterPickerTouchBarItem="NO" allowsUndo="YES" allowsNonContiguousLayout="YES" textCompletion="NO" spellingCorrection="YES" id="w0g-eK-jM4">
<rect key="frame" x="0.0" y="0.0" width="320" height="47"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="320" height="47"/>
<size key="maxSize" width="463" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textView>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> </customView>
</clipView> </subviews>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="24d-1i-uBk"> <holdingPriorities>
<rect key="frame" x="-100" y="-100" width="87" height="18"/> <real value="250"/>
<autoresizingMask key="autoresizingMask"/> <real value="250"/>
</scroller> </holdingPriorities>
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="qgN-F8-fdB"> <connections>
<rect key="frame" x="304" y="0.0" width="16" height="47"/> <outlet property="delegate" destination="-2" id="c8R-36-VRD"/>
<autoresizingMask key="autoresizingMask"/> </connections>
</scroller> </splitView>
</scrollView>
<box verticalHuggingPriority="750" misplaced="YES" boxType="separator" id="5qI-qZ-nkh">
<rect key="frame" x="603" y="352" width="318" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
</box>
<box horizontalHuggingPriority="750" misplaced="YES" boxType="separator" id="Onx-Oe-fBx">
<rect key="frame" x="600" y="25" width="5" height="376"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/>
</box>
</subviews> </subviews>
</view> </view>
<point key="canvasLocation" x="347.5" y="-29"/> <point key="canvasLocation" x="347.5" y="-29"/>
</window> </window>
<window title="Memory" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="mRm-dL-mCj" customClass="NSPanel"> <window title="Memory" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="mRm-dL-mCj" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/> <windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="528" height="320"/>
<rect key="contentRect" x="272" y="172" width="528" height="320"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="8hr-8o-3rN"> <view key="contentView" id="8hr-8o-3rN">
<rect key="frame" x="0.0" y="0.0" width="528" height="320"/> <rect key="frame" x="0.0" y="0.0" width="528" height="320"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view> </view>
<toolbar key="toolbar" implicitIdentifier="D857E961-E523-4295-83F8-0849316E827C" autosavesConfiguration="NO" allowsUserCustomization="NO" displayMode="iconAndLabel" sizeMode="regular" id="82v-uB-RPi"> <toolbar key="toolbar" implicitIdentifier="D857E961-E523-4295-83F8-0849316E827C" autosavesConfiguration="NO" allowsUserCustomization="NO" displayMode="iconAndLabel" sizeMode="regular" id="82v-uB-RPi">
<allowedToolbarItems> <allowedToolbarItems>
@ -217,9 +251,9 @@
<toolbarItem implicitItemIdentifier="4F6AAE25-1E9D-4111-9E5B-91F0792E56CD" label="Address Space" paletteLabel="Address Space" id="VTy-lj-K0H"> <toolbarItem implicitItemIdentifier="4F6AAE25-1E9D-4111-9E5B-91F0792E56CD" label="Address Space" paletteLabel="Address Space" id="VTy-lj-K0H">
<nil key="toolTip"/> <nil key="toolTip"/>
<size key="minSize" width="100" height="25"/> <size key="minSize" width="100" height="25"/>
<size key="maxSize" width="100" height="25"/> <size key="maxSize" width="130" height="25"/>
<popUpButton key="view" verticalHuggingPriority="750" id="vfJ-vu-gqJ"> <popUpButton key="view" verticalHuggingPriority="750" id="vfJ-vu-gqJ">
<rect key="frame" x="0.0" y="14" width="100" height="25"/> <rect key="frame" x="0.0" y="14" width="128" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="bpD-j9-omo"> <popUpButtonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="bpD-j9-omo">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -243,12 +277,12 @@
<nil key="toolTip"/> <nil key="toolTip"/>
<size key="minSize" width="64" height="22"/> <size key="minSize" width="64" height="22"/>
<size key="maxSize" width="64" height="22"/> <size key="maxSize" width="64" height="22"/>
<textField key="view" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" id="rdV-q6-hc6"> <textField key="view" verticalHuggingPriority="750" id="rdV-q6-hc6">
<rect key="frame" x="0.0" y="14" width="64" height="22"/> <rect key="frame" x="0.0" y="14" width="64" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" id="JCn-Y1-eHS"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" id="JCn-Y1-eHS">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
<connections> <connections>
@ -260,12 +294,12 @@
<nil key="toolTip"/> <nil key="toolTip"/>
<size key="minSize" width="96" height="22"/> <size key="minSize" width="96" height="22"/>
<size key="maxSize" width="128" height="22"/> <size key="maxSize" width="128" height="22"/>
<textField key="view" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" id="EJd-jG-hmH"> <textField key="view" verticalHuggingPriority="750" id="EJd-jG-hmH">
<rect key="frame" x="0.0" y="14" width="96" height="22"/> <rect key="frame" x="0.0" y="14" width="96" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" bezelStyle="round" id="vg5-Nn-abb"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" bezelStyle="round" id="vg5-Nn-abb">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
<connections> <connections>
@ -284,21 +318,20 @@
<point key="canvasLocation" x="-185" y="61"/> <point key="canvasLocation" x="-185" y="61"/>
</window> </window>
<menuItem title="Cartridge RAM" id="ylM-ah-PNQ"/> <menuItem title="Cartridge RAM" id="ylM-ah-PNQ"/>
<window title="VRAM Viewer" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="mbr-db-iZh" customClass="NSPanel"> <window title="VRAM Viewer" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="mbr-db-iZh" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" unifiedTitleAndToolbar="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/> <windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="512" height="432"/>
<rect key="contentRect" x="283" y="305" width="512" height="432"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="GYW-dv-Um1"> <view key="contentView" id="GYW-dv-Um1">
<rect key="frame" x="0.0" y="0.0" width="512" height="432"/> <rect key="frame" x="0.0" y="0.0" width="512" height="432"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<box verticalHuggingPriority="750" boxType="separator" id="ucG-cD-wfs"> <box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="ucG-cD-wfs">
<rect key="frame" x="0.0" y="406" width="512" height="5"/> <rect key="frame" x="0.0" y="406" width="512" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</box> </box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" id="6vK-IP-PmP"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6vK-IP-PmP">
<rect key="frame" x="-2" y="4" width="516" height="14"/> <rect key="frame" x="-2" y="4" width="516" height="14"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" id="umk-4r-VNg"> <textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" id="umk-4r-VNg">
@ -307,17 +340,17 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<tabView drawsBackground="NO" type="noTabsNoBorder" initialItem="pXb-od-Wb1" id="AZz-Mh-rPA"> <tabView fixedFrame="YES" drawsBackground="NO" type="noTabsNoBorder" initialItem="pXb-od-Wb1" translatesAutoresizingMaskIntoConstraints="NO" id="AZz-Mh-rPA">
<rect key="frame" x="0.0" y="24" width="512" height="408"/> <rect key="frame" x="0.0" y="24" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<tabViewItems> <tabViewItems>
<tabViewItem label="Tileset" identifier="1" id="pXb-od-Wb1"> <tabViewItem label="Tileset" identifier="1" id="pXb-od-Wb1">
<view key="view" id="lCG-Gt-XMF"> <view key="view" ambiguous="YES" id="lCG-Gt-XMF">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="QcQ-ex-36R" customClass="GBImageView"> <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QcQ-ex-36R" customClass="GBImageView">
<rect key="frame" x="0.0" y="0.0" width="512" height="384"/> <rect key="frame" x="0.0" y="0.0" width="512" height="384"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" id="pXc-O8-jg5"/> <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" id="pXc-O8-jg5"/>
@ -326,7 +359,7 @@
<outlet property="delegate" destination="-2" id="xoo-Uo-872"/> <outlet property="delegate" destination="-2" id="xoo-Uo-872"/>
</connections> </connections>
</imageView> </imageView>
<popUpButton focusRingType="none" verticalHuggingPriority="750" id="TLv-xS-X5K"> <popUpButton focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="TLv-xS-X5K">
<rect key="frame" x="4" y="388" width="128" height="17"/> <rect key="frame" x="4" y="388" width="128" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="roundRect" title="None" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="G8p-CH-PlV" id="1jI-s4-4YY"> <popUpButtonCell key="cell" type="roundRect" title="None" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="G8p-CH-PlV" id="1jI-s4-4YY">
@ -358,7 +391,7 @@
<action selector="reloadVRAMData:" target="-2" id="Qtf-p4-Rqh"/> <action selector="reloadVRAMData:" target="-2" id="Qtf-p4-Rqh"/>
</connections> </connections>
</popUpButton> </popUpButton>
<button verticalHuggingPriority="750" id="fL6-2S-Rgd"> <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fL6-2S-Rgd">
<rect key="frame" x="452" y="388" width="56" height="17"/> <rect key="frame" x="452" y="388" width="56" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundRect" title="Grid" bezelStyle="roundedRect" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="pDn-9a-Se6"> <buttonCell key="cell" type="roundRect" title="Grid" bezelStyle="roundedRect" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="pDn-9a-Se6">
@ -377,7 +410,18 @@
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="LlK-tV-bjv" customClass="GBImageView"> <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DhM-Em-hj7">
<rect key="frame" x="385" y="388" width="63" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundRect" title="Scrolling" bezelStyle="roundedRect" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="P2E-5t-BN9">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES" changeBackground="YES" changeGray="YES"/>
<font key="font" metaFont="miniSystem"/>
</buttonCell>
<connections>
<action selector="toggleScrollingDisplay:" target="-2" id="VhQ-9W-sjU"/>
</connections>
</button>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LlK-tV-bjv" customClass="GBImageView">
<rect key="frame" x="0.0" y="0.0" width="512" height="384"/> <rect key="frame" x="0.0" y="0.0" width="512" height="384"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" id="RvP-El-ILj"/> <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="axesIndependently" id="RvP-El-ILj"/>
@ -386,8 +430,8 @@
<outlet property="delegate" destination="-2" id="EAG-Zh-oRi"/> <outlet property="delegate" destination="-2" id="EAG-Zh-oRi"/>
</connections> </connections>
</imageView> </imageView>
<popUpButton focusRingType="none" verticalHuggingPriority="750" id="loB-0k-Qff"> <popUpButton focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="loB-0k-Qff">
<rect key="frame" x="4" y="387" width="128" height="18"/> <rect key="frame" x="4" y="388" width="128" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="roundRect" title="Effective Palettes" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="oUH-Sa-Ec1" id="Eij-Cp-URa"> <popUpButtonCell key="cell" type="roundRect" title="Effective Palettes" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="oUH-Sa-Ec1" id="Eij-Cp-URa">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -419,8 +463,8 @@
<action selector="reloadVRAMData:" target="-2" id="BmB-JE-W8g"/> <action selector="reloadVRAMData:" target="-2" id="BmB-JE-W8g"/>
</connections> </connections>
</popUpButton> </popUpButton>
<popUpButton focusRingType="none" verticalHuggingPriority="750" id="YIJ-Qc-SIZ"> <popUpButton focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YIJ-Qc-SIZ">
<rect key="frame" x="135" y="387" width="96" height="18"/> <rect key="frame" x="135" y="388" width="96" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="roundRect" title="Effective Tilemap" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="XRF-Vj-3gs" id="3W1-Db-wDn"> <popUpButtonCell key="cell" type="roundRect" title="Effective Tilemap" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="XRF-Vj-3gs" id="3W1-Db-wDn">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -437,8 +481,8 @@
<action selector="reloadVRAMData:" target="-2" id="xwp-Ju-p00"/> <action selector="reloadVRAMData:" target="-2" id="xwp-Ju-p00"/>
</connections> </connections>
</popUpButton> </popUpButton>
<popUpButton focusRingType="none" verticalHuggingPriority="750" id="k4c-Vg-MBu"> <popUpButton focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="k4c-Vg-MBu">
<rect key="frame" x="235" y="387" width="96" height="18"/> <rect key="frame" x="235" y="388" width="96" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="roundRect" title="Effective Tileset" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="CRe-dX-rzY" id="h53-sb-Odg"> <popUpButtonCell key="cell" type="roundRect" title="Effective Tileset" bezelStyle="roundedRect" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" selectedItem="CRe-dX-rzY" id="h53-sb-Odg">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -458,19 +502,19 @@
</subviews> </subviews>
</view> </view>
</tabViewItem> </tabViewItem>
<tabViewItem label="Sprites" identifier="" id="a08-eg-Maw"> <tabViewItem label="Objects" identifier="" id="a08-eg-Maw">
<view key="view" id="EiO-p0-3xn"> <view key="view" id="EiO-p0-3xn">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="20" horizontalPageScroll="10" verticalLineScroll="20" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="krD-gH-o5I"> <scrollView fixedFrame="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="20" horizontalPageScroll="10" verticalLineScroll="20" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="krD-gH-o5I">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" drawsBackground="NO" id="3VT-AA-xVT"> <clipView key="contentView" ambiguous="YES" drawsBackground="NO" id="3VT-AA-xVT">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<tableView appearanceType="vibrantLight" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="18" headerView="of1-KC-dXC" id="TOc-XJ-w9w"> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="18" headerView="of1-KC-dXC" id="TOc-XJ-w9w">
<rect key="frame" x="0.0" y="0.0" width="512" height="391"/> <rect key="frame" x="0.0" y="0.0" width="512" height="391"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/> <size key="intercellSpacing" width="3" height="2"/>
@ -586,11 +630,11 @@
</subviews> </subviews>
<nil key="backgroundColor"/> <nil key="backgroundColor"/>
</clipView> </clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="n53-qA-NpY"> <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="n53-qA-NpY">
<rect key="frame" x="0.0" y="392" width="512" height="16"/> <rect key="frame" x="0.0" y="392" width="512" height="16"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="mqp-NY-g8d"> <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="mqp-NY-g8d">
<rect key="frame" x="224" y="17" width="15" height="102"/> <rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
@ -607,10 +651,10 @@
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<scrollView borderType="none" horizontalLineScroll="20" horizontalPageScroll="10" verticalLineScroll="20" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" verticalScrollElasticity="none" id="iSs-Ow-wwb"> <scrollView fixedFrame="YES" borderType="none" horizontalLineScroll="20" horizontalPageScroll="10" verticalLineScroll="20" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" verticalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="iSs-Ow-wwb">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" id="bP9-su-zQw"> <clipView key="contentView" ambiguous="YES" id="bP9-su-zQw">
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/> <rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
@ -648,7 +692,7 @@
</textFieldCell> </textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn> </tableColumn>
<tableColumn identifier="" width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="syl-os-nSf"> <tableColumn width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="syl-os-nSf">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -661,7 +705,7 @@
</textFieldCell> </textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn> </tableColumn>
<tableColumn identifier="" width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="Qw3-u2-c1s"> <tableColumn width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="Qw3-u2-c1s">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -674,7 +718,7 @@
</textFieldCell> </textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn> </tableColumn>
<tableColumn identifier="" width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="gTl-gN-qLn"> <tableColumn width="93" minWidth="10" maxWidth="3.4028234663852886e+38" id="gTl-gN-qLn">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -695,11 +739,11 @@
</tableView> </tableView>
</subviews> </subviews>
</clipView> </clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="OS3-sw-bjv"> <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="OS3-sw-bjv">
<rect key="frame" x="-100" y="-100" width="510" height="16"/> <rect key="frame" x="-100" y="-100" width="510" height="16"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="4HA-2m-8TZ"> <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="4HA-2m-8TZ">
<rect key="frame" x="-100" y="-100" width="15" height="102"/> <rect key="frame" x="-100" y="-100" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
@ -726,7 +770,7 @@
<segments> <segments>
<segment label="Tileset" selected="YES"/> <segment label="Tileset" selected="YES"/>
<segment label="Tilemap" tag="1"/> <segment label="Tilemap" tag="1"/>
<segment label="Sprites"/> <segment label="Objects"/>
<segment label="Palettes"/> <segment label="Palettes"/>
</segments> </segments>
</segmentedCell> </segmentedCell>
@ -745,35 +789,300 @@
<contentBorderThickness minY="24"/> <contentBorderThickness minY="24"/>
<point key="canvasLocation" x="182" y="760"/> <point key="canvasLocation" x="182" y="760"/>
</window> </window>
<window title="Printer Feed" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="NdE-0B-WCf" customClass="NSPanel"> <window title="Printer Feed" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="NdE-0B-WCf" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="320" height="288"/>
<rect key="contentRect" x="272" y="172" width="320" height="288"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<value key="minSize" type="size" width="320" height="16"/>
<view key="contentView" id="RRS-aa-bPT"> <view key="contentView" id="RRS-aa-bPT">
<rect key="frame" x="0.0" y="0.0" width="320" height="288"/> <rect key="frame" x="0.0" y="0.0" width="320" height="288"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="Ar0-nN-eop" customClass="GBImageView"> <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ar0-nN-eop" customClass="GBImageView">
<rect key="frame" x="0.0" y="0.0" width="320" height="288"/> <rect key="frame" x="0.0" y="0.0" width="320" height="288"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageAlignment="topLeft" id="sff-hk-4nM"/> <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageAlignment="topLeft" id="sff-hk-4nM"/>
</imageView> </imageView>
</subviews> </subviews>
</view> </view>
<toolbar key="toolbar" implicitIdentifier="1FF86A2B-6637-4EE6-A25A-7298D79AE84E" autosavesConfiguration="NO" allowsUserCustomization="NO" displayMode="iconAndLabel" sizeMode="regular" id="gH3-SH-7il">
<allowedToolbarItems>
<toolbarItem implicitItemIdentifier="15EB8D49-8C6E-42F2-9F7F-F7D7A0BBDAAF" label="Save" paletteLabel="Save" tag="-1" image="NSFolder" id="CBz-1N-o0Q">
<connections>
<action selector="savePrinterFeed:" target="-2" id="Dm3-h0-ch4"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="NSToolbarPrintItem" explicitItemIdentifier="Print" id="mtd-zS-DXa"/>
<toolbarItem implicitItemIdentifier="NSToolbarSpaceItem" id="AoG-LH-J4b"/>
<toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="Q0x-n5-Q2Y"/>
</allowedToolbarItems>
<defaultToolbarItems>
<toolbarItem reference="CBz-1N-o0Q"/>
<toolbarItem reference="Q0x-n5-Q2Y"/>
<toolbarItem reference="mtd-zS-DXa"/>
</defaultToolbarItems>
</toolbar>
<point key="canvasLocation" x="-159" y="356"/> <point key="canvasLocation" x="-159" y="356"/>
</window> </window>
<button verticalHuggingPriority="750" id="RLc-0I-sYZ"> <window title="Cheats" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="4Yb-Np-JrF" customClass="NSPanel">
<rect key="frame" x="0.0" y="0.0" width="48" height="25"/> <windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/> <rect key="contentRect" x="0.0" y="0.0" width="692" height="272"/>
<buttonCell key="cell" type="roundTextured" title="Save" bezelStyle="texturedRounded" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="shw-MJ-B3T"> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <view key="contentView" id="gBP-5p-BTh">
<font key="font" metaFont="miniSystem"/> <rect key="frame" x="0.0" y="0.0" width="692" height="272"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view id="fWr-0i-K1d" customClass="GBOptionalVisualEffectView">
<rect key="frame" x="0.0" y="0.0" width="294" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="hqi-ob-NW9">
<rect key="frame" x="16" y="174" width="154" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="To value:" id="Ycx-oE-aA4">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Kq8-6F-9GK">
<rect key="frame" x="16" y="142" width="154" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Only if old value was: " bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="LkB-WQ-9Qd">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell> </buttonCell>
<connections> <connections>
<action selector="savePrinterFeed:" target="-2" id="Y3g-fU-2te"/> <action selector="updateCheat:" target="v7q-gT-jHT" id="kNc-cj-bmF"/>
</connections> </connections>
<point key="canvasLocation" x="-507" y="397"/>
</button> </button>
<box verticalHuggingPriority="750" boxType="separator" id="D6k-Pe-23u">
<rect key="frame" x="10" y="129" width="274" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="r5T-ol-Dod">
<rect key="frame" x="16" y="107" width="270" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Import GameShark or GameGenie cheat:" id="0mf-EN-cKc">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="X7K-nJ-alF">
<rect key="frame" x="39" y="78" width="233" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" focusRingType="none" placeholderString="Code" drawsBackground="YES" usesSingleLineMode="YES" id="2bz-dT-7Fi">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textFieldCell>
<connections>
<action selector="selectText:" target="KHj-uX-Wbk" id="11z-0U-tMA"/>
</connections>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KHj-uX-Wbk">
<rect key="frame" x="39" y="47" width="233" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" focusRingType="none" placeholderString="Description" drawsBackground="YES" usesSingleLineMode="YES" id="50d-va-Cen">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="performClick:" target="C3V-Ep-bMj" id="kIN-jl-A8d"/>
</connections>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="C6E-oI-hDC">
<rect key="frame" x="20" y="233" width="252" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" focusRingType="none" placeholderString="Description" drawsBackground="YES" usesSingleLineMode="YES" id="2uR-9N-hBb">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="delegate" destination="v7q-gT-jHT" id="zyw-h0-hRP"/>
</connections>
</textField>
<button verticalHuggingPriority="750" id="C3V-Ep-bMj">
<rect key="frame" x="202.5" y="12" width="83" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" title="Import" bezelStyle="texturedRounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="mMP-KW-YNy">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="importCheat:" target="v7q-gT-jHT" id="lkX-N5-wD1"/>
</connections>
</button>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" mirrorLayoutDirectionWhenInternationalizing="never" translatesAutoresizingMaskIntoConstraints="NO" id="qHx-1z-daR">
<rect key="frame" x="176" y="204" width="96" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" focusRingType="none" drawsBackground="YES" usesSingleLineMode="YES" id="edq-46-JeP" customClass="GBCheatTextFieldCell">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textFieldCell>
<connections>
<action selector="consoleInput:" target="-2" id="sMf-aM-OvR"/>
<outlet property="delegate" destination="v7q-gT-jHT" id="79v-33-R1X"/>
</connections>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" mirrorLayoutDirectionWhenInternationalizing="never" translatesAutoresizingMaskIntoConstraints="NO" id="N3I-PP-X85">
<rect key="frame" x="176" y="174" width="96" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" focusRingType="none" drawsBackground="YES" usesSingleLineMode="YES" id="CV2-D9-WsB" customClass="GBCheatTextFieldCell">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textFieldCell>
<connections>
<action selector="consoleInput:" target="-2" id="SYC-cW-RjC"/>
<outlet property="delegate" destination="v7q-gT-jHT" id="P69-nT-oOt"/>
</connections>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" mirrorLayoutDirectionWhenInternationalizing="never" translatesAutoresizingMaskIntoConstraints="NO" id="S6O-LB-gSj">
<rect key="frame" x="176" y="144" width="96" height="21"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" focusRingType="none" drawsBackground="YES" usesSingleLineMode="YES" id="tpM-ys-MEO" customClass="GBCheatTextFieldCell">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<allowedInputSourceLocales>
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</textFieldCell>
<connections>
<action selector="consoleInput:" target="-2" id="io6-ha-QNb"/>
<outlet property="delegate" destination="v7q-gT-jHT" id="6RH-dg-SL7"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="uFo-ly-Veq">
<rect key="frame" x="16" y="204" width="152" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Change byte at address:" id="xwa-TF-eY1">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="6rU-Xg-KHc">
<rect key="frame" x="293" y="-1" width="400" height="275"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/>
<clipView key="contentView" id="mzf-yu-RID">
<rect key="frame" x="1" y="0.0" width="398" height="274"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" headerView="pvX-uJ-qK5" id="tA3-8T-bxb">
<rect key="frame" x="0.0" y="0.0" width="398" height="249"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="32" minWidth="32" maxWidth="1000" id="JNd-HW-LvS">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<buttonCell key="dataCell" type="bevel" bezelStyle="regularSquare" image="NSStopProgressFreestandingTemplate" imagePosition="only" inset="2" id="5xh-hN-jHH">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn width="60" minWidth="40" maxWidth="1000" id="9DZ-oW-Scx">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Enabled">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<buttonCell key="dataCell" type="check" bezelStyle="regularSquare" imagePosition="only" inset="2" id="SdJ-Xw-UAG">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn editable="NO" width="160" minWidth="40" maxWidth="1000" id="4Qa-FQ-QWY">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Description">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Description" id="1hX-Sr-bGz">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn editable="NO" width="134" minWidth="40" maxWidth="1000" id="ACq-gU-K36">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Action">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Action" id="8Sq-h9-eV7">
<font key="font" metaFont="fixedUser" size="11"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="v7q-gT-jHT" id="3ns-bk-yQI"/>
<outlet property="delegate" destination="v7q-gT-jHT" id="fVI-Z9-gTJ"/>
</connections>
</tableView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="3Hg-LL-VqH">
<rect key="frame" x="1" y="258" width="398" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="zET-KH-qF4">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="pvX-uJ-qK5">
<rect key="frame" x="0.0" y="0.0" width="398" height="25"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
</subviews>
</view>
<point key="canvasLocation" x="254" y="-463"/>
</window>
<customObject id="v7q-gT-jHT" customClass="GBCheatWindowController">
<connections>
<outlet property="addressField" destination="qHx-1z-daR" id="FWo-4u-Qse"/>
<outlet property="cheatsTable" destination="tA3-8T-bxb" id="Z2r-AQ-5th"/>
<outlet property="descriptionField" destination="C6E-oI-hDC" id="tc0-gI-FBa"/>
<outlet property="document" destination="-2" id="5NX-N4-5Rt"/>
<outlet property="importCodeField" destination="X7K-nJ-alF" id="ni0-zH-XDU"/>
<outlet property="importDescriptionField" destination="KHj-uX-Wbk" id="W0E-ec-BXk"/>
<outlet property="oldValueCheckbox" destination="Kq8-6F-9GK" id="A4a-nz-KMN"/>
<outlet property="oldValueField" destination="S6O-LB-gSj" id="fAc-OW-ZC9"/>
<outlet property="valueField" destination="N3I-PP-X85" id="0zP-9x-4LQ"/>
</connections>
</customObject>
</objects> </objects>
<resources>
<image name="NSFolder" width="32" height="32"/>
<image name="NSStopProgressFreestandingTemplate" width="14" height="14"/>
</resources>
</document> </document>

View File

@ -2,9 +2,9 @@
#import <Core/gb.h> #import <Core/gb.h>
@interface GBAudioClient : NSObject @interface GBAudioClient : NSObject
@property (strong) void (^renderBlock)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer); @property (nonatomic, strong) void (^renderBlock)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer);
@property (readonly) UInt32 rate; @property (nonatomic, readonly) UInt32 rate;
@property (readonly, getter=isPlaying) bool playing; @property (nonatomic, readonly, getter=isPlaying) bool playing;
-(void) start; -(void) start;
-(void) stop; -(void) stop;
-(id) initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block -(id) initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block

View File

@ -26,8 +26,7 @@ static OSStatus render(
-(id) initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block -(id) initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block
andSampleRate:(UInt32) rate andSampleRate:(UInt32) rate
{ {
if(!(self = [super init])) if (!(self = [super init])) {
{
return nil; return nil;
} }
@ -91,7 +90,7 @@ static OSStatus render(
{ {
OSErr err = AudioOutputUnitStart(audioUnit); OSErr err = AudioOutputUnitStart(audioUnit);
NSAssert1(err == noErr, @"Error starting unit: %hd", err); NSAssert1(err == noErr, @"Error starting unit: %hd", err);
_playing = YES; _playing = true;
} }
@ -99,10 +98,11 @@ static OSStatus render(
-(void) stop -(void) stop
{ {
AudioOutputUnitStop(audioUnit); AudioOutputUnitStop(audioUnit);
_playing = NO; _playing = false;
} }
-(void) dealloc { -(void) dealloc
{
[self stop]; [self stop];
AudioUnitUninitialize(audioUnit); AudioUnitUninitialize(audioUnit);
AudioComponentInstanceDispose(audioUnit); AudioComponentInstanceDispose(audioUnit);

View File

@ -2,10 +2,25 @@
@implementation GBBorderView @implementation GBBorderView
- (void)drawRect:(NSRect)dirtyRect {
[[NSColor blackColor] setFill]; - (void)awakeFromNib
NSRectFill(dirtyRect); {
[super drawRect:dirtyRect]; self.wantsLayer = true;
} }
- (BOOL)wantsUpdateLayer
{
return true;
}
- (void)updateLayer
{
/* Wonderful, wonderful windowserver(?) bug. Using 0,0,0 here would cause it to render garbage
on fullscreen windows on some High Sierra machines. Any other value, including the one used
here (which is rendered exactly the same due to rounding) works around this bug. */
self.layer.backgroundColor = [NSColor colorWithCalibratedRed:0
green:0
blue:1.0 / 1024.0
alpha:1.0].CGColor;
}
@end @end

View File

@ -13,13 +13,22 @@ typedef enum : NSUInteger {
GBTurbo, GBTurbo,
GBRewind, GBRewind,
GBUnderclock, GBUnderclock,
GBButtonCount GBButtonCount,
GBGameBoyButtonCount = GBStart + 1,
} GBButton; } GBButton;
extern NSString const *GBButtonNames[GBButtonCount]; extern NSString const *GBButtonNames[GBButtonCount];
static inline NSString *button_to_preference_name(GBButton button) static inline NSString *n2s(uint64_t number)
{ {
return [NSString stringWithFormat:@"%llx", number];
}
static inline NSString *button_to_preference_name(GBButton button, unsigned player)
{
if (player) {
return [NSString stringWithFormat:@"GBPlayer%d%@", player + 1, GBButtonNames[button]];
}
return [NSString stringWithFormat:@"GB%@", GBButtonNames[button]]; return [NSString stringWithFormat:@"GB%@", GBButtonNames[button]];
} }

View File

@ -0,0 +1,5 @@
#import <Cocoa/Cocoa.h>
@interface GBCheatTextFieldCell : NSTextFieldCell
@property (nonatomic) bool usesAddressFormat;
@end

View File

@ -0,0 +1,121 @@
#import "GBCheatTextFieldCell.h"
@interface GBCheatTextView : NSTextView
@property bool usesAddressFormat;
@end
@implementation GBCheatTextView
- (bool)_insertText:(NSString *)string replacementRange:(NSRange)range
{
if (range.location == NSNotFound) {
range = self.selectedRange;
}
NSString *new = [self.string stringByReplacingCharactersInRange:range withString:string];
if (!self.usesAddressFormat) {
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^(\\$[0-9A-Fa-f]{1,2}|[0-9]{1,3})$" options:0 error:NULL];
if ([regex numberOfMatchesInString:new options:0 range:NSMakeRange(0, new.length)]) {
[super insertText:string replacementRange:range];
return true;
}
if ([regex numberOfMatchesInString:[@"$" stringByAppendingString:new] options:0 range:NSMakeRange(0, new.length + 1)]) {
[super insertText:string replacementRange:range];
[super insertText:@"$" replacementRange:NSMakeRange(0, 0)];
return true;
}
if ([new isEqualToString:@"$"] || [string length] == 0) {
self.string = @"$00";
self.selectedRange = NSMakeRange(1, 2);
return true;
}
}
else {
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^(\\$[0-9A-Fa-f]{1,3}:)?\\$[0-9a-fA-F]{1,4}$" options:0 error:NULL];
if ([regex numberOfMatchesInString:new options:0 range:NSMakeRange(0, new.length)]) {
[super insertText:string replacementRange:range];
return true;
}
if ([string length] == 0) {
NSUInteger index = [new rangeOfString:@":"].location;
if (index != NSNotFound) {
if (range.location > index) {
self.string = [[new componentsSeparatedByString:@":"] firstObject];
self.selectedRange = NSMakeRange(self.string.length, 0);
return true;
}
self.string = [[new componentsSeparatedByString:@":"] lastObject];
self.selectedRange = NSMakeRange(0, 0);
return true;
}
else if ([[self.string substringWithRange:range] isEqualToString:@":"]) {
self.string = [[self.string componentsSeparatedByString:@":"] lastObject];
self.selectedRange = NSMakeRange(0, 0);
return true;
}
}
if ([new isEqualToString:@"$"] || [string length] == 0) {
self.string = @"$0000";
self.selectedRange = NSMakeRange(1, 4);
return true;
}
if (([string isEqualToString:@"$"] || [string isEqualToString:@":"]) && range.length == 0 && range.location == 0) {
if ([self _insertText:@"$00:" replacementRange:range]) {
self.selectedRange = NSMakeRange(1, 2);
return true;
}
}
if ([string isEqualToString:@":"] && range.length + range.location == self.string.length) {
if ([self _insertText:@":$0" replacementRange:range]) {
self.selectedRange = NSMakeRange(self.string.length - 2, 2);
return true;
}
}
if ([string isEqualToString:@"$"]) {
if ([self _insertText:@"$0" replacementRange:range]) {
self.selectedRange = NSMakeRange(range.location + 1, 1);
return true;
}
}
}
return false;
}
- (NSUndoManager *)undoManager
{
return nil;
}
- (void)insertText:(id)string replacementRange:(NSRange)replacementRange
{
if (![self _insertText:string replacementRange:replacementRange]) {
NSBeep();
}
}
/* Private API, don't tell the police! */
- (void)_userReplaceRange:(NSRange)range withString:(NSString *)string
{
[self insertText:string replacementRange:range];
}
@end
@implementation GBCheatTextFieldCell
{
bool _drawing, _editing;
GBCheatTextView *_fieldEditor;
}
- (NSTextView *)fieldEditorForView:(NSView *)controlView
{
if (_fieldEditor) {
_fieldEditor.usesAddressFormat = self.usesAddressFormat;
return _fieldEditor;
}
_fieldEditor = [[GBCheatTextView alloc] initWithFrame:controlView.frame];
_fieldEditor.fieldEditor = true;
_fieldEditor.usesAddressFormat = self.usesAddressFormat;
return _fieldEditor;
}
@end

View File

@ -0,0 +1,16 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import "Document.h"
@interface GBCheatWindowController : NSObject <NSTableViewDelegate, NSTableViewDataSource, NSTextFieldDelegate>
@property (nonatomic, weak) IBOutlet NSTableView *cheatsTable;
@property (nonatomic, weak) IBOutlet NSTextField *addressField;
@property (nonatomic, weak) IBOutlet NSTextField *valueField;
@property (nonatomic, weak) IBOutlet NSTextField *oldValueField;
@property (nonatomic, weak) IBOutlet NSButton *oldValueCheckbox;
@property (nonatomic, weak) IBOutlet NSTextField *descriptionField;
@property (nonatomic, weak) IBOutlet NSTextField *importCodeField;
@property (nonatomic, weak) IBOutlet NSTextField *importDescriptionField;
@property (nonatomic, weak) IBOutlet Document *document;
- (void)cheatsUpdated;
@end

View File

@ -0,0 +1,240 @@
#import "GBCheatWindowController.h"
#import "GBWarningPopover.h"
#import "GBCheatTextFieldCell.h"
@implementation GBCheatWindowController
+ (NSString *)addressStringFromCheat:(const GB_cheat_t *)cheat
{
if (cheat->bank != GB_CHEAT_ANY_BANK) {
return [NSString stringWithFormat:@"$%x:$%04x", cheat->bank, cheat->address];
}
return [NSString stringWithFormat:@"$%04x", cheat->address];
}
+ (NSString *)actionDescriptionForCheat:(const GB_cheat_t *)cheat
{
if (cheat->use_old_value) {
return [NSString stringWithFormat:@"[%@]($%02x) = $%02x", [self addressStringFromCheat:cheat], cheat->old_value, cheat->value];
}
return [NSString stringWithFormat:@"[%@] = $%02x", [self addressStringFromCheat:cheat], cheat->value];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return 0;
size_t cheatCount;
GB_get_cheats(gb, &cheatCount);
return cheatCount + 1;
}
- (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return nil;
size_t cheatCount;
GB_get_cheats(gb, &cheatCount);
NSUInteger columnIndex = [[tableView tableColumns] indexOfObject:tableColumn];
if (row >= cheatCount && columnIndex == 0) {
return [[NSCell alloc] init];
}
return nil;
}
- (nullable id)tableView:(NSTableView *)tableView objectValueForTableColumn:(nullable NSTableColumn *)tableColumn row:(NSInteger)row
{
size_t cheatCount;
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return nil;
const GB_cheat_t *const *cheats = GB_get_cheats(gb, &cheatCount);
NSUInteger columnIndex = [[tableView tableColumns] indexOfObject:tableColumn];
if (row >= cheatCount) {
switch (columnIndex) {
case 0:
return @YES;
case 1:
return @NO;
case 2:
return @"Add Cheat...";
case 3:
return @"";
}
}
switch (columnIndex) {
case 0:
return @NO;
case 1:
return @(cheats[row]->enabled);
case 2:
return @(cheats[row]->description);
case 3:
return [GBCheatWindowController actionDescriptionForCheat:cheats[row]];
}
return nil;
}
- (IBAction)importCheat:(id)sender
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return;
[self.document performAtomicBlock:^{
if (GB_import_cheat(gb,
self.importCodeField.stringValue.UTF8String,
self.importDescriptionField.stringValue.UTF8String,
true)) {
self.importCodeField.stringValue = @"";
self.importDescriptionField.stringValue = @"";
[self.cheatsTable reloadData];
[self tableViewSelectionDidChange:nil];
}
else {
NSBeep();
[GBWarningPopover popoverWithContents:@"This code is not a valid GameShark or GameGenie code" onView:self.importCodeField];
}
}];
}
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return;
size_t cheatCount;
const GB_cheat_t *const *cheats = GB_get_cheats(gb, &cheatCount);
NSUInteger columnIndex = [[tableView tableColumns] indexOfObject:tableColumn];
[self.document performAtomicBlock:^{
if (columnIndex == 1) {
if (row >= cheatCount) {
GB_add_cheat(gb, "New Cheat", 0, 0, 0, 0, false, true);
}
else {
GB_update_cheat(gb, cheats[row], cheats[row]->description, cheats[row]->address, cheats[row]->bank, cheats[row]->value, cheats[row]->old_value, cheats[row]->use_old_value, !cheats[row]->enabled);
}
}
else if (row < cheatCount) {
GB_remove_cheat(gb, cheats[row]);
}
}];
[self.cheatsTable reloadData];
[self tableViewSelectionDidChange:nil];
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return;
size_t cheatCount;
const GB_cheat_t *const *cheats = GB_get_cheats(gb, &cheatCount);
unsigned row = self.cheatsTable.selectedRow;
const GB_cheat_t *cheat = NULL;
if (row >= cheatCount) {
static const GB_cheat_t template = {
.address = 0,
.bank = 0,
.value = 0,
.old_value = 0,
.use_old_value = false,
.enabled = false,
.description = "New Cheat",
};
cheat = &template;
}
else {
cheat = cheats[row];
}
self.addressField.stringValue = [GBCheatWindowController addressStringFromCheat:cheat];
self.valueField.stringValue = [NSString stringWithFormat:@"$%02x", cheat->value];
self.oldValueField.stringValue = [NSString stringWithFormat:@"$%02x", cheat->old_value];
self.oldValueCheckbox.state = cheat->use_old_value;
self.descriptionField.stringValue = @(cheat->description);
}
- (void)awakeFromNib
{
[self tableViewSelectionDidChange:nil];
((GBCheatTextFieldCell *)self.addressField.cell).usesAddressFormat = true;
}
- (void)controlTextDidChange:(NSNotification *)obj
{
[self updateCheat:nil];
}
- (IBAction)updateCheat:(id)sender
{
GB_gameboy_t *gb = self.document.gameboy;
if (!gb) return;
uint16_t address = 0;
uint16_t bank = GB_CHEAT_ANY_BANK;
if ([self.addressField.stringValue rangeOfString:@":"].location != NSNotFound) {
sscanf(self.addressField.stringValue.UTF8String, "$%hx:$%hx", &bank, &address);
}
else {
sscanf(self.addressField.stringValue.UTF8String, "$%hx", &address);
}
uint8_t value = 0;
if ([self.valueField.stringValue characterAtIndex:0] == '$') {
sscanf(self.valueField.stringValue.UTF8String, "$%02hhx", &value);
}
else {
sscanf(self.valueField.stringValue.UTF8String, "%hhd", &value);
}
uint8_t oldValue = 0;
if ([self.oldValueField.stringValue characterAtIndex:0] == '$') {
sscanf(self.oldValueField.stringValue.UTF8String, "$%02hhx", &oldValue);
}
else {
sscanf(self.oldValueField.stringValue.UTF8String, "%hhd", &oldValue);
}
size_t cheatCount;
const GB_cheat_t *const *cheats = GB_get_cheats(gb, &cheatCount);
unsigned row = self.cheatsTable.selectedRow;
[self.document performAtomicBlock:^{
if (row >= cheatCount) {
GB_add_cheat(gb,
self.descriptionField.stringValue.UTF8String,
address,
bank,
value,
oldValue,
self.oldValueCheckbox.state,
false);
}
else {
GB_update_cheat(gb,
cheats[row],
self.descriptionField.stringValue.UTF8String,
address,
bank,
value,
oldValue,
self.oldValueCheckbox.state,
cheats[row]->enabled);
}
}];
[self.cheatsTable reloadData];
}
- (void)cheatsUpdated
{
[self.cheatsTable reloadData];
[self tableViewSelectionDidChange:nil];
}
@end

View File

@ -14,7 +14,13 @@ static inline double scale_channel(uint8_t x)
- (void)setObjectValue:(id)objectValue - (void)setObjectValue:(id)objectValue
{ {
_integerValue = [objectValue integerValue]; _integerValue = [objectValue integerValue];
super.objectValue = [NSString stringWithFormat:@"$%04x", (uint16_t)(_integerValue & 0x7FFF)]; uint8_t r = _integerValue & 0x1F,
g = (_integerValue >> 5) & 0x1F,
b = (_integerValue >> 10) & 0x1F;
super.objectValue = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"$%04x", (uint16_t)(_integerValue & 0x7FFF)] attributes:@{
NSForegroundColorAttributeName: r * 3 + g * 4 + b * 2 > 120? [NSColor blackColor] : [NSColor whiteColor],
NSFontAttributeName: [NSFont userFixedPitchFontOfSize:12]
}];
} }
- (NSInteger)integerValue - (NSInteger)integerValue
@ -30,13 +36,14 @@ static inline double scale_channel(uint8_t x)
- (NSColor *) backgroundColor - (NSColor *) backgroundColor
{ {
/* Todo: color correction */
uint16_t color = self.integerValue; uint16_t color = self.integerValue;
return [NSColor colorWithRed:scale_channel(color) green:scale_channel(color >> 5) blue:scale_channel(color >> 10) alpha:1.0]; return [NSColor colorWithRed:scale_channel(color) green:scale_channel(color >> 5) blue:scale_channel(color >> 10) alpha:1.0];
} }
- (BOOL)drawsBackground - (BOOL)drawsBackground
{ {
return YES; return true;
} }
@end @end

7
Cocoa/GBGLShader.h Normal file
View File

@ -0,0 +1,7 @@
#import <Foundation/Foundation.h>
#import "GBView.h"
@interface GBGLShader : NSObject
- (instancetype)initWithName:(NSString *) shaderName;
- (void) renderBitmap: (void *)bitmap previous:(void*) previous sized:(NSSize)srcSize inSize:(NSSize)dstSize scale: (double) scale withBlendingMode: (GB_frame_blending_mode_t)blendingMode;
@end

View File

@ -1,4 +1,4 @@
#import "GBShader.h" #import "GBGLShader.h"
#import <OpenGL/gl3.h> #import <OpenGL/gl3.h>
/* /*
@ -16,12 +16,12 @@ void main(void) {\n\
}\n\ }\n\
"; ";
@implementation GBShader @implementation GBGLShader
{ {
GLuint resolution_uniform; GLuint resolution_uniform;
GLuint texture_uniform; GLuint texture_uniform;
GLuint previous_texture_uniform; GLuint previous_texture_uniform;
GLuint mix_previous_uniform; GLuint frame_blending_mode_uniform;
GLuint position_attribute; GLuint position_attribute;
GLuint texture; GLuint texture;
@ -50,7 +50,7 @@ void main(void) {\n\
// Attributes // Attributes
position_attribute = glGetAttribLocation(program, "aPosition"); position_attribute = glGetAttribLocation(program, "aPosition");
// Uniforms // Uniforms
resolution_uniform = glGetUniformLocation(program, "uResolution"); resolution_uniform = glGetUniformLocation(program, "output_resolution");
glGenTextures(1, &texture); glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
@ -68,9 +68,9 @@ void main(void) {\n\
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
previous_texture_uniform = glGetUniformLocation(program, "previousImage"); previous_texture_uniform = glGetUniformLocation(program, "previous_image");
mix_previous_uniform = glGetUniformLocation(program, "uMixPrevious"); frame_blending_mode_uniform = glGetUniformLocation(program, "frame_blending_mode");
// Configure OpenGL // Configure OpenGL
[self configureOpenGL]; [self configureOpenGL];
@ -79,19 +79,19 @@ void main(void) {\n\
return self; return self;
} }
- (void) renderBitmap: (void *)bitmap previous:(void*) previous inSize:(NSSize)size scale: (double) scale - (void) renderBitmap: (void *)bitmap previous:(void*) previous sized:(NSSize)srcSize inSize:(NSSize)dstSize scale: (double) scale withBlendingMode:(GB_frame_blending_mode_t)blendingMode
{ {
glUseProgram(program); glUseProgram(program);
glUniform2f(resolution_uniform, size.width * scale, size.height * scale); glUniform2f(resolution_uniform, dstSize.width * scale, dstSize.height * scale);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 160, 144, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, srcSize.width, srcSize.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap);
glUniform1i(texture_uniform, 0); glUniform1i(texture_uniform, 0);
glUniform1i(mix_previous_uniform, previous != NULL); glUniform1i(frame_blending_mode_uniform, blendingMode);
if (previous) { if (blendingMode) {
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, previous_texture); glBindTexture(GL_TEXTURE_2D, previous_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 160, 144, 0, GL_RGBA, GL_UNSIGNED_BYTE, previous); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, srcSize.width, srcSize.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, previous);
glUniform1i(previous_texture_uniform, 1); glUniform1i(previous_texture_uniform, 1);
} }
glBindFragDataLocation(program, 0, "frag_color"); glBindFragDataLocation(program, 0, "frag_color");

9
Cocoa/GBHueSliderCell.h Normal file
View File

@ -0,0 +1,9 @@
#import <Cocoa/Cocoa.h>
@interface NSSlider (GBHueSlider)
-(NSColor *)colorValue;
@end
@interface GBHueSliderCell : NSSliderCell
-(NSColor *)colorValue;
@end

113
Cocoa/GBHueSliderCell.m Normal file
View File

@ -0,0 +1,113 @@
#import "GBHueSliderCell.h"
@interface NSSliderCell(privateAPI)
- (double)_normalizedDoubleValue;
@end
@implementation GBHueSliderCell
{
bool _drawingTrack;
}
-(NSColor *)colorValue
{
double hue = self.doubleValue / 360.0;
double r = 0, g = 0, b =0 ;
double t = fmod(hue * 6, 1);
switch ((int)(hue * 6) % 6) {
case 0:
r = 1;
g = t;
break;
case 1:
r = 1 - t;
g = 1;
break;
case 2:
g = 1;
b = t;
break;
case 3:
g = 1 - t;
b = 1;
break;
case 4:
b = 1;
r = t;
break;
case 5:
b = 1 - t;
r = 1;
break;
}
return [NSColor colorWithRed:r green:g blue:b alpha:1.0];
}
-(void)drawKnob:(NSRect)knobRect
{
[super drawKnob:knobRect];
NSRect peekRect = knobRect;
peekRect.size.width /= 2;
peekRect.size.height = peekRect.size.width;
peekRect.origin.x += peekRect.size.width / 2;
peekRect.origin.y += peekRect.size.height / 2;
NSColor *color = self.colorValue;
if (!self.enabled) {
color = [color colorWithAlphaComponent:0.5];
}
[color setFill];
NSBezierPath *path = [NSBezierPath bezierPathWithOvalInRect:peekRect];
[path fill];
[[NSColor colorWithWhite:0 alpha:0.25] setStroke];
[path setLineWidth:0.5];
[path stroke];
}
-(double)_normalizedDoubleValue
{
if (_drawingTrack) return 0;
return [super _normalizedDoubleValue];
}
-(void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped
{
if (!self.enabled) {
[super drawBarInside:rect flipped:flipped];
return;
}
_drawingTrack = true;
[super drawBarInside:rect flipped:flipped];
_drawingTrack = false;
NSGradient *gradient = [[NSGradient alloc] initWithColors:@[
[NSColor redColor],
[NSColor yellowColor],
[NSColor greenColor],
[NSColor cyanColor],
[NSColor blueColor],
[NSColor magentaColor],
[NSColor redColor],
]];
rect.origin.y += rect.size.height / 2 - 0.5;
rect.size.height = 1;
rect.size.width -= 2;
rect.origin.x += 1;
[[NSColor redColor] set];
NSRectFill(rect);
rect.size.width -= self.knobThickness + 2;
rect.origin.x += self.knobThickness / 2 - 1;
[gradient drawInRect:rect angle:0];
}
@end
@implementation NSSlider (GBHueSlider)
- (NSColor *)colorValue
{
return ((GBHueSliderCell *)self.cell).colorValue;
}
@end

View File

@ -3,7 +3,7 @@
@implementation GBImageCell @implementation GBImageCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{ {
CGContextRef context = [[NSGraphicsContext currentContext] CGContext]; CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetInterpolationQuality(context, kCGInterpolationNone); CGContextSetInterpolationQuality(context, kCGInterpolationNone);
[super drawWithFrame:cellFrame inView:controlView]; [super drawWithFrame:cellFrame inView:controlView];
} }

View File

@ -3,15 +3,17 @@
@protocol GBImageViewDelegate; @protocol GBImageViewDelegate;
@interface GBImageViewGridConfiguration : NSObject @interface GBImageViewGridConfiguration : NSObject
@property NSColor *color; @property (nonatomic, strong) NSColor *color;
@property NSUInteger size; @property (nonatomic) NSUInteger size;
- (instancetype) initWithColor: (NSColor *) color size: (NSUInteger) size; - (instancetype) initWithColor: (NSColor *) color size: (NSUInteger) size;
@end @end
@interface GBImageView : NSImageView @interface GBImageView : NSImageView
@property (nonatomic) NSArray *horizontalGrids; @property (nonatomic, strong) NSArray<GBImageViewGridConfiguration *> *horizontalGrids;
@property (nonatomic) NSArray *verticalGrids; @property (nonatomic, strong) NSArray<GBImageViewGridConfiguration *> *verticalGrids;
@property (weak) IBOutlet id<GBImageViewDelegate> delegate; @property (nonatomic) bool displayScrollRect;
@property NSRect scrollRect;
@property (nonatomic, weak) IBOutlet id<GBImageViewDelegate> delegate;
@end @end
@protocol GBImageViewDelegate <NSObject> @protocol GBImageViewDelegate <NSObject>

View File

@ -16,7 +16,7 @@
} }
- (void)drawRect:(NSRect)dirtyRect - (void)drawRect:(NSRect)dirtyRect
{ {
CGContextRef context = [[NSGraphicsContext currentContext] CGContext]; CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetInterpolationQuality(context, kCGInterpolationNone); CGContextSetInterpolationQuality(context, kCGInterpolationNone);
[super drawRect:dirtyRect]; [super drawRect:dirtyRect];
CGFloat y_ratio = self.frame.size.height / self.image.size.height; CGFloat y_ratio = self.frame.size.height / self.image.size.height;
@ -25,8 +25,8 @@
[conf.color set]; [conf.color set];
for (CGFloat y = conf.size * y_ratio; y < self.frame.size.height; y += conf.size * y_ratio) { for (CGFloat y = conf.size * y_ratio; y < self.frame.size.height; y += conf.size * y_ratio) {
NSBezierPath *line = [NSBezierPath bezierPath]; NSBezierPath *line = [NSBezierPath bezierPath];
[line moveToPoint:NSMakePoint(0, y + 0.5)]; [line moveToPoint:NSMakePoint(0, y - 0.5)];
[line lineToPoint:NSMakePoint(self.frame.size.width, y + 0.5)]; [line lineToPoint:NSMakePoint(self.frame.size.width, y - 0.5)];
[line setLineWidth:1.0]; [line setLineWidth:1.0];
[line stroke]; [line stroke];
} }
@ -42,6 +42,35 @@
[line stroke]; [line stroke];
} }
} }
if (self.displayScrollRect) {
NSBezierPath *path = [NSBezierPath bezierPathWithRect:CGRectInfinite];
for (unsigned x = 0; x < 2; x++) {
for (unsigned y = 0; y < 2; y++) {
NSRect rect = self.scrollRect;
rect.origin.x *= x_ratio;
rect.origin.y *= y_ratio;
rect.size.width *= x_ratio;
rect.size.height *= y_ratio;
rect.origin.y = self.frame.size.height - rect.origin.y - rect.size.height;
rect.origin.x -= self.frame.size.width * x;
rect.origin.y += self.frame.size.height * y;
NSBezierPath *subpath = [NSBezierPath bezierPathWithRect:rect];
[path appendBezierPath:subpath];
}
}
[path setWindingRule:NSEvenOddWindingRule];
[path setLineWidth:4.0];
[path setLineJoinStyle:NSRoundLineJoinStyle];
[[NSColor colorWithWhite:0.2 alpha:0.5] set];
[path fill];
[path addClip];
[[NSColor colorWithWhite:0.0 alpha:0.6] set];
[path stroke];
}
} }
- (void)setHorizontalGrids:(NSArray *)horizontalGrids - (void)setHorizontalGrids:(NSArray *)horizontalGrids
@ -56,6 +85,12 @@
[self setNeedsDisplay]; [self setNeedsDisplay];
} }
- (void)setDisplayScrollRect:(bool)displayScrollRect
{
self->_displayScrollRect = displayScrollRect;
[self setNeedsDisplay];
}
- (void)updateTrackingAreas - (void)updateTrackingAreas
{ {
if (trackingArea != nil) { if (trackingArea != nil) {

View File

@ -1,8 +0,0 @@
#import <AppKit/AppKit.h>
@protocol GBJoystickListener <NSObject>
- (void) joystick:(NSString *)joystick_name button: (unsigned)button changedState: (bool) state;
- (void) joystick:(NSString *)joystick_name axis: (unsigned)axis movedTo: (signed) value;
@end

View File

@ -12,6 +12,6 @@ typedef enum {
@interface GBMemoryByteArray : HFByteArray @interface GBMemoryByteArray : HFByteArray
- (instancetype) initWithDocument:(Document *)document; - (instancetype) initWithDocument:(Document *)document;
@property uint16_t selectedBank; @property (nonatomic) uint16_t selectedBank;
@property GB_memory_mode_t mode; @property (nonatomic) GB_memory_mode_t mode;
@end @end

View File

@ -54,7 +54,7 @@
break; break;
case GBMemoryVRAM: case GBMemoryVRAM:
bank_backup = gb->cgb_vram_bank; bank_backup = gb->cgb_vram_bank;
if (gb->is_cgb) { if (GB_is_cgb(gb)) {
gb->cgb_vram_bank = self.selectedBank; gb->cgb_vram_bank = self.selectedBank;
} }
addr += 0x8000; addr += 0x8000;
@ -66,7 +66,7 @@
break; break;
case GBMemoryRAM: case GBMemoryRAM:
bank_backup = gb->cgb_ram_bank; bank_backup = gb->cgb_ram_bank;
if (gb->is_cgb) { if (GB_is_cgb(gb)) {
gb->cgb_ram_bank = self.selectedBank; gb->cgb_ram_bank = self.selectedBank;
} }
addr += 0xC000; addr += 0xC000;
@ -127,7 +127,7 @@
break; break;
case GBMemoryVRAM: case GBMemoryVRAM:
bank_backup = gb->cgb_vram_bank; bank_backup = gb->cgb_vram_bank;
if (gb->is_cgb) { if (GB_is_cgb(gb)) {
gb->cgb_vram_bank = self.selectedBank; gb->cgb_vram_bank = self.selectedBank;
} }
addr += 0x8000; addr += 0x8000;
@ -139,7 +139,7 @@
break; break;
case GBMemoryRAM: case GBMemoryRAM:
bank_backup = gb->cgb_ram_bank; bank_backup = gb->cgb_ram_bank;
if (gb->is_cgb) { if (GB_is_cgb(gb)) {
gb->cgb_ram_bank = self.selectedBank; gb->cgb_ram_bank = self.selectedBank;
} }
addr += 0xC000; addr += 0xC000;

6
Cocoa/GBOSDView.h Normal file
View File

@ -0,0 +1,6 @@
#import <Cocoa/Cocoa.h>
@interface GBOSDView : NSView
@property bool usesSGBScale;
- (void)displayText:(NSString *)text;
@end

104
Cocoa/GBOSDView.m Normal file
View File

@ -0,0 +1,104 @@
#import "GBOSDView.h"
@implementation GBOSDView
{
bool _usesSGBScale;
NSString *_text;
double _animation;
NSTimer *_timer;
}
- (void)setUsesSGBScale:(bool)usesSGBScale
{
_usesSGBScale = usesSGBScale;
[self setNeedsDisplay:true];
}
- (bool)usesSGBScale
{
return _usesSGBScale;
}
- (void)displayText:(NSString *)text
{
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"GBOSDEnabled"]) return;
dispatch_async(dispatch_get_main_queue(), ^{
if (![_text isEqualToString:text]) {
[self setNeedsDisplay:true];
}
_text = text;
self.alphaValue = 1.0;
_animation = 2.5;
// Longer strings should appear longer
if ([_text rangeOfString:@"\n"].location != NSNotFound) {
_animation += 4;
}
[_timer invalidate];
self.hidden = false;
_timer = [NSTimer scheduledTimerWithTimeInterval:0.025 target:self selector:@selector(animate) userInfo:nil repeats:true];
});
}
- (void)animate
{
_animation -= 0.1;
if (_animation < 1.0) {
self.alphaValue = _animation;
};
if (_animation == 0) {
self.hidden = true;
[_timer invalidate];
_text = nil;
}
}
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
if (!_text.length) return;
double fontSize = 8;
NSSize size = self.frame.size;
if (_usesSGBScale) {
fontSize *= MIN(size.width / 256, size.height / 224);
}
else {
fontSize *= MIN(size.width / 160, size.height / 144);
}
NSFont *font = [NSFont boldSystemFontOfSize:fontSize];
/* The built in stroke attribute uses an inside stroke, which is typographically terrible.
We'll use a naïve manual stroke instead which looks better. */
NSDictionary *attributes = @{
NSFontAttributeName: font,
NSForegroundColorAttributeName: [NSColor blackColor],
};
NSAttributedString *text = [[NSAttributedString alloc] initWithString:_text attributes:attributes];
[text drawAtPoint:NSMakePoint(fontSize + 1, fontSize + 0)];
[text drawAtPoint:NSMakePoint(fontSize - 1, fontSize + 0)];
[text drawAtPoint:NSMakePoint(fontSize + 0, fontSize + 1)];
[text drawAtPoint:NSMakePoint(fontSize + 0, fontSize - 1)];
// The uses of sqrt(2)/2, which is more correct, results in severe ugly-looking rounding errors
if (self.window.screen.backingScaleFactor > 1) {
[text drawAtPoint:NSMakePoint(fontSize + 0.5, fontSize + 0.5)];
[text drawAtPoint:NSMakePoint(fontSize - 0.5, fontSize + 0.5)];
[text drawAtPoint:NSMakePoint(fontSize - 0.5, fontSize - 0.5)];
[text drawAtPoint:NSMakePoint(fontSize + 0.5, fontSize - 0.5)];
}
attributes = @{
NSFontAttributeName: font,
NSForegroundColorAttributeName: [NSColor whiteColor],
};
text = [[NSAttributedString alloc] initWithString:_text attributes:attributes];
[text drawAtPoint:NSMakePoint(fontSize, fontSize)];
}
@end

6
Cocoa/GBOpenGLView.h Normal file
View File

@ -0,0 +1,6 @@
#import <Cocoa/Cocoa.h>
#import "GBGLShader.h"
@interface GBOpenGLView : NSOpenGLView
@property (nonatomic) GBGLShader *shader;
@end

39
Cocoa/GBOpenGLView.m Normal file
View File

@ -0,0 +1,39 @@
#import "GBOpenGLView.h"
#import "GBView.h"
#include <OpenGL/gl.h>
@implementation GBOpenGLView
- (void)drawRect:(NSRect)dirtyRect
{
if (!self.shader) {
self.shader = [[GBGLShader alloc] initWithName:[[NSUserDefaults standardUserDefaults] objectForKey:@"GBFilter"]];
}
GBView *gbview = (GBView *)self.superview;
double scale = self.window.backingScaleFactor;
glViewport(0, 0, self.bounds.size.width * scale, self.bounds.size.height * scale);
if (gbview.gb) {
[self.shader renderBitmap:gbview.currentBuffer
previous:gbview.frameBlendingMode? gbview.previousBuffer : NULL
sized:NSMakeSize(GB_get_screen_width(gbview.gb), GB_get_screen_height(gbview.gb))
inSize:self.bounds.size
scale:scale
withBlendingMode:gbview.frameBlendingMode];
}
glFlush();
}
- (instancetype)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat *)format
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(filterChanged) name:@"GBFilterChanged" object:nil];
return [super initWithFrame:frameRect pixelFormat:format];
}
- (void) filterChanged
{
self.shader = nil;
[self setNeedsDisplay:true];
}
@end

View File

@ -0,0 +1,6 @@
#import <Cocoa/Cocoa.h>
/* Fake interface so the compiler assumes it conforms to NSVisualEffectView */
@interface GBOptionalVisualEffectView : NSVisualEffectView
@end

View File

@ -0,0 +1,18 @@
#import <Cocoa/Cocoa.h>
@interface GBOptionalVisualEffectView : NSView
@end
@implementation GBOptionalVisualEffectView
+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
Class NSVisualEffectView = NSClassFromString(@"NSVisualEffectView");
if (NSVisualEffectView) {
return (id)[NSVisualEffectView alloc];
}
return [super allocWithZone:zone];
}
@end

View File

@ -0,0 +1,18 @@
#import <AppKit/AppKit.h>
#import <Core/gb.h>
@interface GBPaletteEditorController : NSObject<NSTableViewDataSource, NSTableViewDelegate>
@property (weak) IBOutlet NSColorWell *colorWell0;
@property (weak) IBOutlet NSColorWell *colorWell1;
@property (weak) IBOutlet NSColorWell *colorWell2;
@property (weak) IBOutlet NSColorWell *colorWell3;
@property (weak) IBOutlet NSColorWell *colorWell4;
@property (weak) IBOutlet NSButton *disableLCDColorCheckbox;
@property (weak) IBOutlet NSButton *manualModeCheckbox;
@property (weak) IBOutlet NSSlider *brightnessSlider;
@property (weak) IBOutlet NSSlider *hueSlider;
@property (weak) IBOutlet NSSlider *hueStrengthSlider;
@property (weak) IBOutlet NSTableView *themesList;
@property (weak) IBOutlet NSMenu *menu;
+ (const GB_palette_t *)userPalette;
@end

View File

@ -0,0 +1,378 @@
#import "GBPaletteEditorController.h"
#import "GBHueSliderCell.h"
#import <Core/gb.h>
#define MAGIC 'SBPL'
typedef struct __attribute__ ((packed)) {
uint32_t magic;
bool manual:1;
bool disabled_lcd_color:1;
unsigned padding:6;
struct GB_color_s colors[5];
int32_t brightness_bias;
uint32_t hue_bias;
uint32_t hue_bias_strength;
} theme_t;
static double blend(double from, double to, double position)
{
return from * (1 - position) + to * position;
}
@implementation NSColor (GBColor)
- (struct GB_color_s)gbColor
{
NSColor *sRGB = [self colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
return (struct GB_color_s){round(sRGB.redComponent * 255), round(sRGB.greenComponent * 255), round(sRGB.blueComponent * 255)};
}
- (uint32_t)intValue
{
struct GB_color_s color = self.gbColor;
return (color.r << 0) | (color.g << 8) | (color.b << 16) | 0xFF000000;
}
@end
@implementation GBPaletteEditorController
- (NSArray<NSColorWell *> *)colorWells
{
return @[_colorWell0, _colorWell1, _colorWell2, _colorWell3, _colorWell4];
}
- (void)updateEnabledControls
{
if (self.manualModeCheckbox.state) {
_brightnessSlider.enabled = false;
_hueSlider.enabled = false;
_hueStrengthSlider.enabled = false;
_colorWell1.enabled = true;
_colorWell2.enabled = true;
_colorWell3.enabled = true;
if (!(_colorWell4.enabled = self.disableLCDColorCheckbox.state)) {
_colorWell4.color = _colorWell3.color;
}
}
else {
_colorWell1.enabled = false;
_colorWell2.enabled = false;
_colorWell3.enabled = false;
_colorWell4.enabled = true;
_brightnessSlider.enabled = true;
_hueSlider.enabled = true;
_hueStrengthSlider.enabled = true;
[self updateAutoColors];
}
}
- (NSColor *)autoColorAtPositon:(double)position
{
NSColor *first = [_colorWell0.color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
NSColor *second = [_colorWell4.color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
double brightness = 1 / pow(4, (_brightnessSlider.doubleValue - 128) / 128.0);
position = pow(position, brightness);
NSColor *hue = _hueSlider.colorValue;
double bias = _hueStrengthSlider.doubleValue / 256.0;
double red = 1 / pow(4, (hue.redComponent * 2 - 1) * bias);
double green = 1 / pow(4, (hue.greenComponent * 2 - 1) * bias);
double blue = 1 / pow(4, (hue.blueComponent * 2 - 1) * bias);
NSColor *ret = [NSColor colorWithRed:blend(first.redComponent, second.redComponent, pow(position, red))
green:blend(first.greenComponent, second.greenComponent, pow(position, green))
blue:blend(first.blueComponent, second.blueComponent, pow(position, blue))
alpha:1.0];
return ret;
}
- (IBAction)updateAutoColors:(id)sender
{
if (!self.manualModeCheckbox.state) {
[self updateAutoColors];
}
else {
[self savePalette:sender];
}
}
- (void)updateAutoColors
{
if (_disableLCDColorCheckbox.state) {
_colorWell1.color = [self autoColorAtPositon:8 / 25.0];
_colorWell2.color = [self autoColorAtPositon:16 / 25.0];
_colorWell3.color = [self autoColorAtPositon:24 / 25.0];
}
else {
_colorWell1.color = [self autoColorAtPositon:1 / 3.0];
_colorWell2.color = [self autoColorAtPositon:2 / 3.0];
_colorWell3.color = _colorWell4.color;
}
[self savePalette:nil];
}
- (IBAction)disabledLCDColorCheckboxChanged:(id)sender
{
[self updateEnabledControls];
}
- (IBAction)manualModeChanged:(id)sender
{
[self updateEnabledControls];
}
- (IBAction)updateColor4:(id)sender
{
if (!self.disableLCDColorCheckbox.state) {
self.colorWell4.color = self.colorWell3.color;
}
[self savePalette:self];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *themes = [defaults dictionaryForKey:@"GBThemes"];
if (themes.count == 0) {
[defaults setObject:@"Untitled Palette" forKey:@"GBCurrentTheme"];
[self savePalette:nil];
return 1;
}
return themes.count;
}
-(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
NSString *oldName = [self tableView:tableView objectValueForTableColumn:tableColumn row:row];
if ([oldName isEqualToString:object]) {
return;
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *themes = [[defaults dictionaryForKey:@"GBThemes"] ?: @{} mutableCopy];
NSString *newName = object;
unsigned i = 2;
if (!newName.length) {
newName = @"Untitled Palette";
}
while (themes[newName]) {
newName = [NSString stringWithFormat:@"%@ %d", object, i];
}
themes[newName] = themes[oldName];
[themes removeObjectForKey:oldName];
if ([oldName isEqualToString:[defaults stringForKey:@"GBCurrentTheme"]]) {
[defaults setObject:newName forKey:@"GBCurrentTheme"];
}
[defaults setObject:themes forKey:@"GBThemes"];
[tableView reloadData];
[self awakeFromNib];
}
- (IBAction)deleteTheme:(id)sender
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *name = [defaults stringForKey:@"GBCurrentTheme"];
NSMutableDictionary *themes = [[defaults dictionaryForKey:@"GBThemes"] ?: @{} mutableCopy];
[themes removeObjectForKey:name];
[defaults setObject:themes forKey:@"GBThemes"];
[_themesList reloadData];
[self awakeFromNib];
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
NSString *name = [self tableView:nil objectValueForTableColumn:nil row:_themesList.selectedRow];
[[NSUserDefaults standardUserDefaults] setObject:name forKey:@"GBCurrentTheme"];
[self loadPalette];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBColorPaletteChanged" object:nil];
}
- (void)tableViewSelectionIsChanging:(NSNotification *)notification
{
[self tableViewSelectionDidChange:notification];
}
- (void)awakeFromNib
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *themes = [defaults dictionaryForKey:@"GBThemes"];
NSString *theme = [defaults stringForKey:@"GBCurrentTheme"];
if (theme && themes[theme]) {
unsigned index = [[themes.allKeys sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)] indexOfObject:theme];
[_themesList selectRowIndexes:[NSIndexSet indexSetWithIndex:index] byExtendingSelection:false];
}
else {
[_themesList selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:false];
}
[self tableViewSelectionDidChange:nil];
}
- (IBAction)addTheme:(id)sender
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *themes = [defaults dictionaryForKey:@"GBThemes"];
NSString *newName = @"Untitled Palette";
unsigned i = 2;
while (themes[newName]) {
newName = [NSString stringWithFormat:@"Untitled Palette %d", i++];
}
[defaults setObject:newName forKey:@"GBCurrentTheme"];
[self savePalette:sender];
[_themesList reloadData];
[self awakeFromNib];
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *themes = [defaults dictionaryForKey:@"GBThemes"];
return [themes.allKeys sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)][row];
}
- (void)loadPalette
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *theme = [defaults dictionaryForKey:@"GBThemes"][[defaults stringForKey:@"GBCurrentTheme"]];
NSArray *colors = theme[@"Colors"];
if (colors.count == 5) {
unsigned i = 0;
for (NSNumber *color in colors) {
uint32_t c = [color unsignedIntValue];
self.colorWells[i++].color = [NSColor colorWithRed:(c & 0xFF) / 255.0
green:((c >> 8) & 0xFF) / 255.0
blue:((c >> 16) & 0xFF) / 255.0
alpha:1.0];
}
}
_disableLCDColorCheckbox.state = [theme[@"DisabledLCDColor"] boolValue];
_manualModeCheckbox.state = [theme[@"Manual"] boolValue];
_brightnessSlider.doubleValue = [theme[@"BrightnessBias"] doubleValue] * 128 + 128;
_hueSlider.doubleValue = [theme[@"HueBias"] doubleValue] * 360;
_hueStrengthSlider.doubleValue = [theme[@"HueBiasStrength"] doubleValue] * 256;
[self updateEnabledControls];
}
- (IBAction)savePalette:(id)sender
{
NSDictionary *theme = @{
@"Colors":
@[@(_colorWell0.color.intValue),
@(_colorWell1.color.intValue),
@(_colorWell2.color.intValue),
@(_colorWell3.color.intValue),
@(_colorWell4.color.intValue)],
@"DisabledLCDColor": _disableLCDColorCheckbox.state? @YES : @NO,
@"Manual": _manualModeCheckbox.state? @YES : @NO,
@"BrightnessBias": @((_brightnessSlider.doubleValue - 128) / 128.0),
@"HueBias": @(_hueSlider.doubleValue / 360.0),
@"HueBiasStrength": @(_hueStrengthSlider.doubleValue / 256.0)
};
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *themes = [[defaults dictionaryForKey:@"GBThemes"] ?: @{} mutableCopy];
themes[[defaults stringForKey:@"GBCurrentTheme"]] = theme;
[defaults setObject:themes forKey:@"GBThemes"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBColorPaletteChanged" object:nil];
}
+ (const GB_palette_t *)userPalette
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
switch ([defaults integerForKey:@"GBColorPalette"]) {
case 1: return &GB_PALETTE_DMG;
case 2: return &GB_PALETTE_MGB;
case 3: return &GB_PALETTE_GBL;
default: return &GB_PALETTE_GREY;
case -1: {
static GB_palette_t customPalette;
NSArray *colors = [defaults dictionaryForKey:@"GBThemes"][[defaults stringForKey:@"GBCurrentTheme"]][@"Colors"];
if (colors.count == 5) {
unsigned i = 0;
for (NSNumber *color in colors) {
uint32_t c = [color unsignedIntValue];
customPalette.colors[i++] = (struct GB_color_s) {c, c >> 8, c >> 16};
}
}
return &customPalette;
}
}
}
- (IBAction)export:(id)sender
{
NSSavePanel *savePanel = [NSSavePanel savePanel];
[savePanel setAllowedFileTypes:@[@"sbp"]];
savePanel.nameFieldStringValue = [NSString stringWithFormat:@"%@.sbp", [[NSUserDefaults standardUserDefaults] stringForKey:@"GBCurrentTheme"]];
if ([savePanel runModal] == NSModalResponseOK) {
theme_t theme = {0,};
theme.magic = MAGIC;
theme.manual = _manualModeCheckbox.state;
theme.disabled_lcd_color = _disableLCDColorCheckbox.state;
unsigned i = 0;
for (NSColorWell *well in self.colorWells) {
theme.colors[i++] = well.color.gbColor;
}
theme.brightness_bias = (_brightnessSlider.doubleValue - 128) * (0x40000000 / 128);
theme.hue_bias = round(_hueSlider.doubleValue * (0x80000000 / 360.0));
theme.hue_bias_strength = (_hueStrengthSlider.doubleValue) * (0x80000000 / 256);
size_t size = sizeof(theme);
if (theme.manual) {
size = theme.disabled_lcd_color? 5 + 5 * sizeof(theme.colors[0]) : 5 + 4 * sizeof(theme.colors[0]);
}
[[NSData dataWithBytes:&theme length:size] writeToURL:savePanel.URL atomically:false];
}
}
- (IBAction)import:(id)sender
{
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setAllowedFileTypes:@[@"sbp"]];
if ([openPanel runModal] == NSModalResponseOK) {
NSData *data = [NSData dataWithContentsOfURL:openPanel.URL];
theme_t theme = {0,};
memcpy(&theme, data.bytes, MIN(sizeof(theme), data.length));
if (theme.magic != MAGIC) {
NSBeep();
return;
}
_manualModeCheckbox.state = theme.manual;
_disableLCDColorCheckbox.state = theme.disabled_lcd_color;
unsigned i = 0;
for (NSColorWell *well in self.colorWells) {
well.color = [NSColor colorWithRed:theme.colors[i].r / 255.0
green:theme.colors[i].g / 255.0
blue:theme.colors[i].b / 255.0
alpha:1.0];
i++;
}
if (!theme.disabled_lcd_color) {
_colorWell4.color = _colorWell3.color;
}
_brightnessSlider.doubleValue = theme.brightness_bias / (0x40000000 / 128.0) + 128;
_hueSlider.doubleValue = theme.hue_bias / (0x80000000 / 360.0);
_hueStrengthSlider.doubleValue = theme.hue_bias_strength / (0x80000000 / 256.0);
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *themes = [defaults dictionaryForKey:@"GBThemes"];
NSString *baseName = openPanel.URL.lastPathComponent.stringByDeletingPathExtension;
NSString *newName = baseName;
i = 2;
while (themes[newName]) {
newName = [NSString stringWithFormat:@"%@ %d", baseName, i++];
}
[defaults setObject:newName forKey:@"GBCurrentTheme"];
[self savePalette:sender];
[self awakeFromNib];
}
}
- (IBAction)done:(NSButton *)sender
{
[sender.window.sheetParent endSheet:sender.window];
}
- (instancetype)init
{
static id singleton = nil;
if (singleton) return singleton;
return (singleton = [super init]);
}
@end

View File

@ -1,13 +1,37 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "GBJoystickListener.h" #import <JoyKit/JoyKit.h>
#import "GBPaletteEditorController.h"
@interface GBPreferencesWindow : NSWindow <NSTableViewDelegate, NSTableViewDataSource, GBJoystickListener> @interface GBPreferencesWindow : NSWindow <NSTableViewDelegate, NSTableViewDataSource, JOYListener>
@property IBOutlet NSTableView *controlsTableView; @property (nonatomic, strong) IBOutlet NSTableView *controlsTableView;
@property IBOutlet NSPopUpButton *graphicsFilterPopupButton; @property (nonatomic, strong) IBOutlet NSPopUpButton *graphicsFilterPopupButton;
@property (strong) IBOutlet NSButton *aspectRatioCheckbox; @property (nonatomic, strong) IBOutlet NSButton *analogControlsCheckbox;
@property (strong) IBOutlet NSPopUpButton *highpassFilterPopupButton; @property (nonatomic, strong) IBOutlet NSButton *aspectRatioCheckbox;
@property (strong) IBOutlet NSPopUpButton *colorCorrectionPopupButton; @property (nonatomic, strong) IBOutlet NSPopUpButton *highpassFilterPopupButton;
@property (strong) IBOutlet NSPopUpButton *rewindPopupButton; @property (nonatomic, strong) IBOutlet NSPopUpButton *colorCorrectionPopupButton;
@property (strong) IBOutlet NSButton *configureJoypadButton; @property (nonatomic, strong) IBOutlet NSPopUpButton *frameBlendingModePopupButton;
@property (strong) IBOutlet NSButton *skipButton; @property (nonatomic, strong) IBOutlet NSPopUpButton *colorPalettePopupButton;
@property (nonatomic, strong) IBOutlet NSPopUpButton *displayBorderPopupButton;
@property (nonatomic, strong) IBOutlet NSPopUpButton *rewindPopupButton;
@property (nonatomic, strong) IBOutlet NSPopUpButton *rtcPopupButton;
@property (nonatomic, strong) IBOutlet NSButton *configureJoypadButton;
@property (nonatomic, strong) IBOutlet NSButton *skipButton;
@property (nonatomic, strong) IBOutlet NSMenuItem *bootROMsFolderItem;
@property (nonatomic, strong) IBOutlet NSPopUpButtonCell *bootROMsButton;
@property (nonatomic, strong) IBOutlet NSPopUpButton *rumbleModePopupButton;
@property (nonatomic, weak) IBOutlet NSSlider *temperatureSlider;
@property (nonatomic, weak) IBOutlet NSSlider *interferenceSlider;
@property (nonatomic, weak) IBOutlet NSPopUpButton *dmgPopupButton;
@property (nonatomic, weak) IBOutlet NSPopUpButton *sgbPopupButton;
@property (nonatomic, weak) IBOutlet NSPopUpButton *cgbPopupButton;
@property (nonatomic, weak) IBOutlet NSPopUpButton *preferredJoypadButton;
@property (nonatomic, weak) IBOutlet NSPopUpButton *playerListButton;
@property (nonatomic, weak) IBOutlet NSButton *autoUpdatesCheckbox;
@property (weak) IBOutlet NSSlider *volumeSlider;
@property (weak) IBOutlet NSButton *OSDCheckbox;
@property (weak) IBOutlet NSButton *screenshotFilterCheckbox;
@property (weak) IBOutlet GBPaletteEditorController *paletteEditorController;
@property (strong) IBOutlet NSWindow *paletteEditor;
@property (weak) IBOutlet NSButton *joystickMBC7Checkbox;
@property (weak) IBOutlet NSButton *mouseMBC7Checkbox;
@end @end

View File

@ -1,6 +1,8 @@
#import "GBPreferencesWindow.h" #import "GBPreferencesWindow.h"
#import "NSString+StringForKey.h" #import "NSString+StringForKey.h"
#import "GBButtons.h" #import "GBButtons.h"
#import "BigSurToolbar.h"
#import "GBViewMetal.h"
#import <Carbon/Carbon.h> #import <Carbon/Carbon.h>
@implementation GBPreferencesWindow @implementation GBPreferencesWindow
@ -9,14 +11,31 @@
NSInteger button_being_modified; NSInteger button_being_modified;
signed joystick_configuration_state; signed joystick_configuration_state;
NSString *joystick_being_configured; NSString *joystick_being_configured;
signed last_axis; bool joypad_wait;
NSPopUpButton *_graphicsFilterPopupButton; NSPopUpButton *_graphicsFilterPopupButton;
NSPopUpButton *_highpassFilterPopupButton; NSPopUpButton *_highpassFilterPopupButton;
NSPopUpButton *_colorCorrectionPopupButton; NSPopUpButton *_colorCorrectionPopupButton;
NSPopUpButton *_frameBlendingModePopupButton;
NSPopUpButton *_colorPalettePopupButton;
NSPopUpButton *_displayBorderPopupButton;
NSPopUpButton *_rewindPopupButton; NSPopUpButton *_rewindPopupButton;
NSPopUpButton *_rtcPopupButton;
NSButton *_aspectRatioCheckbox; NSButton *_aspectRatioCheckbox;
NSButton *_analogControlsCheckbox;
NSEventModifierFlags previousModifiers; NSEventModifierFlags previousModifiers;
NSPopUpButton *_dmgPopupButton, *_sgbPopupButton, *_cgbPopupButton;
NSPopUpButton *_preferredJoypadButton;
NSPopUpButton *_rumbleModePopupButton;
NSSlider *_temperatureSlider;
NSSlider *_interferenceSlider;
NSSlider *_volumeSlider;
NSButton *_autoUpdatesCheckbox;
NSButton *_OSDCheckbox;
NSButton *_screenshotFilterCheckbox;
NSButton *_joystickMBC7Checkbox;
NSButton *_mouseMBC7Checkbox;
} }
+ (NSArray *)filterList + (NSArray *)filterList
@ -28,8 +47,9 @@
@"NearestNeighbor", @"NearestNeighbor",
@"Bilinear", @"Bilinear",
@"SmoothBilinear", @"SmoothBilinear",
@"MonoLCD",
@"LCD", @"LCD",
@"DMG", @"CRT",
@"Scale2x", @"Scale2x",
@"Scale4x", @"Scale4x",
@"AAScale2x", @"AAScale2x",
@ -43,12 +63,17 @@
return filters; return filters;
} }
- (NSWindowToolbarStyle)toolbarStyle
{
return NSWindowToolbarStylePreference;
}
- (void)close - (void)close
{ {
joystick_configuration_state = -1; joystick_configuration_state = -1;
[self.configureJoypadButton setEnabled:YES]; [self.configureJoypadButton setEnabled:true];
[self.skipButton setEnabled:NO]; [self.skipButton setEnabled:false];
[self.configureJoypadButton setTitle:@"Configure Joypad"]; [self.configureJoypadButton setTitle:@"Configure Controller"];
[super close]; [super close];
} }
@ -76,11 +101,99 @@
[_colorCorrectionPopupButton selectItemAtIndex:mode]; [_colorCorrectionPopupButton selectItemAtIndex:mode];
} }
- (NSPopUpButton *)colorCorrectionPopupButton - (NSPopUpButton *)colorCorrectionPopupButton
{ {
return _colorCorrectionPopupButton; return _colorCorrectionPopupButton;
} }
- (void)setTemperatureSlider:(NSSlider *)temperatureSlider
{
_temperatureSlider = temperatureSlider;
[temperatureSlider setDoubleValue:[[NSUserDefaults standardUserDefaults] doubleForKey:@"GBLightTemperature"] * 256];
}
- (NSSlider *)temperatureSlider
{
return _temperatureSlider;
}
- (void)setInterferenceSlider:(NSSlider *)interferenceSlider
{
_interferenceSlider = interferenceSlider;
[interferenceSlider setDoubleValue:[[NSUserDefaults standardUserDefaults] doubleForKey:@"GBInterferenceVolume"] * 256];
}
- (NSSlider *)interferenceSlider
{
return _interferenceSlider;
}
- (void)setVolumeSlider:(NSSlider *)volumeSlider
{
_volumeSlider = volumeSlider;
[volumeSlider setDoubleValue:[[NSUserDefaults standardUserDefaults] doubleForKey:@"GBVolume"] * 256];
}
- (NSSlider *)volumeSlider
{
return _volumeSlider;
}
- (void)setFrameBlendingModePopupButton:(NSPopUpButton *)frameBlendingModePopupButton
{
_frameBlendingModePopupButton = frameBlendingModePopupButton;
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBFrameBlendingMode"];
[_frameBlendingModePopupButton selectItemAtIndex:mode];
}
- (NSPopUpButton *)frameBlendingModePopupButton
{
return _frameBlendingModePopupButton;
}
- (void)setColorPalettePopupButton:(NSPopUpButton *)colorPalettePopupButton
{
_colorPalettePopupButton = colorPalettePopupButton;
[self updatePalettesMenu];
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBColorPalette"];
if (mode >= 0) {
[_colorPalettePopupButton selectItemWithTag:mode];
}
else {
[_colorPalettePopupButton selectItemWithTitle:[[NSUserDefaults standardUserDefaults] stringForKey:@"GBCurrentTheme"] ?: @""];
}
}
- (NSPopUpButton *)colorPalettePopupButton
{
return _colorPalettePopupButton;
}
- (void)setDisplayBorderPopupButton:(NSPopUpButton *)displayBorderPopupButton
{
_displayBorderPopupButton = displayBorderPopupButton;
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBBorderMode"];
[_displayBorderPopupButton selectItemWithTag:mode];
}
- (NSPopUpButton *)displayBorderPopupButton
{
return _displayBorderPopupButton;
}
- (void)setRumbleModePopupButton:(NSPopUpButton *)rumbleModePopupButton
{
_rumbleModePopupButton = rumbleModePopupButton;
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBRumbleMode"];
[_rumbleModePopupButton selectItemWithTag:mode];
}
- (NSPopUpButton *)rumbleModePopupButton
{
return _rumbleModePopupButton;
}
- (void)setRewindPopupButton:(NSPopUpButton *)rewindPopupButton - (void)setRewindPopupButton:(NSPopUpButton *)rewindPopupButton
{ {
_rewindPopupButton = rewindPopupButton; _rewindPopupButton = rewindPopupButton;
@ -93,6 +206,18 @@
return _rewindPopupButton; return _rewindPopupButton;
} }
- (NSPopUpButton *)rtcPopupButton
{
return _rtcPopupButton;
}
- (void)setRtcPopupButton:(NSPopUpButton *)rtcPopupButton
{
_rtcPopupButton = rtcPopupButton;
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBRTCMode"];
[_rtcPopupButton selectItemAtIndex:mode];
}
- (void)setHighpassFilterPopupButton:(NSPopUpButton *)highpassFilterPopupButton - (void)setHighpassFilterPopupButton:(NSPopUpButton *)highpassFilterPopupButton
{ {
_highpassFilterPopupButton = highpassFilterPopupButton; _highpassFilterPopupButton = highpassFilterPopupButton;
@ -101,8 +226,25 @@
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{ {
if (self.playerListButton.selectedTag == 0) {
return GBButtonCount; return GBButtonCount;
} }
return GBGameBoyButtonCount;
}
- (unsigned) usesForKey:(unsigned) key
{
unsigned ret = 0;
for (unsigned player = 4; player--;) {
for (unsigned button = player == 0? GBButtonCount:GBGameBoyButtonCount; button--;) {
NSNumber *other = [[NSUserDefaults standardUserDefaults] valueForKey:button_to_preference_name(button, player)];
if (other && [other unsignedIntValue] == key) {
ret++;
}
}
}
return ret;
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{ {
@ -114,26 +256,38 @@
return @"Select a new key..."; return @"Select a new key...";
} }
return [NSString displayStringForKeyCode:[[NSUserDefaults standardUserDefaults] integerForKey: NSNumber *key = [[NSUserDefaults standardUserDefaults] valueForKey:button_to_preference_name(row, self.playerListButton.selectedTag)];
button_to_preference_name(row)]]; if (key) {
if ([self usesForKey:[key unsignedIntValue]] > 1) {
return [[NSAttributedString alloc] initWithString:[NSString displayStringForKeyCode: [key unsignedIntegerValue]]
attributes:@{NSForegroundColorAttributeName: [NSColor colorWithRed:0.9375 green:0.25 blue:0.25 alpha:1.0],
NSFontAttributeName: [NSFont boldSystemFontOfSize:[NSFont systemFontSize]]
}];
}
return [NSString displayStringForKeyCode: [key unsignedIntegerValue]];
}
return @"";
} }
- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row - (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{ {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
is_button_being_modified = true; is_button_being_modified = true;
button_being_modified = row; button_being_modified = row;
tableView.enabled = NO; tableView.enabled = false;
self.playerListButton.enabled = false;
[tableView reloadData]; [tableView reloadData];
[self makeFirstResponder:self]; [self makeFirstResponder:self];
}); });
return NO; return false;
} }
-(void)keyDown:(NSEvent *)theEvent -(void)keyDown:(NSEvent *)theEvent
{ {
if (!is_button_being_modified) { if (!is_button_being_modified) {
if (self.firstResponder != self.controlsTableView) { if (self.firstResponder != self.controlsTableView && [theEvent type] != NSEventTypeFlagsChanged) {
[super keyDown:theEvent]; [super keyDown:theEvent];
} }
return; return;
@ -142,8 +296,9 @@
is_button_being_modified = false; is_button_being_modified = false;
[[NSUserDefaults standardUserDefaults] setInteger:theEvent.keyCode [[NSUserDefaults standardUserDefaults] setInteger:theEvent.keyCode
forKey:button_to_preference_name(button_being_modified)]; forKey:button_to_preference_name(button_being_modified, self.playerListButton.selectedTag)];
self.controlsTableView.enabled = YES; self.controlsTableView.enabled = true;
self.playerListButton.enabled = true;
[self.controlsTableView reloadData]; [self.controlsTableView reloadData];
[self makeFirstResponder:self.controlsTableView]; [self makeFirstResponder:self.controlsTableView];
} }
@ -153,9 +308,6 @@
if (event.modifierFlags > previousModifiers) { if (event.modifierFlags > previousModifiers) {
[self keyDown:event]; [self keyDown:event];
} }
else {
[self keyUp:event];
}
previousModifiers = event.modifierFlags; previousModifiers = event.modifierFlags;
} }
@ -174,6 +326,25 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBHighpassFilterChanged" object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:@"GBHighpassFilterChanged" object:nil];
} }
- (IBAction)changeMBC7JoystickOverride:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] == NSOnState
forKey:@"GBMBC7JoystickOverride"];
}
- (IBAction)changeMBC7AllowMouse:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] == NSOnState
forKey:@"GBMBC7AllowMouse"];
}
- (IBAction)changeAnalogControls:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] == NSOnState
forKey:@"GBAnalogControls"];
}
- (IBAction)changeAspectRatio:(id)sender - (IBAction)changeAspectRatio:(id)sender
{ {
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] != NSOnState [[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] != NSOnState
@ -186,7 +357,97 @@
[[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem]) [[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem])
forKey:@"GBColorCorrection"]; forKey:@"GBColorCorrection"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBColorCorrectionChanged" object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:@"GBColorCorrectionChanged" object:nil];
}
- (IBAction)lightTemperatureChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender doubleValue] / 256.0)
forKey:@"GBLightTemperature"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBLightTemperatureChanged" object:nil];
}
- (IBAction)interferenceVolumeChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender doubleValue] / 256.0)
forKey:@"GBInterferenceVolume"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBInterferenceVolumeChanged" object:nil];
}
- (IBAction)volumeChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender doubleValue] / 256.0)
forKey:@"GBVolume"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBVolumeChanged" object:nil];
}
- (IBAction)franeBlendingModeChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem])
forKey:@"GBFrameBlendingMode"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBFrameBlendingModeChanged" object:nil];
}
- (void)updatePalettesMenu
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *themes = [defaults dictionaryForKey:@"GBThemes"];
NSMenu *menu = _colorPalettePopupButton.menu;
while (menu.itemArray.count != 4) {
[menu removeItemAtIndex:4];
}
[menu addItem:[NSMenuItem separatorItem]];
for (NSString *name in [themes.allKeys sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]) {
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:name action:nil keyEquivalent:@""];
item.tag = -2;
[menu addItem:item];
}
if (themes) {
[menu addItem:[NSMenuItem separatorItem]];
}
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"Custom…" action:nil keyEquivalent:@""];
item.tag = -1;
[menu addItem:item];
}
- (IBAction)colorPaletteChanged:(id)sender
{
signed tag = [sender selectedItem].tag;
if (tag == -2) {
[[NSUserDefaults standardUserDefaults] setObject:@(-1)
forKey:@"GBColorPalette"];
[[NSUserDefaults standardUserDefaults] setObject:[sender selectedItem].title
forKey:@"GBCurrentTheme"];
}
else if (tag == -1) {
[[NSUserDefaults standardUserDefaults] setObject:@(-1)
forKey:@"GBColorPalette"];
[_paletteEditorController awakeFromNib];
[self beginSheet:_paletteEditor completionHandler:^(NSModalResponse returnCode) {
[self updatePalettesMenu];
[_colorPalettePopupButton selectItemWithTitle:[[NSUserDefaults standardUserDefaults] stringForKey:@"GBCurrentTheme"] ?: @""];
}];
}
else {
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedItem].tag)
forKey:@"GBColorPalette"];
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBColorPaletteChanged" object:nil];
}
- (IBAction)displayBorderChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedItem].tag)
forKey:@"GBBorderMode"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBBorderModeChanged" object:nil];
}
- (IBAction)rumbleModeChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedItem].tag)
forKey:@"GBRumbleMode"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBRumbleModeChanged" object:nil];
} }
- (IBAction)rewindLengthChanged:(id)sender - (IBAction)rewindLengthChanged:(id)sender
@ -196,13 +457,26 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBRewindLengthChanged" object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:@"GBRewindLengthChanged" object:nil];
} }
- (IBAction)rtcModeChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem])
forKey:@"GBRTCMode"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBRTCModeChanged" object:nil];
}
- (IBAction)changeAutoUpdates:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] == NSOnState
forKey:@"GBAutoUpdatesEnabled"];
}
- (IBAction) configureJoypad:(id)sender - (IBAction) configureJoypad:(id)sender
{ {
[self.configureJoypadButton setEnabled:NO]; [self.configureJoypadButton setEnabled:false];
[self.skipButton setEnabled:YES]; [self.skipButton setEnabled:true];
joystick_being_configured = nil; joystick_being_configured = nil;
[self advanceConfigurationStateMachine]; [self advanceConfigurationStateMachine];
last_axis = -1;
} }
- (IBAction) skipButton:(id)sender - (IBAction) skipButton:(id)sender
@ -213,89 +487,137 @@
- (void) advanceConfigurationStateMachine - (void) advanceConfigurationStateMachine
{ {
joystick_configuration_state++; joystick_configuration_state++;
if (joystick_configuration_state < GBButtonCount) { if (joystick_configuration_state == GBUnderclock) {
[self.configureJoypadButton setTitle:[NSString stringWithFormat:@"Press Button for %@", GBButtonNames[joystick_configuration_state]]]; [self.configureJoypadButton setTitle:@"Press Button for Slo-Mo"]; // Full name is too long :<
} }
else if (joystick_configuration_state == GBButtonCount) { else if (joystick_configuration_state < GBButtonCount) {
[self.configureJoypadButton setTitle:@"Move the Analog Stick"]; [self.configureJoypadButton setTitle:[NSString stringWithFormat:@"Press Button for %@", GBButtonNames[joystick_configuration_state]]];
} }
else { else {
joystick_configuration_state = -1; joystick_configuration_state = -1;
[self.configureJoypadButton setEnabled:YES]; [self.configureJoypadButton setEnabled:true];
[self.skipButton setEnabled:NO]; [self.skipButton setEnabled:false];
[self.configureJoypadButton setTitle:@"Configure Joypad"]; [self.configureJoypadButton setTitle:@"Configure Joypad"];
} }
} }
- (void) joystick:(NSString *)joystick_name button: (unsigned)button changedState: (bool) state - (void)controller:(JOYController *)controller buttonChangedState:(JOYButton *)button
{ {
if (!state) return; /* Debounce */
if (joypad_wait) return;
joypad_wait = true;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
joypad_wait = false;
});
if (!button.isPressed) return;
if (joystick_configuration_state == -1) return; if (joystick_configuration_state == -1) return;
if (joystick_configuration_state == GBButtonCount) return; if (joystick_configuration_state == GBButtonCount) return;
if (!joystick_being_configured) { if (!joystick_being_configured) {
joystick_being_configured = joystick_name; joystick_being_configured = controller.uniqueID;
} }
else if (![joystick_being_configured isEqualToString:joystick_name]) { else if (![joystick_being_configured isEqualToString:controller.uniqueID]) {
return; return;
} }
NSMutableDictionary *all_mappings = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"GBJoypadMappings"] mutableCopy]; NSMutableDictionary *instance_mappings = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitInstanceMapping"] mutableCopy];
if (!all_mappings) { NSMutableDictionary *name_mappings = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitNameMapping"] mutableCopy];
all_mappings = [[NSMutableDictionary alloc] init];
if (!instance_mappings) {
instance_mappings = [[NSMutableDictionary alloc] init];
} }
NSMutableDictionary *mapping = [[all_mappings objectForKey:joystick_name] mutableCopy]; if (!name_mappings) {
name_mappings = [[NSMutableDictionary alloc] init];
}
if (!mapping) { NSMutableDictionary *mapping = nil;
if (joystick_configuration_state != 0) {
mapping = [instance_mappings[controller.uniqueID] mutableCopy];
}
else {
mapping = [[NSMutableDictionary alloc] init]; mapping = [[NSMutableDictionary alloc] init];
} }
mapping[GBButtonNames[joystick_configuration_state]] = @(button);
all_mappings[joystick_name] = mapping; static const unsigned gb_to_joykit[] = {
[[NSUserDefaults standardUserDefaults] setObject:all_mappings forKey:@"GBJoypadMappings"]; [GBRight] = JOYButtonUsageDPadRight,
[GBLeft] = JOYButtonUsageDPadLeft,
[GBUp] = JOYButtonUsageDPadUp,
[GBDown] = JOYButtonUsageDPadDown,
[GBA] = JOYButtonUsageA,
[GBB] = JOYButtonUsageB,
[GBSelect] = JOYButtonUsageSelect,
[GBStart] = JOYButtonUsageStart,
[GBTurbo] = JOYButtonUsageL1,
[GBRewind] = JOYButtonUsageL2,
[GBUnderclock] = JOYButtonUsageR1,
};
if (joystick_configuration_state == GBUnderclock) {
mapping[@"AnalogUnderclock"] = nil;
double max = 0;
for (JOYAxis *axis in controller.axes) {
if ((axis.value > 0.5 || (axis.equivalentButtonUsage == button.usage)) && axis.value >= max) {
mapping[@"AnalogUnderclock"] = @(axis.uniqueID);
break;
}
}
}
if (joystick_configuration_state == GBTurbo) {
mapping[@"AnalogTurbo"] = nil;
double max = 0;
for (JOYAxis *axis in controller.axes) {
if ((axis.value > 0.5 || (axis.equivalentButtonUsage == button.usage)) && axis.value >= max) {
max = axis.value;
mapping[@"AnalogTurbo"] = @(axis.uniqueID);
}
}
}
mapping[n2s(button.uniqueID)] = @(gb_to_joykit[joystick_configuration_state]);
instance_mappings[controller.uniqueID] = mapping;
name_mappings[controller.deviceName] = mapping;
[[NSUserDefaults standardUserDefaults] setObject:instance_mappings forKey:@"JoyKitInstanceMapping"];
[[NSUserDefaults standardUserDefaults] setObject:name_mappings forKey:@"JoyKitNameMapping"];
[self advanceConfigurationStateMachine]; [self advanceConfigurationStateMachine];
} }
- (void) joystick:(NSString *)joystick_name axis: (unsigned)axis movedTo: (signed) value - (NSButton *)joystickMBC7Checkbox
{ {
if (abs(value) < 0x4000) return; return _joystickMBC7Checkbox;
if (joystick_configuration_state != GBButtonCount) return;
if (!joystick_being_configured) {
joystick_being_configured = joystick_name;
}
else if (![joystick_being_configured isEqualToString:joystick_name]) {
return;
} }
if (last_axis == -1) { - (void)setJoystickMBC7Checkbox:(NSButton *)joystickMBC7Checkbox
last_axis = axis; {
return; _joystickMBC7Checkbox = joystickMBC7Checkbox;
[_joystickMBC7Checkbox setState: [[NSUserDefaults standardUserDefaults] boolForKey:@"GBMBC7JoystickOverride"]];
} }
if (axis == last_axis) { - (NSButton *)mouseMBC7Checkbox
return; {
return _mouseMBC7Checkbox;
} }
NSMutableDictionary *all_mappings = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"GBJoypadMappings"] mutableCopy]; - (void)setMouseMBC7Checkbox:(NSButton *)mouseMBC7Checkbox
{
if (!all_mappings) { _mouseMBC7Checkbox = mouseMBC7Checkbox;
all_mappings = [[NSMutableDictionary alloc] init]; [_mouseMBC7Checkbox setState: [[NSUserDefaults standardUserDefaults] boolForKey:@"GBMBC7AllowMouse"]];
} }
NSMutableDictionary *mapping = [[all_mappings objectForKey:joystick_name] mutableCopy]; - (NSButton *)analogControlsCheckbox
{
if (!mapping) { return _analogControlsCheckbox;
mapping = [[NSMutableDictionary alloc] init];
} }
mapping[@"XAxis"] = @(MIN(axis, last_axis)); - (void)setAnalogControlsCheckbox:(NSButton *)analogControlsCheckbox
mapping[@"YAxis"] = @(MAX(axis, last_axis)); {
_analogControlsCheckbox = analogControlsCheckbox;
all_mappings[joystick_name] = mapping; [_analogControlsCheckbox setState: [[NSUserDefaults standardUserDefaults] boolForKey:@"GBAnalogControls"]];
[[NSUserDefaults standardUserDefaults] setObject:all_mappings forKey:@"GBJoypadMappings"];
[self advanceConfigurationStateMachine];
} }
- (NSButton *)aspectRatioCheckbox - (NSButton *)aspectRatioCheckbox
@ -312,12 +634,245 @@
- (void)awakeFromNib - (void)awakeFromNib
{ {
[super awakeFromNib]; [super awakeFromNib];
[self updateBootROMFolderButton];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self.controlsTableView selector:@selector(reloadData) name:(NSString*)kTISNotifySelectedKeyboardInputSourceChanged object:nil]; [[NSDistributedNotificationCenter defaultCenter] addObserver:self.controlsTableView selector:@selector(reloadData) name:(NSString*)kTISNotifySelectedKeyboardInputSourceChanged object:nil];
[JOYController registerListener:self];
joystick_configuration_state = -1;
} }
- (void)dealloc - (void)dealloc
{ {
[JOYController unregisterListener:self];
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self.controlsTableView]; [[NSDistributedNotificationCenter defaultCenter] removeObserver:self.controlsTableView];
} }
- (IBAction)selectOtherBootROMFolder:(id)sender
{
NSOpenPanel *panel = [[NSOpenPanel alloc] init];
[panel setCanChooseDirectories:true];
[panel setCanChooseFiles:false];
[panel setPrompt:@"Select"];
[panel setDirectoryURL:[[NSUserDefaults standardUserDefaults] URLForKey:@"GBBootROMsFolder"]];
[panel beginSheetModalForWindow:self completionHandler:^(NSModalResponse result) {
if (result == NSModalResponseOK) {
NSURL *url = [[panel URLs] firstObject];
[[NSUserDefaults standardUserDefaults] setURL:url forKey:@"GBBootROMsFolder"];
}
[self updateBootROMFolderButton];
}];
}
- (void) updateBootROMFolderButton
{
NSURL *url = [[NSUserDefaults standardUserDefaults] URLForKey:@"GBBootROMsFolder"];
BOOL is_dir = false;
[[NSFileManager defaultManager] fileExistsAtPath:[url path] isDirectory:&is_dir];
if (!is_dir) url = nil;
if (url) {
[self.bootROMsFolderItem setTitle:[url lastPathComponent]];
NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:[url path]];
[icon setSize:NSMakeSize(16, 16)];
[self.bootROMsFolderItem setHidden:false];
[self.bootROMsFolderItem setImage:icon];
[self.bootROMsButton selectItemAtIndex:1];
}
else {
[self.bootROMsFolderItem setHidden:true];
[self.bootROMsButton selectItemAtIndex:0];
}
}
- (IBAction)useBuiltinBootROMs:(id)sender
{
[[NSUserDefaults standardUserDefaults] setURL:nil forKey:@"GBBootROMsFolder"];
[self updateBootROMFolderButton];
}
- (void)setDmgPopupButton:(NSPopUpButton *)dmgPopupButton
{
_dmgPopupButton = dmgPopupButton;
[_dmgPopupButton selectItemWithTag:[[NSUserDefaults standardUserDefaults] integerForKey:@"GBDMGModel"]];
}
- (NSPopUpButton *)dmgPopupButton
{
return _dmgPopupButton;
}
- (void)setSgbPopupButton:(NSPopUpButton *)sgbPopupButton
{
_sgbPopupButton = sgbPopupButton;
[_sgbPopupButton selectItemWithTag:[[NSUserDefaults standardUserDefaults] integerForKey:@"GBSGBModel"]];
}
- (NSPopUpButton *)sgbPopupButton
{
return _sgbPopupButton;
}
- (void)setCgbPopupButton:(NSPopUpButton *)cgbPopupButton
{
_cgbPopupButton = cgbPopupButton;
[_cgbPopupButton selectItemWithTag:[[NSUserDefaults standardUserDefaults] integerForKey:@"GBCGBModel"]];
}
- (NSPopUpButton *)cgbPopupButton
{
return _cgbPopupButton;
}
- (IBAction)dmgModelChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedTag])
forKey:@"GBDMGModel"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBDMGModelChanged" object:nil];
}
- (IBAction)sgbModelChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedTag])
forKey:@"GBSGBModel"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBSGBModelChanged" object:nil];
}
- (IBAction)cgbModelChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedTag])
forKey:@"GBCGBModel"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBCGBModelChanged" object:nil];
}
- (IBAction)reloadButtonsData:(id)sender
{
[self.controlsTableView reloadData];
}
- (void)setPreferredJoypadButton:(NSPopUpButton *)preferredJoypadButton
{
_preferredJoypadButton = preferredJoypadButton;
[self refreshJoypadMenu:nil];
}
- (NSPopUpButton *)preferredJoypadButton
{
return _preferredJoypadButton;
}
- (void)controllerConnected:(JOYController *)controller
{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self refreshJoypadMenu:nil];
});
}
- (void)controllerDisconnected:(JOYController *)controller
{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self refreshJoypadMenu:nil];
});
}
- (IBAction)refreshJoypadMenu:(id)sender
{
bool preferred_is_connected = false;
NSString *player_string = n2s(self.playerListButton.selectedTag);
NSString *selected_controller = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitDefaultControllers"][player_string];
[self.preferredJoypadButton removeAllItems];
[self.preferredJoypadButton addItemWithTitle:@"None"];
for (JOYController *controller in [JOYController allControllers]) {
[self.preferredJoypadButton addItemWithTitle:[NSString stringWithFormat:@"%@ (%@)", controller.deviceName, controller.uniqueID]];
self.preferredJoypadButton.lastItem.identifier = controller.uniqueID;
if ([controller.uniqueID isEqualToString:selected_controller]) {
preferred_is_connected = true;
[self.preferredJoypadButton selectItem:self.preferredJoypadButton.lastItem];
}
}
if (!preferred_is_connected && selected_controller) {
[self.preferredJoypadButton addItemWithTitle:[NSString stringWithFormat:@"Unavailable Controller (%@)", selected_controller]];
self.preferredJoypadButton.lastItem.identifier = selected_controller;
[self.preferredJoypadButton selectItem:self.preferredJoypadButton.lastItem];
}
if (!selected_controller) {
[self.preferredJoypadButton selectItemWithTitle:@"None"];
}
[self.controlsTableView reloadData];
}
- (IBAction)changeDefaultJoypad:(id)sender
{
NSMutableDictionary *default_joypads = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitDefaultControllers"] mutableCopy];
if (!default_joypads) {
default_joypads = [[NSMutableDictionary alloc] init];
}
NSString *player_string = n2s(self.playerListButton.selectedTag);
if ([[sender titleOfSelectedItem] isEqualToString:@"None"]) {
[default_joypads removeObjectForKey:player_string];
}
else {
default_joypads[player_string] = [[sender selectedItem] identifier];
}
[[NSUserDefaults standardUserDefaults] setObject:default_joypads forKey:@"JoyKitDefaultControllers"];
}
- (NSButton *)autoUpdatesCheckbox
{
return _autoUpdatesCheckbox;
}
- (void)setAutoUpdatesCheckbox:(NSButton *)autoUpdatesCheckbox
{
_autoUpdatesCheckbox = autoUpdatesCheckbox;
[_autoUpdatesCheckbox setState: [[NSUserDefaults standardUserDefaults] boolForKey:@"GBAutoUpdatesEnabled"]];
}
- (NSButton *)OSDCheckbox
{
return _OSDCheckbox;
}
- (void)setOSDCheckbox:(NSButton *)OSDCheckbox
{
_OSDCheckbox = OSDCheckbox;
[_OSDCheckbox setState: [[NSUserDefaults standardUserDefaults] boolForKey:@"GBOSDEnabled"]];
}
- (IBAction)changeOSDEnabled:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool:[(NSButton *)sender state] == NSOnState
forKey:@"GBOSDEnabled"];
}
- (IBAction)changeFilterScreenshots:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool:[(NSButton *)sender state] == NSOnState
forKey:@"GBFilterScreenshots"];
}
- (NSButton *)screenshotFilterCheckbox
{
return _screenshotFilterCheckbox;
}
- (void)setScreenshotFilterCheckbox:(NSButton *)screenshotFilterCheckbox
{
_screenshotFilterCheckbox = screenshotFilterCheckbox;
if (![GBViewMetal isSupported]) {
[_screenshotFilterCheckbox setEnabled:false];
}
else {
[_screenshotFilterCheckbox setState: [[NSUserDefaults standardUserDefaults] boolForKey:@"GBFilterScreenshots"]];
}
}
@end @end

128
Cocoa/GBS.xib Normal file
View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14868" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14868"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="Document">
<connections>
<outlet property="gbsAuthor" destination="gaD-ZH-Beh" id="2i7-BD-bJ2"/>
<outlet property="gbsCopyright" destination="2dl-dH-E3J" id="LnT-Vb-pN6"/>
<outlet property="gbsNextPrevButton" destination="SRS-M5-VVL" id="YEN-01-wRX"/>
<outlet property="gbsPlayPauseButton" destination="qxJ-pH-d0y" id="qk8-8I-9u5"/>
<outlet property="gbsPlayerView" destination="c22-O7-iKe" id="A1w-e5-EQE"/>
<outlet property="gbsRewindButton" destination="0yD-Sp-Ilo" id="FgR-xd-JW5"/>
<outlet property="gbsTitle" destination="H3v-X3-48q" id="DCl-wL-oy8"/>
<outlet property="gbsTracks" destination="I1T-VS-Vse" id="Vk4-GP-RjB"/>
<outlet property="gbsVisualizer" destination="Q3o-bK-DIN" id="1YC-C5-Je6"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="332" height="221"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="H3v-X3-48q">
<rect key="frame" x="18" y="192" width="296" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Title" id="BwZ-Zj-sP6">
<font key="font" metaFont="systemBold" size="16"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="gaD-ZH-Beh">
<rect key="frame" x="18" y="166" width="296" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Author" id="IgT-r1-T38">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qxJ-pH-d0y">
<rect key="frame" x="61.5" y="127" width="39" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="Play" imagePosition="only" alignment="center" alternateImage="Pause" state="on" borderStyle="border" focusRingType="none" inset="2" id="3ZK-br-UrS">
<behavior key="behavior" pushIn="YES" changeContents="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="togglePause:" target="-2" id="AUe-I7-nOK"/>
</connections>
</button>
<button focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0yD-Sp-Ilo">
<rect key="frame" x="19.5" y="127" width="38" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="Rewind" imagePosition="only" alignment="center" state="on" borderStyle="border" focusRingType="none" inset="2" id="ZIF-TP-Fqn">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="changeGBSTrack:" target="-2" id="jug-AS-bW7"/>
</connections>
</button>
<popUpButton focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="I1T-VS-Vse">
<rect key="frame" x="106" y="127" width="131" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" id="YJh-dI-A5D">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="Knp-Ok-Pb4"/>
</popUpButtonCell>
<connections>
<action selector="changeGBSTrack:" target="-2" id="HET-AT-CfQ"/>
</connections>
</popUpButton>
<segmentedControl verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="SRS-M5-VVL">
<rect key="frame" x="240.5" y="127" width="72" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="texturedRounded" trackingMode="momentary" id="cmq-I8-cFL">
<font key="font" metaFont="system"/>
<segments>
<segment toolTip="Previous Track" image="Previous" width="33"/>
<segment toolTip="Next Track" image="Next" width="32" tag="1"/>
</segments>
</segmentedCell>
<connections>
<action selector="gbsNextPrevPushed:" target="-2" id="roN-Iy-tDQ"/>
</connections>
</segmentedControl>
<box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="b9A-cd-ias">
<rect key="frame" x="0.0" y="117" width="332" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</box>
<customView appearanceType="darkAqua" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tRy-Gw-IaG" customClass="GBOptionalVisualEffectView">
<rect key="frame" x="0.0" y="24" width="332" height="95"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Q3o-bK-DIN" customClass="GBVisualizerView">
<rect key="frame" x="0.0" y="0.0" width="332" height="95"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
</subviews>
</customView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="2dl-dH-E3J">
<rect key="frame" x="18" y="5" width="296" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="clipping" alignment="center" title="Copyright" id="nM9-oF-OV9">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="67" y="292.5"/>
</customView>
</objects>
<resources>
<image name="Next" width="16" height="10"/>
<image name="Pause" width="10" height="10"/>
<image name="Play" width="10" height="10"/>
<image name="Previous" width="16" height="10"/>
<image name="Rewind" width="10" height="10"/>
</resources>
</document>

View File

@ -1,6 +0,0 @@
#import <Foundation/Foundation.h>
@interface GBShader : NSObject
- (instancetype)initWithName:(NSString *) shaderName;
- (void) renderBitmap: (void *)bitmap previous:(void*) previous inSize:(NSSize)size scale: (double) scale;
@end

7
Cocoa/GBSplitView.h Normal file
View File

@ -0,0 +1,7 @@
#import <Cocoa/Cocoa.h>
@interface GBSplitView : NSSplitView
-(void) setDividerColor:(NSColor *)color;
- (NSArray<NSView *> *)arrangedSubviews;
@end

33
Cocoa/GBSplitView.m Normal file
View File

@ -0,0 +1,33 @@
#import "GBSplitView.h"
@implementation GBSplitView
{
NSColor *_dividerColor;
}
- (void)setDividerColor:(NSColor *)color
{
_dividerColor = color;
[self setNeedsDisplay:true];
}
- (NSColor *)dividerColor
{
if (_dividerColor) {
return _dividerColor;
}
return [super dividerColor];
}
/* Mavericks comaptibility */
- (NSArray<NSView *> *)arrangedSubviews
{
if (@available(macOS 10.11, *)) {
return [super arrangedSubviews];
}
else {
return [self subviews];
}
}
@end

View File

@ -1,5 +1,6 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <Core/gb.h>
@interface GBTerminalTextFieldCell : NSTextFieldCell @interface GBTerminalTextFieldCell : NSTextFieldCell
@property (nonatomic) GB_gameboy_t *gb;
@end @end

View File

@ -2,6 +2,7 @@
#import "GBTerminalTextFieldCell.h" #import "GBTerminalTextFieldCell.h"
@interface GBTerminalTextView : NSTextView @interface GBTerminalTextView : NSTextView
@property GB_gameboy_t *gb;
@end @end
@implementation GBTerminalTextFieldCell @implementation GBTerminalTextFieldCell
@ -12,10 +13,12 @@
- (NSTextView *)fieldEditorForView:(NSView *)controlView - (NSTextView *)fieldEditorForView:(NSView *)controlView
{ {
if (field_editor) { if (field_editor) {
field_editor.gb = self.gb;
return field_editor; return field_editor;
} }
field_editor = [[GBTerminalTextView alloc] init]; field_editor = [[GBTerminalTextView alloc] init];
[field_editor setFieldEditor:YES]; [field_editor setFieldEditor:true];
field_editor.gb = self.gb;
return field_editor; return field_editor;
} }
@ -26,6 +29,8 @@
NSMutableOrderedSet *lines; NSMutableOrderedSet *lines;
NSUInteger current_line; NSUInteger current_line;
bool reverse_search_mode; bool reverse_search_mode;
NSRange auto_complete_range;
uintptr_t auto_complete_context;
} }
- (instancetype)init - (instancetype)init
@ -104,7 +109,7 @@
[self updateReverseSearch]; [self updateReverseSearch];
} }
else { else {
[self setNeedsDisplay:YES]; [self setNeedsDisplay:true];
reverse_search_mode = true; reverse_search_mode = true;
} }
@ -170,10 +175,12 @@
-(void)setSelectedRanges:(NSArray<NSValue *> *)ranges affinity:(NSSelectionAffinity)affinity stillSelecting:(BOOL)stillSelectingFlag -(void)setSelectedRanges:(NSArray<NSValue *> *)ranges affinity:(NSSelectionAffinity)affinity stillSelecting:(BOOL)stillSelectingFlag
{ {
reverse_search_mode = false; reverse_search_mode = false;
auto_complete_context = 0;
[super setSelectedRanges:ranges affinity:affinity stillSelecting:stillSelectingFlag]; [super setSelectedRanges:ranges affinity:affinity stillSelecting:stillSelectingFlag];
} }
- (BOOL)resignFirstResponder { - (BOOL)resignFirstResponder
{
reverse_search_mode = false; reverse_search_mode = false;
return [super resignFirstResponder]; return [super resignFirstResponder];
} }
@ -187,6 +194,38 @@
[attributes setObject:color forKey:NSForegroundColorAttributeName]; [attributes setObject:color forKey:NSForegroundColorAttributeName];
[[[NSAttributedString alloc] initWithString:@"Reverse search..." attributes:attributes] drawAtPoint:NSMakePoint(2, 0)]; [[[NSAttributedString alloc] initWithString:@"Reverse search..." attributes:attributes] drawAtPoint:NSMakePoint(2, 0)];
} }
} }
/* Todo: lazy design, make it use a delegate instead of having a gb reference*/
- (void)insertTab:(id)sender
{
if (auto_complete_context == 0) {
NSRange selection = self.selectedRange;
if (selection.length) {
[self delete:nil];
}
auto_complete_range = NSMakeRange(selection.location, 0);
}
char *substring = strdup([self.string substringToIndex:auto_complete_range.location].UTF8String);
uintptr_t context = auto_complete_context;
char *completion = GB_debugger_complete_substring(self.gb, substring, &context);
free(substring);
if (completion) {
NSString *ns_completion = @(completion);
free(completion);
if (!ns_completion) {
goto error;
}
self.selectedRange = auto_complete_range;
auto_complete_range.length = ns_completion.length;
[self replaceCharactersInRange:self.selectedRange withString:ns_completion];
auto_complete_context = context;
return;
}
error:
auto_complete_context = context;
NSBeep();
}
@end @end

View File

@ -1,14 +1,31 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <Core/gb.h> #include <Core/gb.h>
#import "GBJoystickListener.h" #import <JoyKit/JoyKit.h>
#import "GBShader.h" #import "GBOSDView.h"
@class Document;
@interface GBView<GBJoystickListener> : NSOpenGLView typedef enum {
GB_FRAME_BLENDING_MODE_DISABLED,
GB_FRAME_BLENDING_MODE_SIMPLE,
GB_FRAME_BLENDING_MODE_ACCURATE,
GB_FRAME_BLENDING_MODE_ACCURATE_EVEN = GB_FRAME_BLENDING_MODE_ACCURATE,
GB_FRAME_BLENDING_MODE_ACCURATE_ODD,
} GB_frame_blending_mode_t;
@interface GBView : NSView<JOYListener>
- (void) flip; - (void) flip;
- (uint32_t *) pixels; - (uint32_t *) pixels;
@property GB_gameboy_t *gb; @property (nonatomic, weak) IBOutlet Document *document;
@property (nonatomic) BOOL shouldBlendFrameWithPrevious; @property (nonatomic) GB_gameboy_t *gb;
@property GBShader *shader; @property (nonatomic) GB_frame_blending_mode_t frameBlendingMode;
@property (getter=isMouseHidingEnabled) BOOL mouseHidingEnabled; @property (nonatomic, getter=isMouseHidingEnabled) bool mouseHidingEnabled;
@property bool isRewinding; @property (nonatomic) bool isRewinding;
@property (nonatomic, strong) NSView *internalView;
@property (weak) GBOSDView *osdView;
- (void) createInternalView;
- (uint32_t *)currentBuffer;
- (uint32_t *)previousBuffer;
- (void)screenSizeChanged;
- (void)setRumble: (double)amp;
- (NSImage *)renderToImage;
@end @end

View File

@ -1,66 +1,180 @@
#import <OpenGL/gl.h> #import <IOKit/pwr_mgt/IOPMLib.h>
#import <Carbon/Carbon.h> #import <Carbon/Carbon.h>
#import "GBView.h" #import "GBView.h"
#import "GBViewGL.h"
#import "GBViewMetal.h"
#import "GBButtons.h" #import "GBButtons.h"
#import "NSString+StringForKey.h" #import "NSString+StringForKey.h"
#import "Document.h"
#define JOYSTICK_HIGH 0x4000
#define JOYSTICK_LOW 0x3800
static const uint8_t workboy_ascii_to_key[] = {
['0'] = GB_WORKBOY_0,
['`'] = GB_WORKBOY_UMLAUT,
['1'] = GB_WORKBOY_1,
['2'] = GB_WORKBOY_2,
['3'] = GB_WORKBOY_3,
['4'] = GB_WORKBOY_4,
['5'] = GB_WORKBOY_5,
['6'] = GB_WORKBOY_6,
['7'] = GB_WORKBOY_7,
['8'] = GB_WORKBOY_8,
['9'] = GB_WORKBOY_9,
['\r'] = GB_WORKBOY_ENTER,
[3] = GB_WORKBOY_ENTER,
['!'] = GB_WORKBOY_EXCLAMATION_MARK,
['$'] = GB_WORKBOY_DOLLAR,
['#'] = GB_WORKBOY_HASH,
['~'] = GB_WORKBOY_TILDE,
['*'] = GB_WORKBOY_ASTERISK,
['+'] = GB_WORKBOY_PLUS,
['-'] = GB_WORKBOY_MINUS,
['('] = GB_WORKBOY_LEFT_PARENTHESIS,
[')'] = GB_WORKBOY_RIGHT_PARENTHESIS,
[';'] = GB_WORKBOY_SEMICOLON,
[':'] = GB_WORKBOY_COLON,
['%'] = GB_WORKBOY_PERCENT,
['='] = GB_WORKBOY_EQUAL,
[','] = GB_WORKBOY_COMMA,
['<'] = GB_WORKBOY_LT,
['.'] = GB_WORKBOY_DOT,
['>'] = GB_WORKBOY_GT,
['/'] = GB_WORKBOY_SLASH,
['?'] = GB_WORKBOY_QUESTION_MARK,
[' '] = GB_WORKBOY_SPACE,
['\''] = GB_WORKBOY_QUOTE,
['@'] = GB_WORKBOY_AT,
['q'] = GB_WORKBOY_Q,
['w'] = GB_WORKBOY_W,
['e'] = GB_WORKBOY_E,
['r'] = GB_WORKBOY_R,
['t'] = GB_WORKBOY_T,
['y'] = GB_WORKBOY_Y,
['u'] = GB_WORKBOY_U,
['i'] = GB_WORKBOY_I,
['o'] = GB_WORKBOY_O,
['p'] = GB_WORKBOY_P,
['a'] = GB_WORKBOY_A,
['s'] = GB_WORKBOY_S,
['d'] = GB_WORKBOY_D,
['f'] = GB_WORKBOY_F,
['g'] = GB_WORKBOY_G,
['h'] = GB_WORKBOY_H,
['j'] = GB_WORKBOY_J,
['k'] = GB_WORKBOY_K,
['l'] = GB_WORKBOY_L,
['z'] = GB_WORKBOY_Z,
['x'] = GB_WORKBOY_X,
['c'] = GB_WORKBOY_C,
['v'] = GB_WORKBOY_V,
['b'] = GB_WORKBOY_B,
['n'] = GB_WORKBOY_N,
['m'] = GB_WORKBOY_M,
};
static const uint8_t workboy_vk_to_key[] = {
[kVK_F1] = GB_WORKBOY_CLOCK,
[kVK_F2] = GB_WORKBOY_TEMPERATURE,
[kVK_F3] = GB_WORKBOY_MONEY,
[kVK_F4] = GB_WORKBOY_CALCULATOR,
[kVK_F5] = GB_WORKBOY_DATE,
[kVK_F6] = GB_WORKBOY_CONVERSION,
[kVK_F7] = GB_WORKBOY_RECORD,
[kVK_F8] = GB_WORKBOY_WORLD,
[kVK_F9] = GB_WORKBOY_PHONE,
[kVK_F10] = GB_WORKBOY_UNKNOWN,
[kVK_Delete] = GB_WORKBOY_BACKSPACE,
[kVK_Shift] = GB_WORKBOY_SHIFT_DOWN,
[kVK_RightShift] = GB_WORKBOY_SHIFT_DOWN,
[kVK_UpArrow] = GB_WORKBOY_UP,
[kVK_DownArrow] = GB_WORKBOY_DOWN,
[kVK_LeftArrow] = GB_WORKBOY_LEFT,
[kVK_RightArrow] = GB_WORKBOY_RIGHT,
[kVK_Escape] = GB_WORKBOY_ESCAPE,
[kVK_ANSI_KeypadDecimal] = GB_WORKBOY_DECIMAL_POINT,
[kVK_ANSI_KeypadClear] = GB_WORKBOY_M,
[kVK_ANSI_KeypadMultiply] = GB_WORKBOY_H,
[kVK_ANSI_KeypadDivide] = GB_WORKBOY_J,
};
@implementation GBView @implementation GBView
{ {
uint32_t *image_buffers[3]; uint32_t *image_buffers[3];
unsigned char current_buffer; unsigned char current_buffer;
BOOL mouse_hidden; bool mouse_hidden;
NSTrackingArea *tracking_area; NSTrackingArea *tracking_area;
BOOL _mouseHidingEnabled; bool _mouseHidingEnabled;
bool enableAnalog; bool axisActive[2];
bool underclockKeyDown; bool underclockKeyDown;
double clockMultiplier; double clockMultiplier;
double analogClockMultiplier;
bool analogClockMultiplierValid;
NSEventModifierFlags previousModifiers; NSEventModifierFlags previousModifiers;
JOYController *lastController;
GB_frame_blending_mode_t _frameBlendingMode;
bool _turbo;
bool _mouseControlEnabled;
} }
- (void) awakeFromNib + (instancetype)alloc
{ {
NSOpenGLPixelFormatAttribute attrs[] = return [self allocWithZone:NULL];
{
NSOpenGLPFAOpenGLProfile,
NSOpenGLProfileVersion3_2Core,
0
};
NSOpenGLPixelFormat *pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] ;
if (!pf)
{
NSLog(@"No OpenGL pixel format");
} }
NSOpenGLContext* context = [[NSOpenGLContext alloc] initWithFormat:pf shareContext:nil] ; + (instancetype)allocWithZone:(struct _NSZone *)zone
{
[self setPixelFormat:pf]; if (self == [GBView class]) {
if ([GBViewMetal isSupported]) {
[self setOpenGLContext:context]; return [GBViewMetal allocWithZone: zone];
}
return [GBViewGL allocWithZone: zone];
}
return [super allocWithZone:zone];
} }
- (void) createInternalView
{
assert(false && "createInternalView must not be inherited");
}
- (void) _init - (void) _init
{ {
image_buffers[0] = malloc(160 * 144 * 4); [self registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
image_buffers[1] = malloc(160 * 144 * 4);
image_buffers[2] = malloc(160 * 144 * 4);
_shouldBlendFrameWithPrevious = 1;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(filterChanged) name:@"GBFilterChanged" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ratioKeepingChanged) name:@"GBAspectChanged" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ratioKeepingChanged) name:@"GBAspectChanged" object:nil];
tracking_area = [ [NSTrackingArea alloc] initWithRect:(NSRect){} tracking_area = [ [NSTrackingArea alloc] initWithRect:(NSRect){}
options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingInVisibleRect options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseMoved
owner:self owner:self
userInfo:nil]; userInfo:nil];
[self addTrackingArea:tracking_area]; [self addTrackingArea:tracking_area];
clockMultiplier = 1.0; clockMultiplier = 1.0;
[self createInternalView];
[self addSubview:self.internalView];
self.internalView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[JOYController registerListener:self];
_mouseControlEnabled = true;
} }
- (void) filterChanged - (void)screenSizeChanged
{ {
[self setNeedsDisplay:YES]; if (image_buffers[0]) free(image_buffers[0]);
self.shader = nil; if (image_buffers[1]) free(image_buffers[1]);
if (image_buffers[2]) free(image_buffers[2]);
size_t buffer_size = sizeof(image_buffers[0][0]) * GB_get_screen_width(_gb) * GB_get_screen_height(_gb);
image_buffers[0] = calloc(1, buffer_size);
image_buffers[1] = calloc(1, buffer_size);
image_buffers[2] = calloc(1, buffer_size);
dispatch_async(dispatch_get_main_queue(), ^{
[self setFrame:self.superview.frame];
});
} }
- (void) ratioKeepingChanged - (void) ratioKeepingChanged
@ -68,15 +182,26 @@
[self setFrame:self.superview.frame]; [self setFrame:self.superview.frame];
} }
- (void) setShouldBlendFrameWithPrevious:(BOOL)shouldBlendFrameWithPrevious - (void) setFrameBlendingMode:(GB_frame_blending_mode_t)frameBlendingMode
{ {
_shouldBlendFrameWithPrevious = shouldBlendFrameWithPrevious; _frameBlendingMode = frameBlendingMode;
[self setNeedsDisplay:YES]; [self setNeedsDisplay:true];
} }
- (GB_frame_blending_mode_t)frameBlendingMode
{
if (_frameBlendingMode == GB_FRAME_BLENDING_MODE_ACCURATE) {
if (!_gb || GB_is_sgb(_gb)) {
return GB_FRAME_BLENDING_MODE_SIMPLE;
}
return GB_is_odd_frame(_gb)? GB_FRAME_BLENDING_MODE_ACCURATE_ODD : GB_FRAME_BLENDING_MODE_ACCURATE_EVEN;
}
return _frameBlendingMode;
}
- (unsigned char) numberOfBuffers - (unsigned char) numberOfBuffers
{ {
return _shouldBlendFrameWithPrevious? 3 : 2; return _frameBlendingMode? 3 : 2;
} }
- (void)dealloc - (void)dealloc
@ -89,11 +214,12 @@
[NSCursor unhide]; [NSCursor unhide];
} }
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
[self setRumble:0];
[JOYController unregisterListener:self];
} }
- (instancetype)initWithCoder:(NSCoder *)coder - (instancetype)initWithCoder:(NSCoder *)coder
{ {
if (!(self = [super initWithCoder:coder])) if (!(self = [super initWithCoder:coder])) {
{
return self; return self;
} }
[self _init]; [self _init];
@ -102,8 +228,7 @@
- (instancetype)initWithFrame:(NSRect)frameRect - (instancetype)initWithFrame:(NSRect)frameRect
{ {
if (!(self = [super initWithFrame:frameRect])) if (!(self = [super initWithFrame:frameRect])) {
{
return self; return self;
} }
[self _init]; [self _init];
@ -113,16 +238,18 @@
- (void)setFrame:(NSRect)frame - (void)setFrame:(NSRect)frame
{ {
frame = self.superview.frame; frame = self.superview.frame;
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"GBAspectRatioUnkept"]) { if (_gb && ![[NSUserDefaults standardUserDefaults] boolForKey:@"GBAspectRatioUnkept"]) {
double ratio = frame.size.width / frame.size.height; double ratio = frame.size.width / frame.size.height;
if (ratio >= 160.0/144.0) { double width = GB_get_screen_width(_gb);
double new_width = round(frame.size.height / 144.0 * 160.0); double height = GB_get_screen_height(_gb);
if (ratio >= width / height) {
double new_width = round(frame.size.height / height * width);
frame.origin.x = floor((frame.size.width - new_width) / 2); frame.origin.x = floor((frame.size.width - new_width) / 2);
frame.size.width = new_width; frame.size.width = new_width;
frame.origin.y = 0; frame.origin.y = 0;
} }
else { else {
double new_height = round(frame.size.width / 160.0 * 144.0); double new_height = round(frame.size.width / width * height);
frame.origin.y = floor((frame.size.height - new_height) / 2); frame.origin.y = floor((frame.size.height - new_height) / 2);
frame.size.height = new_height; frame.size.height = new_height;
frame.origin.x = 0; frame.origin.x = 0;
@ -132,43 +259,49 @@
[super setFrame:frame]; [super setFrame:frame];
} }
- (void)drawRect:(NSRect)dirtyRect {
if (!self.shader) {
self.shader = [[GBShader alloc] initWithName:[[NSUserDefaults standardUserDefaults] objectForKey:@"GBFilter"]];
}
double scale = self.window.backingScaleFactor;
glViewport(0, 0, self.bounds.size.width * scale, self.bounds.size.height * scale);
if (_shouldBlendFrameWithPrevious) {
[self.shader renderBitmap:image_buffers[current_buffer]
previous:image_buffers[(current_buffer + 2) % self.numberOfBuffers]
inSize:self.bounds.size
scale:scale];
}
else {
[self.shader renderBitmap:image_buffers[current_buffer]
previous:NULL
inSize:self.bounds.size
scale:scale];
}
glFlush();
}
- (void) flip - (void) flip
{ {
if (analogClockMultiplierValid && [[NSUserDefaults standardUserDefaults] boolForKey:@"GBAnalogControls"]) {
clockMultiplier = 1.0;
GB_set_clock_multiplier(_gb, analogClockMultiplier);
if (self.document.partner) {
GB_set_clock_multiplier(self.document.partner.gb, analogClockMultiplier);
}
if (analogClockMultiplier == 1.0) {
analogClockMultiplierValid = false;
}
if (analogClockMultiplier < 2.0 && analogClockMultiplier > 1.0) {
GB_set_turbo_mode(_gb, false, false);
if (self.document.partner) {
GB_set_turbo_mode(self.document.partner.gb, false, false);
}
}
}
else {
if (underclockKeyDown && clockMultiplier > 0.5) { if (underclockKeyDown && clockMultiplier > 0.5) {
clockMultiplier -= 0.1; clockMultiplier -= 1.0/16;
GB_set_clock_multiplier(_gb, clockMultiplier); GB_set_clock_multiplier(_gb, clockMultiplier);
if (self.document.partner) {
GB_set_clock_multiplier(self.document.partner.gb, clockMultiplier);
}
} }
if (!underclockKeyDown && clockMultiplier < 1.0) { if (!underclockKeyDown && clockMultiplier < 1.0) {
clockMultiplier += 0.1; clockMultiplier += 1.0/16;
GB_set_clock_multiplier(_gb, clockMultiplier); GB_set_clock_multiplier(_gb, clockMultiplier);
if (self.document.partner) {
GB_set_clock_multiplier(self.document.partner.gb, clockMultiplier);
}
}
}
if ((!analogClockMultiplierValid && clockMultiplier > 1) ||
_turbo || (analogClockMultiplierValid && analogClockMultiplier > 1)) {
[self.osdView displayText:@"Fast forwarding..."];
}
else if ((!analogClockMultiplierValid && clockMultiplier < 1) ||
(analogClockMultiplierValid && analogClockMultiplier < 1)) {
[self.osdView displayText:@"Slow motion..."];
} }
current_buffer = (current_buffer + 1) % self.numberOfBuffers; current_buffer = (current_buffer + 1) % self.numberOfBuffers;
dispatch_async(dispatch_get_main_queue(), ^{
[self setNeedsDisplay:YES];
});
} }
- (uint32_t *) pixels - (uint32_t *) pixels
@ -178,33 +311,76 @@
-(void)keyDown:(NSEvent *)theEvent -(void)keyDown:(NSEvent *)theEvent
{ {
if ([theEvent type] != NSEventTypeFlagsChanged && theEvent.isARepeat) return;
unsigned short keyCode = theEvent.keyCode; unsigned short keyCode = theEvent.keyCode;
if (GB_workboy_is_enabled(_gb)) {
if (theEvent.keyCode < sizeof(workboy_vk_to_key) && workboy_vk_to_key[theEvent.keyCode]) {
GB_workboy_set_key(_gb, workboy_vk_to_key[theEvent.keyCode]);
return;
}
unichar c = [theEvent type] != NSEventTypeFlagsChanged? [theEvent.charactersIgnoringModifiers.lowercaseString characterAtIndex:0] : 0;
if (c < sizeof(workboy_ascii_to_key) && workboy_ascii_to_key[c]) {
GB_workboy_set_key(_gb, workboy_ascii_to_key[c]);
return;
}
}
bool handled = false; bool handled = false;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
for (GBButton i = 0; i < GBButtonCount; i++) { unsigned player_count = GB_get_player_count(_gb);
if ([defaults integerForKey:button_to_preference_name(i)] == keyCode) { if (self.document.partner) {
player_count = 2;
}
for (unsigned player = 0; player < player_count; player++) {
for (GBButton button = 0; button < GBButtonCount; button++) {
NSNumber *key = [defaults valueForKey:button_to_preference_name(button, player)];
if (!key) continue;
if (key.unsignedShortValue == keyCode) {
handled = true; handled = true;
switch (i) { switch (button) {
case GBTurbo: case GBTurbo:
if (self.document.isSlave) {
GB_set_turbo_mode(self.document.partner.gb, true, false);
}
else {
GB_set_turbo_mode(_gb, true, self.isRewinding); GB_set_turbo_mode(_gb, true, self.isRewinding);
}
_turbo = true;
analogClockMultiplierValid = false;
break; break;
case GBRewind: case GBRewind:
if (!self.document.partner) {
self.isRewinding = true; self.isRewinding = true;
GB_set_turbo_mode(_gb, false, false); GB_set_turbo_mode(_gb, false, false);
_turbo = false;
}
break; break;
case GBUnderclock: case GBUnderclock:
underclockKeyDown = true; underclockKeyDown = true;
analogClockMultiplierValid = false;
break; break;
default: default:
GB_set_key_state(_gb, (GB_key_t)i, true); if (self.document.partner) {
if (player == 0) {
GB_set_key_state_for_player(_gb, (GB_key_t)button, 0, true);
}
else {
GB_set_key_state_for_player(self.document.partner.gb, (GB_key_t)button, 0, true);
}
}
else {
GB_set_key_state_for_player(_gb, (GB_key_t)button, player, true);
}
break; break;
} }
} }
} }
}
if (!handled && [theEvent type] != NSEventTypeFlagsChanged) { if (!handled && [theEvent type] != NSEventTypeFlagsChanged) {
[super keyDown:theEvent]; [super keyDown:theEvent];
@ -214,15 +390,39 @@
-(void)keyUp:(NSEvent *)theEvent -(void)keyUp:(NSEvent *)theEvent
{ {
unsigned short keyCode = theEvent.keyCode; unsigned short keyCode = theEvent.keyCode;
if (GB_workboy_is_enabled(_gb)) {
if (keyCode == kVK_Shift || keyCode == kVK_RightShift) {
GB_workboy_set_key(_gb, GB_WORKBOY_SHIFT_UP);
}
else {
GB_workboy_set_key(_gb, GB_WORKBOY_NONE);
}
}
bool handled = false; bool handled = false;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
for (GBButton i = 0; i < GBButtonCount; i++) { unsigned player_count = GB_get_player_count(_gb);
if ([defaults integerForKey:button_to_preference_name(i)] == keyCode) { if (self.document.partner) {
player_count = 2;
}
for (unsigned player = 0; player < player_count; player++) {
for (GBButton button = 0; button < GBButtonCount; button++) {
NSNumber *key = [defaults valueForKey:button_to_preference_name(button, player)];
if (!key) continue;
if (key.unsignedShortValue == keyCode) {
handled = true; handled = true;
switch (i) { switch (button) {
case GBTurbo: case GBTurbo:
if (self.document.isSlave) {
GB_set_turbo_mode(self.document.partner.gb, false, false);
}
else {
GB_set_turbo_mode(_gb, false, false); GB_set_turbo_mode(_gb, false, false);
}
_turbo = false;
analogClockMultiplierValid = false;
break; break;
case GBRewind: case GBRewind:
@ -231,88 +431,226 @@
case GBUnderclock: case GBUnderclock:
underclockKeyDown = false; underclockKeyDown = false;
analogClockMultiplierValid = false;
break; break;
default: default:
GB_set_key_state(_gb, (GB_key_t)i, false); if (self.document.partner) {
if (player == 0) {
GB_set_key_state_for_player(_gb, (GB_key_t)button, 0, false);
}
else {
GB_set_key_state_for_player(self.document.partner.gb, (GB_key_t)button, 0, false);
}
}
else {
GB_set_key_state_for_player(_gb, (GB_key_t)button, player, false);
}
break; break;
} }
} }
} }
}
if (!handled && [theEvent type] != NSEventTypeFlagsChanged) { if (!handled && [theEvent type] != NSEventTypeFlagsChanged) {
[super keyUp:theEvent]; [super keyUp:theEvent];
} }
} }
- (void) joystick:(NSString *)joystick_name button: (unsigned)button changedState: (bool) state - (void)setRumble:(double)amp
{ {
UpdateSystemActivity(UsrActivity); [lastController setRumbleAmplitude:amp];
NSDictionary *mapping = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"GBJoypadMappings"][joystick_name]; }
for (GBButton i = 0; i < GBButtonCount; i++) { - (bool)shouldControllerUseJoystickForMotion:(JOYController *)controller
NSNumber *mapped_button = [mapping objectForKey:GBButtonNames[i]]; {
if (mapped_button && [mapped_button integerValue] == button) { if (!_gb) return false;
switch (i) { if (!GB_has_accelerometer(_gb)) return false;
case GBTurbo: if ([[NSUserDefaults standardUserDefaults] boolForKey:@"GBMBC7JoystickOverride"]) return true;
GB_set_turbo_mode(_gb, state, state && self.isRewinding); for (JOYAxes3D *axes in controller.axes3D) {
break; if (axes.usage == JOYAxes3DUsageOrientation || axes.usage == JOYAxes3DUsageAcceleration) {
return false;
}
}
return true;
}
case GBRewind: - (void)controller:(JOYController *)controller movedAxis:(JOYAxis *)axis
self.isRewinding = state; {
if (state) { if (!_gb) return;
if (![self.window isMainWindow]) return;
NSDictionary *mapping = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitInstanceMapping"][controller.uniqueID];
if (!mapping) {
mapping = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitNameMapping"][controller.deviceName];
}
if ((axis.usage == JOYAxisUsageR1 && !mapping) ||
axis.uniqueID == [mapping[@"AnalogUnderclock"] unsignedLongValue]){
analogClockMultiplier = MIN(MAX(1 - axis.value + 0.05, 1.0 / 3), 1.0);
analogClockMultiplierValid = true;
}
else if ((axis.usage == JOYAxisUsageL1 && !mapping) ||
axis.uniqueID == [mapping[@"AnalogTurbo"] unsignedLongValue]){
analogClockMultiplier = MIN(MAX(axis.value * 3 + 0.95, 1.0), 3.0);
analogClockMultiplierValid = true;
}
}
- (void)controller:(JOYController *)controller movedAxes2D:(JOYAxes2D *)axes
{
if (!_gb) return;
if ([self shouldControllerUseJoystickForMotion:controller]) {
if (!self.mouseControlsActive) {
GB_set_accelerometer_values(_gb, -axes.value.x, -axes.value.y);
}
}
}
- (void)controller:(JOYController *)controller movedAxes3D:(JOYAxes3D *)axes
{
if (!_gb) return;
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"GBMBC7JoystickOverride"]) return;
if (self.mouseControlsActive) return;
if (axes.usage == JOYAxes3DUsageOrientation) {
for (JOYAxes3D *axes in controller.axes3D) {
// Only use orientation if there's no acceleration axes
if (axes.usage == JOYAxes3DUsageAcceleration) {
return;
}
}
JOYPoint3D point = axes.normalizedValue;
GB_set_accelerometer_values(_gb, point.x, point.z);
}
else if (axes.usage == JOYAxes3DUsageAcceleration) {
JOYPoint3D point = axes.gUnitsValue;
GB_set_accelerometer_values(_gb, point.x, point.z);
}
}
- (void)controller:(JOYController *)controller buttonChangedState:(JOYButton *)button
{
if (!_gb) return;
if (![self.window isMainWindow]) return;
_mouseControlEnabled = false;
if (button.type == JOYButtonTypeAxes2DEmulated && [self shouldControllerUseJoystickForMotion:controller]) return;
unsigned player_count = GB_get_player_count(_gb);
if (self.document.partner) {
player_count = 2;
}
IOPMAssertionID assertionID;
IOPMAssertionDeclareUserActivity(CFSTR(""), kIOPMUserActiveLocal, &assertionID);
for (unsigned player = 0; player < player_count; player++) {
NSString *preferred_joypad = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitDefaultControllers"]
objectForKey:n2s(player)];
if (player_count != 1 && // Single player, accpet inputs from all joypads
!(player == 0 && !preferred_joypad) && // Multiplayer, but player 1 has no joypad configured, so it takes inputs from all joypads
![preferred_joypad isEqualToString:controller.uniqueID]) {
continue;
}
dispatch_async(dispatch_get_main_queue(), ^{
[controller setPlayerLEDs:[controller LEDMaskForPlayer:player]];
});
NSDictionary *mapping = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitInstanceMapping"][controller.uniqueID];
if (!mapping) {
mapping = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitNameMapping"][controller.deviceName];
}
JOYButtonUsage usage = ((JOYButtonUsage)[mapping[n2s(button.uniqueID)] unsignedIntValue]) ?: button.usage;
if (!mapping && usage >= JOYButtonUsageGeneric0) {
usage = (const JOYButtonUsage[]){JOYButtonUsageY, JOYButtonUsageA, JOYButtonUsageB, JOYButtonUsageX}[(usage - JOYButtonUsageGeneric0) & 3];
}
GB_gameboy_t *effectiveGB = _gb;
unsigned effectivePlayer = player;
if (player && self.document.partner) {
effectiveGB = self.document.partner.gb;
effectivePlayer = 0;
if (controller != self.document.partner.view->lastController) {
[self setRumble:0];
self.document.partner.view->lastController = controller;
}
}
else {
if (controller != lastController) {
[self setRumble:0];
lastController = controller;
}
}
switch (usage) {
case JOYButtonUsageNone: break;
case JOYButtonUsageA: GB_set_key_state_for_player(effectiveGB, GB_KEY_A, effectivePlayer, button.isPressed); break;
case JOYButtonUsageB: GB_set_key_state_for_player(effectiveGB, GB_KEY_B, effectivePlayer, button.isPressed); break;
case JOYButtonUsageC: break;
case JOYButtonUsageStart:
case JOYButtonUsageX: GB_set_key_state_for_player(effectiveGB, GB_KEY_START, effectivePlayer, button.isPressed); break;
case JOYButtonUsageSelect:
case JOYButtonUsageY: GB_set_key_state_for_player(effectiveGB, GB_KEY_SELECT, effectivePlayer, button.isPressed); break;
case JOYButtonUsageR2:
case JOYButtonUsageL2:
case JOYButtonUsageZ: {
self.isRewinding = button.isPressed;
if (button.isPressed) {
if (self.document.isSlave) {
GB_set_turbo_mode(self.document.partner.gb, false, false);
}
else {
GB_set_turbo_mode(_gb, false, false); GB_set_turbo_mode(_gb, false, false);
} }
_turbo = false;
}
break; break;
}
case GBUnderclock: case JOYButtonUsageL1: {
underclockKeyDown = state; if (!analogClockMultiplierValid || analogClockMultiplier == 1.0 || !button.isPressed) {
if (self.document.isSlave) {
GB_set_turbo_mode(self.document.partner.gb, button.isPressed, false);
}
else {
GB_set_turbo_mode(_gb, button.isPressed, button.isPressed && self.isRewinding);
}
_turbo = button.isPressed;
}
break; break;
}
case JOYButtonUsageR1: underclockKeyDown = button.isPressed; break;
case JOYButtonUsageDPadLeft: GB_set_key_state_for_player(effectiveGB, GB_KEY_LEFT, effectivePlayer, button.isPressed); break;
case JOYButtonUsageDPadRight: GB_set_key_state_for_player(effectiveGB, GB_KEY_RIGHT, effectivePlayer, button.isPressed); break;
case JOYButtonUsageDPadUp: GB_set_key_state_for_player(effectiveGB, GB_KEY_UP, effectivePlayer, button.isPressed); break;
case JOYButtonUsageDPadDown: GB_set_key_state_for_player(effectiveGB, GB_KEY_DOWN, effectivePlayer, button.isPressed); break;
default: default:
if (i < GB_KEY_A) {
enableAnalog = false;
}
GB_set_key_state(_gb, (GB_key_t)i, state);
break; break;
} }
} }
} }
}
- (void) joystick:(NSString *)joystick_name axis: (unsigned)axis movedTo: (signed) value
{
UpdateSystemActivity(UsrActivity);
NSDictionary *mapping = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"GBJoypadMappings"][joystick_name];
NSNumber *x_axis = [mapping objectForKey:@"XAxis"];
NSNumber *y_axis = [mapping objectForKey:@"YAxis"];
if (value > 0x4000 || value < -0x4000) {
enableAnalog = true;
}
if (!enableAnalog) return;
if (x_axis && [x_axis integerValue] == axis) {
GB_set_key_state(_gb, GB_KEY_LEFT, value < -0x4000);
GB_set_key_state(_gb, GB_KEY_RIGHT, value > 0x4000);
}
else if (y_axis && [y_axis integerValue] == axis) {
GB_set_key_state(_gb, GB_KEY_UP, value < -0x4000);
GB_set_key_state(_gb, GB_KEY_DOWN, value > 0x4000);
}
}
- (BOOL)acceptsFirstResponder - (BOOL)acceptsFirstResponder
{ {
return YES; return true;
}
- (bool)mouseControlsActive
{
return _gb && GB_is_inited(_gb) && GB_has_accelerometer(_gb) &&
_mouseControlEnabled && [[NSUserDefaults standardUserDefaults] boolForKey:@"GBMBC7AllowMouse"];
} }
- (void)mouseEntered:(NSEvent *)theEvent - (void)mouseEntered:(NSEvent *)theEvent
{ {
if (!mouse_hidden) { if (!mouse_hidden) {
mouse_hidden = true; mouse_hidden = true;
if (_mouseHidingEnabled) { if (_mouseHidingEnabled &&
!self.mouseControlsActive) {
[NSCursor hide]; [NSCursor hide];
} }
} }
@ -330,7 +668,47 @@
[super mouseExited:theEvent]; [super mouseExited:theEvent];
} }
- (void)setMouseHidingEnabled:(BOOL)mouseHidingEnabled - (void)mouseDown:(NSEvent *)event
{
_mouseControlEnabled = true;
if (self.mouseControlsActive) {
if (event.type == NSEventTypeLeftMouseDown) {
GB_set_key_state(_gb, GB_KEY_A, true);
}
}
}
- (void)mouseUp:(NSEvent *)event
{
if (self.mouseControlsActive) {
if (event.type == NSEventTypeLeftMouseUp) {
GB_set_key_state(_gb, GB_KEY_A, false);
}
}
}
- (void)mouseMoved:(NSEvent *)event
{
if (self.mouseControlsActive) {
NSPoint point = [self convertPoint:[event locationInWindow] toView:nil];
point.x /= self.frame.size.width;
point.x *= 2;
point.x -= 1;
point.y /= self.frame.size.height;
point.y *= 2;
point.y -= 1;
if (GB_get_screen_width(_gb) != 160) { // has border
point.x *= 256 / 160.0;
point.y *= 224 / 114.0;
}
GB_set_accelerometer_values(_gb, -point.x, point.y);
}
}
- (void)setMouseHidingEnabled:(bool)mouseHidingEnabled
{ {
if (mouseHidingEnabled == _mouseHidingEnabled) return; if (mouseHidingEnabled == _mouseHidingEnabled) return;
@ -345,7 +723,7 @@
} }
} }
- (BOOL)isMouseHidingEnabled - (bool)isMouseHidingEnabled
{ {
return _mouseHidingEnabled; return _mouseHidingEnabled;
} }
@ -362,4 +740,45 @@
previousModifiers = event.modifierFlags; previousModifiers = event.modifierFlags;
} }
- (uint32_t *)currentBuffer
{
return image_buffers[current_buffer];
}
- (uint32_t *)previousBuffer
{
return image_buffers[(current_buffer + 2) % self.numberOfBuffers];
}
-(NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
{
NSPasteboard *pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSURLPboardType] ) {
NSURL *fileURL = [NSURL URLFromPasteboard:pboard];
if (GB_is_save_state(fileURL.fileSystemRepresentation)) {
return NSDragOperationGeneric;
}
}
return NSDragOperationNone;
}
-(BOOL)performDragOperation:(id<NSDraggingInfo>)sender
{
NSPasteboard *pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSURLPboardType] ) {
NSURL *fileURL = [NSURL URLFromPasteboard:pboard];
return [_document loadStateFile:fileURL.fileSystemRepresentation noErrorOnNotFound:false];
}
return false;
}
- (NSImage *)renderToImage;
{
/* Not going to support this on OpenGL, OpenGL is too much of a terrible API for me
to bother figuring out how the hell something so trivial can be done. */
return nil;
}
@end @end

5
Cocoa/GBViewGL.h Normal file
View File

@ -0,0 +1,5 @@
#import "GBView.h"
@interface GBViewGL : GBView
@end

35
Cocoa/GBViewGL.m Normal file
View File

@ -0,0 +1,35 @@
#import "GBViewGL.h"
#import "GBOpenGLView.h"
@implementation GBViewGL
- (void)createInternalView
{
NSOpenGLPixelFormatAttribute attrs[] =
{
NSOpenGLPFAOpenGLProfile,
NSOpenGLProfileVersion3_2Core,
0
};
NSOpenGLPixelFormat *pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
assert(pf);
NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pf shareContext:nil];
self.internalView = [[GBOpenGLView alloc] initWithFrame:self.frame pixelFormat:pf];
((GBOpenGLView *)self.internalView).wantsBestResolutionOpenGLSurface = true;
((GBOpenGLView *)self.internalView).openGLContext = context;
}
- (void)flip
{
[super flip];
dispatch_async(dispatch_get_main_queue(), ^{
[self.internalView setNeedsDisplay:true];
[self setNeedsDisplay:true];
});
}
@end

7
Cocoa/GBViewMetal.h Normal file
View File

@ -0,0 +1,7 @@
#import <Cocoa/Cocoa.h>
#import <MetalKit/MetalKit.h>
#import "GBView.h"
@interface GBViewMetal : GBView<MTKViewDelegate>
+ (bool) isSupported;
@end

232
Cocoa/GBViewMetal.m Normal file
View File

@ -0,0 +1,232 @@
#import <CoreImage/CoreImage.h>
#import "GBViewMetal.h"
#pragma clang diagnostic ignored "-Wpartial-availability"
static const vector_float2 rect[] =
{
{-1, -1},
{ 1, -1},
{-1, 1},
{ 1, 1},
};
@implementation GBViewMetal
{
id<MTLDevice> device;
id<MTLTexture> texture, previous_texture;
id<MTLBuffer> vertices;
id<MTLRenderPipelineState> pipeline_state;
id<MTLCommandQueue> command_queue;
id<MTLBuffer> frame_blending_mode_buffer;
id<MTLBuffer> output_resolution_buffer;
vector_float2 output_resolution;
}
+ (bool)isSupported
{
if (MTLCopyAllDevices) {
return [MTLCopyAllDevices() count];
}
return false;
}
- (void) allocateTextures
{
if (!device) return;
MTLTextureDescriptor *texture_descriptor = [[MTLTextureDescriptor alloc] init];
texture_descriptor.pixelFormat = MTLPixelFormatRGBA8Unorm;
texture_descriptor.width = GB_get_screen_width(self.gb);
texture_descriptor.height = GB_get_screen_height(self.gb);
texture = [device newTextureWithDescriptor:texture_descriptor];
previous_texture = [device newTextureWithDescriptor:texture_descriptor];
}
- (void)createInternalView
{
MTKView *view = [[MTKView alloc] initWithFrame:self.frame device:(device = MTLCreateSystemDefaultDevice())];
view.delegate = self;
self.internalView = view;
view.paused = true;
view.enableSetNeedsDisplay = true;
view.framebufferOnly = false;
vertices = [device newBufferWithBytes:rect
length:sizeof(rect)
options:MTLResourceStorageModeShared];
static const GB_frame_blending_mode_t default_blending_mode = GB_FRAME_BLENDING_MODE_DISABLED;
frame_blending_mode_buffer = [device newBufferWithBytes:&default_blending_mode
length:sizeof(default_blending_mode)
options:MTLResourceStorageModeShared];
output_resolution_buffer = [device newBufferWithBytes:&output_resolution
length:sizeof(output_resolution)
options:MTLResourceStorageModeShared];
output_resolution = (simd_float2){view.drawableSize.width, view.drawableSize.height};
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadShader) name:@"GBFilterChanged" object:nil];
[self loadShader];
}
- (void) loadShader
{
NSError *error = nil;
NSString *shader_source = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"MasterShader"
ofType:@"metal"
inDirectory:@"Shaders"]
encoding:NSUTF8StringEncoding
error:nil];
NSString *shader_name = [[NSUserDefaults standardUserDefaults] objectForKey:@"GBFilter"];
NSString *scaler_source = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:shader_name
ofType:@"fsh"
inDirectory:@"Shaders"]
encoding:NSUTF8StringEncoding
error:nil];
shader_source = [shader_source stringByReplacingOccurrencesOfString:@"{filter}"
withString:scaler_source];
MTLCompileOptions *options = [[MTLCompileOptions alloc] init];
options.fastMathEnabled = true;
id<MTLLibrary> library = [device newLibraryWithSource:shader_source
options:options
error:&error];
if (error) {
NSLog(@"Error: %@", error);
if (!library) {
return;
}
}
id<MTLFunction> vertex_function = [library newFunctionWithName:@"vertex_shader"];
id<MTLFunction> fragment_function = [library newFunctionWithName:@"fragment_shader"];
// Set up a descriptor for creating a pipeline state object
MTLRenderPipelineDescriptor *pipeline_state_descriptor = [[MTLRenderPipelineDescriptor alloc] init];
pipeline_state_descriptor.vertexFunction = vertex_function;
pipeline_state_descriptor.fragmentFunction = fragment_function;
pipeline_state_descriptor.colorAttachments[0].pixelFormat = ((MTKView *)self.internalView).colorPixelFormat;
error = nil;
pipeline_state = [device newRenderPipelineStateWithDescriptor:pipeline_state_descriptor
error:&error];
if (error) {
NSLog(@"Failed to created pipeline state, error %@", error);
return;
}
command_queue = [device newCommandQueue];
}
- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size
{
output_resolution = (vector_float2){size.width, size.height};
dispatch_async(dispatch_get_main_queue(), ^{
[(MTKView *)self.internalView draw];
});
}
- (void)drawInMTKView:(MTKView *)view
{
if (!(view.window.occlusionState & NSWindowOcclusionStateVisible)) return;
if (!self.gb) return;
if (texture.width != GB_get_screen_width(self.gb) ||
texture.height != GB_get_screen_height(self.gb)) {
[self allocateTextures];
}
MTLRegion region = {
{0, 0, 0}, // MTLOrigin
{texture.width, texture.height, 1} // MTLSize
};
[texture replaceRegion:region
mipmapLevel:0
withBytes:[self currentBuffer]
bytesPerRow:texture.width * 4];
if ([self frameBlendingMode]) {
[previous_texture replaceRegion:region
mipmapLevel:0
withBytes:[self previousBuffer]
bytesPerRow:texture.width * 4];
}
MTLRenderPassDescriptor *render_pass_descriptor = view.currentRenderPassDescriptor;
id<MTLCommandBuffer> command_buffer = [command_queue commandBuffer];
if (render_pass_descriptor != nil) {
*(GB_frame_blending_mode_t *)[frame_blending_mode_buffer contents] = [self frameBlendingMode];
*(vector_float2 *)[output_resolution_buffer contents] = output_resolution;
id<MTLRenderCommandEncoder> render_encoder =
[command_buffer renderCommandEncoderWithDescriptor:render_pass_descriptor];
[render_encoder setViewport:(MTLViewport){0.0, 0.0,
output_resolution.x,
output_resolution.y,
-1.0, 1.0}];
[render_encoder setRenderPipelineState:pipeline_state];
[render_encoder setVertexBuffer:vertices
offset:0
atIndex:0];
[render_encoder setFragmentBuffer:frame_blending_mode_buffer
offset:0
atIndex:0];
[render_encoder setFragmentBuffer:output_resolution_buffer
offset:0
atIndex:1];
[render_encoder setFragmentTexture:texture
atIndex:0];
[render_encoder setFragmentTexture:previous_texture
atIndex:1];
[render_encoder drawPrimitives:MTLPrimitiveTypeTriangleStrip
vertexStart:0
vertexCount:4];
[render_encoder endEncoding];
[command_buffer presentDrawable:view.currentDrawable];
}
[command_buffer commit];
}
- (void)flip
{
[super flip];
dispatch_async(dispatch_get_main_queue(), ^{
[(MTKView *)self.internalView setNeedsDisplay:true];
});
}
- (NSImage *)renderToImage
{
CIImage *ciImage = [CIImage imageWithMTLTexture:[[(MTKView *)self.internalView currentDrawable] texture]
options:@{
kCIImageColorSpace: (__bridge_transfer id)CGColorSpaceCreateDeviceRGB()
}];
ciImage = [ciImage imageByApplyingTransform:CGAffineTransformTranslate(CGAffineTransformMakeScale(1, -1),
0, ciImage.extent.size.height)];
CIContext *context = [CIContext context];
CGImageRef cgImage = [context createCGImage:ciImage fromRect:ciImage.extent];
NSImage *ret = [[NSImage alloc] initWithCGImage:cgImage size:self.internalView.bounds.size];
CGImageRelease(cgImage);
return ret;
}
@end

6
Cocoa/GBVisualizerView.h Normal file
View File

@ -0,0 +1,6 @@
#import <Cocoa/Cocoa.h>
#include <Core/gb.h>
@interface GBVisualizerView : NSView
- (void)addSample:(GB_sample_t *)sample;
@end

71
Cocoa/GBVisualizerView.m Normal file
View File

@ -0,0 +1,71 @@
#import "GBVisualizerView.h"
#import "GBPaletteEditorController.h"
#include <Core/gb.h>
#define SAMPLE_COUNT 1024
static NSColor *color_to_effect_color(typeof(GB_PALETTE_DMG.colors[0]) color)
{
if (@available(macOS 10.10, *)) {
double tint = MAX(color.r, MAX(color.g, color.b)) + 64;
return [NSColor colorWithRed:color.r / tint
green:color.g / tint
blue:color.b / tint
alpha:tint/(255 + 64)];
}
return [NSColor colorWithRed:color.r / 255.0
green:color.g / 255.0
blue:color.b / 255.0
alpha:1.0];
}
@implementation GBVisualizerView
{
GB_sample_t _samples[SAMPLE_COUNT];
size_t _position;
}
- (void)drawRect:(NSRect)dirtyRect
{
const GB_palette_t *palette = [GBPaletteEditorController userPalette];
NSSize size = self.bounds.size;
[color_to_effect_color(palette->colors[0]) setFill];
NSRectFill(self.bounds);
NSBezierPath *line = [NSBezierPath bezierPath];
[line moveToPoint:NSMakePoint(0, size.height / 2)];
for (unsigned i = 0; i < SAMPLE_COUNT; i++) {
GB_sample_t *sample = _samples + ((i + _position) % SAMPLE_COUNT);
double volume = ((signed)sample->left + (signed)sample->right) / 32768.0;
[line lineToPoint:NSMakePoint(size.width * (i + 0.5) / SAMPLE_COUNT,
(volume + 1) * size.height / 2)];
}
[line lineToPoint:NSMakePoint(size.width, size.height / 2)];
[line setLineWidth:1.0];
[color_to_effect_color(palette->colors[2]) setFill];
[line fill];
[color_to_effect_color(palette->colors[1]) setFill];
NSRectFill(NSMakeRect(0, size.height / 2 - 0.5, size.width, 1));
[color_to_effect_color(palette->colors[3]) setStroke];
[line stroke];
[super drawRect:dirtyRect];
}
- (void)addSample:(GB_sample_t *)sample
{
_samples[_position++] = *sample;
if (_position == SAMPLE_COUNT) {
_position = 0;
}
}
@end

View File

@ -10,7 +10,7 @@ static GBWarningPopover *lastPopover;
lastPopover = [[self alloc] init]; lastPopover = [[self alloc] init];
[lastPopover setBehavior:NSPopoverBehaviorApplicationDefined]; [lastPopover setBehavior:NSPopoverBehaviorApplicationDefined];
[lastPopover setAnimates:YES]; [lastPopover setAnimates:true];
lastPopover.contentViewController = [[NSViewController alloc] initWithNibName:@"PopoverView" bundle:nil]; lastPopover.contentViewController = [[NSViewController alloc] initWithNibName:@"PopoverView" bundle:nil];
NSTextField *field = (NSTextField *)lastPopover.contentViewController.view; NSTextField *field = (NSTextField *)lastPopover.contentViewController.view;
[field setStringValue:contents]; [field setStringValue:contents];
@ -20,7 +20,7 @@ static GBWarningPopover *lastPopover;
[lastPopover setContentSize:textSize]; [lastPopover setContentSize:textSize];
if (!view.window.isVisible) { if (!view.window.isVisible) {
[view.window setIsVisible:YES]; [view.window setIsVisible:true];
} }
[lastPopover showRelativeToRect:view.bounds [lastPopover showRelativeToRect:view.bounds

View File

@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleDisplayName</key>
<string>SameBoy</string>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDocumentTypes</key> <key>CFBundleDocumentTypes</key>
@ -46,6 +48,46 @@
<key>NSDocumentClass</key> <key>NSDocumentClass</key>
<string>Document</string> <string>Document</string>
</dict> </dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>isx</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>ColorCartridge</string>
<key>CFBundleTypeName</key>
<string>Game Boy ISX File</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>com.github.liji32.sameboy.isx</string>
</array>
<key>LSTypeIsPackage</key>
<integer>0</integer>
<key>NSDocumentClass</key>
<string>Document</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>gbs</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>ColorCartridge</string>
<key>CFBundleTypeName</key>
<string>Game Boy Sound File</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>com.github.liji32.sameboy.gbs</string>
</array>
<key>LSTypeIsPackage</key>
<integer>0</integer>
<key>NSDocumentClass</key>
<string>Document</string>
</dict>
</array> </array>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>SameBoy</string> <string>SameBoy</string>
@ -70,7 +112,7 @@
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>10.9</string> <string>10.9</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright © 2015-2018 Lior Halphon</string> <string>Copyright © 2015-2021 Lior Halphon</string>
<key>NSMainNibFile</key> <key>NSMainNibFile</key>
<string>MainMenu</string> <string>MainMenu</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
@ -115,7 +157,47 @@
</array> </array>
</dict> </dict>
</dict> </dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array> </array>
<key>UTTypeDescription</key>
<string>Game Boy ISX File</string>
<key>UTTypeIconFile</key>
<string>ColorCartridge</string>
<key>UTTypeIdentifier</key>
<string>com.github.liji32.sameboy.isx</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>isx</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Game Boy Sound File</string>
<key>UTTypeIconFile</key>
<string>ColorCartridge</string>
<key>UTTypeIdentifier</key>
<string>com.github.liji32.sameboy.gbs</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gbs</string>
</array>
</dict>
</dict>
</array>
<key>NSCameraUsageDescription</key>
<string>SameBoy needs to access your camera to emulate the Game Boy Camera</string>
<key>NSSupportsAutomaticGraphicsSwitching</key> <key>NSSupportsAutomaticGraphicsSwitching</key>
<true/> <true/>
</dict> </dict>

BIN
Cocoa/Joypad.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
Cocoa/Joypad@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
Cocoa/Joypad~dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
Cocoa/Joypad~dark@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -30,7 +30,7 @@
<h1>SameBoy</h1> <h1>SameBoy</h1>
<h2>MIT License</h2> <h2>MIT License</h2>
<h3>Copyright © 2015-2018 Lior Halphon</h3> <h3>Copyright © 2015-2021 Lior Halphon</h3>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy <p>Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="14F1713" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14868" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14868"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication"> <customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@ -11,7 +12,11 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/> <customObject id="Voe-Tx-rLC" customClass="AppDelegate">
<connections>
<outlet property="linkCableMenuItem" destination="V4S-Fo-xJK" id="KL9-3K-64i"/>
</connections>
</customObject>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/> <customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6"> <menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items> <items>
@ -311,7 +316,36 @@
</menu> </menu>
</menuItem> </menuItem>
<menuItem isSeparatorItem="YES" id="5GS-tt-E0a"/> <menuItem isSeparatorItem="YES" id="5GS-tt-E0a"/>
<menuItem title="Game Boy" tag="1" id="vc7-yy-ARW"> <menuItem title="Save Screenshot" keyEquivalent="s" id="0J3-yf-iXs">
<connections>
<action selector="saveScreenshot:" target="-1" id="gJd-ml-J8p"/>
</connections>
</menuItem>
<menuItem title="Save Screenshot As…" alternate="YES" keyEquivalent="s" id="98X-Fp-Uny">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="saveScreenshotAs:" target="-1" id="Cxc-Gx-ql1"/>
</connections>
</menuItem>
<menuItem title="Copy Screenshot" keyEquivalent="S" id="vbX-pB-QC8">
<connections>
<action selector="copyScreenshot:" target="-1" id="XJC-EB-HNl"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="zk7-gf-LXN"/>
<menuItem title="Game Boy" tag="1" id="g7C-LA-VAr">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="reset:" target="-1" id="rxG-cz-s1S"/>
</connections>
</menuItem>
<menuItem title="Game Boy Pocket/Light" tag="5" id="1bM-CT-hoW">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="reset:" target="-1" id="U7l-BM-kB1"/>
</connections>
</menuItem>
<menuItem title="Super Game Boy" tag="4" id="vc7-yy-ARW">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
<action selector="reset:" target="-1" id="E4M-QG-ua9"/> <action selector="reset:" target="-1" id="E4M-QG-ua9"/>
@ -335,11 +369,22 @@
<action selector="mute:" target="-1" id="YE5-mi-Yzd"/> <action selector="mute:" target="-1" id="YE5-mi-Yzd"/>
</connections> </connections>
</menuItem> </menuItem>
<menuItem isSeparatorItem="YES" id="YIZ-pz-N4V"/> </items>
<menuItem title="Blend Frames" id="AWj-r8-L6U"> </menu>
</menuItem>
<menuItem title="Cheats" id="8ld-Ad-nvc">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Cheats" id="Ucc-Hm-TVA">
<items>
<menuItem title="Enable Cheats" keyEquivalent="C" id="vtx-LG-v6y">
<connections>
<action selector="toggleCheats:" target="-1" id="gsw-UY-fhu"/>
</connections>
</menuItem>
<menuItem title="Show Cheats" id="LZV-QK-YXi">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
<action selector="toggleBlend:" target="-1" id="TjO-ce-UxL"/> <action selector="showCheats:" target="-1" id="tfr-qM-q8X"/>
</connections> </connections>
</menuItem> </menuItem>
</items> </items>
@ -355,18 +400,35 @@
<action selector="disconnectAllAccessories:" target="-1" id="5hY-9U-nRn"/> <action selector="disconnectAllAccessories:" target="-1" id="5hY-9U-nRn"/>
</connections> </connections>
</menuItem> </menuItem>
<menuItem title="Game Link Cable &amp; Infrared" id="V4S-Fo-xJK">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Game Link Cable &amp; Infrared" id="6sJ-Wz-QLj">
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="PMY-5j-25T"/>
</connections>
</menu>
<connections>
<action selector="nop:" target="Voe-Tx-rLC" id="Bpa-0C-lkN"/>
</connections>
</menuItem>
<menuItem title="Game Boy Printer" id="zHR-Ha-pOR"> <menuItem title="Game Boy Printer" id="zHR-Ha-pOR">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
<action selector="connectPrinter:" target="-1" id="tl1-CL-tAw"/> <action selector="connectPrinter:" target="-1" id="tl1-CL-tAw"/>
</connections> </connections>
</menuItem> </menuItem>
<menuItem title="Workboy" id="lo9-CX-BJj">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="connectWorkboy:" target="-1" id="6vS-bq-wAX"/>
</connections>
</menuItem>
</items> </items>
</menu> </menu>
</menuItem> </menuItem>
<menuItem title="Developer" id="IwX-DJ-dBk"> <menuItem title="Develop" id="IwX-DJ-dBk">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Developer" id="UVb-cc-at0"> <menu key="submenu" title="Develop" id="UVb-cc-at0">
<items> <items>
<menuItem title="Developer Mode" id="Qx6-Tt-zZR"> <menuItem title="Developer Mode" id="Qx6-Tt-zZR">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
@ -394,6 +456,19 @@
</connections> </connections>
</menuItem> </menuItem>
<menuItem isSeparatorItem="YES" id="M6n-8G-LZS"/> <menuItem isSeparatorItem="YES" id="M6n-8G-LZS"/>
<menuItem title="Show Background and Window" state="on" id="yfD-Qd-zoz">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleDisplayBackground:" target="-1" id="p5b-1n-SPR"/>
</connections>
</menuItem>
<menuItem title="Show Objects" state="on" id="OWx-a0-vQk">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleDisplayObjects:" target="-1" id="8ie-ey-739"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="afI-BR-65k"/>
<menuItem title="Show Memory" id="UIa-n7-LSa"> <menuItem title="Show Memory" id="UIa-n7-LSa">
<modifierMask key="keyEquivalentModifierMask"/> <modifierMask key="keyEquivalentModifierMask"/>
<connections> <connections>
@ -447,6 +522,7 @@
</menu> </menu>
</menuItem> </menuItem>
</items> </items>
<point key="canvasLocation" x="140" y="260"/>
</menu> </menu>
</objects> </objects>
</document> </document>

View File

@ -0,0 +1,42 @@
#import <AppKit/AppKit.h>
#import <objc/runtime.h>
@interface NSImageRep(PrivateAPI)
@property(setter=_setAppearanceName:) NSString *_appearanceName;
@end
static NSImage * (*imageNamed)(Class self, SEL _cmd, NSString *name);
@implementation NSImage(DarkHooks)
+ (NSImage *)imageNamedWithDark:(NSImageName)name
{
NSImage *light = imageNamed(self, _cmd, name);
if (@available(macOS 10.14, *)) {
NSImage *dark = imageNamed(self, _cmd, [name stringByAppendingString:@"~dark"]);
if (!dark) {
return light;
}
NSImage *ret = [[NSImage alloc] initWithSize:light.size];
for (NSImageRep *rep in light.representations) {
[rep _setAppearanceName:NSAppearanceNameAqua];
[ret addRepresentation:rep];
}
for (NSImageRep *rep in dark.representations) {
[rep _setAppearanceName:NSAppearanceNameDarkAqua];
[ret addRepresentation:rep];
}
return ret;
}
return light;
}
+(void)load
{
if (@available(macOS 10.14, *)) {
imageNamed = (void *)[self methodForSelector:@selector(imageNamed:)];
method_setImplementation(class_getClassMethod(self, @selector(imageNamed:)),
[self methodForSelector:@selector(imageNamedWithDark:)]);
}
}
@end

View File

@ -0,0 +1,7 @@
#import <AppKit/AppKit.h>
@implementation NSObject (MavericksCompat)
- (instancetype)initWithCoder:(NSCoder *)coder
{
return [self init];
}
@end

BIN
Cocoa/Next.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
Cocoa/Next@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
Cocoa/Pause.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
Cocoa/Pause@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
Cocoa/Play.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
Cocoa/Play@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

File diff suppressed because it is too large Load Diff

BIN
Cocoa/Previous.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
Cocoa/Previous@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
Cocoa/Rewind.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
Cocoa/Rewind@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
Cocoa/Speaker.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
Cocoa/Speaker@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
Cocoa/Speaker~dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Some files were not shown because too many files have changed in this diff Show More