@moonbase-machines/player 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/moonbase-player.js +1 -1
- package/dist/moonbase-player.js.map +1 -1
- package/engines/original.js +1 -1
- package/package.json +6 -6
- package/remake/README.md +138 -0
package/README.md
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
The player for Mark Wharton's titles of 1985 to 1995, one way in for every title and every way to play it (`play.js`):
|
|
4
4
|
|
|
5
5
|
- **Original** (`way: 'original'`, `engines/original.js`): the game's own disk, untouched, on Moonbase's Apple IIe or
|
|
6
|
-
Commodore 64 (`@moonbase-machines/apple2e`, `c64`)
|
|
7
|
-
Commodore's.
|
|
6
|
+
Commodore 64 (`@moonbase-machines/apple2e`, `c64`). It's the Original on the makers' ROMs, where the page gives
|
|
7
|
+
them (`roms`), and the Replica on Moonbase's own ROMs, which need nothing of Apple's or Commodore's.
|
|
8
8
|
- **Remake** (`way: 'remake'`): the game's scenes, lifted from its code and compiled to JavaScript, on the remake's
|
|
9
9
|
engine (`engines/scenes.js`, a title of `card` or `vector` scenes), or the title's own engine, a module in its folder.
|
|
10
10
|
|
|
11
|
+
[The four layers](../../docs/layers.md) explains how the Original, the Replica and the Remake differ, and what runs
|
|
12
|
+
each one.
|
|
13
|
+
|
|
11
14
|
The player makes its part of the page and owns it, the same for every title: the section (classes `player`, the way,
|
|
12
15
|
the title's slug), the stage sized a whole number of the device's pixels to each of the screen's dots, the options
|
|
13
16
|
line and the status, the keys (one listener, each machine's codes, `keys.js`), the sound, a Commodore 64's printer,
|
|
@@ -30,7 +33,8 @@ No title is named in it. A title is a folder of its own, kept with the title, wh
|
|
|
30
33
|
scenes call, by address, and what its engine needs beside them: `remake/cards.js` and `remake/vector.js` say what
|
|
31
34
|
each engine reads), the modules it brings (`modules`, its problems; `view`, its view's own drawing), its font's own
|
|
32
35
|
glyphs (`font`), its stylesheet (`style`);
|
|
33
|
-
- its scenes (`<name>.scene`) and `compiled/` (`moonbase-compile`).
|
|
36
|
+
- its scenes (`<name>.scene`) and `compiled/` (`moonbase-compile`); `remake/README.md` says what a scene is, how it
|
|
37
|
+
is compiled and run, and the two engines.
|
|
34
38
|
|
|
35
39
|
Beside it the game's data, `<name>.json` (its disks' files, its kind, and where it saves: `saves`).
|
|
36
40
|
|
package/dist/moonbase-player.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @moonbase-machines/player 0.
|
|
1
|
+
/*! @moonbase-machines/player 0.12.0: MIT, (c) 2026 Mark Wharton (its LICENSE) */
|
|
2
2
|
var Ci=Object.defineProperty;var B=(s,t,e)=>()=>{if(e)throw e[0];try{return s&&(t=s(s=0)),t}catch(n){throw e=[n],n}};var z=(s,t)=>{for(var e in t)Ci(s,e,{get:t[e],enumerable:!0})};var bs={};z(bs,{branchTaken:()=>Ot,operand:()=>Z,parse:()=>Ct,words:()=>Vt});function Ct(s,t="script"){let e=[],n={},i=[];return s.split(`
|
|
3
3
|
`).forEach((o,c)=>{let h=o.replace(/^\s+|\s+$/g,"");if(!h||h.startsWith(";"))return;let f=t+":"+(c+1),l;if(l=/^(L[0-9A-F]{4}|[A-Za-z_][\w-]*):$/.exec(h)){n[l[1]]=e.length;return}if(l=/^data \$([0-9A-F]+)((?: [0-9A-F]{2})+)$/i.exec(h)){i.push({at:parseInt(l[1],16),bytes:l[2].trim().split(" ").map(k=>parseInt(k,16))});return}l=/^([0-9A-F]{4})\s+(.*)$/.exec(h);let m=l?parseInt(l[1],16):null,g=l?l[2]:h;e.push({at:m,words:Vt(g),text:g,where:f,index:e.length})}),{steps:e,labels:n,data:i}}function Z(s){if(typeof s!="string")return{string:s.string};if(/^-?\d+$/.test(s))return{number:+s};if(/^[axy]$/.test(s)||s==="carry"||s==="borrow")return{reg:s};let t;if(t=/^\$([0-9A-F]+)(?:\[([xy])\])?$/i.exec(s))return{at:parseInt(t[1],16),index:t[2],zp:t[1].length<=2};if(t=/^\(\$([0-9A-F]{2})\)\[y\]$/i.exec(s))return{through:parseInt(t[1],16)};if(t=/^\(\$([0-9A-F]{2})\[x\]\)$/i.exec(s))return{pair:parseInt(t[1],16)};if(t=/^\[\$([0-9A-F]{4})\](?:\[([xy])\])?$/i.exec(s))return{via:parseInt(t[1],16),index:t[2]};throw new Error("not an operand: "+s)}function Ot(s){if(s.at===null)return 1;let t=s.words,e=parseInt(t.at(-1).slice(1),16),n=s.at+(t.length===6?Ai(t[3]):0)+2&65535;return/^L[0-9A-F]{4}$/.test(t.at(-1))&&(e&65280)!==(n&65280)?2:1}var Oi,Vt,Ai,Yt=B(()=>{Oi=/"(?:[^"\\]|\\.)*"|\S+/g;Vt=s=>s.match(Oi).map(t=>t.startsWith('"')?{string:JSON.parse(t)}:t);Ai=s=>/^\d+$/.test(s)||/^\$[0-9A-F]{2}(\[[xy]\])?$/i.test(s)||/^\(\$/.test(s)?2:3});import{cpu as Li}from"@moonbase-machines/mos6502";var Oo,me,vs=B(()=>{({CPU:Oo,CYCLES:me}=Li)});var As={};z(As,{Engine:()=>Lt,label16:()=>At});function js(s){if(s===32)return 3;if(s===0||s===64||s===96)return 1;let t=s>>2&7,e=s&3;return e===1?t===3||t===6||t===7?3:2:t===0?e===2||(s&224)>=160?2:1:t===2||t===6?e===0||e===2?1:2:t===4?2:t===3||t===7?3:2}var Ss,Ti,Es,$s,Ri,Cs,Os,At,Lt,xe=B(()=>{Yt();vs();Ss={left:!0},Ti=new Set(["if","goto","call","return","compare","test","asm","push","pull"]),Es=s=>Ti.has(s.words[0])||/^(=|\+=|-=|&=|\|=|\^=|<<=|>>=|rotate)$/.test(s.words[1]),$s=1020.484;Ri=new Set([234,169,162,160,165,166,164,173,174,172,24,56]),Cs=s=>s.words[0]==="if"&&s.words.length===6,Os=s=>s?.at==null?void 0:s.at+2&65535,At=s=>"L"+s.toString(16).toUpperCase().padStart(4,"0"),Lt=class{constructor({routines:t,scripts:e,start:n,label:i,memory:o={}}){this.routines=t,this.sources=e,this.mem=new Uint8Array(65536);for(let[c,h]of Object.entries(o))this.mem[c]=h;this.a=0,this.x=0,this.y=0,this.n=0,this.z=0,this.c=0,this.v=0,this.d=0,this.stack=[],this.keys=[],this.listeners=[],this.takers=[],this.ended=!1,this.timed=!!t.timed,this.cycles=0,this.clicks=[],this.delay=0,this.programs={},t.setup?.(this),this.enter(n,i,!0)}on(t){this.listeners.push(t)}emit(t){this.inside&&(t.inside=!0);for(let e of this.listeners)e(t)}inside=0;press(t){this.keys.push(t)}key(){let t=this.keys.shift();if(t!==void 0)for(let e of this.takers)e(t);return t}onKey(t){return this.takers.push(t),()=>{this.takers=this.takers.filter(e=>e!==t)}}enter(t,e,n=!1){let i=this.script(t);if(n)for(let o of i.data)this.mem.set(o.bytes,o.at);this.program=i,this.name=t,this.pc=e===void 0?0:this.label(e)}script(t){if(this.programs[t])return this.programs[t];let e=this.sources[t];if(e===void 0)throw new Error("no script "+t);let n=this.programs[t]=typeof e=="string"?Ct(e,t):{labels:e.labels,data:e.data.map(([i,o])=>({at:i,bytes:o})),steps:e.steps.map(([i,o,c],h)=>({at:i,text:c,where:t+":"+o,run:e.run[h],words:Vt(c),index:h}))};for(let[i,o]of Object.entries(n.labels)){let c=/^L[0-9A-F]{4}$/.test(i)?parseInt(i.slice(1),16):null;c!==null&&n.steps[o]?.at>c&&(n.steps[o].start=c),c!==null&&n.steps[o]?.at===c&&(n.steps[o].entered=!0)}return n}callInside(t,e,n,i){this.stack.push({name:this.name,pc:this.pc,inside:!0,done:n,ret:i}),this.inside++,this.enter(t,e)}leave(t,e){throw this.stack=[],this.problem=null,this.waitingOn=null,this.visited=null,this.enter(t,e),Ss}visit(t){this.visiting=t}startVisit(t){let[e,n]=this.title.visit[this.visiting];this.visiting=void 0,this.visited||(this.visited={name:this.name,pc:t,stack:this.stack,problem:this.problem,waitingOn:this.waitingOn,asked:this.asked,askMode:this.askMode,regs:[this.a,this.x,this.y,this.n,this.z,this.c,this.v]},this.title.raster?.keepScreen(),this.inside++,this.emit({step:"keep-screen"}),this.inside--,this.routines.show(this,[],null)),this.stack=[{visit:!0}],this.problem=null,this.waitingOn=null,this.asked=null,this.a=2,this.c=0,this.enter(e,n)}endVisit(){let t=this.visited;this.visited=null,this.title.raster?.putScreen(),this.inside++,this.emit({step:"put-screen"}),this.inside--,this.routines.show(this,[],null),this.enter(t.name),Object.assign(this,{pc:t.pc,stack:t.stack,problem:t.problem,waitingOn:t.waitingOn,asked:t.asked,askMode:t.askMode}),[this.a,this.x,this.y,this.n,this.z,this.c,this.v]=t.regs}label(t){let e=this.program.labels[t];if(e===void 0)throw new Error(this.name+": no label "+t);return e}place(t){if(t.through!==void 0)return(this.mem[t.through]|this.mem[t.through+1]<<8)+this.y&65535;if(t.pair!==void 0){let e=t.pair+this.x&255;return this.mem[e]|this.mem[e+1&255]<<8}return t.via!==void 0?(this.mem[t.via]|this.mem[t.via+1]<<8)+(t.index?this[t.index]:0)&65535:t.at+(t.index?this[t.index]:0)&65535}read(t){return this.io&&this.ioAt(t)?this.io(t)&255:this.mem[t]}write(t,e){this.io&&this.ioAt(t)?this.io(t,e&255):this.mem[t]=e}ioAt(t){return(t&65280)===49152}get(t){return t.number!==void 0?t.number&255:t.reg==="carry"?this.c:t.reg?this[t.reg]:this.read(this.place(t))}load(t){return this.timed&&(t.index&&!t.zp||t.through!==void 0)&&((t.through!==void 0?this.mem[t.through]|this.mem[t.through+1]<<8:t.via!==void 0?this.mem[t.via]|this.mem[t.via+1]<<8:t.at)&255)+this[t.index??"y"]>255&&this.cycles++,this.get(t)}ix(t,e){return this.timed&&(t&255)+e>255&&this.cycles++,t+e&65535}set(t,e){if(e&=255,t.reg){this[t.reg]=e;return}this.write(this.place(t),e)}flags(t){return this.n=t>>7&1,this.z=t===0?1:0,t}compare(t,e){let n=t-e&511;this.c=t>=e?1:0,this.flags(n&255)}time(t,e,n){if(!this.timed)return;let i=t[e].cycles;if(i===void 0){i=0;for(let o=e;o<=n;o++)i+=this.cost(t,o);t[e].cycles=i}this.cycles+=i,this.delay+=i/$s}cost(t,e){let n=t[e],i=this.mem;if(n.at===null)return 0;let o=me[i[n.at]]+(Cs(n)?2:0),c=!n.entered&&!["return","goto"].includes(t[e-1]?.words[0])?t[e-1]:null;if(n.start!==void 0||c&&c.at!==null){let h=n.start??c.at+js(i[c.at])+(Cs(c)?2:0)+(this.routines.inline?.(this,c)??0);if(h<n.at&&n.at-h<=9){let f=0,l=h;for(;l<n.at&&Ri.has(i[l]);l+=js(i[l]))f+=me[i[l]];l===n.at&&(o+=f)}}return o}add(t){if(this.d){let i=(this.a&15)+(t&15)+this.c,o=(this.a>>4)+(t>>4);i>9&&(i-=10,o++),this.z=(this.a+t+this.c&255)===0?1:0,this.n=o&8?1:0,this.v=~(this.a^t)&(this.a^o<<4)&128?1:0,o>9?(o-=10,this.c=1):this.c=0,this.a=(o<<4|i)&255;return}let e=this.a,n=e+t+this.c;this.v=~(e^t)&(e^n)&128?1:0,this.c=n>255?1:0,this.a=this.flags(n&255)}sub(t){if(!this.d)return this.add(t^255);let e=(this.a&15)-(t&15)-(1-this.c),n=(this.a>>4)-(t>>4);e<0&&(e+=10,n--);let i=this.a-t-(1-this.c);this.z=(i&255)===0?1:0,this.n=i&128?1:0,this.v=(this.a^t)&(this.a^i)&128?1:0,this.c=i>=0?1:0,n<0&&(n+=10),this.a=(n<<4|e)&255}shift(t,e,n){let i=e?(t<<1|(n?this.c:0))&255:t>>1|(n&&this.c?128:0);return this.c=e?t>>7:t&1,this.flags(i)}test(t){this.n=t>>7&1,this.v=t>>6&1,this.z=(t&this.a)===0?1:0}jump(t,e){if(this.routines.elsewhere?.(this,t))return this.routines["goto-engine"](this,["$"+t.slice(1)],e);this.pc=this.label(t)}jumpThrough(t,e){let n=At(this.mem[t]|this.mem[t+1]<<8);if(this.program.labels[n]===void 0&&this.routines["goto-engine"])return this.routines["goto-engine"](this,["$"+n.slice(1)],e);this.pc=this.label(n)}jumpTable(t,e){this.pc=this.label(At(this.mem[t+e]|this.mem[t+e+1]<<8))}call(t,e){if(this.routines.elsewhere?.(this,t))return this.routines["call-engine"](this,["$"+t.slice(1)],e);this.stack.push({name:this.name,pc:this.pc,ret:Os(e)}),this.pc=this.label(t)}callThrough(t,e){let n=At(this.mem[t]|this.mem[t+1]<<8);if(this.program.labels[n]===void 0&&this.routines["call-engine"])return this.routines["call-engine"](this,["$"+n.slice(1)],e);this.stack.push({name:this.name,pc:this.pc,ret:Os(e)}),this.pc=this.label(n)}ret(t){let e=this.stack.pop();if(!e)throw new Error("return with nothing called");if(e.visit){this.endVisit();return}let n=this.pulled;if(e.a!==void 0&&this.stack.at(-1)?.a!==void 0){let i=this.stack.pop().a,o=(i<<8|e.a)+1&65535,c=At(o);if(n?.ret!==void 0&&o>n.ret&&o-n.ret<=256){this.pulled=null,n.name!==this.name&&this.enter(n.name),this.pc=n.pc,n.inside&&(this.inside--,n.done?.(this));return}if(n?.ret!==void 0&&o<=n.ret&&n.ret-o<=32&&this.script(n.name).labels[c]!==void 0){this.pulled=null,n.name!==this.name&&this.enter(n.name),this.pc=this.label(c),n.inside&&(this.again=this.again?.ret===n.ret?{...this.again,n:this.again.n+1}:{ret:n.ret,done:n.done,n:1});return}if(this.program.labels[c]===void 0&&this.routines["goto-engine"])return this.routines["goto-engine"](this,["$"+c.slice(1)],t);this.pc=this.label(c);return}if(n&&this.stack.length<n.depth&&(this.pulled=null,n.inside&&n.ret!==void 0&&this.inside--),e.name!==this.name&&this.enter(e.name),this.pc=e.pc,e.inside&&(this.inside--,e.done?.(this)),this.again&&e.ret===this.again.ret){let i=this.again;this.again=null,this.inside-=i.n,i.done?.(this)}e.after?.(this)}push(t){this.stack.push(t?{a:this.a}:{flags:[this.n,this.z,this.c,this.v]})}pull(t){let e=this.stack.at(-1);if(e&&e.name!==void 0){let i=e.ret===void 0?0:e.half?e.ret>>8:e.ret&255;e.half?(this.stack.pop(),e.depth=this.stack.length,this.pulled=e,e.inside&&e.ret===void 0&&this.inside--):e.half=!0,t&&(this.a=this.flags(i));return}let n=this.stack.pop();t?this.a=this.flags(n.a):[this.n,this.z,this.c,this.v]=n.flags}sp(){return 255-this.stack.reduce((t,e)=>t+(e.name===void 0||e.half?1:2),0)&255}stackPage(){let t=this.sp();(this.stacks??=new Map).set(t,this.stack.map(n=>({...n})));let e=255;for(let n of this.stack){let i=n.ret??0;n.name===void 0?this.mem[256+e--]=n.a??(n.flags?n.flags[0]<<7|n.flags[3]<<6|48|n.flags[1]<<1|n.flags[2]:0):(this.mem[256+e--]=i>>8,n.half||(this.mem[256+e--]=i&255))}return t}asm(t){if(t==="TSX"&&(this.x=this.flags(this.stackPage())),t==="TXS"){let e=this.stacks?.get(this.x);this.stack=e?e.map(n=>({...n})):[],this.visited=null,this.inside=this.stack.filter(n=>n.inside).length}t==="CLV"&&(this.v=0),t==="SED"&&(this.d=1),t==="CLD"&&(this.d=0),t==="SEI"&&(this.i=1),t==="CLI"&&(this.i=0)}run(t=1e7){this.pacing||(this.idle=0),this.pacing=!1,this.delay??=0;for(let e=0;e<t;e++){if(this.ended)return"end";let n=this.program.steps[this.pc];if(!n)throw new Error(this.name+": ran off the end");if(this.routines.before?.(this,n)==="wait"||this.exec(n)==="wait")return"idle";if(this.polled)return this.polled=!1,"idle";if(this.delay>=16)return this.pacing=!0,"pace"}return"steps"}exec(t){let e=this.pc;this.pc++;try{this.called=!1,!t.run&&Es(t)&&this.time(this.program.steps,e,e);let n=t.run?t.run(this,this.program.steps):this.interpret(t);if(n==="wait"&&(t.run?this.called:!Es(t))&&(this.pc=e,this.visiting!==void 0)){this.startVisit(e);return}return n}catch(n){if(n===Ss){this.inside=0;return}if(this.routines.error?.(this,n)){this.ended=!0;return}throw n.message=t.where+" ("+t.text+"): "+n.message,n}}interpret(t){let e=t.words,[n,i]=e;if(i==="="&&e.length===3){let o=Z(n),c=this.load(Z(e[2]));if(o.reg==="carry"){this.c=c&1;return}this.set(o,c),o.reg&&this.flags(c);return}if(i==="+="||i==="-="){let o=Z(n),c=e.length===3?this.get(Z(e[2])):this.load(Z(e[2]));if(e.length===3){let h=this.get(o)+(i==="+="?c:-c)&255;this.set(o,h),this.flags(h);return}i==="+="?this.add(c):this.sub(c);return}if(i==="&="||i==="|="||i==="^="){let o=this.load(Z(e[2]));this.a=this.flags(i==="&="?this.a&o:i==="|="?this.a|o:this.a^o);return}if(i==="<<="||i===">>="||i==="rotate"){let o=Z(n);this.set(o,this.shift(this.get(o),i==="<<="||e[2]==="left",i==="rotate"));return}switch(n){case"if":return this.branch(e,t);case"goto":return e[1].startsWith("(")?this.jumpThrough(parseInt(e[1].slice(2,-1),16),t):e[1].startsWith("[")?this.jumpTable(parseInt(e[1].slice(2),16),this[e[2][0]]):this.jump(e[1],t);case"call":return e[1].startsWith("(")?this.callThrough(parseInt(e[1].slice(2,-1),16),t):this.call(e[1],t);case"return":return this.ret(t);case"compare":this.compare(this[e[1]],this.load(Z(e[2])));return;case"test":this.test(this.get(Z(e[1])));return;case"asm":if(e[1]==="RTI")return this.ret(t);this.asm(e[1]);return;case"push":this.push(e[1]==="a");return;case"pull":this.pull(e[1]==="a");return}return this.routine(n,e.slice(1),t)}routine(t,e,n){let i=this.routines[t];if(!i)throw new Error("no routine "+t);if(this.called=!0,n&&this.timed&&n.at!==null){let o=this.cost(this.program.steps,n.index);this.cycles+=o,this.delay+=o/$s}return i(this,e,n)}branch(t,e){let n=t.at(-1),i=t.slice(1,-2),o;if(i.length===3&&/^[axy]$/.test(i[0]))this.compare(this[i[0]],this.load(Z(i[2]))),o={"==":this.z,"!=":!this.z,">=":this.c,"<":!this.c}[i[1]];else{let c=i[0]==="not",h=c?i[1]:i[0],f={zero:this.z,carry:this.c,negative:this.n,overflow:this.v}[h];if(f===void 0)throw new Error("no flag "+h);o=c?!f:!!f}o&&(this.cycles+=Ot(e),this.pc=this.label(n))}}});var Rs={};z(Rs,{GIVES:()=>gt,POLLS:()=>Ii,TAKES:()=>pt,WAITS:()=>Mi,describe:()=>G,nothing:()=>ge,result:()=>et});function G(s,t,e,n,i,o){let c={step:s};t.length&&(c.n=t.map(Number));let h=pt[s];if(s==="objects")c.table="$"+(e.x|e.y<<8).toString(16).toUpperCase().padStart(4,"0");else if(s.startsWith("object")&&e.a<2)c.a=e.a;else if(h)for(let f of h)c[f]=e[f];if((s==="key-at"||s==="key")&&c.a!==void 0&&(c.a=String.fromCharCode(c.a&127)),Ts[s]&&i)for(let[f,l]of Object.entries(Ts[s]))c[f]=i(l);if(Ls[s]&&o)for(let[f,l]of Object.entries(Ls[s]))c[f]=o(l);return n!==void 0&&(c.words=n),c}function et(s,t){let e={result:s};for(let n of gt[s])e[n]=t[n];return e}var pt,Ls,Ts,gt,ge,Ii,Mi,yt=B(()=>{pt={box:"axy",object:"axy","object-keep":"axy","object-mode":"axy",objects:"xy",span:"axy",random:"a",beep:"a","key-at":"axy",key:"a",multiply:"ax",divide:"axy",ask:"a","ask-mode":"a","ask-escape":"a",rectangle:"axy","read-dot":"xy",problem:"a",dot:"axy","fill-rows":"axy",part:"a","rectangle-outline":"axy","key-panel":"a","keep-span":"xy","put-span":"xy","white-lines":"y","invert-span":"xy",label:"a","flip-box":"a","flash-box":"a",path:"ax",jump:"a",cell:"axy","cell-box":"axy",pair:"a",piece:"axy",colour:"a",tick:"",print:"axyc",arrow:"a",unpack:"y","load-picture":"a","action-cards":"a","return-key":"a","space-key":"a","wipe-rows":"a","wipe-columns":"a","text-card":"a","fill-left":"a","put-object":"axy","draw-room-objects":"yc",take:"y",drop:"y",effect:"a",outport:"a",cout:"a",char:"a",message:"xy",describe:"axy",chrout:"a",plot:"xyc",close:"a",chkin:"x",chkout:"x",setlfs:"axy",setnam:"axy",load:"axy",save:"axy",listen:"a",second:"a",ciout:"a",talk:"a",tksa:"a",setmsg:"a",tone:"xy","load-objects":"axy",hposn:"axy",hlin:"axy",hcolor:"x",pause:"a","bag-put":"a"},Ls={colour:{shape:3605},"card-frame":{x:16504,high:16505,y:16506,width:16507,height:16508}},Ts={line:{x0:0,x1:1,y0:2,y1:3,color:17},piece:{color:17},rectangle:{width:14,height:15},"rectangle-outline":{width:14,height:15}};gt={random:"a",ask:"ax","ask-mode":"ax","ask-escape":"axc","wait-or-escape":"c",problem:"c","read-key":"a","read-dot":"a",multiply:"ax",divide:"ax","blink-key":"a","which-box":"xy",tick:"a","choose-action":"a",take:"a",drop:"a","show-bag":"a","bag-choose":"a",getin:"a",acptr:"a",readst:"a",load:"cxy",chrin:"a"},ge=(s,t)=>s==="beep"&&t===0,Ii=new Set(["read-key","blink-key"]),Mi=new Set(["wait","wait-erase","wait-or-escape","ask","ask-mode","ask-escape","which-box","tick","choose-action","take","drop","show-bag","bag-choose"])});var Is={};z(Is,{helpers:()=>we});function we(s,t){let e=s.title.map.vars.zero;function*n(h,...f){let l={words:[h]},m=f.map(g=>typeof g=="string"&&h==="text"?{string:g}:typeof g=="number"?String(g):g);for(;;){if(t[h](s,m,l)!=="wait")return{a:s.a,x:s.x,y:s.y,c:s.c};yield"wait"}}let i=(h,f=0,l,m)=>{s.a=f&255,l!==void 0&&(s.x=l&255),m!==void 0&&(s.y=m&255),s.title.paint?.[h]?.(s.title.model,s),s.emit(G(h,[],s,void 0,g=>s.mem[g+e],g=>s.mem[g]))};function*o(h="wait"){let f={words:[h]};for(;;){let l=s.key();if(l===5&&s.title?.menu&&s.leave(...s.title.menu),s.title?.visit?.[l]){s.visit(l),s.waitingOn=f,yield"wait";continue}if(l!==void 0)return s.waitingOn=null,l;s.waitingOn=f,yield"wait"}}function*c(h){s.inside++;try{return yield*h}finally{s.inside--}}return{e:s,mem:s.mem,call:n,drawn:i,key:o,inside:c}}var ke=B(()=>{yt()});import{objects as Ni}from"@moonbase-machines/vector";var Ms,Mo,Ns,Jt,_t=B(()=>{({carry:Ms,decode:Mo,put:Ns,tables:Jt}=Ni)});var Ps={};z(Ps,{pictures:()=>Tt,shapes:()=>Di,windows:()=>Ui});import{pictures as Pi}from"@moonbase-machines/vector";var Tt,Di,Ui,Xt=B(()=>{({pictures:Tt,shapes:Di,windows:Ui}=Pi)});import{font as Bi}from"@moonbase-machines/vector";var Uo,Bo,Gt,Ds,Us,it,Rt=B(()=>{({GLYPHS:Uo,WIDTHS:Bo,dots:Gt,start:Ds,useFont:Us,width:it}=Bi)});import{draw as zi}from"@moonbase-machines/vector";var qo,Bs,Ko,Wo,zs,Ho,ye,Vo,Yo,Fs=B(()=>{({crossings:qo,draw:Bs,fill:Ko,inside:Wo,line:zs,outline:Ho,screen:ye,spans:Vo,under:Yo}=zi)});var Ks={};z(Ks,{LAYOUT:()=>wt,PANELS:()=>It,layout:()=>Mt,resolve:()=>bt,textLayout:()=>Nt,textPage:()=>kt,textPen:()=>Pt,word:()=>qs});function qs(s,[t,e,n,i]){let o=t|e<<8,c=i===255?n:s[n|i<<8];for(;c-- >0;)o+=s[o]+1;let h="";for(let f=1;f<=s[o];f++)h+=String.fromCharCode(s[o+f]&127);return h}function Mt(s,t){let e=t,n=[];e.tall=!1,e.margin=e.x;let i=9,o=!1,c=[],h=e.ink,f=!1,l=g=>{if(c.length){let k=Ds(c.map(w=>w.ch),e.spacing,e.x,e.centre),y=[];for(let w of c){let O=it(w.ch);y.push({ch:w.ch,x:k,ink:w.ink}),k+=w.ch.charCodeAt(0)<32?O:O+e.spacing}n.push({top:e.y,tall:e.tall,height:i,paper:e.paper,ink:e.ink,chars:y}),e.x=k}c=[],g&&(e.y+=(e.tall?2*i:i)+e.gap,e.x=e.margin)},m=g=>c.push({ch:o&&g>="0"&&g<="9"?String.fromCharCode(128+g.charCodeAt(0)-48):g,ink:f?h:void 0});for(let g=0;g<s.length;g++){let k=s[g];if(k===`
|
|
4
4
|
`){l(!0);continue}if(k==="{"){let y=s.indexOf("}",g),[w,O]=s.slice(g+1,y).split(":"),a=(O??"").split(",").map(u=>parseInt(u,16));switch(g=y,parseInt(w,16)){case 0:e.x=e.margin=a[0];break;case 1:a[0]<192?e.y=a[0]:i=a[0]-192;break;case 2:e.spacing=a[0];break;case 3:e.gap=a[0];break;case 4:e.ink=h=a[0],f=!0;break;case 5:e.paper=a[0];break;case 7:e.centre=!0;break;case 8:e.centre=!1;break;case 9:e.tall=!0;break;case 10:e.tall=!1;break;case 13:h=0,f=!0;break;case 14:h=1,f=!0;break;case 16:o=!0;break;case 17:o=!1;break;case 15:for(let u=0;u<(a[1]||256);u++)m(String.fromCharCode(a[0]&127));break}continue}m(k)}return l(!1),n}function Nt(s,t){let e=[];t.inverse=!1;let n=[],i=c=>{let h=t.centre?40-n.length>>1:t.x;n.forEach((f,l)=>e.push({row:t.y,col:h+l,ch:f.ch,inverse:f.inverse})),n.length&&(t.x=h+n.length),n=[],c&&(t.y++,t.x=t.margin)},o=c=>n.push({ch:t.inverse?c.toUpperCase():c,inverse:t.inverse});for(let c=0;c<s.length;c++){let h=s[c];if(h===`
|