Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Editor/Core/MkpsxisoDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace SplashEdit.EditorCode
{
/// <summary>
/// Downloads and manages mkpsxiso — the tool that builds PlayStation CD images
/// Downloads and manages mkpsxiso - the tool that builds PlayStation CD images
/// from an XML catalog. Used for the ISO build target.
/// https://github.com/Lameguy64/mkpsxiso
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions Editor/Core/PCSXReduxDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace SplashEdit.EditorCode
/// Downloads and installs PCSX-Redux from the official distrib.app CDN.
/// Mirrors the logic from pcsx-redux.js (the official download script).
///
/// Flow: fetch platform manifest → find latest build ID → fetch build manifest →
/// get download URL → download zip → extract to .tools/pcsx-redux/
/// Flow: fetch platform manifest -> find latest build ID -> fetch build manifest ->
/// get download URL -> download zip -> extract to .tools/pcsx-redux/
/// </summary>
public static class PCSXReduxDownloader
{
Expand Down Expand Up @@ -94,7 +94,7 @@ public static async Task<bool> DownloadAndInstall(Action<string> log = null)
string downloadUrl = $"https://distrib.app{downloadPath}";
log?.Invoke($"Downloading: {downloadUrl}");

// Step 3: Download — use the real extension from the URL
// Step 3: Download - use the real extension from the URL
string ext = ".zip";
if (downloadPath.EndsWith(".tar.gz")) ext = ".tar.gz";
else if (downloadPath.EndsWith(".dmg")) ext = ".dmg";
Expand All @@ -120,7 +120,7 @@ public static async Task<bool> DownloadAndInstall(Action<string> log = null)
log?.Invoke($"Downloaded to {tempFile}");
EditorUtility.DisplayProgressBar("Installing PCSX-Redux", "Extracting...", 0.9f);

// Step 4: Extract — handle zip, tar.gz, and dmg
// Step 4: Extract - handle zip, tar.gz, and dmg
string installDir = SplashBuildPaths.PCSXReduxDir;
if (Directory.Exists(installDir))
Directory.Delete(installDir, true);
Expand Down Expand Up @@ -166,7 +166,7 @@ public static async Task<bool> DownloadAndInstall(Action<string> log = null)
}
else
{
// The zip might have a nested directory — try to find the exe
// The zip might have a nested directory - try to find the exe
SplashEdit.RuntimeCode.Utils.FixNestedDirectory(installDir);
if (SplashBuildPaths.IsPCSXReduxInstalled())
{
Expand Down Expand Up @@ -254,7 +254,7 @@ private static void PostInstallMacOS(string installDir, Action<string> log)

// SplashBuildPaths.PCSXReduxBinary expects a flat "pcsx-redux" executable,
// but distrib.app ships a .app bundle. This wrapper bridges the gap.
// It also handles process cleanup — without pkill, PCSX-Redux sometimes
// It also handles process cleanup - without pkill, PCSX-Redux sometimes
// survives Unity's Process.Kill and blocks the port on next launch.
if (File.Exists(appBinary))
{
Expand Down
52 changes: 26 additions & 26 deletions Editor/Core/PCdrvSerialHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
namespace SplashEdit.EditorCode
{
/// <summary>
/// PCdrv Host — serves files to a PS1 over serial (Unirom/NOTPSXSerial protocol).
/// PCdrv Host - serves files to a PS1 over serial (Unirom/NOTPSXSerial protocol).
///
/// PCdrv uses MIPS `break` instructions to request file I/O from the host.
/// For real hardware running Unirom, we must:
/// 1. Enter debug mode (DEBG/OKAY) — installs Unirom's kernel-resident SIO handler
/// 1. Enter debug mode (DEBG/OKAY) - installs Unirom's kernel-resident SIO handler
/// 2. Continue execution (CONT/OKAY)
/// 3. Monitor serial for escape sequences: 0x00 followed by 'p' = PCDrv command
/// 4. Handle file operations (init, open, read, close, seek, etc.)
Expand Down Expand Up @@ -47,7 +47,7 @@ private class PCFile
public FileAccess Mode;
}

// Protocol escape char — PCDrv commands are prefixed with 0x00 + 'p'
// Protocol escape char - PCDrv commands are prefixed with 0x00 + 'p'
private const byte ESCAPE_CHAR = 0x00;

// PCDrv function codes (from Unirom kernel)
Expand Down Expand Up @@ -101,9 +101,9 @@ public void Start()

/// <summary>
/// Starts the PCDrv monitor loop on an already-open serial port.
/// Use this after UniromUploader.UploadExeForPCdrv() which sends DEBG → SEXE
/// Use this after UniromUploader.UploadExeForPCdrv() which sends DEBG -> SEXE
/// and returns the open port. The debug hooks are already installed and the
/// exe is already running — we just need to listen for escape sequences.
/// exe is already running - we just need to listen for escape sequences.
/// </summary>
public void Start(SerialPort openPort)
{
Expand Down Expand Up @@ -148,10 +148,10 @@ public void Stop()

public void Dispose() => Stop();

// ═══════════════════════════════════════════════════════════════
// Monitor loop — reads serial byte-by-byte looking for escape sequences
// ---------------------------------------------------------------
// Monitor loop - reads serial byte-by-byte looking for escape sequences
// Matches NOTPSXSerial's Bridge.MonitorSerial()
// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------

private void MonitorLoop(CancellationToken ct)
{
Expand Down Expand Up @@ -214,12 +214,12 @@ private void MonitorLoop(CancellationToken ct)
if (b == 'p')
{
// PCDrv command incoming
_log?.Invoke("PCdrv monitor: got escape+p → PCDrv command!");
_log?.Invoke("PCdrv monitor: got escape+p -> PCDrv command!");
HandlePCDrvCommand(ct);
}
else
{
// Unknown escape sequence — log it
// Unknown escape sequence - log it
_log?.Invoke($"PCdrv monitor: unknown escape seq: 0x00 + 0x{b:X2} ('{(b >= 0x20 && b < 0x7F ? (char)b : '.')}')");
}

Expand All @@ -232,7 +232,7 @@ private void MonitorLoop(CancellationToken ct)
continue;
}

// Regular byte — this is printf output from the PS1
// Regular byte - this is printf output from the PS1
if (b == '\n' || b == '\r')
{
if (textBuffer.Length > 0)
Expand Down Expand Up @@ -273,10 +273,10 @@ private void MonitorLoop(CancellationToken ct)
}
}

// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------
// PCDrv command dispatcher
// Matches NOTPSXSerial's PCDrv.ReadCommand()
// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------

private void HandlePCDrvCommand(CancellationToken ct)
{
Expand All @@ -297,9 +297,9 @@ private void HandlePCDrvCommand(CancellationToken ct)
}
}

// ═══════════════════════════════════════════════════════════════
// Individual PCDrv handlers — match NOTPSXSerial's PCDrv.cs
// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------
// Individual PCDrv handlers - match NOTPSXSerial's PCDrv.cs
// ---------------------------------------------------------------

private void HandleInit()
{
Expand Down Expand Up @@ -429,7 +429,7 @@ private void HandleClose(CancellationToken ct)
var f = FindOpenFile(handle);
if (f == null)
{
// No such file — "great success" per NOTPSXSerial
// No such file - "great success" per NOTPSXSerial
SendString("OKAY");
WriteInt32(0);
return;
Expand Down Expand Up @@ -563,9 +563,9 @@ private void HandleSeek(CancellationToken ct)
}
}

// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------
// PS1 output routing
// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------

/// <summary>
/// Routes PS1 printf output to PSXConsoleWindow (via _psxLog) if available,
Expand All @@ -579,11 +579,11 @@ private void EmitPsxLine(string text)
_log?.Invoke($"PS1> {text}");
}

// ═══════════════════════════════════════════════════════════════
// Chunked data write — matches NOTPSXSerial's WriteBytes()
// ---------------------------------------------------------------
// Chunked data write - matches NOTPSXSerial's WriteBytes()
// Sends data in 2048-byte chunks; for protocol V2+ Unirom
// responds with CHEK/MORE/ERR! per chunk.
// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------

private void WriteDataChunked(byte[] data)
{
Expand Down Expand Up @@ -622,9 +622,9 @@ private void WriteDataChunked(byte[] data)
}
}

// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------
// File handle helpers
// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------

private int NextHandle() => _files.Count + 1;

Expand Down Expand Up @@ -655,9 +655,9 @@ private string ResolvePath(string filename)
return Path.Combine(_baseDir, filename);
}

// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------
// Low-level serial I/O
// ═══════════════════════════════════════════════════════════════
// ---------------------------------------------------------------

private int ReadInt32(CancellationToken ct)
{
Expand Down
Loading
Loading