Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,55 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include "basic-disk-session.h"
|
||||
|
||||
namespace BasicDiskTests {
|
||||
|
||||
inline Bytes volume(const Session& guest)
|
||||
{
|
||||
if (guest.sdc) return readFile(guest.diskPath);
|
||||
if (guest.profile == Profile::rgbHD) {
|
||||
require(guest.floppy->image(0)->bytes() == guest.original, "HD operation changed FD0");
|
||||
const auto& bytes = guest.hard->image(0)->bytes();
|
||||
return {bytes.begin() + rgbStart, bytes.begin() + rgbStart + guest.original.size()};
|
||||
}
|
||||
return guest.floppy->image(0)->bytes();
|
||||
}
|
||||
|
||||
inline void saveVolume(const Session& guest, const fs::path& path)
|
||||
{
|
||||
const auto bytes = volume(guest);
|
||||
std::ofstream out(path, std::ios::binary);
|
||||
out.write(reinterpret_cast<const char*>(bytes.data()), bytes.size());
|
||||
require(out.good(), "Could not save " + path.string());
|
||||
}
|
||||
|
||||
inline void setVolumeProtected(Session& guest, bool protect)
|
||||
{
|
||||
if (guest.sdc) guest.sdc->setWriteProtected(protect);
|
||||
else if (guest.profile == Profile::rgbHD) guest.hard->image(0)->protect(protect);
|
||||
else guest.floppy->setWriteProtected(0, protect);
|
||||
}
|
||||
|
||||
inline void saveDisk(const DiskImage& disk, const fs::path& path)
|
||||
{
|
||||
const auto& bytes = disk.bytes();
|
||||
std::ofstream out(path, std::ios::binary);
|
||||
out.write(reinterpret_cast<const char*>(bytes.data()), bytes.size());
|
||||
require(out.good(), "Could not save guest disk");
|
||||
}
|
||||
|
||||
inline void saveActiveFrame(const Frame& frame, const fs::path& path)
|
||||
{
|
||||
const auto area = frame.activeArea;
|
||||
std::ofstream out(path, std::ios::binary);
|
||||
out << "P6\n" << area.width << ' ' << area.height << "\n255\n";
|
||||
for (int y = 0; y < area.height; ++y)
|
||||
for (int x = 0; x < area.width; ++x) {
|
||||
auto rgb = frame.pixels[(area.y + y) * Frame::width + area.x + x];
|
||||
out.put(char(rgb >> 16)); out.put(char(rgb >> 8)); out.put(char(rgb));
|
||||
}
|
||||
require(out.good(), "Could not save guest display");
|
||||
}
|
||||
|
||||
} // namespace BasicDiskTests
|
||||
Reference in new issue
Block a user