Broadcast has a Default entry in the settings (value 4), but
fixUpDCFlash() only writes values in range, so Default left the flash
byte alone: NTSC from the factory block on a fresh flash, or whatever
the last explicit choice had written. A PAL game booted in NTSC with
Broadcast on Default.
Region's own Default is resolved from IP.BIN just above; resolve
Broadcast the same way: PAL for Europe, NTSC otherwise. Applied with
override() at load, like the region, so the saved setting stays Default.
Testing: compiles on macOS arm64.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without threaded rendering a run ends when a frame is presented, or
after 50 ms of emulated time without one. Frontends that pace retro_run
by the frame rate instead of blocking on audio, Kodi among them, then
get several vblanks per run through loading screens and have to drop
the extra audio. With the option on, every run ends at the next vblank.
[ci skip]
SDL_GameControllerButtonBind2 is a struct over a union whose first member
is `int button`. `bind{}` zero-initializes that member only, so
value.axis.direction holds whatever was on the stack. getBindForAxis()
assigns it only when the mapping has a '+' or '-' prefix or a '~'
suffix; for a plain "lefttrigger:a4" it is returned as read, and the
full-axis branch at the end tests it too. At -O2 on macOS/arm64 a
lefttrigger lookup came back with direction 1 instead of 0 and
"-lefty:-a1" with 1 instead of -1; SDLControllerMappingTest.split_axis
and .reverse_axis fail there. The value just happened to be 0 on Linux.
Set axis and direction to 0 before parsing the axis.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
MapleDevices[][] in maple_if.cpp holds shared_ptr<maple_device>s with
static storage, so the VMUs are destroyed when the process exits.
~maple_sega_vmu() clears the LCD on any attached maple link, which goes
through MapleLink::GetMapleLink() and locks MapleLink::Mutex, another
object with static storage, in another translation unit, that may
already be gone. With libc++ locking a destroyed mutex throws
("mutex lock failed: Invalid argument") and the process aborts; the
unit test binary exits with SIGABRT on macOS after every test passed.
On glibc the same lock happens to succeed, which is why Linux never
showed it. The Links table is read in the same state.
Give both to function-local statics that are allocated once and never
destroyed, so they outlive everything that can still reach them.
Co-authored-by: Claude Fable 5.1 <[email protected]>
[ci skip]
On ARMv7, AND, EOR, ORR, BIC, MOV, MVN, TST and TEQ with the S bit set
leave V unchanged. The AArch64 instructions the recompiler uses for them
(ANDS, BICS, TST) clear V, and storeFlags() wrote the host NZCV back as
is, so every flag-setting logical op cleared the guest's V. A signed
conditional branch (BVS, BGE, BLT, BGT, BLE) after such an op then went
the wrong way. The x64 recompiler already preserves V for these ops
(saveFlags(save_v_flag)); the interpreter does too.
[ci skip]
TST and TEQ had a save/restore under STRICT_MODE with a note that nobody
probably relies on it. That path was never built, and it did not cover
ANDS, EORS, ORRS, BICS, MOVS or MVNS.
Restore V after the op from the PSR that loadFlags() loaded before it,
in the same place the shifter carry is merged, for every logical op that
sets flags. Three instructions, only on those ops.
AicaArmTest.LogicOpsTest asserted exactly this (teq with C,V set must
keep V) and failed on arm64; it passes now, with the rest of the suite.
Co-authored-by: Claude Fable 5.1 <[email protected]>
readConst, writeConst, readt and writet shift the 32-bit guest address by
the whole tagged memInfo_ptr value (pointer | shift). Shifting a u32 by 32
or more is undefined, and GCC 16 targeting 32-bit ARM uses that: once the
pointer is known to be non-null (iirf > 31) it drops the offset, so
read32/write16 compile to a plain load/store at the region base. Every
memory access then hits offset 0, the BIOS trampoline copied to 8C0000E0
is lost and the console never boots (black screen, no sound).
Mask the shift with HANDLER_MAX, which is what x86 does in hardware and
what the code intends. No change in behaviour where the old code worked.
Co-authored-by: hitenmandalia <[email protected]>
[ci skip]
Received frames were passed to the RTL8139 from the network thread,
raising the ASIC interrupt there and racing SIIDRebuild() on the SH-4
thread. Queue them and deliver them from an SH-4 scheduler callback.
Sent frames were pushed into picoTCP from the SH-4 thread, but picoTCP
is built without PICO_SUPPORT_MUTEX so its device queue is unlocked.
Queue them and feed them to picoTCP from the pico thread before each
stack tick.
[ci skip]
Vulkan without VK_EXT_provoking_vertex, DX9 and DX11 take flat-shaded
colors from the first vertex, while on Dreamcast it's the last. For the
depth-sorted triangle list, setFirstProvokingVertex() copied each
triangle's last vertex colors onto its first vertex. But sortTriangles()
builds these triangles from strips, so neighbors share vertices:
tri0=(P0,P1,P2), tri1=(P2,P1,P3). P2 is tri0's source and tri1's
destination, and the list is processed in depth order, so one
triangle's flat color can overwrite another's before it's read. In
strips of three or more triangles, consecutive triangles even share
their first vertex. Flat-shaded translucent polygons then pick up a
neighbor's color, e.g. the player shadow decals in Tony Hawk's Pro
Skater 2 and Mat Hoffman's Pro BMX turn uniformly dark.
Each sorted triangle has its own three slots in idx, so rotate them
(a,b,c) -> (c,a,b) instead. The winding is unchanged and the provoking
vertex comes first, without touching shared vertices. Strips keep the
color copy, which is safe there.
Adds SorterTest, which fails on the old code and passes with this change.
Co-authored-by: Claude Opus 5.5 <[email protected]>
[ci skip]
When nvmem is disabled, termMappings() frees main RAM, VRAM, ARAM and
the Elan RAM but leaves memInfo_ptr unchanged. Each entry still holds
the old host base, so any guest access before the next remap returns a
pointer into freed memory.
Zero the table, as init() does. A null entry routes to handler 0,
readMemNotMapped/writeMemNotMapped, which only log.
Co-authored-by: Claude Opus 5.5 <[email protected]>
[ci skip]
- Bump action versions
- Improve ccache support
- Reformat files
- Replace chkfung/android-version-actions and mathieu-bour/setup-sentry-cli from android workflow
- Update MoltenVK to use the latest official tag
- Update BSD operating systems
Export only retro_* from the core, as the osx build does with
libretro.osx.def. Symbols the core exports bind to same-named ones
the frontend already loaded: RetroArch builds with their builtin
glslang made the Vulkan renderer crash in GlslangToSpv on its first
shader compile, and with a system glslang loaded (ffmpeg ->
libplacebo -> shaderc) 33 glslang entry points, zstd, zlib and
stb_image still went to those copies.
A frontend may size its savestate buffer once, as libretro.h allows,
but a state grows and shrinks with the devices plugged in and the
frames being drawn, and states then outgrow the buffer. Report the
system's memory regions plus the allowance GGPO makes for everything
else, which is constant for a game.
System SP gets NAOMI's allowance, plus the game's media if it has one:
the media is loaded into memory-backed RAM, so a state holds all of it.
[ci skip]
xbrz::scale() only implements factors 2 to 6. Any other value hits an
assert that's compiled out in release builds, and scale() returns
without writing the destination buffer. The texture is then uploaded
from uninitialized memory at the requested size.
rend.TextureUpscale2 can be set to 8 or 16 through emu.cfg or Lua.
Clamp the factor once and use it for the buffer size, the scale call
and the upscaled dimensions so they always agree.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
temp_value was a file-scope global shared by every CDI parse. The boxart
scraper opens discs on its own thread, so it can parse a CDI while a
game is loading and corrupt the other parse's reads.
Use a local in each function. It's a uint32_t initialized to 0 because
every read into it is 4 bytes; a local unsigned long would leave the top
half uninitialized on LP64.
Co-authored-by: Claude Opus 5.5 <[email protected]>
[ci skip]
dc_deserialize() read the broadcast, cable and region settings straight
into the config and checked them with verify(), so a corrupt or
incompatible state killed the process, after already writing the bad
values into the settings.
Read them into locals and throw Deserializer::Exception when one is out
of range. dc_loadstate() and the libretro core already catch it and
report the state as unusable. Valid states load exactly as before.
Co-authored-by: Claude Opus 5.5 <[email protected]>
[ci skip]
The in-RAM save hotkey called gui_saveState(false, true), which runs
dc_serialize() without stopping the emulator. With threaded rendering
on (the default), the SH4 and AICA keep running on the emulator thread
while the input thread serializes, so the state can be torn: memory and
registers from different moments.
Stop and restart around the save like the disk save hotkey and the
in-RAM load hotkey already do.
Co-authored-by: Claude Opus 5.5 <[email protected]>
[ci skip]
The callback was only ever taken once. A frontend that loads a fresh
instance of itself for the next game, as Kodi does, keeps the core
loaded, so the next GD-ROM light change called into the unloaded one.
[ci skip]
Add the missing dump_unique_textures core-option definition beside the
existing texture-dump options. This prevents findDefinition() from
returning null when the frontend supplies a value for this option.
Default to disabled to match the implicit false config default, and use
the existing setting description for skipping video and animated textures.
findNaomiBios checked for the BIOS archive with access(), so a frontend
watching its VFS never saw it being looked for, unlike findFlash, which
already uses path_is_valid. Kodi uses that to name the file a core is
missing.
[ci skip]
RAM base and Sh4Cntx address might change on libretro without Init being
called. So set the correct Sh4Cntx address on Reset and propagate to
dynarec, cycle counter and caches.
[ci skip]
GGPO parses the peer address with inet_pton() only, so a host name in
the Peer field silently becomes 0.0.0.0 and the session never syncs,
without any error. Resolve non-numeric addresses with getaddrinfo()
before handing them to GGPO, and fail with a clear message when the
name cannot be resolved.
Co-authored-by: unjordi <[email protected]>
[ci skip]
Since the switch to hostfs::File (#2299), MD5Sum::add(hostfs::File *)
resolved to the generic add(const T&) template, which hashes the pointer
value. The resulting digests depend on the heap address, so they differ
between peers and between runs. This breaks GGPO peer verification when
a .state.net savestate is used (stateMD5), and with CDI, GDI and CUE
images (gameMD5).
Add an MD5Sum::add(hostfs::File *) overload that hashes the whole file
content, like the std::FILE overload, and reject pointer types in the
template with a static_assert so this cannot happen again silently.
Co-authored-by: unjordi <[email protected]>
[ci skip]
On the SH4 every FPU instruction clears the FPSCR cause field before it
executes, and sets a cause bit only if it raises an FPU exception.
Flycast doesn't update the cause field in FPU instructions, so a cause
bit that the guest writes back with lds/lds.l stays set forever.
Kita He. White Illumination (T14301M) resets to the BIOS when a karaoke
song starts (issue #1058). TRFDRAW.DLL inverts a 4x4 matrix with an LU
decomposition whose pivot comparison helper saves FPSCR, runs fcmp/gt and
reads FPSCR back: a set cause.V means an unordered (NaN) comparison. With
a stale cause.V every comparison looks unordered, no pivot row is chosen,
and the uninitialized pivot index makes the routine read a wild pointer.
The access violation is caught by the game's __except handler, which
calls ResetToFirmware().
Clearing the cause field whenever FPSCR is written matches what the
hardware shows to code that reads FPSCR after an FPU instruction.
Co-authored-by: Claude Opus 5.5 <[email protected]>
[ci skip]
Game ids can have spaces, like "INITIAL D Ver.2". The parser removed all
spaces in the section name so it became "INITIALDVer.2". Now only the
spaces before and after the name are removed.
Co-authored-by: nixxou <[email protected]>
[ci skip]
Use per-request URL buffers for GET and POST to prevent concurrent requests from overwriting each other's host and path.
Return the actual HTTP status for GET requests, retaining an error status when sending the request or querying its status fails
[ci skip]
The OIT color and depth/stencil attachments, a-buffers and pixel counter
are shared by consecutive render passes and by all frames in flight, but
the render pass had no external dependency covering them, and the pixel
counter reset wasn't synchronized with the fragment shaders using it.
With MoltenVK using Metal 3 argument buffers and residency sets (macOS 15+),
Metal no longer tracks hazards on resources accessed through argument
buffers, so input attachment reads and storage buffer accesses of a frame
may race with the attachment clears/loads and a-buffer writes of the next
one. This results in sporadic one-frame glitches with per-pixel alpha
sorting.
Issue #2495