Compare commits

...
1055 Commits
Author SHA1 Message Date
Luke Usher dd73766522 ps1: implement GTE command timing 2026-11-06 21:32:31 +00:00
Luke Usher d3b8a29910 ps1: fix breakpoint and address-error exceptions 2026-11-06 21:31:44 +00:00
Luke Usher 05232171d4 ps1: fix spu envelopes and cd audio capture
Fix envelope timing and key-on delay, jump to the repeat address on sample end.
Capture CD audio before volume processing,
Fix sign handling for cd-rom volume and pitch modulation

ref: https://psx-spx.consoledev.net/soundprocessingunitspu/
2026-11-04 19:53:25 +00:00
Luke Usher 15ef1ac2d5 ps1: overhaul sio timing and fifo behavoir
Devices are now in charge of their own timing, fix Memory Card and Controller timing to be closer to hardware.

Fixes an infinite loop polling for memory cards in Ace Combat 3 (USA)
2026-11-04 19:23:03 +00:00
Luke Usher 234c99911f ps1: gpu write fifo should not be blocked when the gpu is busy drawing 2026-11-03 15:34:12 +00:00
Luke Usher 94e66350a1 ps1: sample external bus reads after wait states apply 2026-11-03 13:34:13 +00:00
Luke Usher c4f133ac0b ps1: abort pending MDEC decode on reset 2026-11-03 11:19:51 +00:00
Luke Usher 4307bf2eff ps1: fix motorOn command
it was responding but not actually turning the motor flag on.
2026-11-02 17:05:17 +00:00
PixelMechanic0 17f29369c4 n64: avoid marking an empty RDP queue busy
Clearing DPC_FREEZE calls flushCommands even when END equals CURRENT. Previously, this set pipeBusy and startGclk without executing any commands, leaving an initially idle RDP reporting busy.

Return before setting the busy flags when no forward command range is available. Preserve existing busy state for starved pipelines and leave START/END latching unchanged.
2026-11-01 22:40:37 +00:00
Luke Usher dc4f4659d4 neogeo: add option to allow loading MVS-only or AES-only games on the other system 2026-10-31 16:03:58 +00:00
Matthew Callis e9639ebae3 nall: handle partial TCP sends and reconnects 2026-10-30 10:52:35 +00:00
Matthew Callis bdf0b044e8 macos: enable ARC for hiro and ruby with CMake 2026-10-30 10:52:01 +00:00
Matthew Callis 26c56bb4bc desktop-ui: preserve window placement on resolution changes 2026-10-30 10:51:33 +00:00
Luke Usher 9c5ed3f68d hiro: fix tab frame races on gtk 2026-10-29 16:02:01 +00:00
Luke Usher b6890c9eff ci: use switch freebsd cmake pkg to cmake-core 2026-10-29 14:54:19 +00:00
Luke Usher 035fb15c71 tools: replace native mame2bml tool with Python scripts
The following are new behavoirs in the python tooling:

Extract DIP switch definitions, input mappings, and other metadata by parsing tables directly from the MAME source tree; this lifts metadata (such as dip switch names and bit-values and button labels) into Arcade.bml, no code is lifted.
Support custom overrides for information that is missing or insufficient in MAME's database.
Allow ROMs to be excluded from the generated database, including incomplete dumps, unsupported bootlegs, and non-game software.
2026-10-29 10:12:17 +00:00
Luke Usher 6fd11e291f arcade: add Sega System E
This is essentially just a master system with two VDPs and an optional encrypted z80
2026-10-29 10:12:17 +00:00
Luke Usher 1c07ebf70c desktop-ui: add per-game input overrides
Extend the existing per-system input override functionality to support game-specific controller mappings.

The intended workflow is for users to configure their Virtual Pad once. The Virtual Pad attempts to map inputs to each system's controller based on the physical position of its buttons.

Users can then customize mappings by adding overrides for specific inputs per-system, or per-game. Per-game overrides can only be configured while the relevant game is loaded.

ares attempts to strip common Disc, Disk, Side and Part suffixes from game titles, allowing multi-disc games to share the same input configuration.
2026-10-29 10:12:17 +00:00
Luke Usher 569acf7ba1 arcade: improve neo geo, centralize dip-switch handling and add support for sg1000a encryption
Introduce a shared DIP switch implementation for arcade systems, replacing system-specific implementations.

Neo Geo:

Implement the NEC uPD4990A real-time clock.
Implement the MVS hardware watchdog.
Fix IRQ acknowledgement register handling to that only pending IRQs can be acknowledged
Move ROM decryption and protection handling into runtime PCB emulation, more closely reflecting the behaviour of original hardware.
Add support for additional protection schemes and game-specific memory mappers.

SG-1000A:

Add support for the encrypted Z80 variant used by Championship Wrestling.
Introduce separate opcode fetch and data read paths for the Z80, allowing accurate emulation of hardware-dependent decryption.

Portions of the ROM decryption and protection implementations are derived from MAME. Only code distributed under permissive licences, including the BSD 3-Clause License, has been incorporated.

All MAME-derived implementations are explicitly identified in the source code, with the applicable copyright notices and licence terms preserved in the project's LICENSE file.
2026-10-29 09:49:27 +00:00
Luke Usher 47bab688e6 a26: fix crash with unusual display co-ordinates 2026-10-28 19:01:54 +00:00
remutro 460fec09a0 Fix layout on Cores settings UI 2026-10-27 22:43:31 +00:00
Luke Usher 5d093ad9e6 ps1: run textured draws in parallel to the cpu
To measure texture cache timing, textured draws previously waited for
the renderer to catch up before emulation could continue.

Now we wait only when the GPU becomes ready for another draw.

draw timing observed by the game is unaffected.
2026-10-27 09:00:05 +00:00
Luke Usher 3474c5c1bc a52: improve ANTIC playfield DMA timing
Moon Patrol's HSCROL write was landing too early in ares, corrupting the mountains

Altirra Hardware Reference Manual was used to determine correct behavoir, which I believe to be trustworthy as the introduction specifies that "This document attempts to describe the hardware in detail as the target to which the emulator aspires to imitate"
2026-10-27 10:57:05 +00:00
Luke Usher d400eee976 ps1: toggling 'overscan' should not change aspect ratio 2026-10-26 21:52:46 +00:00
Luke Usher 8128704f23 screen: add configurable deinterlacing modes
Weave (default): combines the current field with the previous field. this preserves detail but may introduce combing during motion. This is how ares behaved historically.

Bob: displays the current field and interpolates missing lines. This prevents motion combing but causes a noticable loss of vertical detail and may flicker thin lines.

Blend: displays an average of consecutive bobbed fields. Behaves similar to bob, but swaps flicker for motion blur.

Phosphor: displays only the currently displaying field while simulating phosphor decay. This Produces a darker image with visible scanlines and may flicker, but is closer to how a real CRT handles interlaced video.
2026-10-26 16:41:29 +00:00
Luke Usher a774671dc0 ps1: take texture cache into account when calculating GPU draw timing
nocash DIAG's hardware cache tests measure miss penalties of ~60 CPU
clocks for eight entries and ~120 clocks for sixteen entries. This is
approximately 12 GPU clocks per 8-byte refill.

We use 13 clocks here as it better fits JaCzekanski's GPU bandwidth
test; textured drawing timings now measure within ~1-2% of the hardware
baseline.
2026-10-26 11:40:08 +00:00
Luke Usher 3f268697d2 ps1: avoid overflow on cd-audio/xa-adpcm mixing 2026-10-26 09:44:56 +00:00
Luke Usher 26382de232 ps1: various bug-fixes/feedback amendments
- prevent discarded polygons from counting in draw timing calculations
- fix depth mode changes applying one frame too late
- fix cd-rom stop command
- prevent MDEC output fifo from losing data when full and reduce output size to a more realistic 32 words-
2026-10-25 22:15:09 +00:00
Luke Usher 9c65426aab ci: use clang-cl for ares-windows-x64, move mingw-clang64 to build-aux
Rationale is that the clang64 ci is resulting in a build that drops as low as 40vps in FMV sequences in the PS1 core, vs 90vps in the same scene for clang-cl

Pinning a known-performant version of clang was considered (local testing proved clang22 produces more performant builds than clang20), but this is not viable with how msys2 is managed. Investigation concluded that we cannot reliably update the clang msys environment; just running 'update:true' breaks the build due to a ymfm issue with the clang23 runtime, and installing the 'clang22' packages still uses the clang23 runtimes, it only pins the compiler itself.
2026-10-25 10:06:49 +00:00
Christopher Bonhage 4355718dda n64: commit the PC at the end of every JIT block
A block can end before an instruction that has a gdb breakpoint. Its
last instruction can then be straight-line code, which does not commit
the pipeline PC. The block exited with ipu.pc at the last commit point,
so the CPU ran the instructions after that point a second time. If that
point was an internal entry of the same block, the CPU looped forever
and the breakpoint never hit.

Commit the pipeline PC on the last instruction of every block. All other
block ends already commit there, so code without breakpoints is
unchanged.
2026-10-25 07:30:52 +00:00
Luke Usher 022805be81 ps1: overhaul timing and hardware accuracy
- more accurately model the CPU bus, write buffering and cache behavior
- improve DMA arbitration, chopping, transfer timing, and interaction with CPU
- rework CD-ROM command timing, deferred responses, interrupts, sector delivery, subchannel data, and disc session handling
- implement the GPU command FIFO, busy timing, texture caches, rasterization, and improve scanout accuracy
- improve timer synchronization, reset, interrupt, and blanking behavior
- improve peripheral, SPU, MDEC, and memory-mapped I/O timing
- add support for Datel Action Replay and Blaze Xplorer cartridges
- add support for the Pixel Accuracy toggle to enable per-pixel scanout (required by tajmiing demo)

These changes were validated against psxtest_cpx, psxtest_gpu, nocash diag.exe, JaCzekanski's tests, and the pcsx-redux CD-ROM torture tests.
Most of tests now pass, and known problematic games such as Monkey Hero are working.

Framebuffer output matches expected hardware output pixel-for-pixel in the nocash diagnostics and psxtest_gpu primitive tests.

Timer test results generally remain within a small margin of hardware baseline results (when compared against the psx.log reference point shipped with the tests)

psxtest_cpx and psxtest_gpu do not initialize controllers correctly when launched directly from the BIOS. You must run them them through software that initializes the hardware first, such as a Datel Action Replay or Blaze Xplorer cartridge. These devices can be configured in Core settings. This issue exists on real hardware and is correct behavoir.

ares can now run the tajmiing demo and all its effects end-to-end.

tajmiing changes display registers at individual-pixel boundaries, so it requires the Pixel Accuracy option in Video settings. Scanline-level synchronization remains the default as oridnary software does not depend on mid-scanline register changes.
2026-10-24 16:48:25 +01:00
Matthew Callis c76aaffa6e sfc: latch window edges once per scanline
Latch the left and right edge matches independently until the next scanline, preserving the inclusive right edge. This prevents mid-line bounds writes from reopening a stopped window, as demonstrated by Mickey Magic and MiSTer SNES PR #508.

Serialize the latches and bump the SNES state format. Fixes ares-emulator/ares#2645.
2026-10-22 23:02:05 +01:00
Reaper 9408cb43d4 desktop-ui: force 3-button mode for incompatible Mega Drive games 2026-10-06 15:03:27 +01:00
Reaper 4565c732bd desktop-ui: persist controller selection 2026-10-06 12:43:10 +01:00
Stefan Schlosser a776c509bd CI: Update FreeBSD runner to 15.1
With FreeBSD 15.0 going EOL very soon, it is time to update the runner
in the CI to FreeBSD 15.1. This version is supported by Cross-Platform
GitHub Actions since version 1.3.0, and the runner is updated to the
currently newest version 1.6.0, which corresponds to the commit
https://github.com/cross-platform-actions/action/commit/e0b9770014ba65d5e0815f15b74031c3a635f641.

Using the operating system's shell for running commands inside steps is
deprecated. Cross-Platform GitHub Actions provides and recommends the
new custom shell cpa.sh instead, which the runner is now using.

This requires to split the "Build: FreeBSD" step into at least one
separate step for setting up the VM before executing commands in the
following steps. This opens up the opportunity to be more in line with
the Linux runner by installing the build dependencies in its own step,
"Install FreeBSD Dependencies".

Before installing dependencies, the runner now updates the preinstalled
packages in the VM via pkg upgrade -y. This ensures that the whole VM is
cohesively up-to-date.

Last but not least, the TARGET_PRESET environment variable must be set
in the "Build: FreeBSD" step with the --environment-variables option of
cpa.sh, or else it won't be propagated to the build environment.
2026-10-04 23:35:10 +01:00
Akiteru 2976a1ab6b sfc: CX4 accuracy improvements
Ported directly from bsnes PRs 377 and 401.
- When triggering a cache preload by writing to $7f48, update the pb register with the prepared program page
- When preloading a page, ignore all runtime checks and reload the page immediately
- Step 1+WS on both reads for cache, not just one
- Remove extra cycle on bus reads/writes
- Remove extra cycle on DMA to internal RAM (fixes excessive slowdown in Morph Moth fight)
2026-10-04 23:34:57 +01:00
Matthew Callis 4cb8d92b44 sfc: add Super Multitap support 2026-09-23 10:42:53 +01:00
user 17813a3ccd gba: CPU memory access fixes 2026-09-15 09:54:32 +01:00
AeroModes 9c9e4148b0 mia: relax FDS BIOS verification checks 2026-09-14 22:38:54 +01:00
Luis Felipe Strano Moraes b5f2943acb md: add kmod message log channel 2026-09-14 22:38:35 +01:00
ZengGengSen a137e844ac eeprom: implement X24C01 four-byte page writes 2026-09-14 22:37:33 +01:00
ZengGengSen b71dabe7a9 fc: reuse shared X24C01 for Datach EEPROM 2026-09-14 22:37:33 +01:00
ZengGengSen e40b0db1ed fc: implement Datach external EEPROM 2026-09-14 22:37:33 +01:00
Aitor Guevara 1e882cdd12 hiro: ensure focus when launched from a frontend in macos
On macoS, a binary executed directly by another process (e.g. a frontend
spawning and emulator) starts as an unregistered background process. It
must be promoted to a regular GUI application to reclaim focus.
2026-09-13 16:18:40 +01:00
AeroModes 09d0c939c5 fc: initialize VRC7 YM2413 patch set at power-on 2026-09-13 16:11:56 +01:00
AeroModes 412c554e9c fc: honor VRC7 WRAM enable bit for reads and writes 2026-09-13 16:11:48 +01:00
AeroModes fd12c9174e fc: support VRC7 submapper pinouts 2026-09-13 16:11:41 +01:00
zoncabe b7cef2049b n64: read GameCube triggers through a Trigger node 2026-09-13 16:03:38 +01:00
zoncabe 0f6b50412b n64: clarify comment on opposing d-pad directions 2026-09-13 16:03:38 +01:00
zoncabe 6d6e1037e8 n64: add GameCube controller support 2026-09-13 16:03:38 +01:00
Matthew Callis b15d4d378c gdb: continue polling after processing a message 2026-09-13 15:55:10 +01:00
Matthew Callis 2bd312e602 Fix macOS build when show-sdk-platform-version fails 2026-09-13 15:51:16 +01:00
Giovanni Bajo af4cbb04f0 Align semantic of all RTC implementations:
* Initialize using the PC localtime
* Handle backward time warp by ignoring it
2026-09-06 12:34:34 +01:00
Giovanni Bajo dee49f55ae n64: avoid infinite loop at boot when time goes backward 2026-09-06 12:34:34 +01:00
Giovanni Bajo e6130f66e7 n64: speed up first boot of games with RTC
There is no reason to advance ~1.7 billion times from the epoch. We can
just initialize the RTC with the current time.
2026-09-06 12:34:34 +01:00
user 5de16c334d fc: implement PPU internal shift registers 2026-09-06 12:33:37 +01:00
ZengGengSen 7b51c8ab71 desktop-ui: guard hot-swappable port changes
Generic port menu callbacks could mutate scheduler threads and audio streams while the emulator worker was active. Route both disconnect and connect actions through one Program::Guard-protected helper and add a deterministic concurrent regression test.
2026-08-30 19:24:24 +01:00
ZengGengSen 66a53e2ed8 a26: advance save-state format to v141 2026-08-30 19:24:24 +01:00
ZengGengSen 24ab7df1e4 a26: add QuadTari controller support 2026-08-30 19:24:24 +01:00
ZengGengSen 8381b5ae05 a26: add AtariVox speech synthesis 2026-08-30 19:24:24 +01:00
ZengGengSen 0b87e304a0 a26: add SaveKey controller support 2026-08-30 19:24:24 +01:00
ZengGengSen 9092f818b9 a26: add KidVid Voice Module support 2026-08-30 19:24:24 +01:00
ZengGengSen a6869c924d a26: add MindLink controller support 2026-08-30 19:24:24 +01:00
ZengGengSen a144d3150a a26: add XG-1 light gun support 2026-08-30 19:24:24 +01:00
ZengGengSen 5ca93ea4d2 a26: add relative pointing controllers 2026-08-30 19:24:24 +01:00
ZengGengSen cc6b83228f a26: add extra-button controller support 2026-08-30 19:24:24 +01:00
ZengGengSen 4a71d93bb6 a26: add ROM-profiled phosphor persistence 2026-08-30 19:24:24 +01:00
ZengGengSen 751f615205 mia: add Atari 2600 cartridge database 2026-08-30 19:24:24 +01:00
ZengGengSen 39ca282454 a26: implement MovieCart streaming cartridge 2026-08-30 19:24:24 +01:00
ZengGengSen f0c946b55e a26: implement ELF executable cartridge 2026-08-30 19:24:24 +01:00
ZengGengSen 742cc93106 armv6m: add Cortex-M0 processor component 2026-08-30 19:24:24 +01:00
ZengGengSen 6495f9ea0f a26: implement FA2 cartridge 2026-08-30 19:24:24 +01:00
ZengGengSen de92243f40 a26: implement EFF cartridge 2026-08-30 19:24:24 +01:00
ZengGengSen 403c81a8cb a26: implement Chetiry cartridge 2026-08-30 19:24:24 +01:00
ZengGengSen b255ec7f31 a26: add persistent cartridge storage 2026-08-30 19:24:24 +01:00
ZengGengSen 22af611ad5 a26: implement BUS cartridges 2026-08-30 19:24:24 +01:00
ZengGengSen 73d1382c61 a26: implement CDF cartridges 2026-08-30 19:24:24 +01:00
ZengGengSen 7f40b23068 a26: implement DPC+ cartridge 2026-08-30 19:24:24 +01:00
ZengGengSen 99f2d442a7 a26: add Harmony cartridge runtime 2026-08-30 19:24:24 +01:00
ZengGengSen 6c629246bc a26: implement ordinary homebrew cartridge mappers 2026-08-30 19:24:24 +01:00
ZengGengSen bd4e506a19 a26: normalize supported cartridge dump layouts 2026-08-30 19:24:24 +01:00
ZengGengSen 0f15baebfd a26: implement DPC cartridge 2026-08-30 19:24:24 +01:00
ZengGengSen 6cf7770c4c a26: implement ordinary cartridge mappers 2026-08-30 19:24:24 +01:00
ZengGengSen cd3cc0087e a26: finalize cartridge board interface 2026-08-30 19:24:24 +01:00
ZengGengSen 5578e7ca89 a26: improve RIOT accuracy 2026-08-30 19:24:24 +01:00
ZengGengSen eac791413a a26: improve TIA and video accuracy 2026-08-30 19:24:24 +01:00
ZengGengSen 65e69f7159 a26: implement controller devices 2026-08-30 19:24:24 +01:00
ZengGengSen fb7544b169 a26: improve CPU bus timing 2026-08-30 19:24:24 +01:00
ZengGengSen a2d94ebba1 a26: initialize CPU interrupt tracer 2026-08-30 19:24:24 +01:00
Giovanni Bajo e4217366cf n64: report the up-to-date cycle counter when software reads COUNT
The CPU keeps a free-running cycle counter (COUNT) that guest software
reads to measure elapsed time. Internally the emulator does not update
that counter after every instruction: cycles are accumulated in a
running clock and only folded into COUNT when the CPU synchronizes with
the rest of the machine. Reading the register returned the folded value
only, ignoring any cycles accumulated since the last fold, so the value
handed back to software could be stale.

How stale depends on how often synchronization happens, which is why
this was mostly invisible with the interpreter and clearly wrong with
the recompiler. The interpreter synchronizes after every instruction, so
at most one instruction worth of cycles was missing. The recompiler
translates a whole run of instructions into a single unit of host code
and only folds the accumulated cycles at its boundaries, so several
consecutive reads of COUNT inside one such unit all returned the exact
same number. Code that reads the counter repeatedly to check that time
is moving forward would see it standing still; the test_timer_ticks test
in the libdragon test suite fails this way, with two successive readings
comparing equal.

Track how many cycles have already been folded into COUNT in a separate
countClock field, so the cycles accumulated since then can be recovered
at any point. Reading COUNT now folds those pending cycles in first,
which both returns an up-to-date value and evaluates the COMPARE match
at the same moment, keeping the register and the timer interrupt
consistent with each other. Writing COUNT or COMPARE folds them in as
well, so the pending cycles are attributed to the old value rather than
being added on top of the newly written one.
2026-08-26 23:38:43 +01:00
Giovanni Bajo 430def86f2 n64: fix timer interrupt never firing when COMPARE is zero
The CPU has a free-running cycle counter (COUNT) and a programmable
target register (COMPARE); an interrupt is raised whenever the counter
reaches the target. The check for that event was written as
"count < compare && count + elapsed >= compare", which assumes the
target always lies ahead of the current counter value in plain
arithmetic order. Since both registers are unsigned, that assumption
breaks as soon as the target is behind the counter, and it breaks
permanently when the target is exactly zero: no unsigned value is ever
less than zero, so the first half of the condition is never true and the
interrupt is never raised at all.

That is not a corner case in practice. The counter is only 32 bits wide
and wraps around roughly every 90 seconds, so software that wants to
maintain a wider timestamp typically arms the target at zero in order to
be notified on every wrap. libdragon did exactly this: timer_init()
programs COMPARE to zero and used the resulting interrupt to increment
the high half of a 64-bit tick counter. Under ares that interrupt never
arrived, so the high half was never incremented and timer_ticks() went
backwards across a wrap, which is what the test_timer_ticks test in the
libdragon test suite reports.

Replace the ordered comparison with a modular distance computed over the
counter's full range: the number of ticks remaining until the target is
(compare - count) truncated to the counter width, and the interrupt
fires when at least that many ticks elapse. This behaves identically
when the target is ahead of the counter and additionally handles the
wrap-around case, including a target of zero. The counter update, the
crossing check and the cycle profiling counters are moved together into
a new stepCount() helper so that a single implementation stays
authoritative.
2026-08-26 23:38:43 +01:00
Christopher Bonhage 4bfccfc3d5 nall/gdb: support QPassSignals
The client can now ask the stub to deliver chosen signals without stopping
or reporting (gdb sends QPassSignals automatically for signals configured
'handle <sig> nostop noprint pass'). Advertised in qSupported; the pass set
is client state, cleared on connect/disconnect like breakpoints.
2026-08-25 17:56:11 +01:00
invertego e3b53a6ec9 Merge commit '8a22cd8096c8ce366cccd44813b6210c2160ff29' 2026-08-24 02:23:23 -07:00
invertego 8a22cd8096 Squashed 'thirdparty/sljit/' changes from 666125ad6..de0259c7a
de0259c7a aarch64: set bit 14 for encoding [S|U]MULH (#370)
fdb8e8ce2 Fix build warnings by avoid function pointer to object pointer casts (#368)
67893de6c alpha: Add 64-bit JIT backend (#364)
f8d585b76 ppc: add SLJIT_BREAKPOINT (#367)
8c4127005 ubsan: avoid UB with << of a signed integer (#365)
3907e6900 Add zext.w support for riscv (#363)
d8c86ea66 regexJIT: guard dfa_transitions allocation against size overflow (#361)
d74aa8871 ppc64: Cast mask to sljit_sw in TEST_UI_IMM macro (#360)
d9902b1ba config: prevent aarch64_be from being autodetected (#345)
35ffee1a8 remove smartquotes in C comment (#353)
d034fb107 x86_64: fix near jump check (#352)
acf9f8f85 Move modular header includes outside `extern "C"` scope (#351)
68f01a538 Improve overflow check on RISCV (#350)
8d40e0306 riscv: make sure platform identification for RISCV is succint (#348)
8d0d05c58 Improve carry flag handling (#347)
a8d667f81 Improve signed/unsigned comparison of integers larger than a single register (#346)
c2598a9c2 netbsd: allow mprotect exception for PAX in wxalloc (#344)
3150656bb x86: avoid SIGILL in test25 for older CPUs (#343)
45f910b78 Improve sljit_emit_op2_shift on x86 (#342)
72f95ea56 Small emit_select improvements (#341)
31d2e5308 loongarch: Implement compare select (min/max) operation (#340)
15c64bb72 Implement compare select (min/max) operation on s390x (#339)
39754d085 Implement compare select (min/max) operation (#338)
b7442be1c loongarch: Implement sljit_emit_op2_shift (#337)
f621129c0 \Implement sljit_emit_op2_shift on s390x (#336)
6612fe51e Attempt some further improvements to -Wimplicit-fallthrough support (#331)
f9fd801f4 Implement sljit_emit_op2_shift (#335)
88d0ce0c0 Ensure that some log messages are written to the verbose stream (#333)
c57378efb Correct doc string for sljit_emit_jump (#332)
1bec7a611 config: add SLJIT_FALLTHROUGH to exempt -Wimplicit-fallthrough or C5262 (#330)
e281e199c Add more SLJIT_TMP_OPT_REG tests (#328)
a9e5ec6ae Introducing SLJIT_TMP_OPT_REG (#327)
d1fd994c1 Improve tmp register support (#326)
1fade852b aarch64: avoid -Wunused_parameter in older CPUs (#324)
1232958de Improve the description of sljit_emit_[f]select instructions
7779da89d Add test for dynamic code generation in buffers (#318)
8766c3abf Fix spelling in C code comments (#317)
2e7b6f2a7 Fix Docusaurus URL configuration (#316)
5e42fc93b Rework website (#310)
8b3029792 loongarch: improve immediate generator (#315)
1e66c9054 loongarch: Update toolchain and minor code style change (#314)
f9beb306b Fix sljit_emit_icall on Linux x86_64 (#313)
e93aa7c62 Fix test_buffer1 (#312)
98802d939 Improve jump/op_addr code generation on s390x (#309)
f0a7de957 Implement add address operation (#308)
4ec49e599 Improve CI (#307)
2dd451147 Fix test fails on loongarch (#306)
4c9e95004 Fix test fails on s390x (#305)
5aa4885ee Add more buffer tests (#304)
d7bf1f5b2 Implement read-only buffer allocation (#303)
994c013d6 Implement aligned labels on s390x
06e5b0ed5 Implement aligned labels (#302)
abbb179b1 Consolidate docs (#301)
a442875df Improve rewritable consts on s390x (#300)
f57890048 Improve rewritable consts (#299)
959c13542 loongarch: Fix sljit_emit_single and sljit_emit_op2cmpz (#298)
370630ec0 Implement emit_op2cmp operation (#296)
8bacc9aee Rename doc to docs (#297)
a96da7a86 Improve immediate generation on RISCV (#295)
2984ac7b1 Implement 16 bit branches for RISCV (#294)
d3cec21d9 Implement compressed arithmetic instructions for RISCV (#293)
85782cfb7 Implement load/store compressed instructions for RISCV (#291)
500037920 Implement several compressed instructions for RISCV (#290)
a969602da Better detection of available features on RISCV (#289)
2cdf4edee Change instruction size unit to 16 bit on RISCV (#288)
8481dde36 Enable -Wshadow warning, and rename shadowed variables (#286)
415ddeaea Fix sljit_emit_simd_sign RISCV (#284)
eb8ef1e81 Fix sljit_get_local_base (#282)
e51eabbfb Implement proper argument checks for float/simd registers (#280)
f7037aa15 Improve vector reg support on s390x (#279)
dcd3b10cd Improve vector reg support (#278)
a5ecc9c2e Comment else-s and endif-s in macros (#277)
2cf8a2495 Checks for separated vector registers (#275)
9dc3a4cf2 loongarch: Add SLJIT_UPPER_BITS_SIGN_EXTENDED (#276)
c0fd3d1ae Rename zeroed to zero extended
4b419b4bf Provide information about 32 bit operations on s390x
504672a9f Provide information about 32 bit operations register usage
20edfb055 CI: Update uraimo/run-on-arch-action to 2.8.1 (#274)
446e5c71f loongarch: Optimize jump maximum offset prediction & update action compiler (#273)

git-subtree-dir: thirdparty/sljit
git-subtree-split: de0259c7aaf36aa40cba8014f3fad3edde9307f9
2026-08-24 02:23:13 -07:00
invertego 3918992a41 n64: fix builds with ARES_UNITY_CORES=OFF 2026-08-24 09:37:50 +01:00
invertego f42f60d744 recompiler: fix floating-point issues impacting n64 core (#2611) 2026-08-24 10:00:48 +02:00
Giovanni Bajo fc83454343 n64: rename qnan/snan naming
Ares previous naming was following IEE754 but VR4300 uses an inverted
encoding for NaNs. This also shows that the CPU behavior is more logical.
2026-08-22 09:17:02 +01:00
ZengGengSen f23eb39ad5 a52: add v148 save-state support 2026-08-20 16:37:55 +01:00
ZengGengSen f67757e35e a52: add CX53 Trak-Ball controller 2026-08-20 16:37:55 +01:00
ZengGengSen 190afd8ad2 a52: implement POKEY and standard controller 2026-08-20 16:37:55 +01:00
ZengGengSen e2cdee5038 a52: implement GTIA hardware model 2026-08-20 16:37:55 +01:00
ZengGengSen 85adb9862f a52: implement ANTIC hardware model 2026-08-20 16:37:55 +01:00
ZengGengSen 0a78d55452 a52: implement cartridge media model 2026-08-20 16:37:55 +01:00
ZengGengSen e5d619c238 a52: add Atari 5200 scaffold and CPU 2026-08-20 16:37:55 +01:00
user a840e6427e gba: halt OBJ engine early if DISPCNT bit 5 is set 2026-08-20 16:37:08 +01:00
user 9cb73a6842 gba: implement OBJ VRAM access timings 2026-08-20 16:37:08 +01:00
ZengGengSen 901f57e125 desktop-ui: add configurable digital-to-analog mapping (#2602) 2026-08-20 16:36:55 +01:00
Giovanni Bajo 8da242f5a6 n64: remove hardcoded 8 MiB memory limit in recompiler
Fallback to interpreter or slow-path when accessing out-of-bound memory
2026-08-20 16:36:40 +01:00
Max Bebök fa2105ea11 fix: EEPROM null pointer access 2026-08-20 16:36:19 +01:00
ZengGengSen 30131cd32c Fc/vs unisystem support (#2594)
## Overview

Adds Nintendo Vs. UniSystem support to the ares FC core. Games remain in
MAME
ZIP format and load through the existing Arcade path, without going
through
the iNES detection path used by regular Famicom software.

The implementation covers MAME metadata generation, parent ZIP lookup,
Vs. PPU
and palette behavior, cartridge boards, protection logic, cabinet I/O,
DIP
switches, controller wiring, Zapper input, and save states. A total of
41 Vs.
UniSystem sets have been validated. Vs. DualSystem, non-standard bootleg
hardware, and other configurations that have not yet been implemented
are
explicitly marked as unsupported instead of being started with the
UniSystem
model.

## Why `vsnes.py` is separate

MAME groups three substantially different hardware families in
`nintendo/vsnes.cpp`:

- Vs. UniSystem with one CPU and one PPU;
- Vs. DualSystem with two CPUs and two PPUs;
- non-standard bootleg hardware built around a Z80 and SN76489.

The generic MAME parser reads common data such as machine entries, ROM
regions,
and DIP switches. Those fields alone are not enough to determine which
Vs.
hardware model a game requires. The three families have different
runtime
structures and cannot share a single emulation path.

Configurations also differ between Vs. UniSystem games. The PPU,
palette,
cartridge board, protection logic, controller wiring, Zapper support,
and DIP
settings may all vary by set. The core needs explicit configuration data
rather than inferring hardware from a game title.

`vsnes.py` reuses the MAME XML and ROM-region information produced by
the
generic parser, then adds hardware classification and per-game
configuration.
It generates a deterministic `VsSystem.bml` database. At runtime,
supported
sets select the corresponding FC hardware model from this metadata,
while
DualSystem and bootleg sets are rejected with a clear explanation.

## Video

The combined video shows the attract modes of all 41 supported games.
Each
game is shown for approximately ten seconds, with its name in the
upper-right corner.



https://github.com/user-attachments/assets/46a59b2b-f64a-40ce-a870-1351d5df3948



https://github.com/user-attachments/assets/7927d1d0-4349-4f4b-9092-feeb7b0ac127



https://github.com/user-attachments/assets/d162c834-b227-497b-afe7-2f766f3ab42a



https://github.com/user-attachments/assets/12d7b58e-7cd5-4bbf-b040-9d615e654e0c



https://github.com/user-attachments/assets/a8708059-4369-48e1-be1f-42d15099d7a8


## Screenshots

The contact sheet contains one attract-mode screenshot for each game,
composed
at the original capture resolution.

<img width="3920" height="5328" alt="contact-sheet"
src="https://github.com/user-attachments/assets/e111cf05-4a49-4b0d-9719-082b2b925342"
/>

## Supported sets

The following 41 Vs. UniSystem MAME sets have been validated for loading
and
attract-mode operation:

| No. | MAME short name | Game |
| ---: | --- | --- |
| 1 | `btlecity` | Vs. Battle City |
| 2 | `cluclu` | Vs. Clu Clu Land |
| 3 | `cstlevna` | Vs. Castlevania |
| 4 | `drmario` | Vs. Dr. Mario |
| 5 | `duckhunt` | Vs. Duck Hunt (set DH3 E) |
| 6 | `excitebk` | Vs. Excitebike (set EB4-3 E) |
| 7 | `excitebkj` | Vs. Excitebike (set EB4-4 A) |
| 8 | `excitebko` | Vs. Excitebike (set EB4-3 ?) |
| 9 | `goonies` | Vs. The Goonies (set E) |
| 10 | `hogalley` | Vs. Hogan's Alley (set HA4-1 E-1) |
| 11 | `iceclimb` | Vs. Ice Climber (set IC4-4 B-1) |
| 12 | `iceclimba` | Vs. Ice Climber (set IC4-4 ?) |
| 13 | `jajamaru` | Vs. Ninja Jajamaru Kun (Japan) |
| 14 | `ladygolf` | Vs. Stroke & Match Golf (Ladies Version, set LG4 ?)
|
| 15 | `ladygolfe` | Vs. Stroke & Match Golf (Ladies Version, set LG4 E)
|
| 16 | `nvs_machrider` | Vs. Mach Rider (Endurance Course Version) |
| 17 | `nvs_machridera` | Vs. Mach Rider (Fighting Course Version, set
MR4-1 A) |
| 18 | `nvs_mightybj` | Vs. Mighty Bomb Jack (Japan) |
| 19 | `nvs_platoon` | Vs. Platoon |
| 20 | `rbibb` | Vs. Atari R.B.I. Baseball (set 1) |
| 21 | `rbibba` | Vs. Atari R.B.I. Baseball (set 2) |
| 22 | `skatekds` | Vs. Skate Kids. (Graphic hack of Super Mario Bros.)
|
| 23 | `smgolf` | Vs. Stroke & Match Golf (Men Version, set GF4-2 F) |
| 24 | `smgolfb` | Vs. Stroke & Match Golf (Men Version, set GF4-2 ?) |
| 25 | `smgolfj` | Vs. Stroke & Match Golf (Men Version) (Japan, set GF3
B) |
| 26 | `starlstr` | Vs. Star Luster |
| 27 | `suprmrio` | Vs. Super Mario Bros. (set SM4-4 E) |
| 28 | `suprmrioa` | Vs. Super Mario Bros. (set ?, harder) |
| 29 | `supxevs` | Vs. Super Xevious |
| 30 | `tkoboxng` | Vs. T.K.O. Boxing |
| 31 | `topgun` | Vs. Top Gun |
| 32 | `vsfdf` | Vs. Freedom Force |
| 33 | `vsgradus` | Vs. Gradius (US, set GR E) |
| 34 | `vsgshoe` | Vs. Gumshoe (set GM5) |
| 35 | `vspinbal` | Vs. Pinball (US, set PN4 E-1) |
| 36 | `vspinbalj` | Vs. Pinball (Japan, set PN3 B) |
| 37 | `vsskykid` | Vs. Super SkyKid |
| 38 | `vsslalom` | Vs. Slalom |
| 39 | `vssoccer` | Vs. Soccer (set SC4-2 A) |
| 40 | `vssoccera` | Vs. Soccer (set SC4-3 ?) |
| 41 | `vstetris` | Vs. Tetris |
2026-08-20 16:35:50 +01:00
ZengGengSen b80f67d383 input: preserve relative mouse motion between polls (#2593)
## Changes

- Accumulate relative mouse movement until it is read and consumed by an
input mapping.
- Maintain an independent read position for each `InputRelative`
binding.
- Synchronize relative input positions when input bindings or mouse
capture state changes.
- Apply the same relative-motion handling to the Raw Input, NSEvent, and
Xlib mouse drivers.

## Motivation

In my testing, `InputManager::poll()` is called approximately once every
8ms on my system, with observed intervals generally no shorter than 5ms.
At 60Hz, each frame lasts approximately 16.67ms, so input is normally
polled twice per frame.

Each poll retrieves the mouse-axis movement accumulated during the
preceding approximately 8ms. However, emulator cores generally read
relative input only once per frame. This means that `InputManager` may
complete its second poll before the core reads the movement value.

The previous implementation retained only the mouse-axis movement
reported by the most recent poll. The second poll therefore overwrote
the result of the first, allowing the core to observe only the movement
from the latest approximately 8ms. Mouse movement from the earlier
approximately 8ms of the frame was lost.

This change accumulates all relative mouse movement produced between
consecutive core input reads. As a result, even when
`InputManager::poll()` runs multiple times within a single frame, the
core can still retrieve the complete mouse-axis movement accumulated
during that period.
2026-07-30 20:29:09 +01:00
ZengGengSen 53ba720c8d ruby: normalize Windows Raw Input mouse motion (#2592)
## Abstract

Support the absolute mouse movement events in the native input driver
for Windows.
Modifications:

- Convert the absolute original input coordinates to relative motion
increments;
- Handle the coordinate spaces of the main desktop and virtual desktop
while maintaining independent absolute coordinate positions;
- Add locking in the `poll` function to prevent partial data loss in the
event of multi-threaded competition.

## Reasons 

When I used 'Windows Remote Desktop Connection' for remote debugging, I
found that 'win raw input' did not provide the corresponding 'relative
mouse event'. Since 'ruby' ignored the 'absolute mouse event', the input
relying on the mouse (such as the crosshair of a gun sight) could
receive key operations, but it was unable to move.
2026-07-29 10:25:01 +01:00
Roger SandersandRoger Sanders 274aabdf4a megald: Fix NEC LaserActive fader settings in VDP burst mode (#2591)
Fixes a video mixing issue which affected graphics in the "Demon's
Judgement" LDRom2 game for the Pioneer LaserActive with the NEC PAC.

---------

Co-authored-by: Roger Sanders <[email protected]>
2026-07-29 09:39:10 +01:00
Luke Usher cdabe5c5a6 build: grant release action wire permissions to release artifacts 2026-07-25 19:12:02 +01:00
Giovanni Bajo 5fdc7a8c0b n64: fix in-block self-modifying code with JIT 2026-07-24 16:47:33 +01:00
Giovanni Bajo ec5e82ae76 n64: fix RDP buffer busy after flush 2026-07-24 16:47:33 +01:00
Giovanni Bajo 1bad216467 n64: implement various not implemented exceptions 2026-07-24 16:47:33 +01:00
Giovanni Bajo 1fcef61b84 n64: fix COP0 TagLo latching unused bits, and MTC0 writing 64-bit values 2026-07-24 16:47:33 +01:00
Giovanni Bajo f1382f7780 n64: other accuracy improvements to CACHE opcode (icache) 2026-07-24 16:47:33 +01:00
Giovanni Bajo 6ed19d3115 n64: improve accuracy of various corner cases of the CACHE opcode
Specifically, the dirty flag behaves differently from the "obvious" way,
and cannot be affected by the CACHE opcode.
2026-07-24 16:47:33 +01:00
Giovanni Bajo 7806042b31 n64: SC/SCD do not clear llbit 2026-07-24 16:47:33 +01:00
Giovanni Bajo 433d07fbdb n64: implement banked SRAM support (fixes Dezaemon 3D saves) 2026-07-24 07:50:27 +01:00
Giovanni Bajo 5c6607fa9b n64: rewrite flash emulation
This uses all the latest research on the exact behavior of flash chips,
including quirks of specific models, as documented on n64brew.

Thanks to the new PI bus emulation, it is now possible to correctly
implement many quirks "naturally", because of the simple way flash
chips interact with the bus.
2026-07-24 07:50:27 +01:00
Giovanni Bajo 3c63fbcfb4 n64: rewrite PI bus implementation to make it closer to the hardware
PIDevice is now a generic device sitting on the PI bus that is able
to reply to addresses in any range. Now each device knows the addresses
it is listening to, which is how the hardware works.

PI accesses are only 16-bit wide, and both DMA and CPU I/O are built
upon it. There is no more code to mimic the weird access patterns for
misaligned addresses or different access sizes, as everything descends
naturally from the way the bus works (as it should be).

Open bus is simulated by latching the last value on the bus, which is
what happens on hardware.

This opens the door to more accurate emulation of chips which abuse the
bus in weird ways (like flash memories).
2026-07-24 07:50:27 +01:00
Giovanni Bajo 45c2291261 n64: implement access to RDRAM hidden bits
We always update hidden bits on memory writes. Given that in most cases
this is done during dcache flushes, we use SIMD to optimize that code
path and update a whole cacheline's worth with a few opcodes.

Also take the chance to add a mi/bus.hpp that implements the special
MI modes (ebus, repeat, upper), so that they naturally only apply
to CPU-issued reads.
2026-07-24 07:50:16 +01:00
Giovanni Bajo 3cac8a1863 n64: emulate RDRAM chip registers and behaviors
This finally allows Ares to fully run through the IPL3 to fully initialize
the RAM chips. It tries to simulate also all the various non-working
conditions so that a change in a IPL3 that results in failure to boot,
should also fail in Ares. Obviously this would be a very long journey,
but at least all major failures are covered here.

Default RDRAM linear mapping is still kept as default as a fast path
in the recompiler to avoid slowdowns in normal situations. Given
that parallel-RDP doesn't support non-linear mappings, we just emit
a warning in that case.

Invalid current values will result in degraded RAM accesses like on real
hardware. This is also necessary to fully pass the current calibration
algorithm and to provide entropy (collected by libdragon's IPL3).
2026-07-24 07:50:16 +01:00
Giovanni Bajo d5c0568492 ares: add "Deterministic Entropy" option and hook it up to sfc and n64 2026-07-24 07:50:16 +01:00
Roger Sanders 0b9b8bce6b megald: Fix LaserActive support after recent cd changes, plus additional fixes. 2026-07-24 07:50:04 +01:00
T3hD0gg 0583153727 gdb: Fix single step & resume packet address parsing to match GDB specification (hex instead of integer). 2026-07-24 07:47:54 +01:00
T3hD0gg 1cc7dfd4f6 gdb: Fix read register packet index parsing to match GDB specification (hex instead of integer). 2026-07-24 07:47:54 +01:00
Bryce Wilson e1b0d47440 n64: enable gdb reads of sizes that are not multiples of 4 (#2519)
If we hit the final branch of the if in the read hook and `byteCount` is
not a multiple of 4, the remaining bytes are never read, but the buffer
is still sent back with unset data. This adds one more iteration to the
loop if necessary to read another word, and then shrinks the string to
the correct size.

In the write hook, the simple cases will do a write and then break the
switch and end up in the conditionals, potentially writing twice. So I
switched the breaks to returns.

The final conditional code in the write hook also cannot handle data
sizes that aren't multiples of 4 bytes, but I'm less confident about how
to fix that. Happy to add it to this PR if someone who knows what
they're doing advises.

Also trimmed some trailing whitespace.
2026-07-23 02:28:11 +02:00
user be3c7898ce arm7tdmi: prevent STM writeback from modifying r15 2026-07-19 09:19:38 +01:00
thekovic 449b93716f n64: Remove field swapping workaround for interlaced image (#2574)
Before we were drawing the frame according to the VI registers at line
0. After a recent change (I believe
https://github.com/ares-emulator/ares/commit/31526ded9196b046b0b5ce1769f14335eba9cc33
), we now draw it according to VI registers when display area begins.
This means that we take into account the vblank interrupt that normally
changes the registers so the field swapping workaround is not needed
anymore.
2026-06-28 00:59:25 +02:00
Stefan Schlosser 6dc3f3306c ruby: improve SDL3 audio performance
Some platforms experienced very poor performance with the SDL3 audio
driver, especially in combination with a demanding core like the N64.
It is assumed that SDL couldn't keep up filling the output device buffer
with the audio data from the input queue buffer. Increasing the amount
of generated input data before feeding it to the device buffer has shown
to greatly improve the performance.

This sparked the following idea and change to how the SDL3 audio driver
fills its buffers: request a fixed-sized 10ms device buffer and apply
the latency to the input buffer, i.e. the input buffer holds a multiple
of 10ms worth of audio. This allows SDL to steadily consume audio from
the input buffer and feed it into the 10ms device buffer, while the user
can still control the latency.

Additionally add the value 30 to the possible latency options. This
allows users to specify a lower latency than 40 if 20 is just a tiny bit
shy of being good enough.
2026-06-24 15:43:37 +01:00
remutro 91b112279a Fix calculation 2026-06-14 20:31:35 +01:00
remutro c634ac3639 Update available rewind options 2026-06-14 20:31:35 +01:00
remutro 743ef1f2cd Expose rewind controls in the UI 2026-06-14 20:31:35 +01:00
Stefan Schlosser 2e7a877a96 Fix error: undeclared identifier 'renderSettingsLabel'
The renderSettingsLabel identifier isn't declared anymore after the
recent structural changes, but it's still referenced conditionally in
desktop-ui/settings/cores.cpp and breaks the build if the N64 core is
disabled:

/tmp/ares/desktop-ui/settings/cores.cpp:108:3: error: use of undeclared identifier 'renderSettingsLabel'
  108 |   renderSettingsLabel.setCollapsible(true).setVisible(false);
      |   ^

Remove it to fix the build.
2026-06-14 12:47:22 +01:00
remutro 1337a5c013 Use windows-latest image 2026-06-13 23:24:18 +01:00
remutro 459ceb2e22 Update Visual Studio related cmake generators to VS2026 2026-06-13 23:24:18 +01:00
remutro 0d14e49319 Update Visual Studio related cmake generators to VS2026 2026-06-13 23:24:18 +01:00
Stefan Schlosser 9293695459 CI: Cleanup build dependencies on Linux/FreeBSD
Remove the build dependencies of the removed audio and input drivers,
now that SDL3 is the only supported driver.

Additional cleanup on FreeBSD:

- libX* and libglvnd are dependencies of sdl3 itself and can reasonable
  be expected to continue to be so. This allows to remove them from the
  list of explicit bulid dependencies.

- vulkan-loader provides libvulkan.so which is a dlopen'ed runtime
  dependency of parallel-rdp used in the N64 core. It is not a build
  dependency and can be removed (though it gets installed anyway as a
  dependency of sdl3).
2026-06-13 23:23:08 +01:00
remutro 5f2f7dc0d4 Update Debug to Developer panel, GPU sync enabled with video sync 2026-06-12 19:04:14 +01:00
remutro 7032bc6ef0 Complete SDL device enum and settings reorganization 2026-06-12 19:04:14 +01:00
remutro acf213fa5f Causing crashouts due to initial settings reorg 2026-06-12 19:04:14 +01:00
remutro 4ceadb9549 SDL device enum, starting moving settings 2026-06-12 19:04:14 +01:00
remutro 2ce75dde67 Restore audio device setting 2026-06-12 19:04:14 +01:00
Giovanni Bajo 31526ded91 n64: reduce 1 frame of input latency, and fix flickering when CPU drawing
We were telling Vulkan to display a frame as per the VI configuration
at vblank (line 0). This is wrong since all games will actually use
vblank to configure VI for the new frame. Vulkan would thus draw the
*previous* frame, rather than the new one that was just created, causing
one full frame of latency. The correct point where to kick Vulkan is at
vstart, when the active display begins.

With CPU-based rendering in a double-buffering scenario (rather than
triple buffering), this means that the wrong framebuffer would always
be shown: the one that was just going to be drawn upon. Thus, we would
basically get a race between the emulated CPU writing to RDRAM and the
host Vulkan reading RDRAM.

The bug was hidden when using RDP rendering because RDP emulation also
goes through Vulkan, so it would basically be queued *after* the VI
drawing rather than *during* it.
2026-06-09 22:31:32 +01:00
remutro c3c2b79015 Squash audio abstractions into a single audio struct 2026-06-09 13:32:43 +01:00
remutro 8c41639a76 Increase bytes to wait in SDL audio to help performance 2026-06-09 13:32:43 +01:00
remutro 8bcb10f36b Minor cleanup 2026-06-09 13:32:43 +01:00
remutro d6430da5dc Cleanup dependencies 2026-06-09 13:32:43 +01:00
remutro 57a4bec25d Fix FreeBSD build 2026-06-09 13:32:43 +01:00
remutro 920dfb3de8 fix sdl build script 2026-06-09 13:32:43 +01:00
remutro c02233f815 fix script permission 2026-06-09 13:32:43 +01:00
remutro 0ec4b5f953 Remove plugin related functions, add SDL build 2026-06-09 13:32:43 +01:00
remutro aa5df08e2b Remove driver list controls from settings 2026-06-09 13:32:43 +01:00
remutro e70cb9fb58 SDL fixed 10ms latency 2026-06-09 13:32:43 +01:00
remutro 40474c4987 Fix MacOS build 2026-06-09 13:32:43 +01:00
remutro 53d8b81ade Update non-windows cmake files 2026-06-09 13:32:43 +01:00
remutro bb3c36cd96 Delete unused files 2026-06-09 13:32:43 +01:00
remutro 5ee7e9a5ba Make SDL the only available audio & controller input driver 2026-06-09 13:32:43 +01:00
Giovanni Bajo 6fcaa213fb n64: in emux, add basic profiling for RSP (cyles and halted cycles) 2026-06-09 13:32:24 +01:00
Giovanni Bajo 658aad5dd7 n64: in emux XPROFREAD, fix a bug in accessing the global slot 2026-06-09 13:32:24 +01:00
Giovanni Bajo e67f0cefc5 n64: DIV/DIVU in user mode never raise a RI exception 2026-06-04 00:52:24 +01:00
remutro 90c655b944 Update dependencies (post-v148) 2026-05-31 09:08:00 +01:00
remutro 0aafd85789 Fix build warning 2026-05-28 13:42:30 +01:00
Luke Usher 67b0bf7aac ruby: improve SDL audio sync on non-stereo devices
Use the application stream format rather than the physical device format.

Some outputs, such as HDMI/TV devices with Dolby processing enabled,
may expose a multichannel device format even though ares is submitting
stereo float audio to SDL. Using the device format for queue sizing and
drain timing could make the blocking sync path sleep for the wrong
amount of time, causing the emulator to run too slowly.

General cleanup:
 - avoid heap allocation for every audio packet
 - add proper failure checks
 - correctly teardown SDL_Audio on shutdown
2026-05-28 08:47:04 +01:00
remutro 11d887c99c Fix aspect correction menu radio items in GTK 2026-05-28 08:10:27 +01:00
Luke Usher 7c03fb208f desktop-ui: add tape position slider 2026-05-25 16:23:20 +01:00
Luke Usher b33edf5f90 sg/fc/msx/spec: update serialization for tapes 2026-05-25 16:16:05 +01:00
Luke Usher 83369fd40f sg: add tape support to sc-3000 2026-05-25 16:11:50 +01:00
Luke Usher 6ee42f25b4 msx: hook up tape recording to tape manager 2026-05-25 15:39:46 +01:00
Luke Usher fe388a7fcc desktop-ui: fix tape recording button attribute lookup 2026-05-25 15:33:23 +01:00
Luke Usher c7d667fa07 ruby: fix keyboard mappings on macOS by adding missing left/right modifier keys 2026-05-25 11:36:27 +01:00
Luke Usher cc0e405780 msx: use the 'new' tape system rather than hard-coding the tape deck, add support for tsx/tzx and cas.
also prevent creating a .wav when not writing
2026-05-25 10:07:32 +01:00
Luke Usher c21adc7b57 spec: use the 'new' tape system rather than hard-coding the tape deck 2026-05-25 09:25:10 +01:00
Luke Usher 232f85e39c desktop-ui: move dynamic scale options to a vector rather than a grouo
Fixes being able to select multiple scaling-related options simultaneously
2026-05-24 23:40:30 +01:00
Luke Usher c951652efb desktop-ui: fix broken virtualpad overrides 2026-05-24 23:02:26 +01:00
Luke Usher f605d52032 desktop-ui: replace multiplier sizing with viewport sizing and re-add manual integer scaling ratios
Replace the old fixed multiplier window sizing model with configurable
viewport sizing.

Window sizes are now stored as target viewport dimensions rather than
being derived from the emulated screen. Standard presets have been
provided, as well as the option to specify a custom size.

Adaptive sizing has been reworked to treat the window size as target
bounds, the actual window will dynamically grow or shrink within this
boundary to preserve the correct aspect ratio.

Oversized window recovery has been changed to respect aspect ratio
and available workspace rather than a hardcoded reducton from the
monitors geometry.
2026-05-24 20:29:39 +01:00
Luke Usher bdd585a563 hiro: cleanup some macOS compile warnings and deprecation notices 2026-05-24 17:57:20 +01:00
Luke Usher 54fc194182 desktop-ui: persist SDL joypad mappings by GUID slot
Add an optional stable text identifier to HID devices and use it for
persisted input mappings when available.

SDL joypads now expose a GUID/slot identifier, so newly saved controller
mappings no longer depend on SDL serial or device path values that can
change across disconnects, reconnects, or app launches. This keeps
multiplayer controllers distinguishable by assigning slots per matching
GUID while avoiding unstable path-derived IDs.

The input mapping parser remains backward compatible with existing
numeric 0x<deviceID>/<group>/<input> mappings. Drivers that do not set a
stable identifier continue to save and load mappings using the existing
numeric HID device ID format.
2026-05-24 17:38:35 +01:00
user 4c39ca23eb gba: skip rendering sprites that are offscreen horizontally 2026-05-24 17:02:16 +01:00
user 8ea87c75e4 gba: implement OAM stage timings for OBJ engine 2026-05-24 17:02:16 +01:00
Morilli 7f0f91b3da sfc: fix ppu horizontal offset in high-resolution offset-per-tile mode 2026-05-23 16:00:34 +01:00
Luke Usher 164f5648bf ruby: stabilize joypad identity and duplicate device handling for the SDL driver 2026-05-21 14:45:20 +01:00
Luke Usher 19cce7dbba ld: fix LaserActive video seeks after CD-ROM refactor 2026-05-20 20:05:50 +01:00
Giovanni Bajo 765c0d4181 n64: fix partial load/stores in little-endian mode
Uncovered by new tests in n64-systemtest. The JIT wasn't tested because
little-endian is only supported in user-mode for now (RE=1), where
memory accesses must go through TLBs so they currently are not JIT'd.
Anyway the fix should be correct if we eventually uncover full
little-endian mode (with BE=0).
2026-05-18 19:44:25 +01:00
Luke Usher fbc8f22821 desktop-ui: default overscan to true
More natural window aspect by default, especially in PAL regions.
2026-05-17 19:41:04 +01:00
Luke Usher 14f4fc0173 desktop-ui: add direct input mapping mode with VirtualPad fallback
(AKA core-specific input mappings!)

Also adds support for direct input devices that bypass VirtualPad entirely, currently used for Mahjong
2026-05-17 19:40:33 +01:00
user 6920622b7e gba: add OAM to memory viewer 2026-05-17 19:17:02 +01:00
Giovanni Bajo c42bb2626d n64: implement VR4300 reverse-endian mode
This is a mode available only in the user mode, activated when RE=0. It
facilitates running MIPS binary code that was build for a little-endian
architecture, assuming that the code/data was 8-byte swapped in memory
before running it.

It passes the new RE tests in n64-systemtest
2026-05-17 19:16:48 +01:00
Morilli d45be3297f sfc: Improve autojoypad polling accuracy 2026-05-11 10:57:30 +01:00
remutro 54adf82264 Update libchdr to version 0.3.0 2026-05-11 10:56:14 +01:00
remutro 7d1bbf7c04 Update libchdr to version 0.3.0 2026-05-11 10:56:14 +01:00
remutro d17ae2f36d Update libchdr to version 0.3.0 2026-05-11 10:56:14 +01:00
remutro b9f8347d57 Update libchdr to version 0.3.0 2026-05-11 10:56:14 +01:00
Giovanni Bajo 41af52ec27 n64: improve CPU JIT documentation 2026-05-11 10:53:35 +01:00
Giovanni Bajo 87daf87fbb n64: decrease a bit jit interleaving (unfreeze conker) 2026-05-11 10:53:35 +01:00
Giovanni Bajo 2a5b9fe74e n64: fix interrupt generation to never happen mid-instruction 2026-05-11 10:53:35 +01:00
Giovanni Bajo bb91ff1136 n64: fix a few cases where interrupt latency was still higher than expected 2026-05-11 10:53:35 +01:00
Giovanni Bajo 5d7496c6f1 n64: change CPU JIT flush message 2026-05-11 10:53:35 +01:00
Giovanni Bajo 18692c3ced n64: increase JIT interleaving and add more forced syncs on MMIOs 2026-05-11 10:53:35 +01:00
Giovanni Bajo bc3af76716 n64: reduce interrupt latency to zero in JIT 2026-05-11 10:53:35 +01:00
Giovanni Bajo 03dd55bbda n64: in CPU JIT, correctly declare 6 scratch registers (and don't use 7th) 2026-05-11 10:53:35 +01:00
Giovanni Bajo ffab36ed99 n64: in CPU JIT, verify internal assumptions on block links 2026-05-11 10:53:35 +01:00
Giovanni Bajo 8ad8803765 n64: in CPU JIT, implement LL/SC/LLD/SCD 2026-05-11 10:53:35 +01:00
Giovanni Bajo 3198e0e88e n64: in CPU JIT, rewrite branches to use branchless code 2026-05-11 10:53:35 +01:00
Giovanni Bajo 999d858fa7 n64: in CPU JIT, extend blocks also beyond jump and links 2026-05-11 10:53:35 +01:00
Giovanni Bajo a752515d2d n64: bump serializer 2026-05-11 10:53:35 +01:00
Giovanni Bajo 2460b01b27 n64: in CPU jit, synchronize CPU/RSP on status and semaphore I/O 2026-05-11 10:53:35 +01:00
Giovanni Bajo 2af310528b n64: in CPU JIT, fix LWR.
Also fix it in interpreter to align to newly tested corner case
(non sign-extended input).
2026-05-11 10:53:35 +01:00
Giovanni Bajo a1be16873f n64: in CPU JIT, compute homebrew dcache dirty mask after stores
Avoid keeping the dirty-byte mask live across store fast paths in
jitMemoryOpcode. Compute it at the end from Rs+i16 so temporary
register clobbers (eg. SDC1/SWL/SWR) cannot corrupt dirty tracking and
lead to stale cache data.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 8b4f1fa16e n64: CPU now has configurable interleaving with the rest of the hardware 2026-05-11 10:53:35 +01:00
Giovanni Bajo 882fc4df1f n64: split recompiler in three files 2026-05-11 10:53:35 +01:00
Giovanni Bajo 997077527b n64: in CPU JIT, cleanup to remove redundant structure fields 2026-05-11 10:53:35 +01:00
Giovanni Bajo dd834d2c5d n64: revisit integration between JIT and gdb to improve performance 2026-05-11 10:53:35 +01:00
Giovanni Bajo 50b9786587 n64: make sure events inserted in the queue affect JIT timings 2026-05-11 10:53:35 +01:00
Giovanni Bajo fbb6e72e02 n64: in CPU JIT, fix a bug in TLB handling (eg: Linux)
Now that the JIT can hardcode PC in generated code, each block is valid
for a single vaddr. It can't be reused.
2026-05-11 10:53:35 +01:00
Giovanni Bajo c152ef5639 n64: in CPU JIT, simplify decoder removing dead code 2026-05-11 10:53:35 +01:00
Giovanni Bajo 49af8ab6a2 n64: in CPU JIT, blocks now extend through branches
Terminals are now only hard jumps and the special opcodes that change
state key, timers, etc.

Internal branch targets in each block are also registered as JIT
entrypoints.

Opportunistic branch linking is now removed as not useful anymore.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 68134837d4 n64: avoid excessive JIT trashing by reducing the 4K section granularity 2026-05-11 10:53:35 +01:00
Giovanni Bajo bb75c2f058 n64: in CPU JIT, do not emit pipeline prologue for linear instructions 2026-05-11 10:53:35 +01:00
Giovanni Bajo 105e8da924 n64: in CPU JIT, make epilogue code conditional in fast paths 2026-05-11 10:53:35 +01:00
Giovanni Bajo b0de6c11d2 n64: in CPU JIT, return pipeline information from emit functions 2026-05-11 10:53:35 +01:00
Giovanni Bajo b89a0bcce1 n64: in CPU JIT, add SDL/SDR/SWL/SWL/SWC1/SDC1 2026-05-11 10:53:35 +01:00
Giovanni Bajo 04f8b9cb4d n64: implement LWL, LWR, LDL, LDR, LWC1, LDC1 in JIT 2026-05-11 10:53:35 +01:00
Giovanni Bajo c139a4d4ad n64: in CPU JIT, use JIT-time PC for branches as much as possible 2026-05-11 10:53:35 +01:00
Giovanni Bajo 28f05b0297 n64: in FPU JIT, optimize comparisons 2026-05-11 10:53:35 +01:00
Giovanni Bajo 39b5d798b9 n64: in FPU JIT, implement compare opcodes (first draft) 2026-05-11 10:53:35 +01:00
Giovanni Bajo 7e5841d84a n64: in FPU JIT, add MOV.S/MOV.D implementation 2026-05-11 10:53:35 +01:00
Giovanni Bajo 8c3961cd6e n64: in FPU JIT, add comments and slight tweaks to underflow fixup 2026-05-11 10:53:35 +01:00
Giovanni Bajo e6517f5f57 n64: in FPU JIT, reduce input checks required for conversion opcodes 2026-05-11 10:53:35 +01:00
Giovanni Bajo cd604bf619 n64: in FPU JIT, reduce fallbacks to C++ for conversions in most occurrences 2026-05-11 10:53:35 +01:00
Giovanni Bajo 85008a663e n64: in FPU JIT, simplify a bit conversion opcodes 2026-05-11 10:53:35 +01:00
Giovanni Bajo 8031dcd3f2 n64: fix a benign typo in FCVT_D_L
It went unnoticed because it's basically re-running the same conversion
of the CHECK_FPE line, and probably rounding modes don't matter enough.
2026-05-11 10:53:35 +01:00
Giovanni Bajo f0b8a36b6a n64: implement float/int conversions in FPU JIT 2026-05-11 10:53:35 +01:00
Giovanni Bajo 36aed53124 n64: in FPU JIT, implement ALU double opcodes 2026-05-11 10:53:35 +01:00
Giovanni Bajo 1d8c89a50f n64: refactoring and cleanup of FPU JIT opcode emission 2026-05-11 10:53:35 +01:00
Giovanni Bajo 60007e8853 n64: in FPU JIT, implement FADD.S and FSUB.S 2026-05-11 10:53:35 +01:00
Giovanni Bajo 3542371b76 n64: in FPU JIT, unity 1/2 arity codepaths 2026-05-11 10:53:35 +01:00
Giovanni Bajo a8882a1d89 n64: in FPU JIT, add support for MUL.S and DIV.S 2026-05-11 10:53:35 +01:00
Giovanni Bajo 86fa83fc2b n64: in FPU JIT, implement passthrough of flag bits from host processor 2026-05-11 10:53:35 +01:00
Giovanni Bajo 71ddda52b5 n64: simplify FPU JIT by moving some code into nall/recompiler 2026-05-11 10:53:35 +01:00
Giovanni Bajo be0504e1c2 n64: start implementation of FPU JIT for amd64 too 2026-05-11 10:53:35 +01:00
Giovanni Bajo a34a6ab1df n64: implement initial FPU JIT, for ARM64 2026-05-11 10:53:35 +01:00
Giovanni Bajo 515cb06729 n64: in CPU JIT, remove the deferred pc/nextpc/pipeline materialization
While provably useful, the implementation is completely confusing. We
need to rework it from scratch at some point. The way it is written
now, it impedes further progress in other areas.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 2d852d6a9b n64: refactor to remove obsolete decoder JIT flags 2026-05-11 10:53:35 +01:00
Giovanni Bajo 5b8abb5717 n64: in JIT, add optimizations for accesses via $sp/$gp 2026-05-11 10:53:35 +01:00
Giovanni Bajo 496409c199 n64: implement also memory store opcodes in JIT 2026-05-11 10:53:35 +01:00
Giovanni Bajo 9e6be60b9e n64: implement all aligned load opcodes in JIT 2026-05-11 10:53:35 +01:00
Giovanni Bajo fdbd036bd1 n64: in JIT, remove confusing callf macro 2026-05-11 10:53:35 +01:00
Giovanni Bajo f241c4095d n64: optimize dcache to use a single word with both tag and valid bit 2026-05-11 10:53:35 +01:00
Giovanni Bajo 094454e52f n64: add JIT for LW as a first experiment 2026-05-11 10:53:35 +01:00
Giovanni Bajo dabeb68387 n64 cpu: inline MFC1/MTC1/DMFC1/DMTC1 in the JIT when COP1 is enabled.
Emit loads and stores directly against fpu state via sreg(2), using the same
full- versus half-mode register layout as the interpreter (word selection and
pairing). COProcessor-unusable blocks still call the C++ helpers. Skip GPR
writes when MFC1/DMFC1 targets $zero. FPU word offsets use CPU::r64 in offsetof
to avoid colliding with the host Real type at file scope.
2026-05-11 10:53:35 +01:00
Giovanni Bajo cc82697f00 n64: in CPU JIT, inline icache management 2026-05-11 10:53:35 +01:00
Giovanni Bajo e3f4d6dc0d nall: add mov128 and mem0 for absolute addressing 2026-05-11 10:53:35 +01:00
Giovanni Bajo b698206d07 n64: in CPU JIT, inline fastpath of icache hit check 2026-05-11 10:53:35 +01:00
Giovanni Bajo 7451ccbc98 n64: in CPU JIT, simplify branch link management 2026-05-11 10:53:35 +01:00
Giovanni Bajo 6448413adf n64: JIT multiply/divide SPECIAL opcodes via SLJIT
Add generic LMUL and DIVMOD helpers (32/64, signed/unsigned) and emit fast paths for MULT/MULTU, DIV/DIVU, DMULT/DMULTU, DDIV/DDIVU. Reserved-instruction and divide-by-zero cases stay on interpreter slow paths; DDIV avoids host INT64_MIN/-1 idiv overflow. Decoder no longer marks these opcodes as JitUseCallf or JitAddsExtraCyclesInternally.
2026-05-11 10:53:35 +01:00
Giovanni Bajo d91f838e3b n64: lazily emit callf setup in CPU JIT
Move callf synchronization to the paths that actually emit helper calls, and keep slow-path callf state restoration explicit. Rename jitMayCallf to jitUseCallf so the flag name matches its eager-call semantics.
2026-05-11 10:53:35 +01:00
Giovanni Bajo fc820aba6b n64: centralize JIT callf setup
Route opcode helper calls through a shared setup path that materializes PC and flushes deferred state on demand, so callf overhead is emitted where calls actually occur.
2026-05-11 10:53:35 +01:00
Giovanni Bajo a61dba8ec8 n64: JIT 64-bit shifts and trap opcodes
Move trap exception cases to deferred slow paths and generate direct JIT code for the remaining 64-bit shift immediates, keeping reserved-instruction handling and R0 writeback behavior on the fast path.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 025cde8961 n64: JIT more 64-bit integer ALU operations
Expand CPU JIT codegen for DADDIU, DSLLV/DSRLV/DSRAV, DADDU, DSUB, and DSUBU while preserving exact overflow and reserved-instruction behavior through helper fallbacks. Factor 64-bit reserved-instruction gating into a shared helper and collapse duplicated slow-path conditions to keep hot paths compact.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 2f8659a375 n64: optimize CPU JIT ALU slow paths
Move ADD/ADDI/DADD/DADDI hot paths to direct codegen with deferred slow-path helpers so overflow and reserved-instruction behavior stay exact without polluting the hot block body. Centralize state-key bit semantics in a typed accessor wrapper so JIT-time folding no longer depends on hardcoded bit masks.
2026-05-11 10:53:35 +01:00
Giovanni Bajo f1eff7d2f0 n64: gate JIT pipeline state machinery on demand
Emit state test/update and endblock jumps only when branch/helper pipeline semantics are active, removing these control-flow overhead ops from the linear hot path.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 0d3caa546c n64: defer nextpc materialization in JIT hot path
Accumulate linear nextpc advances and flush only when current PC is needed, removing per-opcode nextpc materialization on the fast path. Also rematerialize helper call PC directly from vaddr in the linear non-delay-slot case.
2026-05-11 10:53:35 +01:00
Giovanni Bajo e7444fd852 n64: lazily commit ipu.pc in JIT loop
Commit architectural PC only for branch/helper/terminal paths while preserving exception PC correctness for helper calls and delay slots. This removes unconditional per-opcode ipu.pc stores on the linear hot path.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 55ac593102 n64: materialize CPU pipeline pc only when needed
Keep pipeline pc writes on branch/helper paths, and commit linear opcode ipu.pc from nextpc-4 to reduce per-opcode JIT overhead while preserving n64-systemtest behavior.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 4ed8a7792c n64: flush deferred CPU cycles only on branch/helper opcodes
Skip per-opcode deferred-cycle flushes for straight-line instructions while keeping EndBlock checks unchanged, reducing hot-loop helper-call overhead without regressing system tests.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 161f01fa0d n64: restore unconditional CPU JIT endblock checks
Revert conditional EndBlock test and epilogue gating in the CPU JIT loop to preserve control-flow behavior and keep the system tests passing.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 606151f79d n64: add virtual PC materialization in CPU JIT loop 2026-05-11 10:53:35 +01:00
Giovanni Bajo b00b1778d1 n64: avoid unconditional JIT step flush in hot loop
Only flush deferred cycles at the per-opcode boundary when an EndBlock check is needed, reducing helper-call overhead on straight-line JIT code.
2026-05-11 10:53:35 +01:00
Giovanni Bajo dc4af1ddad n64: gate JIT EndBlock checks on branch and helper ops
Skip emitting EndBlock test/jump in straight-line instructions where state cannot request block termination, reducing hot-loop overhead while preserving control-flow correctness.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 6b88fdfbbf n64: remove CPU JIT metrics instrumentation
Drop JIT metrics counters and reporting from the CPU recompiler to keep the hot-path code easier to read while preserving runtime behavior. This also keeps the architectural state commit path in emit() minimal by removing duplicated commit emission.
2026-05-11 10:53:35 +01:00
Giovanni Bajo edf712f2f6 n64: extend JIT branch linking to dual targets
Model taken and not-taken link edges per block so conditional branches can be linked by final PC, and add finer diagnostics for no-direct-link causes. Also inline BC1 JIT branch handling with deterministic cause clearing layout checks to reduce unsupported FPU branch cases without regressing exception behavior.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 70f1cf07c5 n64: add safe intra-section JIT block linking
Link JIT blocks lazily within sections with state-key matching and pending backpatches to cut dispatcher overhead. Gate linked jumps on dirty sections, clock/queue budget checks, and unsafe delay slots while adding detailed diagnostics on link misses and candidate coverage.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 6d6c5d5fad n64: refactor CPU JIT to introduce 4K sections and state key 2026-05-11 10:53:35 +01:00
Giovanni Bajo 3a44a460bd n64: add JIT documentation 2026-05-11 10:53:35 +01:00
Giovanni Bajo 8655d4027f n64: convert remaining CPU branch opcodes to JIT
Convert all remaining integer branch and branch-likely opcodes to direct JIT emission and update decoder JIT flags, while intentionally keeping BC1 on the callf path.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 271e545a49 n64: convert four CPU branches to JIT and silence offsetof warnings
Convert BGTZ, JR, BLTZ, and BGEZ to direct JIT branch emission and update decoder Jit flags accordingly, then extend invalid-offsetof suppression across cpu/recompiler.cpp to match the RSP pattern.
2026-05-11 10:53:35 +01:00
Giovanni Bajo 6b97edc9db n64: convert four more CPU branches to JIT
Convert J, JAL, BNE and BLEZ to direct JIT emission and update decoder metadata so these opcodes no longer follow the callf flush path.
2026-05-11 10:53:35 +01:00
Giovanni Bajo e4f4a7d657 n64: convert BEQ to JIT 2026-05-11 10:53:35 +01:00
Giovanni Bajo 861020eeb7 n64: initial cleanup of CPU JIT, introduce opcode decoder 2026-05-11 10:53:35 +01:00
Dragorn421 0dc20693e2 Remove "eat stdin" behavior on exit 2026-05-06 12:39:56 +01:00
Dragorn421 08746292c7 Fixup nall/nall/gdb/Readme.md (fix #1360) 2026-05-04 13:08:55 +01:00
Dragorn421 e2636505e2 Fixup versionconfig.cmake: pass --no-show-signature to the git command for getting the commit date 2026-04-30 10:40:59 +01:00
Dragorn421 2219f48fca emux v1.1: remove dashes from instruction names (#2518)
New emux spec location, for reference: https://n64brew.dev/wiki/Emux
2026-04-29 10:31:26 +02:00
Luke Usher 91c64bf350 mia: refactor identify to support when multiple systems use the same file extension
Update desktop-ui so that it prompts the user for the desired system if multiple results were returned, ignoring hidden systems.
2026-04-28 16:23:02 +01:00
kev4cards 6f6786e04f n64: add comment to fastSUV use with respect to SPV 2026-04-27 18:47:08 +01:00
remutro 7974cabb43 Minor Qt6 on Linux cleanup 2026-04-27 18:45:33 +01:00
remutro a8ae8fe83f Add ISViewer RAM to save states 2026-04-23 21:06:11 +01:00
remutro e7cdf9c046 Update dependencies (post-v147-2) 2026-04-23 18:19:26 +01:00
Giovanni Bajo 93c397dca7 n64: bump serializer 2026-04-23 18:19:14 +01:00
Giovanni Bajo c9f2773685 n64: silence invalid offsetof warnings 2026-04-23 18:19:14 +01:00
Giovanni Bajo 652d653736 n64: RSP JIT cleanup and add emux tracing support
Verbose refactoring to only use decoder.cpp for extracting information
from opcodes (removing isTerminal and the return value of emit functions).

Added tracing to the cache index so that we basically version the JIT
blocks depending on whether it is enabled or not. This allows to
implement support for emux tracing without overhead.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 219dff38ad n64: refactor load/store opcodes to make better use of constant addresses 2026-04-23 18:19:14 +01:00
Giovanni Bajo c5ca614492 n64: add LRV/SRV/SWV to RSP JIT 2026-04-23 18:19:14 +01:00
Giovanni Bajo 0fca58b98e n64: add LTV/STV to RSP JIT 2026-04-23 18:19:14 +01:00
Giovanni Bajo 5d04cd3808 n64: add RSP JIT for LFV/SFV 2026-04-23 18:19:14 +01:00
Giovanni Bajo 59a0a898e9 n64: add LHV/SHV in RSP JIT, and refactor LUV/LPV/SUV/SPV to always use SIMD 2026-04-23 18:19:14 +01:00
Giovanni Bajo a6499c3b49 nall: fix build on msvc and GCC 13 2026-04-23 18:19:14 +01:00
Giovanni Bajo 310b665160 n64: add LDV/SDV RSP JIT opcodes 2026-04-23 18:19:14 +01:00
Giovanni Bajo b96b8ac7da n64: add LSB/LSV/LLV/SSB/SSV/SLV RSP JIT opcodes 2026-04-23 18:19:14 +01:00
Giovanni Bajo d20a0e1b8e n64: add LUV/LPV/SUV/SPV RSP JIT opcodes 2026-04-23 18:19:14 +01:00
Giovanni Bajo 716d417359 n64: use sreg(3) in RSP JIT to hold the DMEM pointer 2026-04-23 18:19:14 +01:00
Giovanni Bajo 1b6893ea49 nall: allow a recompiler to define a different number of saved registers 2026-04-23 18:19:14 +01:00
Giovanni Bajo fef2ab4904 n64: in RSP, add JIT for lqv/sqv
This generates optimized codepaths for lqv and sqv. It also relies on
constant tracking to optimize situations where the base address is
know at JIT time (very common) and we can thus prove its alignment.
2026-04-23 18:19:14 +01:00
Giovanni Bajo cbf9f79e5f n64: add constant tracking in RSP JIT
The JIT now tracks constant registers within each recompiled blocks.
This is currently unused in the generated code, will be useful to
improve code generation for vector load/stores opcodes.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 4c4c5460bc nall: add support for register arguments to callf
This is non trivial because input arguments might mistakenly override
ABI registers. Prevent register argument clobber by resolving move
dependencies and breaking cycles with a temporary register.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 26d5ac3a80 n64: specialize R0 source propagation in RSP JIT
Fold R0-based scalar and branch fast paths into direct immediates/moves so the emitter skips unnecessary register reads and compares.
2026-04-23 18:19:14 +01:00
Giovanni Bajo f71568bad4 n64: annotate RSP op metadata for JIT state handling
Move UsesDmem and MayHalt traits into OpInfo so decoder metadata directly drives recompiler decisions, and simplify the JIT loop by unifying delay-slot state while documenting the current architecture and optimizations.
2026-04-23 18:19:14 +01:00
Giovanni Bajo a4ac042f27 n64: skip R0 writes in RSP JIT paths
Drop the JIT write-sink indirection and skip code emission when the destination is R0, while keeping side-effecting C++ helpers and guarding their writeback to preserve R0 semantics.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 25e248a6c3 n64: centralize RSP JIT misaligned access capability
Define a single architecture capability macro for unaligned scalar memory access and use constexpr slowpath selection helpers for half/word DMEM ops.
2026-04-23 18:19:14 +01:00
Giovanni Bajo f43063803b n64: gate RSP halted checks to relevant opcodes
Emit status.halted exit checks only for instructions that can mutate halt state (BREAK and MTC0 to SP_STATUS), reducing per-opcode overhead in the main JIT loop.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 9e20c21b35 n64: avoid VU preflush in RSP callf gate
Do not classify VU opcodes as callf preflush candidates so deferred clocks are only synchronized for paths that actually require clock-visible C++ calls.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 44ab78ade5 n64: defer RSP JIT clock flushes to slow paths
Track deferred clock progress for slow-path entries so memory fast paths avoid callf-triggered flushes while preserving correct timing when deferred fallbacks execute.
2026-04-23 18:19:14 +01:00
Giovanni Bajo c88d2eba79 n64: JIT scalar RSP DMEM ops with deferred fallbacks
Emit direct fast paths for LB/LBU/LH/LHU/LWU/SB/SH/SW and keep unaligned half/word cases in deferred slow paths, reducing callf overhead while preserving interpreter behavior.
2026-04-23 18:19:14 +01:00
Giovanni Bajo b1b51d3070 n64: re-emit RSP JIT slow paths via emitEXECUTE
Keep deferred slow-path records minimal and re-enter opcode emission in slow mode, reducing per-opcode slow-path boilerplate while preserving the compact LW fast path.
2026-04-23 18:19:14 +01:00
Giovanni Bajo dc8ac7d3dc n64: switch RSP DMEM accesses to big-endian semantics
Implement DMEM read/write paths with MSB-first word semantics and byte-accurate unaligned wrapping. Adjust RSP DMA DMEM transfers to use word paths consistent with the new DMEM representation while preserving IMEM behavior.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 3feb849778 n64: call branch epilogue directly in RSP delay slots
Replace the delay-slot call to instructionEpilogue<1> with explicit clock flush plus instructionBranchEpilogue, removing wrapper overhead while preserving delay-slot branch semantics.
2026-04-23 18:19:14 +01:00
Giovanni Bajo bc1009a5f1 n64: inline RSP JIT step clock update
Replace the JIT call to RSP::step with a direct thread clock increment while keeping deferred clock flushing behavior, reducing hot-path call overhead without changing interpreter behavior.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 1f06bbc156 n64: batch fixed RSP JIT clocks between call sites
Defer fixed clock stepping across pure inlined opcodes and flush before callf paths, delay-slot handling, halts, and block exit to preserve observable timing while reducing hot-path step calls.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 09bb1cbf3e n64: fold RSP conditional branch state masking writes
Emit the DelaySlot|EndBlock mask directly into branch state destinations for conditional branches, removing temporary state move instructions in the hot path.
2026-04-23 18:19:14 +01:00
Giovanni Bajo b66752b4fc n64: write RSP branch state directly outside delay slots
Emit branch state updates directly in non-delay-slot branch paths and avoid copying nstate into state in the non-delay-slot epilogue, reducing branch-state traffic in the hot path.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 97b9490845 n64: route RSP JIT branch targets by delay-slot phase
Pass delay-slot phase into EXECUTE/SPECIAL/REGIMM emitters so branch-like ops can write the active destination directly and remove redundant delay-slot branch.begin state traffic.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 6e7cf80f6e n64: virtualize RSP JIT block PC progression
Use compile-time next-PC values for non-delay-slot commits and avoid per-op branch.begin updates outside delay slots, reducing hot-path branch state traffic while preserving delay-slot behavior.
2026-04-23 18:19:14 +01:00
Giovanni Bajo d250931aae n64: simplify RSP JIT conditional target selection
Use a compact xor-mask select for conditional branch target/fallthrough selection, reducing generated hot-path instructions while preserving existing branch semantics.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 7163fb4dbb n64: use virtual fallthrough PC in RSP conditional branches
Replace runtime fallthrough reads from branch.nextpc with compile-time PC+8 immediates for REGIMM and EXECUTE conditional branches to remove extra hot-path memory dependencies.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 838f4c6ad2 n64: stabilize RSP virtual-PC branch targets in JIT
Include block base address in the RSP JIT hash and use compile-time branch targets for conditional branches so generated code stays correct while removing extra runtime target math.
2026-04-23 18:19:14 +01:00
Giovanni Bajo c5e5c38a8a n64: use compile-time PC for RSP link writes
Pass the current block PC into RSP JIT emitters and use compile-time PC+8 immediates for JAL/JALR/BLTZAL/BGEZAL link register writes while keeping existing branch flow unchanged.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 9f98c24394 n64: trim RSP JIT non-branch epilogue overhead
Skip branch state/pc commit work for non-branch non-terminal opcodes and simplify branch begin emission, and fix BLTZAL/BGEZAL when Rs aliases RA by deferring link write until after condition evaluation.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 86765b1706 n64: inline RSP JIT conditional branch opcodes
Emit BEQ/BNE/BLEZ/BGTZ and REGIMM conditional branches directly in JIT to remove per-opcode C++ calls while preserving delay-slot and link-register behavior.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 2585b4667f n64: inline simple RSP JIT jump opcodes
Emit J/JAL/JR/JALR branch updates directly in JIT so these terminal opcodes avoid C++ calls while preserving current delay-slot behavior.
2026-04-23 18:19:14 +01:00
Giovanni Bajo bc4332bbb9 n64: remove temporary RSP epilogue A/B switch
Drop the fastInstructionEpilogue runtime toggle now that the specialized JIT epilogue path is stable. Keep the delay-slot fallback path while making the optimized path the only code path.
2026-04-23 18:19:14 +01:00
Giovanni Bajo a3d75ad5da n64: specialize RSP JIT epilogue by delay-slot position
Choose the fast epilogue path at compile time for non-delay-slot instructions and keep the legacy path only for delay slots. This removes per-opcode branch-state dispatch in the hot path while preserving behavior.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 101ba34f28 n64: inline RSP epilogue slow-path clock accounting
Replace the slow-path JIT epilogue call with direct step/clocksTotal updates and a call to instructionBranchEpilogue, keeping branch exit semantics unchanged. This reduces call overhead while preserving behavior under the fast epilogue toggle.
2026-04-23 18:19:14 +01:00
Giovanni Bajo ece2001360 n64: widen RSP program counter storage
Store RSP IPU PC as 32-bit so JIT word-sized accesses cannot clobber adjacent state. This keeps the fast epilogue path behaviorally stable while preserving 12-bit address masking semantics.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 3e913fda53 n64: add toggled fast RSP instruction epilogue path
Add an A/B switch for a fast JIT epilogue path while preserving the legacy path as fallback, and widen branch pc storage so JIT word-sized accesses are safe. This gives a stable way to compare behavior and performance during further tuning.
2026-04-23 18:19:14 +01:00
Giovanni Bajo ec29392c11 n64: align RSP branch state with CPU pipeline model
Model RSP branch flow with pc/nextpc and latched state/nstate so interpreter and JIT follow the same delay-slot and end-block semantics. This stabilizes branch behavior while keeping stall and dual-issue logic unchanged.
2026-04-23 18:19:14 +01:00
Giovanni Bajo 536fe6964f n64: factor RSP branch epilogue handling
Extract branch-state commit logic into a dedicated helper so we can iterate on JIT epilogue changes from a stable, behavior-preserving baseline.
2026-04-23 18:19:14 +01:00
remutro 18be35d9e0 Fix incorrect setting 2026-04-23 12:49:58 +01:00
remutro c6596bc468 Fix PlayStation extensions 2026-04-23 12:49:58 +01:00
remutro 00bdc72562 Fix MMI extension loading and detection 2026-04-23 12:49:58 +01:00
NovaSquirrel 0394fd90ad snes: update SerializerVersion to v145 2026-04-18 13:47:54 +01:00
NovaSquirrel f27d62f841 snes: fix SGB register mirroring to match hardware
According to fullsnes, SGB only decodes A0-A3,A11-A15,A22
2026-04-18 13:47:54 +01:00
NovaSquirrel 874d32eb42 snes: fix SGB logic for moving to next player
This is supposed to fix #1205
2026-04-18 13:47:54 +01:00
NovaSquirrel 8e10f41188 snes: Fix Super Game Boy $6002 and $700x registers
The Super Game Boy only stores one packet, and packet acknowledgement is done by reading $7000, not $6002
2026-04-18 13:47:54 +01:00
ZengGengSen ad98f53f3b refactor: move reset state from MOS6502 to system-level CPU
Refactor reset handling to align with project architecture by removing the
'resetting' flag from the MOS6502 core. The reset state is now managed via
'resetPending' within the specific A2600 and Famicom CPU implementations.

- MOS6502: Remove resetting flag and internal reset logic from power().
- CPU: Introduce io.resetPending to handle reset triggers in the main loop.
- Debugger: Add interrupt/reset notification support for better tracing.
- Serialization: Update A26 (v140) and FC (v152) versions for state changes.
2026-04-09 13:01:38 +01:00
ZengGengSen 6e0fa73249 fc: add support for Dendy region
- Implement Dendy-specific timings: CPU divider 15, 312 total scanlines, and vblank starting at scanline 291.
- Refactor CPU/APU rate calculation to use a dynamic system divider instead of hardcoded PAL/NTSC checks.
- Add Dendy to the system region enumeration and UI emulator list.
- Handle Dendy-specific hardware differences: disable microphone input and adjust PPU aspect ratio/pixel output offset to match PAL-like characteristics.
- Clean up controller and system unloading logic to prevent memory leaks.
2026-04-08 09:12:51 +01:00
User 722f104fa0 gba: allow re-triggering keypad IRQ when input changes 2026-04-08 09:09:05 +01:00
Giovanni Bajo d55f80d633 n64: in emux, implement xioctl fast/slow
These can be used by testroms to automatically turn on fast forward mode
2026-04-07 08:53:16 +01:00
User 649a29debe gba: fix wave RAM bank selection 2026-04-04 08:56:02 +01:00
Giovanni Bajo dedc446418 n64: in emux, add detect mask for xioctl 2026-04-02 09:35:33 +01:00
Giovanni Bajo 16c5da5dc5 n64: implement emux on RSP
This implements a first subset of the emux extensions on the RSP. The
implementation is similar to the CPU one, and forwards to it things
that have to be identical.
2026-03-31 09:12:22 +01:00
Giovanni Bajo a0f762985e n64: add initial emux support
Emux is a spec for emulator extensions to help homebrew development.
The spec can be found here at the time of writing:
https://hackmd.io/@rasky/r1k7na6Jn

Usage of emux is gated behind the "homebrew development mode" setting.

This commit introduces support for several extensions on the CPU, but
none on the RSP yet.
2026-03-31 09:12:22 +01:00
Giovanni Bajo f76dd51134 n64: introduce RBusDevice for tracking devices accessing the RAM bus
For homebrew profiling features, we need to track what hardware device
is accessing the shared RDRAM. We do have this already for debugging
purposes as a string. This commit changes that to an enum.
2026-03-31 09:12:22 +01:00
Giovanni Bajo 103dd93ae4 ares: add an event to allow a core to request emulator shutdown
Normally, cores shouldn't be able to request the emulator to shut down
on the host computer, but this might be required for some homebrew
development features.
2026-03-31 09:12:22 +01:00
remutro 5f216a7bf5 Add Sega PAC firmware hashes for auto detection 2026-03-30 10:09:08 +01:00
User dfa6ec0c79 gba: improve affine parameter timings 2026-03-26 10:50:22 +00:00
User e011cbecbb gba: window accuracy improvements 2026-03-20 11:20:42 +00:00
Scott Mansell c2b349aeb8 cmake: Add missing include sources 2026-03-19 08:27:52 +00:00
remutro 6f0f7be867 Increase PCE Serialization Version 2026-03-18 14:57:43 +00:00
awsms bc86249658 desktop-ui: fix kiosk crash, ignore hotkeys while Tools window is focused 2026-03-18 12:19:06 +00:00
ZengGengSen 0ac4d8220c cmake: fix XAudio2 detection logic for MSVC vs non-MSVC toolchains
Previously the condition checked for MINGW, treating MSVC and all other
toolchains as a single "no detection needed" case. This inverts the
guard to MSVC, so that MSVC correctly skips detection (Windows SDK
provides xaudio2 directly) while MinGW and other non-MSVC toolchains
go through the CheckCXXSourceCompiles probe as intended.
2026-03-17 16:11:06 +00:00
ZengGengSen 1ce484be52 cmake: add FindXAudio2 module and fix debug symbol detection on MinGW
Add cmake/finders/FindXAudio2.cmake to replace the ad-hoc XAudio2
link logic in os-windows.cmake. On MinGW, the module uses
check_cxx_source_compiles to probe for xaudio2_9 and xaudio2_8 in
the sysroot; on MSVC and other toolchains the Windows SDK umbrella
library is used directly. An imported target XAudio2::XAudio2 is
exported so call sites need no platform conditionals.

Replace the generator-expression-based -gcodeview selection in
compilerconfig.cmake with an explicit check_cxx_compiler_flag probe
at configure time (ARES_COMPILER_SUPPORTS_GCODEVIEW). This avoids
passing -gcodeview to toolchains that do not support it and makes
the fallback to DWARF visible in the configure log rather than
silently resolved at build time.

- ruby/cmake/os-windows.cmake: call find_package(XAudio2) and
  consume XAudio2::XAudio2 via a generator expression; remove the
  old MSVC/else block that unconditionally linked xaudio2/xaudio2_9
- cmake/windows/compilerconfig.cmake: add -gcodeview capability
  probe; rewrite Clang and GCC debug-symbol blocks to branch on the
  cached result instead of a generator expression
2026-03-17 16:11:06 +00:00
awsms 899ac2a2ed desktop-ui: prevent hotkey from firing when setting one 2026-03-17 16:09:33 +00:00
Florian-Simon-RedArtGames ca6974b66f Fix glitch in City Hunter ROM in the intro in the performance-mode VDP
We were rendering background and sprites in burst mode, which shouldn't
happen.

I'm not the author, I'm just upstreaming changes done a member in our
team.
2026-03-17 16:08:37 +00:00
remutro 3d966bda8f Updated n64 serilization 2026-03-16 17:25:29 +00:00
remutro b11ee3fbdb Update serialized fields in N64 save states 2026-03-16 17:25:29 +00:00
User 3f8b0cae72 gba: slightly improve PPU timings 2026-03-16 17:25:20 +00:00
User 8261563a10 gba: fix mid-scanline toggling of background mosaic 2026-03-16 17:25:20 +00:00
remutro b15ce04e5d XAudio2 latency adjustment 2026-03-10 10:52:42 +00:00
ZengGengSen 7a515cd489 feat(fc): add support for JY Company and SC-127 boards
- Implementation of JY Company (Mapper 90, 209, 211) with support for
  complex PRG/CHR banking, IRQ counter modes, and math registers.
- Implementation of SC-127 (Wario Land II Kirby hack) with A12-based
  IRQ filtering.
- Enhanced CPU with `isWriting()` check and PPU with `isRenderingRead()`
  status to support advanced mapper timing.
- Updated MIA database to recognize iNES mappers 35, 90, 209, and 211.
2026-03-10 10:51:44 +00:00
Stefan Schlosser 5b7dafe70a CI: Update FreeBSD runner to 15.0
Update cross-platform-actions to v0.32.0 by using the explicit commit
https://github.com/cross-platform-actions/action/commit/492b0c80085400348c599edace11141a4ee73524

The change from 14.3 to a string literal '15.0' is mandatory, otherwise
the FreeBSD VM image cannot be fetched.
2026-03-08 16:35:08 +00:00
Luke Usher eaa47fbf9c a26: improve RIOT emulation, fixes Berzerk (likely others) 2026-03-06 21:14:18 +00:00
remutro bbc0c1db3b [PS1] Update state serialization 2026-03-06 18:57:35 +00:00
Giovanni Bajo b35a639e33 n64: adjust eeprom timings
Further hardware tests confirmed the EEPROMs are faster than initially
thought.
2026-03-06 15:23:54 +00:00
Giovanni Bajo 48b8c8a3ff n64: implement eeprom write timing and status flags
Currently Ares implements an infinitely fast EEPROM, but alas real
EEPROMs can take even 20 ms to save a single block of 8 bytes.

This commit implement approximate timings and the related flag to
notify the CPU that the EEPROM is busy writing data.
2026-03-06 10:07:41 +00:00
awsms 5a80359443 ruby(audio): enable SDL_HINT_NO_SIGNAL_HANDLERS to avoid ctrl+C hijacks 2026-03-06 10:07:23 +00:00
awsms 67163a9fbe ruby: enable SDL_HINT_NO_SIGNAL_HANDLERS to avoid ctrl+C hijacks 2026-03-05 13:56:48 +00:00
remutro 0d1c90c616 Remove OpenGL macOS Video Driver 2026-03-04 13:06:56 +00:00
awsms 3678a4cc07 Introducing --kiosk mode (#2433)
Introduce a `--batch` command-line option to run with a minimal presentation for frontend-driven launches (eg EmulationStation, arcade cabinets etc).

Behavior
- `--batch` implies `--no-file-prompt`
- Requires at least one valid game path (otherwise exits with a clear error)
- Uses a minimal presentation:
  - hides menu bar
  - removes status bar
  - black background / centered viewport
  - keeps file-open and drag/drop support
- Skips constructing settings/tools/game-browser windows in batch

Runtime safety
- Batch mode avoids UI-only flows where possible (logs messages instead)
- Driver and load/identify failures trigger a clean batch exit path
- Runtime defocus checks now use `settings.input.defocus` instead of `driverSettings.*.checked()`:
  - avoids dereferencing non-constructed UI widgets in batch
  - fixes batch crash from UI-state reads on non-UI code paths
2026-03-04 13:06:36 +00:00
Luke Usher c0a0f34439 ps1: fix some gpu clocking issues 2026-03-01 04:11:18 +00:00
Luke Usher 640ea5e3fa ps1: fix spu canReadDMA/canWriteDMA flags 2026-02-28 23:32:36 +00:00
Luke Usher cb40c6487b ps1: fix block dma using incorrect timing 2026-02-28 23:32:16 +00:00
Luke Usher 1570af44e2 ps1: fix incorrect bit position for dma channel chopping enable 2026-02-28 23:31:52 +00:00
Luke Usher d00c9feeac ps1: fix an issue where configured io access timing for exp1, exp3, bios, cpu, cdrom and exp2 would not apply 2026-02-28 23:30:24 +00:00
Luke Usher b308958bf0 cdrom: refactor CD-ROM session generation and image file handling
- Stop mixing time/address bases; we inconsistently treat LBA 0 as both 00:00:00 and 00:02:00.
 - Clearly separate logical and physical domains:
    - MSF: The MSF implementation assumes absolute MSF (lba 0 = 00:02:00)
    - LBA: logical addressing  (LBA 0 = Track 1 Index 01 / 00:02:00)
    - ABA: absolute addressing (ABA 0 = Track 1 Index 00 / 00:00:00)
 - Fix subchannel generation and support negative MSF (90–99)
 - Fix discs with non-default track 01 index 01 lba
2026-02-28 21:27:54 +00:00
Luke Usher 9125d0c79f ps1: rework cd-rom emulation 2026-02-28 21:27:53 +00:00
User ee80782345 gba: refactor bus reads 2026-02-28 09:45:06 +00:00
meauxdal b5fd6611f2 Update serialization.cpp 2026-02-27 19:55:12 +00:00
Luke Usher 12558c7ef3 gpu: fix hblank timing 2026-02-24 20:54:53 +00:00
awsms 99733cda7c fix abort on exit caused by invalid mutex unlock
`Program::quit()` could call `unlock()` on a `unique_lock` that did not own
the mutex, triggering `std::system_error` ("Operation not permitted")
and terminating the process on exit.

Guard the `unlock()` call with `owns_lock()`.
2026-02-24 12:03:13 +00:00
awsms 1482689f09 ps1: enable scheduler synchronization
Call scheduler.setSynchronize(synchronize) during PS1 serialization
to match the behavior used by other cores.

Without synchronized serialization, coroutine/thread state may be
captured inconsistently, which can lead to crashes or undefined
behavior when loading savestates after relaunch.

Bump serializer version to v147 to invalidate incompatible v146
savestates created without scheduler synchronization.
2026-02-24 12:02:43 +00:00
Alex Bates a1d3fc19a2 n64: fix return GDB read result for RCP/PI bus path
The multi-byte read handler for the RCP/PI address range
(0xA4000000-0xBFFFFFFF) correctly fills the result buffer via
bus.read<Word> but then falls through to `return {}` instead
of returning the result. This causes GDB memory reads from ROM
cartridge addresses to return empty responses.
2026-02-23 19:15:23 +00:00
User 103770a995 gba: prevent instruction tracing from modifying open bus 2026-02-21 08:25:49 +00:00
Le-Syl21andClaude Opus 4.6 38a2e62603 Fix Linux shader install: copy contents instead of directory
CMake install(DIRECTORY "path") without a trailing slash copies the
directory itself, creating an extra shaders_slang/ level under Shaders/.

Adding a trailing slash makes it copy the contents directly, consistent
with macOS (ditto) and Windows (copy_directory) which both copy contents.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-16 08:22:39 +00:00
meauxdal ae41a43567 n64: fix audio pops when AI DMA ends
On a real console, when the AI DMA ends, even if the volume is not zero,
there is a decay happening on the analog path that doesn't cause any
audible pops. This can happen in games when they fail to meet the
audio deadline and schedule a new buffer before the previous one ends.
2026-02-15 22:53:40 +01:00
TascoDLX 08a7253e99 md: fix screen in interlace mode 1 2026-02-13 13:30:28 +00:00
remutro ba6069686f add missing file 2026-02-08 17:32:01 +00:00
remutro 6bb521a207 Import & export settings in the UI 2026-02-08 17:32:01 +00:00
remutro fac53a08ca Windows OpenGL 4.6 Core Profile Driver 2026-02-08 17:31:32 +00:00
izzy d67a92b2b4 make lambda more concise and strict 2026-02-08 17:31:12 +00:00
remutro ffee6d658d Fix fast forward getting stuck 2026-02-03 17:23:58 +00:00
remutro 58f3d7badf Exclude additional systems from using Run-Ahead 2026-02-03 17:23:36 +00:00
remutro 388e98fba9 Fix bug with disabling of secondary media 2026-01-30 06:40:08 +00:00
remutro f883420714 sort emulator cores by manufacturer 2026-01-30 06:40:08 +00:00
remutro d99f7598e1 macOS looks better using same value as Windows 2026-01-30 06:40:08 +00:00
remutro 64bfe58e03 Cleanup UI text and controls 2026-01-30 06:40:08 +00:00
meauxdal d05f7b64b4 Update vulkan.cpp 2026-01-28 07:55:22 +00:00
User bc036dcaf6 gba: improve handling of OBJ mosaic counters 2026-01-28 07:53:43 +00:00
User 64cebdad77 gba: fix interaction between OBJ mosaic and priority 2026-01-28 07:53:43 +00:00
remutro e594251208 add version string to end of help message 2026-01-27 10:12:38 +00:00
remutro cea26bd150 add option to print version string 2026-01-27 10:12:38 +00:00
remutro 27905a8fc7 Add ability to change disc for ldrom2 titles 2026-01-27 10:12:25 +00:00
remutro 2f2704b2b6 adjust string placement 2026-01-27 10:10:10 +00:00
remutro 5afa255ab8 logo alignment in about 2026-01-27 10:10:10 +00:00
remutro daa781706a Use lambda for sort comparer 2026-01-20 11:54:06 +00:00
remutro 88bd798427 Sort once when vector is created 2026-01-20 11:54:06 +00:00
remutro d77c8b1c56 Sort the emulators setting list also 2026-01-20 11:54:06 +00:00
remutro e07f18c172 Sort the emulator list in firmware settings 2026-01-20 11:54:06 +00:00
remutro 6bc13e8d66 Fix crash opening about window 2026-01-20 10:37:42 +00:00
remutro 25482bc539 Single xaudio2 source file, fix vector calls in asio.cpp 2026-01-19 14:34:34 +00:00
remutro 847e2a24cf Fix silly mistake 2026-01-19 14:34:34 +00:00
remutro 514933d459 Fix MSVC Linking 2026-01-19 14:34:34 +00:00
remutro 04e4f0ffa0 Fix MSVC builds 2026-01-19 14:34:34 +00:00
remutro 109c669056 Update XAudio2 from 2.1 to 2.9 2026-01-19 14:34:34 +00:00
Giovanni Bajo fb68c74143 n64: with homebrew header, don't default to install a controller pak
When the homebrew header was first introduced, in its first limited
spec, Ares defaulted to enable both rumble pak and controller pak:
https://github.com/ares-emulator/ares/commit/bc8c308ee96162f5a7068001a0ece83e5f821e16

Back at the time, there wasn't any way to specify that a controller pak
was needed by the ROM, and Ares didn't even provide a GUI to install it.
So basically this was the only way to allow a homebrew game to use
the controller pak at all.

Fast forward 4 years and now we have a GUI to select which pak to install
on each controller, and the homebrew header allows to pre-install whatever
you want into each port.

In case the user doesn't specify a suggested controller configuration
in the homebrew header, the default of using a controller pak has the
annoying side effect of creating a useless .sav file next to any ROM.
CPak is not very common in homebrew ROMs anyway, so enabling it by
default now seems to create more hassle than it solves.
2026-01-19 14:34:02 +00:00
remutro acdf31b40a Stay in pseudo-fullscreen when game is reset 2026-01-18 00:04:56 +00:00
remutro 48c611c90b Fix optnone attribute warning 2026-01-15 12:55:37 +00:00
remutro f338f50b4d some refactoring 2026-01-14 11:36:53 +00:00
remutro f0b119d90a Fix mapped drives not working after symlink fix (Windows) 2026-01-14 11:36:53 +00:00
remutro e8c268026c Update current save slot on successful save state load 2026-01-14 11:33:30 +00:00
remutro 9387eab814 Add command line option to specify a save state slot to load 2026-01-14 11:33:30 +00:00
remutro d769abafd9 Update hotkey text 2026-01-14 11:33:06 +00:00
remutro 742ab90d21 rogue spaces removed 2026-01-14 11:33:06 +00:00
remutro 2a346af4e2 Add hotkey to disable/enable selected shader 2026-01-14 11:33:06 +00:00
Giovanni Bajo df5ebc9245 n64: implement support for region-free ROMs (homebrew extension)
The advanced homebrew header (https://n64brew.dev/wiki/ROM_Header)
specifies a bit to mark a ROM as "region free", meaning that it can be
booted in all regions. Ares now has a region preference option, so
that option can be respected for the region free ROMs.
2026-01-11 17:04:57 +00:00
Luke Usher 71f17d9a2a ps1: fix crash when saving/loading state 2026-01-09 21:00:32 +00:00
Luke Usher 4e7ab5d3e3 ps1: refactor core to use libco threading
- cpu: implemented memory timing/control registers
 - cpu: update bus accesses to obey memory timing registers
 - cdrom: incorrect 150lba offset in command 0x14
 - cdrom: fix behavior when a command is issued before the previous has completed
 - cdrom: implement behavior where a new command cannot be executed until pending IRQ are acknowledged
 - cdrom: implement 'command/parameter busy' register
 - dma: update bus accesses to obey memory timing registers
 - dma: improve chopping/allowing the cpu to run between blocks of a long transfer
 - mdec: implement basic decode timing
 - mdec: implement correct input fifo behavior
 - mdec: fix behavior when an incomplete block is transferred via the input fifo
 - mdec: fix dma request registers, input/output full/empty registers, busy register
 - gpu: use correct clock frequency for PAL and NTSC
 - timer: improve behavior around timer overflow/target reached irq
2026-01-09 16:11:58 +00:00
remutro e5ffe61a07 Fix Dip Switches menu on Linux 2026-01-09 12:53:53 +00:00
remutro e601bccdfb Add pseduefullscreen command line argument 2026-01-09 10:27:41 +00:00
remutro 155c9b4154 Fix formatting 2026-01-09 10:27:31 +00:00
remutro 7b0e29baa9 Expose option to not prompt for secondary media in GUI 2026-01-09 10:27:31 +00:00
jsgroth 0152831319 m32x: adjust H32 pixel offset between Gen/MD VDP and 32X VDP
the adjusted offset is equal to 2.6 H32 pixels / 3.25 H40 pixels
2026-01-08 23:32:28 +00:00
remutro 17ce1bbe0f Fix loading shaders from the command line 2026-01-08 14:15:56 +00:00
remutro db953dbc62 minor format fixes 2026-01-08 09:27:05 +00:00
remutro 65ed77ecd7 Fix symlinks to files for rom loading 2026-01-08 09:27:05 +00:00
Luke Usher bdf4dc9ce1 desktop-ui: add '--settings-file' command line parameter 2026-01-07 10:32:43 +00:00
Luke Usher c01f3b885e desktop-ui: do not enable 'Arcade' if no arcade cores are compiled in. 2026-01-07 10:20:51 +00:00
Luke Usher 538078f6d0 ruby: prefer 'metal' video driver as both optimal and safest on macOS. 2026-01-07 10:11:43 +00:00
Luke Usher 2a4be17f56 ruby: remove erroneous include 2026-01-06 23:15:36 +00:00
ZengGengSen 9d647291fa add unload emulator to save the wav file 2026-01-06 16:32:21 +00:00
ZengGengSen 595de2e2aa fix new tape file resize bug 2026-01-06 16:32:21 +00:00
ZengGengSen 778e1f0b76 feat: add famicom data recorder support
1. add famicom data recorder support
2. refactor the tape control
3. fix the wav bug
2026-01-06 16:32:21 +00:00
User b5910c75f5 gba: prefetcher should fail reading across 128KiB boundaries 2026-01-06 16:21:35 +00:00
Luke Usher 23cd8772f5 ruby: allow drivers to set controller names and use deterministic device id in SDL driver 2026-01-06 12:09:44 +00:00
remutro 202db872de Add Cubivore English translation to N64 DB 2026-01-05 09:55:12 +00:00
remutro 934e9d36c3 Update dependencies (post-v147) 2026-01-02 16:21:26 +00:00
remutro 30066aa336 [SFC] Add support for GBC titles to the Super Game Boy 2025-12-31 12:33:22 +00:00
invertego cc4db18707 libco: limit scope of section hack to gcc
When placing co_swap_function byte array into the text section, libco
uses the trick of appending a # to the section name. This name string is
passed directly to the generated assembly and the # is treated as
comment token by the GNU assembler. This is a hack to avoid a warning
about changed section attributes.

This hack doesn't work with other compilers like Clang or TinyCC, but
unlike GCC they don't require such hacks. I've added some compile time
checks around the hack to try to isolate it to GCC and allow other
compilers to see the unmodified section name.

Validated on the following OSes/architectures/compilers:
- Windows/amd64: gcc, clang, cl, clang-cl, tcc
- Windows/aarch64: clang, cl, clang-cl
- Linux/amd64: gcc, clang, tcc[1]
- Linux/aarch64: gcc, clang, tcc[1]
- macOS/aarch64: gcc, clang

[1] TCC only works with a fix to glibc headers that was only made very
recently. Without it, you have to #undef __attribute__ after including
glibc headers.
2025-12-29 12:01:33 +00:00
invertego 30a3b125c8 libco: align co_active_buffer on amd64, aarch64
This is required on amd64 due to the aligned moves in co_swap. While
note technically needed on aarch64, I found information online that
suggested ldp/stp perform better on certain microarchitectures with
16-byte alignment.
2025-12-29 12:01:33 +00:00
User 084d8fb72b gba: only trigger keypad IRQ when input changes 2025-12-29 12:01:15 +00:00
User 463d44920b gba: fix handling of repeat bit during immediate DMA transfers 2025-12-27 22:38:59 +00:00
Stefan Schlosser adfc78f952 pce: fix missing qon linking 2025-12-23 14:44:52 +00:00
remutro f533120df6 Add noise channel to save state serialization 2025-12-18 12:44:55 +00:00
remutro ec37caccfb [N64] Fix pak menu radio selection 2025-12-09 11:50:14 +00:00
remutro d0b9669c50 Update CC92 based on agreed ROM and No-Intro entry 2025-12-07 16:33:51 +00:00
Luke Usher dfb355495a pce: fix missing cd-da playback 2025-12-01 16:03:05 +00:00
invertego 0f618995f4 mia: remove line of dead code 2025-12-01 15:47:30 +00:00
User 35ead94515 gba: implement write protection for HALTCNT 2025-11-28 16:05:42 +00:00
remutro 6c8ccc1c7e Add support for Viewpoint 2064 master to the N62 DB 2025-11-27 13:51:47 +00:00
Giovanni Bajo 361fb49fd0 n64: fix VI bug causing spinloop
VI_H_TOTAL is defined as the number of cycles per scanline *minus 1*.
We forgot to add that 1 back. Besides the minor inaccuracy in timing,
we could hit a race condition during initial VI config: if the Ares
VI thread ran when the display was turned on (VI_CTRL configured) but
VI_H_TOTAL wasn't already configured (and thus defaulted to 0), the
thread would spinloop forever because it would step by 0 cycles.

While fixing this, I also noticed that I wasn't properly taking into
account leap timings because of a typo; this means that PAL timings
were very slightly off.

Fixes #2293
2025-11-27 12:05:29 +00:00
Max Bebök 90139d028d increase n64 serialize version 2025-11-23 19:19:57 +00:00
Max Bebök d03915bde9 n64: handle correct R/W to RDP spans in test mode 2025-11-23 19:19:57 +00:00
remutro 8a7549fb21 Remove the entry for a test build of PF94 (already done for CC92) 2025-11-12 13:03:27 +00:00
remutro 6003e6933b [SNES] add db entries for newly dumped competition carts 2025-11-12 13:03:27 +00:00
Roger Sanders 35671b2f8d ld: Fix some media info registers. Fixes JB Harold side changing. 2025-11-04 11:33:39 +00:00
ZengGengSen 43686810d2 fix fc_keyboard support 2025-10-31 13:12:19 +00:00
Adrian Siekierka 9bd2afee61 ws: implement Karnak mapper ADPCM decoder 2025-10-29 14:55:07 +00:00
jcm 7bcb9ae39f build: Run gersemi formatting pass 2025-10-29 14:37:17 +00:00
jcm f39eac9b87 build: Add missing sources to CMake file enumeration 2025-10-29 14:37:17 +00:00
jcm f370521a55 build: Disable Metal GPU capture by default due to Xcode memory issues 2025-10-28 11:34:33 +00:00
jcm c763218430 build: Add ARES_DEBUG_DEPENDENCIES build option 2025-10-28 11:34:33 +00:00
jcm 2df5b97e5e build: Account for multiple possible prefixes in slang-shaders finder 2025-10-28 11:34:33 +00:00
jcm 0a7e1c5e4c Update dependencies to 2025-10-27 release 2025-10-28 11:34:33 +00:00
Adrian Siekierka 2d80fca221 ws: add I/O port access tracer support 2025-10-28 11:33:58 +00:00
User 3b8baddfba fc: fix evaluation of sprites not aligned to 4-byte boundaries in OAM 2025-10-28 11:33:49 +00:00
Luke Usher 5319fe68f0 screen: prevent blowing out brightness when increasing saturation. 2025-10-16 16:17:59 +01:00
User 6b11b281c4 fc: improve handling of OAM accesses during rendering 2025-10-16 07:10:01 +01:00
Rupert Carmichael c79a73e88c myvision: Adjust audio frequency to match real hardware
The divider is still unconfirmed, but 21 produces the correct pitch.

References:
https://gitlab.com/jgemu/jollycv/-/blob/master/src/jcv_myvision.c
https://www.youtube.com/watch?v=UqKuNb1Z9Uc
https://www.youtube.com/watch?v=RsNxhfD7iJk
2025-10-16 07:06:52 +01:00
remutro 53a63d6ae2 Resize board vector so that there are 2 entries minimum 2025-10-15 10:10:44 +01:00
Luke Usher c95ddfe754 tms9918: simplify/clarify timing.
The real chip expects colorburst*3 as input, and then divides that by 2 internally to get the pixel clock.
2025-10-08 10:03:48 +01:00
Luke Usher bfed5a56f0 myvision: adjust audio frequency to match other hardware with the same PSG.
Real hardware value unknown.
Still just a guess, but a better? guess than we had.
2025-10-07 21:42:02 +01:00
Luke Usher 41275f4a8a ym2149: implement readIO/writeIO
currently unused, but noticed support was missing compared to ay38910
2025-10-07 21:34:54 +01:00
Luke Usher 9fcb4f93e4 myvision: fix vdp clock to 2x colorburst. 2025-10-07 21:20:49 +01:00
png183 11a7827eef fc: bump serialization 2025-10-06 10:39:23 +01:00
User b7de9976a6 fc: values in CGRAM are six bits in size 2025-10-05 21:54:37 +01:00
DirtBag Xon 9671ec7c3d Fix ambiguous overload on mouseCursor types. Always compare with matching string types.
Fixes:
widget.cpp:142:20: error: ambiguous overload for ‘operator==’ (operand types are ‘const hiro::MouseCursor’ and ‘const nall::string’)

 142 | if(mouseCursor == MouseCursor::Hand) name = "hand1";
  | ~~~~~~~~~~~ ^~ ~~~~~~~~~~~~~~~~~
  | |           |
  | const hiro::MouseCursor const nall::string
2025-10-04 09:41:42 +01:00
Luke Usher cb4aec479f ps1: properly fix color modulation this time 2025-10-03 18:49:01 +01:00
Luke Usher 44f34f9bb2 ps1: improve color modulation
Fixes excessive colour banding, without breaking Silent Hill's loading screen.
2025-10-02 20:49:24 +01:00
Giovanni Bajo 90b6c0902d stdc++: remove nall::shared_pointer, now unused 2025-10-02 14:19:44 +01:00
Giovanni Bajo 445cfacb10 stdc++: migrate nall to std::shared_ptr 2025-10-02 14:19:44 +01:00
Giovanni Bajo 7989498177 stdc++: convert hiro to std::shared_ptr 2025-10-02 14:19:44 +01:00
Giovanni Bajo b38cacbab8 stdc++: convert ares/node to std::shared_ptr 2025-10-02 14:19:44 +01:00
Giovanni Bajo 4b121c28d0 stdc++: continue migrating most uses of nall::shared_pointer 2025-10-02 14:19:44 +01:00
Giovanni Bajo 4e1b4b79ef stdc++: start migrating nall::shared_pointer to std::shared_ptr 2025-10-02 14:19:44 +01:00
Roger Sanders 18500e679b ld: Fixed a potential threading issue with frame prefetch 2025-10-01 10:07:17 +01:00
Roger Sanders 174eb5bcf2 ld: Update minimum macOS target from 10.15 to 11.0 2025-09-30 14:57:05 +01:00
Roger Sanders 8d32ab3f4f ld: Fixed some missing includes which triggered build errors on some platforms 2025-09-30 14:57:05 +01:00
Roger Sanders 5cc3a8118f ld: Added frame prefetch and video resampling coefficient precalculation 2025-09-30 14:57:05 +01:00
User 753ba2af6a fc: improve frame counter IRQ timing 2025-09-30 08:57:24 +01:00
User 757f326c33 fc: reading APU status register should not affect open bus 2025-09-30 08:57:24 +01:00
Giovanni Bajo fc36600a6a stdc++: convert nall::unique_pointer to std::unique_ptr 2025-09-29 14:24:14 +01:00
Giovanni Bajo 038bcb91c2 stdc++: migrate nall::function to std::function 2025-09-29 14:24:14 +01:00
Giovanni Bajo 0b1714c8f6 stdc++: remove merge-sort.hpp, use std::stable_sort instead 2025-09-29 14:24:14 +01:00
User 76141ba703 gba: fix addressing of 2D mapped sprites 2025-09-27 16:14:19 +01:00
Giovanni Bajo 064b2120e4 stdc++: simplify span constructors 2025-09-27 16:14:06 +01:00
Giovanni Bajo 732d03f3af stdc++: apply review suggestions 2025-09-27 16:14:06 +01:00
Giovanni Bajo 81d0f131c4 stdc++: drop unused functions from span-helpers.hpp 2025-09-27 16:14:06 +01:00
Giovanni Bajo 5d0ff02cb3 stdc++: remove nall::array_span/array_view 2025-09-27 16:14:06 +01:00
Giovanni Bajo ba41375179 stdc++: convert uses in nall to std::span 2025-09-27 16:14:06 +01:00
Giovanni Bajo fe7f05fc1e stdc++: nall: convert some uses to std::span 2025-09-27 16:14:06 +01:00
Giovanni Bajo cbe2b7be32 stdc++: migrate missing uses in ares to std::span 2025-09-27 16:14:06 +01:00
Giovanni Bajo 0d1152de1c stdc++: migrate missing uses in ares to std::span 2025-09-27 16:14:06 +01:00
Giovanni Bajo eaf5e06683 stdc++: migrate most uses in mia to std::span 2025-09-27 16:14:06 +01:00
Giovanni Bajo 0921eb8038 stdc++: migrate serializers to std::span 2025-09-27 16:14:06 +01:00
Giovanni Bajo 64c8354511 stdc++: migrate vfs functions to use std::span 2025-09-27 16:14:06 +01:00
Giovanni Bajo cd21ca7bf4 stdc++: nall: migrate some uses of array_view/span to std::span 2025-09-27 16:14:06 +01:00
Giovanni Bajo ded925451b stdc++: introduce span-helpers.hpp to aid migration to std::span 2025-09-27 16:14:06 +01:00
Giovanni Bajo b0d5be69d0 stdc++: remove unusued / seldom used methods of array_view/array_span 2025-09-27 16:14:06 +01:00
Roger Sanders 2f7fa79b07 ld: Fix a potential out of bounds memory access in some video modes 2025-09-23 10:18:30 +01:00
Roger Sanders 4fd5318e52 ld: Fix image hold forcing a new frame to be latched when one was already in the buffer 2025-09-23 10:18:30 +01:00
Giovanni Bajo 810c508489 n64: fix PIF HLE on RX flag clearing
When beginning to execute a joybus frame, PIF clears the RX flags before
the transaction begins, so that errors notified in previous transactions
don't accumulate.

This is only visible in the where an application performs multiple
transactions (SI DMA reads) on the same frame layout (sent via a single
SI DMA write), while controllers are being hotplugged. This is not very
common in Ares, which is probably why it was not noticed before.
2025-09-23 06:38:17 +01:00
jsgroth 383a0870f1 m68000: fix write ordering in MOVEM.L with indirect pre-decrement addressing
pre-decrement mode writes each longword in reverse-word order in addition to writing the registers in reverse order
2025-09-23 06:31:56 +01:00
Luke Usher 9e4a00b968 pc-engine-ld: detect and insert a bios hucard when a cd-rom is loaded that depends on it.
Currently non-working because mia rejects non-ld content for LaserActive right now, but it's here for when we fix that!
2025-09-22 13:37:55 +01:00
Luke Usher a57cce6b94 pc-engine-ld: use internal bios rather than incorrectly mountitng the LD bios in the HuCard slot. 2025-09-22 13:23:47 +01:00
Luke Usher 74a561f62e pc-engine-cd: clarify 'arcade card' and 'system card 3.0' are the same bios rom. 2025-09-22 10:46:42 +01:00
Roger Sanders 52acac2933 ld: Added hash for NEC PAC-N10 bios 2025-09-22 07:46:21 +01:00
Dragorn421 9830daef91 Review: waitGDB -> awaitGDBClient, rename "Launch Debugger" to "Launch Tracer" 2025-09-21 09:39:28 +01:00
Dragorn421 2f9f7670da Add "Wait GDB" boot option 2025-09-21 09:39:28 +01:00
Luke Usher 808aaaf053 Revert "ps1: use physical addresses as early as possible"
This reverts commit 325c0ed876.
2025-09-19 22:19:26 +01:00
Luke Usher 1044d0ad37 desktop-ui: fix settings.bml loading/saving
This was broken by the renaming of the laseractive cores, because () are not valid bml node name characters.
2025-09-19 22:14:50 +01:00
invertego 0ebd9e3bbe ps1: use constant random seed in homebrew mode 2025-09-19 21:37:43 +01:00
invertego 57d1a2ef9a ps1: randomly initialize memory on boot
Randomly initialize CPU RAM, CPU I-cache, CPU scratchpad, GPU VRAM, and
SPU RAM.
2025-09-19 21:37:43 +01:00
Luke Usher eeacac8749 pcd: fixing the build after #2220 2025-09-19 14:13:04 +01:00
Giovanni Bajo 9e1ff7b479 stdc++: reindent 2025-09-19 12:49:19 +01:00
Giovanni Bajo 32d2f3d2b2 stdc++: completely remove nall::vector, now unused 2025-09-19 12:49:19 +01:00
Giovanni Bajo c64aff5992 stdc++: nall: remove vector<string> specialization (not used anymore) 2025-09-19 12:49:19 +01:00
Giovanni Bajo 3390d66a7e stdc++: migrate tools/tests removing uses of nall::vector 2025-09-19 12:49:19 +01:00
Giovanni Bajo e388299f05 stdc++: nall: remove other nall::vector usages 2025-09-19 12:49:19 +01:00
Giovanni Bajo f31fa5c99f stdc++: nall: migrate more uses to std::vector 2025-09-19 12:49:19 +01:00
Giovanni Bajo fec8d9029c stdc++: nall: remove some uses of nall::vector 2025-09-19 12:49:19 +01:00
Giovanni Bajo c4bc76b219 stdc++: avoid nall::vector in implementation of split functions 2025-09-19 12:49:19 +01:00
jcm 7d91e5f38a CI: avoid Strawberry Perl Ccache installation 2025-09-19 12:49:00 +01:00
jcm 907ccf6494 build: Clarify when to build genius 2025-09-19 12:49:00 +01:00
jcm c7fabe82d6 build: Remove /permissive- (unneeded under C++20) 2025-09-19 12:49:00 +01:00
jcm 9f9ff6bf09 build: disable IPO for *nix CI builds 2025-09-19 12:49:00 +01:00
jcm f60c003826 build: Don't use unsupported option in Clang-CL 2025-09-19 12:49:00 +01:00
jcm 6a30f98145 build: move generated targets to work around Visual Studio 2025-09-19 12:49:00 +01:00
Luke Usher 7855c8b469 desktop-ui: group mega ld/pc-engine ld as Pioneer LaserActive 2025-09-19 12:29:00 +01:00
Roger Sanders ee85afd30c ld: Initial working version of NEC PAC support for the LaserActive 2025-09-19 10:35:55 +01:00
Roger Sanders 09932f11d5 ld: MegaLD emulation accuracy and speed improvements 2025-09-19 10:35:55 +01:00
Luke Usher 85afab5b36 mia: fix fds loading 2025-09-18 10:13:48 +01:00
Giovanni Bajoandjcm 75ef6810e2 stdc+: switch to nall::split_and_strip and apply review suggestions
Co-authored-by: jcm <[email protected]>
2025-09-16 06:42:29 +01:00
Giovanni Bajo 66db5eb88c stdc++: discard global namespace qualifier for nall everywhere 2025-09-16 06:42:29 +01:00
Giovanni Bajo d5c3a4805b stdc++: apply review suggestions 2025-09-16 06:42:29 +01:00
Giovanni Bajo 82c777e7c2 stdc++: hiro: fix qt backend build 2025-09-16 06:42:29 +01:00
Giovanni Bajo cdbc88f92e stdc++: ruby: fix freebsd build 2025-09-16 06:42:29 +01:00
Giovanni Bajo 970a019476 stdc++: nall::string remove non-const constructors to avoid problematic uses 2025-09-16 06:42:29 +01:00
Giovanni Bajo 9c9ba5d6f4 stdc++: nall: remove string::split and vector<string>::match 2025-09-16 06:42:29 +01:00
Giovanni Bajo 86790da2ec stdc++: nall: finish migrating string split/match methods to functions 2025-09-16 06:42:29 +01:00
Giovanni Bajo 7fff423649 stdc++:: add global nall::split/match functions, migrate part of the code 2025-09-16 06:42:29 +01:00
Giovanni Bajo d258228cc0 md: avoid including dc-removal.hpp within the ares::MegaDrive namespace 2025-09-16 06:42:29 +01:00
Giovanni Bajo 9bf3ffc3ae stdc++: finish mia migration 2025-09-16 06:42:29 +01:00
Giovanni Bajo 7168f2e411 stdc++: migrate part of mia to std::vector 2025-09-16 06:42:29 +01:00
Giovanni Bajo c75ad74ce0 stdc++: desktop-ui: migrate from nall::vector to std::vector
- Replace all nall::vector declarations with std::vector in desktop-ui
- Update API calls: .append() -> .push_back(), .reset() -> .clear()
- Replace .takeFirst()/.takeLast() with .front()/.back() + .erase()/.pop_back()
- Convert .find() to std::ranges::find() and std::ranges::find_if()
- Replace .sort() with std::ranges::sort()
- Fix boolean conversions: if(!vector) -> if(vector.empty())
- Migrate all emulator-specific files and core desktop-ui components
- Use direct assignments between std::vector instead of manual loops
- Maintain compatibility with nall::split() by using auto type deduction
2025-09-16 06:42:29 +01:00
Giovanni Bajo 7ed8d6feac cmake: disable build of optional targets in ubuntu-ci-qt
genius can't build with Qt as it uses ComboEdit, but it is currently
enabled in the ubuntu-ci-qt as it inherits the base ubuntu-ci (which is
GTK-based).
2025-09-16 06:42:29 +01:00
tykkiman e2bf15a6ce recompiler: remove static_assert(false) from a template
GCC evaluated the always failing assert before the constexprs leading
to it, resulting in a compilation failure. As a workaround, we can move
the 'imm64' case inside the else block and check for the type there,
which also catches unhandled types at compile time.
2025-09-15 18:55:06 +01:00
Jay Prewitt 29139b104c n64: Use ISV read pointer as a start address 2025-09-15 18:54:17 +01:00
tykkiman 0b2a85f803 n64: use faster host function calls in the recompiler
Uses the new 'callf' function instead of 'call' in generated code. In
the n64-systemtest ROM, this change shaves off 6% and 10% of the
respective VR4300 and RSP  median block sizes:

  VR4300 block size statistics

            min   max   mean     median
   before   113   6369  893.93   573
   after    104   5937  881.17   537

  RSP block size statistics

            min   max   mean     median
   before   97   19196  3941.95  5336
   after    88   17044  3414.06  4606

Also, on a benchmark with an RSP-intensive homebrew libdragon ROM, this
change gave about 1% actual runtime speedup.
2025-09-14 21:20:30 +01:00
tykkiman a55688a95d recompiler: optimized 64-bit System V function calls
When ares switched to SLJIT, some tiny overhead was introduced in every call
from guest to host code on 64-bit Linux. This was due to the argument register
mapping differing between SLJIT's own convention and the System V AMD64 ABI.
This commit makes the recompiler put function arguments directly in the correct
registers.

This commit introduces a new 'callf' template function that accepts recompiler's
'mem' and 'imm' argument types. It abstracts away the register setup so that
different host platforms can implement their optimized function calls. This also
results in slightly shorter code in the recompiler (see the followup commit).

The SLJIT_CALL_REG_ARG type of call is actually meant for SLJIT's own, optimized
calling convention, but since it assumes function arguments are placed in
correct registers, it works here. The only other option I could think would've
been emitting x64 machine code directly.
2025-09-14 21:20:30 +01:00
Jay Prewitt f39ca5e3a7 n64: Make MI repeat mode accurate for 1 and 2 byte writes 2025-09-12 11:30:05 +01:00
jcmandStefan Schlosser 1a2aedcf00 CI: Add FreeBSD runner
Co-authored-by: Stefan Schlosser <[email protected]>
2025-09-09 17:09:21 +01:00
jcm 05e9c3a6c9 CI: Add Qt build 2025-09-09 17:09:21 +01:00
Christopher Bonhage 0d9ce81d20 Implement N64 Bio Sensor accessory 2025-09-09 14:06:34 +01:00
Christopher Bonhage eed44e0012 Support for N64 accessory commands with non-standard data lengths 2025-09-09 14:06:34 +01:00
Christopher Bonhage 93073f2700 Implement N64 accessory DETECT controller status 2025-09-09 14:06:34 +01:00
jcm 53a08c9101 build: Fix framework bundle copies under non-Xcode generators on macOS 2025-09-09 12:11:23 +01:00
jcm 6540059a28 build: Don't use -fno-char8_t when compiling C 2025-09-09 12:11:23 +01:00
jcm 48c816f2f9 desktop-ui: Properly initialize rewind state on startup 2025-09-09 12:11:07 +01:00
User 1edb30d1ea gba: improve handling of MEMCNT register 2025-09-08 14:34:10 +01:00
Jay Prewitt 797c798787 n64: Implement basic MI repeat mode
A simple implementation that is only accurate for 4-byte or 8-byte
aligned writes. Smaller accesses will require a full implementation of
write masking to be accurate.
2025-09-08 14:33:59 +01:00
Giovanni Bajo 2c3341dfdf stdc++: finish migrating ares 2025-09-08 14:32:44 +01:00
Giovanni Bajo 31357eb4e5 stdc++: bulk migration of ares 2025-09-08 14:32:44 +01:00
Giovanni Bajo 3401322e6e stdc++: migrate node and debuggers 2025-09-08 14:32:44 +01:00
Giovanni Bajo 50ed2ba9bc stdc++: replace vector<string>.merge macros with nall::merge; keep nall::vector path ops; add initializer_list overload 2025-09-08 14:32:44 +01:00
Giovanni Bajo ff8bdbcdc6 stdc++: add vector-helpers merge/split; migrate includes; use merge() in N64 disassemblers; std::vector<string> split 2025-09-08 14:32:44 +01:00
Giovanni Bajo 935802da1a stdc++: migrate enumerate() to std::vector<string> 2025-09-08 14:32:44 +01:00
Roger Sanders 1dffa3d974 nall: Fix linux-only compilation issue with owning string_view removal 2025-09-05 06:47:30 +01:00
Roger Sanders 78144f5fab nall: fixed remaining string_view conversion cases from release builds 2025-09-05 06:47:30 +01:00
Roger Sanders 47aa5dc1df nall: string_view missing change fix no2 2025-09-05 06:47:30 +01:00
Roger Sanders bf7a1a205c nall: Fixed a missing change 2025-09-05 06:47:30 +01:00
Roger Sanders 96bd51471d nall: remove memory ownership from string_view again 2025-09-05 06:47:30 +01:00
Giovanni Bajo bbd9fcca0c hiro: fix undefined behavior converting negative coordinates to u32
ubsan on Mac caught an issue in this method: all geometry coordinates
are floats out and into Cocoa, but intermediate calculations were
being performed with u32 that caused undefined behavior when negative
numbers were involved.
2025-09-04 11:10:42 +01:00
Giovanni Bajo f263e89f06 nall: remove unused modules 2025-09-03 19:48:57 +01:00
User 698ea74132 gba: fix remaining C++20 deprecation warnings 2025-09-02 22:04:44 +01:00
Giovanni Bajo 766fc1ece2 stdc++: remove all instances of if statements with initializers 2025-09-02 22:04:32 +01:00
Giovanni Bajo 247dd180ce stdc++: fixes from review 2025-09-02 22:04:32 +01:00
Giovanni Bajo 23ed3de93c stdc++: hiro: revert changes to clear of subwidgets that were broken 2025-09-02 22:04:32 +01:00
Giovanni Bajo c0791baa3d stdc++: simplify some code via std::erase 2025-09-02 22:04:32 +01:00
Giovanni Bajo 9ad89d134e stdc++: use range syntax in more places 2025-09-02 22:04:32 +01:00
Giovanni Bajo 84ce0e3d9f stdc++: convert all sorts and reverse loops to ranges 2025-09-02 22:04:32 +01:00
Giovanni Bajo 92fe0d2e44 stdc++: Introduce range-helpers and nall::index_of. 2025-09-02 22:04:32 +01:00
Giovanni Bajo 864ca3d91e stdc++: C++20 compactness pass (branch-local):
- Use std::erase and ranges::find where shorter.
- Replace ranges::distance with iterator subtraction.
- Enable <ranges> in hiro core/extension; use views::reverse for reverse-destruction loops.
- Minor cleanups (array_view ctor from vector, build fixes).
2025-09-02 22:04:32 +01:00
Giovanni Bajo 8729c5f591 stdc++: array_view: remove redundant explicit constructions where implicit std::vector conversion works (Pak append callers, vfs cdrom, emulator firmware, BWT/LZSA). Keep explicit array_view only when required for string construction or subspan. 2025-09-02 22:04:32 +01:00
Giovanni Bajo 89be74aab5 stdc++: Apply changes from review 2025-09-02 22:04:32 +01:00
Giovanni Bajo 24c5e367cc stdc++: Fix CI: map remaining vector-only APIs to std::vector equivalents: gtk keyboard keycodes push_back; windows menu-bar use erase/push_back and clear; WASAPI/XAudio2/WaveOut: use std algorithms and front()/empty() instead of vector truthiness/first/find; compute indices explicitly. 2025-09-02 22:04:32 +01:00
Giovanni Bajo 5004ca4a33 stdc++: hiro gtk/qt: migrate remaining nall::vector usages to std::vector; map append/remove/reset; update keyboard polling and settings containers; fix window lists to use std::vector ops. 2025-09-02 22:04:32 +01:00
Giovanni Bajo 799d0ce726 stdc++: tests: minimal changes to make tests building 2025-09-02 22:04:32 +01:00
Giovanni Bajo 47348d9002 stdc++: hiro/windows: replace nall::vector with std::vector; map append/remove/reset; fix utilities/keyboards/timer APIs; guard DropPaths and pixel buffers accordingly. 2025-09-02 22:04:32 +01:00
Giovanni Bajo 3eeecf1cc2 stdc++: Fix CI: std::vector<bool> copy; BrowserDialog truthiness; replace remaining .append/remove/reset in joypad/combo/icon-view; GTK TabFrame tabs as std::vector; ALSA/OSS device selection via std algorithms; fix reverse iteration and setSelected signature. 2025-09-02 22:04:32 +01:00
Giovanni Bajo 31380a1976 stdc++: ruby: migrate nall::vector to std::vector; mechanical API alignment
- Replace nall::vector with std::vector across ruby (audio/input) and hiro glue; update overrides to std::vector.

- Map vector APIs: append/reset/remove/truthiness -> push_back/clear/erase/empty(); adjust DropPaths guards and BrowserDialog callers.

- Fix Windows/GTK fallout: DropPaths checks and Windows TableView indexing; Keyboard::poll returns std::vector<bool>.

- Source-only commit; excludes build outputs and submodules.
2025-09-02 22:04:32 +01:00
Giovanni Bajo 6974764393 stdc++: std::vector alignment across nall/ruby/hiro; remove nall::vector-only APIs
- nall/directory (Windows): return std::vector<string>; replace list.append with push_back; convert drive split to std::vector
- ruby audio/video/input: make virtual overrides return std::vector; replace .append with .push_back; poll() now uses std::vector for device lists
- hiro utilities (cocoa/gtk/qt/windows): DropPaths now returns std::vector<string>; replace .append with .push_back; guard empty paths on GTK
- hiro widgets: tab-frame reordering uses erase/insert instead of take(); console history uses std::vector ops; table-view selection uses std::vector<u32>
- string: add stringify<std::vector<string>> for toolchains that instantiate it indirectly

No semantic changes intended; local build verified with ninja.
2025-09-02 22:04:32 +01:00
Giovanni Bajo 0e73ba0cc1 stdc++: nall: std::vector compatibility across toolchains
- array-view/span: include <vector> so std::vector constructors are visible on stricter compilers
- directory (Windows): make ufolders/ufiles return std::vector<string>; update locals accordingly to match headers

Build verified locally with ninja.
2025-09-02 22:04:32 +01:00
Giovanni Bajo 5bb5a70b0c stdc++: std::vector migration and interop cleanup across mia/desktop-ui
- Add Pak::append(std::vector<u8>&, string) overload to accept std::vector without wrappers
- Convert remaining callers to pass std::vector directly; remove redundant array_view wrappers
- Replace nall::vector truthiness/foreach assumptions with std::vector equivalents (!empty(), range-for)
- Use std::vector APIs consistently (push_back; insert with begin()/end() when merging)
- Align medium analyze signatures/callers to std::vector where required; no semantic changes intended
- Keep explicit array_view only for subspans (pointer+length) where necessary

Build verified with ninja.
2025-09-02 22:04:32 +01:00
Giovanni Bajo 2830ab92f7 stdc++: nall: remove most uses of nall::vector from the library and adapt callers
- directory, zip, mmi, cue: switch public APIs to std::vector; fix sort/find/append
- vfs/cdrom: use std::vector buffers and wrap into array_view when needed
- hid: replace inheritance from nall::vector with std::vector-backed fields
- instruction-set: use std::vector for cpuid data blocks
- windows/registry: contents() returns std::vector<string>
- set: iterator internals use std::vector stack
- tcptext socket/server: move buffers and onData() to std::vector<u8>
- remove umbrella includes of <nall/vector.hpp>

Callers fixed accordingly (ares/mcd, mia, desktop-ui).
2025-09-02 22:04:32 +01:00
Giovanni Bajo 2eb0e677a8 stdc++: Migrate project off nall::vector (outside nall) to std::vector
Scope
- Replace nall::vector with std::vector across hiro, ruby, and desktop-ui.
- Remove external includes of <nall/vector.hpp>; keep nall/ self-includes unchanged.

API adaptations
- append/prepend -> push_back/insert(begin,...).
- remove/removeLeft/removeRight -> erase/erase(begin)/erase(end-1) as appropriate.
- take*/first/last/left/right -> front()/back() or index-based access.
- contains/find/findSorted/foreach -> std::find, std algorithms, or range loops.
- reverse(...) iterations -> rbegin()/rend() or explicit reverse-iterator loops.
- vector truthiness -> use empty()/size() checks.

Subsystem-specific changes
- Ares node registry: use std::vector for class lists and child nodes; replace find/append/remove usage.
- Debug facility: store notices in std::vector; dedup via std::find.
- Hiro widgets/layouts: convert container state to std::vector; update signatures (e.g., onDrop/doDrop to std::vector<string>);
  fix batch/selection helpers to build std::vector results; update menu/popup/combo/table/tree widgets accordingly.
- Cocoa/GTK integrations: adjust DropPaths usage and emptiness checks.
- Ruby backends (audio/video/input): change capability lists and device enumerations to std::vector; replace .first() with front()
  and .append() with push_back; fix OpenAL/SDL/driver helpers.
- Desktop UI: Program::screens/streams now std::vector; platform attach/detach uses erase+remove; message queue uses std::vector
  push_back + pop-front pattern; Presentation drop handler accepts std::vector<string>.
- Message/Browser dialogs: std::vector for button/options/filters; remove truthiness; use back()/empty().

Build
- Verified clean build for desktop-ui, hiro, and ruby after changes (ninja).

Notes
- Conservative migration: no changes inside nall/ itself (still ships its own vector for internal use).
- Follow-up work can progressively replace remaining nall containers/APIs as needed.
2025-09-02 22:04:32 +01:00
John Chadwick a5f5eccdbe hiro/qt: Add Qt 6 support
Basic functionality is tested and working great. Obviously, things do
not work in Wayland yet.
2025-09-01 20:33:41 +01:00
John Chadwick 82ff8dbf6b hiro/qt: QLayout::setMargin -> QLayout::setContentsMargins
setMargin has been obsolete since Qt 4.3!
2025-09-01 20:33:41 +01:00
John Chadwick c9d8fc525c hiro/qt: Use QScreen for Monitor
Qt 5 introduces QScreen, which can be used to implement most of the
functionality needed by Monitor, although some of it probably won't make
sense when using Wayland.
2025-09-01 20:33:41 +01:00
John Chadwick 3854a4561d hiro/qt: Remove pendingEvents, add timeout to processEvents
Qt 6 no longer allows us to poll for the status of the event loop.
However, Qt 6 does still have a processEvents function, and the version
with the timeout actually spins the event loop and returns as early as
there are no more events in it. That's basically what we want to do. We
could run this with a really huge timeout, but that would just make it
more likely that hiro freezes up, so instead let's mirror hiro/gtk3 and
use a 50ms timeout.
2025-09-01 20:33:41 +01:00
John Chadwick cf4afeb7f0 hiro/core: Remove Application::pendingEvents
This does not seem to be used anywhere in bsnes, higan or ares. It's not
really possible to implement with Qt 6, which has stop exposing this
detail of the event loop. It turns out this is actually OK, since we
don't *really* need it anyway, and in the case of hiro/qt, the
replacement should be more robust anyways.
2025-09-01 20:33:41 +01:00
John Chadwick 755e15c3e1 Use QScreen for Desktop::{size,workspace}
Qt 5.0 adds the QScreen API, which exposes enough information that
Desktop::{size,workspace} no longer needs to fall back to Win32/Xlib. I
manually tested that this seems to give the same exact answers as the
Xlib path (though it technically goes a different route for
Desktop::size.)
2025-09-01 15:51:27 +01:00
John Chadwick 7f0d020466 Remove Qt 4 support.
Qt 4.8 LTS was released on December 15th, 2011. It hit its official
end-of-life on December 31st, 2015. It has been dead for nearly 10
years. Qt 4 is now so old, that it has been removed from Debian long
enough that "qt4" doesn't show up in *any* of the indexed package suites
in Debian's online package search service.

The CMake build of ares never supported Qt 4 in the first place, so this
code should all be dead anyway.
2025-09-01 15:47:36 +01:00
User 5a2be88f41 gba: fix some warnings from C++20 deprecating bitwise operations between different enums 2025-08-31 11:42:24 +01:00
jcm be570117bb CI: overwrite built-in pinned CMake installation 2025-08-30 16:31:42 +01:00
User 640fe5722c gba: handle cartridge access sizes via CPU bus 2025-08-30 15:35:57 +01:00
jcm dff1ad01a6 build: Disable C++20 module scanning 2025-08-29 23:58:11 +01:00
jcm e7a00354dc build: Add -fno-char8_t and /Zc:char8_t- 2025-08-29 16:14:23 +01:00
jcm f042f7a51a build: Compile in C++20 mode 2025-08-29 16:14:23 +01:00
jcm 4d92a5b433 Do not rely on implicit capture of this in lambdas 2025-08-29 16:14:23 +01:00
User 4aed87bf45 fc: bit 5 of $4015 reads open bus 2025-08-29 13:58:01 +01:00
User a5e76e2e4e mos6502: fix JSR memory transactions 2025-08-29 13:58:01 +01:00
User c7277c964e mos6502: general cleanup 2025-08-29 13:58:01 +01:00
jcm 846b622c80 build: Run gersemi formatting pass 2025-08-29 13:57:23 +01:00
jcm abcdff3e60 build: Fix list/string conversion in component list 2025-08-29 13:57:23 +01:00
jcm 4fcfe3a485 build: Clean up miscellaneous target locations 2025-08-29 13:57:23 +01:00
jcm 76b0204d91 build: Clean up link relationships
mame2bml: Fix linking

mia-ui: Fix linking

dekstop-ui: Fix linking
2025-08-29 13:57:23 +01:00
jcm cac6f0534a Update CMake policy version 2025-08-29 13:57:23 +01:00
jcm f66bb568df build: Match libco source organization with other targets 2025-08-29 13:57:23 +01:00
jcm cc4556824e build: Update .gersemirc for newer gersemi version 2025-08-29 13:57:23 +01:00
jcm c6f7efb797 build: Remove/fix up various unused/extraneous build code 2025-08-29 13:57:23 +01:00
jcm 6a2fcb21dc hiro: Make backend definition public 2025-08-29 13:57:23 +01:00
jcm 2b347c65de build: Track project meta files in IDEs 2025-08-29 13:57:23 +01:00
jcm f1823630be build: Update dependencies
deps.windows: Update SDL to 3.2.20
Update slang-shaders to ref `c9303dc`
deps.macos: Update SDL to 3.2.20
deps.macos: Update MoltenVK to 1.4.0
2025-08-29 13:57:13 +01:00
Christopher Bonhage 41d1b7e57d Fix Controller "Nothing" checked state in portMenu 2025-08-26 09:40:01 +01:00
invertego c28ba81684 Revert "nall: clean up string conversions in cue/mmi decode"
This reverts commit 81dea4cf7e.
2025-08-26 09:39:42 +01:00
invertego 1561a1d0b4 Revert "nall: remove memory ownership from string_view"
This reverts commit 70fa70fff4.
2025-08-26 09:39:42 +01:00
jcm 0a302dcf0e desktop-ui: Create program guard for system menu items 2025-08-23 20:25:26 +01:00
TascoDLX 07051ab738 desktop-ui: avoid overwriting paused status message 2025-08-23 19:39:31 +01:00
jcm 973030ab67 ares: Set up color settings before calling colors() 2025-08-23 19:39:00 +01:00
jcm 67716bcedf hiro/cocoa: Don't autoenable menu items 2025-08-22 12:40:07 +01:00
Giovanni Bajo e06b748516 n64: activate pak menu on all four controllers 2025-08-22 11:16:13 +01:00
remutro 02dac5b4b7 Update controller pak menues for the N64 2025-08-22 08:30:17 +01:00
jcm a4b8571b61 desktop-ui: remove Apply buttons from driver settings 2025-08-21 14:25:51 +01:00
Roger Sanders a3fa22b5fc ld: Revert palette nullptr check 2025-08-21 14:25:45 +01:00
Roger Sanders 9e9b6f8642 ld: Apply a pixel offset patch to fix alignment under H40 mode 2025-08-21 14:25:45 +01:00
Roger Sanders 5f6a0983bd ld: Fixed some stop point resume and image blanking behaviour 2025-08-21 14:25:45 +01:00
Roger Sanders 2fcab5ca5f ld: Fix overscan mode, and address some redraw issues. 2025-08-21 14:25:45 +01:00
jcm 778a32700d screen: consistently refresh palette after reset() 2025-08-20 12:33:43 +01:00
Luke Usher a6577318b6 md: bump save state version 2025-08-19 13:57:24 +01:00
Roger Sanders badd476d3b ld: Fixed a double buffering issue which caused single-frame errors 2025-08-19 13:56:36 +01:00
Roger Sanders 5a3548402b ld: Fixed several aspects of video disable and stop point behaviour 2025-08-18 15:42:20 +01:00
User c1f0307a8d gba: allow running DMA during CPU idle cycles 2025-08-17 22:30:04 +01:00
Roger Sanders 77c0718df4 ld: Convert video composition to use 16.16 fixed point for a 3x speedup 2025-08-17 16:00:42 +01:00
Roger Sanders 30bff8dd06 ld: Cleaned up version of video compositing prior to optimization 2025-08-17 16:00:42 +01:00
Roger Sanders b1cf9bf4e5 ld: Added support for remaining analog audio mixing features 2025-08-17 07:52:41 +01:00
Roger Sanders bafc2b6ef4 ld: Fixed a potential out of bounds array index issue in the previous commit 2025-08-16 06:31:39 +01:00
Roger Sanders 565591568f ld: Fixed a few disc side changing issues 2025-08-16 06:31:39 +01:00
Roger Sanders 9df891606f ld: Removed region blocks for now since titles appear region free 2025-08-16 00:43:31 +01:00
Roger Sanders eea666317b ld: Fixed incorrect alignment of CLV seek operations. Improved media detection. 2025-08-16 00:43:31 +01:00
Luke Usher ceff1d47a6 ld: preliminary support for multi-disc/multi-side titles
Mostly untested, but verified going from "Disc 1 side 1" to "No Disc" to "Disc 1 Side 1" again in the bios works as expected.
2025-08-15 12:58:47 +01:00
invertego 81dea4cf7e nall: clean up string conversions in cue/mmi decode
Now that the usage issues with string_view have been resolved it can be
safely used to wrap a vector<u8>. I'll note that passing a vector<u8>
directly to the string constructor would work as well (thanks to a
stringify overload) but I'm preserving the wishes of the author of the
MegaLD code to keep the type conversions explicit.

I'll also note that we're still constructing a string from the
string_view when we call JSON::unserialize(). Ideally, it would take a
string_view instead of a const string& and we could avoid the copy.
Unfortunately, all of the markup decoders currently require the input to
be null-terminated, which is only guaranteed by the string class.
2025-08-14 08:56:08 +01:00
jcmandkev4cards 17fa3b58a6 desktop-ui: Fix hotkey behavior when unfocused
Co-authored-by: kev4cards <[email protected]>
2025-08-14 07:46:11 +01:00
invertego 70fa70fff4 nall: remove memory ownership from string_view
Previously, string_view had a constuctor that allocated a new string and
forwarded all arguments to the string constructor. Among other things,
this allowed construction of string_view objects using any of the
various stringify overloads. However, there were drawbacks:

1.  The constructor string_view(const char*, u32) shadowed the
    forwarding constructor, leading to very different behavior. In the
    forwarding version, the first parameter would be treated as a
    null-terminated string, and the second parameter would be formatted
    as a string and concatenated with the first.
2.  Having both owning and non-owning modes makes it difficult for
    someone reading the code to reason about lifetimes, as they depend
    on how the object was constructed. It also deviates from the
    behavior of the identically-named standard C++ string_view.
2025-08-14 07:45:14 +01:00
Roger Sanders 137afe5b5b ld: Fix memory issues with MegaLD games after merge. Some additional cleanup. 2025-08-14 07:44:37 +01:00
Luke Usher 545790f048 Revert "nall: in priority-queue, call event callbacks with correct timing"
This reverts commit 6992197fb8.
2025-08-13 17:34:12 +01:00
Luke Usher 807ef03005 Revert "n64: improve PI DMA accuracy with stricter timings"
This reverts commit bea395b24b.
2025-08-13 17:34:12 +01:00
Luke Usher ce89a31749 ld: pass system type through a pak attribute 2025-08-13 17:25:28 +01:00
Luke Usher 3e7675cafb ld: pass location through a pak attribute 2025-08-13 17:25:23 +01:00
Luke Usher 4132375f26 desktop-ui: fix a crash when opening the settings dialog from the "missing firmware" prompt 2025-08-13 17:25:17 +01:00
Luke Usher 5e0bd5b3b8 ld: nall-ize mmi; remove nlohmann/json
Likely still room for improvement; especially if multi-side games exist, but that's a later problem.

mia: minor cleanups/nallisms
2025-08-13 17:25:11 +01:00
Luke Usher d00c84ff1b mia: add laserdisc medium type 2025-08-13 17:25:06 +01:00
Luke Usher 97f3a7a6fb thirdparty: fix qoi/qon build on all platforms 2025-08-13 17:25:00 +01:00
Roger Sanders 8c656cdfd3 mld: Initial MegaLD support based on a skeleton by Luke Usher 2025-08-13 17:24:54 +01:00
Giovanni Bajo bea395b24b n64: improve PI DMA accuracy with stricter timings
This commit splits the PI DMA-Write transfers (that is, loads from ROM)
in multiple blocks, following what happens on real hardware. Moreover,
it tries to more accurately reflect timing that each block takes. This
is easier to be done at the block granularity, otherwise the timing
algorithm would need to figure it out again the whole block splitting
logic.

From the point of view of the running application, now a ROM con see
the two hardware registers PI_CART_ADDR and PI_RDRAM_ADDR increment
one block at a time during the transfer, which more accurately reflect
what happens on real hardware.

This commit is validated with n64_pi_dma_test test ROM
(https://github.com/rasky/n64_pi_dma_test) which we now pass in full,
including timing tests with the default 10% tolerance.
2025-08-12 14:09:16 +01:00
Giovanni Bajo 6992197fb8 nall: in priority-queue, call event callbacks with correct timing
This allows callbacks for repeated events (rescheduled at each callback)
to not have additional latency caused by the latency with which we call
step().
2025-08-12 14:09:16 +01:00
Giovanni Bajo 097698ab63 n64: support configuration of different paks via homebrew header
The homebrew header supports configuring a different controller and pak
for each port, but mia couldn't represent that in the manifest. The
required change is trivial though.

For backward compatibility, if the homebrew header doesn't declare
anything (which is the same as asking for a standard controller in all
four ports with no paks), we install a cpak in port 1 and a rpak in
port 2, which is also what we have been doing forever with commercial
games.
2025-08-12 14:08:59 +01:00
Giovanni Bajo 46abceebf5 n64: fix controller pak formatting
Controller pak formatting had two bugs: checksum calculation was wrong
(didn't really iterate on all bugs), and the FAT backup copy was in the
wrong position.
2025-08-08 09:03:54 +01:00
Giovanni Bajo 06130778b7 n64: fix readback of PI_CART_ADDR after direct I/O 2025-08-06 15:51:22 +01:00
jcm 85b8d6c5a5 nall: Dynamically load SetThreadDescription on Windows 2025-08-06 08:57:28 +01:00
Luke Usher 8436634bc1 desktop-ui: remove "Fixed" and "Pixel Perfect" scale factors
Pixel perfect (1.1 PAR) can still be achieved "Scale:Integer" combined with "Aspect: No correction"; this works better than the 'Pixel Perfect' setting ever did.
2025-07-29 10:12:10 +01:00
Giovanni Bajo 5972b4e1aa Implement aspect correction mode
Currently, Ares has an "Aspect Correction" checkbox that allows to
disable the PAR (pixel aspect ratio) configuration made by each core,
to basically display the framebuffer without any additional scaling,
with host PC aspect ratio.

In addition to this, it is common for people to request an
"anamorphic 16:9" option, to correctly display games the way they would
appear on a 16:9 TV when stretched. Sometimes, homebrew games are even
designed to be viewed like this.

This PR changes the aspect mode from a boolean to a 3-value option.
The standard option is now named "Standard (4:3 TV)", and a new
option called "Anamorphic (16:9 TV)" is added.
2025-07-29 09:45:52 +01:00
jcm 426606bd02 desktop-ui: Defer settings window initialization on startup 2025-07-27 19:04:22 +01:00
Giovanni Bajo f9604e29e6 n64: correctly render full resolution on PAL
Currently, we render PAL games as 640x480 which is wrong because PAL has
more vertical resolution. This causes PAL graphics to be reduced in
quality compared to a real output.

This commit renders PAL at 640x576 which is the commonly used active
display area used by PAL games, and then configure the aspect ratio to
make sure the output is correct.
2025-07-27 19:04:12 +01:00
jcm 7d7b8ea4b2 n64: Reinitialize paraLLEl-RDP on system reset 2025-07-23 15:52:10 +01:00
remutro 2ed529d564 Fix mouse capture on Windows devices 2025-07-23 13:35:56 +01:00
clippy 73148db456 prevent 64 bit access to RCP over gdb 2025-07-23 13:35:37 +01:00
User 2fbc9c391c arm7tdmi: fix cycle order for SWP instruction 2025-07-23 11:29:10 +01:00
png183 12f3d6d89d gba: add comments to clarify how the upper 8 bits of SIOMLT_SEND are used 2025-07-23 11:28:42 +01:00
User 78c13dddef gba: SIOMLT_SEND should be a 16-bit register 2025-07-23 11:28:42 +01:00
Luke Usher be19b58307 sfc: add support for Limited Run Games SNES rumble specification.
See https://github.com/LimitedRunGames-Tech/snes-rumble
2025-07-21 13:09:30 +01:00
jcm bca80dc784 desktop-ui: Make internal program methods private; add docstrings 2025-07-20 19:38:22 +01:00
jcm e6fe07b084 desktop-ui: Fix undefined behavior in exit handler 2025-07-20 19:38:22 +01:00
jcm c28e47cb93 deps: Update dependencies to 2025-07-14 release 2025-07-15 12:38:57 +01:00
jcm c217662211 desktop-ui: Prevent deadlock when exiting 2025-07-14 14:49:40 +01:00
jcm 975a35e7a7 build: Provide librashader header path hint on all OSs 2025-07-14 10:38:40 +01:00
jcm 2e9233e534 CI: Ignore signing errors on Windows 2025-07-14 10:38:21 +01:00
jcm 4c6d151f7f build: Statically link runtime library for Windows CI builds 2025-07-14 10:38:13 +01:00
invertego 383931bde9 build: remove extraneous msvc optimization flags
/Oi, /Ob2, and /Ot are implied by /O2, which CMake adds by default in
Release and RelWithDebInfo builds. In RelWithDebInfo builds CMake also
downgrades inlining by adding in /Ob1, but we already have a workaround
for this. MinSizeRel builds may see a change in behavior, where CMake
passes /O1 instead, but in any case that is the recommended flag for
minimizing binary size.

The removal of /GL is especially important for MSVC builds. CMake will
add it when IPO is enabled, and forcing it on for all non-debug builds
was not simply redundant; it was overriding the user preference
expressed with ENABLE_IPO. ClangCL requires other flags to enable the
equivalent LTO feature, and this is already addressed elsewhere.
2025-07-14 10:37:55 +01:00
TascoDLX 1ac8c602c9 ms: remove obsolete screen resize code 2025-07-13 15:31:15 +01:00
Giovanni Bajo d5135ca35f n64: improve gdb memory hooks
Now support reads and writes of arbitrary lengths in both RDRAM
and RCP ares (using respectively 8-bit and 32-bit accesses).
2025-07-13 15:30:52 +01:00
User 8265726879 gba: prefetcher cannot be read when R15 is misaligned 2025-07-12 13:43:20 +01:00
User 5261757f3c gba: prefetcher should not be marked full if read on the same cycle that it was filled 2025-07-12 13:43:20 +01:00
Luke Usher c099be2b85 pce: force enable Pixel Accuracy VDP
The scanline renderer in this case is too buggy and causes too many game issues at this time.
2025-07-10 19:27:26 +01:00
jcm de8143ef47 CI: Upload source archives with releases 2025-07-10 18:24:30 +01:00
jcm b80f08956b build: Fix ARES_VERSION_OVERRIDE in source archives 2025-07-10 18:24:30 +01:00
kev4cards a3088f6d4c node, n64, ps1: rework ps1 stick into a virtual square, adjust scaling for N64 stick, and move common code into Node::Input::Axis 2025-07-10 10:08:06 +01:00
jcm fdaf0b65a1 build: Run gersemi CMake formatting pass 2025-07-10 10:06:03 +01:00
jcm 71e0ad1f5b build: Improve build code for test harnesses 2025-07-10 10:06:03 +01:00
User c87be1b4f0 gba: more prefetcher timing improvements 2025-07-10 10:05:42 +01:00
jcm 625df94505 n64: Always re-init paraLLEl-RDP from worker thread 2025-07-09 06:48:58 +01:00
jcm 0dc80ee4a2 desktop-ui: Fix data race when loading title on startup 2025-07-08 20:38:47 +01:00
jcm f373fdc165 desktop-ui: Guard changes to emulator video settings 2025-07-07 17:49:49 +01:00
jcm 68f2c94658 desktop-ui: Use Program::Guard to manage program state 2025-07-07 17:49:49 +01:00
jcm 11750b9600 hiro: Adjust GUI run loop frequency 2025-07-07 17:49:49 +01:00
remutro 135cadd32f Use GBC core with N64 transfer pak to allow both GB & GBC saves 2025-07-07 17:49:42 +01:00
invertego f015fffd69 build: #ifdef guard pragmas specific to gcc/clang
This eliminates some warnings compiling with MSVC.
2025-06-30 11:39:31 +01:00
User aa7260a58d s3511a: port alarm handling from WonderSwan core 2025-06-30 11:39:22 +01:00
User cdd551f122 s3511a: add comments for registers with 0-byte payloads 2025-06-30 11:39:22 +01:00
User f3ce7952f6 gba: make S3511A a shared component 2025-06-30 11:39:22 +01:00
User 9b1eb2e2f9 gba: use same variable for input and output of RTC SIO pin 2025-06-30 11:39:22 +01:00
User c337ba258f gba: RTC status bit 7 is cleared on write, not read 2025-06-30 11:39:22 +01:00
User 6f16c5c17e gba: RTC should not be aware of GPIO direction 2025-06-30 11:39:22 +01:00
User b494705ad7 gba: fix RTC power-on state 2025-06-30 11:39:22 +01:00
User 371ba7b136 gba: implement GPIO output buffer 2025-06-30 11:39:22 +01:00
User fb685afa70 gba: initial RTC implementation 2025-06-30 11:39:22 +01:00
jcm f3ff75feb1 desktop-ui: Synchronize access to emulator configuration shown in status bar 2025-06-29 07:48:16 +01:00
jcm 5211e6c56d ares: Use atomic to synchronize run-ahead setting 2025-06-29 07:48:16 +01:00
invertego e3c5cfb44d ps1: make mute bit apply to reverb voices 2025-06-28 08:47:02 +01:00
invertego c95b48d95f ps1: make save states robust across ares launches
The CPU serialization logic would sometimes write pointers to save
states. Needless to say, this was not very compatible with saving and
loading states across separate runs of the ares process.
2025-06-28 08:46:36 +01:00
invertego 136afead52 ps1: represent spu noise as a signed 16-bit quantity 2025-06-27 12:17:26 +01:00
jcm 0865680da1 CI: Pin commit hashes for all third-party actions 2025-06-26 09:59:57 +01:00
jcm 08811ee3cb build: Use CMake build type for default launch configuration in Xcode 2025-06-26 09:59:57 +01:00
jcm b79ed895ff build: Prefer built-in setting for LTO on Xcode 2025-06-26 09:59:57 +01:00
jcm ece74e44e4 Show explicit Ccache status messages 2025-06-26 09:59:57 +01:00
TascoDLX b1c69c9f3f md: add cpu wait for apu bus access 2025-06-25 06:40:35 +01:00
Luke Usher 4c42273a07 ps1: DICR bit 15 is readable 2025-06-24 10:41:53 +01:00
Luke Usher ac58451996 nall: allow the use of VT100 escape sequences on Windows when supported and treat console output as utf8 2025-06-24 10:41:01 +01:00
Luke Usher 325c0ed876 ps1: use physical addresses as early as possible 2025-06-24 10:41:00 +01:00
Luke Usher f89777d8cc ps1: allow loading of executables with ps-exe extension 2025-06-24 10:41:00 +01:00
invertego f0fd4c0bd2 ps1: fix dma interrupt flag calculation
The topmost bit of the DICR (DMA Interrupt) register should not
influenced by the per-channel interrupt enable bits. This flaw was
masked in fast boot mode, as it allows title code to begin execution in
a pristine state unlike what the BIOS leaves behind.

With this change, the titles that were "fixed" by enabling fast boot
mode can now be launched with it disabled.
2025-06-24 07:02:17 +01:00
png183 a3d8db1c2a arm7tdmi: implement R15 misalignment and clean up LDM/STM (#2058)
Allows bit 1 of R15 to be set in ARM mode.

The updated LDM/STM implementations are functionally identical to the
previous versions, but are significantly shorter and require less
special-casing.
2025-06-23 11:21:30 +01:00
Luke Usher 073d7a5375 desktop-ui: status bar overhaul
The status bar now shows the loaded system configuration when there are no messages to display.
When GDB is enabled, debug status will show instead.
2025-06-13 12:13:25 +01:00
Luke Usher 264a1baafa desktop-ui: simplify region detection; fix "NTSC" base region and NTSC-DEV, etc 2025-06-13 11:42:14 +01:00
Luke Usher 645be6ab9b ui: implement order of region preferences= 2025-06-11 18:59:55 +01:00
Luke Usher 67fc2b1073 fc: fix database to allow running PAL/NTSC games in both supported modes 2025-06-11 15:03:16 +01:00
png183 46b1991f8f gba: prefetcher timing improvements (#2051)
Fixed a bug where the prefetcher was restarting too early upon being
emptied, and implemented a timing edge case involving simultaneous
accesses from the CPU and prefetcher.
2025-06-11 10:06:31 +01:00
Luke Usher c9dfe8a1b9 gb: g/hdma takes 4 clocks to setup + 32|64 clocks depending on mode 2025-06-09 16:55:02 +01:00
Luke Usher af07e1f863 gb: hdma should be triggered on the rising edge of the combined hblank & hdmaActive signal 2025-06-09 16:55:02 +01:00
jcm b624fadd75 desktop-ui: Acquire program mutex for hotkeys affecting state (#2048)
Fixes an oversight where hotkeys that affected emulated system state
were not acquiring the program mutex.

Should fix #2045
2025-06-06 17:21:40 +01:00
png183 46209710d7 gba: do not advance IRQs during DMA (#2047)
Improves timings regarding interactions between the IRQ pipeline and
DMA, allowing ares to pass more of Alyosha's new test ROMs.
2025-06-05 07:26:20 +01:00
Luke Usher 90eb0df7d7 gb: HDMA issued during hblank (mode 0) should be processed immediately
Fixes:
Little Mermaid II, The - Pinball Frenzy
3-D Ultra Pinball - Thrillride

Likely others
2025-06-04 11:19:53 +01:00
jcm 64c9751dc5 desktop-ui: Threading fixes (#2046)
* Acquire the program mutex when updating audio sync settings to prevent
a possible crash in some audio drivers
* Pause emulation while showing driver confirmation modals to prevent
interference from the UI thread calling `ruby::audio.clear()` during the
modal state, and also because pausing the application for a modal is a
normal pattern
* Restore a workaround when loading Arcade systems via the game browser
window that prevented a crash
2025-06-03 22:33:37 +01:00
jcm 54e3479708 desktop-ui: Initialize tools window before program (#2044)
When loading a ROM via a startup argument, `Program` requires access to
elements that are initialized as part of the Tools window. Thus, make
sure the Tools window is fully loaded before creating `Program`.

This restores the load order prior to the threading rework. An earlier
version of the threading rework created the program mutex differently,
which is why the load order was modified in the first place
(incidentally rather than intentionally).

Fixes #2043
2025-06-02 17:26:19 +01:00
png183 9186ec0201 arm7tdmi: specify undefined instructions more strictly (#2042)
- Adds instruction encodings for BX with bit 21 clear, and for an
undocumented `mov rd, rn` instruction
- Uses specific encodings for undefined instructions, rather than
binding them to unused encodings, and then asserts that all encodings
have been bound
2025-05-31 18:20:05 +01:00
png183 64196caef8 gba: step CPU 1 cycle at a time while halted (#2041)
Removes a speedup in the GBA core that was detrimental to accuracy.
Testing on Linux, the performance cost is more than offset by the recent
UI threading rework.
2025-05-30 20:34:53 +01:00
jcm 1d0d6177a5 desktop-ui: Threading rework (#1906)
Rearranges ares's main run loop, putting emulation in its own dedicated
thread that is separate from the main/GUI thread. This updates ares to
somewhat more modern application practices. This rework should have an
array of benefits, including increased UI responsiveness, improved
energy efficiency/performance, and increased compatibility with various
modern APIs and frameworks for rendering, input, and audio.

## Details

Generally, this PR implements a fairly simple approach to threading,
using `nall::thread`'s pthread-like semantics and several basic
recursive mutexes. For this initial implementation, we use very coarse
locking on the emulation thread, combined with very limited access to
the emulator state from the main and other ares threads, allowed to
occur between emulator run loop iterations. Synchronization on the
emulator state is managed via `programMutex`.

Since this mutex is held for the duration of the primary work loop,
including while the thread is suspended, the GUI thread should try to
never acquire the program mutex unless absolutely necessary. Doing so
with regularity will incur a severe UI responsiveness penalty. For
destructive updates like driver settings updates, memory writes, and
game loads/unloads, we acquire it. For other cross-thread communication,
we try to synchronize using other methods that do not incur a
significant performance penalty.

Window resizes triggered via the emulation loop synchronize with the
`_needsResize` atomic. Status messages are passed by acquiring the
`messageMutex`. `vBlanksPerSecond` is also now an `atomic<u64>`.

Input continues to poll on the main thread for compatibility with
existing code. Access to the input system is managed via `inputMutex`.

### Known Issues

Draft status as this is still a work in progress, but PRing now for
visibility, feedback, and to consolidate any issue tracking. There are
likely kinks left to work out; testing is appreciated.

~~- Cores are loaded on the main thread before being run on the emulator
thread; this causes issues for paraLLEl-RDP, which expects that the
thread to initialize Vulkan is also the thread that will make RDP
calls.~~ Addressed.

~~- Memory editor currently does not have access to the program mutex;
reads and writes are unsynchronized.~~ Addressed; memory editor
synchronizes on writes but reads occur in a thread-unsafe fashion.

~~- The Clang thread sanitizer still reports a couple data races in
Metal and OpenGL; further testing with other Ruby drivers is needed to
make sure resource access is properly managed, particularly with respect
to the output framebuffers.~~ A larger examination of locking in other
parts of ares is probably necessary, but I think out of scope for the
first iteration of this rework.

- The gdb server seems to still be working fine, but could probably use
more testing.
2025-05-30 09:48:22 +01:00
jcm 421b7abf96 build: Fix build on macOS 10.15 (#2027)
[Build docs
state](https://github.com/ares-emulator/ares/wiki/Build-Instructions-For-macOS)
that we support building on macOS 10.15. A couple things broke since
that was written:


https://github.com/ares-emulator/ares/commit/6cc9f5a416ec9b0077fc0f50912b1af96987cdf5
broke because AppleClang 12.0 thinks that `step` is referring to the
function called `step` rather than the argument provided to the
function.


https://github.com/ares-emulator/ares/commit/c287c1b22501152342746ada4c988049715a1934
broke because the availability macro was not written correctly.


https://github.com/ares-emulator/ares/commit/4fc09438d22b02ea23d70ff96661e24151165ef6
broke because we made an inappropriate replacement when replacing
deprecations: `NSRegularSquareBezelStyle` should have become
`NSBezelStyleRegularSquare`; `NSBezelStyleFlexiblePush` resolves to the
same appearance, but is unavailable in the SDK included with Xcode 12.4.
2025-05-29 18:01:11 +01:00
thekovic 7e9df5858d n64: Improve labels for internal resolution upscaling options (#2026)
The SD/HD/UHD options represent scaling the internal N64 resolution to
1x/2x/4x. Even for a title running at 640x480, this results in 1280x960
and 2560x1920 which doesn't match the meaning of HD/UHD. Games running
at lower resolutions give even more out of whack results. New label
communicates more explicitly what the option actually does.

I didn't change the string used to serialize this option in
`settings.bml`. Feedback welcome on whether I should do that.
2025-05-29 18:01:04 +01:00
Luke Usher 69381f7c54 ms: improve header validation; fixes many NTSC-J titles being detected as international 2025-05-29 12:51:24 +01:00
png183 8f55894d65 arm7tdmi: add support for more undocumented instruction fields (#2039)
Adds unused bits to MUL and MRS, and adds support for undocumented STR
counterparts to LDRSH and LDRSB.
2025-05-29 10:01:44 +01:00
jcm 4e1435be8a ruby/metal: Zero-initialize librashader handles (#2038)
Metal checks whether librashader handles are non-null during
deinitialization to determine whether to call librashader's `free`
functions on them.

If the handles are initialized to contain junk data, they will be
non-null but `free` will fail, causing a crash during the deinit that
occurs prior to any initialization of the video driver.

On Apple Silicon, the system malloc implementation provides something of
a guarantee that heap allocations are zero-initialized, but this proves
to not always be the case in practice. There are also no (or fewer) such
guarantees on x86_64.

On OpenGL, these pointers were already being zero-initialized.
2025-05-29 10:01:14 +01:00
png183 cf0c21e15a arm7tdmi: improved handling of PSR edge cases (#2036)
When the CPSR mode field is set to an invalid mode, SP (R13), LR (R14),
and SPSR are not mapped to any register. Therefore, writes to them
should fail, and reading them should return zero (or 0x00000010 in the
case of SPSR).

Update: Also implemented a new edge case for BX instructions, where
setting bit 22 causes SPSR to be modified rather than CPSR.
2025-05-26 09:16:36 +01:00
png183 e10ce79153 arm7tdmi: add undocumented SWP encodings (#2032)
Instruction bits 23, 21, and 20 do not need to be zero for a SWP
instruction to be successfully decoded.
2025-05-24 19:16:10 +01:00
jcm ad7b83b604 build: Miscellaneous fixes (#2033)
* Fix a regression where the application manifest was not embedding
properly on Windows, leading to various problems including incorrect UI
styling and DPI settings
* Fix an issue where we would fail to parse a canonical version from a
`git describe` string without a suffix
2025-05-24 19:15:39 +01:00
jcm 53f3b6a2a2 Update dependencies to 2025-05-22 release (#2029)
* Update SDL to 3.2.14, containing miscellaneous bugfixes
* Update librashader to 0.8.1, which should address a rare crash with
bad shader caches on Windows
* Update slang-shaders to its master branch contents as of 5-21
(8c630e0d3234d93b6c2bc847371f86aa4e535686)
* Update MoltenVK to version 1.3.0
2025-05-22 19:34:36 +01:00
Alexander Chen b630377ddc hiro/cocoa: Add Edit Menu, refactor menu creation (#2024) 2025-05-18 08:35:00 +01:00
User 24a9c00ae7 arm7tdmi: finish coprocessor interface 2025-05-18 08:34:06 +01:00
User b5488aad82 arm7tdmi: simplify coprocessor interface 2025-05-18 08:34:06 +01:00
User 5f782419ae arm7tdmi: implement CDP instruction 2025-05-18 08:34:06 +01:00
User 7d5c6d2561 arm7tdmi: implement MCR instruction 2025-05-18 08:34:06 +01:00
User 585e43a94c arm7tdmi: implement MRC instruction 2025-05-18 08:34:06 +01:00
Luke Usher 28ab75242f cmake: keyboard.cpp should not have been duplicated as an included source 2025-05-17 13:58:26 +01:00
jcm 4dd7a1f5fe build: Fix up artifact metadata to include version info, copyright 2025-05-17 13:55:29 +01:00
jcm 756ea5b704 build: Do not require tags, add unofficial versioning scheme 2025-05-17 13:55:29 +01:00
jcm 7c051bae0b Update CMake policy version, add old Finder metadata to .gitignore (#2019)
Add explicit support for CMake 4.0 version policies; the only change
required is to remove a superfluous/invalid POST_BUILD designation from
Linux bundling code.

Also add .DS_Store to the .gitignore, since developers may possibly
still be on systems old enough to litter these everywhere.
2025-05-16 19:23:55 +01:00
Luke Usher edfc6b5fb0 sg: SC-3000 keyboard support 2025-05-16 19:19:47 +01:00
Luke Usher cdc0633fdd sg: properly handle software with on-cart *volatile* ram 2025-05-16 18:07:41 +01:00
Luke Usher 71facd2e14 cmake: add missing sc-3000.cpp 2025-05-16 17:15:37 +01:00
Luke Usher af95d2b760 sg: preliminary sg-3000 emulation (no keyboard yet) 2025-05-16 17:11:56 +01:00
Luke Usher f4f48eb4b9 sg: fix that base SG-1000 doesn't use a PPI
The PPI chip is only present in SG-1000A (Arcade Board) and SC-3000
2025-05-16 14:52:22 +01:00
Luke Usher 667827ab00 sg: IO port B bits 3-6 are active low, 7 is active high 2025-05-16 14:44:07 +01:00
Luke Usher 70480452a8 i8255: implement BSR mode 2025-05-16 14:43:22 +01:00
png183 a70acad605 arm7tdmi: fix failed assertion in debug builds (#2016)
Fixes an assertion that was failing because of an oversight in #2007
regarding ARM7TDMI BX instruction decode bits.
2025-05-15 17:58:47 +01:00
png183 dca8745f83 arm7tdmi: implement more undocumented fields in BX and MSR instructions (#2011)
Adds shifter fields to MSR, and a CPSR mask field to BX.
2025-05-14 13:30:22 +01:00
png183 fabbdc8d8f arm7tdmi: branch instruction fixes (#2007)
Fixed an issue where an undefined opcode was being treated as an
unconditional branch in Thumb mode, and added a destination register
field to ARM mode BX instructions.
2025-05-09 07:36:00 +01:00
png183 1a79a0aae0 gba: various APU improvements (#1997)
- Fixes an edge case involving overflowing audio FIFOs
- Slight FIFO channel timing improvements
- Prevents most APU registers from being written while audio is disabled
- Fixes writing to wave RAM while audio is disabled
2025-05-06 10:34:52 +01:00
jcm de066b1ea2 build: Improve version handling (#1995)
ares' build system tries to always have version information available
for debuggability and build tracking. It depends upon the presence of
Git to provide version information, since Git is the version control
system used by the project.

When distributing tarballs of ares, however, no `.git` directory and no
inherent version information is included in-tree, which causes the build
to fail with a vague fatal error after failing to derive a version for
itself.

Since we would like building a tarball to be at least possible with
minimal fuss, we should provide some version information inside a tar
archive served by GitHub. This PR uses Git's
[export-subst](https://git-scm.com/docs/gitattributes#_export_subst)
attribute to automatically bundle version information when `git-archive`
is run against the repository, as is done when the GitHub API serves a
tar archive of a given release, branch or commit. The build system will
check for the presence of this file if it finds that there is no `.git`
directory at the root of the repository.

This PR also improves the version handling in general to better support
semantic version strings of the form `v123.x.y`, in case future releases
of ares require hotfixes or minor versions.
2025-05-05 14:50:07 +01:00
png183 c185fbd66e gba: reduce audio FIFO size from 32 to 28 bytes (#1963)
Closes #1869.
2025-05-01 11:54:09 +01:00
Alexander Chen dae8db9883 Edited insert to fix bug with "result" variable (#1961)
Fixed result such that insert(std::.....) actually updates result as it
is supposed to.

The change is occured in ares/nall/nall/set.hpp, line 83
2025-04-30 16:03:19 +01:00
jcm 4c4b2a5e5a CI: clangarm64 Windows to aux, clang-cl-arm64 to primary (#1960)
The [Windows signing action used by
ares](https://github.com/Dana-Prajea/code-sign-action) fails under
clangarm64 due to having the wrong path for `signtool.exe`.

This PR swaps the clang-cl arm64 Windows build back into the
primary/nightly workflow until we have a fix for clangarm64 codesigning.
2025-04-29 19:32:35 +01:00
png183 510ccf01d7 gba: add option to enable Game Boy Player (#1856)
Re-adds support for Game Boy Player rumble, with a UI toggle to
enable/disable the feature.
2025-04-29 18:44:46 +01:00
Luke Usher aab2fdf9b2 ps1: missed cmakelists in previous commit 2025-04-29 16:31:08 +01:00
Luke Usher e2d7106a6c ps1: remove the buggy recompiler while we improve overall accuracy
It may be replaced in future, but it introduces too many bugs in its current form.
2025-04-29 13:53:37 +01:00
Luke Usher 1598f67506 ps1: fix VRAMtoCPU transfers 2025-04-29 13:53:37 +01:00
Luke Usher 5d3f614c63 ps1: fix boot of discs without Sony copyright string (XPloder, etc) 2025-04-29 13:53:37 +01:00
Luke Usher 8ef16dfbd9 ps1: fix handling of CE bits of COP0.CAUSE
All tests in psxtest_cpu and psxtest_cpx now pass (when using the interpreter)
2025-04-29 13:53:37 +01:00
User 701cfb7b13 gba: fix erroneous EEPROM zero-initialization 2025-04-29 12:27:42 +01:00
jcm ae121d7377 build: Add arm64 runners to CI, fix msys2 clangarm64 build 2025-04-29 12:27:31 +01:00
remutro ed1e34c74e remove errant NALL_NOINLINE macro from SH2 instructions 2025-04-29 12:26:15 +01:00
Tim Hentenaar 728105b28e ps1: gpu: macro -> constexpr 2025-04-23 09:43:14 +01:00
Tim Hentenaar 3d88e24559 ps1: gpu: Ensure hi >= lo when calling std::clamp() 2025-04-22 13:41:06 +01:00
Adrian Siekierka a61ce6449f ws: support 8-bit bus width ROMs 2025-04-22 11:05:26 +01:00
jcm 63aa9ec5e4 hiro: Use GTK native file dialogs for portal compatibility 2025-04-21 09:49:36 +01:00
remutroandjcm 50e42627e2 Update mia/medium/super-famicom.cpp
Explicit cast so we hit the right constructor.

Co-authored-by: jcm <[email protected]>
2025-04-18 19:01:30 +01:00
remutro 3a46652b15 [SNES] Remove unnecessary additional string allocation 2025-04-18 19:01:30 +01:00
remutro 7528feabe8 [SNES] Update special case Sufami Turbo handling for Fuwafuwa Panic 2025-04-18 19:01:30 +01:00
remutro e57a80ea1b [SNES] Fix loading of some games using firmware by removing unnecessary data definition/reference to rom 2025-04-18 19:01:30 +01:00
User 4c0a03b35a gba: approximate PRAM access stalls in scanline renderer 2025-04-18 19:00:16 +01:00
jcm a247271e35 CI: Preserve symlinks in artifacts 2025-04-10 21:18:40 +01:00
jcm d61cfa905a Update ares-deps to 2025-04-09 release
Includes:
* Stop vendoring the librashader header on Linux
* deps.windows: Update librashader to 0.6.3
* deps.macos: Update librashader to 0.6.3
* Update slang-shaders to ref 25311dc
* Pin Rust nightly to version contemporary with librashader version
* Establish macOS deployment targets
* deps.macos: Update SDL to 3.2.10
* deps.windows: Update SDL to 3.2.10
2025-04-10 14:48:52 +01:00
jcm 9987bf18b2 ruby: Update to SDL3 2025-04-10 14:48:49 +01:00
Adrian Siekierka 8a80d32519 ws: PPU palette 4-7, 12-15 bit 0-2 reads as zero 2025-04-08 17:07:12 +01:00
remutro 5d0de5fbb3 Update MD serialization.cpp
Serialization for the MD, specific to the ym2612 audio implementation was changed, but there wasn't a version bump. This corrects this missing contribution.
2025-04-04 07:18:49 +01:00
jsgroth f06168e3f5 ym2612: fix LFO AM enabled bit not functioning 2025-04-04 06:52:02 +01:00
Adrian Siekierka 828f847efe ws: fix RTC cartridge protocol emulation 2025-04-03 18:36:34 +01:00
jcm d8c997ca8a build: Enable CHD support via build option 2025-04-03 10:47:15 +01:00
jcm 93137b76b4 mia: Add generic CD data sector read method 2025-04-03 10:47:15 +01:00
jcm b889aff3d4 desktop-ui: Don't show missing firmware error twice 2025-04-02 10:42:35 +01:00
Giovanni Bajo 70f3bfa00c n64: disable RDP readbacks from super-sampled image
This fixes some tests in the official RDP testsuite
2025-04-01 17:53:16 +01:00
User d942746f74 gb: implement undocumented PCM12 and PCM34 registers 2025-03-31 18:52:41 +01:00
jcm 1c05456bec libco: Define LIBCO_MPROTECT by default on aarch64 2025-03-27 15:36:11 +00:00
User 240363d31a gba: add renderingCycle to scanline renderer 2025-03-27 10:37:54 +00:00
User ebb3bcb37b gba: improve handling of mid-scanline writes to linear background scroll registers 2025-03-27 10:37:54 +00:00
remutro ab14fb1d10 [MS] Update PAL only entries in mia DB 2025-03-26 14:32:33 +00:00
User 7ba94fe7e4 gba: override save type in known problematic cases 2025-03-24 07:28:00 +00:00
jcm 69ea086d95 build: Remove invalid arguments from custom commands 2025-03-24 07:27:40 +00:00
jcm a510ac7e55 build: Don't search for usbhid on non-BSD 2025-03-24 07:27:40 +00:00
jcm ac98fd8d9c build: Fix macOS SDK detection for CMake 4.0 2025-03-24 07:27:40 +00:00
remutro 122820753e Add DB entry for Back to the Future III which was PAL only 2025-03-20 11:59:56 +00:00
remutro e355fbe88c [N64] Fix Id for Rampage 2 - Universal Tour in DB 2025-03-20 11:59:49 +00:00
Adrian Siekierka c1efa05d65 ws: fix regression in APU logic 2025-03-16 17:46:58 +00:00
Adrian Siekierka da071246fe v30mz: make I/O access timing marginally more accurate 2025-03-15 15:49:37 +00:00
Giovanni Bajo cca0ecf202 n64: add IPL2 checksum failure as accuracy flag
As part of the boot security, IPL2 (run by CPU), PIF and CIC collaborate
to verify that the IPL3 (stored at the beginning of the ROM) is valid
and not tampered, by running a checksum. If the checksum is invalid,
the console is halted immediately.

Ares emulates this behavior correctly. Sometimes, though, it might be
useful for development purposes to let some ROM boot even with a failing
checksum. Given that disabling the check was non-obvious, I'm adding
an accuracy compile-time flag for now.
2025-03-15 15:49:28 +00:00
remutro 17aee9071d Fix check for pif rom when loading Aleck64 games 2025-03-15 15:49:14 +00:00
User b92ae8a14c gba: improve linear background VRAM access timings 2025-03-15 07:59:34 +00:00
jcm 4ae42b2d44 desktop-ui: Fix up app icon, macOS asset compilation 2025-03-13 20:01:42 +00:00
Adrian Siekierka 2a11da200d ws: APU accuracy fixes
- the noise LFSR reset bit takes effect immediately
- channel period counters tick only when they're enabled, including
  if channel 2 is in voice mode or channel 4 is in noise mode
- the noise LFSR only ticks if channel 4 is enabled in noise mode
2025-03-09 21:32:21 +00:00
Giovanni Bajo cbf4a939aa n64: allow booting ROMs with non-standard PI DOM1 parms in the header
All commercial ROMs in N64 have the value 0x80371240 in the first 4
bytes. This has long been used by emulators both as a magic number to
"detect a N64 rom", and as a way to detect endianess of the dump.

In reality, the first byte (0x80) is unused/ignored by the console, while
the other 3 (0x371240) are just parameters used to configure cartridge
access (basically, ROM speed). There's absolutely nothing that prevents
a ROM with other values to boot. Ares currently fails to honor this
by refusing booting ROMs with different values, but this is just wrong.

To fix this, we change approach and use the CIC detection algorithm to
also detect the endianess, given that it's based on a checksum match.
If we can't find a match, we tried the two common types of byteswaps,
hoping to find a match. Eventually, we fallback to assume it's a
big-endian dump, and needs the common CIC-6102.

This means that analyze() will now only reject ROMs with size lower
than 4 KiB, but that's correct. Given that 4 KiB are loaded by the
IPL2, we assume that minimum size is required. Besides that, there is
nothing else in the ROM that can be used to "detect" a N64 ROM, so
it's correct to just let it boot and see what happens.
2025-03-09 19:20:31 +00:00
Adrian Siekierka d10a8498e2 ws: clear serial IRQs if serial block is disabled 2025-03-09 19:19:57 +00:00
Giovanni Bajo 2eb6bf6df8 gamepad: bank switch command must be ignored for single-bank paks 2025-03-05 12:21:44 +00:00
Cuyler36 35ede44b80 Support dynamic bank counts for N64 Contorller Paks 2025-03-05 12:21:44 +00:00
Giovanni Bajo 0c011fb2d4 n64: add O.D.T. to gamelist 2025-03-05 12:21:30 +00:00
Giovanni Bajo a006ef97e7 vi: make sure we refresh the screen even when VI is disabled 2025-03-04 20:07:46 +00:00
User 14a4f32997 gba: perform VRAM accesses in bitmap and affine modes even when no pixel is rendered 2025-03-04 20:06:28 +00:00
Adrian Siekierka 25c1e281cc v30mz, ws: fix HLT regression 2025-03-03 22:47:01 +00:00
invertegoandpng183 3ee7556bb7 arm7tdmi: add missing idle cycles
Co-authored-by: png183 <[email protected]>
2025-03-03 13:15:10 +00:00
invertegoandpng183 a5b11b13d0 arm7tdmi: move to status register bit 4 fix
Co-authored-by: png183 <[email protected]>
2025-03-03 13:15:10 +00:00
invertego 01e6cc1443 arm7tdmi: thumb carry flag fixes 2025-03-03 13:15:10 +00:00
invertegoandpng183 f5dace0a0f arm7tdmi: r15 fixes
Co-authored-by: png183 <[email protected]>
2025-03-03 13:15:10 +00:00
invertego 6b5ebb2882 arm7tdmi: fix disassembler mnemonic 2025-03-03 13:15:10 +00:00
Adrian Siekierka 140782662b v30mz: breaks are also delayed by one instruction 2025-03-02 18:13:58 +00:00
Adrian Siekierka 3daec1184a v30mz, ws: fix interrupt triggering edge cases on interrupt flag change 2025-03-02 18:13:58 +00:00
Adrian Siekierka 7e4386c1bf v30mz: fix interrupt triggering incorrectly around segment move instructions 2025-03-02 18:13:58 +00:00
Adrian Siekierka 8eba8ad784 ws: make level interrupts take immediate effect 2025-03-02 18:13:58 +00:00
png183 08377d02e2 gba: update list of game codes that require mirroring 2025-03-02 18:13:11 +00:00
Luke Usher ea4ad6890a md: 32X display is offset by approx 3.25 pixels to the right in H32 mode 2025-02-27 14:07:21 +00:00
Luke Usher 50be2e4e63 fc: add delay when changing FDS disk state 2025-02-27 11:48:05 +00:00
jcm effc5614bc CI: Align MSYS2 git line ending settings with system git 2025-02-23 14:47:32 +00:00
jcm 5f81464857 misc: CMake formatting pass 2025-02-22 08:50:47 +00:00
jcm bd8442605e build: Move Linux librashader path hint to package finder 2025-02-22 08:50:47 +00:00
jcm da312032de build: Prevent macOS deployment target being modified during auto-regeneration 2025-02-22 08:50:47 +00:00
jcm c509dd3964 Remove CRLFs from ares/n64/CMakeLists.txt 2025-02-22 08:50:47 +00:00
jcm 10a4d480de CI: Unset draft status on tagged releases 2025-02-22 08:50:47 +00:00
User 8c3ead7cb0 gba: latch lower ROM address lines during burst transfer 2025-02-22 08:50:32 +00:00
jcm 1b36d47554 ruby: SDL2 input fixups 2025-02-21 08:37:07 +00:00
jcm 2c940b03a1 nall: Retrieve executable path more reliably 2025-02-21 00:16:50 +00:00
User 7a5174a712 gb: tick timer on falling edge 2025-02-19 18:03:06 +00:00
remutro 274d6eb9a5 Allow for trimmed and padded versions 2025-02-19 18:02:56 +00:00
remutro de0cb099cb Update sha256 for Wonder Boy in Monster World (USA, Europe) for proper eeprom assignment 2025-02-19 18:02:56 +00:00
jcm 32fd70f7c7 build: Enable system library semantics for nall in other targets 2025-02-19 18:02:47 +00:00
Luke Usher b2251305c0 md: always sync core MD components regardless of reduced sync
Fixes VDP H/V tests in testpico when running as a 32X rom.
2025-02-18 14:25:38 +00:00
FitzRoyX 25a2602300 Update README.md 2025-02-18 08:35:00 +00:00
FitzRoyX 4480f7adec Update README.md 2025-02-18 08:35:00 +00:00
jcm 4197502402 nall: Resolve all file paths passed on command line 2025-02-18 08:34:42 +00:00
TascoDLX fb96de3eef mcd: fix subcpu reset behavior 2025-02-18 08:31:56 +00:00
Luke Usher 54c898f199 pak: saveName() needs to call name(), in case it was overridden. 2025-02-17 17:57:26 +00:00
TascoDLX e48b208de2 ym2612: fix timer behaviors 2025-02-17 12:07:24 +00:00
TascoDLX a9f9fd90e7 m32x: fix regs & reset state 2025-02-17 12:07:24 +00:00
TascoDLX deb8830c82 md: fix vdp irq timings 2025-02-17 12:07:24 +00:00
Adrian Siekierka 58af8cb64b ws: First pass at "mono" model color emulation. 2025-02-16 13:17:41 +00:00
TascoDLX c9285b5289 m32x: fix pwm serialization 2025-02-12 06:28:23 +00:00
jcm 4fc09438d2 misc: Address macOS deprecation warnings 2025-02-11 21:36:32 +00:00
jcm a0a7a53b32 build: Increment macOS deployment target to 10.15 2025-02-11 21:36:32 +00:00
User 90f1425b8e Simplify prefetcher logic 2025-02-10 20:47:44 +00:00
User 9f4446061d Initial commit 2025-02-10 20:47:44 +00:00
jcm 32e58943f0 build: Adjust CI push workflow to properly run on all branches 2025-02-10 18:03:40 +00:00
jcm bc116e70e1 build: Add legacy zconf header to .gitignore 2025-02-10 18:03:40 +00:00
jcm 992e1c08cb misc: Use shortened copyright string in About dialog 2025-02-10 18:03:40 +00:00
jcm 9dcc1a39d3 build: Statically link libc++ when using GCC on Windows 2025-02-10 18:03:40 +00:00
Luke Usher 9bbcf638dd gb: use "Game Boy" save path for both GB and GBC
Fixes using the same rom file on both GB and GBC hardware without losing save-data between them
Fixes Pokemon Stadium when loading a .gbc rom (the Transfer Pak only used the GB path)

Existing users using a custom save game path will have to manually move their saves from "Game Boy Color" to "Game Boy"
Users using the default "Save alongside rom files" will not have to take any action.
2025-02-10 16:18:42 +00:00
Luke Usher d6c8d36770 md: fix 32x blending when MD is in H32 mode 2025-02-10 12:54:49 +00:00
jcm c19cf47803 hiro/cocoa: Ensure trailing slash in directory picker result 2025-02-10 09:45:15 +00:00
remutro 1d5a5aef83 remove accidentally introduced space in line with no change 2025-02-09 18:46:25 +00:00
remutro 64ec01bd57 Proper 32X region header processing for licensed games 2025-02-09 18:46:25 +00:00
Luke Usher 82b1e88ec1 sfc: fix typos in sub-rom loading
Fixes Super Game Boy
Fixed Sufami Turbo
Fixes Satellaview/BS Memory Pak
2025-02-07 23:25:43 +00:00
Vincent Cunningham a592dc24d2 ci: Ignore nightly tag for versioning 2025-02-07 18:40:12 +00:00
Luke Usher 976b9828b6 md: Fix new emulator hang/crash in SRB2 32X port 2025-02-07 12:09:04 +00:00
Luke Usher 7f625b6348 md: more 32X PEN=0 stalls; cleaner multi-device sync 2025-02-07 11:51:48 +00:00
Luke Usher 23a9d66924 md: stall m68k when accessing 32x palette when PEN=0
Fixes colours in Chaotix
2025-02-07 11:37:52 +00:00
TascoDLX e4e9044097 m32x vdp fixes
- SH2 memory windows have been adjusted. The framebuffer areas must be mirrored up to 0x5ffffff -- fixes Toughman Contest backgrounds.
- VDP FEN & PEN flags are closer to accurate but still missing some finer timing details.
- FEN/PEN status may block vdp memory accesses. The docs seem to indicate that accesses may be held in wait until a status change, but thats not totally clear (nor validated?). For now, these accesses are blocked and logged in debug.
- FM setting (framebufferAccess) only allows vdp access by either 68k or SH2-side, so additional guards have been inserted for cram/framebuffer accesses. VDP reg accesses should be blocked as well according to docs, but this aspect needs to be reviewed.
- VDP reg latching has been implemented. The timing isnt completely accurate, but should be decent enough for now. Fixes Mars Check image test (corrupt lines from mode switching).
- Autofill timing has been implemented according to the docs. For now, this is just signaling via the FEN flag. Fixes MK II glitching et al.
2025-02-07 09:06:57 +00:00
Vincent Cunningham 04a51df859 ci: Update nightly tag to latest commit 2025-02-07 07:27:08 +00:00
Luke Usher 0c80c1e56b Merge remote-tracking branch 'origin/master' 2025-02-06 21:16:47 +00:00
Luke Usher 6f7618dc81 sh7604: log when wdt is used in watchdog mode 2025-02-06 21:16:29 +00:00
Luke Usher fdd7acb76b md: tweak 32X timing numbers
Should fix Brutal and Chaotix
2025-02-06 20:55:14 +00:00
Luke Usher 7ce2ffd010 md: tweak 32X timing numbers
Should fix Brutal and Chaotix
2025-02-06 20:54:38 +00:00
Vincent Cunningham bb22386f5f n64: Don't report interrupt exceptions to GDB
Interrupt exceptions fire multiple times per second and having to ack all of them can cause performance issues while debugging.
2025-02-06 19:04:36 +00:00
Luke Usher b372f65691 md: refactor sync between 32X components
Hopefully we don't see any negative impact from this;
I have tested many known timing-sensitive games with no ill effects locally.
2025-02-06 19:00:27 +00:00
Luke Usher 048d0e331d md: add internalStep function for 32x recompiler
Allows in-block calls to step() to become an increment which to be
actioned in bulk at the end of the recompiler block
2025-02-06 13:01:43 +00:00
jcm 1323a627b3 Update scripts and documentation 2025-02-06 06:41:02 +00:00
jcm b4ef96e4d6 Remove old macOS build script 2025-02-06 06:41:02 +00:00
jcm 8d2f88b745 build: Re-add librashader headers to source tree for Linux builds 2025-02-06 06:41:02 +00:00
jcm ca7eee17a9 build: Remove CMake platform definitions 2025-02-06 06:41:02 +00:00
jcm 9ef81df3cf build: Remove legacy gitignore entries 2025-02-06 06:41:02 +00:00
jcm 68af829f8e build: Remove legacy zconf header 2025-02-06 06:41:02 +00:00
jcm 56862e0026 build: Use configure_file to define version, copyright info 2025-02-06 06:41:02 +00:00
jcm 09d8af1c18 build: Rename configured files 2025-02-06 06:41:02 +00:00
jcm d20bc3c1b0 build: Remove legacy compatibility compile definitions 2025-02-06 06:41:02 +00:00
jcm 97c82119b5 build: Remove resource files 2025-02-06 06:41:02 +00:00
jcm b78228c5c0 build: Remove legacy workflow 2025-02-06 06:41:02 +00:00
jcm 5107ed00cb build: Remove dynamic dependencies from thirdparty 2025-02-06 06:41:02 +00:00
jcm aeff8ec8f9 build: Remove GNUmakefiles 2025-02-06 06:41:02 +00:00
Christopher Bonhage 7640e1598c n64: fix Joybus RTC read/write status byte (#1814)
As documented in the N64brew wiki:
https://n64brew.dev/wiki/Joybus_Protocol#0x07_-_Read_Real-Time_Clock_Block

The final output byte of Joybus RTC read/write commands should be the
RTC status.

This intended behavior has been confirmed with Mateusz Faderewski, the
creator of SummerCart.
2025-02-05 23:58:05 +01:00
Luke Usher 04c608a21e bump version to v142 2025-02-05 13:28:51 +00:00
James Groth 8a75015d7e m32x: make PWM timer interrupt interval bits read-only from the MD side (#1813)
Per page 24 of the 32X hardware manual, the PWM timer interrupt interval
is read-only from the Mega Drive side.

This change fixes incorrect sound effects in Primal Rage. If the 68000
is allowed to write to these bits, it will change the PWM timer interval
from 1 to 16 during game boot, which breaks the game's PWM sound driver
code.

Primal Rage title screen audio before this change:

[primal-rage-before.webm](https://github.com/user-attachments/assets/0d8a33d1-22fb-4664-a802-00715541e67f)

After:

[primal-rage-after.webm](https://github.com/user-attachments/assets/87a3cdfe-85a4-45e7-8ea8-bc3e5bde4f7a)
2025-02-05 07:56:36 +00:00
Luke Usher 330a329abc desktop-ui: clear game browser search field when loading 2025-02-04 11:46:15 +00:00
Luke Usher a21f8c074c desktop-ui: add search to arcade game browser 2025-02-04 11:46:15 +00:00
jcm c899461cf1 build: More miscellaneous fixes (#1811)
Minor changes:

- Run CI for pushes to any branch, not just master. This is mostly
relevant for forks, where you will often want CI on WIP branches.
Releases still check that they are on the master branch and won't be
generated for other branches.

- The GCC `stringop-overflow` heuristic still seems to be buggy,
tripping in seemingly irrelevant areas, and in different areas depending
on toolchain/OS. Hence, just disable it for now; conforms with legacy
behavior.

- Fix a macro redefinition in the GTK CMake code

- Add a missing "included" source to the desktop-ui CMake code so it
shows up in IDEs

- `gersemi` formatting pass

Lastly:

Allow generating DWARF symbols in MSYS2/MinGW environments. This is
controlled by the cache variable `ARES_MINGW_USE_DWARF_SYMBOLS` (on by
default only for GCC, inoperable under MSVC/Clang-CL). This allows for
easier use of gdb or lldb for debugging on Windows. The support here is
considered incomplete but functional for debugging the main ares
executable.

In particular, we do not generate DWARF symbols on Windows in ares-deps,
so debugging dynamic dependency issues with gdb or lldb will require
self-compiling dependencies. DWARF symbols are also embedded and this PR
does not ship them with releases. The "primary" Windows clang build will
continue to use CodeView symbols so that releases may be debugged with
WinDbg, Visual Studio, etc.

I am not satisfied with this level of support, but I am also not sure
whether "full support" for two independent debugging symbol formats on
one platform is a reasonable thing or a good idea to maintain. For one
thing, ares-deps targets the MSVC ABI for portability, where DWARF
symbol availability is limited. Targeting the GNU ABI in ares-deps would
mean reconciling multiple independent components' dependence on libc++
that would eventually need to be linked together. This might
theoretically be possible but in any case is not undertaken here. Also
not undertaken is the extant PDB functionality for stripping into
separate files, bundling, copying to the rundir, etc.
2025-02-04 11:45:23 +00:00
Luke Usher 512b53f808 mia: update neo geo database 2025-02-03 13:48:45 +00:00
Luke Usher 2fb2da047c scripts: update-arcade-rom-db.sh should also import mame softwarelists too 2025-02-03 12:21:44 +00:00
Luke Usher cdbd9e0d2c mame2bml: better softwarelist export 2025-02-03 12:20:55 +00:00
Luke Usher 745e41a6ee desktop-ui: fix game browser not listing "neo geo" games. 2025-02-03 11:37:08 +00:00
Luke Usher ab40ecbb9b md: slight performance boost with loop free 32x timers 2025-02-03 10:07:05 +00:00
Luke Usher 72ead4d2a6 md: remove unnecessary pwm comment
was a note to self while testing
2025-02-03 10:07:05 +00:00
TascoDLX aef110f35d m32x+md fixes (#1807)
1. Revised pwm emulation, mostly to align with documentation. Not likely
to affect much except for rare edge cases. Also, added a dc filter to
prevent audio popping in certain situations (like window losing focus),
but pops on init are correct behavior. Fixes #937 by implementing
byte-wide fifo writes from the SH2 side.
2. Various fixups to 32x io access by the 68k. Fixes #1196 and missing
music in Brutal.
3. Follow-up to a previous PR: cram dots were not limited properly, and
line buffer adjustment was crashing 32x in certain cases (as reported in
the discord).
2025-02-03 07:45:59 +00:00
Giovanni Bajo e99c9c57b0 n64: fix a typo in ISViewer address range (#1806)
Added in 14786372. This basically prevented ROM size between 0x3f0'0000
and 0x3ff'0000 to work correctly in Ares.
2025-02-01 08:26:45 +00:00
Luke Usher 9c273abec3 md: better handle 32X PWM sample/clock rate changes 2025-01-31 19:53:54 +00:00
Luke Usher 6cc9f5a416 pce: reduce per-iteration conditional statements in psg
This also significantly increases performance
2025-01-31 14:40:52 +00:00
Luke Usher 69c20711fc pce: evaluate SuperGrafx check at power-on time in the VDP
This provides a significant performance boost pixel-accuracy mode
2025-01-31 14:40:52 +00:00
FitzRoyX 539aa9b7d6 cv, msx, myv: adjust overscan numbers (#1805)
active framing
2025-01-31 06:34:47 +00:00
FitzRoyX 5d7dbb7eed ms: adjust overscan numbers (#1803)
targeted 192 for ntsc and 224 for pal. Framing on top and sides is now
precise to active display. Sadly, only a few codemasters pal games
utilized 224.
2025-01-30 09:47:56 +00:00
FitzRoyX 6176287392 sg: adjust overscan numbers (#1804)
set to active display 256x192
2025-01-30 09:47:39 +00:00
FitzRoyX ce2e6f8c19 fc: adjust overscan numbers (#1801)
Overscan=off now shows active display centered and intact for both
regions. The pal ppu micromasking behavior was corrected (253 vs 254)
and commented out.

SMB2 EUR full frame

![smb2_e_fullframe](https://github.com/user-attachments/assets/3645d6b2-d97e-4f8a-865a-61464da01287)

before/after


![smb2before](https://github.com/user-attachments/assets/27fa1157-f715-4f92-9814-e1d13da2690a)
![ares-n](https://github.com/user-attachments/assets/fbed864b-2a05-4c0d-8a6b-8ce83d8a4684)

before/after

![Untitledggg](https://github.com/user-attachments/assets/03f41051-ca9b-4223-940d-d869745ff0a5)
![Untitledhhh](https://github.com/user-attachments/assets/dd761deb-6a34-4132-903c-433a36d22066)
2025-01-29 17:21:53 +00:00
Luke Usher 76ab41c69c sfc: fix screen offset after line-doubling work 2025-01-29 17:19:34 +00:00
jcm 928d76b0b5 CI: Use CI source directory when generating description (#1802)
Fixes the build. Verified to work here:
https://github.com/jcm93/ares/actions/runs/13033850846
2025-01-29 16:16:50 +00:00
jcm c1949d8eb5 CI: fix build (#1799)
Only include the commit subject in the release body rather than the
entire message.
2025-01-29 10:57:54 +00:00
Luke UsherandDarren Thompson 6946437115 Preliminary support for Aleck64 (#1758)
In its current form, all games that use standard Aleck64 hardware should
function correctly, using the current MAME romset at the time of writing
(0.273)

The following games are known to be working:

- Eleven Beat
- Hanabi de Doon! - Don-chan Puzzle
- Hi Pai Paradise
- Hi Pai Paradise 2
- Kurukuru Fever
- Mayjinsen 3
- Star Soldier: Vanishing Earth
- Super Real Mahjong VS
- Super Real Mahjong VS (Rev A)
- Tower & Shaft
- Vivid Dolls

The following games are known to be non-working:

- Magical Tetris Challenge (981009 Japan): Requires custom video
hardware: boots but unplayable.

Known Issues: 

- Games using EEPROM do not currently save their settings between
executions.|

---------

Co-authored-by: Darren Thompson <[email protected]>
2025-01-28 13:01:22 +00:00
invertegoandpng183 76a5f8e1da arm7tdmi: add instruction test harness (#1796)
Co-authored-by: png183 <[email protected]>
2025-01-28 12:45:24 +00:00
invertego bf9aae53d0 hiro: fix double character inputs in Windows HexEdit widget (#1798)
At some point it might be worth going through the list of widgets to
understand which ones require WM_KEYDOWN messages to be forwarded by
Application_keyboardProc. For the time being, it's clear the HexEdit
widget is not among them, so this change disables forwarding for that
widget type.

As an added bonus, this change also makes the number pad functional.
2025-01-28 12:45:13 +00:00
jcm 1a5559a24b build: Miscellaneous fixes (#1795)
- Fixes the nightly release so that the release body will contain the
latest commit message (only the first line). Tagged releases will now
also contain a description.
- Ignore a benign warning in sljit that was popping up in build
annotations.
- Fix a warning about a conflict in the `mia-ui` domain string on macOS.
2025-01-28 06:27:38 +00:00
jcm af5fa1a1c8 mia, desktop-ui: Add basic error handling to ROM loading (#1785)
> [!NOTE]
> Seeking testers on this to validate that errors appear correctly, are
accurate, and we didn't break anything.

### Description

Adds the `LoadResult` type, used to identify and propagate upwards
errors encountered when loading ROMs and systems.

Modifies the `mia` and `desktop-ui` load routines to use this type
instead of generic booleans, so that if we have a load failure, we can
propagate a precise and useful error to the user rather than a vague and
possibly mismatched one.

Currently the scope of the error handling is just `mia` and
`desktop-ui`; errors encountered when loading in `ares` itself are
currently generic "`otherError`"s. `LoadResult` is placed in
`mia/mia.hpp` so it is accessible to both `mia` and `desktop-ui`. If
LoadResult is added to ares loading in the future, the LoadResult type
may need to be moved.
2025-01-27 18:46:05 +00:00
Luke Usher 4c367fd32f sfc: don't line-double non-interlaced content 2025-01-27 14:49:22 +00:00
Luke Usher 2d714d1a9c md: don't line-double non-interlaced content 2025-01-27 14:33:42 +00:00
jcm 8dbd2135b7 CI: Refactor workflows (#1790)
This is a minor reorganization of the new CI to be more modular and use
more organized patterns. Rather than one large all-in-one workflow,
items are now split slightly into discrete parts. Namely, there is a now
a PR workflow called for PRs, and a push workflow called for pushes to
the master branch, which in turn call constituent workflows for builds
and releases.

This enables a few conveniences:

- Workflows are split into concurrency groups that will automatically
cancel themselves. For example, if a PR is pushed multiple times in
succession, CI will be automatically canceled for all but the most
recent push.

- Permissions are applied discretely and in a somewhat more organized
way. The PR workflow simply has the "read" permission, while the master
push workflow has the "write" permission.

While the existing all-in-one workflow was not insecure, it relied on
GitHub Actions failsafes (such as pulls from public forks not being
granted write permissions nor secrets) in order to work properly, which
has the side effect of making the workflow's logic somewhat more
difficult to understand.

- New workflows can hopefully be more easily created based on
constituent parts. For example, the PR flow simply executes "build",
while the push workflow simply executes "build" as well as "release".
Future workflows could, for example, "build" and then call a new "test"
workflow to execute the test harnesses using the built artifacts and
report results. This can now be done without requiring as much delicate
attention to the existing workflow logic.

Future work:

- Ideally our "build" workflow could be refactored into a composite
action rather than a workflow. This would enable it to use defines
created in the initial "pull" or "push" workflows more easily, allowing
us to cleanly separate, for example, codesigning-related steps that
install secrets on the build machine, from actual build steps/jobs.

> [!NOTE]
> This was tested on a local fork, but several minor changes were made,
so it's opened as a draft until it can be double checked that nothing
broke.
2025-01-27 10:04:33 +00:00
FitzRoyX c62e2a254c sfc: adjust overscan numbers (#1794)
These coord and offset numbers will hide all empty space (including
blanked active lines) without cropping any good pixels on the sides. The
output now matches old ares and bsnes. Whether the blanked lines should
be shown can be revisited later (most users have no idea what these are
and will hate them). SMW USA 1.0, SMW EUR 1.0, and SMW EUR 1.1 were used
for testing as each variant triggers each of the 3 modes and the game
draws border tiles all around.

Screenshots:

SMW USA 1.0


![smw_u10_overscan](https://github.com/user-attachments/assets/ab087adb-ccbf-4039-935c-876fab46baa8)


![smw_u10_xhideoverscan](https://github.com/user-attachments/assets/3a74120a-8468-4451-842e-495837fa4902)

SMW EUR 1.0


![smw_e10_overscan](https://github.com/user-attachments/assets/b790b84d-3632-434c-9307-8bc35555e995)


![smw_e10_xhideoverscan](https://github.com/user-attachments/assets/e11a179f-0775-4929-be19-3af24347e8c2)

SMW EUR 1.1


![smw_e11_overscan](https://github.com/user-attachments/assets/5ebdb315-3700-4ce4-9bd1-91077c3ff357)


![smw_e11_xhideoverscan](https://github.com/user-attachments/assets/ae07af5a-4acd-419f-b79f-bd4d07aeee63)
2025-01-27 07:00:03 +00:00
Giovanni Bajo dfcd7d4fce n64: fix gdb causing MIPS exception on attach (#1793)
Fixes #1778
2025-01-26 20:57:37 +00:00
Luke Usher fa1c21ba3d sfc: reduce overscan crop area slightly 2025-01-25 20:14:42 +00:00
曾耿森 a584782a86 fix: fix ppu scroll glitch bug (#1788)
Use open bus to set some parts of V
(glitch that occurs when writing to
$2000/$2005/$2006 on cycle 257)

Related issue #1235
2025-01-23 18:21:07 +00:00
jcm 6185edc43b ruby: Initialize sRGB option on Metal (#1789)
While looking at something else I noticed that we were not respecting
the stored value of the "Force sRGB" option on startup. As a result we
would always output in sRGB unless the user explicitly modified the
option during the session.
2025-01-22 19:15:34 +00:00
remutro 7772fdbf0a [MD/32X] Force PAL region when (PAL) or (Europe) are in ROM name (#1781)
There are numerous headers in Mega Drive & 32X games that are not
correct resulting in PAL games to run at 60Hz instead of 50Hz. This
corrects this issue by using the same technique the Atari 2600 core uses
which is to look for "(PAL)" or "(Europe)" in the ROM name which will
then force the game to run as a PAL game.

This also addresses the 32X game Shadow Squadron - Stellar Assault which
is supposed to be an NTSC-U and PAL game, but only has PAL in the header
so it could only run at 50Hz. This adds NTSC-U as an option (leaving PAL
as the default), but can be selected using the "Prefer US" boot option
so it can run at 60Hz.

Addresses issues: 
https://github.com/ares-emulator/ares/issues/1066
https://github.com/ares-emulator/ares/issues/1067

And yes, I'm aware I submitted an additional commit cause I spelled
Assault wrong in the comment, and managed to spell it wrong again in the
commit message. 🤦‍♂️
2025-01-19 17:22:06 +00:00
jcm fd8bcad5a1 CI: fix macOS CI PR runs (#1777)
Fix macOS CI on pull requests by persisting if we fail to import the
certificate (as expected). Notarization should expectedly fail as well
on pull requests, if it tries to run.

(Whether CI succeeds on this is the testing)
2025-01-19 10:09:06 +00:00
jcm da7a79b21e build: Remove redundant linking under gcc for test harnesses (#1779)
After https://github.com/ares-emulator/ares/pull/1774 the workaround for
the Windows variant of `main` being discarded early by `ld` is no longer
necessary.
2025-01-19 10:07:11 +00:00
invertego 639ebe6285 m68000: fix CHK instruction timing and flags (#1776) 2025-01-18 16:14:22 +00:00
invertego 9be2f9bb92 nall: move main/WinMain definition from .cpp to .hpp (#1774)
It's already expected that nall/main.hpp will only be included in a
single file, so we may as well define main at the same time. This allows
the console/Windows subsystem distinction to be controlled on a
per-target basis instead of being compiled into nall.

Targets that should always build as console applications now set a
CONSOLE variable in their CMakeLists.txt, overriding the cache variable
of the same name. The remaining targets can still be controlled at
configure time by passing -DCONSOLE=1, which will compile everything as
a console application.
2025-01-18 12:40:28 +00:00
TascoDLX ce71fff00c ym2612: fixing the bugs (#1775)
1. The cycle update order needed clean up, mostly to fix feedback.
2. Envelope update function was also reordered to avoid double update
issue.
3. LFO behavior was corrected (should apply proper attenuation when
disabled).
4. To avoid potential update issue, rate scaling was lightly refactored.
Avoids recalc of key scale factor and renames keyScale to rateScaling
(RS) for clarity.

Related issues: #1159, #1112
2025-01-18 12:39:40 +00:00
png183 a91b24acf1 arm7tdmi: write to rh after rl in multiply long instructions (#1773)
Tested on hardware, and verified that when rh and rl refer to the same
register, the write to rh overwrites the value written to rl.
2025-01-18 07:58:29 +00:00
png183 c5d316274a arm7tdmi: allow BX in Thumb mode with bit 7 set (#1772) 2025-01-17 13:41:34 +00:00
jcm 8444f52843 CI: Run new CI on pull requests (#1770)
Run the new CI on pull requests (and not just the old one) so we can
catch bugs and failures, take advantage of new inline annotations, etc.

Working on a slight refactor of CI in general to make it
better-organized, but seems worth PRing this first before that is
complete.
2025-01-16 09:12:25 +00:00
invertego d775c0968b m68000: fix linking error (#1771)
processor/m68000/m68000.cpp is already compiled into the ares static
library. It shouldn't be built directly by the m68000 test harness.
2025-01-16 09:11:31 +00:00
jcm c76b87cdb2 mia, desktop-ui: Emit error if database files not found (#1769)
For each emulator core with a `.bml` file in the Database folder
packaged with ares, this PR adds a separate check in their mia `load`
functions to verify that their database file exists on disk. If it does
not, we bail out of the loading process.

Meanwhile, in desktop-ui, if loading failed, we will now throw up an
error.

This PR stops short of adding fully robust error handling to the load
routines; the error message we throw up is generalized, and will appear
for anything that causes loading to fail, not just specifically database
files not being found. I think that the database files should be by far
the most common cause of load failure, so this seems OK to me for now,
but could certainly be improved in the future to provide more specific
errors. I obviously welcome feedback on how to handle any aspect of this
better.
2025-01-16 09:11:15 +00:00
invertego 2197df8cca m68000: add instruction test harness (#1767)
Add test harness for single step instruction tests located here:
https://github.com/SingleStepTests/m68000.git

See included scripts for cloning and running the tests.
2025-01-15 11:08:01 +00:00
invertego 324a192109 m68000: fix pc in privilege violation exception stack frame (#1768) 2025-01-15 11:05:57 +00:00
jcmandinvertego 4a9b77a5e1 build: macOS toolchain fixups (#1765)
Changes the regex used to determine our macOS SDK version to match on
Command Line Tools install paths and not just Xcode install paths, since
we do not require Xcode to build ares, just the Xcode Command Line
Tools.

Also fixes up how we handle the macOS deployment target.

(boring details below)

CMake is meant to transparently derive and pass appropriate compiler
options for our minimum deployment target. It does this via the
`CMAKE_OSX_DEPLOYMENT_TARGET` variable. This variable can be initialized
either by the project (which must happen before the `project()` call),
or else as part of the `project()` call, CMake will inherit it from the
`MACOSX_DEPLOYMENT_TARGET` environment variable, or else "compute it
based on the host platform" (whatever that means).

Our desired behavior is to set it to 10.13, except for local builds,
where we should respect the MACOSX_DEPLOYMENT_TARGET environment
variable (if it is set). This PR enables that behavior.

---------

Co-authored-by: invertego <[email protected]>
2025-01-14 13:43:19 +00:00
png183 a27c2a2b3a gba: stall CPU when accessing memory in use by PPU (#1763)
Since the timing of these stalls is dependent on PPU memory access
timings, this change should only impact the pixel accuracy setting.
2025-01-12 09:09:45 +00:00
jcm 34124fd1cc build: Switch invalid-offset diagnostic pragma to gcc (#1761)
Removes spurious warnings for invalid `offsetof` usage under GCC
(warnings have been previously determined to be benign for our usage).
2025-01-12 09:08:48 +00:00
jcm f6b58b076b ruby: Driver defaults fixups (#1762)
By default the SDL audio driver would initialize with a latency value of
0; this doesn't crash, but it ends up causing an unpleasant stuttering
and hitching, which is a bad default.

Also makes Metal the default driver on macOS.
2025-01-12 09:02:48 +00:00
jcm b4b026db28 build: Add local build option on Linux; compiler fixups (#1756)
> [!IMPORTANT]
> This alters default behavior for configuration on Linux that
maintainers should be aware of.

Introduces `ARES_BUILD_LOCAL` on Linux, enabled by default, that will
pass `-march=native` if enabled. Maintainers will probably want to
disable this. Also adds `ARES_ENABLE_MINIMUM_CPU`, `ON` by default, that
compiles with the previously enforced `x86-64-v2` minimum on x86_64.
Maintainers should do whatever they want with this option.

(@bsdcode @Mastergatto)

These changes are intended to give Linux users building from source a
better experience. Enabling x86-64-v2 compared to compiling without any
SSE functionality is a 10%+ performance loss locally in the N64 core,
and may be higher on actual x86_64 machines.

> [!NOTE]
> It is worth noting that even though we do not explicitly define a
minimum SSE functionality on arm64, in practice nall will still [define
`__SSE4_1__`](https://github.com/ares-emulator/ares/blob/e808d2c5ab5be91d3e1035063892e8c5115d25e2/nall/intrinsics.hpp#L232)
and take advantage of SIMD on that platform via sse2neon.

### Other changes

* Adds `-march=native` on macOS builds under the control of
`ARES_BUILD_LOCAL`, and fixes `ARES_BUILD_LOCAL` on Windows so that
`-march=native` is added under gcc and not just clang.

* Removes warning in the N64 core related to the issue caused by strict
aliasing under GCC.

* Fixed an issue where macOS would always generate for arm64 rather than
the host architecture.

* Ran a formatter pass that was previously missed on the CMake code, so
there are a couple miscellaneous formatting changes.
2025-01-11 18:11:56 +00:00
invertego 05898a6a04 sh2: fix recompiler regressions (#1760)
This change corrects two regressions introduced by my last change.

1. The purge() call in SH2::Cache::power() was, through a call to
Recompiler::invalidate(), accessing the pool array before it was
allocated.

    This purge call was erronous for two reasons:
    -   It was purging a single line, though it *appears* the intent was
        to purge the entire cache.
    -   According to the SH7604 manual, the cache is not initialized on
        reset.

    Therefore, I simply removed the call.

2. The size of the recompiler code cache for both of the two SH2s is now
halved to fit within the recently halved fixed code cache buffer. The
SH2 recompiler is good at reusing previously compiled blocks, so flushes
should not be especially common even with this reduced capacity.
2025-01-11 10:45:11 +00:00
Luke Usher 331c4956b0 desktop-ui: add support for cores that use DIP Switches 2025-01-09 11:57:57 +00:00
Luke Usher d6c42e59e4 desktop-ui: allow emulator interfaces a chance to modify port menus rather than hard-coding 2025-01-09 11:57:43 +00:00
Luke Usher 58661451ed mame2bml: exclude bios roms 2025-01-09 11:57:23 +00:00
invertego e808d2c5ab recompiler: code cache compaction (#1755)
- Reduce the code cache allocation from 128 MiB to 64 MiB. The CPU/RSP
split is now 63/1 instead of 64/64 (which was egregiously generous to
the RSP) so this should have little practical impact on cache flushes.
- Convert some larger static allocations to heap allocations to shrink
the ares executable's data section.

These changes increase the likelihood of the entire code cache being
within 128 MiB of the ares executable's text section, allowing for more
efficient branch encodings on ARM64 and better performance from the host
CPU's branch predictor.
2025-01-08 09:41:16 +00:00
jcm 445acba894 build: Allow non-strict aliasing and overflow optimizations (#1752)
Non-strict aliasing is found to resolve
https://github.com/ares-emulator/ares/issues/1737.

We also use signed integer overflow around ares, so we want to allow the
compiler to optimize for that if it wants to; essentially everywhere
ares runs is two's complement.

Couple quirks: Xcode has its own declaration for strict aliasing, so use
that. Clang-CL doesn't transparently accept `-fwrapv`, so it's passed
with `/clang:-fwrapv`.

`_ares_gcc_common_options` will eventually see more development to make
warnings consistent across platforms where possible.

(Fixes https://github.com/ares-emulator/ares/issues/1737)
2025-01-06 10:18:51 +00:00
remutro 07fa6bc265 Fix misc build warnings and vertical scroll on controller combo box (Windows) (#1753)
Cmake based builds don't disable as many checks as the old make files,
so there were a few new warnings clang was showing during the Windows
build about unreachable code in mia.cpp & desktop-ui.cpp that are now
fixed (it would fall through properly on other OSes). Note that there
are still two remaining warnings about unreachable code during the build
but this is within zstd included in libchdr so this needs to be
addressed upstream.

A user trying to compile ares made a single post in the ares Discord
channel about a warning they were receiving during the link phase about
an overflow. I've never seen the warning or remember anyone bringing it
up so I asked about OS/compiler (I know it was Linux flavored cause they
mentioned working on an AppImage) but they never responded. I think they
were using openSUSE, but it is interesting this wasn't flagged anywhere
else. We were assigning an enum value to a Color struct in
table-view-cell.cpp which wasn't correct, so this has been fixed.

Finally, SuperMikeMan100 pointed out that when the controller combobox
in Settings > Input didn't fit entirely on the screen, you couldn't
scroll to the bottom of the list (Windows issue). They also pointed out
the fix needed in combo-button.cpp which I've tested and have included
the fix for it here.
2025-01-06 07:37:23 +00:00
jcm 3e5ed40801 CI: fixups (#1754)
First commit stops notarizing the legacy build; for some reason
notarization currently
[fails](https://github.com/ares-emulator/ares/actions/runs/12626365618/job/35179407527)
only with the legacy build, despite us not having modified the legacy
workflow. In any case it seems fine to no longer notarize this artifact.

Second commit allows the new build CI to continue if the repository it
is being run on does not have macOS codesigning set up. This means CI
won't automatically fail on your fork if you do not have macOS
codesigning set up on your repository.
2025-01-06 07:34:12 +00:00
invertego 10b747c305 nall: add instruction_set to query cpu features (#1751)
Currently only implemented for x86.
2025-01-06 04:11:42 +00:00
jcm 2ed2ed34bc build: Add option to build cores as single compilation units (#1746)
Many parts of ares are compiled as a single translation unit in a "unity
build". Targets such as `hiro` and `ruby` directly compile only one
file, `hiro.cpp` or `ruby.cpp` (or `hiro.mm` and `ruby.mm` on macOS),
which `#include`s all other files beneath it in a branching fashion. By
contrast, in the `ares` target, each area of each core is generally
compiled as a separate translation unit, with lots of redundant
inclusion of common headers. This allows for faster "development cycle"
build times; if a small change to one part of the core is made, we do
not need to recompile the entire core.

Despite slower incremental build times, compiling each ares core instead
as a single translation unit has some benefits.

We can lower build times by a decent amount:

| Build | Build time (multiple units) | Build time (single unit) |
|-----------|-------------|-----|
| `ares-windows-x64` | 9m16s | 6m47s |
| `ares-windows-clang-cl-x64` | 11m3s | 8m23s |
| `ares-windows-clang-cl-arm64` | 12m29s | 9m20s |
| `ares-macos-universal` | 13m33s | 8m12s |

Not only that, but single-unit builds also seem to confer a minor
performance benefit, presumably due to more effective link-time
optimization.

On macOS arm64:

| Game (core) | VPS (multiple units) | VPS (single unit) |
|-----------|-------------|-----|
| Knuckles Chaotix (Mega Drive) | 101-102 | 108-109 |
| Snowboard Kids (N64) | 66-67 | 69-70 |

Last but not least, we can actually arrange for single-unit builds
without any code-level changes to existing ares source files. We can
simply add a `<core>.cpp` file for each core that includes each
'primary' `.cpp` file that would otherwise be directly compiled; due to
the magic of the `#pragma once` compiler directive, redundant header
inclusions are eliminated in the unity build, but compiling still works
normally if we are compile as multiple units.

Given that there were no significant issues adapting existing code to
compile this way, it seems worth considering adding this functionality.
It can disabled for default configurations transparently (to enable
faster incremental builds during development), but enabled on CI for
faster builds and a modest performance benefit.
2025-01-05 09:22:06 +00:00
jcm 41b61ee6d5 hiro: Fix various warnings and deprecations in Cocoa (#1748)
* Fix a bunch of miscellaneous name deprecations
* Fix deprecated modal file handling patterns; use the `URL` properties
rather than the ones for paths
* Remove the Gatekeeper bypass menu item
* While the idea here was quaint, it's very dated, the approach doesn't
work at all on modern macOS (and would be a significant exploit surface
if it did), and the functionality is somewhat outside the scope of the
ares application in the first place. It won't remove Gatekeeper
restrictions on ares itself, since if we're using the menu item, we've
already made it past Gatekeeper. Functionality to disable Gatekeeper in
general for other applications is, again, maybe nice in an abstract way,
but well outside our scope.
* Suppress OpenGL symbol resolver deprecation warnings
* Fix protocol warnings in `CocoaMenu` that revealed a mistaken design
pattern:
* We had both a protocol and an interface called `CocoaMenu`, and our
Cocoa hiro menu subclasses were declaring that they adopted the
`CocoaMenu` protocol, rather than what was almost certainly intended, to
be subclasses of `CocoaMenu` which would itself conform to the protocol
by virtue of being an `NSMenuItem`.
* In effect, this meant that each CocoaMenu subclass interface was
telling the compiler it wanted to reimplement the `NSObject` protocol
rather than be an `NSObject` subclass. This may have resulted in various
typical properties of `NSObject`s not being present, and various methods
(such as Accessibility) entirely not working.
2025-01-05 09:21:39 +00:00
jcmandJohn Tur a960aeef52 build: gcc improvements (#1750)
Linking was failing under MinGW gcc because of a link order issue
between `libares` and `mingw32`. Establishing a direct link relationship
between `desktop-ui` and `mingw32` means that our `WinMain` definition
will not be discarded by `ld` before it's needed.

We also here add a Linux gcc runner and a Windows gcc runner; these do
not upload artifacts, but will allow us to detect build failures on CI.

At the moment, gcc support in general under CMake will still rougher
edges than clang or MSVC support, but it is intended that building with
`gcc` and `ld` should always at least work, even if `clang` remains
recommended and achieves superior performance.

This PR also adds a warning in the N64 core to acknowledge
https://github.com/ares-emulator/ares/issues/1737 until that issue can
be fixed.

Co-authored-by: John Tur <[email protected]>
2025-01-05 07:24:54 +00:00
Giovanni Bajo 1eb0a1659a Update sse2neon.h (af7596e) (#1749)
Necessary to build the iQue branch on arm64
2025-01-05 00:01:49 +00:00
Adrian Siekierka c19a2ac1b2 ngp: more accurate refresh rate hint (#1742)
In practice that's ~59.95 Hz.
2025-01-02 00:46:37 +00:00
jcm 8642d35e5f CI: Fetch tags on checkout (again) (#1741)
`fetch-tags: true` only works within the specified fetch depth.

`fetch-depth: 0` fetches more than necessary, but seems to be the
simplest way to guarantee we actually fetch the latest release tag
needed by CI.

See also: https://github.com/actions/checkout/issues/338
2025-01-02 00:46:09 +00:00
jcm 80db392140 build: Disable OpenAL on Windows (#1744)
For various reasons, OpenAL on Windows is not supported. If we do manage
to find it and link against it, the build we produce is unlikely to work
outside of an MSYS2 command line environment, so we should just disable
it.

If we ever want OpenAL support on Windows, we would need to either
locate a version that depends only on Windows system libraries (i.e.
does not dynamically load libc++ or other MSYS2 libraries), or else
build and provide OpenAL ourselves as part of `ares-deps`.
2025-01-02 00:45:43 +00:00
jcm a2400ad43a CI: Fetch tags on checkout (#1740)
Should unbreak the new build.
2025-01-01 13:41:35 +00:00
TascoDLX e8cd9b3e04 md: vdp improvements, dots and stuff (#1739)
- Completes #1498 -- dots should be clearly visible in overscan areas
normally. If you notice odd dots appearing on top of games irregularly
(inbounds, non-overscan), please mention it. The Direct Color DMA demos
(https://gendev.spritesmind.net/forum/viewtopic.php?f=8&t=1203) should
be stable for the most part (note, they are very timing sensitive).
- VDPFIFOTesting rom should run without any failures. Previously,
16-FIFO Wait States was the only failed test.
- Both Titan Overdrive demos should run cleanly. There were a few minor
wrinkles that needed to be ironed out.
- Fixes #1075 -- there was a minor adjustment for a window edge case in
H32 mode. Unlikely to affect other games.
- Fixes #1061 -- looks pretty clean now.
- Fixes #626 -- I don't notice anything weird currently, just some minor
fringe in the left border, not visible when overscan is disabled.
- Review #1675 wrt md -- there are no parts of the active display area
that are currently cropped out. There was an unreported issue with Exo
Squad (E) that had clipped the topmost lines in PAL V30 mode (observed
on the copyright screen) but that has been fixed.
- Fixes an unreported bug in 32X PWM sound (right channel was missing),
typo from previous commit d7dfae7a7a.
2025-01-01 11:58:13 +00:00
jcm e04922c4d5 build: Finalize CMake merge (#1736)
* Remove version overrides from CMakePresets.json
* These were necessary for CI to run when CMake existed on the forked
branch, but *should* no longer be necessary
* Disable release flows for the legacy build
* Keep legacy builds running for the time being, but disable the release
flow so it does not conflict with the new CI
2025-01-01 10:22:22 +00:00
Mastergatto 69795d578a desktop-ui/presentation: Add an alternative path for loading shaders on Linux and BSD (#1738)
On some Linux and BSD distribution, Ares from the repositories may not
come with shaders preinstalled. Instead, these one may come from another
package, for example on Archlinux the package `libretro-shaders-slang`
installs the shaders in the following path:
`/usr/share/libretro/shaders/shaders_slang/` .

This will make Ares fail to load any shaders on these distro. So to fix
it, this PR adds the aforementioned location as another path to search
for, as a fallback.

I know, the two dots are a bit ugly, given that locate() normally
doesn't search for files or directories outside of those of
Ares...Ideally, locate() should be expanded to search the entire file
system, but I'm afraid the required changes may be a bit more far
reaching than expected.
2025-01-01 10:22:10 +00:00
8433666dc2 build: Build system overhaul (#1686)
This PR introduces a new CMake-based build system for ares.

Broadly, the goals of this build system are to:

* Modernize the build process somewhat, and make ares more approachable
for new developers
* Improve ares's dependency handling
* Expand and standardize platform/compiler/architecture support for ares
* Improve project code quality
* Improve build performance
* Lay groundwork for easier support of more platforms in the future

There are a few notable changes that this PR brings about. Briefly:

* Dynamic dependencies (librashader, MoltenVK, SDL, slang-shaders) are
no longer built in-tree
* Build system generation and building now take place as two separate
steps

Other notes:

* The legacy build system is deprecated, but is planned to still
function until such time as it is removed in a later PR

# New Features

* ares can now generate projects for Xcode and Visual Studio 17 2022.
Xcode is the recommended generator on macOS, supporting universal
binaries, advanced profiling and GPU debugging. Visual Studio projects
can be configured with either Clang-CL or MSVC, and may be generated for
either x86_64 or arm64.

* On macOS and Windows, dynamic dependencies are now built by
[ares-deps](https://github.com/jcm93/ares-deps) and fetched at
configure-time. This is to reduce build requirements for development,
define explicit versioning for dependencies, reduce build times
generally, and streamline CI workflows.

* Builds can now be configured through the default Windows command line
rather than requiring an MSYS2/MinGW shell.

* Ccache is also now universally supported to improve build performance.
Compile times should be further reduced with the addition of
precompilation of certain headers.

* A variety of other build system generators are now supported on all
platforms, including multi-configuration Ninja and applicable types of
Makefiles.

* Compiler diagnostic flags with clang have been standardized across all
platforms where possible[^1]. Currently, diagnostic flags have rough
parity with the old build system, but one goal of the new build system
is to introduce more strict compiler settings, to eliminate certain
classes of bugs and generally increase code quality.

# Supported Platforms

ARM64 and x86_64 architectures are officially supported across macOS,
Windows, Linux, and BSD[^1]. clang, Clang-CL, gcc, and MSVC are all
supported on applicable platforms. MSYS2/MinGW is supported along with
configuration and builds via the default Windows shell.

32-bit builds have not been tested.

# Current Status

Builds across all three of macOS, Windows, Linux, and BSD are generally
expected to work. Detailed build instructions can be found on the new
[ares wiki](https://github.com/ares-emulator/ares/wiki). CI workflows
are present and implemented but are still a work in progress. More
complete documentation is also a work in progress.

#### macOS

* Xcode, Ninja, Ninja Multi-Config, and Makefile generators are
functional
* Unlike Windows, multi-architecture builds are supported; pass
`-DCMAKE_OSX_ARCHITECTURES` as appropriate.
* Builds should generate a fully functional and relocatable app bundle
within the build directory, with relative rpaths; `install` rules are
placeholders.

#### Windows

* Visual Studio 17 2022, Ninja, Ninja Multi-Config, and Makefile
generators are functional
* Only single-architecture builds are currently supported
* Similarly to macOS, the build step generates a fully functional and
relocatable rundir with placeholder `install` commands.

#### Linux / BSD

* Unlike on macOS and Windows, it is required that the developer have
packages installed for libraries ares links against. A list of required
and optional libraries is found in the README.
* Build will output to a staging directory `rundir`; ares only uses
system libraries so this rundir should be fully relocatable
* `install` will perform a standard installation as CMake deems
appropriate for your distribution; you may pass the `--prefix` argument
as needed
* Maintainers may package as appropriate; a new Flatpak may be created
as part of this process, but has not yet

> [!IMPORTANT]
> These tasks should be completed before this PR moves out of the draft
state:
> 
> * ~~CI workflows~~ - incomplete
> * ~~BSD support~~
> * ~~Windows SDL added to ares-deps~~
> * ~~ares-deps should probably be migrated to the ares-emulator
organization~~
> * More documentation
> * Miscellaneous cleanup, fixing issues found in testing, incorporating
general feedback

Nevertheless, now that builds are functioning on all three platforms, I
wanted to get this PR out there in a draft state to solicit testing and
feedback, as well as to give Linux package maintainers a head start in
terms of packaging.

> [!NOTE]
> While the PR is in a draft state, there may be breaking changes,
things may temporarily stop functioning, commits may be squashed, etc.
Thank you for testing and please report any issues you encounter!

* More detailed documentation on the internals of the build system is
available
[here](https://github.com/jcm93/ares/blob/cmake/cmake/README.md).

### Miscellaneous changes/points

* .gitignore is reorganized
* [gersemi](https://github.com/BlankSpruce/gersemi) is used for CMake
formatting, hence the presence of a `.gersemirc` file
* SDL on Windows is now a dynamic dependency.
* macOS asset files are reworked into .xcassets archives
* new macOS local build script introduced
* CI will include debug symbols for easier crash debugging

[^1]: Indicates something that might not be finished yet, or is subject
to change

---------

Co-authored-by: invertego <[email protected]>
Co-authored-by: Stefan Schlosser <[email protected]>
Co-authored-by: John Tur <[email protected]>
2024-12-31 09:07:24 +00:00
png183 ecdce5e92b arm7tdmi, gba: lock bus during SWP instruction (#1729)
Hardware locks the bus during SWP instructions to ensure atomicity.

Also fixed an oversight from #1714 that broke serialization.
2024-12-29 21:46:36 +00:00
invertego 0b4fea8ce5 32x: fix instruction tracing with recompiler (#1734)
Fixes #1733
2024-12-29 21:46:00 +00:00
Luke Usher 5bcef4741a ps1: invalidate single blocks rather than entire pools (recompiler) 2024-12-18 17:56:14 +00:00
mote 3b18a3f808 fc: Save FDS disk when saving Famicom system (#1725)
This commit ensures that changes to the FDS disk get saved when the
Famicom system saves (similar to how the 64DD works already). Without
this, changes to the FDS disk were only written back to the pak in
FDS::disconnect, _after_ the save on unloading/exit or any periodic
autosaves.
2024-12-18 17:52:50 +00:00
Serina Huandjcm 7d327a2c8a Implement the hex editor widget for Cocoa and enable memory editor on macOS (#1723)
This PR adds the hex editor widget to Cocoa hiro and enables the memory
editor in Tools. The widget is a cell-based NSTableView with data source
the core hex editor widget and supports editing of memory (but not of
the encoded ANSI).

---------

Co-authored-by: jcm <[email protected]>
2024-12-17 05:18:14 +00:00
Giovanni Bajo 07bafb6a51 n64: improve VI timings and interrupts (#1716)
This commit implements correct VI timings using VI registers rather than
hardcoding the behavior for the default presets made by commercial
games. This makes Ares behaves correctly, timing-wise, also with non
standard timing like eg: the so-called PAL60 mode.

Moreover, it fixes VI interrupts in interlaced mode to happen on the
exact scanline they happen on the hardware, including known hardware
bugs.
2024-12-17 05:18:01 +00:00
png183 1bb1669b03 gba: cycle-based bitmap and affine backgrounds (#1714)
The pixel accuracy setting will now emulate the sub-pixel timing
behaviours for bitmap and affine backgrounds described in [fleroviux's
PPU
docs](https://github.com/nba-emu/hw-docs/blob/main/src/ppu/background.md).

This PR also splits the PPU into two separate libco threads: one for
rendering and one for raising IRQs and starting DMAs. This allows the
CPU and PPU to be run more asynchronously, which helps mitigate the
performance cost of finer-grained PPU emulation.
2024-12-17 05:17:47 +00:00
invertego a752b85d6f n64: step rsp dma during rsp execution (#1722)
Instead of advancing RSP DMA only after each CPU basic block, allow it
to run between each RSP block. This prevents the RSP from racing with
the DMAs it initiates in the event of a long running CPU block (which
can trigger multiple consecutive blocks of RSP execution).

This fixes hangs in Tarzan and possibly other games that use MusyX.

Another observable side effect of this change is that when the RSP is
halted, it no longer risks falling increasingly behind the CPU, because
ares will now step multiple times if needed instead of just once.
2024-12-15 10:46:15 +00:00
jcm a02c0f80de build: Remove brew make requirement for reals (#1720) 2024-12-14 09:17:50 +00:00
remutroandremutro 50ceb088ef Don't default to 'Text' column visibility being false in firmware window (#1721)
The "Type" column in the Settings > Firmware table view was being set to
false by default. As there is no visibility handling for columns in hiro
for Windows or Cocoa, this column would always be visible. But in the
hiro GTK table view definition (there is also a visibility
implementation for Qt) it did contain a function to disable/enable a
specific column so this column would be absent on Linux distros making
it look like there were duplicate entries in the table. This PR removes
removes the call setting visibility by default so that the column is
always visible.

Co-authored-by: remutro <remulationtro.gmail.com>
2024-12-14 09:17:33 +00:00
jcm 65618ce1e2 build: Remove macos-compat, establish appropriate minimum macOS (#1719)
* Remove `macos-compat`, since the macOS 12 runner is no longer in
GitHub Actions, so we can no longer target macOS 10.9
* Rename the macOS build to "macos-universal", reflecting the OS and
arch
* Don't install `make` via brew any more, since it isn't necessary
* Establish the macOS version minimum as 10.13
* 10.9 was not a proper target, because of `fstatat` usage, which isn't
available on macOS 10.9. On a code level, we may technically be
compatible with macOS 10.10, but because no available build environment
can target this macOS version, it makes no sense to support it without
being able to test it. Since we can deploy for macOS 10.13, just
establish this version as the minimum. If someone wants to compile
themselves for lower macOS versions, they should still be able to.
* Increment the macOS runner for the primary macOS build to macOS 15,
and the Xcode version to Xcode 16.1.
* Better to explicitly pick the macOS and Xcode version rather than
using `macos-latest` as the runner, even though they refer to the same
thing, just so that we have explicit versioning wherever possible.

Not tested; CI run needed.
2024-12-13 21:15:08 +00:00
remutro 4691971416 disable Apply button if driver changed then options updated before applying driver switch (#1712)
If you choose to select a new driver without pressing the Apply button,
and then go ahead and update related options for the currently loaded
driver then the combo box will revert to the currently loaded driver but
leave the Apply button enabled indicating the user has to do something
when they do not. This changes this behavior so that if options are
changed and the driver is reverted back to the current driver the Apply
button will be disabled again.
2024-12-07 13:55:21 +00:00
remutro 98d9eb7786 Bring back bsnes Pseudo Fullscreen Option (#1710)
Brings back the Pseudo Full Screen option present in bsnes as a
configurable hotkey.

I'm also including the type mistake pointed out for the colorWidthBleed
value someone pointed out so we don't lose track of it.
2024-12-06 11:04:07 +00:00
TascoDLX 431aba5a1a md: dma timing fixes (#1709)
Fixes test cases in the dma_speed_test rom.
1. "*VRAM TO ROM" is a dma load to a VRAM read target, which doesn't
have any effect. Though, for timing purposes, it's similar to a VRAM
write (1 byte access per slot) so fifo throughput is the limiting
factor.
2. A VDP refresh blocks bus access for 2 consecutive slots, slightly
affecting dma load transfer rates.
2024-12-06 00:24:07 +00:00
Luke Usher 78e5332361 sfc: use snprintf rather than sprintf in disassembler (-Wdeprecated-declarations) 2024-12-03 15:48:25 +00:00
jcm 687bfe8efc ares: move generated sources out of ares.hpp (#1704)
Random fix from CMake work.

Precompiled headers under CMake are currently buggy and unreliable on
Windows, largely because the precompiled `<ares/ares.hpp>` header
includes `<ares/resource/resource.hpp>`, which is generated by
`sourcery` as part of the build process.

While sourcery will almost never meaningfully change the contents of
this `resource.hpp` file, Windows may insert its own line endings
depending on the user's environment, and despite enforcing uniform line
endings as part of our `.gitattributes` file, some compilers will throw
a fit about the precompiled header being modified from underneath it.

Since the `resource.hpp` file is simple, short, and not included in that
many places, we can just refactor it out of `<ares/ares.hpp>` without
issue, and precompiled headers will work again regardless of system line
ending convention or environment.

Tested to build locally on macOS; CI run definitely recommended.
2024-12-02 12:48:55 +00:00
png183 7cc6d517a2 arm7tdmi, gba: more IRQ timing improvements (#1707)
- Check CPSR interrupt disable bit during decode stage
- Only update IRQ line at the start of memory accesses or idle cycles
2024-12-02 11:43:02 +00:00
png183 3bd385e4a8 gba: open bus improvements (#1706)
Fixes a few issues relating to open bus emulation:

- Accounts for cases where the last memory access was not an instruction
fetch
- For most memory regions, 8-bit and 16-bit accesses should be mirrored
along bus (except in IWRAM, where only part of the open bus value gets
overwritten, and the rest is carried over from the last IWRAM access)
- Open bus read alignment was not being respected in all regions
2024-11-28 03:23:51 +00:00
png183 de2d7d86c9 arm7tdmi, gba: IRQ timing improvements (#1702)
- Adds 1-cycle latch for IME register, similarly to IE and IF
- IRQ line is now checked between pipeline flush and instruction fetch
2024-11-21 11:02:48 +00:00
jcm a0d8ce25c5 nall: Use relative path for prefix (#1697)
Following up on #1688 and #1575; removes the ARES_PREFIX preprocessor
variable and its use in `prefixSharedData()` in favor of a relative
path.

Passing a preprocessor argument to the program to define an install
prefix, which is then used to locate application data, is awkward and
overall not an ideal approach. Wherever possible, ares should have the
same behavior on the same classes of OS. Further, if we are to cleanly
separate ares's build and install steps, we shouldn't be defining
anything related to install locations at build-time. After building
ares, it should be able to be installed wherever the user wishes without
any unexpected changes in behavior.

Following the standard paradigm here means that on *nix systems, the
prefix's data directory would be, relative to the executable, in
`../share/ares/`. Hence, define `prefixSharedData()` from #1688 to
return this relative path appended to the executable path (given by
nall's `Path::program()`), instead of doing the preprocessor prefix
hooplah.

Tested on aarch64 Fedora; made sure ares can still locate the database
and shaders.
2024-11-18 10:40:08 +00:00
Giovanni Bajo 557ecb5319 n64: correctly implement invalid SPECIAL opcodes in RSP (#1700)
All invalid opcodes in the SPECIAL range behave like "srlv rd, rs, rs".
Testrom: https://github.com/sauraen/rsp_inval_instrs

Thanks to Sauraen for the RE work
2024-11-18 10:39:07 +00:00
Tharo 8cc98f94ae n64: Fix 32-bit signed integer multiplication and division when the input operands are not sign-extended 32-bit values. (#1701)
Verified by the test ROM at
https://github.com/Thar0/N64-IntegerMulDiv-Test, see the readme there
for full details.

Note that the behavior of the div instruction is still not
well-understood when bits 31 and 63 of the divisor in rt are not equal.
These will still give incorrect results for now. The test ROM classifies
tests with such inputs in "failed emulations" since their behavior is
not understood well enough, while "failures" consists of tests with
inputs whose behavior is known and still failed.

Ares result before this patch:

![image](https://github.com/user-attachments/assets/f6e68e2c-b4be-4b38-8a5a-e7c2950817b1)

Hardware result (apologies for the poor video quality 😬)

![image](https://github.com/user-attachments/assets/51b5c5be-75cb-48a3-9828-9ed638722966)

Ares result after this patch:

![image](https://github.com/user-attachments/assets/6f19524b-eaa4-47c5-9e6a-1dd77ca400e4)
2024-11-18 10:38:47 +00:00
png183 7e5d749adc gba: implement pixel blend timings (#1695)
Separates `dac.run()` into two steps, with the lower layer being
processed two cycles after the upper layer. PRAM fetch timings should
now match [fleroviux's PPU
docs](https://github.com/nba-emu/hw-docs/blob/main/src/ppu/composite.md).
2024-11-15 11:08:47 +00:00
jcm 675d57b6fa nall: Fix data paths changes (#1694)
#1688 broke the build, and also did not actually perform one of the main
intended changes; reverting `sharedData()` to return "/usr/share/".

Second time's the charm!
2024-11-12 15:12:24 +00:00
jcm 28cfa89970 nall, desktop-ui: Account for other *nix data locations (#1688)
### Context

https://github.com/ares-emulator/ares/pull/1575 ended up defining the
`sharedData` directory on Unix-like systems as `~/.local/share` if a
build prefix was not defined. This is not exactly correct; the meaning
of a "shared data" directory on a Unix-like system is variously
`/usr/share`, `/usr/local/share`, or else the `share` directory of a
given install prefix.

### Changes

This PR allows us to respect normal Unix conventions while also
respecting the option to build and install with a given prefix. This is
done by defining two more functions in nall's `path`:
* `localSharedData()` for `/usr/local/share`
* `prefixSharedData()` for `${ARES_PREFIX}/share`

`sharedData()` is changed back to the old behavior and returns
`/usr/share`.

Then, the `locate` logic in desktop-ui (and uh, mia) is adjusted to now
search (in order):

1. the prefix's shared data if the prefix exists
2. local shared data
3. system shared data
2024-11-12 13:02:37 +00:00
Giovanni Bajo 8668f98fa5 Update parallel-rdp (#1691) 2024-11-09 13:51:34 +00:00
png183 8f772cdb01 gba: halt prefetcher when full (#1689)
Passes Alyosha's [test
ROM](https://github.com/alyosha-tas/gba-tests/blob/master/prefetcher/prefetcher_full_thumb.asm)
for timings in Thumb mode when the prefetcher is full.
2024-11-08 07:28:47 +00:00
Luke Usher 229e16df98 md: add support for QuackShot Starring Donald Duck (World) (Rev A)
This game has non-standard wiring; see comments.
2024-11-05 16:15:42 +00:00
Luke Usher 36290b9705 Merge commit '014d0130f534191ef36e727147264b84daaedb27' 2024-11-04 13:00:00 +00:00
Luke Usher 014d0130f5 Squashed 'thirdparty/slang-shaders/' changes from 263a54c414..7e2975e906
7e2975e906 Update crt-nobody shader (#645)
66de8e522b Sync to koko-aio 1.9.50 (#644)
4f3d214b31 Document #pragma include_optional (#643)

git-subtree-dir: thirdparty/slang-shaders
git-subtree-split: 7e2975e90632c93bc879707362469e6c9a3027b0
2024-11-04 12:59:37 +00:00
Luke Usher d6465d0daa Merge commit '802a902cd39324f874c9a7fa8ee1b2f0011ea432' 2024-11-04 12:59:23 +00:00
Luke Usher 802a902cd3 Squashed 'thirdparty/librashader/' changes from cbdbdafecd..82bfc2d576
82bfc2d576 deps: update deps
7d7536f9fd rt(wgpu): approximate clamp-to-border with clamp-to-edge if not supported
9039a7c040 reflect: use FastHashMap for linkinputs pass
d8e35d4374 preprocess: add a test for include_optional
76347f63ac preprocess: add support for pragma include_optional

git-subtree-dir: thirdparty/librashader
git-subtree-split: 82bfc2d576d4c1a90339dcfba6c0163d5345b9c3
2024-11-04 12:59:22 +00:00
Luke Usher 1469299363 Squashed 'thirdparty/sljit/' changes from f6326087b3..666125ad64
666125ad64 Fix maximum offset prediction for jump operations

git-subtree-dir: thirdparty/sljit
git-subtree-split: 666125ad64fc694aafe6b816822ab446db14f5fe
2024-11-04 12:59:18 +00:00
Luke Usher 2bf4e28db5 Merge commit '14692993633944dc0edda0595cc4acbd56bd3581' 2024-11-04 12:59:18 +00:00
7025 changed files with 350146 additions and 871523 deletions

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json
definitions: [ares/CMakeLists.txt]
line_length: 120
indent: 2
list_expansion: favour-inlining
unsafe: false
warn_about_unknown_commands: false
+2
View File
@@ -0,0 +1,2 @@
# When archiving, export a version file containing tag/commit information
cmake/common/.archive-version.json export-subst
+32
View File
@@ -0,0 +1,32 @@
# dummy GitHub target used to enable editing of GitHub files within generated IDE projects
add_library(.github INTERFACE)
set(.github_sources
ISSUE_TEMPLATE/bug_report.md
ISSUE_TEMPLATE/feature_request.md
ISSUE_TEMPLATE/game-issue-report.md
scripts/build_macos.sh
scripts/build_sdl.sh
scripts/build_ubuntu.sh
scripts/build_windows.sh
scripts/package_artifacts.sh
workflows/build-aux.yml
workflows/build.yml
workflows/pr.yml
workflows/push.yml
workflows/release.yml
)
target_sources(
.github
PRIVATE
${.github_sources}
../.gitignore
../.gitattributes
../README.md
../LICENSE
)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${.github_sources})
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env sh
set -euo pipefail
# configure
cmake --preset $TARGET_PRESET
# change into the build directory
pushd build
# build; pipe output to render warnings neatly
xcodebuild -configuration RelWithDebInfo \
DEBUG_INFORMATION_FORMAT="dwarf-with-dsym" \
-parallelizeTargets \
2>&1 | xcbeautify --renderer github-actions
popd
# package debug symbols
# move dependency dSYMs to build output directory
ditto .deps/ares-deps-macos-universal/lib/*.dSYM build/desktop-ui/RelWithDebInfo
mkdir build/dsyms
# ares.app.dSYM already exists alongside ares.app; package it with the rest
mv build/desktop-ui/RelWithDebInfo/*.dSYM build/dSYMs/
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
# clone the SDL repository
git clone https://github.com/libsdl-org/SDL.git
# change into the SDL directory
pushd SDL
mkdir build
# build SDL
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
# install SDL libs and include files to /usr/local
sudo cmake --install build --prefix=/usr/local
popd
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail
# configure
cmake --preset $TARGET_PRESET
# change into the build directory
pushd build
ninja
popd
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env sh
set -euo pipefail
if [ "$CROSS_COMPILE" = true ]; then
cmake --preset $NATIVE_PRESET -B build_native
pushd build_native
# build sourcery natively so it may be invoked during cross-compilation
cmake --build . --target sourcery --config RelWithDebInfo
popd
fi
cmake --preset $TARGET_PRESET
pushd build
cmake --build . --config RelWithDebInfo
if [ "$CROSS_COMPILE" = true ] || [ "$ARES_PLATFORM_NAME" = "windows-arm64" ]; then
cp ../.deps/ares-deps-windows-arm64/lib/*.pdb desktop-ui/rundir/
else
cp ../.deps/ares-deps-windows-x64/lib/*.pdb desktop-ui/rundir/
fi
mkdir PDBs
mv desktop-ui/rundir/*.pdb PDBs/
popd
+49
View File
@@ -0,0 +1,49 @@
set -eu
case ${GITHUB_REF} in
refs/tags/*) suffix="-${GITHUB_REF#refs/tags/}" ;;
refs/heads/master) suffix="-nightly" ;;
*) suffix="" ;;
esac
bindir="${GITHUB_WORKSPACE}/bin"
# Hack: Workaround for GitHub artifacts losing attributes.
chmod +x ${bindir}/ares-macos-universal/ares.app/Contents/MacOS/ares
for package in macos-universal
do
mkdir "${package}"
cd "${package}"
# Package ares.
outdir=ares${suffix}
mkdir ${outdir}
mkdir ${outdir}-dSYMs
cp -a ${bindir}/ares-${package}-dSYMs/*.dSYM ${outdir}-dSYMs
cp -a ${bindir}/ares-${package}/*.app ${outdir}
zip -r -y ../ares-${package}.zip ${outdir}
zip -r -y ../ares-${package}-dSYMs.zip ${outdir}-dSYMs
cd -
done
for package in windows-x64 windows-clang-cl-arm64
do
mkdir "${package}"
cd "${package}"
# Package ares.
outdir=ares${suffix}
mkdir ${outdir}
mkdir ${outdir}-PDBs
cp -a ${bindir}/ares-${package}-PDBs/*.pdb ${outdir}-PDBs
zip -r ../ares-${package}-PDBs.zip ${outdir}-PDBs
rm -rf ${bindir}/ares-${package}/PDBs
cp -a ${bindir}/ares-${package}/* ${outdir}
zip -r ../ares-${package}.zip ${outdir}
cd -
done
# Package the source archive
pushd src
git archive --format=tar.gz -o ../ares-source.tar.gz HEAD
popd
+142
View File
@@ -0,0 +1,142 @@
name: Build (Auxiliary)
on:
workflow_call
jobs:
build:
strategy:
fail-fast: false
matrix:
program:
- ares
config:
- RelWithDebInfo
platform:
- name: windows-x64-gcc
os: windows-latest
shell: 'msys2 {0}'
msystem: mingw64
install: make git cmake ccache ninja mingw-w64-x86_64-toolchain
target-cmake-preset: windows-ci-mingw-native
- name: windows-mingw-clang64-x64
os: windows-latest
compiler: clang++
shell: 'msys2 {0}'
msystem: clang64
install: make git cmake ccache ninja mingw-w64-clang-x86_64-clang
target-cmake-preset: windows-ci-mingw-native
- name: windows-arm64
os: windows-11-arm
compiler: clang++
shell: 'msys2 {0}'
msystem: clangarm64
install: mingw-w64-clang-aarch64-make git mingw-w64-clang-aarch64-cmake mingw-w64-clang-aarch64-ccache mingw-w64-clang-aarch64-ninja mingw-w64-clang-aarch64-clang
target-cmake-preset: windows-ci-mingw-native
- name: windows-msvc-x64
os: windows-latest
windres: rc
shell: bash
target-cmake-preset: windows-ci-msvc-native
- name: windows-msvc-arm64
os: windows-latest
windres: rc
shell: bash
target-cmake-preset: windows-ci-msvc-cross
native-cmake-preset: windows-ci-msvc-native
- name: ubuntu-gcc-x64
os: ubuntu-24.04
shell: bash
target-cmake-preset: ubuntu-ci
- name: ubuntu-gcc-arm64
os: ubuntu-24.04-arm
shell: bash
target-cmake-preset: ubuntu-ci
- name: ubuntu-clang-x64
os: ubuntu-24.04
shell: bash
target-cmake-preset: ubuntu-ci-clang
- name: ubuntu-clang-arm64
os: ubuntu-24.04-arm
shell: bash
target-cmake-preset: ubuntu-ci-clang
- name: ubuntu-gcc-arm64-qt
os: ubuntu-24.04-arm
shell: bash
target-cmake-preset: ubuntu-ci-qt
- name: freebsd
os: ubuntu-24.04
shell: cpa.sh {0}
target-cmake-preset: ubuntu-ci-clang
name: ${{ matrix.program }}-${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- name: Install MSYS2 Dependencies
if: matrix.platform.shell == 'msys2 {0}'
uses: msys2/setup-msys2@40677d36a502eb2cf0fb808cc9dec31bf6152638
with:
msystem: ${{ matrix.platform.msystem }}
install: ${{ matrix.platform.install }}
- name: Checkout source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-tags: true
fetch-depth: 0
- name: Setup MSYS2 Git Environment
if: matrix.platform.shell == 'msys2 {0}'
run: |
git config core.autocrlf true
- name: Install Linux Dependencies
if: runner.os == 'Linux' && matrix.platform.name != 'freebsd'
run: |
sudo apt-get update -y -qq
sudo apt-get install cmake ccache ninja-build libsdl2-dev libgtk-3-dev qt6-base-dev
- name: Build SDL3
if: runner.os == 'Linux' && matrix.platform.name != 'freebsd'
run: .github/scripts/build_sdl.sh
- name: "Build: Linux"
if: runner.os == 'Linux' && matrix.platform.name != 'freebsd'
run: .github/scripts/build_ubuntu.sh
env:
TARGET_PRESET: ${{ matrix.platform.target-cmake-preset }}
- name: "Build: Windows"
if: runner.os != 'macOS' && runner.os != 'Linux'
run: .github/scripts/build_windows.sh
env:
ARES_PLATFORM_NAME: ${{ matrix.platform.name }}
CROSS_COMPILE: ${{ matrix.platform.native-cmake-preset != '' }}
NATIVE_PRESET: ${{ matrix.platform.native-cmake-preset }}
TARGET_PRESET: ${{ matrix.platform.target-cmake-preset }}
- name: "Start FreeBSD VM"
if: matrix.platform.name == 'freebsd'
uses: cross-platform-actions/action@e0b9770014ba65d5e0815f15b74031c3a635f641
with:
operating_system: freebsd
version: '15.1'
- name: "Install FreeBSD Dependencies"
if: matrix.platform.name == 'freebsd'
run: |
sudo pkg upgrade -y
sudo pkg install -y cmake-core pkgconf ccache ninja gtk3 sdl3 librashader
- name: "Build: FreeBSD"
if: matrix.platform.name == 'freebsd'
env:
TARGET_PRESET: ${{ matrix.platform.target-cmake-preset }}
shell: cpa.sh {0} --environment-variables TARGET_PRESET
run: .github/scripts/build_ubuntu.sh
- name: "Compress Build Artifacts (Windows)"
if: runner.os != 'macOS' && runner.os != 'Linux'
run: |
tar -cvJf ares-${{ matrix.platform.name }}.tar.xz -C build/desktop-ui/rundir/ .
- name: Upload Build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ matrix.program }}-${{ matrix.platform.name }}
path: ares-${{ matrix.platform.name }}.tar.xz
- name: Upload Debug Symbols (Windows)
if: runner.os != 'macOS' && runner.os != 'Linux'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ matrix.program }}-${{ matrix.platform.name }}-PDBs
path: build/PDBs/*
+84 -286
View File
@@ -1,10 +1,17 @@
name: Build
name: Build (Primary)
on:
push:
branches: [ master ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]
workflow_call:
inputs:
codesign:
description: Enable codesigning
required: false
default: false
type: boolean
official:
description: Use official version strings
required: true
default: true
type: boolean
jobs:
build:
strategy:
@@ -12,57 +19,26 @@ jobs:
matrix:
program:
- ares
config:
- RelWithDebInfo
platform:
- name: windows
- name: windows-x64
os: windows-latest
compiler: clang++
windres: windres
shell: 'msys2 {0}'
msystem: clang64
install: mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-SDL2
- name: windows-arm64
os: windows-latest
compiler: clang++ --target=aarch64-w64-windows-gnu --sysroot=/clangarm64 -resource-dir=/clangarm64/lib/clang/$(basename "$(clang++ -print-resource-dir)")
windres: windres --target=aarch64-w64-windows-gnu
shell: 'msys2 {0}'
msystem: clang64
install: mingw-w64-clang-x86_64-clang mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-pkgconf mingw-w64-clang-aarch64-SDL2
- name: windows-msvc-x64
os: windows-latest
compiler: clang++
windres: llvm-rc
shell: bash
msvc-arch: x64
- name: windows-msvc-arm64
os: windows-latest
compiler: clang++ --target=aarch64-w64-windows-msvc
windres: llvm-rc
shell: bash
msvc-arch: x64_arm64
- name: windows-cl-x64
os: windows-latest
compiler: cl
windres: rc
shell: bash
msvc-arch: x64
- name: windows-cl-arm64
target-cmake-preset: windows-ci-cl-native
- name: windows-clang-cl-arm64
os: windows-latest
compiler: cl
windres: rc
shell: bash
msvc-arch: x64_arm64
- name: macos-compat
os: macos-12
target-cmake-preset: windows-ci-cl-cross
native-cmake-preset: windows-ci-cl-native
- name: macos-universal
os: macos-15
compiler: clang++
shell: sh
- name: macos-latest
os: macos-latest
compiler: clang++
shell: sh
- name: ubuntu
os: ubuntu-latest
compiler: g++
shell: sh
install: cmake ccache xcbeautify
target-cmake-preset: macos-ci-universal
name: ${{ matrix.program }}-${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.os }}
defaults:
@@ -71,264 +47,86 @@ jobs:
steps:
- name: Install MSYS2 Dependencies
if: matrix.platform.shell == 'msys2 {0}'
uses: msys2/setup-msys2@v2
uses: msys2/setup-msys2@40677d36a502eb2cf0fb808cc9dec31bf6152638
with:
msystem: ${{ matrix.platform.msystem }}
install: make ${{ matrix.platform.install }}
install: ${{ matrix.platform.install }}
- name: "macOS: Import Certificate"
if: runner.os == 'macOS' && inputs.codesign
uses: apple-actions/import-codesign-certs@65cfbc37e1464d733524cb555b724878f278b8c3
continue-on-error: ${{ secrets.MACOS_CERTIFICATE_NAME == '' }}
with:
p12-file-base64: ${{ secrets.MACOS_CERTIFICATE_DATA }}
p12-password: ${{ secrets.MACOS_CERTIFICATE_PASSPHRASE }}
- name: Checkout source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-tags: true
fetch-depth: 0
- name: Setup MSYS2 Git Environment
if: matrix.platform.shell == 'msys2 {0}'
run: |
git config core.autocrlf true
- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update -y -qq
sudo apt-get install libsdl2-dev libgtk-3-dev libao-dev libopenal-dev
- name: "macOS: Import Certificate"
if: runner.os == 'macOS' && github.event_name != 'pull_request'
continue-on-error: ${{ github.repository != 'ares-emulator/ares' }}
uses: wpilibsuite/import-signing-certificate@2ac4f44d28045073d23153256efbb4c4b2d8aa22 # Don't use rolling branch for security reasons
with:
certificate-data: ${{ secrets.MACOS_CERTIFICATE_DATA }}
certificate-passphrase: ${{ secrets.MACOS_CERTIFICATE_PASSPHRASE }}
keychain-name: ares-macos-keychain
keychain-password: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Windows Dependencies
if: runner.os == 'Windows'
run: |
export PATH="/c/Users/runneradmin/.cargo/bin:$PATH" # correct on windows-latest as of 2024-02-19
if [[ ${{ matrix.platform.name }} == *-arm64 ]]; then
rustup toolchain install nightly
rustup default nightly
rustup target add aarch64-pc-windows-msvc
pushd thirdparty/librashader
./build-librashader.sh aarch64-pc-windows-msvc
popd
else
rustup toolchain install nightly
rustup default nightly
pushd thirdparty/librashader
./build-librashader.sh
popd
fi
- name: "macOS: recover MoltenVK cache"
if: runner.os == 'macOS'
uses: actions/cache@v4
env:
cache-name: moltenvk
with:
path: thirdparty/MoltenVK/MoltenVK
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('thirdparty/MoltenVK/HEAD') }}
sudo apt-get install ${{ matrix.platform.install }}
- name: Install macOS Dependencies
if: runner.os == 'macOS'
run: |
if [ $ImageOS == "macos14" ]; then
sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer
export MACOSX_DEPLOYMENT_TARGET=10.13
echo "Set Xcode version to 15.2 for macos-latest build."
elif [ $ImageOS == "macos12" ]; then
sudo xcode-select -s /Applications/Xcode_13.4.app/Contents/Developer
export MACOSX_DEPLOYMENT_TARGET=10.9
echo "Set Xcode version to 13.4 for macos-compat build."
fi
brew install make ninja cmake
pip install --no-input setuptools
rustup toolchain install nightly
rustup default nightly
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
echo "MAKE=gmake" >> $GITHUB_ENV
pushd thirdparty/SDL
./build-SDL.sh
popd
pushd thirdparty/MoltenVK
./build-moltenvk.sh
popd
export MACOSX_DEPLOYMENT_TARGET=10.15
pushd thirdparty/librashader
./build-librashader.sh
popd
- name: Set up MSVC environment
if: matrix.platform.msvc-arch != ''
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.platform.msvc-arch }}
- name: Make
if: runner.os != 'macOS'
run: ${MAKE:-make} -j4 -C desktop-ui build=optimized local=false compiler="${{ matrix.platform.compiler }}" windres="${{ matrix.platform.windres }}"
- name: "macOS: Make universal app"
if: runner.os == 'macOS'
run: scripts/macos-make-universal.sh build=optimized local=false
brew uninstall --ignore-dependencies cmake
brew install ${{ matrix.platform.install }}
- name: "Build: Windows"
if: runner.os != 'macOS' && runner.os != 'Linux'
run: .github/scripts/build_windows.sh
env:
MAKEFLAGS: -j3
MACOS_CERTIFICATE_NAME: ${{ secrets.MACOS_CERTIFICATE_NAME }}
MACOS_KEYCHAIN_NAME: ares-macos-keychain
MACOS_KEYCHAIN_PASSWORD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
ARES_BUILD_OFFICIAL: ${{ inputs.official }}
ARES_PLATFORM_NAME: ${{ matrix.platform.name }}
CROSS_COMPILE: ${{ matrix.platform.native-cmake-preset != '' }}
NATIVE_PRESET: ${{ matrix.platform.native-cmake-preset }}
TARGET_PRESET: ${{ matrix.platform.target-cmake-preset }}
- name: "Windows: sign"
if: runner.os == 'Windows' && github.event_name != 'pull_request'
if: runner.os == 'Windows' && inputs.codesign
continue-on-error: true
uses: DanaBear/code-sign-action@98c79121b376beab8d6a9484f445089db4461bca
with:
certificate: '${{ secrets.WIN_CERTIFICATE }}'
password: '${{ secrets.WIN_PASSWORD }}'
certificatesha1: '${{ secrets.WIN_CERTHASH }}'
certificatename: '${{ secrets.WIN_CERTNAME }}'
folder: 'desktop-ui/out'
timestampUrl: 'http://timestamp.digicert.com'
- name: "macOS: notarize"
if: runner.os == 'macOS' && github.event_name != 'pull_request'
continue-on-error: ${{ github.repository != 'ares-emulator/ares' }}
run: |
ditto -c -k --keepParent desktop-ui/out/ares.app /tmp/ares.zip
xcrun notarytool submit /tmp/ares.zip --apple-id "$MACOS_NOTARIZATION_USERNAME" --password "$MACOS_NOTARIZATION_PASSWORD" --team-id "$MACOS_NOTARIZATION_TEAMID" --wait
xcrun stapler staple desktop-ui/out/ares.app
folder: 'build/desktop-ui/rundir/'
timestampUrl: 'http://timestamp.digicert.com'
- name: "Build: macOS"
if: runner.os == 'macOS'
run: .github/scripts/build_macos.sh
env:
MACOS_NOTARIZATION_USERNAME: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
MACOS_NOTARIZATION_PASSWORD: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
ARES_BUILD_OFFICIAL: ${{ inputs.official }}
TARGET_PRESET: ${{ matrix.platform.target-cmake-preset }}
MACOS_CERTIFICATE_NAME: ${{ secrets.MACOS_CERTIFICATE_NAME }}
MACOS_NOTARIZATION_TEAMID: ${{ secrets.MACOS_NOTARIZATION_TEAMID }}
- name: Upload
uses: actions/upload-artifact@v4
- name: "Compress Build Artifact (macOS)"
if: runner.os == 'macOS'
run: |
tar -cvJf ares-${{ matrix.platform.name }}.tar.xz -C build/desktop-ui/RelWithDebInfo/ .
- name: "Compress Build Artifacts (Windows)"
if: runner.os != 'macOS' && runner.os != 'Linux'
run: |
tar -cvJf ares-${{ matrix.platform.name }}.tar.xz -C build/desktop-ui/rundir/ .
- name: Upload Build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ matrix.program }}-${{ matrix.platform.name }}
path: desktop-ui/out/*
release:
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
path: ares-${{ matrix.platform.name }}.tar.xz
- name: Upload Debug Symbols (Windows)
if: runner.os != 'macOS' && runner.os != 'Linux'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
path: 'src'
- name: Download Artifacts
uses: actions/download-artifact@v4
name: ${{ matrix.program }}-${{ matrix.platform.name }}-PDBs
path: build/PDBs/*
- name: Upload Debug Symbols (macOS)
if: runner.os == 'macOS'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
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.
chmod +x ${bindir}/ares-macos-latest/ares.app/Contents/MacOS/ares
chmod +x ${bindir}/ares-macos-compat/ares.app/Contents/MacOS/ares
for package in windows windows-msvc-arm64 macos-latest macos-compat
do
mkdir "${package}"
cd "${package}"
# Package ares.
outdir=ares${suffix}
mkdir ${outdir}
cp -ar ${bindir}/ares-${package}/* ${outdir}
zip -r ../ares-${package}.zip ${outdir}
cd -
done
- name: Create Release
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eu
github_rest()
{
local method="${1}"
local url="https://api.github.com${2}"
shift 2
>&2 echo "${method} ${url}"
curl \
--fail \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-X "${method}" \
"${url}" \
"$@"
}
github_get_release_id_for_tag()
{
payload=$(github_rest GET "/repos/${GITHUB_REPOSITORY}/releases/tags/${1}") || return
echo "${payload}" | jq .id
}
github_delete_release_by_id()
{
github_rest DELETE "/repos/${GITHUB_REPOSITORY}/releases/${1}"
}
github_create_release()
{
local payload="{
\"tag_name\": \"${1}\",
\"target_commitish\": \"${2}\",
\"name\": \"${3}\",
\"body\": \"${4}\",
\"draft\": ${5},
\"prerelease\": ${6}
}"
github_rest POST "/repos/${GITHUB_REPOSITORY}/releases" -d "${payload}"
}
make_nightly_release()
{
github_create_release \
nightly \
"${GITHUB_SHA}" \
"ares nightly $(date +"%Y-%m-%d")" \
"Auto-generated nightly release on $(date -u +"%Y-%m-%d %T %Z")" \
false \
true
}
make_version_release()
{
github_create_release \
"${1}" \
"${GITHUB_SHA}" \
"ares ${1}" \
"This is ares ${1}, released on $(date +"%Y-%m-%d")." \
false \
false
}
case ${GITHUB_REF} in
refs/tags/*)
# Create a new version release using the current revision.
echo "UPLOAD_URL=$(make_version_release ${GITHUB_REF#refs/tags/} | jq -r .upload_url)" >> $GITHUB_ENV
;;
refs/heads/master)
# Check for an existing nightly release.
{ release_id=$(github_get_release_id_for_tag nightly); status=$?; } || true
# Delete existing nightly release if it exists.
case ${status} in
0) github_delete_release_by_id "${release_id}" ;;
22) >&2 echo "No current nightly release; skipping tag deletion." ;;
*) >&2 echo "API call failed unexpectedly." && exit 1 ;;
esac
# Create a new nightly release using the current revision.
echo "UPLOAD_URL=$(make_nightly_release | jq -r .upload_url)" >> $GITHUB_ENV
;;
esac
- name: Upload ares-windows
uses: actions/upload-release-asset@v1
env: { GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' }
with: { upload_url: '${{ env.UPLOAD_URL }}', asset_path: 'ares-windows.zip', asset_name: 'ares-windows.zip', asset_content_type: 'application/zip' }
- name: Upload ares-windows-msvc-arm64
uses: actions/upload-release-asset@v1
env: { GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' }
with: { upload_url: '${{ env.UPLOAD_URL }}', asset_path: 'ares-windows-msvc-arm64.zip', asset_name: 'ares-windows-msvc-arm64.zip', asset_content_type: 'application/zip' }
- name: Upload ares-macos-latest
uses: actions/upload-release-asset@v1
env: { GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' }
with: { upload_url: '${{ env.UPLOAD_URL }}', asset_path: 'ares-macos-latest.zip', asset_name: 'ares-macos-latest.zip', asset_content_type: 'application/zip' }
- name: Upload ares-macos-compat
uses: actions/upload-release-asset@v1
env: { GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' }
with: { upload_url: '${{ env.UPLOAD_URL }}', asset_path: 'ares-macos-compat.zip', asset_name: 'ares-macos-compat.zip', asset_content_type: 'application/zip' }
# - name: Upload ares-ubuntu
# uses: actions/upload-release-asset@v1
# env: { GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' }
# with: { upload_url: '${{ env.UPLOAD_URL }}', asset_path: 'ares-ubuntu.zip', asset_name: 'ares-ubuntu.zip', asset_content_type: 'application/zip' }
name: ${{ matrix.program }}-${{ matrix.platform.name }}-dSYMs
path: build/dSYMs/*
+23
View File
@@ -0,0 +1,23 @@
name: Pull Request
run-name: ${{ github.event.pull_request.title }} PR run
on:
pull_request:
branches: [ '*' ]
types: [ opened, synchronize, reopened ]
permissions:
contents: read
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
build-project:
name: Build ares (primary)
uses: ./.github/workflows/build.yml
permissions:
contents: read
with:
official: false
build-aux:
name: Build ares (auxiliary)
uses: ./.github/workflows/build-aux.yml
secrets: inherit
+27
View File
@@ -0,0 +1,27 @@
name: Push
on:
push
concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true
permissions:
contents: write
jobs:
build:
name: Build ares (primary)
uses: ./.github/workflows/build.yml
secrets: inherit
with:
codesign: true
official: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }}
build-aux:
name: Build ares (auxiliary)
uses: ./.github/workflows/build-aux.yml
secrets: inherit
release:
name: Release
needs: build
secrets: inherit
uses: ./.github/workflows/release.yml
with:
notarize: true
+84
View File
@@ -0,0 +1,84 @@
name: Release
permissions:
contents: write
on:
workflow_call:
inputs:
notarize:
description: Notarize build (macOS only)
required: false
default: true
type: boolean
jobs:
release:
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
runs-on: macos-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
path: 'src'
- name: Download Artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
path: 'bin'
- name: "Decompress Build Artifacts"
if: runner.os == 'macOS'
run: |
for package in macos-universal windows-x64 windows-clang-cl-arm64; do
pushd bin/ares-${package}
tar -xJf ares-${package}.tar.xz
rm -f ares-${package}.tar.xz
popd
done
- name: "macOS: notarize"
if: inputs.notarize
run: |
ditto -c -k --keepParent ${{ github.workspace }}/bin/ares-macos-universal/ares.app /tmp/ares.zip
xcrun notarytool submit /tmp/ares.zip --apple-id "$MACOS_NOTARIZATION_USERNAME" --password "$MACOS_NOTARIZATION_PASSWORD" --team-id "$MACOS_NOTARIZATION_TEAMID" --wait
xcrun stapler staple ${{ github.workspace }}/bin/ares-macos-universal/ares.app
env:
MACOS_NOTARIZATION_USERNAME: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
MACOS_NOTARIZATION_PASSWORD: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
MACOS_NOTARIZATION_TEAMID: ${{ secrets.MACOS_NOTARIZATION_TEAMID }}
- name: Package Artifacts
run: src/.github/scripts/package_artifacts.sh
- name: Check Release Tag ☑️
id: check
run: |
now=$(date +'%Y-%m-%d')
subject=$(git -C src log -1 --pretty=%s)
if [[ ${GITHUB_REF_NAME} == master ]];
then
echo "tag=nightly" >> $GITHUB_OUTPUT
versionName="nightly ${now}"
echo "versionName=${versionName}" >> $GITHUB_OUTPUT
echo "description=${subject}" >> $GITHUB_OUTPUT
else
echo "tag=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
echo "versionName=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
description="This is ares ${GITHUB_REF_NAME}, released on ${now}."
echo "description=${description}" >> $GITHUB_OUTPUT
fi
- name: Update Git Tag
if: steps.check.outputs.tag == 'nightly'
id: update-tag
run: |
git -C src tag -f ${{ steps.check.outputs.tag }}
git -C src push -f origin ${{ steps.check.outputs.tag }}
- name: Create Release 🛫
id: create_release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
with:
prerelease: ${{ steps.check.outputs.tag == 'nightly' }}
tag_name: ${{ steps.check.outputs.tag }}
name: ares ${{ steps.check.outputs.versionName }}
body: ${{ steps.check.outputs.description }}
files: |
${{ github.workspace }}/ares-source.tar.gz
${{ github.workspace }}/ares-macos-universal.zip
${{ github.workspace }}/ares-macos-universal-dSYMs.zip
${{ github.workspace }}/ares-windows-x64.zip
${{ github.workspace }}/ares-windows-x64-PDBs.zip
${{ github.workspace }}/ares-windows-clang-cl-arm64.zip
${{ github.workspace }}/ares-windows-clang-cl-arm64-PDBs.zip
+53 -18
View File
@@ -1,18 +1,53 @@
*.moc
*.user
*.xcuserdata
.vs/
.vscode/
.idea/
cmake-*/
obj/
out/
obj-amd64/
obj-arm64/
out-amd64/
out-arm64/
thirdparty/SDL/SDL
thirdparty/SDL/libSDL2-2.0.0.dylib
macos-xcode/
.swiftpm
*.xcodeproj
# Exclude everything
/*
# Except for default project files
!/.github
!/ares
!/desktop-ui
!/hiro
!/cmake
!/libco
!/mia
!/nall
!/ruby
!/scripts
!/tests
!/thirdparty
!/tools
!/GNUMakefile
!/LICENSE
!/README.md
!.editorconfig
!.gitignore
!.gitattributes
!.gersemirc
!deps.json
!CMakeLists.txt
!CMakePresets.json
# Exclude old macOS Finder metadata
.DS_Store
# Exclude generated sources that still reside in-tree
ruby/video/metal/shaders.metallib
ruby/video/metal/shaders.ir
ares/ares/resource/resource.cpp
ares/ares/resource/resource.hpp
hiro/resource/resource.cpp
hiro/resource/resource.hpp
desktop-ui/resource/resource.cpp
desktop-ui/resource/resource.hpp
mia/resource/resource.cpp
mia/resource/resource.hpp
# Exclude Qt generated MOC file
hiro/qt/qt.moc
# Exclude fetched third-party processor test binaries
tests/arm7tdmi/tests
tests/m68000/tests
# Exclude unused legacy zlib header that is renamed by CMake
thirdparty/libchdr/deps/zlib-*/zconf.h
thirdparty/libchdr/deps/zlib-*/zconf.h.included
+57
View File
@@ -0,0 +1,57 @@
cmake_minimum_required(VERSION 3.28...4.1)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/bootstrap.cmake" NO_POLICY_SCOPE)
project(ares VERSION ${ARES_VERSION_CANONICAL})
include(compilerconfig)
include(defaults)
include(helpers)
add_subdirectory(thirdparty)
add_subdirectory(nall/nall)
add_subdirectory(libco)
add_subdirectory(ruby)
add_subdirectory(hiro)
# gersemi: off
set(
ARES_CORES
a26 a52 fc sfc sg ms md ps1 pce ng msx cv myvision gb gba ws ngp spec n64
CACHE STRING "List of systems to be built by the project"
)
# gersemi: on
add_subdirectory(ares)
add_subdirectory(mia)
add_subdirectory(desktop-ui)
option(ARES_BUILD_OPTIONAL_TARGETS "Include supplemental tools and tests" OFF)
if(ARES_BUILD_OPTIONAL_TARGETS)
enable_testing()
add_subdirectory(tests/arm7tdmi)
add_subdirectory(tests/armv6m)
add_subdirectory(tests/i8080)
add_subdirectory(tests/m68000)
if(HIRO_BACKEND STREQUAL "GTK3")
add_subdirectory(tools/genius)
else()
target_disable_subproject(genius "genius (database editor)")
endif()
else()
target_disable_subproject(arm7tdmi "arm7tdmi processor test harness")
target_disable_subproject(armv6m "armv6m processor test harness")
target_disable_subproject(i8080 "i8080 processor test harness")
target_disable_subproject(m68000 "m68000 processor test harness")
target_disable_subproject(genius "genius (database editor)")
endif()
add_subdirectory(tools/sourcery)
message_configuration()
add_subdirectory(.github)
add_subdirectory(cmake)
return()
+200
View File
@@ -0,0 +1,200 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 28,
"patch": 0
},
"configurePresets": [
{
"name": "baseCacheVars",
"hidden": true,
"cacheVariables": {
"ARES_PROFILE_ACCURACY": false,
"ARES_BUILD_LOCAL": true,
"ENABLE_CCACHE": true,
"ARES_BUILD_OFFICIAL": {"type": "BOOL", "value": "$penv{ARES_BUILD_OFFICIAL}"}
}
},
{
"name": "macos",
"displayName": "macOS",
"description": "Xcode project (host architecture by default)",
"inherits": ["baseCacheVars"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"generator": "Xcode",
"binaryDir": "${sourceDir}/build_macos",
"cacheVariables": {
"ARES_CODESIGN_IDENTITY": {"type": "STRING", "value": "$penv{CODESIGN_IDENT}"},
"ARES_CODESIGN_TEAM": {"type": "STRING", "value": "$penv{CODESIGN_TEAM}"},
"ARES_BUILD_OPTIONAL_TARGETS": true,
"ENABLE_CCACHE": true
}
},
{
"name": "windows",
"displayName": "Windows (Visual Studio, ClangCL)",
"description": "Visual Studio project using ClangCL (host architecture)",
"inherits": ["baseCacheVars"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"binaryDir": "${sourceDir}/build_vsclang",
"generator": "Visual Studio 18 2026",
"toolset": "ClangCL",
"cacheVariables": {
"ENABLE_CCACHE": true
}
},
{
"name": "windows-msvc",
"displayName": "Windows (Visual Studio, MSVC)",
"description": "Visual Studio project using MSVC (host architecture)",
"inherits": ["baseCacheVars"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"binaryDir": "${sourceDir}/build_msvc",
"generator": "Visual Studio 18 2026",
"cacheVariables": {
"ENABLE_CCACHE": true
}
},
{
"name": "macos-ci-universal",
"displayName": "macOS for CI",
"description": "Universal binary for building on Github Actions",
"inherits": ["baseCacheVars"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"generator": "Xcode",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": {"type": "STRING", "value": "x86_64;arm64"},
"CMAKE_OSX_DEPLOYMENT_TARGET": {"type": "STRING", "value": "11.0"},
"ARES_CODESIGN_IDENTITY": {"type": "STRING", "value": "$penv{MACOS_CERTIFICATE_NAME}"},
"ARES_CODESIGN_TEAM": {"type": "STRING", "value": "$penv{MACOS_NOTARIZATION_TEAMID}"},
"ENABLE_CCACHE": true,
"ARES_BUILD_LOCAL": false,
"ARES_UNITY_CORES": true,
"ARES_BUILD_OPTIONAL_TARGETS": true
}
},
{
"name": "windows-ci-base",
"hidden": true,
"inherits": ["baseCacheVars"],
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": {"type": "STRING", "value": "RelWithDebInfo"},
"ENABLE_CCACHE": true,
"ARES_BUILD_LOCAL": false,
"ARES_BUILD_OPTIONAL_TARGETS": true,
"ARES_UNITY_CORES": true,
"ARES_PRECOMPILE_HEADERS": true,
"CMAKE_MSVC_RUNTIME_LIBRARY": {"type": "STRING", "value": "MultiThreaded"},
"CMAKE_IGNORE_PATH": {"type": "STRING", "value": "C:/Strawberry/c/bin/"}
}
},
{
"name": "windows-ci-mingw-native",
"displayName": "Windows for CI (x64 MSYS2/MinGW Clang)",
"description": "Single-arch binary for building on Github Actions",
"inherits": ["windows-ci-base"],
"generator": "Ninja"
},
{
"name": "windows-ci-cl-native",
"displayName": "Windows for CI (x64 ClangCL)",
"description": "Single-arch binary for building on Github Actions",
"generator": "Visual Studio 18 2026",
"inherits": ["windows-ci-base"],
"toolset": "ClangCL"
},
{
"name": "windows-ci-cl-cross",
"displayName": "Windows for CI (arm64 ClangCL)",
"description": "Single-arch binary for building on Github Actions",
"inherits": ["windows-ci-base"],
"generator": "Visual Studio 18 2026",
"architecture": "arm64",
"toolset": "ClangCL",
"cacheVariables": {
"ARES_CROSSCOMPILING": true
}
},
{
"name": "windows-ci-msvc-native",
"displayName": "Windows for CI (x64 MSVC)",
"description": "Single-arch binary for building on Github Actions",
"generator": "Visual Studio 18 2026",
"inherits": ["windows-ci-base"]
},
{
"name": "windows-ci-msvc-cross",
"displayName": "Windows for CI (arm64 MSVC)",
"description": "Single-arch binary for building on Github Actions",
"generator": "Visual Studio 18 2026",
"architecture": "arm64",
"inherits": ["windows-ci-base"],
"cacheVariables": {
"ARES_CROSSCOMPILING": true
}
},
{
"name": "ubuntu-ci",
"displayName": "Ubuntu CI (x64 gcc)",
"description": "Single-arch binary for building on Github Actions",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": {"type": "STRING", "value": "RelWithDebInfo"},
"ENABLE_CCACHE": true,
"ENABLE_IPO": false,
"ARES_BUILD_LOCAL": false,
"ARES_BUILD_OPTIONAL_TARGETS": true,
"ARES_PRECOMPILE_HEADERS": false
}
},
{
"name": "ubuntu-ci-clang",
"displayName": "Ubuntu CI (clang)",
"description": "Single-arch binary for building on Github Actions",
"inherits": ["ubuntu-ci"],
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
}
},
{
"name": "ubuntu-ci-qt",
"displayName": "Ubuntu CI (arm64, gcc, Qt)",
"description": "Single-arch binary for building on Github Actions",
"inherits": ["ubuntu-ci"],
"cacheVariables": {
"USE_QT6": true,
"ARES_BUILD_OPTIONAL_TARGETS": false
}
}
],
"buildPresets": [
{
"name": "windows",
"configurePreset": "windows",
"displayName": "Windows build (host architecture)",
"description": "Windows build (host architecture)",
"configuration": "RelWithDebInfo"
}
]
}
-6
View File
@@ -1,6 +0,0 @@
targets = all clean install uninstall verbose
$(targets):
@$(MAKE) -C desktop-ui $@
.PHONY: $(targets)
+64 -2
View File
@@ -1,7 +1,7 @@
----------------------------------------------------------------------
ares
Copyright (c) 2004-2021 ares team, Near et al
Copyright (c) 2004-2025 ares team, Near 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 above
@@ -16,6 +16,40 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
----------------------------------------------------------------------
----------------------------------------------------------------------
MAME-derived ROM decryption and arcade database
Portions of the ROM decryption code are derived from MAME source files
licensed under the BSD 3-Clause License. The arcade database is generated
from MAME machine data.
Copyright (c) 1997-2026 MAMEdev and contributors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
----------------------------------------------------------------------
Stack-less Just-In-Time compiler
@@ -828,4 +862,32 @@ You may add additional accurate notices of copyright ownership.
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
----------------------------------------------------------------------
----------------------------------------------------------------------
----------------------------------------------------------------------
qoi/qon
Copyright (c) 2025, Roger Sanders
Revised QOI format, achieving higher compression with equivalent performance.
Based on the "Quite OK Image" format for fast, lossless image compression
Copyright (c) 2021, Dominic Szablewski - https://phoboslab.org
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.
----------------------------------------------------------------------
+17 -121
View File
@@ -1,10 +1,12 @@
![ares logo](https://github.com/ares-emulator/ares/blob/master/ares/ares/resource/logo.png)
<img src="https://github.com/ares-emulator/ares/blob/master/ares/ares/resource/logo@2x.png" width="350"/>
[![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://github.com/higan-emu/ares/blob/master/LICENSE)
**ares** is a multi-system emulator that began development on October 14th, 2004.
It is a descendant of [higan](https://github.com/higan-emu/higan) and [bsnes](https://github.com/bsnes-emu/bsnes/), and focuses on accuracy and preservation.
It's worth noting that ares takes some uncommon design approaches that essentially trade speed for code clarity. We avoid state machines and bitmasks (when possible). Most cores end up being half the amount of code, but slower. The code is clearer and less spaghettified, especially for systems with lots of processors. C bitfields being non-portable incurs a speedhit. Windows also has a speedhit over Linux due to its ABI needing more instructions to switch contexts.
Official Releases
-----------------
@@ -14,130 +16,18 @@ Official releases are available from
Nightly Builds
--------------
Automated, untested builds of ares are available for Windows and macOS as a [pre-release](https://github.com/higan-emu/ares/releases/tag/nightly).
Automated, untested builds of ares are available for Windows and macOS as a [pre-release](https://github.com/ares-emulator/ares/releases/tag/nightly).
Only the latest nightly build is kept.
Prerequisites
Building ares
-------------
### *nix building
###### Minimum required packages:
```
g++ make pkg-config libgtk-3-dev libcanberra-gtk-module libgl-dev libasound2-dev
```
###### Additional Audio Drivers
ares supports additional audio drivers besides the ALSA drivers included above. Installing these additional packages will allow them to be selected in Settings > Drivers:
`libao-dev libopenal-dev`
###### GTK2 & GTK3
By default, GTK3 is used, but support for GTK2 is available. You will need to install the additional package `libgtk2.0-dev` as well as specifying the command line option `hiro=gtk2` at compile time.
###### SDL2 for input
If you would like to use SDL for input (e.g. for using a controller), you will need to install the `libsdl2-dev` and `libsdl2-2.0-0` packages and perform a clean build of ares.
You should then be able to select SDL for input in the Settings > Drivers menu.
##### Building with clang
clang++ is now the preferred compiler for ares. If clang is detected on Windows/macOS/BSD, it will be selected by default. On Linux and other platforms, g++ remains the default if present. To build with clang, it is necessary to install both the `clang` and `lld` packages. If you would like to manually specify a compiler, you can use the following option: `compiler=[g++|clang++]`
##### Librashader Support
If you do not want to include librashader support, you can pass the following option to the `make` command to skip these requirements using: `librashader=false`
Librashader requires rust in order to build. You can install it with the following command:
```
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
rustup toolchain install nightly
```
In order to build librashader, change into the `ares/thirdparty/librashader` directory and run the script `build-librashader.sh`
Note that once the build completes, it will instruct you to run three copy commands to install the library on your system. These paths may be different depending on Linux distribution.
--------------
### Windows building
To build on Windows, using MSYS2 is recommended which can be download [here](https://www.msys2.org/). Follow the instructions
on this page to install and setup an appropriate MINGW64 environment. Running the command:
```
pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-SDL2
```
from the MSYS2 MSYS terminal should setup everything you need to compile ares. Note that in order to compile, you will want to be in a MINGW64 terminal window after install and setup is complete.
##### Building with clang
clang is available through Visual Studio (or Build Tools for Visual Studio) through its installer and can be used to build ares. You will still need to supply GNU make in this instance. MSYS2 also offers a clang environment. You will want to make sure you select the clangw64 option during installation of MSYS2 which should provide and additional CLANG64 pre-configured environment. Install the clang toolchain package from the MSYS2 terminal:
```
pacman -S mingw-w64-clang-x86_64-toolchain mingw-w64-clang-x86_64-SDL2
```
Once complete, open a CLANG64 terminal window and proceed with building ares.
###### Debug Symbols
When building with clang, by default symbols will be generated for debug builds using an MSVC compatible format (CodeView) for use with Windows debugging tools. In order to generate GDB compatible symbols, specify the following option: `symformat=gdb`
###### Librashader Support
ares has introduced support for the [librashader](https://github.com/SnowflakePowered/librashader) library, which is a preprocessor, compiler, and runtime for RetroArch 'slang' shaders. If you are not interested in working with librashaders, you can pass the following option to the `make` command to skip these requirements using: `librashader=false`
Building the librashader library on Windows requires Rust. Follow these steps to prepare your system and build the librashader library:
1. Download and execute the rustup-init.exe installer from: https://rustup.rs/
2. Open a new Windows terminal and run the following commands:
```
rustup toolchain install nightly
rustup default nightly
```
3. With Rust successfully installed, you will need to update your PATH environment variable within your MSYS2 environment. In an MSYS2 shell, open $HOME/.bash_profile and append something like the following (note you will need to replace both instances of %USER_NAME% with the real user name you used to install Rust):
```
if [ -d "/C/Users/%USER_NAME%/.cargo/bin" ] ; then
PATH="/C/Users/%USER_NAME%/.cargo/bin:${PATH}"
fi
```
4. Open a new MSYS2 based shell for the compiler you are using (MinGW64|CLANG64|UCRT64), execute `rustup` to validate the path is set properly within your MSYS2 environment.
5. In your MSYS2 compiler shell, `cd` into the `ares/thirdparty/librashader` directory
6. Execute the build script, build should complete successfully:
```
./build-librashader.sh
```
This only needs to be done once, or anytime the librashader library is updated. Once built, ares will build with librashader support by default requiring no additional flags.
Compilation
-----------
Check out the source code by running this command:
```
git clone https://github.com/ares-emulator/ares.git
```
From the root of the project directory run:
```
make -j4
```
`-j#` indicates number of parallel build processes, and shouldn't be set higher than N-1 cores on your processor. Specifying this option can significantly decrease the time to build this project. There are multiple build types available and it defaults to an 'optimized' build. Build types can be specified using: `build=[debug|stable|release|minified|optimized]`
Build options can be found in the following two make files: nall/GNUmakefile desktop-ui/GNUmakefile
To start compilation from the beginning, run the following prior to compiling:
```
make clean
```
#### Building specific cores
If you would like to build a subset of cores, you can specify the `cores="core1 core2"` option. Currently available cores:
```
a26 fc sfc n64 sg ms md ps1 pce ng msx cv myvision gb gba ws ngp spec
```
Build Output
------------
There is a single binary produced at the end of compilation which can be found in `desktop-ui/out`. On OS's besides Linux, the `Database` & `Shader` directories are copied over here as well. On Linux, running `make install` after compilation will copy these directories and binary into suitable locations (see desktop-ui/GNUmakefile for details). Alternatively, these directories can be copied from `thirdparty/slang-shaders/*` into a `Shader` directory, and by copying `mia/Database/*`
ares supports building on Windows, macOS, and various Linux/BSD distributions. See build instructions for:
* [Windows](https://github.com/ares-emulator/ares/wiki/Build-Instructions-For-Windows)
* [macOS](https://github.com/ares-emulator/ares/wiki/Build-Instructions-For-macOS)
* [Linux](https://github.com/ares-emulator/ares/wiki/Build-Instructions-For-Linux)
* [BSD](https://github.com/ares-emulator/ares/wiki/Build-Instructions-For-BSD)
Command-line options
--------------------
@@ -148,12 +38,18 @@ When started from the command-line, ares accepts a few options.
Usage: ./ares [options] game(s)
--help Displays available options and exit
--version Displays the version string of the application
--terminal Create new terminal window (Windows only)
--fullscreen Start in full screen mode
--pseudofullscreen Start in pseudo full screen mode
--kiosk Start in minimal UI mode (implies --no-file-prompt)
--system system Specify the system name
--shader shader Specify GLSL shader name to load (requires OpenGL driver)
--shader shader Specify a slang shader to load (requires OpenGL or Metal)
--setting name=value Specify a value for a setting
--dump-all-settings Show a list of all existing settings and exit
--no-file-prompt Do not prompt to load (optional) additional roms (eg: 64DD)
--settings-file path Specify a settings file override (settings.bml)
--save-state slot Specify a save state slot to load (1-9)
```
The --system option is useful when the system type cannot be auto-detected.
+333
View File
@@ -0,0 +1,333 @@
add_library(ares STATIC ares/ares.cpp ares/memory/fixed-allocator.cpp)
configure_file(ares/ares.cpp.in ares/ares.cpp @ONLY)
add_library(ares::ares ALIAS ares)
option(ARES_PROFILE_ACCURACY "Build to prefer emulation accuracy over performance in certain specific areas" OFF)
option(ARES_PRECOMPILE_HEADERS "Precompile ares/ares.hpp header for performance" OFF)
option(
ARES_UNITY_CORES
"\
Build each core as one translation unit. Decreases cold build times but increases incremental build times. Slightly \
increases performance.
"
OFF
)
add_sourcery_command(ares ares/resource)
if(ARES_PRECOMPILE_HEADERS)
target_precompile_headers(ares PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:ares/ares.hpp>")
endif()
target_link_libraries(ares PRIVATE libco ares::nall::headers $<$<BOOL:${ARES_ENABLE_CHD}>:chdr-static> PUBLIC sljit)
if(ARES_PROFILE_ACCURACY)
target_compile_definitions(ares PUBLIC PROFILE_ACCURACY)
else()
target_compile_definitions(ares PUBLIC PROFILE_PERFORMANCE)
endif()
target_sources(
ares
PRIVATE ares/ares.cpp ares/ares.cpp.in ares/ares.hpp ares/inline.hpp ares/platform.hpp ares/random.hpp ares/types.hpp
)
target_sources(
ares
PRIVATE
ares/debug/debug.cpp
ares/debug/debug.hpp
ares/memory/fixed-allocator.cpp
ares/memory/fixed-allocator.hpp
ares/memory/memory.hpp
ares/memory/readable.hpp
ares/memory/writable.hpp
)
target_sources(
ares
PRIVATE ares/scheduler/scheduler.cpp ares/scheduler/scheduler.hpp ares/scheduler/thread.cpp ares/scheduler/thread.hpp
)
target_sources(
ares
PRIVATE
ares/node/attribute.hpp
ares/node/class.hpp
ares/node/node.cpp
ares/node/node.hpp
ares/node/object.hpp
ares/node/peripheral.hpp
ares/node/port.hpp
ares/node/system.hpp
)
target_sources(ares PRIVATE ares/node/audio/audio.hpp ares/node/audio/stream.cpp ares/node/audio/stream.hpp)
target_sources(ares PRIVATE ares/node/component/component.hpp ares/node/component/real-time-clock.hpp)
target_sources(
ares
PRIVATE
ares/node/input/axis.hpp
ares/node/input/button.hpp
ares/node/input/input.hpp
ares/node/input/rumble.hpp
ares/node/input/trigger.hpp
)
target_sources(
ares
PRIVATE
ares/node/setting/boolean.hpp
ares/node/setting/integer.hpp
ares/node/setting/natural.hpp
ares/node/setting/real.hpp
ares/node/setting/setting.hpp
ares/node/setting/string.hpp
)
target_sources(
ares
PRIVATE
ares/node/video/screen.cpp
ares/node/video/screen.hpp
ares/node/video/sprite.cpp
ares/node/video/sprite.hpp
ares/node/video/video.hpp
)
target_sources(
ares
PRIVATE
ares/node/debugger/debugger.hpp
ares/node/debugger/graphics.hpp
ares/node/debugger/memory.hpp
ares/node/debugger/properties.hpp
ares/node/debugger/tracer/tracer.hpp
ares/node/debugger/tracer/instruction.hpp
ares/node/debugger/tracer/notification.hpp
)
if(OS_WINDOWS)
include(cmake/os-windows.cmake)
elseif(OS_MACOS)
include(cmake/os-macos.cmake)
elseif(OS_LINUX OR OS_FREEBSD OR OS_OPENBSD)
include(cmake/os-linux.cmake)
endif()
macro(ares_components)
list(APPEND ares.components ${ARGV})
set(ares.components ${ares.components} PARENT_SCOPE)
endmacro()
macro(ares_add_sources)
set(options "")
set(oneValueArgs CORE)
set(multiValueArgs PRIMARY INCLUDED UNITY)
cmake_parse_arguments(AAS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
target_sources(ares PRIVATE ${AAS_INCLUDED} ${AAS_PRIMARY})
if(ARES_UNITY_CORES)
list(APPEND AAS_INCLUDED ${AAS_PRIMARY})
target_sources(ares PRIVATE ${AAS_UNITY})
endif()
foreach(arg IN ITEMS ${AAS_INCLUDED})
list(APPEND ARES_HEADER_SOURCES "${AAS_CORE}/${arg}")
endforeach()
set(ARES_HEADER_SOURCES ${ARES_HEADER_SOURCES} PARENT_SCOPE)
endmacro()
list(TRANSFORM ARES_CORES STRIP)
if(a26 IN_LIST ARES_CORES)
enable_core("Atari 2600")
add_subdirectory(a26)
else()
disable_core("Atari 2600")
endif()
if(a52 IN_LIST ARES_CORES)
enable_core("Atari 5200")
add_subdirectory(a52)
else()
disable_core("Atari 5200")
endif()
if(fc IN_LIST ARES_CORES)
enable_core("NES / Famicom")
add_subdirectory(fc)
else()
disable_core("NES / Famicom")
endif()
if(sfc IN_LIST ARES_CORES)
enable_core("SNES / Super Famicom")
add_subdirectory(sfc)
else()
disable_core("SNES / Super Famicom")
endif()
if(n64 IN_LIST ARES_CORES)
enable_core("Nintendo 64")
add_subdirectory(n64)
else()
disable_core("Nintendo 64")
endif()
if(sg IN_LIST ARES_CORES)
enable_core("Sega SG-1000")
add_subdirectory(sg)
else()
disable_core("Sega SG-1000")
endif()
if(ms IN_LIST ARES_CORES)
enable_core("Sega Master System / Mark III")
add_subdirectory(ms)
else()
disable_core("Sega Master System / Mark III")
endif()
if(md IN_LIST ARES_CORES)
enable_core("Sega Mega Drive / Genesis")
add_subdirectory(md)
else()
disable_core("Sega Mega Drive / Genesis")
endif()
if(saturn IN_LIST ARES_CORES)
enable_core("Sega Saturn")
add_subdirectory(saturn)
else()
disable_core("Sega Saturn")
endif()
if(ps1 IN_LIST ARES_CORES)
enable_core("PlayStation")
add_subdirectory(ps1)
else()
disable_core("Playstation")
endif()
if(pce IN_LIST ARES_CORES)
enable_core("PC-Engine / TurboGrafx")
add_subdirectory(pce)
else()
disable_core("PC-Engine / TurboGrafx")
endif()
if(msx IN_LIST ARES_CORES)
enable_core("Microsoft MSX")
add_subdirectory(msx)
else()
disable_core("Microsoft MSX")
endif()
if(cv IN_LIST ARES_CORES)
enable_core("ColecoVision")
add_subdirectory(cv)
else()
disable_core("ColecoVision")
endif()
if(myvision IN_LIST ARES_CORES)
enable_core("My Vision")
add_subdirectory(myvision)
else()
disable_core("My Vision")
endif()
if(gb IN_LIST ARES_CORES)
enable_core("Game Boy / Game Boy Color")
add_subdirectory(gb)
else()
disable_core("Game Boy / Game Boy Color")
endif()
if(gba IN_LIST ARES_CORES)
enable_core("Game Boy Advance")
add_subdirectory(gba)
else()
disable_core("Game Boy Advance")
endif()
if(ws IN_LIST ARES_CORES)
enable_core("WonderSwan / WonderSwan Color")
add_subdirectory(ws)
else()
disable_core("WonderSwan / WonderSwan Color")
endif()
if(ng IN_LIST ARES_CORES)
enable_core("Neo Geo (AES/MVS)")
add_subdirectory(ng)
else()
disable_core("Neo Geo (AES/MVS)")
endif()
if(ngp IN_LIST ARES_CORES)
enable_core("Neo Geo Pocket / Neo Geo Pocket Color")
add_subdirectory(ngp)
else()
disable_core("Neo Geo Pocket / Neo Geo Pocket Color")
endif()
if(spec IN_LIST ARES_CORES)
enable_core("ZX Spectrum")
add_subdirectory(spec)
else()
disable_core("ZX Spectrum")
endif()
add_subdirectory(component)
foreach(c IN LISTS ARES_CORES)
# target_enable_feature(ares "${c} core" CORE_$<UPPER_CASE:${c}>)
target_compile_definitions(ares PUBLIC CORE_$<UPPER_CASE:${c}>)
endforeach()
get_target_property(ares_SOURCES ares SOURCES)
set_source_files_properties(
ares
ares/debug/debug.cpp
ares/node/audio/stream.cpp
ares/node/node.cpp
ares/node/video/screen.cpp
ares/node/video/sprite.cpp
ares/scheduler/thread.cpp
ares/scheduler/scheduler.cpp
PROPERTIES HEADER_FILE_ONLY TRUE
)
set_source_files_properties(
n64/vulkan/parallel-rdp/vulkan/shader.cpp
n64/vulkan/parallel-rdp/vulkan/descriptor_set.cpp
n64/vulkan/parallel-rdp/vulkan/device.cpp
n64/vulkan/parallel-rdp/vulkan/command_buffer.cpp
n64/vulkan/parallel-rdp/vulkan/render_pass.cpp
n64/vulkan/parallel-rdp/vulkan/context.cpp
n64/vulkan/parallel-rdp/vulkan/memory_allocator.cpp
n64/vulkan/parallel-rdp/vulkan/semaphore.cpp
n64/vulkan/parallel-rdp/util/logging.cpp
n64/vulkan/parallel-rdp/util/environment.cpp
n64/vulkan/parallel-rdp/util/thread_name.cpp
n64/vulkan/parallel-rdp/util/timer.cpp
PROPERTIES SKIP_PRECOMPILE_HEADERS ON
)
target_sources(ares PRIVATE cmake/os-macos.cmake cmake/os-windows.cmake cmake/os-linux.cmake)
set_source_files_properties(ares ${ARES_HEADER_SOURCES} PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties(ares ares/ares.cpp ares/memory/fixed-allocator.cpp PROPERTIES HEADER_FILE_ONLY FALSE)
target_include_directories(ares INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${ares_SOURCES})
-108
View File
@@ -1,108 +0,0 @@
ifeq ($(platform),windows)
options += $(call lib,uuid kernel32 user32 gdi32 comctl32 comdlg32 shell32)
else ifeq ($(platform),macos)
else ifneq ($(filter $(platform),linux bsd),)
options += -Wl,-export-dynamic
options += -lX11 -lXext
else
$(error "ares is a library and cannot be built directly.")
endif
ares.objects := ares ares-fixed-allocator
$(object.path)/ares.o: $(ares.path)/ares/ares.cpp
$(object.path)/ares-fixed-allocator.o: $(ares.path)/ares/memory/fixed-allocator.cpp
ifeq ($(vulkan),true)
flags += -DVULKAN
endif
ifeq ($(profile),accuracy)
flags += -DPROFILE_ACCURACY
endif
ifeq ($(profile),performance)
flags += -DPROFILE_PERFORMANCE
endif
ifneq ($(filter $(cores),a26),)
include $(ares.path)/a26/GNUmakefile
endif
ifneq ($(filter $(cores),fc),)
include $(ares.path)/fc/GNUmakefile
endif
ifneq ($(filter $(cores),sfc),)
include $(ares.path)/sfc/GNUmakefile
endif
ifneq ($(filter $(cores),n64),)
include $(ares.path)/n64/GNUmakefile
endif
ifneq ($(filter $(cores),sg),)
include $(ares.path)/sg/GNUmakefile
endif
ifneq ($(filter $(cores),ms),)
include $(ares.path)/ms/GNUmakefile
endif
ifneq ($(filter $(cores),md),)
include $(ares.path)/md/GNUmakefile
endif
ifneq ($(filter $(cores),saturn),)
include $(ares.path)/saturn/GNUmakefile
endif
ifneq ($(filter $(cores),ps1),)
include $(ares.path)/ps1/GNUmakefile
endif
ifneq ($(filter $(cores),pce),)
include $(ares.path)/pce/GNUmakefile
endif
ifneq ($(filter $(cores),msx),)
include $(ares.path)/msx/GNUmakefile
endif
ifneq ($(filter $(cores),cv),)
include $(ares.path)/cv/GNUmakefile
endif
ifneq ($(filter $(cores),myvision),)
include $(ares.path)/myvision/GNUmakefile
endif
ifneq ($(filter $(cores),gb),)
include $(ares.path)/gb/GNUmakefile
endif
ifneq ($(filter $(cores),gba),)
include $(ares.path)/gba/GNUmakefile
endif
ifneq ($(filter $(cores),ws),)
include $(ares.path)/ws/GNUmakefile
endif
ifneq ($(filter $(cores),ng),)
include $(ares.path)/ng/GNUmakefile
endif
ifneq ($(filter $(cores),ngp),)
include $(ares.path)/ngp/GNUmakefile
endif
ifneq ($(filter $(cores),spec),)
include $(ares.path)/spec/GNUmakefile
endif
include $(ares.path)/component/GNUmakefile
flags += $(foreach c,$(call strupper,$(cores)),-DCORE_$c)
ares.objects := $(ares.objects:%=$(object.path)/%.o)
+173
View File
@@ -0,0 +1,173 @@
ares_components(arm7tdmi armv6m m24c mos6502)
ares_add_sources(
CORE #
a26
UNITY #
a26.cpp
PRIMARY #
system/system.cpp
controller/controller.cpp
cartridge/cartridge.cpp
cpu/cpu.cpp
elf/elf.cpp
harmony/harmony.cpp
video/video.cpp
tia/tia.cpp
riot/riot.cpp
)
ares_add_sources(
CORE #
a26
INCLUDED #
a26.hpp
persistent-memory.hpp
CMakeLists.txt
)
ares_add_sources(
CORE #
a26
INCLUDED #
cartridge/cartridge.hpp
cartridge/serialization.cpp
cartridge/slot.cpp
cartridge/slot.hpp
cartridge/board/atari16k.cpp
cartridge/board/atari32k.cpp
cartridge/board/atari8k.cpp
cartridge/board/board.cpp
cartridge/board/board.hpp
cartridge/board/commavid.cpp
cartridge/board/cdf.cpp
cartridge/board/bus.cpp
cartridge/board/chetiry.cpp
cartridge/board/fa2.cpp
cartridge/board/dpc-plus.cpp
cartridge/board/elf.cpp
cartridge/board/linear.cpp
cartridge/board/movie-cart.cpp
cartridge/board/parker-bros.cpp
cartridge/board/tigervision.cpp
)
ares_add_sources(
CORE #
a26
INCLUDED #
movie-cart/format.hpp
)
ares_add_sources(
CORE #
a26
INCLUDED #
elf/elf.hpp
elf/queue.cpp
elf/parser.cpp
elf/linker.cpp
elf/memory.cpp
elf/vcslib.cpp
elf/runtime.cpp
)
ares_add_sources(
CORE #
a26
INCLUDED #
harmony/harmony.hpp
harmony/memory.cpp
harmony/serialization.cpp
harmony/timing.cpp
)
ares_add_sources(
CORE #
a26
INCLUDED #
controller/controller.hpp
controller/port.cpp
controller/port.hpp
controller/gamepad/gamepad.cpp
controller/gamepad/gamepad.hpp
controller/booster-grip/booster-grip.cpp
controller/booster-grip/booster-grip.hpp
controller/sega-genesis/sega-genesis.cpp
controller/sega-genesis/sega-genesis.hpp
controller/joy2b-plus/joy2b-plus.cpp
controller/joy2b-plus/joy2b-plus.hpp
controller/savekey/savekey.cpp
controller/savekey/savekey.hpp
controller/atarivox/atarivox.cpp
controller/atarivox/atarivox.hpp
controller/atarivox/speakjet.cpp
controller/atarivox/speakjet.hpp
controller/kidvid/audio.cpp
controller/kidvid/audio.hpp
controller/kidvid/kidvid.cpp
controller/kidvid/kidvid.hpp
controller/kidvid/tables.hpp
controller/quadtari/quadtari.cpp
controller/quadtari/quadtari.hpp
)
ares_add_sources(
CORE #
a26
INCLUDED #
cpu/cpu.hpp
cpu/debugger.cpp
cpu/memory.cpp
cpu/serialization.cpp
cpu/timing.cpp
)
ares_add_sources(
CORE #
a26
INCLUDED #
riot/io.cpp
riot/riot.hpp
riot/serialization.cpp
)
ares_add_sources(
CORE #
a26
INCLUDED #
system/controls.cpp
system/serialization.cpp
system/system.hpp
)
ares_add_sources(
CORE #
a26
INCLUDED #
video/color.cpp
video/receiver.cpp
video/serialization.cpp
video/video.hpp
)
ares_add_sources(
CORE #
a26
INCLUDED #
tia/audio.cpp
tia/analog.cpp
tia/ball.cpp
tia/collision.cpp
tia/io.cpp
tia/missile.cpp
tia/objects.cpp
tia/player.cpp
tia/playfield.cpp
tia/priority.cpp
tia/serialization.cpp
tia/timing.cpp
tia/tia.hpp
tia/trigger.cpp
tia/write-queue.cpp
)
-15
View File
@@ -1,15 +0,0 @@
ares.components += mos6502
ares.objects += ares-a26-system
ares.objects += ares-a26-controller
ares.objects += ares-a26-cartridge
ares.objects += ares-a26-cpu
ares.objects += ares-a26-tia
ares.objects += ares-a26-riot
$(object.path)/ares-a26-system.o: $(ares.path)/a26/system/system.cpp
$(object.path)/ares-a26-controller.o: $(ares.path)/a26/controller/controller.cpp
$(object.path)/ares-a26-cartridge.o: $(ares.path)/a26/cartridge/cartridge.cpp
$(object.path)/ares-a26-cpu.o: $(ares.path)/a26/cpu/cpu.cpp
$(object.path)/ares-a26-tia.o: $(ares.path)/a26/tia/tia.cpp
$(object.path)/ares-a26-riot.o: $(ares.path)/a26/riot/riot.cpp
+9
View File
@@ -0,0 +1,9 @@
#include <a26/cartridge/cartridge.cpp>
#include <a26/controller/controller.cpp>
#include <a26/cpu/cpu.cpp>
#include <a26/elf/elf.cpp>
#include <a26/harmony/harmony.cpp>
#include <a26/video/video.cpp>
#include <a26/riot/riot.cpp>
#include <a26/system/system.cpp>
#include <a26/tia/tia.cpp>
+11 -2
View File
@@ -1,12 +1,17 @@
#pragma once
#include <ares/ares.hpp>
#include <array>
#include <vector>
#include <component/processor/mos6502/mos6502.hpp>
#include <component/processor/arm7tdmi/arm7tdmi.hpp>
#include <component/processor/armv6m/armv6m.hpp>
#include <component/eeprom/m24c/m24c.hpp>
namespace ares::Atari2600 {
#include <ares/inline.hpp>
auto enumerate() -> vector<string>;
auto enumerate() -> std::vector<string>;
auto load(Node::System& node, string name) -> bool;
struct Region {
@@ -15,11 +20,15 @@ namespace ares::Atari2600 {
static inline auto SECAM() -> bool;
};
#include <a26/movie-cart/format.hpp>
#include <a26/persistent-memory.hpp>
#include <a26/controller/controller.hpp>
#include <a26/system/system.hpp>
#include <a26/elf/elf.hpp>
#include <a26/harmony/harmony.hpp>
#include <a26/cartridge/cartridge.hpp>
#include <a26/cpu/cpu.hpp>
#include <a26/video/video.hpp>
#include <a26/tia/tia.hpp>
#include <a26/riot/riot.hpp>
}
+48
View File
@@ -0,0 +1,48 @@
struct Activision8k : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n1 bank;
bool lastAccessWasFE;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto save() -> void override {
}
auto unload() -> void override {
}
auto read(n16 address, n8 data) -> n8 override {
if(address.bit(12)) data = rom.read((bank * 0x1000) + (address & 0xfff));
access(address, data);
return data;
}
auto write(n16 address, n8 data) -> n8 override {
access(address, data);
return data;
}
auto power(bool reset) -> void override {
bank = 0;
lastAccessWasFE = false;
}
auto serialize(serializer& s) -> void override {
s(bank);
s(lastAccessWasFE);
}
private:
auto access(n16 address, n8 data) -> void {
if(lastAccessWasFE) {
//Released 8 KiB FE cartridges ignore D7-D6 and invert D5 to select one of two banks.
bank = data.bit(5) ^ 1;
lastAccessWasFE = false;
return;
}
lastAccessWasFE = address == 0x01fe;
}
};
+47
View File
@@ -0,0 +1,47 @@
struct AmigaFC : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
u32 bankCount = 0;
u8 activeBank = 0;
u8 targetBank = 0;
auto load() -> void override {
if(!Interface::load(rom, "program.rom")) return;
bankCount = rom.size() / 4_KiB;
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(address == 0x1ffc) activeBank = targetBank % bankCount;
if(address.bit(12)) return rom.read(activeBank * 0x1000 + (address & 0xfff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(address == 0x1ff8) {
targetBank = data & 3;
} else if(address == 0x1ff9) {
auto highBank = (u32)data << 2;
if(highBank < bankCount) {
targetBank += highBank;
targetBank %= bankCount;
} else {
targetBank = data % bankCount;
}
} else if(address == 0x1ffc) {
activeBank = targetBank % bankCount;
}
return data;
}
auto power(bool reset) -> void override {
activeBank = 0;
targetBank = 0;
}
auto serialize(serializer& s) -> void override {
s(activeBank);
s(targetBank);
}
};
@@ -0,0 +1,30 @@
struct Atari32In1 : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n5 game;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
if(address.bit(12)) return rom.read(game * 0x800 + (address & 0x07ff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
return data;
}
auto power(bool reset) -> void override {
//MAME's verified software-list contract cycles 32 2 KiB games on machine reset.
//Stella instead presents the same image as frontend-selected slices; no PCB or schematic
//presently proves the physical counter or latch behavior.
if(reset) game++;
else game = 0;
}
auto serialize(serializer& s) -> void override {
s(game);
}
};
+11 -19
View File
@@ -1,9 +1,8 @@
struct Atari16k : Interface {
using Interface::Interface;
Atari16k(Cartridge& cartridge, bool hasSaraRam = false) : Interface(cartridge), saraRam(hasSaraRam) {}
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
SaraRam saraRam;
n2 bank;
bool hasRam;
auto load() -> void override {
Interface::load(rom, "program.rom");
@@ -15,44 +14,37 @@ struct Atari16k : Interface {
auto unload() -> void override {
}
auto read(n16 address) -> n8 override {
auto read(n16 address, n8 data) -> n8 override {
if(address == 0x1ff6) bank = 0;
if(address == 0x1ff7) bank = 1;
if(address == 0x1ff8) bank = 2;
if(address == 0x1ff9) bank = 3;
if(address.bit(12)) {
if(hasRam && address >= 0x1080 && address <= 0x10ff) return ram.read(address & 0x7f);
if(saraRam.readable(address)) return saraRam.read(address, data);
return rom.read((bank * 0x1000) + (address & 0xfff));
}
return 0xff;
return data;
}
auto write(n16 address, n8 data) -> bool override {
auto write(n16 address, n8 data) -> n8 override {
if(address == 0x1ff6) bank = 0;
if(address == 0x1ff7) bank = 1;
if(address == 0x1ff8) bank = 2;
if(address == 0x1ff9) bank = 3;
if(address >= 0x1000 && address <= 0x107f) {
hasRam = true;
ram.write(address & 0x7f, data);
return true;
}
return false;
saraRam.write(address, data);
return data;
}
auto power() -> void override {
auto power(bool reset) -> void override {
bank = 0;
hasRam = 0;
ram.allocate(128);
saraRam.power();
}
auto serialize(serializer& s) -> void override {
s(bank);
s(hasRam);
s(ram);
saraRam.serialize(s);
}
};
+11 -19
View File
@@ -1,9 +1,8 @@
struct Atari32k : Interface {
using Interface::Interface;
Atari32k(Cartridge& cartridge, bool hasSaraRam = false) : Interface(cartridge), saraRam(hasSaraRam) {}
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
SaraRam saraRam;
n3 bank;
bool hasRam;
auto load() -> void override {
Interface::load(rom, "program.rom");
@@ -15,7 +14,7 @@ struct Atari32k : Interface {
auto unload() -> void override {
}
auto read(n16 address) -> n8 override {
auto read(n16 address, n8 data) -> n8 override {
if(address == 0x1ff4) bank = 0;
if(address == 0x1ff5) bank = 1;
if(address == 0x1ff6) bank = 2;
@@ -26,14 +25,14 @@ struct Atari32k : Interface {
if(address == 0x1ffb) bank = 7;
if(address.bit(12)) {
if(hasRam && address >= 0x1080 && address <= 0x10ff) return ram.read(address & 0x7f);
if(saraRam.readable(address)) return saraRam.read(address, data);
return rom.read((bank * 0x1000) + (address & 0xfff));
}
return 0xff;
return data;
}
auto write(n16 address, n8 data) -> bool override {
auto write(n16 address, n8 data) -> n8 override {
if(address == 0x1ff4) bank = 0;
if(address == 0x1ff5) bank = 1;
if(address == 0x1ff6) bank = 2;
@@ -43,24 +42,17 @@ struct Atari32k : Interface {
if(address == 0x1ffa) bank = 6;
if(address == 0x1ffb) bank = 7;
if(address >= 0x1000 && address <= 0x107f) {
hasRam = true;
ram.write(address & 0x7f, data);
return true;
}
return false;
saraRam.write(address, data);
return data;
}
auto power() -> void override {
auto power(bool reset) -> void override {
bank = 0;
hasRam = 0;
ram.allocate(128);
saraRam.power();
}
auto serialize(serializer& s) -> void override {
s(bank);
s(hasRam);
s(ram);
saraRam.serialize(s);
}
};
+12 -20
View File
@@ -1,9 +1,8 @@
struct Atari8k : Interface {
using Interface::Interface;
Atari8k(Cartridge& cartridge, bool hasSaraRam = false) : Interface(cartridge), saraRam(hasSaraRam) {}
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
SaraRam saraRam;
n1 bank;
bool hasRam;
auto load() -> void override {
Interface::load(rom, "program.rom");
@@ -15,40 +14,33 @@ struct Atari8k : Interface {
auto unload() -> void override {
}
auto read(n16 address) -> n8 override {
auto read(n16 address, n8 data) -> n8 override {
if(address == 0x1ff8) bank = 0;
if(address == 0x1ff9) bank = 1;
if(address.bit(12)) {
if(hasRam && address >= 0x1080 && address <= 0x10ff) return ram.read(address & 0x7f);
if(saraRam.readable(address)) return saraRam.read(address, data);
return rom.read((bank * 0x1000) + (address & 0xfff));
}
return 0xff;
return data;
}
auto write(n16 address, n8 data) -> bool override {
auto write(n16 address, n8 data) -> n8 override {
if(address == 0x1ff8) bank = 0;
if(address == 0x1ff9) bank = 1;
if(address >= 0x1000 && address <= 0x107f) {
hasRam = true;
ram.write(address & 0x7f, data);
return true;
}
return false;
saraRam.write(address, data);
return data;
}
auto power() -> void override {
bank = 0;
hasRam = 0;
ram.allocate(128);
auto power(bool reset) -> void override {
bank = 1;
saraRam.power();
}
auto serialize(serializer& s) -> void override {
s(bank);
s(hasRam);
s(ram);
saraRam.serialize(s);
}
};
+64
View File
@@ -1,12 +1,45 @@
namespace Board {
#include "sara-ram.cpp"
#include "linear.cpp"
#include "activision.cpp"
#include "atari8k.cpp"
#include "atari16k.cpp"
#include "atari32k.cpp"
#include "commavid.cpp"
#include "parker-bros.cpp"
#include "parker-bros-03e0.cpp"
#include "jvp.cpp"
#include "tigervision.cpp"
#include "ua.cpp"
#include "cbs-ram-plus.cpp"
#include "m-network.cpp"
#include "amiga-fc.cpp"
#include "wickstead.cpp"
#include "jane.cpp"
#include "dpc.cpp"
#include "mega-boy.cpp"
#include "atari-32-in-1.cpp"
//Homebrew
#include "dpc-plus.cpp"
#include "cdf.cpp"
#include "bus.cpp"
#include "chetiry.cpp"
#include "fa2.cpp"
#include "elf.cpp"
#include "movie-cart.cpp"
#include "cpuwiz-4ksc.cpp"
#include "three-e.cpp"
#include "three-ex.cpp"
#include "three-e-plus.cpp"
#include "enhanced-3f.cpp"
#include "four-a50.cpp"
#include "ef.cpp"
#include "mdm.cpp"
#include "x07.cpp"
#include "econo-banking.cpp"
#include "superbanking.cpp"
auto Interface::load(Memory::Readable<n8>& memory, string name) -> bool {
if(auto fp = pak->read(name)) {
@@ -34,4 +67,35 @@ auto Interface::save(Memory::Writable<n8>& memory, string name) -> bool {
return false;
}
auto Interface::readARMMemory(Memory::Readable<n8>& rom, Memory::Writable<n8>& ram,
u32 mode, n32 address, u32 romBase, u32 ramLimit, n32& data) -> Harmony::Access {
u32 size = mode & ARM7TDMI::Byte ? 1 : mode & ARM7TDMI::Half ? 2 : 4;
u32 location = address;
auto read = [&](auto& memory, u32 offset) -> Harmony::Access {
if(offset > memory.size() || size > memory.size() - offset) return Harmony::Access::Fault;
data = 0;
for(u32 byte : range(size)) data |= memory.read(offset + byte) << byte * 8;
return Harmony::Access::Granted;
};
if(location >= romBase && location < rom.size()) return read(rom, location);
if(location >= 0x40000000 && location - 0x40000000 < ramLimit) {
return read(ram, location - 0x40000000);
}
return Harmony::Access::Unmapped;
}
auto Interface::writeARMMemory(Memory::Writable<n8>& ram, u32 mode, n32 address,
u32 ramLimit, n32 data) -> Harmony::Access {
u32 size = mode & ARM7TDMI::Byte ? 1 : mode & ARM7TDMI::Half ? 2 : 4;
u32 location = address;
if(location < 0x40000000 || location - 0x40000000 >= ramLimit) return Harmony::Access::Unmapped;
auto offset = location - 0x40000000;
if(offset > ram.size() || size > ram.size() - offset || size > ramLimit - offset) {
return Harmony::Access::Fault;
}
for(u32 byte : range(size)) ram.write(offset + byte, data >> byte * 8);
return Harmony::Access::Granted;
}
}
+18 -3
View File
@@ -8,15 +8,30 @@ struct Interface {
virtual auto load() -> void {}
virtual auto save() -> void {}
virtual auto unload() -> void {}
virtual auto read(n16 address) -> n8 { return 0xff; }
virtual auto write(n16 address, n8 data) -> bool { return false; }
virtual auto power() -> void {}
virtual auto read(n16 address, n8 data) -> n8 { return data; }
virtual auto write(n16 address, n8 data) -> n8 { return data; }
virtual auto power(bool reset) -> void {}
virtual auto serialize(serializer&) -> void {}
virtual auto armInvocation() const -> Harmony::Invocation { return {}; }
virtual auto readARM(u32 mode, n32 address, n32& data) -> Harmony::Access {
return Harmony::Access::Unmapped;
}
virtual auto writeARM(u32 mode, n32 address, n32 data) -> Harmony::Access {
return Harmony::Access::Unmapped;
}
virtual auto trapARM(u32 address, n32& value, n32 argument) -> bool { return false; }
virtual auto stepARM(u32 clocks) -> void {}
auto load(Memory::Readable<n8>&, string name) -> bool;
auto load(Memory::Writable<n8>&, string name) -> bool;
auto save(Memory::Writable<n8>&, string name) -> bool;
auto readARMMemory(Memory::Readable<n8>& rom, Memory::Writable<n8>& ram,
u32 mode, n32 address, u32 romBase, u32 ramLimit, n32& data) -> Harmony::Access;
auto writeARMMemory(Memory::Writable<n8>& ram, u32 mode, n32 address,
u32 ramLimit, n32 data) -> Harmony::Access;
Cartridge& cartridge;
};
+354
View File
@@ -0,0 +1,354 @@
struct BUS : Interface {
using Interface::Interface;
enum class Revision : u32 { BUS0, BUS1, BUS2, BUS3 };
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
Revision revision = Revision::BUS0;
n3 bank;
n8 mode;
n2 fastJumpActive;
n16 styOperand;
n16 busOverdriveAddress;
n16 jumpOperand;
n32 musicCounter[3];
n32 musicFrequency[3];
n8 waveformShift[3];
u16 datastreamBase = 0;
u16 incrementBase = 0;
u16 mapBase = 0;
u16 waveformBase = 0;
u32 audioPhase = 0;
static constexpr u8 CommunicationStream = 0x10;
static constexpr u8 JumpStream = 0x11;
template<typename MemoryType>
auto read32(u32 address, const MemoryType& memory) const -> u32 {
if(address + 3 >= memory.size()) return 0;
return memory.read(address + 0) << 0 | memory.read(address + 1) << 8
| memory.read(address + 2) << 16 | memory.read(address + 3) << 24;
}
auto write32(u32 address, u32 data) -> void {
if(address + 3 >= ram.size()) return;
for(u32 byte : range(4)) ram.write(address + byte, data >> byte * 8);
}
auto scan(u32 value) const -> u32 {
for(u32 offset = 0; offset + 3 < min<u32>(rom.size(), 3_KiB); offset += 4) {
if(read32(offset, rom) == value) return offset;
}
return ~0u;
}
auto detectRevision() -> void {
auto signature = scan(0x00535542);
if(signature == 0x07f4) revision = Revision::BUS1;
else if(signature == 0x0778) revision = Revision::BUS2;
else if(signature == 0x0770) revision = Revision::BUS3;
else revision = Revision::BUS0;
if(revision == Revision::BUS0) {
datastreamBase = 0x0ae0;
incrementBase = 0x0b20;
mapBase = 0x0b64;
waveformBase = 0;
} else {
datastreamBase = revision == Revision::BUS3 ? 0x06d8 : 0x06e0;
incrementBase = 0x0720;
mapBase = 0x0760;
waveformBase = 0x07f4;
}
}
auto load() -> void override {
Interface::load(rom, "program.rom");
detectRevision();
ram.allocate(8_KiB, 0x00);
harmony.load(cartridge.node);
}
auto unload() -> void override {
harmony.unload();
}
auto armInvocation() const -> Harmony::Invocation override {
if(revision == Revision::BUS0) return {.pc = 0x0c08, .lr = 0x0c00, .sp = 0x40001ffc};
return {.pc = 0x0808, .lr = 0x0800, .sp = 0x40001ffc};
}
auto readARM(u32 mode, n32 address, n32& data) -> Harmony::Access override {
auto romBase = mode & ARM7TDMI::Prefetch ? 0x50u : 0x0750u;
return readARMMemory(rom, ram, mode, address, romBase, min<u32>(8_KiB, ram.size()), data);
}
auto writeARM(u32 mode, n32 address, n32 data) -> Harmony::Access override {
u32 location = address;
if(location >= 0x40000000 && location - 0x40000000 < min<u32>(8_KiB, ram.size())) {
auto offset = location - 0x40000000;
if(offset > 0x28 && offset < 0x06d8) return Harmony::Access::Fault;
}
return writeARMMemory(ram, mode, address, min<u32>(8_KiB, ram.size()), data);
}
auto trapARM(u32 address, n32& voice, n32 value) -> bool override {
constexpr u32 base = 0x06da;
if(address < base || address > base + 12 || (address - base) % 4) return false;
if(voice >= 3) {
if(address == base + 8) voice = 0;
return true;
}
if(address == base + 0) musicFrequency[voice] = value;
if(address == base + 4) musicCounter[voice] = 0;
if(address == base + 8) voice = musicCounter[voice];
if(address == base + 12) waveformShift[voice] = min<u32>(value, 31);
return true;
}
auto stepARM(u32 clocks) -> void override {
stepAudio(clocks);
}
auto programBase() const -> u32 {
return revision == Revision::BUS0 ? 3_KiB : 4_KiB;
}
auto displayBase() const -> u32 {
return revision == Revision::BUS0 ? 3_KiB : 2_KiB;
}
auto program(u32 address) const -> n8 {
auto offset = programBase() + u32{bank} * 4_KiB + (address & 0x0fff);
if(offset < rom.size()) return rom.read(offset);
return 0;
}
auto displayRead(u32 address) const -> u8 {
if(displayBase() + address < ram.size()) return ram.read(displayBase() + address);
return 0;
}
auto displayWrite(u32 address, u8 data) -> void {
if(displayBase() + address < ram.size()) ram.write(displayBase() + address, data);
}
auto streamPointer(u8 index) const -> u32 {
return read32(datastreamBase + index * 4, ram);
}
auto setStreamPointer(u8 index, u32 value) -> void {
write32(datastreamBase + index * 4, value);
}
auto streamIncrement(u8 index) const -> u32 {
return read32(incrementBase + index * 4, ram);
}
auto setStreamIncrement(u8 index, u32 value) -> void {
write32(incrementBase + index * 4, value);
}
auto addressMap(u8 index) const -> u32 {
return read32(mapBase + index * 4, ram);
}
auto setAddressMap(u8 index, u32 value) -> void {
write32(mapBase + index * 4, value);
}
auto nextStreamByte(u8 index) -> u8 {
auto pointer = streamPointer(index);
auto result = displayRead(pointer >> 20);
pointer += streamIncrement(index) << 12;
setStreamPointer(index, pointer);
return result;
}
auto stepAudio(u32 clocks) -> void {
audioPhase += clocks;
auto ticks = audioPhase / 3500;
audioPhase %= 3500;
for(u32 voice : range(3)) musicCounter[voice] += u32{musicFrequency[voice]} * ticks;
}
auto waveform(u32 voice) const -> u32 {
auto address = read32(waveformBase + voice * 4, ram);
if(address < 0x40000800) return 0;
address -= 0x40000800;
return address < 4_KiB ? address : 0;
}
auto amplitude() -> u8 {
if((mode & 0xf0) == 0) {
auto address = read32(waveformBase, ram) + (u32{musicCounter[0]} >> 21);
u8 sample = 0;
if(address < rom.size()) sample = rom.read(address);
else if(address >= 0x40000000 && address - 0x40000000 < ram.size()) {
sample = ram.read(address - 0x40000000);
}
if(!(u32{musicCounter[0]} & 1 << 20)) sample >>= 4;
return sample & 15;
}
u32 result = 0;
for(u32 voice : range(3)) {
result += displayRead(waveform(voice) + (u32{musicCounter[voice]} >> waveformShift[voice]));
}
return result;
}
auto switchBank(u32 address) -> void {
if(revision == Revision::BUS0) {
if(address >= 0x0ff6 && address <= 0x0ffb) bank = address - 0x0ff6;
return;
}
if(address >= 0x0ff5 && address <= 0x0ffb) bank = address - 0x0ff5;
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
u32 offset = address & 0x0fff;
u8 value = program(offset);
if(revision == Revision::BUS3) {
if(fastJumpActive && jumpOperand == offset) {
fastJumpActive--;
jumpOperand++;
auto pointer = streamPointer(JumpStream);
auto result = displayRead(pointer >> 20);
setStreamPointer(JumpStream, pointer + 0x00100000);
return result;
}
if((mode & 15) == 0 && value == 0x4c && offset <= 0x0ffd
&& program(offset + 1) == 0 && program(offset + 2) == 0) {
fastJumpActive = 2;
jumpOperand = offset + 1;
return value;
}
jumpOperand = 0;
}
if((mode & 15) == 0 && styOperand == offset) busOverdriveAddress = value;
styOperand = 0;
if(revision == Revision::BUS0 && offset < 0x10) return nextStreamByte(offset);
if((revision == Revision::BUS1 || revision == Revision::BUS2) && offset < 0x20) {
if(offset < 0x10) return nextStreamByte(offset);
if(offset == 0x18) return amplitude();
return 0;
}
if(revision == Revision::BUS3 && offset >= 0x0fee && offset <= 0x0ff3) {
if(offset == 0x0fee) return amplitude();
if(offset == 0x0fef) return nextStreamByte(CommunicationStream);
}
switchBank(offset);
if((mode & 15) == 0 && value == 0x84) styOperand = offset + 1;
return value;
}
auto writeBelowCartridge(n16 address, n8 data) -> n8 {
bool matches = address == busOverdriveAddress;
busOverdriveAddress = 0xff;
if(!matches) return data;
auto target = u8(address & 0x7f);
if(target > 0x24) return data;
auto mappings = addressMap(target);
auto stream = u8(mappings & 15);
auto stuffed = u8(data) & nextStreamByte(stream);
setAddressMap(target, mappings >> 4 | u32{stream} << 28);
return stuffed;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return writeBelowCartridge(address, data);
u32 offset = address & 0x0fff;
if(revision == Revision::BUS0) {
auto index = u8(offset & 15);
if(offset >= 0x10 && offset <= 0x13) {
auto pointer = streamPointer(index);
displayWrite(pointer >> 20, data);
setStreamPointer(index, pointer + 0x00100000);
}
if(offset == 0x1b && (data == 254 || data == 255)) harmony.call(data == 254);
if(offset == 0x1c) mode = data == 0 ? 0 : 0x0f;
if(offset >= 0x20 && offset <= 0x2f) {
auto pointer = streamPointer(index) << 8;
setStreamPointer(index, pointer & 0xf0000000 | u32{data} << 20);
}
if(offset >= 0x30 && offset <= 0x3f) setStreamIncrement(index, data);
switchBank(offset);
return data;
}
switchBank(offset);
if(revision == Revision::BUS3) {
if(offset == 0x0ff0) {
auto pointer = streamPointer(CommunicationStream);
displayWrite(pointer >> 20, data);
setStreamPointer(CommunicationStream, pointer + 0x00100000);
}
if(offset == 0x0ff1) {
auto pointer = streamPointer(CommunicationStream) << 8;
setStreamPointer(CommunicationStream, pointer & 0xf0000000 | u32{data} << 20);
}
if(offset == 0x0ff2) mode = data;
if(offset == 0x0ff3 && (data == 254 || data == 255)) harmony.call(data == 254);
return data;
}
if(offset >= 0x10 && offset <= 0x1f) {
auto index = u8(offset & 15);
if(index <= 3) {
auto pointer = streamPointer(index);
displayWrite(pointer >> 20, data);
setStreamPointer(index, pointer + 0x00100000);
}
if(index >= 4 && index <= 7) {
index &= 3;
auto pointer = streamPointer(index) << 8;
setStreamPointer(index, pointer & 0xf0000000 | u32{data} << 20);
}
if(index == 9) mode = data == 0 ? 0 : 0x0f;
if(index == 10 && (data == 254 || data == 255)) harmony.call(data == 254);
}
return data;
}
auto power(bool reset) -> void override {
ram.fill(0x00);
auto driverSize = revision == Revision::BUS0 ? 3_KiB : 2_KiB;
for(u32 offset : range(min<u32>(driverSize, rom.size()))) ram.write(offset, rom.read(offset));
bank = revision == Revision::BUS0 ? 5 : 6;
mode = 0xff;
fastJumpActive = 0;
styOperand = 0;
busOverdriveAddress = 0;
jumpOperand = 0;
for(auto& item : musicCounter) item = 0;
for(auto& item : musicFrequency) item = 0;
for(auto& item : waveformShift) item = 27;
audioPhase = 0;
harmony.power();
}
auto serialize(serializer& s) -> void override {
s(ram);
s(bank);
s(mode);
s(fastJumpActive);
s(styOperand);
s(busOverdriveAddress);
s(jumpOperand);
for(auto& item : musicCounter) s(item);
for(auto& item : musicFrequency) s(item);
for(auto& item : waveformShift) s(item);
s(audioPhase);
harmony.serialize(s);
}
};
+40
View File
@@ -0,0 +1,40 @@
struct CbsRamPlus : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
n2 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
if(address >= 0x1ff8 && address <= 0x1ffa) bank = address - 0x1ff8;
if(address >= 0x1000 && address <= 0x10ff) {
ram.write(address & 0xff, data);
return data;
}
if(address >= 0x1100 && address <= 0x11ff) return ram.read(address & 0xff);
if(address.bit(12)) return rom.read((bank * 0x1000) + (address & 0x0fff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
if(address >= 0x1ff8 && address <= 0x1ffa) bank = address - 0x1ff8;
if(address >= 0x1000 && address <= 0x10ff) {
ram.write(address & 0xff, data);
return data;
}
return data;
}
auto power(bool reset) -> void override {
bank = 2;
ram.allocate(256, 0x00);
}
auto serialize(serializer& s) -> void override {
s(bank);
s(ram);
}
};
+354
View File
@@ -0,0 +1,354 @@
struct CDF : Interface {
using Interface::Interface;
enum class Revision : u32 { CDF0, CDF1, CDFJ, CDFJPlus };
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
Revision revision = Revision::CDF0;
n3 bank;
n8 mode;
n2 fastJumpActive;
n6 fastJumpStream;
n16 immediateOperand;
n16 jumpOperand;
n32 musicCounter[3];
n32 musicFrequency[3];
n8 waveformShift[3];
u16 datastreamBase = 0;
u16 incrementBase = 0;
u16 waveformBase = 0;
u16 fastFetcherOffset = 0;
u8 amplitudeStream = 0;
u8 fastJumpMask = 0;
bool ldxEnabled = false;
bool ldyEnabled = false;
u32 audioPhase = 0;
static constexpr u8 CommunicationStream = 0x20;
static constexpr u8 JumpStreamBase = 0x21;
static constexpr u16 NoImmediate = 0xffff;
template<typename MemoryType>
auto read32(u32 address, const MemoryType& memory) const -> u32 {
if(address + 3 >= memory.size()) return 0;
return memory.read(address + 0) << 0 | memory.read(address + 1) << 8
| memory.read(address + 2) << 16 | memory.read(address + 3) << 24;
}
auto write32(u32 address, u32 data) -> void {
if(address + 3 >= ram.size()) return;
for(u32 byte : range(4)) ram.write(address + byte, data >> byte * 8);
}
auto scan(u32 value) const -> u32 {
if(rom.size() < 2_KiB) return ~0u;
for(u32 offset = 0; offset < 2_KiB; offset += 4) {
if(read32(offset, rom) == value) return offset;
}
return ~0u;
}
auto detectRevision() -> void {
auto plusSignature = scan(0x53554c50);
if(plusSignature != ~0u && read32(plusSignature + 4, rom) == 0x4a464443
&& read32(plusSignature + 8, rom) == 1) {
revision = Revision::CDFJPlus;
amplitudeStream = 0x23;
fastJumpMask = 0xfe;
datastreamBase = 0x0098;
incrementBase = 0x0124;
waveformBase = 0x01b0;
for(u32 offset = 0; offset < 2_KiB; offset += 4) {
auto word = read32(offset, rom);
if(word == 0x135200a2) ldxEnabled = true;
if(word == 0x135200a0) ldyEnabled = true;
if((word & 0xffffff00) == 0xe2422000) fastFetcherOffset = offset;
}
return;
}
u8 subversion = 0;
for(u32 offset = 0; offset + 11 < min<u32>(rom.size(), 2_KiB); offset += 4) {
if(rom.read(offset + 0) == 'C' && rom.read(offset + 1) == 'D' && rom.read(offset + 2) == 'F'
&& rom.read(offset + 4) == 'C' && rom.read(offset + 5) == 'D' && rom.read(offset + 6) == 'F'
&& rom.read(offset + 8) == 'C' && rom.read(offset + 9) == 'D' && rom.read(offset + 10) == 'F') {
subversion = rom.read(offset + 3);
break;
}
}
if(subversion == 0x4a) {
revision = Revision::CDFJ;
amplitudeStream = 0x23;
fastJumpMask = 0xfe;
datastreamBase = 0x0098;
incrementBase = 0x0124;
waveformBase = 0x01b0;
} else if(subversion == 0) {
revision = Revision::CDF0;
amplitudeStream = 0x22;
fastJumpMask = 0xff;
datastreamBase = 0x06e0;
incrementBase = 0x0768;
waveformBase = 0x07f0;
} else {
revision = Revision::CDF1;
amplitudeStream = 0x22;
fastJumpMask = 0xff;
datastreamBase = 0x00a0;
incrementBase = 0x0128;
waveformBase = 0x01b0;
}
}
auto isPlus() const -> bool {
return revision == Revision::CDFJPlus;
}
auto load() -> void override {
Interface::load(rom, "program.rom");
detectRevision();
ram.allocate(isPlus() ? 32_KiB : 8_KiB, 0x00);
harmony.load(cartridge.node);
}
auto unload() -> void override {
harmony.unload();
}
auto armInvocation() const -> Harmony::Invocation override {
if(isPlus()) {
auto address = read32(0x17f8, rom) & ~1u;
return {.pc = address, .lr = address, .sp = read32(0x17f4, rom)};
}
return {.pc = 0x0808, .lr = 0x0800, .sp = 0x40001ffc};
}
auto armRamLimit() const -> u32 {
if(!isPlus()) return min<u32>(8_KiB, ram.size());
if(rom.size() == 64_KiB || rom.size() == 128_KiB) return min<u32>(16_KiB, ram.size());
if(rom.size() == 256_KiB || rom.size() == 512_KiB) return min<u32>(32_KiB, ram.size());
return min<u32>(8_KiB, ram.size());
}
auto readARM(u32 mode, n32 address, n32& data) -> Harmony::Access override {
auto romBase = mode & ARM7TDMI::Prefetch ? 0x50u : 0x0750u;
return readARMMemory(rom, ram, mode, address, romBase, armRamLimit(), data);
}
auto writeProtectedARM(u32 offset) const -> bool {
if(revision == Revision::CDF0) {
return offset > 0x28 && offset < 0x0800 && !(offset >= 0x06e0 && offset < 0x07fc);
}
if(revision == Revision::CDF1) {
return offset > 0x28 && offset < 0x0800 && !(offset >= 0x00a0 && offset < 0x01bc);
}
return offset > 0x28 && offset < 0x0800 && !(offset >= 0x0098 && offset < 0x01bc)
&& !(isPlus() && offset == 0x03e0);
}
auto writeARM(u32 mode, n32 address, n32 data) -> Harmony::Access override {
u32 location = address;
if(location >= 0x40000000 && location - 0x40000000 < armRamLimit()) {
if(writeProtectedARM(location - 0x40000000)) return Harmony::Access::Fault;
}
return writeARMMemory(ram, mode, address, armRamLimit(), data);
}
auto trapARM(u32 address, n32& voice, n32 value) -> bool override {
u32 base = revision == Revision::CDF0 ? 0x06e2 : 0x0752;
if(address < base || address > base + 12 || (address - base) % 4) return false;
if(voice >= 3) {
if(address == base + 8) voice = 0;
return true;
}
if(address == base + 0) musicFrequency[voice] = value;
if(address == base + 4) musicCounter[voice] = 0;
if(address == base + 8) voice = musicCounter[voice];
if(address == base + 12) waveformShift[voice] = min<u32>(value, 31);
return true;
}
auto stepARM(u32 clocks) -> void override {
stepAudio(clocks);
}
auto programBase() const -> u32 {
return isPlus() ? 2_KiB : 4_KiB;
}
auto program(u32 address) const -> n8 {
u32 offset = programBase() + u32{bank} * 4_KiB + (address & 0x0fff);
if(offset < rom.size()) return rom.read(offset);
return 0;
}
auto displaySize() const -> u32 {
return ram.size() > 2_KiB ? ram.size() - 2_KiB : 0;
}
auto displayRead(u32 address) const -> u8 {
if(address < displaySize()) return ram.read(2_KiB + address);
return 0;
}
auto displayWrite(u32 address, u8 data) -> void {
if(address < displaySize()) ram.write(2_KiB + address, data);
}
auto streamPointer(u8 index) const -> u32 {
return read32(datastreamBase + index * 4, ram);
}
auto setStreamPointer(u8 index, u32 value) -> void {
write32(datastreamBase + index * 4, value);
}
auto streamIncrement(u8 index) const -> u32 {
return read32(incrementBase + index * 4, ram);
}
auto nextStreamByte(u8 index) -> u8 {
if(index > amplitudeStream) return 0;
auto pointer = streamPointer(index);
u32 location = isPlus() ? pointer >> 16 : pointer >> 20;
auto data = displayRead(location);
pointer += streamIncrement(index) << (isPlus() ? 8 : 12);
setStreamPointer(index, pointer);
return data;
}
auto waveform(u32 voice) const -> u32 {
u32 address = read32(waveformBase + voice * 4, ram);
address -= 0x40000800;
if(!isPlus() && address >= 4_KiB) address &= 0x0fff;
if(isPlus() && address >= displaySize()) return 0;
return address;
}
auto stepAudio(u32 clocks) -> void {
audioPhase += clocks;
auto ticks = audioPhase / 3500;
audioPhase %= 3500;
for(u32 voice : range(3)) musicCounter[voice] += u32{musicFrequency[voice]} * ticks;
}
auto audioValue() -> u8 {
if((mode & 0xf0) == 0) {
u32 address = read32(waveformBase, ram) + (u32{musicCounter[0]} >> (isPlus() ? 13 : 21));
u8 sample = 0;
if(address < rom.size()) sample = rom.read(address);
else if(address >= 0x40000000 && address - 0x40000000 < ram.size()) sample = ram.read(address - 0x40000000);
if(!(u32{musicCounter[0]} & 1 << (isPlus() ? 12 : 20))) sample >>= 4;
return sample & 15;
}
u32 result = 0;
for(u32 voice : range(3)) {
auto location = waveform(voice) + (u32{musicCounter[voice]} >> waveformShift[voice]);
result += displayRead(location);
}
return result;
}
auto switchBank(u32 address) -> void {
if(address < 0x0ff4 || address > 0x0ffb) return;
if(isPlus()) bank = address == 0x0ffb ? 0 : address - 0x0ff4;
else bank = address == 0x0ff4 || address == 0x0ffb ? 6 : address - 0x0ff5;
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
u32 offset = address & 0x0fff;
u8 value = program(offset);
if(fastJumpActive && jumpOperand == offset) {
fastJumpActive--;
jumpOperand++;
auto pointer = streamPointer(fastJumpStream);
auto result = displayRead(isPlus() ? pointer >> 16 : pointer >> 20);
pointer += isPlus() ? 0x00010000 : 0x00100000;
setStreamPointer(fastJumpStream, pointer);
return result;
}
if((mode & 15) == 0 && value == 0x4c && offset <= 0x0ffd
&& !(program(offset + 1) & fastJumpMask) && program(offset + 2) == 0) {
fastJumpActive = 2;
jumpOperand = offset + 1;
fastJumpStream = program(offset + 1) + JumpStreamBase;
return value;
}
jumpOperand = 0;
bool fastFetch = false;
if((mode & 15) == 0 && immediateOperand == offset) {
u8 base = 0;
if(fastFetcherOffset && fastFetcherOffset < ram.size()) base = ram.read(fastFetcherOffset);
fastFetch = value >= base && u32{value} <= u32{base} + amplitudeStream;
if(fastFetch && fastFetcherOffset) value -= base;
}
immediateOperand = NoImmediate;
if(fastFetch) return value == amplitudeStream ? audioValue() : nextStreamByte(value);
switchBank(offset);
if((mode & 15) == 0 && (value == 0xa9 || (ldxEnabled && value == 0xa2) || (ldyEnabled && value == 0xa0))) {
immediateOperand = offset + 1;
}
return value;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
u32 offset = address & 0x0fff;
if(offset == 0x0ff0) {
auto pointer = streamPointer(CommunicationStream);
displayWrite(isPlus() ? pointer >> 16 : pointer >> 20, data);
setStreamPointer(CommunicationStream, pointer + (isPlus() ? 0x00010000 : 0x00100000));
}
if(offset == 0x0ff1) {
auto pointer = streamPointer(CommunicationStream) << 8;
pointer = isPlus() ? (pointer & 0xff000000) | u32{data} << 16
: (pointer & 0xf0000000) | u32{data} << 20;
setStreamPointer(CommunicationStream, pointer);
}
if(offset == 0x0ff2) mode = data;
if(offset == 0x0ff3 && (data == 254 || data == 255)) harmony.call(data == 254);
switchBank(offset);
return data;
}
auto power(bool reset) -> void override {
ram.fill(0x00);
for(u32 offset : range(min<u32>(2_KiB, rom.size()))) ram.write(offset, rom.read(offset));
bank = isPlus() ? 0 : 6;
mode = 0xff;
fastJumpActive = 0;
fastJumpStream = 0;
immediateOperand = NoImmediate;
jumpOperand = 0;
for(auto& item : musicCounter) item = 0;
for(auto& item : musicFrequency) item = 0;
for(auto& item : waveformShift) item = 27;
audioPhase = 0;
harmony.power();
}
auto serialize(serializer& s) -> void override {
s(ram);
s(bank);
s(mode);
s(fastJumpActive);
s(fastJumpStream);
s(immediateOperand);
s(jumpOperand);
for(auto& item : musicCounter) s(item);
for(auto& item : musicFrequency) s(item);
for(auto& item : waveformShift) s(item);
s(audioPhase);
harmony.serialize(s);
}
};
+212
View File
@@ -0,0 +1,212 @@
struct Chetiry : Interface, Thread {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Readable<n8> tunes;
Memory::Writable<n8> ram;
PersistentMemory persistent;
n3 bank;
n8 operation;
n16 tunePosition;
n1 ldaImmediate;
n32 random = 0x2b435044;
n32 musicCounter[3];
n32 musicFrequency[3];
n15 busyTicks;
n1 operationCompleted;
n1 operationSucceeded;
n3 tune;
auto load() -> void override {
Memory::Readable<n8> image;
Interface::load(image, "program.rom");
rom.allocate(32_KiB, 0x00);
for(u32 offset : range(min<u32>(image.size(), 32_KiB))) rom.program(offset, image.read(offset));
tunes.allocate(28_KiB, 0x00);
if(image.size() > 32_KiB) {
for(u32 offset : range(min<u32>(image.size() - 32_KiB, 28_KiB))) {
tunes.program(offset, image.read(32_KiB + offset));
}
}
persistent.load(pak, "save.eeprom", 256, 0x00);
}
auto save() -> void override {
persistent.flush(pak);
}
auto unload() -> void override {
persistent.flush(pak);
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
auto value = rom.read(bank * 4_KiB + (address & 0x0fff));
if(ldaImmediate && value == 0xf2) {
ldaImmediate = 0;
return (musicCounter[0] >> 31) + (musicCounter[1] >> 31) + (musicCounter[2] >> 31) << 2;
}
ldaImmediate = 0;
if(address <= 0x103f) {
ram.write(address & 0x3f, data);
return data;
}
if(address <= 0x107f) return readRAM(address & 0x3f);
if(address == 0x1ff4) return operate(value);
bankswitch(address);
ldaImmediate = value == 0xa9;
return value;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
if(address <= 0x103f) {
writeRAM(address & 0x3f, data);
return data;
}
if(address == 0x1ff4) {
operate(rom.read(bank * 4_KiB + 0x0ff4));
return data;
}
bankswitch(address);
return data;
}
auto main() -> void {
for(u32 channel : range(3)) musicCounter[channel] += musicFrequency[channel];
if(busyTicks && !--busyTicks) {
operationCompleted = 1;
ram.write(0, operationSucceeded ? 0x00 : 0xff);
}
step(1);
Thread::synchronize(cpu);
}
auto power(bool reset) -> void override {
Thread::create(20'000, std::bind_front(&Chetiry::main, this));
bank = 1;
operation = 0;
tunePosition = 0;
ldaImmediate = 0;
random = 0x2b435044;
busyTicks = 0;
operationCompleted = 0;
operationSucceeded = 0;
tune = 0;
for(auto& counter : musicCounter) counter = 0;
for(auto& frequency : musicFrequency) frequency = 0;
ram.allocate(64, 0x00);
for(u32 offset : range(4)) ram.write(offset, 0xff);
}
auto serialize(serializer& s) -> void override {
Thread::serialize(s);
s(bank);
s(operation);
s(tunePosition);
s(ldaImmediate);
s(random);
s(musicCounter);
s(musicFrequency);
s(busyTicks);
s(operationCompleted);
s(operationSucceeded);
s(tune);
s(ram);
}
private:
static auto noteFrequency(u32 note) -> u32 {
static constexpr u32 table[63] = {
0, 0, 0, 11811160, 12513387, 13257490, 14045832, 14881203, 15765966,
16703557, 17696768, 18749035, 19864009, 21045125, 22296464, 23622320,
25026989, 26515195, 28091878, 29762191, 31531932, 33406900, 35393537,
37498071, 39727803, 42090250, 44592927, 47244640, 50053978, 53030391,
56183756, 59524596, 63064079, 66814014, 70787074, 74996142, 79455606,
84180285, 89186069, 94489281, 100107957, 106060567, 112367297,
119048977, 126128157, 133628029, 141573933, 149992288, 158911428,
168360785, 178371925, 188978561, 200215913, 212121348, 224734593,
238098169, 252256099, 267256058, 283147866, 299984783, 317822855,
336721571, 356744064,
};
return note < 63 ? table[note] : 0;
}
auto bankswitch(n16 address) -> void {
if(address >= 0x1ff5 && address <= 0x1ffb) bank = address - 0x1ff4;
}
auto readRAM(u32 address) -> n8 {
if(address == 0) return ram.read(0);
if(address == 1) {
random = (random.bit(10) ? 0x10adab1e : 0) ^ (u32{random} >> 11 | u32{random} << 21);
return random.byte(0);
}
if(address == 2) return tunePosition.byte(0);
if(address == 3) return tunePosition.byte(1);
return ram.read(address);
}
auto writeRAM(u32 address, n8 data) -> void {
if(address == 0) operation = data;
else if(address == 1) random = 0x2b435044;
else if(address == 2) {
tunePosition = 0;
for(auto& counter : musicCounter) counter = 0;
for(auto& frequency : musicFrequency) frequency = 0;
} else if(address == 3) {
updateTune();
} else {
ram.write(address, data);
}
}
auto updateTune() -> void {
auto position = u32{tune} * 4_KiB + u32{tunePosition} * 3;
if(position + 2 >= tunes.size() || position + 2 >= (u32{tune} + 1) * 4_KiB) {
tunePosition = 0;
return;
}
tunePosition++;
auto note0 = tunes.read(position + 0);
auto note1 = tunes.read(position + 1);
auto note2 = tunes.read(position + 2);
if(note0) musicFrequency[0] = noteFrequency(note0);
if(note1) musicFrequency[1] = noteFrequency(note1);
if(note2 == 1) tunePosition = 0;
else musicFrequency[2] = noteFrequency(note2);
}
auto operate(n8 value) -> n8 {
if(busyTicks) return value | 0x40;
if(operationCompleted) {
operationCompleted = 0;
return value & ~0x40;
}
auto index = u32{operation} >> 4;
auto command = u32{operation} & 15;
operationSucceeded = 1;
if(command == 1 && index < 7) {
tune = index;
tunePosition = 0;
busyTicks = 10'000;
} else if(command == 2 && index < 4) {
for(u32 offset : range(4, 64)) ram.write(offset, persistent.read(index * 64 + offset));
busyTicks = 10'000;
} else if(command == 3 && index < 4) {
for(u32 offset : range(4, 64)) persistent.write(index * 64 + offset, ram.read(offset));
busyTicks = 20'000;
} else if(command == 4) {
persistent.erase();
busyTicks = 20'000;
} else {
operationSucceeded = 0;
ram.write(0, 0xff);
return value & ~0x40;
}
return value | 0x40;
}
};
+6 -6
View File
@@ -13,25 +13,25 @@ struct Commavid : Interface {
auto unload() -> void override {
}
auto read(n16 address) -> n8 override {
auto read(n16 address, n8 data) -> n8 override {
if(address.bit(12)) {
if(address >= 0x1000 && address <= 0x13ff) return ram.read(address & 0x3ff);
return rom.read(address & 0xfff);
}
return 0xff;
return data;
}
auto write(n16 address, n8 data) -> bool override {
auto write(n16 address, n8 data) -> n8 override {
if(address >= 0x1400 && address <= 0x17ff) {
ram.write(address & 0x3ff, data);
return true;
return data;
}
return false;
return data;
}
auto power() -> void override {
auto power(bool reset) -> void override {
ram.allocate(1_KiB);
}
+41
View File
@@ -0,0 +1,41 @@
struct CPUWiz4KSC : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto save() -> void override {
}
auto unload() -> void override {
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(address < 0x1000) return data;
if(address <= 0x107f) {
ram.write(address & 0x7f, data);
return data;
}
if(address <= 0x10ff) return ram.read(address & 0x7f);
return rom.read(address & 0xfff);
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(address < 0x1000 || address > 0x107f) return data;
ram.write(address & 0x7f, data);
return data;
}
auto power(bool reset) -> void override {
ram.allocate(128, 0x00);
}
auto serialize(serializer& s) -> void override {
s(ram);
}
};
+276
View File
@@ -0,0 +1,276 @@
struct DPCPlus : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
n3 bank;
n8 top[8];
n8 bottom[8];
n12 counter[8];
n20 fractionalCounter[8];
n8 fractionalIncrement[8];
n32 musicCounter[3];
n32 musicFrequency[3];
n7 musicWaveform[3];
n32 random;
n1 fastFetch;
n1 ldaImmediate;
n8 parameter[8];
n4 parameterPointer;
u32 fractionalLowMask = 0x0f00ff;
u32 audioPhase = 0;
auto load() -> void override {
Memory::Readable<n8> image;
Interface::load(image, "program.rom");
auto size = min<u32>(image.size(), 32_KiB);
rom.allocate(32_KiB, 0x00);
auto destination = 32_KiB - size;
for(u32 offset : range(size)) rom.program(destination + offset, image.read(offset));
if(image.size() >= 3_KiB) {
Hash::SHA256 hash;
for(u32 offset : range(3_KiB)) hash.input((u8)image.read(offset));
auto driver = hash.digest();
if(driver == "bcbe33dc02ad5104f3a3a53a856a23c57f435344790843f4fb6e746193468d0c"
|| driver == "445ca7866a0efdf0e35076a25e963708dc630f80fd82dcdaf775fb80c8b0c58d") {
fractionalLowMask = 0x0f0000;
}
}
ram.allocate(8_KiB, 0x00);
harmony.load(cartridge.node);
}
auto unload() -> void override {
harmony.unload();
}
auto armInvocation() const -> Harmony::Invocation override {
return {.pc = 0x0c08, .lr = 0x0c00, .sp = 0x40001ffc};
}
auto readARM(u32 mode, n32 address, n32& data) -> Harmony::Access override {
auto romBase = mode & ARM7TDMI::Prefetch ? 0x50u : 0x0c00u;
return readARMMemory(rom, ram, mode, address, romBase, min<u32>(8_KiB, ram.size()), data);
}
auto writeARM(u32 mode, n32 address, n32 data) -> Harmony::Access override {
u32 location = address;
if(location >= 0x40000000 && location - 0x40000000 < min<u32>(8_KiB, ram.size())) {
auto offset = location - 0x40000000;
if(offset > 0x28 && offset < 0x0c00) return Harmony::Access::Fault;
}
return writeARMMemory(ram, mode, address, min<u32>(8_KiB, ram.size()), data);
}
auto stepARM(u32 clocks) -> void override {
stepAudio(clocks);
}
auto program(u32 address) const -> n8 {
return rom.read(3_KiB + bank * 4_KiB + (address & 0x0fff));
}
auto displayRead(u32 address) const -> n8 {
return ram.read(3_KiB + (address & 0x0fff));
}
auto displayWrite(u32 address, n8 data) -> void {
ram.write(3_KiB + (address & 0x0fff), data);
}
auto frequency(u32 note) const -> u32 {
u32 address = 7_KiB + (note << 2);
return ram.read(address + 0) << 0 | ram.read(address + 1) << 8
| ram.read(address + 2) << 16 | ram.read(address + 3) << 24;
}
auto clockRandom() -> void {
random = (random.bit(10) ? 0x10adab1e : 0) ^ (u32{random} >> 11 | u32{random} << 21);
}
auto priorRandom() -> void {
u32 value = random;
if(value >> 31) value ^= 0x10adab1e;
random = value << 11 | value >> 21;
}
auto stepAudio(u32 clocks) -> void {
audioPhase += clocks;
auto ticks = audioPhase / 3500;
audioPhase %= 3500;
for(u32 channel : range(3)) musicCounter[channel] += u32{musicFrequency[channel]} * ticks;
}
auto amplitude() -> n8 {
u32 value = 0;
for(u32 channel : range(3)) {
value += displayRead((u32{musicWaveform[channel]} << 5) + (u32{musicCounter[channel]} >> 27));
}
return value;
}
auto readRegister(u32 address) -> n8 {
u32 index = address & 7;
u32 function = address >> 3 & 7;
u8 topDistance = u8(u32{top[index]} - (u32{counter[index]} & 0xff));
u8 window = u8(u32{top[index]} - u32{bottom[index]});
n8 flag = topDistance > window ? 0xff : 0x00;
if(function == 0) {
if(index == 0) return clockRandom(), random.byte(0);
if(index == 1) return priorRandom(), random.byte(0);
if(index == 2) return random.byte(1);
if(index == 3) return random.byte(2);
if(index == 4) return random.byte(3);
if(index == 5) return amplitude();
return 0;
}
if(function == 1) {
auto data = displayRead(counter[index]);
counter[index]++;
return data;
}
if(function == 2) {
auto data = displayRead(counter[index]) & flag;
counter[index]++;
return data;
}
if(function == 3) {
auto data = displayRead(u32{fractionalCounter[index]} >> 8);
fractionalCounter[index] += fractionalIncrement[index];
return data;
}
if(function == 4 && index < 4) return flag;
return 0;
}
auto callFunction(n8 function) -> void {
u32 source = parameter[0] | parameter[1] << 8;
if(function == 0) parameterPointer = 0;
if(function == 1 || function == 2) {
u32 destination = counter[parameter[2] & 7];
u32 count = parameter[3];
if(destination < 4_KiB) {
count = min(count, 4_KiB - destination);
if(function == 1 && source < rom.size() - 3_KiB) {
count = min(count, rom.size() - 3_KiB - source);
for(u32 offset : range(count)) displayWrite(destination + offset, rom.read(3_KiB + source + offset));
}
if(function == 2) {
for(u32 offset : range(count)) displayWrite(destination + offset, parameter[0]);
}
}
parameterPointer = 0;
}
if(function == 254 || function == 255) {
harmony.call(function == 254);
}
}
auto writeRegister(u32 address, n8 data) -> void {
u32 index = address & 7;
u32 function = (address - 0x28) >> 3 & 15;
if(function == 0) fractionalCounter[index] =
(u32{fractionalCounter[index]} & fractionalLowMask) | u32{data} << 8;
if(function == 1) fractionalCounter[index] =
((u32{data} & 15) << 16) | (u32{fractionalCounter[index]} & 0xffff);
if(function == 2) {
fractionalIncrement[index] = data;
fractionalCounter[index] = u32{fractionalCounter[index]} & 0x0fff00;
}
if(function == 3) top[index] = data;
if(function == 4) bottom[index] = data;
if(function == 5) counter[index] = (u32{counter[index]} & 0x0f00) | data;
if(function == 6) {
if(index == 0) fastFetch = data == 0;
if(index == 1 && parameterPointer < 8) parameter[parameterPointer++] = data;
if(index == 2) callFunction(data);
if(index >= 5) musicWaveform[index - 5] = data & 0x7f;
}
if(function == 7) {
counter[index]--;
displayWrite(counter[index], data);
}
if(function == 8) counter[index] = ((u32{data} & 15) << 8) | (u32{counter[index]} & 0xff);
if(function == 9) {
if(index == 0) random = 0x2b435044;
if(index >= 1 && index <= 4) random.byte(index - 1) = data;
if(index >= 5) musicFrequency[index - 5] = frequency(data);
}
if(function == 10) {
displayWrite(counter[index], data);
counter[index]++;
}
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
u32 offset = address & 0x0fff;
n8 result = program(offset);
if(fastFetch && ldaImmediate && result < 0x28) offset = result;
ldaImmediate = 0;
if(offset < 0x28) return readRegister(offset);
if(offset >= 0x0ff6 && offset <= 0x0ffb) bank = offset - 0x0ff6;
if(fastFetch) ldaImmediate = result == 0xa9;
return result;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
u32 offset = address & 0x0fff;
if(offset >= 0x28 && offset < 0x80) {
writeRegister(offset, data);
return data;
}
if(offset >= 0x0ff6 && offset <= 0x0ffb) bank = offset - 0x0ff6;
return data;
}
auto power(bool reset) -> void override {
ram.fill(0x00);
if(rom.size() >= 32_KiB) {
for(u32 offset : range(5_KiB)) ram.write(3_KiB + offset, rom.read(27_KiB + offset));
}
bank = 5;
for(auto& item : top) item = 0;
for(auto& item : bottom) item = 0;
for(auto& item : counter) item = 0;
for(auto& item : fractionalCounter) item = 0;
for(auto& item : fractionalIncrement) item = 0;
for(auto& item : musicCounter) item = 0;
for(auto& item : musicFrequency) item = 0;
for(auto& item : musicWaveform) item = 0;
for(auto& item : parameter) item = 0;
random = 0x2b435044;
fastFetch = 0;
ldaImmediate = 0;
parameterPointer = 0;
audioPhase = 0;
harmony.power();
}
auto serialize(serializer& s) -> void override {
s(ram);
s(bank);
for(auto& item : top) s(item);
for(auto& item : bottom) s(item);
for(auto& item : counter) s(item);
for(auto& item : fractionalCounter) s(item);
for(auto& item : fractionalIncrement) s(item);
for(auto& item : musicCounter) s(item);
for(auto& item : musicFrequency) s(item);
for(auto& item : musicWaveform) s(item);
s(random);
s(fastFetch);
s(ldaImmediate);
for(auto& item : parameter) s(item);
s(parameterPointer);
s(audioPhase);
harmony.serialize(s);
}
};
+190
View File
@@ -0,0 +1,190 @@
struct DPC : Interface, Thread {
using Interface::Interface;
struct Fetcher {
n8 top;
n8 bottom;
n8 low;
n3 high;
n1 flag;
n1 musicMode;
n1 oscillatorClock;
} fetcher[8];
Memory::Readable<n8> rom;
n1 bank;
n8 random;
n4 movement;
n8 drawLatch;
n8 drawOperand;
n1 drawCarry;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto clockRandom() -> void {
n1 input = !((random.bit(7) ^ random.bit(5)) ^ (random.bit(4) ^ random.bit(3)));
random = random << 1 | input;
}
auto checkFlag(u32 index) -> void {
if(fetcher[index].low == fetcher[index].top) fetcher[index].flag = 1;
if(fetcher[index].low == fetcher[index].bottom) fetcher[index].flag = 0;
}
auto decrement(u32 index) -> void {
if(--fetcher[index].low == 0xff) {
fetcher[index].high--;
if(index >= 5 && fetcher[index].musicMode) fetcher[index].low = fetcher[index].top;
}
checkFlag(index);
}
auto display(u32 index) -> n8 {
auto counter = fetcher[index].high << 8 | fetcher[index].low;
return rom.read(8_KiB + (0x7ff - counter));
}
auto music() -> n4 {
static constexpr u8 amplitude[] = {0x0, 0x4, 0x5, 0x9, 0x6, 0xa, 0xb, 0xf};
u32 state = 0;
if(fetcher[5].musicMode && fetcher[5].flag) state |= 1;
if(fetcher[6].musicMode && fetcher[6].flag) state |= 2;
if(fetcher[7].musicMode && fetcher[7].flag) state |= 4;
return amplitude[state];
}
auto reverse(n8 data) -> n8 {
n8 result;
for(u32 bit : range(8)) result.bit(7 - bit) = data.bit(bit);
return result;
}
auto readRegister(n16 address) -> n8 {
auto index = address & 7;
auto function = address.bit(3, 5);
if(function == 0) {
if(index < 4) return random;
if(index <= 5) {
drawOperand = drawLatch;
auto sum = u32{drawOperand} + u32{fetcher[4].top};
drawLatch = sum;
drawCarry = sum > 0xff;
}
return n8{drawCarry ? movement << 4 : 0} | music();
}
checkFlag(index);
auto data = display(index);
n8 result;
if(function == 1) result = data;
if(function == 2) result = fetcher[index].flag ? data : n8{0};
if(function == 3) result = fetcher[index].flag ? n8{data << 4 | data >> 4} : n8{0};
if(function == 4) result = fetcher[index].flag ? reverse(data) : n8{0};
if(function == 5) result = fetcher[index].flag ? n8{data >> 1} : n8{0};
if(function == 6) result = fetcher[index].flag ? n8{data << 1} : n8{0};
if(function == 7) result = fetcher[index].flag ? 0xff : 0x00;
if(index < 5 || !fetcher[index].oscillatorClock) decrement(index);
return result;
}
auto writeRegister(n16 address, n8 data) -> void {
auto index = address & 7;
auto function = address.bit(3, 5);
if(function == 0) {
fetcher[index].top = data;
fetcher[index].flag = 0;
}
if(function == 1) {
fetcher[index].bottom = data;
checkFlag(index);
}
if(function == 2) {
fetcher[index].low = index >= 5 && fetcher[index].musicMode ? fetcher[index].top : data;
if(index == 4) drawLatch = data;
checkFlag(index);
}
if(function == 3) {
fetcher[index].high = data.bit(0, 2);
if(index >= 5) {
fetcher[index].musicMode = data.bit(4);
fetcher[index].oscillatorClock = data.bit(5);
if(fetcher[index].musicMode && fetcher[index].low == 0xff) {
fetcher[index].low = fetcher[index].top;
checkFlag(index);
}
}
}
if(function == 4) movement = data.bit(4, 7);
if(function == 6) random = 0;
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
clockRandom();
if(address == 0x1ff8) bank = 0;
if(address == 0x1ff9) bank = 1;
if(address <= 0x103f) return readRegister(address);
return rom.read(bank * 4_KiB + (address & 0xfff));
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
clockRandom();
if(address == 0x1ff8) bank = 0;
if(address == 0x1ff9) bank = 1;
if(address >= 0x1040 && address <= 0x107f) {
writeRegister(address, data);
return data;
}
return data;
}
auto main() -> void {
for(u32 index = 5; index < 8; index++) {
if(fetcher[index].oscillatorClock) decrement(index);
}
step(1);
Thread::synchronize(cpu);
}
auto power(bool reset) -> void override {
Thread::create(20'000, std::bind_front(&DPC::main, this));
//Stella latch bank 1.
//MAME latch bank 0.
bank = 1;
random = 0;
movement = 0;
drawLatch = 0;
drawOperand = 0;
drawCarry = 0;
for(auto& item : fetcher) item = {};
}
auto serialize(serializer& s) -> void override {
Thread::serialize(s);
s(bank);
s(random);
s(movement);
s(drawLatch);
s(drawOperand);
s(drawCarry);
for(auto& item : fetcher) {
s(item.top);
s(item.bottom);
s(item.low);
s(item.high);
s(item.flag);
s(item.musicMode);
s(item.oscillatorClock);
}
}
};
@@ -0,0 +1,36 @@
struct EconoBanking : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n1 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
if(address.bit(12)) return rom.read(bank * 0x1000 + (address & 0x0fff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
return data;
}
auto power(bool reset) -> void override {
bank = 0;
}
auto serialize(serializer& s) -> void override {
s(bank);
}
private:
auto select(n16 address) -> void {
if((address & 0x1840) == 0x0800) bank = 0;
if((address & 0x1840) == 0x0840) bank = 1;
}
};
+156
View File
@@ -0,0 +1,156 @@
struct EFBase : Interface {
EFBase(Cartridge& cartridge, n16 hotspotMask, n16 hotspot, n6 startupBank, bool hasRam = false)
: Interface(cartridge), hotspotMask(hotspotMask), hotspot(hotspot), startupBank(startupBank), hasRam(hasRam) {}
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
const n16 hotspotMask;
const n16 hotspot;
const n6 startupBank;
const bool hasRam;
n6 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
bankswitch(address);
if(!address.bit(12)) return data;
if(hasRam && address <= 0x107f) {
ram.write(address & 0x7f, data);
return data;
}
if(hasRam && address <= 0x10ff) return ram.read(address & 0x7f);
return rom.read(bank * 0x1000 + (address & 0x0fff));
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
bankswitch(address);
if(hasRam && address >= 0x1000 && address <= 0x107f) {
ram.write(address & 0x7f, data);
return data;
}
return data;
}
auto power(bool reset) -> void override {
bank = startupBank;
if(hasRam) ram.allocate(128, 0x00);
}
auto serialize(serializer& s) -> void override {
s(bank);
if(hasRam) s(ram);
}
private:
auto bankswitch(n16 address) -> void {
if((address & hotspotMask) == hotspot) bank = address - hotspot;
}
};
struct EF : EFBase {
EF(Cartridge& cartridge) : EFBase(cartridge, 0x1ff0, 0x1fe0, 1) {}
};
struct EFF : EFBase {
EFF(Cartridge& cartridge) : EFBase(cartridge, 0x1ff0, 0x1fe0, 1) {}
M24C eeprom;
PersistentMemory persistent;
auto load() -> void override {
EFBase::load();
persistent.load(pak, "save.eeprom", 2_KiB, 0xff);
eeprom.load(M24C::Type::M24C16);
std::copy(persistent.memory.begin(), persistent.memory.end(), std::begin(eeprom.memory));
}
auto save() -> void override {
persistent.flush(pak);
}
auto unload() -> void override {
persistent.flush(pak);
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(address >= 0x1ff0 && address <= 0x1ff4) {
if(address == 0x1ff0) setClock(0);
if(address == 0x1ff1) setClock(1);
if(address == 0x1ff2) setData(0);
if(address == 0x1ff3) setData(1);
if(address == 0x1ff4) return rom.read(bank * 0x1000 + 0x0ff4 + eeprom.read());
}
return EFBase::read(address, data);
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(address >= 0x1ff0 && address <= 0x1ff3) {
if(address == 0x1ff0) setClock(0);
if(address == 0x1ff1) setClock(1);
if(address == 0x1ff2) setData(0);
if(address == 0x1ff3) setData(1);
}
return EFBase::write(address, data);
}
auto power(bool reset) -> void override {
EFBase::power(reset);
eeprom.power();
}
auto serialize(serializer& s) -> void override {
EFBase::serialize(s);
eeprom.serialize(s, false);
if(s.reading()) {
std::copy(persistent.memory.begin(), persistent.memory.end(), std::begin(eeprom.memory));
}
}
private:
auto synchronizePersistent() -> void {
persistent.replace({(const u8*)eeprom.memory, eeprom.size()});
}
auto setClock(bool value) -> void {
eeprom.clock = eeprom.clock();
eeprom.data = eeprom.data();
eeprom.clock = value;
eeprom.write();
synchronizePersistent();
}
auto setData(bool value) -> void {
eeprom.clock = eeprom.clock();
eeprom.data = eeprom.data();
eeprom.data = value;
eeprom.write();
synchronizePersistent();
}
};
struct DF : EFBase {
DF(Cartridge& cartridge) : EFBase(cartridge, 0x1fe0, 0x1fc0, 15) {}
};
struct BF : EFBase {
BF(Cartridge& cartridge) : EFBase(cartridge, 0x1fc0, 0x1f80, 1) {}
};
struct EFSC : EFBase {
EFSC(Cartridge& cartridge) : EFBase(cartridge, 0x1ff0, 0x1fe0, 15, true) {}
};
struct DFSC : EFBase {
DFSC(Cartridge& cartridge) : EFBase(cartridge, 0x1fe0, 0x1fc0, 15, true) {}
};
struct BFSC : EFBase {
BFSC(Cartridge& cartridge) : EFBase(cartridge, 0x1fc0, 0x1f80, 15, true) {}
};
+89
View File
@@ -0,0 +1,89 @@
struct ELFCartridge : Interface {
ELFCartridge(Cartridge& cartridge) : Interface(cartridge) {}
auto fail(string reason) -> void {
runtime.unload();
publishedError = std::move(reason);
ready = false;
cartridge.node->setAttribute("error", publishedError);
}
auto clearError() -> void {
publishedError = {};
cartridge.node->setAttribute("error");
}
auto publishRuntimeError() -> bool {
if(!runtime.faulted()) return false;
auto error = runtime.error();
if(error != publishedError) {
publishedError = std::move(error);
cartridge.node->setAttribute("error", publishedError);
}
return true;
}
auto access(n16 address, n8 value) -> n8 {
if(!ready || publishRuntimeError()) return value;
return runtime.access(address, value);
}
auto load() -> void override {
image.clear();
object = {};
linker = {};
ready = false;
clearError();
if(auto fp = pak->read("program.elf")) {
if(fp->size() > ELF::MaximumImageSize) return fail("ELF image exceeds 16 MiB");
image.resize(fp->size());
fp->read({image.data(), image.size()});
} else {
return fail("ELF package is missing program.elf");
}
if(!object.parse(image)) return fail(object.error());
if(!linker.link(object, ELF::externalSymbols(Region::NTSC()))) return fail(linker.error());
ready = true;
}
auto unload() -> void override {
runtime.unload();
image.clear();
object = {};
linker = {};
ready = false;
publishedError = {};
}
auto power(bool) -> void override {
if(!ready) return;
if(!linker.link(object, ELF::externalSymbols(Region::NTSC()))) return fail(linker.error());
runtime.power(linker.result(), Region::NTSC());
clearError();
publishRuntimeError();
}
auto read(n16 address, n8 value) -> n8 override {
return access(address, value);
}
auto write(n16 address, n8 value) -> n8 override {
return access(address, value);
}
auto serialize(serializer& s) -> void override {
if(!ready) return;
runtime.serialize(s);
if(s.reading()) {
clearError();
publishRuntimeError();
}
}
std::vector<u8> image;
ELF::Object object;
ELF::Linker linker;
ELF::Runtime runtime;
bool ready = false;
string publishedError;
};
+31
View File
@@ -0,0 +1,31 @@
struct Enhanced3F : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n8 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
if(!address.bit(11)) return rom.read(bank * 0x800 + (address & 0x07ff));
return rom.read(rom.size() - 0x800 + (address & 0x07ff));
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(address <= 0x003f) bank = data % (rom.size() >> 11);
return data;
}
auto power(bool reset) -> void override {
//Stella powers bank 0; MAME powers the final bank.
bank = 0;
}
auto serialize(serializer& s) -> void override {
s(bank);
}
};
+118
View File
@@ -0,0 +1,118 @@
struct FA2 : Interface, Thread {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
PersistentMemory persistent;
n3 bank;
n9 busyTicks;
n1 operationCompleted;
n1 operationSucceeded;
auto load() -> void override {
Memory::Readable<n8> image;
Interface::load(image, "program.rom");
if(image.size() >= 29_KiB) {
rom.allocate(28_KiB, 0x00);
for(u32 offset : range(28_KiB)) rom.program(offset, image.read(1_KiB + offset));
} else {
rom.allocate(image.size(), 0x00);
for(u32 offset : range(image.size())) rom.program(offset, image.read(offset));
}
persistent.load(pak, "save.flash", 256, 0x00);
}
auto save() -> void override {
persistent.flush(pak);
}
auto unload() -> void override {
persistent.flush(pak);
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
if(address == 0x1ff4 && rom.size() == 28_KiB) return operate();
bankswitch(address);
if(address <= 0x10ff) {
ram.write(address & 0xff, data);
return data;
}
if(address <= 0x11ff) return ram.read(address & 0xff);
return rom.read(bank * 4_KiB + (address & 0x0fff));
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
if(address == 0x1ff4 && rom.size() == 28_KiB) {
operate();
return data;
}
bankswitch(address);
if(address <= 0x10ff) ram.write(address & 0xff, data);
return data;
}
auto main() -> void {
if(busyTicks && !--busyTicks) {
operationCompleted = 1;
ram.write(255, operationSucceeded ? 0x00 : 0xff);
}
step(1);
Thread::synchronize(cpu);
}
auto power(bool reset) -> void override {
Thread::create(2'000, std::bind_front(&FA2::main, this));
bank = 0;
busyTicks = 0;
operationCompleted = 0;
operationSucceeded = 0;
ram.allocate(256, 0x00);
}
auto serialize(serializer& s) -> void override {
Thread::serialize(s);
s(bank);
s(busyTicks);
s(operationCompleted);
s(operationSucceeded);
s(ram);
}
private:
auto bankswitch(n16 address) -> void {
if(address < 0x1ff5 || address > 0x1ffb) return;
auto selected = address - 0x1ff5;
if(selected < rom.size() / 4_KiB) bank = selected;
}
auto operate() -> n8 {
auto value = rom.read(bank * 4_KiB + 0x0ff4);
if(busyTicks) return value | 0x40;
if(operationCompleted) {
operationCompleted = 0;
return value & ~0x40;
}
operationSucceeded = 1;
auto command = ram.read(255);
if(command == 0) {
persistent.erase();
busyTicks = 202;
} else if(command == 1) {
for(u32 offset : range(256)) ram.write(offset, persistent.read(offset));
busyTicks = 1;
} else if(command == 2) {
persistent.replace({(const u8*)ram.data(), 256});
busyTicks = 202;
} else {
operationSucceeded = 0;
ram.write(255, 0xff);
return value & ~0x40;
}
return value | 0x40;
}
};
+124
View File
@@ -0,0 +1,124 @@
struct FourA50 : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
n16 sliceLow;
n16 sliceMiddle;
n16 sliceHigh;
n1 romLow;
n1 romMiddle;
n1 romHigh;
n16 lastAddress;
n8 lastData;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) {
checkBankSwitch(address, data);
} else if((address & 0x1800) == 0x1000) {
data = romLow ? readRom(sliceLow + (address & 0x07ff)) : ram.read(sliceLow + (address & 0x07ff));
} else if(address <= 0x1dff) {
data = romMiddle ? readRom(0x10000 + sliceMiddle + (address & 0x07ff))
: ram.read(sliceMiddle + (address & 0x07ff));
} else if(address <= 0x1eff) {
data = romHigh ? readRom(0x10000 + sliceHigh + (address & 0x00ff))
: ram.read(sliceHigh + (address & 0x00ff));
} else {
data = readRom(0x1ff00 + (address & 0x00ff));
if((lastData & 0xe0) == 0x60 && (lastAddress >= 0x1000 || lastAddress < 0x0200)) {
sliceHigh = (sliceHigh & 0xf0ff) | ((address & 0x0008) << 8) | ((address & 0x0070) << 4);
}
}
lastData = data;
lastAddress = address;
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) {
checkBankSwitch(address, data);
} else if((address & 0x1800) == 0x1000) {
if(!romLow) {
ram.write(sliceLow + (address & 0x07ff), data);
}
} else if(address <= 0x1dff) {
if(!romMiddle) {
ram.write(sliceMiddle + (address & 0x07ff), data);
}
} else if(address <= 0x1eff) {
if(!romHigh) {
ram.write(sliceHigh + (address & 0x00ff), data);
}
} else if((lastData & 0xe0) == 0x60 && (lastAddress >= 0x1000 || lastAddress < 0x0200)) {
sliceHigh = (sliceHigh & 0xf0ff) | ((address & 0x0008) << 8) | ((address & 0x0070) << 4);
}
lastData = data;
lastAddress = address;
return data;
}
auto power(bool reset) -> void override {
sliceLow = 0;
sliceMiddle = 0;
sliceHigh = 0;
romLow = 1;
romMiddle = 1;
romHigh = 1;
lastAddress = 0xffff;
lastData = 0xff;
ram.allocate(32_KiB, 0x00);
}
auto serialize(serializer& s) -> void override {
s(ram);
s(sliceLow);
s(sliceMiddle);
s(sliceHigh);
s(romLow);
s(romMiddle);
s(romHigh);
s(lastAddress);
s(lastData);
}
private:
auto readRom(u32 address) -> n8 {
return rom.read(address % rom.size());
}
auto bankROMLower(u16 value) -> void { romLow = 1; sliceLow = value << 11; }
auto bankRAMLower(u16 value) -> void { romLow = 0; sliceLow = value << 11; }
auto bankROMMiddle(u16 value) -> void { romMiddle = 1; sliceMiddle = value << 11; }
auto bankRAMMiddle(u16 value) -> void { romMiddle = 0; sliceMiddle = value << 11; }
auto bankROMHigh(u16 value) -> void { romHigh = 1; sliceHigh = value << 8; }
auto bankRAMHigh(u16 value) -> void { romHigh = 0; sliceHigh = value << 8; }
auto checkBankSwitch(n16 address, n8 data) -> void {
if((lastData & 0xe0) == 0x60 && (lastAddress >= 0x1000 || lastAddress < 0x0200)) {
if((address & 0x0f00) == 0x0c00) bankROMHigh(address & 0x00ff);
else if((address & 0x0f00) == 0x0d00) bankRAMHigh(address & 0x007f);
else if((address & 0x0f40) == 0x0e00) bankROMLower(address & 0x001f);
else if((address & 0x0f40) == 0x0e40) bankRAMLower(address & 0x000f);
else if((address & 0x0f40) == 0x0f00) bankROMMiddle(address & 0x001f);
else if((address & 0x0f50) == 0x0f40) bankRAMMiddle(address & 0x000f);
else if((address & 0x0f00) == 0x0400) sliceLow ^= 0x0800;
else if((address & 0x0f00) == 0x0500) sliceLow ^= 0x1000;
else if((address & 0x0f00) == 0x0800) sliceMiddle ^= 0x0800;
else if((address & 0x0f00) == 0x0900) sliceMiddle ^= 0x1000;
}
if((address & 0x0f75) == 0x0074) bankROMHigh(data);
else if((address & 0x0f75) == 0x0075) bankRAMHigh(data & 0x7f);
else if((address & 0x0f7c) == 0x0078) {
if((data & 0xf0) == 0x00) bankROMLower(data & 0x0f);
else if((data & 0xf0) == 0x40) bankRAMLower(data & 0x0f);
else if((data & 0xf0) == 0x90) bankROMMiddle((data & 0x0f) | 0x10);
else if((data & 0xf0) == 0xc0) bankRAMMiddle(data & 0x0f);
}
}
};
+38
View File
@@ -0,0 +1,38 @@
struct Jane : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n2 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
if(address.bit(12)) return rom.read(bank * 0x1000 + (address & 0x0fff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
return data;
}
auto power(bool reset) -> void override {
bank = 1;
}
auto serialize(serializer& s) -> void override {
s(bank);
}
private:
auto select(n16 address) -> void {
if(address == 0x1ff0) bank = 0;
if(address == 0x1ff1) bank = 1;
if(address == 0x1ff8) bank = 2;
if(address == 0x1ff9) bank = 3;
}
};
+38
View File
@@ -0,0 +1,38 @@
struct JVP : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n1 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
if(address.bit(12)) return rom.read(bank * 0x1000 + (address & 0x0fff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
return data;
}
auto power(bool reset) -> void override {
//Stella powers bank 1; MAME powers bank 0.
bank = 0;
}
auto serialize(serializer& s) -> void override {
s(bank);
}
private:
auto select(n16 address) -> void {
//Stella selects directly; MAME toggles either hotspot.
if((address & 0x16e0) == 0x06a0) bank = 0;
if((address & 0x16e0) == 0x06c0) bank = 1;
}
};
+6 -21
View File
@@ -1,8 +1,6 @@
struct Linear : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
bool hasRam;
auto load() -> void override {
Interface::load(rom, "program.rom");
@@ -14,32 +12,19 @@ struct Linear : Interface {
auto unload() -> void override {
}
auto read(n16 address) -> n8 override {
if(address.bit(12)) {
if(hasRam && address >= 0x1080 && address <= 0x10ff) return ram.read(address & 0x7f);
return rom.read(address & 0xfff);
}
auto read(n16 address, n8 data) -> n8 override {
if(address.bit(12)) return rom.read(address & 0xfff);
return 0xff;
return data;
}
auto write(n16 address, n8 data) -> bool override {
if(address >= 0x1000 && address <= 0x107f) {
hasRam = true;
ram.write(address & 0x7f, data);
return true;
}
return false;
auto write(n16 address, n8 data) -> n8 override {
return data;
}
auto power() -> void override {
hasRam = 0;
ram.allocate(128);
auto power(bool reset) -> void override {
}
auto serialize(serializer& s) -> void override {
s(hasRam);
s(ram);
}
};
+86
View File
@@ -0,0 +1,86 @@
struct MNetwork : Interface {
using Interface::Interface;
static constexpr u8 LowerRam = 7;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
n3 lowerSelector;
n2 upperRamBank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto select(n16 address) -> void {
address &= 0x1fff;
if(address >= 0x1fe8 && address <= 0x1feb) upperRamBank = address - 0x1fe8;
if(address < 0x1fe0 || address > 0x1fe7) return;
auto selector = address - 0x1fe0;
if(selector == 7) {
lowerSelector = LowerRam;
return;
}
if(rom.size() == 8_KiB) {
if(selector >= 4) lowerSelector = selector - 4;
return;
}
if(rom.size() == 12_KiB) {
static constexpr u8 banks[] = {0, 1, 0, 1, 2, 3, 4};
lowerSelector = banks[selector];
return;
}
lowerSelector = selector;
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
if(address >= 0x1000 && address <= 0x13ff) {
if(lowerSelector != LowerRam) return rom.read((lowerSelector * 0x800) + (address & 0x7ff));
ram.write(address & 0x3ff, data);
return data;
}
if(address >= 0x1400 && address <= 0x17ff) {
if(lowerSelector != LowerRam) return rom.read((lowerSelector * 0x800) + (address & 0x7ff));
return ram.read(address & 0x3ff);
}
if(address >= 0x1800 && address <= 0x18ff) {
auto offset = 0x400 + upperRamBank * 0x100 + (address & 0xff);
ram.write(offset, data);
return data;
}
if(address >= 0x1900 && address <= 0x19ff) {
return ram.read(0x400 + upperRamBank * 0x100 + (address & 0xff));
}
if(address >= 0x1a00) return rom.read((rom.size() - 0x800) + (address & 0x7ff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
if(lowerSelector == LowerRam && address >= 0x1000 && address <= 0x13ff) {
ram.write(address & 0x3ff, data);
return data;
}
if(address >= 0x1800 && address <= 0x18ff) {
ram.write(0x400 + upperRamBank * 0x100 + (address & 0xff), data);
return data;
}
return data;
}
auto power(bool reset) -> void override {
lowerSelector = 0;
upperRamBank = 0;
ram.allocate(2_KiB, 0x00);
}
auto serialize(serializer& s) -> void override {
s(lowerSelector);
s(upperRamBank);
s(ram);
}
};
+40
View File
@@ -0,0 +1,40 @@
struct MDM : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n7 bank;
n1 bankingDisabled;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
bankswitch(address);
if(address.bit(12)) return rom.read(bank * 0x1000 + (address & 0x0fff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
bankswitch(address & 0x1fff);
return data;
}
auto power(bool reset) -> void override {
bank = 0;
bankingDisabled = 0;
}
auto serialize(serializer& s) -> void override {
s(bank);
s(bankingDisabled);
}
private:
auto bankswitch(n16 address) -> void {
if(bankingDisabled || (address & 0x1c00) != 0x0800) return;
auto selector = address & 0x00ff;
bank = selector % (rom.size() >> 12);
if(selector > 127) bankingDisabled = 1;
}
};
+37
View File
@@ -0,0 +1,37 @@
struct MegaBoy : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n4 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
if(address.bit(12)) return rom.read(bank * 0x1000 + (address & 0x0fff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
return data;
}
auto power(bool reset) -> void override {
//Stella latch bank 15.
//MAME latch bank 0.
bank = 0;
}
auto serialize(serializer& s) -> void override {
s(bank);
}
private:
auto select(n16 address) -> void {
if(address == 0x1ff0) bank++;
}
};
+702
View File
@@ -0,0 +1,702 @@
struct MovieCart : Interface {
using Interface::Interface;
static constexpr u32 TitleCycles = 1'000'000;
static constexpr u16 StreamRoutine = 0x1080;
static constexpr u16 BlankRoutine = 0x1180;
static constexpr u16 InputRoutine = 0x1100;
static constexpr u16 DifficultyRoutine = 0x1200;
static constexpr u16 ConsoleRoutine = 0x1300;
static constexpr u16 PulseRoutine = 0x1560;
static constexpr u16 LineTrampoline = 0x1070;
struct Kernel {
std::array<u8, 1_KiB> image{};
u16 vsyncLines = 0;
u16 vblankLines = 0;
u16 overscanLines = 0;
u16 visibleDone = 0;
u16 visibleExit = 0;
u16 background = 0;
std::array<u16, 5> playfieldColor{};
u16 playfield0Left = 0;
u16 playfield1Left = 0;
u16 playfield2Left = 0;
u16 playfield0Right = 0;
u16 playfield1Right = 0;
u16 playfield2Right = 0;
std::array<u16, 2> audioVolume{};
} kernel;
VFS::File stream;
std::array<std::array<u8, MVC::FieldSize>, 2> fields{};
MVC::FieldDescriptor descriptors[2];
std::array<u32, 2> loadedFields = {~0u, ~0u};
std::array<bool, 2> blankFields{};
std::array<u8, 32> fingerprint{};
u64 streamSize = 0;
u32 fieldCount = 0;
u32 fieldNumber = 0;
u16 scanline = 0;
n1 activeBuffer = 0;
n1 odd = 1;
n1 a7 = 0;
n1 a10 = 0;
n16 a10Pulses = 0;
bool streamStarted = false;
u8 previousCommand = 0;
u8 repeatFields = 0;
u8 seekSpeed = 2;
u8 muteFields = 0;
u8 volume = 15;
u8 brightness = 15;
u8 osdMode = 0;
bool monochrome = false;
bool playing = true;
enum class TitleState : u8 { Display, Exiting, Stream } titleState = TitleState::Display;
u32 titleCycles = 0;
bool ready = false;
auto emit(u16& pc, u8 value) -> void {
kernel.image[pc++ & 0x03ff] = value;
}
auto immediate(u16& pc, u8 opcode, u8 value, u16* operand = nullptr) -> void {
emit(pc, opcode);
if(operand) *operand = pc;
emit(pc, value);
}
auto absolute(u16& pc, u8 opcode, u16 address) -> void {
emit(pc, opcode);
emit(pc, address);
emit(pc, address >> 8);
}
auto zeroPage(u16& pc, u8 opcode, u8 address) -> void {
emit(pc, opcode);
emit(pc, address);
}
auto branch(u16& pc, u8 opcode, u16 target) -> void {
emit(pc, opcode);
auto origin = pc + 1;
emit(pc, (u8)(target - origin));
}
auto branchPlaceholder(u16& pc, u8 opcode) -> u16 {
emit(pc, opcode);
auto operand = pc;
emit(pc, 0);
return operand;
}
auto patchBranch(u16 operand, u16 target) -> void {
kernel.image[operand & 0x03ff] = (u8)(target - (operand + 1));
}
auto buildKernel() -> void {
kernel = {};
kernel.image.fill(0xea);
u16 pc = 0;
emit(pc, 0x78); //SEI
emit(pc, 0xd8); //CLD
immediate(pc, 0xa2, 0xff); //LDX #$ff
emit(pc, 0x9a); //TXS
immediate(pc, 0xa9, 0x02); //LDA #$02
zeroPage(pc, 0x85, 0x01); //STA VBLANK
immediate(pc, 0xa9, 0x00); //LDA #$00
zeroPage(pc, 0x85, 0x0a); //STA CTRLPF
immediate(pc, 0xa9, 0x04); //LDA #pure tone
zeroPage(pc, 0x85, 0x15); //STA AUDC0
immediate(pc, 0xa9, 0x00); //LDA #frequency
zeroPage(pc, 0x85, 0x17); //STA AUDF0
auto frame = pc;
immediate(pc, 0xa9, 0x02); //LDA #$02
zeroPage(pc, 0x85, 0x00); //STA VSYNC
immediate(pc, 0xa2, 3, &kernel.vsyncLines); //LDX #vsync
auto vsyncLoop = pc;
absolute(pc, 0x20, BlankRoutine); //JSR blank line
emit(pc, 0xca); //DEX
branch(pc, 0xd0, vsyncLoop); //BNE
immediate(pc, 0xa9, 0x00); //LDA #0
zeroPage(pc, 0x85, 0x00); //STA VSYNC
immediate(pc, 0xa2, 37, &kernel.vblankLines);//LDX #vblank
auto vblankLoop = pc;
absolute(pc, 0x20, BlankRoutine); //JSR blank line
emit(pc, 0xca); //DEX
branch(pc, 0xd0, vblankLoop); //BNE
immediate(pc, 0xa9, 0x00); //LDA #0
zeroPage(pc, 0x85, 0x01); //STA VBLANK
absolute(pc, 0x4c, StreamRoutine); //JMP visible stream
auto visibleDone = pc;
kernel.visibleExit = visibleDone + 0x1000;
immediate(pc, 0xa9, 0x02); //LDA #2
zeroPage(pc, 0x85, 0x01); //STA VBLANK
absolute(pc, 0x20, InputRoutine); //JSR input sampler
immediate(pc, 0xa2, 30, &kernel.overscanLines);//LDX #overscan
auto overscanLoop = pc;
absolute(pc, 0x20, BlankRoutine); //JSR blank line
emit(pc, 0xca); //DEX
branch(pc, 0xd0, overscanLoop); //BNE
absolute(pc, 0x4c, 0x1000 + frame); //JMP frame
pc = LineTrampoline & 0x03ff;
emit(pc, 0x4c); //JMP visible stream/done
kernel.visibleDone = pc;
emit(pc, StreamRoutine & 0xff);
emit(pc, StreamRoutine >> 8);
pc = PulseRoutine & 0x03ff;
emit(pc, 0x60); //RTS (one A10 pulse)
pc = StreamRoutine & 0x03ff;
zeroPage(pc, 0x85, 0x02); //STA WSYNC
immediate(pc, 0xa9, 0x00, &kernel.background);
zeroPage(pc, 0x85, 0x09); //STA COLUBK
immediate(pc, 0xa9, 0x0e, &kernel.playfieldColor[0]);
zeroPage(pc, 0x85, 0x08); //STA COLUPF
immediate(pc, 0xa9, 0x00, &kernel.playfield0Left);
zeroPage(pc, 0x85, 0x0d); //STA PF0
immediate(pc, 0xa9, 0x00, &kernel.playfield1Left);
zeroPage(pc, 0x85, 0x0e); //STA PF1
immediate(pc, 0xa9, 0x00, &kernel.playfield2Left);
zeroPage(pc, 0x85, 0x0f); //STA PF2
immediate(pc, 0xa9, 0x00, &kernel.audioVolume[0]);
zeroPage(pc, 0x85, 0x19); //STA AUDV0
emit(pc, 0xea); //align five color cells
immediate(pc, 0xa9, 0x0e, &kernel.playfieldColor[1]);
zeroPage(pc, 0x85, 0x08); //STA COLUPF
immediate(pc, 0xa9, 0x0e, &kernel.playfieldColor[2]);
zeroPage(pc, 0x85, 0x08); //STA COLUPF
immediate(pc, 0xa9, 0x00, &kernel.playfield0Right);
zeroPage(pc, 0x85, 0x0d); //STA PF0
immediate(pc, 0xa9, 0x0e, &kernel.playfieldColor[3]);
zeroPage(pc, 0x85, 0x08); //STA COLUPF
immediate(pc, 0xa9, 0x00, &kernel.playfield1Right);
zeroPage(pc, 0x85, 0x0e); //STA PF1
immediate(pc, 0xa9, 0x0e, &kernel.playfieldColor[4]);
zeroPage(pc, 0x85, 0x08); //STA COLUPF
immediate(pc, 0xa9, 0x00, &kernel.playfield2Right);
zeroPage(pc, 0x85, 0x0f); //STA PF2
absolute(pc, 0x4c, LineTrampoline); //JMP low-page trampoline
pc = BlankRoutine & 0x03ff;
zeroPage(pc, 0x85, 0x02); //STA WSYNC
immediate(pc, 0xa9, 0x00, &kernel.audioVolume[1]);
zeroPage(pc, 0x85, 0x19); //STA AUDV0
emit(pc, 0x60); //RTS
pc = InputRoutine & 0x03ff;
zeroPage(pc, 0xa5, 0x0c); //LDA INPT4
auto noFire = branchPlaceholder(pc, 0x30); //BMI not pressed
absolute(pc, 0x20, PulseRoutine);
emit(pc, 0x60); //fire = command 1
patchBranch(noFire, pc);
auto joystickCommand = [&](u8 mask, u8 pulses) {
absolute(pc, 0xad, 0x0280); //LDA SWCHA
immediate(pc, 0x29, mask); //AND direction
auto notPressed = branchPlaceholder(pc, 0xd0);
for(u32 pulse : range(pulses)) absolute(pc, 0x20, PulseRoutine);
emit(pc, 0x60);
patchBranch(notPressed, pc);
};
joystickCommand(0x40, 2); //left = seek backward
joystickCommand(0x80, 3); //right = seek forward
joystickCommand(0x10, 4); //up = volume up
joystickCommand(0x20, 5); //down = volume down
absolute(pc, 0x4c, DifficultyRoutine); //JMP difficulty sampler
pc = DifficultyRoutine & 0x03ff;
auto difficultyCommand = [&](u8 mask, u8 pulses) {
absolute(pc, 0xad, 0x0282); //LDA SWCHB
immediate(pc, 0x29, mask); //AND difficulty switch
auto inactive = branchPlaceholder(pc, 0xd0);
for(u32 pulse : range(pulses)) absolute(pc, 0x20, PulseRoutine);
emit(pc, 0x60);
patchBranch(inactive, pc);
};
difficultyCommand(0x40, 9); //left difficulty = ten seconds back
difficultyCommand(0x80, 10); //right difficulty = single step
absolute(pc, 0x4c, ConsoleRoutine); //JMP console sampler
pc = ConsoleRoutine & 0x03ff;
auto consoleCommand = [&](u8 mask, u8 pulses) {
absolute(pc, 0xad, 0x0282); //LDA SWCHB
immediate(pc, 0x29, mask); //AND console switch
auto inactive = branchPlaceholder(pc, 0xd0);
for(u32 pulse : range(pulses)) absolute(pc, 0x20, PulseRoutine);
emit(pc, 0x60);
patchBranch(inactive, pc);
};
consoleCommand(0x02, 6); //select = cycle OSD
consoleCommand(0x01, 7); //reset = restart movie
consoleCommand(0x08, 8); //B/W = monochrome toggle
emit(pc, 0x60);
kernel.image[0x03fc] = 0x00;
kernel.image[0x03fd] = 0x10;
kernel.image[0x03fe] = 0x00;
kernel.image[0x03ff] = 0x10;
}
auto fail(string reason) -> void {
ready = false;
cartridge.node->setAttribute("error", reason);
}
auto updateStatus() -> void {
cartridge.node->setAttribute("moviecart-field", string{fieldNumber});
cartridge.node->setAttribute("moviecart-state", playing ? "playing" : "paused");
cartridge.node->setAttribute("moviecart-volume", string{volume});
cartridge.node->setAttribute("moviecart-brightness", string{brightness});
cartridge.node->setAttribute("moviecart-monochrome", monochrome ? "on" : "off");
cartridge.node->setAttribute("moviecart-osd", string{osdMode});
cartridge.node->setAttribute("moviecart-seek-speed", string{seekSpeed});
cartridge.node->setAttribute("moviecart-repeat", string{repeatFields});
cartridge.node->setAttribute("moviecart-mute", string{muteFields});
static constexpr const char* titleNames[] = {"display", "exiting", "stream"};
cartridge.node->setAttribute("moviecart-title", titleNames[(u32)titleState]);
}
auto readField(u32 number, u32 buffer) -> bool {
if(!stream || number >= fieldCount || buffer >= fields.size()) return false;
auto offset = (u64)number * MVC::FieldSize;
if(offset > streamSize || MVC::FieldSize > streamSize - offset) return false;
std::array<u8, MVC::FieldSize> candidate{};
stream->seek(offset);
stream->read({candidate.data(), candidate.size()});
MVC::FieldDescriptor descriptor;
if(!MVC::parseField(candidate, descriptor)) {
loadedFields[buffer] = number;
blankFields[buffer] = true;
return false;
}
fields[buffer] = candidate;
descriptors[buffer] = descriptor;
loadedFields[buffer] = number;
blankFields[buffer] = false;
return true;
}
auto calculateFingerprint() -> void {
Hash::SHA256 hash;
MVC::fingerprintPrefix(hash, streamSize, fields[0], fields[1]);
stream->seek(streamSize - MVC::FieldSize);
for(u32 byte : range(MVC::FieldSize)) hash.input(stream->read());
auto output = hash.output();
for(u32 index : range(fingerprint.size())) fingerprint[index] = output[index];
}
auto load() -> void override {
cartridge.node->setAttribute("error");
stream = pak->read("stream.mvc");
if(!stream) return fail("MovieCart package is missing stream.mvc");
streamSize = stream->size();
if(streamSize < MVC::MinimumSize || streamSize % MVC::FieldSize) return fail("invalid MovieCart stream size");
if(streamSize / MVC::FieldSize > 0xffffffffull) return fail("MovieCart stream has too many fields");
fieldCount = streamSize / MVC::FieldSize;
if(!readField(0, 0) || !readField(1, 1)) return fail("invalid initial MovieCart field");
calculateFingerprint();
ready = true;
}
auto unload() -> void override {
stream.reset();
for(auto& field : fields) field.fill(0);
descriptors[0] = {};
descriptors[1] = {};
loadedFields = {~0u, ~0u};
blankFields = {};
fingerprint.fill(0);
streamSize = 0;
fieldCount = 0;
ready = false;
}
auto activateField() -> void {
auto& descriptor = descriptors[(u32)activeBuffer];
scanline = 0;
if(!descriptor.valid) return;
odd = descriptor.embeddedFrame & 1;
kernel.image[kernel.vsyncLines] = descriptor.vsync;
kernel.image[kernel.vblankLines] = descriptor.vblank;
kernel.image[kernel.overscanLines] = descriptor.overscan;
kernel.image[kernel.visibleDone + 0] = StreamRoutine & 0xff;
kernel.image[kernel.visibleDone + 1] = StreamRoutine >> 8;
if(blankFields[(u32)activeBuffer]) {
cartridge.node->setAttribute("error", string{"invalid MovieCart field ", fieldNumber});
} else {
cartridge.node->setAttribute("error");
}
patchLeft();
}
auto clearLeft() -> void {
kernel.image[kernel.background] = 0;
for(u32 cell : range(3)) kernel.image[kernel.playfieldColor[cell]] = 0;
kernel.image[kernel.playfield0Left] = 0;
kernel.image[kernel.playfield1Left] = 0;
kernel.image[kernel.playfield2Left] = 0;
}
auto clearRight() -> void {
for(u32 cell : range(3, 5)) kernel.image[kernel.playfieldColor[cell]] = 0;
kernel.image[kernel.playfield0Right] = 0;
kernel.image[kernel.playfield1Right] = 0;
kernel.image[kernel.playfield2Right] = 0;
}
static auto reverseByte(u8 value) -> u8 {
value = (value & 0x55) << 1 | (value & 0xaa) >> 1;
value = (value & 0x33) << 2 | (value & 0xcc) >> 2;
return value << 4 | value >> 4;
}
static auto reverseNybble(u8 value) -> u8 {
value &= 15;
return ((value & 1) << 3) | ((value & 2) << 1) | ((value & 4) >> 1) | ((value & 8) >> 3);
}
auto adjustColor(u8 color) const -> u8 {
auto luminance = ((color & 0x0e) * brightness / 15) & 0x0e;
return (monochrome ? 0 : color & 0xf0) | luminance;
}
static auto titlePixel(u32 x, u32 y) -> bool {
auto letterM = (x == 2 || x == 11) || (y < 5 && (x == 2 + y || x == 11 - y));
auto letterV = x == 15 + y / 2 || x == 24 - y / 2;
auto letterC = (x == 28 && y > 0 && y < 11) || ((y == 0 || y == 11) && x >= 29 && x <= 37);
return letterM || letterV || letterC;
}
auto titleByte(u32 visibleLine, u32 cell, u32 visibleLines) const -> u8 {
static constexpr u32 height = 12;
auto presentationLines = Region::NTSC() ? 192u : 228u;
auto top = (presentationLines - height) / 2;
if(visibleLines < top + height) top = visibleLines > height ? visibleLines - height : 0;
if(visibleLine < top || visibleLine >= top + height) return 0;
auto y = visibleLine - top;
u8 output = 0;
for(u32 bit : range(8)) if(titlePixel(cell * 8 + bit, y)) output |= 0x80 >> bit;
return output;
}
auto patchLeft() -> void {
auto buffer = (u32)activeBuffer;
auto& descriptor = descriptors[buffer];
if(blankFields[buffer] || !descriptor.valid || scanline >= descriptor.audioCount) {
clearLeft();
for(auto operand : kernel.audioVolume) kernel.image[operand] = 0;
return;
}
auto visibleStart = (u32)descriptor.vsync + descriptor.vblank;
if(titleState != TitleState::Stream) {
for(auto operand : kernel.audioVolume) kernel.image[operand] = 0;
if(scanline < visibleStart || scanline >= visibleStart + descriptor.visible) return clearLeft();
auto visibleLine = scanline - visibleStart;
auto graph0 = titleByte(visibleLine, 0, descriptor.visible);
auto graph1 = titleByte(visibleLine, 1, descriptor.visible);
auto graph2 = titleByte(visibleLine, 2, descriptor.visible);
kernel.image[kernel.background] = adjustColor(((visibleLine / 12 + 1) & 15) << 4 | 0x02);
for(u32 cell : range(3)) kernel.image[kernel.playfieldColor[cell]] = adjustColor(0x0e);
kernel.image[kernel.playfield0Left] = reverseNybble(graph0 >> 4) << 4;
kernel.image[kernel.playfield1Left] = graph0 << 4 | graph1 >> 4;
kernel.image[kernel.playfield2Left] = reverseByte(graph1 << 4 | graph2 >> 4);
return;
}
auto& field = fields[buffer];
auto audio = muteFields ? 0 : (field[descriptor.audioOffset + scanline] & 15) * volume / 15;
for(auto operand : kernel.audioVolume) kernel.image[operand] = audio;
if(scanline < visibleStart || scanline >= visibleStart + descriptor.visible) {
clearLeft();
return;
}
auto visibleLine = scanline - visibleStart;
auto overlay = osdMode && visibleLine < descriptor.timecodeCount / 5;
auto graph = overlay ? descriptor.timecodeOffset + visibleLine * 5
: descriptor.graphOffset + visibleLine * 5;
auto color = descriptor.colorOffset + visibleLine * 5;
auto backgroundLine = min<u32>(visibleLine + !odd, descriptor.backgroundCount - 1);
auto graph0 = field[graph + 0];
auto graph1 = field[graph + 1];
auto graph2 = field[graph + 2];
kernel.image[kernel.background] = overlay ? 0 : adjustColor(field[descriptor.backgroundOffset + backgroundLine]);
for(u32 cell : range(3)) {
kernel.image[kernel.playfieldColor[cell]] = overlay ? adjustColor(0x0e) : adjustColor(field[color + cell]);
}
kernel.image[kernel.playfield0Left] = reverseNybble(graph0 >> 4) << 4;
kernel.image[kernel.playfield1Left] = graph0 << 4 | graph1 >> 4;
kernel.image[kernel.playfield2Left] = reverseByte(graph1 << 4 | graph2 >> 4);
}
auto patchRight() -> void {
auto buffer = (u32)activeBuffer;
auto& descriptor = descriptors[buffer];
auto visibleStart = (u32)descriptor.vsync + descriptor.vblank;
if(blankFields[buffer] || !descriptor.valid || scanline < visibleStart
|| scanline >= visibleStart + descriptor.visible) {
clearRight();
return;
}
if(titleState != TitleState::Stream) {
auto visibleLine = scanline - visibleStart;
auto graph2 = titleByte(visibleLine, 2, descriptor.visible);
kernel.image[kernel.playfield0Right] = reverseNybble(graph2) << 4;
kernel.image[kernel.playfield1Right] = titleByte(visibleLine, 3, descriptor.visible);
kernel.image[kernel.playfield2Right] = reverseByte(titleByte(visibleLine, 4, descriptor.visible));
kernel.image[kernel.playfieldColor[3]] = adjustColor(0x0e);
kernel.image[kernel.playfieldColor[4]] = adjustColor(0x0e);
return;
}
auto& field = fields[buffer];
auto visibleLine = scanline - visibleStart;
auto overlay = osdMode && visibleLine < descriptor.timecodeCount / 5;
auto graph = overlay ? descriptor.timecodeOffset + visibleLine * 5
: descriptor.graphOffset + visibleLine * 5;
auto color = descriptor.colorOffset + visibleLine * 5;
auto graph2 = field[graph + 2];
kernel.image[kernel.playfield0Right] = reverseNybble(graph2) << 4;
kernel.image[kernel.playfield1Right] = field[graph + 3];
kernel.image[kernel.playfield2Right] = reverseByte(field[graph + 4]);
kernel.image[kernel.playfieldColor[3]] = overlay ? adjustColor(0x0e) : adjustColor(field[color + 3]);
kernel.image[kernel.playfieldColor[4]] = overlay ? adjustColor(0x0e) : adjustColor(field[color + 4]);
}
auto advanceField() -> void {
if(titleState != TitleState::Stream) {
a10Pulses = 0;
previousCommand = 0;
fieldNumber = 0;
activeBuffer = loadedFields[0] == 0 ? 0 : 1;
activateField();
updateStatus();
return;
}
auto command = min<u32>(a10Pulses, 10);
a10Pulses = 0;
if(muteFields) muteFields--;
s32 seek = 0;
bool restart = false;
bool step = false;
auto fresh = command != previousCommand;
if(command == 2 || command == 3) {
if(fresh) {
repeatFields = 0;
seekSpeed = 2;
} else {
if(repeatFields < 255) repeatFields++;
if(repeatFields && repeatFields % 30 == 0) seekSpeed = min<u32>(seekSpeed * 2, 64);
}
seek = command == 2 ? -(s32)seekSpeed : +(s32)seekSpeed;
} else {
repeatFields = 0;
seekSpeed = 2;
}
if(fresh) {
if(command == 1) playing = !playing;
if(command == 4) {
if(osdMode == 2 && brightness < 15) brightness++;
else if(osdMode != 2 && volume < 15) volume++;
}
if(command == 5) {
if(osdMode == 2 && brightness > 0) brightness--;
else if(osdMode != 2 && volume > 0) volume--;
}
if(command == 6) osdMode = (osdMode + 1) % 3;
if(command == 7) {
restart = true;
playing = true;
}
if(command == 8) monochrome = !monochrome;
if(command == 9) seek = -(s32)descriptors[(u32)activeBuffer].rate * 10;
if(command == 10) {
playing = false;
step = true;
}
}
previousCommand = command;
s64 requested = fieldNumber;
if(restart) requested = 0;
else if(seek) requested += seek;
else if(step) requested++;
else if(playing) requested++;
while(requested < 0) requested += 2;
auto reachedEOF = requested >= fieldCount;
while(requested >= fieldCount) requested -= 2;
if(reachedEOF) {
repeatFields = 0;
seekSpeed = 2;
muteFields = 2;
}
auto next = (u32)requested;
auto targetBuffer = next == fieldNumber ? (u32)activeBuffer : (u32)!activeBuffer;
if(loadedFields[targetBuffer] != next) readField(next, targetBuffer);
fieldNumber = next;
activeBuffer = targetBuffer;
auto lookahead = fieldNumber + 1;
if(lookahead >= fieldCount) lookahead = fieldCount - 2;
auto lookaheadBuffer = (u32)!activeBuffer;
if(loadedFields[lookaheadBuffer] != lookahead) readField(lookahead, lookaheadBuffer);
activateField();
updateStatus();
}
auto process(n16 address) -> void {
if(titleState == TitleState::Display && ++titleCycles >= TitleCycles) titleState = TitleState::Exiting;
auto nextA10 = address.bit(10);
if(!a10 && nextA10 && !address.bit(7)) a10Pulses++;
a10 = nextA10;
auto nextA7 = address.bit(7);
if(!streamStarted) {
auto routine = address & 0x03ff;
if(nextA7 && (routine == (StreamRoutine & 0x03ff) || routine == (BlankRoutine & 0x03ff))) {
streamStarted = true;
patchRight();
}
a7 = nextA7;
return;
}
if(titleState == TitleState::Exiting && !a7 && nextA7) {
titleState = TitleState::Stream;
fieldNumber = 0;
activeBuffer = loadedFields[0] == 0 ? 0 : 1;
activateField();
updateStatus();
}
if(!a7 && nextA7) patchRight();
if(a7 && !nextA7) {
scanline++;
auto& descriptor = descriptors[(u32)activeBuffer];
auto totalLines = (u32)descriptor.vsync + descriptor.vblank + descriptor.visible + descriptor.overscan;
if(!descriptor.valid || scanline >= totalLines) advanceField();
else {
patchLeft();
auto visibleEnd = (u32)descriptor.vsync + descriptor.vblank + descriptor.visible;
if(scanline == visibleEnd) {
kernel.image[kernel.visibleDone + 0] = kernel.visibleExit & 0xff;
kernel.image[kernel.visibleDone + 1] = kernel.visibleExit >> 8;
}
}
}
a7 = nextA7;
}
auto power(bool) -> void override {
if(!ready) return;
buildKernel();
if(!readField(0, 0) || !readField(1, 1)) return fail("MovieCart stream changed while attached");
fieldNumber = 0;
activeBuffer = 0;
odd = 0;
a7 = 0;
a10 = 0;
a10Pulses = 0;
streamStarted = false;
previousCommand = 0;
repeatFields = 0;
seekSpeed = 2;
muteFields = 0;
volume = 15;
brightness = 15;
osdMode = 0;
monochrome = false;
playing = true;
titleState = TitleState::Display;
titleCycles = 0;
activateField();
updateStatus();
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!ready || !address.bit(12)) return data;
process(address);
return kernel.image[address & 0x03ff];
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(ready && address.bit(12)) process(address);
return data;
}
auto serializeDescriptor(serializer& s, MVC::FieldDescriptor& descriptor) -> void {
s(descriptor.valid);
s(descriptor.extended);
s(descriptor.signatureOffset);
s(descriptor.vsync);
s(descriptor.vblank);
s(descriptor.overscan);
s(descriptor.visible);
s(descriptor.rate);
s(descriptor.embeddedFrame);
s(descriptor.audioOffset);
s(descriptor.audioCount);
s(descriptor.graphOffset);
s(descriptor.graphCount);
s(descriptor.colorOffset);
s(descriptor.colorCount);
s(descriptor.backgroundOffset);
s(descriptor.backgroundCount);
s(descriptor.timecodeOffset);
s(descriptor.timecodeCount);
}
auto serialize(serializer& s) -> void override {
if(!ready) return;
auto savedSize = streamSize;
auto savedFingerprint = fingerprint;
s(std::span<u8>{kernel.image.data(), kernel.image.size()});
for(auto& field : fields) s(std::span<u8>{field.data(), field.size()});
serializeDescriptor(s, descriptors[0]);
serializeDescriptor(s, descriptors[1]);
for(auto& loadedField : loadedFields) s(loadedField);
for(auto& blankField : blankFields) s(blankField);
s(std::span<u8>{savedFingerprint.data(), savedFingerprint.size()});
s(savedSize);
s(fieldNumber);
s(scanline);
s(activeBuffer);
s(odd);
s(a7);
s(a10);
s(a10Pulses);
s(streamStarted);
s(previousCommand);
s(repeatFields);
s(seekSpeed);
s(muteFields);
s(volume);
s(brightness);
s(osdMode);
s(monochrome);
s(playing);
s(titleState);
s(titleCycles);
if(s.reading()) {
if(savedSize != streamSize || savedFingerprint != fingerprint) return fail("MovieCart state media mismatch");
MVC::FieldDescriptor parsed[2];
if(!MVC::parseField(fields[0], parsed[0]) || !MVC::parseField(fields[1], parsed[1])
|| parsed[0] != descriptors[0] || parsed[1] != descriptors[1]) {
return fail("invalid MovieCart field state");
}
auto& descriptor = descriptors[(u32)activeBuffer];
auto totalLines = (u32)descriptor.vsync + descriptor.vblank + descriptor.visible + descriptor.overscan;
if(fieldNumber >= fieldCount || loadedFields[0] >= fieldCount || loadedFields[1] >= fieldCount
|| loadedFields[(u32)activeBuffer] != fieldNumber || scanline >= totalLines
|| previousCommand > 10 || !seekSpeed || seekSpeed > 64 || volume > 15 || brightness > 15 || osdMode > 2
|| (u32)titleState > (u32)TitleState::Stream || titleCycles > TitleCycles) {
return fail("invalid MovieCart cursor state");
}
updateStatus();
}
}
};
@@ -0,0 +1,48 @@
struct ParkerBros03E0 : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n3 chunks[3];
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
if(address.bit(12)) {
u32 segment = address.bit(10, 11);
u32 chunk = 7;
if(segment < 3) chunk = chunks[segment];
return rom.read(chunk * 0x400 + (address & 0x03ff));
}
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
return data;
}
auto power(bool reset) -> void override {
chunks[0] = 4;
chunks[1] = 5;
chunks[2] = 6;
}
auto serialize(serializer& s) -> void override {
s(chunks[0]);
s(chunks[1]);
s(chunks[2]);
}
private:
auto select(n16 address) -> void {
if(address < 0x0380 || address > 0x03ff) return;
auto chunk = address & 7;
if(!address.bit(4)) chunks[0] = chunk;
if(!address.bit(5)) chunks[1] = chunk;
if(!address.bit(6)) chunks[2] = chunk;
}
};
+5 -5
View File
@@ -13,7 +13,7 @@ struct ParkerBros : Interface {
auto unload() -> void override {
}
auto read(n16 address) -> n8 override {
auto read(n16 address, n8 data) -> n8 override {
bankswitch(address);
if(address.bit(12)) {
@@ -23,12 +23,12 @@ struct ParkerBros : Interface {
if(address >= 0x1c00 && address <= 0x1fff) return rom.read(( 7 * 0x400) + (address & 0x3ff));
}
return 0xff;
return data;
}
auto write(n16 address, n8 data) -> bool override {
auto write(n16 address, n8 data) -> n8 override {
bankswitch(address);
return false;
return data;
}
auto bankswitch(n16 address) -> void {
@@ -37,7 +37,7 @@ struct ParkerBros : Interface {
if(address >= 0x1ff0 && address <= 0x1ff7) banks[2] = address - 0x1ff0;
}
auto power() -> void override {
auto power(bool reset) -> void override {
banks[0] = 0;
banks[1] = 1;
banks[2] = 2;
+32
View File
@@ -0,0 +1,32 @@
struct SaraRam {
SaraRam(bool present = false) : present(present) {}
auto readable(n16 address) -> bool {
return present && address >= 0x1000 && address <= 0x10ff;
}
auto read(n16 address, n8 data) -> n8 {
if(address <= 0x107f) {
ram.write(address & 0x7f, data);
return data;
}
return ram.read(address & 0x7f);
}
auto write(n16 address, n8 data) -> bool {
if(!present || address < 0x1000 || address > 0x107f) return false;
ram.write(address & 0x7f, data);
return true;
}
auto power() -> void {
if(present) ram.allocate(128, 0x00);
}
auto serialize(serializer& s) -> void {
if(present) s(ram);
}
const bool present;
Memory::Writable<n8> ram;
};
+34
View File
@@ -0,0 +1,34 @@
struct Superbanking : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n6 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
select(address);
if(address.bit(12)) return rom.read(bank * 0x1000 + (address & 0x0fff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
select(address & 0x1fff);
return data;
}
auto power(bool reset) -> void override {
bank = (rom.size() >> 12) - 1;
}
auto serialize(serializer& s) -> void override {
s(bank);
}
private:
auto select(n16 address) -> void {
if((address & 0x1800) == 0x0800) bank = address & ((rom.size() >> 12) - 1);
}
};
+60
View File
@@ -0,0 +1,60 @@
struct ThreeEPlus : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
n1 ramSelected[4];
n6 bank[4];
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
auto segment = address.bit(10, 11);
auto offset = address & 0x03ff;
if(!ramSelected[segment]) return rom.read((u32)(bank[segment] % (rom.size() >> 10)) * 0x400 + offset);
auto ramOffset = (u32)bank[segment] * 0x200 + (offset & 0x01ff);
if(!(offset & 0x0200)) return ram.read(ramOffset);
ram.write(ramOffset, data);
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(address == 0x003e || address == 0x003f) {
auto segment = data.bit(6, 7);
ramSelected[segment] = address == 0x003e;
bank[segment] = data.bit(0, 5);
return data;
}
if(!address.bit(12)) return data;
auto segment = address.bit(10, 11);
auto offset = address & 0x03ff;
if(ramSelected[segment] && (offset & 0x0200)) {
ram.write((u32)bank[segment] * 0x200 + (offset & 0x01ff), data);
return data;
}
return data;
}
auto power(bool reset) -> void override {
for(auto segment : range(4)) {
ramSelected[segment] = 0;
bank[segment] = 0;
}
ram.allocate(32_KiB, 0x00);
}
auto serialize(serializer& s) -> void override {
for(auto segment : range(4)) {
s(ramSelected[segment]);
s(bank[segment]);
}
s(ram);
}
};
+56
View File
@@ -0,0 +1,56 @@
struct ThreeE : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
n1 ramSelected;
n8 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
if(address.bit(11)) return rom.read(rom.size() - 0x800 + (address & 0x07ff));
if(!ramSelected) return rom.read(bank * 0x800 + (address & 0x07ff));
auto offset = bank * 0x400 + (address & 0x03ff);
if(!address.bit(10)) return ram.read(offset);
ram.write(offset, data);
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(address == 0x003e) {
ramSelected = 1;
bank = data & 31;
return data;
}
if(address == 0x003f) {
ramSelected = 0;
bank = data % (rom.size() >> 11);
return data;
}
if(ramSelected && address >= 0x1400 && address <= 0x17ff) {
ram.write(bank * 0x400 + (address & 0x03ff), data);
return data;
}
return data;
}
auto power(bool reset) -> void override {
//Stella powers bank 0 and MAME the final bank.
//Boulder Dash Demo 2 selects bank 1 before using the lower window.
ramSelected = 0;
bank = 1;
ram.allocate(32_KiB, 0x00);
}
auto serialize(serializer& s) -> void override {
s(ramSelected);
s(bank);
s(ram);
}
};
+57
View File
@@ -0,0 +1,57 @@
struct ThreeEX : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
n1 ramSelected;
n8 bank;
u16 ramBankCount = 1;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(!address.bit(12)) return data;
if(address.bit(11)) return rom.read(rom.size() - 0x800 + (address & 0x07ff));
if(!ramSelected) return rom.read(bank * 0x800 + (address & 0x07ff));
auto offset = bank * 0x400 + (address & 0x03ff);
if(!address.bit(10)) return ram.read(offset);
ram.write(offset, data);
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
if(address == 0x003e) {
ramSelected = 1;
bank = data % ramBankCount;
return data;
}
if(address == 0x003f) {
ramSelected = 0;
bank = data % (rom.size() >> 11);
return data;
}
if(ramSelected && address >= 0x1400 && address <= 0x17ff) {
ram.write(bank * 0x400 + (address & 0x03ff), data);
return data;
}
return data;
}
auto power(bool reset) -> void override {
ramSelected = 0;
bank = 1;
ramBankCount = (u16)rom.read(rom.size() - 6);
ramBankCount++;
ram.allocate(ramBankCount * 1_KiB, 0x00);
}
auto serialize(serializer& s) -> void override {
s(ramSelected);
s(bank);
s(ram);
}
};
+5 -5
View File
@@ -14,23 +14,23 @@ struct Tigervision : Interface {
auto unload() -> void override {
}
auto read(n16 address) -> n8 override {
auto read(n16 address, n8 data) -> n8 override {
if(address.bit(12)) {
if(bank != nextBank) bank = nextBank;
if(address <= 0x17ff) return rom.read((bank * 0x800) + (address & 0x7ff));
return rom.read((rom.size() - 0x800) + (address & 0x7ff));
}
return 0xff;
return data;
}
auto write(n16 address, n8 data) -> bool override {
auto write(n16 address, n8 data) -> n8 override {
if(address.bit(12) && bank != nextBank) bank = nextBank;
if(address <= 0x3f) nextBank = data;
return false;
return data;
}
auto power() -> void override {
auto power(bool reset) -> void override {
bank = 0;
nextBank = 0;
}
+41
View File
@@ -0,0 +1,41 @@
struct UA8k : Interface {
UA8k(Cartridge& cartridge, bool swapped = false) : Interface(cartridge), swapped(swapped) {}
Memory::Readable<n8> rom;
const bool swapped;
n1 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto save() -> void override {
}
auto unload() -> void override {
}
auto read(n16 address, n8 data) -> n8 override {
bankswitch(address);
if(address.bit(12)) return rom.read((bank * 0x1000) + (address & 0x0fff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
bankswitch(address);
return data;
}
auto power(bool reset) -> void override {
bank = 0;
}
auto serialize(serializer& s) -> void override {
s(bank);
}
private:
auto bankswitch(n16 address) -> void {
if((address & 0x1260) == 0x0220) bank = swapped ? 1 : 0;
if((address & 0x1260) == 0x0240) bank = swapped ? 0 : 1;
}
};
+86
View File
@@ -0,0 +1,86 @@
struct Wickstead : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
Memory::Writable<n8> ram;
n3 arrangement;
n3 pendingArrangement;
u8 delay;
bool pending;
static constexpr u8 arrangements[8][4] = {
{0, 0, 1, 3},
{0, 1, 2, 3},
{4, 5, 6, 7},
{7, 4, 2, 3},
{0, 0, 6, 7},
{0, 1, 7, 6},
{2, 3, 4, 5},
{6, 0, 5, 1},
};
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
advance(true);
if(address >= 0x0030 && address <= 0x003f) {
pendingArrangement = address & 7;
delay = 3;
pending = true;
return data;
}
if(address >= 0x1000 && address <= 0x103f) return ram.read(address & 0x3f);
if(address >= 0x1040 && address <= 0x107f) {
ram.write(address & 0x3f, data);
return data;
}
if(address.bit(12)) {
auto segment = (address >> 10) & 3;
auto chunk = arrangements[arrangement][segment];
return rom.read(chunk * 1_KiB + (address & 0x3ff));
}
return data;
}
auto write(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
advance(false);
if(address >= 0x1040 && address <= 0x107f) {
ram.write(address & 0x3f, data);
return data;
}
return data;
}
auto power(bool reset) -> void override {
arrangement = 0;
pendingArrangement = 0;
delay = 0;
pending = false;
ram.allocate(64, 0x00);
}
auto serialize(serializer& s) -> void override {
s(arrangement);
s(pendingArrangement);
s(delay);
s(pending);
s(ram);
}
private:
auto advance(bool isRead) -> void {
if(!pending) return;
if(delay) {
delay--;
return;
}
if(isRead) {
arrangement = pendingArrangement;
pending = false;
}
}
};
+39
View File
@@ -0,0 +1,39 @@
struct X07 : Interface {
using Interface::Interface;
Memory::Readable<n8> rom;
n4 bank;
auto load() -> void override {
Interface::load(rom, "program.rom");
}
auto read(n16 address, n8 data) -> n8 override {
address &= 0x1fff;
bankswitch(address);
if(address.bit(12)) return rom.read(bank * 0x1000 + (address & 0x0fff));
return data;
}
auto write(n16 address, n8 data) -> n8 override {
bankswitch(address & 0x1fff);
return data;
}
auto power(bool reset) -> void override {
bank = 0;
}
auto serialize(serializer& s) -> void override {
s(bank);
}
private:
auto bankswitch(n16 address) -> void {
if((address & 0x180f) == 0x080d) {
bank = address.bit(4, 7);
} else if((address & 0x1880) == 0 && bank >= 14) {
bank = 14 | address.bit(6);
}
}
};
+89 -18
View File
@@ -18,24 +18,72 @@ auto Cartridge::connect() -> void {
information.title = pak->attribute("title");
information.region = pak->attribute("region");
information.board = pak->attribute("board");
information.phosphor = pak->attribute("phosphor").boolean();
if(auto fp = pak->read("program.rom")) {
information.sha256 = Hash::SHA256({fp->data(), fp->size()}).digest();
}
if(information.board == "Linear") board = new Board::Linear{*this};
if(information.board == "Atari8k") board = new Board::Atari8k{*this};
if(information.board == "Atari16k") board = new Board::Atari16k{*this};
if(information.board == "Atari32k") board = new Board::Atari32k{*this};
if(information.board == "Commavid") board = new Board::Commavid{*this};
if(information.board == "ParkerBros8k") board = new Board::ParkerBros{*this};
if(information.board == "Tigervision") board = new Board::Tigervision{*this};
if(information.board == "Linear") board = std::make_unique<Board::Linear>(*this);
if(information.board == "Activision8k") board = std::make_unique<Board::Activision8k>(*this);
if(information.board == "Atari8k") board = std::make_unique<Board::Atari8k>(*this);
if(information.board == "Atari8kSC") board = std::make_unique<Board::Atari8k>(*this, true);
if(information.board == "Atari16k") board = std::make_unique<Board::Atari16k>(*this);
if(information.board == "Atari16kSC") board = std::make_unique<Board::Atari16k>(*this, true);
if(information.board == "Atari32k") board = std::make_unique<Board::Atari32k>(*this);
if(information.board == "Atari32kSC") board = std::make_unique<Board::Atari32k>(*this, true);
if(information.board == "Commavid") board = std::make_unique<Board::Commavid>(*this);
if(information.board == "ParkerBros8k") board = std::make_unique<Board::ParkerBros>(*this);
if(information.board == "ParkerBros03E0") board = std::make_unique<Board::ParkerBros03E0>(*this);
if(information.board == "JVP") board = std::make_unique<Board::JVP>(*this);
if(information.board == "Tigervision") board = std::make_unique<Board::Tigervision>(*this);
if(information.board == "UA8k") board = std::make_unique<Board::UA8k>(*this);
if(information.board == "UASW") board = std::make_unique<Board::UA8k>(*this, true);
if(information.board == "CbsRamPlus") board = std::make_unique<Board::CbsRamPlus>(*this);
if(information.board == "MNetwork") board = std::make_unique<Board::MNetwork>(*this);
if(information.board == "AmigaFC") board = std::make_unique<Board::AmigaFC>(*this);
if(information.board == "Wickstead") board = std::make_unique<Board::Wickstead>(*this);
if(information.board == "Jane") board = std::make_unique<Board::Jane>(*this);
if(information.board == "DPC") board = std::make_unique<Board::DPC>(*this);
if(information.board == "MegaBoy") board = std::make_unique<Board::MegaBoy>(*this);
if(information.board == "Atari32In1") board = std::make_unique<Board::Atari32In1>(*this);
if(!board) board = new Board::Interface{*this};
//Homebrew
if(information.board == "DPC+") board = std::make_unique<Board::DPCPlus>(*this);
if(information.board == "CDF") board = std::make_unique<Board::CDF>(*this);
if(information.board == "BUS") board = std::make_unique<Board::BUS>(*this);
if(information.board == "Chetiry") board = std::make_unique<Board::Chetiry>(*this);
if(information.board == "FA2") board = std::make_unique<Board::FA2>(*this);
if(information.board == "ELF") board = std::make_unique<Board::ELFCartridge>(*this);
if(information.board == "MovieCart") board = std::make_unique<Board::MovieCart>(*this);
if(information.board == "4KSC") board = std::make_unique<Board::CPUWiz4KSC>(*this);
if(information.board == "3E") board = std::make_unique<Board::ThreeE>(*this);
if(information.board == "3EX") board = std::make_unique<Board::ThreeEX>(*this);
if(information.board == "3E+") board = std::make_unique<Board::ThreeEPlus>(*this);
if(information.board == "Enhanced3F") board = std::make_unique<Board::Enhanced3F>(*this);
if(information.board == "4A50") board = std::make_unique<Board::FourA50>(*this);
if(information.board == "EF") board = std::make_unique<Board::EF>(*this);
if(information.board == "EFF") board = std::make_unique<Board::EFF>(*this);
if(information.board == "DF") board = std::make_unique<Board::DF>(*this);
if(information.board == "BF") board = std::make_unique<Board::BF>(*this);
if(information.board == "EFSC") board = std::make_unique<Board::EFSC>(*this);
if(information.board == "DFSC") board = std::make_unique<Board::DFSC>(*this);
if(information.board == "BFSC") board = std::make_unique<Board::BFSC>(*this);
if(information.board == "MDM") board = std::make_unique<Board::MDM>(*this);
if(information.board == "X07") board = std::make_unique<Board::X07>(*this);
if(information.board == "EconoBanking") board = std::make_unique<Board::EconoBanking>(*this);
if(information.board == "Superbanking") board = std::make_unique<Board::Superbanking>(*this);
if(!board) board = std::make_unique<Board::Interface>(*this);
board->pak = pak;
board->load();
power();
video.setPhosphor(information.phosphor);
power(false);
}
auto Cartridge::disconnect() -> void {
if(!node || !board) return;
board->unload();
video.setPhosphor(false);
board->pak.reset();
board.reset();
node.reset();
@@ -46,21 +94,44 @@ auto Cartridge::save() -> void {
if(board) board->save();
}
auto Cartridge::power() -> void {
if(board) board->power();
auto Cartridge::power(bool reset) -> void {
if(board) board->power(reset);
}
auto Cartridge::read(n16 address) -> n8 {
if(!node) return 0xff;
if(board) return board->read(address);
return 0xff;
auto Cartridge::read(n16 address, n8 data) -> n8 {
if(!node) return data;
if(board) return board->read(address, data);
return data;
}
auto Cartridge::write(n16 address, n8 data) -> bool {
if(!node) return false;
auto Cartridge::write(n16 address, n8 data) -> n8 {
if(!node) return data;
if(board) return board->write(address, data);
return data;
}
auto Cartridge::armInvocation() const -> Harmony::Invocation {
if(board) return board->armInvocation();
return {};
}
auto Cartridge::readARM(u32 mode, n32 address, n32& data) -> Harmony::Access {
if(board) return board->readARM(mode, address, data);
return Harmony::Access::Unmapped;
}
auto Cartridge::writeARM(u32 mode, n32 address, n32 data) -> Harmony::Access {
if(board) return board->writeARM(mode, address, data);
return Harmony::Access::Unmapped;
}
auto Cartridge::trapARM(u32 address, n32& value, n32 argument) -> bool {
if(board) return board->trapARM(address, value, argument);
return false;
}
auto Cartridge::stepARM(u32 clocks) -> void {
if(board) board->stepARM(clocks);
}
}
+13 -4
View File
@@ -7,6 +7,7 @@ struct Cartridge {
auto title() const -> string { return information.title; }
auto region() const -> string { return information.region; }
auto sha256() const -> string { return information.sha256; }
//cartridge.cpp
auto allocate(Node::Port) -> Node::Peripheral;
@@ -14,21 +15,29 @@ struct Cartridge {
auto disconnect() -> void;
auto save() -> void;
auto power() -> void;
auto power(bool reset) -> void;
auto read(n16 address) -> n8;
auto write(n16 address, n8 data) -> bool;
auto read(n16 address, n8 data) -> n8;
auto write(n16 address, n8 data) -> n8;
auto armInvocation() const -> Harmony::Invocation;
auto readARM(u32 mode, n32 address, n32& data) -> Harmony::Access;
auto writeARM(u32 mode, n32 address, n32 data) -> Harmony::Access;
auto trapARM(u32 address, n32& value, n32 argument) -> bool;
auto stepARM(u32 clocks) -> void;
//serialization.cpp
auto serialize(serializer&) -> void;
unique_pointer<Board::Interface> board;
std::unique_ptr<Board::Interface> board;
//private:
struct Information {
string title;
string region;
string board;
string sha256;
bool phosphor;
} information;
};
@@ -0,0 +1,9 @@
AmigaMouse::AmigaMouse(Node::Port parent)
: RelativePointingDevice(parent, "Amiga Mouse", 4) {
}
auto AmigaMouse::encode(u8 xPhase, u8 yPhase, bool, bool) const -> u8 {
static constexpr u8 horizontal[4] = {0b0000, 0b1000, 0b1010, 0b0010};
static constexpr u8 vertical[4] = {0b0000, 0b0100, 0b0101, 0b0001};
return horizontal[xPhase & 3] | vertical[yPhase & 3];
}
@@ -0,0 +1,6 @@
struct AmigaMouse : RelativePointingDevice {
AmigaMouse(Node::Port);
protected:
auto encode(u8 xPhase, u8 yPhase, bool left, bool down) const -> u8 override;
};
@@ -0,0 +1,9 @@
AtariMouse::AtariMouse(Node::Port parent)
: RelativePointingDevice(parent, "Atari Mouse", 4) {
}
auto AtariMouse::encode(u8 xPhase, u8 yPhase, bool, bool) const -> u8 {
static constexpr u8 horizontal[4] = {0b0000, 0b0001, 0b0011, 0b0010};
static constexpr u8 vertical[4] = {0b0000, 0b0100, 0b1100, 0b1000};
return horizontal[xPhase & 3] | vertical[yPhase & 3];
}
@@ -0,0 +1,6 @@
struct AtariMouse : RelativePointingDevice {
AtariMouse(Node::Port);
protected:
auto encode(u8 xPhase, u8 yPhase, bool left, bool down) const -> u8 override;
};
+92
View File
@@ -0,0 +1,92 @@
AtariVox::AtariVox(Node::Port parent) : SaveKey(parent, "AtariVox", "atarivox.eeprom") {
stream = node->append<Node::Audio::Stream>("AtariVox");
stream->setChannels(1);
stream->setFrequency(SpeakJet::Frequency);
speakjet.reset();
serialBits = 0;
serialData = 0;
serialValid = 1;
serialCycle = 0;
Thread::create(SpeakJet::Frequency, std::bind_front(&AtariVox::main, this));
}
AtariVox::~AtariVox() {
Thread::destroy();
stream.reset();
}
auto AtariVox::main() -> void {
stream->frame(speakjet.clock());
Thread::step(1);
Thread::synchronize(cpu);
}
auto AtariVox::power(bool reset) -> void {
SaveKey::power(reset);
speakjet.reset();
serialBits = 0;
serialData = 0;
serialValid = 1;
serialCycle = 0;
Thread::create(SpeakJet::Frequency, std::bind_front(&AtariVox::main, this));
}
auto AtariVox::read() -> n8 {
n8 data = SaveKey::read();
data.bit(1) = speakjet.ready();
return data;
}
auto AtariVox::write(n8 data) -> void {
SaveKey::write(data);
receiveSerial(data.bit(0));
}
auto AtariVox::serialize(serializer& s) -> void {
SaveKey::serialize(s);
Thread::serialize(s);
speakjet.serialize(s);
s(serialBits);
s(serialData);
s(serialValid);
s(serialCycle);
}
auto AtariVox::receiveSerial(bool level) -> void {
if(!cpu.scalar()) return;
//The CPU Thread advances three color clocks per 6507 cycle. Stella's serial
//thresholds are expressed in CPU cycles, so compare in that same domain.
auto cycle = cpu.clock() / cpu.scalar() / 3;
if(serialBits && (cycle < serialCycle || cycle > serialCycle + 1000)) {
serialBits = 0;
serialData = 0;
serialValid = 1;
}
if(!serialBits && level) {
serialCycle = cycle;
return;
}
if(serialBits && cycle >= serialCycle && cycle < serialCycle + 62) {
serialCycle = cycle;
return;
}
if(serialBits == 0) {
serialValid = !level;
} else if(serialBits <= 8) {
serialData.bit(serialBits - 1) = level;
} else {
serialValid &= level;
}
serialCycle = cycle;
if(++serialBits < 10) return;
if(serialValid) speakjet.enqueue(serialData);
serialBits = 0;
serialData = 0;
serialValid = 1;
}
+23
View File
@@ -0,0 +1,23 @@
#include "speakjet.hpp"
struct AtariVox : SaveKey, Thread {
AtariVox(Node::Port);
~AtariVox();
auto main() -> void;
auto power(bool reset) -> void override;
auto read() -> n8 override;
auto write(n8 data) -> void override;
auto serialize(serializer&) -> void override;
private:
auto receiveSerial(bool level) -> void;
Node::Audio::Stream stream;
SpeakJet speakjet;
n4 serialBits;
n8 serialData;
n1 serialValid;
u64 serialCycle;
};
+347
View File
@@ -0,0 +1,347 @@
namespace {
constexpr u16 AllophoneDuration[] = {
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70, 70, 200, 200, 190,
200, 185, 165, 200, 225, 185, 170, 140, 180, 170, 170, 200,
131, 70, 70, 70, 70, 70, 45, 45, 10, 10, 45, 45,
10, 10, 55, 55, 55, 55, 70, 70, 70, 70, 70, 40,
40, 50, 40, 50, 70, 170, 55, 55, 55, 45, 99, 99,
};
constexpr u16 EffectDuration[] = {
80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
300, 101, 102, 540, 530, 500, 135, 600, 300, 250,
200, 270, 280, 260, 300, 100, 104, 100, 270, 262,
160, 300, 182, 120, 175, 350, 160, 260, 95, 75,
95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
125, 250, 530,
};
constexpr u16 PauseDuration[] = {0, 100, 200, 700, 30, 60, 90};
static_assert(std::size(AllophoneDuration) == 72);
static_assert(std::size(EffectDuration) == 55);
}
auto SpeakJet::reset() -> void {
std::fill(std::begin(fifo), std::end(fifo), 0);
fifoRead = 0;
fifoWrite = 0;
fifoCount = 0;
parameterPending = 0;
pendingCommand = 0;
waiting = 0;
volume = 96;
speed = 114;
pitch = 88;
bend = 5;
portControl = 7;
portOutput = 0;
repeatRequest = 0;
repeatCode = 0;
repeatRemaining = 0;
nextDurationScale = 1.0;
nextPitchScale = 1.0;
soundCode = 0;
soundClass = SoundClass::None;
soundSamples = 0;
soundRemaining = 0;
soundPitchScale = 1.0;
std::fill(std::begin(phase), std::end(phase), 0.0);
for(auto& stage : filter) std::fill(std::begin(stage), std::end(stage), 0.0);
noiseLfsr = 0x4a3d;
}
auto SpeakJet::enqueue(u8 data) -> bool {
if(fifoCount == 64) return false;
fifo[fifoWrite++] = data;
fifoCount++;
return true;
}
auto SpeakJet::clock() -> f64 {
if(!soundRemaining && !waiting) processCommands();
if(!soundRemaining) return 0.0;
auto sample = synthesize();
if(!--soundRemaining) finishSound();
return sample;
}
auto SpeakJet::serialize(serializer& s) -> void {
for(auto& byte : fifo) s(byte);
s(fifoRead);
s(fifoWrite);
s(fifoCount);
s(parameterPending);
s(pendingCommand);
s(waiting);
s(volume);
s(speed);
s(pitch);
s(bend);
s(portControl);
s(portOutput);
s(repeatRequest);
s(repeatCode);
s(repeatRemaining);
s(nextDurationScale);
s(nextPitchScale);
s(soundCode);
s(soundClass);
s(soundSamples);
s(soundRemaining);
s(soundPitchScale);
for(auto& value : phase) s(value);
for(auto& stage : filter) for(auto& value : stage) s(value);
s(noiseLfsr);
}
auto SpeakJet::dequeue() -> u8 {
if(!fifoCount) return 0;
auto data = fifo[fifoRead++];
fifoCount--;
return data;
}
auto SpeakJet::processCommands() -> void {
for(u32 commands : range(64)) {
if(parameterPending) {
if(!fifoCount) return;
parameter(pendingCommand, dequeue());
parameterPending = 0;
if(soundRemaining || waiting) return;
continue;
}
if(repeatRemaining) {
execute(repeatCode, true);
if(soundRemaining || waiting) return;
continue;
}
if(!fifoCount) return;
execute(dequeue());
if(soundRemaining || waiting) return;
}
}
auto SpeakJet::execute(u8 code, bool repeated) -> void {
if(repeated) repeatRemaining--;
if(code <= 6) {
startSound(code);
return;
}
switch(code) {
case 7: nextDurationScale = 0.5; return;
case 8: nextDurationScale = 1.5; return;
case 14: nextPitchScale = 1.08; return;
case 15: nextPitchScale = 0.92; return;
case 16: waiting = 1; return;
case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 28: case 29: case 30:
pendingCommand = code;
parameterPending = 1;
return;
case 31:
volume = 96;
speed = 114;
pitch = 88;
bend = 5;
nextDurationScale = 1.0;
nextPitchScale = 1.0;
return;
case 255:
repeatRequest = 0;
repeatRemaining = 0;
nextDurationScale = 1.0;
nextPitchScale = 1.0;
return;
}
if(code < 128) return;
if(!repeated && repeatRequest) {
repeatCode = code;
repeatRemaining = repeatRequest;
repeatRequest = 0;
}
startSound(code);
}
auto SpeakJet::parameter(u8 command, u8 value) -> void {
switch(command) {
case 20: volume = min(value, (u8)127); break;
case 21: speed = min(value, (u8)127); break;
case 22: pitch = value; break;
case 23: bend = min(value, (u8)15); break;
case 24: portControl = value & 7; break;
case 25: portOutput = value & 7; break;
case 26: repeatRequest = value; break;
case 28: break; //Phrase EEPROM execution is outside the behavioral model.
case 29: break; //Phrase EEPROM execution is outside the behavioral model.
case 30:
soundCode = command;
soundClass = SoundClass::Pause;
auto samples = value * Frequency / 100.0;
soundSamples = soundRemaining = samples > 0.0 ? max(1u, (u32)(samples + 0.5)) : 0;
break;
}
}
auto SpeakJet::startSound(u8 code) -> void {
soundCode = code;
soundClass = classify(code);
auto milliseconds = duration(code);
auto scaled = milliseconds * Frequency / 1000.0;
scaled *= 114.0 / max(1.0, (f64)speed);
scaled *= nextDurationScale;
soundSamples = soundRemaining = scaled > 0.0 ? max(1u, (u32)(scaled + 0.5)) : 0;
soundPitchScale = nextPitchScale;
nextDurationScale = 1.0;
nextPitchScale = 1.0;
std::fill(std::begin(phase), std::end(phase), 0.0);
for(auto& stage : filter) std::fill(std::begin(stage), std::end(stage), 0.0);
}
auto SpeakJet::finishSound() -> void {
soundClass = SoundClass::None;
soundSamples = 0;
}
auto SpeakJet::synthesize() -> f64 {
if(soundClass == SoundClass::Pause) return 0.0;
auto progress = soundSamples ? 1.0 - (f64)soundRemaining / soundSamples : 1.0;
auto attack = min(1.0, progress * 12.0);
auto release = min(1.0, (1.0 - progress) * 10.0);
auto envelope = attack * release;
auto sample = soundCode < 200 ? synthesizeSpeech(progress) : synthesizeEffect(progress);
sample *= envelope * ((f64)volume / 127.0);
return max(-1.0, min(1.0, sample));
}
auto SpeakJet::synthesizeSpeech(f64 progress) -> f64 {
//The public MSA tables specify identities and durations, not oscillator trajectories.
//Use a deterministic phonetic-class model rather than importing a third-party voice table.
auto identity = soundCode - 128;
auto voiced = soundCode <= 181;
auto fundamental = (f64)pitch * soundPitchScale;
auto glottal = fundamental ? oscillator(0, fundamental) * 2.0 - 1.0 : 0.0;
auto source = voiced ? glottal : 0.0;
auto breath = noise();
if(soundClass == SoundClass::Fricative) source = voiced ? 0.4 * glottal + 0.75 * breath : breath;
if(soundClass == SoundClass::Affricate) source = 0.35 * glottal + 0.85 * breath;
if(soundClass == SoundClass::Stop) {
if(progress < 0.45) source = 0.0;
else source = (voiced ? 0.25 * glottal : 0.0) + breath * (1.0 - progress);
}
if(soundClass == SoundClass::Nasal) source = 0.75 * glottal + 0.1 * breath;
auto bendScale = 0.75 + (f64)bend * 0.05;
auto formant1 = (330.0 + (identity * 73) % 520) * bendScale;
auto formant2 = (850.0 + (identity * 97) % 1300) * bendScale;
auto formant3 = (2100.0 + (identity * 53) % 1050) * bendScale;
if(soundClass == SoundClass::Nasal) {
formant1 *= 0.72;
formant2 *= 0.82;
}
if(soundClass == SoundClass::Resonate) formant2 *= 0.88;
auto low = resonator(0, source, formant1, 110.0);
auto middle = resonator(1, source, formant2, 170.0);
auto high = resonator(2, source, formant3, 260.0);
return 0.95 * low + 0.65 * middle + 0.4 * high;
}
auto SpeakJet::synthesizeEffect(f64 progress) -> f64 {
auto index = soundCode % 10;
switch(soundClass) {
case SoundClass::Robot: {
auto carrier = oscillator(0, 90.0 + index * 31.0) < 0.5 ? -1.0 : 1.0;
auto modulator = oscillator(1, 8.0 + index * 2.0) * 2.0 - 1.0;
return carrier * (0.45 + 0.35 * modulator);
}
case SoundClass::Alarm: {
auto sweep = 250.0 + index * 45.0 + 900.0 * progress;
return 0.65 * sin(2.0 * Math::Pi * oscillator(0, sweep))
+ 0.25 * sin(2.0 * Math::Pi * oscillator(1, sweep * 1.51));
}
case SoundClass::Beep:
return 0.8 * sin(2.0 * Math::Pi * oscillator(0, 420.0 + index * 145.0));
case SoundClass::Biological: {
auto chirp = 130.0 + index * 37.0 + sin(progress * Math::Pi * 6.0) * (90.0 + index * 9.0);
return 0.6 * sin(2.0 * Math::Pi * oscillator(0, chirp)) + 0.2 * noise();
}
case SoundClass::DTMF: {
static constexpr u16 low[] = {941, 697, 697, 697, 770, 770, 770, 852, 852, 852, 941, 941};
static constexpr u16 high[] = {1336, 1209, 1336, 1477, 1209, 1336, 1477, 1209, 1336, 1477, 1209, 1477};
auto digit = soundCode - 240;
return 0.45 * sin(2.0 * Math::Pi * oscillator(0, low[digit]))
+ 0.45 * sin(2.0 * Math::Pi * oscillator(1, high[digit]));
}
case SoundClass::Sonar: {
auto frequency = 1500.0 - 900.0 * progress;
return sin(2.0 * Math::Pi * oscillator(0, frequency)) * (1.0 - progress);
}
case SoundClass::Pistol:
return noise() * (1.0 - progress) * (1.0 - progress);
case SoundClass::Wow: {
auto frequency = 180.0 + 780.0 * sin(progress * Math::Pi);
return 0.7 * sin(2.0 * Math::Pi * oscillator(0, frequency));
}
default: return 0.0;
}
}
auto SpeakJet::resonator(u32 index, f64 input, f64 frequency, f64 bandwidth) -> f64 {
frequency = min(frequency, 3999.0);
auto radius = exp(-Math::Pi * bandwidth / Frequency);
auto output = (1.0 - radius) * input
+ 2.0 * radius * cos(2.0 * Math::Pi * frequency / Frequency) * filter[index][0]
- radius * radius * filter[index][1];
filter[index][1] = filter[index][0];
filter[index][0] = output;
return output;
}
auto SpeakJet::oscillator(u32 index, f64 frequency) -> f64 {
phase[index] += min(frequency, 3999.0) / Frequency;
if(phase[index] >= 1.0) phase[index] -= 1.0;
return phase[index];
}
auto SpeakJet::noise() -> f64 {
auto feedback = (noiseLfsr ^ (noiseLfsr >> 2) ^ (noiseLfsr >> 3) ^ (noiseLfsr >> 5)) & 1;
noiseLfsr = (noiseLfsr >> 1) | feedback << 15;
return (noiseLfsr & 1) ? 1.0 : -1.0;
}
auto SpeakJet::duration(u8 code) -> u32 {
if(code <= 6) return PauseDuration[code];
if(code >= 128 && code <= 199) return AllophoneDuration[code - 128];
if(code >= 200 && code <= 254) return EffectDuration[code - 200];
return 0;
}
auto SpeakJet::classify(u8 code) -> SoundClass {
if(code <= 6) return SoundClass::Pause;
if(code >= 128 && (code <= 139 || code >= 149 && code <= 164)) return SoundClass::Vowel;
if(code >= 140 && code <= 144) return SoundClass::Nasal;
if(code >= 145 && code <= 148) return SoundClass::Resonate;
if(code == 165 || code == 182) return SoundClass::Affricate;
if((code >= 166 && code <= 169) || (code >= 183 && code <= 190)) return SoundClass::Fricative;
if((code >= 170 && code <= 181) || (code >= 191 && code <= 199)) return SoundClass::Stop;
if(code >= 200 && code <= 209) return SoundClass::Robot;
if(code >= 210 && code <= 219) return SoundClass::Alarm;
if(code >= 220 && code <= 229) return SoundClass::Beep;
if(code >= 230 && code <= 239) return SoundClass::Biological;
if(code >= 240 && code <= 251) return SoundClass::DTMF;
if(code == 252) return SoundClass::Sonar;
if(code == 253) return SoundClass::Pistol;
if(code == 254) return SoundClass::Wow;
return SoundClass::None;
}
+76
View File
@@ -0,0 +1,76 @@
struct SpeakJet {
static constexpr f64 Frequency = 8192.0;
enum class SoundClass : u8 {
None,
Vowel,
Nasal,
Resonate,
Affricate,
Fricative,
Stop,
Robot,
Alarm,
Beep,
Biological,
DTMF,
Sonar,
Pistol,
Wow,
Pause,
};
auto reset() -> void;
auto enqueue(u8 data) -> bool;
auto ready() const -> bool { return fifoCount < 64; }
auto buffered() const -> u32 { return fifoCount; }
auto speaking() const -> bool { return soundRemaining; }
auto clock() -> f64;
auto serialize(serializer&) -> void;
static auto duration(u8 code) -> u32;
static auto classify(u8 code) -> SoundClass;
private:
auto dequeue() -> u8;
auto processCommands() -> void;
auto execute(u8 code, bool repeated = false) -> void;
auto parameter(u8 command, u8 value) -> void;
auto startSound(u8 code) -> void;
auto finishSound() -> void;
auto synthesize() -> f64;
auto synthesizeSpeech(f64 progress) -> f64;
auto synthesizeEffect(f64 progress) -> f64;
auto resonator(u32 index, f64 input, f64 frequency, f64 bandwidth) -> f64;
auto oscillator(u32 index, f64 frequency) -> f64;
auto noise() -> f64;
u8 fifo[64] = {};
n6 fifoRead;
n6 fifoWrite;
n7 fifoCount;
n1 parameterPending;
u8 pendingCommand;
n1 waiting;
u8 volume;
u8 speed;
u8 pitch;
u8 bend;
n3 portControl;
n3 portOutput;
u8 repeatRequest;
u8 repeatCode;
u8 repeatRemaining;
f64 nextDurationScale;
f64 nextPitchScale;
u8 soundCode;
SoundClass soundClass;
u32 soundSamples;
u32 soundRemaining;
f64 soundPitchScale;
f64 phase[5] = {};
f64 filter[3][2] = {};
u16 noiseLfsr;
};
@@ -0,0 +1,10 @@
BoosterGrip::BoosterGrip(Node::Port parent) : Gamepad(parent, "Booster Grip") {
booster = node->append<Node::Input::Button>("Booster");
trigger = node->append<Node::Input::Button>("Trigger");
}
auto BoosterGrip::readAnalog(n1 index) -> AnalogConnection {
auto& button = index ? booster : trigger;
platform->input(button);
return button->value() ? AnalogConnection::vcc() : AnalogConnection::disconnected();
}
@@ -0,0 +1,8 @@
struct BoosterGrip : Gamepad {
Node::Input::Button booster;
Node::Input::Button trigger;
BoosterGrip(Node::Port);
auto readAnalog(n1 index) -> AnalogConnection override;
};
+19
View File
@@ -1,8 +1,27 @@
#include <a26/a26.hpp>
#include <ares/resource/resource.hpp>
namespace ares::Atari2600 {
#include "port.cpp"
#include "gamepad/gamepad.cpp"
#include "booster-grip/booster-grip.cpp"
#include "sega-genesis/sega-genesis.cpp"
#include "joy2b-plus/joy2b-plus.cpp"
#include "paddles/paddles.cpp"
#include "driving/driving.cpp"
#include "keyboard/keyboard.cpp"
#include "relative-pointing/relative-pointing.cpp"
#include "trak-ball/trak-ball.cpp"
#include "atari-mouse/atari-mouse.cpp"
#include "amiga-mouse/amiga-mouse.cpp"
#include "xg1-light-gun/xg1-light-gun.cpp"
#include "mindlink/mindlink.cpp"
#include "savekey/savekey.cpp"
#include "atarivox/speakjet.cpp"
#include "atarivox/atarivox.cpp"
#include "kidvid/audio.cpp"
#include "kidvid/kidvid.cpp"
#include "quadtari/quadtari.cpp"
}
+36
View File
@@ -1,11 +1,47 @@
struct Controller {
Node::Peripheral node;
struct AnalogConnection {
enum class Type : u32 { Disconnected, Ground, Vcc };
static auto disconnected() -> AnalogConnection { return {}; }
static auto ground(u32 resistance = 0) -> AnalogConnection { return {Type::Ground, resistance}; }
static auto vcc(u32 resistance = 0) -> AnalogConnection { return {Type::Vcc, resistance}; }
Type type = Type::Disconnected;
u32 resistance = 0;
};
virtual ~Controller() = default;
virtual auto save() -> void {}
virtual auto power(bool reset) -> void {}
virtual auto poll() -> void {}
virtual auto frame() -> void {}
virtual auto clock() -> void {}
virtual auto vblank(n1 dumped) -> void {}
virtual auto read() -> n8 { return 0xff; }
virtual auto write(n8 data) -> void {}
virtual auto controlWrite(n8 data) -> void {}
virtual auto readAnalog(n1 index) -> AnalogConnection { return AnalogConnection::disconnected(); }
virtual auto serialize(serializer&) -> void {}
};
#include "port.hpp"
#include "gamepad/gamepad.hpp"
#include "booster-grip/booster-grip.hpp"
#include "sega-genesis/sega-genesis.hpp"
#include "joy2b-plus/joy2b-plus.hpp"
#include "paddles/paddles.hpp"
#include "driving/driving.hpp"
#include "keyboard/keyboard.hpp"
#include "relative-pointing/relative-pointing.hpp"
#include "trak-ball/trak-ball.hpp"
#include "atari-mouse/atari-mouse.hpp"
#include "amiga-mouse/amiga-mouse.hpp"
#include "xg1-light-gun/xg1-light-gun.hpp"
#include "mindlink/mindlink.hpp"
#include "savekey/savekey.hpp"
#include "atarivox/atarivox.hpp"
#include "kidvid/kidvid.hpp"
#include "quadtari/quadtari.hpp"
+38
View File
@@ -0,0 +1,38 @@
Driving::Driving(Node::Port parent) {
node = parent->append<Node::Peripheral>("Driving");
wheel = node->append<Node::Input::Axis>("Wheel");
fire = node->append<Node::Input::Button>("Fire");
}
auto Driving::poll() -> void {
platform->input(wheel);
auto value = wheel->value();
s32 nextDirection = value < -16384 ? -1 : value > 16384 ? 1 : 0;
if(nextDirection && nextDirection != direction) {
auto phase = position.bit(8, 9);
if(nextDirection < 0) position = (phase + 4) * 256 - 1;
if(nextDirection > 0) position = (phase + 1) * 256;
} else if(nextDirection) {
auto distance = value / 512 + (value > 0);
position = (position + distance + 1024) & 1023;
}
direction = nextDirection;
}
auto Driving::read() -> n8 {
platform->input(fire);
static constexpr u8 gray[4] = {0x03, 0x01, 0x00, 0x02};
n8 data = 0xff;
data.bit(0, 1) = gray[position.bit(8, 9)];
data.bit(4) = !fire->value();
return data;
}
auto Driving::serialize(serializer& s) -> void {
s(position);
s(direction);
}
+14
View File
@@ -0,0 +1,14 @@
struct Driving : Controller {
Node::Input::Axis wheel;
Node::Input::Button fire;
Driving(Node::Port);
auto poll() -> void override;
auto read() -> n8 override;
auto serialize(serializer&) -> void override;
private:
n10 position = 0;
s8 direction = 0;
};
+6 -18
View File
@@ -1,5 +1,5 @@
Gamepad::Gamepad(Node::Port parent) {
node = parent->append<Node::Peripheral>("Gamepad");
Gamepad::Gamepad(Node::Port parent, string name) {
node = parent->append<Node::Peripheral>(name);
up = node->append<Node::Input::Button>("Up");
down = node->append<Node::Input::Button>("Down");
@@ -15,23 +15,11 @@ auto Gamepad::read() -> n8 {
platform->input(right);
platform->input(fire);
if(!(up->value() & down->value())) {
yHold = 0, upLatch = up->value(), downLatch = down->value();
} else if(!yHold) {
yHold = 1, swap(upLatch, downLatch);
}
if(!(left->value() & right->value())) {
xHold = 0, leftLatch = left->value(), rightLatch = right->value();
} else if(!xHold) {
xHold = 1, swap(leftLatch, rightLatch);
}
n8 data = 0xff;
data.bit(0) = !upLatch;
data.bit(1) = !downLatch;
data.bit(2) = !leftLatch;
data.bit(3) = !rightLatch;
data.bit(0) = !up->value();
data.bit(1) = !down->value();
data.bit(2) = !left->value();
data.bit(3) = !right->value();
data.bit(4) = !fire->value();
return data;
}
+1 -9
View File
@@ -5,15 +5,7 @@ struct Gamepad : Controller {
Node::Input::Button right;
Node::Input::Button fire;
Gamepad(Node::Port);
Gamepad(Node::Port, string name = "Gamepad");
auto read() -> n8 override;
private:
b1 yHold;
b1 upLatch;
b1 downLatch;
b1 xHold;
b1 leftLatch;
b1 rightLatch;
};
@@ -0,0 +1,10 @@
Joy2BPlus::Joy2BPlus(Node::Port parent) : Gamepad(parent, "Joy 2B+") {
buttonC = node->append<Node::Input::Button>("C");
button3 = node->append<Node::Input::Button>("Button 3");
}
auto Joy2BPlus::readAnalog(n1 index) -> AnalogConnection {
auto& button = index ? buttonC : button3;
platform->input(button);
return button->value() ? AnalogConnection::ground(330) : AnalogConnection::vcc();
}
@@ -0,0 +1,8 @@
struct Joy2BPlus : Gamepad {
Node::Input::Button buttonC;
Node::Input::Button button3;
Joy2BPlus(Node::Port);
auto readAnalog(n1 index) -> AnalogConnection override;
};
+39
View File
@@ -0,0 +1,39 @@
Keyboard::Keyboard(Node::Port parent) {
node = parent->append<Node::Peripheral>("Keyboard");
static constexpr const char* names[12] = {
"1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "0", "#"
};
for(u32 index : range(12)) key[index] = node->append<Node::Input::Button>(names[index]);
}
auto Keyboard::read() -> n8 {
n8 data = 0xff;
data.bit(4) = readColumn(2) != ColumnState::Ground;
return data;
}
auto Keyboard::write(n8 data) -> void {
rows = data.bit(0, 3);
}
auto Keyboard::readAnalog(n1 index) -> AnalogConnection {
switch(readColumn(index)) {
case ColumnState::Pullup: return AnalogConnection::vcc(4700);
case ColumnState::Ground: return AnalogConnection::ground();
case ColumnState::Vcc: return AnalogConnection::vcc();
}
unreachable;
}
auto Keyboard::readColumn(u32 column) -> ColumnState {
bool vcc = false;
for(u32 row : range(4)) {
auto& button = key[row * 3 + column];
platform->input(button);
if(!button->value()) continue;
if(!rows.bit(row)) return ColumnState::Ground;
vcc = true;
}
return vcc ? ColumnState::Vcc : ColumnState::Pullup;
}
+16
View File
@@ -0,0 +1,16 @@
struct Keyboard : Controller {
Node::Input::Button key[12];
Keyboard(Node::Port);
auto read() -> n8 override;
auto write(n8 data) -> void override;
auto readAnalog(n1 index) -> AnalogConnection override;
private:
enum class ColumnState : u32 { Pullup, Ground, Vcc };
auto readColumn(u32 column) -> ColumnState;
n4 rows = 0x0f;
};
+150
View File
@@ -0,0 +1,150 @@
auto KidVidAudio::load(VFS::Pak pak) -> void {
static constexpr u64 MaximumFileSize = 64_MiB;
static constexpr std::array<const char*, (u32)File::Count> Names = {
"KVS3.WAV", "KVS1.WAV", "KVS2.WAV",
"KVB3.WAV", "KVB1.WAV", "KVB2.WAV",
"KVSHARED.WAV",
};
reset();
sources = {};
mediaIdentity = 14695981039346656037ull;
for(u32 index : range((u32)File::Count)) {
auto fp = pak ? pak->read(Names[index]) : VFS::File{};
if(!fp) continue;
if(fp->size() > MaximumFileSize) continue;
auto& item = sources[index];
item.bytes.resize(fp->size());
if(!item.bytes.empty()) memory::copy(item.bytes.data(), fp->data(), item.bytes.size());
for(auto byte : item.bytes) {
mediaIdentity ^= byte;
mediaIdentity *= 1099511628211ull;
}
mediaIdentity ^= index;
mediaIdentity *= 1099511628211ull;
item.valid = parse(item);
}
}
auto KidVidAudio::reset() -> void {
activeFile = File::Shared;
cursor = 0;
end = 0;
active = false;
}
auto KidVidAudio::available(File file) const -> bool {
return file < File::Count && source(file).valid;
}
auto KidVidAudio::play(File file, u32 begin, u32 end) -> bool {
stop();
if(!available(file)) return false;
auto& item = source(file);
if(begin < item.dataBegin || end < begin || end > item.dataEnd) return false;
activeFile = file;
cursor = begin;
this->end = end;
active = cursor < end;
return active;
}
auto KidVidAudio::stop() -> void {
active = false;
cursor = end;
}
auto KidVidAudio::remaining() const -> u32 {
if(!active || cursor >= end) return 0;
return end - cursor;
}
auto KidVidAudio::clock() -> f64 {
if(!active) return 0.0;
auto& item = source(activeFile);
if(cursor >= end || cursor >= item.bytes.size()) {
stop();
return 0.0;
}
auto sample = item.bytes[cursor++];
if(cursor >= end) active = false;
return ((s32)sample - 128) / 128.0;
}
auto KidVidAudio::serialize(serializer& s) -> bool {
auto identity = mediaIdentity;
u32 file = (u32)activeFile;
s(identity);
s(file);
s(cursor);
s(end);
s(active);
if(s.reading()) {
if(identity != mediaIdentity || file >= (u32)File::Count) {
reset();
return false;
}
activeFile = (File)file;
if(!active) {
reset();
return true;
}
auto& item = source(activeFile);
if(!item.valid || cursor < item.dataBegin || end < cursor || end > item.dataEnd) {
reset();
return false;
}
}
return true;
}
auto KidVidAudio::parse(Source& source) -> bool {
auto& bytes = source.bytes;
if(bytes.size() < 12) return false;
auto tag = [&](u32 offset, const char* text) {
return offset <= bytes.size() - 4 && bytes[offset + 0] == text[0] && bytes[offset + 1] == text[1]
&& bytes[offset + 2] == text[2] && bytes[offset + 3] == text[3];
};
auto read16 = [&](u32 offset) -> u16 {
return (u16)bytes[offset] | (u16)bytes[offset + 1] << 8;
};
auto read32 = [&](u32 offset) -> u32 {
return (u32)bytes[offset] | (u32)bytes[offset + 1] << 8
| (u32)bytes[offset + 2] << 16 | (u32)bytes[offset + 3] << 24;
};
if(!tag(0, "RIFF") || !tag(8, "WAVE")) return false;
auto declaredEnd = (u64)read32(4) + 8;
if(declaredEnd > bytes.size() || declaredEnd < 12) return false;
bool formatValid = false;
bool dataFound = false;
for(u64 offset = 12; offset + 8 <= declaredEnd;) {
auto chunkSize = read32((u32)offset + 4);
auto dataBegin = offset + 8;
auto dataEnd = dataBegin + chunkSize;
if(dataEnd > declaredEnd || dataEnd < dataBegin) return false;
if(tag((u32)offset, "fmt ")) {
if(chunkSize < 16) return false;
formatValid = read16((u32)dataBegin + 0) == 1
&& read16((u32)dataBegin + 2) == 1
&& read32((u32)dataBegin + 4) == 16000
&& read16((u32)dataBegin + 12) == 1
&& read16((u32)dataBegin + 14) == 8;
}
if(tag((u32)offset, "data") && !dataFound) {
source.dataBegin = dataBegin;
source.dataEnd = dataEnd;
dataFound = true;
}
offset = dataEnd;
//Several canonical KidVid WAVs end on an odd-sized data chunk without a
//physical pad byte. A pad is required before another chunk, not after EOF.
if((chunkSize & 1) && offset < declaredEnd) offset++;
if(offset > declaredEnd) return false;
}
return formatValid && dataFound && source.dataBegin < source.dataEnd;
}
+41
View File
@@ -0,0 +1,41 @@
struct KidVidAudio {
enum class File : u32 {
Smurfs3,
Smurfs1,
Smurfs2,
Bears3,
Bears1,
Bears2,
Shared,
Count,
};
auto load(VFS::Pak) -> void;
auto reset() -> void;
auto available(File) const -> bool;
auto play(File, u32 begin, u32 end) -> bool;
auto stop() -> void;
auto playing() const -> bool { return active; }
auto remaining() const -> u32;
auto clock() -> f64;
auto serialize(serializer&) -> bool;
private:
struct Source {
std::vector<u8> bytes;
u32 dataBegin = 0;
u32 dataEnd = 0;
bool valid = false;
};
auto parse(Source&) -> bool;
auto source(File file) -> Source& { return sources[(u32)file]; }
auto source(File file) const -> const Source& { return sources[(u32)file]; }
std::array<Source, (u32)File::Count> sources;
u64 mediaIdentity = 0;
File activeFile = File::Shared;
u32 cursor = 0;
u32 end = 0;
bool active = false;
};
+216
View File
@@ -0,0 +1,216 @@
#include "tables.hpp"
static constexpr const char* KidVidSmurfsSha256 =
"bbe0f1d952aab334de82db18cd84feb49a7fd9beb60a39c52658483564af78be";
static constexpr const char* KidVidBearsSha256 =
"6161ac39cddfe7773c553f1b7a5925b703025ebe6ac18e934b8eb94465ed4548";
KidVid::KidVid(Node::Port parent) {
node = parent->append<Node::Peripheral>("KidVid Voice Module");
game1 = node->append<Node::Input::Button>("Game 1");
game2 = node->append<Node::Input::Button>("Game 2");
game3 = node->append<Node::Input::Button>("Game 3");
skip = node->append<Node::Input::Button>("Skip");
stream = node->append<Node::Audio::Stream>("KidVid");
stream->setChannels(1);
stream->setFrequency(16000);
node->setPak(pak = platform->pak(node));
audio.load(pak);
if(cartridge.sha256() == KidVidSmurfsSha256) profile = Profile::Smurfs;
if(cartridge.sha256() == KidVidBearsSha256) profile = Profile::Bears;
rewind();
Thread::create(16000, std::bind_front(&KidVid::main, this));
}
KidVid::~KidVid() {
Thread::destroy();
stream.reset();
pak.reset();
}
auto KidVid::main() -> void {
stream->frame(audio.clock());
Thread::step(1);
Thread::synchronize(cpu);
}
auto KidVid::power(bool reset) -> void {
if(!reset || profile == Profile::Smurfs) rewind();
Thread::create(16000, std::bind_front(&KidVid::main, this));
}
auto KidVid::poll() -> void {
platform->input(game1);
platform->input(game2);
platform->input(game3);
platform->input(skip);
}
auto KidVid::frame() -> void {
if(profile == Profile::Unknown) return;
if(profile == Profile::Smurfs && system.controls.reset->value()) rewind();
if(skip->value() && song && KidVidData::ClipOrder[song - 1] != 0
&& KidVidData::ClipOrder[song - 1] != 11) {
audio.stop();
}
if(!tape) {
if(game1->value()) select(1);
else if(game2->value()) select(2);
else if(game3->value()) select(3);
}
if(tape && run && !tapeBusy) advanceCassette();
updatePlayback();
}
auto KidVid::read() -> n8 {
n8 lines = 0xff;
lines.bit(3) = data;
return lines;
}
auto KidVid::write(n8 lines) -> void {
run = lines.bit(0);
}
auto KidVid::serialize(serializer& s) -> void {
Thread::serialize(s);
auto audioStateCompatible = audio.serialize(s);
s(tape);
s(bit);
s(bitsRemaining);
s(block);
s(song);
s(fallbackFrames);
s(run);
s(data);
s(tapeBusy);
s(songPlaying);
s(beep);
if(s.reading()) {
auto cassetteBits = KidVidData::CassetteData.size() * 8;
if(tape > 4 || bit >= cassetteBits || !bitsRemaining || bitsRemaining > 48
|| bitsRemaining > cassetteBits - bit || song > KidVidData::ClipOrder.size() || fallbackFrames > 92) {
rewind();
}
mediaAvailable = tape && audio.available(KidVidAudio::File::Shared) && audio.available(tapeFile());
if(!audioStateCompatible) {
mediaAvailable = false;
songPlaying = false;
beep = true;
tapeBusy = tape != 0;
fallbackFrames = tape ? 92 : 0;
}
}
}
auto KidVid::rewind() -> void {
audio.reset();
tape = 0;
bit = profile == Profile::Bears ? 48 : 0;
bitsRemaining = 48;
block = 0;
song = 0;
fallbackFrames = 0;
data = true;
tapeBusy = false;
songPlaying = false;
beep = false;
mediaAvailable = false;
}
auto KidVid::select(u32 game) -> void {
if(game < 1 || game > 3) return;
tape = game == 1 ? 2 : game == 2 ? 3 : profile == Profile::Bears ? 4 : 1;
bit = profile == Profile::Bears ? 48 : 0;
bitsRemaining = 48;
block = 0;
song = KidVidData::FirstClip[tapeIndex()];
fallbackFrames = 0;
tapeBusy = false;
songPlaying = false;
beep = false;
mediaAvailable = audio.available(KidVidAudio::File::Shared) && audio.available(tapeFile());
}
auto KidVid::tapeIndex() const -> u32 {
if(tape == 4) return 3;
return profile == Profile::Smurfs ? tape - 1 : tape + 2;
}
auto KidVid::tapeFile() const -> KidVidAudio::File {
return (KidVidAudio::File)tapeIndex();
}
auto KidVid::advanceCassette() -> void {
auto byte = KidVidData::CassetteData[bit >> 3];
data = byte >> (7 - (bit & 7)) & 1;
bit++;
if(--bitsRemaining) return;
if(block == 0) {
bit = 96 + (tape - 1) * 48;
} else if(block >= KidVidData::BlockCounts[tapeIndex()]) {
bit = 336;
} else {
bit = 288;
startNextClip();
}
block++;
bitsRemaining = 48;
}
auto KidVid::startNextClip() -> void {
if(!mediaAvailable || song >= KidVidData::ClipOrder.size()) {
beep = true;
tapeBusy = true;
songPlaying = false;
fallbackFrames = 92;
return;
}
auto entry = KidVidData::ClipOrder[song++];
beep = !(entry & 0x80);
auto clip = entry & 0x7f;
if(clip + 1 >= KidVidData::ClipBoundaries.size()) {
mediaAvailable = false;
return startNextClip();
}
auto begin = KidVidData::ClipBoundaries[clip];
auto end = KidVidData::ClipBoundaries[clip + 1];
if(end < begin + 786) {
mediaAvailable = false;
return startNextClip();
}
auto file = clip < 10 ? KidVidAudio::File::Shared : tapeFile();
if(!audio.play(file, begin, end - 786)) {
mediaAvailable = false;
return startNextClip();
}
songPlaying = true;
tapeBusy = true;
}
auto KidVid::updatePlayback() -> void {
if(mediaAvailable) {
if(!songPlaying) return;
auto remaining = audio.remaining();
tapeBusy = remaining > 262 * 60 || !beep;
if(remaining) return;
songPlaying = false;
tapeBusy = !beep;
if(!beep) startNextClip();
return;
}
if(fallbackFrames) {
fallbackFrames--;
tapeBusy = fallbackFrames > 60;
}
}
+47
View File
@@ -0,0 +1,47 @@
#include "audio.hpp"
struct KidVid : Controller, Thread {
KidVid(Node::Port);
~KidVid();
auto main() -> void;
auto power(bool reset) -> void override;
auto poll() -> void override;
auto frame() -> void override;
auto read() -> n8 override;
auto write(n8 data) -> void override;
auto serialize(serializer&) -> void override;
private:
enum class Profile : u32 { Unknown, Smurfs, Bears };
auto rewind() -> void;
auto select(u32 game) -> void;
auto tapeIndex() const -> u32;
auto tapeFile() const -> KidVidAudio::File;
auto advanceCassette() -> void;
auto startNextClip() -> void;
auto updatePlayback() -> void;
Node::Input::Button game1;
Node::Input::Button game2;
Node::Input::Button game3;
Node::Input::Button skip;
Node::Audio::Stream stream;
VFS::Pak pak;
KidVidAudio audio;
Profile profile = Profile::Unknown;
u32 tape = 0;
u32 bit = 0;
u32 bitsRemaining = 48;
u32 block = 0;
u32 song = 0;
u32 fallbackFrames = 0;
bool run = true;
bool data = true;
bool tapeBusy = false;
bool songPlaying = false;
bool beep = false;
bool mediaAvailable = false;
};
+75
View File
@@ -0,0 +1,75 @@
namespace KidVidData {
//Connector data recorded by the two supported programs. Each cassette block
//is six bytes and is shifted most-significant bit first.
static constexpr std::array<u8, 48> CassetteData = {
0x7b, 0x1e, 0xc6, 0x31, 0xec, 0x60,
0x7b, 0x1e, 0xc6, 0x3d, 0x8c, 0x60,
0xf6, 0x31, 0x8c, 0x63, 0x18, 0xc0,
0xf6, 0x31, 0x8c, 0x63, 0x18, 0xf0,
0xf6, 0x31, 0x8c, 0x63, 0x1e, 0xc0,
0xf6, 0x31, 0x8c, 0x63, 0x1e, 0xf0,
0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00,
0xf7, 0xb1, 0x8c, 0x63, 0x18, 0xc0,
};
//Order: Smurfs 3/1/2, then Bears 3/1/2.
static constexpr std::array<u8, 6> BlockCounts = {42, 23, 37, 102, 120, 102};
static constexpr std::array<u16, 6> FirstClip = {82, 0, 44, 266, 124, 186};
//The high bit marks a segment that ends without the cassette acknowledgement
//beep. The low seven bits select adjacent boundaries from ClipBoundaries.
static constexpr std::array<u8, 328> ClipOrder = {
11, 12+0x80, 13+0x80, 14, 15+0x80, 16, 8+0x80, 17, 18+0x80, 19, 20+0x80,
21, 8+0x80, 22, 15+0x80, 23, 18+0x80, 14, 20+0x80, 16, 18+0x80,
17, 15+0x80, 19, 8+0x80, 21, 20+0x80, 22, 18+0x80, 23, 15+0x80,
14, 20+0x80, 16, 8+0x80, 22, 15+0x80, 23, 18+0x80, 14, 20+0x80,
16, 8+0x80, 9,
25+0x80, 26, 27, 28, 8, 29, 30, 26, 27, 28, 8, 29, 30, 26, 27, 28, 8, 29,
30, 26, 27, 28, 8, 29, 30, 26, 27, 28, 8, 29, 30, 26, 27, 28, 8, 29,
30+0x80, 9,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 34, 42, 36, 43, 40, 39, 38, 37,
34, 43, 36, 39, 40, 37, 38, 43, 34, 37, 36, 43, 40, 39, 38, 37, 34, 43,
36, 39, 40, 37, 38+0x80, 9,
0, 1, 45, 2, 3, 46, 4, 5, 47, 6, 7, 48, 4, 3, 49, 2, 1, 50, 6, 7, 51,
4, 5, 52, 6, 1, 53, 2, 7, 54, 6, 5, 45, 2, 1, 46, 4, 3, 47, 2, 5, 48,
4, 7, 49, 6, 1, 50, 2, 5, 51, 6, 3, 52, 4, 7, 53, 2, 1, 54, 6+0x80, 9,
0, 1, 56, 4, 3, 57, 2, 5, 58, 6, 7, 59, 2, 3, 60, 4, 1, 61, 6, 7, 62,
2, 5, 63, 6, 1, 64, 4, 7, 65, 6, 5, 66, 4, 1, 67, 2, 3, 68, 6, 5, 69,
2, 7, 70, 4, 1, 71, 2, 5, 72, 4, 3, 73, 6, 7, 74, 2, 1, 75, 6, 3, 76,
4, 5, 77, 6, 7, 78, 2, 3, 79, 4, 1, 80, 2, 7, 81, 4+0x80, 9,
0, 1, 83, 2, 3, 84, 4, 5, 85, 6, 7, 86, 4, 3, 87, 2, 1, 88, 6, 7, 89,
2, 5, 90, 6, 1, 91, 4, 7, 92, 6, 5, 93, 4, 1, 94, 2, 3, 95, 6, 5, 96,
2, 7, 97, 4, 1, 98, 6, 5, 99, 4, 3, 100, 2, 7, 101, 4, 1, 102, 2+0x80, 9,
};
//Absolute byte offsets in the canonical RIFF files. Indexes 0..10 belong to
//KVSHARED; every later index belongs to the selected tape file.
static constexpr std::array<u32, 104> ClipBoundaries = {
44, 980829, 1178398, 1430063, 1691136, 1841665, 2100386, 2283843, 2629588, 2824805, 3059116,
44, 164685, 395182, 750335, 962016, 1204273, 1538258, 1801683, 2086276, 2399093,
2589606, 2801287, 3111752, 3436329,
44, 778557, 1100782, 1293648, 1493569, 1801682, 2086275,
44, 686829, 893806, 1143119, 1385376, 1578241, 1942802, 2168595, 2493172,
2662517, 3022374, 3229351, 3720920,
44, 592749, 936142, 1465343, 1787568, 2145073, 2568434, 2822451, 3045892, 3709157, 4219542,
44, 303453, 703294, 1150175, 1514736, 2208577, 2511986, 2864787, 3306964, 3864389,
4148982, 4499431, 4824008, 5162697, 5581354, 5844779, 6162300, 6590365, 6839678,
7225407, 7552336, 7867505, 8316738, 8608387, 8940020, 9274005, 9593878,
44, 341085, 653902, 1018463, 1265424, 1669969, 1919282, 2227395, 2535508, 3057653,
3375174, 3704455, 4092536, 4487673, 5026282, 5416715, 5670732, 6225805, 6736190,
7110159, 7676992,
};
}
+47
View File
@@ -0,0 +1,47 @@
MindLink::MindLink(Node::Port parent) {
node = parent->append<Node::Peripheral>("MindLink");
x = node->append<Node::Input::Axis>("X");
trigger = node->append<Node::Input::Button>("Trigger");
}
auto MindLink::poll() -> void {
platform->input(x);
platform->input(trigger);
auto next = (s64)(position & ~TriggerValue) + x->value() * PositionScale;
position = std::clamp<s64>(next, MinimumPosition, MaximumPosition);
//Stella exposes this compatibility trigger, but the physical MindLink had no button.
if(trigger->value()) position |= TriggerValue;
lines = 0x1f;
shift = 1;
nextBit();
}
auto MindLink::read() -> n8 {
n8 data = 0xff;
data.bit(0, 4) = lines;
return data;
}
auto MindLink::write(n8 data) -> void {
lines.bit(0, 3) = data.bit(0, 3);
}
auto MindLink::controlWrite(n8 data) -> void {
if(data.bit(0)) nextBit();
}
auto MindLink::serialize(serializer& s) -> void {
s(position);
s(shift);
s(lines);
}
auto MindLink::nextBit() -> void {
lines.bit(2) = 0;
lines.bit(3) = (position & shift) != 0;
shift <<= 1;
}
+24
View File
@@ -0,0 +1,24 @@
struct MindLink : Controller {
Node::Input::Axis x;
Node::Input::Button trigger;
MindLink(Node::Port);
auto poll() -> void override;
auto read() -> n8 override;
auto write(n8 data) -> void override;
auto controlWrite(n8 data) -> void override;
auto serialize(serializer&) -> void override;
private:
auto nextBit() -> void;
u32 position = 0x2a00;
u32 shift = 1;
n5 lines = 0x1f;
static constexpr s32 PositionScale = 10;
static constexpr s32 MinimumPosition = 0x0b00;
static constexpr s32 MaximumPosition = 0x6500;
static constexpr u32 TriggerValue = 0x8000;
};
+28
View File
@@ -0,0 +1,28 @@
Paddles::Paddles(Node::Port parent, bool axes) {
node = parent->append<Node::Peripheral>("Paddles");
if(axes) {
axis[0] = node->append<Node::Input::Axis>("Paddle 1");
axis[1] = node->append<Node::Input::Axis>("Paddle 2");
}
fire[0] = node->append<Node::Input::Button>("Paddle 1 Fire");
fire[1] = node->append<Node::Input::Button>("Paddle 2 Fire");
}
auto Paddles::read() -> n8 {
platform->input(fire[0]);
platform->input(fire[1]);
n8 data = 0xff;
data.bit(3) = !fire[0]->value();
data.bit(2) = !fire[1]->value();
return data;
}
auto Paddles::readAnalog(n1 index) -> AnalogConnection {
if(!axis[index]) return AnalogConnection::disconnected();
platform->input(axis[index]);
auto value = std::clamp<s64>(axis[index]->value(), -32768, 32767);
auto resistance = (u64)(32767 - value) * MaximumResistance / 65535;
return AnalogConnection::vcc(resistance);
}
+11
View File
@@ -0,0 +1,11 @@
struct Paddles : Controller {
Node::Input::Axis axis[2];
Node::Input::Button fire[2];
Paddles(Node::Port, bool axes = true);
auto read() -> n8 override;
auto readAnalog(n1 index) -> AnalogConnection override;
static constexpr u32 MaximumResistance = 1'000'000;
};
+45 -4
View File
@@ -10,20 +10,61 @@ auto ControllerPort::load(Node::Object parent) -> void {
port->setType("Controller");
port->setHotSwappable(true);
port->setAllocate([&](auto name) { return allocate(name); });
port->setDisconnect([&] { device.reset(); });
port->setSupported({"Gamepad"});
port->setDisconnect([&] {
save();
device.reset();
});
std::vector<string> supported = {
"Gamepad", "Paddles", "Driving", "Keyboard",
"Booster Grip", "Sega Genesis", "Joy 2B+",
"CX-22 Trak-Ball", "CX-80 Trak-Ball", "Atari Mouse", "Amiga Mouse",
"XG-1 Light Gun", "MindLink", "SaveKey", "AtariVox", "QuadTari",
};
if(name == "Controller Port 2") supported.push_back("KidVid Voice Module");
port->setSupported(supported);
output = 0x0f;
}
auto ControllerPort::unload() -> void {
device = {};
port = {};
output = 0x0f;
}
auto ControllerPort::allocate(string name) -> Node::Peripheral {
if(name == "Gamepad") device = new Gamepad(port);
if(device) return device->node;
auto role = this == &controllerPort2 ? Role::ConsoleRight : Role::ConsoleLeft;
device = create(port, name, role);
if(device) {
device->write(output);
return device->node;
}
return {};
}
auto ControllerPort::create(Node::Port port, string name, Role role) -> std::unique_ptr<Controller> {
auto quadTariChild = role == Role::QuadTariChild;
if(name == "Gamepad") return std::make_unique<Gamepad> (port);
if(name == "Paddles") return std::make_unique<Paddles> (port, !quadTariChild);
if(name == "Driving") return std::make_unique<Driving> (port);
if(name == "Keyboard") return std::make_unique<Keyboard> (port);
if(name == "Booster Grip") return std::make_unique<BoosterGrip>(port);
if(name == "Sega Genesis") return std::make_unique<SegaGenesis>(port);
if(name == "Joy 2B+") return std::make_unique<Joy2BPlus> (port);
if(name == "CX-22 Trak-Ball") return std::make_unique<TrakBall> (port, name);
if(name == "CX-80 Trak-Ball") return std::make_unique<TrakBall> (port, name);
if(name == "Atari Mouse") return std::make_unique<AtariMouse> (port);
if(name == "Amiga Mouse") return std::make_unique<AmigaMouse> (port);
if(name == "XG-1 Light Gun") return std::make_unique<XG1LightGun>(port);
if(name == "MindLink") return std::make_unique<MindLink> (port);
if(name == "SaveKey") return std::make_unique<SaveKey> (port);
if(name == "AtariVox") return std::make_unique<AtariVox> (port);
if(name == "KidVid Voice Module")
if(role == Role::ConsoleRight) return std::make_unique<KidVid> (port);
if(name == "QuadTari")
if(!quadTariChild) return std::make_unique<QuadTari> (port);
return {};
}
auto ControllerPort::serialize(serializer& s) -> void {
if(device) device->serialize(s);
}
+27 -2
View File
@@ -1,19 +1,44 @@
struct ControllerPort {
enum class Role : u32 { ConsoleLeft, ConsoleRight, QuadTariChild };
Node::Port port;
unique_pointer<Controller> device;
std::unique_ptr<Controller> device;
//port.cpp
ControllerPort(string name);
auto load(Node::Object) -> void;
auto unload() -> void;
auto allocate(string name) -> Node::Peripheral;
static auto create(Node::Port, string name, Role) -> std::unique_ptr<Controller>;
auto save() -> void { if(device) device->save(); }
auto power(bool reset) -> void {
if(device) {
device->power(reset);
device->write(output);
}
}
auto poll() -> void { if(device) device->poll(); }
auto frame() -> void { if(device) device->frame(); }
auto clock() -> void { if(device) device->clock(); }
auto vblank(n1 dumped) -> void { if(device) device->vblank(dumped); }
auto read() -> n8 { if(device) return device->read(); return 0xff; }
auto write(n8 data) -> void { if(device) return device->write(data); }
auto write(n8 data) -> void {
output = data;
if(device) device->write(data);
}
auto controlWrite(n4 data) -> void {
if(device) device->controlWrite(data);
}
auto readAnalog(n1 index) -> Controller::AnalogConnection {
if(device) return device->readAnalog(index);
return Controller::AnalogConnection::disconnected();
}
auto serialize(serializer&) -> void;
const string name;
n4 output = 0x0f;
};
extern ControllerPort controllerPort1;
+152
View File
@@ -0,0 +1,152 @@
QuadTari::QuadTari(Node::Port parent) : first(*this), second(*this) {
node = parent->append<Node::Peripheral>("QuadTari");
auto left = parent->name() == "Controller Port 1";
first.load(node, left ? "QuadTari Player 1" : "QuadTari Player 2");
second.load(node, left ? "QuadTari Player 3" : "QuadTari Player 4");
}
QuadTari::~QuadTari() {
first.unload();
second.unload();
}
auto QuadTari::Slot::load(Node::Peripheral parent, string name) -> void {
port = parent->append<Node::Port>(name);
port->setFamily(system.name());
port->setType("Controller");
port->setHotSwappable(true);
port->setAllocate([&](auto name) { return allocate(name); });
port->setDisconnect([&] {
save();
device.reset();
});
port->setSupported({"Gamepad", "Paddles", "Driving", "SaveKey", "AtariVox"});
port->allocate("Gamepad");
port->connect();
}
auto QuadTari::Slot::unload() -> void {
save();
device = {};
port = {};
}
auto QuadTari::Slot::allocate(string name) -> Node::Peripheral {
save();
device = {};
if(name != "Gamepad" && name != "Paddles" && name != "Driving" && name != "SaveKey" && name != "AtariVox") {
return {};
}
device = ControllerPort::create(port, name, ControllerPort::Role::QuadTariChild);
if(device) {
device->write(owner.output);
device->controlWrite(owner.control);
return device->node;
}
return {};
}
auto QuadTari::Slot::save() -> void {
if(device) device->save();
}
auto QuadTari::Slot::power(bool reset) -> void {
if(device) device->power(reset);
}
auto QuadTari::Slot::serialize(serializer& s) -> void {
if(device) device->serialize(s);
}
auto QuadTari::save() -> void {
first.save();
second.save();
}
auto QuadTari::power(bool reset) -> void {
first.power(reset);
second.power(reset);
dumped = 0;
selected = 0;
pending = 0;
settling = 0;
output = 0x0f;
control = 0x0f;
}
auto QuadTari::poll() -> void {
if(first.device) first.device->poll();
if(second.device) second.device->poll();
}
auto QuadTari::frame() -> void {
if(first.device) first.device->frame();
if(second.device) second.device->frame();
}
auto QuadTari::clock() -> void {
if(settling && !--settling) {
selected = pending;
synchronizeActive();
}
}
auto QuadTari::vblank(n1 dumped) -> void {
if(this->dumped == dumped) return;
this->dumped = dumped;
pending = dumped;
settling = SettlingClocks;
}
auto QuadTari::read() -> n8 {
if(auto device = active()) return device->read();
return 0xff;
}
auto QuadTari::write(n8 data) -> void {
output = data;
if(auto device = active()) device->write(data);
}
auto QuadTari::controlWrite(n8 data) -> void {
control = data;
if(auto device = active()) device->controlWrite(data);
}
auto QuadTari::readAnalog(n1 index) -> AnalogConnection {
return index ? AnalogConnection::vcc() : AnalogConnection::ground();
}
auto QuadTari::serialize(serializer& s) -> void {
s(dumped);
s(selected);
s(pending);
s(settling);
s(output);
s(control);
first.serialize(s);
second.serialize(s);
if(s.reading() && settling > SettlingClocks) {
dumped = 0;
selected = 0;
pending = 0;
settling = 0;
output = 0x0f;
control = 0x0f;
synchronizeActive();
}
}
auto QuadTari::active() -> Controller* {
auto& slot = selected ? second : first;
return slot.device.get();
}
auto QuadTari::synchronizeActive() -> void {
if(auto device = active()) {
device->write(output);
device->controlWrite(control);
}
}
+47
View File
@@ -0,0 +1,47 @@
struct QuadTari : Controller {
struct Slot {
Slot(QuadTari& owner) : owner(owner) {}
auto load(Node::Peripheral, string name) -> void;
auto unload() -> void;
auto allocate(string name) -> Node::Peripheral;
auto save() -> void;
auto power(bool reset) -> void;
auto serialize(serializer&) -> void;
QuadTari& owner;
Node::Port port;
std::unique_ptr<Controller> device;
};
QuadTari(Node::Port);
~QuadTari() override;
auto save() -> void override;
auto power(bool reset) -> void override;
auto poll() -> void override;
auto frame() -> void override;
auto clock() -> void override;
auto vblank(n1 dumped) -> void override;
auto read() -> n8 override;
auto write(n8 data) -> void override;
auto controlWrite(n8 data) -> void override;
auto readAnalog(n1 index) -> AnalogConnection override;
auto serialize(serializer&) -> void override;
static constexpr u16 SettlingClocks = 228;
private:
auto active() -> Controller*;
auto synchronizeActive() -> void;
public:
Slot first;
Slot second;
n1 dumped = 0;
n1 selected = 0;
n1 pending = 0;
u16 settling = 0;
n4 output = 0x0f;
n4 control = 0x0f;
};
Loaded 100 of 7025 files, more files were not shown because too many files have changed in this diff. Show more