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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ add_library(splasheditdoc STATIC
src/editor/project.cpp
src/editor/serial.cpp
src/editor/hardware.cpp
src/editor/psxmon.cpp
src/editor/unirom.cpp)
target_include_directories(splasheditdoc PUBLIC src)
find_package(Threads REQUIRED)
Expand Down
21 changes: 17 additions & 4 deletions src/editor/hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <fstream>
#include <iterator>

#include "editor/psxmon.hh"
#include "editor/unirom.hh"

namespace editor {
Expand Down Expand Up @@ -78,8 +79,14 @@ void HardwareRun::start(Opener open, std::filesystem::path exe, std::filesystem:
return;
}
phase_ = Phase::Uploading;
add("Uploading psxsplash...");
if (!uniromUpload(*link, bytes, &err, [this](int p) { progress_ = p; }, &cancel_)) {
// psxmon answers a PING; anything else is taken to be the Unirom shell,
// which ignores the PING frames as unknown command text.
uint16_t caps = 0;
const bool monitor = psxmonPresent(*link, 1500, &caps);
add(monitor ? "Uploading psxsplash through psxmon..." : "Uploading psxsplash through Unirom...");
auto progress = [this](int p) { progress_ = p; };
if (!(monitor ? psxmonUpload(*link, bytes, &err, progress, &cancel_)
: uniromUpload(*link, bytes, &err, progress, &cancel_))) {
if (cancel_) {
phase_ = Phase::Stopped;
return;
Expand All @@ -89,8 +96,14 @@ void HardwareRun::start(Opener open, std::filesystem::path exe, std::filesystem:
phase_ = Phase::Running;
add("Running. Files are served from " + dir.string());
PcdrvHost host(dir);
const bool ok = host.serve(*link, cancel_, [this](const std::string& l) { add(l); },
[this](const std::string& e) { add("[file] " + e); }, &err);
auto line = [this](const std::string& l) { add(l); };
auto event = [this](const std::string& e) { add("[file] " + e); };
// Under a psxmon entered from the exception handler's slot, psxsplash
// asks for files with break calls the monitor stops on; anywhere else
// it speaks its own SIO1 protocol.
const bool breaks = monitor && (caps & psxmon::kCapSlot);
const bool ok = breaks ? psxmonServe(*link, host, cancel_, line, event, &err)
: host.serve(*link, cancel_, line, event, &err);
if (!ok && !cancel_) return fail(err);
phase_ = Phase::Stopped;
});
Expand Down
Loading
Loading