Implement CoCo 3 Quadrapassel and deliver build 01

Add gameplay, keyboard/joystick controls, disk-backed high scores and settings,
standard CMOC effects, and the approved C graphics renderer. Include the clearer
attributed font, title/credits updates, source-verified Modern and Classic (40.2)
scoring, meaningful regression fixtures, and recorded guest validation.

Deliver QUADPSL01.DSK with fresh high scores. Retain source, licenses and selected
guest evidence; exclude personal disks, private connections and build scratch.

Host rules/input/persistence/video checks and memory guards pass. Official
512 KB playtests pass the recorded checks; actual 128 KB/physical joystick
qualification and the normal-window buzzing retest remain pending.
This commit is contained in:
Brian Holman committed 2026-11-11 03:14:14 -07:00
1 parent 8a4b44bc73
commit d412e35c4e
79 files changed
+4187 -16

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Build bounded, independently checked 512-byte menu text pages.
use strict;
use warnings;
my ($source,$target)=@ARGV;
open my $in,'<',$source or die "$source: $!";
my @pages=map { [] } 0..11;
while(<$in>){chomp;next if /^#/ || /^$/;my ($scene,$id,$text)=split /\t/,$_,3;
die "invalid text record" unless defined($text) && $scene=~/^\d+$/ && $scene<12 && $id=~/^\d+$/ && $id>0 && $id<256 && $text=~/^[ -~]*$/;
push @{$pages[$scene]},[$id,$text];
}
close $in;
open my $out,'>:raw',$target or die "$target: $!";
for my $scene (0..11){
my @entries=@{$pages[$scene]};my $offset=8+3*@entries;
my $head=pack('a4CCCC','QPTX',$scene,scalar(@entries),1,0);my $strings='';
for(@entries){$head.=pack('Cn',$_->[0],$offset);$strings.=$_->[1]."\0";$offset+=length($_->[1])+1;}
die "menu page exceeds 510 bytes" if $offset>510;
my $data=$head.$strings.("\0" x (510-$offset));my $crc=0xFFFF;
for my $byte(unpack('C*',$data)){$crc^=$byte<<8;for(1..8){$crc=(($crc&0x8000)?(($crc<<1)^0x1021):($crc<<1))&65535;}}
print {$out} $data,pack('n',$crc);
}
close $out or die "$target: $!";
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Check direct MCP PCM16 WAV captures for digital silence or a bounded effect."""
import argparse
import array
import json
import sys
import wave
def measure(path, tail_ms=500):
with wave.open(str(path), 'rb') as wav:
if wav.getsampwidth() != 2 or wav.getcomptype() != 'NONE':
raise ValueError('Expected uncompressed PCM16 WAV')
channels = wav.getnchannels()
rate = wav.getframerate()
frames = wav.getnframes()
samples = array.array('h', wav.readframes(frames))
if sys.byteorder != 'little':
samples.byteswap()
if not frames or channels < 1 or len(samples) != frames * channels:
raise ValueError('Empty or incomplete WAV')
separate = [samples[channel::channels] for channel in range(channels)]
tail_frames = min(frames, max(1, rate * tail_ms // 1000))
return {
'sample_rate': rate,
'channels': channels,
'sample_frames': frames,
'peak_per_channel': [max(abs(n) for n in channel) for channel in separate],
'changing_edges_per_channel': [
sum(channel[i] != channel[i - 1] for i in range(1, frames))
for channel in separate
],
'nonzero_frames': sum(
any(samples[i * channels + channel] for channel in range(channels))
for i in range(frames)
),
'tail_ms': tail_ms,
'tail_peak': max(abs(n) for n in samples[-tail_frames * channels:]),
}
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('wav')
parser.add_argument('--expect', choices=('silent', 'effect'), required=True)
parser.add_argument('--tail-ms', type=int, default=500)
args = parser.parse_args()
if args.tail_ms <= 0:
parser.error('--tail-ms must be positive')
result = measure(args.wav, args.tail_ms)
if args.expect == 'silent':
passed = result['nonzero_frames'] == 0
else:
passed = (result['nonzero_frames'] > 0
and max(result['changing_edges_per_channel']) >= 2
and result['tail_peak'] == 0)
print(json.dumps({'passed': passed, 'expect': args.expect, **result}))
return 0 if passed else 1
if __name__ == '__main__':
sys.exit(main())
+20
View File
@@ -0,0 +1,20 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# CMOC --limit checks program_end (data end for split layouts). Check ALL ranges.
use strict;
use warnings;
open my $map,'<',$ARGV[0] or die "$ARGV[0]: $!";
my ($code_end,$data_end)=(0,0);
while(<$map>){
next unless /^Section: (\S+) \([^)]*\) load at ([0-9A-F]+), length ([0-9A-F]+)/;
my ($section,$start,$length)=($1,hex($2),hex($3));next unless $length;
my $end=$start+$length;
if($section eq 'bss'||$section eq 'rwdata'){
die "Static data outside 0E00..13FF" if $start<0x0E00||$end>0x1400;
$data_end=$end if $end>$data_end;
}else{
die "Code/read-only data outside 1400..7AFF ($section ends at ".sprintf('%04X',$end).")" if $start<0x1400||$end>0x7B00;
$code_end=$end if $end>$code_end;
}
}
die "Missing link-map sections" unless $code_end&&$data_end;
printf "Memory bounds: code/const end %04X; static data end %04X; stack reserve 1024 bytes.\n",$code_end,$data_end;
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Host-only input/persistence regression suites; CoCo qualification is separate."""
import subprocess
from pathlib import Path
root=Path(__file__).resolve().parents[1]
out=root/'test-output/components'
out.mkdir(parents=True,exist_ok=True)
for name in ['input','store']:
exe=out/(name+'_test')
subprocess.run(['clang','-std=c89','-Wall','-Wextra','-Werror','-pedantic',
'-fsanitize=address,undefined','-DQUAD_HOST','-I'+str(root/'src/game'),
str(root/'tests'/(name+'_test.c')),str(root/'src/game'/(name+'.c')),
'-o',str(exe)],check=True)
subprocess.run([str(exe)],check=True)
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Host regression tests against the repository's authoritative JSON fixtures.
These complement, and never claim to replace, CMOC/CoCo execution.
"""
import json
import math
import subprocess
from pathlib import Path
root = Path(__file__).resolve().parents[1]
out = root / 'test-output' / 'rules'
out.mkdir(parents=True, exist_ok=True)
pieces = json.loads((root / 'docs/reference/pieces.json').read_text())['pieces']
cases = json.loads((root / 'docs/reference/scoring.json').read_text())['cases']
lines = ['/* Generated from committed specification fixtures for this test only. */',
'static const Q16 reference_masks[7][4] = {']
for piece in pieces:
masks = []
for rotation in piece['rotations']:
mask = int(''.join(rotation['rows']).replace('.', '0').replace('#', '1'), 2)
assert mask == int(rotation['mask_hex'], 16)
masks.append('0x%04X' % mask)
lines.append('{' + ','.join(masks) + '},')
lines += ['};', 'typedef struct { int rule,difficulty; Q32 prior; int rows,bottom,level; Q32 points; } ScoreCase;',
'static const ScoreCase score_cases[] = {']
for c in cases:
lines.append('{%d,%d,%dUL,%d,%d,%d,%dUL},' % (
c['rule'] == 'Classic', c['difficulty'], c['prior_lines'], c['rows_cleared'],
c['includes_bottom'], c['expected_level'], c['expected_delta']))
lines += ['};', 'static const Q16 reference_gravity[100] = {',
','.join(str(math.floor(80 + 800 * .75 ** i + .5)) for i in range(100)), '};']
(out / 'reference_cases.h').write_text('\n'.join(lines) + '\n')
subprocess.run(['clang', '-std=c89', '-Wall', '-Wextra', '-Werror', '-pedantic',
'-fsanitize=address,undefined', '-g', '-DQUAD_HOST',
'-I'+str(root/'src/game'), '-I'+str(out),
str(root/'tests/rules_test.c'), str(root/'src/game/rules.c'),
'-o', str(out/'rules_test')], check=True)
subprocess.run([str(out/'rules_test')], check=True)
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Compare the real C renderer with the unmodified upstream public-domain font."""
import subprocess
from pathlib import Path
root=Path(__file__).resolve().parents[1]
out=root/'test-output/font'
out.mkdir(parents=True,exist_ok=True)
exe=out/'video_test'
subprocess.run(['clang','-std=c99','-Wall','-Wextra','-Werror','-pedantic',
'-fsanitize=address,undefined','-DQUAD_HOST',
*['-I'+str(root/p) for p in ['tests/include','src/game','src/platform','third_party/cardgame-font']],
*[str(root/p) for p in ['tests/video_test.c','src/platform/video.c','src/game/rules.c','third_party/cardgame-font/8-bit-wide-font.c']],
'-o',str(exe)],check=True)
subprocess.run([str(exe),str(out/'font-and-borders.ppm')],check=True)