   Is Carmack Crazy?
  Ok, I''m currently making a GBA game using a wolfenstein-like engine (raycasting). Now, I have Carmack''s code from wolfenstein but can''t seem to figure out how he does the drawing. Here is the problem I''m having: If I am close up to a wall, then the wall obviously fills the entire screen. In order to draw each wall strip (2 bytes wide each) I need to figure out each wall pixel''s texture coordinate. Now, I have optimized this as much as I can think of using huge look-up tables and pure assembly but can''t seem to use fewer than 5 or 6 instructions per pixel. Since the resolution I''m using is 240x160, then this equals around 96000 to 115200 instructions to draw the entire screen!!! This is obviously too much and my frame rate is really bad! But, for the life of me I can''t figure out Carmack''s drawing code! He must be doing something crazy to get the speed he needs. The GBA port of wolfenstein runs very smooth (i''m estimating 30-60 fps), so it''s definately possible to draw all this and still have game logic going on. So, my question is: Does anyone have any idea how Carmack is able to draw so much and keep a good framerate. Or does anyone have any suggestions for speeding up the drawing part of a wolfenstein-like raycasting engine since that is the most costly part? Thanks soooooo much. Any help would be absolutely wonderful!  
  A wolfenstein-style raytracer could concievably do 1 or 2 cycles per pixel plus a few extra per line. Post some code.    ********A Problem Worthy of AttackProves It''s Worth by Fighting Back  ;  Look at how Carmack did the texturing-code. The strip-renderer is done the other way around than usual, but that''s not very important. What''s important is that he makes one specialized code for EVERY wall height. So, when he''s going to draw a wall with height 20, he picks the pre-compiled code for drawing a wall with the height 20.I found this in the PC-version, I have no idea how it works on the GBA. When you gain some FPS for your raycaster, try to figure out how they made DOOM ;  coelurus, I''m not sure I follow what you are saying. I''ve looked through his code lots but i can''t seem to find the exact place he is actually drawing the walls. By pre-compiled code, do you mean that he is using lookup tables? Thanks  ;quote:Since the resolution I''m using is 240x160, then this equals around 96000 to 115200 instructions to draw the entire screen!!!   nope, only about 480.His raycasting engine is not per pixal, its on a flat plane.  His engine is per "vertical wall chunk".   I think he places 1/4th of the wall, and draws that 1/4 of a wall, then moves over and draws the next 1/4th.   It makes it go much faster. of course, you lose 1 degree of freedom, but back then, it was amazing. GuessI''m prolly going to assume the GBA verson of Wolf3D is much more advance than the computer verson.  They are prolly using the GBA Doom port and modifying it to read Wolf3D files.;  dede,So he doesn''t draw the 240 vertical strips (or 120 if each is 2bytes wide) seperately? How is that possible, because depending on where the player is looking in the world, there is probably a million possibilities for combinations of vertical strips next to each other? How does he just draw a chunk of scaled, textured wall? I''m confused.  ;  The farther away the camera is from the wall, the wider the strips get if you were infact "in the world."  The strips won''t get wider on screen but will comprise more of the wall''s texture.  Look around your cubicle,  can you read what''s 15 feet away and in size 9 font?  I sure can''t, because as you move farther away from an object, the object loses resolution in your perspective, so to speak.  When you do this deliberately with your own code, ie with terrain polygons, I think it''s called "CLOD," or Continuous Level of Detail.  Or something like that.  I may be wrong, but this is just from hearing people talk in the forums.    ;  Yeah, I understand how to scale my vertical wall strips with textures and everything, but the problem is that I have to calculate each pixel on a vertical strip to figure out what texture pixel to use. This is all fine, except if I am very close to a wall, this means that the wall strips will cover the entire screen. So, I have to figure out the texture pixel for all 160 pixels of 120 strips (resolution is 240x160 and each vertical strip is 2 bytes wide). So this is 19200 pixels to calculate. I have optimized my pixel loop down to 5 assembly instructions per pixel (a load, a store, an add, a compare, and a branch) but it is still too slow for the GBA. Since the GBA wolfenstien runs very fast, I am lead to beleive that THERE MUST BE A TRICK that carmack is using to draw all this a still retain a good frame rate. I''m just asking if anyone knows of what technique he is using to do this. coelurus and dede offered some suggestions but I''m not sure I understand them exactly. Any other suggestions. Thanks!!  ;  Could you explain in more detail what you''re doing?  I ask because I''ve never used the terminology you speak of:  ''strips'' and the combination of that with heard of words.  I could probably help you but I''m not receiving the why exactly you are doing these "5 instructions" per pixel.  Or you could explain for those of us who are not fluent in GBA jargon, but may be able to "port" through correspondance in architecture to your situation.   ;  >> (a load, a store, an add, a compare, and a branch)you can surely avoid the compare and branch. i suppose you have those for handling overflows, rite? a better alternative for overflows, which only works for power of 2''s, is a simple AND instruction.say you want a value to wrap in the range of 0..255, then just ADD whatever you need to and then AND with 255.hope this helps...deemage  