-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1028: simplified memory init, more fluidity
- Loading branch information
Showing
4 changed files
with
9 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
HOW TO PLAY | ||
|
||
- Golf c8.min.html | ||
- Copy the JS in before_png.js | ||
- Remove q=C.createImageData(64,32); | ||
- Put "V.width=64;" at the beginning | ||
- Replace "eval"'s with "e" | ||
- Golf before_png.js | ||
- Execute jsexe -cn before_png.js index.html | ||
- Replace the code at the end of index.html with this: | ||
- Replace the code at the end of index.html (<canvas...) with this: | ||
|
||
<canvas id=V><img src=# onload=C=V.getContext('2d');for($=_='';C.drawImage(this,$--,0),X=(q=C.getImageData(0,0,64,32)).data[0];_+=String.fromCharCode(X));(e=eval)(_)> | ||
<!-- the above xxxx bytes load the chip8 ROM asked in the URL's hash and emulates it. --> | ||
|
||
<!-- the following code is just decoration --> | ||
</canvas><a href=//github.com/xem/chip8><img style="position:absolute;top:0;right:0;border:0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a><h1>1kb chip8 emulator</h1><div> Source code: <br> <a href=c8.html>commented, with sound</a> <br> <a href=c8.min.html>minified & golfed by xem, p01, rlauck, aemkei</a> <br> <br> Choose a ROM: <br> <a href="index.html?1#ROM/TEST/C8PIC.ch8">C8PIC</a> <br> <a href="index.html?2#ROM/TEST/IBM.ch8">IBM</a> <br> <a href="index.html?3#ROM/TEST/Rocket2.ch8">Rocket2</a> (press Y to launch) <br> <a href="index.html?4#ROM/TEST/X-MIRROR.ch8">X-MIRROR</a> (press 2,4,6,8 to draw) <br> <a href="index.html?5#ROM/TEST/TAPEWORM.ch8">TAPEWORM</a> (Y to start, 2,4,6,8 to move) <br> <a href="index.html?6#ROM/TEST/TIMEBOMB.ch8">TIMEBOMB</a> (set up with 2 and 8, start with 5) <br> <a href="index.html?8#ROM/AIRPLANE.ch8">AIRPLANE</a> (send bombs with 2) <br> <a href="index.html?10#ROM/BLITZ.ch8">BLITZ</a> (send bombs with 2) <br> <a href="index.html?11#ROM/BREAKOUT.ch8">BREAKOUT</a> (move with 4 and 6) <br> <a href="index.html?12#ROM/BRIX.ch8">BRIX</a> (move with 4 and 6) <br> <a href="index.html?13#ROM/CAVE.ch8">CAVE</a> (start with Y, move with 2,4,6,8) <br> <a href="index.html?14#ROM/CONNECT4.ch8">CONNECT4</a> <br> <a href="index.html?15#ROM/FIGURES.ch8">FIGURES</a> <br> <a href="index.html?16#ROM/FILTER.ch8">FILTER</a> <br> <a href="index.html?17#ROM/GUESS.ch8">GUESS</a> <br> <a href="index.html?18#ROM/HIDDEN.ch8">HIDDEN</a> <br> <a href="index.html?19#ROM/INVADERS.ch8">INVADERS</a> <br> <a href="index.html?20#ROM/KALEID.ch8">KALEID</a> <br> <a href="index.html?21#ROM/LANDING.ch8">LANDING</a> <br> <a href="index.html?22#ROM/MAZE.ch8">MAZE</a> <br> <a href="index.html?23#ROM/MERLIN.ch8">MERLIN</a> <br> <a href="index.html?24#ROM/MISSILE.ch8">MISSILE</a> <br> <a href="index.html?25#ROM/PADDLES.ch8">PADDLES</a> <br> <a href="index.html?26#ROM/PONG(1P).ch8">PONG(1P)</a> <br> <a href="index.html?27#ROM/PONG.ch8">PONG</a> <br> <a href="index.html?28#ROM/PONG2.ch8">PONG2</a> <br> <a href="index.html?29#ROM/PUZZLE.ch8">PUZZLE</a> <br> <a href="index.html?30#ROM/ROCKET.ch8">ROCKET</a> <br> <a href="index.html?31#ROM/SOCCER.ch8">SOCCER</a> <br> <a href="index.html?32#ROM/SPACEF.ch8">SPACEF</a> <br> <a href="index.html?33#ROM/SQUASH.ch8">SQUASH</a> <br> <a href="index.html?34#ROM/SYZYGY.ch8">SYZYGY</a> <br> <a href="index.html?35#ROM/TANK.ch8">TANK</a> <br> <a href="index.html?36#ROM/TETRIS.ch8">TETRIS</a> <br> <a href="index.html?37#ROM/TICTAC.ch8">TICTAC</a> <br> <a href="index.html?38#ROM/TRON.ch8">TRON</a> <br> <a href="index.html?39#ROM/UFO.ch8">UFO</a> <br> <a href="index.html?40#ROM/VBRIX.ch8">VBRIX</a> <br> <a href="index.html?41#ROM/VERS.ch8">VERS</a> <br> <a href="index.html?42#ROM/WALL.ch8">WALL</a> <br> <a href="index.html?43#ROM/WIPEOFF.ch8">WIPEOFF</a> <br> <br></div><style>*{text-indent:-9999;color:#fff;font-family:arial}h1,div{color: #000;text-indent:0}a{color:blue}h1,canvas{position:absolute;left:10px}canvas{overflow:hidden;top:80px;-webkit-transform:scale(4);transform:scale(4);-webkit-transform-origin:0 0;transform-origin:0 0}h1{top:0;text-indent:0}div{position:absolute;top:250px} | ||
</canvas><a href=//github.com/xem/chip8><img style="position:absolute;top:0;right:0;border:0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a><h1>1kb chip8 emulator</h1><div> Source code: <br> <a href=c8.html>commented, with sound</a> <br> <a href=c8.min.html>minified & golfed by xem, p01, rlauck, aemkei, subzey</a> <br> <br> Choose a ROM: <br> <a href="index.html?1#ROM/TEST/C8PIC.ch8">C8PIC</a> <br> <a href="index.html?2#ROM/TEST/IBM.ch8">IBM</a> <br> <a href="index.html?3#ROM/TEST/Rocket2.ch8">Rocket2</a> (press Y to launch) <br> <a href="index.html?4#ROM/TEST/X-MIRROR.ch8">X-MIRROR</a> (press 2,4,6,8 to draw) <br> <a href="index.html?5#ROM/TEST/TAPEWORM.ch8">TAPEWORM</a> (Y to start, 2,4,6,8 to move) <br> <a href="index.html?6#ROM/TEST/TIMEBOMB.ch8">TIMEBOMB</a> (set up with 2 and 8, start with 5) <br> <a href="index.html?8#ROM/AIRPLANE.ch8">AIRPLANE</a> (send bombs with 2) <br> <a href="index.html?10#ROM/BLITZ.ch8">BLITZ</a> (send bombs with 2) <br> <a href="index.html?11#ROM/BREAKOUT.ch8">BREAKOUT</a> (move with 4 and 6) <br> <a href="index.html?12#ROM/BRIX.ch8">BRIX</a> (move with 4 and 6) <br> <a href="index.html?13#ROM/CAVE.ch8">CAVE</a> (start with Y, move with 2,4,6,8) <br> <a href="index.html?14#ROM/CONNECT4.ch8">CONNECT4</a> <br> <a href="index.html?15#ROM/FIGURES.ch8">FIGURES</a> <br> <a href="index.html?16#ROM/FILTER.ch8">FILTER</a> <br> <a href="index.html?17#ROM/GUESS.ch8">GUESS</a> <br> <a href="index.html?18#ROM/HIDDEN.ch8">HIDDEN</a> <br> <a href="index.html?19#ROM/INVADERS.ch8">INVADERS</a> <br> <a href="index.html?20#ROM/KALEID.ch8">KALEID</a> <br> <a href="index.html?21#ROM/LANDING.ch8">LANDING</a> <br> <a href="index.html?22#ROM/MAZE.ch8">MAZE</a> <br> <a href="index.html?23#ROM/MERLIN.ch8">MERLIN</a> <br> <a href="index.html?24#ROM/MISSILE.ch8">MISSILE</a> <br> <a href="index.html?25#ROM/PADDLES.ch8">PADDLES</a> <br> <a href="index.html?26#ROM/PONG(1P).ch8">PONG(1P)</a> <br> <a href="index.html?27#ROM/PONG.ch8">PONG</a> <br> <a href="index.html?28#ROM/PONG2.ch8">PONG2</a> <br> <a href="index.html?29#ROM/PUZZLE.ch8">PUZZLE</a> <br> <a href="index.html?30#ROM/ROCKET.ch8">ROCKET</a> <br> <a href="index.html?31#ROM/SOCCER.ch8">SOCCER</a> <br> <a href="index.html?32#ROM/SPACEF.ch8">SPACEF</a> <br> <a href="index.html?33#ROM/SQUASH.ch8">SQUASH</a> <br> <a href="index.html?34#ROM/SYZYGY.ch8">SYZYGY</a> <br> <a href="index.html?35#ROM/TANK.ch8">TANK</a> <br> <a href="index.html?36#ROM/TETRIS.ch8">TETRIS</a> <br> <a href="index.html?37#ROM/TICTAC.ch8">TICTAC</a> <br> <a href="index.html?38#ROM/TRON.ch8">TRON</a> <br> <a href="index.html?39#ROM/UFO.ch8">UFO</a> <br> <a href="index.html?40#ROM/VBRIX.ch8">VBRIX</a> <br> <a href="index.html?41#ROM/VERS.ch8">VERS</a> <br> <a href="index.html?42#ROM/WALL.ch8">WALL</a> <br> <a href="index.html?43#ROM/WIPEOFF.ch8">WIPEOFF</a> <br> <br></div><style>*{text-indent:-9999;color:#fff;font-family:arial}h1,div{color: #000;text-indent:0}a{color:blue}h1,canvas{position:absolute;left:10px}canvas{overflow:hidden;top:80px;-webkit-transform:scale(4);transform:scale(4);-webkit-transform-origin:0 0;transform-origin:0 0}h1{top:0;text-indent:0}div{position:absolute;top:250px} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
<canvas id=C width=64></canvas><a href=//github.com/xem/chip8><img style="position:absolute;top:0;right:0;border:0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a><h1>1kb chip8 emulator</h1><h2>Minified & golfed source code</h2><div><a href=.>Homepage</a><br><br>Choose a ROM:<br><a href="c8.min.html?1#ROM/TEST/C8PIC.ch8">C8PIC</a><br><a href="c8.min.html?2#ROM/TEST/IBM.ch8">IBM</a><br><a href="c8.min.html?3#ROM/TEST/Rocket2.ch8">Rocket2</a> (press Y to launch)<br><a href="c8.min.html?4#ROM/TEST/X-MIRROR.ch8">X-MIRROR</a> (press 2,4,6,8 to draw)<br><a href="c8.min.html?5#ROM/TEST/TAPEWORM.ch8">TAPEWORM</a> (Y to start, 2,4,6,8 to move)<br><a href="c8.min.html?6#ROM/TEST/TIMEBOMB.ch8">TIMEBOMB</a> (set up with 2 and 8, start with 5)<br><a href="c8.min.html?8#ROM/AIRPLANE.ch8">AIRPLANE</a> (send bombs with 2)<br><a href="c8.min.html?10#ROM/BLITZ.ch8">BLITZ</a> (send bombs with 2)<br><a href="c8.min.html?11#ROM/BREAKOUT.ch8">BREAKOUT</a> (move with 4 and 6)<br><a href="c8.min.html?12#ROM/BRIX.ch8">BRIX</a> (move with 4 and 6)<br><a href="c8.min.html?13#ROM/CAVE.ch8">CAVE</a> (start with Y, move with 2,4,6,8)<br><a href="c8.min.html?14#ROM/CONNECT4.ch8">CONNECT4</a><br><a href="c8.min.html?15#ROM/FIGURES.ch8">FIGURES</a><br><a href="c8.min.html?16#ROM/FILTER.ch8">FILTER</a><br><a href="c8.min.html?17#ROM/GUESS.ch8">GUESS</a><br><a href="c8.min.html?18#ROM/HIDDEN.ch8">HIDDEN</a><br><a href="c8.min.html?19#ROM/INVADERS.ch8">INVADERS</a><br><a href="c8.min.html?20#ROM/KALEID.ch8">KALEID</a><br><a href="c8.min.html?21#ROM/LANDING.ch8">LANDING</a><br><a href="c8.min.html?22#ROM/MAZE.ch8">MAZE</a><br><a href="c8.min.html?23#ROM/MERLIN.ch8">MERLIN</a><br><a href="c8.min.html?24#ROM/MISSILE.ch8">MISSILE</a><br><a href="c8.min.html?25#ROM/PADDLES.ch8">PADDLES</a><br><a href="c8.min.html?26#ROM/PONG (1P).ch8">PONG (1P)</a><br><a href="c8.min.html?27#ROM/PONG.ch8">PONG</a><br><a href="c8.min.html?28#ROM/PONG2.ch8">PONG2</a><br><a href="c8.min.html?29#ROM/PUZZLE.ch8">PUZZLE</a><br><a href="c8.min.html?30#ROM/ROCKET.ch8">ROCKET</a><br><a href="c8.min.html?31#ROM/SOCCER.ch8">SOCCER</a><br><a href="c8.min.html?32#ROM/SPACEF.ch8">SPACEF</a><br><a href="c8.min.html?33#ROM/SQUASH.ch8">SQUASH</a><br><a href="c8.min.html?34#ROM/SYZYGY.ch8">SYZYGY</a><br><a href="c8.min.html?35#ROM/TANK.ch8">TANK</a><br><a href="c8.min.html?36#ROM/TETRIS.ch8">TETRIS</a><br><a href="c8.min.html?37#ROM/TICTAC.ch8">TICTAC</a><br><a href="c8.min.html?38#ROM/TRON.ch8">TRON</a><br><a href="c8.min.html?39#ROM/UFO.ch8">UFO</a><br><a href="c8.min.html?40#ROM/VBRIX.ch8">VBRIX</a><br><a href="c8.min.html?41#ROM/VERS.ch8">VERS</a><br><a href="c8.min.html?42#ROM/WALL.ch8">WALL</a><br><a href="c8.min.html?43#ROM/WIPEOFF.ch8">WIPEOFF</a><br><br></div><style>*{text-indent:-9999;color:#fff;font-family:arial}h1,h2,div{color:#000;text-indent:0}a{color:blue}h1,h2,canvas{position:absolute;left:10px}canvas{overflow:hidden;top:100px;-webkit-transform:scale(4);transform:scale(4);-webkit-transform-origin:0 0;transform-origin:0 0}h1{top:0;text-indent:0}h2{top:40px;text-indent:0}div{position:absolute;top:250px}</style><script> | ||
q=(C=C.getContext("2d")).createImageData(64,32);n=[];for(a=80;a--;)n[a]=eval("0x"+"F999F26227F1F8FF1F1F99F11F8F1FF8F9FF1244F9F9FF9F1FF9F99E9E9EF888FE999EF8F8FF8F88"[a]+0);for(a=3;a<8192;a+=4)q.data[a]=255;V=new(U=Uint8Array)(16);D=[];h=512;g=r=w=k=0;s=[];with(new XMLHttpRequest)open("GET",location.hash.slice(1)),send(responseType="arraybuffer",onload=function(c){u=new U(response);for(a=3584;a--;)n[a+512]=u[a];setInterval(function(c){w&&w--;for(F=4;F--;){p=n[h]<<8|n[h+1];f=p>>12;x=p&4095;d=p&255;l=p&15;b=p>>8&15;z=V[b];m=V[p>>4&15];eval(["if(l)h=D.pop();else for(a=3;8192>a;a+=4)q.data[a]=255","h=x-2","D.push(h),h=x-2","if(z==d)h+=2","if(z!=d)h+=2","if(z==m)h+=2","V[b]=d","V[b]=z+d",["V[b]=m","V[b]|=m","V[b]&=m","V[b]^=m","V[15]=+(255<(V[b]+=m))","V[15]=+(0<=(V[b]-=m))","V[15]=z&1;V[b]/=2","V[15]=+(0<=(V[b]=m-z))",,,,,,,"V[15]=z>>7;V[b]*=2"][l],"if(z!=m)h+=2","k=x","h=x+V[0]","V[b]=~~(Math.random()*d)","for(V[15]=0,a=l;a--;)for(B=8;B--;)y=z+B,A=m+a,(n[k+a]>>7-B&1)&&(63<y&&(y-=63),31<A&&(A-=31),u=4*(64*A+y)+3,q.data[u]?q.data[u]=0:(q.data[u]=255,V[15]=1))","if((158==d&&s[z])||(161==d&&!s[z]))h+=2",["w=z","k=5*z",,,"for(a=b;a--;)V[a]=n[k+a]","V[b]=w",,"for(a=b;a--;)n[k+a]=V[a]","~(V[b]=s.indexOf('w'))||(h-=2)","k+=z;V[15]=+(4095<k);k&=4095",,"for(a=3;a--;)n[k+a]=(''+z)[a]"][d%19-2]][f]);h+=2}C.putImageData(q,0,0)},16)});onkeydown=onkeyup=function(c){s[[0,7,8,9,4,5,6,1,2,3,33,39,21,34,36,41].indexOf(c.keyCode%48)]=c.type[5]} | ||
<canvas id=V width=64></canvas><a href=//github.com/xem/chip8><img style="position:absolute;top:0;right:0;border:0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a><h1>1kb chip8 emulator</h1><h2>Minified & golfed source code</h2><div><a href=.>Homepage</a><br><br>Choose a ROM:<br><a href="c8.min.html?1#ROM/TEST/C8PIC.ch8">C8PIC</a><br><a href="c8.min.html?2#ROM/TEST/IBM.ch8">IBM</a><br><a href="c8.min.html?3#ROM/TEST/Rocket2.ch8">Rocket2</a> (press Y to launch)<br><a href="c8.min.html?4#ROM/TEST/X-MIRROR.ch8">X-MIRROR</a> (press 2,4,6,8 to draw)<br><a href="c8.min.html?5#ROM/TEST/TAPEWORM.ch8">TAPEWORM</a> (Y to start, 2,4,6,8 to move)<br><a href="c8.min.html?6#ROM/TEST/TIMEBOMB.ch8">TIMEBOMB</a> (set up with 2 and 8, start with 5)<br><a href="c8.min.html?8#ROM/AIRPLANE.ch8">AIRPLANE</a> (send bombs with 2)<br><a href="c8.min.html?10#ROM/BLITZ.ch8">BLITZ</a> (send bombs with 2)<br><a href="c8.min.html?11#ROM/BREAKOUT.ch8">BREAKOUT</a> (move with 4 and 6)<br><a href="c8.min.html?12#ROM/BRIX.ch8">BRIX</a> (move with 4 and 6)<br><a href="c8.min.html?13#ROM/CAVE.ch8">CAVE</a> (start with Y, move with 2,4,6,8)<br><a href="c8.min.html?14#ROM/CONNECT4.ch8">CONNECT4</a><br><a href="c8.min.html?15#ROM/FIGURES.ch8">FIGURES</a><br><a href="c8.min.html?16#ROM/FILTER.ch8">FILTER</a><br><a href="c8.min.html?17#ROM/GUESS.ch8">GUESS</a><br><a href="c8.min.html?18#ROM/HIDDEN.ch8">HIDDEN</a><br><a href="c8.min.html?19#ROM/INVADERS.ch8">INVADERS</a><br><a href="c8.min.html?20#ROM/KALEID.ch8">KALEID</a><br><a href="c8.min.html?21#ROM/LANDING.ch8">LANDING</a><br><a href="c8.min.html?22#ROM/MAZE.ch8">MAZE</a><br><a href="c8.min.html?23#ROM/MERLIN.ch8">MERLIN</a><br><a href="c8.min.html?24#ROM/MISSILE.ch8">MISSILE</a><br><a href="c8.min.html?25#ROM/PADDLES.ch8">PADDLES</a><br><a href="c8.min.html?26#ROM/PONG (1P).ch8">PONG (1P)</a><br><a href="c8.min.html?27#ROM/PONG.ch8">PONG</a><br><a href="c8.min.html?28#ROM/PONG2.ch8">PONG2</a><br><a href="c8.min.html?29#ROM/PUZZLE.ch8">PUZZLE</a><br><a href="c8.min.html?30#ROM/ROCKET.ch8">ROCKET</a><br><a href="c8.min.html?31#ROM/SOCCER.ch8">SOCCER</a><br><a href="c8.min.html?32#ROM/SPACEF.ch8">SPACEF</a><br><a href="c8.min.html?33#ROM/SQUASH.ch8">SQUASH</a><br><a href="c8.min.html?34#ROM/SYZYGY.ch8">SYZYGY</a><br><a href="c8.min.html?35#ROM/TANK.ch8">TANK</a><br><a href="c8.min.html?36#ROM/TETRIS.ch8">TETRIS</a><br><a href="c8.min.html?37#ROM/TICTAC.ch8">TICTAC</a><br><a href="c8.min.html?38#ROM/TRON.ch8">TRON</a><br><a href="c8.min.html?39#ROM/UFO.ch8">UFO</a><br><a href="c8.min.html?40#ROM/VBRIX.ch8">VBRIX</a><br><a href="c8.min.html?41#ROM/VERS.ch8">VERS</a><br><a href="c8.min.html?42#ROM/WALL.ch8">WALL</a><br><a href="c8.min.html?43#ROM/WIPEOFF.ch8">WIPEOFF</a><br><br></div><style>*{text-indent:-9999;color:#fff;font-family:arial}h1,h2,div{color:#000;text-indent:0}a{color:blue}h1,h2,canvas{position:absolute;left:10px}canvas{overflow:hidden;top:100px;-webkit-transform:scale(4);transform:scale(4);-webkit-transform-origin:0 0;transform-origin:0 0}h1{top:0;text-indent:0}h2{top:40px;text-indent:0}div{position:absolute;top:250px}</style> | ||
<script> | ||
q=(C=V.getContext("2d")).createImageData(64,32); | ||
e=eval; | ||
</script> | ||
<script src=before_png.js></script> |
Binary file not shown.
d909d95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi guys,
I adjusted the refresh rate to make the the gameplay a lot fluider. See:
http://localhost/chip8/index.html?3#ROM/TEST/Rocket2.ch8
I included @subzey's trick to init the memory with less characters (b4db4ce#commitcomment-5031874)
And I simplified the golf & build system, there's one single file to edit (before_png.js)
More details on "HOW TO PLAY.txt"
The counter is now at 1028b PNG'd. (1398 before PNG).
Cheers,
cc @p01 @aemkei @rlauck