Skip to content

Commit 71a094c

Browse files
committed
golf
1 parent 58f51f6 commit 71a094c

File tree

8 files changed

+31
-4
lines changed

8 files changed

+31
-4
lines changed

0 renamed to 0.ch8

File renamed without changes.

1 renamed to 1.ch8

File renamed without changes.

2 renamed to 2.ch8

File renamed without changes.

3 renamed to 3.ch8

File renamed without changes.

4 renamed to 4.ch8

File renamed without changes.

5.htm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<center><input onchange="with(new FileReader)readAsArrayBuffer(files[0]),onload=s=>{play(new Uint8Array(result))}"type=file><canvas id=Z width=64 height=32 style="width:320px;height:160px"></canvas><script>S=0;w=[];keys=[96,103,104,105,100,101,102,97,98,99,81,87,69,82,84,89];play=q=>{if(S)clearInterval(S);var p,t,f,a,m,B,g,l,u,r,D,x,n,e,v,c,h,b,d,k,E,y,z,A;p=(C=Z.getContext("2d")).createImageData(64,32);for(a=8192;a--;)p.data[a]=a%4-3?0:255;t=new (AudioContext=this.AudioContext||webkitAudioContext||0);m=[];for(a=80;a--;)m[a]=eval("0x"+"F999F26227F1F8FF1F1F99F11F8F1FF8F9FF1244F9F9FF9F1FF9F99E9E9EF888FE999EF8F8FF8F88"[a]+"0");V=new Uint8Array(new ArrayBuffer(16));B=[];g=512;r=u=l=0;for(a=q.length;a--;)m[a+512]=q[a];S=setInterval(()=>{u&&u--;r&&r--;t&&r&&!f&&(f=t.createOscillator(),f.start||(f.noteOn=f.start),f.stop||(f.noteOff=f.stop),f.connect(t.destination),f.type=3,f.start(0));t&&!r&&f&&(f.stop(0),f=0);for(D=4;D--;){n=m[g]<<8|m[g+1];e=n>>12;v=n&4095;c=n&255;h=n&15;b=n>>8&15;d=V[b];k=V[n>>4&15];if(224==n)for(a=8192;a--;)p.data[a]=a%4-3?0:255;238==n&&(g=B.pop());1==e&&(g=v-2);2==e&&(B.push(g),g=v-2);if(3==e&&d==c||4==e&&d!=c||5==e&&d==k||9==e&&d!=k||14==e&&(158==c&&w[d]||161==c&&!w[d]))g+=2;6==e&&(V[b]=c);7==e&&(V[b]=d+c);8==e&&(h||(V[b]=k),1==h&&(V[b]|=k),2==h&&(V[b]&=k),3==h&&(V[b]^=k),4==h&&(V[15]=+(255<(V[b]+=k))),5==h&&(V[15]=+(0<=(V[b]-=k))),6==h&&(V[15]=d&1,V[b]/=2),7==h&&(V[15]=+(0<=(V[b]=k-d))),14==h&&(V[15]=d>>7,V[b]*=2));10==e&&(l=v);11==e&&(g=v+V[0]);12==e&&(V[b]=Math.floor(Math.random()*c));if(13==e)for(V[15]=0,a=h;a--;)for(y=8;y--;)E=m[l+a]>>7-y&1,z=d+y,A=k+a,E&&(63<z&&(z-=63),31<A&&(A-=31),x=4*(64*A+z)+3,p.data[x]?p.data[x]=0:(p.data[x]=255,V[15]=1));if(15==e){7==c&&(V[b]=u);10==c&&(~(V[b]=w.a(!0))||(g-=2));21==c&&(u=d);24==c&&(r=d);30==c&&(l+=d,V[15]=+(4095<l),l&=4095);41==c&&(l=5*d);if(51==c)for(a=3;a--;)m[l+a]=(""+d)[a];if(85==c)for(a=b;a--;)m[l+a]=V[a];if(101==c)for(a=b;a--;)V[a]=m[l+a]}g+=2}C.putImageData(p,0,0)},16)};onkeydown=q=>{w[keys.indexOf(q.keyCode)]=!0};onkeyup=q=>{w[keys.indexOf(q.keyCode)]=!1};load=(r,x)=>{x=new XMLHttpRequest;x.open('GET',r);x.responseType='arraybuffer';x.send();x.onload=()=>{play(new Uint8Array(x.response))}};load(0)</script><br>Demo<br><button onclick=load(1)>Rocket2<button onclick=load(2)>Breakout<button onclick=load(3)>X-mirror<button onclick=load(4)>Cave
1+
<center><input onchange="with(new FileReader)readAsArrayBuffer(files[0]),onload=s=>{play(new Uint8Array(result))}"type=file><canvas id=Z width=64 height=32 style="width:320px;height:160px"></canvas><script>S=0;w=[];keys=[96,103,104,105,100,101,102,97,98,99,81,87,69,82,84,89];play=q=>{if(S)clearInterval(S);var p,t,f,a,m,B,g,l,u,r,D,x,n,e,v,c,h,b,d,k,E,y,z,A;p=(C=Z.getContext("2d")).createImageData(64,32);for(a=8192;a--;)p.data[a]=a%4-3?0:255;t=new (AudioContext=this.AudioContext||webkitAudioContext||0);m=[];for(a=80;a--;)m[a]=eval("0x"+"F999F26227F1F8FF1F1F99F11F8F1FF8F9FF1244F9F9FF9F1FF9F99E9E9EF888FE999EF8F8FF8F88"[a]+"0");V=new Uint8Array(new ArrayBuffer(16));B=[];g=512;r=u=l=0;for(a=q.length;a--;)m[a+512]=q[a];S=setInterval(()=>{u&&u--;r&&r--;t&&r&&!f&&(f=t.createOscillator(),f.start||(f.noteOn=f.start),f.stop||(f.noteOff=f.stop),f.connect(t.destination),f.type=3,f.start(0));t&&!r&&f&&(f.stop(0),f=0);for(D=4;D--;){n=m[g]<<8|m[g+1];e=n>>12;v=n&4095;c=n&255;h=n&15;b=n>>8&15;d=V[b];k=V[n>>4&15];if(224==n)for(a=8192;a--;)p.data[a]=a%4-3?0:255;238==n&&(g=B.pop());1==e&&(g=v-2);2==e&&(B.push(g),g=v-2);if(3==e&&d==c||4==e&&d!=c||5==e&&d==k||9==e&&d!=k||14==e&&(158==c&&w[d]||161==c&&!w[d]))g+=2;6==e&&(V[b]=c);7==e&&(V[b]=d+c);8==e&&(h||(V[b]=k),1==h&&(V[b]|=k),2==h&&(V[b]&=k),3==h&&(V[b]^=k),4==h&&(V[15]=+(255<(V[b]+=k))),5==h&&(V[15]=+(0<=(V[b]-=k))),6==h&&(V[15]=d&1,V[b]/=2),7==h&&(V[15]=+(0<=(V[b]=k-d))),14==h&&(V[15]=d>>7,V[b]*=2));10==e&&(l=v);11==e&&(g=v+V[0]);12==e&&(V[b]=Math.floor(Math.random()*c));if(13==e)for(V[15]=0,a=h;a--;)for(y=8;y--;)E=m[l+a]>>7-y&1,z=d+y,A=k+a,E&&(63<z&&(z-=63),31<A&&(A-=31),x=4*(64*A+z)+3,p.data[x]?p.data[x]=0:(p.data[x]=255,V[15]=1));if(15==e){7==c&&(V[b]=u);10==c&&(~(V[b]=w.a(!0))||(g-=2));21==c&&(u=d);24==c&&(r=d);30==c&&(l+=d,V[15]=+(4095<l),l&=4095);41==c&&(l=5*d);if(51==c)for(a=3;a--;)m[l+a]=(""+d)[a];if(85==c)for(a=b;a--;)m[l+a]=V[a];if(101==c)for(a=b;a--;)V[a]=m[l+a]}g+=2}C.putImageData(p,0,0)},16)};onkeydown=q=>{w[keys.indexOf(q.keyCode)]=!0};onkeyup=q=>{w[keys.indexOf(q.keyCode)]=!1};load=(r,x)=>{x=new XMLHttpRequest;x.open('GET',r+".ch8");x.responseType='arraybuffer';x.send();x.onload=()=>{play(new Uint8Array(x.response))}};load(0)</script><br>Demo<br><button onclick=load(1)>Rocket2<button onclick=load(2)>Breakout<button onclick=load(3)>X-mirror<button onclick=load(4)>Cave

7.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
⡼ ⠰ ⡝ ⠻ ⡯
1515
⡮ ⡫ ⡥ ⡹
1616
⡵ ⡰ ⠽⡡⠽⠾⡤⠫⠽⡡⠮⡷⡨
17-
⡩ ⡣ ⡨ ⠭
17+
⡩ ⡣ ⡨
1818
⠳⠹⠻⡳⡥ ⡴ ⡉⡮⡴⡥⡲⡶⡡⡬⠨⠧⠳
19-
⠼ ⡥ ⠦
19+
⠼ ⡥
2020
⠦⠡⠨⡥⠥ ⠲⠷⠩⠿⡩⠦⠦⡢⡛⡧⠫
2121
⠫⡝⠽⠽⡤⠿⡦⠫⠫⠺
2222

index.html

+28-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
<!doctype html><meta charset=utf-8><style>body{border-radius:10px;border:2px solid #555;border-right:4px solid #555;border-bottom:4px solid #555;margin:20px auto;width:800px;height:520px;padding:10px}nav#n1{width:130px;float:left;margin:9px 0 0}nav#n1 button{width:130px;margin:6px 0 0;border:2px solid #555}button:active,button:focus{background:#555;color:#fff}#i1{width:650px;height:500px;margin:10px 0 0 140px;border:2px solid #555;background:#777;position:relative}iframe{background:#fff;display:block}pre{word-wrap:break-word;white-space:pre-wrap;background:#fff;margin:20px;padding:10px;max-height:360px;overflow:auto}</style><nav id=n1></nav><div id=i1><script>for(i in j="MMXLVIII0flASCII bird0Four0Impossible Road02P games0Chip80Floppy dragon0Flappy Braille0PopTiles0Simon0Sweeper0Ping0Run0Snake0Snake Lite0Color0Game of Life".split(0))n1.innerHTML+="<button onclick=p("+i+",this)>"+j[i];p=(n,o)=>{location.hash="";var req=new XMLHttpRequest;req.open("GET",n.toString(36)+(n==7?".js":".htm"),!1);req.send(null);if(n!=2)i1.innerHTML="<center><br><button onclick=q('"+n+"')><h2>PLAY "+o.innerHTML+"</button></center><pre>"+req.responseText.replace(/.{69}/g,"$&\n").replace(/this/g,"top").replace(/</g,"&lt;");else i1.innerHTML="<center><br><button onclick=q('"+n+"')><h2>PLAY "+o.innerHTML+"</button></center><pre>"+req.responseText.replace(/this/g,"top").replace(/</g,"&lt;")};q=(n)=>{i1.innerHTML="<iframe id=P src="+(n.toString(36))+".htm frameborder=no>";if(n==0){P.style.width="250px";P.style.height="280px";P.style.margin="100px auto"}else if(n==1){P.style.width="200px";P.style.height="200px";P.style.margin="150px auto"}else if(n==2){P.style.width="580px";P.style.height="150px";P.style.margin="180px auto"}else if(n==3){P.style.width="98%";P.style.height="98%";P.style.margin="5px auto"}else if(n==4){P.style.width="98%";P.style.height="98%";P.style.margin="5px auto"}else if(n==5){P.style.width="350px";P.style.height="250px";P.style.margin="110px auto"}else if(n==6){P.style.width="98%";P.style.height="98%";P.style.margin="5px auto"}else if(n==7){P.style.width="0";P.style.height="0";P.style.margin="5px auto"}else if(n==8){P.style.width="130px";P.style.height="180px";P.style.margin="150px auto"}else if(n==9){P.style.width="98%";P.style.height="98%";P.style.margin="5px auto"}else if(n==10){P.style.width="300px";P.style.height="280px";P.style.margin="100px auto"}else if(n==11){P.style.width="250px";P.style.height="210px";P.style.margin="130px auto"}else if(n==12){P.style.width="500px";P.style.height="150px";P.style.margin="180px auto"}else if(n==13){P.style.width="335px";P.style.height="185px";P.style.margin="180px auto"}else if(n==14){P.style.width="280px";P.style.height="280px";P.style.margin="110px auto"}else if(n==15){P.style.width="400px";P.style.height="98%";P.style.margin="5px auto"}else{P.style.width="120px";P.style.height="120px";P.style.margin="180px auto"}P.focus();for(i of document.querySelectorAll("button"))i.className=""}</script>
1+
<!doctype html>
2+
<style>
3+
body{border-radius:10px;border:2px solid #555;border-right:4px solid #555;border-bottom:4px solid #555;margin:20px auto;width:810px;height:520px;padding:10px}
4+
#n1{width:130px;float:left;margin:9px 0 0}
5+
#n1 button{width:130px;margin:6px 0 0;border:2px solid #555}
6+
button:active,button:focus{background:#555;color:#fff}
7+
#i1{width:650px;height:500px;margin:10px 0 0 140px;border:2px solid #555;background:#777;position:relative}
8+
iframe{background:#fff;display:block}
9+
pre{word-wrap:break-word;white-space:pre-wrap;background:#fff;margin:20px;padding:10px;max-height:360px;overflow:auto}
10+
</style>
11+
<nav id=n1></nav>
12+
<div id=i1>
13+
<script>
14+
for(i in j="MMXLVIII0flASCII bird0Four0Impossible Road02P games0Chip80Floppy dragon0Flappy Braille0PopTiles0Simon0Sweeper0Ping0Run0Snake0Snake Lite0Color0Game of Life".split(0))n1.innerHTML+="<button onclick=\"p("+i+",'"+j[i]+"')\">"+j[i];
15+
16+
p=(n,o)=>{
17+
location.hash="";
18+
if(n==2)q(n);
19+
else{
20+
x=new XMLHttpRequest;x.open("GET",n.toString(36)+(n==7?".js":".htm"),!1);x.send(null);
21+
z=x.responseText.replace(/.{71}/g,"$&\n").replace(/this/g,"top").replace(/</g,"&lt;");
22+
i1.innerHTML="<center><br><button onclick=q("+n+")><h2>PLAY "+o;
23+
i1.innerHTML+="<pre>"+z;
24+
}}
25+
26+
q=(n)=>{
27+
h=[26,18,16,50,48,26,50,0,16,50,28,22,16,20,28,48,12];i1.innerHTML="<iframe id=P src="+(n.toString(36))+".htm frameborder=no style='width:"+[25,20,58,65,50,35,65,0,13,65,30,25,50,34,28,40,12][n]+"0px;height:"+h[n]+"0px;margin:"+((50-h[n])/2)+"0px auto'>";P.focus()}
28+
</script>

0 commit comments

Comments
 (0)