Publish the reproducible Sound Lab and FPGA Colour Lab sources

This commit is contained in:
bholman committed 2026-11-18 12:28:31 -07:00
commit 88254d7e24
27 files changed
+4574

No files matched your search

+122
View File
@@ -0,0 +1,122 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Isolated headless test: real Disk BASIC/FD502 path, private local ROM inputs.
#include "../../../tests/toolchain/ssc/session.h"
static void type(Session& run, const std::string& text) {
for(char c:text) {
if(c>='A' && c<='Z') run.press(c-'@');
else if(c>='0' && c<='9') run.press(32+c-'0');
else if(c=='-') run.press(45);
else if(c=='"') run.press(34,true);
else if(c=='\r') run.press(48);
else throw std::runtime_error("Unsupported input character");
}
}
static void capture(Session& run,const fs::path& path) {
for(unsigned i=0;i<3;++i) run.tick();
auto frame=run.machine.snapshot().frame;
require(frame && frame->pixels.size()==Frame::width*Frame::height,"No guest raster");
std::ofstream file(path,std::ios::binary);
file<<"P6\n"<<Frame::width<<' '<<Frame::height<<"\n255\n";
for(auto pixel:frame->pixels) { file.put(char(pixel>>16));file.put(char(pixel>>8));file.put(char(pixel)); }
}
static void select(Session& run,const std::string& id) {
type(run,"4"); run.until("CASE ID"); type(run,id+"\r");
run.until("ENTER TO PLAY",2400); type(run,"\r"); run.until("H HEARD",2400);
}
struct NeverReady final:CartridgeDevice {
unsigned reads=0,writes=0;
void reset() override {}
void horizontalSync(DeviceHost&) override {}
std::uint8_t readMemory(std::uint16_t)const override{return 0;}
std::uint8_t readPort(std::uint8_t p,DeviceHost&)override {if(p==0x7e){++reads;return 1;}return 0;}
void writePort(std::uint8_t p,std::uint8_t,DeviceHost&)override {if(p==0x7e)++writes;}
};
static void writeFile(const fs::path& path,const Bytes& bytes) {
std::ofstream file(path,std::ios::binary);
file.write(reinterpret_cast<const char*>(bytes.data()),bytes.size());
require(bool(file),"Cannot write owned test output");
}
int main(int argc,char**argv) {
try {
require(argc==4,"Usage: run ROM_DIRECTORY SOUNDLAB.DSK OUTPUT_DIRECTORY");
fs::path roms=argv[1], out=argv[3]; fs::create_directories(out);
auto system=readFile(roms/"coco3.rom"), diskrom=readFile(roms/"disk11.rom");
auto chips=readFile(roms/"pic-7040-510.bin"), speech=readFile(roms/"sp0256-al2.bin");
chips.insert(chips.end(),speech.begin(),speech.end());
for(auto cpu:{Processor::MC6809,Processor::HD6309}) {
std::string label=cpu==Processor::MC6809?"6809":"6309";
Session run(cpu,system,diskrom,std::make_shared<SpeechSoundDevice>(chips));
run.floppy->mount(0,DiskImage::load(readFile(argv[2])));
type(run,"DOS\r"); run.until("WELCOME, LISTENER",1200);
type(run,"11ND"); run.until("MAIN MENU",2400);
if(cpu==Processor::MC6809) { run.until("REPORT SAVED",2400); capture(run,out/"main-menu.ppm"); }
run.audio.clear();
type(run,"1"); run.until("ENTER TO PLAY",2400); type(run,"\r"); run.until("H HEARD",2400);
run.checkSignal(0); // PCM signal only; never a listening verdict.
type(run,"R"); run.until("ENTER TO PLAY",2400); type(run,"\r"); run.until("ATTEMPT 1",2400); run.until("H HEARD",2400);
type(run,"U"); run.until("ENTER TO PLAY",2400); type(run,"\r"); run.until("H HEARD",2400);
type(run,"X"); run.until("MAIN MENU",2400);
type(run,"Q"); run.until("SOUND LAB FINISHED",2400);
for(unsigned i=0;i<30;++i) run.tick();
require(run.contains("OK"),"Did not return to BASIC");
require(run.floppy->writeEvents(0)>0,"No report disk writes");
writeFile(out/(label+"-reports.dsk"),run.floppy->image(0)->bytes());
saveWav(out/(label+"-showcase.wav"),run.audio);
std::ofstream(out/(label+"-final.txt"))<<run.machine.copyScreenText();
std::cout<<"PASS "<<label<<" actual DOS boot, speech PCM, repeat, uncertain/abort, reports, BASIC return\n";
}
// No physical-presence inference: absent hardware still permits menu/quit.
{
Session absent(Processor::MC6809,system,diskrom,nullptr);
absent.floppy->mount(0,DiskImage::load(readFile(argv[2]),true));
type(absent,"RUN\"SOUNDLAB\"\r"); absent.until("WELCOME, LISTENER",1200);
type(absent,"11NM"); absent.until("MAIN MENU");
type(absent,"1"); absent.until("ENTER TO PLAY"); type(absent,"\r"); absent.until("H HEARD",3000);
type(absent,"X"); absent.until("MAIN MENU"); type(absent,"Q"); absent.until("SOUND LAB FINISHED");
require(absent.floppy->writeEvents(0)==0,"Screen-only run wrote disk");
std::cout<<"PASS absent SSC bounded observation and screen-only return without writes\n";
}
{
Session engineering(Processor::MC6809,system,diskrom,std::make_shared<SpeechSoundDevice>(chips));
engineering.floppy->mount(0,DiskImage::load(readFile(out/"6809-reports.dsk")));
type(engineering,"DOS\r"); engineering.until("WELCOME, LISTENER",1200);
type(engineering,"11ND"); engineering.until("MAIN MENU",2400);
engineering.until("REPORT SAVED",2400);
require(!engineering.contains("SND0001.TXT"),"Existing report filename was reused on relaunch");
for(const auto&id:{"REG01","REG02","NOI01","ENV01-10","ALP01-00"}) {
auto first=engineering.audio.size();
select(engineering,id);
if(std::string(id)!="ALP01-00") engineering.checkSignal(first);
if(std::string(id)=="REG01") capture(engineering,out/"direct-register-result.ppm");
type(engineering,"X"); engineering.until("MAIN MENU",2400);
}
type(engineering,"Q"); engineering.until("SOUND LAB FINISHED",2400);
for(unsigned i=0;i<30;++i) engineering.tick();
writeFile(out/"engineering-reports.dsk",engineering.floppy->image(0)->bytes());
std::cout<<"PASS held AY/direct FF data, noise, envelope, silent pause, report rollover and filename preservation\n";
}
{
auto stall=std::make_shared<NeverReady>();
Session stopped(Processor::MC6809,system,diskrom,nullptr,false,stall);
stopped.floppy->mount(0,DiskImage::load(readFile(argv[2]),true));
type(stopped,"DOS\r"); stopped.until("WELCOME, LISTENER",1200);
type(stopped,"11NM"); stopped.until("MAIN MENU");
type(stopped,"1"); stopped.until("ENTER TO PLAY"); type(stopped,"\r"); stopped.until("TIMEOUT / RESET",1200);
require(stall->reads>1 && stall->writes==0,"Bounded ready polling wrote to a not-ready device");
type(stopped,"X"); stopped.until("MAIN MENU"); type(stopped,"Q"); stopped.until("SOUND LAB FINISHED");
std::cout<<"PASS never-ready bounded timeout with zero command writes\n";
}
{
Session panic(Processor::MC6809,system,diskrom,std::make_shared<SpeechSoundDevice>(chips));
panic.floppy->mount(0,DiskImage::load(readFile(argv[2]),true));
type(panic,"DOS\r"); panic.until("WELCOME, LISTENER",1200);
type(panic,"11NM"); panic.until("MAIN MENU"); type(panic,"1"); panic.until("ENTER TO PLAY"); type(panic,"\r"); panic.until("PLAYING");
type(panic,"X"); panic.until("ABORTED",1200); panic.until("H HEARD");
type(panic,"X"); panic.until("MAIN MENU"); type(panic,"Q"); panic.until("SOUND LAB FINISHED");
require(panic.floppy->writeEvents(0)==0,"Panic screen-only path wrote disk");
std::cout<<"PASS panic during playback and safe return\n";
}
return 0;
} catch(const std::exception&e) { std::cerr<<e.what()<<'\n'; return 1; }
}