Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
DuckReconMajor

Doom source code oddity.

Recommended Posts

I was looking through r_segs.c in the source code and noticed something odd. Take a close look, especially at third 'if' block.

// two sided line
if (toptexture)
{
// top wall
mid = pixhigh>>HEIGHTBITS;
pixhigh += pixhighstep;

if (mid >= floorclip[rw_x])
    mid = floorclip[rw_x]-1;
	
if (mid >= yl)
{
    dc_yl = yl;
    dc_yh = mid;
    dc_texturemid = rw_toptexturemid;
    dc_source = R_GetColumn(toptexture,texturecolumn);
    colfunc ();
    ceilingclip[rw_x] = mid;
}
else
    ceilingclip[rw_x] = yl-1;
}
else
{
// no top wall
if (markceiling)
    ceilingclip[rw_x] = yl-1;
}
	
if (bottomtexture)
{
// bottom wall
mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
pixlow += pixlowstep;
That way of rendering always boggled my mind, but I never noticed they'd stumbled upon something way ahead of their time. Carmack truly was (and of course still is) a genius. But it seems even he wasn't aware how smart he was!

Still don't see it? Here's a hint.

Share this post


Link to post

By golly who'd ever knew that source code could be the object of such a wondrously funny jape. Damn good show I say!

Share this post


Link to post
Guest

Posting in this thread for no good reason.





Also... Headcrabs.

Share this post


Link to post
baronofheck82 said:

Reading source code for me is like reading Latin. Looks cool, but makes no sense :P

My current favorite chunk:

for(shift = 28; shift >= 0; shift -= 4)
   *c++ = "0123456789abcdef"[(hash->digest[i] >> shift) & 0x0F];

Share this post


Link to post
Quasar said:

for(shift = 28; shift >= 0; shift -= 4)
   *c++ = "0123456789abcdef"[(hash->digest[i] >> shift) & 0x0F];


Is that from Doom? It looks like some kind of integer to hex string conversion.

baronofheck82 said:

Reading source code for me is like reading Latin.


I'd say reading other peoples source code is like reading Latin.

Share this post


Link to post
Scet said:

Is that from Doom? It looks like some kind of integer to hex string conversion.

It's from EE, of course. Recent revisions have been on a branch where many arrays are being converted to hashes. There aren't many hashes in vanilla Doom...

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×