Slashdot Mirror


Code Review of Doom For the iPhone

Developer Fabien Sanglard has written a code review for id Software's iPhone port of Doom. It's an interesting look into how the original 1993 game (which he also reviewed to understand its rendering process) was adapted to a modern platform. "Just like Wolfenstein 3D, Doom was rendering a screenframe pixel per pixel. The only way to do this on iPhone with an acceptable framerate would be to use CoreSurface/CoreSurface.h framework. But it is unfortunately restricted and using it would prevent distribution on the AppStore. The only solution is to use OpenGL, but this comes with a few challenges: Doom was faking 3D with a 2D map. OpenGL needs real 3D vertices. More than 3D vertices, OpenGL needs data to be sent as triangles (among other things because they are easy to rasterize). But Doom sectors were made of arbitrary forms. Doom 1993's perspective was also faked, it was actually closer to an orthogonal projection than a perspective projection. Doom was using VGA palette indexing to perform special effect (red for damage, silver for invulnerable...)."

33 of 161 comments (clear)

  1. Re:Already done by Anonymous Coward · · Score: 2, Funny

    When in slashdot, nerds dont RTFA.

  2. Re:Already done by VShael · · Score: 5, Funny

    did you even read the article?

    You must be new here...

  3. Pushing pixels by MtHuurne · · Score: 4, Interesting

    Forgive my ignorance, but couldn't you have the original software renderer write to an in-memory buffer and then upload that using glTexSubImage2D()?

    1. Re:Pushing pixels by pananza · · Score: 2, Funny

      Nah, too easy and direct approach.

    2. Re:Pushing pixels by Lord+Pillage · · Score: 2, Interesting

      Or glWritePixels() would work too. Might be a little bit closer to the original method. But then again, I didn't RTFA, so I wouldn't know.

      --
      try { Signature mysig = new CleverAttempt(); } catch(NonCleverSignatureException e) { postanyway(); }
    3. Re:Pushing pixels by RedK · · Score: 4, Interesting

      glDrawPixels is not supported under OpenGL ES which is what the iPhone uses. An in-memory buffer used as a texture is about the only way for fullscreen images (vertex arrays drawn using GL_POINTS is another solution but would not be fast enough).

      --
      "Not to mention all the idiots who use words like boxen."
      Anonymous Coward on Monday August 04, @06:49PM
  4. Classics never die by adosch · · Score: 5, Insightful

    I remember playing Doom in the mid-90's on my friend's Gateway 2000 Pentium 100Mhz. I still play it to this day from time to time (openGL port on Linux). It's mindless, self-indulging, gory, non-challenging (now, not then!), and it's becoming one of timeless those FPS games that won't die because it's story line is simple and not drug out, you're thrown right into the mix and you can keep your objective as simple as you want: Make it to the end of the map.

    1. Re:Classics never die by goldaryn · · Score: 3, Interesting

      It's mindless, self-indulging, gory, non-challenging (now, not then!), and it's becoming one of timeless those FPS games that won't die because it's story line is simple and not drug out,

      In my opinion, DOOM was a good game but it wasn't ground breaking in the same way that Quake was a few years later. It was the first FPS to do real 3D, and gave birth to real FPS competitive play, based on the groundwork that DOOM did with FPS LAN play. Aside from that, the Quake engine led to all sorts of interesting gamemodes and mods that live with us still (Team Fortress was originally a Quake mod), and the physics of Quake 1 still has a legacy today (rocket jumping, bunny hopping).

      I think the insurgence of DOOM ports to phones is because the pseudo 3D interface of DOOM lends itself more to the controls of mobile devices. It'd be nice to see more Quake and Duke3D ports.

    2. Re:Classics never die by Hadlock · · Score: 4, Funny

      DOOM was a good game but it wasn't ground breaking in the same way that Quake was a few years later. It was the first FPS to do real 3D, and gave birth to real FPS competitive play, based on the groundwork that DOOM did with FPS LAN play. Aside from that, the Quake engine led to all sorts of interesting gamemodes and mods that live with us still (Team Fortress was originally a Quake mod), and the physics of Quake 1 still has a legacy today (rocket jumping, bunny hopping).

      You sir, have a career in video game blogging! Let me sign you up for a 3000 word "Top 10 Groundbreaking games of the 1990s" blog entry.

      --
      moox. for a new generation.
    3. Re:Classics never die by goldaryn · · Score: 2, Interesting

      Aside from that, the Quake engine led to all sorts of interesting gamemodes and mods that live with us still

      I forgot to say: Action Quake was another Quake 1 mod, which eventually became Counter Strike.

    4. Re:Classics never die by jaggeh · · Score: 2, Interesting

      It was S.E.A.L. Quake not Action Quake

      Although my favorite quake mod was malice.

      --
      I would give everything i own for a little bit more.
    5. Re:Classics never die by Antiocheian · · Score: 5, Insightful

      The groundbreaking REAL 3d game was Ultima Underworld. Amazing story, great music and paced to the action (due to midi synthesis) and total 3d immersion.

      Pay your respects to Looking Glass.

    6. Re:Classics never die by imakemusic · · Score: 2, Funny

      it's story line is simple and not drug out

      Unlike, say, Pacman in which the main character spends the entire game eating pills.

      I think the word you're looking for is 'dragged'.

      --
      Brain surgery - it's not rocket science!
    7. Re:Classics never die by Sir_Lewk · · Score: 2, Insightful

      It added a whole new kind of depth to the gameplay. Suddenly, the game wasn't just about how well you could aim, and how well you knew the maps and where the pickups where, it also mattered how good you were at moving. It was so influencial and loved, that future quake engines made it a point to allow alternative movement styles, the pro mods (CPMA stands out in particular) enhanced and added movement tricks, and entire mods were created around completely around the concept (DeFragged). The quakes were really the perfect games for FPS fans, you could pick them up easily enough because the basics were simple and the weapons were easy to use, but there were always more ways that you could improve your gameplay. If you mastered killing people with weapons, and memorized all of the maps, you cou always find better ways around the maps with the weapons.

      The concepts developed in Quake I-III helped make those games legend and have made a presence in nearly every FPS since then. Now I understand that in some gaming circles, movement tricks are look down upon, somehow seen as cheating or as degrading to other peoples gaming experiances in general. I've heard of people being banned from Modern Warfare 2 servers for being "unrealistic". More than anything, this saddens me, and signifies to me an end of an era where fun and skill were important in gaming, not misguided ideas of realism.

      --
      "linux is just DOS with a UNIX like syntax" -- Galactic Dominator (944134)
    8. Re:Classics never die by Anonymous Coward · · Score: 2, Insightful

      ....and before doom, a thing that most people seem to forgot..

    9. Re:Classics never die by gregmac · · Score: 3, Insightful

      This is also in a game where you can get hit by a rocket and live if you have enough health. And take a few hundred bullets from a simple 'machine gun'. And jumping from a ledge 6 times your height? No problem.

      If it was realistic, you'd be dead from the first

      --
      Speak before you think
  5. Bloody Hell by Anonymous Coward · · Score: 2, Funny

    I thought it was "Code Review of Doom" for the iPhone not "Code Review" of "Doom for the iPhone".
    I've seen some "code reviews of doom". I was looking forward to some juicy ApplePain.
    Oh well.

  6. Re:Already done by sznupi · · Score: 2, Funny

    What makes articles slashdotted anyway?...

    Or is that some mystery not approachable "even" by 6-digiters?

    --
    One that hath name thou can not otter
  7. He's wrong though by Anonymous Coward · · Score: 5, Interesting

    Doom 1993's perspective was also faked, it was actually closer to an orthogonal projection than a perspective projection

    Not remotely true; DOOM's perspective is/was perfectly correct (apart from the monsters being billboards, of course - but they were perspective-correct billboards).

    The method for achieving perspective is rather unconventional, but the maths works out the same.

    Matching up floor and ceiling in an animated view with fake perspective is basically impossible.

    [I did a port of DOOM before it was open-source, so I know a thing or two about this.]

    1. Re:He's wrong though by Anonymous Coward · · Score: 5, Informative

      You are correct. What TFA probably means is that walls, floors and ceilings are drawn in strips, and that for every strip all the texels are looked up according to a straight line. But that doesn't mean at all that hence Doom just uses an orthogonal projection, since it actually let's things diminish in the distance properly. A lot of real three dimensional games actually linearised texel lookup, but that says nothing at all about the overall projection a game uses. If you want to know what an orthogonal projection looks like, go play Age of Empires. As an added comparison, take a look at Mode 7 tricks on the SNES. You can actually perspectively correctly display a flat surface on it. How is this done? By setting a different orthogonal projection for each (in this case horizontal) line. That does not mean however that games using this therefore use an orthogonal projection, because the parameters are different for each scanline and the overall projection is perspective.

  8. I'd like to read this article by drinkypoo · · Score: 3, Funny

    But it won't fit on a 800 pixel wide screen. WTF? I thought it was a code review, not a flash game.

    --
    "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    1. Re:I'd like to read this article by slim · · Score: 4, Informative

      You need the Readability bookmarklet.

  9. Re:Already done by JosKarith · · Score: 2, Funny

    10,000 geeks hitting a server designed for 1000 connections max. Simultaneously.

    --
    'Don't worry' said the trees when they saw the axe coming, 'The handle is one of us.'
  10. These are implementation notes, not a code review by HisMother · · Score: 3, Insightful


    This isn't a "code review" -- it's a short monograph (with Quicktime movies!) that talks about how Id got DOOM working well on the iPhone. A "code review" is, well, a critique of code, and the style, correctness, and efficiency, thereof.
    </pedant>

    --
    Cantankerous old coot since 1957.
  11. What's with this CoreSurface licensing restriction by mikelieman · · Score: 4, Insightful

    The only way to do this on iPhone with an acceptable framerate would be to use CoreSurface/CoreSurface.h framework. But it is unfortunately restricted and using it would prevent distribution on the AppStore.

    Now this is what really annoys me. Here are tools. Appropriate tools. But you aren't allowed to use the tools, because what you're going to use them for offends The Gods.

    What was that RMS was saying again?

    --
    Technology -- No Place For Wimps! Grateful Dead and Jerry Garcia Chatroom -- http://www.wemissjerry.org
  12. Doom is still incredible by renrutal · · Score: 2, Interesting

    Heh, I remember playing Doom in my uncle's computer back in 94 as as 9 year old boy, and loved it, adored it.

    16 years later, now an employed programmer, I still think it is made of black sorcery and an ingenious amount of coding. That's awesome!

    Does Carmack /id Soft have a donation paypal-esque account? I'd love to give them what is due for all those early years of pure fun.

    1. Re:Doom is still incredible by shutdown+-p+now · · Score: 2, Informative

      You can still buy id classics on e.g. Steam.

  13. Re:What's with this CoreSurface licensing restrict by slim · · Score: 4, Insightful

    What was that RMS was saying again?

    Don't bring attention to RMS's pragmatism. It confuses those who prefer to think of him as a hippy.

  14. Re:What's with this CoreSurface licensing restrict by Fahrvergnuugen · · Score: 4, Interesting

    Disallowing the use of private APIs ensures that your software will continue to function with new versions of the iPhone OS. The private APIs might change, but the public ones will not. The real questions is whether or not there should be a public API for CoreSurface.

    --
    Kiteboarding Gear Mention slashdot and get 10% off!
  15. Re:Already done by EricWright · · Score: 2, Insightful

    There are those who read (and create the /. effect) and those who post. The intersection of those groups is vanishingly small.

  16. Re:Already done by buanzo · · Score: 2, Funny

    .\ is the MS-DOS oriented slashdot, right?

    --
    Buanzo Consulting - 15 Years of GNU/Linux experience, for you.
  17. Code Review of DOOM by asylumx · · Score: 3, Funny

    I think this is how I'll start referring to ALL my code reviews ;-)

  18. Quake 3 code is mostly ready for iPhone now. by Anonymous Coward · · Score: 3, Interesting

    A long time ago, I ported Quake 3 to windows mobile. Tedious, but it worked reasonably at around 30fps (and deathmatch worked) with OpenGLES acceleration on the Dell Axim x50v enabled with the intel 2700g coprocessor. The code is still out there, but frankly, it wouldn't be kosher for me to push a copy of Quake 3 to the iphone store since i dont have copyright access to the 'assets' of the game and i dont need to get sued or something.

    it's a bit useless to gpl your game and not the assets. If iD software wants to use the code for a quake 3 for iphone, they can do so at http://code.google.com/p/q3ce/source/checkout. Should save them some time. Open invite, go right ahead, i can't do anything with it these days anyway.

    (and yes, i converted the whole thing from floating point to fixed point using some fun c++ templates, poke around the code to see how it works, it's kinda neat.)