Complete Bone Quest high-resolution anatomy quiz

This commit is contained in:
Brian Holman committed 2026-11-11 23:43:09 -07:00
1 parent 3cc37be5fb
commit 2ceb44a48c
62 files changed
+3204 -1301

No files matched your search

+264 -156
View File
@@ -2,10 +2,10 @@
"""Prepare Bone Quest's compact masks from the retained public-domain SVG.
Optional authoring dependencies: Python 3, Pillow and rsvg-convert. Normal game
builds use the generated C files and do not run this converter. The SVG remains
builds use the generated metadata and BONES.DAT and do not run this converter. The SVG remains
unchanged; labels/background are omitted and source bone silhouettes are reduced
into a 25-owner pixel mask. All coordinates below refer to a 436x842 render of the
source's nominal 435.687x841.89 viewBox. No SVG is parsed on the CoCo.
into a 28-structure pixel mask. All coordinates below refer to a 436x842 render of the
source's nominal 435.687x841.89 viewBox; the SVG is rendered at 2x before reduction. No SVG is parsed on the CoCo.
"""
import argparse
import copy
@@ -19,7 +19,15 @@ import xml.etree.ElementTree as ET
from PIL import Image, ImageChops
ROOT = Path(__file__).resolve().parents[1]
TOPICS = [
RASTER_SCALE = 2
RASTER_WIDTH, RASTER_HEIGHT = 436 * RASTER_SCALE, 842 * RASTER_SCALE
def scaled_box(box):
return tuple(value * RASTER_SCALE for value in box)
def crop(mask, box):
return mask.crop(scaled_box(box))
ORIGINAL_GROUPS = [
('CRANIUM', ['Cranium', 'g1297']),
('MANDIBLE', ['Mandible']),
('CLAVICLE', ['ClavicleLeft', 'ClavicleRight']),
@@ -46,18 +54,6 @@ TOPICS = [
('METATARSALS', ['MetatarsalsLeft', 'MetatarsalsRight']),
('TOES', ['PhalangesFootLeft', 'PhalangesFootRight']),
]
# Front-view occlusion: scapulae/spine are behind chest and limbs; sternum,
# clavicles and knees remain visible. Both sides share each topic identity.
PAINT_ORDER = [15,16,17,22,23,24,21,20,18,11,3,10,9,8,5,7,6,0,1,4,2,12,14,13,19]
DETAIL_VIEW = [1,1,5,5,5,5,1,5,4,4,4,4,0,0,0,2,2,2,0,0,0,0,3,3,3]
VIEWS = [
('overview', None, 64, 149),
('head', (163,17,243,154), 38,65),
('hand', (313,397,410,500),61,65),
('foot', (199,747,275,825),63,65),
('spine', (169,274,235,400),34,65),
('chest', (107,132,300,308),68,62),
]
def selected_svg(source, elements, selected):
@@ -79,23 +75,6 @@ def selected_svg(source, elements, selected):
return ET.tostring(root)
def runs(pixels, width, height):
result, offsets = [], [0]
for topic in range(1,26):
for y in range(height):
x = 0
while x < width:
if pixels[y*width+x] != topic:
x += 1
continue
start = x
while x < width and pixels[y*width+x] == topic:
x += 1
result.extend((y,start,x-start))
offsets.append(len(result))
return result, offsets
def c_array(name, values, kind='unsigned char', static=False):
lines = ['static ' if static else '']
prefix = ('static ' if static else '') + 'const '+kind+' '+name+'[] = {\n'
@@ -103,140 +82,269 @@ def c_array(name, values, kind='unsigned char', static=False):
for n in range(0,len(values),24)) + '};\n\n'
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--rsvg-convert', default=shutil.which('rsvg-convert'))
args = parser.parse_args()
if not args.rsvg_convert:
parser.error('Install rsvg-convert for optional asset authoring, or use generated C unchanged.')
source_path = ROOT/'assets/skeleton-source.svg'
source = ET.parse(source_path).getroot()
elements = {e.get('id'):e for e in source.iter() if e.get('id')}
images, masks = [], []
for code, ids in TOPICS:
if any(name not in elements for name in ids):
raise ValueError('Missing source bone group: '+code)
rendered = subprocess.run([args.rsvg_convert,'-w','436','-h','842'],
input=selected_svg(source,elements,set(ids)),capture_output=True,check=True)
image = Image.open(io.BytesIO(rendered.stdout)).convert('RGBA')
images.append(image)
masks.append(image.getchannel('A'))
combined = masks[0]
for mask in masks[1:]:
combined = ImageChops.lighter(combined,mask)
overall_bounds = combined.getbbox()
if overall_bounds != (59,20,405,822):
raise ValueError('Source geometry bounds changed; review bone mapping before regenerating.')
# Keep actual shaded facial recesses from the original illustration visible
# after flattening its colors. No new anatomical shapes are drawn here.
recess = Image.new('L',(436,842),0)
original = images[0]
for y in range(55,103):
for x in range(175,232):
r,g,b,a = original.getpixel((x,y))
eye = ((177<=x<198 or 207<=x<231) and 58<=y<80)
nose = 195<=x<212 and 75<=y<101
luminance = (299*r+587*g+114*b)//1000
if a>128 and ((eye and luminance<213) or (nose and luminance<130)):
recess.putpixel((x,y),255)
generated = ROOT/'assets/generated'; generated.mkdir(parents=True,exist_ok=True)
view_data, overview_pixels = [], None
code = ['/* Generated by tools/prepare_assets.py from LadyofHats public-domain SVG. */\n',
'#include "map_data.h"\n\n']
manifest = dict(schemaVersion=1,source=dict(file='assets/skeleton-source.svg',
sha256=hashlib.sha256(source_path.read_bytes()).hexdigest(),
author='Mariana Ruiz Villarreal (LadyofHats)',license='Public domain dedication',
page='https://commons.wikimedia.org/wiki/File:Human_skeleton_front_en.svg'),
coordinateRender=[436,842],overviewSourceBounds=list(overall_bounds),
topics=[dict(id=i,code=topic,sourceElements=ids) for i,(topic,ids) in enumerate(TOPICS)],
paintOrder=PAINT_ORDER,facialRecesses='Original source shading thresholds, eyes and nasal recess only',
pairedSides='Both sides use one bone-family identity; no left/right questions',views=[])
sizes = 0
for view_index,(name,box,width,height) in enumerate(VIEWS):
box = box or overall_bounds
pixels = bytearray(width*height)
for topic in PAINT_ORDER:
alpha = masks[topic].crop(box).resize((width,height),Image.Resampling.LANCZOS)
for pos,value in enumerate(alpha.tobytes()):
if value>=64:
pixels[pos]=topic+1
if name in ('overview','head'):
holes = recess.crop(box).resize((width,height),Image.Resampling.LANCZOS)
for pos,value in enumerate(holes.tobytes()):
if pixels[pos]==1 and value>=64:
pixels[pos]=0
data,offsets=runs(pixels,width,height)
counts=[pixels.count(i+1) for i in range(25)]
if view_index==0:
overview_pixels=pixels
if not all(counts):
raise ValueError('A bone family disappeared from overview: '+str(counts))
stem='bone'
STRUCTURES = ['SKULL','CERVICAL','MANUBRIUM','STERNUM','XIPHOID','LUMBAR',
'ILIUM','SACRUM','COCCYX','PUBIS','FEMUR','PATELLA','TARSALS',
'METATARSALS','TOES','ORBIT','NASAL','CLAVICLE','SCAPULA','RIBS',
'HUMERUS','ULNA','RADIUS','CARPALS','METACARPALS','FINGERS','FIBULA','TIBIA']
PAINT_ORDER = [28,12,13,14,26,27,10,6,9,18,8,7,5,19,1,0,3,4,2,17,20,21,22,23,24,25,11,15,16]
DETAIL_VIEW = [1,1,5,5,5,4,4,4,4,4,0,0,3,3,3,1,1,5,5,5,0,0,0,2,2,2,0,0]
VIEWS = [('overview',(59,20,405,822),159,184),('head',(163,17,243,154),114,98),
('hand',(313,397,410,500),185,98),('foot',(199,747,275,825),191,98),
('spine',(126,274,279,423),201,98),('chest',(107,132,300,308),215,98)]
def packed_runs(rows, width):
"""Block: initial y,x, then skip,length pairs; 255 escapes a16-bit skip."""
if not rows:
return []
result = [rows[0][0],rows[0][1]]
end = rows[0][0]*width+rows[0][1]
for y,x,length in rows:
skip=y*width+x-end
assert skip>=0 and 0<length<=255
if skip>=255:
result.extend((255,skip>>8,skip&255))
else:
stem=name
code.append(c_array(stem+'_spans',data,static=view_index!=0))
code.append(c_array(stem+'_offsets',offsets,'unsigned',static=view_index!=0))
sizes += len(data)+len(offsets)*2
view_data.append((stem,width,height))
manifest['views'].append(dict(id=view_index,name=name,sourceBounds=list(box),
width=width,height=height,spanBytes=len(data),offsetBytes=len(offsets)*2,
pixels={TOPICS[i][0]:counts[i] for i in range(25)}))
# A developer preview uses the runtime's palette; it is not a native
# emulator capture. The selected sample topic is yellow.
sample = next(i for i,value in enumerate(DETAIL_VIEW) if value==view_index) if view_index else 0
colors=[(0,0,85)] + [(255,255,0) if i==sample else (85,170,170) for i in range(25)]
preview=Image.new('RGB',(width,height));preview.putdata([colors[value] for value in pixels])
preview.save(generated/(name+'-preview.png'))
debug=Image.new('RGB',(width,height));palette=[(0,0,85)]+[((i*73+80)%220+35,(i*41)%220+35,(i*109)%220+35) for i in range(25)];debug.putdata([palette[value] for value in pixels]);debug.save(generated/(name+'-regions.png'))
# Independently decode all authored runs to prove disjoint bounds and
# exact reconstruction of every generated view.
decoded=bytearray(width*height)
for topic in range(25):
for p in range(offsets[topic],offsets[topic+1],3):
y,x,length=data[p:p+3]
assert 0<=y<height and 0<=x<x+length<=width
for xx in range(x,x+length):
pos=y*width+xx;assert decoded[pos]==0;decoded[pos]=topic+1
assert decoded==pixels
result.append(skip)
result.append(length)
end=y*width+x+length
return result
def row_runs(pixels,width,height,value):
rows=[]
for y in range(height):
x=0
while x<width:
if pixels[y*width+x]!=value:
x+=1
continue
start=x
while x<width and pixels[y*width+x]==value:
x+=1
rows.append((y,start,x-start))
return rows
def decode(data,offsets,width,height):
pixels=bytearray(width*height)
for structure in range(30):
p,end=offsets[structure],offsets[structure+1]
if p==end:
continue
y,x=data[p:p+2];p+=2
while p<end:
skip=data[p];p+=1
if skip==255:
skip=data[p]*256+data[p+1];p+=2
x+=skip
while x>=width:
x-=width;y+=1
length=data[p];p+=1
assert 0<=y<height and 0<=x<x+length<=width
for xx in range(x,x+length):
assert pixels[y*width+xx]==0
pixels[y*width+xx]=structure+1
x+=length
assert p==end
return pixels
def main():
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--rsvg-convert',default=shutil.which('rsvg-convert'))
args=parser.parse_args()
if not args.rsvg_convert:
parser.error('Optional asset authoring requires rsvg-convert; ordinary builds use generated C.')
source_path=ROOT/'assets/skeleton-source.svg'
source=ET.parse(source_path).getroot()
elements={e.get('id'):e for e in source.iter() if e.get('id')}
# Relax the artist's widely splayed anatomical left thumb (screen right).
# Rotate the complete three-bone chain together about its wrist attachment;
# the original SVG and all relative bone lengths/joints remain unchanged.
thumb_ids = ('g1977', 'g1951', 'g1963')
for ident in thumb_ids:
element = elements[ident]
assert not element.get('transform'), 'Review the source thumb transform'
element.set('transform', 'rotate(30 367 416)')
def render(ids):
if any(i not in elements for i in ids):
raise ValueError('Missing source SVG group: '+str(ids))
result=subprocess.run([args.rsvg_convert,'-w',str(RASTER_WIDTH),'-h',str(RASTER_HEIGHT)],
input=selected_svg(source,elements,set(ids)),capture_output=True,check=True)
return Image.open(io.BytesIO(result.stdout)).convert('RGBA')
def alpha(ids):return render(ids).getchannel('A')
def clipped(mask,box):
result=Image.new('L',mask.size);result.paste(crop(mask,box),scaled_box(box)[:2]);return result
original=[alpha(ids) for code,ids in ORIGINAL_GROUPS]
sternum=alpha(['Sternum']);pelvis=alpha(['PelvicGirdle']);skull=alpha(['Skull'])
# The artist's explicit eye-recess paths provide both selectable orbits.
for ident in ('path1577','path1579'):
e=elements[ident];e.set('style',e.get('style','')+';opacity:1')
orbit=alpha(['path1577','path1579'])
# Select the visible nasal recess from the source's dark facial region.
skull_rgb=render(['Skull']);nasal=Image.new('L',(RASTER_WIDTH,RASTER_HEIGHT))
for y in range(75*RASTER_SCALE,103*RASTER_SCALE):
for x in range(195*RASTER_SCALE,213*RASTER_SCALE):
red,green,blue,a=skull_rgb.getpixel((x,y))
if a>128 and (299*red+587*green+114*blue)//1000<140:
nasal.putpixel((x,y),255)
cartilage=[]
for group in ('g845','g1609'):
for e in elements[group].iter():
if 'fill:#e1e2e3' in e.get('style',''):
cartilage.append(e.get('id'))
cartilage_mask=alpha(cartilage)
# Preserve the rib faces rather than merging the original overlapping
# shaded polygons into a solid chest plate. The original source luminance
# separates light faces from darker boundaries and cast shadows.
rib_rgb=render(['g845','g1609']);ribs=Image.new('L',(RASTER_WIDTH,RASTER_HEIGHT))
raw=rib_rgb.tobytes()
for pos in range(RASTER_WIDTH*RASTER_HEIGHT):
red,green,blue,a=raw[pos*4:pos*4+4]
if a>=128 and max(red,green,blue)-min(red,green,blue)>30 and (299*red+587*green+114*blue)//1000>=211:
ribs.putpixel((pos%RASTER_WIDTH,pos//RASTER_WIDTH),255)
masks=[skull,original[6],alpha(['Manubrium']),clipped(sternum,(0,0,436,228)),
clipped(sternum,(0,228,436,842)),original[8],clipped(pelvis,(0,0,436,371)),
original[9],original[10],alpha(['g447']),original[18],original[19],
original[22],original[23],original[24],orbit,nasal,original[2],original[3],
ribs,original[12],original[14],original[13],original[15],original[16],
original[17],original[21],original[20]]
context=ImageChops.lighter(original[7],clipped(pelvis,(0,371,436,842)))
masks.append(ImageChops.lighter(context,cartilage_mask))
# Retain the artist's darker bone boundaries and joint lines. A separate
# black ink owner keeps these visible when the selected bone changes color.
source_rgb=render(['layer3'])
source_ink=Image.new('L',source_rgb.size)
ink_bytes=bytearray(RASTER_WIDTH*RASTER_HEIGHT)
source_bytes=source_rgb.tobytes()
for pos in range(RASTER_WIDTH*RASTER_HEIGHT):
red,green,blue,a=source_bytes[pos*4:pos*4+4]
if a>=128 and (299*red+587*green+114*blue)//1000<180:
ink_bytes[pos]=255
source_ink.frombytes(bytes(ink_bytes))
manifest=dict(schemaVersion=3,encoding='delta-runs-v1',source=dict(file='assets/skeleton-source.svg',
sha256=hashlib.sha256(source_path.read_bytes()).hexdigest(),author='Mariana Ruiz Villarreal (LadyofHats)',
license='Public domain dedication',page='https://commons.wikimedia.org/wiki/File:Human_skeleton_front_en.svg'),
coordinateRender=[RASTER_WIDTH,RASTER_HEIGHT],sourceCoordinates=[436,842],pixelAspect=[1,2],topics=[dict(id=i,code=name) for i,name in enumerate(STRUCTURES)],
contextIndex=28,inkIndex=29,drawCount=30,
derivedRegions=dict(leftThumbPose=dict(elements=list(thumb_ids),rotationDegrees=30,pivot=[367,416],purpose='Relax the anatomical left thumb on screen right without changing bone lengths or joints'),sternum='Native Sternum path split atsource y228: body above, xiphoid below',
ilium='Native PelvicGirdle upperwings clipped atsource y371; remaining lowerhip isneutralcontext',
pubis='Nativeg447 pairedpubicarch',orbit='Nativepath1577/path1579 eye-recess shapes withopacityflattened',
nasal='Source facialregion x195..212 y75..102 withluminance<140',
ribs='Native g845/g1609 bright bone-face pixels, excluding gray cartilage; source rib matte occludes rear scapula',
internalInk='Native full-skeleton luminance below180/255, box resampled coverage at least70/255; cavity cores retain their own selectable masks'),
originalSourceGroups={name:ids for name,ids in ORIGINAL_GROUPS},views=[])
code=['/* Generated source-derived Bone Quest structure masks. */\n#include "map_data.h"\n\n']
generated=ROOT/'assets/generated';generated.mkdir(parents=True,exist_ok=True)
sizes=0;view_data=[];overview=None;asset=bytearray();data_offsets=[]
for view_index,(name,box,width,height) in enumerate(VIEWS):
pixels=bytearray(width*height)
for topic in PAINT_ORDER:
if topic==19:
# Rear scapula and unlabelled spine must not fill the rib gaps.
matte=crop(original[5],box).resize((width,height),Image.Resampling.LANCZOS)
for p,value in enumerate(matte.tobytes()):
if value>=64 and pixels[p] in (19,29):pixels[p]=0
cart=crop(cartilage_mask,box).resize((width,height),Image.Resampling.LANCZOS)
for p,value in enumerate(cart.tobytes()):
if value>=64:pixels[p]=29
mode=Image.Resampling.LANCZOS
layer=crop(masks[topic],box).resize((width,height),mode)
threshold=128 if topic in (0,6,10,18,19) else 64
for p,value in enumerate(layer.tobytes()):
if value>=threshold:pixels[p]=topic+1
# Store internal separators. The black canvas supplies exterior contours,
# avoiding duplicate edge data and an extra runtime outline pass.
before=pixels[:]
for y in range(height):
for x in range(width):
p=y*width+x
adjacent=[before[n] for n in (p-1,p+1,p-width,p+width)
if 0<=n<len(before) and (n//width==y or n%width==x)]
if before[p]==29 and any(0<v<29 for v in adjacent):pixels[p]=30
elif before[p]==1 and any(v in (16,17) for v in adjacent):pixels[p]=30
elif before[p]==4 and any(v in (3,5) for v in adjacent):pixels[p]=30
ink_layer=crop(source_ink,box).resize((width,height),Image.Resampling.BOX)
ink_values=ink_layer.tobytes()
for p,value in enumerate(ink_values):
if value>=70 and pixels[p] and pixels[p] not in (16,17):pixels[p]=30
# Keep at least one visible fill pixel for every represented topic; this
# protects the smallest overview structures from stroke quantization.
for owner in range(1,29):
if owner in before and owner not in pixels:
candidates=[p for p,v in enumerate(before) if v==owner]
p=min(candidates,key=lambda p:ink_values[p])
pixels[p]=owner
counts=[pixels.count(i+1) for i in range(30)]
if view_index==0:
overview=pixels[:]
if not all(counts[:28]):raise ValueError('Astructuredisappearedfromoverview:'+str(counts))
data=[];offsets=[0]
for i in range(30):data.extend(packed_runs(row_runs(pixels,width,height,i+1),width));offsets.append(len(data))
assert decode(data,offsets,width,height)==pixels
stem='bone' if view_index==0 else name
data_offsets.append(len(asset));asset.extend(data)
code.append(c_array(stem+'_offsets',offsets,'unsigned',static=True))
sizes+=len(offsets)*2;view_data.append((stem,width,height))
manifest['views'].append(dict(id=view_index,name=name,sourceBounds=list(box),width=width,height=height,
fileOffset=data_offsets[-1],spanBytes=len(data),offsetBytes=len(offsets)*2,pixels={STRUCTURES[i] if i<28 else 'CONTEXT' if i==28 else 'INK':counts[i] for i in range(30)}))
# The black canvas supplies the exterior outlines; ink is internal.
display=pixels
sample=next((i for i,view in enumerate(DETAIL_VIEW) if view==view_index),0)
colors=[(0,0,0)]+[(255,255,0) if i==sample else(255,255,255) for i in range(28)]+[(255,255,255),(0,0,0)]
image=Image.new('RGB',(width,height));image.putdata([colors[value] for value in display]);image.save(generated/(name+'-preview.png'))
image.resize((width*2,height*4),Image.Resampling.NEAREST).save(generated/(name+'-display-preview.png'))
palette=[(0,0,85)]+[((i*73+80)%220+35,(i*41)%220+35,(i*109)%220+35) for i in range(29)]+[(0,0,0)]
image.putdata([palette[value] for value in pixels]);image.save(generated/(name+'-regions.png'))
boxes=[]
for topic in range(1,26):
points=[(i%64,i//64) for i,value in enumerate(overview_pixels) if value==topic]
for topic in range(1,29):
points=[(p%VIEWS[0][2],p//VIEWS[0][2]) for p,value in enumerate(overview) if value==topic]
xmin=min(x for x,y in points);ymin=min(y for x,y in points)
boxes.extend((xmin,ymin,max(x for x,y in points)-xmin+1,max(y for x,y in points)-ymin+1))
code.append('const unsigned char bone_boxes[25][4] = {'+','.join('{'+','.join(map(str,boxes[i:i+4]))+'}' for i in range(0,100,4))+'};\n')
code.append(c_array('bone_detail_view',DETAIL_VIEW))
code.append(c_array('bone_view_widths',[v[1] for v in view_data]))
code.append(c_array('bone_view_heights',[v[2] for v in view_data]))
code.append('const unsigned char * const bone_view_spans[BONE_VIEW_COUNT] = {'+','.join(v[0]+'_spans' for v in view_data)+'};\n')
code.append('const unsigned char bone_boxes[28][4] = {'+','.join('{'+','.join(map(str,boxes[i:i+4]))+'}' for i in range(0,112,4))+'};\n')
code.append(c_array('bone_detail_view',DETAIL_VIEW));code.append(c_array('bone_view_widths',[v[1] for v in view_data]));code.append(c_array('bone_view_heights',[v[2] for v in view_data]))
code.append(c_array('bone_view_data_offsets',data_offsets,'unsigned'))
code.append('const unsigned * const bone_view_offsets[BONE_VIEW_COUNT] = {'+','.join(v[0]+'_offsets' for v in view_data)+'};\n')
sizes+=len(boxes)+len(DETAIL_VIEW)+len(view_data)*2+len(view_data)*4
if sizes>6000:
raise ValueError('Geometry exceeds 6000-byte ROM budget: '+str(sizes))
sizes+=len(boxes)+len(DETAIL_VIEW)+len(view_data)*6+4
raw_size=len(asset)
asset.extend(bytes((-len(asset))%256))
if len(asset)>32768:raise ValueError('Banked geometry exceeds32768-byte budget:'+str(len(asset)))
checksum=sum(asset)&65535
code.append('const unsigned bone_asset_size = '+str(len(asset))+';\n')
code.append('const unsigned bone_asset_checksum = '+str(checksum)+';\n')
(generated/'BONES.DAT').write_bytes(asset)
manifest['asset']=dict(file='assets/generated/BONES.DAT',spanBytes=raw_size,bytes=len(asset),sha256=hashlib.sha256(asset).hexdigest(),checksum=checksum,padding='Zero padded to256 bytes')
(ROOT/'src/map_data.c').write_text(''.join(code))
(ROOT/'map_data.h').write_text('''#ifndef BONE_MAP_DATA_H
(ROOT/'map_data.h').write_text("""#ifndef BONE_MAP_DATA_H
#define BONE_MAP_DATA_H
#define BONE_MAP_WIDTH 64
#define BONE_MAP_HEIGHT 149
#define BONE_MAP_WIDTH 159
#define BONE_MAP_HEIGHT 184
#define BONE_VIEW_COUNT 6
/* Spans are (y,x,length) triples. Offsets index bytes, 26 entries per view.
bone_boxes is [25][4]: xmin,ymin,width,height in overview pixels.
View IDs: 0 overview,1 head/neck,2 hand,3 foot,4 lower spine/pelvis,5 chest.
A zero detail-view selector asks the UI to magnify the current overview crop. */
extern const unsigned char bone_spans[];
extern const unsigned bone_offsets[26];
extern const unsigned char bone_boxes[25][4];
extern const unsigned char bone_detail_view[25];
#define BONE_CONTEXT_INDEX 28
#define BONE_INK_INDEX 29
#define BONE_DRAW_COUNT 30
/* Each nonempty owner block starts y,x; then (skip,length) pairs. Skip255
escapes 16-bit big-endian skip. Gaps are row-major from the previous run end.
Offsets index bytes within each view,31 entries perview.
View bytes live in external BONES.DAT, starting at bone_view_data_offsets.
Native 640x225 pixels have1:2 width:height aspect; source masks are fitted accordingly. Context is neutral; ink is black.
The black canvas supplies exterior contours; stored ink preserves internal lines.
Boxes: xmin,ymin,width,height in overview pixels. View0=overview,1=head,
2=hand,3=foot,4=pelvis/lowerback,5=chest. Selector 0 uses an overview crop. */
extern const unsigned char bone_boxes[28][4];
extern const unsigned char bone_detail_view[28];
extern const unsigned char bone_view_widths[6],bone_view_heights[6];
extern const unsigned char * const bone_view_spans[BONE_VIEW_COUNT];
extern const unsigned bone_view_data_offsets[BONE_VIEW_COUNT];
extern const unsigned bone_asset_size, bone_asset_checksum;
extern const unsigned * const bone_view_offsets[BONE_VIEW_COUNT];
#endif
''')
manifest['geometryROMBytes']=sizes
manifest['detailSelector']=DETAIL_VIEW
manifest['overviewBoxes']={TOPICS[i][0]:boxes[4*i:4*i+4] for i in range(25)}
""")
manifest['geometryROMBytes']=sizes;manifest['detailSelector']=DETAIL_VIEW
manifest['overviewBoxes']={STRUCTURES[i]:boxes[i*4:i*4+4] for i in range(28)}
(ROOT/'data/geometry-manifest.json').write_text(json.dumps(manifest,indent=2)+'\n')
print('PASS25 source-group masks; six disjoint bounded views; geometry ROM bytes:',sizes)
print('PASS28 structures; exact disjoint delta decoding. Metadata ROM bytes:',sizes,'Banked asset bytes:',len(asset),'Unpadded:',raw_size,'Checksum:',checksum)
if __name__=='__main__':
main()
if __name__=='__main__':main()