Compare commits

...

1822 Commits
v115 ... master

Author SHA1 Message Date
Fernap b815744b4c change target address to 24 bits instead of 16 for DMAs to BWRAM to reflect size of DDA register 2024-11-03 00:26:22 +11:00
Morilli cdef244f38 Implement SA1 I-RAM write protection 2024-09-23 18:38:31 +10:00
Tim Allen 710d92cbdd Force-enable coprocessor delayed-sync while creating a save-state.
When making a save state, all the system components are "fast forwarded" to a
safe state that can be serialised. If delayedSync (called "Coprocessor Fast
Sync" in the UI) is enabled, this works perfectly. If it is disabled, the
accurate coprocessor synching interferes with the save-state creation, leading
to the game crashing or (worse) the emulator freezing.

Star Fox is a good test case - repeatedly saving state and loading it will very
quickly cause the game to run super-slowly, hang, or crash.

Ideally, somebody should dig into exactly what coprocessor syncing is doing
that breaks the assumptions of the state-saving code, but given how complex
the whole thing is, and given that it doesn't affect hardware emulation
accuracy (real hardware can't save states at all), it's easiest to just force-
enable delayedSync while a save-state is in progress.

Fix from the jgemu bsnes fork:
8b4d1b8ae5
2024-09-18 23:17:39 +10:00
invertego 9fbbea23d3 nall: always pass by reference to make_string()
Many specializations of stringify store a reference to the wrapped
value. Therefore, passing arguments to make_string() by value can be
disastrous if the compiler does not perform copy elision and stringify
stores a reference to a variable that goes out of scope when
make_string() returns.

Cherry-picked from ares commit 3d826f5b266027529f0c12211c744a23bbe25a56.
2024-09-05 15:21:21 +10:00
Tim Allen df4981787c Use a non-deprecated version of upload-artifact. 2024-09-04 21:11:17 +10:00
dependabot[bot] 4adbcdc017 Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-04 18:17:36 +10:00
Tim Allen 0fd8f56a6e Fix a crash in heuristic memory mapping.
Commit 712ed9b6b0 changed the way that the Sufami
Turbo base cartridge was detected, but it caused crashes. Apparently the way we
were converting the binary ROM data to a string for comparison, was actually
calling the wrong `string` constructor. Let's more explicitly create a
string_view instead of hoping for the compiler to pick a suitable constructor
chain.
2024-09-01 18:12:38 +10:00
Tim Allen 712ed9b6b0 Fix detection of the Sufami Turbo base cartridge.
The Sufami Turbo base cartridge is listed in the Super Famicom verified dump
database, so it did not use the heuristics. It turns out the heuristic detection
wouldn't have worked anyway - although the game's header does contain the serial
A9PJ, the heuristic revision() method does not report that serial at all.

Meanwhile, the serial A9PJ is *also* used by the game Bishoujo Senshi Sailor
Moon SuperS - Fuwafuwa Panic, so loading this game would prompt for Sufami Turbo
mini-cartridges even though the game could not make use of them.

Fixes #323
2024-08-30 13:25:22 +10:00
Morilli 79770f6207 implementation of SA-1 BW-RAM protection
Manually cherry-picked ares commit 70f361094b.

Co-Authored-By: absindx <59403574+absindx@users.noreply.github.com>
2024-03-02 00:26:03 +11:00
Morilli ccbe394e7d wdc65816: emulate (direct,X) wraparound bug in emulation mode
Manually cherry-picked ares commit be8fa76e7d

Co-Authored-By: Adrian Siekierka <kontakt@asie.pl>
2024-03-02 00:24:20 +11:00
Screwtapello 4faca659c1
Remove link to near.sh
The domain expired, and got taken over by spammers.
2024-02-17 14:17:11 +11:00
John Chadwick 40486d61c2 Simplify + update GHA workflow 2023-11-18 22:23:29 +11:00
Tim Allen 9560959fef Don't bother with Cirrus for anything but FreeBSD builds.
Since we have different hosts for different builds, let's try linking to them
directly. I vaguely recall this stopped working at some point, but we'll try
again.
2023-11-13 21:12:18 +11:00
Tim Allen 2b7bc3b08e Build bsnes with GTK+3 on Ubuntu and FreeBSD.
The latest version of Ubuntu no longer provides the GTK+2 libs that bsnes
requires.
2023-11-13 21:12:18 +11:00
Rasim Labibov 3f93cd4393 hiro: Force Gtk3 to use X11 backend 2023-11-13 21:12:18 +11:00
Adrian Siekierka dab534b658 wdc65816: fix PLB wrapping in emulation mode (#1277)
>Regarding PLB, it looks like it reads from $200 and snes9x, mesen,
bsnes, and the official CPU manual all got it wrong.

Reproduced and verified on real hardware via
https://github.com/gilyon/snes-tests
2023-10-31 17:48:07 +11:00
deadmeu 55925d9149 Update desktop entry comment field 2023-09-16 18:51:38 +10:00
Rupert Carmichael e3fcc35922 libretro: Correctly apply filters for subsystems 2023-08-07 11:35:28 +10:00
Rupert Carmichael 18afbc3770 libretro: Support blargg's NTSC filter 2023-08-06 17:10:35 +10:00
Tim Allen ea05fa0c3e CI: Update the 'nightly' tag along with the release. 2023-06-28 20:41:55 +10:00
Tim Allen 7ec3077079 Revert "nall: Add needed #include <stdexcept>"
This reverts commit e658f50da2.

bsnes' compatibility with GCC 13 was already fixed in a different way in
5cefce5c08.
2023-06-10 19:22:40 +10:00
Tim Allen e658f50da2 nall: Add needed #include <stdexcept>
Taken from ares commit 6a7898396a14eef257e63cd002fb26ffbf6e2581

Apparently this is needed by GCC 13.
2023-06-08 22:01:59 +10:00
Tim Allen 3ca0504e67 Extend the Super Famicom LOROM-RAM#A memory map.
Although Nintendo made many different cartridge circuit boards with different
memory mappings, ROMs do not indicate which specific board they are intended
to work with. Super Famicom emulators traditionally group mutually-compatible
mappings together and use heuristics to guess which family of mappings the
game expects.

There's one family of mappings that maps ROM data to the top half ($8000-$FFFF)
of memory banks in the Super Famicom address space. For historical reasons,
this family is called "LoROM" and has three main variants:

1. ROM only, mapped to the top half of every possible bank.
   The boards database calls this "LOROM".
2. ROM mapped to the top half of every possible bank,
   RAM mapped to the bottom half of banks 70-7d,f0-ff.
   The boards database calls this "LOROM-RAM"
3. ROM mapped to the top half of low-numbered banks,
   RAM mapped to both halves of banks 70-7d,f0-ff.
   The boards database calls this "LOROM-RAM#A"

The largest official game that used variant 3 was 1MiB, so a common heuristic
is "if the ROM is 2MiB or less, use variant 3, otherwise use variant 2".
2MiB is used as the threshold instead of 1MiB, perhaps so somebody can expand a
commercial ROM that uses variant 3 without having to rework it to suit a
different mapping.

Since v107 or so, higan (and by extension, bsnes) has implemented variant 3 by
mapping ROM to banks 00-3f,80-bf, which exactly fits a 2MiB ROM. However,
other emulators like Mesen, snes9x and higan v106 implement it by mapping ROM
to banks 00-6f,80-ef, all the space that is left after the RAM is mapped.

This doesn't affect any verified games in the `Super Famicom.bml` database,
since those have specific, accurate memory maps. It also won't affect
well-written games that only read from memory addresses they have populated.
However, homebrew games and ROM hacks that have never existed on a real circuit
board depend on these heuristics across all devices that read Super Famicom
ROMs, including software emulators, flash-carts, and FPGA implementations, so
bsnes should match what other emulators do.

Fixes #278.
2023-05-23 23:26:49 +10:00
orbea 5cefce5c08 nall: Fix the build for gcc13 2023-03-08 17:35:32 +11:00
Tim Allen a22c5c3eeb Cirrus CI: Build macOS binaries on AArch64. 2023-03-08 17:34:58 +11:00
Rupert Carmichael c0c60c83a8 Fix the Justifier 2022-12-11 19:18:39 +11:00
Alcaro 43e42b2dca Simplify sa1 division
Removes the branch and the double modulo

I have verified that it gives the same results for all 2^32 pairs of inputs
2022-11-25 17:26:53 +11:00
Kawa 717606dda9
Update README.md 2022-11-03 13:15:52 +01:00
Benjamin FRANCOIS 6fc6bf14a3 Allow Haiku build of libretro target 2021-10-31 20:39:10 +11:00
Sintendo 74f6ffe89b ruby/input: Add macOS mouse support
While keyboard and joypad input had already been present for some time,
mouse input for macOS remained unimplemented in ruby.

Until now, that is.
2021-10-31 19:36:15 +11:00
Tim Allen 6df1807068 Update SameBoy to v0.14.7. 2021-10-31 09:37:51 +11: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 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
Ghislain Antony Vaillant e5809740a5 Reorder optimal audio drivers
Same order as defined in ares, which favor pulseaudio over ALSA.
2021-09-06 15:24:47 +10: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
Rupert Carmichael 063e645ff2 nall: File timestamp fix for OpenBSD and DragonFly BSD, add DragonFly BSD to PLATFORM_BSD definition 2021-08-01 14:50:01 +10:00
Rupert Carmichael 3ccb543622 Set up SameBoy log callback 2021-08-01 09:49:13 +10:00
Rupert Carmichael 8c1f41e65a Build updates for SameBoy 0.14.4 2021-08-01 09:48:51 +10:00
Tim Allen 56e359af28 Merge commit 'de500cd397f6028e43574ecd36168bc4665e30bc' into update-subtrees 2021-08-01 09:46:40 +10:00
Tim Allen 139a44b142 Merge commit 'fba00e5d3404e1bcfe1007ee2e3bfc3b3bb888af' into update-subtrees 2021-08-01 09:46:29 +10:00
Kawa fba00e5d34
Merge pull request #33 from carmiker/master
Whitespace consistency in OpenBSD-specific code
2021-07-31 14:45:49 +02:00
Rupert Carmichael d31ac2e10b Whitespace cleanup in OpenBSD-specific code 2021-07-30 21:16:15 -04: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
Morilli 41f30f348a Remove unnecessary WIN* defines.
We keep WINVER and _WIN32_WINNT because different versions of mingw-w64 have different defaults.

Fixes #198.
2021-07-28 15:09:19 +10: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
Tim Allen e8105c46a7 Add a link to the official Discord.
With Near's death, we no longer have access to update https://bsnes.dev,
so we'll need to put links in the README now.
2021-07-12 18:51:52 +10: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
Rupert Carmichael 52d9bfde94 Port to OpenBSD 2021-07-06 20:09:44 +10: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
Morilli 64d484476d Fix vector<T>::acquire() arguments 2021-05-26 17:02:48 +10: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
Near 55e05c89c2 Fix critical undefined bit-shift length operation
Natural/Integer<T>.bit() (BitRange) was shifting by whatever type the source was to match the target bit length.
But this breaks when the target type is u64/s64 and the source type is u32/s32 or smaller. Shifting by >=32 becomes undefined behavior.
We have to cast the input source to the target type first, so that the source<<shift result is valid.
This is safe here regardless of source's signedness, because it's only used in =, &=, ^=, |= operations.
2021-04-14 22:55:36 +10: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
Tim Allen 4ea984b688 sfc: You can turn off auto-joypad-polling while it's in progress.
Discovered by Jonas Quinn, and originally implemented for higan in commit
e422ddc.
2021-04-06 21:43:31 +10:00
Tim Allen 34af95da9e sfc: Remove unused auto-joypad-polling variables.
These variables stopped being useful after commit 39c37ec, which switched to
tracking auto-polling state in the autoJoypadCounter variable.
2021-04-06 21:43:31 +10: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
Tim Allen 83e76c87eb hiro: Disable padding for the GTK+3 backend.
GTK+3 is designed for automatic layout, where widgets are automatically sized
and positioned according to the size of their contents. However, hiro has to be
compatible with Windows, which lacks an automatic layout system, so hiro apps
tend to position widgets manually.

Unfortunately, the GTK+3 default theme uses much bigger widgets than GTK+2 or
Windows, so hiro apps using the GTK+3 backend tend to have ugly, overlapping
widgets. To make GTK+3 behave more like other hiro targets, we add custom CSS
and override the default theme at runtime.

Fixes #168.
2021-04-03 19:24:31 +11: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
Karim DRIDI f57657f27d make it compilable on case-sensitive systems 2021-03-13 10:24:28 +11:00
Tim Allen 73b275a7d0 hiro: Remove gtksourceview dependency.
The GTK2 and GTK3 backends for hiro implement a source-code editing widget
based on gtksourceview. gtksourceview2 in particular is quite old and
unmaintained, and Linux distros are keen to drop it, so removing the dependency
helps keep bsnes portable to future platforms -- especially since bsnes doesn't
*use* the source-editing widget anywhere. It's only used by Near's text-editor,
amethyst.

We could just rip out the gtksourceview-related code and be done with it,
but since Near is still around and still working on his own copy of hiro, I
asked him to contribute his implementation so that it will be easier to merge
any future changes too.

This adds two new hiro targets, "gtk2-se" and "gtk3-se" which include the
source-code editing widget and the gtksourceview dependency. Since bsnes
defaults to "gtk2" (without the dependency) we no longer need that package
installed to build bsnes.

Fixes #137.
2021-03-04 20:29:51 +11: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
C.W. Betts c2481ac115 Update targets.md
Fix formatting
2021-02-22 20:00:06 +11: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
orbea 2dc384adcb ruby: Auto detect some dependencies with pkg-config. 2021-02-18 19:20:43 +11:00
Tim Allen be0ee7652c Update the FreeBSD image to fix a build failure.
Apparently Ports only supports the latest stable release, not earlier releases
in the 12.x family.
2021-02-15 22:03:24 +11: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
Erendel 0ceddd3968 CI: Add settings.bml to Cirrus and Github Actions 2021-02-08 20:13:01 +11:00
Erendel ee543e7ecd Add stock settings.bml 2021-02-08 20:13:01 +11:00
Near bfab1a3a9c Update name and website link
Thank you ^_^
2021-02-08 00:11:38 +01: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
Near b1a4f2700e Update website and copyright
I've registered https://bsnes.dev to be the new homepage for the project.
Screwtape and I are still working out how we're going to handle the page, but I want to get away from the old domain, and this is where we start that process.
2021-01-26 11:18:07 +11:00
Lior Halphon ef9671010b More NR43 obscurities 2021-01-24 20:57:46 +02:00
Tim Allen 4649eb83ea README: use the bsnes logo from the about box.
It's a bit more proportionately sized.
2021-01-22 18:17:15 +11:00
Tim Allen e7accf7092 doc: Document `co_serializable()`. 2021-01-22 18:10:06 +11:00
Tim Allen 4f75515cd3 doc: Add example programs using libco.
These examples were originally included in various standalone libco
releases, not as part of any higan or bsnes release. test_timing in
particular is a benchmark and smoke-test as well as a basic example
of how to use libco.
2021-01-22 18:10:06 +11: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
Zee a22bd9dba2 doc: Update usage.md 2021-01-11 22:34:29 +11: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
Tim Allen 0dcbe627c2 target-bsnes: Do not set the window background to black.
To resize a window on X11, the window manager tells the X11 server to change the
window size, then the X11 server tells the application to paint itself, and then
(eventually) the application tells the X11 server what to draw. This adds an
arbitrary amount of latency to resizing, so to make things feel more responsive,
the X11 server will paint any newly-exposed parts of the window with a default
background colour. If it happens to be the same colour as the appplication would
paint anyway, this gives resizing a much better user-experience.

Since most of bsnes' window is occupied by the viewport, which is always black,
bsnes accordingly set its window background colour to black for the best
resizing experience. However, this had two additional effects:

  - When no game is loaded, bsnes displays the bsnes icon in the main display
    area. Black canvas widgets are used as spacers to position the icon
    correctly, but the spacers don't cover the entire background, and the window
    background shines through.
  - GTK+3 draws widget transparent by default, so the background colour of the
    parent widget shines through child widgets. In particular, setting the
    window background to black makes the menu background black, even if the menu
    text is also a dark colour.

In order to get the menu to display properly in GTK+3 builds, we have to stop
bsnes from setting the top-level window background colour, and we also have to
ensure that the spacer widgets around the icon cover the entire surface of the
window.

Fixes #108.
2021-01-08 23:00:39 +11: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
Tim Allen 67d8586720 hiro: Fix screensaver suspension under GNOME on X11.
On X11, hiro uses the xdg-screensaver helper tool to disable the screensaver,
which detects the screensaver that is running and uses the appropriate
mechanism to communicate with it. The tool's API expects an X11 window ID,
but at least some screensavers ignore it, so it can be set up however. The
GNOME backend *does* care about the window ID, but its expectations are not
documented anywhere, so byuu spent a frustrating few days trying things
at random to get it working, and failing.

It turns out, GNOME does *not* require the window to be mapped, but it *does*
require the window to have a name. Using XStoreName() to name the window fixes
screensaver suspension for me under GNOME 3.38.

Note: while XStoreName is technically deprecated, it's not going to go away
while X11 is still around, and the reason it's deprecated is because it doesn't
include character encoding data. We don't care — no user should ever see the
window name, and it's plain ASCII so it should be fine.

Fixes #102.
2020-11-12 20:56:40 +11:00
Asura 4f7a269ba5 sfc: Report auto joypad polling in the HVBJOY register.
This corrects the reporting bit of HVBJOY to be set during the auto joypad
polling sequence.

This change will fix *SpellCraft - Aspects of Valor*. SpellCraft works by
polling JOY1 nonstop once menus are entered on every scanline, so with incorrect
HVBJOY bit 0 reporting, the game was thinking it was safe to read JOY1 during
the auto joypad polling sequence, so partially shifted in results were being
read back as valid. With this patch, you'll find that the game stops polling
between V:225 H:130 and V:228 H:256, which is the auto polling time range.
Before, it was polling during that time. As a result of this fix, the password
menu can be accessed safely without it closing immediately.

Fixes #86.
2020-11-11 14:49:05 +11:00
John Chadwick c15877a7b7 target-bsnes: Fixes for a couple of input settings bugs.
-   Fixes a bug where the program may crash or display improper buttons
    when changing the selected row during assignment.

    This appears to just be a mistake, accidentally using the 'batched'
    rows instead of the activeMapping row.

-   Fixes a bug where starting multiple assignments without finishing
    one leads to stale "Assigning..." text in some rows.

    This appears to be an oversight. Simply refreshing the mappings
    before starting an assignment fixes this.
2020-11-11 14:48:32 +11:00
Ghislain Antony Vaillant 083406f404 Missing install and uninstall steps 2020-11-10 22:13:16 +11:00
Ghislain Antony Vaillant 868fff9c06 Install icons to default theme
See the [Icon Theme Specification](https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html)
2020-11-10 18:03:44 +11:00
Ghislain Antony Vaillant 7a1d16bb3b Use XDG base directories 2020-11-10 17:59:14 +11:00
Sintendo d29677b778 target-bsnes: Only suppress screensavers when active
This commit reworks when the screensaver suppression kicks in.

Previously, bsnes would only engage screensaver suppression once, on
application launch. Now that the option is exposed and can be toggled at
any time, we have to be a little more clever.

Additionally, screensaver suppression is now only engaged while
emulation is active, because it doesn't make much sense otherwise.
2020-11-09 20:25:35 +11:00
Sintendo dba608a808 target-bsnes: Expose screensaver supression in UI
The setting already existed and could be changed by manually editing the
configuration file, but wasn't exposed in the UI. This commit adds the
corresponding check box.
2020-11-09 20:25:35 +11:00
Sintendo 0a9d15a978 hiro/cocoa: Implement Application::setScreenSaver
Based on code from Dolphin and SDL2.

908d6f8fa0/Source/Core/UICommon/UICommon.cpp (L416)
cf1c192936/src/video/cocoa/SDL_cocoaevents.m (L514)
2020-11-09 20:25:35 +11:00
Tim Allen f78502e131 Add a skeleton for bsnes user documentation.
As I was doing the research for #51, I figured I should write down what I
learned before I forgot it, and if I was going to do that, I might as well
write it down in Markdown so we can make a website from it.
2020-11-07 23:45:20 +11:00
Tim Allen a2571fe106 target-bsnes: Patch up broken recent-game entries.
In f09c45f, we fixed native file picker dialogs, so they would correctly set the
"option" field to Auto when loading games, instead of leaving it set to an empty
string which effectively forced NTSC mode. However, this wouldn't fix up the old
entries in the Recent Games menu, so we will patch them up if we encounter them.
2020-11-07 23:44:03 +11:00
Tim Allen 33cb7eb106 Add some documentation about what's in various bsnes directories. 2020-11-07 23:43:38 +11:00
Moonchild 09100f5d88 correctly set O_NONBLOCK in OSS 2020-11-06 21:34:39 +11:00
John Chadwick d4e1c34d0b Fix EXHIROM-RAM-* board mappings.
It is unclear why these addresses were added to the mapping. Removing
these two mappings brings behavior inline with SNES9x:

https://github.com/snes9xgit/snes9x/blob/master/memmap.cpp#L2812
2020-11-06 15:04:28 +11:00
Tim Allen 216bcee66b nall: Support all the names endian.h provides on common platforms.
Also, moved the snippet that includes endian.h beneath the "Endian detection"
header, since I think it fits more neatly there.

Fixes #77.
2020-11-04 15:50:23 +11:00
asuramaru 6b38388a67 I have added comments to clarify the unknown behaviors that remain.
Specifically, we don't know what happens when reading from 4016-4017 or 4218-421f, or when writing to 4016 or 4200, during the auto joypad polling sequence.
Presumably, nothing good.
2020-10-29 15:24:40 +11:00
Asura 42f9e68fb2 Update timing.cpp
I have updated the comment to reflect the new stepOnce() name, instead of the older step() name.
2020-10-29 15:24:40 +11:00
asuramaru 39c37ec2d1 Fix SNES auto-joypad polling
anomie's notes indicate that polling begins between cycles 32.5-95.5, but his
notes were slightly off. 32.5-95.5 is referring to the PPU dot clock. If you
multiply by 4 you get the cycle count, 130-382. It's pretty clear that in
256-cycle units, that would need to be 130-384 or you'd have no event when it
lands on cycle 384. Jonas Quinn confirmed that with his testing in any case.

I chose to split the cycle range in half and run things every 128 clocks. So
that reduces us to 32.5-64.0, or 130 to 256 + 258-384. The reason I chose 128
over 256 was so I could emulate the time it takes to perform the joypad
latching. I don't believe you can set the controller latch to 1 and then 0
immediately. It needs time to let the controllers see this happening and then
release the latch, and time to let that take effect. Polling the controllers is
only one operation so it makes sense that happens once every 256 cycles, which
is why I have the (counter&1) test for that.

Think about it this way: we know the polling sequence takes 4224 cycles, and
4224/256 is 16.5. Isn't that a little strange to have half a cycle? But if we
consider the latching is actually twice as fast, then it's 2x128 + 16x256. If we
run on a 128-clock counter, it becomes 2x128 + 16x2x128, or 34 total states. But
now since we don't actually poll on the second half of each 16x2x256 states, we
don't need to bother running the event there, so we can stop at 33 instead of 34
and it's the same thing. And by doing that, it turns our polling duration into
4224 cycles, just like we've observed.

Fixes #61.
2020-10-29 15:24:40 +11:00
jsd1982 9d262ed113 nall: fix bad memory access pattern in string.format 2020-10-28 18:35:28 +11:00
Tim Allen ac37afd153 Use byuu.org/bsnes as the official homepage.
Previously, we didn't have control of byuu.org and it wasn't obvious what we
should do about hosting. Now we can update byuu.org, though, we should continue
using it as the authoritative source information.

Fixes #2.
2020-10-27 23:21:19 +11:00
Tim Allen f09c45f3e4 Fix region auto-detection when using native file dialogs.
hiro has two confusingly-named file-picker dialogs. "BrowserDialog" is the
custom dialog built entirely with hiro widgets, "BrowserWindow" is a wrapper
around the native file-picker. bsnes is built for BrowserDialog, but if you tick
"Use native file picker" in the Emulator options, when it needs a file it will
construct a BrowserDialog, copy the relevant config options across to a new
BrowserWindow and invoke that.

Unfortunately, BrowserDialog and BrowserWindow have different capabilities.
Specifically, BrowserDialog includes an "options" list which bsnes uses to let
the user override region detection when loading a game. BrowserWindow has no
such widget. Thus, when using a BrowserDialog the options list worked as intended,
but when using a BrowserWindow the options list was never initialised and no
option was ever chosen. As a result, when opening a game with the native file-
picker, bsnes always used NTSC emulation mode, instead of auto-detecting.

Previously, constructing a BrowserDialog and calling setOptions would leave the
BrowserDialog in an inconsistent state (with no option selected). This was OK if
you immediately displayed the dialog to the user (this would complete the
initialisation and choose a default), but bsnes also used BrowserDialog as an
*interface* typee, to represent the parameters and results of a file-picker
operation that was implemented elsewhere. For this use-case, the inconsistent
state caused problems.

Therefore, BrowserDialog has been changed:

  - setting the list of options always chooses a default, maintaining the
    invariant that `.options()` always returns one of the available options.
  - The internal BrowserDialogWindow class now takes a reference to a Response
    object, instead of constructing one from scratch and having to duplicate
    the "set .option to a reasonable value" code.

Fixes #44.
2020-10-27 23:20:56 +11:00
Tim Allen 090b79b3be Strip whitespace and empty lines from the cheat editor.
Previously, bsnes would turn the cheat text into a list of cheats by splitting
on '\n', producing an empty "cheat" after the last line of the editor:

    "7e0003=00\n".split("\n") -> ["7e0003=00", ""]

That empty "cheat" is not a valid cheat, so the result would be marked invalid.
Teaching bsnes to silently skip empty lines worked, but it would preserve
multiple blank lines between two cheats, which was silly.

Now we iterate over all the lines of the cheat editor, putting valid codes in a
new vector, and setting a flag for invalid codes.

Fixes #63.
2020-10-21 16:39:39 +11:00
John Chadwick 968e6b5feb Implement GitHub Actions Based CI.
This is lightly adapted from the implementation in Higan. For more
information, see that PR in higan-emu/higan#118.

The main difference is that we only compile one binary here, and
packaging is similar to (but adapted from) packaging byuu.
2020-10-19 17:37:02 +11:00
Tim Allen 1f943663b8 C89 requires __STDC__ to be defined, but not __STDC_VERSION__
gcc defines it anyway, but clang doesn't.

Fixes #22.
2020-10-17 10:46:43 +11: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
Tim Allen e866a909dc Apply bsnes' customisations back on top of the upstream SameBoy source.
This includes changes to SameBoy (updating the README to be clear about
provenance, and adding a GNUmakefile to integrate with bsnes' build system),
updates the SameBoy version number in the about box, and adds SameBoy to the
list of subtrees updated by update-subtrees.sh.
2020-10-12 18:40:44 +11:00
Tim Allen ec18efcb04 Add 'bsnes/gb/' from commit '919a88ec23f8011dd0389a4abceb62b3d0c83e00'
git-subtree-dir: bsnes/gb
git-subtree-mainline: 844e23d0f4
git-subtree-split: 919a88ec23
2020-10-12 16:43:40 +11:00
Tim Allen 844e23d0f4 Remove old SameBoy snapshot. 2020-10-12 16:41:26 +11: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
Tim Allen 0ab0ab6957 Merge commit '5e109224fb3480d806e44d74587d052c7f88bf83' into master 2020-10-09 02:31:32 +11:00
Ruslan Tretiakov 5e109224fb Make comments ANSI C compliant 2020-10-09 02:30:21 +11: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
Ruslan Tretiakov d0efbfbcd9 libretro: Add support for BS-X Satellaview 2020-10-02 23:57:23 +10:00
Tim Allen d72874fa59 Merge libco repository's commit 'd31c6e75a54be12307d65fd80f55adfbe7aa9d67' into master 2020-10-01 16:34:55 +10:00
Ruslan Tretiakov a2255f6052 Add update-subtrees.sh based on script from higan 2020-10-01 16:34:50 +10:00
Ruslan Tretiakov fcc982dff0 PPU Mosaic fixes imported from higan 2020-10-01 09:47:47 +10: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
Ruslan Tretiakov 9517080349 Merge fix from higan for Sound Novel Tsukura/Derby Stallion 96 (jbo-85) 2020-09-29 23:09:59 +10:00
Ruslan Tretiakov 7eee058864 libretro: sync Boards dump with upstream 2020-09-29 23:09:59 +10:00
Sanaki 366a20386c Corrected valid extensions to fix archive loading of GB/GBC 2020-09-29 23:09:59 +10:00
Rouven Spreckels 9ef085fb06 Add games Bahamut Lagoon and Tales of Phantasia.
This updates the game database to match higan's version.
2020-09-28 18:59:20 +10:00
Rouven Spreckels 1c83a6fe44 Add boards SHVC-1K1X-10 and SHVC-LJ3M-01. 2020-09-25 14:22:41 +10:00
Sintendo a8c1f19f75 Add 'Unload Game' hotkey 2020-09-22 23:43:01 +10:00
Sintendo c2c479440e Add 'Power Cycle' hotkey
Closes #25.
2020-09-22 23:43:01 +10: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
Alcaro b9ccb90324 GNU Make 4.3 compatibility
* WARNING: Backward-incompatibility!
  Previously appending using '+=' to an empty variable would result in a value
  starting with a space.  Now the initial space is only added if the variable
  already contains some value.  Similarly, appending an empty string does not
  add a trailing space.

https://lwn.net/Articles/810071/
2020-09-19 23:22:13 +10:00
Tim Allen 24503fc922 hiro: qt.moc should be generated, not committed to the repo. 2020-09-18 22:31:17 +10:00
Zeno Sebastian Endemann d383f0e883 Use pkg-config instead of hardcoded path to Qt5 moc 2020-09-18 22:31:17 +10: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
Tim Allen d31c6e75a5 Add a copy of the ISC license.
Apparently there's two versions of the ISC license; the original says "and"
while the updated one says "and/or". This was copied from the ares v115 release,
so it should be the variant byuu intended by "ISC".

Fixes #19.
2020-08-24 21:52:19 +10: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
Nadia Holmquist Pedersen d9f80db036 Consider the overscan setting when getting the aspect ratio 2020-08-15 15:35:30 +10:00
Naman Dixit 096df4242a Proper cross-platform thread_local and alignas 2020-08-12 01:35:57 +10: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
Tim Allen fdacdf976d Make the README use local assets, not remotely-hosted ones.
When Near took down byuu.org, he also removed the images that the bsnes
README was ointing to. He gave me backups of data from the site, including the
images used on the bsnes homepage, but apparently the README used different
images hosted in a different location.

I've replaced the missing images with ones from the bsnes homepage that
look reasonable.
2020-07-30 10:31:09 +10: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
Kawa 5bb5e34aa1
Merge pull request #18 from namandixit/clang-signature-warning
Fix Clang's -Wstrict-prototypes warning
2020-06-25 17:43:14 +02:00
Kawa 1931c7d20d
Merge pull request #10 from namandixit/optional-libc
Made the dependency on stdlib.h and assert.h optional
2020-06-25 09:56:53 +02:00
Naman Dixit d4a67ab8d5 Added void to function signatures, in order to fix Clang's -Wstrict-prototypes 2020-06-25 11:39:40 +05:30
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
Kawa 3808e8e25f Revert "Merge pull request #41 from RokkumanX/patch-10"
This reverts commit 5d1a33daf7, reversing
changes made to 8dc73b6cec.
2020-06-23 21:02:29 +02:00
Kawa 5d1a33daf7
Merge pull request #41 from RokkumanX/patch-10
SameBoy 0.13.2
2020-06-23 21:00:06 +02:00
Rokkuman X 57cabdcf58
SameBoy 0.13.2
Updated all files with changes between 0.13.1 and 0.13.2
2020-06-23 20:16:59 +02: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
Kawa 8dc73b6cec
Merge pull request #28 from Screwtapello/ci-testing
Fix Cirrus CI builds
2020-06-08 23:00:19 +02:00
Tim Allen 35598cf622 Prevent Debian packages from prompting for configuration.
At some point the Debian tzdata package started waiting for somebody to tell it
what timezone it was in, causing CI builds to timeout.
2020-06-09 06:02:16 +10:00
Tim Allen f6d2645fd4 Apparently the MinGW compiler automatically appends the .exe extension now. 2020-06-09 06:02:16 +10:00
Tim Allen 92ebbae4ce Make CirrusCI use a supported version of FreeBSD. 2020-06-09 06:01:52 +10:00
Kawa bbcdddfcd1 Revenge of the son of the bride of ambiguity
See also some of higan's recent commits.
2020-06-08 20:33:59 +02:00
Kawa 20fa36a7d8
Change docs from HTML to MD 2020-06-06 16:29:44 +02:00
Naman Dixit fb700978ac Moved the libc override macros to settings.h, and removed __VA_ARGS__ 2020-06-06 18:57:44 +05:30
Naman Dixit bd9d4c96be Made the dependency on stdlib.h and assert.h optional
Some platforms still depend on Libc (if they are exclusively POSIX/Unix/Linux),
or need some other functionality (e.g., memcpy)
2020-06-06 17:04:16 +05:30
Lior Halphon c07588e3bd Console auto complete 2020-06-05 02:10:05 +03:00
Kawa f98cb01d0a Update presentation.cpp
Should've hit "save all"
2020-06-03 21:21:29 +02:00
Kawa 7ff2a874b6 Forgot to hit save.
Kawa says sorry.
2020-06-03 21:20:58 +02:00
Kawa b94720ffa6 Update to SameBoy 0.13.1 2020-06-03 21:16:30 +02:00
Kawa b98ce40021 Update mbc.c
6a3cd371d0
2020-06-03 20:44:27 +02: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
Tim Allen 94acbce822 Merge libco's commit history.
The official libco repository was created as a snapshopt of the then-current state of libco
in the higan repository. However, it would be a shame to lose all the
development history and changelogs that led up to this point.

This commit merges in the change history extracted from the higan repository,
including reconstructed history from the bsnes-history-kit project. Note that
many commit messages mention changes outside of libco, and some *only* mention
non-libco changes because the libco change was relatively minor compared to the
overall changes. Hopefully it's generally clear what libco changes were made and
why... but even if it isn't, this is all the information we have.

Fixes #2.
2020-04-25 15:57:07 +10: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
MerryMage 30e274953a Add 'libco/' from commit '7871e50f7d48444f1a6333128308acb0a1c8ad2b'
git-subtree-dir: libco
git-subtree-mainline: c5b39e2dfc
git-subtree-split: 7871e50f7d
2020-04-19 17:41:20 +01:00
MerryMage c5b39e2dfc libco: Remove to make space for libco subtree 2020-04-19 17:40:54 +01:00
MerryMage 7871e50f7d First commit 2020-04-19 17:36:19 +01: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
Kawa-oneechan 882e5d292f Fix QT pWindow::setModal
As in higan, not my code.
2020-04-07 20:32:45 +02:00
Kawa 1ebed1701a
Merge pull request #6 from Sintendo/setting-input-crash
settings/input: Fix updateControls crashes
2020-04-03 00:38:21 +02:00
Sintendo 97452b6ec3 settings/input: Fix updateControls crashes
updateControls assumes that when activeMapping is set, an item from
mappingList is guaranteed to be selected. However, there are several
scenarios that break this assumption:

- changing port during an active mapping
- changing device during an active mapping
- reloading the input driver during an active mapping

In all of these cases, updateControls is eventually called. It sees an
outstanding activeMapping and proceeds to figure out the offset of the
currently selected item, but since there are no selected items it ends
up dereferncing a null pointer.

The assumption can be honored by having reloadMappings cancel the
outstanding activeMapping, thus preventing a crash.

Fixes #4.
2020-04-01 01:05:10 +02: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
Sintendo 1cde5dfad8 libco/aarch64: Optimize co_swap_function
Improves thread-switching performance using the following techniques:

- Interleave stores/loads
- Restore the stack pointer and link register as early as possible
2020-03-23 23:31:19 +01:00
Sintendo 7d9ebc59a0 libco/aarch64: Fix vector register handling
The calling convention specifies that d8-d15 (the lower 64 bits of
vector registers q8-q15) are callee-saved. However, libco was
erroneously saving and restoring general-purpose registers x8-x15
instead.
2020-03-23 23:31:19 +01:00
MerryMage 69d527f322 presentation: Bugfix for macOS: about -> aboutBsnes 2020-03-22 17:24:53 +00:00
byuu da335007e7 Remove documentation website link. 2020-03-23 01:28:48 +09:00
byuu 3df6623fbf Convert bsnes into a group project and relicense it to GPLv3 or later. 2020-03-23 00:57:29 +09: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
byuu 1c7e6c58c3 v106.232
Correct merge issue with libco
Don't invoke uname on Windows targets [Alcaro]
2019-12-02 19:45:14 +09:00
byuu 0d6a02168b v106.231
SFC: disable math color bleed for first pixel
(fixes green line on the left-edge of Jurassic Park)
SFC/GG: attach Screen settings to Screen node, not PPU/VDP node
(fixes remembering Screen settings)
2019-12-02 19:28:48 +09:00
Nikos Chantziaras d094c21824 Don't include sys/mman.h when not using mprotect 2019-11-25 13:26:30 +02: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
byuu 0d87e92a10 v106.224 2019-10-20 01:14:04 +09:00
byuu ef1d4b592a v106.223 2019-10-20 00:28:09 +09:00
Lior Halphon 7d6cdf3819 Fix SGB support in SDL’s software rendering. Fixes #208 2019-10-17 21:21:10 +03:00
byuu 3a1855a80f v106.222
Added port filter panel list
Renamed ProgramWindow to Program
2019-10-14 20:31:17 +09: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
byuu 07c1beadfb v106.185 2019-07-24 22:05:39 +09:00
Shawn Anastasio 6d4cddb818 Implement ppc64 ELFv2 support in libco
The existing ppc implementation in libco only supports
the ELFv1 ABI on PowerPC 64 and therefore can't be used on
Little Endian systems and Big Endian systems running ELFv2
distros.

This commit introduces a new implementation of the libco
API for ppc64 elfv2. It has been tested with bsnes and higan.
The original ppc implementation is maintained for non-ELFv2
targets.
2019-07-23 17:24:45 -05: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
byuu 5ff2383af7 v106.181
* SFC: fixed PPU WIP regression with sprites in Donkey Kong Country 2
* libco: fix ELFv2 PowerPC compilation
* hiro: fix Cocoa compilation
* other: miscellaneous code cleanups
2019-07-19 00:39:19 +09: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
byuu 0d35f2277b Update license copyright dates. 2019-07-17 22:23:15 +09: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
peterlemon d6ffae9c1b Fix libco aarch64 typo 2019-07-16 20:12:03 +01: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
Tim Allen 4dae9affda Update to v106r175 release.
byuu says:

  - ruby: fullscreen support for Windows OpenGL 3.2, DirectDraw 7.0, GDI drivers
  - ruby: output(width, height) support for all drivers on all platforms
  - hiro: improve focus capture for Canvas and Viewport widgets
  - hiro: added two hotfixes for the macOS Cocoa target [Sintendo]
  - higan, bsnes: focus the viewport after leaving fullscreen exclusive mode
  - freebsd: moved from GCC 8.2.0 to Clang 6.0.1
  - higan: added video display emulation option to Famicom and Mega Drive cores

The reason I moved to Clang was because GCC keeps deadlocking my FreeBSD system.
I don't know if it's GCC's fault, or suddenly running 32 copies of any high-CPU
usage program, heh. But at any rate, it's worth a try. The performance is the
same, but compilation takes a tiny bit longer with Clang.
2019-07-04 12:17:01 +10: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
Tim Allen 8a751a7946 Update to v106r170 release.
byuu says:

I finally pass blargg's dmg-sound and cgb-sound tests, but at quite a cost.
Reads and writes can't happen on an exact T-cycle (clock cycle) point within an
M-cycle (opcode cycle) for the DMG. Writes to trigger take effect two clocks
after writes to wave RAM, for instance. Probably going to be a lot more of this
in low-level PPU emulation, so I'm biting the bullet and slowly converting the
Game Boy bus handler to this new format, which I'll use as a test bench for
doing this later to other systems with, since Game Boy performance isn't as
critical (it's a drop from 220fps to 200fps to have to poll the bus four times
per memory access and synchronize the CPU four times as often, so a lot less bad
than I'd feared at least.)
2019-06-27 22:13:03 +10: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
Tim Allen 80cc16d62d Update to v106r107 release.
[This WIP was made after byuu's forum closed, so byuu only gave a one-line
description -Ed.]

byuu says:

This splits ColecoVision, SG-1000/SC-3000 away from Master System/Game Gear.
Was getting too crowded in there.
2019-02-27 23:03:24 +11: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
Maximilian Mader 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
Lior Halphon d95ad1ca54 SWAP was incorrectly disassembled as RLC 2018-06-09 15:39:40 +03:00
Lior Halphon 38c0cb3323 Typo 2018-06-09 15:12:42 +03:00
Lior Halphon f64da1864f APU glitch: When turning the APU on while DIV's bit 4 (or 5 in double speed mode), the first DIV/APU event is skipped. 2018-06-09 15:11:20 +03:00
Lior Halphon 593cb7c107 Pixel accurate emulation of Prehistorik Man on a CGB-CPU-E 2018-06-08 18:44:03 +03:00
Lior Halphon ca01ff6f79 Finally, perfect emulation of the STAT write bug. 2018-06-08 17:16:15 +03:00
Lior Halphon 127324d2d6 Fixed regression involving rendering a window with negative X position. Closes #75 2018-06-07 23:08:46 +03:00
Lior Halphon f1dfa2a1bc More sensible implementation of the STAT interrupt. 2018-06-04 02:07:38 +03:00
Lior Halphon 8f892ab798 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2018-06-04 01:52:34 +03:00
Lior Halphon 0481ff9af5 Whoops 2018-06-04 01:52:24 +03:00
Lior Halphon 66ab22a5e9
Merge pull request #76 from Nadia-h/master
SDL: Add controller hat support in-game and in the GUI.
2018-06-03 17:41:28 +03:00
Nadia Pedersen 6f1070cccd SDL: Add controller hat support in-game and in the GUI. 2018-06-03 00:21:43 +02:00
Lior Halphon 8721a48206 Fixed incorrect double speed behavior. 2018-06-03 00:36:05 +03:00
Lior Halphon 7003e31b7e Fixed a regression with STAT blocking. 2018-06-02 04:00:10 +03:00
Lior Halphon 80c92daacd Include cleanup (#73) 2018-05-27 19:30:23 +03:00
Lior Halphon 6532aef089 Correct emulation of the DMG stat write bug 2018-05-26 18:06:40 +03:00
Lior Halphon 9693b2de6a Refined the STAT bug behavior. Still not perfect. 2018-05-26 17:06:49 +03:00
Lior Halphon 855ffb490a A HBlank interrupt cannot occur in the last M-cycle of HBlank. Correct emulation of STAT access conflicts on the CGB (Test: CPU-E, single speed only). Fixes a minor graphical glitch in Pokémon Puzzle Challenge. 2018-05-25 23:42:36 +03:00
Lior Halphon 249acb04cc Verified some timings on a DMG. Fixed palette write conflict timing (Although the fix kind of implies time traveling). Closes #65 2018-05-16 00:59:11 +03:00
Lior Halphon 562b43a7c5 Notes about the DMG wave-ram glitch 2018-05-15 23:02:07 +03:00
Lior Halphon 7df571d42f Less strict matching for `delete` and `unwatch`. Fixes #71 2018-05-13 23:17:23 +03:00
Lior Halphon 1fcde88d8a Improved accuracy of the halt bug 2018-05-12 22:13:52 +03:00
Lior Halphon 4527d9ee39 Styling fixes, fixed bugs caused by a rebellious brace, removed debug prints 2018-05-11 13:29:58 +03:00
Lior Halphon 9a29beb189 Merge commit '8f3fc1c2ade3c1c632cd3f3998ee26d2962e4dea'
# Conflicts:
#	SDL/main.c
2018-05-11 13:26:30 +03:00
Lior Halphon 6b6c25635a Merge commit '240730417774174315c2f7c148393834eb3297eb' 2018-05-11 13:11:53 +03:00
Lior Halphon bfc96abf8f Make save state names consistent across the Cocoa and SDL port 2018-05-11 12:51:15 +03:00
Lior Halphon feaa0d0654 Merge commit '7fe86cec59c1143275ffb7fc07b6716ae0116033' 2018-05-11 12:50:53 +03:00
Lior Halphon f4eddf316b Merge commit '9343d8162d5e6934d7894d9eea57c55f52faa503' 2018-05-11 12:46:23 +03:00
Lior Halphon 713dc02e46 A bit tacky, but T-cycle accurate emulation of LYC write conflicts on the CGB. Only single speed mode verified. Closes #54 2018-05-11 12:38:55 +03:00
Lior Halphon af3554c1d1 More accurate emulation of the LYC register and interrupt. (Still not perfect on a CGB) 2018-04-27 13:40:39 +03:00
Lior Halphon 0f8385a798 Refined line 153 behavior on a CGB. Verified on CGB-E. 2018-04-25 00:08:06 +03:00
Lothar Serra Mari 8f3fc1c2ad Fix check for SDL2 version 2018-04-22 16:20:11 +02:00
Lothar Serra Mari ca571c6fa5 SDL2: Update to SDL_OpenAudioDevice()
Instead of the legacy SDL_OpenAudio() method, we now use the newer
SDL_OpenAudioDevice() functions. This fixes audio in Windows if the SDL
version is 2.0.6 or higher.

It also allows us to use 48kHz audio for Windows (96kHz somewhat works
too, but since we don't get absolutely smooth audio with it, I'd stick
with 48kHz for now until we find a solution. 44.1Khz is available as
fallback for SDL 2.0.5 and lower. Yes, the 2.0.5 to 2.0.6 transition was
quite harsh in terms of Windows audio support...
2018-04-22 15:22:10 +02:00
Lothar Serra Mari 2407304177 SDL2: Write battery file information before issueing RESET_COMMAND
Before performing the GB reset, we should perform a GB_save_battery.

Otherwise, resetting the emulation will kill ("kill" as in simply don't
write them into the .sav) all changes made to the battery save since
sameboy was started.
2018-04-19 16:47:54 +02:00
Lothar Serra Mari 7fe86cec59 Fix savestates in SDL2 port
Because SDL_SCANCODE_0 comes *after* SDL_SCANCODE_9 in the SDL keycode
table, we have to check if the keycode is between >=1 and <=0. We also
have to substract SDL_SCANCODE_1 in order to set command_parameter
properly.

Errata: Currently, the savestate created with CTRL+0 is created, but
refuses to load on Windows (working fine on Linux).
2018-04-19 14:52:36 +02:00
Lothar Serra Mari 9343d8162d Add fullscreen mode for the SDL2 port 2018-04-18 19:22:08 +02:00
Lior Halphon be9df4d658 Added mechanism to handle MMIO read/write conflicts. Fixes #65 2018-04-14 17:57:00 +03:00
Lior Halphon 2c6f7906c5 Make multi-byte opcodes trigger the OAM bug when they increase PC 2018-04-14 15:32:55 +03:00
Lior Halphon 84aa06aba5 Clean up OAM bug code 2018-04-14 13:35:16 +03:00
Lior Halphon d667d87bbe Refactor CPU code so handling access conflicts is possible 2018-04-14 13:25:55 +03:00
Lior Halphon f1ec42d4ba H/GDMA was 4 times faster than it should have been. Made it also more accurate. Fixes #56 2018-04-13 14:41:39 +03:00
Lior Halphon 51e3cb7b9f
Merge pull request #64 from orbea/debugger
Core: Fix libretro builds
2018-04-12 00:25:38 +03:00
orbea 10dc12c502 Core: Fix libretro builds 2018-04-11 14:21:46 -07:00
Lior Halphon 417ae21dfa
Merge pull request #63 from libretro/master
Refactor android jni makefiles (#17)
2018-04-11 11:02:03 +03:00
webgeek1234 ebe0aa0c76 Refactor android jni makefiles (#17) 2018-04-10 21:42:04 -05:00
Lior Halphon 89094950f8 Correct emulation of mapping both button sets. Fixes #60 2018-04-07 16:45:31 +03:00
Lior Halphon 5be2b3db29 It appears that OAM DMA blocks PPU access to OAM 2018-04-07 13:59:36 +03:00
Lior Halphon 0725b008be Further simplifications 2018-04-07 13:02:53 +03:00
Lior Halphon 097b768127 Update comments 2018-04-07 03:36:47 +03:00
Lior Halphon 9ce028056a Cleanup 2018-04-07 03:26:10 +03:00
Lior Halphon fed2556fc3 More reasonable implementation of sprite timings 2018-04-07 03:00:26 +03:00
Lior Halphon 0751eae90b Moved the fetcher state machine to another function 2018-04-06 19:29:49 +03:00
Lior Halphon 0461fb5b2a Simplified FIFO logic 2018-04-06 19:11:48 +03:00
Lior Halphon cb01259073 Fixed #61 2018-04-06 11:37:49 +03:00
Lior Halphon 0c86ff1ee4 More CGB revision quirks 2018-04-06 04:00:37 +03:00
Lior Halphon a6ed2029b7 New information about PPU changes between CGB-B and CGB-E 2018-04-06 03:19:47 +03:00
Lior Halphon cc95c89d3c Surprise! The CGB has a 16-bit VRAM data bus 2018-04-05 16:15:51 +03:00
Lior Halphon 9aadc80f75 Implemented some obscure PPU rendering quirks, verified some timings 2018-04-05 15:33:21 +03:00
Lior Halphon d785e45308 More accurate emulation of LCDC.0 2018-04-05 12:27:01 +03:00
Lior Halphon d8e0683c35 Fixed a bug where skipping a sprite by modifying LCDC flags mid-scanline will disable sprites for the rest of the scalene. 2018-04-05 00:51:37 +03:00
Lior Halphon b1d65fd84f Fixed `boot_hwio-C` (for SameBoy’s boot). Closes #59 2018-04-03 20:10:11 +03:00
Lior Halphon 5d63892949 T-cycle accurate timing of the extra OAM interrupt. Fixes vblank_stat_intr-GS, related to #54 2018-04-03 01:43:24 +03:00
Lior Halphon ba07e7ba85 Fixed a bug where 0:$dxxx reads/writes from the wrong bank in CGB mode. Made sure symbols are reset after reloading a sym file. 2018-04-02 19:57:39 +03:00
Lior Halphon e163026ca9 The STAT bug does not occur during the glitched mode 0 2018-04-02 01:05:32 +03:00
Lior Halphon 9339a6027f Slight refinement to the last fix 2018-04-01 22:20:26 +03:00
Lior Halphon ec64c041ab The OAM interrupt is internally implemented differently from the other 3. Fixed the stat_write_if tests, relates to #54 2018-04-01 21:45:56 +03:00
Lior Halphon 69a625af97
How did I miss this thing after over 2 years?! 2018-04-01 16:53:21 +03:00
Lior Halphon 0d0d9ccdae Fixed a timer regression, fixes timer_if in DMG mode. Relates to #54 2018-03-31 15:52:31 +03:00
Lior Halphon 73dc3560a5 Mode 0 interrupts do not occur in the glitched mode 0 of the first line 0. The extra OAM interrupt bug also affects DMG. 2018-03-31 13:18:02 +03:00
Lior Halphon 0a2d6e6dcb Fixed DMG timing regression 2018-03-31 12:21:34 +03:00
Lior Halphon 7706b8727a Updated Cocoa copyright 2018-03-30 17:06:39 +03:00
Lior Halphon 9811dceca1 Emulate another OAM timing quirk; a sprite at x = 0 has extra penalty if SCX is not 0. Fixes intr_2_mode0_timing_sprites_scx*_nops, affects #54 2018-03-30 17:06:27 +03:00
Lior Halphon 2c44ffbe39 More accurate fetcher penalty emulation, fixed intr_2_mode0_timing_sprites_nops, affects #54 2018-03-30 02:53:49 +03:00
Lior Halphon 311a470806 Maybe now? Affects #55 2018-03-29 23:11:53 +03:00
Lior Halphon 3a52d2da97
Updated Windows copyright 2018-03-29 22:22:50 +03:00
Lior Halphon 5a81d83d30 Yet another attempt to fix building using MINGW. Affects #55 2018-03-29 22:02:01 +03:00
Lior Halphon b757b4c590 Another attempt to fix building using MINGW. Affects #55 2018-03-29 21:46:14 +03:00
Lior Halphon c7ca786e77 Attempt to fix building using MINGW. Affects #55 2018-03-29 21:27:19 +03:00
Lior Halphon a9fbbd3894 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2018-03-29 21:07:04 +03:00
Lior Halphon e380a00b67 Fixed another timing regression with the CB opcodes 2018-03-29 21:06:53 +03:00
Lior Halphon b89c93a624
Merge pull request #53 from kylophone/fix_typo
Fix typo, file permissons
2018-03-29 10:56:54 +03:00
Kyle Swanson 7ffe132e79 fix typo 2018-03-28 21:38:48 -07:00
Kyle Swanson 7bfe5de9c7 chmod -x 2018-03-28 21:37:34 -07:00
Lior Halphon 96063fb0da Fixed Windows build, added Unicode support in Windows. 2018-03-28 21:59:27 +03:00
Lior Halphon 4cf78139a8 Fixed a bug where SameBoy freezes for a while after leaving turbo mode 2018-03-27 23:33:31 +03:00
Lior Halphon fd2e169dc9 Seems like the audio bug introduced in SDL 2.0.5 for macOS wasn’t fixed. 2018-03-27 23:05:08 +03:00
Lior Halphon 0e3d2770d9 Properly handle cases where an object’s X position is modified between the OAM mode and rendering mode 2018-03-27 22:13:08 +03:00
Lior Halphon 0912a30bb9 Fixed a regression in dmg_sound-2 2018-03-27 21:04:55 +03:00
Lior Halphon f5493e023d Fixed a timing regression in the CB opcodes 2018-03-27 20:21:24 +03:00
Lior Halphon 7671648fca Simplified a function 2018-03-27 19:06:36 +03:00
Lior Halphon 7543461c24 Increasing PC in OAM triggers the OAM bug 2018-03-27 16:36:39 +03:00
Lior Halphon 4cbade9a88 Function name change 2018-03-27 15:55:12 +03:00
Lior Halphon 4986930511 Mostly complete emulation of the OAM bug. Passes oam_bug-2. 2018-03-27 15:46:00 +03:00
Lior Halphon 9093f22293 More accurate emulation of the OAM bug 2018-03-24 14:46:51 +03:00
Lior Halphon 5cb74fb684 Bugfix: turning the PPU off during OAM mode made the OAM bug persist while the LCD is off 2018-03-24 02:58:37 +03:00
Lior Halphon d343152fca Basic emulation of the OAM bug 2018-03-24 00:32:19 +03:00
Lior Halphon f8c6b9e7a0 Fixed the lcd command 2018-03-23 21:26:49 +03:00
Lior Halphon 4e3928df81 Turns out the behavior differs between DMG and CGB – in DMG mode, the objects enabled bit is checked before halting the FIFOs, meaning that disabled sprites do not affect Mode 3’s length on the DMG. 2018-03-23 20:01:27 +03:00
Lior Halphon 48a8db233d Refinement to the last fix 2018-03-23 19:54:11 +03:00
Lior Halphon e9eeace995 The object enabled bit is checked only when popping from the object FIFO. Objects affect timing even when disabled. 2018-03-23 19:50:19 +03:00
Lior Halphon 04bfc89816 Cycle accurate OAM search mode 2018-03-23 19:07:14 +03:00
Lior Halphon c11af7ea26 Fix CGB timings 2018-03-23 12:58:51 +03:00
Lior Halphon 3e5e17d1a3 Fixed CB [hl] opcodes timings 2018-03-23 12:35:37 +03:00
Lior Halphon 18e32d1755 Merge branch 'master' into timing
# Conflicts:
#	Core/gb.c
2018-03-22 22:37:35 +02:00
Lior Halphon 2a5407cf70 Fix libretro build on master 2018-03-22 20:22:09 +02:00
Lior Halphon 577e23925b Fixed sources-dmgABCXmgbS 2018-03-22 20:09:01 +02:00
Lior Halphon 6176befecb
Merge pull request #50 from libretro/master
Sync libretro port
2018-03-22 14:47:19 +02:00
radius f050457976 fix error in savestate code 2018-03-22 00:20:51 -05:00
radius 337617afbb change sameboy emulated model selection to apply on restart (because otherwise it may crash due the change on savestate size with rewind enabled) 2018-03-22 00:00:03 -05:00
Lior Halphon e9f243a913 Fix sprite priority 2018-03-21 00:02:35 +02:00
Lior Halphon cb33a5b25a Fix Aevilla 2018-03-20 20:08:29 +02:00
radius 007765daa6 refine variables, add comments 2018-03-19 18:25:20 -05:00
radius b1ea7c5f06 handle saving for GB2 in single cart mode 2018-03-19 18:25:20 -05:00
radius 3b5b400909 implement RTC saves in dual mode, capitalization nitpicking in core opts 2018-03-19 18:25:20 -05:00
Lior Halphon 3883b7d86a Merge branch 'master' into timing
# Conflicts:
#	Core/display.c
#	Core/z80_cpu.c
2018-03-19 23:46:33 +02:00
Lior Halphon b50c97f4a7 Prevent starting HDMA in the middle of an instruction, making both the CPU and DMA access memory at the same time. Closes #47 2018-03-19 20:01:31 +02:00
Lior Halphon 202eb2b5cc Fix stat_lyc_onoff 2018-03-18 20:32:19 +02:00
Lior Halphon 80b1275e07 Fix stat_lyc_onoff 2018-03-18 20:08:45 +02:00
Lior Halphon 0dc30f081a CGB halt interrupt timing 2018-03-17 23:21:14 +02:00
Lior Halphon 12ae5745db While fixing some rendering issues, this change was incorrect. 2018-03-17 21:04:48 +02:00
Lior Halphon 269bac4626 More CGB fixes 2018-03-17 20:34:55 +02:00
Lior Halphon 2f1e21dc2d Merge branch 'master' into timing 2018-03-16 12:18:18 +02:00
Lior Halphon 8b4714d8e2
Merge pull request #45 from LMLB/patch-1
Fix some broken shaders
2018-03-16 12:14:32 +02:00
LMLB c365c450a7 Fix shaders that break with specific pixel factors
OmniScaleLegacy seems to has problems with every odd factor (3x, 5x, 7x,
9x, etc.).
SmoothBilinear has problems with 5x and 11x and probably more.
2018-03-14 20:06:37 +01:00
LMLB 0c80ac3296 Fix shaders that sample at texel edges
Sampling at the edge between texels causes one or the other to be chosen
semi-randomly, depending on rounding errors. Add half a pixel so they
sample at texel centers instead.
2018-03-14 20:05:51 +01:00
Lior Halphon 029c685268
Merge pull request #43 from AlvaroBurnett/master
Makefile: Find SDL2.dll
2018-03-12 23:56:13 +02:00
Alvaro Burnett 05ba352f2f Makefile: Find SDL2.dll 2018-03-12 22:38:05 +01:00
Lior Halphon 21b75494a2 More CGB fixes (currently on DMG-mode CGB is verified). Halt interrupt timing isn’t correct yet. 2018-03-11 00:17:57 +02:00
Lior Halphon 15b6c48d7c Fixed vblank_stat_intr-C 2018-03-10 15:52:22 +02:00
Lior Halphon c267ad00b5 Goodbye 2018-03-09 23:34:23 +02:00
Lior Halphon e8b107efdb In double speed mode, there are no quirks where IF and STAT don’t update together 2018-03-09 23:31:49 +02:00
Lior Halphon cb6bb0590e Starting to fix CGB timing quirks 2018-03-09 21:11:35 +02:00
Lior Halphon 9083e883fe CGB BG rendering 2018-03-09 18:52:36 +02:00
Lior Halphon a32f232bb1 Fixed OAM-window priority glitch, fixed OAM glitch in Prehistoric Man 2018-03-09 17:10:19 +02:00
Lior Halphon 1149c266cf More regression fixes, actually fix Pinball Deluxe this time 2018-03-08 23:22:03 +02:00
Lior Halphon 544ca2be4c Changing the timings of memory writes so they’re not effectively one T-cycle late. This screws up APU’s cycle accuracy for now. 2018-03-05 21:17:37 +02:00
Lior Halphon 88a11b891f Object rendering 2018-03-04 23:27:31 +02:00
Lior Halphon 3d1c8b50c4 OAM search and OAM timing in mode 3 2018-03-04 22:21:56 +02:00
Lior Halphon 476133abd0 The scrolled y value is cached and not recalculated 2018-03-03 20:51:38 +02:00
Lior Halphon 518746f664 fixed rendering off by one 2018-03-03 19:52:48 +02:00
Lior Halphon 496c5589e6 Added window support 2018-03-03 19:36:21 +02:00
Lior Halphon 5ea33cc931 Cleanup 2018-03-03 19:05:29 +02:00
Lior Halphon b08f02c4f3 Rewriting the PPU rendering: T-cycle accurate background rendering. DMG only, CGB completely broken 2018-03-03 15:47:36 +02:00
Lior Halphon 487c063d48 Merge branch 'master' into timing 2018-03-02 19:45:15 +02:00
Lior Halphon 6e8567eadc Silence some annoying Cocoa warnings, hopefully it won’t affect performance 2018-03-02 19:42:02 +02:00
Lior Halphon 3c8f3ad3fc Stop annoying beeps and exceptions 2018-03-02 19:37:40 +02:00
Lior Halphon a67db0595b Fixed window behavior 2018-03-01 22:03:56 +02:00
Lior Halphon b702d56547 Merge branch 'master' into timing
# Conflicts:
#	Core/display.c
#	Core/z80_cpu.c
2018-03-01 21:22:33 +02:00
Lior Halphon 94c6dbd281 Fixed ‘call’ instruction not being properly symbolicated. Closes #37 2018-03-01 21:12:37 +02:00
Lior Halphon 7248403be7 Fixed several DMG regressions, fixes Pinball Deluxe again 2018-03-01 00:12:04 +02:00
Lior Halphon fb03479a1f Added 16-bit dereferencing operator (`{address}`) to the debugger. Closes #38 2018-02-28 19:39:22 +02:00
Lior Halphon 58d287da7a
Merge pull request #36 from ISSOtm/patch-1
Make the main menu's last option's purpose more explicit
2018-02-28 19:24:50 +02:00
Panda Habert 980acc3fb8
Make the last option's purpose more explicit
I mistook it several times for the option to exit the menu :/
2018-02-26 02:27:50 +01:00
Lior Halphon b02e40d5a2 Refinement to that last fix 2018-02-25 23:23:55 +02:00
Lior Halphon 90a943d05a Emulate an HDMA quirk required to properly emulate Aevilia 2018-02-25 22:32:41 +02:00
Lior Halphon ef670986c6 Rewrote PPU (currently only emulates DMG correctly) to use the new timing mechanism. Removed “future interrupts” (No longer required because SameBoy is now T-cycle based) 2018-02-25 00:48:45 +02:00
Lior Halphon 42ab746a66 Starting to remove the delayed interrupts hack – done for timer interrupt, broken for display interrupts 2018-02-23 15:33:44 +02:00
Lior Halphon c48097a484 Convert div counter to the SM mechanism 2018-02-23 13:16:05 +02:00
Lior Halphon 5974092c94 Bugfix 2018-02-20 23:04:35 +02:00
Lior Halphon 56eac9f875 Removed some dead code from display.c 2018-02-20 21:23:27 +02:00
Lior Halphon 9802ca41dd Components not affected by CGB’s double speed mode now operate in 8MHz mode to theoretically make advance_cycles(gb, 1) safe. 2018-02-20 21:17:12 +02:00
Lior Halphon 058913f8a2
Fixed libretro-Android build 2018-02-20 19:57:33 +02:00
Lior Halphon d0202a3f9a Added LCD graphics filter; emulates low-resolution LCD artifacts 2018-02-17 20:43:48 +02:00
Lior Halphon f79af39ea2 More accurate emulation of the APU’s analog characteristics 2018-02-16 18:01:50 +02:00
Lior Halphon fc35111ae7 Corrected the emulated DAC’s range 2018-02-16 01:26:37 +02:00
Lior Halphon 0c231db9e7 This is probably not correct (and makes no sense from an hardware design perspective), but this correctly emulates my analog test cases and fixes the pops introduced by the last commit. 2018-02-13 23:13:15 +02:00
Lior Halphon bfb37884e1 Inactive channels are not equivalent to channels with 0 volume. 2018-02-11 22:50:15 +02:00
Lior Halphon afcc66fb3c Added CPU under/over-clocking support in Core, add under-clocking hotkey in the Cocoa port, allow modifier keys to be configured as input keys in Cocoa. 2018-02-10 23:30:30 +02:00
Lior Halphon 0cbbaac490 Updated incorrect comment after verification 2018-02-10 19:50:42 +02:00
Lior Halphon 220ba9ff38 Restored auto model selection in libretro. Fixed incorrect aspect ratio in libretro (Closes #30). 2018-02-10 15:41:00 +02:00
Lior Halphon 81f808e184 Refinements for the Wii U port 2018-02-10 15:02:22 +02:00
Lior Halphon 00c67f8842 Merge commit '217e9787bd640cbd1b8250e31c0064331ddc302f' 2018-02-10 14:49:57 +02:00
Lior Halphon 369a915d66 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2018-02-10 14:44:48 +02:00
Lior Halphon 1c61b006ba Added rewinding support to the core and the Cocoa frontend 2018-02-10 14:42:14 +02:00
radius 217e9787bd change MAX_CH_AMP on WiiU 2018-02-07 15:28:30 -05:00
Twinaphex 26d51a831c
Merge pull request #14 from libretro/link
Link Cable
2018-02-06 01:12:23 +01:00
radius cc296a3114 fix savefile names 2018-02-05 19:07:18 -05:00
radius 8dd94505a8 save ram handling for dual mode 2018-02-05 19:07:08 -05:00
radius 792087276e cleanup logs 2018-02-05 19:07:08 -05:00
radius ff8a20ef04 disable this for now 2018-02-05 19:07:08 -05:00
radius d3a67f9e19 make link cable a runtime option 2018-02-05 19:07:08 -05:00
radius 567936a21d cut code duplication a bit 2018-02-05 19:07:08 -05:00
radius 0b96df1428 readd single game link cable 2018-02-05 19:07:08 -05:00
radius f98b71a257 rename core options 2018-02-05 19:07:07 -05:00
radius a5b182f0fa standarize core options 2018-02-05 19:07:07 -05:00
radius b74095a2cd set emulated devices automatically 2018-02-05 19:07:01 -05:00
radius b169d86bf8 subsystem support 2018-02-05 19:07:01 -05:00
Tatsuya79 7459b9610c Reduce input lag by 1 frame 2018-02-05 19:06:56 -05:00
radius a8741674ce better savestate code 2018-02-05 19:06:56 -05:00
radius 50fd7f1140 use set geometry instead 2018-02-05 19:06:56 -05:00
radius 120edb6f8c rebase from master 2018-02-05 19:06:56 -05:00
Brad Parker ef143261e5 implement left-right screen layout option, add ASAN to Makefile 2018-02-05 19:06:55 -05:00
radius 5e04600ab1 add descriptors to P2 2018-02-05 19:06:55 -05:00
radius 408bf5baab add audio output selection 2018-02-05 19:06:55 -05:00
radius 945ee0bdb3 rename the array so it doesn't conflict with the function signature 2018-02-05 19:06:55 -05:00
radius 88dfb9a159 fix emulated model for slot 2 2018-02-05 19:06:55 -05:00
radius 457b3b3f06 change viewport size 2018-02-05 19:06:55 -05:00
radius 8b506e84fd fix changing mode between link enabled and disabled 2018-02-05 19:06:54 -05:00
radius 7ee063da28 single mode works 2018-02-05 19:06:54 -05:00
radius f7d129bd24 separate core options for single and linked mode 2018-02-05 19:06:47 -05:00
radius 52634b8023 add layout core option 2018-02-05 19:06:42 -05:00
radius b573fbcdc4 reduce code duplication 2018-02-05 19:06:41 -05:00
radius 49a8cd0bb5 hook up savestates for GB#2 2018-02-05 19:06:23 -05:00
radius 91816c30b5 fix gameboy synchronization thanks to @LIJI32 2018-02-05 19:06:23 -05:00
radius 45e0a75491 savefile hack for slot 2, both load from the same SRM file but gb2 doesn't save 2018-02-05 19:06:23 -05:00
radius 3b858fb6af initial link cable implementation 2018-02-05 19:06:23 -05:00
radius ff4168b8f6 fix warning 2018-02-05 19:04:51 -05:00
radius db0269cd3f clean whitespace 2018-02-05 18:39:25 -05:00
radius dd7704e572 set sample rate to 44100 on WIIU 2018-02-05 18:31:31 -05:00
radius a939fed872 cleanup whitespaces 2018-02-05 18:17:55 -05:00
radius 9a09f92032 update Android.mk 2018-02-05 18:13:36 -05:00
radius a04646ab5b update Android.mk 2018-02-05 18:13:36 -05:00
radius e1bd85caa6 add WiiU target 2018-02-05 18:13:35 -05:00
radius 3bd1c122c3 try to fix jni build 2018-02-05 18:13:35 -05:00
kwyxz ede16f1d3b Allow build on Haiku target 2018-02-05 18:13:35 -05:00
Tatsuya79 9c23fe2563 Reduce input lag by 1 frame 2018-02-05 18:13:35 -05:00
radius 39c352c89b add address sanitizer support 2018-02-05 18:13:35 -05:00
radius 5660b762c0 add prebuilt roms again 2018-02-05 18:13:34 -05:00
radius e97624ba7d fix warning 2018-02-05 18:13:34 -05:00
radius d047897462 use the prebuilt roms 2018-02-05 18:13:34 -05:00
Lior Halphon 96f6839434
Merge pull request #28 from rootfather/enumlation
SDL: Fix typo in the GUI
2018-02-03 17:37:49 +02:00
rootfather 8f56da465a SDL: Fix typo in the GUI 2018-02-03 16:35:50 +01:00
Lior Halphon 51eacd3174 Update version to 0.10.1, update copyright to 2018 2018-02-03 00:50:38 +02:00
Lior Halphon aeb9f0eda4 Prevent screensaver when using a joypad 2018-02-02 19:22:08 +02:00
Lior Halphon f3c07f1f99 Fixed a silly bug that prevented libretro automatic model selection from functioning correctly. 2018-01-31 23:58:17 +02:00
Lior Halphon 95234036bb Added return value to GB_run API. 2018-01-31 15:18:04 +02:00
Lior Halphon bc55531204 Added automatic model selection for the libretro port. 2018-01-27 21:46:13 +02:00
Lior Halphon 2bda598ac6 Merge commit 'ab49034205261e8e50708d097ec22151f153a801' 2018-01-27 02:16:55 +02:00
radius ab49034205 update Bootroms 2018-01-26 19:08:31 -05:00
radius b047c7a9e1 readd bootroms 2018-01-26 19:01:20 -05:00
radius 6d868c8f7c update to master 2018-01-26 18:51:39 -05:00
Lior Halphon cc73796897
Merge pull request #26 from ConnorRigby/sdl/fix-load-from-cmdline
Fix loading game from command line.
2018-01-23 00:02:40 +02:00
connor rigby ce31de47cb Fix loading game from command line. 2018-01-22 12:25:27 -08:00
Twinaphex 935b2f6114
Merge pull request #8 from lubosz/switch
Makefile: Add Switch target.
2018-01-22 17:52:24 +01:00
Lubosz Sarnecki 59fe551f26 Makefile: Add Switch target. 2018-01-22 16:58:06 +01:00
Lior Halphon af143b0420 Added model selection to libretro, including GBA. Closes #23. 2018-01-20 00:06:33 +02:00
Lior Halphon 09dd47c6de Fixed unintentional delay in NR50 and NR51’s effects 2018-01-19 19:56:39 +02:00
Lior Halphon 37906bcd1f Fixed sound pops in Super Mario Land 2. 2018-01-19 00:47:46 +02:00
Lior Halphon 130c7c28c2 Re-do the way the libretro port does audio. Audio is now sent to libretro at 384KHz, which is then resampled to whatever rate the user configured. 2018-01-15 22:23:20 +02:00
Lior Halphon 5c16d0e656 Added model selection GUI in the SDL port. Closes #24 2018-01-13 13:49:20 +02:00
Lior Halphon 69a712b07f Added AGB as a model option in Cocoa 2018-01-13 13:31:06 +02:00
Lior Halphon 2cd5c49935 Made CGB boot more accurate, added AGB boot 2018-01-13 13:02:31 +02:00
Lior Halphon 59d4cb4bc2 Make menu key more obvious on the SDL port 2018-01-13 13:02:07 +02:00
radius 82e2df7a2a keep using prebuild roms for libretro 2018-01-07 20:02:36 -05:00
radius bebb94738c Merge remote-tracking branch 'upstream/master' 2018-01-07 19:54:22 -05:00
Lior Halphon a2a1148354 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2018-01-06 12:38:05 +02:00
Lior Halphon 0a76881eb6 Correctly emulating NRx4 effects on the sound envelop of the previously playing sound. Closes #19 2018-01-06 12:37:45 +02:00
Lior Halphon a20e8a8220 Fixed bug in NR42 write that also caused memory corruption 2018-01-06 12:17:06 +02:00
Lior Halphon a1af4c59ca Fixed NR51 volume levels (They’re 1-8, not 0-7) 2018-01-06 11:58:49 +02:00
Twinaphex afbd62c665
Merge pull request #5 from retro-wertz/pitch
Fix pitch issue
2018-01-04 11:38:20 +01:00
Twinaphex 968399a409
Merge pull request #6 from retro-wertz/libretro_api
Access system and video ram using Librero API
2018-01-04 11:38:11 +01:00
Twinaphex 8bbfab3183
Merge pull request #7 from retro-wertz/makefile
Fix target location when compiling
2018-01-04 11:37:55 +01:00
retrowertz acac96310b Fix target location when compiling 2018-01-04 16:46:57 +08:00
retrowertz c578b36dfb Access system and video ram using Librero API 2018-01-04 16:43:31 +08:00
retrowertz c0cf5646da Fix pitch issue
This issue affects when running in vulkan driver
2018-01-04 16:24:37 +08:00
Lior Halphon 60862a35c8
Merge pull request #22 from Nadia-h/patch-1
libretro: Fix video being broken with Vulkan
2018-01-02 10:42:58 +02:00
Nadia Pedersen e4fbece88f
libretro: Fix video being broken with Vulkan
This corrects the pitch parameter for the video refresh callback to be the actual pitch instead of 0.

Setting it to 0 seems to work fine for OpenGL, but it causes the graphics to be broken with Vulkan, at least with an AMD card on Linux.
2018-01-02 07:41:02 +01:00
Lior Halphon d62ff4eb75 Fixed timing issues with the DMG boot ROM. Closes #20. 2017-12-31 23:02:28 +02:00
Andrés f905c4d0f6
Merge pull request #4 from hizzlekizzle/master
update to upstream v0.10
2017-12-30 16:08:10 -05:00
hunterk 1272405f16 update to upstream v0.10 2017-12-30 14:33:52 -06:00
Lior Halphon 42bf575a0e Updated version to 0.10 2017-12-30 17:58:17 +02:00
Lior Halphon 2205493862 Bug fixes in the SDL port 2017-12-30 17:07:05 +02:00
Lior Halphon a4465b72e7 Clean up unneeded joystick code, joystick is now internally driven by callbacks (instead of polling) 2017-12-30 17:00:07 +02:00
Lior Halphon 8eeda02d50 Added Joypad support, closes #9 2017-12-30 16:23:17 +02:00
Lior Halphon d6236b87dd Fixed a crash in the OAM tab 2017-12-29 13:42:32 +02:00
Lior Halphon 595bb563f9 OmniScale is no longer beta 2017-12-29 13:35:03 +02:00
Lior Halphon e8f0615635
Update README.md 2017-12-29 13:32:12 +02:00
Lior Halphon fc15b5c9f9 Remove hardcoded version from libretro.c, use version from the Makefile 2017-12-29 13:26:11 +02:00
Lior Halphon 0891de668b Merge commit '1d96a10acb661e07775de954338f4bb3724705a3' into libretro_core
# Conflicts:
#	libretro/libretro.c
2017-12-29 13:18:52 +02:00
Lior Halphon d3a2e49d38 Merge branch 'sdl_gui' into libretro_core
# Conflicts:
#	Makefile
#	SDL/main.c
2017-12-29 13:12:12 +02:00
Lior Halphon 600f0eadd9 Better Windows and Linux compatibility 2017-12-29 13:06:38 +02:00
Lior Halphon 3d8e22ed50 Use SDL’s OpenGL headers 2017-12-29 11:35:09 +02:00
Lior Halphon b1edf540d8 Handle failures to create an OpenGL context better 2017-12-29 00:43:19 +02:00
Lior Halphon ca92c51f51 Save user configuration 2017-12-28 21:46:59 +02:00
Lior Halphon effc02ce8e Use SDL_GetBasePath for better portability 2017-12-28 20:29:15 +02:00
Lior Halphon 61f9dbd95d Use SDL’s key mapping when available 2017-12-28 20:22:54 +02:00
Lior Halphon c559a308ad Slightly improved background 2017-12-27 23:20:06 +02:00
Lior Halphon dc59fdf40e Highpass filter in SDL 2017-12-23 22:11:53 +02:00
Lior Halphon 3c1a805770 Frame blending 2017-12-23 22:11:53 +02:00
Lior Halphon d262dde71a Scaling filters in SDL 2017-12-23 22:11:53 +02:00
Lior Halphon c03ccba8db Basic Joypad support 2017-12-23 22:11:43 +02:00
Lior Halphon 3f9d62ceee Merge branch 'master' into sdl_gui 2017-12-22 22:26:16 +02:00
Lior Halphon f48194f480 Added configurable controls 2017-12-22 22:25:53 +02:00
Lior Halphon f0e772ca97 Fixed: Loading states in DMG mode results in a black screen 2017-12-22 21:58:31 +02:00
Twinaphex 1d96a10acb
Merge pull request #2 from orbea/cxxflags
libretro: Change CXXFLAGS to CFLAGS.
2017-12-22 08:02:36 +01:00
Twinaphex 2a69081e53
Merge pull request #3 from orbea/git_version
libretro: Add GIT_VERSION
2017-12-22 06:25:57 +01:00
orbea 536e47c567 libretro: Add GIT_VERSION 2017-12-21 21:16:55 -08:00
orbea 2184fd0902 libretro: Change CXXFLAGS to CFLAGS.
This core does not use CXXFLAGS...
2017-12-21 21:03:41 -08:00
radius be3385a8c1 Update to upstream/master 2017-12-09 21:07:11 -05:00
Lior Halphon 19c382c9e0 Fixed ei_sequence test 2017-12-03 21:07:34 +02:00
Tim Allen 40524fef8a Update to v105r1 release.
byuu says:

Changelog:

  - higan: readded support for soft-reset to Famicom, Super Famicom,
    Mega Drive cores (work in progress)
      - handhelds lack soft reset obviously
      - the PC Engine also lacks a physical reset button
      - the Master System's reset button acts like a gamepad button, so
        can't show up in the menu
  - Mega Drive: power cycle wasn't initializing CPU (M68K) or APU (Z80)
    RAM
  - Super Famicom: fix SPC700 opcode 0x3b regression; fixes Majuu Ou
    [Jonas Quinn]
  - Super Famicom: fix SharpRTC save regression; fixes Dai Kaijuu
    Monogatari II's real-time clock [Talarubi]
  - Super Famicom: fix EpsonRTC save regression; fixes Tengai Makyou
    Zero's real-time clock [Talarubi]
  - Super Famicom: removed `*::init()` functions, as they were never used
  - Super Famicom: removed all but two `*::load()` functions, as they
    were not used
  - higan: added option to auto-save backup RAM every five seconds
    (enabled by default)
      - this is in case the emulator crashes, or there's a power outage;
        turn it off under advanced settings if you want
  - libco: updated license from public domain to ISC, for consistency
    with nall, ruby, hiro
  - nall: Linux compiler defaults to g++; override with g++-version if
    g++ is <= 4.8
      - FreeBSD compiler default is going to remain g++49 until my dev
        box OS ships with g++ >= 4.9

Errata: I have weird RAM initialization constants, thanks to hex_usr
and onethirdxcubed for both finding this:
http://wiki.nesdev.com/w/index.php?title=CPU_power_up_state&diff=11711&oldid=11184

I'll remove this in the next WIP.
2017-11-07 09:05:54 +11:00
Talarubi 57826a7ef1 Update version and license
Added LICENSE.txt and GPLv3.txt. Also updated libco documentation.

After discussion with byuu, libco gets a more specific ISC license
to match nall, ruby and hiro. higan, as clarified in LICENSE.txt,
continues to be GPL version 3 only (no "or later" clause).
2017-10-24 23:37:22 -04:00
Brad Parker 8c9ff67b21 add travis build script 2017-10-24 13:32:22 -04:00
radius 212947d83c really strong rumble 2017-10-17 23:42:55 +03:00
radius f1bcddf421 hookup reset and unload 2017-10-17 23:42:55 +03:00
radius 32e4d705c6 check_variables later 2017-10-17 23:42:55 +03:00
leiradel a8dbae00c2 Added cheevos support 2017-10-17 23:42:54 +03:00
radius 85971e9158 hookup color filter & highpass filter 2017-10-17 23:42:54 +03:00
Lior Halphon 4b69331321 Merge branch 'master' into libretro_core 2017-10-16 20:49:33 +03:00
Lior Halphon e71154b7e0 Fixed set_color_correction breaking DMG’s palette 2017-10-16 20:48:39 +03:00
radius 55412d7093 don't apply color correction for DMG 2017-10-15 22:08:13 -05:00
radius f724cbbacd really strong rumble 2017-10-15 18:46:37 -05:00
radius 9f8d871c9c hookup reset and unload 2017-10-15 18:08:31 -05:00
radius d57d4dbe24 check_variables later 2017-10-15 15:48:56 -05:00
leiradel d8e460ca47 Added cheevos support 2017-10-15 12:47:33 -05:00
radius 7313473fd2 use prebuilt bootroms 2017-10-15 12:47:33 -05:00
radius a42fed5d53 hookup color filter & highpass filter 2017-10-15 12:47:33 -05:00
radius 930ee8145c move the target to TLD for our fork 2017-10-15 12:47:33 -05:00
Lior Halphon 42712a0280 Refined dep-generation condition 2017-10-15 20:26:49 +03:00
Lior Halphon 8e61098fec Use scan codes instead of key symbols 2017-10-14 20:24:13 +03:00
Lior Halphon 47d5b485d4 Better controls and visuals for settings 2017-10-14 17:08:52 +03:00
Lior Halphon 2dfe22e834 Added graphics options menu, fixed issues with exiting not saving battery in some cases 2017-10-14 14:10:26 +03:00
Lior Halphon c66e9a06cf Added basic menu 2017-10-14 01:41:51 +03:00
Lior Halphon 7a024d2a69 Merge branch 'master' into sdl_gui 2017-10-14 00:25:02 +03:00
Lior Halphon c7e82b4a47 Use hexdump instead of xxd (more portable) 2017-10-13 18:13:26 +03:00
Lior Halphon 6c97bb9052 Accidentally reversed ifdef condition 2017-10-13 17:28:32 +03:00
Lior Halphon 57f50edaa2 Use $(MAKE) instead of make 2017-10-13 00:14:32 +03:00
Lior Halphon bbd3b7e550 Got rid of -ICore 2017-10-13 00:02:02 +03:00
Lior Halphon 27b5718b07 Merge branch 'master' into libretro_core 2017-10-12 22:50:02 +03:00
Lior Halphon a753e00b59 Added direct_access interface to interrupt_enable/IE register 2017-10-12 22:49:39 +03:00
Lior Halphon a5f66c8b8b Updated readme 2017-10-12 22:46:35 +03:00
Lior Halphon a498b19bfd Moved libretro’s Makefile to libretro’s folder 2017-10-12 22:40:48 +03:00
Lior Halphon 49095ebc5e Moved libretro’s target to the build folder 2017-10-12 22:27:08 +03:00
Lior Halphon 40e4f93637 Replaced libretro specific code with a generic API 2017-10-12 22:06:01 +03:00
Lior Halphon 6b71d1d477 “Baked” boot ROM is now auto-generated. 2017-10-12 21:52:51 +03:00
Lior Halphon 441781cbe9 Libretro .o files are now in the build/obj folder and are suffixed with _libretro (since they have different compilation flags). This also lets us rename gbmemory.c/h back to its original name. 2017-10-12 19:42:30 +03:00
Lior Halphon 7c0ad24175 Added compilation flag to disable timekeeping for frontends that handle fps keeping on their own 2017-10-12 19:24:12 +03:00
Lior Halphon a50aa2486b Removed input callbacks when no debugger is included 2017-10-12 19:16:33 +03:00
Lior Halphon dcadfc37f4 Changed the way HAVE_DEBUGGER works and renamed it (so it’s on by default) to DISABLE_DEBUGGER. Fixes build break. 2017-10-12 19:05:27 +03:00
Lior Halphon 9615ca6fa6 Merge pull request #14 from libretro/master
libretro core
2017-10-12 18:29:26 +03:00
Lior Halphon 65dd02cc52 Added 3 color correction profiles, added color correction setting to Cocoa GUI, improved cross-platform and cross-frontend save-state compatibility 2017-10-12 17:22:22 +03:00
radius 6f40885f73 this seems to improve audio a lot but I still hear some small crackles 2017-10-10 20:29:46 -05:00
radius 8d691563c7 include unistd 2017-10-09 19:53:07 -05:00
radius 18b376ac5f Updates:
-fix input descriptors
-implement savestates
-implement sram interface
2017-10-09 14:21:32 -05:00
Yoshi Sugawara dd30b63426 support for iOS arm64 build 2017-10-09 11:36:56 -05:00
twinaphex 1eb1113a24 Update Makefile 2017-10-09 11:36:56 -05:00
ggf906 a009616726 (VITA) Fix compilation 2017-10-09 11:36:55 -05:00
twinaphex a7db98c22e Memory needs to be uniquely named for Android 2017-10-09 11:36:55 -05:00
twinaphex b02aeab022 We don't need stdin 2017-10-09 11:36:54 -05:00
twinaphex 5e3a24573e Bump up version 2017-10-09 11:36:54 -05:00
twinaphex 091df682cd Silence warning 2017-10-09 11:36:54 -05:00
twinaphex 09f4edda57 Comment out debugger code - add HAVE_DEBUGGER ifdef 2017-10-09 11:36:53 -05:00
twinaphex aeea20ae9d Comment out nsleep 2017-10-09 11:36:53 -05:00
twinaphex 9f5b746e0b Fix compiler error 2017-10-09 11:36:53 -05:00
twinaphex 63b17e14af Update 2017-10-09 11:36:24 -05:00
twinaphex fedea2cad7 Don't hook up regular audio_cb 2017-10-09 11:36:24 -05:00
radius 7d2dbe2988 no need for turbo mode in libretro 2017-10-09 11:36:24 -05:00
radius 765a072c73 this fixes fast forwarding but probably has to change to a proper fix 2017-10-09 11:36:24 -05:00
radius 3dffa3a0ca fix gbc 2017-10-09 11:36:23 -05:00
radius 65e6e5f30b use GB_run_frame 2017-10-09 11:36:23 -05:00
twinaphex 33a9c54842 Correct memset lines 2017-10-09 11:36:23 -05:00
twinaphex d433cdf260 Add baked-in generated BIOS files 2017-10-09 11:36:23 -05:00
Not6 3f86d898a3 some others input 2017-10-09 11:36:23 -05:00
Not6 009a66d723 basic libretro port 2017-10-09 11:36:23 -05:00
Lior Halphon 947c62bea9 Oops 2017-10-04 13:14:37 +03:00
Lior Halphon d171a0ccee Updating the DMG palette to match the new SDL GUI 2017-10-04 12:43:46 +03:00
Lior Halphon 9cc8b3320a Starting to add a GUI to the SDL port 2017-10-04 12:43:31 +03:00
Lior Halphon c1f27d7b27 Spacing 2017-10-02 22:59:03 +03:00
Lior Halphon d9b0576351 Emulation of NRX2-write glitches. Fixes Prehistorik Man audio. 2017-10-02 22:56:24 +03:00
Lior Halphon 78446f0ed4 Fixed several memory leaks (mostly in Cocoa port debugging utils) 2017-09-27 22:09:26 +03:00
Lior Halphon 7a41a9b417 Refined OAM interrupt timing. Fixes Pinball Deluxe in DMG mode; closes #1. 2017-09-23 21:08:05 +03:00
Lior Halphon 1804a5c8e6 Updated save struct version 2017-09-23 00:25:21 +03:00
Lior Halphon 67f1566b5e Minor refinement to sweep 2017-09-23 00:23:02 +03:00
Lior Halphon e0a6edac35 Setting sweep period to 0 cancels pending calculate event 2017-09-22 14:53:24 +03:00
Lior Halphon 2ffce49e16 Minor bugfixes related to sweeping 2017-09-22 14:39:39 +03:00
Lior Halphon 75db33559a Current sample index (Channel 1 and 2) is only reset after turning the APU off 2017-09-22 02:25:06 +03:00
Lior Halphon 8f4cd5c412 Corrected behavior for channel 1 and 2 restart 2017-09-22 02:04:29 +03:00
Lior Halphon 882b141478 Fixed dmg_sound-1 2017-09-21 18:32:21 +03:00
Lior Halphon 2ca550273a Fixed dmg_sound-5 2017-09-21 18:18:10 +03:00
Lior Halphon d3c15ef6ca Fixing APU bugs, one at a time: Blargg’s dmg_sound 8.2 2017-09-21 14:52:09 +03:00
Lior Halphon 02ac609f3c Merge branch 'master' into new_apu 2017-09-20 16:16:05 +03:00
Lior Halphon be038dc8e7 Refinement to the last fix 2017-09-20 03:08:54 +03:00
Lior Halphon 57e7782ac4 Interrupt servicing is now more accurate. Fixes mooneye-gb’s ie_push (all models) and Pinball Deluxe (!!!) for CGB mode 2017-09-20 02:49:45 +03:00
Lior Halphon 09b7e2fff4 Fixed a bug in scx_delay’s calculation 2017-09-11 23:56:35 +03:00
Lior Halphon b9bdd6c49c Merge branch 'master' into new_apu 2017-09-10 02:33:40 +03:00
Lior Halphon 14f267b4fa Another whoops 2017-09-09 19:31:05 +03:00
Lior Halphon 02841ddde6 Whoops 2017-09-09 16:55:55 +03:00
Lior Halphon 026baddbab Implemented delayed/future interrupts for DMG hblank interrupt. Restores vblank_stat_intr-GS support. 2017-09-09 13:45:01 +03:00
Lior Halphon 1e90400916 Reimplemented delayed/future interrupts, currently correct only for CGB. 2017-09-09 13:32:12 +03:00
Lior Halphon 742c9e95d3 Updated previous timing improvements to correctly implement double speed behavior 2017-09-08 23:46:38 +03:00
Lior Halphon e5d354e896 Refined SCX’s effects on PPU timing 2017-09-08 23:02:24 +03:00
Lior Halphon 0f1fa3176f Refinements to LCD timing (breaks vblank_stat_intr-GS for now) 2017-09-08 12:59:57 +03:00
Lior Halphon 0f643e01b7 Removing the delayed interrupt mechanism, research is not complete enough for implementation 2017-09-08 12:58:35 +03:00
Lior Halphon ba0e66a5b7 Merge branch 'master' into new_apu 2017-09-04 18:41:13 +03:00
Lior Halphon 72d26c7046 Fixed obscure timer behavior, fixed regression in rapid_toggle.gb. 2017-09-04 18:40:43 +03:00
Lior Halphon 9bde98dede SCY latching is now correctly emulated, rendering mode timing refined. 2017-09-04 15:45:18 +03:00
Lior Halphon a1a13c61bf On CGB, the VBlank and STAT interrupts are “delayed” by one T-cycle (relative to IF) since they’re not aligned to a T-Cycle 2017-09-03 00:41:52 +03:00
Lior Halphon 0532d2a159 A test ROM I wrote seems to contradicts some of AntonioND’s findings regrading PPU timing in CGB mode. CGB mode now behaves like DMG mode until I figure out what caused the difference. 2017-09-02 23:51:02 +03:00
Lior Halphon 9b490396bb Fixed timing when turning the LCD display on during double speed mode 2017-09-02 23:26:45 +03:00
Lior Halphon 54eb51d8db Refined timer interrupt timing 2017-09-02 22:08:20 +03:00
Lior Halphon e7d5cdbb42 Merge branch 'master' into new_apu 2017-08-20 01:37:33 +03:00
Lior Halphon cbbaf2ee84 Refined Window behavior once more, Fixes #12 (While not breaking Donkey Kong or 007) 2017-08-20 01:34:12 +03:00
Lior Halphon 62878fdc7a More accurate div-event handling 2017-08-15 22:27:15 +03:00
Lior Halphon 8d011ca4b9 Accuracy improvements (Sweep) 2017-08-15 22:05:20 +03:00
Lior Halphon 5d84ee250e Added Cocoa GUI for the High-Pass filter selection 2017-08-15 21:59:53 +03:00
Lior Halphon d04aaddcbd Added highpass filter 2017-08-15 21:59:11 +03:00
Lior Halphon ca59aca4a6 Fixed a bug where writing to NR52 affected channels 1 and 2’s duty pattern in DMG mode. Fixed NR43 being written to NR44 as well. 2017-08-13 20:26:35 +03:00
Lior Halphon 36943866e2 Better click prevention 2017-08-12 23:35:18 +03:00
Lior Halphon d43daed6a6 Merge branch 'master' into new_apu 2017-08-12 21:43:09 +03:00
Lior Halphon 7df4e56454 KEY1 is only writable in CGB mode; screen should be black is LCD is on while in stop mode. 2017-08-12 21:42:47 +03:00
Lior Halphon dba7370d6d Turns out APU signal is inverted. This fixes Perfect Dark’s audio. 2017-08-12 20:47:55 +03:00
Lior Halphon 688991f57f The volume envelopes and length controls are handled in different phases of the div-divider 2017-08-12 20:17:20 +03:00
Lior Halphon 4b8be255ce Fixed some channel 4 delays, documented a not currently emulated timing quirk. 2017-08-12 19:50:39 +03:00
Lior Halphon 066efab985 In DMG mode, the length registers are not affected by turning the APU on and off. Why? Why not! 2017-08-11 22:23:03 +03:00
Lior Halphon 0e22ad8eb1 Noise channel support 2017-08-11 17:57:08 +03:00
Lior Halphon 1a8bcd314d Accuracy improvements to sweeping (Still not complete though, more research needed) 2017-08-10 19:42:23 +03:00
Lior Halphon ab5611119a Accuracy improvements, especially to the length control 2017-08-02 21:14:23 +03:00
Lior Halphon d65c2247e5 Added channel 1 and 2, fixed accuracy issues with channel 3 2017-07-27 23:11:33 +03:00
Tim Allen 0382100a97 Update to v103r21 release.
byuu says:

Changelog:

  - gb: added TAMA emulation [thanks to endrift for the initial notes]
  - gb: save RTC memory to disk (MBC3 doesn't write to said memory yet;
    TAMA doesn't emulate it yet)
  - gb: expect MMM01 boot loader to be at end of ROM instead of start
  - gb: store MBC2 save RAM as 256-bytes (512x4-bit) instead of
    512-bytes (with padding)
  - gb: major cleanups to every cartridge mapper; moved to Mapper class
    instead of MMIO class
  - gb: don't serialize all mapper states with every save state; only
    serialize the active mapper
  - gb: serialize RAM even if a battery isn't present¹
  - gb/cartridge: removed unnecessary code; refactored other code to
    eliminate duplication of functions
  - icarus: improve GB(C) heuristics generation to not include filenames
    for cartridges without battery backup
  - icarus: remove incorrect rearrangement of MMM01 ROM data
  - md/vdp: fix CRAM reads -- fixes Sonic Spinball colors [hex\_usr]
  - tomoko: hide the main higan window when entering fullscreen
    exclusive mode; helps with multi-monitor setups
  - tomoko: destroy ruby drivers before calling Application::quit()
    [Screwtape]
  - libco: add settings.h and defines to fiber, ucontext [Screwtape]

¹: this is one of those crystal clear indications that nobody's
actually playing the higan DMG/CGB cores, or at least not with save
states. This was a major mistake.

Note: I can't find any official documentation that `GL_ALPHA_TEST` was
removed from OpenGL 3.2. Since it's not hurting anything except showing
some warnings in debug mode, I'm just going to leave it there for now.
2017-07-26 22:42:06 +10:00
Tim Allen 9a271f5452 Update to v103r20 release.
byuu says:

Changelog:

  - ruby/audio/xaudio2: ported to new ruby API
  - ruby/video/cgl: ported to new ruby API (untested, won't compile)
  - ruby/video/directdraw: ported to new ruby API
  - ruby/video/gdi: ported to new ruby API
  - ruby/video/glx: ported to new ruby API
  - ruby/video/wgl: ported to new ruby API
  - ruby/video/opengl: code cleanups

The macOS CGL driver is sure to have compilation errors. If someone will
post the compilation error log, I can hopefully fix it in one or two
iterations of WIPs.

I am unable to test the Xorg GLX driver, because my FreeBSD desktop
video card drivers do not support OpenGL 3.2. If the driver doesn't
work, I'm going to need help tracking down what broke from the older
releases.

The real fun is still yet to come ... all the Linux-only drivers, where
I don't have a single Linux machine to test with.

Todo:

  - libco/fiber
  - libco/ucontext (I should really just delete this)
  - tomoko: hide main UI window when in exclusive fullscreen mode
2017-07-24 15:23:40 +10:00
Tim Allen 91104e6ab6 Update to v103r19 release.
byuu says:

Changelog:

  - tomoko: Application::onMain assigned at end of Program::Program()
    [Screwtape]¹
  - libco: add `#define _XOPEN_SOURCE 500` to fix compilation of sjlj.c
    [Screwtape]
  - ruby/audio/openal: fixed device driver string list enumeration
  - ruby/audio/wasapi: changing device re-initializes the driver now
  - ruby/audio/wasapi: probably a pointless change, but don't fill the
    buffer beyond the queue size with silence
  - ruby/video/xvideo: renamed from ruby/video/xv
  - ruby/video/xvideo: check to see if `XV_AUTOPAINT_COLORKEY` exists
    before setting it [SuperMikeMan]
  - ruby/video/xvideo: align buffer sizes to be evenly divisible by four
    [SuperMikeMan]
  - ruby/video/xvideo: fail nicely without crashing (hopefully)
  - ruby/video/xvideo: add support for YV12 and I420 12-bit planar YUV
    formats²

¹: prevents crashes when drivers fail to initialize from running the
main loop that polls input drivers before the input driver is
initialized (or fails to initialize itself.) Some drivers still don't
block their main functions when initialization fails, so they will still
crash, but I'll work to fix them.

²: this was a **major** pain in the ass, heh. You only get one chroma
sample for every four luma samples, so the color reproduction is even
worse than UYVY and YUYV (which is two to four chroma to luma.) Further,
the planar format took forever to figure out. Apparently it doesn't care
what portion of the image you specify in XvShmPutImage, it expects you
to use the buffer dimensions to locate the U and V portions of the data.

This is probably the most thorough X-Video driver in existence now.

Notes:

  - forgot to rename the configuration settings dialog window title to
    just "Settings"
2017-07-23 19:18:16 +10:00
Lior Halphon 2936f7fa57 Fixed channel 3 counter behavior, verified with new tests. The DIV register ticks the APU at 512Hz. 2017-07-22 19:51:11 +03:00
Lior Halphon a19ee1e5e0 2MHz audio downscaling support. Implemented NR50 and NR51. 2017-07-21 23:17:48 +03:00
Lior Halphon baccf336d7 Complete rewrite of the APU. Channel 3 is complete and passes all the relevant tests from blargg’s suite, as well as PCM34-based tests. Actual sound output is basic and limited, though. 2017-07-21 19:06:55 +03:00
Lior Halphon c0a8a570e8 Merge pull request #11 from nattthebear/master
Fix compilation in GCC 4.6.4
2017-07-17 12:22:52 +03:00
nattthebear eb7492c6c6 Fix undefined behavior (sequence point modification). GCC 4.6.4 compiles the code incorrectly without this fix. 2017-07-16 21:08:07 -04:00
Lior Halphon efc11783c7 Updated SameBoy’s “score” on mooneye-gb’s tests 2017-06-23 18:04:51 +03:00
Lior Halphon c4ccbd5cce Improved serial interrupt timing, fixes boot_sclk_align. 2017-06-23 17:58:04 +03:00
Lior Halphon 623f92378d Added --boot option to the automatic tester to specify the boot ROM, better support for automatic testing of the mooneye-GB tests 2017-06-21 23:25:39 +03:00
Lior Halphon c59272d46d Misc minor fixes, fixes several Mooneye-GB tests 2017-06-21 20:39:23 +03:00
Lior Halphon efbc385417 Forgot to amend the last commit, it was broken. 2017-06-21 01:07:11 +03:00
Lior Halphon aefca34b39 Improved MBC1 emulation. Fixed incorrect error messages. 2017-06-19 19:46:09 +03:00
Lior Halphon abf7efcc5a Fixed lcdon_write_timing. 2017-06-18 21:27:07 +03:00
Lior Halphon 86c9f9d89d Updated SameBoy to pass Mooneye-GB’s lcdon_timing test (on a DMG), as well as refined related CBG behaviors. 2017-06-17 22:17:58 +03:00
Lior Halphon bbd2ca8ddf Fixed Linux compilation 2017-06-16 01:25:39 +03:00
Lior Halphon babcc0a7dc Added API to load/save states from RAM 2017-06-14 00:23:34 +03:00
Lior Halphon 204e22657b The CGB boot ROM will now not finish if the user is still selecting palettes 2017-06-09 19:52:40 +03:00
Lior Halphon 144d0348dd Loading a save state creating during the effect of the previous MBC RAM bug will now attempt to fix the (broken) save state. 2017-06-08 23:26:04 +03:00
Lior Halphon c650337928 Fixed a bug where MBC RAM was no longer accessible after using the GB_reset functions 2017-06-08 22:48:23 +03:00
Lior Halphon a9475fbdf4 Refined the behavior of the last fix on a DMG. 2017-06-03 20:06:52 +03:00
Lior Halphon 65b0dcb2c5 Fixed a bug where SameBoy freeze for a moment after leaving turbo mode 2017-06-03 17:02:12 +03:00
Lior Halphon d72807dd67 Implemented LCD first-frame-skip behavior, fixes a visual glitch in Pokémon Pinball 2017-06-03 16:42:42 +03:00
Lior Halphon 48acc09e91 Fixed the first item in the backtrace command 2017-06-03 16:19:39 +03:00
Lior Halphon 22ee6f6ca2 Fixed incorrect calculation in rendering timing. Fixes some of the issues in Prehistorik Man (and doesn’t break GBVideoPlayer) 2017-05-31 23:58:14 +03:00
Lior Halphon 81de2c3d9b Incremented version to 0.9, updated copyright 2017-05-27 19:41:09 +03:00
Lior Halphon 1e228e1d9b Fixed a bug where the SDL port exited on “warning” logs when loading ROMs 2017-05-27 19:16:07 +03:00
Lior Halphon 9b89d76b3b Todo cleanup 2017-05-27 17:30:12 +03:00
Lior Halphon f34103473e Fixed ^C not giving focus to the console window 2017-05-27 17:16:20 +03:00
Lior Halphon a69f0a64b1 Added reverse text search to the Cocoa console 2017-05-27 17:15:52 +03:00
Lior Halphon 6b2a302393 Terminal-style command history in the Cocoa debugger 2017-05-27 14:32:32 +03:00
Lior Halphon 44b414d45f Fixed VRAM window not showing correctly if opened while the game is paused 2017-05-27 12:52:31 +03:00
Lior Halphon da852119de Updated readme to SDL2 2017-05-27 12:47:25 +03:00
Lior Halphon 096bd8ba94 Merge branch 'sdl2' 2017-05-27 12:30:25 +03:00
Lior Halphon 6e7ab3558a Use a smaller audio buffer size if supported. 2017-05-27 12:29:36 +03:00
Lior Halphon a01ea29cf1 The first entry in the backtrace command is now in the same format as the rest 2017-05-26 20:21:39 +03:00
Lior Halphon 7d88ee00cc Added side view to Cocoa debugger 2017-05-26 20:16:19 +03:00
Lior Halphon ece1a11a23 SDL port: GUI-based error reporting, added help dialog (? on macOS, F1 on everything else) 2017-05-25 23:28:48 +03:00
Lior Halphon 4d5dc6a30e Cleanup 2017-05-24 21:44:43 +03:00
Lior Halphon 52e99adc32 SDL port: Resizing, resizing modes, and pause support 2017-05-24 20:33:39 +03:00
Lior Halphon 00439f4d49 SDL port: added drag and drop support, added model switch command, fixed macOS audio 2017-05-23 23:18:16 +03:00
Lior Halphon bef89c6604 Upgraded Sameboy-SDL to SDL2, fixed Windows build, fixed save states in SDL, added reset and mute to SDL. The SDL port now renders via OpenGL. 2017-05-21 21:45:19 +03:00
Lior Halphon 50a21da4d5 False positive fixes 2017-05-13 22:55:59 +03:00
Lior Halphon 6dd24e0733 Fixed hung note issue. Closes #7 2017-05-13 17:04:05 +03:00
Lior Halphon 86332d0311 Modifying WX and WY outside of VBlank is now more accurate, but still requires more research. Closes #6. 2017-05-12 19:33:42 +03:00
Lior Halphon 00623d4eea - Added audio supersampling support to greatly improve audio quality.
- Fixed a bug where low sampling rate or disabled sound resulted in wrong APU behavior.
- Added API to get the current number of pending samples.
- This change broke save state compatibility with v0.8 and older
Closes #8.
2017-05-12 17:11:55 +03:00
Lior Halphon b858f17425 Added the GB_run_frame API; closes #5. 2017-04-25 00:19:10 +03:00
Lior Halphon 22d3510dde Added LCD command to the debugger 2017-04-22 14:55:17 +03:00
Lior Halphon c766704267 More accurate FPS capping that tracks time correctly even when the screen is off. Should also support restarting the LCD during blank to increase FPS to 63. 2017-04-21 16:00:53 +03:00
Lior Halphon fb55c35f87 New APIs, Document.m no longer requires GB_INTERNAL, fixed a bug where the sprite viewer showed incorrect sprites for some CGB exclusive games. 2017-04-19 23:26:39 +03:00
Lior Halphon 3feaeb153e New turbo related APIs, Quick Look no longer requires GB_INTERNAL 2017-04-19 21:55:58 +03:00
Lior Halphon a925ef130d Stabilizing API: New joypad, debugger and reset APIs; internal APIs and direct struct access are no longer available without defining GB_INTERNAL. The SDL port uses the new “public” APIs, as well as most of the non-debug Cocoa code. 2017-04-17 20:16:17 +03:00
Lior Halphon 0b1e2784cd Fixed saves and save states not working correctly on Windows 2017-03-24 14:39:39 +03:00
Lior Halphon 4bf391b1c8 SCX now effects Mode 3’s length. Fixes hblank_ly_scx_timing-GS 2017-02-25 23:30:31 +02:00
Lior Halphon 55e54d9499 Refinements to DMG STAT write interrupt bug. Fixes stat_irq_blocking on DMG. 2017-02-25 21:56:46 +02:00
Lior Halphon 2c1d2571d3 More false positive fixes 2017-02-25 16:06:38 +02:00
Lior Halphon dbd04f09e8 HBlank HDMA should start instantly when starting during HBlank. Fixes 3-D Ultra Pinball. 2017-02-25 15:42:59 +02:00
Lior Halphon 9fbcce689c False positive stack overflow detection 2017-02-24 23:00:10 +02:00
Lior Halphon ce05b5f7f0 Added the faster but unportable native_release configuration 2017-02-24 18:35:31 +02:00
Lior Halphon 371b575d2e Added information to stack overflow detection in the automatic tester 2017-02-24 18:25:27 +02:00
Lior Halphon c116c70bfa Better GUI for user errors/warnings in Cocoa 2017-02-24 18:15:31 +02:00
Lior Halphon 724153e5ef Minimal attempt to be compatible with ROMs without correct headers 2017-02-24 15:14:47 +02:00
Lior Halphon 3d99773ddb Changed how the Cocoa port initializes GB_gameboy_t 2017-02-24 15:14:00 +02:00
Lior Halphon 39253bec80 Yet-another-false-positive automation fix 2017-02-24 01:19:44 +02:00
Lior Halphon 319857db89 Fixed window behavior 2017-02-24 00:59:07 +02:00
Lior Halphon a420cfd798 HUC1’s RAM Enable only controls writing 2017-02-23 00:27:08 +02:00
Lior Halphon c5ce14dad1 Prevent Hblank HDMAs when the LCD is off 2017-02-21 22:33:09 +02:00
Lior Halphon f4a364c3db It seems like STAT’s LYC flag should be on while the screen is off. 2017-02-21 21:31:52 +02:00
Lior Halphon fed3b4f9cd Symbolicate LDH instructions 2017-02-21 21:31:22 +02:00
Lior Halphon aca7687edd Fixed a bug where LYC would be compared to the wrong value in the first cycle of a frame 2017-02-20 22:52:34 +02:00
Lior Halphon b0dfb8c5ac Added built-in IO-Register symbols 2017-02-20 14:37:15 +02:00
Lior Halphon 91513ced22 Minor adjustment to LCD timing after enabling it. 2017-02-20 14:20:45 +02:00
Lior Halphon 399e88d5fe STAT timing and LCD interrupts rewritten, should be more accurate. 2017-02-19 02:22:50 +02:00
Lior Halphon 74d00b84b7 Treat STOP as a 2-byte instruction 2017-02-17 00:21:02 +02:00
Lior Halphon 6b1363e96e Fixed: Writing to 3XXX in MBC5 before writing to 2XXX no longer switches to the wrong bank. 2017-02-16 23:13:55 +02:00
Lior Halphon 421d3b27f5 Correct emulation of HUC1 banks higher than 0x1F 2017-02-16 21:07:35 +02:00
Lior Halphon 10ab2b4fe0 Fixed typo in the disassembler. 2017-02-16 20:51:32 +02:00
Lior Halphon 86837761fa Improved compatibility with SameBoy's boot ROM by removing the RAM bank switch (The original boot ROM does that for no reason, but eventually switches back to bank 1) 2017-02-15 22:37:43 +02:00
Lior Halphon 3fbc2c5716 DI should not be delayed. 2017-02-15 19:04:53 +02:00
Lior Halphon 4b6fda0cb6 Simplified HDMA and fixed the reading of the HDMA5 register 2017-02-08 21:58:15 +02:00
Lior Halphon d5c9a52337 Fixed: HDMA registers were not being updated during transfer 2017-02-07 00:24:26 +02:00
Lior Halphon 7ee96766b6 Updated documents to refer to the new website 2017-02-05 21:50:46 +02:00
Lior Halphon cfe0e55df8 Updated change log and incremented version to 0.8 2017-02-05 21:13:42 +02:00
Lior Halphon a17213d89c Fixed SDL compilation on macOS Sierra 2017-02-04 19:00:48 +02:00
Lior Halphon eed8a06fc0 Several fixes to the help command 2017-02-04 19:00:31 +02:00
Lior Halphon 57c73c8a51 Fixed the help command for the disassemble command 2017-02-04 17:49:22 +02:00
Lior Halphon 6f94664428 Close Open Panels if a document is opened via other means 2017-01-24 23:10:50 +02:00
Lior Halphon a5f72627fe Cocoa key bindings now based on key codes 2017-01-24 21:00:56 +02:00
Tim Allen dd76846cf2 Update to v102r02 release.
byuu says:

Changelog:

  - I caved on the `samples[] = {0.0}` thing, but I'm very unhappy about it
      - if it's really invalid C++, then GCC needs to stop accepting it
        in strict `-std=c++14` mode
  - Emulator::Interface::Information::resettable is gone
  - Emulator::Interface::reset() is gone
  - FC, SFC, MD cores updated to remove soft reset behavior
  - split GameBoy::Interface into GameBoyInterface,
    GameBoyColorInterface
  - split WonderSwan::Interface into WonderSwanInterface,
    WonderSwanColorInterface
  - PCE: fixed off-by-one scanline error [hex_usr]
  - PCE: temporary hack to prevent crashing when VDS is set to < 2
  - hiro: Cocoa: removed (u)int(#) constants; converted (u)int(#)
    types to (u)int_(#)t types
  - icarus: replaced usage of unique with strip instead (so we don't
    mess up frameworks on macOS)
  - libco: added macOS-specific section marker [Ryphecha]

So ... the major news this time is the removal of the soft reset
behavior. This is a major!! change that results in a 100KiB diff file,
and it's very prone to accidental mistakes!! If anyone is up for
testing, or even better -- looking over the code changes between v102r01
and v102r02 and looking for any issues, please do so. Ideally we'll want
to test every NES mapper type and every SNES coprocessor type by loading
said games and power cycling to make sure the games are all cleanly
resetting. It's too big of a change for me to cover there not being any
issues on my own, but this is truly critical code, so yeah ... please
help if you can.

We technically lose a bit of hardware documentation here. The soft reset
events do all kinds of interesting things in all kinds of different
chips -- or at least they do on the SNES. This is obviously not ideal.
But in the process of removing these portions of code, I found a few
mistakes I had made previously. It simplifies resetting the system state
a lot when not trying to have all the power() functions call the reset()
functions to share partial functionality.

In the future, the goal will be to come up with a way to add back in the
soft reset behavior via keyboard binding as with the Master System core.
What's going to have to happen is that the key binding will have to send
a "reset pulse" to every emulated chip, and those chips are going to
have to act independently to power() instead of reusing functionality.
We'll get there eventually, but there's many things of vastly greater
importance to work on right now, so it'll be a while. The information
isn't lost ... we'll just have to pull it out of v102 when we are ready.

Note that I left the SNES reset vector simulation code in, even though
it's not possible to trigger, for the time being.

Also ... the Super Game Boy core is still disconnected. To be honest, it
totally slipped my mind when I released v102 that it wasn't connected
again yet. This one's going to be pretty tricky to be honest. I'm
thinking about making a third GameBoy::Interface class just for SGB, and
coming up with some way of bypassing platform-> calls when in this
mode.
2017-01-23 08:04:26 +11:00
Lior Halphon 9779635c34 Added NSSupportsAutomaticGraphicsSwitching to Cocoa's Info.plist 2017-01-22 22:25:15 +02:00
Lior Halphon 7a9377de34 Fixed compilation issues under more recent Xcode versions 2017-01-22 21:53:52 +02:00
Lior Halphon 430b733da6 Disabled Quick Look preview/thumbnail cancelation. It seems that the API sometime return true for no reason, and documentation of QL APIs is extremely poor. 2017-01-22 21:04:10 +02:00
Lior Halphon 0d8244748c Fixed icon alignment 2017-01-22 00:37:25 +02:00
Lior Halphon a012d721a3 Added a Preview generator for Quick Look, so QL framework won't "ban" our plugin for failing to generate these. 2017-01-22 00:10:27 +02:00
Lior Halphon 517e72f92b Printer compression support 2017-01-20 23:00:02 +02:00
Lior Halphon 8cd82ebb68 Quick Look icon generation for GameBoy ROMs, using screenshots from the actual ROMs 2017-01-20 18:35:20 +02:00
Lior Halphon 8d5bacf6ae Updated Cocoa cartridge icons 2017-01-20 18:16:45 +02:00
Lior Halphon 5dcc8e744e Fixed a crash in the Cocoa port that might happen after closing GameBoy Camera 2017-01-14 19:45:07 +02:00
Lior Halphon 613d3b2e82 Printer support in Cocoa 2017-01-13 22:26:44 +02:00
Lior Halphon 527ae01e0e Printer API, compression not supported yet 2017-01-13 22:20:11 +02:00
Lior Halphon cd382ef236 Fixed: Conditional read watchpoints crashed if the expression referred to the 'new' variable. Breakpoint and watchpoint conditions no longer trigger watchpoints. 2017-01-12 23:11:26 +02:00
Lior Halphon 8c14ec3268 An interrupt should also occur when using external clock. 2016-11-13 00:42:05 +02:00
Lior Halphon 22c34e1095 Serial API 2016-11-12 01:58:53 +02:00
Lior Halphon 15f6412581 Update README.md 2016-10-29 22:54:32 +03:00
Lior Halphon 388fb600de Added VRAM-debugging APIs, added VRAM viewer to Cocoa Port, fixed uninitialized VRAM, fixed memory viewer crash 2016-10-27 00:23:24 +03:00
Lior Halphon 47aaf44017 Rumble API 2016-10-22 15:37:03 +03:00
Lior Halphon 2d51d13479 Various optimizations 2016-10-22 02:18:29 +03:00
Lior Halphon 1b8832a7ff Added disassemble command 2016-10-19 23:55:23 +03:00
Lior Halphon ee51dec20e Added modifier syntax to debugger: Changed watch's syntax, added format modifier to print/eval, added count option to examine command. 2016-10-19 23:48:46 +03:00
Lior Halphon 18ec502cfe Fine tuning the stack-overflow tester detection 2016-10-18 02:35:21 +03:00
Lior Halphon edf93abff1 According to Mooneye's test ROMs, this behavior does not happen on a CGB 2016-10-18 00:31:07 +03:00
Lior Halphon 11f8c41305 Basic HUC3 support 2016-10-17 18:51:43 +03:00
Lior Halphon 3fc4fcc538 Added a custom automation combo for Tsuri Sensei, to avoid an in-game buffer-overflow 2016-10-14 01:30:54 +03:00
Lior Halphon 9ca7540c69 Fixed dereferencing a non-banked address in the debugger 2016-10-14 01:19:39 +03:00
Lior Halphon 5cca2a4168 Be more forgiving about stack overflows. Some games commercially leak stack every once in a while when being stress-tested. 2016-10-11 14:53:54 +03:00
Lior Halphon fa35869bc4 Implemented DMG STAT-write interrupt bug, fixed Road Rash and Zero no Densetsu (These game do not work on CGBs) 2016-10-11 13:37:43 +03:00
Lior Halphon 11cbe58eb1 False positive corrections 2016-10-05 23:57:19 +03:00
Lior Halphon 76c795a966 Whoops. 2016-10-04 04:01:06 +03:00
Lior Halphon 90b7383df7 The camera's get pixel callback must return the same value for every coordinate until a new photo is taken. 2016-10-03 23:05:47 +03:00
Lior Halphon 2d06599a85 Edge enhancement support 2016-10-03 19:39:20 +03:00
Lior Halphon 8941504863 Refinements to camera support according to AntonioND's docs 2016-10-03 18:24:15 +03:00
Lior Halphon dd23fffcc0 Proper (I believe) emulation of most GameBoy Camera registers 2016-10-03 14:22:54 +03:00
Lior Halphon 2a84d62187 Forbid reading the image while the camera is busy 2016-10-03 01:29:54 +03:00
Lior Halphon b50b38c78a GameBoy Camera support in Cocoa 2016-10-03 00:26:12 +03:00
Lior Halphon 479a64dca6 Dither using a pattern, closer to actual GameBoy Camera 2016-10-02 23:36:20 +03:00
Lior Halphon de7c15fc68 Another camera API bugfix 2016-10-02 18:33:33 +03:00
Lior Halphon 9c68ac1419 Camera API bugfix 2016-10-02 18:14:05 +03:00
Lior Halphon ab5f66795a Gameboy Camera API 2016-10-02 17:14:58 +03:00
Lior Halphon b3b041a151 Basic GB Camera support (Emulate only MBC, enough for the ROM to boot). 2016-10-02 03:40:11 +03:00
Lior Halphon 9b71454f07 Basic HUC1 support (Emulated as MBC1) 2016-10-02 02:15:03 +03:00
Lior Halphon 58a4081b48 Improved open performance in Cocoa 2016-10-02 00:10:31 +03:00
Lior Halphon 21b91adf6a Improved open-dialog behavior in Cocoa 2016-10-02 00:10:09 +03:00
Lior Halphon 4904277f0d Corrected behavior of palette registers in DMG mode. This affected a broken Game & Watch Gallery 2 ROM that was previously used in the automation test. 2016-10-01 22:10:44 +03:00
Lior Halphon 80a1b12ae7 Added palette command to the debugger 2016-10-01 22:08:34 +03:00
Lior Halphon 3dd1580256 Automation triggered a bug in DX Bakenou, fixed false positive. 2016-10-01 14:31:34 +03:00
Lior Halphon 4a2bec239a MBC2 RAM support was completely broken. 2016-09-30 23:34:06 +03:00
Lior Halphon 17748b980a Fixed a false positive with the FF-loop detection 2016-09-30 18:24:01 +03:00
Lior Halphon 5c5b1cd3ae Seems like even 1 second isn't enough for some games. 2016-09-30 14:12:41 +03:00
Lior Halphon 4f9b86c900 Make Github not count HexFiend into the language stats. 2016-09-30 13:51:59 +03:00
Lior Halphon 7bf9cc8f1a Detect blank screens by actual screen content, as some games modify LCDC between vblanks. 2016-09-30 01:10:50 +03:00
Lior Halphon 5565c096c7 Misc optimizations, especially for the tester 2016-09-30 01:09:44 +03:00
Lior Halphon 3ac3eccebb Bugfix: Multiple watchpoints did not work correctly and conflicted with breakpoints 2016-09-30 01:09:17 +03:00
Lior Halphon 258500bda3 Merge branch 'master' into rateless_apu 2016-09-23 18:53:38 +03:00
Lior Halphon 52ed2ca55e Corrected BG enable's behavior (Fixes visual glitch with Krusty's Funhouse) 2016-09-23 18:30:07 +03:00
Lior Halphon 42c01a21b2 Fixed crash when accessing MBC RAM on a cartridge that "has RAM", but it's 0-sized. 2016-09-22 01:52:40 +03:00
Lior Halphon 0991705379 Refined HALT bug behavior, fixed Robocop 2016-09-22 01:51:09 +03:00
Lior Halphon bc3cab7dfa Forbid pressing two opposing direction keys. Fixes Pocket Bomberman (U). 2016-09-21 02:15:02 +03:00
Lior Halphon 252439c1af Fixed a deadlocking race condition that might happen when reading APU memory in the hex viewer 2016-09-21 01:59:43 +03:00
Lior Halphon c40b86d4a4 Merge branch 'master' into rateless_apu 2016-09-21 00:23:59 +03:00
Lior Halphon 6f2b36cacb The HALT bug also happens on CGBs, regardless of DMG mode. 2016-09-20 22:59:25 +03:00
Lior Halphon 97eb3fe209 Detect games stuck on blank screens 2016-09-20 22:59:00 +03:00
Lior Halphon f88c9d299b Merge branch 'master' into rateless_apu 2016-09-20 20:05:03 +03:00
Lior Halphon f46414b7b1 Updated struct version :( 2016-09-20 20:04:38 +03:00
Lior Halphon 37e895352f Volumes no longer doubles 2016-09-20 19:58:30 +03:00
Lior Halphon a026f8b26d Update README.md 2016-09-20 01:45:02 +03:00
Lior Halphon f049284324 Emulate the HALT bug on a DMG 2016-09-20 01:22:21 +03:00
Lior Halphon 1a3a96762b CPU cleanup 2016-09-18 23:50:04 +03:00
Lior Halphon ed31358934 Forgot to emulate LCDC bit 0! 2016-09-18 21:00:05 +03:00
Lior Halphon fe51805ed7 Incorrect constant name 2016-09-16 18:24:38 +03:00
Lior Halphon f4c5cf20bc Cleanup of ret_cc 2016-09-16 13:27:32 +03:00
Lior Halphon 71d4ba21f2 Added a tick-counting debugger command 2016-09-16 11:58:31 +03:00
Lior Halphon 4beb946468 Slight APU optimization 2016-09-14 22:49:35 +03:00
Tim Allen 45a725e4b7 Update to v101r18 release.
byuu says:

Changelog:

  - added 30 new PAL games to icarus (courtesy of Mikerochip)
  - new version of libco no longer requires mprotect nor W|X permissions
  - nall: default C compiler to -std=c11 instead of -std=c99
  - nall: use `-fno-strict-aliasing` during compilation
  - updated nall/certificates (hopefully for the last time)
  - updated nall/http to newer coding conventions
  - nall: improve handling of range() function

I didn't really work on higan at all, this is mostly just a release
because lots of other things have changed.

The most interesting is `-fno-strict-aliasing` ... basically, it joins
`-fwrapv` as being "stop the GCC developers from doing *really* evil
shit that could lead to security vulnerabilities or instabilities."

For the most part, it's a ~2% speed penalty for higan. Except for the
Sega Genesis, where it's a ~10% speedup. I have no idea how that's
possible, but clearly something's going very wrong with strict aliasing
on the Genesis core.

So ... it is what it is. If you need the performance for the non-Genesis
cores, you can turn it off in your builds. But I'm getting quite sick of
C++'s "surprises" and clever compiler developers, so I'm keeping it on
in all of my software going forward.
2016-09-14 21:55:53 +10:00
Lior Halphon f274cbc2ec Read wave form while playing 2016-09-13 17:40:10 +03:00
Lior Halphon 594aea2d5a APU is now being run lazily 2016-09-13 17:33:48 +03:00
Lior Halphon eefc998e43 Removed for loop in APU 2016-09-13 17:06:35 +03:00
Lior Halphon ff7b8a6854 Removed doubles, reorganized code a bit 2016-09-13 16:57:16 +03:00
Lior Halphon b95860c034 Making the APU independent of sample rate 2016-09-13 16:55:26 +03:00
Lior Halphon 43be91f032 Slightly more readable code. 2016-09-13 01:20:18 +03:00
Lior Halphon 71a9b7eb77 Updated change log and incremented version to 0.7 2016-09-10 20:59:02 +03:00
Lior Halphon 6e86dbcebb Cocoa port now shows the open dialog if no ROM is open. 2016-09-10 19:46:42 +03:00
Lior Halphon 95cfb114a2 Properly setting MBC RAM 2016-09-10 13:25:18 +03:00
Lior Halphon 6d836b9f48 Fixed APU bug that prevented some games from working 2016-09-10 02:20:44 +03:00
Lior Halphon ad604036a5 More false-negative fixes 2016-09-09 19:29:14 +03:00
Lior Halphon 7bafb6a843 Cocoa port: remember breakpoints and watchpoints after reset 2016-09-07 00:44:00 +03:00
Lior Halphon 62ecadeb57 Fixed another reset-while-debugging deadlock in Cocoa 2016-09-07 00:37:11 +03:00
Lior Halphon 01fc137256 Fixed an APU issue that might occur when having more than one GB_gameboy_t object 2016-09-06 22:36:16 +03:00
Lior Halphon ae003ee020 Fixed several automation false negatives. 2016-09-06 18:00:05 +03:00
Lior Halphon 603b8969ab Correct (disconnected) serial emulation. 2016-09-06 13:13:14 +03:00
Lior Halphon ab2e532cc3 Added link to automation results 2016-09-03 23:24:47 +03:00
Lior Halphon 84a4701733 Auto-detect common crashes, fixed logs about unsupported carts not being written. 2016-09-03 22:59:23 +03:00
Lior Halphon a6c5a8fdaa Fixed a bug that caused the Cocoa port to freeze sometimes if the emulator was reset while debugging. 2016-09-03 13:34:49 +03:00
Lior Halphon a2d77b1754 Warn about unsupported cartridges/MBCs 2016-09-03 04:00:37 +03:00
Lior Halphon a746c726ee Added basic automatic ROM tester 2016-09-03 03:39:32 +03:00
Lior Halphon 833cd88aea Allow compilation with precompiled boot ROMs. 2016-08-27 01:30:11 +03:00
Lior Halphon ee4907949b Support for RTC latching. Fixes #4. 2016-08-21 22:33:57 +03:00
Lior Halphon 92c2b22735 Cocoa port now remembers the mute switch 2016-08-21 21:58:33 +03:00
Lior Halphon 33da8734fe Mouse hiding is now only enabled during full screen mode 2016-08-21 00:38:26 +03:00
Lior Halphon 9479fce7d0 Update README.md 2016-08-20 23:05:13 +03:00
Lior Halphon 0420538034 Update README.md 2016-08-20 23:03:28 +03:00
Lior Halphon 276fe53385 Added icon and version information to Windows port 2016-08-20 22:59:03 +03:00
Lior Halphon 44dfb60c9c Updated README 2016-08-20 18:15:15 +03:00
Lior Halphon e7626535a8 Initial Windows support 2016-08-20 17:51:17 +03:00
Lior Halphon 0734e990b3 Memory viewer now has a Goto command, different memory space modes, and allows viewing/editing specific banks 2016-08-19 14:54:54 +03:00
Lior Halphon f9236d12bf Improvements to the help command and general debugger usability. 2016-08-13 22:52:41 +03:00
Lior Halphon e79ddee705 Basic memory hex viewer/editor, using a (heavily stripped down) HexFiend framework 2016-08-13 00:58:52 +03:00
Lior Halphon 806d0775a4 Added backtrace command to debugger 2016-08-09 22:48:53 +03:00
Lior Halphon a5670b6643 Fixed boot ROM trimming 2016-08-07 00:39:32 +03:00
Lior Halphon 109af49933 Updated DMG boot ROM to finish with the same register values as the original boot ROM 2016-08-06 19:11:54 +03:00
Lior Halphon bebb5c7a41 Correctly emulating the unused OAM memory in DMG mode 2016-08-06 18:58:44 +03:00
Lior Halphon cc8664b0a8 Correctly emulating a disconnected serial cable 2016-08-06 18:57:33 +03:00
Lior Halphon af10e07ed7 Initing OBP0/1 correctly 2016-08-06 18:57:13 +03:00
Lior Halphon 5816b6a688 Updated change log and incremented version to 0.6 2016-08-06 17:16:39 +03:00
Lior Halphon e95d2c4abe Fixed DI instruction on CGB 2016-08-06 17:16:38 +03:00
Lior Halphon 68740c70e4 Stripping executables on release to reduce file size 2016-08-06 16:19:04 +03:00
Lior Halphon 722550c5bc Enabled link time optimization when building in release, improving speed by about 6% 2016-08-06 16:18:23 +03:00
Lior Halphon 553f700b79 Fixed needless deep generation, which caused errors when compiling the Cocoa GUI when SDL is not installed 2016-08-06 15:57:32 +03:00
Lior Halphon d03a1fbd16 Fixed TMA writing while reloading. 2016-08-06 14:36:33 +03:00
Lior Halphon 85a33ed8ef Emulating DMA delay correctly 2016-08-06 14:24:43 +03:00
Lior Halphon 4a50000e83 Corrected timing for many instructions 2016-08-06 14:00:35 +03:00
Lior Halphon 8dd5462525 Correct DMA timing 2016-08-06 13:57:38 +03:00
Lior Halphon 0f98ac5ff9 Emulate TIMA reloading 2016-08-06 13:56:29 +03:00
Lior Halphon 55cbe5d4d0 Accuracy improvements to timers 2016-08-06 00:24:12 +03:00
Lior Halphon d098458ee4 Major improvements to accuracy: Fixed instruction timing, DMA timing, and IO reg masking. Passes most of mooneye-gb acceptance tests. 2016-08-05 16:36:38 +03:00
Lior Halphon 47e3300b66 Improved DMA accuracy, mooneyegb test ROMs no longer crash miserably. (but still fail) 2016-08-03 23:31:10 +03:00
Lior Halphon fad1007427 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2016-08-03 22:28:28 +03:00
Lior Halphon e6d4cac00e Fix logical bug when changing watchpoint flags 2016-07-21 15:20:25 +03:00
Lior Halphon 185e71fe12 Improvements to IR API, since timing is VERY important 2016-07-21 01:03:13 +03:00
Lior Halphon b740b7f3ba Fixed Cocoa memory leak 2016-07-20 23:52:29 +03:00
Lior Halphon 1d35c04ab1 Infrared API 2016-07-18 22:11:18 +03:00
Lior Halphon 0fbc72f197 SDL save states 2016-07-18 14:37:06 +03:00
Lior Halphon da0911d69b Fixed SDL crash 2016-07-18 14:30:21 +03:00
Lior Halphon b30822fd0b Async commands in SDL port, better handling of ^C and ^D 2016-07-18 13:10:19 +03:00
Lior Halphon aa6438fa06 Async debugger commands 2016-07-18 00:46:45 +03:00
Lior Halphon 67f3a3a9d8 Symbol support in SDL port 2016-07-17 23:08:07 +03:00
Lior Halphon 9d53760016 Fixing Linux build 2016-07-17 22:43:23 +03:00
Lior Halphon a68b06226a Fixed crash on free 2016-07-15 23:20:14 +03:00
Lior Halphon eaca0634aa Reading and writing absolute addresses in the expression evaluator. 2016-07-15 17:06:46 +03:00
Lior Halphon e20e81befd Symbol support in the expression evaluator 2016-07-15 14:31:27 +03:00
Lior Halphon c3a831db7d Debugger's pc "variable" now returns a full address 2016-07-14 23:27:48 +03:00
Lior Halphon 909f3ba75e Bank-specific breakpoints and watchpoints 2016-07-14 23:25:16 +03:00
Lior Halphon ce837b3727 Bank-specific examine support 2016-07-14 21:15:24 +03:00
Lior Halphon 65f37bccbd Initial 25-bit debugger values support 2016-07-14 21:01:45 +03:00
Lior Halphon ea082b777d ...And another crash 2016-07-14 01:46:55 +03:00
Lior Halphon f6b10ed439 Operators priorities were inverted! 2016-07-13 23:51:46 +03:00
Lior Halphon 46714108ac ...And a crash. 2016-07-13 23:46:18 +03:00
Lior Halphon c3f1eb26b1 Fixed potential overflow 2016-07-13 23:07:36 +03:00
Lior Halphon d49404d248 Debugger can now read .sym files, and display them. (No expression support yet) 2016-07-13 23:00:50 +03:00
Lior Halphon e9b3a38171 Uniform syntax for debugger input and output 2016-07-12 23:30:18 +03:00
Lior Halphon bd7f8f2555 Support for an alternative MBC1 wiring, should solve most N-in-1 carts (Issue #3) 2016-07-09 19:25:25 +03:00
Lior Halphon c6bafe3fc3 Rewrote MBC support 2016-07-09 17:34:55 +03:00
Lior Halphon 78a809795e Renaming MBC constants 2016-07-09 14:45:25 +03:00
Lior Halphon b4208be4f4 Multiple watchpoints were broken 2016-07-09 14:37:11 +03:00
Lior Halphon de4983099a Added (conditional) r/w watchpoints. Fixed a bug where breakpoint condition syntax is not checked. Added != operator. 2016-07-07 00:29:25 +03:00
Lior Halphon dce0e5fdeb Hide mouse cursor when running (Cocoa) 2016-07-05 23:34:33 +03:00
Lior Halphon 1268bf3a35 Keeping aspect ratio is now optional (but default) 2016-07-05 21:23:55 +03:00
Lior Halphon c9d4a4ebb5 Proper fullscreen support (Including Yosemite and older) 2016-07-03 21:32:58 +03:00
Lior Halphon 39f91f0dd6 Proportional Reiszing 2016-07-03 20:58:25 +03:00
Lior Halphon 9321df9630 Prevent the Cocoa port from being both "paused" and "debug_paused" 2016-07-02 20:58:06 +03:00
Lior Halphon cc9af4a5c5 Updated change log and incremented version to 0.5 2016-07-01 20:57:50 +03:00
Lior Halphon 19aea4096b Added condition breakpoint. Fixed a possible crash when deleting a breakpoint. 2016-07-01 18:24:21 +03:00
Lior Halphon 8eee70aed9 Fixed disassembler bugs 2016-07-01 18:04:25 +03:00
Lior Halphon 79fd9ed6ad Added boolean operators to the debugger 2016-07-01 13:12:04 +03:00
Lior Halphon 70bd90740a Mass name and type changes. Save states are now compatible between 32- and 64-bit systems. Maybe. 2016-06-18 20:29:11 +03:00
Lior Halphon 32a1ad87b7 Fixed a bug where a Cocoa emulator window will appear frozen (or partially frozen) until resized 2016-06-18 17:48:24 +03:00
Lior Halphon 180f0e16b0 Cocoa port now remembers the previous window size 2016-06-18 17:43:39 +03:00
Lior Halphon b99ed2676a Use NSThread instead of GDC when invoking run 2016-06-18 17:20:40 +03:00
Lior Halphon 64832e0e9e HDMA accuracy improvement 2016-06-18 16:51:25 +03:00
Lior Halphon d58ddef07b Proper initial value for the Joypad register 2016-06-18 15:01:51 +03:00
Lior Halphon 07c5e8fcb1 Fixed smooth bilinear filter 2016-06-18 02:05:52 +03:00
Lior Halphon 7e8d5fe57c Updated SCALING.md 2016-06-18 00:01:51 +03:00
Lior Halphon 846a9318ba Added anti aliasing to OmniScale. Fixed color differentiation for HQ2x and OmniScale 2016-06-17 23:47:41 +03:00
Lior Halphon 5723b82293 Fixed graphical glitches caused by the last change to LCDC emulation 2016-06-17 02:27:32 +03:00
Lior Halphon 6f73ee053d The old OmniScale filter became OmniScale Legacy. A new OmniScale filter was added instead. 2016-06-17 01:06:52 +03:00
Lior Halphon e6c4b4d1b2 Seems like I forgot to finish implementing the stop instruction! 2016-06-14 14:12:13 +03:00
Lior Halphon 52afba21d1 Added HQ2x shader, upgrading to OpenGL 3 2016-06-14 14:11:37 +03:00
Lior Halphon 8153b765a2 General cleanup. Minor fixes to LCD Controller accuracy. 2016-06-12 19:39:05 +03:00
Lior Halphon d7d8da3fa9 More accurate emulation of the SCX register 2016-06-11 17:58:00 +03:00
Lior Halphon b7e999b242 Modified saved data to be more future-compatible. 2016-06-11 17:49:42 +03:00
Lior Halphon 36d46567ba Updated change log and incremented version to 0.4 2016-06-10 18:07:39 +03:00
Lior Halphon 6c7dd761e2 Fixed a crash related to adding and deleting breakpoints 2016-06-10 18:03:12 +03:00
Lior Halphon ee7e58e44b Fixed a bug introduced by the last STAT fix. This restores GBVideoPlayer support. 2016-06-10 17:29:49 +03:00
Lior Halphon 759b497c07 Fixed bug introduced by the stereo support 2016-06-10 16:38:20 +03:00
Lior Halphon aca5873de2 More accurate STAT interrupt. This fixes Altered Space and partially fixes Pinball Deluxe. It breaks GBVideoPlayer, however. 2016-06-10 16:31:57 +03:00
Lior Halphon 3e1863ec51 Battery save support in the SDL version 2016-06-10 15:48:40 +03:00
Lior Halphon 6bc64a9902 Added stereo support. Correct some PCM register behavior. 2016-06-10 15:28:50 +03:00
Lior Halphon 4d8f2cfac8 Added missing -framework Carbon 2016-06-09 18:22:47 +03:00
Lior Halphon c27ee9d879 Fixed a bug in the Cocoa port that made SameBoy ignore some input keys when the keyboard layout is set to a non-Latin/ASCII keyboard. This was solved by forcing an ASCII layout. 2016-06-09 00:37:00 +03:00
Lior Halphon 94ea44da0c Introducing the OmniScale (beta) algorithm to SameBoy 2016-06-09 00:06:55 +03:00
Lior Halphon 8a3e0c3f24 Merge branch 'master' of https://github.com/LIJI32/SameBoy 2016-06-04 17:39:16 +03:00
Lior Halphon da65b4e90d Audio support for the SDL port 2016-05-23 22:22:09 +03:00
Lior Halphon 8d59bfcbdd Filter support for Cocoa port + 7 basic filters 2016-04-29 00:45:56 +03:00
Lior Halphon dde983db8f Updated change log and incremented version to 0.3 2016-04-16 15:21:22 +03:00
Lior Halphon 79e4c22c6b Fixed string in MBC command 2016-04-16 15:18:40 +03:00
Lior Halphon 0fa2d6ea2f Prevent creating .sav files for ROMs claiming they have a battery but have no cartridge RAM or RTC 2016-04-16 14:09:56 +03:00
Lior Halphon 7dc575d01e Fixed a bug where audio channel 3 was playing silently instead of being muted. 2016-04-16 14:08:30 +03:00
Lior Halphon ddc9605271 Load DMG's tilemap for specific games in the CGB boot (Fixes X's title screen and an unknown game with title checksum $43) 2016-04-16 13:50:29 +03:00
Lior Halphon d63a801821 Fixed a mistake that made the CGB boot ROM not initialize the wave pattern. Closes #2. 2016-04-15 22:09:06 +03:00
Lior Halphon b8bc84db4e Corrected read of HDMA5, fixing A Bug's Life 2016-04-15 01:26:48 +03:00
Lior Halphon 4a05c4243d Corrected description for the breakpoint command 2016-04-13 22:48:07 +03:00
Lior Halphon 2a5375a0c8 Configurable keys for the Cocoa port 2016-04-13 22:43:16 +03:00
Lior Halphon 8dd1b3c854 Added (experimental) stack-leak and stack-overflow detection command to the debugger. 2016-04-10 23:22:54 +03:00
Lior Halphon 71ef40f4b6 "Standardized" the finish/next call depth as debugger "hooks" 2016-04-10 22:36:54 +03:00
Lior Halphon bf6dff30cb Corrected debugger's finish behavior's on interrupt handlers 2016-04-10 20:58:14 +03:00
Lior Halphon 0a09fba091 Correcting DIV and TIMA speed in CGB's double speed mode 2016-04-09 16:48:37 +03:00
Lior Halphon de95e6f6fc Fixed incorrect DMA validity check, fixing The Smurfs 3 2016-04-09 15:00:29 +03:00
Lior Halphon 80d03f3c91 Added ROM-bank wrapping support, making bootleg game "Pocket Monster Adventures" boot.
(Although this game is better not booting)
2016-04-09 02:18:09 +03:00
Lior Halphon a3b44d20cb Added mbc/cartridge command to debugger 2016-04-09 02:00:10 +03:00
Lior Halphon 6fd2daae06 Added changelog, updated version to 0.2 2016-04-08 14:05:21 +03:00
Lior Halphon c97033b81c Console output is now configurable in the Cocoa port as "Developer Mode" 2016-04-08 13:54:34 +03:00
Lior Halphon d580a33a7f Save user's preferences in the Cocoa port 2016-04-08 13:10:01 +03:00
Lior Halphon d5a13900dd Missing </body> in Cocoa's License.html 2016-04-08 12:41:41 +03:00
Lior Halphon 448e46ddce Support for PCM_12 and PCM_34 in SDL port 2016-04-08 12:37:09 +03:00
Lior Halphon f448865b8a Silently ignoring empty lines 2016-04-08 01:53:21 +03:00
Lior Halphon 1069637e45 Added support for multiple breakpoints 2016-04-07 00:25:41 +03:00
Lior Halphon eb3e0eaa1e Pause the debugger on SIGINT in the SDL port 2016-04-06 22:58:30 +03:00
Lior Halphon 1c2af7fa5b Fixed the default debugger input to strip new lines, fixing the debugger in SDL 2016-04-06 22:57:37 +03:00
Lior Halphon eb0b642247 Improved debugger command style and usability, made code more flexible 2016-04-06 01:43:35 +03:00
Lior Halphon 3e135a7c00 More accurate emulation of the DMG-emulation-mode registers. 2016-04-05 23:21:51 +03:00
Lior Halphon cda6621dc2 Fixed mask for TAC and STAT 2016-04-04 22:12:00 +03:00
Lior Halphon af7309b98d Moved the call to display_run to advance_cycle.
This fixes games with delicate timings such as X/Ekkusu, that expect STAT to change *during* an opcode.
2016-04-02 19:15:07 +03:00
Lior Halphon 0787e5b271 Debugger's next command can now exit a function 2016-04-02 19:06:43 +03:00
Lior Halphon b7555e9976 Correct OAM interrupt behavior 2016-04-02 16:29:27 +03:00
Lior Halphon da00e240e5 Correct read of IF and write of IE 2016-04-02 16:29:02 +03:00
Lior Halphon 8ff433bb97 Remove useless key from plist 2016-04-02 12:51:07 +03:00
Lior Halphon cc8a09763f Version 0.1 2016-04-01 23:36:43 +03:00
Lior Halphon 1538ad451c Copy the license to the SDL build directory 2016-04-01 23:29:03 +03:00
Lior Halphon abfebf0eb2 Added debug/release configurations 2016-04-01 22:53:29 +03:00
Lior Halphon 1a66f26a5e Added readme 2016-04-01 22:25:26 +03:00
Lior Halphon e11faaf3fb Added license and copyright 2016-04-01 22:13:05 +03:00
Lior Halphon a3dd58c92c Fixed inaccurate LCD controller behavior that caused Pokémon Pinball to freeze. 2016-04-01 21:27:16 +03:00
Lior Halphon 3344480de7 Vblank now returns a white screen if LCD is off, instead of keeping the buffer unmodified. 2016-04-01 21:27:16 +03:00
Lior Halphon e822f17bb7 Wrapping external RAM banking support. Required for Pokémon Pinball's saves. 2016-04-01 21:27:16 +03:00
Lior Halphon ec8823e620 Cocoa port can now enter an empty line in the debugger to repeat the previous command 2016-04-01 21:27:15 +03:00
Lior Halphon f1e9623371 Initial public commit 2016-04-01 21:27:01 +03:00
Tim Allen 750af6ebc3 Update to v096r02 (OS X Preview for Developers) release.
byuu says:

Warning: this is not for the faint of heart. This is a very early,
unpolished, buggy release. But help testing/fixing bugs would be greatly
appreciated for anyone willing.

Requirements:
- Mac OS X 10.7+
- Xcode 7.2+

Installation Commands:

    cd higan
    gmake -j 4
    gmake install
    cd ../icarus
    gmake -j 4
    gmake install

(gmake install is absolutely required, sorry. You'll be missing key
files in key places if you don't run it, and nothing will work.)

(gmake uninstall also exists, or you can just delete the .app bundles
from your Applications folder, and the Dev folder on your desktop.)

If you want to use the GBA emulation, then you need to drop the GBA BIOS
into ~/Emulation/System/Game\ Boy\ Advance.sys\bios.rom

Usage:
You'll now find higan.app and icarus.app in your Applications folders.
First, run icarus.app, navigate to where you keep your game ROMs. Now
click the settings button at the bottom right, and check "Create
Manifests", and click OK. (You'll need to do this every time you run
icarus because there's some sort of bug on OSX saving the settings.) Now
click "Import", and let it bring in your games into ~/Emulation.

Note: "Create Manifests" is required. I don't yet have a pipe
implementation on OS X for higan to invoke icarus yet. If you don't
check this box, it won't create manifest.bml files, and your games won't
run at all.

Now you can run higan.app. The first thing you'll want to do is go to
higan->Preferences... and assign inputs for your gamepads. At the very
least, do it for the default controller for all the systems you want to
emulate.

Now this is very important ... close the application at this point so
that it writes your config file to disk. There's a serious crashing bug,
and if you trigger it, you'll lose your input bindings.

Now the really annoying part ... go to Library->{System} and pick the
game you want to play. Right now, there's a ~50% chance the application
will bomb. It seems the hiro::pListView object is getting destroyed, yet
somehow the internal Cocoa callbacks are being triggered anyway. I don't
know how this is possible, and my attempts to debug with lldb have been
a failure :(

If you're unlucky, the application will crash. Restart and try again. If
it crashes every single time, then you can try launching your game from
the command-line instead. Example:

    open /Applications/higan.app \
	--args ~/Emulation/Super\ Famicom/Zelda3.sfc/

Help wanted:
I could really, really, really use some help with that crashing on game
loading. There's a lot of rough edges, but they're all cosmetic. This
one thing is pretty much the only major show-stopping issue at the
moment, preventing a wider general audience pre-compiled binary preview.
2016-01-07 19:17:15 +11:00
Tim Allen f0d1b7fa8c Update to v096r01 release.
byuu says:

Changelog:

- restructured the project and removed a whole bunch of old/dead
  directives from higan/GNUmakefile
- huge amounts of work on hiro/cocoa (compiles but ~70% of the
  functionality is commented out)
- fixed a masking error in my ARM CPU disassembler [Lioncash]
- SFC: decided to change board cic=(411,413) back to board
  region=(ntsc,pal) ... the former was too obtuse

If you rename Boolean (it's a problem with an include from ruby, not
from hiro) and disable all the ruby drivers, you can compile an
OS X binary, but obviously it's not going to do anything.

It's a boring WIP, I just wanted to push out the project structure
change now at the start of this WIP cycle.
2015-12-30 17:54:59 +11:00
Tim Allen 6b44980c6c Update to v094r29 release.
byuu says:

Note: for Windows users, please go to nall/intrinsics.hpp line 60 and
correct the typo from "DISPLAY_WINDOW" to "DISPLAY_WINDOWS" before
compiling, otherwise things won't work at all.

This will be a really major WIP for the core SNES emulation, so please
test as thoroughly as possible.

I rewrote the 65816 CPU core's dispatcher from a jump table to a switch
table. This was so that I could pass class variables as parameters to
opcodes without crazy theatrics.

With that, I killed the regs.r[N] stuff, the flag_t operator|=, &=, ^=
stuff, and all of the template versions of opcodes.

I also removed some stupid pointless flag tests in xcn and pflag that
would always be true.

I sure hope that AWJ is happy with this; because this change was so that
my flag assignments and branch tests won't need to build regs.P into
a full 8-bit variable anymore.

It does of course incur a slight performance hit when you pass in
variables by-value to functions, but it should help with binary size
(and thus cache) by reducing a lot of extra functions. (I know I could
have used template parameters for some things even with a switch table,
but chose not to for the aforementioned reasons.)

Overall, it's about a ~1% speedup from the previous build. The CPU core
instructions were never a bottleneck, but I did want to fix the P flag
building stuff because that really was a dumb mistake v_v'
2015-06-22 23:31:49 +10:00
Tim Allen ddffcd7600 Update to v094r28 release.
byuu says:

This WIP substantially restructures the ruby API for the first time
since that project started.

It is my hope that with this restructuring, destruction of the ruby
objects should now be deterministic, which should fix the crashing on
closing the emulator on Linux. We'll see I guess ... either way, it
removed two layers of wrappers from ruby, so it's a pretty nice code
cleanup.

It won't compile on Windows due to a few issues I didn't see until
uploading the WIP, too lazy to upload another. But I fixed all the
compilation issues locally, so it'll work on Windows again with the next
WIP (unless I break something else.)

(Kind of annoying that Linux defines glActiveTexture but Windows
doesn't.)
2015-06-20 15:44:05 +10:00
Tim Allen 81a87a1e01 Update to v093 release.
byuu says:

Changelog:
- added Cocoa target: higan can now be compiled for OS X Lion
  [Cydrak, byuu]
- SNES/accuracy profile hires color blending improvements - fixes
  Marvelous text [AWJ]
- fixed a slight bug in SNES/SA-1 VBR support caused by a typo
- added support for multi-pass shaders that can load external textures
  (requires OpenGL 3.2+)
- added game library path (used by ananke->Import Game) to
  Settings->Advanced
- system profiles, shaders and cheats database can be stored in "all
  users" shared folders now (eg /usr/share on Linux)
- all configuration files are in BML format now, instead of XML (much
  easier to read and edit this way)
- main window supports drag-and-drop of game folders (but not game files
  / ZIP archives)
- audio buffer clears when entering a modal loop on Windows (prevents
  audio repetition with DirectSound driver)
- a substantial amount of code clean-up (probably the biggest
  refactoring to date)

One highly desired target for this release was to default to the optimal
drivers instead of the safest drivers, but because AMD drivers don't
seem to like my OpenGL 3.2 driver, I've decided to postpone that. AMD
has too big a market share. Hopefully with v093 officially released, we
can get some public input on what AMD doesn't like.
2013-08-18 13:21:14 +10:00
Tim Allen 5a09a0476d Update to higan v091 release.
byuu says:

Basically just a project rename, with s/bsnes/higan and the new icon
from lowkee added in.

It won't compile on Windows because I forgot to update the resource.rc
file, and a path transform command isn't working on Windows.
It was really just meant as a starting point, so that v091 WIPs can flow
starting from .00 with the new name (it overshadows bsnes v091, so
publicly speaking this "shouldn't exist" and will probably be deleted
from Google Code when v092 is ready.)
2012-12-26 17:46:36 +11:00
Tim Allen d9d3ac685a Update to v090 release.
byuu says:

Most notably, this release adds Nintendo DS emulation. The Nintendo DS
module was written entirely by Cydrak, so please give him all of the
credit for it. I for one am extremely grateful to be allowed to use his
module in bsnes.

The Nintendo DS emulator's standalone name is dasShiny. You will need
the Nintendo DS firmware, which I cannot provide, in order to use it. It
also cannot (currently?) detect the save type used by NDS games. As
such, manifest.xml files must be created manually for this purpose. The
long-term plan is to create a database of save types for each game.
Also, you will need an analog input device for the touch screen for now
(joypad axes work well.)

There have also been a lot of changes from my end: a unified
manifest.xml format across all systems, major improvements to SPC7110
emulation, enhancements to RTC emulation, MSU1 enhancements, icons in
the file browser list, improvements to SNES coprocessor memory mapping,
cleanups and improvements in the libraries used to build bsnes, etc.

I've also included kaijuu (which allows launching game folders directly
with bsnes) and purify (which allows opening images that are compressed,
have copier headers, and have wrong extensions); both of which are fully
GUI-based.

This release only loads game folders, not files. Use purify to load ROM
files in bsnes.

Note that this will likely be the last release for a long time, and that
I will probably rename the emulator for the next release, due to how
many additional systems it now supports.
2012-08-08 00:08:37 +10:00
Tim Allen 772fb31ee5 Update to v073r02 release.
byuu says:

Changelog:
- removed bsnes/supergameboy (libgameboy -> libgambatte binding)
- added direct ICD2-R coprocessor emulation
- linked in bgameboy to the ICD2-R module
- Makefile removes -Isnes, all files adjusted from <name.hpp> to
  <snes/name.hpp> [relic from asnes split]

You can now play Super Game Boy games with the core bsnes library.
2011-01-08 21:01:51 +11:00
Tim Allen 648061bb95 Initial commit of bgameboy v000.
The source tarball also included empty obj/ and out/ directories which
git does not support.

byuu says:

Project started, so basically everything is new.

It's basically a rough skeleton that mimics bsnes project structure.
Eventually the src/gameboy folder will be copied into bsnes-official and
used by the chip/supergameboy core.
The middleware layer (supergameboy/interface) will be merged into a new
chip/icd2 folder that will represent direct Super Game Boy emulation in
the future.
At least, if all goes according to plan.

There is a simple GUI that can load ROMs, but do nothing after it. It's
not hooked up to ruby yet.
There is a basic system class and interface to expose the
video/audio/input functions.
There is a basic memory bus that doesn't support any MBCs yet.
There is a CPU skeleton that only handles easy read/write access to the
CPU registers (AF is a really fucked up register.)
The core is not hooked up to libco yet, but I intend for it to be, so
that I can run the CPU + LCD how I like.
If it turns out the LCD+audio is easily enslavable, then I'll probably
drop libco and just run it like a regular emulator, using a thread
wrapper around it in bsnes only. We'll see.

The CPU doesn't actually support any opcodes, and loading a ROM won't
actually execute anything.
2010-12-28 12:53:15 +11:00
Tim Allen 7dcdaef9bd Update to v073 release.
byuu says:

This release marks a major step forward, offering full low-level
emulation of all four DSP coprocessors based on the NEC uPD77C25
processor core. Many people were responsible for this milestone: Dr.
Decapitator for the actual decapping and extraction; Lord Nightmare for
the cartridges and some special analysis tools; myself, Jonas Quinn and
Cydrak for the uPD77C25 emulation; and all of the donors who raised the
necessary $1,000 for the necessary hardware and equipment needed to pull
this all off. To say thanks to the donors, I am releasing the uPD77C25
emulation core to the public domain, so that everyone can benefit from
it.

All four DSP emulations will be improved by this by way of having
realistic timing; the DSP-4 will benefit further as the high-level
emulation was incomplete and somewhat buggy; and the DSP-3 will benefit
the most as the high-levle emulation there was not complete enough to be
playable. As a result, most notably, this means bsnes v073 is the first
emulator to fully be able to play SD Gundam GX (J)!

As bsnes' primary goal is accuracy, the LLE DSP support renders the old
HLE DSP support obsolete. Ergo, I have removed the 166KB of HLE source
code, and replaced it with the uPD77C25 core, which comprises a mere
20KB of source code. As this LLE module supports save states, this also
means that for the first time, DSP-3 and DSP-4 games have save state
support.

On the other hand, this also means that to run any DSP game, you will
need the appropriate program ROM. As these are copyrighted, I cannot
distribute them nor tell you where to get them. All I can do is provide
you with the necessary filenames and hashes.

Changelog (since v072 release):
* added NEC uPD77C25 emulation core
* added low-level emulation of the DSP-1, DSP-1B, DSP-2, DSP-3, DSP-4
  coprocessors
* removed high-level emulation of the DSP-n coprocessors
* added blargg's libco::ppc.c module, which is far more portable, even
  running on the PS3
* added software filter support via binary plugins
* added debugger (currently Linux-only); but it is as yet unstable
* added pause shortcut
* updated mightymo's cheat code database
2010-12-26 23:24:34 +11:00
Tim Allen cc2950139d Update to 20100808 release.
byuu says:

This fixes libsnes and debugger builds, and collapses bsnes/ppu/bppu to
bsnes/ppu and bsnes/dsp/sdsp to bsnes/dsp. It also introduces
bsnes/sync.sh, which will synchronize all of asnes/ with bsnes/,
excepting the custom speed-focused modules. So far, that's bsnes/ppu
(scanline renderer) and bsnes/dsp (state machine.)

Should make keeping the two ports in sync much, much easier. It's
basically the same thing as before, only you run sync.sh and have a few
duplicated folders now. May make it clearer by creating a stub/ or src/
folder inside bsnes to do all of the copying, so that you only see the
custom folders in bsnes/' root directory.
2010-08-09 23:31:09 +10:00
byuu e6e19a7c89 Update to bsnes v053 release.
This release greatly polishes the user interface, adds a new cheat code search utility, adds the snesfilter library, and adds Qt-based GUI support to both snesfilter and snesreader. snesfilter gains 2xSaI, Super 2xSaI and Super Eagle support, plus full configuration for both the NTSC and scanline filters; and snesreader gains support support for multi-file ROM archives (eg GoodMerge sets.)
Statically linking Qt to bsnes, snesfilter and snesreader would be too prohibitive size-wise (~10MB or so.) I have to link dynamically so that all three can share the same Qt runtime, which gets all of bsnes and its modules to ~1MB (including the debugger build); and Qt itself to about ~2.5MB.
However, there is some bad news. There's a serious bug in MinGW 4.4+, where it is not generating profile-guided input files (*.gcno files.) There is also a serious bug in Qt 4.5.2/Windows when using dynamic linking: the library is hanging indefinitely, forcing me to manually terminate the process upon exit. This prevents the creation of profile-guided output files (*.gcda files.) It would be tough enough to work around one, but facing both of these issues at once is too much.
I'm afraid I have no choice but to disable profile-guided optimizations until these issues can be addressed. I did not know about these bugs until trying to build the official v053 release, so it's too late to revert to an all-in-one binary now. And I'm simply not willing to stop releasing new builds because of bugs in third-party software. As soon as I can work around this, I'll post a new optimized binary. In the mean time, despite the fact that this release is actually more optimized, please understand that the Windows binary will run approximately ~10% slower than previous releases. I recommend keeping v052 for now if you need the performance. Linux and OS X users are unaffected.
Changelog:
    - save RAM is initialized to 0xff again to work around Ken Griffey Jr Baseball issue
    - libco adds assembly-optimized targets for Win64 and PPC-ELF [the latter courtesy of Kernigh]
    - libco/x86 and libco/amd64 use pre-assembled blocks now, obviates need for custom compilation flags
    - added a new cheat code search utility to the tools menu
    - separated filters from main bsnes binary to libsnesfilter / snesfilter.dll
    - added 2xSaI, Super 2xSaI and Super Eagle filters [kode54]
    - added full configuration settings for NTSC and scanline filters (12+ new options)
    - further optimized HQ2x filter [blargg]
    - added Vsync support to the Mac OS X OpenGL driver
    - added folder creation button to custom file load dialog
    - fixed a few oddities with loading of "game folders" (see older news for an explanation on what this is)
    - updated to blargg's file_extractor v1.0.0
    - added full support for multi-file archives (eg GoodMerge sets)
    - split multi-cart loading again (BS-X, Sufami Turbo, etc) as required for multi-file support
    - cleaned up handling of file placement detection for save files (.srm, .cht, etc)
    - file load dialog now remembers your previous folder path across runs even without a custom games folder assigned
    - windows now save their exact positioning and size across runs, they no longer forcibly center
    - menus now have radio button and check box icons where appropriate
    - debugger's hex editor now has a working scrollbar widget
    - added resize splitter to settings and tools windows
    - worked around Qt style sheet bug where subclassed widgets were not properly applying style properties
2009-10-18 17:33:04 +00:00
byuu b45ff0433e Update to bsnes v029 release.
A new version of bsnes has been released. It contains a few minor emulation fixes, as well as user interface improvements. Behind the scenes, the source has been cleaned up more in preparation for running the CPU and PPU (video processor) separately from each other (eg with no enslavement.) This is required for implementing a clock cycle based PPU renderer.
    - Greatly improved invalid DMA transfer behavior, should be nearly perfect now
    - Major code cleanup -- most importantly, almost all PPU timing-related settings moved back to PPU, from CPU
    - Added option to auto-detect file type by inspecting file headers rather than file extensions
    - Rewrote video filter system to move it out of the emulation core -- HQ2x and Scale2x will work even in hires and interlace modes now, 50% scanline filter added
    - Re-added bsnes window icon
    - Added new controller graphic when assigning joypad keys [FitzRoy]
    - Redundant "Advanced" panel settings which can be configured via the GUI are no longer displayed
    - Improved speed regulation settings
    - XP and Vista themes will now apply to bsnes controls
    - Added "Path Settings" window to allow easy selection of default file directories
    - Tab key now mostly works throughout most of the GUI (needs improvement)
    - Main window will no longer disappear when setting a video multipler which results in a window size larger than the current desktop resolution
    - Added two new advanced options: one to control GUI window opacity, and one to adjust the statusbar text
2008-03-18 06:19:43 +00:00
byuu dc692754c3 Update to bsnes v028 release.
Changelog:
    - OpenGL (with hardware filter mode support) and SDL video drivers added to Linux port
    - OpenAL (with speed regulation disable support) and OSS audio drivers added to Linux port [Nach]
    - SDL input driver (with joypad support) added to Linux port
    - Emulator pause option added
    - Added option to select behavior of bsnes when idle: allow input, ignore input or pause emulator
    - Added support to remap common GUI actions to key/joypad presses on the "Input Configuration" screen
    - bsnes will now clamp the video output size when it is larger than the screen resolution
    - GUI library has been enhanced, and renamed to hiro
    - Fullscreen mode now always centers video, rather than approximates
    - Fullscreen mode now works correctly on Linux/Openbox
    - Extra layer of abstraction in src/ui has been removed, as GUI lib unifies all ports anyway
    - Video, audio and input drivers unified into standard library, named ruby
    - All custom headers have been merged into a new template library, named nall
    - Makefile rewritten, vastly improved. Allows quick toggling of compiled-in drivers
    - Makefile: all object files now placed in /src/obj, binary placed in /
    - libco greatly enhanced, no longer requires an assembler to build [byuu, blargg, Nach]
    - libco SJLJ driver added; bsnes should now build on any Unix-derivative now (Solaris, OS X, PS3, etc) [Nach]
    - Fixed register $213e.d4 PPU1 open bus behavior [zones]
    - Windows port will not activate screensaver while bsnes is running [Nightcrawler]
    - Visual C++ target no longer requires stdint.h
    - And lots more -- mostly code refactoring related
2008-02-04 16:16:34 +00:00
byuu b934ce41d9 Update to bsnes v027 release.
This version replaces libui with miu -- a new GUI wrapper library, and cleans up large portions of the source code.
Unfortunately, the GUI rewrite took far, far longer than I ever imagined. As a result, no work has gone into the core emulation for this version. But with the GUI rewrite out of the way, that should change in the near future. And thanks to the new UI library, I can now begin work on adding a cross-platform debugger to bsnes, at long last.
Changelog:
    - Major source code cleanup (lib/, ui/miu/, ui/vai/)
    - Cheat code editor was broken in v0.026, this is now fixed
    - Cheat code file format simplified for human readability
    - Makefile install target improvements [belegdol]
    - libui replaced with miu GUI library
    - Custom video / audio / input drivers replaced with vai HW library
    - ppc and ppc64 libco targets added [Vas Crabb]
    - x86 and x86-64 libco targets now work on OS X [Lucas Newman]
2007-12-22 18:26:54 +00:00
446 changed files with 54911 additions and 5508 deletions

BIN
.assets/bahamut-lagoon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

BIN
.assets/user-interface.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -1,32 +1,9 @@
linux-x86_64-binaries_task:
container:
image: ubuntu:latest
setup_script:
- apt-get update && apt-get -y install build-essential libgtk2.0-dev libpulse-dev mesa-common-dev libgtksourceview2.0-dev libcairo2-dev libsdl2-dev libxv-dev libao-dev libopenal-dev libudev-dev zip
compile_script:
- make -C bsnes local=false
package_script:
- mkdir bsnes-nightly
- mkdir bsnes-nightly/Database
- mkdir bsnes-nightly/Firmware
- cp -a bsnes/out/bsnes bsnes-nightly/bsnes
- cp -a bsnes/Database/* bsnes-nightly/Database
- cp -a shaders bsnes-nightly/Shaders
- cp -a GPLv3.txt bsnes-nightly
- zip -r bsnes-nightly.zip bsnes-nightly
bsnes-nightly_artifacts:
path: "bsnes-nightly.zip"
freebsd-x86_64-binaries_task:
freebsd_instance:
image: freebsd-12-0-release-amd64
image_family: freebsd-12-2
setup_script:
- pkg install --yes gmake gdb gcc8 pkgconf sdl2 openal-soft gtksourceview2 libXv zip
- pkg install --yes gmake gdb gcc8 pkgconf sdl2 openal-soft gtk3 gtksourceview3 libXv zip
compile_script:
- gmake -C bsnes local=false
@ -39,45 +16,7 @@ freebsd-x86_64-binaries_task:
- cp -a bsnes/Database/* bsnes-nightly/Database
- cp -a shaders bsnes-nightly/Shaders
- cp -a GPLv3.txt bsnes-nightly
- zip -r bsnes-nightly.zip bsnes-nightly
bsnes-nightly_artifacts:
path: "bsnes-nightly.zip"
windows-x86_64-binaries_task:
container:
image: ubuntu:latest
setup_script:
- apt-get update && apt-get -y install build-essential mingw-w64 zip
compile_script:
- make -C bsnes local=false platform=windows compiler="x86_64-w64-mingw32-g++" windres="x86_64-w64-mingw32-windres"
package_script:
- mkdir bsnes-nightly
- mkdir bsnes-nightly/Database
- mkdir bsnes-nightly/Firmware
- cp -a bsnes/out/bsnes bsnes-nightly/bsnes.exe
- cp -a bsnes/Database/* bsnes-nightly/Database
- cp -a shaders bsnes-nightly/Shaders
- cp -a GPLv3.txt bsnes-nightly
- zip -r bsnes-nightly.zip bsnes-nightly
bsnes-nightly_artifacts:
path: "bsnes-nightly.zip"
macOS-x86_64-binaries_task:
osx_instance:
image: mojave-base
compile_script:
- make -C bsnes local=false
package_script:
- mkdir bsnes-nightly
- cp -a bsnes/out/bsnes.app bsnes-nightly
- cp -a GPLv3.txt bsnes-nightly
- cp -a extras/* bsnes-nightly
- zip -r bsnes-nightly.zip bsnes-nightly
bsnes-nightly_artifacts:

1
.github/FUNDING.yml vendored
View File

@ -1 +0,0 @@
patreon: byuu

139
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,139 @@
name: Build
on:
push:
branches: [ master ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]
permissions:
contents: write
jobs:
build:
strategy:
matrix:
os:
- name: ubuntu
version: latest
- name: windows
version: latest
- name: macos
version: latest
runs-on: ${{ matrix.os.name }}-${{ matrix.os.version }}
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
if: matrix.os.name == 'ubuntu'
run: |
sudo apt-get update -y -qq
sudo apt-get install libsdl2-dev libgtk-3-dev gtksourceview-3.0 libao-dev libopenal-dev
- name: Make
run: make -j4 -C bsnes local=false
- name: Upload
uses: actions/upload-artifact@v4
with:
name: bsnes-${{ matrix.os.name }}
path: bsnes/out/bsnes*
release:
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
# Prevent multiple conflicting release jobs from running at once.
concurrency: release-${{ github.ref == 'refs/heads/master' && 'nightly' || github.ref }}
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
with:
path: 'src'
- name: Download Artifacts
uses: actions/download-artifact@v4.1.7
with:
path: 'bin'
- name: Package Artifacts
run: |
set -eu
case ${GITHUB_REF} in
refs/tags/*) suffix="-${GITHUB_REF#refs/tags/}" ;;
refs/heads/master) suffix="-nightly" ;;
*) suffix="" ;;
esac
srcdir="${GITHUB_WORKSPACE}/src"
bindir="${GITHUB_WORKSPACE}/bin"
# Hack: Workaround for GitHub artifacts losing attributes.
for program in bsnes
do
chmod +x ${bindir}/${program}-ubuntu/${program}
chmod +x ${bindir}/${program}-macos/${program}.app/Contents/MacOS/${program}
done
for os in ubuntu windows macos
do
mkdir "${os}"
cd "${os}"
# Package bsnes.
outdir=bsnes${suffix}
mkdir ${outdir}
mkdir ${outdir}/Database
mkdir ${outdir}/Firmware
cp -ar ${bindir}/bsnes-${os}/* ${outdir}
cp -a ${srcdir}/bsnes/Database/* ${outdir}/Database
cp -a ${srcdir}/shaders ${outdir}/Shaders
cp -a ${srcdir}/GPLv3.txt ${outdir}
cp -a ${srcdir}/extras/* ${outdir}
zip -r ../bsnes-${os}.zip ${outdir}
cd -
done
- name: Calculate release info
id: relinfo
run: |
echo "datetime=$(date -u +"%Y-%m-%d %T %Z")" >> $GITHUB_OUTPUT
echo "date=$(date +"%Y-%m-%d")" >> $GITHUB_OUTPUT
- name: Delete old nightly release
uses: actions/github-script@v7
id: release
if: ${{!startsWith(github.ref, 'refs/tags/')}}
with:
retries: 3
script: |
const {owner, repo} = context.repo;
try {
const release = await github.rest.repos.getReleaseByTag({owner, repo, tag: "nightly"});
if (release && release.status === 200) {
await github.rest.repos.deleteRelease({owner, repo, release_id: release.data.id});
}
} catch (e) {
console.log(`error deleting old release: ${e}`);
}
try {
await github.rest.git.deleteRef({owner, repo, ref: "tags/nightly"});
} catch (e) {
console.log(`error trying to delete ref: ${e}`);
}
await github.rest.git.createTag({
owner,
repo,
tag: "nightly",
message: "nightly release",
object: context.sha,
type: "commit",
})
- name: Create nightly release
uses: softprops/action-gh-release@v1
if: ${{!startsWith(github.ref, 'refs/tags/')}}
with:
tag_name: nightly
name: bsnes nightly ${{steps.relinfo.outputs.date}}
body: Auto-generated nightly release on ${{steps.relinfo.outputs.datetime}}
files: bsnes*.zip
prerelease: true
- name: Create version release
uses: softprops/action-gh-release@v1
if: ${{startsWith(github.ref, 'refs/tags/')}}
with:
name: bsnes ${{github.ref_name}}
body: This is bsnes ${{github.ref_name}}, released on ${{steps.relinfo.outputs.date}}.
files: bsnes*.zip

1
.gitignore vendored
View File

@ -0,0 +1 @@
hiro/qt/qt.moc

View File

@ -1,89 +0,0 @@
Contributing
============
Code contributions are most welcome and highly appreciated!
But first, please note that although bsnes is licensed under the GPLv3 license,
in order to be merged upstream, any code contributions must be provided under
the ISC source code license.
This is *not* a CLA (community license agreement), no legal contract needs to be
signed, and you will maintain full and exclusive copyright ownership over any
contributed source code.
There are two reasons for this requirement:
GPLv4+
------
bsnes is currently licensed under the GPLv3 license only. I do not license bsnes
under the GPLv3 or later license, because there is no way of knowing what the
GPLv4 and later licenses will change, and if they will be in the best interests
of emulator development and video game preservation.
Although I put a good deal of trust into the FSF, no one is an oracle that can
predict the future. Would *you* agree to a license before being able to read it?
However, the GPLv4 may prove beneficial, and close important holes in the GPLv3
license, just as the GPLv3 license closed the GPLv2's TiVoization loophole. And
so it is important that bsnes retains the option of relicensing to the GPLv4+ in
the future.
As a point of interest, there have been projects with similar concerns about
using a GPLv2 or later clause, that are now permanently stuck on the GPLv2
license. There have also been projects that did use a GPLv2 or later clause,
only to disagree with the changes introduced in the GPLv3.
ISC
---
The more important reason for this requirement is that it is my intention to
release the entirety of bsnes under the ISC license once official upstream
development has ceased.
The reason I would want to relicense bsnes to the ISC license upon its official
discontinuation is because once again, no one is an oracle, and I cannot predict
what future issues bsnes permanently remaining under the GPLv3 license may
cause.
For instance, imagine a world where a certain vendor took over the world, and
the only way to distribute applications was with their approval, and their store
rules forbade GPLv3 software. Or perhaps a world where the GPL was abandoned in
favor of the new OSSv1 license. But GPLv3 software was incompatible with the
OSSv1 license. Other open source developers would not be able to use bsnes in
that scenario.
It would be very disappointing if all of our work ended up unusable 50+ years
into the future because it was permanently bound to the GPLv3 license.
GPLv3
-----
The reason I use the GPLv3 license currently is because it is a balance between
altruism and self-interest. The GPLv3 allows other vendors to sell my own code
without sharing revenue with me, and indeed this has already happened. But the
GPLv3 also prevents other vendors from improving upon bsnes without sharing
their work with everyone else as I have.
While I am actively developing bsnes, I do not wish to compete against myself.
As such, I believe the GPLv3 is the best license during active development, and
the ISC is the best license once bsnes is officially discontinued.
Considerations
--------------
This is the part that should concern you as a contributor: I am not requesting
contributed source code to be released under the ISC so that I personally may
sell GPLv3 commercial license exemptions to your work, but in the future when
bsnes is released under the ISC license, that will open the door for anyone to
sell the work commercially in a closed source form.
If this is not acceptable to you, I wholly understand and I welcome you to
release your work under the GPLv3 in the form of a bsnes fork. And if your work
is not an essential part of the core emulation -- that is to say, it may be
optionally disabled -- then I am still willing to work with you in merging such
work upstream anyway under the full GPLv3 license, but please reach out to me
first before developing under the assumption your work will be merged upstream.
Thank you very much for reading and hopefully for your understanding.

View File

@ -1,4 +1,4 @@
bsnes was created and is maintained by byuu (Near), but many people have contributed to the project.
bsnes was originally developed by byuu, and is now a group project.
This software would not be where it is today without the help and support of the following individuals:
@ -6,8 +6,10 @@ This software would not be where it is today without the help and support of the
- Ange Albertini
- anomie
- AWJ
- BearOso
- Bisqwit
- blargg
- byuu
- Łukasz Krawczyk
- Danish
- DerKoun
@ -39,6 +41,7 @@ This software would not be where it is today without the help and support of the
- Overload
- p4plus2
- quequotion
- qwertymodo
- RedDwarf
- Richard Bannister
- Ryphecha
@ -52,4 +55,5 @@ This software would not be where it is today without the help and support of the
- wareya
- zones
If your contributions have been missed here, please reach out [here](https://byuu.org/contact) to have this corrected, thank you!
If you feel you are missing from this list, please submit a pull request and we will be happy to add your name here!

View File

@ -1,14 +1,14 @@
----------------------------------------------------------------------
bsnes - Super Nintendo emulator
Copyright © 2004-2019 byuu
Copyright © 2004-2020 byuu et al
https://byuu.org
https://byuu.org/bsnes/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, specifically version 3 of the License
and no other version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -25,7 +25,7 @@ nall - C++ template library
ruby - Hardware abstraction library
hiro - User interface library
Copyright © 2006-2019 byuu
Copyright © 2006-2020 byuu et al
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the

View File

@ -1,21 +1,11 @@
bsnes
=====
![bsnes logo © byuu](https://byuu.org/images/bsnes/github/byuu-bsnes-logo.png)
![bsnes logo](bsnes/target-bsnes/resource/logo.png)
bsnes is a multi-platform Super Nintendo (Super Famicom) emulator from
[byuu](https://byuu.org/about) that focuses on performance, features, and ease
of use.
Development
-----------
Git is used for the development of new releases, and represents a staging
environment. As bsnes is rather mature, things should generally be quite stable.
However, bugs will exist, regressions will occur, so proceed at your own risk.
If stability is required, please download the latest stable release from the
[official website.](https://byuu.org/bsnes)
bsnes is a multi-platform Super Nintendo (Super Famicom) emulator, originally
developed by Near, which focuses on performance,
features, and ease of use.
Unique Features
---------------
@ -66,27 +56,20 @@ Standard Features
Links
-----
- [Official website](https://byuu.org/bsnes)
- [Official git repository](https://github.com/byuu/bsnes)
- [Donations](https://patreon.com/byuu)
Release Builds
--------------
- [Windows binaries](https://byuu.itch.io/bsnes)
- [Official git repository](https://github.com/bsnes-emu/bsnes)
- [Official Discord](https://discord.gg/B27hf27ZVf)
Nightly Builds
--------------
- [Download](https://cirrus-ci.com/github/byuu/bsnes/master)
- ![Build status](https://api.cirrus-ci.com/github/byuu/bsnes.svg?task=windows-x86_64-binaries)
- ![Build status](https://api.cirrus-ci.com/github/byuu/bsnes.svg?task=macOS-x86_64-binaries)
- ![Build status](https://api.cirrus-ci.com/github/byuu/bsnes.svg?task=linux-x86_64-binaries)
- ![Build status](https://api.cirrus-ci.com/github/byuu/bsnes.svg?task=freebsd-x86_64-binaries)
- [Windows](https://github.com/bsnes-emu/bsnes/releases/download/nightly/bsnes-windows.zip)
- [macOS](https://github.com/bsnes-emu/bsnes/releases/download/nightly/bsnes-macos.zip)
- [Linux](https://github.com/bsnes-emu/bsnes/releases/download/nightly/bsnes-ubuntu.zip)
- [FreeBSD](https://api.cirrus-ci.com/v1/artifact/github/bsnes-emu/bsnes/freebsd-x86_64-binaries/bsnes-nightly/bsnes-nightly.zip)
Preview
-------
![bsnes user interface © byuu](https://byuu.org/images/bsnes/github/byuu-bsnes-user-interface.png)
![bsnes running Bahamut Lagoon © byuu](https://byuu.org/images/bsnes/github/byuu-bsnes-bahamut-lagoon.png)
![bsnes running Tengai Makyou Zero © byuu](https://byuu.org/images/bsnes/github/byuu-bsnes-tengai-makyou-zero.png)
![bsnes user interface](.assets/user-interface.png)
![bsnes running Bahamut Lagoon](.assets/bahamut-lagoon.png)
![bsnes running Tengai Makyou Zero](.assets/tengai-makyou-zero.png)

View File

@ -1,5 +1,5 @@
database
revision: 2020-01-01
revision: 2020-01-21
//Prototypes (JPN)
@ -125,7 +125,7 @@ game
//Super Famicom (JPN)
database
revision: 2020-01-01
revision: 2020-01-21
game
sha256: 5c4e283efc338958b8dd45ebd6daf133a9eb280420a98e2e1df358ae0242c366
@ -171,6 +171,22 @@ game
size: 0x8000
content: Save
game
sha256: a98eb5f0521746e6ce6d208591e86d366b6e0479d96474bfff43856fe8cfec12
label: バハムートラグーン
name: Bahamut Lagoon
region: SHVC-AXBJ-JPN
revision: SHVC-AXBJ-0
board: SHVC-1J3M-20
memory
type: ROM
size: 0x300000
content: Program
memory
type: RAM
size: 0x2000
content: Save
game
sha256: 47779500c43a0c2e75d7684078489a17baea31170a123063b8ece6ce77359413
label: ボール・ブレット・ガン
@ -1465,6 +1481,22 @@ game
size: 0x2000
content: Save
game
sha256: 77b2d5450ce3c87185f913c2584673530c13dfbe8cc433b1e9fe5e9a653bf7d5
label: テイルズオブファンタジア
name: Tales of Phantasia
region: SHVC-ATVJ-JPN
revision: SHVC-ATVJ-0
board: SHVC-LJ3M-01
memory
type: ROM
size: 0x600000
content: Program
memory
type: RAM
size: 0x2000
content: Save
game
sha256: c9002e77bcc656e033c35e2574ee6067c4c0d070943359a850806c123a558949
label: 戦え原始人3 主役はやっぱりジョーアンドマック

53
bsnes/README.md Normal file
View File

@ -0,0 +1,53 @@
bsnes source code
=================
A guide to what all these directories are for:
- [Database](./Database/)
contains the databases bsnes uses
to figure out what circuit board a game expects,
and also the database of pre-made game cheats
- [emulator](./emulator/)
contains the interface
that the emulation core in [sfc](./sfc/) implements
- It comes from higan v106,
which has many emulation cores
that all implement the same interface —
bsnes only has one,
but the interface is still a good abstraction,
so it's still here.
- [filter](./filter/)
contains classic CPU-based image upscaling filters,
like HQ2x and Super Eagle
- [gb](./gb/)
contains the SameBoy emulator code
used for Super Game Boy emulation
- [heuristics](./heuristics/)
contains the logic that guesses
which memory map a particular game expects
and what extra hardware it assumes is present,
when a game cannot be found in the database
- [Locale](./Locale/)
contains translation databases
that bsnes can use to display its user interface
in a different language
- [lzma](./lzma/)
contains the 7-Zip SDK
allowing bsnes to understad `.7z` archives
- [processor](./processor/)
contains all the CPU emulation cores
used by the hardware bsnes emulates
- Another holdover from higan v106,
where different supported systems
happen to use the same model CPU,
so the CPU emulation cores
are not specific to a system
- [sfc](./sfc/)
contains Super Famicom (SNES) emulation code
- [target-bsnes](./target-bsnes/)
contains the normal bsnes user interface
- [target-libretro](./target-libretro/)
implements the "libretro" API
on top of bsnes' native
[emulator](./emulator/) API,
so bsnes can be used with libretro-based frontends

View File

@ -30,9 +30,9 @@ using namespace nall;
namespace Emulator {
static const string Name = "bsnes";
static const string Version = "115";
static const string Copyright = "byuu";
static const string License = "GPLv3";
static const string Website = "https://byuu.org";
static const string Copyright = "bsnes team";
static const string License = "GPLv3 or later";
static const string Website = "https://bsnes.dev";
//incremented only when serialization format changes
static const string SerializerVersion = "115";

10
bsnes/gb/.gitattributes vendored Normal file
View File

@ -0,0 +1,10 @@
# Always use LF line endings for shaders
*.fsh text eol=lf
*.metal text eol=lf
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
bsnes/gb/.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
bsnes/gb/.github/actions/cgb-acid2.gbc vendored Normal file

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

23
bsnes/gb/.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
bsnes/gb/.github/actions/oam_bug-2.gb vendored Executable file

Binary file not shown.

33
bsnes/gb/.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
bsnes/gb/.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

1
bsnes/gb/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build

217
bsnes/gb/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.
* Sprite 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -0,0 +1,177 @@
; SameBoy DMG 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
ld a, $54
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
ld a, 30
ldh [$ff42], a
; Turn on LCD
ld a, $91
ldh [$40], a
ld d, (-119) & $FF
ld c, 15
.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
ld a, $83
call PlaySound
ld b, 5
call WaitBFrames
; Play second sound
ld a, $c1
call PlaySound
; Wait ~1 second
ld b, 60
call WaitBFrames
; Set registers to match the original DMG boot
ld hl, $01B0
push hl
pop af
ld hl, $014D
ld bc, $0013
ld de, $00D8
; Boot the game
jp BootGame
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
WaitBFrames:
call WaitFrame
dec b
jr nz, WaitBFrames
ret
PlaySound:
ldh [$13], a
ld a, $87
ldh [$14], a
ret
TrademarkSymbol:
db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c
SECTION "BootGame", ROM0[$fe]
BootGame:
ldh [$50], a

102
bsnes/gb/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;
}

View File

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

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

1
bsnes/gb/CHANGES.md Normal file
View File

@ -0,0 +1 @@
See https://sameboy.github.io/changelog/

79
bsnes/gb/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

@ -0,0 +1,25 @@
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface AppDelegate : NSObject <NSApplicationDelegate, NSUserNotificationCenterDelegate, NSMenuDelegate, WebUIDelegate, WebPolicyDelegate, WebFrameLoadDelegate>
@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)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

View File

@ -0,0 +1,449 @@
#import "AppDelegate.h"
#include "GBButtons.h"
#include "GBView.h"
#include <Core/gb.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
{
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
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
for (unsigned i = 0; i < GBButtonCount; i++) {
if ([[defaults objectForKey:button_to_preference_name(i, 0)] isKindOfClass:[NSString class]]) {
[defaults removeObjectForKey:button_to_preference_name(i, 0)];
}
}
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
@"GBRight": @(kVK_RightArrow),
@"GBLeft": @(kVK_LeftArrow),
@"GBUp": @(kVK_UpArrow),
@"GBDown": @(kVK_DownArrow),
@"GBA": @(kVK_ANSI_X),
@"GBB": @(kVK_ANSI_Z),
@"GBSelect": @(kVK_Delete),
@"GBStart": @(kVK_Return),
@"GBTurbo": @(kVK_Space),
@"GBRewind": @(kVK_Tab),
@"GBSlow-Motion": @(kVK_Shift),
@"GBFilter": @"NearestNeighbor",
@"GBColorCorrection": @(GB_COLOR_CORRECTION_EMULATE_HARDWARE),
@"GBHighpassFilter": @(GB_HIGHPASS_REMOVE_DC_OFFSET),
@"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),
}];
[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
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[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
{
if ([anItem action] == @selector(toggleDeveloperMode:)) {
[(NSMenuItem *)anItem setState:[[NSUserDefaults standardUserDefaults] boolForKey:@"DeveloperMode"]];
}
if (anItem == self.linkCableMenuItem) {
return [[NSDocumentController sharedDocumentController] documents].count > 1;
}
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
{
NSArray *objects;
if (!_preferencesWindow) {
[[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];
}
- (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];
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];
});
}
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

BIN
bsnes/gb/Cocoa/AppIcon.icns Normal file

Binary file not shown.

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

BIN
bsnes/gb/Cocoa/CPU.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
bsnes/gb/Cocoa/CPU@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Binary file not shown.

BIN
bsnes/gb/Cocoa/Display.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

61
bsnes/gb/Cocoa/Document.h Normal file
View File

@ -0,0 +1,61 @@
#import <Cocoa/Cocoa.h>
#include "GBView.h"
#include "GBImageView.h"
#include "GBSplitView.h"
#include "GBVisualizerView.h"
#include "GBOSDView.h"
@class GBCheatWindowController;
@interface Document : NSDocument <NSWindowDelegate, GBImageViewDelegate, NSTableViewDataSource, NSTableViewDelegate, NSSplitViewDelegate>
@property (nonatomic, readonly) GB_gameboy_t *gb;
@property (nonatomic, strong) IBOutlet GBView *view;
@property (nonatomic, strong) IBOutlet NSTextView *consoleOutput;
@property (nonatomic, strong) IBOutlet NSPanel *consoleWindow;
@property (nonatomic, strong) IBOutlet NSTextField *consoleInput;
@property (nonatomic, strong) IBOutlet NSWindow *mainWindow;
@property (nonatomic, strong) IBOutlet NSView *memoryView;
@property (nonatomic, strong) IBOutlet NSPanel *memoryWindow;
@property (nonatomic, readonly) GB_gameboy_t *gameboy;
@property (nonatomic, strong) IBOutlet NSTextField *memoryBankInput;
@property (nonatomic, strong) IBOutlet NSToolbarItem *memoryBankItem;
@property (nonatomic, strong) IBOutlet GBImageView *tilesetImageView;
@property (nonatomic, strong) IBOutlet NSPopUpButton *tilesetPaletteButton;
@property (nonatomic, strong) IBOutlet GBImageView *tilemapImageView;
@property (nonatomic, strong) IBOutlet NSPopUpButton *tilemapPaletteButton;
@property (nonatomic, strong) IBOutlet NSPopUpButton *tilemapMapButton;
@property (nonatomic, strong) IBOutlet NSPopUpButton *TilemapSetButton;
@property (nonatomic, strong) IBOutlet NSButton *gridButton;
@property (nonatomic, strong) IBOutlet NSTabView *vramTabView;
@property (nonatomic, strong) IBOutlet NSPanel *vramWindow;
@property (nonatomic, strong) IBOutlet NSTextField *vramStatusLabel;
@property (nonatomic, strong) IBOutlet NSTableView *paletteTableView;
@property (nonatomic, strong) IBOutlet NSTableView *spritesTableView;
@property (nonatomic, strong) IBOutlet NSPanel *printerFeedWindow;
@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;
-(void) writeMemory:(uint16_t) addr value:(uint8_t)value;
-(void) performAtomicBlock: (void (^)())block;
-(void) connectLinkCable:(NSMenuItem *)sender;
-(int)loadStateFile:(const char *)path noErrorOnNotFound:(bool)noErrorOnFileNotFound;
@end

2315
bsnes/gb/Cocoa/Document.m Normal file

File diff suppressed because it is too large Load Diff

1088
bsnes/gb/Cocoa/Document.xib Normal file

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -0,0 +1,111 @@
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import "GBAudioClient.h"
static OSStatus render(
GBAudioClient *self,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData)
{
GB_sample_t *buffer = (GB_sample_t *)ioData->mBuffers[0].mData;
self.renderBlock(self.rate, inNumberFrames, buffer);
return noErr;
}
@implementation GBAudioClient
{
AudioComponentInstance audioUnit;
}
-(id) initWithRendererBlock:(void (^)(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer)) block
andSampleRate:(UInt32) rate
{
if (!(self = [super init])) {
return nil;
}
// Configure the search parameters to find the default playback output unit
// (called the kAudioUnitSubType_RemoteIO on iOS but
// kAudioUnitSubType_DefaultOutput on Mac OS X)
AudioComponentDescription defaultOutputDescription;
defaultOutputDescription.componentType = kAudioUnitType_Output;
defaultOutputDescription.componentSubType = kAudioUnitSubType_DefaultOutput;
defaultOutputDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
defaultOutputDescription.componentFlags = 0;
defaultOutputDescription.componentFlagsMask = 0;
// Get the default playback output unit
AudioComponent defaultOutput = AudioComponentFindNext(NULL, &defaultOutputDescription);
NSAssert(defaultOutput, @"Can't find default output");
// Create a new unit based on this that we'll use for output
OSErr err = AudioComponentInstanceNew(defaultOutput, &audioUnit);
NSAssert1(audioUnit, @"Error creating unit: %hd", err);
// Set our tone rendering function on the unit
AURenderCallbackStruct input;
input.inputProc = (void*)render;
input.inputProcRefCon = (__bridge void * _Nullable)(self);
err = AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input,
0,
&input,
sizeof(input));
NSAssert1(err == noErr, @"Error setting callback: %hd", err);
AudioStreamBasicDescription streamFormat;
streamFormat.mSampleRate = rate;
streamFormat.mFormatID = kAudioFormatLinearPCM;
streamFormat.mFormatFlags =
kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked | kAudioFormatFlagsNativeEndian;
streamFormat.mBytesPerPacket = 4;
streamFormat.mFramesPerPacket = 1;
streamFormat.mBytesPerFrame = 4;
streamFormat.mChannelsPerFrame = 2;
streamFormat.mBitsPerChannel = 2 * 8;
err = AudioUnitSetProperty (audioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
0,
&streamFormat,
sizeof(AudioStreamBasicDescription));
NSAssert1(err == noErr, @"Error setting stream format: %hd", err);
err = AudioUnitInitialize(audioUnit);
NSAssert1(err == noErr, @"Error initializing unit: %hd", err);
self.renderBlock = block;
_rate = rate;
return self;
}
-(void) start
{
OSErr err = AudioOutputUnitStart(audioUnit);
NSAssert1(err == noErr, @"Error starting unit: %hd", err);
_playing = true;
}
-(void) stop
{
AudioOutputUnitStop(audioUnit);
_playing = false;
}
-(void) dealloc
{
[self stop];
AudioUnitUninitialize(audioUnit);
AudioComponentInstanceDispose(audioUnit);
}
@end

View File

@ -0,0 +1,5 @@
#import <Cocoa/Cocoa.h>
@interface GBBorderView : NSView
@end

View File

@ -0,0 +1,26 @@
#import "GBBorderView.h"
@implementation GBBorderView
- (void)awakeFromNib
{
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

View File

@ -0,0 +1,35 @@
#ifndef GBButtons_h
#define GBButtons_h
typedef enum : NSUInteger {
GBRight,
GBLeft,
GBUp,
GBDown,
GBA,
GBB,
GBSelect,
GBStart,
GBTurbo,
GBRewind,
GBUnderclock,
GBButtonCount,
GBGameBoyButtonCount = GBStart + 1,
} GBButton;
extern NSString const *GBButtonNames[GBButtonCount];
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]];
}
#endif

View File

@ -0,0 +1,4 @@
#import <Foundation/Foundation.h>
#import "GBButtons.h"
NSString const *GBButtonNames[] = {@"Right", @"Left", @"Up", @"Down", @"A", @"B", @"Select", @"Start", @"Turbo", @"Rewind", @"Slow-Motion"};

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

@ -0,0 +1,5 @@
#import <Cocoa/Cocoa.h>
@interface GBColorCell : NSTextFieldCell
@end

View File

@ -0,0 +1,49 @@
#import "GBColorCell.h"
static inline double scale_channel(uint8_t x)
{
x &= 0x1f;
return x / 31.0;
}
@implementation GBColorCell
{
NSInteger _integerValue;
}
- (void)setObjectValue:(id)objectValue
{
_integerValue = [objectValue integerValue];
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
{
return _integerValue;
}
- (int)intValue
{
return (int)_integerValue;
}
- (NSColor *) backgroundColor
{
/* Todo: color correction */
uint16_t color = self.integerValue;
return [NSColor colorWithRed:scale_channel(color) green:scale_channel(color >> 5) blue:scale_channel(color >> 10) alpha:1.0];
}
- (BOOL)drawsBackground
{
return true;
}
@end

View File

@ -0,0 +1,7 @@
#import "Document.h"
#import "HexFiend/HexFiend.h"
#import "HexFiend/HFByteSlice.h"
@interface GBCompleteByteSlice : HFByteSlice
- (instancetype) initWithByteArray:(HFByteArray *)array;
@end

View File

@ -0,0 +1,26 @@
#import "GBCompleteByteSlice.h"
@implementation GBCompleteByteSlice
{
HFByteArray *_array;
}
- (instancetype) initWithByteArray:(HFByteArray *)array
{
if ((self = [super init])) {
_array = array;
}
return self;
}
- (unsigned long long)length
{
return [_array length];
}
- (void)copyBytes:(unsigned char *)dst range:(HFRange)range
{
[_array copyBytes:dst range:range];
}
@end

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

190
bsnes/gb/Cocoa/GBGLShader.m Normal file
View File

@ -0,0 +1,190 @@
#import "GBGLShader.h"
#import <OpenGL/gl3.h>
/*
Loosely based of https://www.raywenderlich.com/70208/opengl-es-pixel-shaders-tutorial
This code probably makes no sense after I upgraded it to OpenGL 3, since OpenGL makes aboslute no sense and has zero
helpful documentation.
*/
static NSString * const vertex_shader = @"\n\
#version 150 \n\
in vec4 aPosition;\n\
void main(void) {\n\
gl_Position = aPosition;\n\
}\n\
";
@implementation GBGLShader
{
GLuint resolution_uniform;
GLuint texture_uniform;
GLuint previous_texture_uniform;
GLuint frame_blending_mode_uniform;
GLuint position_attribute;
GLuint texture;
GLuint previous_texture;
GLuint program;
}
+ (NSString *) shaderSourceForName:(NSString *) name
{
return [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:name
ofType:@"fsh"
inDirectory:@"Shaders"]
encoding:NSUTF8StringEncoding
error:nil];
}
- (instancetype)initWithName:(NSString *) shaderName
{
self = [super init];
if (self) {
// Program
NSString *fragment_shader = [[self class] shaderSourceForName:@"MasterShader"];
fragment_shader = [fragment_shader stringByReplacingOccurrencesOfString:@"{filter}"
withString:[[self class] shaderSourceForName:shaderName]];
program = [[self class] programWithVertexShader:vertex_shader fragmentShader:fragment_shader];
// Attributes
position_attribute = glGetAttribLocation(program, "aPosition");
// Uniforms
resolution_uniform = glGetUniformLocation(program, "output_resolution");
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
texture_uniform = glGetUniformLocation(program, "image");
glGenTextures(1, &previous_texture);
glBindTexture(GL_TEXTURE_2D, previous_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
previous_texture_uniform = glGetUniformLocation(program, "previous_image");
frame_blending_mode_uniform = glGetUniformLocation(program, "frame_blending_mode");
// Configure OpenGL
[self configureOpenGL];
}
return self;
}
- (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);
glUniform2f(resolution_uniform, dstSize.width * scale, dstSize.height * scale);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, srcSize.width, srcSize.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap);
glUniform1i(texture_uniform, 0);
glUniform1i(frame_blending_mode_uniform, blendingMode);
if (blendingMode) {
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, previous_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, srcSize.width, srcSize.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, previous);
glUniform1i(previous_texture_uniform, 1);
}
glBindFragDataLocation(program, 0, "frag_color");
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
- (void)configureOpenGL
{
// Program
glUseProgram(program);
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
GLuint vbo;
glGenBuffers(1, &vbo);
// Attributes
static GLfloat const quad[16] = {
-1.f, -1.f, 0, 1,
-1.f, +1.f, 0, 1,
+1.f, -1.f, 0, 1,
+1.f, +1.f, 0, 1,
};
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STATIC_DRAW);
glEnableVertexAttribArray(position_attribute);
glVertexAttribPointer(position_attribute, 4, GL_FLOAT, GL_FALSE, 0, 0);
}
+ (GLuint)programWithVertexShader:(NSString*)vsh fragmentShader:(NSString*)fsh
{
// Build shaders
GLuint vertex_shader = [self shaderWithContents:vsh type:GL_VERTEX_SHADER];
GLuint fragment_shader = [self shaderWithContents:fsh type:GL_FRAGMENT_SHADER];
// Create program
GLuint program = glCreateProgram();
// Attach shaders
glAttachShader(program, vertex_shader);
glAttachShader(program, fragment_shader);
// Link program
glLinkProgram(program);
// Check for errors
GLint status;
glGetProgramiv(program, GL_LINK_STATUS, &status);
if (status == GL_FALSE) {
GLchar messages[1024];
glGetProgramInfoLog(program, sizeof(messages), 0, &messages[0]);
NSLog(@"%@:- GLSL Program Error: %s", self, messages);
}
// Delete shaders
glDeleteShader(vertex_shader);
glDeleteShader(fragment_shader);
return program;
}
- (void)dealloc
{
glDeleteProgram(program);
glDeleteTextures(1, &texture);
glDeleteTextures(1, &previous_texture);
/* OpenGL is black magic. Closing one view causes others to be completely black unless we reload their shaders */
/* We're probably not freeing thing in the right place. */
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBFilterChanged" object:nil];
}
+ (GLuint)shaderWithContents:(NSString*)contents type:(GLenum)type
{
const GLchar *source = [contents UTF8String];
// Create the shader object
GLuint shader = glCreateShader(type);
// Load the shader source
glShaderSource(shader, 1, &source, 0);
// Compile the shader
glCompileShader(shader);
// Check for errors
GLint status = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE) {
GLchar messages[1024];
glGetShaderInfoLog(shader, sizeof(messages), 0, &messages[0]);
NSLog(@"%@:- GLSL Shader Error: %s", self, messages);
}
return shader;
}
@end

View File

@ -0,0 +1,5 @@
#import <Cocoa/Cocoa.h>
@interface GBImageCell : NSImageCell
@end

View File

@ -0,0 +1,10 @@
#import "GBImageCell.h"
@implementation GBImageCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetInterpolationQuality(context, kCGInterpolationNone);
[super drawWithFrame:cellFrame inView:controlView];
}
@end

View File

@ -0,0 +1,23 @@
#import <Cocoa/Cocoa.h>
@protocol GBImageViewDelegate;
@interface GBImageViewGridConfiguration : NSObject
@property (nonatomic, strong) NSColor *color;
@property (nonatomic) NSUInteger size;
- (instancetype) initWithColor: (NSColor *) color size: (NSUInteger) size;
@end
@interface GBImageView : NSImageView
@property (nonatomic, strong) NSArray<GBImageViewGridConfiguration *> *horizontalGrids;
@property (nonatomic, strong) NSArray<GBImageViewGridConfiguration *> *verticalGrids;
@property (nonatomic) bool displayScrollRect;
@property NSRect scrollRect;
@property (nonatomic, weak) IBOutlet id<GBImageViewDelegate> delegate;
@end
@protocol GBImageViewDelegate <NSObject>
@optional
- (void) mouseDidLeaveImageView: (GBImageView *)view;
- (void) imageView: (GBImageView *)view mouseMovedToX:(NSUInteger) x Y:(NSUInteger) y;
@end

View File

@ -0,0 +1,127 @@
#import "GBImageView.h"
@implementation GBImageViewGridConfiguration
- (instancetype)initWithColor:(NSColor *)color size:(NSUInteger)size
{
self = [super init];
self.color = color;
self.size = size;
return self;
}
@end
@implementation GBImageView
{
NSTrackingArea *trackingArea;
}
- (void)drawRect:(NSRect)dirtyRect
{
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetInterpolationQuality(context, kCGInterpolationNone);
[super drawRect:dirtyRect];
CGFloat y_ratio = self.frame.size.height / self.image.size.height;
CGFloat x_ratio = self.frame.size.width / self.image.size.width;
for (GBImageViewGridConfiguration *conf in self.verticalGrids) {
[conf.color set];
for (CGFloat y = conf.size * y_ratio; y < self.frame.size.height; y += conf.size * y_ratio) {
NSBezierPath *line = [NSBezierPath bezierPath];
[line moveToPoint:NSMakePoint(0, y - 0.5)];
[line lineToPoint:NSMakePoint(self.frame.size.width, y - 0.5)];
[line setLineWidth:1.0];
[line stroke];
}
}
for (GBImageViewGridConfiguration *conf in self.horizontalGrids) {
[conf.color set];
for (CGFloat x = conf.size * x_ratio; x < self.frame.size.width; x += conf.size * x_ratio) {
NSBezierPath *line = [NSBezierPath bezierPath];
[line moveToPoint:NSMakePoint(x + 0.5, 0)];
[line lineToPoint:NSMakePoint(x + 0.5, self.frame.size.height)];
[line setLineWidth:1.0];
[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
{
self->_horizontalGrids = horizontalGrids;
[self setNeedsDisplay];
}
- (void)setVerticalGrids:(NSArray *)verticalGrids
{
self->_verticalGrids = verticalGrids;
[self setNeedsDisplay];
}
- (void)setDisplayScrollRect:(bool)displayScrollRect
{
self->_displayScrollRect = displayScrollRect;
[self setNeedsDisplay];
}
- (void)updateTrackingAreas
{
if (trackingArea != nil) {
[self removeTrackingArea:trackingArea];
}
trackingArea = [ [NSTrackingArea alloc] initWithRect:[self bounds]
options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingMouseMoved
owner:self
userInfo:nil];
[self addTrackingArea:trackingArea];
}
- (void)mouseExited:(NSEvent *)theEvent
{
if ([self.delegate respondsToSelector:@selector(mouseDidLeaveImageView:)]) {
[self.delegate mouseDidLeaveImageView:self];
}
}
- (void)mouseMoved:(NSEvent *)theEvent
{
if ([self.delegate respondsToSelector:@selector(imageView:mouseMovedToX:Y:)]) {
NSPoint location = [self convertPoint:theEvent.locationInWindow fromView:nil];
location.x /= self.bounds.size.width;
location.y /= self.bounds.size.height;
location.y = 1 - location.y;
location.x *= self.image.size.width;
location.y *= self.image.size.height;
[self.delegate imageView:self mouseMovedToX:(NSUInteger)location.x Y:(NSUInteger)location.y];
}
}
@end

View File

@ -0,0 +1,17 @@
#import "Document.h"
#import "HexFiend/HexFiend.h"
#import "HexFiend/HFByteArray.h"
typedef enum {
GBMemoryEntireSpace,
GBMemoryROM,
GBMemoryVRAM,
GBMemoryExternalRAM,
GBMemoryRAM
} GB_memory_mode_t;
@interface GBMemoryByteArray : HFByteArray
- (instancetype) initWithDocument:(Document *)document;
@property (nonatomic) uint16_t selectedBank;
@property (nonatomic) GB_memory_mode_t mode;
@end

View File

@ -0,0 +1,177 @@
#define GB_INTERNAL // Todo: Some memory accesses are being done using the struct directly
#import "GBMemoryByteArray.h"
#import "GBCompleteByteSlice.h"
@implementation GBMemoryByteArray
{
Document *_document;
}
- (instancetype) initWithDocument:(Document *)document
{
if ((self = [super init])) {
_document = document;
}
return self;
}
- (unsigned long long)length
{
switch (_mode) {
case GBMemoryEntireSpace:
return 0x10000;
case GBMemoryROM:
return 0x8000;
case GBMemoryVRAM:
return 0x2000;
case GBMemoryExternalRAM:
return 0x2000;
case GBMemoryRAM:
return 0x2000;
}
}
- (void)copyBytes:(unsigned char *)dst range:(HFRange)range
{
__block uint16_t addr = (uint16_t) range.location;
__block unsigned long long length = range.length;
if (_mode == GBMemoryEntireSpace) {
while (length) {
*(dst++) = [_document readMemory:addr++];
length--;
}
}
else {
[_document performAtomicBlock:^{
unsigned char *_dst = dst;
uint16_t bank_backup = 0;
GB_gameboy_t *gb = _document.gameboy;
switch (_mode) {
case GBMemoryROM:
bank_backup = gb->mbc_rom_bank;
gb->mbc_rom_bank = self.selectedBank;
break;
case GBMemoryVRAM:
bank_backup = gb->cgb_vram_bank;
if (GB_is_cgb(gb)) {
gb->cgb_vram_bank = self.selectedBank;
}
addr += 0x8000;
break;
case GBMemoryExternalRAM:
bank_backup = gb->mbc_ram_bank;
gb->mbc_ram_bank = self.selectedBank;
addr += 0xA000;
break;
case GBMemoryRAM:
bank_backup = gb->cgb_ram_bank;
if (GB_is_cgb(gb)) {
gb->cgb_ram_bank = self.selectedBank;
}
addr += 0xC000;
break;
default:
assert(false);
}
while (length) {
*(_dst++) = [_document readMemory:addr++];
length--;
}
switch (_mode) {
case GBMemoryROM:
gb->mbc_rom_bank = bank_backup;
break;
case GBMemoryVRAM:
gb->cgb_vram_bank = bank_backup;
break;
case GBMemoryExternalRAM:
gb->mbc_ram_bank = bank_backup;
break;
case GBMemoryRAM:
gb->cgb_ram_bank = bank_backup;
break;
default:
assert(false);
}
}];
}
}
- (NSArray *)byteSlices
{
return @[[[GBCompleteByteSlice alloc] initWithByteArray:self]];
}
- (HFByteArray *)subarrayWithRange:(HFRange)range
{
unsigned char arr[range.length];
[self copyBytes:arr range:range];
HFByteArray *ret = [[HFBTreeByteArray alloc] init];
HFFullMemoryByteSlice *slice = [[HFFullMemoryByteSlice alloc] initWithData:[NSData dataWithBytes:arr length:range.length]];
[ret insertByteSlice:slice inRange:HFRangeMake(0, 0)];
return ret;
}
- (void)insertByteSlice:(HFByteSlice *)slice inRange:(HFRange)lrange
{
if (slice.length != lrange.length) return; /* Insertion is not allowed, only overwriting. */
[_document performAtomicBlock:^{
uint16_t addr = (uint16_t) lrange.location;
uint16_t bank_backup = 0;
GB_gameboy_t *gb = _document.gameboy;
switch (_mode) {
case GBMemoryROM:
bank_backup = gb->mbc_rom_bank;
gb->mbc_rom_bank = self.selectedBank;
break;
case GBMemoryVRAM:
bank_backup = gb->cgb_vram_bank;
if (GB_is_cgb(gb)) {
gb->cgb_vram_bank = self.selectedBank;
}
addr += 0x8000;
break;
case GBMemoryExternalRAM:
bank_backup = gb->mbc_ram_bank;
gb->mbc_ram_bank = self.selectedBank;
addr += 0xA000;
break;
case GBMemoryRAM:
bank_backup = gb->cgb_ram_bank;
if (GB_is_cgb(gb)) {
gb->cgb_ram_bank = self.selectedBank;
}
addr += 0xC000;
break;
default:
break;
}
uint8_t values[lrange.length];
[slice copyBytes:values range:HFRangeMake(0, lrange.length)];
uint8_t *src = values;
unsigned long long length = lrange.length;
while (length) {
[_document writeMemory:addr++ value:*(src++)];
length--;
}
switch (_mode) {
case GBMemoryROM:
gb->mbc_rom_bank = bank_backup;
break;
case GBMemoryVRAM:
gb->cgb_vram_bank = bank_backup;
break;
case GBMemoryExternalRAM:
gb->mbc_ram_bank = bank_backup;
break;
case GBMemoryRAM:
gb->cgb_ram_bank = bank_backup;
break;
default:
break;
}
}];
}
@end

View File

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

104
bsnes/gb/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

View File

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

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,32 @@
#import <Cocoa/Cocoa.h>
#import <JoyKit/JoyKit.h>
@interface GBPreferencesWindow : NSWindow <NSTableViewDelegate, NSTableViewDataSource, JOYListener>
@property (nonatomic, strong) IBOutlet NSTableView *controlsTableView;
@property (nonatomic, strong) IBOutlet NSPopUpButton *graphicsFilterPopupButton;
@property (nonatomic, strong) IBOutlet NSButton *analogControlsCheckbox;
@property (nonatomic, strong) IBOutlet NSButton *aspectRatioCheckbox;
@property (nonatomic, strong) IBOutlet NSPopUpButton *highpassFilterPopupButton;
@property (nonatomic, strong) IBOutlet NSPopUpButton *colorCorrectionPopupButton;
@property (nonatomic, strong) IBOutlet NSPopUpButton *frameBlendingModePopupButton;
@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;
@end

View File

@ -0,0 +1,794 @@
#import "GBPreferencesWindow.h"
#import "NSString+StringForKey.h"
#import "GBButtons.h"
#import "BigSurToolbar.h"
#import "GBViewMetal.h"
#import <Carbon/Carbon.h>
@implementation GBPreferencesWindow
{
bool is_button_being_modified;
NSInteger button_being_modified;
signed joystick_configuration_state;
NSString *joystick_being_configured;
bool joypad_wait;
NSPopUpButton *_graphicsFilterPopupButton;
NSPopUpButton *_highpassFilterPopupButton;
NSPopUpButton *_colorCorrectionPopupButton;
NSPopUpButton *_frameBlendingModePopupButton;
NSPopUpButton *_colorPalettePopupButton;
NSPopUpButton *_displayBorderPopupButton;
NSPopUpButton *_rewindPopupButton;
NSPopUpButton *_rtcPopupButton;
NSButton *_aspectRatioCheckbox;
NSButton *_analogControlsCheckbox;
NSEventModifierFlags previousModifiers;
NSPopUpButton *_dmgPopupButton, *_sgbPopupButton, *_cgbPopupButton;
NSPopUpButton *_preferredJoypadButton;
NSPopUpButton *_rumbleModePopupButton;
NSSlider *_temperatureSlider;
NSSlider *_interferenceSlider;
NSSlider *_volumeSlider;
NSButton *_autoUpdatesCheckbox;
NSButton *_OSDCheckbox;
NSButton *_screenshotFilterCheckbox;
}
+ (NSArray *)filterList
{
/* The filter list as ordered in the popup button */
static NSArray * filters = nil;
if (!filters) {
filters = @[
@"NearestNeighbor",
@"Bilinear",
@"SmoothBilinear",
@"MonoLCD",
@"LCD",
@"CRT",
@"Scale2x",
@"Scale4x",
@"AAScale2x",
@"AAScale4x",
@"HQ2x",
@"OmniScale",
@"OmniScaleLegacy",
@"AAOmniScaleLegacy",
];
}
return filters;
}
- (NSWindowToolbarStyle)toolbarStyle
{
return NSWindowToolbarStylePreference;
}
- (void)close
{
joystick_configuration_state = -1;
[self.configureJoypadButton setEnabled:true];
[self.skipButton setEnabled:false];
[self.configureJoypadButton setTitle:@"Configure Controller"];
[super close];
}
- (NSPopUpButton *)graphicsFilterPopupButton
{
return _graphicsFilterPopupButton;
}
- (void)setGraphicsFilterPopupButton:(NSPopUpButton *)graphicsFilterPopupButton
{
_graphicsFilterPopupButton = graphicsFilterPopupButton;
NSString *filter = [[NSUserDefaults standardUserDefaults] objectForKey:@"GBFilter"];
[_graphicsFilterPopupButton selectItemAtIndex:[[[self class] filterList] indexOfObject:filter]];
}
- (NSPopUpButton *)highpassFilterPopupButton
{
return _highpassFilterPopupButton;
}
- (void)setColorCorrectionPopupButton:(NSPopUpButton *)colorCorrectionPopupButton
{
_colorCorrectionPopupButton = colorCorrectionPopupButton;
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBColorCorrection"];
[_colorCorrectionPopupButton selectItemAtIndex:mode];
}
- (NSPopUpButton *)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;
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBColorPalette"];
[_colorPalettePopupButton selectItemAtIndex:mode];
}
- (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
{
_rewindPopupButton = rewindPopupButton;
NSInteger length = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBRewindLength"];
[_rewindPopupButton selectItemWithTag:length];
}
- (NSPopUpButton *)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
{
_highpassFilterPopupButton = highpassFilterPopupButton;
[_highpassFilterPopupButton selectItemAtIndex:[[[NSUserDefaults standardUserDefaults] objectForKey:@"GBHighpassFilter"] unsignedIntegerValue]];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
if (self.playerListButton.selectedTag == 0) {
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
{
if ([tableColumn.identifier isEqualToString:@"keyName"]) {
return GBButtonNames[row];
}
if (is_button_being_modified && button_being_modified == row) {
return @"Select a new key...";
}
NSNumber *key = [[NSUserDefaults standardUserDefaults] valueForKey:button_to_preference_name(row, self.playerListButton.selectedTag)];
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
{
dispatch_async(dispatch_get_main_queue(), ^{
is_button_being_modified = true;
button_being_modified = row;
tableView.enabled = false;
self.playerListButton.enabled = false;
[tableView reloadData];
[self makeFirstResponder:self];
});
return false;
}
-(void)keyDown:(NSEvent *)theEvent
{
if (!is_button_being_modified) {
if (self.firstResponder != self.controlsTableView && [theEvent type] != NSEventTypeFlagsChanged) {
[super keyDown:theEvent];
}
return;
}
is_button_being_modified = false;
[[NSUserDefaults standardUserDefaults] setInteger:theEvent.keyCode
forKey:button_to_preference_name(button_being_modified, self.playerListButton.selectedTag)];
self.controlsTableView.enabled = true;
self.playerListButton.enabled = true;
[self.controlsTableView reloadData];
[self makeFirstResponder:self.controlsTableView];
}
- (void) flagsChanged:(NSEvent *)event
{
if (event.modifierFlags > previousModifiers) {
[self keyDown:event];
}
previousModifiers = event.modifierFlags;
}
- (IBAction)graphicFilterChanged:(NSPopUpButton *)sender
{
[[NSUserDefaults standardUserDefaults] setObject:[[self class] filterList][[sender indexOfSelectedItem]]
forKey:@"GBFilter"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBFilterChanged" object:nil];
}
- (IBAction)highpassFilterChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem])
forKey:@"GBHighpassFilter"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBHighpassFilterChanged" object:nil];
}
- (IBAction)changeAnalogControls:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] == NSOnState
forKey:@"GBAnalogControls"];
}
- (IBAction)changeAspectRatio:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool: [(NSButton *)sender state] != NSOnState
forKey:@"GBAspectRatioUnkept"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBAspectChanged" object:nil];
}
- (IBAction)colorCorrectionChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem])
forKey:@"GBColorCorrection"];
[[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"];
}
- (IBAction)franeBlendingModeChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem])
forKey:@"GBFrameBlendingMode"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBFrameBlendingModeChanged" object:nil];
}
- (IBAction)colorPaletteChanged:(id)sender
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem])
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
{
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedTag])
forKey:@"GBRewindLength"];
[[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
{
[self.configureJoypadButton setEnabled:false];
[self.skipButton setEnabled:true];
joystick_being_configured = nil;
[self advanceConfigurationStateMachine];
}
- (IBAction) skipButton:(id)sender
{
[self advanceConfigurationStateMachine];
}
- (void) advanceConfigurationStateMachine
{
joystick_configuration_state++;
if (joystick_configuration_state == GBUnderclock) {
[self.configureJoypadButton setTitle:@"Press Button for Slo-Mo"]; // Full name is too long :<
}
else if (joystick_configuration_state < GBButtonCount) {
[self.configureJoypadButton setTitle:[NSString stringWithFormat:@"Press Button for %@", GBButtonNames[joystick_configuration_state]]];
}
else {
joystick_configuration_state = -1;
[self.configureJoypadButton setEnabled:true];
[self.skipButton setEnabled:false];
[self.configureJoypadButton setTitle:@"Configure Joypad"];
}
}
- (void)controller:(JOYController *)controller buttonChangedState:(JOYButton *)button
{
/* 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 == GBButtonCount) return;
if (!joystick_being_configured) {
joystick_being_configured = controller.uniqueID;
}
else if (![joystick_being_configured isEqualToString:controller.uniqueID]) {
return;
}
NSMutableDictionary *instance_mappings = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitInstanceMapping"] mutableCopy];
NSMutableDictionary *name_mappings = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitNameMapping"] mutableCopy];
if (!instance_mappings) {
instance_mappings = [[NSMutableDictionary alloc] init];
}
if (!name_mappings) {
name_mappings = [[NSMutableDictionary alloc] init];
}
NSMutableDictionary *mapping = nil;
if (joystick_configuration_state != 0) {
mapping = [instance_mappings[controller.uniqueID] mutableCopy];
}
else {
mapping = [[NSMutableDictionary alloc] init];
}
static const unsigned gb_to_joykit[] = {
[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) {
max = axis.value;
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];
}
- (NSButton *)analogControlsCheckbox
{
return _analogControlsCheckbox;
}
- (void)setAnalogControlsCheckbox:(NSButton *)analogControlsCheckbox
{
_analogControlsCheckbox = analogControlsCheckbox;
[_analogControlsCheckbox setState: [[NSUserDefaults standardUserDefaults] boolForKey:@"GBAnalogControls"]];
}
- (NSButton *)aspectRatioCheckbox
{
return _aspectRatioCheckbox;
}
- (void)setAspectRatioCheckbox:(NSButton *)aspectRatioCheckbox
{
_aspectRatioCheckbox = aspectRatioCheckbox;
[_aspectRatioCheckbox setState: ![[NSUserDefaults standardUserDefaults] boolForKey:@"GBAspectRatioUnkept"]];
}
- (void)awakeFromNib
{
[super awakeFromNib];
[self updateBootROMFolderButton];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self.controlsTableView selector:@selector(reloadData) name:(NSString*)kTISNotifySelectedKeyboardInputSourceChanged object:nil];
[JOYController registerListener:self];
joystick_configuration_state = -1;
}
- (void)dealloc
{
[JOYController unregisterListener:self];
[[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

128
bsnes/gb/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

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

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

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

View File

@ -0,0 +1,231 @@
#import <Carbon/Carbon.h>
#import "GBTerminalTextFieldCell.h"
@interface GBTerminalTextView : NSTextView
@property GB_gameboy_t *gb;
@end
@implementation GBTerminalTextFieldCell
{
GBTerminalTextView *field_editor;
}
- (NSTextView *)fieldEditorForView:(NSView *)controlView
{
if (field_editor) {
field_editor.gb = self.gb;
return field_editor;
}
field_editor = [[GBTerminalTextView alloc] init];
[field_editor setFieldEditor:true];
field_editor.gb = self.gb;
return field_editor;
}
@end
@implementation GBTerminalTextView
{
NSMutableOrderedSet *lines;
NSUInteger current_line;
bool reverse_search_mode;
NSRange auto_complete_range;
uintptr_t auto_complete_context;
}
- (instancetype)init
{
self = [super init];
if (!self) {
return NULL;
}
lines = [[NSMutableOrderedSet alloc] init];
return self;
}
- (void)moveUp:(id)sender
{
reverse_search_mode = false;
if (current_line != 0) {
current_line--;
[self setString:[lines objectAtIndex:current_line]];
}
else {
[self setSelectedRange:NSMakeRange(0, 0)];
NSBeep();
}
}
- (void)moveDown:(id)sender
{
reverse_search_mode = false;
if (current_line == [lines count]) {
[self setString:@""];
NSBeep();
return;
}
current_line++;
if (current_line == [lines count]) {
[self setString:@""];
}
else {
[self setString:[lines objectAtIndex:current_line]];
}
}
-(void)insertNewline:(id)sender
{
if ([self.string length]) {
NSString *string = [self.string copy];
[lines removeObject:string];
[lines addObject:string];
}
[super insertNewline:sender];
current_line = [lines count];
reverse_search_mode = false;
}
- (void)keyDown:(NSEvent *)event
{
if (event.keyCode == kVK_ANSI_R && (event.modifierFlags & NSEventModifierFlagDeviceIndependentFlagsMask) == NSEventModifierFlagControl) {
if ([lines count] == 0) {
NSBeep();
return;
}
if (!reverse_search_mode) {
[self selectAll:self];
current_line = [lines count] - 1;
}
else {
if (current_line != 0) {
current_line--;
}
else {
NSBeep();
}
}
if (self.string.length) {
[self updateReverseSearch];
}
else {
[self setNeedsDisplay:true];
reverse_search_mode = true;
}
}
else {
[super keyDown:event];
}
}
- (void) updateReverseSearch
{
NSUInteger old_line = current_line;
reverse_search_mode = false;
NSString *substring = [self.string substringWithRange:self.selectedRange];
do {
NSString *line = [lines objectAtIndex:current_line];
NSRange range = [line rangeOfString:substring];
if (range.location != NSNotFound) {
self.string = line;
[self setSelectedRange:range];
reverse_search_mode = true;
return;
}
} while (current_line--);
current_line = old_line;
reverse_search_mode = true;
NSBeep();
}
- (void) insertText:(NSString *)string replacementRange:(NSRange)range
{
if (reverse_search_mode) {
range = self.selectedRange;
self.string = [[self.string substringWithRange:range] stringByAppendingString:string];
[self selectAll:nil];
[self updateReverseSearch];
}
else {
[super insertText:string replacementRange:range];
}
}
-(void)deleteBackward:(id)sender
{
if (reverse_search_mode && self.string.length) {
NSRange range = self.selectedRange;
range.length--;
self.string = [self.string substringWithRange:range];
if (range.length) {
[self selectAll:nil];
[self updateReverseSearch];
}
else {
reverse_search_mode = true;
current_line = [lines count] - 1;
}
}
else {
[super deleteBackward:sender];
}
}
-(void)setSelectedRanges:(NSArray<NSValue *> *)ranges affinity:(NSSelectionAffinity)affinity stillSelecting:(BOOL)stillSelectingFlag
{
reverse_search_mode = false;
auto_complete_context = 0;
[super setSelectedRanges:ranges affinity:affinity stillSelecting:stillSelectingFlag];
}
- (BOOL)resignFirstResponder
{
reverse_search_mode = false;
return [super resignFirstResponder];
}
-(void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
if (reverse_search_mode && [super string].length == 0) {
NSMutableDictionary *attributes = [self.typingAttributes mutableCopy];
NSColor *color = [attributes[NSForegroundColorAttributeName] colorWithAlphaComponent:0.5];
[attributes setObject:color forKey:NSForegroundColorAttributeName];
[[[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

31
bsnes/gb/Cocoa/GBView.h Normal file
View File

@ -0,0 +1,31 @@
#import <Cocoa/Cocoa.h>
#include <Core/gb.h>
#import <JoyKit/JoyKit.h>
#import "GBOSDView.h"
@class Document;
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;
- (uint32_t *) pixels;
@property (nonatomic, weak) IBOutlet Document *document;
@property (nonatomic) GB_gameboy_t *gb;
@property (nonatomic) GB_frame_blending_mode_t frameBlendingMode;
@property (nonatomic, getter=isMouseHidingEnabled) bool mouseHidingEnabled;
@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

686
bsnes/gb/Cocoa/GBView.m Normal file
View File

@ -0,0 +1,686 @@
#import <IOKit/pwr_mgt/IOPMLib.h>
#import <Carbon/Carbon.h>
#import "GBView.h"
#import "GBViewGL.h"
#import "GBViewMetal.h"
#import "GBButtons.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
{
uint32_t *image_buffers[3];
unsigned char current_buffer;
bool mouse_hidden;
NSTrackingArea *tracking_area;
bool _mouseHidingEnabled;
bool axisActive[2];
bool underclockKeyDown;
double clockMultiplier;
double analogClockMultiplier;
bool analogClockMultiplierValid;
NSEventModifierFlags previousModifiers;
JOYController *lastController;
GB_frame_blending_mode_t _frameBlendingMode;
bool _turbo;
}
+ (instancetype)alloc
{
return [self allocWithZone:NULL];
}
+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
if (self == [GBView class]) {
if ([GBViewMetal isSupported]) {
return [GBViewMetal allocWithZone: zone];
}
return [GBViewGL allocWithZone: zone];
}
return [super allocWithZone:zone];
}
- (void) createInternalView
{
assert(false && "createInternalView must not be inherited");
}
- (void) _init
{
[self registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ratioKeepingChanged) name:@"GBAspectChanged" object:nil];
tracking_area = [ [NSTrackingArea alloc] initWithRect:(NSRect){}
options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingInVisibleRect
owner:self
userInfo:nil];
[self addTrackingArea:tracking_area];
clockMultiplier = 1.0;
[self createInternalView];
[self addSubview:self.internalView];
self.internalView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[JOYController registerListener:self];
}
- (void)screenSizeChanged
{
if (image_buffers[0]) free(image_buffers[0]);
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
{
[self setFrame:self.superview.frame];
}
- (void) setFrameBlendingMode:(GB_frame_blending_mode_t)frameBlendingMode
{
_frameBlendingMode = frameBlendingMode;
[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
{
return _frameBlendingMode? 3 : 2;
}
- (void)dealloc
{
free(image_buffers[0]);
free(image_buffers[1]);
free(image_buffers[2]);
if (mouse_hidden) {
mouse_hidden = false;
[NSCursor unhide];
}
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self setRumble:0];
[JOYController unregisterListener:self];
}
- (instancetype)initWithCoder:(NSCoder *)coder
{
if (!(self = [super initWithCoder:coder])) {
return self;
}
[self _init];
return self;
}
- (instancetype)initWithFrame:(NSRect)frameRect
{
if (!(self = [super initWithFrame:frameRect])) {
return self;
}
[self _init];
return self;
}
- (void)setFrame:(NSRect)frame
{
frame = self.superview.frame;
if (_gb && ![[NSUserDefaults standardUserDefaults] boolForKey:@"GBAspectRatioUnkept"]) {
double ratio = frame.size.width / frame.size.height;
double width = GB_get_screen_width(_gb);
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.size.width = new_width;
frame.origin.y = 0;
}
else {
double new_height = round(frame.size.width / width * height);
frame.origin.y = floor((frame.size.height - new_height) / 2);
frame.size.height = new_height;
frame.origin.x = 0;
}
}
[super setFrame:frame];
}
- (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) {
clockMultiplier -= 1.0/16;
GB_set_clock_multiplier(_gb, clockMultiplier);
if (self.document.partner) {
GB_set_clock_multiplier(self.document.partner.gb, clockMultiplier);
}
}
if (!underclockKeyDown && clockMultiplier < 1.0) {
clockMultiplier += 1.0/16;
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;
}
- (uint32_t *) pixels
{
return image_buffers[(current_buffer + 1) % self.numberOfBuffers];
}
-(void)keyDown:(NSEvent *)theEvent
{
if ([theEvent type] != NSEventTypeFlagsChanged && theEvent.isARepeat) return;
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;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
unsigned player_count = GB_get_player_count(_gb);
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;
switch (button) {
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);
}
_turbo = true;
analogClockMultiplierValid = false;
break;
case GBRewind:
if (!self.document.partner) {
self.isRewinding = true;
GB_set_turbo_mode(_gb, false, false);
_turbo = false;
}
break;
case GBUnderclock:
underclockKeyDown = true;
analogClockMultiplierValid = false;
break;
default:
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;
}
}
}
}
if (!handled && [theEvent type] != NSEventTypeFlagsChanged) {
[super keyDown:theEvent];
}
}
-(void)keyUp:(NSEvent *)theEvent
{
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;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
unsigned player_count = GB_get_player_count(_gb);
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;
switch (button) {
case GBTurbo:
if (self.document.isSlave) {
GB_set_turbo_mode(self.document.partner.gb, false, false);
}
else {
GB_set_turbo_mode(_gb, false, false);
}
_turbo = false;
analogClockMultiplierValid = false;
break;
case GBRewind:
self.isRewinding = false;
break;
case GBUnderclock:
underclockKeyDown = false;
analogClockMultiplierValid = false;
break;
default:
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;
}
}
}
}
if (!handled && [theEvent type] != NSEventTypeFlagsChanged) {
[super keyUp:theEvent];
}
}
- (void)setRumble:(double)amp
{
[lastController setRumbleAmplitude:amp];
}
- (void)controller:(JOYController *)controller movedAxis:(JOYAxis *)axis
{
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 buttonChangedState:(JOYButton *)button
{
if (![self.window isMainWindow]) 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);
}
_turbo = false;
}
break;
}
case JOYButtonUsageL1: {
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;
}
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:
break;
}
}
}
- (BOOL)acceptsFirstResponder
{
return true;
}
- (void)mouseEntered:(NSEvent *)theEvent
{
if (!mouse_hidden) {
mouse_hidden = true;
if (_mouseHidingEnabled) {
[NSCursor hide];
}
}
[super mouseEntered:theEvent];
}
- (void)mouseExited:(NSEvent *)theEvent
{
if (mouse_hidden) {
mouse_hidden = false;
if (_mouseHidingEnabled) {
[NSCursor unhide];
}
}
[super mouseExited:theEvent];
}
- (void)setMouseHidingEnabled:(bool)mouseHidingEnabled
{
if (mouseHidingEnabled == _mouseHidingEnabled) return;
_mouseHidingEnabled = mouseHidingEnabled;
if (mouse_hidden && _mouseHidingEnabled) {
[NSCursor hide];
}
if (mouse_hidden && !_mouseHidingEnabled) {
[NSCursor unhide];
}
}
- (bool)isMouseHidingEnabled
{
return _mouseHidingEnabled;
}
- (void) flagsChanged:(NSEvent *)event
{
if (event.modifierFlags > previousModifiers) {
[self keyDown:event];
}
else {
[self keyUp:event];
}
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

View File

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

35
bsnes/gb/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

View File

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

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

View File

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

View File

@ -0,0 +1,87 @@
#import "GBVisualizerView.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;
switch ([[NSUserDefaults standardUserDefaults] integerForKey:@"GBColorPalette"]) {
case 1:
palette = &GB_PALETTE_DMG;
break;
case 2:
palette = &GB_PALETTE_MGB;
break;
case 3:
palette = &GB_PALETTE_GBL;
break;
default:
palette = &GB_PALETTE_GREY;
break;
}
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

@ -0,0 +1,8 @@
#import <Cocoa/Cocoa.h>
@interface GBWarningPopover : NSPopover
+ (GBWarningPopover *) popoverWithContents:(NSString *)contents onView:(NSView *)view;
+ (GBWarningPopover *) popoverWithContents:(NSString *)contents onWindow:(NSWindow *)window;
@end

View File

@ -0,0 +1,46 @@
#import "GBWarningPopover.h"
static GBWarningPopover *lastPopover;
@implementation GBWarningPopover
+ (GBWarningPopover *) popoverWithContents:(NSString *)contents onView:(NSView *)view
{
[lastPopover close];
lastPopover = [[self alloc] init];
[lastPopover setBehavior:NSPopoverBehaviorApplicationDefined];
[lastPopover setAnimates:true];
lastPopover.contentViewController = [[NSViewController alloc] initWithNibName:@"PopoverView" bundle:nil];
NSTextField *field = (NSTextField *)lastPopover.contentViewController.view;
[field setStringValue:contents];
NSSize textSize = [field.cell cellSizeForBounds:[field.cell drawingRectForBounds:NSMakeRect(0, 0, 240, CGFLOAT_MAX)]];
textSize.width = ceil(textSize.width) + 16;
textSize.height = ceil(textSize.height) + 12;
[lastPopover setContentSize:textSize];
if (!view.window.isVisible) {
[view.window setIsVisible:true];
}
[lastPopover showRelativeToRect:view.bounds
ofView:view
preferredEdge:NSMinYEdge];
NSRect frame = field.frame;
frame.origin.x += 8;
frame.origin.y -= 6;
field.frame = frame;
[lastPopover performSelector:@selector(close) withObject:nil afterDelay:3.0];
return lastPopover;
}
+ (GBWarningPopover *)popoverWithContents:(NSString *)contents onWindow:(NSWindow *)window
{
return [self popoverWithContents:contents onView:window.contentView.superview.subviews.lastObject];
}
@end

204
bsnes/gb/Cocoa/Info.plist Normal file
View File

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>SameBoy</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>gb</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>Cartridge</string>
<key>CFBundleTypeName</key>
<string>Game Boy Game</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>com.github.liji32.sameboy.gb</string>
</array>
<key>LSTypeIsPackage</key>
<integer>0</integer>
<key>NSDocumentClass</key>
<string>Document</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>gbc</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>ColorCartridge</string>
<key>CFBundleTypeName</key>
<string>Game Boy Color Game</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>com.github.liji32.sameboy.gbc</string>
</array>
<key>LSTypeIsPackage</key>
<integer>0</integer>
<key>NSDocumentClass</key>
<string>Document</string>
</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>
<key>CFBundleExecutable</key>
<string>SameBoy</string>
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.github.liji32.sameboy</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>SameBoy</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>Version @VERSION</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>LSMinimumSystemVersion</key>
<string>10.9</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015-2021 Lior Halphon</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Game Boy Game</string>
<key>UTTypeIconFile</key>
<string>Cartridge</string>
<key>UTTypeIdentifier</key>
<string>com.github.liji32.sameboy.gb</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gb</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Game Boy Color Game</string>
<key>UTTypeIconFile</key>
<string>ColorCartridge</string>
<key>UTTypeIdentifier</key>
<string>com.github.liji32.sameboy.gbc</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gbc</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</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>
<true/>
</dict>
</plist>

BIN
bsnes/gb/Cocoa/Joypad.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -0,0 +1,26 @@
#ifndef KeyboardShortcutPrivateAPIs_h
#define KeyboardShortcutPrivateAPIs_h
/* These are private APIs, but they are a very simple and comprehensive way
to convert a key equivalent to its display name. */
@interface NSKeyboardShortcut : NSObject <NSCopying>
+ (id)shortcutWithPreferencesEncoding:(NSString *)encoding;
+ (id)shortcutWithKeyEquivalent:(NSString *)key_equivalent modifierMask:(unsigned long long)mask;
- (id)initWithKeyEquivalent:(NSString *)key_equivalent modifierMask:(unsigned long long)mask;
@property(readonly) unsigned long long modifierMask;
@property(readonly) NSString *keyEquivalent;
@property(readonly) NSString *preferencesEncoding;
@property(readonly) NSString *localizedModifierMaskDisplayName;
@property(readonly) NSString *localizedKeyEquivalentDisplayName;
@property(readonly) NSString *localizedDisplayName;
@end
@interface NSPrefPaneUtils : NSObject
+ (id)stringForVirtualKey:(unsigned int)key modifiers:(unsigned int)flags;
@end
#endif

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