Files
LibretroAdmin 3702e90cbd Route all core file I/O through the libretro VFS
Pull the libretro VFS stack into libretro/libretro-common (from the
snes9x2010 tree's curated copy): vfs_implementation, file_stream,
file_stream_transforms, file_path/file_path_io, the compat family
(strl/posix_string/strcasestr/snprintf/fopen_utf8), encoding_utf,
stdstring and rtime, plus the include tree. libretro.h is upgraded to
the current version -- required because file_path_io uses the
retro_vfs_stat_64_t extension the old 2020-era header predates. A
file_stream_transforms.h header is reconstructed from the .c's
signatures (the source tree ships the implementation without it).
Makefile.common builds these outside STATIC_LINKING, same split as
snes9x2010: statically linked frontends export all of these symbols
themselves. retro_set_environment now requests
RETRO_ENVIRONMENT_GET_VFS_INTERFACE and initializes filestream and
path with it; without a frontend VFS, filestream falls back to its
local implementation.

Conversion:
- The FSTREAM macro layer in snes9x.h moves wholesale from the
  ZLIB/stdio dual implementation to RFILE (rfopen family), which
  converts every STREAM/fStream consumer at once: stream.cpp,
  snapshot.cpp, msu1's fStream path, conffile parsing, memmap's
  soft-patch loader and snes9x.cpp. Compressed (.gz) stream support
  is gone by design -- the frontend handles compressed content.
  REOPEN_FSTREAM / reopenStreamFromFd (fdopen-based, no VFS
  equivalent, zero callers) are deleted.
- Direct stdio converted to RFILE: memmap (BIOS + SRTC RTC data),
  crosshairs (text format), cheats2 (load/save), apu (SPC dump),
  conffile SaveTo, bsx (Satellaview stream files; SBSX struct fields
  retyped), libretro.cpp's BIOS loader, and the DEBUGGER trace
  handles in debug.h / snes9x.cpp / cpuops.cpp.
- bml switches from std::ifstream to filestream_read_file plus an
  std::istringstream; the parser itself now takes std::istream.
- minizip's ioapi.c backend is rewritten on RFILE, so unzOpen (zipped
  ROM loading, MSU-1 .msu1 packs) goes through the VFS; the stdio
  fopen64/fseeko64 platform selection in ioapi.h is removed. The
  unused minizip tools (zip.c, miniunz.c, minizip.c, mztools,
  iowin32) are deleted. zlib remains linked for DEFLATE
  decompression only.
- crosshairs' HAVE_LIBPNG block is removed: never defined in this
  build, and png_init_io requires stdio FILE.

stderr/stdout console logging is intentionally untouched -- it is not
file I/O. After conversion, a tree-wide audit finds no fopen family,
gzopen, fstream, or fdopen outside libretro-common.

Validation:
- Functional VFS smoke: loading a ROM by path (data == NULL) through
  memmap -> fStream -> filestream produces the byte-identical m7 test
  ROM hash, and loading the same ROM from a .zip exercises
  loadzip -> unzip -> the RFILE ioapi backend with the identical
  hash again.
- Full gauntlet byte-exact: Contra III savestate vs pre-port oracle,
  Mega Man X2, Mode 5 bright/dim, m7 option matrix, probe
  (serialize size 823407).
- ASan+UBSan+LSan over the probe, the path-load and the zip-load
  scenarios: zero findings in the new I/O paths; the only report is
  a pre-existing 288-byte S9xGetCommandT leak (controls.cpp input
  bindings, unrelated).

Untested but converted by the same mechanical mapping: SRTC RTC
file, BS-X Satellaview streams, cheat file save, SPC dump, DEBUGGER
traces.
2026-08-04 02:08:38 +02:00

44 lines
1.0 KiB
C++

/*****************************************************************************\
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
This file is licensed under the Snes9x License.
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#ifdef DEBUGGER
#ifndef _DEBUG_H_
#define _DEBUG_H_
#include <string>
struct SBreakPoint
{
bool8 Enabled;
uint8 Bank;
uint16 Address;
};
#include <streams/file_stream_transforms.h>
#define ENSURE_TRACE_OPEN(fp, file, mode) \
if (!fp) \
{ \
std::string fn = S9xGetDirectory(LOG_DIR); \
fn += SLASH_STR file; \
fp = rfopen(fn.c_str(), mode); \
}
extern struct SBreakPoint S9xBreakpoint[6];
void S9xDoDebug (void);
void S9xTrace (void);
void S9xSA1Trace (void);
void S9xTraceMessage (const char *);
void S9xTraceFormattedMessage (const char *, ...);
void S9xPrintHVPosition (char *);
void S9xDebugProcessCommand(char *);
#endif
#endif