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,37 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Run the guest input and audio qualification on both CoCo 3 processors."""
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("runtime", type=Path, help="staged CMOC toolchain")
|
||||
parser.add_argument("core", type=Path, help="current libVCCCore.a")
|
||||
parser.add_argument("roms", type=Path, help="local CoCo 3 and Speech/Sound ROM directory")
|
||||
args = parser.parse_args()
|
||||
runtime, core, roms = (p.resolve(strict=True) for p in (args.runtime, args.core, args.roms))
|
||||
fixture = Path(__file__).resolve().parent
|
||||
env = dict(os.environ, PATH=str(runtime / "bin") + ":/usr/bin:/bin", VCC_CMOC_COMPAT="0")
|
||||
with tempfile.TemporaryDirectory(prefix="vcc-input-") as folder:
|
||||
work = Path(folder)
|
||||
subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
|
||||
"-I", fixture.parents[2] / "src", fixture / "run.cpp", core, "-o", work / "run"],
|
||||
check=True)
|
||||
for optimization in ("-O0", "-O2"):
|
||||
subprocess.run([runtime / "bin/cmoc", "--coco", "--intermediate", "--org=2800", optimization,
|
||||
"-Werror", "-o", "QUAL.bin", fixture / "qualification.c", "-linput", "-lbcontrol",
|
||||
"-lssc", "-lorch90"], env=env, cwd=work, check=True)
|
||||
symbols = dict(re.findall(r"^Symbol: _(\w+) \(.+?\) = ([0-9A-F]+)$",
|
||||
(work / "QUAL.map").read_text(), re.MULTILINE))
|
||||
print("Checking compiled input caller", optimization, flush=True)
|
||||
subprocess.run([work / "run", roms, work / "QUAL.bin", *(symbols[n] for n in ("stage", "ack", "report"))],
|
||||
check=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,144 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#include <coco.h>
|
||||
#include <vcc/input.h>
|
||||
#include <vcc/ssc.h>
|
||||
#include <vcc/orch90.h>
|
||||
|
||||
unsigned char stage, ack, report[14];
|
||||
static VccInput right, left;
|
||||
#define REG(a) (*(unsigned char *)(a))
|
||||
|
||||
static void waitForHost(unsigned char n)
|
||||
{
|
||||
stage = n;
|
||||
asm {
|
||||
lda :n
|
||||
@wait cmpa :ack
|
||||
bne @wait
|
||||
}
|
||||
}
|
||||
|
||||
/* Marshal the public fields explicitly so the host test is independent of
|
||||
their layout, padding and signedness in a host C++ compiler. */
|
||||
static void reportPort(unsigned char *p, const VccInput *s)
|
||||
{
|
||||
p[0] = s->x;
|
||||
p[1] = s->y;
|
||||
p[2] = s->dx;
|
||||
p[3] = s->dy;
|
||||
p[4] = s->held;
|
||||
p[5] = s->pressed;
|
||||
p[6] = s->released;
|
||||
}
|
||||
|
||||
static unsigned char readBoth(unsigned char n)
|
||||
{
|
||||
unsigned char columns = REG(0xff02), dac = REG(0xff20);
|
||||
unsigned char muxLow = REG(0xff01) & 63, muxHigh = REG(0xff03) & 63;
|
||||
unsigned char speaker = REG(0xff23) & 63;
|
||||
if (n == 1 || n == 7) {
|
||||
input_init(&right, INPUT_RIGHT);
|
||||
input_init(&left, INPUT_LEFT);
|
||||
} else {
|
||||
input_sample(&right);
|
||||
input_sample(&left);
|
||||
}
|
||||
reportPort(report, &right);
|
||||
reportPort(report + 7, &left);
|
||||
return columns == REG(0xff02) && dac == REG(0xff20) &&
|
||||
muxLow == (REG(0xff01) & 63) && muxHigh == (REG(0xff03) & 63) &&
|
||||
speaker == (REG(0xff23) & 63);
|
||||
}
|
||||
|
||||
#define COUNT 256
|
||||
static struct orch90_frame leftSound[COUNT], rightSound[COUNT];
|
||||
|
||||
static unsigned char stereo(unsigned char clock)
|
||||
{
|
||||
unsigned char capturedPress;
|
||||
setHighSpeed(clock);
|
||||
asm {
|
||||
sync
|
||||
sync
|
||||
}
|
||||
input_init(&right, INPUT_RIGHT);
|
||||
orch90_write(32, 80);
|
||||
if (!orch90_play(leftSound, COUNT, clock)) return 0;
|
||||
input_sample(&right); /* The host pressed fire during the left block. */
|
||||
capturedPress = right.pressed;
|
||||
if (!orch90_play(rightSound, COUNT, clock)) return 0;
|
||||
input_sample(&right); /* The host released it during the right block. */
|
||||
orch90_write(0, 0);
|
||||
return capturedPress == INPUT_PRIMARY && right.released == INPUT_PRIMARY;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
unsigned char n;
|
||||
unsigned int i, start, route = ssc_route_audio();
|
||||
VccInput inactive;
|
||||
unsigned char oldFlags, restoredMask, preserved;
|
||||
input_init(0, INPUT_RIGHT);
|
||||
input_sample(0);
|
||||
input_init(&inactive, 7);
|
||||
input_sample(&inactive);
|
||||
if (inactive.x != 31 || inactive.y != 31 || inactive.dx || inactive.dy ||
|
||||
inactive.held || inactive.pressed || inactive.released) {
|
||||
printf("FAIL INVALID PORT\n"); return 1;
|
||||
}
|
||||
for (n = 1; n <= 8; ++n) {
|
||||
waitForHost(n);
|
||||
/* Non-default keyboard columns and DAC baseline reveal side effects.
|
||||
Preserve a consistent test setup across the two guest samples. */
|
||||
asm {
|
||||
tfr cc,a
|
||||
sta :oldFlags
|
||||
orcc #$50
|
||||
}
|
||||
REG(0xff02) = 0xfd;
|
||||
REG(0xff20) = 0x56;
|
||||
preserved = readBoth(n);
|
||||
asm {
|
||||
tfr cc,a
|
||||
anda #$50
|
||||
sta :restoredMask
|
||||
lda :oldFlags
|
||||
tfr a,cc
|
||||
}
|
||||
if (!preserved || restoredMask != 0x50) {
|
||||
printf("FAIL PIA\n"); return 1;
|
||||
}
|
||||
}
|
||||
waitForHost(9);
|
||||
|
||||
for (i = 0; i < COUNT; ++i) {
|
||||
leftSound[i].left = (i & 8) ? 64 : 128;
|
||||
rightSound[i].right = leftSound[i].left;
|
||||
}
|
||||
for (n = 0; n < 2; ++n) {
|
||||
waitForHost(10 + n);
|
||||
if (!stereo(n)) { printf("FAIL STEREO INPUT\n"); return 1; }
|
||||
}
|
||||
setHighSpeed(0);
|
||||
input_init(&right, INPUT_RIGHT);
|
||||
if (ssc_say("SURVEY PROBE READY", 16384) != SSC_OK) { printf("FAIL SPEECH\n"); return 1; }
|
||||
start = getTimer();
|
||||
while (ssc_status() & SSC_SPEECH_IDLE)
|
||||
if ((unsigned)(getTimer() - start) > 120) return 1;
|
||||
waitForHost(12);
|
||||
input_sample(&right);
|
||||
if (right.pressed != INPUT_PRIMARY || (ssc_status() & SSC_SPEECH_IDLE)) {
|
||||
printf("FAIL SPEECH INPUT\n"); return 1;
|
||||
}
|
||||
start = getTimer();
|
||||
while ((unsigned)(getTimer() - start) < 120) {
|
||||
asm("sync"); /* Sample once per refresh while firmware speaks. */
|
||||
input_sample(&right);
|
||||
if (right.held != INPUT_PRIMARY || right.pressed || right.released) {
|
||||
printf("FAIL SPEECH HOLD\n"); return 1;
|
||||
}
|
||||
}
|
||||
ssc_restore_audio(route);
|
||||
printf("INPUT PASSED\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#include "core/MachineSession.h"
|
||||
#include "devices/Orchestra90Device.h"
|
||||
#include "devices/SpeechSoundDevice.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace VCC::Mac;
|
||||
using namespace VCC::Devices;
|
||||
namespace fs = std::filesystem;
|
||||
using Bytes = std::vector<std::uint8_t>;
|
||||
|
||||
static void require(bool ok, const std::string& reason) {
|
||||
if (!ok) throw std::runtime_error(reason);
|
||||
}
|
||||
|
||||
static Bytes read(const fs::path& path) {
|
||||
std::ifstream file(path, std::ios::binary);
|
||||
require(file.good(), "Cannot open " + path.string());
|
||||
return {std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
|
||||
}
|
||||
|
||||
struct Session {
|
||||
MachineSession machine;
|
||||
std::shared_ptr<SpeechSoundDevice> speech;
|
||||
std::shared_ptr<Orchestra90Device> stereo = std::make_shared<Orchestra90Device>();
|
||||
unsigned stage, ack, report;
|
||||
std::vector<StereoSample> pcm;
|
||||
|
||||
Session(const fs::path& roms, const Bytes& guest, Processor cpu, unsigned s, unsigned a, unsigned r)
|
||||
: stage(s), ack(a), report(r) {
|
||||
auto chips = read(roms / "pic-7040-510.bin");
|
||||
auto phonemes = read(roms / "sp0256-al2.bin");
|
||||
chips.insert(chips.end(), phonemes.begin(), phonemes.end());
|
||||
speech = std::make_shared<SpeechSoundDevice>(chips);
|
||||
machine.cartridges().configure({nullptr, speech, stereo, nullptr, nullptr}, true, 4);
|
||||
machine.load(read(roms / "coco3.rom"), cpu);
|
||||
machine.resume();
|
||||
for (unsigned i = 0; i < 180; ++i) machine.advance();
|
||||
require(machine.copyScreenText().find("OK") != std::string::npos, "BASIC did not boot");
|
||||
require(guest.size() >= 5 && guest[guest.size()-5] == 0xff, "Missing guest entry point");
|
||||
auto entry = std::uint16_t((guest[guest.size()-2] << 8) | guest.back());
|
||||
machine.debuggerLoadBinary(guest, entry);
|
||||
machine.debuggerClearDevelopmentBreakpoints();
|
||||
machine.resume();
|
||||
machine.takeAudio();
|
||||
}
|
||||
|
||||
void tick() {
|
||||
machine.advance();
|
||||
auto block = machine.takeAudio();
|
||||
pcm.insert(pcm.end(), block.begin(), block.end());
|
||||
}
|
||||
|
||||
void wait(unsigned target) {
|
||||
for (unsigned i = 0; i < 400; ++i) {
|
||||
if (machine.debuggerMemoryRange(stage, 1, false).bytes[0] == target) return;
|
||||
tick();
|
||||
}
|
||||
throw std::runtime_error("Guest missed checkpoint " + std::to_string(target) + ": " + machine.copyScreenText());
|
||||
}
|
||||
|
||||
void release(unsigned target) {
|
||||
machine.pause();
|
||||
machine.debuggerWriteMemory(ack, {static_cast<std::uint8_t>(target)});
|
||||
machine.resume();
|
||||
}
|
||||
};
|
||||
|
||||
// Each guest row is x, y, dx, dy, held, pressed, released. Opposite ports
|
||||
// deliberately have different axes/buttons to detect accidental shared state.
|
||||
using Row = std::array<int, 7>;
|
||||
using Pair = std::array<Row, 2>;
|
||||
static const Pair steps[] = {
|
||||
{{{31,32,0,0,1,0,0}, {63,0,1,-1,2,0,0}}}, // Baseline with held buttons.
|
||||
{{{26,37,0,0,1,0,0}, {37,26,0,0,2,0,0}}}, // Inclusive dead zone limits.
|
||||
{{{25,38,-1,1,3,2,0}, {38,25,1,-1,1,1,2}}},
|
||||
{{{0,63,-1,1,2,0,1}, {63,0,1,-1,0,0,1}}},
|
||||
{{{32,31,0,0,0,0,2}, {31,32,0,0,2,2,0}}},
|
||||
{{{32,31,0,0,1,1,0}, {31,32,0,0,2,0,0}}},
|
||||
{{{32,31,0,0,3,0,0}, {31,32,0,0,3,0,0}}}, // Explicit re-baseline.
|
||||
{{{32,31,0,0,0,0,3}, {31,32,0,0,0,0,3}}}
|
||||
};
|
||||
|
||||
static void checkInputs(Session& run) {
|
||||
run.wait(1);
|
||||
for (unsigned i = 0; i < std::size(steps); ++i) {
|
||||
run.release(i + 1); // Pausing releases the host controls, so apply them after resuming.
|
||||
for (unsigned port = 0; port < 2; ++port) {
|
||||
const auto& row = steps[i][port];
|
||||
// Sample exactly at a six-bit DAC threshold with the serial pin set.
|
||||
run.machine.setJoystick(port, 256 * row[0], 256 * row[1], row[4], 0);
|
||||
}
|
||||
run.machine.setKeyboard(std::uint64_t(1) << 1); // A held during sampling must not become fire.
|
||||
run.wait(i + 2);
|
||||
auto bytes = run.machine.debuggerMemoryRange(run.report, 14, false).bytes;
|
||||
for (unsigned port = 0; port < 2; ++port) {
|
||||
for (unsigned j = 0; j < steps[i][port].size(); ++j) {
|
||||
auto expected = static_cast<std::uint8_t>(steps[i][port][j]);
|
||||
require(bytes[7 * port + j] == expected, "Input mismatch at update " + std::to_string(i+1) +
|
||||
", port " + std::to_string(port) + ", field " + std::to_string(j) +
|
||||
": expected " + std::to_string(expected) + ", got " + std::to_string(bytes[7 * port + j]));
|
||||
}
|
||||
}
|
||||
}
|
||||
run.release(9);
|
||||
}
|
||||
|
||||
// Measure from the first through the last plateau onset *within* each block.
|
||||
// The last sample stays latched while the CoCo polls input between blocks.
|
||||
static void analyzeBlock(const std::vector<StereoSample>& pcm, bool right) {
|
||||
unsigned plateaus = 0, first = 0, last = 0;
|
||||
float previous = 0;
|
||||
for (unsigned i = 0; i < pcm.size(); ++i) {
|
||||
const float delta = right ? pcm[i].right - pcm[i].left : pcm[i].left - pcm[i].right;
|
||||
if (delta != 0.25f && delta != 0.50f) continue;
|
||||
if (delta != previous) {
|
||||
require(delta == (plateaus % 2 ? 0.25f : 0.50f), "Wrong stereo level or channel order");
|
||||
if (!plateaus) first = i;
|
||||
last = i;
|
||||
previous = delta;
|
||||
++plateaus;
|
||||
}
|
||||
}
|
||||
require(plateaus == 32, "Expected 32 alternating stereo plateaus, found " + std::to_string(plateaus));
|
||||
const double rate = 44100.0 * (31 * 8) / (last - first);
|
||||
require(std::fabs(rate - 4000.0) < 200, "Stereo playback rate drifted: " + std::to_string(rate));
|
||||
std::cout << (right ? "right " : "left ") << int(rate) << " Hz ";
|
||||
}
|
||||
|
||||
static void checkStereo(Session& run, unsigned clock) {
|
||||
unsigned stage = 10 + clock;
|
||||
run.wait(stage);
|
||||
run.pcm.clear();
|
||||
run.release(stage);
|
||||
// Change the physical button mid-block. Guest software first sees the
|
||||
// change when orch90_play returns and input_sample reads the port.
|
||||
for (bool right : {false, true}) {
|
||||
unsigned n = 0;
|
||||
while (n++ < 90) {
|
||||
run.tick();
|
||||
auto latch = run.stereo->audio();
|
||||
if (right ? (latch == 64 || latch == 128) : (latch == 16384 || latch == 32768)) break;
|
||||
}
|
||||
require(n <= 90, "Missing stereo block: " + run.machine.copyScreenText());
|
||||
run.machine.setJoystick(0,8191,8191,right ? 0 : 1,0);
|
||||
}
|
||||
run.wait(stage + 1);
|
||||
analyzeBlock(run.pcm, false);
|
||||
analyzeBlock(run.pcm, true);
|
||||
std::cout << (clock ? "(fast)\n" : "(normal)\n");
|
||||
}
|
||||
|
||||
static void checkSpeech(Session& run) {
|
||||
run.wait(12);
|
||||
run.release(12);
|
||||
run.machine.setJoystick(0,8191,8191,1,0);
|
||||
run.pcm.clear();
|
||||
for (unsigned i = 0; i < 240; ++i) {
|
||||
run.tick();
|
||||
if (run.machine.copyScreenText().find("INPUT PASSED\nOK") != std::string::npos) break;
|
||||
}
|
||||
require(run.machine.copyScreenText().find("INPUT PASSED\nOK") != std::string::npos,
|
||||
"Guest did not return to BASIC: " + run.machine.copyScreenText());
|
||||
auto& diagnostics = run.speech->diagnostics();
|
||||
require(diagnostics.AldSpeechCount() > 4 && diagnostics.CpuIllegalCount() == 0 &&
|
||||
diagnostics.CommandCount() == std::string("SURVEY PROBE READY").size()+2, "Incomplete spoken phrase");
|
||||
require(!run.pcm.empty(), "No speech samples captured");
|
||||
auto range = std::minmax_element(run.pcm.begin(), run.pcm.end(),
|
||||
[](auto a, auto b){ return a.left < b.left; });
|
||||
require(range.second->left - range.first->left > 0.02f, "Speech PCM stayed silent");
|
||||
std::cout << diagnostics.AldSpeechCount() << " speech phonemes while polling, input and return passed\n";
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
try {
|
||||
require(argc == 6, "Usage: run ROM_DIR QUAL.BIN STAGE ACK REPORT");
|
||||
const auto guest = read(argv[2]);
|
||||
for (auto cpu : {Processor::MC6809, Processor::HD6309}) {
|
||||
Session run(argv[1], guest, cpu, std::stoul(argv[3],nullptr,16),
|
||||
std::stoul(argv[4],nullptr,16), std::stoul(argv[5],nullptr,16));
|
||||
std::cout << (cpu == Processor::MC6809 ? "6809\n" : "6309\n");
|
||||
checkInputs(run);
|
||||
for (unsigned clock = 0; clock <= 1; ++clock) checkStereo(run, clock);
|
||||
checkSpeech(run);
|
||||
}
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << error.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user