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,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')
|
||||
Reference in new issue
Block a user