Slashdot Mirror


Doom Ported To the Web

kripkenstein writes "Ever since Id Software released the Doom source code under the GPL, it's been ported to platform after platform. Now, you can play Doom compiled to JavaScript on the web, using standard web technologies like Canvas and without any plugins. If your browser has trouble running it, here's a screencast." The translation was accomplished using Emscripten, a Javascript backend for LLVM. As per the GPL, full source code is available. Pretty neat.

29 of 248 comments (clear)

  1. Progress by Anonymous Coward · · Score: 5, Insightful

    So instead of a 40MHz 486 and 8MiB of EDO RAM, we now require at least a 2,5GHz dual core with 1GiB of DDR3 SDRAM to accomplish the same thing on a web page.

  2. Not as cool as GWT Quake by empiricistrob · · Score: 2

    While this is impressive, it has been done before (and better): GWT Quake

    1. Re:Not as cool as GWT Quake by kripkenstein · · Score: 5, Informative

      While this is impressive, it has been done before (and better): GWT Quake

      I think that Quake demo is awesome! I'd just like to mention though that this Doom demo is very different from a technical standpoint, and I think both are interesting:

      • The Quake demo compiled Java to JavaScript using GWT, the Doom demo compiles C through LLVM into JavaScript using Emscripten.
      • The Quake demo uses WebGL to render, the Doom demo translates a 100% software renderer. It's much more challenging to get good performance with a software renderer in JS, especially given that the original renderer was heavily optimized for the CPUs of the day (for example, it uses fixed-point math).
      • The Quake demo was a major effort, with rewriting and fixing. The Doom demo is a straightforward port, no new code (only a few tiny tweaks), took only a week to do. (Btw, speaking of the timetable, sorry for the sound quality - I just spent a few hours on that part, and I had never used the Audio Data API before.)
  3. Sound is abysmal by kevinmenzel · · Score: 2

    So... no music, and the sound effects are like a half second delayed from the action, AND they sound really REALLY bad. I guess it's impressive what you can do visually with Javascript these days, but at least on my setup, the sound is just.... no where near as mature. That's probably not a huge problem for many people, but personally sound is a huge part of any experience for me, and I find the web constantly disappoints. Except, generally for Flash animation/Flash games which seem to have at least gotten THAT... well, MORE right.

    1. Re:Sound is abysmal by kripkenstein · · Score: 4, Interesting

      So... no music, and the sound effects are like a half second delayed from the action, AND they sound really REALLY bad.

      I agree, the sound is terrible, sorry about that. I don't know much about how sound stuff works, that is the best I could do in a few hours of hacking something together with the Audio Data API.

  4. Re:Hooray by grub · · Score: 2


    Yea, most of the rest of us have upgraded our computers since the time Doom originally came out.

    Don't be too hard on the poor fellow, he's probably having a hard time finding a shop which sells the correct vacuum tubes.

    --
    Trolling is a art,
  5. Re:Wow by empiricistrob · · Score: 2

    I agree that we should start considering replacing javascript as a language. Why not provide a strongly typed extension to javascript? Javascript would get a lost faster.

  6. Come on, you could do this with flash 2 years ago by Anonymous Coward · · Score: 2, Interesting

    Here's the link: http://www.newgrounds.com/portal/view/470460, plus: it does run with a higher framerate.

  7. Ughhhhhh by davidbrit2 · · Score: 2

    I mean, it's a cool accomplishment in terms of implementation and all, but...

    Ughhhhhhhhhh.

    1. Re:Ughhhhhh by danieltdp · · Score: 2

      Its not ughhhh. Its old... :-) You should look what lies behind the bad graphics: playability, balance, level design, enemy design, etc. IMO, this game has some of the best level designs in game history.

      --
      -- dnl
  8. Re:Wow by Necroman · · Score: 4, Informative

    If you want real graphics performance out of a browser, you should be using WebGL (assuming Flash is not an option). WebGL lets you execute OpenGL code on the video card of the machine, which will be a ton faster than Canvas.

    You have to remember that Canvas is just an image rendering platform. From my understand of Canvas in Firefox, it actually renders every frame as a PNG and displays it to the screen. There is no GPU acceleration. That's what WebGL is fore.

    --
    Its not what it is, its something else.
  9. This proves the old adage by Jailbrekr · · Score: 2, Insightful

    "Just because you can, doesn't mean you should"

    --
    Feed the need: Digitaladdiction.net
    1. Re:This proves the old adage by david.given · · Score: 4, Informative

      "We do what we must, because we can."

    2. Re:This proves the old adage by lennier · · Score: 2

      I'll be honest with you. We're just throwing science at the wall here to see what sticks.

      --
      You are not a brain: http://books.google.com/books?id=2oV61CeDx-YC
  10. Re:Not bad by KiloByte · · Score: 4, Informative

    Video card hardly makes any difference, browser does. 35 fps full-screen on Firefox 7.0a1, 34 on Firefox 4.0, slideshow on Firefox 3.5. This is on a cheap-ass 2.8Ghz Phenom II. It uses no OpenGL, about any graphics card can handle shoving such bitmaps around. It's single-threaded, too, so what you're ripping on your other cores doesn't matter.

    However, without such basic controls as strafe, this demo is not playable. No mouse input hurts but DOS versions had unusable mouse anyway so it's just a throwback to the old times. I estimate I've clocked around 4000 hours those days so I'd cope :p Heck, even comma/dot might be acceptable if they don't want to allow redefining keys, although I'd really prefer a sane setup like Z/X=strafe, alt=fire, shift=run (assuming no autorun like in the original).

    --
    The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
  11. Re:Not bad by GameboyRMH · · Score: 3, Funny

    1.4fps on my N900! IN YOUR FACE!

    (Protip for N900 users: Use Firefox Mobile, if you try with MicroB it will just consume all your memory)

    --
    "When information is power, privacy is freedom" - Jah-Wren Ryel
  12. Re:Wow by parlancex · · Score: 2

    The original doom used software rendering which makes this a fair comparison actually, things like OpenGL and hardware accelerated 3D graphics certainly didn't exist (in the consumer realm) in 1993. Doom ran at full frames on 66 mhz Pentium processor. Loosely extrapolating, this means the Javascript version is about 200 to 300 times slower than the original.

  13. Re:Come on, you could do this with flash 2 years a by kevinmenzel · · Score: 2

    And that version runs faster, renders better, and has better sound.... AND it doesn't make every fan in my computer speed up to the point where I think I'm playing doom on a jet engine. Still not perfect (Gosh, native code runs better than code through a browser, who'd have thought?) but it's better than the JS version by leaps and bounds. Or it would be if you could jump in Doom.

  14. Re:My performance by nogginthenog · · Score: 2

    CPU: Celeron Dual-Core @ 1.8Ghz
    Firefox 4.x gets around 30fps, so I guess the answer is yes.

  15. Re:Not bad by kripkenstein · · Score: 3, Informative

    However, without such basic controls as strafe, this demo is not playable.

    Actually strafe works, hold down alt.

  16. Re:No, It's Not Just You, It's Just Developers by Anonymous Coward · · Score: 3, Informative

    Javascript is fine. It's the 'running inside a browser' that kills performance by 99%, and makes this an impressive feat. If the Javascript engine was ripped out of Firefox 4 or Chrome, and given a decent graphics & sound API, it would have respectable performance (nowhere near C or C++, of course). When you're writing a graphics heavy app in a browser, though, it's like playing a song on a dot matrix printer. The fact it exists at all is the amazing thing.

  17. Re:Is it just me... by Nimey · · Score: 4, Informative

    No. My 486SX-25 would run Doom at 20-some FPS (mainly dependent on how many monsters were within visual/acting range), and after an upgrade to a DX2-50 Overdrive it would usually be 30-something -- and the original DOS executable had a hard limit of 35 FPS.

    Don't forget this is running as interpreted code in what amounts to a virtual machine.

    --
    Hail Eris, full of mischief...

    E pluribus sanguinem
  18. Re:Wow by Dahamma · · Score: 3, Informative

    This demo is rendering to an HTML5 *canvas* as a virtualized framebuffer in an interpreted language with no hardware support whatsoever. Are you *seriously* trying to use this as a complaint against Javascript? I remember back when "demo" just meant "write a cool app to show off"...

    Of course it's not the way someone would build a real app in Javascript, but it's an excellent demo to help people understand what the platform can do and how it might be improved. And for those of us who understand all of the tools that went into it, it's just pretty damn cool.

    A couple weeks ago a story was posted about a demo that booted a real 2.6 Linux kernel image with ramdisk entirely in Javascript: JSLinux.

    That takes a whole 6 seconds to boot to a bash prompt *in Javascript* on my machine. SO SLOOOW, Javascript sucks!!! ;)

  19. Re:Is it just me... by Surt · · Score: 2

    I think it's actually depressing that web browser implementations are so poor that they can eat up the entirety of the significantly more than 50X improvement in processing power that has happened in the intervening time.

    --
    "Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
  20. Re:version of java matter? by H0p313ss · · Score: 2

    Amazing... Over a decade and a half and even tech-heads still get this wrong.

    I did a "RESTful webservices in java" course the other day and the instructor felt it necessary to point out that JavaScript was not Java despite the fact that you had to have years of Java experience to even register for the course.

    --
    XML is a known as a key material required to create SMD: Software of Mass Destruction
  21. Re:Wow by Gaygirlie · · Score: 3, Informative

    The original doom used software rendering which makes this a fair comparison actually, things like OpenGL and hardware accelerated 3D graphics certainly didn't exist (in the consumer realm) in 1993. Doom ran at full frames on 66 mhz Pentium processor. Loosely extrapolating, this means the Javascript version is about 200 to 300 times slower than the original.

    Indeed, it is a lot slower than the original. But the reasons for the slowness are quite clear: it's a byte-compiled language that must run in a VM, so that incurs already a lot of overhead; it cannot use any assembler tricks to speed the game up, it cannot align things in memory on double-word boundaries and so on. But then in addition to that it's running inside a web browser and renders every single frame as a PNG which involves first compressing the PNG and then decompressing it, just to display it.

    The original one of course was running on bare metal, having the CPU fully to itself, and VGA was actually very fast as a graphics card back in the day; you'd render an image, change a register or two on the VGA card to flip the buffer and voila, you got a picture on the screen. No need for compressions or decompressions or anything. Not to mention that it was all indexed 256-bit colour graphics which means that the entire screen only weighed in at 62.5Kb and you could modify the colour index table for fast special effects, no need to modify individual pixels as the hardware took care of displaying the appropriate colour!

    Comparing it straight-up to the JavaScript version simply isn't fair to either of them.

  22. Re:Is it just me... by shutdown+-p+now · · Score: 4, Informative

    No, it's not bytecode. Most (all) modern JS engines actually JIT-compile to native code.

    It's still slower than C version simply because native code doesn't mean fast - if it has to do dynamic dispatch over method names, for example (because the compiler couldn't infer types deep enough), it's still slower than a direct or virtual call.

  23. Re:Is it just me... by tibit · · Score: 2

    Couldn't agree more. Javascript is like early RISC chips. People joked that RISC meant 'relegate impossible stuff to the compiler'. We've since figured out how to handle RISC instruction sets well, but Javascript compilers are at the same early stage it seems. Javascript is an "impossible" language to compile into fast code. It requires significant advances in JIT type inference, whole program profile-guided optimization, etc. The theory for all that has been mostly worked out long ago, it's just a matter of efficient implementations that don't take 1GB to JIT a piece of 90s vintage cross-compiled C that used to run in 8MB and compiled in just as much... Javascript's architecture, unfortunately, requires very nontrivial code analysis. My expectation is that a well done Javascript engine will use more memory while JITting than the heap used by the target code itself. There's very little one can do to help in this department methinks.

    --
    A successful API design takes a mixture of software design and pedagogy.
  24. Re:Not bad by KiloByte · · Score: 2

    The HUGE fps difference is because of accelerated video via DirectX as you must be on Vista or Windows 7 correct?

    Cthulhu forbid, no!

    Your cheap-ass card can do wonders with Direct2D which is what Firefox 4 for Windows renders compared to 3.6.

    Comparing with nouveau, the speed decrease is small, roughly consistent with that on programs which don't do hardware rendering at all. I even doubt Firefox actually uses any hardware acceleration there.

    This is why it sucks on Linux.

    The same hardware, a Windows 7 partition (sad to break its 4 months non-uptime): 24 fps on FF4, XP: 27 fps. So no, not quite "sucks".

    --
    The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.