Jump to content
IGNORED

Original Centipede arcade game translated to JavaScript


Recommended Posts

Hi,

 

like I did already with Asteroids and Astro Fighter, I made an automatized port of Atari's original arcade game Centipede to JavaScript (with the HTML5 Canvas element).

 

The JavaScript version was created by applying the method of static binary translation to the original binary program code. The program code originally written in the machine language of the 6502 CPU of the Centipede machine was converted in a one-to-one manner to JavaScript. The translation was automized by a Prolog program, which generates semantically equivalent JavaScript code for each 6502 instruction and then applies some optimization techniques (e.g., removal of redundant flag calculations). The outcome is an exact simulation of the original arcade game. Sound is still missing, though.

 

Try it out on my homepage: http://members.aon.at/nkehrer/index.html

 

Norbert

  • Like 6
Link to comment
Share on other sites

Automatized, Automized, Simulation... it all equals emulation in the end now matter what buzzword you use. It may be beyond my programming skills, but is hardly anything new...

Also, I don't know how you can say it's "an exact simulation of the original arcade game" followed by "Sound is still missing"... "Similar to original Arcade Game" would be a more honest and accurate statement.

 

Keep at it though.

Link to comment
Share on other sites

Automatized, Automized, Simulation... it all equals emulation in the end now matter what buzzword you use. It may be beyond my programming skills, but is hardly anything new...

It's impressive in the sense that he's got Centipede running in a browser. This kind of thing has been done before, but not that often, especially not with this level of care for detail.

  • Like 4
Link to comment
Share on other sites

This kind of thing has been done before, but not that often, especially not with this level of care for detail.

 

I don't know, I think about another thread on here where people are talking about homebrewers/home programmers aren't getting appropriate criticization.

 

Again, it's more than "I" could ever do, but I look at it and see:

 

A centipede that doesn't move one pixel at a time, it's moving one segment at a time, it's almost like an LCD game where the last segment of the centipede disappears and the next segment appears as though it's not really scrolling pixel by pixel but sprite by sprite. Maybe I'm using the wrong terminology, but hopefully I'm getting my point across. Anyone who has played the game and this browser version would have to notice that the centipede is moving way too fast for the first wave. It's moving too fast because it's it's not moving ahead one pixel at a time but one centipede segment at a time. Which is odd, because the shots and the spider seem to be moving fairly fluidly. So I can retract my use of the word "emulation" because it appears to be an actual re-programming. However the Centipede itself needs BETTER re-programming. Plus we kinda need sound. Sound doesn't make the game more fun, but sound and an accurately moving centipede WILL make a more honest statement of "EXACT simulation of the original arcade game".

Edited by Torr
Link to comment
Share on other sites

Automatized, Automized, Simulation... it all equals emulation in the end now matter what buzzword you use. It may be beyond my programming skills, but is hardly anything new...

Also, I don't know how you can say it's "an exact simulation of the original arcade game" followed by "Sound is still missing"... "Similar to original Arcade Game" would be a more honest and accurate statement.

 

Keep at it though.

 

Well someone definitely has a stick that requires immediate removal.

 

No, this isn't emulation. It's a port, which the OP specifically stated in his post. It's also a port that has been automatically generated through an process of converting the original program's code to JavaScript. This is not something you come across every day and deserves better than the kick in the face you provided.

  • Like 4
Link to comment
Share on other sites

OK, I think I know what's the problem here...

 

basically, it does seem to run a translation of the original arcade code. However, the screen update only takes place at a fixed framerate which is lower than 60 Hz. The centipede in theory does move more fluidly, but you can't see it doing so. You can see it on the player's shots as well which on the arcade machine would cover every given row, but here they visually jump up multiple rows at a time. The collision detection is still there, but you can't see the shots' movement because of the screen update problem.

 

However, since this is Javascript, you can take a peek at the code... there's a variable set with "frameskip=3", you could try to set that to 0 to make it move more smoothly. I'm running this in Firefox, and it doesn't take up many CPU cycles, so I think it should still run at full speed with a 60 Hz frame rate.

  • Like 1
Link to comment
Share on other sites

OK, I think I know what's the problem here...

 

However, since this is Javascript, you can take a peek at the code... there's a variable set with "frameskip=3", you could try to set that to 0 to make it move more smoothly. I'm running this in Firefox, and it doesn't take up many CPU cycles, so I think it should still run at full speed with a 60 Hz frame rate.

 

Thanks to all of you for the feedback on the program and on the bugs.

 

Kurt, you are absolutely right. I had the frameskip variable set to 3, and now changed it to 1, and it should move more smoothly now and hopefully still be fast enough.

 

Of course, I agree, that the simulation quality is not as good as, e.g., the one of MAME or other programs. This is mainly due to my missing programming skills. It is the method of static binary recompilation that I found really interesting, because one can learn so much about compiler code generation and optimization techniques. So, I wanted to share the result.

 

I am still trying to add a Pokey sound chip emulator for Centipede's sound.

 

Norbert

Link to comment
Share on other sites

  • 1 month later...

I think I have spotted a small bug... as far as I can see, you're rewriting the high-score table, but something goes wrong with it. In the arcade version, you can enter your initials whenever you make the top 5, however in your Javascript version you only get to enter your name if you make the top spot of the list, displaying the previous top-spot owner instead of pushing him one row down.

 

Also, I think there could be made some optimizations to the code. One thing that occurs to me is the cycle counting. Often the cycles get counted up mutiple times in a string of commands (until a break occurs). This counting could be folded down to one statement. E.g. the following sequence:

case 8209:cycles+=2;flagI=0;cycles+=6;mem[256|regS]=32;regS=regS-1&255;mem[256|regS]=21;regS=regS-1&255;regPC=11612;break;

could be changed to:

case 8209:cycles+=8;flagI=0;mem[256|regS]=32;regS=regS-1&255;mem[256|regS]=21;regS=regS-1&255;regPC=11612;break;

Also, but this is more complicated, there are places where the A register's content is irrelevant because it immediately gets overwritten, so some assignments could be short-circuited. For instance, the following sequence:

cycles+=4;regA=mem[437];cycles+=2;regA=(regA^255)&255;cycles+=4;mem[437]=regA;cycles+=2;regA=61;cycles+=3;mem[249]=regA;cycles+=2;regA=0;cycles+=3;mem[250]=regA;

to the same effect could be shortened to:

cycles+=20;mem[437]=(mem[437]^255)&255;mem[249]=61;regA=0;mem[250]=regA;

(5 instructions instead of 14)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...