Publish VCC Plus OSS source distribution for 3.6.2 build 60

This commit is contained in:
Brian Holman committed 2026-11-13 00:14:03 -07:00
commit c652a5276d
1192 files changed
+272368

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Run the stored Speech/Sound API and Book 6 Mission Announcer on the emulator."""
import argparse
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("runtime", type=Path)
parser.add_argument("core", type=Path)
parser.add_argument("roms", type=Path)
parser.add_argument("--capture", type=Path, help="write the actual guest display as a PNG")
parser.add_argument("--audio", type=Path, help="save the emulator's Mission Announcer stereo PCM as a WAV")
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
root = fixture.parents[2]
env = dict(os.environ, VCC_CMOC_COMPAT="0", PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
with tempfile.TemporaryDirectory(prefix="vcc-announcer-") as temp:
work = Path(temp)
def run(*cmd):
subprocess.run(cmd, cwd=work, env=env, check=True)
run("xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
"-I", root / "src", fixture / "run.cpp", core, "-o", "run")
for opt in ("-O0", "-O2"):
run(runtime / "bin/cmoc", "--coco", "--org=2800", opt, "-Werror", "-o", "QUAL.BIN",
fixture / "qualification.c", "-lssc")
run(runtime / "bin/cmoc", "--coco", "--org=2800", opt, "-Werror", "-o", "ANNOUNCE.BIN",
root / "examples/cmoc/manual/announcer.c", "-lssc", "-linput", "-lbcontrol")
shutil.copyfile(root / "docs/manuals/software-storage-and-peripherals/media/BLANK.DSK", work / "VOL.DSK")
run(runtime / "bin/writecocofile", "VOL.DSK", "ANNOUNCE.BIN")
print(f"Checking {opt}", flush=True)
capture = (args.capture or args.audio) and opt == "-O2"
run("./run", roms, *(["capture"] if capture else []))
if args.audio and opt == "-O2":
shutil.copyfile(work / "announcer.wav", args.audio.resolve())
if args.capture and opt == "-O2":
run("sips", "-s", "format", "png", "announcer.ppm", "--out", args.capture.resolve())
if __name__ == "__main__":
main()
+84
View File
@@ -0,0 +1,84 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include <coco.h>
#include <cmoc.h>
#include <vcc/ssc.h>
#define POLLS 8192
#define CHECK(test) do { if (!(test)) { printf("FAIL LINE %u\n", (unsigned)__LINE__); return 1; } } while (0)
static unsigned char codes[62];
static const unsigned char name[] = { SSC_AL_ZZ, SSC_AL_OR, SSC_AL_AX };
static void wait_for_fire_during(unsigned char idle)
{
unsigned int start = getTimer();
while ((unsigned int)(getTimer() - start) < 180) {
if (!(ssc_status() & idle) && !(readJoystickButtons() & JOYSTK_BUTTON_1_RIGHT)) {
printf("FIRE DURING %s\n", idle == SSC_EFFECT_IDLE ? "ALERT" : "NAME");
return;
}
}
}
int main(void)
{
unsigned char i;
unsigned int saved;
for (i = 0; i < sizeof(codes); ++i)
codes[i] = i + 2; // Include 63 at the last usable position.
CHECK(ssc_store_allophones(8, name, 3, POLLS) == SSC_INVALID);
CHECK(ssc_store_allophones(0, 0, 3, POLLS) == SSC_INVALID);
CHECK(ssc_store_allophones(0, name, 0, POLLS) == SSC_INVALID);
CHECK(ssc_store_allophones(0, name, 63, POLLS) == SSC_INVALID);
CHECK(ssc_store_allophones(0, name, 256, POLLS) == SSC_INVALID);
codes[61] = 64;
CHECK(ssc_store_allophones(0, codes, 62, POLLS) == SSC_INVALID);
codes[61] = 63;
CHECK(ssc_play_allophones(8, POLLS) == SSC_INVALID);
CHECK(ssc_store_phrase(8, "OK", POLLS) == SSC_INVALID);
CHECK(ssc_store_phrase(1, 0, POLLS) == SSC_INVALID);
CHECK(ssc_store_phrase(1, "", POLLS) == SSC_INVALID);
CHECK(ssc_store_phrase(1, "A\rB", POLLS) == SSC_INVALID);
CHECK(ssc_play_phrase(8, POLLS) == SSC_INVALID);
CHECK(ssc_store_phrase(1, "OK", 0) == SSC_TIMEOUT);
CHECK(ssc_play_phrase(1, 0) == SSC_TIMEOUT);
CHECK(ssc_store_enveloped_tone(8, 0, 1, 0, 1, 1, POLLS) == SSC_INVALID);
CHECK(ssc_store_enveloped_tone(0, 3, 1, 0, 1, 1, POLLS) == SSC_INVALID);
CHECK(ssc_store_enveloped_tone(0, 0, 0, 0, 1, 1, POLLS) == SSC_INVALID);
CHECK(ssc_store_enveloped_tone(0, 0, 4096, 0, 1, 1, POLLS) == SSC_INVALID);
CHECK(ssc_store_enveloped_tone(0, 0, 1, 16, 1, 1, POLLS) == SSC_INVALID);
CHECK(ssc_store_enveloped_tone(0, 0, 1, 0, 0, 1, POLLS) == SSC_INVALID);
CHECK(ssc_play_stored_effect(8, POLLS) == SSC_INVALID);
CHECK(ssc_store_allophones(0, name, 1, 0) == SSC_TIMEOUT);
CHECK(ssc_play_allophones(0, 0) == SSC_TIMEOUT);
CHECK(ssc_store_enveloped_tone(0, 0, 1, 0, 1, 0, 0) == SSC_TIMEOUT);
CHECK(ssc_play_stored_effect(0, 0) == SSC_TIMEOUT);
saved = ssc_route_audio();
if (ssc_store_allophones(7, codes, sizeof(codes), POLLS) == SSC_TIMEOUT) {
ssc_restore_audio(saved);
printf("NO SPEECH CART\n");
return 0;
}
CHECK(ssc_store_allophones(0, name, sizeof(name), POLLS) == SSC_OK);
CHECK(ssc_store_phrase(7, "mars", POLLS) == SSC_OK); // Replaces the long allophone buffer.
CHECK(ssc_store_enveloped_tone(7, 2, 4095, 15, 65535, 255, POLLS) == SSC_OK);
CHECK(ssc_store_enveloped_tone(0, 0, 250, SSC_ENV_DECAY, 4096, 60, POLLS) == SSC_OK);
printf("BANKS LOADED\n");
waitkey(FALSE);
CHECK(ssc_play_allophones(0, POLLS) == SSC_OK);
wait_for_fire_during(SSC_SPEECH_IDLE);
printf("ALERT READY\n");
waitkey(FALSE);
CHECK(ssc_play_stored_effect(0, POLLS) == SSC_OK);
wait_for_fire_during(SSC_EFFECT_IDLE);
printf("REPLAY READY\n");
waitkey(FALSE);
CHECK(ssc_play_allophones(0, POLLS) == SSC_OK);
printf("TEXT READY\n");
waitkey(FALSE);
CHECK(ssc_play_phrase(7, POLLS) == SSC_OK);
ssc_restore_audio(saved);
printf("BANKS PASSED\n");
return 0;
}
+191
View File
@@ -0,0 +1,191 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "../ssc/session.h"
#include "../guest-captures.h"
// A passive second MPI slot records commands in bus order. The real SSC
// supplies every status read, runs both ROMs and produces the captured audio.
struct CommandLog final : CartridgeDevice {
Bytes bytes;
void reset() override { bytes.clear(); }
void horizontalSync(DeviceHost&) override {}
std::uint8_t readMemory(std::uint16_t) const override { return 0xff; }
std::uint8_t readPort(std::uint8_t, DeviceHost&) override { return 0; }
void writePort(std::uint8_t port, std::uint8_t value, DeviceHost&) override {
if (port == 0x7e) bytes.push_back(value);
}
};
template<class Predicate>
static void waitUntil(Session& run, Predicate done, const char* failure) {
for (unsigned i = 0; i < 360; ++i) {
if (done()) return;
run.tick();
}
throw std::runtime_error(std::string(failure) + "\n" + run.machine.copyScreenText());
}
static void frames(Session& run, unsigned count) {
while (count--) run.tick();
}
static void fire(Session& run, bool pressed) {
run.machine.setJoystick(0, 8191, 8191, pressed ? 1 : 0, 0);
}
static void awaitSpeech(Session& run, unsigned baseline) {
waitUntil(run, [&] {
return run.ssc->diagnostics().AldSpeechCount() > baseline &&
!(run.machine.cartridges().readPort(0x7e) & 0x40);
}, "The speech chip never began a new phoneme");
}
static float amplitude(const std::vector<StereoSample>& pcm, std::size_t first, std::size_t last) {
require(first < last && last <= pcm.size(), "Empty PCM measurement");
auto range = std::minmax_element(pcm.begin() + first, pcm.begin() + last,
[](const auto& a, const auto& b) { return a.left < b.left; });
return range.second->left - range.first->left;
}
static Bytes expectedBanks() {
Bytes writes{0xb7};
for (unsigned i = 2; i <= 63; ++i) writes.push_back(i);
writes.insert(writes.end(), {
0, 0xff,
0xb0, 43, 58, 15, 0, 0xff, // SP0256 ZZ, OR, AX, PA1
0x97, 'M', 'A', 'R', 'S', ' ', 13,
0x9f, 0x6f, 255, 255, 0, 0x50, 15, 255, 255, 0x6f, 255, 255, 0, 0x40, 15, 255, 0, 255,
0x98, 0x60, 16, 0, 0, 0x10, 0, 250, 60, 0x60, 16, 0, 0, 0, 0, 250, 0, 255
});
return writes;
}
static void qualify(Session& run, const Bytes& guest, CommandLog& log) {
log.bytes.clear();
run.launch(guest);
run.until("BANKS LOADED");
frames(run, 20);
auto expected = expectedBanks();
require(log.bytes == expected, "Invalid input wrote a byte or a stored packet was malformed");
const auto& chip = run.ssc->diagnostics();
require(chip.AldSpeechCount() == 0, "Loading a slot played it");
run.press(1);
awaitSpeech(run, 0);
fire(run, true);
run.until("FIRE DURING NAME");
run.until("ALERT READY");
fire(run, false);
frames(run, 120); // isolate the tone from the earlier phrase
require(chip.AldSpeechCount() == 3, "Unexpected stored pronunciation length");
run.machine.setKeyboard(std::uint64_t{1} << 2);
waitUntil(run, [&] { return !(run.machine.cartridges().readPort(0x7e) & 0x20); },
"Stored envelope never raised the sound activity signal");
run.machine.setKeyboard(0);
const auto start = run.audio.size();
fire(run, true);
run.until("FIRE DURING ALERT", 30);
fire(run, false);
run.until("REPLAY READY");
frames(run, 7);
const auto middle = run.audio.size();
frames(run, 14);
const auto late = run.audio.size();
frames(run, 40);
const auto tail = run.audio.size();
frames(run, 10);
const auto earlyAmplitude = amplitude(run.audio, start, middle);
const auto laterAmplitude = amplitude(run.audio, late, tail);
const auto tailAmplitude = amplitude(run.audio, tail, run.audio.size());
require(earlyAmplitude > 0.02f && laterAmplitude < earlyAmplitude * 0.7f && tailAmplitude < 0.01f,
"Expected a loud attack, a softer envelope and silence: " + std::to_string(earlyAmplitude) +
", " + std::to_string(laterAmplitude) + ", " + std::to_string(tailAmplitude));
require((run.machine.cartridges().readPort(0x7e) & 0x20) != 0, "SAC stayed active after the effect");
run.press(3);
run.until("TEXT READY");
frames(run, 150);
require(chip.AldSpeechCount() == 6, "One-byte replay did not reproduce the first pronunciation");
run.press(4);
run.until("BANKS PASSED");
frames(run, 150);
require(chip.AldSpeechCount() > 6 && chip.CpuIllegalCount() == 0, "English phrase failed");
expected.insert(expected.end(), {0xf0, 0xd8, 0xf0, 0xd7});
require(log.bytes == expected, "Replay rewrote a stored buffer");
std::cout << " " << log.bytes.size() << " commands, " << chip.AldSpeechCount()
<< " phonemes, envelope peak-to-peak " << earlyAmplitude << " -> "
<< laterAmplitude << " -> " << tailAmplitude << '\n';
}
static void bookExercise(Session& run, bool fromDisk, bool capture) {
if (fromDisk)
run.diskExec(readFile("VOL.DSK"), "ANNOUNCE");
else
run.launch(readFile("ANNOUNCE.BIN"));
run.until("Q RETURN TO BASIC", 1200);
run.audio.clear();
const auto& chip = run.ssc->diagnostics();
run.press(34); // 2: English text in its own slot
awaitSpeech(run, 0);
frames(run, 180);
auto baseline = chip.AldSpeechCount();
require(baseline > 3, "WELCOME ABOARD never spoke");
run.press(33); // 1: invented planet name
run.until("APPROACHING ZORA");
awaitSpeech(run, baseline);
fire(run, true);
run.until("LANDING ALERT 1", 30);
frames(run, 50);
require(!run.contains("LANDING ALERT 2"), "Holding fire repeated the alert");
fire(run, false);
frames(run, 5);
fire(run, true);
run.until("LANDING ALERT 2", 30);
fire(run, false);
frames(run, 70);
require(chip.AldSpeechCount() == baseline + 3, "Joystick input interrupted the announcement");
run.checkSignal(0);
if (capture) {
BasicDiskTests::saveActiveFrame(*run.machine.snapshot().frame, "announcer.ppm");
saveWav("announcer.wav", run.audio);
}
run.press(17); // Q
run.until("OK");
frames(run, 12);
run.press(47, true); run.press(39); run.press(43, true); run.press(35); run.press(48); // ?7+3
run.until(" 10");
if (fromDisk)
require(run.floppy->readEvents(0) > 0 && run.floppy->writeEvents(0) == 0, "Unexpected demo disk I/O");
}
int main(int argc, char** argv) {
try {
require(argc == 2 || argc == 3, "Usage: run ROM_DIRECTORY [capture]");
const fs::path rom(argv[1]);
const auto system = readFile(rom / "coco3.rom"), disk = readFile(rom / "disk11.rom");
auto chips = readFile(rom / "pic-7040-510.bin");
auto speech = readFile(rom / "sp0256-al2.bin");
require(chips.size() == 4096 && speech.size() == 2048, "Missing Speech/Sound firmware");
chips.insert(chips.end(), speech.begin(), speech.end());
const auto guest = readFile("QUAL.BIN");
for (auto cpu : {Processor::MC6809, Processor::HD6309}) {
std::cout << (cpu == Processor::MC6809 ? "6809" : "6309") << std::endl;
{
auto log = std::make_shared<CommandLog>();
Session fixture(cpu, system, disk, std::make_shared<SpeechSoundDevice>(chips), false, log);
qualify(fixture, guest, *log);
}
{
Session absent(cpu, system, disk, nullptr);
absent.launch(guest);
absent.until("NO SPEECH CART");
}
for (bool fromDisk : {false, true}) {
Session demo(cpu, system, disk, std::make_shared<SpeechSoundDevice>(chips));
bookExercise(demo, fromDisk, argc == 3 && !fromDisk && cpu == Processor::MC6809);
}
std::cout << " PASS stored banks, joystick during speech and alert, direct and disk launch, BASIC return\n";
}
} catch (const std::exception& e) {
std::cerr << e.what() << '\n';
return 1;
}
}