Compare commits

...
259 Commits
Author SHA1 Message Date
Luke Usher 1f73642031 ares v124
ares v124 brings the compatibility rating for the Famicom and Nintendo 64 cores
up to three stars. This means that at least 80% of the game library is working.

There have been notable improvements to Game Boy, Mega Drive, Sega Mega CD,
Sega 32X and Nintendo 64 emulation, and the PC-Engine multi-tap is now supported.

Finally, the dynamic recompiler now generates slightly more efficient code. You
may notice a slight performance boost in Nintendo 64, Sega 32X and Sony
PlayStation.

**Changelog:**
 * Famicom: Add support for Jaleco JF11/JF14 mapper [Shideravan]
 * Game Boy: Bring fast-boot closer to normal boot; Fixes Dr. Fraken [invertego]
 * Game Boy: Use stable sort for sprites; fixes speech bubbles in Crayon Shin-chan 3 [invertego]
 * Game Boy: Remove limit on window width; fixes pause screen in Heiankyo Alien [invertego]
 * Game Boy: Emulate serial transfers with no link; fixes input in Alleyway [invertego]
 * Game Boy: Improve handling of LCD/BG enable for DMG; fixes Hyper Lode Runner [invertego]
 * Game Boy: Resume from halt whenever (IE & IF) != 0; fies Amazing Penguin [invertego]
 * Mega Drive: Fix DMA transfer rate and H-Int signalling; fixes Another World, 3 Ninja's Kick Back, Virtua Racing, Burning Force [TascoDLX]
 * Mega Drive: Fix sprite masking and overflow; Fixes Mickey Mania [TascoDLX]
 * Mega Drive: Fix DMA fill; Fixes Demons of Asteborg [TascoDLX]
 * Mega Drive: Fix VRAM byte addressing; Fixes Contra Hard Corps, Musha [TascoDLX]
 * Mega Drive: Fix VDP control port writes [TascoDLX]
 * Mega Drive: Implement HV Counter Patching [TascoDLX]
 * Mega Drive: Implement STOP instruction; fixes Thunder Force IV [TascoDLX]
 * Mega Drive: Default to 3-button gamepad; fixes games that don't support 6-button pads [Shideravan]
 * Mega Drive/Mega CD: Fix detection of device rom header; allows Mode-1 to work [Luke Usher]
 * Mega CD: Fix word-ram 1M access pattern; Fixes Lethal Enforcers II [TascoDLX]
 * Mega CD: Fix H-Int vectoring; Fixes Microcosm, Silpheed, Wing Commander, and others [TascoDLX]
 * Mega CD: Implement full graphics/1M wordram translations; fixes Rebel Assault [TascoDLX]
 * Mega 32X: Tighten M68k sync; Fixes Kolibri and Fifa 96 [TascoDLX]
 * Neo Geo Pocket: Fix off-by-one error in LDAR instruction; fixes a crash in SNK Gals' Fighters [invertego]
 * Nintendo 64: Support controller ports 3 & 4 [LukeUsher]
 * Nintendo 64: Better Flash Ram support; Fixes Majora's Mask, Paper Mario, Derby Stallion 64 [jeltaqq]
 * Nintendo 64: Add mempack/rumble status to database; eliminates controller pak/rumble pak warnings [remutro]
 * Nintendo 64: Consume cycles to compensate for skipped RDRAM initialization; fixes Wave Race 64 Shindou Pak [invertego]
 * Nintendo 64: Fix PIF RAM init on cold boot, preserve RDRAM on warm reset; fixes Perfect Dark boot [invertego]
 * Nintendo 64: Default to 3 controllers for Jeopardy!, this game doesn't work with 4 controllers, even on hardware [invertego]
 * Nintendo 64: Fix FPU compare and divide exceptions; Turok is now able to play the entire Acclaim logo animation [invertego]
 * Nintendo 64: Decrease SI DMA delay; improves Turok, Donkey Kong 64, Forsaken 64, Hercules, Triple Play 2000 [invertego]
 * Nintendo 64: Implement perfect PI DMA write [rasky]
 * PC Engine: Support Multi-Tap [LukeUsher]
 * TMS9918: Widen vcounter to 9-bits; improves ColecoVision, SG-1000, MSX [invertego]
 * desktop-ui: Support up-to 5 virtual controllers (For PC-Engine) [LukeUsher]
 * desktop-ui: Fix window background with GTK3 [ghisvail]
 * desktop-ui: Install icons in freedesktop compliant locations [ghisvail]
 * desktop-ui/hiro: Improved macOS user experience [LIJI32]
 * ruby: Fix conflated keys on Windows; fixes some keyboard input issues [invertego]
 * nall: Use XDG base directories on *nix systems [ghisvail]
 * shaders: Include a selection of public-domain shaders [LukeUsher]
 * ares: Fix address masking in instruction tracer [invertego]
 * ares: Fix warnings reported by clang [invertego]
 * ares: Fix static init in node subclasses [invertego]
 * ares: Use 64-bit integers instead of 128-bit integers in the scheduler [invertego]
 * ares: Use IP relative direct branches in the recompiler, where possible [invertego]
 * ares: Emit only one epilog per block in the recompiler [invertego]
 * ares: add label API to recompiler to simplify branches [invertego]
 * ares: Use fixed BSS allocation for code cache; improves recompiler performance [invertego]
 * ares: Fix instructionEpilogue test [invertego]
 * ares: Directly emit code for target ABI; generates more efficient code in the recompiler [invertego]
 * ares: Avoid encoding absolute data addresses in the recompiler [invertego]
 * nall: allow mingw headers to define _MSVCRT_VERSION_ [invertego]
 * nall: generate PDB when building with clang on windows [invertego]
 * nall: allow generation of debug symbols with symbols=true [invertego]
 * nall: link with lld wen building with clang on Windows [invertego]
 * nall: Make thread movable but not copyable; fixes random UI hangs on Windows [invertego]
 * mia: Fix MSU-1 rom loading [Luke Usher]
2021-10-15 14:48:42 +01:00
invertego d31d5a9310 recompiler: avoid encoding absolute data addresses
Reference data members via offsets from nonvolatile registers instead of
directly encoded absolute memory addresses. This is the last change
required for generated code to be fully position independent.

The reduction in code size is generally 5-7%, with the exception of the
N64 RSP, which sees a reduction of nearly 40%. This is mostly a result
of moving the clock increment to instructionEpilogue().
2021-10-15 09:11:47 +01:00
Luke Usher 6b9844a4e4 mia: fix msu-1 rom loading 2021-10-14 20:14:04 +01:00
invertego 3ca1f9ebb4 recompiler: directly emit code for target ABI
Previously, the recompilers in ares would assume the System V calling
convention, then emit extra moves on Windows to handle the differences
in register usage. Now, they directly populate the registers used by the
target system for passing parameters to functions. This is achieved
with register aliases set for the appropriate ABI at compile time.

Furthermore, registers that are nonvolatile only on Windows - rsi and
rdi - are no longer used as temporaries, removing the need to save and
restore them in recompiled code blocks.

This accounts for roughly a 10% reduction in recompiled code size on
Windows while making functionally no difference to other systems.
2021-10-02 10:14:00 +01:00
TascoDLX 47545c7d01 mcd: implement full graphics / 1M-wordram translations 2021-10-01 09:00:52 +01:00
Shideravan d2df3a6b25 Fixing the typo 2021-09-29 09:00:33 +01:00
Shideravan 7b2ddaaab7 Adding ISC badge 2021-09-29 09:00:33 +01:00
invertego 84d4efe09f nall: make thread movable but not copyable
The thread class owns a resource and should have semantics akin to
std::unique_ptr. By allowing copying, the Windows implementation was
calling CloseHandle() when the original copy was destructed, meaning the
new copy would have no actual ownership of the handle. Once the thread
itself exited (dropping the last reference on the handle), later uses of
this handle in join() and ~thread() could end up operating on anything
or nothing depending on whether the handle value had been recycled.

This change modifies the POSIX implementation just enough to keep the
semantics the same as the Windows implementation for users of the class.
Otherwise, there is no functional change.

This fixes random UI hangs and other bad behavior on reset or unload.
2021-09-28 09:08:15 +01:00
invertego 67db4349d8 recompiler: fix instructionEpilogue() test
instructionEpilogue() returns a bool, but all recompilers were
performing a 64-bit test on the return value. If sizeof(bool) == 1, only
the bottom 8 bits are guaranteed to be valid.
2021-09-27 16:54:14 +01:00
TascoDLX bfca0dc6ca 32x: tighten 68k sync 2021-09-27 10:43:34 +01:00
TascoDLX 0ae31ab8a4 mcd: fix h-int vectoring 2021-09-27 10:43:34 +01:00
TascoDLX c4017ede21 mcd: correct wordram 1M access pattern 2021-09-27 10:43:34 +01:00
Shideravan 9f8838e4d9 ares and bsnes are now clickable links to the respective projects 2021-09-27 10:42:02 +01:00
invertego 2770c20007 recompiler: use fixed bss allocation for code caches
Place code caches in the bss section to guarantee proximity to the text
section in order to improve branch prediction and eventually so we can
reliably utilize IP-relative branch instructions.

There is now a fixed 1 GB buffer that is shared by all system cores with
recompilers (m32x, n64, ps1). Because the linker will place it in bss,
it will consume no space in the executable on disk, and operating
systems should be clever enough to avoid comitting physical pages until
it is actually in use. The buffer is defined in a separate translation
unit and only referenced from under compile-time recompiler checks, so
it should be left out by the linker when recompilers are disabled.
2021-09-27 10:41:38 +01:00
invertego 394da44a09 recompiler: add label API to simplify emitting branches 2021-09-27 10:41:24 +01:00
invertego 9b99a961f5 recompiler: emit one epilog per block 2021-09-27 10:41:24 +01:00
invertego d17a5ea045 recompiler: use IP-relative direct branches when possible 2021-09-27 10:41:24 +01:00
Luke Usher 741bfcda01 mia: fix detection of mega-drive device rom header 2021-09-22 11:41:50 +01:00
Lior Halphon ddf5ccadf5 Avoid unicode in files 2021-09-22 09:39:59 +01:00
Lior Halphon 9fc5072597 System colors API and Dark Mode support on macOS 2021-09-22 09:39:59 +01:00
Lior Halphon 151418da8d Hide the memory viewer tool in macOS because hiro on Cocoa lacks the hex editor widget 2021-09-22 09:39:59 +01:00
Lior Halphon 2ad3f3379c Update Tools UI 2021-09-22 09:39:59 +01:00
Lior Halphon e1ad2661a7 High DPI sources, redo CocoaCanvas rendering, improved About dialog 2021-09-22 09:39:59 +01:00
Lior Halphon c1f6d5702a Add HiDPI icons to hiro 2021-09-22 09:39:59 +01:00
Lior Halphon 41f7d14e75 High DPI APIs in hiro 2021-09-22 09:39:59 +01:00
Lior Halphon c6d6431e82 Invert ifdef 2021-09-22 09:39:59 +01:00
Lior Halphon b035ce9560 Proper ellipsis on macOS 2021-09-22 09:39:59 +01:00
Lior Halphon 6599155ad2 Revise the settings UI layouts 2021-09-22 09:39:59 +01:00
Lior Halphon ee61536d52 Cocoa bug fixes 2021-09-22 09:39:59 +01:00
Lior Halphon ff209f0f19 Accidentally ignored fonts 2021-09-22 09:39:59 +01:00
Lior Halphon cac6885bfb Update the look of the settings sidebar 2021-09-22 09:39:59 +01:00
Lior Halphon bdfc477b8a Improve table-view rendering code 2021-09-22 09:39:59 +01:00
Lior Halphon ce43723566 The settings window should not be resizable 2021-09-22 09:39:59 +01:00
Lior Halphon 04ea2a52ee Better handling of fullscreen 2021-09-22 09:39:59 +01:00
Lior Halphon 01a89c3db0 Implement missing window methods 2021-09-22 09:39:59 +01:00
Lior Halphon 2900376896 This convention is the most common on both Windows and Mac for "Recent" menus 2021-09-22 09:39:59 +01:00
Lior Halphon e812f9fdb9 Use the standard Mac term 2021-09-22 09:39:59 +01:00
Lior Halphon add71b87e8 Native file/folder icons 2021-09-22 09:39:59 +01:00
Lior Halphon a563083096 Disable menu icons for Cocoa 2021-09-22 09:39:59 +01:00
Lior Halphon 984d2d125f Proxy icons 2021-09-22 09:39:59 +01:00
Lior Halphon c50a8a0ebe Use consistent ifdefs 2021-09-22 09:39:59 +01:00
Lior Halphon 280bc39df4 Prevent calling output from 2 different threads at the same time (will crash) 2021-09-22 09:39:59 +01:00
Lior Halphon 878d111e52 Fix titlebar discoloration 2021-09-22 09:39:59 +01:00
Lior Halphon f9e755dd04 Fix filtering in dialogs, allow selecting game folders, allow opening game folder via the Dock/open with 2021-09-22 09:39:59 +01:00
Lior Halphon 35279ba28d Fix slider off-by-one 2021-09-22 09:39:59 +01:00
Lior Halphon 815ad9a73d Add onOpenFile to application, make the hiro's Cocoa frontend use it 2021-09-22 09:39:59 +01:00
Lior Halphon fb0d69e74b Add missing Hide shortcuts 2021-09-22 09:39:59 +01:00
Lior Halphon 80c14502f3 Remove excessive use of @autoreleasepools 2021-09-22 09:39:59 +01:00
Lior Halphon ae8f761f46 Switch to ARC 2021-09-22 09:39:59 +01:00
Lior Halphon 5b1cbdb542 Prepare for ARC 2021-09-22 09:39:59 +01:00
Lior Halphon 985e3c10fd Improve menu titles, add keyboard shorts to standard items 2021-09-22 09:39:59 +01:00
Lior Halphon eecdde4ee7 Improve compatibility and silence warnings 2021-09-22 09:39:59 +01:00
Lior Halphon 580b322313 Replace hardcoded Lucida Grande with the current system font 2021-09-22 09:39:59 +01:00
Shideravan 641ebdaca1 MD: Supporting default 3-button Control Pad
And defaulting it, as some older games depend on it to this kind of input to work properly.
eg.: Forgotten Worlds
https://youtu.be/ngHDIFQHFyQ

This also solves https://github.com/higan-emu/ares/issues/177

Fighting pad is still supported just need to be selected in Mega Drive->Controller Port
2021-09-22 09:03:11 +01:00
invertego ed4d21d7a3 scheduler: use 64-bit counters on all platforms
Currently ares is using 128-bit counters when the built-in __int128 type
is available. Near's notes on this topic conceded that it wasn't really
necessary, but defended it by stating there was no speed penalty on
64-bit architectures.

Unfortunately, LLVM's 128-bit integer support is buggy when compiling
for Windows targets. I've filed a bug report and am optimistic this will
eventually be fixed, but to prevent people from being burned when
compiling ares themselves, it would be safer to avoid the built-in
__int128 type entirely.

This change imposes 64-bit counters on all architectures for
consistency. It redefines the nall (u)intmax types to match the standard
(u)intmax_t types, though there is no longer anything in ares using them
at the moment.
2021-09-21 20:37:35 +01:00
Giovanni Bajo b050c5f04c n64: implement perfect PI DMA write
This commit implement perfect PI DMA write. The PI DMA is normally used
for 8-byte aligned transfers, which is where it constantly works. The
hardware does contain a half-baked, buggy support for 2-byte aligned
transfers and odd-size lengths. I have extensively investigated the
behavior of every single quirk, and produced a test ROM that Ares
passes after this commit (timing is still off, but that's for another
day):

https://github.com/rasky/n64_pi_dma_test

The implementation is the same that I've previously submitted to cen64,
adapted for the ares codebase.
2021-09-21 09:06:37 +01:00
invertego d1b00bfa6b link with lld when building with clang for Windows
The LLVM linker is required for both PDB generation and LTO support.
2021-09-21 09:05:26 +01:00
invertego d2ee5b9db9 generate PDB when building with clang for Windows
Also, you can now set symbols=true to forcibly generate debugging
information for any non-debug build configuration.
2021-09-21 09:05:26 +01:00
invertego f275f9f176 allow mingw headers to define __MSVCRT_VERSION__
Whatever defining this manually was intended to fix, today it is only
breaking things. The mingw headers define this as 0x700 if you are
linking against MSVCRT and 0xE00 if you are linking against UCRT. This
is a mingw-internal macro, and there is currently no comparison in the
headers that evaluates differently for 0x601 than for 0x700. However,
always forcing it to 0x601 as nall does breaks linking against UCRT.

We should let mingw define this appropriately.
2021-09-21 09:05:26 +01:00
invertego b069d68e05 fix static initialization in Node subclasses
When building with clang, two static inline members of Node subclasses -
identifier and register - were not consistently initialized in that
order during application startup. Because the constructor of register
depends on identifier, this poses a problem.

I'm not sure if clang is on the wrong or if the initialization order is
actually unspecified by the language standard, but this situation can be
easily avoided, so I opted to do just that.
2021-09-21 09:05:26 +01:00
invertego b6d95c838f enable clang warnings tautological-compare and shift-count-overflow
These warnings can often catch genuine bugs. The only tautological
compare warning I observed was reporting a real bug in the SFC core. The
shift count overflow warnings appeared to be for cases that were benign,
though only because I already fixed a significant one in the instruction
tracer. In general, such shifts are undefined behavior and require
surrendering to the whims of the compiler and the processor
architecture, so they are worth avoiding.

The large diff in ares/component/processor/tlcs900h/instruction.cpp is
mostly uninteresting. I had to make the control flow more explicit for
undefined instructions to stop the compiler from complaining about bad
template specializations. While I was at it, I enabled unused-value
warnings for that file, which only required adding a few void casts.
2021-09-21 09:05:26 +01:00
invertego 0976b64dd8 fix warnings reported by clang
Most of the warnings are from Windows specific code, as the rest of the
codebase is already fairly clean. This change fixes a couple of (benign)
bugs discovered by these warnings.

In hiro/windows/action/menu.cpp, menu-item.cpp:
A function pointer was being passed in place of a bool argument to
nall::image::scale(). At one point the name Interpolation::Linear
referred to an enum. In any case, the argument in question defaults to
true - specifying linear interpolation - so it is unneeded.

In hiro/windows/widget/widget.hpp:
The function minimumSize() was being overloaded instead of overridden
due to a missing const qualifier. It doesn't appear to have had any
negative side effects in ares.
2021-09-21 09:05:26 +01:00
Luke Usher c71f131b0c Merge commit '8639e306c77db691296adebcd6be33870fbec619' 2021-09-17 13:35:22 +01:00
Luke Usher 8639e306c7 Squashed 'ares/n64/vulkan/parallel-rdp/' changes from 464ab61fc..05136e3b4
05136e3b4 Update to 31ea5eb2d6fcb2d8f1df5f0951364322d09ac01a

git-subtree-dir: ares/n64/vulkan/parallel-rdp
git-subtree-split: 05136e3b4717fc78445e6c5b3085601151327eb3
2021-09-17 13:35:22 +01:00
invertego 822186413c debugger: fix address masking in instruction tracer
This change corrects masking for 32 bit addresses.

Per the C++ standard on shift operators: "The behavior is undefined if
the right operand is negative, or greater than or equal to the width of
the promoted left operand."
2021-09-15 15:16:04 +01:00
TascoDLX da53c2b905 ares: bump serializer version ahead of next point release 2021-09-13 09:01:12 +01:00
TascoDLX f09cddddd5 m68000: implement STOP'd state 2021-09-13 09:01:12 +01:00
TascoDLX 56ea29e244 md: implement HV-counter latching 2021-09-13 09:01:12 +01:00
TascoDLX e6231d4379 md: correct DMA fills (according to research by Nemesis) 2021-09-13 09:01:12 +01:00
TascoDLX 8ab3f79f6a md: fix VDP control port writes 2021-09-13 09:01:12 +01:00
TascoDLX 547d6658dd md: fix VRAM byte addressing 2021-09-13 09:01:12 +01:00
invertego 008486531d n64: decrease SI DMA delay
Reduce the (minimum) number of cycles between an SI DMA request and the
completion of said request from 131072 to 2304 cycles. This is the
duration used in other emulators, and it is in agreement with the
observed behavior of Turok, which can only tolerate a delay between 215
and 3888 cycles (subject to current timings in ares).

In addition to fixing input in Turok - Dinosaur Hunter, this change gets
the following games past the intro:
- Donkey Kong 64 (w/ major graphical issues)
- Forsaken 64
- Hercules - The Legendary Journeys
- Triple Play 2000
2021-09-12 22:46:25 +01:00
invertego 1e71f59bc0 n64: fix fpu compare and divide exceptions
On compare to NaN:
- do not raise an exception if exceptions are disabled
- do not update the csr condition bit if exceptions are enabled

On divide by zero:
- do update the destination fpr if exceptions are disabled

For both of the above:
- do set the csr cause bit
- do set the csr flag bit if exceptions are disabled

Turok is now able to play out the entire Acclaim logo animation. It was
previously resetting due to erroneously raised invalid operation
exceptions.
2021-09-12 22:46:02 +01:00
invertego 80bc2ad805 n64: default to 3 controllers for Jeopardy!
Jeopardy! only supports up to 3 players, and if four controllers are
plugged in when the game starts, it performs an out of bounds array
access that breaks further input logic. The only workaround is to unplug
a controller and reset the system. To make this game work well in ares
out of the box, we should connect no more than 3 controllers by default.

I opted to put a check specifically in desktop-ui because this is
fundamentally a mismatch between a specific game and a design choice (to
default to 4 controllers) in the desktop-ui frontend. It didn't feel
right to add a dedicated attribute to mia that did not describe a
feature of the cartridge itself and would not be generally applicable
other games (unlike rumble and memory pak support).

This change also brings the rumble and memory pak attributes in line
with the implementation of boolean attributes for other systems. There
is no functional change, though it will affect generated manifests if
they are/were persisted to disk.
2021-09-11 18:26:16 +01:00
invertego ae6cbb52ae n64: fix PIF RAM init on cold boot, preserve RDRAM on warm reset
A recent workaround for BattleTanx caused a regression in Perfect Dark.
Essentially, it was always telling games that they had been started by a
warm reset rather than a cold boot. Perfect Dark expects data to be
preserved in RDRAM across resets and fails to get as far as drawing
something on the screen if it isn't there.

This change reverts the workaround so that Perfect Dark will perform the
full initialization required after a cold boot. Luckily, this will not
regress the BattleTanx games, as they were fixed by my last change
(making sure IPL3 consumes a sufficient number of cycles). This change
also skips clearing RDRAM on resets, which is again required by Perfect
Dark and possibly other games.
2021-09-10 13:47:06 +01:00
invertego 3212ce0148 n64: consume cycles to compensate for skipped RDRAM initialization
The RI_SELECT register is read by IPL3 to check if RDRAM initialization
should be skipped. If we are forcing it to be skipped, we should also
consume enough cycles to not inadvertently speed up the boot process.

Wave Race 64 Shindou Pak Taiou Version will freeze on the N64 logo if
the SCC count register, which increments at half the CPU clock rate, has
too small a value.

The idea of using RI_SELECT reads as a cue to consume extra cycles was
borrowed from MAME.

Thanks to Rasky for measuring the timing on real hardware.
2021-09-09 21:48:37 +01:00
remutro e43902175c fix n64 controller detection/reporting 2021-09-09 21:15:07 +01:00
remutro 9065009045 add detection for shindou editions of wave race and mario 64 2021-09-09 21:15:07 +01:00
Luke Usher fe94e4046c docs: remove old docs directory 2021-09-08 09:48:31 +01:00
remutro a5d8289017 remove erroroneous Fifa entry, fix the world is not enough id - thanks simer 2021-09-06 09:04:41 +01:00
remutro 11a97f6cd1 Add mempak and rumble status to mia; elimiate most controller pak or rumble pak warnings in games 2021-09-05 20:29:35 +01:00
Luke Usher 4146f9df6d pc-engine: hide multitap and "controller port"
This means that it is not possible to disconnect the multi-tap, but it
avoids unsupported situations within ares, that lead to crashes.
2021-09-02 15:58:05 +01:00
remutro 530ce845c5 Workaround for Github issue: https://github.com/higan-emu/ares/issues/61 2021-09-02 09:02:42 +01:00
jeltaqq b199273635 n64: Better Flashram support
Fix Majora's Mask, Paper Mario, Derby Stallion 64
2021-09-01 21:05:04 +01:00
Shideravan 9e1402d437 Removing unnecessary address manipulation 2021-08-31 14:50:05 +01:00
Shideravan 1c2c5845e1 Removing programRAM 2021-08-31 14:50:05 +01:00
Shideravan fb10aba946 Removing CHR RAM 2021-08-31 14:50:05 +01:00
Shideravan 1d4b82f0d5 Creating support for Jaleco JF11/JF14 (Mapper 140) 2021-08-31 14:50:05 +01:00
Ghislain Antony Vaillant 40ce138196 Install icons in freedesktop compliant location
See https://specifications.freedesktop.org/icon-theme-spec

Same behavior as with bsnes and higan.
2021-08-31 13:05:18 +01:00
Ghislain Antony Vaillant 53c0e1c190 Fix window background with GTK3 2021-08-31 13:04:55 +01:00
Ghislain Antony Vaillant beea62f4c3 Use XDG base directories 2021-08-31 13:04:41 +01:00
invertego e6948d2c03 ruby: fix conflated keys on Windows
The flags returned by the Raw Input API have distinct meanings. The
lowest bit reflects the state of the key and the next two bits indicate
scan code prefixes. An oversimplified interpretation of these flags was
causing ruby to conflate events for keys that differ only by prefix.

Reference:
https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-rawkeyboard

The full set of conflated key pairs:
Return Enter
Keypad0 Insert
Keypad1 End
Keypad2 Down
Keypad3 PageDown
Keypad4 Left
Keypad6 Right
Keypad7 Home
Keypad8 Up
Keypad9 PageUp
LeftAlt RightAlt
LeftControl RightControl
Multiply PrintScreen
Point Delete
Slash Divide
2021-08-28 17:48:28 +01:00
TascoDLX 2c970caafe md: fix dma fill errors by synching trigger with fifo 2021-08-28 10:11:55 +01:00
TascoDLX 6017b3dd52 ares: resync serializer version to current release, v123 2021-08-28 10:11:55 +01:00
TascoDLX bb49f49373 md: fix sprite masking and overflow 2021-08-28 10:11:55 +01:00
invertego 206a87c82d ngp: fix off-by-one error in LDAR instruction
The TLCS-900 manual states the loaded address is relative to the start
of the instruction plus four bytes - in other words, one byte before the
end of the instruction.

This fixes crashes in SNK Gals' Fighters.
2021-08-28 10:10:01 +01:00
invertego b2e6f2b280 tms9918: widen vcounter to 9 bits
By using an 8 bit counter, the last 6 lines of every frame were being
skipped and the VDP was firing vblank interrupts ~2.3% faster than
intended in the ColecoVision, SG-1000, and MSX.

This also fixes the corrupted turtle graphics in Frogger for
ColecoVision, though this is mostly by chance. The game is buggy and
susceptible to graphics corruption if a vblank is raised between these
instructions:

1d09  out  ($bf),a      ; write low VRAM address byte
1d0b  ld   a,h
1d0c  out  ($bf),a      ; write high VRAM address byte

It could easily be regressed by any future change that impacts timing.
2021-08-27 10:06:30 +01:00
Luke Usher 4e8015b663 ares: add a selection of public domain shaders 2021-08-26 10:31:53 +01:00
invertego 1d4ac499e2 gb: resume from halt whenever (IE & IF) != 0
Normally, breaking out of the halt state is handled by CPU::raise(), but
there is an edge case:
    ; preconditions: IME = 0, IE = 1, IF.0 = 1, LCDC.7 = 0
    ei
    halt

In other words, a vblank interrupt was requested with IME disabled, then
the display was disabled (so no more vblank interrupts will follow),
then interrupts were enabled while entering the halt state. Once halted,
there is no logic in ares to service the requested vblank interrupt.

A better long term approach would be to refactor the SM83 implementation
of halt to be more like the Z80 core - eliminating the loop within the
halt instruction itself - but in the meantime this change offers an
incremental improvement.

This fix prevents Amazing Penguin from freezing immediately on load.
2021-08-26 07:34:00 +01:00
invertego 7ac40e85c6 gb: improve handling of LCD/BG enable bits on DMG
On DMG, when the LCD is toggled from off to on, the screen remains blank
until one frame after the PPU becomes operational.

Furthermore, when the BG is disabled, the window is also no longer
drawn, though the other window logic (like the incrementing window line
counter) seems to remain operational.

This cleans up the visuals of Hyper Lode Runner on level start, but many
more games will be affected by blanking the first frame after the LCD is
toggled on.
2021-08-26 07:07:24 +01:00
Luke Usher 2380e62c79 md: fix sync to be in terms of cpu cycles 2021-08-25 09:45:22 +01:00
Luke Usher 5f0baa9405 pce: remove debug print from multitap 2021-08-24 13:09:50 +01:00
Luke Usher 6f3a90b938 pce: support multi-tap 2021-08-24 12:54:18 +01:00
Luke Usher 99183728eb n64dd: implement all 4 ports 2021-08-24 12:46:35 +01:00
Luke Usher ab39fe00f0 n64: connect ports 3 & 4 2021-08-24 12:11:35 +01:00
Luke Usher 50d76e2657 desktop-ui: support up-to 5 virtual pads
This allows for all four n64 controllers to be used, while providing
capatbility to expand to five controllers for PC-Engine, once we
implement the multi/tubo-tap
2021-08-24 11:33:18 +01:00
Luke Usher d7c3f860f9 readme: remove compatibility/features table
These are best suited to the website, to avoid duplicating the effort of 
updating this information in multiple places.
2021-08-24 09:04:17 +01:00
invertego 8d8de9e328 gb: emulate serial transfers with no link
When a serial transfer is started using the internal clock and no second
device is connected via link cable, 1 bits are shifted into the SB
register. This behavior must be emulated for the game Alleyway;
otherwise, it does not accept player input.
2021-08-24 09:02:00 +01:00
invertego bd0d68a788 gb: remove limit on window width
I couldn't find any research to support this limit, nor does it match
the behavior of other emulators. Everything I could find indicates that
the window should be drawn to the end of the line.

This fixes the right edge of the pause screen in Heiankyo Alien.
2021-08-24 09:01:19 +01:00
TascoDLX d7b57ba411 md: fix h-int signaling 2021-08-24 06:52:15 +01:00
TascoDLX 13786dec7c md: fix dma transfer rate 2021-08-24 06:52:15 +01:00
invertego e5b521d4fb gb: use stable sort for sprites
On DMG, sprites are sorted by x value then by OAM address. As the sprite
array begins in OAM order, a stable sort on x can achieve the desired
result. Conveniently, nall already contains a stable sort implementation
that is optimized for small arrays.

This fixes ordering issues with speech bubbles in Crayon Shin-chan 3.
2021-08-23 09:11:43 +01:00
invertego b44f4b57a6 gb: bring fast boot closer to normal boot
The previous fast boot patch skipped the entire Nintendo logo animation
and sound. Unfortunately, this left a number of registers with different
values than they would otherwise have. The European release of the game
Dr. Franken does not initialize SCY, and fast boot was leaving it set to
100 instead of zero, causing the first logo to be shifted offscreen.

It would be easy enough to amend the patch to initialize SCY to 0, but
for most games this will cause the Nintendo logo to appear for a single
frame, which doesn't look so great.

This new patch skips the first ~4 seconds of the boot animation and
disables scrolling but otherwise leaves things alone. The result is a
a stationary Nintendo logo that appears centered on the screen,
accompanied by the usual sound, for ~1.5 seconds.
2021-08-23 08:52:44 +01:00
Luke Usher 5abc150d05 ares v123 released
ares v123 includes significant improvements to the emulation of the ColecoVision,
SG-1000 and the Game Boy/Game Boy Color.

This release brings the compatibility rating for ColecoVision and SG-1000 to
four stars.

This means that we have 100% compatiiblity with both of those libraries, with
the only exception being the few games that require additional peripherals
(driving controllers; touchpads, etc).

The Game Boy improvements are significant, but not quite enough to increase
the compatibility rating at the present time, even so, Many more games are
playable than before.

Finally, a few tweaks to MegaDrive emulation have improved compatibility,
reduced the occurance of video corruption, and improved performance of
the Sega 32X emulation.

**Changelog:**

 * ColecoVision: Initialize ram to 0; fixes a crash in The Heist [Luke Usher]
 * ColecoVision: Disable cartridge rom mirroring; fixes Sammy Lightfoot [invertego]
 * ColecoVision/MSX/SG-1000: Initialize VRAM to 0; fixes various games [invertego]
 * Game Boy: Check window x-coord instead of only y-coord; improves the Acid2 test rom [Luke Usher]
 * Game Boy: Only raise STAT interrupt when display is enabled; fixes Cool Hand [invertego]
 * Game Boy: Implement HALT hardware bug [Meepster99]
 * Game Boy: Fix relationship between LY and STAT interrupt; fixes Elite Soccer, Mouse Trap Hotel, Shantae [invertego]
 * Game Boy: Only trigger STAT interrupts at the start of OAM search; fixes Mortal Kombat 3 [invertego]
 * Game Boy Color: Fix HDMA5 bit.7 reads; improves a significant number of GBC games [invertego]
 * Game Boy Advance: Simulate standard GBA instead of Game Boy Player; fixes GBA Video titles [Luke Usher]
 * Mega Drive: Implement support for Sonic & Knuckles merged roms; fixes Sonic 2K, Sonic 3K [Luke Usher]
 * Mega Drive: Implement support for SRAM/EEPROM when using the SEGA Mapper; fixes Demons of Asteborg [Luke Usher]
 * Mega Drive: Default to 'accuracy' VDP; improves compatibility at the expense of performance [Luke Usher]
 * Mega Drive: Optimize how often the emulator synchronises between components; offsets the cost of the previous change [Luke Usher]
 * Nintendo 64: Maintain Parallel-RDP as a subtree; simplifies compilation [Luke Usher]
 * SG-1000: Implement support for roms greater than 32KB [Luke Usher]
 * SG-1000: Implement support for Taiwan Type-A/Type-B mappers; fixes unlicensed Taiwan releases [Luke Usher]
 * SM83: Fix DAA instruction [Meepster99]
 * TMS9918: Implement multicolor mode; fixes various SG-1000/ColecoVision games [invertego]
 * TMS9918/Master System/MSX: Allow sprites to bleed off top/left screen edges [invertego]
 * ares: Rename lucia to desktop-ui to better represent it's function [Luke Usher]
 * mia: Improve N64 save-type database [jeltaqq]
 * mia: Add support for UNF extension, alongside UNIF and NES [Shideravan]
 * nall: Add macOS deployment target flags; fixes ares on macOS 10.14 [MerryMage]
 * ruby: Give PulseAudio higher priority than ALSA on Linux Systems; ALSA was causing frame-rate issues [Luke Usher]
2021-08-22 14:32:04 +01:00
Luke Usher 91b1ef6837 readme: bump SG-1000 to four stars 2021-08-22 10:56:40 +01:00
invertego c1d8f2d873 gbc: invert HDMA5 bit 7 on read
A refactor in v116r07 replaced the variable dmaCompleted with dmaActive
but failed to update its usage on HDMA5 register reads. Bit 7 should
read 0 if HDMA is active and 1 if completed.

This change will affect many (most?) GBC games.
2021-08-22 09:46:05 +01:00
invertego 4ee6492d18 gb: only trigger STAT at start of OAM search
STAT interrupts triggered by mode 2 (OAM search) should only occur at the
start of the line. Crucially, writes to STAT in the midst of mode 2 that
enable OAM interrupts should not trigger a STAT interrupt. This is
especially important on DMG because of the hardware bug that causes STAT
writes to briefly enable all STAT interrupts. Spurious STAT interrupts
that would not have occurred on real hardware can violate the
assumptions of games that aren't expecting them. Mortal Kombat 3 is one
such game, and it is now playable.
2021-08-22 09:45:30 +01:00
Luke Usher 8bfef958aa ares: remove accidental vscode file 2021-08-21 21:19:37 +01:00
invertego d50e9d2f5d gb: reconcile LY with STAT interrupts
Previously, ares was emulating the coincidence flag in the the STAT
register with M-cycle accuracy but was much less accurate with the
timing of coincidence triggered STAT interrupts or with resetting the LY
register to 0 during vblank. This was breaking a pattern common to a
number of games that goes like this:

1) Write 0 to LYC and set the coincidence interrupt enable bit in STAT
2) In the STAT interrupt handler, read LY and increment by one
3) Loop until LY equals the incremented value

ares would trigger a STAT interrupt during line 153 but LY would
continue to read back as 153 instead of 0. A game incrementing this
value and waiting for it to appear in LY would become stuck in an
infinite loop, as there is no line 154.

This change brings M-cycle accuracy to the LY register and STAT
interrupts using "The Cycle-Accurate Game Boy Docs" by AntonioND as a
reference. It also stops resetting LY on write, as this erroneously
described behavior is not hardware accurate.

The following games should now be playable:
- Elite Soccer
- Mouse Trap Hotel
- Shantae
2021-08-21 12:44:53 +01:00
Luke Usher 8e94e664c5 md: optimize how often we sync the cpu with other components.
This significantly improves performance for md, cd, 32x and cd32x, with
minimal impact on accuracy.

Assuming 3420 cpu cycles per scanline, with a max horizontal resolution
of 320/342:

For MegaDrive/Mega-CD, we can sync every 10 cycles (approx 1 pixel),
since we're using a dot renderer, there is little point in synching more
often than that.

For 32X/CD32X, we sync once every 40 cycles (4 pixels), this provides
enough of a performance boost to make 32X emulation viable for modest
machines, but does not significantly impact compatibiltiy or accuracy;
it's still significantly better than with the scanline renderer we used
previously.
2021-08-20 10:49:46 +01:00
Luke Usher 9c7f114baf md: default to accuracy vdp
This improves compatibility with both MegaDrive and 32X titles at the
expense of performance.

On modest hardware, this still retains full-speed for MegaDrive titles, but 32X and MegaCD may struggle; this will be addressed in a later
commit.
2021-08-20 10:37:26 +01:00
Shideravan 0056a195b1 Adding .unf file support
Fix https://github.com/higan-emu/ares/issues/70
2021-08-20 08:55:00 +01:00
Meepster99 5072497629 Fix cpu.hpp 2021-08-19 20:50:44 +01:00
Meepster99 46675146ff Fixed halt bug
Halt bug fixed, albeit not elegantly
switched spacing to spaces instead of tabs
2021-08-19 20:50:44 +01:00
Luke Usher 65f3f507c8 ruby: shuffle order of optimal drivers
PulseAudio seems to perform better than ALSA when available.
2021-08-19 19:32:40 +01:00
Luke Usher 9f92c633ee md: fix sram/eeprom in banked cartridges
This fixes saving in Demons of Asteborg
2021-08-19 18:57:19 +01:00
Luke Usher faa4f1854a desktop-ui: use 'Game Boy Advance' instead of 'Game Boy Player'
This fixes compatibility with the GBA Video titles.
2021-08-19 11:23:45 +01:00
invertego 7a55003e5f gb: only raise stat interrupts if display enabled
This emulation bug, combined with the intentional emulation of the
hardware bug that causes spurious stat interrupts, was causing stat
interrupts to be raised when the display was disabled.

This stops the GB game Cool Hand from freezing after selecting cribbage.
2021-08-19 10:53:25 +01:00
Luke Usher 8574d0db24 gb: check window x-coord
This dramatically improves the acid-2 tests for DMG and CGB, but they are still imperfect.
2021-08-19 10:49:27 +01:00
Meepster99 c96f34ad02 Fix DAA instruction 2021-08-18 22:12:53 +01:00
Luke Usher 6b6b6027ec sg: fix all known taiwan type-a/type-b games 2021-08-18 21:40:14 +01:00
Luke Usher 0d8933988b sg: add support for Taiwan mappers
Currently only Bomberman Special and Knightmare are supported

The remaining games will be added to the database later.
2021-08-18 16:39:22 +01:00
Luke Usher 7f5be570cd md: fix Sonic & Knuckles
This removes the special casing for Sonic & Knuckles, treating it as a standard rom.

While not strictly correct from an accuracy/real world point of view, all existing
emulators and rom dumps assume the emulator will treat it as a single cart.
2021-08-18 09:27:40 +01:00
invertego 94de2e10d7 ms, v9938: allow sprites to bleed off top/left screen edge
Apply fixes to the Master System VDP and the V9938 (used by MSX 2) that
are analogous to the recent TMS9918 fix.
2021-08-18 09:09:22 +01:00
Luke Usher 862e94b49d ares: point to new website 2021-08-16 15:58:08 +01:00
Luke Usher ad51e37222 sg: support roms > 32k 2021-08-16 15:04:43 +01:00
Luke Usher b3a438b9eb readme: bump ColecoVision to 4 stars
In the most recent builds, all games that do not require additional peripherals are playable
2021-08-16 14:15:55 +01:00
invertego 9d2bd692f5 tms9918: allow sprites to bleed off top/left screen edge
The TMS9918 allows for sprites to, in the words of TI's VDP Programmer's
Guide, "bleed" off the top or left edge of the screen. Depending on the
edge, this is accomplished by different means.

Proper implementation of this behavior is known to affect the following
ColecoVision games:
- Frogger: some sprites should be hidden off the left edge of the screen
- The Heist: the player sprite crosses the left edge of the screen
- Bump 'N' Jump: car sprites cross the top edge of the screen

It looks as though the V9938 and SMS VDP will require similar fixes.
2021-08-16 07:02:32 +01:00
invertego 55f8a38d59 cv, msx, sg: init VRAM to zero on load
Initialize VRAM to zero on load for systems that use the TMS9918/V9938.
On real hardware this memory will be in a partially indeterminate state,
but as far as approximations go, 0x00 is much less problematic than
0xff. A sprite attribute table filled with 0xff is interpreted to have
valid entries for sprites in the top right corner of the screen. If the
pattern data is also filled with 0xff, a white square will be drawn in
the corner. On the other hand, a sprite entry of all 0x00 bytes will be
fully transparent (due to the color byte being zero) and therefore
invisible.

This is most noticeable in games that never get around to fully
initializing VRAM, such as the ColecoVision game Boulder Dash, which has
a permanent square in the corner.

SG-1000 games only seem to exhibit this problem briefly after booting,
and only for certain games, as they eventually get around to
initializing VRAM. Some homebrew is more seriously affected.

MSX compatibility is in too poor a state to test comprehensively, but a
survey of other emulators shows initializing VRAM to zero is the norm.

This change also allows VRAM to carry over across soft resets. This
should be closer to hardware behavior, though in reality it is possible
for some bits to be perturbed.
2021-08-16 07:02:06 +01:00
Luke Usher 3288fcce4e make 'update-subtrees' script executable 2021-08-15 08:36:15 +01:00
invertego 13e23df347 tms9918: implement multicolor mode
This mode is used by the ColecoVision games Cabbage Patch Kids Picture
Show and Smurf Paint 'n' Play Workshop.
2021-08-11 08:52:36 +01:00
invertego 409ea8d7cf cv: disable cart rom mirroring
ColecoVision carts contain up to 4 separate 8 KiB banks, and there is no
mirroring when some banks are absent. The existing mirroring behavior
was causing Sammy Lightfoot to freeze on load.
2021-08-07 09:16:05 +01:00
jeltaqq 7aa95db26c mia: Fix n64 save chip database
First Japanese revisions of Kirby 64 used sram.
2021-08-06 12:04:10 +01:00
Luke Usher c2fcacb331 n64: maintain parallel-rdp as a subtree 2021-08-06 10:52:33 +01:00
Luke Usher 60e135a71d Squashed 'ares/n64/vulkan/parallel-rdp/' content from commit 464ab61fc
git-subtree-dir: ares/n64/vulkan/parallel-rdp
git-subtree-split: 464ab61fce58b27a0e0ed9f0e366aa1113694965
2021-08-06 10:50:32 +01:00
Luke Usher b083b32836 Merge commit '60e135a71d50b583dc2bb2f4371f02c100c6a6ab' as 'ares/n64/vulkan/parallel-rdp' 2021-08-06 10:50:32 +01:00
Merry 7adfece675 nall: Add macOS deployment target flags 2021-08-05 18:45:48 +01:00
Luke Usher 8da4623d39 cv: initialize ram to 0; allows 'The Heist' to reach in-game 2021-08-04 22:31:54 +01:00
Luke Usher 189487a2ca rename lucia -> desktop-ui/ares
To avoid/reduce confusion, the ares gui (lucia) has been renamed  to
desktop-ui.

The executable name/install name/settings directory are named ares.
2021-08-04 21:50:08 +01:00
Luke Usher 82040066b2 ares: bump version number, start next dev cycle 2021-08-04 21:30:06 +01:00
Luke Usher e14b01fdc4 ares v122 released
This release primarily provides improved Neo Geo Pocket/Neo Geo Pocket Color and Sega 32X emulation.

The entire Neo Geo Pocket/Color library is now thought to be playable, with minor graphical issues in four titles.

A small number of SEGA 32X games are now playable, although most still experience graphical and/or audio issues.

Changelog:

ColecoVision: Clear top bit of controller port reads; fixes Defender [invertego]
Neo Geo Pocket: Allow BIOS to handle the boot process [invertego]
Neo Geo Pocket: Copy SNK logo from BIOS during fast boot; fixes Metal Slug: 2nd Mission [invertego]
Neo Geo Pocket: Fix address used to test ram initialization [invertego]
Neo Geo Pocket: Initialize Neo Geo Pocket port 1 to zero; fixes Dynamite Slugger [invertego]
Neo Geo Pocket: Many improvements to 'fast boot' [invertego]
Neo Geo Pocket: Re-enable savint ram to disk on unload [invertego]
Sega 32X: Implement FM/Framebuffer access bit; fixes Spiderman [Luke Usher]
Sega 32X: Implement RV bit [Luke Usher]
Sega 32X: Optimise SH7604 recompiler min-cycles for 32X; fixes Knuckles Choatix & Virtua Fighter [remutro]
Sega 32X: PWM DREQ and timer are different things; fixes PWM audio in many games [Luke Usher]
Sega 32X: Used cached interpreter instead of recompiler [Luke Usher]
TMS9918: Fix sprite size emulation; fixes many graphical issues in ColecoVision/MSX/SG-1000 [invertego]
TMS9918: fix interrupt behavior [invertego]
hiro: Fix browser dialog filters on macOS [Luke Usher]
hiro: Force GTK3 to use X11 backend; fixes a crash under Wayland [thrimbor]
lucia: Disable fast boot by default [Luke Usher]
lucia: Support digital presses from analog inputs [invertego]
mia: Add workaround for underdumped Delta Warp rom [Luke Usher]
mia: Improve Nintendo 64 save chip database; fixes saving in some titles [sp1187]
nall: Enable LTO by default on non-debug builds [Luke Usher]
nall: Speed up recompiler codegen [Luke Usher]
sh2: Allow cores to determine an ideal minimum recompiler block size [Luke Usher]
sh2: Optimised code-gen for the interpreter [Luke Usher]
sh2: Recompiler should invalidate single blocks, not entire pools [Luke Usher]
tlc2900h: Fix immediate mask in BIT #,r; fixes Pocket Tennis [invertego]
z80: Correct the effect of IE on the next instruction; fixes audio drop-out in Neo Geo Pocket games [invertego]
2021-08-02 20:05:24 +01:00
invertego 768d31d4dd tms9918: fix interrupt behavior
The existing implementation was very incorrect. Fortunately, this chip
is well documented and the correct behavior is quite easy to implement.
This fixes most of the remaining ColecoVision bugs that aren't related
to missing peripheral support.

The TMS9918 is also used by the SG-1000 and MSX cores. I don't have a
list of bugs for those platforms, so I couldn't do any targeted testing,
but I booted up a few games and did not see any new issues.
2021-08-02 15:56:48 +01:00
invertego 4304c1c108 TMS9918, V9938, SMS VDP: fix sprite size emulation
Commit 532aafe074 made some improvements
to sprite zoom (magnification) emulation. It also corrected sprite size
emulation in the SMS VDP in what is referred to as Mode 4 by most
sources ("graphics3" in ares). Unfortunately, it erroneously applied the
same changes to the TMS9918 and V9938 as well as the SMS VDP in TMS9918
compatible modes. This caused widespread regressions in ColecoVision,
SG-1000, MSX, and MSX2 emulation.

This commit reverts the changes made outside of SMS VDP Mode 4,
restoring the dimensions of double sized sprites from 8x16 to 16x16.
2021-08-02 09:28:43 +01:00
invertego 0054b5793e cv: clear top bit of controller port reads
I couldn't find any references describing the expected value of the top
bit of controller port reads, but some games require it to be cleared.
Here is an example from Defender when it is waiting a 1/2 button press:

in   a,($FC)    ; read controller 1
cp   $7D        ; compare 1 button
jr   z,$876D
cp   $77        ; compare 2 button
jr   z,$8773

Clearing it fixes input in games that depend on all the undefined bits.
2021-08-02 09:26:50 +01:00
Luke Usher b3fd78e6f4 readme: promote NGP/NGPC to 4 stars.
The only known issues are minor graphical glitches, not harming gameplay.
2021-07-29 14:02:54 +01:00
Luke Usher 8046515c7a mia: oops, whitespace
This is what happens when I use GitHub to make a commit, rather than locally. 
Lesson learned.
2021-07-29 13:37:27 +01:00
Luke Usher 76c4d09118 mia: add workaround for underdumped Delta Warp rom 2021-07-29 13:33:46 +01:00
invertego 4100ae0009 z80: correct the effect of IE on next instruction
The implementation of IE in the Z80 processor was incorrectly causing
nonmaskable interrupts raised before the next instruction to be dropped.
A correct implementation should do two things:
- set IFF1 and IFF2 to 1
- disable maskable interrupts until after the following instruction

This fixes the issue of audio dropping out of Neo Geo Pocket games
seemingly at random.

References:
Z80 CPU User Manual (http://www.zilog.com/docs/z80/UM0080.pdf)
Page 6: "NMI is always recognized at the end of the current instruction,
independent of the status of the interrupt enable flip-flop..."
Page 183: "During the execution of this instruction [EI] and the
following instruction, maskable interrupts are disabled."
2021-07-26 12:04:08 +01:00
Simon Eriksson ab9bc590a2 mia: Improve n64 save chip database
Use three first letters of game ID for mapping.
Add more entries (mostly Japanese games) and fix a few incorrect ones.
Handle some special cases involving different save chips for different
revisions and regions of the same game.

Change manifest generation to use whole four-letter ID and also output
the revision.
2021-07-26 10:02:24 +01:00
remutro 87d97af20a Optimize SH7604 Recompiler Min Cycles for 32X
modified:   ares/md/m32x/sh7604.cpp

Change the cached interpreter's recompiler min_cycles value from 23 to 22.
It's just ever so slightly too agressive.

This addresses problems with the bonus levels in Knuckles Chaotix,
as well as the hang in Virtua Fighter after selecting your character.

This appears to be the optimal value through lots of additional testing.
There were no other problems observed in the 32X library by lowering this
value to 22. Additionally, there were no further gains to be made by going
any lower (all the way to zero) such as correcting the hang at the end of
the match in Brutal: Above the Claw or NBA Jam failing to go in-game. Both
of these currently require using the full interpreter, and not the cached
interpreter enabled by default to correct timing issues.

This fixes 5% of games in the 32X library. :-)
2021-07-26 10:02:08 +01:00
invertego 544759dff7 lucia: support digital presses from analog inputs
lucia maps the N64 C-buttons to the right thumbstick of the virtual pad.
These are analog inputs on the virtual pad, so sampled analog values are
not converted to digital. This means any nonzero value is treated as
button press, which is not ideal when mapped to an analog input device.

This change introduces a helper to convert raw input values to a binary
"pressed" state at time of use, currently only defined for digital and
analog input mappings - for relative and absolute inputs this concept
would not make much sense.
2021-07-26 09:46:51 +01:00
invertego 595f87f3ac ngp: fix address used to test ram initialization
My last change indexed into the ram array by an absolute memory address,
but the array only covers a portion of the address space beginning at
0x4000. This was in fact indexing past the end of the array, but it
appeared to work as long as 1) something was mapped there and 2) that
something was nonzero. It's possible that booting from the shutdown
vector every time doesn't have any negative side effects, but booting
from the hardware reset vector the first time is still the more correct
thing to do from an accuracy perspective.
2021-07-22 18:35:31 +01:00
invertego 815f4b31d8 ngp: allow BIOS to handle the boot process
Neo Geo Pocket is an "always on" system. On first boot, it quickly
enters a low power state via a halt instruction. From there, the user
must press the power button to wake the sytem. At this point, the BIOS
setup is shown, requiring the user to pick a preferred language among
other choices. When power is pressed again, the system returns to a low
power state. This state is maintained by an internal battery should the
external batteries discharge or be removed. The hardware reset entry
point will not execute again until the internal battery fails.

The current design of ares appears to be motivated by a few goals:
- Avoid requiring the user to press the emulated power button
- Avoid showing the BIOS setup more times than necessary
- Enable "fast boot" mode to skip the boot animation

The required power button press is avoided by skipping the first boot
code entirely in CPU::power(). Emulation never begins at the hardware
reset vector, but rather at 0xFF1800, following MAME's lead. This entry
point appears to have been for development purposes only and is not
referenced by the BIOS itself. Crucially, it does not run some
bookkeeping logic that only occurs when entering a low power state
either after a cold boot, in response to a power button press, or after
a software requested shutdown. Skipping this logic can cause the BIOS
setup to be shown on next boot.

The BIOS setup is avoided by simulating the bookkeping done by the BIOS
in the emulator itself. This logic is located in CPU::load(), meaning
that it does not run between system resets. Therefore, resetting a game
can still cause the BIOS setup to be shown. The BIOS setup is also
skipped by fast boot mode.

Fast boot mode bypasses the BIOS entirely on boot, jumping straight to
the cartridge entry point. This means all of the many important side
effects of the boot process must be replicated by CPU::fastBoot().
Currently, it also gives the user no way to select Japanese as a
preferred language.

The existing solutions to these problems fall short of providing a
consistent user experience, tightly couple ares to the internals of the
BIOS rom, and (particularly with fast boot) have been a source of many
bugs. This change removes the existing solutions in favor of ones that
let the BIOS handle the entirety of the boot process.

The new code in this change does the following:
- Begin execution at the hardware reset vector on first boot
- Begin execution at the VECT_SHUTDOWN syscall on subsequent boots
- Simulate a power button press when entering a low power state
- Patch the BIOS to skip the boot animation in fast boot mode

Starting at the hardware reset vector ensures the BIOS setup will be
shown on first boot, affording the user the opportunity to pick a
preferred language. Subsequent boots will begin at the VECT_SHUTDOWN
system call. It may seem counterintuitive, but this allows the BIOS to
perform cleanup that would normally only occur when the user shuts off
the device before switching cartridges. In both of these cases, we can
avoid requiring the user to press the emulated power button by
simulating a button press on their behalf. It's a low tech solution to
be sure, but a reliable one.

Finally, the implementation of fast boot mode is replaced with a single
byte patch to the BIOS to immediately return from the routine that plays
the boot animation.
2021-07-21 13:00:05 +01:00
Luke Usher 657b0c0f5d sh2: invalidate single blocks, not entire pools 2021-07-16 22:09:18 +01:00
Luke Usher 934202c244 sh2: further optimize code gen for the cached interpreter 2021-07-16 22:08:58 +01:00
Luke Usher 99ef67b4a0 sh2: slight speed up 'call' generation 2021-07-16 22:00:25 +01:00
Luke Usher 1e4683fbac nall:: speed up recompiler codegen
agressive inlining allows for a slight performance increase when
emitting code.
2021-07-16 21:01:49 +01:00
Luke Usher 27d0826e30 sh2: use cached interpreter instead of recompiler
This improves compatibility as the full recompiler currently has some game
breaking issues, but is faster than using a pure interpreter solution
2021-07-16 20:53:20 +01:00
Luke Usher 5168ee4089 32x: implement 'RV' bit
The SH2 should stall when accessing rom while RV is set.
2021-07-15 18:17:54 +01:00
Luke Usher a9f2a301b4 32x: implement FM/framebufferAccess bit
When this bit is set to 0, any framebuffer or VDP access from the sh2 has to be ignored and when this bit is set to 1, any framebuffer or VDP access from the m68k should be ignored.

This fixes the rendering issues in Spiderman, likely others too.
2021-07-14 14:20:38 +01:00
Luke Usher 53dedb9a84 lucia: disable "fast boot" by default
The fastboot option is a nice to have, but it has potential to introduce serious bugs/glitches into emulation, as seen with Neo Geo Pocket, so it is safer to default this option to disabled.
2021-07-14 10:34:02 +01:00
invertego b73fb828c5 ngp: copy SNK logo from BIOS during fast boot
The game Metal Slug - 2nd Mission compares a region of character memory
to a copy of the SNK logo in the game rom. Normally this memory is
initialized for the boot animation played by the BIOS. If the logo isn't
an exact match, the game starts but you are unable to fire any weapons.

Conceptually, this is the reverse of what the Game Boy does on boot.
There, the boot rom validates a Nintendo logo on the cartridge.

Since we already have the BIOS loaded, we can copy the logo from there
during a fast boot, though some unpacking is required.
2021-07-14 09:30:09 +01:00
invertego 5f96077613 ngp: re-enable saving ram to disk on unload
This code was commented out in commit
4e82321182 which otherwise only affected
TLCS900/H timing. I believe this was left in by mistake. Uncommenting
this code restores the ability to persist BIOS settings across play
sessions.
2021-07-14 09:19:27 +01:00
Luke Usher a284722486 hiro: fix browser dialog filters on macOS 2021-07-12 16:18:49 +01:00
Luke Usher cb9f94ae34 nall: enable lto by default on non-debug builds 2021-07-12 10:28:48 +01:00
Luke Usher 10856348a3 nall: don't pass unsupported lto options to clang 2021-07-12 10:22:43 +01:00
Luke Usher 7b5026313e ci: include shaders + database in macOS builds 2021-07-12 10:22:16 +01:00
invertego 1cccbb67da Initialize Neo Geo Pocket port 1 to zero
In the game Dynamite Slugger, when your batter strikes out it loads a
16-bit word from 0x0000 and resets the game if anything but zero comes
back. The second byte, at address 0x0001, is mapped to internal port 1,
and currently almost all port values are initialized to 1 at power on.

In a 2019 nesdev post [1], Near stated that port emulation was incomplete
and likely incorrect. Without hardware tests, I'd rather not touch this
code more than necessary, but at the very least it seems more correct to
initialize the latched value in port 1 to zero.

There is a chance that the null dereference in Dynamite Slugger is
itself the result of an emulation bug, but all I have to compare against
is MAME, and the game behaves the same there. I believe this is decent
evidence that we are seeing a real game bug and that reading back zero
is what would have occurred on actual hardware.

[1] http://forums.nesdev.com/viewtopic.php?f=23&t=18579#p236069
"I added ports 1, 2, A, and B. Although ports 1 (d8-d15) and 2 (a16-a23)
are ... strange. They're likely emulated very wrong. I don't even
understand how one can change the direction of the data bus. I'm ...
suspecting that ports have their own latch values, but the manual isn't
very clear on this."
2021-07-11 19:17:20 +01:00
invertego 8b09014c67 Fixes for "Fast Boot" option for Neo Geo Pocket (Color)
Perform more initialization to match the side effects of booting from
the BIOS.

1) Initialize XIX register. Puyo Pop World relies on this (likely a game
   bug).
2) Initialize interrupt vector table. SNK Gals' Fighters and the Pocket
   Casino Series games rely on this.
3) Initialize interrupt request levels used by the VECT_INTLVSET system
   call. The Pocket Casino Series games rely on this.
2021-07-11 19:14:21 +01:00
Stefan Schmidt 19171c2723 hiro: Force Gtk3 to use X11 backend 2021-07-11 19:12:22 +01:00
Luke Usher e130f0297e 32x: reduce minimum recompiler block size
Fixes a hang in Virtua Racing Deluxe
2021-07-11 12:51:09 +01:00
Luke Usher 735f3ec902 32x: pwm dreq and timer are two different things
This fixes PWM audio playback in most titles.
2021-07-11 12:09:13 +01:00
Luke Usher 109ebc4683 32x: use min block size of 46 for sh2 rec 2021-07-10 20:34:59 +01:00
Luke Usher 3da4e20905 sh2: allow cores to set min recompiler block size 2021-07-10 20:34:42 +01:00
Luke Usher 963086edb5 mia: use database for msx 2021-07-10 00:39:11 +01:00
Luke Usher b0a0640089 ci: include shaders/database in Windows builds 2021-07-10 00:38:58 +01:00
Luke Usher 2e648ac845 restore genius, a .bml database editor 2021-07-09 17:55:41 +01:00
invertego 77110f15a3 tlcs900h: Fix immediate mask in BIT #,r
The BIT (imm, reg) instruction uses the low 4 bits of its immediate operand even
when the register operand is only 8 bits wide. When the register is 8 bits and
the immediate value is between 8 and 15, ZF will be always be set. ares was
erroneously using only the bottom 3 immediate bits in this case (so 15 would
behave the same as 7).

With this fix, sprites now render correctly in the Neo Geo Pocket game Pocket
Tennis.

This bug was discovered by comparing against an instruction trace from MAME.
This change is the functional equivalent of commit
57e42cda31430c75566403c5f27ec290dc123da3 in the MAME git repo.
2021-07-07 09:34:45 +01:00
Luke Usher 5c697600f7 ares: bump version to v121a 2021-07-06 11:14:47 +01:00
Tim Allen bf3b824a71 Fix building mia on Linux.
Although mia doesn't use threads itself, it includes `ares/ares.hpp` and ares
*does* use threads, so we need to build with `-pthread` in order to link
successfully.
2021-07-06 10:59:14 +01:00
Luke Usher cedfd160c4 readme: clarify nightly builds 2021-07-06 09:57:24 +01:00
Luke Usher 9ac22b34fa ci: disable Linux release publishing
We should still verify Linux builds are compiling, but Linux users should self-compile or use distro-specific packages.
2021-07-06 09:56:41 +01:00
Luke Usher fad4ef8908 docs: add README.md 2021-07-06 09:46:04 +01:00
Luke Usher cb4a79e8c1 ci: introduce ci + 'nightlies' 2021-07-06 01:54:06 +01:00
Luke Usher 8cca04113d hiro: fix table-view compilation on macOS 2021-07-06 01:20:53 +01:00
Luke Usher e4789472e3 sfc: default to 64KB VRAM when using ppu-performance 2021-07-06 01:16:42 +01:00
Luke Usher 11c818591b ares: fix the build with gcc 2021-07-06 01:16:17 +01:00
Luke Usher ea1eef8d22 add license (ISC) 2021-07-05 15:15:37 +01:00
Near 4428bb70e9 Update to ares v121 release.
I've released ares v121. Because it is not fully complete or stable, it is
released as source code only.

The license is now once again ISC instead of CC-BY-NC-ND.

Master System, WonderSwan, and WonderSwan Color compatibility have increased to
100%, with no remaining known bugs.

The Neo Geo Pocket is very close to 100% now with one issue remaining, where
sound effects sometimes mute in games.

Nintendo 64 compatibility has increased to above 80% thanks to corrections to
controller pak handling.

Several NES and Mega CD fixes have been added. EEPROM support has been added for
the Mega Drive.

Memory cards and paks now pre-format themselves, so you don't have to do so in-
game or in BIOS settings.

The new Neo Geo emulation is slowly improving, but it's still very preliminary
with only seven games fully playable so far.

The Nintendo 64 SM5K and PlayStation HC05 processor cores have been emulated,
but not connected yet due to a lack of information.

Added mouse input support and connected peripheral selection to the GUI, so mice
and light gun games can now be used.

There is now per-system input mapping overlays, so you can map controllers based
on the original system button names.

And lastly as promised, the SNES core has gained optional widescreen support.

Changelog (since v120):

  - Nintendo 64: added Windows ABI support to dynamic recompilers
  - PlayStation: added Windows ABI support to dynamic recompiler
  - Nintendo 64: temporarily disabled 64-bit addressing mode due to issues
  - Nintendo 64: corrected analog stick ranges and emulated octagonal
    boundaries
  - Nintendo 64: code cleanups around memory access functions
  - Nintendo 64: started to implement RDRAM broadcasting (very incomplete
    still)
  - Mega Drive: improved VDP scanline renderer timing
  - M68K: corrected clipping bug in ADD,CMP,SUB instructions
  - Nintendo 64: improved SI scanning of PIF RAM and emulated more flags
  - Nintendo 64: added very accurate controller pak initialization code
  - Nintendo 64: improved controller analog stick approximations [MerryMage]
  - Nintendo 64: added priority queue to delay SI and PI DMA transfers
  - Master System: added bit-perfect YM2413 instrument patch sets
  - Mega Drive: fixed a bug with LINEA and LINEF instructions (should not
    decrement PC)
  - Mega Drive: added EEPROM emulation
  - mia: added Mega Drive and Mega 32X EEPROM database entries
  - nall: added priority_queue::remove(T) support
  - Nintendo 64: reverted 64-bit TLB (not actually present)
  - Neo Geo: initial implementation
  - Neo Geo: many emulation improvements
  - nall: add workaround for compilers that lack __has_builtin
  - Nintendo 64: ignore A15 on controller pak reads and writes
  - Master System: implemented Codemasters, Korea, MSX, Janggun mappers
  - Master System: improved Sega mapper emulation
  - Master System: added initial emulation of port $3e
  - Master System: added support to load BIOSes
  - Master System: initialize stack pointer to 0xfffd when no BIOS loaded
    [Luke Usher]
  - Game Boy Advance: emulated BIOS swap register [MerryMage]
  - Mega Drive: cancel pending IRQs when they are disabled [Jonas Quinn]
  - Mega Drive: fixed handling of VDP field flag [Jonas Quinn]
  - Mega Drive: mask upper bit of VDP sprite Y value when in progressive
    display mode [Jonas Quinn]
  - X24C01, M24Cxx: improve emulation of EEPROM command sequences
  - Famicom: added database entries for Jajamaru Gekimaden and Mazase Top
    Pro PRG-RAM
  - M24Cx: rewrote emulation to be more complete; though still not working
    for Cxx/Cxxx sizes
  - Nintendo 64: try stopping SI polling on recv=0xfe
  - Mega Drive: improved EEPROM emulation
  - Nintendo 64: fixed CPU SCC counter rate [simer]
  - Nintendo 64: added initial emulation of the SM5K processor (not connected
    yet)
  - lucia: update frame rate from the main thread to prevent a race condition
    with GTK
  - Master System: emulated sprite zoom and fifth-sprite status flag
  - Master System: corrected VDP background emulation for mode 4 [fixes
    Codemasters games]
  - Master System: latch VDP background nametable address and scroll registers
    [fixes Desert Speedtrap]
  - Master System: mask CRAM reads to 6-bit in Master System mode [fixes Mercs]
  - Master System: refactored VDP code
  - Z80: swapped IND/INI to post-decrement B, and OUTD/OUTI to pre-decrement B
  - lucia: fixed a crash when loading Game Gear games due to stubbing out
    the BIOS
  - Nintendo 64: fixed cartridge flash memory support
  - Master System: VDP line coincidence should be initialized to $ff [fixes
    Shadow Dancer]
  - Master System: VDP sprite overflow index defaults to $1f, not $00 [fixes
    PGA Tour Golf]
  - SN76489: corrected port latching behavior and noise volume writes [fixes
    Micro Machines]
  - TMS9918: greatly refactored code
  - V9938: greatly refactored code
  - Z80: disassembler fixes
  - lucia: corrected mapping of Master System pause button [fixes Baku
    Baku Panic]
  - nall: disable -Wstringop-overflow for GCC due to compiler heuristics error
  - M68HC05: initial core implementation added
  - M68000: renamed core from M68K
  - Super Famicom: clearing $4200.d0 stops active joypad polling for the rest
    of the frame [Jonas Quinn]
  - Master System: don't evaluate sprites past active display area [fixes
    Rescue Mission]
  - Mega Drive: don't acknowledge VDP IRQs until the CPU triggers them [fixes
    Mega Lo Mania]
  - lucia: begin refactoring input mapping to allow per-system mappings and
    multiple controller types
  - Game Gear: set CPU::in() unmapped return value to MDR; fixes RoboCop 3
    [Jonas Quinn]
  - WonderSwan Color: do not mask screen tilemap base address; fixes Sorobang
    [FPGAzumSpass]
  - Mega Drive: set supervisor mode and clear trace mode for all exceptions;
    fixes Gouketsuji Ichizoku [Jonas Quinn]
  - Mega CD: format BRAM instead of leaving it uninitialized; fixes Popful Mail
    (US)
  - WonderSwan: add patch for Meitantei Conan: Nishi no Meitantei Saidai
    no Kiki!
  - Game Boy: add MBC1#M mapper database entries; fixes Bomber Man Collection,
    Genjin Collection, Momotarou Collection, and Mortal Kombat I & II
  - Neo Geo Pocket: $8118 background register exists even in the K1GE GPU;
    fixes Samurai Shodown
  - Neo Geo Pocket Color: return 0xFF acknowledge byte after flash erase
    command; fixes Puzzle Link 2 and Memories off: Pure
  - Neo Geo Pocket: clear watchdog timer counter on trigger to prevent
    infinite triggering; fixes Neo Baccarat, Neo Cherry Master Color, and
    Neo Mystery Bonus
  - TLCS900H: do not allow interrupts to run between CPDR, LDIR, LDDR
    instructions; fixes Fantastic Night Dreams Cotton
  - Neo Geo Pocket: add all remaining missing I/O registers (not emulated,
    but registers are readable and writable now)
  - Neo Geo Pocket Color: above changes also fixed in-game audio in Crush
    Roller and Dynamite Slugger
  - Mega CD: added 1M mode WRAM swap request flag; fxies AX-101, Earnest Evans,
    and Might & Magic III [TascoDLX]
  - lucia: added input mapping overlays for all remaining systems
  - lucia: added two-player support to all remaining systems
  - TLCS900H: refactored instruction decoder and disassembler using range-case
  - TLCS900H: improved emulation of (PC+d16) addressing mode (LDAR)
  - TMS9918, V9938, SMS VDP: corrected sprite zoom emulation [Jonas Quinn]
  - Neo Geo Pocket: added new debugging modules (flash ROM, I/O accesses,
    system calls)
  - Neo Geo Pocket: improved CPU interrupt logger (prints name of interrupt
    now)
  - Neo Geo Pocket: fixed a critical issue with interrupt priority levels;
    fixes many games
  - Neo Geo Pocket: added stubs for all remaining TMP95C061F I/O registers
    (not emulated yet)
  - Neo Geo Pocket: set CPU I/O port $b1.d2 reads to return 1 (fixes SNK
    Gals' Fighter)
  - Neo Geo Pocket: added stubs for undocumented CPU I/O ports $b6 and $b7
  - Super Famicom: PPU code restructuring
  - Super Famicom: added widescreen (16:9 and 21:9) support to the scanline
    renderer
  - WonderSwan: refactored I/O handlers to use switch/case instead of if tests
  - WonderSwan: rewrote PPU renderer to modularize each component (screen1,
    screen2, sprite, dac, etc)
  - WonderSwan: corrected timers to count down instead of up; fixes timing
    in many games [FPGAzumSpass]
  - WonderSwan: improved screen two window emulation [FPGAzumSpass]
  - hiro: TableView::onContext() is now TableView::onContext(TableViewCell)
    (not supported for Cocoa or Qt yet)
  - lucia: merged code to handle input assignment overlays and controller
    polling for each emulation core
  - lucia: added virtual mouse emulation and added mouse capture support
  - lucia: added support to change devices connected to controller ports
  - Neo Geo Pocket: added database workaround for underdumped Prize Game:
    PP-AA01 Pusher Program (Japan)
  - Neo Geo Pocket: fixed fast boot mode for Neo Cherry Pocket
  - nall/range: added new within() templates
  - V30MZ: emulated instruction prefetch
  - V30MZ: greatly improved instruction timings (thanks to FPGAzumSpass'
    test ROM)
  - WonderSwan: disabling an interrupt source does clear its pending status
    (fixes Digimon Tamers)
  - TLCS900H: improved prefetch handling and instruction timing (still
    imperfect)
  - TLCS900H: improved timing further (still imperfect)
2021-06-26 23:49:00 +00:00
Near 4e82321182 Update to ares v120r18 release.
Just slight 'improvements' to TLCS900/H timing.
2021-06-23 14:58:00 +00:00
Near b2fc626854 Update to ares v120r17 release.
- WonderSwan: disabling an interrupt source does clear its pending status
    (fixes Digimon Tamers)
  - TLCS900H: improved prefetch handling and instruction timing (still
    imperfect)
2021-06-20 21:35:00 +00:00
Near 189147fc31 Update to ares v120r16 release.
This gets a 100% pass on FPGAzumSpass' WonderSwan instruction timing tests, and
emulates CPU prefetch as well, but it seems to make games less stable rather
than more =(
2021-06-16 08:01:00 +00:00
Near 532aafe074 Update to ares v120r15 release.
- TLCS900H: refactored instruction decoder and disassembler using range-case
  - TLCS900H: improved emulation of (PC+d16) addressing mode (LDAR)
  - TMS9918, V9938, SMS VDP: corrected sprite zoom emulation [Jonas Quinn]
  - Neo Geo Pocket: added new debugging modules (flash ROM, I/O accesses,
    system calls)
  - Neo Geo Pocket: improved CPU interrupt logger (prints name of interrupt
    now)
  - Neo Geo Pocket: fixed a critical issue with interrupt priority levels;
    fixes many games
  - Neo Geo Pocket: added stubs for all remaining TMP95C061F I/O registers
    (not emulated yet)
  - Neo Geo Pocket: set CPU I/O port $b1.d2 reads to return 1 (fixes SNK
    Gals' Fighter)
  - Neo Geo Pocket: added stubs for undocumented CPU I/O ports $b6 and $b7
  - Super Famicom: PPU code restructuring
  - Super Famicom: added widescreen (16:9 and 21:9) support to the scanline
    renderer
  - WonderSwan: refactored I/O handlers to use switch/case instead of if tests
  - WonderSwan: rewrote PPU renderer to modularize each component (screen1,
    screen2, sprite, dac, etc)
  - WonderSwan: corrected timers to count down instead of up; fixes timing
    in many games [FPGAzumSpass]
  - WonderSwan: improved screen two window emulation [FPGAzumSpass]
  - hiro: TableView::onContext() is now TableView::onContext(TableViewCell)
    (not supported for Cocoa or Qt yet)
  - lucia: merged code to handle input assignment overlays and controller
    polling for each emulation core
  - lucia: added virtual mouse emulation and added mouse capture support
  - lucia: added support to change devices connected to controller ports
  - Neo Geo Pocket: added database workaround for underdumped Prize Game:
    PP-AA01 Pusher Program (Japan)
  - Neo Geo Pocket: fixed fast boot mode for Neo Cherry Pocket
  - nall/range: added new within() templates
2021-06-14 08:07:00 +00:00
Near eefd470752 Update to ares v120r14 release.
- Game Gear: set CPU::in() unmapped return value to MDR; fixes RoboCop 3
    [Jonas Quinn]
  - WonderSwan Color: do not mask screen tilemap base address; fixes Sorobang
    [FPGAzumSpass]
  - Mega Drive: set supervisor mode and clear trace mode for all exceptions;
    fixes Gouketsuji Ichizoku [Jonas Quinn]
  - Mega CD: format BRAM instead of leaving it uninitialized; fixes Popful Mail
    (US)
  - WonderSwan: add patch for Meitantei Conan: Nishi no Meitantei Saidai
    no Kiki!
  - Game Boy: add MBC1#M mapper database entries; fixes Bomber Man Collection,
    Genjin Collection, Momotarou Collection, and Mortal Kombat I & II
  - Neo Geo Pocket: $8118 background register exists even in the K1GE GPU;
    fixes Samurai Shodown
  - Neo Geo Pocket Color: return 0xFF acknowledge byte after flash erase
    command; fixes Puzzle Link 2 and Memories off: Pure
  - Neo Geo Pocket: clear watchdog timer counter on trigger to prevent
    infinite triggering; fixes Neo Baccarat, Neo Cherry Master Color, and
    Neo Mystery Bonus
  - TLCS900H: do not allow interrupts to run between CPDR, LDIR, LDDR
    instructions; fixes Fantastic Night Dreams Cotton
  - Neo Geo Pocket: add all remaining missing I/O registers (not emulated,
    but registers are readable and writable now)
  - Neo Geo Pocket Color: above changes also fixed in-game audio in Crush
    Roller and Dynamite Slugger
  - Mega CD: added 1M mode WRAM swap request flag; fxies AX-101, Earnest Evans,
    and Might & Magic III [TascoDLX]
  - Nintendo 64: added ISViewer support
  - lucia: added input mapping overlays for all remaining systems
  - lucia: added two-player support to all remaining systems
2021-06-07 09:45:00 +00:00
Near 9d6d3612a7 Update to ares v120r13 release.
- Game Gear: fix inputs
  - Master System: don't evaluate sprites past active display area [fixes
    Rescue Mission]
  - Mega Drive: don't acknowledge VDP IRQs until the CPU triggers them [fixes
    Mega Lo Mania]
  - lucia: begin refactoring input mapping to allow per-system mappings and
    multiple controller types
2021-06-04 09:21:00 +00:00
Near e867dbd380 Update to ares v120r12 release.
- M68HC05: initial core implementation added
  - M68000: renamed core from M68K
  - Super Famicom: clearing $4200.d0 stops active joypad polling for the rest
    of the frame [Jonas Quinn]
2021-06-03 03:21:00 +00:00
Near cf25b04854 Update to ares v120r11 release.
- Nintendo 64: fixed cartridge flash memory support
  - Master System: VDP line coincidence should be initialized to $ff [fixes
    Shadow Dancer]
  - Master System: VDP sprite overflow index defaults to $1f, not $00 [fixes
    PGA Tour Golf]
  - SN76489: corrected port latching behavior and noise volume writes [fixes
    Micro Machines]
  - TMS9918: greatly refactored code
  - V9938: greatly refactored code
  - Z80: disassembler fixes
  - lucia: corrected mapping of Master System pause button [fixes Baku
    Baku Panic]
  - nall: disable -Wstringop-overflow for GCC due to compiler heuristics error
2021-06-01 00:24:00 +00:00
Near 02028d8fe2 Update to ares v120r10 release.
- Master System: emulated sprite zoom and fifth-sprite status flag
  - Master System: corrected VDP background emulation for mode 4 [fixes
    Codemasters games]
  - Master System: latch VDP background nametable address and scroll registers
    [fixes Desert Speedtrap]
  - Master System: mask CRAM reads to 6-bit in Master System mode [fixes Mercs]
  - Master System: refactored VDP code
  - Z80: swapped IND/INI to post-decrement B, and OUTD/OUTI to pre-decrement B
  - lucia: fixed a crash when loading Game Gear games due to stubbing out
    the BIOS
2021-05-31 05:15:00 +00:00
Near 47c2fca103 Update to ares v120r09 release.
- Mega Drive: improved EEPROM emulation
  - Nintendo 64: fixed CPU SCC counter rate [simer]
  - Nintendo 64: added initial emulation of the SM5K processor (not connected
    yet)
  - lucia: update frame rate from the main thread to prevent a race condition
    with GTK
2021-05-29 23:42:00 +00:00
Near b8dfb68f6b Update to ares v120r08 release.
- Famicom: added database entries for Jajamaru Gekimaden and Mazase Top
    Pro PRG-RAM
  - M24Cx: rewrote emulation to be more complete; though still not working
    for Cxx/Cxxx sizes
  - Nintendo 64: try stopping SI polling on recv=0xfe
2021-05-27 00:12:00 +00:00
Near 960d8a8dcb Update to ares v120r07 release.
- Nintendo 64: ignore A15 on controller pak reads and writes
  - Master System: implemented Codemasters, Korea, MSX, Janggun mappers
  - Master System: improved Sega mapper emulation
  - Master System: added initial emulation of port $3e
  - Master System: added support to load BIOSes
  - Master System: initialize stack pointer to 0xfffd when no BIOS loaded
    [Luke Usher]
  - Game Boy Advance: emulated BIOS swap register [MerryMage]
  - Mega Drive: cancel pending IRQs when they are disabled [Jonas Quinn]
  - Mega Drive: fixed handling of VDP field flag [Jonas Quinn]
  - Mega Drive: mask upper bit of VDP sprite Y value when in progressive
    display mode [Jonas Quinn]
  - X24C01, M24Cxx: improve emulation of EEPROM command sequences
2021-05-24 16:24:00 +00:00
Near ca273d320e Update to ares v120r06 release.
Metal Slug should be fully playable in AES mode now, but still no sound.
2021-05-21 16:58:00 +00:00
Near 54159cf95e Update to ares v120r05 release.
- Nintendo 64: reverted 64-bit TLB (not actually present)
  - Neo Geo: initial implementation
2021-05-19 01:23:00 +00:00
Near 3cebf21a5e Update to ares 20210516a release.
This one is an experiment to ignore A15 on memory pak reads+writes. If possible,
I'd like to know if any games with controller pak issues start working with this
change that didn't before ^-^;
2021-05-16 17:05:00 +00:00
Near 28a57b9347 Update to ares v120r04 release.
- Mega Drive: fixed a bug with LINEA and LINEF instructions (should not
    decrement PC)
  - Mega Drive: added EEPROM emulation
  - mia: added Mega Drive and Mega 32X EEPROM database entries
  - nall: added priority_queue::remove(T) support
2021-05-16 16:49:00 +00:00
Near 64857906b3 Update to ares 20210516 release.
Fixes *Super Bubble Bobble (Taiwan) (En) (Unl)* for the Mega Drive3
2021-05-16 06:02:00 +00:00
Near c5583ade47 Update to ares 20210513 release.
This doesn't justify a new WIP release yet, but it changes the PI DMA delay
timing which seems to make Aidyn Chronicles work again, so let's see how it
does.
2021-05-13 09:09:00 +00:00
Near 8c7bad148c Update to ares v120r03 release.
- Nintendo 64: improved SI scanning of PIF RAM and emulated more flags
  - Nintendo 64: added very accurate controller pak initialization code
  - Nintendo 64: improved controller analog stick approximations [MerryMage]
  - Nintendo 64: added priority queue to delay SI and PI DMA transfers
  - Master System: added bit-perfect YM2413 instrument patch sets
2021-05-12 10:37:00 +00:00
Near a290c96899 Update to ares v120r02 release.
This fixes a major issue with the 68K ADD,CMP,SUB instructions not clipping, and
improves the VDP scanline renderer timing somewhat.

This fixes Alien Solder, and I also moved the DMA run below the FIFO/prefetch to
fix Comix Zone's graphics. It regresses several Titan Overdrive 2 screens, but
oh well.

I'm trying to track down a bug in Popful Mail (US) where the CPU crashes right
after the title screen. It seems like the CPU is getting stuck in a loop that
keeps calling the same function, so the stack keeps decrementing until it ends
up overwriting the currently executing code with a bad instruction.

Without an I/O tracer it's really difficult to try and understand what the CPU
is stuck waiting on and looping on. I'll have to add an I/O tracer to the Mega
CD registers.

The CPU fixes sadly didn't improve anything in the 32X space. Metal Head gets in
a loop until it overwrites the stack frame return address with 0x1fff1fff that
causes a return to an unaligned address that crashes the SH2 master.

After Burner Complete doesn't boot at all. Amazing Spider-Man still has screwed
up graphics priority ordering for the 32X VDP.

Space Harrier still shows a bunch of junk lines at the top and bottom of the
screen.

The scanline VDP can now run Lemmings 1&2, Alien Soldier, etc. But it still does
horrifically bad with Titan Overdrive, especially 2.
2021-05-10 13:31:00 +00:00
Near 034468c384 Update to ares v120r01 release.
I started to implement N64 RDRAM broadcasting with this WIP, but it's only about
1% complete.
2021-05-07 05:33:00 +00:00
Near 340f48d029 Update to ares v120 release.
This release provides improved Nintendo 64 and Mega Drive emulation, plus some
emulation speedups and new features like keyboard-mapping for all Nintendo 64
controls.

The infamous Titan Overdrive demos now run with the exception of one glitched
screen each, but you will need to compile with profile=accuracy to enable the
required cycle-based VDP renderer for this to work. I'll try in the future to
support as much of it as I can with the default scanline renderer as well.

Changelog (since v119):

  - SH2: added support for Windows ABI to the recompiler
  - SH2: MAC must increment R[n] before reading from R[m]; fixes Virtua
    Fighter and Toughman Contest
  - SH2: fixed dynarec MOV @Rm+,Rn to not increment when Rm==Rn
  - SH2: fixed dynarec TST instruction
  - SH2: improved dynarec accuracy by breaking blocks on delay slot branches
  - SH2: improved dynarec accuracy by decreasing the underclocking amount
  - Mega Drive: implemented undocumented VSRAM and CRAM DMA fill
  - Mega Drive: simplified scanline VDP renderer; fixes TMNT: Tournament
    Fighters graphics
  - Mega Drive: improved region detection; correctly identifies Alien Soldier
    region now
  - Mega CD: fixed crash on game load
  - Super Famicom: fixed direct color mode; fixes Secret of Mana world map
  - WonderSwan Color: fixed initial state for new EEPROMs plus EEPROM size;
    fixes missing sound
  - lucia: fixed saving RAM files when a manual save path was specified
  - ruby: fixed library dependency detection for Arch Linux and other
    distributions
  - SH2: additional correction for dynarec MOV @Rm+,Rn instructions
  - hiro/GTK3: added CSS stylesheet overrides to improve appearance [Screwtape]
  - N64: VMRG was not clearing VCO in C++ version [Rasky]
  - N64: fixed "ctc2" in the disassembler
  - Mega Drive: VDP address/command bits are set even for non-register writes
    [Eke]
  - Mega Drive: implemented VDP FIFO with approximated timings
  - Mega Drive: implemented CPU bus arbitrator
  - N64: fixed RSP vector unit register values in the disassembler
  - Mega Drive: implemented proper VDP FIFO timings for both reads and writes
    (hopefully)
  - Mega Drive: enabled external and RAM refresh timing
  - Mega Drive: added (Mega Drive | Mega 32X) + Mega CD mode 1 emulation
  - Mega Drive: refactored dot-based VDP renderer
  - ares: added Thread::restart() function to reset a thread without resetting
    its clock
  - Mega Drive: improved DRAM refresh timings
  - Mega Drive: added VDP I/O logger
  - Mega Drive: fixed VDP counter emulation (still inaccurate)
  - Mega Drive: improved VDP DMA and FIFO emulation
  - Nintendo 64: report 64DD as missing for now; fixes F-Zero X
  - Nintendo 64: improved TLB emulation; fixes Conker's Bad Fur Day
  - Nintendo 64: PI DMA from flash always reads data, never the status;
    fixes Paper Mario
  - Mega Drive: improved VDP FIFO emulation
  - Mega Drive: improved VDP dot-renderer
  - nall/bit-range: fixed bug with bit indexes >= 32
  - Mega Drive: fixed VDP read buffer indexing for VSRAM and CRAM
  - Mega Drive: fixed 68K to VDP DMA so that it instantly freezes the CPU
  - Mega Drive: emulated VDP left window hardware glitch where hscroll&15!=0
  - Mega Drive: improved CPU interrupt handling
  - Mega Drive: added APU bus mirrorings
  - Mega Drive: emulated the VDP debug register
  - Mega Drive: fixed VDP VRAM DMA copy
  - Mega Drive: improved 128KB VRAM mode support
  - Mega Drive: mask sprite attribute table address in H40 mode [Sik]
  - Mega Drive: VDP timing improvements
  - Nintendo 64: improved EEPROM support; fixes Perfect Dark
  - Nintendo 64: improved VI interrupt support; fixes Star Wars: Rogue Squadron
    title screen [nodev]
  - Nintendo 64: emulated CIC-NUS-6105 copy protection; fixes Banjo-Tooie
    [XScale]
  - Nintendo 64: added serrate (interlace) support and fixed bug when
    supersampling in serrate mode
  - Nintendo 64: emulated CPU instruction cache
  - Nintendo 64: emulated CPU data cache
  - Nintendo 64: emulated CPU CACHE instruction
  - Nintendo 64: fixed CPU TLB bug; fixes GoldenEye
  - Nintendo 64: began adapting CPU cached interpreter into a dynamic
    recompiler
  - Nintendo 64: began adapting RSP cached interpreter into a dynamic
    recompiler
  - Nintendo 64: added 64-bit addressing and TLB supporting
  - Nintendo 64: added endian support to [LS][WD][LR] instructions
  - Nintendo 64: improved dynamic recompiler
  - PlayStation: began adapting CPU cached interpreter into a dynamic
    recompiler
  - lucia: allow mapping analog axes separately (allows mapping sticks to
    the keyboard)
  - Nintendo 64: corrected analog stick ranges
  - Nintendo 64: emulate the analog stick as an octagon rather than a circle
    [YetAnotherEmuDev]

[This is actually the second release of v120; the change since the first release
is the N64 analog stick ranges and the octagon gate. -Ed.]
2021-05-06 02:14:00 +00:00
Near 1b574d0bb5 Update to ares v119r16 release.
- Mega Drive: VDP scanline renderer compiles once more
  - Nintendo 64: improved dynamic recompiler
  - PlayStation: began adapting CPU cached interpreter into a dynamic
    recompiler
  - lucia: allow mapping analog axes separately (allows mapping sticks to
    the keyboard)

All that's left now is fixing the call() function in the N64/PS1 to support >3
(4) arguments on Windows and we can release v120
2021-05-05 03:10:00 +00:00
Near 25771ba202 Update to ares v119r15 release.
- Nintendo 64: began adapting CPU cached interpreter into a dynamic
    recompiler
  - Nintendo 64: began adapting RSP cached interpreter into a dynamic
    recompiler
  - Nintendo 64: added 64-bit addressing and TLB supporting
  - Nintendo 64: added endian support to [LS][WD][LR] instructions

I could really use a hand with my CPU dynarec, n64/cpu/recompiler.cpp line 1335.

When calling an FPU instruction without SCC coprocessor 1 enabled, it throws an
exception.

If I call the exception function, the emulator crashes hard and I don't
understand why at all.

The stack is aligned, but it seems if I modify rbx/rbp/r13 as I do with the
RSP+SH2 just fine, it seems to die. Yet even if I make that code restore
rbx/rbp/r13 before calling the coprocessor exception function, it still dies.
Really at a loss >_>

Also, this will only work on Linux/BSD at the moment. The RSP vector functions
pass four parameters, and my Windows call wrapper can only handle 3 arguments
because after that the argument has to go on the stack. I'll fix that later.
2021-05-04 08:31:00 +00:00
Near 02180bad08 Update to ares v119r14 release.
Working Nintendo 64 data cache emulation (still don't know the memory access
timings for it) and improved Mega Drive VDP emulation (still can't run TO1&2)
2021-04-30 07:34:00 +00:00
Near 8b7daf3c26 Update to ares v119r13 release.
GoldenEye 007 and Jet Force Gemini run now. Right now, known N64 bugs are:
Donkey Kong 64 hangs when the EEPROM support is enabled, Indiana Jones doesn't
boot (probably anti-emulator code?), Blast Corps blinks a lot (though less than
it did before.)

This WIP has CPU instruction and data cache emulation, though I had to disable
the data cache as it's not working yet.
2021-04-28 04:17:00 +00:00
Near 32ce9a54db Update to ares v119r12 release.
Three N64 game fixes. Refactored Mega Drive profile=accuracy vdp more, still
can't pass Titan Overdrive 1 or 2 ._. Really getting demotivated on that one.
2021-04-25 22:48:00 +00:00
Near f80efd1c05 Update to ares 20210422 release.
This has really really really improved timings.
2021-04-22 04:52:00 +00:00
Near 88714763ca Update to ares v119r10 release.
[Previously, Near said "Now to fix sprite fetching on Y=-1"]

Should be substantially better now.

Titan Overdrive 2 shows distorted graphics on the "Overdrive 2" logo screen
(after the ship crash and maze run), and the only way to get that working is to
double the VDP FIFO speed. It already runs twice as fast in 128K VRAM mode. The
same FIFO speed doubling is required to not crash after the Titancade screen.

Unless I'm really fundamentally misunderstanding something, I'm not sure what's
going on here.
2021-04-20 07:10:00 +00:00
Near 1b67ca2b79 Update to ares v119r09 release.
This gets us a lot further with the Mega Drive, but still some major issues.
Lemmings 2 will sometimes crash when you load it (not threading related), and
Titan Overdrive 2 crashes after the arcade scene. Ran out of steam to work on
this more today though, 12 hours in already.
2021-04-18 06:10:00 +00:00
Near a657ddf23d Update to ares 20210418a release.
This has VDP debug register emulation, well one of the 16 debug registers anyway

I fixed sound in TO2, was mirroring like crazy in the APU space, also fixed
sprites not rendering all the way in the rain scene.

So what you'll see I'm doing is setting an irq.(vh)blank.pending=1 flag, and
then whenever you have hvirq enabled AND a pending flag, it sends an IRQ to the
CPU and clears the pending flag, and when the CPU triggers it, the CPU marks it
as acknowledged.

Apparently BlastEm links bit 7 of the control status register to the
vblank.pending flag, so I'm copying that.

[Near then posted a screenshot of Titan Overdrive 2 running inside ares. In
white text on a blue background, it says:

    0D2 B50D

    D0 00000001
    D1 00FF2700
    D2 93979301
    D3 40000002
    D4 0D12001C
    D5 00000000
    D6 00000001
    D7 0000FFFF
    A0 00C00004
    A1 00C00000
    A2 00000CBC
    A3 00000DEC
    A4 00FF1464
    A5 00FF0C1A
    A6 00FF0C1A
    A7 00FFFFFE

-Ed.]

Crashes here if I don't lower the CPU H/VIRQ lines on Vblank/Hblank=0

Also I am faking the Vcounter incrementing early when reading the Vcounter,
easier that way.
2021-04-18 01:59:00 +00:00
Near a986fafb69 Update to ares 20210418 release.
Here's a snapshot, gets Titan Overdrive 2 music playing.
2021-04-17 22:02:00 +00:00
Near f45ccd4b7d Update to ares v119r08 release.
Really substantial Mega Drive profile=accuracy timing improvements, but still
Titan Overdrive 2 performs much worse than the default performance profile, and
that fucking audio driver still won't play any sound.
2021-04-15 19:58:00 +00:00
Near 1b6b4f1ae2 Update to ares v119r06 release.
- Nintendo 64: report 64DD as missing for now; fixes F-Zero X
  - Nintendo 64: improved TLB emulation; fixes Conker's Bad Fur Day
  - Mega Drive: improved VDP FIFO emulation
2021-04-10 23:07:00 +00:00
Near bd8a1b5155 Update to ares v119r05 release.
- ares: added Thread::restart() function to reset a thread without resetting
    its clock
  - Mega Drive: improved DRAM refresh timings
  - Mega Drive: added VDP I/O logger
  - Mega Drive: fixed VDP counter emulation (still inaccurate)
  - Mega Drive: improved VDP DMA and FIFO emulation
2021-04-08 21:28:00 +00:00
Near 21d3983b4d Update to ares v119r04 release.
- N64: fixed RSP vector unit register values in the disassembler
  - Mega Drive: implemented proper VDP FIFO timings for both reads and writes
    (hopefully)
  - Mega Drive: enabled external and RAM refresh timing
  - Mega Drive: added (Mega Drive | Mega 32X) + Mega CD mode 1 emulation
  - Mega Drive: refactored dot-based VDP renderer
2021-04-06 16:38:00 +00:00
Near c9d2f41bdb Update to ares v119r03 release.
A working VDP FIFO implementation (write slots only), but probably wildly
inaccurate. Rough timing approximations for the slots.

This build fixes some issues in MD Sonic the Hedgehog (forgot to undo the
background color register bit twiddling when reverting some overly aggressive
VDP-performance optimizations) and also fixes MD Golden Axe II.

I spent a few hours trying to fix Lemmings 2 from locking up immediately. What
happens is I get a fourth Hblank IRQ before it clears a RAM value, whereas
Mednafen only gets three. And that desyncs something and it never gets out of a
loop.
2021-04-04 08:31:00 +00:00
Near 787417cf2b Update to ares v119r2 release.
Unfortunately a few critical issues crept in between v118 and v119, so here is a
bugfix release for all reported issues.

It also fixes some game bugs while I'm at it, and boosts 32X compatibility from
50% to a little over 60%.

Please do upgrade if you have v119, this one's important.

  - SH2: MAC must increment R[n] before reading from R[m]; fixes Virtua
    Fighter and Toughman Contest
  - SH2: fixed dynarec MOV @Rm+,Rn to not increment when Rm==Rn
  - SH2: fixed dynarec TST instruction
  - SH2: improved dynarec accuracy by breaking blocks on delay slot branches
  - SH2: improved dynarec accuracy by decreasing the underclocking amount
  - Mega Drive: implemented undocumented VSRAM and CRAM DMA fill
  - Mega Drive: simplified scanline VDP renderer; fixes TMNT: Tournament
    Fighters graphics
  - Mega Drive: improved region detection; correctly identifies Alien Soldier
    region now
  - Mega CD: fixed crash on game load
  - Super Famicom: fixed direct color mode; fixes Secret of Mana world map
  - WonderSwan Color: fixed initial state for new EEPROMs plus EEPROM size;
    fixes missing sound
  - lucia: fixed saving RAM files when a manual save path was specified
  - ruby: fixed library dependency detection for Arch Linux and other
    distributions
  - hiro/GTK3: added CSS stylesheet overrides to improve appearance [Screwtape]
2021-04-02 07:23:00 +00:00
Near b3aeb41ee5 Update to ares v119 release.
I'm releasing ares v119 today, which includes very preliminary Sega 32X
emulation support. Compatibility is currently at around 50% with the dynamic
recompiler, probably closer to 75% with the cached interpreter, and since the
system requirements were a bit too steep (on account of my Mega Drive core being
cycle/dot-accurate), I downclocked the SH2s a bit until I can speed up the
emulator more. You'll currently need about a Ryzen 5 2600 to hit 60fps reliably.
With the underclock, my Ryzen 7 5800X hits 120fps, and without it, 85fps.

Although the compatibility for the new 32X core is a bit low, this is mostly due
to pesky CPU bugs. The accuracy is quite high and I've emulated as much of the
32X and SH7604 peripheral functions as possible. I pass all 161 tests from the
Mars Check Program. It should not take much more work to reach 98% compatibility
in the future. Sega CD 32X emulation support is present, but is likely not
functional, as I haven't tested it yet.

Other major features in this release include Sega SVP support for Virtua Racing,
plus improved Nintendo 64, Mega Drive, and Mega CD emulation compatibility.

I'm going to start working on Sega Saturn emulation now, while Luke Usher works
on Neo Geo emulation. No promises as to when or if these cores will become
playable, I'm just giving you all a heads up since you'll see the skeletons for
these systems in the source code now.

Changelog:

  - Nintendo 64: improved Expansion Pak detection
  - Nintendo 64: fixed swapped L and R buttons [simer]
  - Nintendo 64: emulated the RST bit for gamepads
  - ruby: added library detection support for the Linux and BSD targets
  - lucia: gained support for game paks (custom file dialog only)
  - Super Famicom: added support for Super Game Boy, Sufami Turbo, and BS
    Memory packs
  - hiro: made SourceEdit optional for gtk2 and gtk3 targets (disabled
    for ares)
  - Nintendo 64: emulated 2048-byte EEPROM identifier and transfer protocol
  - Super Famicom: corrected ppu-performance widths table indexing to consider
    overscan
  - Mega CD: fixed a bug in register $ff8003; allows Popful Mail to boot
    [TascoDLX]
  - Mega Drive: fixed a bug with 256-width video modes
  - Mega Drive: improved VDP DMA emulation which should fix many games
  - Mega Drive: added SVP emulation
  - Mega Drive: added 32X emulation
  - Mega CD: fixed a bit-masking bug in register $ff8004; fixes Radical Rex
    [TascoDLX]
  - Nintendo 64: fixed C implementation of RSP VMACU instruction
  - Nintendo 64: use correct NTSC and PAL PIF ROM images based on the region
  - Mega Drive: fixed reset logic, Z80 interrupt timing + prefix timing +
    bus control [TascoDLX]
  - Mega CD: fixed word RAM access and CDC DMA word RAM transfers [TascoDLX]
  - Nintendo 64: improved RSP VMOV emulation [Rasky]
  - Nintendo 64: fixed RSP DMEM DMA alignment (&~7, not &~3) [Rasky]
  - Nintendo 64: upgraded to the latest version of ParaLLEl-RDP
  - nall: greatly expanded recompiler/amd64's supported intrinsics
  - mia: substantial refactoring around a new virtual filesystem implementation
    from nall
2021-03-31 04:38:00 +00:00
Near d0258c76e6 Update to ares v118r16 release.
My latest ares WIP hooked up 128KB VRAM mode to my fast SNES PPU.
2021-03-27 20:22:00 +00:00
Near fd4eb76bf5 Update to ares v118r15 release.
[This release was posted to the ares Discord after r16. That version introduced
128KB VRAM mode for the Super Famicom core, and somebody requested the previous
version so they could see the changes involved in implementing that feature.
-Ed.]
2021-03-25 05:31:00 +00:00
Near 8c1d9840c0 Update to ares v118r13 release.
Latest version with VMOV and RSP DMEM mask fix
2021-03-24 00:21:00 +00:00
Near fae7a763fa Update to ares v118r12 release.
With TascoDLX's Mega CD fix ❤️❤️
2021-03-22 09:36:00 +00:00
Near d6dfd20dd6 Update to ares v118r11 release.
That's as far as I can go with 32X support for now. I fully emulated the Sh2
cache but I still hang at Mars test 123. The Hblank (2) test fails because it
looks like I'm running a bit too fast. The DMA test fails because it expects
DREQ to become inactive when the DREQ length hits zero. If I do that, the test
hangs. If I don't do that, the test fails.

Virtua Fighter shows no graphics in-game, Virtua Racing shows no graphics
period.
2021-03-22 09:03:00 +00:00
Near 493a446168 Update to ares v118r09 release.
Knuckles Chaotix is now fully playable at glorious 20fps, heh.

Still a whole ton of issues but I really went to town with this WIP. I
implemented read/write functionality for all the SH7804 internal
registers/functional units, and added basic simulation of the free-range timer,
DMA controller (very basic) and interrupt controller.

On the 32X side, it should be functionally complete save for bugs now. VDP and
PWM are fully implemented.
2021-03-18 07:07:00 +00:00
Near 1ca28694f9 Update to ares 20210317 release.
I am getting my ass kicked by SH-2 delay slots >_>

The basic idea of them is simple, but the PR register and when to do the +4 or
+2 or not is not intuitive.
2021-03-17 09:23:00 +00:00
Near 382634e311 Update to ares v118r08 release.
Still too many bugs to run anything. Hopefully next time ...

Chaotix 68K writes to FIFO, then SH2s never read it or query FIFO status.
2021-03-15 06:33:00 +00:00
Near e6f5e75854 Update to ares v118r07 release.
SH-2 core finished, started connecting the 32X to it. It executes some
instructions and does some I/O register stuff before hanging. Still gotta
implement the 32X interrupts, PWM, and VDP stuff.
2021-03-14 03:57:00 +00:00
Near a17f29d4c4 Update to ares v118r05 release.
Here's the current build with working SVP support. Build with profile=accuracy
if you try it because my fast scanline renderer breaks soooo many games
including Virtua Racing ._.
2021-03-10 07:31:00 +00:00
Near a38a31e47a Update to ares v118r04 release.
This WIP has the new mia system. It's a pretty massive change ... I hope it will
go okay for you. Feel free to ping me and I'll walk you through it.

Essentially, we want to edit mia/system/neo-geo-(aes|mvs).cpp to load in the
necessary files from MAME's neogeo.zip that is given to it (I have a helper
Pak::read(zipfile, pattern) function to grab files out of the archive for you
into a vector<u8>), do endian conversion, add to the pak, then the Neo Geo core
can see it.

The Neo Geo cartridge support should be enough for Magician Lord and super early
games with no mappers or crypto, so we'll start there and work our way up.
2021-03-07 19:05:00 +00:00
Near 007b27704d Update to ares 20210303 release.
My tracer was crashing in v118 for the Mega CD due to the trace address not
being masked and the value underflowing, so here's a pre-v118.4 WIP with that
fixed.
2021-03-03 04:44:00 +00:00
Near c5759c503f Update to ares v118r02 release.
So, spoiler since you'll all see it: Luke and I are gonna be working on a
Neo*Geo core. Please keep that a secret for now until we can get some
screenshots to share with people.

Would appreciate feedack on the vfs redesign, still a work in progress. Right
now, the potential is there to have ares cores that don't use manifests at all.
So far, only the ColecoVision core actually does it. However, all cores are
ported to use the new Platform::pak() function instead of Platform::open() [now
removed.]

Lots of stuff is broken right now: N64/PS1 memory cards, PC Engine CD / Mega CD
internal save memory, Mega CD can't play any games, FDS and NGP don't save, etc.
2021-03-01 19:28:00 +00:00
Near c72292ef4b Update to ares v118r01 release.
[No official changelog available for this version. -Ed.]
2021-02-26 19:33:00 +00:00
Near 44bdc531bb Update to ares v118 release.
I'm excited to launch ares v118 today, the first release featuring playable,
full-speed Nintendo 64 emulation!

The new Nintendo 64 emulation is made possible thanks to [Themaister] very
graciously porting his Vulkan-based ParaLLEl-RDP graphics renderer to ares. With
its default settings, it is nearly pixel-perfect to real hardware, and it
optionally supports upscaling to 2x or 4x the original Nintendo 64 resolution,
plus optional supersampling back down to the original resolution (for enhanced
anti-aliasing) if desired. The Vulkan support requires an appropriate graphics
card, and either Windows or Linux. At this time, Vulkan is not available for
macOS nor the BSDs.

Also new for the Nintendo 64 core in this release is Rumble Pak, Cartridge Pak,
SRAM, EEPROM, and Flash save support. Note that for right now, the Rumble Pak
will only be enabled for games which use internal saves (SRAM, EEPROM, and
Flash.) That does not cover all Rumble Pak-capable games. The option to choose
between Rumble Paks and Cartridge Paks will be added to a future release.

For the PlayStation core, [Luke Usher] provided two rendering fixes that allow
Final Fantasy VII and Tony Hawk's Pro Skater to be fully playable!

Right now, approximately 33% of the Nintendo 64 library is fully playable, and
about 67% of the PlayStation library is fully playable. Each core has only been
under active development for about one month each, so they both have a long way
to go. Please treat these early releases as tech samples, rather than finished
emulation cores.

Further, note that the Nintendo 64 and PlayStation cores employ cached
interpreters. This is a middle-ground between the accuracy of interpreters and
the performance of dynamic recompilers. As such, ares' system requirements will
be a bit higher than traditional emulators for these systems. Presuming no
background task interference or CPU throttling, generally speaking, a Ryzen 5
2600 or better CPU should get you to around ~120fps in the average case, and
~60fps in the worst case.

The source code has also been released under the terms of the Creative Commons
BY-NC-ND 4.0 license.

[Themaister]: http://github.com/Themaister/
[Luke Usher]: https://twitter.com/LukeUsher1
2021-02-20 23:51:00 +00:00
Near 43af5c298b Update to ares v117r03 release.
[No official changelog available for this version. -Ed.]
2021-02-18 16:27:00 +00:00
Near 1e577f56e7 Update to ares v117r01 release.
[No official changelog available for this version. -Ed.]
2021-02-15 23:04:00 +00:00
Near 7656765f30 Update to ares v117 release.
[No official changelog available for this version. -Ed.]
2021-02-08 09:11:00 +00:00
Near fabde308e9 Update to ares v116r08 release.
[No official changelog available for this version. -Ed.]
2021-01-18 21:03:00 +00:00
Near 4af59c63f1 Update to ares v116r07 release.
[No official changelog available for this version. -Ed.]
2021-01-14 21:00:00 +00:00
Near 70cdb5b199 Update to ares v115a release.
[No official changelog available for this version. -Ed.]
2020-07-26 17:29:00 +00:00
2749 changed files with 289506 additions and 65880 deletions

No files matched your search

+170
View File
@@ -0,0 +1,170 @@
name: Build
on:
push:
branches: [ master ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]
jobs:
build:
strategy:
matrix:
program:
- ares
os:
- name: windows
version: latest
- name: macos
version: latest
- name: ubuntu
version: latest
runs-on: ${{ matrix.os.name }}-${{ matrix.os.version }}
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
if: matrix.os.name == 'ubuntu'
run: |
sudo apt-get update -y -qq
sudo apt-get install libsdl2-dev libgtksourceview2.0-dev libgtk2.0-dev libao-dev libopenal-dev
- name: Make
run: make -j4 -C desktop-ui build=optimized local=false lto=true
- name: Upload
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.program }}-${{ matrix.os.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@v2
with:
path: 'src'
- name: Download Artifacts
uses: actions/download-artifact@v2
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/ares.app/Contents/MacOS/ares
for os in windows macos
do
mkdir "${os}"
cd "${os}"
# Package ares.
outdir=ares${suffix}
mkdir ${outdir}
cp -ar ${bindir}/ares-${os}/* ${outdir}
zip -r ../ares-${os}.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-macos
uses: actions/upload-release-asset@v1
env: { GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' }
with: { upload_url: '${{ env.UPLOAD_URL }}', asset_path: 'ares-macos.zip', asset_name: 'ares-macos.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' }
+15
View File
@@ -0,0 +1,15 @@
ares
Copyright (c) 2004-2021 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
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+18
View File
@@ -0,0 +1,18 @@
# ares
[![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 descendent of [higan](https://github.com/higan-emu/higan) and [bsnes](https://github.com/bsnes-emu/bsnes/), and focuses on accuracy and preservation.
Official Releases
-----------------
Official releases are available from
[the ares website](https://ares-emulator.github.io).
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).
Only the latest nightly build is kept.
+15 -2
View File
@@ -7,12 +7,17 @@ else ifneq ($(filter $(platform),linux bsd),)
options += -Wl,-export-dynamic
options += -lX11 -lXext
else
$(error "unsupported platform")
$(error "ares is a library and cannot be built directly.")
endif
ares.objects := ares
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
@@ -46,6 +51,10 @@ 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
@@ -74,6 +83,10 @@ 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
+81
View File
@@ -0,0 +1,81 @@
#version 150
//anti-aliased nearest-neighbor
precision highp float;
uniform sampler2D source[];
uniform vec4 sourceSize[];
uniform vec4 targetSize[];
in Vertex {
vec2 texCoord;
};
out vec4 fragColor;
vec4 vpow(vec4 n, float e) {
return vec4(pow(n.x, e), pow(n.y, e), pow(n.z, e), pow(n.w, e));
}
vec4 toLQV(vec3 c) {
return vec4(c.r, c.g, c.b, c.r * 0.2989 + c.g * 0.5870 + c.b * 0.1140);
}
vec3 fromLQV(vec4 c) {
float f = c.w / (c.r * 0.2989 + c.g * 0.5870 + c.b * 0.1140);
return vec3(c.rgb) * f;
}
vec3 percent(float ssize, float tsize, float coord) {
float minfull = (coord * tsize - 0.5) / tsize * ssize;
float maxfull = (coord * tsize + 0.5) / tsize * ssize;
float realfull = floor(maxfull);
if(minfull > realfull) {
return vec3(
1,
(realfull + 0.5) / ssize,
(realfull + 0.5) / ssize
);
}
return vec3(
(maxfull - realfull) / (maxfull - minfull),
(realfull - 0.5) / ssize,
(realfull + 0.5) / ssize
);
}
void main() {
float srgb = 2.1;
float gamma = 3.0;
vec3 x = percent(sourceSize[0].x, targetSize[0].x, texCoord.x);
vec3 y = percent(sourceSize[0].y, targetSize[0].y, texCoord.y);
//get points to interpolate across in linear RGB
vec4 a = toLQV(vpow(texture(source[0], vec2(x[1], y[1])), srgb).rgb);
vec4 b = toLQV(vpow(texture(source[0], vec2(x[2], y[1])), srgb).rgb);
vec4 c = toLQV(vpow(texture(source[0], vec2(x[1], y[2])), srgb).rgb);
vec4 d = toLQV(vpow(texture(source[0], vec2(x[2], y[2])), srgb).rgb);
//use perceptual gamma for luminance component
a.w = pow(a.w, 1 / gamma);
b.w = pow(b.w, 1 / gamma);
c.w = pow(c.w, 1 / gamma);
d.w = pow(d.w, 1 / gamma);
//interpolate
vec4 gammaLQV =
(1.0 - x[0]) * (1.0 - y[0]) * a +
(0.0 + x[0]) * (1.0 - y[0]) * b +
(1.0 - x[0]) * (0.0 + y[0]) * c +
(0.0 + x[0]) * (0.0 + y[0]) * d;
//convert luminance gamma back to linear
gammaLQV.w = pow(gammaLQV.w, gamma);
//convert color back to sRGB
fragColor = vpow(vec4(fromLQV(gammaLQV), 1), 1 / srgb);
}
+8
View File
@@ -0,0 +1,8 @@
input
filter: nearest
program
fragment: AANN.fs
output
filter: nearest
@@ -0,0 +1,10 @@
input
filter: nearest
program
filter: nearest
wrap: border
fragment: shadertoy.fs
output
filter: nearest
+145
View File
@@ -0,0 +1,145 @@
//
// PUBLIC DOMAIN CRT STYLED SCAN-LINE SHADER
//
// by Timothy Lottes
//
// This is more along the style of a really good CGA arcade monitor.
// With RGB inputs instead of NTSC.
// The shadow mask example has the mask rotated 90 degrees for less chromatic aberration.
//
// Left it unoptimized to show the theory behind the algorithm.
//
// It is an example what I personally would want as a display option for pixel art games.
// Please take and use, change, or whatever.
//
#version 150
uniform sampler2D source[];
uniform vec4 sourceSize[];
uniform int phase;
in Vertex {
vec2 texCoord;
};
out vec4 fragColor;
// Emulated input resolution.
vec2 res=sourceSize[0].xy;
// Hardness of scanline.
// -8.0 = soft
// -16.0 = medium
float hardScan=-8.0;
// Hardness of pixels in scanline.
// -2.0 = soft
// -4.0 = hard
float hardPix=-3.0;
// Display warp.
// 0.0 = none
// 1.0/8.0 = extreme
vec2 warp=vec2(1.0/32.0,1.0/24.0);
// Amount of shadow mask.
float maskDark=0.5;
float maskLight=1.5;
//------------------------------------------------------------------------
// sRGB to Linear.
// Assuing using sRGB typed textures this should not be needed.
float ToLinear1(float c){return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);}
vec3 ToLinear(vec3 c){return vec3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));}
// Linear to sRGB.
// Assuing using sRGB typed textures this should not be needed.
float ToSrgb1(float c){return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);}
vec3 ToSrgb(vec3 c){return vec3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));}
// Nearest emulated sample given floating point position and texel offset.
// Also zero's off screen.
vec3 Fetch(vec2 pos,vec2 off){
pos=(floor(pos*res+off)+vec2(0.5,0.5))/res;
return ToLinear(1.2 * texture(source[0],pos.xy,-16.0).rgb);}
// Distance in emulated pixels to nearest texel.
vec2 Dist(vec2 pos){pos=pos*res;return -((pos-floor(pos))-vec2(0.5));}
// 1D Gaussian.
float Gaus(float pos,float scale){return exp2(scale*pos*pos);}
// 3-tap Gaussian filter along horz line.
vec3 Horz3(vec2 pos,float off){
vec3 b=Fetch(pos,vec2(-1.0,off));
vec3 c=Fetch(pos,vec2( 0.0,off));
vec3 d=Fetch(pos,vec2( 1.0,off));
float dst=Dist(pos).x;
// Convert distance to weight.
float scale=hardPix;
float wb=Gaus(dst-1.0,scale);
float wc=Gaus(dst+0.0,scale);
float wd=Gaus(dst+1.0,scale);
// Return filtered sample.
return (b*wb+c*wc+d*wd)/(wb+wc+wd);}
// 5-tap Gaussian filter along horz line.
vec3 Horz5(vec2 pos,float off){
vec3 a=Fetch(pos,vec2(-2.0,off));
vec3 b=Fetch(pos,vec2(-1.0,off));
vec3 c=Fetch(pos,vec2( 0.0,off));
vec3 d=Fetch(pos,vec2( 1.0,off));
vec3 e=Fetch(pos,vec2( 2.0,off));
float dst=Dist(pos).x;
// Convert distance to weight.
float scale=hardPix;
float wa=Gaus(dst-2.0,scale);
float wb=Gaus(dst-1.0,scale);
float wc=Gaus(dst+0.0,scale);
float wd=Gaus(dst+1.0,scale);
float we=Gaus(dst+2.0,scale);
// Return filtered sample.
return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
// Return scanline weight.
float Scan(vec2 pos,float off){
float dst=Dist(pos).y;
return Gaus(dst+off,hardScan);}
// Allow nearest three lines to effect pixel.
vec3 Tri(vec2 pos){
vec3 a=Horz3(pos,-1.0);
vec3 b=Horz5(pos, 0.0);
vec3 c=Horz3(pos, 1.0);
float wa=Scan(pos,-1.0);
float wb=Scan(pos, 0.0);
float wc=Scan(pos, 1.0);
return a*wa+b*wb+c*wc;}
// Distortion of scanlines, and end of screen alpha.
vec2 Warp(vec2 pos){
pos=pos*2.0-1.0;
pos*=vec2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y);
return pos*0.5+0.5;}
// Shadow mask.
vec3 Mask(vec2 pos){
pos.x+=pos.y*3.0;
vec3 mask=vec3(maskDark,maskDark,maskDark);
pos.x=fract(pos.x/6.0);
if(pos.x<0.333)mask.r=maskLight;
else if(pos.x<0.666)mask.g=maskLight;
else mask.b=maskLight;
return mask;}
void main() {
vec2 pos = texCoord.xy * 1.0001;
hardScan=-12.0;
// maskDark=maskLight;
pos=Warp(pos.xy);
fragColor.rgb=Tri(pos)*Mask(gl_FragCoord.xy);
fragColor.a=1.0;
fragColor = vec4(ToSrgb(fragColor.rgb), fragColor.a);
}
+609
View File
@@ -0,0 +1,609 @@
#version 150
//_____________________________/\_______________________________
//==============================================================
//
//
// [CRTS] PUBLIC DOMAIN CRT-STYLED SCALAR - 20180120b
//
// by Timothy Lottes
// https://www.shadertoy.com/view/MtSfRK
// adapted for quark syntax by hunterk
//
//
//==============================================================
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//_____________________________/\_______________________________
//==============================================================
//
// WHAT'S NEW
//
//--------------------------------------------------------------
// Evolution of prior shadertoy example
//--------------------------------------------------------------
// This one is semi-optimized
// - Less texture fetches
// - Didn't get to instruction level optimization
// - Could likely use texture fetch to generate phosphor mask
//--------------------------------------------------------------
// Added options to disable unused features
//--------------------------------------------------------------
// Added in exposure matching
// - Given scan-line effect and mask always darkens image
// - Uses generalized tonemapper to boost mid-level
// - Note this can compress highlights
// - And won't get back peak brightness
// - But best option if one doesn't want as much darkening
//--------------------------------------------------------------
// Includes option saturation and contrast controls
//--------------------------------------------------------------
// Added in subtractive aperture grille
// - This is a bit brighter than prior
//--------------------------------------------------------------
// Make sure input to this filter is already low-resolution
// - This is not designed to work on titles doing the following
// - Rendering to hi-res with nearest sampling
//--------------------------------------------------------------
// Added a fast and more pixely option for 2 tap/pixel
//--------------------------------------------------------------
// Improved the vignette when WARP is enabled
//--------------------------------------------------------------
// Didn't test HLSL or CPU options
// - Will incorportate patches if they are broken
// - But out of time to try them myself
//==============================================================
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//_____________________________/\_______________________________
//==============================================================
//
// LICENSE = UNLICENSE (aka PUBLIC DOMAIN)
//
//--------------------------------------------------------------
// This is free and unencumbered software released into the
// public domain.
//--------------------------------------------------------------
// Anyone is free to copy, modify, publish, use, compile, sell,
// or distribute this software, either in source code form or as
// a compiled binary, for any purpose, commercial or
// non-commercial, and by any means.
//--------------------------------------------------------------
// In jurisdictions that recognize copyright laws, the author or
// authors of this software dedicate any and all copyright
// interest in the software to the public domain. We make this
// dedication for the benefit of the public at large and to the
// detriment of our heirs and successors. We intend this
// dedication to be an overt act of relinquishment in perpetuity
// of all present and future rights to this software under
// copyright law.
//--------------------------------------------------------------
// 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 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.
//--------------------------------------------------------------
// For more information, please refer to
// <http://unlicense.org/>
//==============================================================
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
#define MASK 1.0
#define MASK_INTENSITY 0.5
#define SCANLINE_THINNESS 0.5
#define SCAN_BLUR 2.5
#define CURVATURE 0.02
#define TRINITRON_CURVE 0.0
#define CORNER 3.0
#define CRT_GAMMA 2.4
uniform sampler2D source[];
uniform vec4 sourceSize[];
uniform vec4 outputSize;
in Vertex {
vec2 vTexCoord;
};
out vec4 FragColor;
//_____________________________/\_______________________________
//==============================================================
//
// GAMMA FUNCTIONS
//
//--------------------------------------------------------------
//--------------------------------------------------------------
// Since shadertoy doesn't have sRGB textures
// And we need linear input into shader
// Don't do this in your code
float FromSrgb1(float c){
return (c<=0.04045)?c*(1.0/12.92):
pow(c*(1.0/1.055)+(0.055/1.055),CRT_GAMMA);}
//--------------------------------------------------------------
vec3 FromSrgb(vec3 c){return vec3(
FromSrgb1(c.r),FromSrgb1(c.g),FromSrgb1(c.b));}
// Convert from linear to sRGB
// Since shader toy output is not linear
float ToSrgb1(float c){
return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);}
//--------------------------------------------------------------
vec3 ToSrgb(vec3 c){return vec3(
ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));}
//--------------------------------------------------------------
//_____________________________/\_______________________________
//==============================================================
//
// DEFINES
//
//--------------------------------------------------------------
// CRTS_CPU - CPU code
// CRTS_GPU - GPU code
//--------------------------------------------------------------
// CRTS_GLSL - GLSL
// CRTS_HLSL - HLSL (not tested yet)
//--------------------------------------------------------------
// CRTS_DEBUG - Define to see on/off split screen
//--------------------------------------------------------------
// CRTS_WARP - Apply screen warp
//--------------------------------------------------------------
// CRTS_2_TAP - Faster very pixely 2-tap filter (off is 8)
//--------------------------------------------------------------
// CRTS_MASK_GRILLE - Aperture grille (aka Trinitron)
// CRTS_MASK_GRILLE_LITE - Brighter (subtractive channels)
// CRTS_MASK_NONE - No mask
// CRTS_MASK_SHADOW - Horizontally stretched shadow mask
//--------------------------------------------------------------
// CRTS_TONE - Normalize mid-level and process color
// CRTS_CONTRAST - Process color - enable contrast control
// CRTS_SATURATION - Process color - enable saturation control
//--------------------------------------------------------------
#define CRTS_STATIC
#define CrtsPow
#define CRTS_RESTRICT
//==============================================================
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//==============================================================
// SETUP FOR CRTS
//--------------------------------------------------------------
//==============================================================
//#define CRTS_DEBUG 1
#define CRTS_GPU 1
#define CRTS_GLSL 1
//--------------------------------------------------------------
//#define CRTS_2_TAP 1
//--------------------------------------------------------------
#define CRTS_TONE 1
#define CRTS_CONTRAST 0
#define CRTS_SATURATION 0
//--------------------------------------------------------------
#define CRTS_WARP 1
//--------------------------------------------------------------
// Try different masks -> moved to runtime parameters
//#define CRTS_MASK_GRILLE 1
//#define CRTS_MASK_GRILLE_LITE 1
//#define CRTS_MASK_NONE 1
//#define CRTS_MASK_SHADOW 1
//--------------------------------------------------------------
// Scanline thinness
// 0.50 = fused scanlines
// 0.70 = recommended default
// 1.00 = thinner scanlines (too thin)
#define INPUT_THIN (0.5 + (0.5 * SCANLINE_THINNESS))
//--------------------------------------------------------------
// Horizonal scan blur
// -3.0 = pixely
// -2.5 = default
// -2.0 = smooth
// -1.0 = too blurry
#define INPUT_BLUR (-1.0 * SCAN_BLUR)
//--------------------------------------------------------------
// Shadow mask effect, ranges from,
// 0.25 = large amount of mask (not recommended, too dark)
// 0.50 = recommended default
// 1.00 = no shadow mask
#define INPUT_MASK (1.0 - MASK_INTENSITY)
//--------------------------------------------------------------
#define INPUT_X sourceSize[0].x
#define INPUT_Y sourceSize[0].y
//--------------------------------------------------------------
// Setup the function which returns input image color
vec3 CrtsFetch(vec2 uv){
// For shadertoy, scale to get native texels in the image
uv*=vec2(INPUT_X,INPUT_Y)/sourceSize[0].xy;
// Move towards intersting parts
// uv+=vec2(0.5,0.5);
// Non-shadertoy case would not have the color conversion
return FromSrgb(texture(source[0],uv.xy,-16.0).rgb);}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//_____________________________/\_______________________________
//==============================================================
//
// GPU CODE
//
//==============================================================
#ifdef CRTS_GPU
//_____________________________/\_______________________________
//==============================================================
// PORTABILITY
//==============================================================
#ifdef CRTS_GLSL
#define CrtsF1 float
#define CrtsF2 vec2
#define CrtsF3 vec3
#define CrtsF4 vec4
#define CrtsFractF1 fract
#define CrtsRcpF1(x) (1.0/(x))
#define CrtsSatF1(x) clamp((x),0.0,1.0)
//--------------------------------------------------------------
CrtsF1 CrtsMax3F1(CrtsF1 a,CrtsF1 b,CrtsF1 c){
return max(a,max(b,c));}
#endif
//==============================================================
#ifdef CRTS_HLSL
#define CrtsF1 float
#define CrtsF2 float2
#define CrtsF3 float3
#define CrtsF4 float4
#define CrtsFractF1 frac
#define CrtsRcpF1(x) (1.0/(x))
#define CrtsSatF1(x) saturate(x)
//--------------------------------------------------------------
CrtsF1 CrtsMax3F1(CrtsF1 a,CrtsF1 b,CrtsF1 c){
return max(a,max(b,c));}
#endif
//_____________________________/\_______________________________
//==============================================================
// TONAL CONTROL CONSTANT GENERATION
//--------------------------------------------------------------
// This is in here for rapid prototyping
// Please use the CPU code and pass in as constants
//==============================================================
CrtsF4 CrtsTone(
CrtsF1 contrast,
CrtsF1 saturation,
CrtsF1 thin,
CrtsF1 mask){
//--------------------------------------------------------------
if(MASK == 0.0) mask=1.0;
//--------------------------------------------------------------
if(MASK == 1.0){
// Normal R mask is {1.0,mask,mask}
// LITE R mask is {mask,1.0,1.0}
mask=0.5+mask*0.5;
}
//--------------------------------------------------------------
CrtsF4 ret;
CrtsF1 midOut=0.18/((1.5-thin)*(0.5*mask+0.5));
CrtsF1 pMidIn=pow(0.18,contrast);
ret.x=contrast;
ret.y=((-pMidIn)+midOut)/((1.0-pMidIn)*midOut);
ret.z=((-pMidIn)*midOut+pMidIn)/(midOut*(-pMidIn)+midOut);
ret.w=contrast+saturation;
return ret;}
//_____________________________/\_______________________________
//==============================================================
// MASK
//--------------------------------------------------------------
// Letting LCD/OLED pixel elements function like CRT phosphors
// So "phosphor" resolution scales with display resolution
//--------------------------------------------------------------
// Not applying any warp to the mask (want high frequency)
// Real aperture grille has a mask which gets wider on ends
// Not attempting to be "real" but instead look the best
//--------------------------------------------------------------
// Shadow mask is stretched horizontally
// RRGGBB
// GBBRRG
// RRGGBB
// This tends to look better on LCDs than vertical
// Also 2 pixel width is required to get triad centered
//--------------------------------------------------------------
// The LITE version of the Aperture Grille is brighter
// Uses {dark,1.0,1.0} for R channel
// Non LITE version uses {1.0,dark,dark}
//--------------------------------------------------------------
// 'pos' - This is 'fragCoord.xy'
// Pixel {0,0} should be {0.5,0.5}
// Pixel {1,1} should be {1.5,1.5}
//--------------------------------------------------------------
// 'dark' - Exposure of of masked channel
// 0.0=fully off, 1.0=no effect
//==============================================================
CrtsF3 CrtsMask(CrtsF2 pos,CrtsF1 dark){
if(MASK == 2.0){
CrtsF3 m=CrtsF3(dark,dark,dark);
CrtsF1 x=CrtsFractF1(pos.x*(1.0/3.0));
if(x<(1.0/3.0))m.r=1.0;
else if(x<(2.0/3.0))m.g=1.0;
else m.b=1.0;
return m;
}
//--------------------------------------------------------------
if(MASK == 1.0){
CrtsF3 m=CrtsF3(1.0,1.0,1.0);
CrtsF1 x=CrtsFractF1(pos.x*(1.0/3.0));
if(x<(1.0/3.0))m.r=dark;
else if(x<(2.0/3.0))m.g=dark;
else m.b=dark;
return m;
}
//--------------------------------------------------------------
if(MASK == 0.0){
return CrtsF3(1.0,1.0,1.0);
}
//--------------------------------------------------------------
if(MASK == 3.0){
pos.x+=pos.y*2.9999;
CrtsF3 m=CrtsF3(dark,dark,dark);
CrtsF1 x=CrtsFractF1(pos.x*(1.0/6.0));
if(x<(1.0/3.0))m.r=1.0;
else if(x<(2.0/3.0))m.g=1.0;
else m.b=1.0;
return m;
}
}
//_____________________________/\_______________________________
//==============================================================
// FILTER ENTRY
//--------------------------------------------------------------
// Input must be linear
// Output color is linear
//--------------------------------------------------------------
// Must have fetch function setup: CrtsF3 CrtsFetch(CrtsF2 uv)
// - The 'uv' range is {0.0 to 1.0} for input texture
// - Output of this must be linear color
//--------------------------------------------------------------
// SCANLINE MATH & AUTO-EXPOSURE NOTES
// ===================================
// Each output line has contribution from at most 2 scanlines
// Scanlines are shaped by a windowed cosine function
// This shape blends together well with only 2 lines of overlap
//--------------------------------------------------------------
// Base scanline intensity is as follows
// which leaves output intensity range from {0 to 1.0}
// --------
// thin := range {thick 0.5 to thin 1.0}
// off := range {0.0 to <1.0},
// sub-pixel offset between two scanlines
// --------
// a0=cos(min(0.5, off *thin)*2pi)*0.5+0.5;
// a1=cos(min(0.5,(1.0-off)*thin)*2pi)*0.5+0.5;
//--------------------------------------------------------------
// This leads to a image darkening factor of roughly:
// {(1.5-thin)/1.0}
// This is further reduced by the mask:
// {1.0/2.0+mask*1.0/2.0}
// Reciprocal of combined effect is used for auto-exposure
// to scale up the mid-level in the tonemapper
//==============================================================
CrtsF3 CrtsFilter(
//--------------------------------------------------------------
// SV_POSITION, fragCoord.xy
CrtsF2 ipos,
//--------------------------------------------------------------
// inputSize / outputSize (in pixels)
CrtsF2 inputSizeDivOutputSize,
//--------------------------------------------------------------
// 0.5 * inputSize (in pixels)
CrtsF2 halfInputSize,
//--------------------------------------------------------------
// 1.0 / inputSize (in pixels)
CrtsF2 rcpInputSize,
//--------------------------------------------------------------
// 1.0 / outputSize (in pixels)
CrtsF2 rcpOutputSize,
//--------------------------------------------------------------
// 2.0 / outputSize (in pixels)
CrtsF2 twoDivOutputSize,
//--------------------------------------------------------------
// inputSize.y
CrtsF1 inputHeight,
//--------------------------------------------------------------
// Warp scanlines but not phosphor mask
// 0.0 = no warp
// 1.0/64.0 = light warping
// 1.0/32.0 = more warping
// Want x and y warping to be different (based on aspect)
CrtsF2 warp,
//--------------------------------------------------------------
// Scanline thinness
// 0.50 = fused scanlines
// 0.70 = recommended default
// 1.00 = thinner scanlines (too thin)
// Shared with CrtsTone() function
CrtsF1 thin,
//--------------------------------------------------------------
// Horizonal scan blur
// -3.0 = pixely
// -2.5 = default
// -2.0 = smooth
// -1.0 = too blurry
CrtsF1 blur,
//--------------------------------------------------------------
// Shadow mask effect, ranges from,
// 0.25 = large amount of mask (not recommended, too dark)
// 0.50 = recommended default
// 1.00 = no shadow mask
// Shared with CrtsTone() function
CrtsF1 mask,
//--------------------------------------------------------------
// Tonal curve parameters generated by CrtsTone()
CrtsF4 tone
//--------------------------------------------------------------
){
//--------------------------------------------------------------
#ifdef CRTS_DEBUG
CrtsF2 uv=ipos*rcpOutputSize;
// Show second half processed, and first half un-processed
if(uv.x<0.5){
// Force nearest to get squares
uv*=1.0/rcpInputSize;
uv=floor(uv)+CrtsF2(0.5,0.5);
uv*=rcpInputSize;
CrtsF3 color=CrtsFetch(uv);
return color;}
#endif
//--------------------------------------------------------------
// Optional apply warp
CrtsF2 pos;
#ifdef CRTS_WARP
// Convert to {-1 to 1} range
pos=ipos*twoDivOutputSize-CrtsF2(1.0,1.0);
// Distort pushes image outside {-1 to 1} range
pos*=CrtsF2(
1.0+(pos.y*pos.y)*warp.x,
1.0+(pos.x*pos.x)*warp.y);
// TODO: Vignette needs optimization
CrtsF1 vin=(1.0-(
(1.0-CrtsSatF1(pos.x*pos.x))*(1.0-CrtsSatF1(pos.y*pos.y)))) * (0.998 + (0.001 * CORNER));
vin=CrtsSatF1((-vin)*inputHeight+inputHeight);
// Leave in {0 to inputSize}
pos=pos*halfInputSize+halfInputSize;
#else
pos=ipos*inputSizeDivOutputSize;
#endif
//--------------------------------------------------------------
// Snap to center of first scanline
CrtsF1 y0=floor(pos.y-0.5)+0.5;
#ifdef CRTS_2_TAP
// Using Inigo's "Improved Texture Interpolation"
// http://iquilezles.org/www/articles/texture/texture.htm
pos.x+=0.5;
CrtsF1 xi=floor(pos.x);
CrtsF1 xf=pos.x-xi;
xf=xf*xf*xf*(xf*(xf*6.0-15.0)+10.0);
CrtsF1 x0=xi+xf-0.5;
CrtsF2 p=CrtsF2(x0*rcpInputSize.x,y0*rcpInputSize.y);
// Coordinate adjusted bilinear fetch from 2 nearest scanlines
CrtsF3 colA=CrtsFetch(p);
p.y+=rcpInputSize.y;
CrtsF3 colB=CrtsFetch(p);
#else
// Snap to center of one of four pixels
CrtsF1 x0=floor(pos.x-1.5)+0.5;
// Inital UV position
CrtsF2 p=CrtsF2(x0*rcpInputSize.x,y0*rcpInputSize.y);
// Fetch 4 nearest texels from 2 nearest scanlines
CrtsF3 colA0=CrtsFetch(p);
p.x+=rcpInputSize.x;
CrtsF3 colA1=CrtsFetch(p);
p.x+=rcpInputSize.x;
CrtsF3 colA2=CrtsFetch(p);
p.x+=rcpInputSize.x;
CrtsF3 colA3=CrtsFetch(p);
p.y+=rcpInputSize.y;
CrtsF3 colB3=CrtsFetch(p);
p.x-=rcpInputSize.x;
CrtsF3 colB2=CrtsFetch(p);
p.x-=rcpInputSize.x;
CrtsF3 colB1=CrtsFetch(p);
p.x-=rcpInputSize.x;
CrtsF3 colB0=CrtsFetch(p);
#endif
//--------------------------------------------------------------
// Vertical filter
// Scanline intensity is using sine wave
// Easy filter window and integral used later in exposure
CrtsF1 off=pos.y-y0;
CrtsF1 pi2=6.28318530717958;
CrtsF1 hlf=0.5;
CrtsF1 scanA=cos(min(0.5, off *thin )*pi2)*hlf+hlf;
CrtsF1 scanB=cos(min(0.5,(-off)*thin+thin)*pi2)*hlf+hlf;
//--------------------------------------------------------------
#ifdef CRTS_2_TAP
#ifdef CRTS_WARP
// Get rid of wrong pixels on edge
scanA*=vin;
scanB*=vin;
#endif
// Apply vertical filter
CrtsF3 color=(colA*scanA)+(colB*scanB);
#else
// Horizontal kernel is simple gaussian filter
CrtsF1 off0=pos.x-x0;
CrtsF1 off1=off0-1.0;
CrtsF1 off2=off0-2.0;
CrtsF1 off3=off0-3.0;
CrtsF1 pix0=exp2(blur*off0*off0);
CrtsF1 pix1=exp2(blur*off1*off1);
CrtsF1 pix2=exp2(blur*off2*off2);
CrtsF1 pix3=exp2(blur*off3*off3);
CrtsF1 pixT=CrtsRcpF1(pix0+pix1+pix2+pix3);
#ifdef CRTS_WARP
// Get rid of wrong pixels on edge
pixT*=vin;
#endif
scanA*=pixT;
scanB*=pixT;
// Apply horizontal and vertical filters
CrtsF3 color=
(colA0*pix0+colA1*pix1+colA2*pix2+colA3*pix3)*scanA +
(colB0*pix0+colB1*pix1+colB2*pix2+colB3*pix3)*scanB;
#endif
//--------------------------------------------------------------
// Apply phosphor mask
color*=CrtsMask(ipos,mask);
//--------------------------------------------------------------
// Optional color processing
#ifdef CRTS_TONE
// Tonal control, start by protecting from /0
CrtsF1 peak=max(1.0/(256.0*65536.0),
CrtsMax3F1(color.r,color.g,color.b));
// Compute the ratios of {R,G,B}
CrtsF3 ratio=color*CrtsRcpF1(peak);
// Apply tonal curve to peak value
#ifdef CRTS_CONTRAST
peak=pow(peak,tone.x);
#endif
peak=peak*CrtsRcpF1(peak*tone.y+tone.z);
// Apply saturation
#ifdef CRTS_SATURATION
ratio=pow(ratio,CrtsF3(tone.w,tone.w,tone.w));
#endif
// Reconstruct color
return ratio*peak;
#else
return color;
#endif
//--------------------------------------------------------------
}
#endif
void main() {
vec2 warp_factor;
warp_factor.x = CURVATURE;
warp_factor.y = (3.0 / 4.0) * warp_factor.x; // assume 4:3 aspect
warp_factor.x *= (1.0 - TRINITRON_CURVE);
FragColor.rgb = CrtsFilter(vTexCoord.xy * outputSize.xy,
sourceSize[0].xy * outputSize.zw,
sourceSize[0].xy * vec2(0.5,0.5),
sourceSize[0].zw,
outputSize.zw,
2.0 * outputSize.zw,
sourceSize[0].y,
warp_factor,
INPUT_THIN,
INPUT_BLUR,
INPUT_MASK,
CrtsTone(1.0,0.0,INPUT_THIN,INPUT_MASK));
// Shadertoy outputs non-linear color
FragColor.rgb = ToSrgb(FragColor.rgb);
}
+16
View File
@@ -0,0 +1,16 @@
#version 150
in vec4 position;
in vec2 texCoord;
out Vertex {
vec2 vTexCoord;
};
uniform vec4 targetSize;
uniform vec4 sourceSize[];
void main() {
gl_Position = position;
vTexCoord = texCoord;
}
@@ -0,0 +1,12 @@
input
filter: nearest
program
filter: nearest
vertex: lottes.vs
fragment: lottes.fs
output
height: 0
width: 0
filter: linear
@@ -0,0 +1,21 @@
#version 150
#define distortion 0.2
uniform sampler2D source[];
uniform vec4 sourceSize[];
in Vertex {
vec2 texCoord;
};
out vec4 fragColor;
vec2 radialDistortion(vec2 coord) {
vec2 cc = coord - vec2(0.5);
float dist = dot(cc, cc) * distortion;
return coord + cc * (1.0 - dist) * dist;
}
void main() {
fragColor = texture(source[0], radialDistortion(texCoord));
}
@@ -0,0 +1,4 @@
program
filter: linear
wrap: border
fragment: curvature.fs
@@ -0,0 +1,25 @@
#version 150
uniform sampler2D source[];
uniform vec4 sourceSize[];
in Vertex {
vec2 texCoord;
};
out vec4 fragColor;
vec3 grayscale(vec3 color) {
return vec3(dot(color, vec3(0.3, 0.59, 0.11)));
}
void main() {
vec2 offset = fract(texCoord * sourceSize[0].xy) - 0.5;
offset /= sourceSize[0].xy;
vec3 cx = texture(source[0], texCoord - offset).xyz;
vec3 cy = texture(source[0], texCoord).xyz;
vec3 cz = vec3(5.0 * grayscale(abs(cx - cy)));
fragColor = vec4(clamp(cz, 0.0, 1.0), 1.0);
}
@@ -0,0 +1,4 @@
program
filter: linear
wrap: edge
fragment: edge-detection.fs
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

@@ -0,0 +1,99 @@
#version 150
// GritsScanlines by torridgristle
// license: public domain (https://forums.libretro.com/t/lightweight-lut-based-scanline-glow-concept-prototype-glsl/18336/7)
/* Runtime parameters
#in LuminanceDawnbringer
#in LuminanceLUT
#in ScanlinesOpacity
#in GammaCorrection
#in TrinitronColors
*/
// static parameters
//#define LuminanceDawnbringer
#define LuminanceLUT
//#define TrinitronColors
#define ScanlinesOpacity 0.9
//#define GammaCorrection 1.2
uniform sampler2D source[];
uniform vec4 sourceSize[];
uniform vec4 targetSize;
uniform sampler2D pixmap[];
in Vertex {
vec2 texCoord;
};
out vec4 fragColor;
#ifdef LuminanceLUT
#define LUT_SizeLum 16.0
// Code taken from RetroArch's LUT shader
float luminancelut(vec4 org)
{
vec4 imgColorLum = org;
float redLum = ( imgColorLum.r * (LUT_SizeLum - 1.0) + 0.4999 ) / (LUT_SizeLum * LUT_SizeLum);
float greenLum = ( imgColorLum.g * (LUT_SizeLum - 1.0) + 0.4999 ) / LUT_SizeLum;
float blue1Lum = (floor( imgColorLum.b * (LUT_SizeLum - 1.0) ) / LUT_SizeLum) + redLum;
float blue2Lum = (ceil( imgColorLum.b * (LUT_SizeLum - 1.0) ) / LUT_SizeLum) + redLum;
float mixerLum = clamp(max((imgColorLum.b - blue1Lum) / (blue2Lum - blue1Lum), 0.0), 0.0, 32.0);
float color1Lum = texture(pixmap[1], vec2( blue1Lum, greenLum )).x;
float color2Lum = texture(pixmap[1], vec2( blue2Lum, greenLum )).x;
return mix(color1Lum, color2Lum, mixerLum);
}
#endif
#ifdef TrinitronColors
#define LUT_SizeTrinitron 32.0
vec4 TrinitronD50(vec4 org)
{
vec4 imgColorTrinitron = org;
float redTrinitron = ( imgColorTrinitron.r * (LUT_SizeTrinitron - 1.0) + 0.4999 ) / (LUT_SizeTrinitron * LUT_SizeTrinitron);
float greenTrinitron = ( imgColorTrinitron.g * (LUT_SizeTrinitron - 1.0) + 0.4999 ) / LUT_SizeTrinitron;
float blue1Trinitron = (floor( imgColorTrinitron.b * (LUT_SizeTrinitron - 1.0) ) / LUT_SizeTrinitron) + redTrinitron;
float blue2Trinitron = (ceil( imgColorTrinitron.b * (LUT_SizeTrinitron - 1.0) ) / LUT_SizeTrinitron) + redTrinitron;
float mixerTrinitron = clamp(max((imgColorTrinitron.b - blue1Trinitron) / (blue2Trinitron - blue1Trinitron), 0.0), 0.0, 32.0);
vec4 color1Trinitron = texture(pixmap[2], vec2( blue1Trinitron, greenTrinitron ));
vec4 color2Trinitron = texture(pixmap[2], vec2( blue2Trinitron, greenTrinitron ));
vec4 fragColorTrinitron = mix(color1Trinitron, color2Trinitron, mixerTrinitron);
return vec4(pow(fragColorTrinitron.rgb,vec3(GammaCorrection,GammaCorrection,GammaCorrection)),1.0);
}
#endif
void main() {
//Source Image
vec4 org = texture(source[0], texCoord);
#ifdef LuminanceLUT
// Use a 3DLUT instead of an equation so that it can use any arbitrary mess you can come up with.
float luminance = luminancelut(org);
#elif defined LuminanceDawnbringer
// Dawnbringer's brightness equation from Dawnbringer's Toolbox scripts for Grafx2
float luminance = sqrt(org.r*org.r*0.0676 + org.g*org.g*0.3025 + org.b*org.b*0.0361) * 1.5690256395005606;
#else
// Plain, standard, fine; slightly faster
float luminance = ((0.299*org.r) + (0.587*org.g) + (0.114*org.b));
#endif
// Don't let it exceed 1.0
luminance = clamp(luminance, 0.0, 1.0);
// Scanline Mapping, based on the Phosphor LUT shader's method of tiling a texture over the screen
vec2 LUTeffectiveCoord = vec2(luminance,fract((texCoord.y*targetSize.y)/4.0));
// Scanline Layer
vec4 screen = texture(pixmap[0], LUTeffectiveCoord);
// Output multiplying the scanlines into the original image, with control over opacity
#ifdef TrinitronColors
org = TrinitronD50(org);
#endif
fragColor = ((screen*ScanlinesOpacity)+(1.0 - ScanlinesOpacity)) * (org);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

@@ -0,0 +1,35 @@
settings
LuminanceDawnbringer
active: false
LuminanceLUT
active: false
TrinitronColors
active: true
ScanlinesOpacity: 0.9
min: 0.0
max: 1.0
step: 0.05
GammaCorrection: 1.2
min: 0.5
max: 2.0
step: 0.1
program
filter: nearest
wrap: edge
width: 100%
height: 400%
fragment: GritsScanlines.fs
pixmap: Scanline-LUT-4px.png
filter: linear
wrap: edge
pixmap: Fake-Self-Illumination.png
filter: linear
wrap: edge
pixmap: Trinitron D50 Absolute Colorimetric - LUT.png
filter: linear
wrap: edge
output1
filter: linear
@@ -0,0 +1,39 @@
#version 150
/*
Interlacing
Author: hunterk
License: Public domain
Note: This shader is designed to work with the typical interlaced output from an emulator, which displays both even and odd fields twice.
This shader will un-weave the image, resulting in a standard, alternating-field interlacing.
*/
uniform sampler2D source[];
uniform vec2 targetSize;
uniform vec4 sourceSize[];
uniform int phase;
in Vertex {
vec2 texCoord;
};
out vec4 fragColor;
// This controls how bright the intermediate lines are; 0.0 = totally black
#define percent 0.0
void main()
{
vec4 res = texture(source[0], texCoord);
float y = 0.0;
// assume anything with a vertical resolution greater than 400 lines is interlaced
if (sourceSize[0].y > 400.0) y = sourceSize[0].y * texCoord.y + phase;
else
y = 2.00001 * sourceSize[0].y * texCoord.y;
if (mod(y, 2.0) > 0.99999) fragColor = res;
else
fragColor = vec4(percent) * res;
}
@@ -0,0 +1,6 @@
input
filter: nearest
program
fragment: interlace.fs
modulo: 2
@@ -0,0 +1,11 @@
input
filter: nearest
program
filter: nearest
height: 100%
fragment: pal-r57shell.fs
output
height: 0
filter: linear
@@ -0,0 +1,368 @@
#version 150
// NES PAL composite signal simulation for RetroArch
// shader by r57shell
// thanks to feos & HardWareMan & NewRisingSun
// also TV subpixels and scanlines
// LICENSE: PUBLIC DOMAIN
// NOTE: for nice TV subpixels and scanlines I recommend to
// disable this features here and apply CRT-specialized shader.
// Quality considerations
// there are three main options:
// USE_RAW (R), USE_DELAY_LINE (D), USE_COLORIMETRY (C)
// here is table of quality in decreasing order:
// RDC, RD, RC, DC, D, C
// compatibility macros
#define float2 vec2
#define float3 vec3
#define float4 vec4
#define frac(c) fract(c)
#define saturate(c) clamp(c, 0.0, 1.0)
#define fmod(x,y) mod(x,y)
#define mul(x,y) (y*x)
#define float2x2 mat2
#define float3x3 mat3
#define float4x4 mat4
#define bool2 bvec2
#define bool3 bvec3
#define bool4 bvec4
#define static
uniform sampler2D source[];
uniform vec4 sourceSize[];
uniform vec4 outputSize;
uniform int phase;
in Vertex {
vec2 texCoord;
};
out vec4 fragColor;
// TWEAKS start
// use delay line technique
// without delay line technique, color would interleave
// to avoid this, set HueRotation to zero.
#define USE_DELAY_LINE
// use this if you need to swap even/odd V sign.
// sign of V changes each scanline
// so if some scanline is positive, then next is negative
// and if you want to match picture
// to actual running PAL NES on TV
// you may want to have this option, to change signs
// if they don't match
//#define SWAP_VSIGN
// rough simulation of scanlines
// better if you use additional shader instead
// if you still use it, make sure that SizeY
// is at least twice lower than output height
#define USE_SCANLINES // FIXME: scanlines are broken and I'm too lazy to fix it right now
// to change gamma of virtual TV from 2.2 to something else
#define USE_GAMMA
// use sampled version. it's much more slower version of shader.
// because it is computing x4 more values. NOT RECOMMENDED.
//#define USE_SAMPLED
#ifndef PARAMETER_UNIFORM
// NTSC standard gamma = 2.2
// PAL standard gamma = 2.8
// according to many sources, very unlikely gamma of TV is 2.8
// most likely gamma of PAL TV is in range 2.4-2.5
const float Gamma_static = 2.8; // gamma of virtual TV
const float Brightness_static = 0.25;
const float Contrast_static = 1.1;
const float Saturation_static = 1.1;
const int
Ywidth_static = 12,
Uwidth_static = 23,
Vwidth_static = 23;
#define Brightness Brightness_static
#define Gamma Gamma_static
#define Ywidth Ywidth_static
#define Uwidth Uwidth_static
#define Vwidth Vwidth_static
#define SCANLINE_MUL (sw.x*dark_scanline+sw.y)
int Mwidth = int(max(float(Ywidth), max(float(Uwidth), float(Vwidth))));
// correct one is -2.5
// works only with USE_RAW
const float HueShift = -2.5;
// rotation of hue due to luma level.
const float HueRotation = 2.;
// touch this only if you know what you doing
const float Phase_Y = 2.; // fmod(341*10,12)
const float Phase_One = 0.; // alternating phases.
const float Phase_Two = 8.;
// screen size, scanlines = y*2; y one field, and y other field.
const int SizeX = 256;
const int SizeY = 240;
// count of pixels of virtual TV.
// value close to 1000 produce small artifacts
const int TV_Pixels = 400;
const float dark_scanline = 0.5; // half
#endif
// this is using following matrixes.
// it provides more scientific approach
// by conversion into linear XYZ space
// and back to sRGB.
// it's using Gamma setting too.
// define USE_GAMMA is not required.
#define USE_COLORIMETRY
const float3x3 RGB_to_XYZ =
mat3(
0.4306190, 0.3415419, 0.1783091,
0.2220379, 0.7066384, 0.0713236,
0.0201853, 0.1295504, 0.9390944
);
const float3x3 XYZ_to_sRGB =
mat3(
3.2406, -1.5372, -0.4986,
-0.9689, 1.8758, 0.0415,
0.0557, -0.2040, 1.0570
);
// TWEAKS end
const float YUV_u = 0.492;
const float YUV_v = 0.877;
const mat3 RGB_to_YUV =
mat3(
float3( 0.299, 0.587, 0.114), //Y
float3(-0.299,-0.587, 0.886)*YUV_u, //B-Y
float3( 0.701,-0.587,-0.114)*YUV_v //R-Y
);
#ifdef USE_DELAY_LINE
const float comb_line = 1.;
#else
const float comb_line = 2.;
#endif
static const float Voltage_0 = 0.518;
static const float Voltage_1 = 1.962;
static const float DeltaV = (Voltage_1-Voltage_0);
float RGB_y = Contrast_static/Ywidth_static/DeltaV;
float RGB_u = comb_line*Contrast_static*Saturation_static/YUV_u/Uwidth_static/DeltaV;
float RGB_v = comb_line*Contrast_static*Saturation_static/YUV_v/Vwidth_static/DeltaV;
mat3 YUV_to_RGB =
mat3(
float3(1., 1., 1.)*RGB_y,
float3(0., -0.114/0.587, 1.)*RGB_u,
float3(1., -0.299/0.587, 0.)*RGB_v
);
const float pi = 3.1415926535897932384626433832795;
float sinn(float x)
{
return sin(/*fmod(x,24)*/x*(pi*2./24.));
}
float coss(float x)
{
return cos(/*fmod(x,24)*/x*(pi*2./24.));
}
float3 monitor(sampler2D tex, float2 p)
{
float2 size = sourceSize[0].xy;//float2(SizeX,SizeY);
// align vertical coord to center of texel
float2 uv = float2(
p.x,
(floor(p.y*sourceSize[0].y)+0.5)/sourceSize[0].y);
#ifdef USE_DELAY_LINE
float2 sh = (sourceSize[0].xy/sourceSize[0].xy/size)*float2(14./10.,-1.0);
#endif
float2 pc = uv*sourceSize[0].xy/sourceSize[0].xy*size*float2(10.,1.);
float alpha = dot(floor(float2(pc.x,pc.y)),float2(2.,Phase_Y*2.));
alpha += Phase_One*2.;
// 1/size.x of screen in uv coords = sourceSize[0].x/sourceSize[0].x/size.x;
// then 1/10*size.x of screen:
float ustep = sourceSize[0].x/sourceSize[0].x/size.x/10.;
float border = sourceSize[0].x/sourceSize[0].x;
float ss = 2.0;
#ifdef SWAP_VSIGN
#define PAL_SWITCH(A) A < 1.
#else
#define PAL_SWITCH(A) A > 1.
#endif
if (PAL_SWITCH(fmod(uv.y*sourceSize[0].y/sourceSize[0].y*size.y,2.0)))
{
// cos(pi-alpha) = -cos(alpha)
// sin(pi-alpha) = sin(alpha)
// pi - alpha
alpha = -alpha+12012.0;
ss = -2.0;
}
float ysum = 0., usum = 0., vsum = 0.;
for (int i=0; i<Mwidth; ++i)
{
float4 res = texture(tex, uv);
float3 yuv = mul(RGB_to_YUV, res.xyz);
float a1 = alpha+(HueShift+2.5)*2.-yuv.x*ss*HueRotation;
float sig = yuv.x+dot(yuv.yz,sign(float2(sinn(a1),coss(a1))));
#ifdef USE_DELAY_LINE
float4 res1 = texture(tex, uv+sh);
float3 yuv1 = mul(RGB_to_YUV, res1.xyz);
float a2 = (HueShift+2.5)*2.+12012.0-alpha+yuv.x*ss*HueRotation;
float sig1 = yuv1.x+dot(yuv1.yz,sign(float2(sinn(a2),coss(a2))));
#endif
if (i < Ywidth)
ysum += sig;
#ifdef USE_DELAY_LINE
if (i < Uwidth)
usum += (sig+sig1)*sinn(alpha);
if (i < Vwidth)
vsum += (sig-sig1)*coss(alpha);
#else
if (i < Uwidth)
usum += sig*sinn(alpha);
if (i < Vwidth)
vsum += sig*coss(alpha);
#endif
alpha -= ss;
uv.x -= ustep;
}
float3 rgb = mul(float3(ysum+Brightness*Ywidth_static,usum,vsum), YUV_to_RGB);
#if defined(USE_GAMMA) && !defined(USE_COLORIMETRY)
float3 rgb1 = saturate(rgb);
rgb = pow(rgb1, Gamma/2.2);
#endif
#ifdef USE_COLORIMETRY
float3 rgb1 = saturate(rgb);
rgb = pow(rgb1, float3(Gamma, Gamma, Gamma));
#endif
#if (defined(USE_SCANLINES))
float2 q = (p*sourceSize[0].xy/sourceSize[0].xy)*float2(TV_Pixels*3.,size.y*2.);
#endif
#ifdef USE_SCANLINES
float scanlines = size.y * outputSize.z;
float top = fmod(q.y-0.5*scanlines*2.,2.);
float bottom = top+frac(scanlines)*2.;
float2 sw = saturate(min(float2(1.,2.),float2(bottom, bottom))
-max(float2(0.,1.),float2(top)))
+saturate(min(float2(3.,4.),float2(bottom, bottom))
-max(float2(2.,3.),float2(top)))
+floor(scanlines);
rgb = rgb*SCANLINE_MUL/(sw.x+sw.y);
/*
//old stupid method
float z =
#ifdef ANIMATE_SCANLINE
fmod(phase,2.0)+
#endif
0.5;
if (abs(fmod(q.y+0.5,2)-z)<0.5)
rgb *= dark_scanline;
*/
#endif
// size of pixel screen in texture coords:
//float output_pixel_size = sourceSize[0].x/(outputSize.x*sourceSize[0].x);
// correctness check
//if (fmod(p.x*output_pixel_size,2.0) < 1.0)
// rgb = float3(0.,0.,0.);
#ifdef USE_COLORIMETRY
float3 xyz1 = mul(RGB_to_XYZ,rgb);
float3 srgb = saturate(mul(XYZ_to_sRGB,xyz1));
float3 a1 = 12.92*srgb;
float3 a2 = 1.055*pow(srgb,float3(1./2.4))-0.055;
float3 ssrgb;
ssrgb.x = (srgb.x<0.0031308?a1.x:a2.x);
ssrgb.y = (srgb.y<0.0031308?a1.y:a2.y);
ssrgb.z = (srgb.z<0.0031308?a1.z:a2.z);
return ssrgb;
#else
return rgb;
#endif
}
// pos (left corner, sample size)
float4 monitor_sample(sampler2D tex, float2 p, float2 sample_)
{
// linear interpolation was...
// now other thing.
// http://imgur.com/m8Z8trV
// AT LAST IT WORKS!!!!
// going to check in retroarch...
float2 size = sourceSize[0].xy;
float2 next = float2(.25,1.)/size;
float2 f = frac(float2(4.,1.)*size*p);
sample_ *= float2(4.,1.)*size;
float2 l;
float2 r;
if (f.x+sample_.x < 1.)
{
l.x = f.x+sample_.x;
r.x = 0.;
}
else
{
l.x = 1.-f.x;
r.x = min(1.,f.x+sample_.x-1.);
}
if (f.y+sample_.y < 1.)
{
l.y = f.y+sample_.y;
r.y = 0.;
}
else
{
l.y = 1.-f.y;
r.y = min(1.,f.y+sample_.y-1.);
}
float3 top = mix(monitor(tex, p), monitor(tex, p+float2(next.x,0.)), r.x/(l.x+r.x));
float3 bottom = mix(monitor(tex, p+float2(0.,next.y)), monitor(tex, p+next), r.x/(l.x+r.x));
return float4(mix(top,bottom, r.y/(l.y+r.y)),1.0);
}
void main() {
#ifdef USE_SAMPLED
fragColor = vec4(monitor_sample(source[0], texCoord, outputSize.zw).rgb, 1.0);
#else
fragColor = float4(monitor(source[0], texCoord), 1.);
#endif
}
@@ -0,0 +1,2 @@
program
fragment: phosphorish.fs
@@ -0,0 +1,56 @@
/* Phosphorish
Copyright (C) 2011 Themaister
This program is licensed in the public domain
*/
#version 150
uniform sampler2D source[];
uniform vec4 sourceSize[];
uniform vec4 targetSize;
in Vertex {
vec2 texCoord;
};
out vec4 fragColor;
vec3 to_focus(float pixel)
{
pixel = mod(pixel + 3.0, 3.0);
if (pixel >= 2.0) // Blue
return vec3(pixel - 2.0, 0.0, 3.0 - pixel);
else if (pixel >= 1.0) // Green
return vec3(0.0, 2.0 - pixel, pixel - 1.0);
else // Red
return vec3(1.0 - pixel, pixel, 0.0);
}
void main()
{
float y = mod(texCoord.y * sourceSize[0].y, 1.0);
float intensity = exp(-0.2 * y);
vec2 one_x = vec2(1.0 / (3.0 * sourceSize[0].x), 0.0);
vec3 color = texture(source[0], texCoord.xy - 0.0 * one_x).rgb;
vec3 color_prev = texture(source[0], texCoord.xy - 1.0 * one_x).rgb;
vec3 color_prev_prev = texture(source[0], texCoord.xy - 2.0 * one_x).rgb;
float pixel_x = 3.0 * texCoord.x * sourceSize[0].x;
vec3 focus = to_focus(pixel_x - 0.0);
vec3 focus_prev = to_focus(pixel_x - 1.0);
vec3 focus_prev_prev = to_focus(pixel_x - 2.0);
vec3 result =
0.8 * color * focus +
0.6 * color_prev * focus_prev +
0.3 * color_prev_prev * focus_prev_prev;
result = 2.3 * pow(result, vec3(1.4));
fragColor = vec4(intensity * result, 1.0);
}
@@ -0,0 +1,4 @@
program
filter: linear
wrap: border
fragment: scanline.fs
+20
View File
@@ -0,0 +1,20 @@
#version 150
uniform sampler2D source[];
in Vertex {
vec2 texCoord;
};
out vec4 fragColor;
void main() {
vec4 rgba = texture(source[0], texCoord);
vec4 intensity;
if(fract(gl_FragCoord.y * (0.5 * 4.0 / 3.0)) > 0.5) {
intensity = vec4(0);
} else {
intensity = smoothstep(0.2, 0.8, rgba) + normalize(rgba);
}
fragColor = intensity * -0.25 + rgba * 1.1;
}
@@ -0,0 +1,8 @@
input
filter: linear
program
fragment: sharp-bilinear.fs
output
filter: linear
@@ -0,0 +1,33 @@
#version 150
// Sharp Bilinear
// Author: Themaister
// License: Public Domain
uniform sampler2D source[];
uniform vec4 sourceSize[];
uniform vec4 targetSize;
in Vertex {
vec2 texCoord;
};
out vec4 fragColor;
void main() {
float prescale = floor(targetSize.y / sourceSize[0].y);
vec2 texel = texCoord.xy * sourceSize[0].xy;
vec2 texel_floored = floor(texel);
vec2 s = fract(texel);
float region_range = 0.5 - 0.5 / prescale;
// Figure out where in the texel to sample to get correct pre-scaled bilinear.
// Uses the hardware bilinear interpolator to avoid having to sample 4 times manually.
vec2 center_dist = s - 0.5;
vec2 f = (center_dist - clamp(center_dist, -region_range, region_range)) * prescale + 0.5;
vec2 mod_texel = texel_floored + f;
fragColor = texture(source[0], mod_texel / sourceSize[0].xy);;
}
Whitespace-only changes.
Whitespace-only changes.
Binary file not shown.
+2 -4
View File
@@ -1,5 +1,5 @@
database
revision: 2020-06-07
revision: 2020-11-09
//Boards (Production)
@@ -587,7 +587,7 @@ board: SHVC-YJ0N-01
//Boards (Generic)
database
revision: 2020-06-07
revision: 2020-11-09
board: ARM-LOROM-RAM
memory type=ROM content=Program
@@ -706,7 +706,6 @@ board: EXHIROM-RAM
map address=c0-ff:0000-ffff mask=0xc00000
memory type=RAM content=Save
map address=20-3f,a0-bf:6000-7fff mask=0xe000
map address=70-7d:0000-7fff
board: EXHIROM-RAM-SHARPRTC
memory type=ROM content=Program
@@ -716,7 +715,6 @@ board: EXHIROM-RAM-SHARPRTC
map address=c0-ff:0000-ffff mask=0xc00000
memory type=RAM content=Save
map address=20-3f,a0-bf:6000-7fff mask=0xe000
map address=70-7d:0000-7fff
rtc manufacturer=Sharp
map address=00-3f,80-bf:2800-2801
memory type=RTC content=Time manufacturer=Sharp
+27 -16
View File
@@ -13,12 +13,15 @@
#include <nall/endian.hpp>
#include <nall/image.hpp>
#include <nall/literals.hpp>
#include <nall/priority-queue.hpp>
#include <nall/queue.hpp>
#include <nall/random.hpp>
#include <nall/serializer.hpp>
#include <nall/set.hpp>
#include <nall/shared-pointer.hpp>
#include <nall/string.hpp>
#include <nall/terminal.hpp>
#include <nall/thread.hpp>
#include <nall/traits.hpp>
#include <nall/unique-pointer.hpp>
#include <nall/variant.hpp>
@@ -33,37 +36,45 @@
using namespace nall;
namespace ares {
static const string Name = "ares";
static const string Version = "124";
static const string Copyright = "ares team, Near";
static const string License = "ISC";
static const string LicenseURI = "https://opensource.org/licenses/ISC";
static const string Website = "ares-emulator.github.io";
static const string WebsiteURI = "https://ares-emulator.github.io";
//incremented only when serialization format changes
static const u32 SerializerSignature = 0x31545342; //"BST1" (little-endian)
static const string SerializerVersion = "123.1";
namespace VFS {
using Pak = shared_pointer<vfs::directory>;
using File = shared_pointer<vfs::file>;
}
namespace Video {
static constexpr bool Threaded = true;
}
namespace Constants {
namespace Colorburst {
static constexpr double NTSC = 315.0 / 88.0 * 1'000'000.0;
static constexpr double PAL = 283.75 * 15'625.0 + 25.0;
static constexpr f64 NTSC = 315.0 / 88.0 * 1'000'000.0;
static constexpr f64 PAL = 283.75 * 15'625.0 + 25.0;
}
}
//nall/vfs shorthand constants
namespace File {
static const auto Read = vfs::file::mode::read;
static const auto Write = vfs::file::mode::write;
static const auto Optional = false;
static const auto Required = true;
}
namespace Shared {
using File = shared_pointer<vfs::file>;
}
extern bool _runAhead;
inline auto runAhead() -> bool { return _runAhead; }
inline auto setRunAhead(bool runAhead) -> void { _runAhead = runAhead; }
}
#include <ares/information.hpp>
#include <ares/types.hpp>
#include <ares/random.hpp>
#include <ares/debug/debug.hpp>
#include <ares/node/node.hpp>
#include <ares/platform.hpp>
#include <ares/interface.hpp>
#include <ares/memory/fixed-allocator.hpp>
#include <ares/memory/readable.hpp>
#include <ares/memory/writable.hpp>
#include <ares/resource/resource.hpp>
+29 -1
View File
@@ -3,15 +3,43 @@ namespace ares {
Debug _debug;
auto Debug::reset() -> void {
_totalNotices = 0;
_unhandledNotices.reset();
_unimplementedNotices.reset();
_unusualNotices.reset();
_unverifiedNotices.reset();
}
auto Debug::_unhandled(const string& text) -> void {
if(_unhandledNotices.find(text)) return;
if(_totalNotices++ > 256) return;
_unhandledNotices.append(text);
print(terminal::color::yellow("[unhandled] "), text, "\n");
}
auto Debug::_unimplemented(const string& text) -> void {
//only warn about missing unimplemented functionality once per type
if(_unimplementedNotices.find(text)) return;
if(_totalNotices++ > 256) return;
_unimplementedNotices.append(text);
print(terminal::color::magenta("[unimplemented] "), text, "\n");
}
auto Debug::_unusual(const string& text) -> void {
if(_unusualNotices.find(text)) return;
if(_totalNotices++ > 256) return;
_unusualNotices.append(text);
print(terminal::color::cyan("[unusual] "), text, "\n");
}
auto Debug::_unverified(const string& text) -> void {
if(_unverifiedNotices.find(text)) return;
if(_totalNotices++ > 256) return;
_unverifiedNotices.append(text);
print(terminal::color::gray("[unverified] "), text, "\n");
}
}
+22 -5
View File
@@ -1,22 +1,39 @@
namespace ares {
struct Debug {
static constexpr bool enabled = true;
auto reset() -> void;
template<typename... P> auto unhandled(P&&... p) -> void {
return _unhandled({forward<P>(p)...});
}
template<typename... P> auto unimplemented(P&&... p) -> void {
return _unimplemented({forward<P>(p)...});
}
private:
auto _unimplemented(const string&) -> void;
template<typename... P> auto unusual(P&&... p) -> void {
return _unusual({forward<P>(p)...});
}
template<typename... P> auto unverified(P&&... p) -> void {
return _unverified({forward<P>(p)...});
}
private:
auto _unhandled(const string&) -> void;
auto _unimplemented(const string&) -> void;
auto _unusual(const string&) -> void;
auto _unverified(const string&) -> void;
u64 _totalNotices = 0;
vector<string> _unhandledNotices;
vector<string> _unimplementedNotices;
vector<string> _unusualNotices;
vector<string> _unverifiedNotices;
};
extern Debug _debug;
}
#define debug(function, ...) if constexpr(ares::_debug.enabled) ares::_debug.function(__VA_ARGS__)
#define debug(function, ...) if constexpr(1) ares::_debug.function(__VA_ARGS__)
-14
View File
@@ -1,14 +0,0 @@
#pragma once
namespace ares {
static const string Name = "ares";
static const string Version = "115";
static const string Copyright = "ares team";
static const string License = "ISC";
static const string LicenseURI = "https://opensource.org/licenses/ISC";
static const string Website = "ares.dev";
static const string WebsiteURI = "https://ares.dev";
//incremented only when serialization format changes
static const string SerializerVersion = "115";
}
-28
View File
@@ -1,28 +0,0 @@
#pragma once
namespace ares {
struct Interface {
virtual ~Interface() = default;
//information
virtual auto name() -> string { return {}; }
virtual auto game() -> string { return {}; }
//system interface
virtual auto root() -> Node::Object { return {}; }
virtual auto load(Node::Object&) -> void {}
virtual auto power() -> void {}
virtual auto run() -> void {}
virtual auto save() -> void {}
virtual auto unload() -> void {}
//state functions
virtual auto serialize(bool synchronize = true) -> serializer { return {}; }
virtual auto unserialize(serializer&) -> bool { return false; }
//debugging functions
virtual auto exportMemory() -> bool { return false; }
};
}
+16
View File
@@ -0,0 +1,16 @@
#include <ares/ares.hpp>
namespace ares::Memory {
alignas(4096) u8 fixedBuffer[1_GiB];
FixedAllocator::FixedAllocator() {
_allocator.resize(sizeof(fixedBuffer), 0, fixedBuffer);
}
auto FixedAllocator::get() -> bump_allocator& {
static FixedAllocator allocator;
return allocator._allocator;
}
}
+14
View File
@@ -0,0 +1,14 @@
#pragma once
namespace ares::Memory {
struct FixedAllocator {
static auto get() -> bump_allocator&;
private:
FixedAllocator();
bump_allocator _allocator;
};
}
+5 -5
View File
@@ -2,10 +2,10 @@
namespace ares::Memory {
inline auto mirror(uint address, uint size) -> uint {
inline auto mirror(u32 address, u32 size) -> u32 {
if(size == 0) return 0;
uint base = 0;
uint mask = 1 << 31;
u32 base = 0;
u32 mask = 1 << 31;
while(address >= size) {
while(!(address & mask)) mask >>= 1;
address -= mask;
@@ -18,9 +18,9 @@ inline auto mirror(uint address, uint size) -> uint {
return base + address;
}
inline auto reduce(uint address, uint mask) -> uint {
inline auto reduce(u32 address, u32 mask) -> u32 {
while(mask) {
uint bits = (mask & -mask) - 1;
u32 bits = (mask & -mask) - 1;
address = address >> 1 & ~bits | address & bits;
mask = (mask & mask - 1) >> 1;
}
+18 -23
View File
@@ -15,7 +15,7 @@ struct Readable {
self.mask = 0;
}
auto allocate(uint size, T fill = ~0ull) -> void {
auto allocate(u32 size, T fill = (T)~0ull) -> void {
if(!size) return reset();
delete[] self.data;
self.size = size;
@@ -25,33 +25,32 @@ struct Readable {
}
auto fill(T fill = ~0ull) -> void {
for(uint address : range(self.size)) {
for(u32 address : range(self.size)) {
self.data[address] = fill;
}
}
auto load(shared_pointer<vfs::file> fp) -> void {
if(!self.size) return;
fp->read(self.data, min(fp->size(), self.size * sizeof(T)));
for(uint address = self.size; address <= self.mask; address++) {
auto load(VFS::File fp) -> void {
if(!self.size) allocate(fp->size());
fp->read({self.data, min(fp->size(), self.size * sizeof(T))});
for(u32 address = self.size; address <= self.mask; address++) {
self.data[address] = self.data[mirror(address, self.size)];
}
}
auto save(shared_pointer<vfs::file> fp) -> void {
if(!self.size) return;
fp->write(self.data, self.size * sizeof(T));
auto save(VFS::File fp) -> void {
fp->write({self.data, min(fp->size(), self.size * sizeof(T))});
}
explicit operator bool() const { return (bool)self.data; }
auto data() const -> const T* { return self.data; }
auto size() const -> uint { return self.size; }
auto mask() const -> uint { return self.mask; }
auto size() const -> u32 { return self.size; }
auto mask() const -> u32 { return self.mask; }
auto operator[](uint address) const -> T { return self.data[address & self.mask]; }
auto read(uint address) const -> T { return self.data[address & self.mask]; }
auto write(uint address, T data) const -> void {}
auto program(uint address, T data) const -> void { self.data[address & self.mask] = data; }
auto operator[](u32 address) const -> T { return self.data[address & self.mask]; }
auto read(u32 address) const -> T { return self.data[address & self.mask]; }
auto write(u32 address, T data) const -> void {}
auto program(u32 address, T data) const -> void { self.data[address & self.mask] = data; }
auto begin() -> T* { return &self.data[0]; }
auto end() -> T* { return &self.data[self.size]; }
@@ -60,18 +59,14 @@ struct Readable {
auto end() const -> const T* { return &self.data[self.size]; }
auto serialize(serializer& s) -> void {
const uint size = self.size;
s.integer(self.size);
s.integer(self.mask);
if(self.size != size) allocate(self.size);
s.array(self.data, self.size);
s(array_span<T>{self.data, self.size});
}
private:
//private:
struct {
T* data = nullptr;
uint size = 0;
uint mask = 0;
u32 size = 0;
u32 mask = 0;
} self;
};
+18 -23
View File
@@ -15,7 +15,7 @@ struct Writable {
self.mask = 0;
}
auto allocate(uint size, T fill = ~0ull) -> void {
auto allocate(u32 size, T fill = (T)~0ull) -> void {
if(!size) return reset();
delete[] self.data;
self.size = size;
@@ -25,35 +25,34 @@ struct Writable {
}
auto fill(T fill = ~0ull) -> void {
for(uint address : range(self.size)) {
for(u32 address : range(self.size)) {
self.data[address] = fill;
}
}
auto load(shared_pointer<vfs::file> fp) -> void {
if(!self.size) return;
fp->read(self.data, min(fp->size(), self.size * sizeof(T)));
for(uint address = self.size; address <= self.mask; address++) {
auto load(VFS::File fp) -> void {
if(!self.size) allocate(fp->size());
fp->read({self.data, min(fp->size(), self.size * sizeof(T))});
for(u32 address = self.size; address <= self.mask; address++) {
self.data[address] = self.data[mirror(address, self.size)];
}
}
auto save(shared_pointer<vfs::file> fp) -> void {
if(!self.size) return;
fp->write(self.data, self.size * sizeof(T));
auto save(VFS::File fp) -> void {
fp->write({self.data, min(fp->size(), self.size * sizeof(T))});
}
explicit operator bool() const { return (bool)self.data; }
auto data() -> T* { return self.data; }
auto data() const -> const T* { return self.data; }
auto size() const -> uint { return self.size; }
auto mask() const -> uint { return self.mask; }
auto size() const -> u32 { return self.size; }
auto mask() const -> u32 { return self.mask; }
auto operator[](uint address) -> T& { return self.data[address & self.mask]; }
auto operator[](uint address) const -> T { return self.data[address & self.mask]; }
auto read(uint address) const -> T { return self.data[address & self.mask]; }
auto write(uint address, T data) -> void { self.data[address & self.mask] = data; }
auto program(uint address, T data) -> void { self.data[address & self.mask] = data; }
auto operator[](u32 address) -> T& { return self.data[address & self.mask]; }
auto operator[](u32 address) const -> T { return self.data[address & self.mask]; }
auto read(u32 address) const -> T { return self.data[address & self.mask]; }
auto write(u32 address, T data) -> void { self.data[address & self.mask] = data; }
auto program(u32 address, T data) -> void { self.data[address & self.mask] = data; }
auto begin() -> T* { return &self.data[0]; }
auto end() -> T* { return &self.data[self.size]; }
@@ -62,18 +61,14 @@ struct Writable {
auto end() const -> const T* { return &self.data[self.size]; }
auto serialize(serializer& s) -> void {
const uint size = self.size;
s.integer(self.size);
s.integer(self.mask);
if(self.size != size) allocate(self.size);
s.array(self.data, self.size);
s(array_span<T>{self.data, self.size});
}
private:
struct {
T* data = nullptr;
uint size = 0;
uint mask = 0;
u32 size = 0;
u32 mask = 0;
} self;
};
+4
View File
@@ -0,0 +1,4 @@
struct Audio : Object {
DeclareClass(Audio, "audio")
using Object::Object;
};
+24 -22
View File
@@ -1,14 +1,14 @@
auto Stream::setChannels(uint channels) -> void {
auto Stream::setChannels(u32 channels) -> void {
_channels.reset();
_channels.resize(channels);
}
auto Stream::setFrequency(double frequency) -> void {
auto Stream::setFrequency(f64 frequency) -> void {
_frequency = frequency;
setResamplerFrequency(_resamplerFrequency);
}
auto Stream::setResamplerFrequency(double resamplerFrequency) -> void {
auto Stream::setResamplerFrequency(f64 resamplerFrequency) -> void {
_resamplerFrequency = resamplerFrequency;
for(auto& channel : _channels) {
@@ -18,12 +18,12 @@ auto Stream::setResamplerFrequency(double resamplerFrequency) -> void {
if(_frequency >= _resamplerFrequency * 2) {
//add a low-pass filter to prevent aliasing during resampling
double cutoffFrequency = min(25000.0, _resamplerFrequency / 2.0 - 2000.0);
f64 cutoffFrequency = min(25000.0, _resamplerFrequency / 2.0 - 2000.0);
for(auto& channel : _channels) {
uint passes = 3;
for(uint pass : range(passes)) {
u32 passes = 3;
for(u32 pass : range(passes)) {
DSP::IIR::Biquad filter;
double q = DSP::IIR::Biquad::butterworth(passes * 2, pass);
f64 q = DSP::IIR::Biquad::butterworth(passes * 2, pass);
filter.reset(DSP::IIR::Biquad::Type::LowPass, cutoffFrequency, _frequency, q);
channel.nyquist.append(filter);
}
@@ -41,9 +41,9 @@ auto Stream::resetFilters() -> void {
}
}
auto Stream::addLowPassFilter(double cutoffFrequency, uint order, uint passes) -> void {
auto Stream::addLowPassFilter(f64 cutoffFrequency, u32 order, u32 passes) -> void {
for(auto& channel : _channels) {
for(uint pass : range(passes)) {
for(u32 pass : range(passes)) {
if(order == 1) {
Filter filter{Filter::Mode::OnePole, Filter::Type::LowPass, Filter::Order::First};
filter.onePole.reset(DSP::IIR::OnePole::Type::LowPass, cutoffFrequency, _frequency);
@@ -51,7 +51,7 @@ auto Stream::addLowPassFilter(double cutoffFrequency, uint order, uint passes) -
}
if(order == 2) {
Filter filter{Filter::Mode::Biquad, Filter::Type::LowPass, Filter::Order::Second};
double q = DSP::IIR::Biquad::butterworth(passes * 2, pass);
f64 q = DSP::IIR::Biquad::butterworth(passes * 2, pass);
filter.biquad.reset(DSP::IIR::Biquad::Type::LowPass, cutoffFrequency, _frequency, q);
channel.filters.append(filter);
}
@@ -59,9 +59,9 @@ auto Stream::addLowPassFilter(double cutoffFrequency, uint order, uint passes) -
}
}
auto Stream::addHighPassFilter(double cutoffFrequency, uint order, uint passes) -> void {
auto Stream::addHighPassFilter(f64 cutoffFrequency, u32 order, u32 passes) -> void {
for(auto& channel : _channels) {
for(uint pass : range(passes)) {
for(u32 pass : range(passes)) {
if(order == 1) {
Filter filter{Filter::Mode::OnePole, Filter::Type::HighPass, Filter::Order::First};
filter.onePole.reset(DSP::IIR::OnePole::Type::HighPass, cutoffFrequency, _frequency);
@@ -69,7 +69,7 @@ auto Stream::addHighPassFilter(double cutoffFrequency, uint order, uint passes)
}
if(order == 2) {
Filter filter{Filter::Mode::Biquad, Filter::Type::HighPass, Filter::Order::Second};
double q = DSP::IIR::Biquad::butterworth(passes * 2, pass);
f64 q = DSP::IIR::Biquad::butterworth(passes * 2, pass);
filter.biquad.reset(DSP::IIR::Biquad::Type::HighPass, cutoffFrequency, _frequency, q);
channel.filters.append(filter);
}
@@ -77,22 +77,22 @@ auto Stream::addHighPassFilter(double cutoffFrequency, uint order, uint passes)
}
}
auto Stream::addLowShelfFilter(double cutoffFrequency, uint order, double gain, double slope) -> void {
auto Stream::addLowShelfFilter(f64 cutoffFrequency, u32 order, f64 gain, f64 slope) -> void {
for(auto& channel : _channels) {
if(order == 2) {
Filter filter{Filter::Mode::Biquad, Filter::Type::LowShelf, Filter::Order::Second};
double q = DSP::IIR::Biquad::shelf(gain, slope);
f64 q = DSP::IIR::Biquad::shelf(gain, slope);
filter.biquad.reset(DSP::IIR::Biquad::Type::LowShelf, cutoffFrequency, _frequency, q);
channel.filters.append(filter);
}
}
}
auto Stream::addHighShelfFilter(double cutoffFrequency, uint order, double gain, double slope) -> void {
auto Stream::addHighShelfFilter(f64 cutoffFrequency, u32 order, f64 gain, f64 slope) -> void {
for(auto& channel : _channels) {
if(order == 2) {
Filter filter{Filter::Mode::Biquad, Filter::Type::HighShelf, Filter::Order::Second};
double q = DSP::IIR::Biquad::shelf(gain, slope);
f64 q = DSP::IIR::Biquad::shelf(gain, slope);
filter.biquad.reset(DSP::IIR::Biquad::Type::HighShelf, cutoffFrequency, _frequency, q);
channel.filters.append(filter);
}
@@ -103,14 +103,16 @@ auto Stream::pending() const -> bool {
return _channels && _channels[0].resampler.pending();
}
auto Stream::read(double samples[]) -> uint {
for(uint c : range(_channels.size())) samples[c] = _channels[c].resampler.read() * !muted();
auto Stream::read(f64 samples[]) -> u32 {
for(u32 c : range(_channels.size())) {
samples[c] = _channels[c].resampler.read() * !muted();
}
return _channels.size();
}
auto Stream::write(const double samples[]) -> void {
for(uint c : range(_channels.size())) {
double sample = samples[c] + 1e-25; //constant offset used to suppress denormals
auto Stream::write(const f64 samples[]) -> void {
for(u32 c : range(_channels.size())) {
f64 sample = samples[c] + 1e-25; //constant offset used to suppress denormals
for(auto& filter : _channels[c].filters) {
switch(filter.mode) {
case Filter::Mode::OnePole: sample = filter.onePole.process(sample); break;
+22 -22
View File
@@ -1,39 +1,39 @@
struct Stream : Object {
DeclareClass(Stream, "Stream")
using Object::Object;
struct Stream : Audio {
DeclareClass(Stream, "audio.stream")
using Audio::Audio;
auto channels() const -> uint { return _channels.size(); }
auto frequency() const -> double { return _frequency; }
auto resamplerFrequency() const -> double { return _resamplerFrequency; }
auto channels() const -> u32 { return _channels.size(); }
auto frequency() const -> f64 { return _frequency; }
auto resamplerFrequency() const -> f64 { return _resamplerFrequency; }
auto muted() const -> bool { return _muted; }
auto setChannels(uint channels) -> void;
auto setFrequency(double frequency) -> void;
auto setResamplerFrequency(double resamplerFrequency) -> void;
auto setChannels(u32 channels) -> void;
auto setFrequency(f64 frequency) -> void;
auto setResamplerFrequency(f64 resamplerFrequency) -> void;
auto setMuted(bool muted) -> void;
auto resetFilters() -> void;
auto addLowPassFilter(double cutoffFrequency, uint order, uint passes = 1) -> void;
auto addHighPassFilter(double cutoffFrequency, uint order, uint passes = 1) -> void;
auto addLowShelfFilter(double cutoffFrequency, uint order, double gain, double slope) -> void;
auto addHighShelfFilter(double cutoffFrequency, uint order, double gain, double slope) -> void;
auto addLowPassFilter(f64 cutoffFrequency, u32 order, u32 passes = 1) -> void;
auto addHighPassFilter(f64 cutoffFrequency, u32 order, u32 passes = 1) -> void;
auto addLowShelfFilter(f64 cutoffFrequency, u32 order, f64 gain, f64 slope) -> void;
auto addHighShelfFilter(f64 cutoffFrequency, u32 order, f64 gain, f64 slope) -> void;
auto pending() const -> bool;
auto read(double samples[]) -> uint;
auto write(const double samples[]) -> void;
auto read(f64 samples[]) -> u32;
auto write(const f64 samples[]) -> void;
template<typename... P>
auto sample(P&&... p) -> void {
auto frame(P&&... p) -> void {
if(runAhead()) return;
double samples[sizeof...(p)] = {forward<P>(p)...};
f64 samples[sizeof...(p)] = {forward<P>(p)...};
write(samples);
}
protected:
struct Filter {
enum class Mode : uint { OnePole, Biquad } mode;
enum class Type : uint { None, LowPass, HighPass, LowShelf, HighShelf } type;
enum class Order : uint { None, First, Second } order;
enum class Mode : u32 { OnePole, Biquad } mode;
enum class Type : u32 { None, LowPass, HighPass, LowShelf, HighShelf } type;
enum class Order : u32 { None, First, Second } order;
DSP::IIR::OnePole onePole;
DSP::IIR::Biquad biquad;
};
@@ -43,7 +43,7 @@ protected:
DSP::Resampler::Cubic resampler;
};
vector<Channel> _channels;
double _frequency = 48000.0;
double _resamplerFrequency = 48000.0;
f64 _frequency = 48000.0;
f64 _resamplerFrequency = 48000.0;
bool _muted = false;
};
+2 -2
View File
@@ -13,8 +13,8 @@ struct Class {
}
template<typename T> static auto register() -> void {
if(!classes().find([&](auto instance) { return instance.identifier == T::identifier; })) {
classes().append({T::identifier, &T::create});
if(!classes().find([&](auto instance) { return instance.identifier == T::identifier(); })) {
classes().append({T::identifier(), &T::create});
} else {
throw;
}
@@ -1,4 +1,4 @@
struct Component : Object {
DeclareClass(Component, "Component")
DeclareClass(Component, "component");
using Object::Object;
};
@@ -0,0 +1,30 @@
struct RealTimeClock : Component {
DeclareClass(RealTimeClock, "component.real-time-clock")
using Component::Component;
auto update() -> void { if(_update) return _update(); }
auto timestamp() const -> u64 { return _timestamp; }
auto setUpdate(function<void ()> update) -> void { _update = update; }
auto setTimestamp(u64 timestamp) -> void { _timestamp = timestamp; }
auto synchronize(u64 timestamp = 0) -> void {
if(!timestamp) timestamp = chrono::timestamp();
_timestamp = timestamp;
update();
}
auto serialize(string& output, string depth) -> void override {
Component::serialize(output, depth);
output.append(depth, " timestamp: ", _timestamp, "\n");
}
auto unserialize(Markup::Node node) -> void override {
Component::unserialize(node);
_timestamp = node["timestamp"].natural();
}
protected:
function<void ()> _update;
u64 _timestamp;
};
-26
View File
@@ -1,26 +0,0 @@
struct Graphics : Object {
DeclareClass(Graphics, "Graphics")
Graphics(string name = {}) : Object(name) {
}
auto width() const -> uint { return _width; }
auto height() const -> uint { return _height; }
auto capture() const -> vector<uint32_t> { if(_capture) return _capture(); return {}; }
auto setSize(uint width, uint height) -> void { _width = width, _height = height; }
auto setCapture(function<vector<uint32_t> ()> capture) -> void { _capture = capture; }
auto serialize(string& output, string depth) -> void override {
Object::serialize(output, depth);
}
auto unserialize(Markup::Node node) -> void override {
Object::unserialize(node);
}
protected:
uint _width = 0;
uint _height = 0;
function<vector<uint32_t> ()> _capture;
};
-83
View File
@@ -1,83 +0,0 @@
struct Instruction : Tracer {
DeclareClass(Instruction, "Instruction")
Instruction(string name = {}, string component = {}) : Tracer(name, component) {
setDepth(_depth);
}
auto depth() const -> uint { return _depth; }
auto addressBits() const -> uint { return _addressBits; }
auto setDepth(uint depth) -> void {
_depth = depth;
_history.reset();
_history.resize(depth);
for(auto& history : _history) history = ~0ull;
}
auto setAddressBits(uint addressBits) -> void {
_addressBits = addressBits;
}
auto address(uint64 address) -> bool {
_address = address;
if(!_depth) return false;
for(auto history : _history) {
if(address == history) {
_omitted++;
return false;
}
}
for(auto index : range(_depth - 1)) {
_history[index] = _history[index + 1];
}
_history.last() = _address;
return true;
}
auto notify(string_view instruction, string_view context, string_view extra = {}) -> void {
if(!enabled()) return;
if(_omitted) {
PlatformLog({
//_component, " ",
"[Omitted: ", _omitted, "]\n"}
);
_omitted = 0;
}
string output{
//_component, " ",
hex(_address, _addressBits + 3 >> 2), " ",
instruction, " ",
context, " ",
extra
};
PlatformLog({output.strip(), "\n"});
}
auto serialize(string& output, string depth) -> void override {
Tracer::serialize(output, depth);
output.append(depth, " depth: ", _depth, "\n");
output.append(depth, " addressBits: ", _addressBits, "\n");
}
auto unserialize(Markup::Node node) -> void override {
Tracer::unserialize(node);
_depth = node["depth"].natural();
_addressBits = node["addressBits"].natural();
setDepth(_depth);
}
protected:
uint _depth = 4;
uint _addressBits = 0;
uint64 _address = 0;
uint64 _omitted = 0;
vector<uint64> _history;
};
-27
View File
@@ -1,27 +0,0 @@
struct Memory : Object {
DeclareClass(Memory, "Memory")
Memory(string name = {}) : Object(name) {
}
auto size() const -> uint { return _size; }
auto read(uint32 address) const -> uint8 { if(_read) return _read(address); return 0; }
auto write(uint32 address, uint8 data) const -> void { if(_write) return _write(address, data); }
auto setSize(uint size) -> void { _size = size; }
auto setRead(function<uint8 (uint32)> read) -> void { _read = read; }
auto setWrite(function<void (uint32, uint8)> write) -> void { _write = write; }
auto serialize(string& output, string depth) -> void override {
Object::serialize(output, depth);
}
auto unserialize(Markup::Node node) -> void override {
Object::unserialize(node);
}
protected:
uint _size = 0;
function<uint8 (uint32)> _read;
function<void (uint32, uint8)> _write;
};
-18
View File
@@ -1,18 +0,0 @@
struct Notification : Tracer {
DeclareClass(Notification, "Notification")
Notification(string name = {}, string component = {}) : Tracer(name, component) {
}
auto notify(string_view message = {}) -> void {
if(!enabled()) return;
if(message) {
PlatformLog({_component, " [", _name, ": ", message, "]\n"});
} else {
PlatformLog({_component, " [", _name, "]\n"});
}
}
protected:
};
+4
View File
@@ -0,0 +1,4 @@
struct Debugger : Object {
DeclareClass(Debugger, "debugger")
using Object::Object;
};
+26
View File
@@ -0,0 +1,26 @@
struct Graphics : Debugger {
DeclareClass(Graphics, "debugger.graphics")
Graphics(string name = {}) : Debugger(name) {
}
auto width() const -> u32 { return _width; }
auto height() const -> u32 { return _height; }
auto capture() const -> vector<u32> { if(_capture) return _capture(); return {}; }
auto setSize(u32 width, u32 height) -> void { _width = width, _height = height; }
auto setCapture(function<vector<u32> ()> capture) -> void { _capture = capture; }
auto serialize(string& output, string depth) -> void override {
Debugger::serialize(output, depth);
}
auto unserialize(Markup::Node node) -> void override {
Debugger::unserialize(node);
}
protected:
u32 _width = 0;
u32 _height = 0;
function<vector<u32> ()> _capture;
};
+27
View File
@@ -0,0 +1,27 @@
struct Memory : Debugger {
DeclareClass(Memory, "debugger.memory")
Memory(string name = {}) : Debugger(name) {
}
auto size() const -> u32 { return _size; }
auto read(u32 address) const -> n8 { if(_read) return _read(address); return 0; }
auto write(u32 address, u8 data) const -> void { if(_write) return _write(address, data); }
auto setSize(u32 size) -> void { _size = size; }
auto setRead(function<u8 (u32)> read) -> void { _read = read; }
auto setWrite(function<void (u32, u8)> write) -> void { _write = write; }
auto serialize(string& output, string depth) -> void override {
Debugger::serialize(output, depth);
}
auto unserialize(Markup::Node node) -> void override {
Debugger::unserialize(node);
}
protected:
u32 _size = 0;
function<u8 (u32)> _read;
function<void (u32, u8)> _write;
};
@@ -1,7 +1,7 @@
struct Properties : Object {
DeclareClass(Properties, "Properties")
struct Properties : Debugger {
DeclareClass(Properties, "debugger.properties")
Properties(string name = {}) : Object(name) {
Properties(string name = {}) : Debugger(name) {
}
auto query() const -> string { if(_query) return _query(); return {}; }
@@ -9,11 +9,11 @@ struct Properties : Object {
auto setQuery(function<string ()> query) -> void { _query = query; }
auto serialize(string& output, string depth) -> void override {
Object::serialize(output, depth);
Debugger::serialize(output, depth);
}
auto unserialize(Markup::Node node) -> void override {
Object::unserialize(node);
Debugger::unserialize(node);
}
protected:
@@ -0,0 +1,125 @@
struct Instruction : Tracer {
DeclareClass(Instruction, "debugger.tracer.instruction")
Instruction(string name = {}, string component = {}) : Tracer(name, component) {
setMask(_mask);
setDepth(_depth);
}
auto addressBits() const -> u32 { return _addressBits; }
auto addressMask() const -> u32 { return _addressMask; }
auto mask() const -> bool { return _mask; }
auto depth() const -> u32 { return _depth; }
auto setAddressBits(u32 addressBits, u32 addressMask = 0) -> void {
_addressBits = addressBits;
_addressMask = addressMask;
}
auto setMask(bool mask) -> void {
_mask = mask;
}
auto setDepth(u32 depth) -> void {
_depth = depth;
_history.reset();
_history.resize(depth);
for(auto& history : _history) history = ~0;
}
auto address(u32 address) -> bool {
address &= (1ull << _addressBits) - 1; //mask upper bits of address
_address = address;
address >>= _addressMask; //clip unneeded alignment bits (to reduce _masks size)
if(_mask && updateMasks()) {
if(_masks[address >> 3] & 1 << (address & 7)) return false; //do not trace twice
_masks[address >> 3] |= 1 << (address & 7);
}
if(_depth) {
for(auto history : _history) {
if(_address == history) {
_omitted++;
return false; //do not trace again if recently traced
}
}
for(auto index : range(_depth - 1)) {
_history[index] = _history[index + 1];
}
_history.last() = _address;
}
return true;
}
//mark an already-executed address as not executed yet for trace masking.
//call when writing to executable RAM to support self-modifying code.
auto invalidate(u32 address) -> void {
if(unlikely(_mask && updateMasks())) {
address &= (1ull << _addressBits) - 1;
address >>= _addressMask;
_masks[address >> 3] &= ~(1 << (address & 7));
}
}
auto notify(const string& instruction, const string& context, const string& extra = {}) -> void {
if(!enabled()) return;
if(_omitted) {
PlatformLog({
"[Omitted: ", _omitted, "]\n"}
);
_omitted = 0;
}
string output{
_component, " ",
hex(_address, _addressBits + 3 >> 2), " ",
instruction, " ",
context, " ",
extra
};
PlatformLog({output.strip(), "\n"});
}
auto serialize(string& output, string depth) -> void override {
Tracer::serialize(output, depth);
output.append(depth, " addressBits: ", _addressBits, "\n");
output.append(depth, " addressMask: ", _addressMask, "\n");
output.append(depth, " mask: ", _mask, "\n");
output.append(depth, " depth: ", _depth, "\n");
}
auto unserialize(Markup::Node node) -> void override {
Tracer::unserialize(node);
_addressBits = node["addressBits"].natural();
_addressMask = node["addressMask"].natural();
_mask = node["mask"].boolean();
_depth = node["depth"].natural();
setMask(_mask);
setDepth(_depth);
}
protected:
auto updateMasks() -> bool {
auto size = 1ull << _addressBits >> _addressMask >> 3;
if(!_mask || !size) return _masks.reset(), false;
if(_masks.size() == size) return true;
_masks.reset();
_masks.resize(size);
return true;
}
u32 _addressBits = 32;
u32 _addressMask = 0;
bool _mask = false;
u32 _depth = 4;
//unserialized:
n64 _address = 0;
n64 _omitted = 0;
vector<u32> _history;
vector<u08> _masks;
};
@@ -0,0 +1,18 @@
struct Notification : Tracer {
DeclareClass(Notification, "debugger.tracer.notification")
Notification(string name = {}, string component = {}) : Tracer(name, component) {
}
auto notify(const string& message = {}) -> void {
if(!enabled()) return;
if(message) {
PlatformLog({_component, " ", _name, ": ", message, "\n"});
} else {
PlatformLog({_component, " ", _name, "\n"});
}
}
protected:
};
@@ -1,7 +1,7 @@
struct Tracer : Object {
DeclareClass(Tracer, "Tracer")
struct Tracer : Debugger {
DeclareClass(Tracer, "debugger.tracer")
Tracer(string name = {}, string component = {}) : Object(name) {
Tracer(string name = {}, string component = {}) : Debugger(name) {
_component = component;
}
@@ -12,13 +12,13 @@ struct Tracer : Object {
auto setEnabled(bool enabled) -> void { _enabled = enabled; }
auto serialize(string& output, string depth) -> void override {
Object::serialize(output, depth);
Debugger::serialize(output, depth);
output.append(depth, " component: ", _component, "\n");
output.append(depth, " enabled: ", _enabled, "\n");
}
auto unserialize(Markup::Node node) -> void override {
Object::unserialize(node);
Debugger::unserialize(node);
_component = node["component"].string();
_enabled = node["enabled"].boolean();
}
-52
View File
@@ -1,52 +0,0 @@
struct Input : Object {
DeclareClass(Input, "Input")
using Object::Object;
};
struct Button : Input {
DeclareClass(Button, "Button")
using Input::Input;
auto value() const -> boolean { return _value; }
auto setValue(boolean value) -> void { _value = value; }
protected:
boolean _value;
};
struct Axis : Input {
DeclareClass(Axis, "Axis")
using Input::Input;
auto value() const -> integer { return _value; }
auto setValue(integer value) -> void { _value = value; }
protected:
integer _value;
integer _minimum = -32768;
integer _maximum = +32767;
};
struct Trigger : Input {
DeclareClass(Trigger, "Trigger")
using Input::Input;
auto value() const -> integer { return _value; }
auto setValue(integer value) -> void { _value = value; }
protected:
integer _value;
integer _minimum = 0;
integer _maximum = +32767;
};
struct Rumble : Input {
DeclareClass(Rumble, "Rumble")
using Input::Input;
auto enable() const -> boolean { return _enable; }
auto setEnable(boolean enable) -> void { _enable = enable; }
protected:
boolean _enable;
};
+12
View File
@@ -0,0 +1,12 @@
struct Axis : Input {
DeclareClass(Axis, "input.axis")
using Input::Input;
auto value() const -> s64 { return _value; }
auto setValue(s64 value) -> void { _value = value; }
protected:
s64 _value = 0;
s64 _minimum = -32768;
s64 _maximum = +32767;
};
+10
View File
@@ -0,0 +1,10 @@
struct Button : Input {
DeclareClass(Button, "input.button")
using Input::Input;
auto value() const -> bool { return _value; }
auto setValue(bool value) -> void { _value = value; }
protected:
bool _value = 0;
};
+4
View File
@@ -0,0 +1,4 @@
struct Input : Object {
DeclareClass(Input, "input")
using Object::Object;
};
+10
View File
@@ -0,0 +1,10 @@
struct Rumble : Input {
DeclareClass(Rumble, "input.rumble")
using Input::Input;
auto enable() const -> bool { return _enable; }
auto setEnable(bool enable) -> void { _enable = enable; }
protected:
bool _enable = 0;
};
+12
View File
@@ -0,0 +1,12 @@
struct Trigger : Input {
DeclareClass(Trigger, "input.trigger")
using Input::Input;
auto value() const -> s64 { return _value; }
auto setValue(s64 value) -> void { _value = value; }
protected:
s64 _value = 0;
s64 _minimum = 0;
s64 _maximum = +32767;
};
+7 -3
View File
@@ -1,5 +1,9 @@
namespace ares::Core {
#include <ares/node/video/sprite.cpp>
#include <ares/node/video/screen.cpp>
#include <ares/node/audio/stream.cpp>
namespace Video {
#include <ares/node/video/sprite.cpp>
#include <ares/node/video/screen.cpp>
}
namespace Audio {
#include <ares/node/audio/stream.cpp>
}
}
+121 -69
View File
@@ -1,71 +1,97 @@
namespace ares::Core {
struct Object;
struct System;
struct System;
struct Peripheral;
struct Port;
namespace Component {
struct Component;
struct RealTimeClock;
struct Peripheral;
struct Port;
}
namespace Video {
struct Video;
struct Sprite;
struct Screen;
}
namespace Audio {
struct Audio;
struct Stream;
}
namespace Input {
struct Input;
struct Button;
struct Axis;
struct Trigger;
struct Rumble;
struct Settings;
struct Button;
struct Axis;
struct Trigger;
struct Rumble;
}
namespace Setting {
struct Setting;
struct Boolean;
struct Natural;
struct Integer;
struct Real;
struct String;
//struct Video;
struct Sprite;
struct Screen;
//struct Audio;
struct Stream;
//struct Debug;
struct Memory;
struct Graphics;
struct Properties;
struct Boolean;
struct Natural;
struct Integer;
struct Real;
struct String;
}
namespace Debugger {
struct Debugger;
struct Memory;
struct Graphics;
struct Properties;
namespace Tracer {
struct Tracer;
struct Notification;
struct Instruction;
struct Notification;
struct Instruction;
}
}
}
namespace ares::Node {
using Object = shared_pointer<Core::Object>;
using System = shared_pointer<Core::System>;
using Component = shared_pointer<Core::Component>;
using RealTimeClock = shared_pointer<Core::RealTimeClock>;
using Peripheral = shared_pointer<Core::Peripheral>;
using Port = shared_pointer<Core::Port>;
using Input = shared_pointer<Core::Input>;
using Button = shared_pointer<Core::Button>;
using Axis = shared_pointer<Core::Axis>;
using Trigger = shared_pointer<Core::Trigger>;
using Rumble = shared_pointer<Core::Rumble>;
using Settings = shared_pointer<Core::Settings>;
using Setting = shared_pointer<Core::Setting>;
using Boolean = shared_pointer<Core::Boolean>;
using Natural = shared_pointer<Core::Natural>;
using Integer = shared_pointer<Core::Integer>;
using Real = shared_pointer<Core::Real>;
using String = shared_pointer<Core::String>;
//using Video;
using Sprite = shared_pointer<Core::Sprite>;
using Screen = shared_pointer<Core::Screen>;
//using Audio;
using Stream = shared_pointer<Core::Stream>;
//using Debug;
using Memory = shared_pointer<Core::Memory>;
using Graphics = shared_pointer<Core::Graphics>;
using Properties = shared_pointer<Core::Properties>;
using Tracer = shared_pointer<Core::Tracer>;
using Notification = shared_pointer<Core::Notification>;
using Instruction = shared_pointer<Core::Instruction>;
using Object = shared_pointer<Core::Object>;
using System = shared_pointer<Core::System>;
using Peripheral = shared_pointer<Core::Peripheral>;
using Port = shared_pointer<Core::Port>;
namespace Component {
using Component = shared_pointer<Core::Component::Component>;
using RealTimeClock = shared_pointer<Core::Component::RealTimeClock>;
}
namespace Video {
using Video = shared_pointer<Core::Video::Video>;
using Sprite = shared_pointer<Core::Video::Sprite>;
using Screen = shared_pointer<Core::Video::Screen>;
}
namespace Audio {
using Audio = shared_pointer<Core::Audio::Audio>;
using Stream = shared_pointer<Core::Audio::Stream>;
}
namespace Input {
using Input = shared_pointer<Core::Input::Input>;
using Button = shared_pointer<Core::Input::Button>;
using Axis = shared_pointer<Core::Input::Axis>;
using Trigger = shared_pointer<Core::Input::Trigger>;
using Rumble = shared_pointer<Core::Input::Rumble>;
}
namespace Setting {
using Setting = shared_pointer<Core::Setting::Setting>;
using Boolean = shared_pointer<Core::Setting::Boolean>;
using Natural = shared_pointer<Core::Setting::Natural>;
using Integer = shared_pointer<Core::Setting::Integer>;
using Real = shared_pointer<Core::Setting::Real>;
using String = shared_pointer<Core::Setting::String>;
}
namespace Debugger {
using Debugger = shared_pointer<Core::Debugger::Debugger>;
using Memory = shared_pointer<Core::Debugger::Memory>;
using Graphics = shared_pointer<Core::Debugger::Graphics>;
using Properties = shared_pointer<Core::Debugger::Properties>;
namespace Tracer {
using Tracer = shared_pointer<Core::Debugger::Tracer::Tracer>;
using Notification = shared_pointer<Core::Debugger::Tracer::Notification>;
using Instruction = shared_pointer<Core::Debugger::Tracer::Instruction>;
}
}
}
namespace ares::Core {
// <emulator/platform.hpp> forward declarations (dependent on <emulator/node.hpp>)
// <ares/platform.hpp> forward declarations
static auto PlatformAttach(Node::Object) -> void;
static auto PlatformDetach(Node::Object) -> void;
static auto PlatformLog(string_view) -> void;
@@ -74,21 +100,47 @@ namespace ares::Core {
#include <ares/node/class.hpp>
#include <ares/node/object.hpp>
#include <ares/node/system.hpp>
#include <ares/node/component.hpp>
#include <ares/node/real-time-clock.hpp>
#include <ares/node/peripheral.hpp>
#include <ares/node/port.hpp>
#include <ares/node/input.hpp>
#include <ares/node/setting.hpp>
#include <ares/node/video/sprite.hpp>
#include <ares/node/video/screen.hpp>
#include <ares/node/audio/stream.hpp>
#include <ares/node/debug/memory.hpp>
#include <ares/node/debug/graphics.hpp>
#include <ares/node/debug/properties.hpp>
#include <ares/node/debug/tracer.hpp>
#include <ares/node/debug/notification.hpp>
#include <ares/node/debug/instruction.hpp>
namespace Component {
#include <ares/node/component/component.hpp>
#include <ares/node/component/real-time-clock.hpp>
}
namespace Video {
#include <ares/node/video/video.hpp>
#include <ares/node/video/sprite.hpp>
#include <ares/node/video/screen.hpp>
}
namespace Audio {
#include <ares/node/audio/audio.hpp>
#include <ares/node/audio/stream.hpp>
}
namespace Input {
#include <ares/node/input/input.hpp>
#include <ares/node/input/button.hpp>
#include <ares/node/input/axis.hpp>
#include <ares/node/input/trigger.hpp>
#include <ares/node/input/rumble.hpp>
}
namespace Setting {
#include <ares/node/setting/setting.hpp>
#include <ares/node/setting/boolean.hpp>
#include <ares/node/setting/natural.hpp>
#include <ares/node/setting/integer.hpp>
#include <ares/node/setting/real.hpp>
#include <ares/node/setting/string.hpp>
}
namespace Debugger {
#include <ares/node/debugger/debugger.hpp>
#include <ares/node/debugger/memory.hpp>
#include <ares/node/debugger/graphics.hpp>
#include <ares/node/debugger/properties.hpp>
namespace Tracer {
#include <ares/node/debugger/tracer/tracer.hpp>
#include <ares/node/debugger/tracer/notification.hpp>
#include <ares/node/debugger/tracer/instruction.hpp>
}
}
}
namespace ares::Node {
@@ -106,7 +158,7 @@ namespace ares::Node {
static inline auto unserialize(string markup) -> Object {
auto document = BML::unserialize(markup);
if(!document) return {};
auto node = Core::Class::create(document["node"].text());
auto node = Core::Class::create(document["node"].string());
node->unserialize(document["node"]);
return node;
}
+32 -10
View File
@@ -1,14 +1,18 @@
//identifier is static, allowing template<typename T> to access via T::identifier
//identifier() is static, allowing template<typename T> to access via T::identifier()
//identity() is virtual, allowing T* to access via T->identity()
#define DeclareClass(Type, Name) \
static inline const string identifier = Name; \
virtual auto identity() const -> string { return Name; } \
static auto identifier() -> string { return Name; } \
static auto create() -> Node::Object { return new Type; } \
auto identity() const -> string override { return Name; } \
private: static inline Class::Register<Type> register; public: \
struct Object : shared_pointer_this<Object> {
DeclareClass(Object, "Object")
static auto identifier() -> string { return "Object"; }
static auto create() -> Node::Object { return new Object; }
virtual auto identity() const -> string { return "Object"; }
private: static inline Class::Register<Object> register; public:
//DeclareClass(Object, "object")
Object(string name = {}) : _name(name) {}
virtual ~Object() = default;
@@ -86,7 +90,7 @@ struct Object : shared_pointer_this<Object> {
}
template<typename T>
auto find(uint index) -> shared_pointer<typename T::type> {
auto find(u32 index) -> shared_pointer<typename T::type> {
auto result = find<T>();
if(index < result.size()) return result[index];
return {};
@@ -108,7 +112,7 @@ struct Object : shared_pointer_this<Object> {
for(auto& node : _nodes) {
if(node->_name != name) continue;
if(path) return node->find<T>(path.merge("/"));
if(node->identity() == Type::identifier) return node;
if(node->identity() == Type::identifier()) return node;
}
return {};
}
@@ -117,7 +121,7 @@ struct Object : shared_pointer_this<Object> {
auto scan(string name) -> T {
using Type = typename T::type;
for(auto& node : _nodes) {
if(node->identity() == Type::identifier && node->_name == name) return node;
if(node->identity() == Type::identifier() && node->_name == name) return node;
if(auto result = node->scan<T>(name)) return result;
}
return {};
@@ -130,6 +134,15 @@ struct Object : shared_pointer_this<Object> {
for(auto& node : _nodes) node->enumerate<T>(objects);
}
auto pak() -> VFS::Pak {
return _pak;
}
auto setPak(VFS::Pak pak) -> bool {
_pak = pak;
return (bool)_pak;
}
template<typename T = string>
auto attribute(const string& name) const -> T {
if(auto attribute = _attributes.find(name)) {
@@ -138,6 +151,14 @@ struct Object : shared_pointer_this<Object> {
return {};
}
template<typename T = string>
auto hasAttribute(const string& name) const -> bool {
if(auto attribute = _attributes.find(name)) {
if(attribute->value.is<T>()) return true;
}
return false;
}
template<typename T = string, typename U = string>
auto setAttribute(const string& name, const U& value = {}) -> void {
if constexpr(is_same_v<T, string> && !is_same_v<U, string>) return setAttribute(name, string{value});
@@ -178,13 +199,13 @@ struct Object : shared_pointer_this<Object> {
virtual auto unserialize(Markup::Node markup) -> void {
if(!markup) return;
_name = markup["name"].text();
_name = markup["name"].string();
_attributes.reset();
for(auto& attribute : markup.find("attribute")) {
_attributes.insert({attribute["name"].text(), attribute["value"].text()});
_attributes.insert({attribute["name"].string(), attribute["value"].string()});
}
for(auto& leaf : markup.find("node")) {
auto node = Class::create(leaf.text());
auto node = Class::create(leaf.string());
append(node);
node->unserialize(leaf);
}
@@ -207,6 +228,7 @@ struct Object : shared_pointer_this<Object> {
protected:
string _name;
VFS::Pak _pak;
set<Attribute> _attributes;
shared_pointer_weak<Object> _parent;
vector<Node::Object> _nodes;
+1 -8
View File
@@ -1,11 +1,4 @@
struct Peripheral : Object {
DeclareClass(Peripheral, "Peripheral")
DeclareClass(Peripheral, "peripheral")
using Object::Object;
auto manifest() -> string { if(_manifest) return _manifest(); return {}; }
auto setManifest(function<string()> manifest) -> void { _manifest = manifest; }
protected:
function<string ()> _manifest;
};
+1 -1
View File
@@ -1,5 +1,5 @@
struct Port : Object {
DeclareClass(Port, "Port")
DeclareClass(Port, "port")
using Object::Object;
auto type() const -> string { return _type; }
-30
View File
@@ -1,30 +0,0 @@
struct RealTimeClock : Object {
DeclareClass(RealTimeClock, "Real Time Clock")
using Object::Object;
auto update() -> void { if(_update) return _update(); }
auto timestamp() const -> uint64 { return _timestamp; }
auto setUpdate(function<void ()> update) { _update = update; }
auto setTimestamp(uint64 timestamp) -> void { _timestamp = timestamp; }
auto synchronize(uint64 timestamp = 0) -> void {
if(!timestamp) timestamp = chrono::timestamp();
_timestamp = timestamp;
update();
}
auto serialize(string& output, string depth) -> void override {
Object::serialize(output, depth);
output.append(depth, " timestamp: ", _timestamp, "\n");
}
auto unserialize(Markup::Node node) -> void override {
Object::unserialize(node);
_timestamp = node["timestamp"].natural();
}
protected:
function<void ()> _update;
uint64 _timestamp;
};
-192
View File
@@ -1,192 +0,0 @@
struct Settings : Object {
DeclareClass(Settings, "Settings")
using Object::Object;
};
struct Setting : Object {
DeclareClass(Setting, "Setting")
using Object::Object;
auto dynamic() const -> bool { return _dynamic; }
auto setDynamic(bool dynamic) -> void {
_dynamic = dynamic;
}
virtual auto setLatch() -> void {}
virtual auto readValue() const -> string { return {}; }
virtual auto readLatch() const -> string { return {}; }
virtual auto readAllowedValues() const -> vector<string> { return {}; }
virtual auto writeValue(string value) -> void {}
auto serialize(string& output, string depth) -> void override {
Object::serialize(output, depth);
output.append(depth, " dynamic: ", _dynamic, "\n");
}
auto unserialize(Markup::Node node) -> void override {
Object::unserialize(node);
_dynamic = node["dynamic"].boolean();
}
protected:
bool _dynamic = false;
};
template<typename Cast, typename Type> struct Abstract : Setting {
using Setting::Setting;
Abstract(string name = {}, Type value = {}, function<void (Type)> modify = {}) : Setting(name), _defaultValue(value) {
_currentValue = value;
_latchedValue = value;
if constexpr(is_same_v<Type, boolean>) _allowedValues = {false, true};
_modify = modify;
}
auto modify(Type value) const -> void { if(_modify) return _modify(value); }
auto value() const -> Type { return _currentValue; }
auto latch() const -> Type { return _latchedValue; }
auto setModify(function<void (Type)> modify) {
_modify = modify;
}
auto setValue(Type value) -> void {
if(_allowedValues && !_allowedValues.find(value)) return;
_currentValue = value;
if(_dynamic) _latchedValue = _currentValue;
modify(value);
}
auto setLatch() -> void override {
_latchedValue = _currentValue;
}
auto setAllowedValues(vector<Type> allowedValues) -> void {
_allowedValues = allowedValues;
//if the current setting isn't an allowed value, change it to the first allowed value
if(_allowedValues && !_allowedValues.find(_currentValue)) {
_currentValue = _allowedValues.first();
_latchedValue = _currentValue;
}
}
auto readValue() const -> string override { return value(); }
auto readLatch() const -> string override { return latch(); }
auto readAllowedValues() const -> vector<string> override {
vector<string> values;
for(auto& value : _allowedValues) values.append(value);
return values;
}
auto writeValue(string value) -> void override {
if(_allowedValues && !readAllowedValues().find(value)) return;
if constexpr(is_same_v<Type, boolean>) _currentValue = value.boolean();
if constexpr(is_same_v<Type, natural>) _currentValue = value.natural();
if constexpr(is_same_v<Type, integer>) _currentValue = value.integer();
if constexpr(is_same_v<Type, real >) _currentValue = value.real();
if constexpr(is_same_v<Type, string >) _currentValue = value;
if(_dynamic) _latchedValue = _currentValue;
modify(_currentValue);
}
auto load(Node::Object source) -> bool override {
if(!Setting::load(source)) return false;
if(auto setting = source->cast<shared_pointer<Cast>>()) {
if(!_allowedValues || _allowedValues.find(setting->_currentValue)) {
_currentValue = setting->_currentValue;
_latchedValue = _currentValue;
modify(_currentValue);
}
}
return true;
}
auto serialize(string& output, string depth) -> void override {
Setting::serialize(output, depth);
output.append(depth, " value: ", _currentValue, "\n");
if(_latchedValue) output.append(depth, " latch: ", _latchedValue, "\n");
}
auto unserialize(Markup::Node node) -> void override {
Setting::unserialize(node);
if constexpr(is_same_v<Type, boolean>) _currentValue = node["value"].boolean(), _latchedValue = node["latch"].boolean();
if constexpr(is_same_v<Type, natural>) _currentValue = node["value"].natural(), _latchedValue = node["latch"].natural();
if constexpr(is_same_v<Type, integer>) _currentValue = node["value"].integer(), _latchedValue = node["latch"].integer();
if constexpr(is_same_v<Type, real>) _currentValue = node["value"].real(), _latchedValue = node["latch"].real();
if constexpr(is_same_v<Type, string>) _currentValue = node["value"].text(), _latchedValue = node["latch"].text();
}
protected:
function<void (Type)> _modify;
const Type _defaultValue;
Type _currentValue;
Type _latchedValue;
vector<Type> _allowedValues;
};
struct Boolean : Abstract<Boolean, boolean> {
DeclareClass(Boolean, "Boolean")
using Abstract::Abstract;
auto copy(Node::Object object) -> void override {
if(auto source = object->cast<Node::Boolean>()) {
Object::copy(source);
setValue(source->value());
setLatch();
}
}
};
struct Natural : Abstract<Natural, natural> {
DeclareClass(Natural, "Natural")
using Abstract::Abstract;
auto copy(Node::Object object) -> void override {
if(auto source = object->cast<Node::Natural>()) {
Object::copy(source);
setValue(source->value());
setLatch();
}
}
};
struct Integer : Abstract<Integer, integer> {
DeclareClass(Integer, "Integer")
using Abstract::Abstract;
auto copy(Node::Object object) -> void override {
if(auto source = object->cast<Node::Integer>()) {
Object::copy(source);
setValue(source->value());
setLatch();
}
}
};
struct Real : Abstract<Real, real> {
DeclareClass(Real, "Real")
using Abstract::Abstract;
auto copy(Node::Object object) -> void override {
if(auto source = object->cast<Node::Real>()) {
Object::copy(source);
setValue(source->value());
setLatch();
}
}
};
struct String : Abstract<String, string> {
DeclareClass(String, "String")
using Abstract::Abstract;
auto copy(Node::Object object) -> void override {
if(auto source = object->cast<Node::String>()) {
Object::copy(source);
setValue(source->value());
setLatch();
}
}
};
+36
View File
@@ -0,0 +1,36 @@
struct Boolean : Setting {
DeclareClass(Boolean, "setting.boolean")
Boolean(string name = {}, bool value = {}, function<void (bool)> modify = {}) : Setting(name) {
_currentValue = value;
_latchedValue = value;
_modify = modify;
}
auto modify(bool value) const -> void { if(_modify) return _modify(value); }
auto value() const -> bool { return _currentValue; }
auto latch() const -> bool { return _latchedValue; }
auto setModify(function<void (bool)> modify) { _modify = modify; }
auto setValue(bool value) -> void {
_currentValue = value;
if(_dynamic) setLatch();
}
auto setLatch() -> void override {
if(_latchedValue == _currentValue) return;
_latchedValue = _currentValue;
modify(_latchedValue);
}
auto readValue() const -> string override { return value(); }
auto readLatch() const -> string override { return latch(); }
auto readAllowedValues() const -> vector<string> override { return {"false", "true"}; }
auto writeValue(string value) -> void override { setValue(value.boolean()); }
protected:
function<void (bool)> _modify;
bool _currentValue = {};
bool _latchedValue = {};
};
+47
View File
@@ -0,0 +1,47 @@
struct Integer : Setting {
DeclareClass(Integer, "setting.integer")
Integer(string name = {}, s64 value = {}, function<void (s64)> modify = {}) : Setting(name) {
_currentValue = value;
_latchedValue = value;
_modify = modify;
}
auto modify(s64 value) const -> void { if(_modify) return _modify(value); }
auto value() const -> s64 { return _currentValue; }
auto latch() const -> s64 { return _latchedValue; }
auto setModify(function<void (s64)> modify) { _modify = modify; }
auto setValue(s64 value) -> void {
if(_allowedValues && !_allowedValues.find(value)) return;
_currentValue = value;
if(_dynamic) setLatch();
}
auto setLatch() -> void override {
if(_latchedValue == _currentValue) return;
_latchedValue = _currentValue;
modify(_latchedValue);
}
auto setAllowedValues(vector<s64> allowedValues) -> void {
_allowedValues = allowedValues;
if(_allowedValues && !_allowedValues.find(_currentValue)) setValue(_allowedValues.first());
}
auto readValue() const -> string override { return value(); }
auto readLatch() const -> string override { return latch(); }
auto readAllowedValues() const -> vector<string> override {
vector<string> values;
for(auto value : _allowedValues) values.append(value);
return values;
}
auto writeValue(string value) -> void override { setValue(value.integer()); }
protected:
function<void (s64)> _modify;
s64 _currentValue = {};
s64 _latchedValue = {};
vector<s64> _allowedValues;
};
+47
View File
@@ -0,0 +1,47 @@
struct Natural : Setting {
DeclareClass(Natural, "setting.natural")
Natural(string name = {}, u64 value = {}, function<void (u64)> modify = {}) : Setting(name) {
_currentValue = value;
_latchedValue = value;
_modify = modify;
}
auto modify(u64 value) const -> void { if(_modify) return _modify(value); }
auto value() const -> u64 { return _currentValue; }
auto latch() const -> u64 { return _latchedValue; }
auto setModify(function<void (u64)> modify) { _modify = modify; }
auto setValue(u64 value) -> void {
if(_allowedValues && !_allowedValues.find(value)) return;
_currentValue = value;
if(_dynamic) setLatch();
}
auto setLatch() -> void override {
if(_latchedValue == _currentValue) return;
_latchedValue = _currentValue;
modify(_latchedValue);
}
auto setAllowedValues(vector<u64> allowedValues) -> void {
_allowedValues = allowedValues;
if(_allowedValues && !_allowedValues.find(_currentValue)) setValue(_allowedValues.first());
}
auto readValue() const -> string override { return value(); }
auto readLatch() const -> string override { return latch(); }
auto readAllowedValues() const -> vector<string> override {
vector<string> values;
for(auto value : _allowedValues) values.append(value);
return values;
}
auto writeValue(string value) -> void override { setValue(value.natural()); }
protected:
function<void (u64)> _modify;
u64 _currentValue = {};
u64 _latchedValue = {};
vector<u64> _allowedValues;
};
+47
View File
@@ -0,0 +1,47 @@
struct Real : Setting {
DeclareClass(Real, "setting.real")
Real(string name = {}, f64 value = {}, function<void (f64)> modify = {}) : Setting(name) {
_currentValue = value;
_latchedValue = value;
_modify = modify;
}
auto modify(f64 value) const -> void { if(_modify) return _modify(value); }
auto value() const -> f64 { return _currentValue; }
auto latch() const -> f64 { return _latchedValue; }
auto setModify(function<void (f64)> modify) { _modify = modify; }
auto setValue(f64 value) -> void {
if(_allowedValues && !_allowedValues.find(value)) return;
_currentValue = value;
if(_dynamic) setLatch();
}
auto setLatch() -> void override {
if(_latchedValue == _currentValue) return;
_latchedValue = _currentValue;
modify(_latchedValue);
}
auto setAllowedValues(vector<f64> allowedValues) -> void {
_allowedValues = allowedValues;
if(_allowedValues && !_allowedValues.find(_currentValue)) setValue(_allowedValues.first());
}
auto readValue() const -> string override { return value(); }
auto readLatch() const -> string override { return latch(); }
auto readAllowedValues() const -> vector<string> override {
vector<string> values;
for(auto value : _allowedValues) values.append(value);
return values;
}
auto writeValue(string value) -> void override { setValue(value.real()); }
protected:
function<void (f64)> _modify;
f64 _currentValue = {};
f64 _latchedValue = {};
vector<f64> _allowedValues;
};
+46
View File
@@ -0,0 +1,46 @@
struct Setting : Object {
DeclareClass(Setting, "setting")
using Object::Object;
auto dynamic() const -> bool { return _dynamic; }
auto setDynamic(bool dynamic) -> void {
_dynamic = dynamic;
}
virtual auto setLatch() -> void {}
virtual auto readValue() const -> string { return {}; }
virtual auto readLatch() const -> string { return {}; }
virtual auto readAllowedValues() const -> vector<string> { return {}; }
virtual auto writeValue(string value) -> void {}
auto load(Node::Object source) -> bool override {
if(!Object::load(source)) return false;
if(auto setting = source->cast<shared_pointer<Setting>>()) writeValue(setting->readValue());
return true;
}
auto copy(Node::Object object) -> void override {
if(auto source = object->cast<Node::Setting::Setting>()) {
Object::copy(source);
writeValue(source->readValue());
setLatch();
}
}
auto serialize(string& output, string depth) -> void override {
Object::serialize(output, depth);
output.append(depth, " dynamic: ", _dynamic, "\n");
output.append(depth, " value: ", readValue(), "\n");
}
auto unserialize(Markup::Node node) -> void override {
Object::unserialize(node);
_dynamic = node["dynamic"].boolean();
writeValue(node["value"].string());
}
protected:
bool _dynamic = false;
};
+43
View File
@@ -0,0 +1,43 @@
struct String : Setting {
DeclareClass(String, "setting.string")
String(string name = {}, string value = {}, function<void (string)> modify = {}) : Setting(name) {
_currentValue = value;
_latchedValue = value;
_modify = modify;
}
auto modify(string value) const -> void { if(_modify) return _modify(value); }
auto value() const -> string { return _currentValue; }
auto latch() const -> string { return _latchedValue; }
auto setModify(function<void (string)> modify) { _modify = modify; }
auto setValue(string value) -> void {
if(_allowedValues && !_allowedValues.find(value)) return;
_currentValue = value;
if(_dynamic) setLatch();
}
auto setLatch() -> void override {
if(_latchedValue == _currentValue) return;
_latchedValue = _currentValue;
modify(_latchedValue);
}
auto setAllowedValues(vector<string> allowedValues) -> void {
_allowedValues = allowedValues;
if(_allowedValues && !_allowedValues.find(_currentValue)) setValue(_allowedValues.first());
}
auto readValue() const -> string override { return value(); }
auto readLatch() const -> string override { return latch(); }
auto readAllowedValues() const -> vector<string> override { return _allowedValues; }
auto writeValue(string value) -> void override { setValue(value); }
protected:
function<void (string)> _modify;
string _currentValue = {};
string _latchedValue = {};
vector<string> _allowedValues;
};
+26 -1
View File
@@ -1,4 +1,29 @@
struct System : Object {
DeclareClass(System, "System")
DeclareClass(System, "system")
using Object::Object;
auto game() -> string { if(_game) return _game(); return {}; }
auto run() -> void { if(_run) return _run(); }
auto power(bool reset = false) -> void { if(_power) return _power(reset); }
auto save() -> void { if(_save) return _save(); }
auto unload() -> void { if(_unload) return _unload(); }
auto serialize(bool synchronize = true) -> serializer { if(_serialize) return _serialize(synchronize); return {}; }
auto unserialize(serializer& s) -> bool { if(_unserialize) return _unserialize(s); return false; }
auto setGame(function<string ()> game) -> void { _game = game; }
auto setRun(function<void ()> run) -> void { _run = run; }
auto setPower(function<void (bool)> power) -> void { _power = power; }
auto setSave(function<void ()> save) -> void { _save = save; }
auto setUnload(function<void ()> unload) -> void { _unload = unload; }
auto setSerialize(function<serializer (bool)> serialize) -> void { _serialize = serialize; }
auto setUnserialize(function<bool (serializer&)> unserialize) -> void { _unserialize = unserialize; }
protected:
function<string ()> _game;
function<void ()> _run;
function<void (bool)> _power;
function<void ()> _save;
function<void ()> _unload;
function<serializer (bool)> _serialize;
function<bool (serializer&)> _unserialize;
};
+257 -79
View File
@@ -1,106 +1,237 @@
Screen::Screen(string name, u32 width, u32 height) : Video(name) {
_canvasWidth = width;
_canvasHeight = height;
if(width && height) {
_inputA = new u32[width * height]();
_inputB = new u32[width * height]();
_output = new u32[width * height]();
_rotate = new u32[width * height]();
if constexpr(ares::Video::Threaded) {
_thread = nall::thread::create({&Screen::main, this});
}
}
}
Screen::~Screen() {
if constexpr(ares::Video::Threaded) {
if(_canvasWidth && _canvasHeight) {
_kill = true;
_thread.join();
}
}
}
auto Screen::main(uintptr_t) -> void {
while(!_kill) {
usleep(1);
if(_frame) {
refresh();
_frame = false;
}
}
}
auto Screen::quit() -> void {
_kill = true;
_thread.join();
}
auto Screen::power() -> void {
lock_guard<recursive_mutex> lock(_mutex);
memory::fill<u32>(_inputA.data(), _canvasWidth * _canvasHeight, _fillColor);
memory::fill<u32>(_inputB.data(), _canvasWidth * _canvasHeight, _fillColor);
memory::fill<u32>(_output.data(), _canvasWidth * _canvasHeight, _fillColor);
memory::fill<u32>(_rotate.data(), _canvasWidth * _canvasHeight, _fillColor);
}
auto Screen::pixels(bool frame) -> array_span<u32> {
if(frame == 0) return {_inputA.data(), _canvasWidth * _canvasHeight};
if(frame == 1) return {_inputB.data(), _canvasWidth * _canvasHeight};
return {};
}
auto Screen::resetPalette() -> void {
lock_guard<recursive_mutex> lock(_mutex);
_palette.reset();
}
auto Screen::resetSprites() -> void {
lock_guard<recursive_mutex> lock(_mutex);
_sprites.reset();
}
auto Screen::attach(Node::Sprite sprite) -> void {
auto Screen::setRefresh(function<void ()> refresh) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_refresh = refresh;
}
auto Screen::setViewport(u32 x, u32 y, u32 width, u32 height) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_viewportX = x;
_viewportY = y;
_viewportWidth = width;
_viewportHeight = height;
}
auto Screen::setSize(u32 width, u32 height) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_width = width;
_height = height;
}
auto Screen::setScale(f64 scaleX, f64 scaleY) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_scaleX = scaleX;
_scaleY = scaleY;
}
auto Screen::setAspect(f64 aspectX, f64 aspectY) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_aspectX = aspectX;
_aspectY = aspectY;
}
auto Screen::setSaturation(f64 saturation) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_saturation = saturation;
_palette.reset();
}
auto Screen::setGamma(f64 gamma) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_gamma = gamma;
_palette.reset();
}
auto Screen::setLuminance(f64 luminance) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_luminance = luminance;
_palette.reset();
}
auto Screen::setFillColor(u32 fillColor) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_fillColor = fillColor;
}
auto Screen::setColorBleed(bool colorBleed) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_colorBleed = colorBleed;
}
auto Screen::setInterframeBlending(bool interframeBlending) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_interframeBlending = interframeBlending;
}
auto Screen::setRotation(u32 rotation) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_rotation = rotation;
}
auto Screen::setProgressive(bool progressiveDouble) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_interlace = false;
_progressive = true;
_progressiveDouble = progressiveDouble;
}
auto Screen::setInterlace(bool interlaceField) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_progressive = false;
_interlace = true;
_interlaceField = interlaceField;
}
auto Screen::attach(Node::Video::Sprite sprite) -> void {
lock_guard<recursive_mutex> lock(_mutex);
if(_sprites.find(sprite)) return;
_sprites.append(sprite);
}
auto Screen::detach(Node::Sprite sprite) -> void {
auto Screen::detach(Node::Video::Sprite sprite) -> void {
lock_guard<recursive_mutex> lock(_mutex);
if(!_sprites.find(sprite)) return;
_sprites.removeByValue(sprite);
}
auto Screen::colors(uint colors, function<uint64 (uint32)> color) -> void {
auto Screen::colors(u32 colors, function<n64 (n32)> color) -> void {
lock_guard<recursive_mutex> lock(_mutex);
_colors = colors;
_color = color;
_palette.reset();
}
auto Screen::refresh(uint32* input, uint pitch, uint width, uint height) -> void {
auto Screen::frame() -> void {
if(runAhead()) return;
while(_frame) spinloop();
lock_guard<recursive_mutex> lock(_mutex);
_inputA.swap(_inputB);
_frame = true;
if constexpr(!ares::Video::Threaded) {
refresh();
_frame = false;
}
}
auto Screen::refresh() -> void {
lock_guard<recursive_mutex> lock(_mutex);
if(runAhead()) return;
//allocate the screen buffers (only when growing)
if(_renderWidth != width || _renderHeight != height) {
if(_renderWidth * _renderHeight < width * height) {
_buffer = new uint32[width * height];
_rotate = new uint32[width * height];
}
}
refreshPalette();
if(_refresh) _refresh();
//generate the color lookup palettes to convert native colors to ARGB8888
if(!_palette) {
_palette = new uint32[_colors];
for(uint index : range(_colors)) {
uint64 color = _color(index);
uint16 b = color.bit( 0,15);
uint16 g = color.bit(16,31);
uint16 r = color.bit(32,47);
uint16 a = 65535;
auto viewX = _viewportX;
auto viewY = _viewportY;
auto viewWidth = _viewportWidth;
auto viewHeight = _viewportHeight;
if(_saturation != 1.0) {
uint16 grayscale = uclamp<16>((r + g + b) / 3);
double inverse = max(0.0, 1.0 - _saturation);
r = uclamp<16>(r * _saturation + grayscale * inverse);
g = uclamp<16>(g * _saturation + grayscale * inverse);
b = uclamp<16>(b * _saturation + grayscale * inverse);
}
auto pitch = _canvasWidth;
auto width = _canvasWidth;
auto height = _canvasHeight;
auto input = _inputB.data();
auto output = _output.data();
if(_gamma != 1.0) {
double reciprocal = 1.0 / 32767.0;
r = r > 32767 ? r : uint16(32767 * pow(r * reciprocal, _gamma));
g = g > 32767 ? g : uint16(32767 * pow(g * reciprocal, _gamma));
b = b > 32767 ? b : uint16(32767 * pow(b * reciprocal, _gamma));
}
if(_luminance != 1.0) {
r = uclamp<16>(r * _luminance);
g = uclamp<16>(g * _luminance);
b = uclamp<16>(b * _luminance);
}
a >>= 8;
r >>= 8;
g >>= 8;
b >>= 8;
_palette[index] = a << 24 | r << 16 | g << 8 | b << 0;
}
}
auto output = _buffer.data();
pitch >>= 2; //bytes to words
for(uint y : range(height)) {
auto source = input + y * pitch;
for(u32 y : range(height)) {
auto source = input + y * pitch;
auto target = output + y * width;
//if not blending, or if previous frame resolution was different, render normally
if(!_interframeBlending || width != _renderWidth || height != _renderHeight) {
for(uint x : range(width)) {
if(_interlace) {
if((_interlaceField & 1) == (y & 1)) {
for(u32 x : range(width)) {
auto color = _palette[*source++];
*target++ = color;
}
}
} else if(_progressive && _progressiveDouble) {
source = input + (y & ~1) * pitch;
for(u32 x : range(width)) {
auto color = _palette[*source++];
*target++ = color;
}
} else {
uint32 mask = 1 << 24 | 1 << 16 | 1 << 8 | 1 << 0;
for(uint x : range(width)) {
} else if(_interframeBlending) {
n32 mask = 1 << 24 | 1 << 16 | 1 << 8 | 1 << 0;
for(u32 x : range(width)) {
auto a = *target;
auto b = _palette[*source++];
*target++ = (a + b - ((a ^ b) & mask)) >> 1;
}
} else {
for(u32 x : range(width)) {
auto color = _palette[*source++];
*target++ = color;
}
}
}
if(_colorBleed) {
uint32 mask = 1 << 24 | 1 << 16 | 1 << 8 | 1 << 9;
for(uint y : range(height)) {
n32 mask = 1 << 24 | 1 << 16 | 1 << 8 | 1 << 0;
for(u32 y : range(height)) {
auto target = output + y * width;
for(uint x : range(width)) {
for(u32 x : range(width)) {
auto a = target[x];
auto b = target[x + (x != width - 1)];
target[x] = (a + b - ((a ^ b) & mask)) >> 1;
@@ -111,15 +242,15 @@ auto Screen::refresh(uint32* input, uint pitch, uint width, uint height) -> void
for(auto& sprite : _sprites) {
if(!sprite->visible()) continue;
uint32 alpha = 255u << 24;
n32 alpha = 255u << 24;
for(int y : range(sprite->height())) {
int pixelY = sprite->y() + y;
s32 pixelY = sprite->y() + y;
if(pixelY < 0 || pixelY >= height) continue;
auto source = sprite->image() + y * sprite->width();
auto source = sprite->image().data() + y * sprite->width();
auto target = &output[pixelY * width];
for(int x : range(sprite->width())) {
int pixelX = sprite->x() + x;
for(s32 x : range(sprite->width())) {
s32 pixelX = sprite->x() + x;
if(pixelX < 0 || pixelX >= width) continue;
auto pixel = source[x];
@@ -130,22 +261,23 @@ auto Screen::refresh(uint32* input, uint pitch, uint width, uint height) -> void
if(_rotation == 90) {
//rotate left
for(uint y : range(height)) {
for(u32 y : range(height)) {
auto source = output + y * width;
for(uint x : range(width)) {
for(u32 x : range(width)) {
auto target = _rotate.data() + (width - 1 - x) * height + y;
*target = *source++;
}
}
output = _rotate.data();
swap(width, height);
swap(viewWidth, viewHeight);
}
if(_rotation == 180) {
//rotate upside down
for(uint y : range(height)) {
for(u32 y : range(height)) {
auto source = output + y * width;
for(uint x : range(width)) {
for(u32 x : range(width)) {
auto target = _rotate.data() + (height - 1 - y) * width + (width - 1 - x);
*target = *source++;
}
@@ -155,25 +287,67 @@ auto Screen::refresh(uint32* input, uint pitch, uint width, uint height) -> void
if(_rotation == 270) {
//rotate right
for(uint y : range(height)) {
for(u32 y : range(height)) {
auto source = output + y * width;
for(uint x : range(width)) {
for(u32 x : range(width)) {
auto target = _rotate.data() + x * height + (height - 1 - y);
*target = *source++;
}
}
output = _rotate.data();
swap(width, height);
swap(viewWidth, viewHeight);
}
platform->video(shared(), (const uint32_t*)output, width * sizeof(uint32), width, height);
platform->video(shared(), output + viewX + viewY * width, width * sizeof(u32), viewWidth, viewHeight);
memory::fill<u32>(_inputB.data(), width * height, _fillColor);
}
_renderWidth = width;
_renderHeight = height;
auto Screen::refreshPalette() -> void {
lock_guard<recursive_mutex> lock(_mutex);
if(_palette) return;
//generate the color lookup palettes to convert native colors to ARGB8888
_palette = new u32[_colors];
for(u32 index : range(_colors)) {
n64 color = _color(index);
n16 b = color.bit( 0,15);
n16 g = color.bit(16,31);
n16 r = color.bit(32,47);
n16 a = 65535;
if(_saturation != 1.0) {
n16 grayscale = uclamp<16>((r + g + b) / 3);
f64 inverse = max(0.0, 1.0 - _saturation);
r = uclamp<16>(r * _saturation + grayscale * inverse);
g = uclamp<16>(g * _saturation + grayscale * inverse);
b = uclamp<16>(b * _saturation + grayscale * inverse);
}
if(_gamma != 1.0) {
f64 reciprocal = 1.0 / 32767.0;
r = r > 32767 ? r : n16(32767 * pow(r * reciprocal, _gamma));
g = g > 32767 ? g : n16(32767 * pow(g * reciprocal, _gamma));
b = b > 32767 ? b : n16(32767 * pow(b * reciprocal, _gamma));
}
if(_luminance != 1.0) {
r = uclamp<16>(r * _luminance);
g = uclamp<16>(g * _luminance);
b = uclamp<16>(b * _luminance);
}
a >>= 8;
r >>= 8;
g >>= 8;
b >>= 8;
_palette[index] = a << 24 | r << 16 | g << 8 | b << 0;
}
}
auto Screen::serialize(string& output, string depth) -> void {
Object::serialize(output, depth);
Video::serialize(output, depth);
output.append(depth, " width: ", _width, "\n");
output.append(depth, " height: ", _height, "\n");
output.append(depth, " scaleX: ", _scaleX, "\n");
@@ -184,13 +358,15 @@ auto Screen::serialize(string& output, string depth) -> void {
output.append(depth, " saturation: ", _saturation, "\n");
output.append(depth, " gamma: ", _gamma, "\n");
output.append(depth, " luminance: ", _luminance, "\n");
output.append(depth, " fillColor: ", _fillColor, "\n");
output.append(depth, " colorBleed: ", _colorBleed, "\n");
output.append(depth, " interlace: ", _interlace, "\n");
output.append(depth, " interframeBlending: ", _interframeBlending, "\n");
output.append(depth, " rotation: ", _rotation, "\n");
}
auto Screen::unserialize(Markup::Node node) -> void {
Object::unserialize(node);
Video::unserialize(node);
_width = node["width"].natural();
_height = node["height"].natural();
_scaleX = node["scaleX"].real();
@@ -201,7 +377,9 @@ auto Screen::unserialize(Markup::Node node) -> void {
_saturation = node["saturation"].real();
_gamma = node["gamma"].real();
_luminance = node["luminance"].real();
_fillColor = node["fillColor"].natural();
_colorBleed = node["colorBleed"].boolean();
_interlace = node["interlace"].natural();
_interframeBlending = node["interframeBlending"].boolean();
_rotation = node["rotation"].natural();
resetPalette();
+80 -42
View File
@@ -1,68 +1,106 @@
struct Screen : Object {
DeclareClass(Screen, "Screen")
using Object::Object;
struct Screen : Video {
DeclareClass(Screen, "video.screen")
using Video::Video;
auto width() const -> uint { return _width; }
auto height() const -> uint { return _height; }
auto scaleX() const -> double { return _scaleX; }
auto scaleY() const -> double { return _scaleY; }
auto aspectX() const -> double { return _aspectX; }
auto aspectY() const -> double { return _aspectY; }
auto colors() const -> uint { return _colors; }
Screen(string name = {}, u32 width = 0, u32 height = 0);
~Screen();
auto main(uintptr_t) -> void;
auto quit() -> void;
auto power() -> void;
auto canvasWidth() const -> u32 { return _canvasWidth; }
auto canvasHeight() const -> u32 { return _canvasHeight; }
auto width() const -> u32 { return _width; }
auto height() const -> u32 { return _height; }
auto scaleX() const -> f64 { return _scaleX; }
auto scaleY() const -> f64 { return _scaleY; }
auto aspectX() const -> f64 { return _aspectX; }
auto aspectY() const -> f64 { return _aspectY; }
auto colors() const -> u32 { return _colors; }
auto pixels(bool frame = 0) -> array_span<u32>;
auto saturation() const -> double { return _saturation; }
auto gamma() const -> double { return _gamma; }
auto luminance() const -> double { return _luminance; }
auto fillColor() const -> u32 { return _fillColor; }
auto colorBleed() const -> bool { return _colorBleed; }
auto interframeBlending() const -> bool { return _interframeBlending; }
auto rotation() const -> uint { return _rotation; }
auto rotation() const -> u32 { return _rotation; }
auto resetPalette() -> void;
auto resetSprites() -> void;
auto setSize(uint width, uint height) -> void { _width = width, _height = height; }
auto setScale(double scaleX, double scaleY) -> void { _scaleX = scaleX, _scaleY = scaleY; }
auto setAspect(double aspectX, double aspectY) -> void { _aspectX = aspectX, _aspectY = aspectY; }
auto setRefresh(function<void ()> refresh) -> void;
auto setViewport(u32 x, u32 y, u32 width, u32 height) -> void;
auto setSaturation(double saturation) -> void { _saturation = saturation; _palette.reset(); }
auto setGamma(double gamma) -> void { _gamma = gamma; _palette.reset(); }
auto setLuminance(double luminance) -> void { _luminance = luminance; _palette.reset(); }
auto setSize(u32 width, u32 height) -> void;
auto setScale(f64 scaleX, f64 scaleY) -> void;
auto setAspect(f64 aspectX, f64 aspectY) -> void;
auto setColorBleed(bool colorBleed) -> void { _colorBleed = colorBleed; }
auto setInterframeBlending(bool interframeBlending) -> void { _interframeBlending = interframeBlending; }
auto setRotation(uint rotation) -> void { _rotation = rotation; }
auto setSaturation(f64 saturation) -> void;
auto setGamma(f64 gamma) -> void;
auto setLuminance(f64 luminance) -> void;
auto attach(Node::Sprite) -> void;
auto detach(Node::Sprite) -> void;
auto setFillColor(u32 fillColor) -> void;
auto setColorBleed(bool colorBleed) -> void;
auto setInterframeBlending(bool interframeBlending) -> void;
auto setRotation(u32 rotation) -> void;
auto colors(uint colors, function<uint64 (uint32)> color) -> void;
auto refresh(uint32* input, uint pitch, uint width, uint height) -> void;
auto setProgressive(bool progressiveDouble = false) -> void;
auto setInterlace(bool interlaceField) -> void;
auto attach(Node::Video::Sprite) -> void;
auto detach(Node::Video::Sprite) -> void;
auto colors(u32 colors, function<n64 (n32)> color) -> void;
auto frame() -> void;
auto refresh() -> void;
auto serialize(string& output, string depth) -> void override;
auto unserialize(Markup::Node node) -> void override;
private:
auto refreshPalette() -> void;
protected:
uint _width = 0;
uint _height = 0;
double _scaleX = 1.0;
double _scaleY = 1.0;
double _aspectX = 1.0;
double _aspectY = 1.0;
uint _colors = 0;
double _saturation = 1.0;
double _gamma = 1.0;
double _luminance = 1.0;
u32 _canvasWidth = 0;
u32 _canvasHeight = 0;
u32 _width = 0;
u32 _height = 0;
f64 _scaleX = 1.0;
f64 _scaleY = 1.0;
f64 _aspectX = 1.0;
f64 _aspectY = 1.0;
u32 _colors = 0;
f64 _saturation = 1.0;
f64 _gamma = 1.0;
f64 _luminance = 1.0;
u32 _fillColor = 0;
bool _colorBleed = false;
bool _interframeBlending = false;
uint _rotation = 0; //counter-clockwise (90 = left, 270 = right)
u32 _rotation = 0; //counter-clockwise (90 = left, 270 = right)
function<uint64 (uint32)> _color;
unique_pointer<uint32[]> _buffer;
unique_pointer<uint32[]> _rotate;
unique_pointer<uint32[]> _palette;
vector<Node::Sprite> _sprites;
function<n64 (n32)> _color;
unique_pointer<u32> _inputA;
unique_pointer<u32> _inputB;
unique_pointer<u32> _output;
unique_pointer<u32> _rotate;
unique_pointer<u32[]> _palette;
vector<Node::Video::Sprite> _sprites;
uint _renderWidth = 0;
uint _renderHeight = 0;
//unserialized:
nall::thread _thread;
recursive_mutex _mutex;
atomic<bool> _kill = false;
atomic<bool> _frame = false;
function<void ()> _refresh;
bool _progressive = false;
bool _progressiveDouble = false;
bool _interlace = false;
bool _interlaceField = false;
u32 _viewportX = 0;
u32 _viewportY = 0;
u32 _viewportWidth = 0;
u32 _viewportHeight = 0;
};
+5 -5
View File
@@ -2,7 +2,7 @@ auto Sprite::setVisible(bool visible) -> void {
_visible = visible;
}
auto Sprite::setPosition(uint x, uint y) -> void {
auto Sprite::setPosition(u32 x, u32 y) -> void {
_x = x;
_y = y;
}
@@ -10,14 +10,14 @@ auto Sprite::setPosition(uint x, uint y) -> void {
auto Sprite::setImage(nall::image image, bool invert) -> void {
_width = image.width();
_height = image.height();
_pixels = new uint32[_width * _height];
_pixels = new u32[_width * _height];
image.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
memory::copy(_pixels.data(), _width * _height * sizeof(uint32), image.data(), image.size());
memory::copy(_pixels.data(), _width * _height * sizeof(u32), image.data(), image.size());
if(!invert) return;
for(uint y : range(_height)) {
for(u32 y : range(_height)) {
auto data = _pixels.data() + y * _width;
for(uint x : range(_width)) {
for(u32 x : range(_width)) {
auto pixel = data[x];
pixel ^= 0xffffff;
data[x] = pixel;
+14 -14
View File
@@ -1,23 +1,23 @@
struct Sprite : Object {
DeclareClass(Sprite, "Sprite")
using Object::Object;
struct Sprite : Video {
DeclareClass(Sprite, "video.sprite")
using Video::Video;
auto visible() const -> bool { return _visible; }
auto x() const -> uint { return _x; }
auto y() const -> uint { return _y; }
auto width() const -> uint { return _width; }
auto height() const -> uint { return _height; }
auto image() const -> const uint32* { return _pixels.data(); }
auto x() const -> u32 { return _x; }
auto y() const -> u32 { return _y; }
auto width() const -> u32 { return _width; }
auto height() const -> u32 { return _height; }
auto image() const -> array_view<u32> { return {_pixels.data(), _width * _height}; }
auto setVisible(bool visible) -> void;
auto setPosition(uint x, uint y) -> void;
auto setPosition(u32 x, u32 y) -> void;
auto setImage(nall::image, bool invert = false) -> void;
protected:
bool _visible = false;
uint _x = 0;
uint _y = 0;
uint _width = 0;
uint _height = 0;
unique_pointer<uint32[]> _pixels;
u32 _x = 0;
u32 _y = 0;
u32 _width = 0;
u32 _height = 0;
unique_pointer<u32[]> _pixels;
};
+4
View File
@@ -0,0 +1,4 @@
struct Video : Object {
DeclareClass(Video, "video");
using Object::Object;
};
+6 -5
View File
@@ -2,7 +2,7 @@
namespace ares {
enum class Event : uint {
enum class Event : u32 {
None,
Step,
Frame,
@@ -13,12 +13,12 @@ enum class Event : uint {
struct Platform {
virtual auto attach(Node::Object) -> void {}
virtual auto detach(Node::Object) -> void {}
virtual auto open(Node::Object, string name, vfs::file::mode mode, bool required = false) -> shared_pointer<vfs::file> { return {}; }
virtual auto pak(Node::Object) -> shared_pointer<vfs::directory> { return {}; }
virtual auto event(Event) -> void {}
virtual auto log(string_view message) -> void {}
virtual auto video(Node::Screen, const uint32_t* data, uint pitch, uint width, uint height) -> void {}
virtual auto audio(Node::Stream) -> void {}
virtual auto input(Node::Input) -> void {}
virtual auto video(Node::Video::Screen, const u32* data, u32 pitch, u32 width, u32 height) -> void {}
virtual auto audio(Node::Audio::Stream) -> void {}
virtual auto input(Node::Input::Input) -> void {}
};
extern Platform* platform;
@@ -26,6 +26,7 @@ extern Platform* platform;
}
namespace ares::Core {
// <ares/node/node.hpp> forward declarations
auto PlatformAttach(Node::Object node) -> void { if(platform && node->name()) platform->attach(node); }
auto PlatformDetach(Node::Object node) -> void { if(platform && node->name()) platform->detach(node); }
auto PlatformLog(string_view text) -> void { if(platform) platform->log(text); }
+30 -30
View File
@@ -3,9 +3,9 @@
namespace ares {
struct Random {
enum class Entropy : uint { None, Low, High };
enum class Entropy : u32 { None, Low, High };
auto operator()() -> uint64 {
auto operator()() -> n64 {
return random();
}
@@ -14,8 +14,8 @@ struct Random {
seed();
}
auto seed(maybe<uint32> seed = nothing, maybe<uint32> sequence = nothing) -> void {
if(!seed) seed = (uint32)clock();
auto seed(maybe<n32> seed = nothing, maybe<n32> sequence = nothing) -> void {
if(!seed) seed = (n32)clock();
if(!sequence) sequence = 0;
_state = 0;
@@ -25,72 +25,72 @@ struct Random {
step();
}
auto random() -> uint64 {
auto random() -> n64 {
if(_entropy == Entropy::None) return 0;
return (uint64)step() << 32 | (uint64)step() << 0;
return (n64)step() << 32 | (n64)step() << 0;
}
auto bias(uint64 bias) -> uint64 {
auto bias(n64 bias) -> n64 {
if(_entropy == Entropy::None) return bias;
return random();
}
auto bound(uint64 bound) -> uint64 {
uint64 threshold = -bound % bound;
auto bound(n64 bound) -> n64 {
n64 threshold = -bound % bound;
while(true) {
uint64 result = random();
n64 result = random();
if(result >= threshold) return result % bound;
}
}
auto array(uint8* data, uint32 size) -> void {
auto array(array_span<n8> buffer) -> void {
if(_entropy == Entropy::None) {
memory::fill(data, size);
memory::fill(buffer.data(), buffer.size());
return;
}
if(_entropy == Entropy::High) {
for(uint32 address : range(size)) {
data[address] = random();
for(n32 address : range(buffer.size())) {
buffer[address] = random();
}
return;
}
//Entropy::Low
uint lobit = random() & 3;
uint hibit = (lobit + 8 + (random() & 3)) & 15;
uint lovalue = random() & 255;
uint hivalue = random() & 255;
u32 lobit = random() & 3;
u32 hibit = (lobit + 8 + (random() & 3)) & 15;
u32 lovalue = random() & 255;
u32 hivalue = random() & 255;
if((random() & 3) == 0) lovalue = 0;
if((random() & 1) == 0) hivalue = ~lovalue;
for(uint32 address : range(size)) {
uint8 value = address.bit(lobit) ? lovalue : hivalue;
for(n32 address : range(buffer.size())) {
n8 value = address.bit(lobit) ? lovalue : hivalue;
if(address.bit(hibit)) value = ~value;
if((random() & 511) == 0) value.bit(random() & 7) ^= 1;
if((random() & 2047) == 0) value.bit(random() & 7) ^= 1;
data[address] = value;
buffer[address] = value;
}
}
auto serialize(serializer& s) -> void {
s.integer((uint&)_entropy);
s.integer(_state);
s.integer(_increment);
s((u32&)_entropy);
s(_state);
s(_increment);
}
private:
auto step() -> uint32 {
uint64 state = _state;
auto step() -> n32 {
n64 state = _state;
_state = state * 6364136223846793005ull + _increment;
uint32 xorshift = (state >> 18 ^ state) >> 27;
uint32 rotate = state >> 59;
n32 xorshift = (state >> 18 ^ state) >> 27;
n32 rotate = state >> 59;
return xorshift >> rotate | xorshift << (-rotate & 31);
}
Entropy _entropy = Entropy::High;
uint64 _state;
uint64 _increment;
n64 _state;
n64 _increment;
};
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

+4 -2
View File
@@ -1,7 +1,9 @@
namespace name=Resource
namespace name=Ares
binary name=Icon file=icon.png
binary name=Logo file=logo.png
binary name=Icon1x file=icon.png
binary name=Icon2x file=icon@2x.png
binary name=Logo1x file=logo.png
binary name=Logo2x [email protected]
namespace name=Sprite
namespace name=SuperFamicom
binary name=CrosshairBlue file=sprite/sfc/crosshair-blue.png
File diff suppressed because it is too large. Load diff
+4 -2
View File
@@ -1,7 +1,9 @@
namespace Resource {
namespace Ares {
extern const unsigned char Icon[6562];
extern const unsigned char Logo[13719];
extern const unsigned char Icon1x[6562];
extern const unsigned char Icon2x[9662];
extern const unsigned char Logo1x[11533];
extern const unsigned char Logo2x[18991];
}
namespace Sprite {
namespace SuperFamicom {
+8 -8
View File
@@ -2,11 +2,11 @@ inline auto Scheduler::reset() -> void {
_threads.reset();
}
inline auto Scheduler::threads() const -> uint {
inline auto Scheduler::threads() const -> u32 {
return _threads.size();
}
inline auto Scheduler::thread(uint uniqueID) const -> maybe<Thread&> {
inline auto Scheduler::thread(u32 uniqueID) const -> maybe<Thread&> {
for(auto& thread : _threads) {
if(thread->_uniqueID == uniqueID) return *thread;
}
@@ -16,15 +16,15 @@ inline auto Scheduler::thread(uint uniqueID) const -> maybe<Thread&> {
//if threads A and B both have a clock value of 0, it is ambiguous which should run first.
//to resolve this, a uniqueID is assigned to each thread when appended to the scheduler.
//the first unused ID is selected, to avoid the uniqueID growing in an unbounded fashion.
inline auto Scheduler::uniqueID() const -> uint {
uint uniqueID = 0;
inline auto Scheduler::uniqueID() const -> u32 {
u32 uniqueID = 0;
while(thread(uniqueID)) uniqueID++;
return uniqueID;
}
//find the clock time of the furthest behind thread.
inline auto Scheduler::minimum() const -> uintmax {
uintmax minimum = (uintmax)-1;
inline auto Scheduler::minimum() const -> u64 {
u64 minimum = (u64)-1;
for(auto& thread : _threads) {
minimum = min(minimum, thread->_clock - thread->_uniqueID);
}
@@ -32,8 +32,8 @@ inline auto Scheduler::minimum() const -> uintmax {
}
//find the clock time of the furthest ahead thread.
inline auto Scheduler::maximum() const -> uintmax {
uintmax maximum = 0;
inline auto Scheduler::maximum() const -> u64 {
u64 maximum = 0;
for(auto& thread : _threads) {
maximum = max(maximum, thread->_clock - thread->_uniqueID);
}
+6 -6
View File
@@ -1,7 +1,7 @@
struct Thread;
struct Scheduler {
enum class Mode : uint {
enum class Mode : u32 {
Run,
Synchronize,
SynchronizePrimary,
@@ -13,11 +13,11 @@ struct Scheduler {
auto operator=(const Scheduler&) = delete;
auto reset() -> void;
auto threads() const -> uint;
auto thread(uint threadID) const -> maybe<Thread&>;
auto uniqueID() const -> uint;
auto minimum() const -> uintmax;
auto maximum() const -> uintmax;
auto threads() const -> u32;
auto thread(u32 threadID) const -> maybe<Thread&>;
auto uniqueID() const -> u32;
auto minimum() const -> u64;
auto maximum() const -> u64;
auto append(Thread& thread) -> bool;
auto remove(Thread& thread) -> void;
+23 -22
View File
@@ -4,7 +4,7 @@ inline auto Thread::EntryPoints() -> vector<EntryPoint>& {
}
inline auto Thread::Enter() -> void {
for(uint64_t index : range(EntryPoints().size())) {
for(u32 index : range(EntryPoints().size())) {
if(co_active() == EntryPoints()[index].handle) {
auto entryPoint = EntryPoints()[index].entryPoint;
EntryPoints().remove(index);
@@ -24,9 +24,9 @@ inline Thread::~Thread() {
inline auto Thread::active() const -> bool { return co_active() == _handle; }
inline auto Thread::handle() const -> cothread_t { return _handle; }
inline auto Thread::frequency() const -> uintmax { return _frequency; }
inline auto Thread::scalar() const -> uintmax { return _scalar; }
inline auto Thread::clock() const -> uintmax { return _clock; }
inline auto Thread::frequency() const -> u64 { return _frequency; }
inline auto Thread::scalar() const -> u64 { return _scalar; }
inline auto Thread::clock() const -> u64 { return _clock; }
inline auto Thread::setHandle(cothread_t handle) -> void {
_handle = handle;
@@ -37,11 +37,11 @@ inline auto Thread::setFrequency(double frequency) -> void {
_scalar = Second / _frequency;
}
inline auto Thread::setScalar(uintmax scalar) -> void {
inline auto Thread::setScalar(u64 scalar) -> void {
_scalar = scalar;
}
inline auto Thread::setClock(uintmax clock) -> void {
inline auto Thread::setClock(u64 clock) -> void {
_clock = clock;
}
@@ -57,13 +57,19 @@ inline auto Thread::create(double frequency, function<void ()> entryPoint) -> vo
scheduler.append(*this);
}
//returns a thread to its entry point (eg for a reset), without resetting the clock value
inline auto Thread::restart(function<void()> entryPoint) -> void {
co_derive(_handle, Thread::Size, &Thread::Enter);
EntryPoints().append({_handle, entryPoint});
}
inline auto Thread::destroy() -> void {
scheduler.remove(*this);
if(_handle) co_delete(_handle);
_handle = nullptr;
}
inline auto Thread::step(uint clocks) -> void {
inline auto Thread::step(u32 clocks) -> void {
_clock += _scalar * clocks;
}
@@ -89,30 +95,25 @@ inline auto Thread::synchronize(Thread& thread, P&&... p) -> void {
}
inline auto Thread::serialize(serializer& s) -> void {
s.integer(_frequency);
s.integer(_scalar);
s.integer(_clock);
s(_frequency);
s(_scalar);
s(_clock);
if(!scheduler._synchronize) {
static uint8_t stack[Thread::Size];
static u8 stack[Thread::Size];
bool resume = co_active() == _handle;
if(s.mode() == serializer::Size) {
s.array(stack, Thread::Size);
s.boolean(resume);
}
if(s.mode() == serializer::Load) {
s.array(stack, Thread::Size);
s.boolean(resume);
if(s.reading()) {
s(stack);
s(resume);
memory::copy(_handle, stack, Thread::Size);
if(resume) scheduler._resume = _handle;
}
if(s.mode() == serializer::Save) {
if(s.writing()) {
memory::copy(stack, _handle, Thread::Size);
s.array(stack, Thread::Size);
s.boolean(resume);
s(stack);
s(resume);
}
}
}
+13 -12
View File
@@ -1,8 +1,8 @@
struct Scheduler;
struct Thread {
enum : uintmax { Second = (uintmax)-1 >> 1 };
enum : uintmax { Size = 8_KiB * sizeof(void*) };
enum : u64 { Second = (u64)-1 >> 1 };
enum : u64 { Size = 16_KiB * sizeof(void*) };
struct EntryPoint {
cothread_t handle = nullptr;
@@ -20,19 +20,20 @@ struct Thread {
explicit operator bool() const { return _handle; }
auto active() const -> bool;
auto handle() const -> cothread_t;
auto frequency() const -> uintmax;
auto scalar() const -> uintmax;
auto clock() const -> uintmax;
auto frequency() const -> u64;
auto scalar() const -> u64;
auto clock() const -> u64;
auto setHandle(cothread_t handle) -> void;
auto setFrequency(double frequency) -> void;
auto setScalar(uintmax scalar) -> void;
auto setClock(uintmax clock) -> void;
auto setScalar(u64 scalar) -> void;
auto setClock(u64 clock) -> void;
auto create(double frequency, function<void ()> entryPoint) -> void;
auto restart(function<void ()> entryPoint) -> void;
auto destroy() -> void;
auto step(uint clocks) -> void;
auto step(u32 clocks) -> void;
auto synchronize() -> void;
template<typename... P> auto synchronize(Thread&, P&&...) -> void;
@@ -40,10 +41,10 @@ struct Thread {
protected:
cothread_t _handle = nullptr;
uint _uniqueID = 0;
uintmax _frequency = 0;
uintmax _scalar = 0;
uintmax _clock = 0;
u32 _uniqueID = 0;
u64 _frequency = 0;
u64 _scalar = 0;
u64 _clock = 0;
friend class Scheduler;
};
+131 -141
View File
@@ -1,144 +1,134 @@
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using i128 = int128_t;
using b1 = nall::Boolean;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using u128 = uint128_t;
using i1 = nall::Integer< 1>; using s1 = nall::IntegerPrimitive< 1>;
using i2 = nall::Integer< 2>; using s2 = nall::IntegerPrimitive< 2>;
using i3 = nall::Integer< 3>; using s3 = nall::IntegerPrimitive< 3>;
using i4 = nall::Integer< 4>; using s4 = nall::IntegerPrimitive< 4>;
using i5 = nall::Integer< 5>; using s5 = nall::IntegerPrimitive< 5>;
using i6 = nall::Integer< 6>; using s6 = nall::IntegerPrimitive< 6>;
using i7 = nall::Integer< 7>; using s7 = nall::IntegerPrimitive< 7>;
using i8 = nall::Integer< 8>;
using i9 = nall::Integer< 9>; using s9 = nall::IntegerPrimitive< 9>;
using i10 = nall::Integer<10>; using s10 = nall::IntegerPrimitive<10>;
using i11 = nall::Integer<11>; using s11 = nall::IntegerPrimitive<11>;
using i12 = nall::Integer<12>; using s12 = nall::IntegerPrimitive<12>;
using i13 = nall::Integer<13>; using s13 = nall::IntegerPrimitive<13>;
using i14 = nall::Integer<14>; using s14 = nall::IntegerPrimitive<14>;
using i15 = nall::Integer<15>; using s15 = nall::IntegerPrimitive<15>;
using i16 = nall::Integer<16>;
using i17 = nall::Integer<17>; using s17 = nall::IntegerPrimitive<17>;
using i18 = nall::Integer<18>; using s18 = nall::IntegerPrimitive<18>;
using i19 = nall::Integer<19>; using s19 = nall::IntegerPrimitive<19>;
using i20 = nall::Integer<20>; using s20 = nall::IntegerPrimitive<20>;
using i21 = nall::Integer<21>; using s21 = nall::IntegerPrimitive<21>;
using i22 = nall::Integer<22>; using s22 = nall::IntegerPrimitive<22>;
using i23 = nall::Integer<23>; using s23 = nall::IntegerPrimitive<23>;
using i24 = nall::Integer<24>; using s24 = nall::IntegerPrimitive<24>;
using i25 = nall::Integer<25>; using s25 = nall::IntegerPrimitive<25>;
using i26 = nall::Integer<26>; using s26 = nall::IntegerPrimitive<26>;
using i27 = nall::Integer<27>; using s27 = nall::IntegerPrimitive<27>;
using i28 = nall::Integer<28>; using s28 = nall::IntegerPrimitive<28>;
using i29 = nall::Integer<29>; using s29 = nall::IntegerPrimitive<29>;
using i30 = nall::Integer<30>; using s30 = nall::IntegerPrimitive<30>;
using i31 = nall::Integer<31>; using s31 = nall::IntegerPrimitive<31>;
using i32 = nall::Integer<32>;
using i33 = nall::Integer<33>; using s33 = nall::IntegerPrimitive<33>;
using i34 = nall::Integer<34>; using s34 = nall::IntegerPrimitive<34>;
using i35 = nall::Integer<35>; using s35 = nall::IntegerPrimitive<35>;
using i36 = nall::Integer<36>; using s36 = nall::IntegerPrimitive<36>;
using i37 = nall::Integer<37>; using s37 = nall::IntegerPrimitive<37>;
using i38 = nall::Integer<38>; using s38 = nall::IntegerPrimitive<38>;
using i39 = nall::Integer<39>; using s39 = nall::IntegerPrimitive<39>;
using i40 = nall::Integer<40>; using s40 = nall::IntegerPrimitive<40>;
using i41 = nall::Integer<41>; using s41 = nall::IntegerPrimitive<41>;
using i42 = nall::Integer<42>; using s42 = nall::IntegerPrimitive<42>;
using i43 = nall::Integer<43>; using s43 = nall::IntegerPrimitive<43>;
using i44 = nall::Integer<44>; using s44 = nall::IntegerPrimitive<44>;
using i45 = nall::Integer<45>; using s45 = nall::IntegerPrimitive<45>;
using i46 = nall::Integer<46>; using s46 = nall::IntegerPrimitive<46>;
using i47 = nall::Integer<47>; using s47 = nall::IntegerPrimitive<47>;
using i48 = nall::Integer<48>; using s48 = nall::IntegerPrimitive<48>;
using i49 = nall::Integer<49>; using s49 = nall::IntegerPrimitive<49>;
using i50 = nall::Integer<50>; using s50 = nall::IntegerPrimitive<50>;
using i51 = nall::Integer<51>; using s51 = nall::IntegerPrimitive<51>;
using i52 = nall::Integer<52>; using s52 = nall::IntegerPrimitive<52>;
using i53 = nall::Integer<53>; using s53 = nall::IntegerPrimitive<53>;
using i54 = nall::Integer<54>; using s54 = nall::IntegerPrimitive<54>;
using i55 = nall::Integer<55>; using s55 = nall::IntegerPrimitive<55>;
using i56 = nall::Integer<56>; using s56 = nall::IntegerPrimitive<56>;
using i57 = nall::Integer<57>; using s57 = nall::IntegerPrimitive<57>;
using i58 = nall::Integer<58>; using s58 = nall::IntegerPrimitive<58>;
using i59 = nall::Integer<59>; using s59 = nall::IntegerPrimitive<59>;
using i60 = nall::Integer<60>; using s60 = nall::IntegerPrimitive<60>;
using i61 = nall::Integer<61>; using s61 = nall::IntegerPrimitive<61>;
using i62 = nall::Integer<62>; using s62 = nall::IntegerPrimitive<62>;
using i63 = nall::Integer<63>; using s63 = nall::IntegerPrimitive<63>;
using i64 = nall::Integer<64>;
using f32 = float32_t;
using f64 = float64_t;
using n1 = nall::Natural< 1>; using u1 = nall::NaturalPrimitive< 1>;
using n2 = nall::Natural< 2>; using u2 = nall::NaturalPrimitive< 2>;
using n3 = nall::Natural< 3>; using u3 = nall::NaturalPrimitive< 3>;
using n4 = nall::Natural< 4>; using u4 = nall::NaturalPrimitive< 4>;
using n5 = nall::Natural< 5>; using u5 = nall::NaturalPrimitive< 5>;
using n6 = nall::Natural< 6>; using u6 = nall::NaturalPrimitive< 6>;
using n7 = nall::Natural< 7>; using u7 = nall::NaturalPrimitive< 7>;
using n8 = nall::Natural< 8>;
using n9 = nall::Natural< 9>; using u9 = nall::NaturalPrimitive< 9>;
using n10 = nall::Natural<10>; using u10 = nall::NaturalPrimitive<10>;
using n11 = nall::Natural<11>; using u11 = nall::NaturalPrimitive<11>;
using n12 = nall::Natural<12>; using u12 = nall::NaturalPrimitive<12>;
using n13 = nall::Natural<13>; using u13 = nall::NaturalPrimitive<13>;
using n14 = nall::Natural<14>; using u14 = nall::NaturalPrimitive<14>;
using n15 = nall::Natural<15>; using u15 = nall::NaturalPrimitive<15>;
using n16 = nall::Natural<16>;
using n17 = nall::Natural<17>; using u17 = nall::NaturalPrimitive<17>;
using n18 = nall::Natural<18>; using u18 = nall::NaturalPrimitive<18>;
using n19 = nall::Natural<19>; using u19 = nall::NaturalPrimitive<19>;
using n20 = nall::Natural<20>; using u20 = nall::NaturalPrimitive<20>;
using n21 = nall::Natural<21>; using u21 = nall::NaturalPrimitive<21>;
using n22 = nall::Natural<22>; using u22 = nall::NaturalPrimitive<22>;
using n23 = nall::Natural<23>; using u23 = nall::NaturalPrimitive<23>;
using n24 = nall::Natural<24>; using u24 = nall::NaturalPrimitive<24>;
using n25 = nall::Natural<25>; using u25 = nall::NaturalPrimitive<25>;
using n26 = nall::Natural<26>; using u26 = nall::NaturalPrimitive<26>;
using n27 = nall::Natural<27>; using u27 = nall::NaturalPrimitive<27>;
using n28 = nall::Natural<28>; using u28 = nall::NaturalPrimitive<28>;
using n29 = nall::Natural<29>; using u29 = nall::NaturalPrimitive<29>;
using n30 = nall::Natural<30>; using u30 = nall::NaturalPrimitive<30>;
using n31 = nall::Natural<31>; using u31 = nall::NaturalPrimitive<31>;
using n32 = nall::Natural<32>;
using n33 = nall::Natural<33>; using u33 = nall::NaturalPrimitive<33>;
using n34 = nall::Natural<34>; using u34 = nall::NaturalPrimitive<34>;
using n35 = nall::Natural<35>; using u35 = nall::NaturalPrimitive<35>;
using n36 = nall::Natural<36>; using u36 = nall::NaturalPrimitive<36>;
using n37 = nall::Natural<37>; using u37 = nall::NaturalPrimitive<37>;
using n38 = nall::Natural<38>; using u38 = nall::NaturalPrimitive<38>;
using n39 = nall::Natural<39>; using u39 = nall::NaturalPrimitive<39>;
using n40 = nall::Natural<40>; using u40 = nall::NaturalPrimitive<40>;
using n41 = nall::Natural<41>; using u41 = nall::NaturalPrimitive<41>;
using n42 = nall::Natural<42>; using u42 = nall::NaturalPrimitive<42>;
using n43 = nall::Natural<43>; using u43 = nall::NaturalPrimitive<43>;
using n44 = nall::Natural<44>; using u44 = nall::NaturalPrimitive<44>;
using n45 = nall::Natural<45>; using u45 = nall::NaturalPrimitive<45>;
using n46 = nall::Natural<46>; using u46 = nall::NaturalPrimitive<46>;
using n47 = nall::Natural<47>; using u47 = nall::NaturalPrimitive<47>;
using n48 = nall::Natural<48>; using u48 = nall::NaturalPrimitive<48>;
using n49 = nall::Natural<49>; using u49 = nall::NaturalPrimitive<49>;
using n50 = nall::Natural<50>; using u50 = nall::NaturalPrimitive<50>;
using n51 = nall::Natural<51>; using u51 = nall::NaturalPrimitive<51>;
using n52 = nall::Natural<52>; using u52 = nall::NaturalPrimitive<52>;
using n53 = nall::Natural<53>; using u53 = nall::NaturalPrimitive<53>;
using n54 = nall::Natural<54>; using u54 = nall::NaturalPrimitive<54>;
using n55 = nall::Natural<55>; using u55 = nall::NaturalPrimitive<55>;
using n56 = nall::Natural<56>; using u56 = nall::NaturalPrimitive<56>;
using n57 = nall::Natural<57>; using u57 = nall::NaturalPrimitive<57>;
using n58 = nall::Natural<58>; using u58 = nall::NaturalPrimitive<58>;
using n59 = nall::Natural<59>; using u59 = nall::NaturalPrimitive<59>;
using n60 = nall::Natural<60>; using u60 = nall::NaturalPrimitive<60>;
using n61 = nall::Natural<61>; using u61 = nall::NaturalPrimitive<61>;
using n62 = nall::Natural<62>; using u62 = nall::NaturalPrimitive<62>;
using n63 = nall::Natural<63>; using u63 = nall::NaturalPrimitive<63>;
using n64 = nall::Natural<64>;
using int1 = nall::Integer< 1>;
using int2 = nall::Integer< 2>;
using int3 = nall::Integer< 3>;
using int4 = nall::Integer< 4>;
using int5 = nall::Integer< 5>;
using int6 = nall::Integer< 6>;
using int7 = nall::Integer< 7>;
using int8 = nall::Integer< 8>;
using int9 = nall::Integer< 9>;
using int10 = nall::Integer<10>;
using int11 = nall::Integer<11>;
using int12 = nall::Integer<12>;
using int13 = nall::Integer<13>;
using int14 = nall::Integer<14>;
using int15 = nall::Integer<15>;
using int16 = nall::Integer<16>;
using int17 = nall::Integer<17>;
using int18 = nall::Integer<18>;
using int19 = nall::Integer<19>;
using int20 = nall::Integer<20>;
using int21 = nall::Integer<21>;
using int22 = nall::Integer<22>;
using int23 = nall::Integer<23>;
using int24 = nall::Integer<24>;
using int25 = nall::Integer<25>;
using int26 = nall::Integer<26>;
using int27 = nall::Integer<27>;
using int28 = nall::Integer<28>;
using int29 = nall::Integer<29>;
using int30 = nall::Integer<30>;
using int31 = nall::Integer<31>;
using int32 = nall::Integer<32>;
using int33 = nall::Integer<33>;
using int34 = nall::Integer<34>;
using int35 = nall::Integer<35>;
using int36 = nall::Integer<36>;
using int37 = nall::Integer<37>;
using int38 = nall::Integer<38>;
using int39 = nall::Integer<39>;
using int40 = nall::Integer<40>;
using int41 = nall::Integer<41>;
using int42 = nall::Integer<42>;
using int43 = nall::Integer<43>;
using int44 = nall::Integer<44>;
using int45 = nall::Integer<45>;
using int46 = nall::Integer<46>;
using int47 = nall::Integer<47>;
using int48 = nall::Integer<48>;
using int49 = nall::Integer<49>;
using int50 = nall::Integer<50>;
using int51 = nall::Integer<51>;
using int52 = nall::Integer<52>;
using int53 = nall::Integer<53>;
using int54 = nall::Integer<54>;
using int55 = nall::Integer<55>;
using int56 = nall::Integer<56>;
using int57 = nall::Integer<57>;
using int58 = nall::Integer<58>;
using int59 = nall::Integer<59>;
using int60 = nall::Integer<60>;
using int61 = nall::Integer<61>;
using int62 = nall::Integer<62>;
using int63 = nall::Integer<63>;
using int64 = nall::Integer<64>;
using uint1 = nall::Natural< 1>;
using uint2 = nall::Natural< 2>;
using uint3 = nall::Natural< 3>;
using uint4 = nall::Natural< 4>;
using uint5 = nall::Natural< 5>;
using uint6 = nall::Natural< 6>;
using uint7 = nall::Natural< 7>;
using uint8 = nall::Natural< 8>;
using uint9 = nall::Natural< 9>;
using uint10 = nall::Natural<10>;
using uint11 = nall::Natural<11>;
using uint12 = nall::Natural<12>;
using uint13 = nall::Natural<13>;
using uint14 = nall::Natural<14>;
using uint15 = nall::Natural<15>;
using uint16 = nall::Natural<16>;
using uint17 = nall::Natural<17>;
using uint18 = nall::Natural<18>;
using uint19 = nall::Natural<19>;
using uint20 = nall::Natural<20>;
using uint21 = nall::Natural<21>;
using uint22 = nall::Natural<22>;
using uint23 = nall::Natural<23>;
using uint24 = nall::Natural<24>;
using uint25 = nall::Natural<25>;
using uint26 = nall::Natural<26>;
using uint27 = nall::Natural<27>;
using uint28 = nall::Natural<28>;
using uint29 = nall::Natural<29>;
using uint30 = nall::Natural<30>;
using uint31 = nall::Natural<31>;
using uint32 = nall::Natural<32>;
using uint33 = nall::Natural<33>;
using uint34 = nall::Natural<34>;
using uint35 = nall::Natural<35>;
using uint36 = nall::Natural<36>;
using uint37 = nall::Natural<37>;
using uint38 = nall::Natural<38>;
using uint39 = nall::Natural<39>;
using uint40 = nall::Natural<40>;
using uint41 = nall::Natural<41>;
using uint42 = nall::Natural<42>;
using uint43 = nall::Natural<43>;
using uint44 = nall::Natural<44>;
using uint45 = nall::Natural<45>;
using uint46 = nall::Natural<46>;
using uint47 = nall::Natural<47>;
using uint48 = nall::Natural<48>;
using uint49 = nall::Natural<49>;
using uint50 = nall::Natural<50>;
using uint51 = nall::Natural<51>;
using uint52 = nall::Natural<52>;
using uint53 = nall::Natural<53>;
using uint54 = nall::Natural<54>;
using uint55 = nall::Natural<55>;
using uint56 = nall::Natural<56>;
using uint57 = nall::Natural<57>;
using uint58 = nall::Natural<58>;
using uint59 = nall::Natural<59>;
using uint60 = nall::Natural<60>;
using uint61 = nall::Natural<61>;
using uint62 = nall::Natural<62>;
using uint63 = nall::Natural<63>;
using uint64 = nall::Natural<64>;
using r32 = nall::Real<32>;
using r64 = nall::Real<64>;
+16 -4
View File
@@ -6,18 +6,24 @@ ares.objects += $(if $(findstring sn76489,$(ares.components)),ares-audio-sn76489
ares.objects += $(if $(findstring t6w28,$(ares.components)),ares-audio-t6w28)
ares.objects += $(if $(findstring ym2149,$(ares.components)),ares-audio-ym2149)
ares.objects += $(if $(findstring ym2413,$(ares.components)),ares-audio-ym2413)
ares.objects += $(if $(findstring ym2610,$(ares.components)),ares-audio-ym2610)
ares.objects += $(if $(findstring ym2612,$(ares.components)),ares-audio-ym2612)
ares.objects += $(if $(findstring m24c,$(ares.components)),ares-eeprom-m24c)
ares.objects += $(if $(findstring m93lcx6,$(ares.components)),ares-eeprom-m93lcx6)
ares.objects += $(if $(findstring x24c01,$(ares.components)),ares-eeprom-x24c01)
ares.objects += $(if $(findstring arm7tdmi,$(ares.components)),ares-processor-arm7tdmi)
ares.objects += $(if $(findstring gsu,$(ares.components)),ares-processor-gsu)
ares.objects += $(if $(findstring hg51b,$(ares.components)),ares-processor-hg51b)
ares.objects += $(if $(findstring huc6280,$(ares.components)),ares-processor-huc6280)
ares.objects += $(if $(findstring m68k,$(ares.components)),ares-processor-m68k)
ares.objects += $(if $(findstring m68hc05,$(ares.components)),ares-processor-m68hc05)
ares.objects += $(if $(findstring m68000,$(ares.components)),ares-processor-m68000)
ares.objects += $(if $(findstring mos6502,$(ares.components)),ares-processor-mos6502)
ares.objects += $(if $(findstring sh2,$(ares.components)),ares-processor-sh2)
ares.objects += $(if $(findstring sm5k,$(ares.components)),ares-processor-sm5k)
ares.objects += $(if $(findstring sm83,$(ares.components)),ares-processor-sm83)
ares.objects += $(if $(findstring spc700,$(ares.components)),ares-processor-spc700)
ares.objects += $(if $(findstring ssp1601,$(ares.components)),ares-processor-ssp1601)
ares.objects += $(if $(findstring tlcs900h,$(ares.components)),ares-processor-tlcs900h)
ares.objects += $(if $(findstring upd96050,$(ares.components)),ares-processor-upd96050)
ares.objects += $(if $(findstring v30mz,$(ares.components)),ares-processor-v30mz)
@@ -33,18 +39,24 @@ $(object.path)/ares-audio-sn76489.o: $(ares.path)/component/audio/sn76489/s
$(object.path)/ares-audio-t6w28.o: $(ares.path)/component/audio/t6w28/t6w28.cpp
$(object.path)/ares-audio-ym2149.o: $(ares.path)/component/audio/ym2149/ym2149.cpp
$(object.path)/ares-audio-ym2413.o: $(ares.path)/component/audio/ym2413/ym2413.cpp
$(object.path)/ares-audio-ym2610.o: $(ares.path)/component/audio/ym2610/ym2610.cpp
$(object.path)/ares-audio-ym2612.o: $(ares.path)/component/audio/ym2612/ym2612.cpp
$(object.path)/ares-eeprom-m24c.o: $(ares.path)/component/eeprom/m24c/m24c.cpp
$(object.path)/ares-eeprom-m93lcx6.o: $(ares.path)/component/eeprom/m93lcx6/m93lcx6.cpp
$(object.path)/ares-eeprom-x24c01.o: $(ares.path)/component/eeprom/x24c01/x24c01.cpp
$(object.path)/ares-processor-arm7tdmi.o: $(ares.path)/component/processor/arm7tdmi/arm7tdmi.cpp
$(object.path)/ares-processor-gsu.o: $(ares.path)/component/processor/gsu/gsu.cpp
$(object.path)/ares-processor-hg51b.o: $(ares.path)/component/processor/hg51b/hg51b.cpp
$(object.path)/ares-processor-huc6280.o: $(ares.path)/component/processor/huc6280/huc6280.cpp
$(object.path)/ares-processor-m68k.o: $(ares.path)/component/processor/m68k/m68k.cpp
$(object.path)/ares-processor-m68hc05.o: $(ares.path)/component/processor/m68hc05/m68hc05.cpp
$(object.path)/ares-processor-m68000.o: $(ares.path)/component/processor/m68000/m68000.cpp
$(object.path)/ares-processor-mos6502.o: $(ares.path)/component/processor/mos6502/mos6502.cpp
$(object.path)/ares-processor-sh2.o: $(ares.path)/component/processor/sh2/sh2.cpp
$(object.path)/ares-processor-sm5k.o: $(ares.path)/component/processor/sm5k/sm5k.cpp
$(object.path)/ares-processor-sm83.o: $(ares.path)/component/processor/sm83/sm83.cpp
$(object.path)/ares-processor-spc700.o: $(ares.path)/component/processor/spc700/spc700.cpp
$(object.path)/ares-processor-ssp1601.o: $(ares.path)/component/processor/ssp1601/ssp1601.cpp
$(object.path)/ares-processor-tlcs900h.o: $(ares.path)/component/processor/tlcs900h/tlcs900h.cpp
$(object.path)/ares-processor-upd96050.o: $(ares.path)/component/processor/upd96050/upd96050.cpp
$(object.path)/ares-processor-v30mz.o: $(ares.path)/component/processor/v30mz/v30mz.cpp
Loaded 100 of 2749 files, more files were not shown because too many files have changed in this diff. Show more