Complete Bone Quest high-resolution anatomy quiz
This commit is contained in:
1 parent
3cc37be5fb
commit
2ceb44a48c
62 files changed
+3204
-1301
No files matched your search
@@ -0,0 +1,32 @@
|
||||
# Isolated high-resolution graphics checks
|
||||
|
||||
Run the independent graphics fixture with your own private ROMs:
|
||||
|
||||
```sh
|
||||
python3 tests/check_graphics.py --rom /path/to/coco3.rom --disk-rom /path/to/disk11.rom
|
||||
```
|
||||
|
||||
The installed VCC Plus app supplies the CMOC tools and isolated `vcc-playtest`
|
||||
helper. This does not launch or control the normal emulator, use personal media,
|
||||
or rebuild/replace the game disk. Each run builds a fresh fixture disk and keeps
|
||||
its source hashes, logs and captures beneath ignored `test-output/graphics/`.
|
||||
Use `--app` for another app bundle or `--evidence` for another output directory.
|
||||
Private ROM paths must be supplied explicitly; no ROMs are retained by the test.
|
||||
|
||||
The guest fixture checks every pixel in four observations of three 640 × 225
|
||||
four-color presentations, partial byte edges, all four 8 KiB bank seams, the final scan line,
|
||||
clipping and no-op inputs. It copies the displayed second page into the hidden
|
||||
first page, changes a few edge pixels, and verifies that every other pixel is
|
||||
preserved. A capture before the explicit third presentation verifies that the
|
||||
hidden edits have not appeared prematurely. It verifies normal MMU mappings between draw calls,
|
||||
page flipping, return to BASIC and zero disk writes on both emulated CPUs.
|
||||
Captures are actual guest frames, not synthesized previews. They do not establish
|
||||
physical hardware, host Intel or audible behavior.
|
||||
|
||||
The supplemental host check compiles the actual current `gfx_fill_rect` function
|
||||
with only its hardware span writer substituted. It compares all horizontal
|
||||
positions/widths on 15 critical rows and 1,000 clipped multirow rectangles with
|
||||
an independent per-pixel reference, including untouched neighboring bits and
|
||||
memory beyond the visible image. A host C compiler is required for this optional
|
||||
check; `--skip-host` records the skip instead of reporting it as a pass. Ordinary
|
||||
game builds do not require a host compiler or these tests.
|
||||
+55
-22
@@ -1,25 +1,58 @@
|
||||
"""Validate exact generated anatomy/data and compact rendering ownership."""
|
||||
"""Validate the authored bank and independently decode compact geometry."""
|
||||
import hashlib,json,re,runpy
|
||||
from pathlib import Path
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
module=runpy.run_path(str(ROOT/'tools/prepare_questions.py'));assert module['generated']()==(ROOT/'src/bones.c').read_text()
|
||||
receipt=json.loads((ROOT/'assets/source-receipt.json').read_text());assert hashlib.sha256((ROOT/'assets/skeleton-source.svg').read_bytes()).hexdigest()==receipt['sha256']
|
||||
source=(ROOT/'src/map_data.c').read_text();manifest=json.loads((ROOT/'data/geometry-manifest.json').read_text())
|
||||
# Parse every span/offset pair independently of the conversion dependency stack.
|
||||
arrays={name:[int(v) for v in re.findall(r'\d+',body)] for name,body in re.findall(r'(?:unsigned char|unsigned)\s+(\w+)\s*\[[^]]*\]\s*=\s*\{([^{}]*)\}',source)}
|
||||
view_names=re.search(r'bone_view_spans\[[^]]*\]\s*=\s*\{([^}]+)\}',source)[1]
|
||||
view_names=re.findall(r'[A-Za-z_]\w*',view_names)
|
||||
widths=arrays['bone_view_widths'];heights=arrays['bone_view_heights'];assert len(view_names)==len(widths)==len(heights)==6
|
||||
pairs=[]
|
||||
for name,data in arrays.items():
|
||||
if name.endswith('_spans'):
|
||||
view=view_names.index(name);off=arrays.get(name[:-6]+'_offsets');assert off is not None,(name,'offsets missing');assert len(off)==26 and off[0]==0 and off[-1]==len(data);occupied=set()
|
||||
for bone in range(25):
|
||||
assert off[bone]%3==off[bone+1]%3==0
|
||||
if name=='bone_spans':assert off[bone+1]>off[bone],bone
|
||||
for k in range(off[bone],off[bone+1],3):
|
||||
y,x,n=data[k:k+3];assert n>0 and 0<=y<heights[view] and 0<=x<x+n<=widths[view]
|
||||
for xx in range(x,x+n):assert (xx,y) not in occupied,(name,xx,y);occupied.add((xx,y))
|
||||
pairs.append(name)
|
||||
assert len(pairs)==6,pairs
|
||||
print('PASS authored bank/C identity, source SVG hash, six bounded disjoint views, 25 nonempty overview masks.')
|
||||
|
||||
def read_views():
|
||||
source=(ROOT/'src/map_data.c').read_text()
|
||||
arrays={name:[int(v) for v in re.findall(r'\d+',body)] for name,body in re.findall(r'(?:unsigned char|unsigned)\s+(\w+)\s*\[[^]]*\]\s*=\s*\{([^{}]*)\}',source)}
|
||||
names=re.findall(r'[A-Za-z_]\w*',re.search(r'bone_view_offsets\[[^]]*\]\s*=\s*\{([^}]+)\}',source)[1])
|
||||
blob=(ROOT/'assets/generated/BONES.DAT').read_bytes()
|
||||
assert len(blob)==int(re.search(r'bone_asset_size = (\d+)',source)[1])<=32768
|
||||
assert sum(blob)%65536==int(re.search(r'bone_asset_checksum = (\d+)',source)[1])
|
||||
widths=arrays['bone_view_widths'];heights=arrays['bone_view_heights'];assert len(names)==len(widths)==len(heights)==6
|
||||
count=len(json.loads((ROOT/'data/bones.json').read_text()));views=[]
|
||||
for name,w,h,base in zip(names,widths,heights,arrays['bone_view_data_offsets']):
|
||||
off=arrays[name];data=blob[base:base+off[-1]];assert len(off)==count+3 and off[0]==0 and off[-1]==len(data)
|
||||
layers=[]
|
||||
for start,end in zip(off,off[1:]):
|
||||
assert 0<=start<=end<=len(data);pixels=set();i=start
|
||||
if start<end:
|
||||
assert end-start>=4
|
||||
cursor=data[i]*w+data[i+1];i+=2
|
||||
while i<end:
|
||||
skip=data[i];i+=1
|
||||
if skip==255:
|
||||
assert i+2<=end;skip=data[i]*256+data[i+1];i+=2;assert skip>=255
|
||||
assert i<end
|
||||
n=data[i];i+=1;cursor+=skip;x=cursor%w;y=cursor//w
|
||||
assert n>0 and 0<=y<h and x+n<=w,(name,x,y,n)
|
||||
for pos in range(cursor,cursor+n):assert pos not in pixels;pixels.add(pos)
|
||||
cursor+=n
|
||||
assert i==end
|
||||
layers.append(pixels)
|
||||
views.append(dict(name=name,width=w,height=h,layers=layers))
|
||||
return views,arrays
|
||||
|
||||
def main():
|
||||
module=runpy.run_path(str(ROOT/'tools/prepare_questions.py'));assert module['generated']()==(ROOT/'src/bones.c').read_text()
|
||||
receipt=json.loads((ROOT/'assets/source-receipt.json').read_text());assert hashlib.sha256((ROOT/'assets/skeleton-source.svg').read_bytes()).hexdigest()==receipt['sha256']
|
||||
rows=json.loads((ROOT/'data/bones.json').read_text());manifest=json.loads((ROOT/'data/geometry-manifest.json').read_text())
|
||||
assert [t['code'] for t in manifest['topics']]==[r['code'] for r in rows]
|
||||
asset=(ROOT/manifest['asset']['file']).read_bytes()
|
||||
assert hashlib.sha256(asset).hexdigest()==manifest['asset']['sha256']
|
||||
assert sum(asset)%65536==manifest['asset']['checksum']
|
||||
assert len(rows)==28
|
||||
views,arrays=read_views()
|
||||
for view in views:
|
||||
occupied=set()
|
||||
for pixels in view['layers'][:-1]:
|
||||
assert not pixels&occupied,(view['name'],'overlapping ownership');occupied|=pixels
|
||||
assert view['layers'][-1],(view['name'],'missing outline')
|
||||
for i,row in enumerate(rows):
|
||||
assert views[0]['layers'][i]-views[0]['layers'][-1],(row['code'],'invisible overview')
|
||||
detail=arrays['bone_detail_view'][i]
|
||||
assert views[detail]['layers'][i]-views[detail]['layers'][-1],(row['code'],'invisible detail')
|
||||
print('PASS 28 authored structures/C identity, original SVG hash, six bounded delta views, visible topics and outlines.')
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,220 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Qualify the local 640x225 graphics driver on isolated VCC Plus machines.
|
||||
|
||||
Supply your own ROMs explicitly. This builds an independent fixture disk into a
|
||||
fresh ignored run directory, never uses the normal emulator or the game disk,
|
||||
and requires no Python packages beyond the standard library. Host arithmetic
|
||||
checks additionally need a host C compiler; --skip-host records that skip.
|
||||
"""
|
||||
import argparse
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import plistlib
|
||||
import re
|
||||
import selectors
|
||||
import shutil
|
||||
import struct
|
||||
import subprocess
|
||||
import tempfile
|
||||
import zlib
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
COLORS=((0,0,0),(255,255,255),(255,255,0),(255,85,85))
|
||||
|
||||
|
||||
def sha(path):
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def run(command,folder,log):
|
||||
with log.open('ab') as stream:
|
||||
subprocess.run([str(v) for v in command],cwd=folder,stdout=stream,
|
||||
stderr=subprocess.STDOUT,check=True)
|
||||
|
||||
|
||||
def host_arithmetic(folder,compiler):
|
||||
source=(ROOT/'src/graphics.c').read_text()
|
||||
start=source.index('void gfx_fill_rect(')
|
||||
end=source.index('\nvoid gfx_plot(',start)
|
||||
(folder/'graphics_fill_under_test.h').write_text(source[start:end]+'\n')
|
||||
executable=folder/'graphics_arithmetic'
|
||||
log=folder/'host-build.log'
|
||||
run([compiler,'-std=c99','-O2','-Wall','-Wextra','-Werror','-I'+str(ROOT),
|
||||
'-I'+str(folder),ROOT/'tests/graphics_arithmetic.c','-o',executable],folder,log)
|
||||
run([executable],folder,log)
|
||||
|
||||
|
||||
def build_fixture(app,folder):
|
||||
tools=app/'Contents/Resources/Toolchain/bin'
|
||||
compiler=tools/'cmoc'
|
||||
log=folder/'guest-build.log'
|
||||
for stem,source in (('fixture',ROOT/'tests/graphics_fixture.c'),
|
||||
('graphics',ROOT/'src/graphics.c')):
|
||||
run([compiler,'--coco','-O2','--intermediate','--intdir='+str(folder),
|
||||
'-I'+str(ROOT),'-c','-o',folder/(stem+'.o'),source],folder,log)
|
||||
run([compiler,'--coco','--org=2000','--limit=7800','--intermediate','-o',
|
||||
folder/'BONEQ.BIN',folder/'fixture.o',folder/'graphics.o'],folder,log)
|
||||
run([compiler,'--dos','-O0','--limit=2800','-o',folder/'boot.bin',
|
||||
ROOT/'tools/boot.c'],folder,log)
|
||||
disk=folder/'fixture.dsk'
|
||||
disk.write_bytes(bytes([255])*(35*18*256))
|
||||
run([tools/'install-coco-boot-loader',disk,folder/'boot.bin'],folder,log)
|
||||
run([tools/'writecocofile',disk,folder/'BONEQ.BIN'],folder,log)
|
||||
source=(folder/'BONEQ.map').read_text()
|
||||
phase=int(re.search(r'Symbol: _phase .*?= ([0-9A-Fa-f]+)',source)[1],16)
|
||||
return disk,phase
|
||||
|
||||
|
||||
def png(path):
|
||||
"""Decode the helper's 8-bit RGB/RGBA PNG without optional image modules."""
|
||||
blob=path.read_bytes();position=8;compressed=b''
|
||||
assert blob[:8]==b'\x89PNG\r\n\x1a\n'
|
||||
while position<len(blob):
|
||||
count=int.from_bytes(blob[position:position+4],'big')
|
||||
kind=blob[position+4:position+8]
|
||||
data=blob[position+8:position+8+count];position+=count+12
|
||||
if kind==b'IHDR':width,height,depth,color,*_=struct.unpack('>IIBBBBB',data)
|
||||
if kind==b'IDAT':compressed+=data
|
||||
assert depth==8 and color in (2,6)
|
||||
channels=3 if color==2 else 4;stride=width*channels
|
||||
raw=zlib.decompress(compressed);prior=bytearray(stride);rows=[];position=0
|
||||
for _ in range(height):
|
||||
method=raw[position];position+=1
|
||||
row=bytearray(raw[position:position+stride]);position+=stride
|
||||
assert method in range(5)
|
||||
for i in range(stride):
|
||||
a=row[i-channels] if i>=channels else 0
|
||||
b=prior[i];c=prior[i-channels] if i>=channels else 0
|
||||
if method==1:prediction=a
|
||||
elif method==2:prediction=b
|
||||
elif method==3:prediction=(a+b)//2
|
||||
elif method==4:
|
||||
v=a+b-c;pa=abs(v-a);pb=abs(v-b);pc=abs(v-c)
|
||||
prediction=a if pa<=pb and pa<=pc else b if pb<=pc else c
|
||||
else:prediction=0
|
||||
row[i]=(row[i]+prediction)&255
|
||||
rows.append(row);prior=row
|
||||
return width,height,channels,rows
|
||||
|
||||
|
||||
def rectangle(image,x,y,width,height,color):
|
||||
for yy in range(y,min(225,y+height)):
|
||||
for xx in range(x,min(640,x+width)):
|
||||
image[yy*640+xx]=color
|
||||
|
||||
|
||||
def expected_page(page):
|
||||
if page==1:
|
||||
image=[1]*(640*225)
|
||||
for i in range(1,5):
|
||||
rectangle(image,(i*8192%160)*4-3,i*8192//160,9,1,2)
|
||||
rectangle(image,638,223,9,9,0)
|
||||
rectangle(image,639,0,1,1,3);rectangle(image,0,224,1,1,3)
|
||||
else:
|
||||
image=[2]*(640*225)
|
||||
rectangle(image,0,0,640,1,1);rectangle(image,0,224,640,1,3)
|
||||
rectangle(image,0,0,1,225,0);rectangle(image,639,0,1,225,0)
|
||||
rectangle(image,17,51,619,154,3);rectangle(image,18,52,617,152,1)
|
||||
if page==4:
|
||||
rectangle(image,1,1,2,1,3);rectangle(image,639,224,1,1,1)
|
||||
return image
|
||||
|
||||
|
||||
def qualify_cpu(app,folder,disk,phase,cpu,system_rom,disk_rom):
|
||||
stderr=(folder/(cpu+'-helper.log')).open('w')
|
||||
process=subprocess.Popen([str(app/'Contents/Helpers/vcc-playtest')],
|
||||
stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=stderr,text=True,bufsize=1)
|
||||
selector=selectors.DefaultSelector();selector.register(process.stdout,selectors.EVENT_READ)
|
||||
def call(op,**kwargs):
|
||||
process.stdin.write(json.dumps(dict(op=op,**kwargs))+'\n');process.stdin.flush()
|
||||
if not selector.select(timeout=60):raise TimeoutError('Playtest helper timed out: '+op)
|
||||
line=process.stdout.readline()
|
||||
if not line:raise RuntimeError('Playtest helper closed during '+op)
|
||||
response=json.loads(line)
|
||||
if 'error' in response:raise RuntimeError('Playtest helper rejected '+op+': '+str(response['error']))
|
||||
return response['result']
|
||||
def step():return call('input',steps=[dict(mask=0,fields=600)])
|
||||
def key():return call('input',steps=[dict(mask=1<<31,fields=8),dict(mask=0,fields=600)])
|
||||
def current_phase():return call('read_memory',address=phase,count=1)['bytes'][0]
|
||||
def capture(name):
|
||||
result=call('capture');path=folder/(cpu+'-'+name+'.png')
|
||||
path.write_bytes(base64.b64decode(result.pop('png_base64')))
|
||||
(folder/(cpu+'-'+name+'.json')).write_text(json.dumps(result,indent=2)+'\n')
|
||||
return png(path)
|
||||
encode=lambda data:base64.b64encode(data).decode()
|
||||
try:
|
||||
call('init',system_rom=encode(system_rom),disk_rom=encode(disk_rom),
|
||||
disk=encode(disk.read_bytes()),cpu=cpu,boot_keys=[1<<b for b in (4,15,19,48)])
|
||||
step();assert current_phase()==1,(cpu,'first page phase',current_phase())
|
||||
top=None
|
||||
for page in (1,2,3,4):
|
||||
if page>1:key();assert current_phase()==page,(cpu,'page phase',page,current_phase())
|
||||
width,height,channels,rows=capture('page'+str(page))
|
||||
assert (width,height)==(640,480),(cpu,width,height)
|
||||
def pixel(x,y):return tuple(rows[y][x*channels:x*channels+3])
|
||||
if page==1:
|
||||
visible=[y for y in range(height)
|
||||
if sum(pixel(x,y)==COLORS[1] for x in range(width))>600]
|
||||
assert len(visible)==450 and max(visible)==min(visible)+449,(cpu,'active height')
|
||||
top=min(visible)
|
||||
expected=expected_page(page)
|
||||
for y in range(225):
|
||||
for x in range(640):
|
||||
value=COLORS[expected[y*640+x]]
|
||||
for repeat in (0,1):
|
||||
actual=pixel(x,top+y*2+repeat)
|
||||
assert actual==value,(cpu,page,x,y,actual,value)
|
||||
mmu=call('read_memory',address=0xffa0,count=8)['bytes']
|
||||
assert [value&63 for value in mmu]==list(range(0x38,0x40)),(cpu,'MMU restoration')
|
||||
key();assert current_phase()==5,(cpu,'exit phase',current_phase())
|
||||
result=call('capture')
|
||||
assert 'GRAPHICS TEST COMPLETE' in result.get('screen_text',''),(cpu,'BASIC return')
|
||||
capture('exit')
|
||||
final=call('stop')
|
||||
assert final['disk_writes']==0 and final['disk_sha256']==sha(disk),(cpu,'disk changed')
|
||||
process.wait(timeout=10)
|
||||
return dict(cpu=cpu,ramKB=512,width=640,height=225,frameTop=top,pageFlips=3,frontCopied=True,noPrematurePresentation=True,
|
||||
guestPixelsChecked=576000,clipping=True,partialByteEdges=True,
|
||||
bankBoundaries=True,MMURestored=True,BASICReturned=True,diskWrites=0)
|
||||
finally:
|
||||
if process.poll() is None:process.kill();process.wait(timeout=10)
|
||||
selector.close();stderr.close()
|
||||
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--app',type=Path,default=Path('/Applications/VCC Plus.app'))
|
||||
parser.add_argument('--rom',type=Path,required=True)
|
||||
parser.add_argument('--disk-rom',type=Path,required=True)
|
||||
parser.add_argument('--cpu',choices=('6809','6309','both'),default='both')
|
||||
parser.add_argument('--evidence',type=Path,default=ROOT/'test-output/graphics')
|
||||
parser.add_argument('--cc',default='cc',help='Host C compiler for the arithmetic check')
|
||||
parser.add_argument('--skip-host',action='store_true',help='Skip and record the optional host-compiler check')
|
||||
args=parser.parse_args()
|
||||
args.app=args.app.resolve()
|
||||
system_rom=args.rom.read_bytes();disk_rom=args.disk_rom.read_bytes()
|
||||
evidence=args.evidence.resolve();evidence.mkdir(parents=True,exist_ok=True)
|
||||
folder=Path(tempfile.mkdtemp(prefix='run-',dir=evidence))
|
||||
sources=('src/graphics.c','graphics.h','tests/graphics_fixture.c','tests/graphics_arithmetic.c','tests/check_graphics.py','tools/boot.c')
|
||||
identity={path:sha(ROOT/path) for path in sources}
|
||||
if not args.skip_host:
|
||||
compiler=shutil.which(args.cc)
|
||||
if not compiler:parser.error('Host C compiler unavailable; supply --cc or record --skip-host.')
|
||||
host_arithmetic(folder,compiler);print('PASS host graphics arithmetic',flush=True)
|
||||
disk,phase=build_fixture(args.app,folder)
|
||||
reports=[]
|
||||
for cpu in (('6809','6309') if args.cpu=='both' else (args.cpu,)):
|
||||
reports.append(qualify_cpu(args.app,folder,disk,phase,cpu,system_rom,disk_rom))
|
||||
print('PASS',cpu,'640x225 pages, front copy, all pixels, clipping, bank seams, MMU and BASIC return',flush=True)
|
||||
assert identity=={path:sha(ROOT/path) for path in sources},'Source changed during graphics checks; rerun.'
|
||||
info=plistlib.loads((args.app/'Contents/Info.plist').read_bytes())
|
||||
report=dict(sourceSHA256=identity,fixtureDiskSHA256=sha(disk),
|
||||
emulatorVersion=info.get('CFBundleShortVersionString'),emulatorBuild=info.get('CFBundleVersion'),
|
||||
hostArithmetic='skipped by explicit option' if args.skip_host else 'passed',tests=reports)
|
||||
(folder/'verification.json').write_text(json.dumps(report,indent=2)+'\n')
|
||||
print('Evidence:',folder)
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Reject missing/corrupt artwork cleanly in isolated disposable machines."""
|
||||
import argparse,base64,hashlib,json,subprocess
|
||||
from pathlib import Path
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
p=argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument('--app',type=Path,default=Path('/Applications/VCC Plus.app'))
|
||||
p.add_argument('--rom',type=Path,required=True);p.add_argument('--disk-rom',type=Path,required=True)
|
||||
p.add_argument('--evidence',type=Path,default=ROOT/'test-output/loader')
|
||||
a=p.parse_args();a.evidence.mkdir(parents=True,exist_ok=True)
|
||||
blob=(ROOT/'build/BONEQ.dsk').read_bytes();directory=17*18*256+2*256
|
||||
entry=next(i for i in range(directory,18*18*256,32) if blob[i:i+11]==b'BONES DAT')
|
||||
g=blob[entry+13];track=g//2;track+=track>=17;first=track*18*256+(g%2)*9*256
|
||||
reports=[]
|
||||
for cpu in ('6809','6309'):
|
||||
for variant in ('missing','wrong-size','wrong-checksum'):
|
||||
disk=bytearray(blob)
|
||||
if variant=='missing':disk[entry]=0
|
||||
elif variant=='wrong-size':disk[entry+14:entry+16]=bytes([0,255])
|
||||
else:disk[first]^=1
|
||||
sha=hashlib.sha256(disk).hexdigest()
|
||||
proc=subprocess.Popen([str(a.app/'Contents/Helpers/vcc-playtest')],stdin=subprocess.PIPE,stdout=subprocess.PIPE,text=True)
|
||||
def call(op,**kw):
|
||||
proc.stdin.write(json.dumps(dict(op=op,**kw))+'\n');proc.stdin.flush();r=json.loads(proc.stdout.readline());assert 'error' not in r,r;return r['result']
|
||||
enc=lambda data:base64.b64encode(data).decode()
|
||||
try:
|
||||
call('init',system_rom=enc(a.rom.read_bytes()),disk_rom=enc(a.disk_rom.read_bytes()),disk=enc(disk),cpu=cpu,boot_keys=[1<<b for b in (4,15,19,48)])
|
||||
call('input',steps=[dict(mask=0,fields=600)])
|
||||
r=call('capture');assert 'CANNOT LOAD BONES.DAT' in r['screen_text'] and r['display_buffer']['width']==256,(cpu,variant,r['screen_text'])
|
||||
path=a.evidence/(cpu+'-'+variant+'.png');path.write_bytes(base64.b64decode(r['png_base64']))
|
||||
result=call('stop');assert result['disk_writes']==0 and result['disk_sha256']==sha
|
||||
reports.append(dict(cpu=cpu,variant=variant,BASICReturned=True,diskWrites=0))
|
||||
finally:
|
||||
proc.stdin.close();proc.wait(timeout=10)
|
||||
print('PASS',cpu,variant,flush=True)
|
||||
(a.evidence/'verification.json').write_text(json.dumps(reports,indent=2)+'\n')
|
||||
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check global exits through real guest keys without controlling a desktop."""
|
||||
import argparse,base64,hashlib,json,re,subprocess
|
||||
from pathlib import Path
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
p=argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument('--app',type=Path,default=Path('/Applications/VCC Plus.app'))
|
||||
p.add_argument('--rom',type=Path,required=True);p.add_argument('--disk-rom',type=Path,required=True)
|
||||
p.add_argument('--evidence',type=Path,default=ROOT/'test-output/quit')
|
||||
a=p.parse_args();a.evidence.mkdir(parents=True,exist_ok=True)
|
||||
mp=(ROOT/'build/BONEQ.map').read_text();symbols={n:int(v,16) for n,v in re.findall(r'Symbol: _(\w+) .*?= ([0-9A-Fa-f]+)',mp)}
|
||||
rows=json.loads((ROOT/'data/bones.json').read_text());disk=(ROOT/'build/BONEQ.dsk').read_bytes();sha=hashlib.sha256(disk).hexdigest();reports=[]
|
||||
for cpu in ('6809','6309'):
|
||||
for scenario in ('title-Q','credits-Break','choice-Q','typed-q','typed-ASCII27','spelling-Break','typed-feedback-Q','auto-feedback-Break'):
|
||||
proc=subprocess.Popen([str(a.app/'Contents/Helpers/vcc-playtest')],stdin=subprocess.PIPE,stdout=subprocess.PIPE,text=True)
|
||||
def call(op,**kw):
|
||||
proc.stdin.write(json.dumps(dict(op=op,**kw))+'\n');proc.stdin.flush();r=json.loads(proc.stdout.readline());assert 'error' not in r,r;return r['result']
|
||||
def step(n=600):call('input',steps=[dict(mask=0,fields=n)])
|
||||
def press(mask,settle=600):call('input',steps=[dict(mask=mask,fields=8)]+([dict(mask=0,fields=settle)] if settle else []))
|
||||
def key(bit,settle=600):press(1<<bit,settle)
|
||||
def read(name):return call('read_memory',address=symbols[name],count=1)['bytes'][0]
|
||||
def ready(phase):
|
||||
for _ in range(120):
|
||||
if read('phase')==phase:return
|
||||
step(30)
|
||||
raise AssertionError(('screen not ready',scenario,phase,read('phase')))
|
||||
def type_text(text):
|
||||
for c in text:key(31 if c==' ' else ord(c.lower())-96,16)
|
||||
enc=lambda b:base64.b64encode(b).decode()
|
||||
stopped=False
|
||||
try:
|
||||
call('init',system_rom=enc(a.rom.read_bytes()),disk_rom=enc(a.disk_rom.read_bytes()),disk=enc(disk),cpu=cpu,boot_keys=[1<<b for b in (4,15,19,48)])
|
||||
step();ready(0)
|
||||
quit_mask=1<<17
|
||||
if scenario=='credits-Break':key(3);ready(5);quit_mask=1<<50
|
||||
elif scenario.startswith('choice') or scenario.startswith('auto-'):
|
||||
key(33);ready(1)
|
||||
if scenario.startswith('auto-'):
|
||||
current=read('current_bone');opts=call('read_memory',address=symbols['options'],count=4)['bytes']
|
||||
key(33+opts.index(current),0)
|
||||
for _ in range(1000):
|
||||
if read('phase')==3:break
|
||||
step(1)
|
||||
assert read('phase')==3;step(60);quit_mask=1<<50
|
||||
elif scenario!='title-Q':
|
||||
key(34);ready(1)
|
||||
if scenario=='typed-q':press((1<<55)|(1<<32),16);type_text('fem')
|
||||
elif scenario=='typed-ASCII27':quit_mask=(1<<28)|(1<<55)|(1<<52)
|
||||
elif scenario=='spelling-Break':
|
||||
name=rows[read('current_bone')]['name'];type_text(name[0]+name[2]+name[1]+name[3:]);key(48);ready(2);quit_mask=1<<50
|
||||
elif scenario=='typed-feedback-Q':key(48);ready(3)
|
||||
press(quit_mask);r=call('capture')
|
||||
assert 'THANKS FOR PLAYING BONE QUEST!' in r['screen_text'] and r['display_buffer']['width']==256,(cpu,scenario,r['screen_text'])
|
||||
assert [v&63 for v in call('read_memory',address=0xffa0,count=8)['bytes']]==list(range(0x38,0x40))
|
||||
if scenario=='auto-feedback-Break':assert read('question')==0,'Quit was delayed until next question'
|
||||
(a.evidence/(cpu+'-'+scenario+'.png')).write_bytes(base64.b64decode(r['png_base64']))
|
||||
final=call('stop');stopped=True;assert final['disk_writes']==0 and final['disk_sha256']==sha
|
||||
reports.append(dict(cpu=cpu,scenario=scenario,BASICReturned=True,MMURestored=True,diskWrites=0,diskSHA256=sha))
|
||||
finally:
|
||||
if not stopped:
|
||||
try:call('stop')
|
||||
except Exception:pass
|
||||
proc.stdin.close();proc.wait(timeout=10)
|
||||
print('PASS',cpu,scenario,flush=True)
|
||||
(a.evidence/'verification.json').write_text(json.dumps(reports,indent=2)+'\n')
|
||||
@@ -0,0 +1,60 @@
|
||||
/* Host check of the actual gfx_fill_rect arithmetic, with only the banked
|
||||
hardware span writer substituted. check_graphics.py extracts the current
|
||||
driver function into graphics_fill_under_test.h in a disposable build folder.
|
||||
GPL-3.0-or-later. */
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "graphics.h"
|
||||
typedef unsigned char byte;
|
||||
#define WINDOW 0x8000
|
||||
static byte back=0x1e;
|
||||
static byte image[40960],reference_image[40960];
|
||||
static void span(byte bank,unsigned address,byte firstMask,byte fullBytes,
|
||||
byte lastMask,byte packed)
|
||||
{
|
||||
unsigned pos=(bank-back)*8192+address-WINDOW;
|
||||
assert(pos<36000);
|
||||
if(firstMask) {image[pos]=(image[pos]&~firstMask)|(packed&firstMask);++pos;}
|
||||
while(fullBytes--) {assert(pos<36000);image[pos++]=packed;}
|
||||
if(lastMask) {assert(pos<36000);image[pos]=(image[pos]&~lastMask)|(packed&lastMask);}
|
||||
}
|
||||
#include "graphics_fill_under_test.h"
|
||||
|
||||
static void reference(unsigned x,unsigned y,unsigned w,unsigned h,byte color)
|
||||
{
|
||||
unsigned xx,yy,pos,shift;
|
||||
if(color>3 || x>=640 || y>=225 || !w || !h)return;
|
||||
if(w>640-x)w=640-x;
|
||||
if(h>225-y)h=225-y;
|
||||
for(yy=y;yy<y+h;++yy)for(xx=x;xx<x+w;++xx) {
|
||||
pos=yy*160+xx/4;shift=(3-xx%4)*2;
|
||||
reference_image[pos]=(reference_image[pos]&~(3<<shift))|(color<<shift);
|
||||
}
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
unsigned x,w,y,color,n;
|
||||
uint32_t seed=12345;
|
||||
static const unsigned rows[]={0,1,50,51,52,101,102,103,152,153,154,203,204,205,224};
|
||||
memset(image,0x96,sizeof(image));
|
||||
memset(reference_image,0x96,sizeof(reference_image));
|
||||
for(n=0;n<sizeof(rows)/sizeof(rows[0]);++n) {
|
||||
y=rows[n];
|
||||
for(x=0;x<640;++x)for(w=1;w<=640-x;++w) {
|
||||
color=(x+w+n)%4;gfx_fill_rect(x,y,w,1,color);reference(x,y,w,1,color);
|
||||
assert(!memcmp(image,reference_image,sizeof(image)));
|
||||
}
|
||||
}
|
||||
for(n=0;n<1000;++n) {
|
||||
seed=seed*1664525u+1013904223u;x=seed%700;
|
||||
seed=seed*1664525u+1013904223u;y=seed%260;
|
||||
seed=seed*1664525u+1013904223u;w=seed%700;
|
||||
seed=seed*1664525u+1013904223u;color=seed%5;
|
||||
gfx_fill_rect(x,y,w,n%250,color);reference(x,y,w,n%250,color);
|
||||
assert(!memcmp(image,reference_image,sizeof(image)));
|
||||
}
|
||||
puts("PASS graphics arithmetic: every x/width on15 edge/bank rows and1000 clipped multirow rectangles.");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/* Isolated 640x225 graphics regression fixture. GPL-3.0-or-later.
|
||||
Built/run only by check_graphics.py, never included in the game disk. */
|
||||
#include <cmoc.h>
|
||||
#include <coco.h>
|
||||
#include "graphics.h"
|
||||
|
||||
unsigned char phase;
|
||||
static void wait_for_space(void)
|
||||
{
|
||||
while(inkey()!=' ') {}
|
||||
while(inkey()) {}
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
unsigned i;
|
||||
setHighSpeed(TRUE);
|
||||
if(!gfx_open()) {phase=99;printf("GFX OPEN FAILED\n");return 1;}
|
||||
gfx_set_palette(0,0);gfx_set_palette(1,63);
|
||||
gfx_set_palette(2,54);gfx_set_palette(3,39);
|
||||
|
||||
gfx_clear(1);
|
||||
/* Each stripe straddles an 8 KiB physical bank boundary. */
|
||||
for(i=1;i<5;++i)
|
||||
gfx_fill_rect((i*8192u%160u)*4-3,i*8192u/160u,9,1,2);
|
||||
gfx_fill_rect(638,223,9,9,0);
|
||||
gfx_plot(639,0,3);gfx_plot(0,224,3);
|
||||
/* Empty, out-of-range and invalid-color draws must be no-ops. */
|
||||
gfx_fill_rect(100,100,0,12,3);gfx_fill_rect(100,100,12,0,3);
|
||||
gfx_fill_rect(640,0,3,3,3);gfx_fill_rect(0,225,3,3,3);
|
||||
gfx_fill_rect(10,10,9,9,4);
|
||||
if(!gfx_present()) {phase=98;return 1;}
|
||||
phase=1;wait_for_space();
|
||||
|
||||
/* A different image exercises the other page and many partial byte edges. */
|
||||
gfx_clear(2);
|
||||
gfx_fill_rect(0,0,640,1,1);gfx_fill_rect(0,224,640,1,3);
|
||||
gfx_fill_rect(0,0,1,225,0);gfx_fill_rect(639,0,1,225,0);
|
||||
gfx_fill_rect(17,51,619,154,3);gfx_fill_rect(18,52,617,152,1);
|
||||
if(!gfx_present()) {phase=97;return 1;}
|
||||
phase=2;wait_for_space();
|
||||
/* The hidden page still contains page1. Copy page2, edit two edges, and
|
||||
prove that the rest of page2 survives on this different physical page. */
|
||||
if(!gfx_copy_front()) {phase=96;return 1;}
|
||||
gfx_fill_rect(1,1,2,1,3);gfx_plot(639,224,1);
|
||||
/* These hidden edits must not appear until the explicit presentation. */
|
||||
phase=3;wait_for_space();
|
||||
if(!gfx_present()) {phase=95;return 1;}
|
||||
phase=4;wait_for_space();
|
||||
gfx_close();setHighSpeed(FALSE);phase=5;
|
||||
printf("GRAPHICS TEST COMPLETE\n");return 0;
|
||||
}
|
||||
+73
-36
@@ -4,6 +4,7 @@ Requires explicitly supplied private ROMs; does not operate the personal emulato
|
||||
"""
|
||||
import argparse,ast,base64,hashlib,json,re,struct,subprocess,zlib
|
||||
from pathlib import Path
|
||||
from check_assets import read_views
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
|
||||
def png(path):
|
||||
@@ -30,11 +31,11 @@ def png(path):
|
||||
|
||||
class Screen:
|
||||
def __init__(self,path,font):self.w,self.h,self.ch,self.rows=png(path);self.font=font
|
||||
def guest(self,x,y):return tuple(self.rows[50+y*2][x*2*self.ch:x*2*self.ch+3])
|
||||
def guest(self,x,y):return tuple(self.rows[16+y*2][x*self.ch:x*self.ch+3])
|
||||
def text(self,x,y,n):
|
||||
bg=self.guest(x+5,y);out=''
|
||||
bg=self.guest(x+10,y);out=''
|
||||
for j in range(n):
|
||||
bits=[self.guest(x+j*6+c,y+r)!=bg for r in range(8) for c in range(5)]
|
||||
bits=[self.guest(x+j*12+c*2,y+r)!=bg for r in range(8) for c in range(5)]
|
||||
scores=[]
|
||||
for k in range(32,127):
|
||||
expected=[not(self.font[(k-32)*8+r]&(128>>c)) for r in range(8) for c in range(5)]
|
||||
@@ -48,7 +49,7 @@ def main():
|
||||
p.add_argument('--rom',type=Path,required=True);p.add_argument('--disk-rom',type=Path,required=True)
|
||||
p.add_argument('--evidence',type=Path,default=ROOT/'test-output/playtest')
|
||||
p.add_argument('--cpu',choices=['6809','6309','both'],default='both');args=p.parse_args();out=args.evidence.resolve();out.mkdir(parents=True,exist_ok=True)
|
||||
rows=json.loads((ROOT/'data/bones.json').read_text());binary=ROOT/'build/BONEQ.bin';disk=ROOT/'build/BONEQ.dsk';sha=hashlib.sha256(disk.read_bytes()).hexdigest()
|
||||
rows=json.loads((ROOT/'data/bones.json').read_text());count=len(rows);binary=ROOT/'build/BONEQ.bin';disk=ROOT/'build/BONEQ.dsk';sha=hashlib.sha256(disk.read_bytes()).hexdigest()
|
||||
mp=binary.with_suffix('.map').read_text();symbols={n:int(a,16) for n,a in re.findall(r'Symbol: _(\w+) .*?= ([0-9A-Fa-f]+)',mp)}
|
||||
blob=binary.read_bytes();memory={};i=0
|
||||
while i<len(blob):
|
||||
@@ -56,8 +57,8 @@ def main():
|
||||
if kind==255:break
|
||||
memory.update((a+j,b) for j,b in enumerate(blob[i:i+n]));i+=n
|
||||
font=bytes(memory[symbols['font5x8']+i] for i in range(768))
|
||||
src=(ROOT/'src/map_data.c').read_text();arrays={name:[int(v) for v in re.findall(r'\d+',body)] for name,body in re.findall(r'(?:unsigned char|unsigned)\s+(\w+)\s*\[[^]]*\]\s*=\s*\{([^{}]*)\}',src)}
|
||||
spans=arrays['bone_spans'];offsets=arrays['bone_offsets'];colors={3:(85,170,170),4:(85,85,170),5:(255,85,85),6:(255,255,0)}
|
||||
views,arrays=read_views();colors={0:(0,0,0),1:(255,255,255),2:(255,255,0),3:(255,0,0)}
|
||||
manifest=json.loads((ROOT/'data/geometry-manifest.json').read_text())
|
||||
b64=lambda path:base64.b64encode(path.read_bytes()).decode();reports=[]
|
||||
for cpu in (('6809','6309') if args.cpu=='both' else (args.cpu,)):
|
||||
proc=subprocess.Popen([str(args.app/'Contents/Helpers/vcc-playtest')],stdin=subprocess.PIPE,stdout=subprocess.PIPE,text=True)
|
||||
@@ -65,7 +66,7 @@ def main():
|
||||
proc.stdin.write(json.dumps(dict(op=op,**kw))+'\n');proc.stdin.flush();r=json.loads(proc.stdout.readline());assert 'error' not in r,r;return r['result']
|
||||
def read(name,n=1):return call('read_memory',address=symbols[name],count=n)['bytes']
|
||||
def step(n=600):return call('input',steps=[dict(mask=0,fields=n)])
|
||||
def press(mask,settle=600,hold=8):return call('input',steps=[dict(mask=mask,fields=hold),dict(mask=0,fields=settle)])
|
||||
def press(mask,settle=600,hold=8):return call('input',steps=[dict(mask=mask,fields=hold)]+([dict(mask=0,fields=settle)] if settle else []))
|
||||
def key(bit,settle=600,hold=8):return press(1<<bit,settle,hold)
|
||||
def type_text(s):
|
||||
steps=[]
|
||||
@@ -78,40 +79,69 @@ def main():
|
||||
r=call('capture');path=out/(cpu+'-'+name+'.png');path.write_bytes(base64.b64decode(r.pop('png_base64')))
|
||||
(out/(cpu+'-'+name+'.json')).write_text(json.dumps(r,indent=2)+'\n');return Screen(path,font)
|
||||
def check_map(s,current,outcomes):
|
||||
checked=0
|
||||
for bone in range(25):
|
||||
col=6 if bone==current else 4 if outcomes.get(bone) is True else 5 if bone in outcomes else 3
|
||||
for j in range(offsets[bone],offsets[bone+1],3):
|
||||
y,x,n=spans[j:j+3]
|
||||
for xx in range(x,x+n):
|
||||
assert s.guest(22+xx,30+y)==colors[col],(cpu,bone,current,xx,y,s.guest(22+xx,30+y),colors[col]);checked+=1
|
||||
assert checked>1000
|
||||
def check_view(view,ox,oy,scale=1,cx=0,cy=0,cw=None,ch=None):
|
||||
w=view['width'];h=view['height'];cw=w if cw is None else cw;ch=h if ch is None else ch
|
||||
expected=[None]*(w*h)
|
||||
for bone,pixels in enumerate(view['layers']):
|
||||
col=0 if bone==count+1 else 2 if bone==current else 3 if outcomes.get(bone) is False else 1
|
||||
for pos in pixels:expected[pos]=colors[col]
|
||||
checked=0
|
||||
for y in range(cy,cy+ch):
|
||||
for x in range(cx,cx+cw):
|
||||
value=expected[y*w+x]
|
||||
if value is None:continue
|
||||
for yy in range(scale):
|
||||
for xx in range(scale):
|
||||
actual=s.guest(ox+(x-cx)*scale+xx,oy+(y-cy)*scale+yy)
|
||||
assert actual==value,(cpu,current,view['name'],x,y,actual,value)
|
||||
checked+=1
|
||||
assert checked>0
|
||||
check_view(views[0],8+(200-views[0]['width'])//2,30)
|
||||
if current is None:return
|
||||
detail=arrays['bone_detail_view'][current]
|
||||
if detail:
|
||||
view=views[detail];check_view(view,224+(400-view['width'])//2,34+(98-view['height'])//2)
|
||||
else:
|
||||
x,y,w,h=manifest['overviewBoxes'][rows[current]['code']]
|
||||
if x>2:x-=2;w+=2
|
||||
else:x=0
|
||||
if y>2:y-=2;h+=2
|
||||
else:y=0
|
||||
w+=2;h+=2;w=min(w,views[0]['width']-x);h=min(h,views[0]['height']-y)
|
||||
scale=max(1,min(4,98//h))
|
||||
if w*scale>400:scale=400//w
|
||||
check_view(views[0],224+(400-w*scale)//2,34+(98-h*scale)//2,scale,x,y,w,h)
|
||||
def ready(phase,q=None):
|
||||
for _ in range(120):
|
||||
if read('phase')==[phase] and (q is None or read('question')==[q]):return
|
||||
step(30)
|
||||
raise AssertionError(('Screen did not finish',cpu,phase,q,read('phase'),read('question')))
|
||||
def sound(name):
|
||||
r=call('audio_capture',fields=120);wav=base64.b64decode(r['audio_wav_base64']);(out/(cpu+'-'+name+'.wav')).write_bytes(wav)
|
||||
assert any(wav[44:]),'No guest audio samples'
|
||||
call('init',system_rom=b64(args.rom),disk_rom=b64(args.disk_rom),disk=b64(disk),cpu=cpu,boot_keys=[1<<b for b in (4,15,19,48)])
|
||||
step();check_map(capture('title'),None,{})
|
||||
key(3);s=capture('credits');assert s.text(8,42,45)=='Skeleton: Mariana Ruiz Villarreal';key(31);key(33)
|
||||
step();ready(0);s=capture('title');check_map(s,None,{});assert s.text(224,35,34)==f'{count} STRUCTURES'
|
||||
key(3);s=capture('credits');assert s.text(16,42,45)=='Skeleton: Mariana Ruiz Villarreal';key(31);key(33)
|
||||
outcomes={};slots=[];visited=[]
|
||||
for q in range(25):
|
||||
assert read('phase')==[1] and read('question')==[q]
|
||||
for q in range(count):
|
||||
ready(1,q);assert read('phase')==[1] and read('question')==[q]
|
||||
bone=read('current_bone')[0];s=capture('mc-%02d-%s'%(q+1,rows[bone]['code']));check_map(s,bone,outcomes)
|
||||
assert s.text(8,19,45)==f'Question {q+1}/25 Score {sum(outcomes.values())}'
|
||||
opts=[s.text(112,132+i*11,34)[2:] for i in range(4)];assert len(set(opts))==4 and rows[bone]['name'] in opts,(q,opts)
|
||||
assert s.text(16,19,45)==f'Question {q+1}/{count} Score {sum(outcomes.values())}'
|
||||
opts=[s.text(224,168+i*11,34)[2:] for i in range(4)];assert len(set(opts))==4 and rows[bone]['name'] in opts,(q,opts)
|
||||
slot=opts.index(rows[bone]['name']);assert not slots or slot!=slots[-1];slots.append(slot);visited.append(bone)
|
||||
right=q%5!=0;selection=slot if right else (slot+1)%4
|
||||
right=q not in (0,5,10,15,20);selection=slot if right else (slot+1)%4
|
||||
if q==0:
|
||||
# Hold through feedback and the next question; only one answer.
|
||||
press(1<<(33+selection),600,600);assert read('question')==[1];step(16)
|
||||
else:key(33+selection)
|
||||
outcomes[bone]=right
|
||||
if q%5==0:print(cpu,'multiple choice',q+1,flush=True)
|
||||
assert len(set(visited))==25 and read('phase')==[4]
|
||||
s=capture('mc-results');check_map(s,None,outcomes);assert s.text(112,55,34)=='20 / 25 correct 80%'
|
||||
key(18);s=capture('mc-review');assert s.text(8,39,45)==rows[visited[0]]['name'];key(14);capture('mc-review-next');key(2);key(16);check_map(capture('replay-title'),None,{})
|
||||
ready(4);assert len(set(visited))==count and read('phase')==[4]
|
||||
s=capture('mc-results');check_map(s,None,outcomes);assert s.text(224,55,34)==f'{count-5} / {count} correct {(count-5)*100//count}%'
|
||||
key(18);ready(6);s=capture('mc-review');assert s.text(16,39,45)==rows[visited[0]]['name'];key(14);capture('mc-review-next');key(2);key(16);ready(0);check_map(capture('replay-title'),None,{})
|
||||
key(34);press((1<<55)|(1<<32),16);outcomes={};typed=[];corrections=0
|
||||
for q in range(25):
|
||||
assert read('phase')==[1] and read('question')==[q]
|
||||
for q in range(count):
|
||||
ready(1,q);assert read('phase')==[1] and read('question')==[q]
|
||||
bone=read('current_bone')[0];name=rows[bone]['name'];s=capture('typed-%02d-%s'%(q+1,rows[bone]['code']));check_map(s,bone,outcomes)
|
||||
right=q not in (2,3,4,5,6)
|
||||
if q==0:
|
||||
@@ -122,26 +152,33 @@ def main():
|
||||
elif q==1:
|
||||
type_text(rows[bone]['aliases'][0] if rows[bone]['aliases'] else name);capture('typed-alias')
|
||||
elif q==3:
|
||||
key(50)
|
||||
pass # Blank Enter now reveals; Break is a global quit key.
|
||||
elif q==4:
|
||||
type_text('X'*33);type_text('XXXXXX');step();s=capture('input-limit');assert s.text(112,132,34)=='X'*33+'_'
|
||||
type_text('X'*33);type_text('XXXXXX');step();s=capture('input-limit');assert s.text(224,168,34)=='X'*33+'_'
|
||||
elif q==5:pass
|
||||
elif q in (2,6):
|
||||
other=rows[(bone+1)%25];type_text(other['aliases'][0] if q==6 and other['aliases'] else other['name'])
|
||||
other=rows[(bone+1)%count];type_text(other['aliases'][0] if q==6 and other['aliases'] else other['name'])
|
||||
else:
|
||||
text=' '.join(name.split());text=(' '+text.replace(' ',' ')+' ') if q%3==0 else text.lower() if q%3==1 else text.upper();type_text(text)
|
||||
if q!=3:key(48)
|
||||
if q in (0,2):
|
||||
key(48,0)
|
||||
for _ in range(1200):
|
||||
if read('phase')==[3]:break
|
||||
step(1)
|
||||
assert read('phase')==[3]
|
||||
sound('correct-feedback' if right else 'incorrect-feedback');step()
|
||||
else:key(48)
|
||||
s=capture('typed-feedback-%02d'%(q+1));assert read('phase')==[3]
|
||||
assert s.text(112,134,30)==('CORRECT!' if right else 'NOT THIS TIME.'),(q,name,s.text(112,134,30))
|
||||
assert s.text(224,170,30)==('CORRECT!' if right else 'NOT THIS TIME.'),(q,name,s.text(224,170,30))
|
||||
outcomes[bone]=right;typed.append(bone);assert read('score')==[sum(outcomes.values())]
|
||||
key(31)
|
||||
if q%5==0:print(cpu,'typed',q+1,flush=True)
|
||||
assert len(set(typed))==25 and read('phase')==[4]
|
||||
s=capture('typed-results');check_map(s,None,outcomes);assert s.text(112,55,34)=='20 / 25 correct 80%';assert s.text(112,77,34)=='1 spelling corrections'
|
||||
key(18);s=capture('typed-review');assert s.text(8,39,45)==rows[typed[2]]['name'];key(2);key(17)
|
||||
ready(4);assert len(set(typed))==count and read('phase')==[4]
|
||||
s=capture('typed-results');check_map(s,None,outcomes);assert s.text(224,55,34)==f'{count-5} / {count} correct {(count-5)*100//count}%';assert s.text(224,77,34)=='1 spelling corrections'
|
||||
key(18);ready(6);s=capture('typed-review');assert s.text(16,39,45)==rows[typed[2]]['name'];key(50)
|
||||
s=capture('exit');r=call('capture');assert 'THANKS FOR PLAYING BONE QUEST!' in r.get('screen_text','')
|
||||
final=call('stop');final.pop('disk_base64',None);proc.wait(timeout=10)
|
||||
assert final['disk_writes']==0 and final['disk_sha256']==sha
|
||||
reports.append(dict(cpu=cpu,ramKB=512,multipleChoice=25,typed=25,score=20,spellingCorrections=1,mapPixelsChecked=True,noRepeatedCorrectSlots=True,heldKey=True,review=True,replay=True,exit=True,diskSHA256=sha,diskWrites=0))
|
||||
reports.append(dict(cpu=cpu,ramKB=512,multipleChoice=count,typed=count,score=count-5,spellingCorrections=1,mapPixelsChecked=True,detailPixelsChecked=True,feedbackAudio=True,noRepeatedCorrectSlots=True,heldKey=True,review=True,replay=True,exit=True,diskSHA256=sha,diskWrites=0))
|
||||
(out/'report.json').write_text(json.dumps(reports,indent=2)+'\n');print('PASS',cpu,'complete quizzes, map/colors/choices/input/review/replay/exit',flush=True)
|
||||
if __name__=='__main__':main()
|
||||
+9
-5
@@ -7,6 +7,10 @@ static void aliases(U8 bone,U8 target)
|
||||
const char *p=bones[bone].aliases;char word[ANSWER_SIZE];unsigned n;
|
||||
while(*p){n=0;while(*p && *p!='|'){assert(n<ANSWER_SIZE-1);word[n++]=*p++;}word[n]=0;assert(classify(target,word)==(bone==target?2:0));if(*p)++p;}
|
||||
}
|
||||
static U8 named(const char *name)
|
||||
{
|
||||
U8 i;for(i=0;i<BONE_COUNT;++i)if(!strcmp(bones[i].name,name))return i;assert(0);return 0;
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
unsigned seed,i,j,k,p,slot,previous,positions[4]={0},transitions[4][4]={{0}};
|
||||
@@ -28,15 +32,15 @@ int main(void)
|
||||
for(j=0;j<BONE_COUNT;++j)if(j!=i){assert(classify(i,bones[j].name)==0);aliases(j,i);}
|
||||
assert(classify(i,"")==0 && classify(i,"not a bone")==0);
|
||||
}
|
||||
assert(classify(12,"Humeruz")==1);assert(classify(18,"Femru")==1);
|
||||
assert(classify(17,"phalanges")!=2 && classify(24,"phalanges")!=2);
|
||||
assert(classify(2," COLLAR BONE ")==2);
|
||||
assert(classify(named("Humerus"),"Humeruz")==1);assert(classify(named("Femur"),"Femru")==1);
|
||||
assert(classify(named("Finger phalanges"),"phalanges")!=2 && classify(named("Toe phalanges"),"phalanges")!=2);
|
||||
assert(classify(named("Clavicle")," COLLAR BONE ")==2);
|
||||
normalize(" \t Lumbar VERTEBRAE ",normalized);assert(!strcmp(normalized,"lumbar vertebrae"));
|
||||
quiz_start(2709);
|
||||
for(i=0;i<BONE_COUNT;++i){quiz_record(order[i],i%2?"wrong":bones[order[i]].name,!(i%2),!(i%4));quiz_record(order[i],"duplicate",1,1);}
|
||||
assert(score==13 && corrections==7);
|
||||
assert(score==(BONE_COUNT+1)/2 && corrections==(BONE_COUNT+3)/4);
|
||||
for(i=0;i<BONE_COUNT;++i)assert(answered[i]);
|
||||
quiz_start(2710);assert(!score && !corrections);
|
||||
for(i=0;i<BONE_COUNT;++i)assert(!answered[i] && !responses[i][0]);
|
||||
puts("PASS: 50000 unique option sets, no repeated correct slot, all permitted transitions, aliases/wrong-name guards, spelling, score and reset.");return 0;
|
||||
puts("PASS: 56000 unique option sets, no repeated correct slot, all permitted transitions, aliases/wrong-name guards, spelling, score and reset.");return 0;
|
||||
}
|
||||
Reference in new issue
Block a user