DosDoom Worknote

It’s 3:04 PM 01-Jun-99 and i’ve started writing this doc(or whatever
it is). The ideea of writing this thing came (probably) from the
dosdoom.history file, but also after having to restore and recompile
the whole dosdoom source after ruining something(i don’t know what) and
this way losing all my comments(it’s prety hard to find something in
the whole source if you don’t know what you’re looking for). Actually
it all started last summer(I think that’s about when i decided to
become a programmer–hey i’m just 17,and i’ve still got one year of
highschool). It was then that a friend got me the LinuxDoom source
–man was i excited or what–. I printed lots of pages of source and
tried to understand something(that’s when I learned about lists and
binary trees,while wondering what’s a BSP–i hardly knew C and Asm
and even these learned on my own so…, no knoledge of what Linux is,
no 3dprogramming–). After working on compile errors and reading
sources for a couple of days I finally realised that the Linux
version had not only sound differences and compile warnings and errors
but also some kind video library that i didn’t know how to replace, so
i gave up). Since february I’ve been really working on understanding
what making 3d stuff is about (and getting bad marks at school
in the process). So now that I know a little more and I found the
DosDoom source I’m gonna try again(thanks to all the PROS out there for
making source and docs available).

//. things done before starting to write this doc
-eliminated anything that had something to do with the CD cause i
don’t have BCD lib–first time (couple of weeks ago) i also wiped
the sound by mistake,or maybe i just did’t turn up??–
-no more crash because I don’t have playback.wad (just don’t load it
anymore). I wonder what it does. Maybe it has something to do with
more players(8) or music???
-no more black pixelnet darkening (V_DarkenScreen? in V_Video does
nothing now)
-changed MAXPLAYERS(doomdef.h) to 4 because of crash at end of level
(and not only)

I’ve decided to put in this file not only achievements(hmmm…)but also
personal notes, guesses and discoveries. Hope it will be usefull for
someone. I won’t always bother to put in the time/date usually
because I did’n stop working somewhere in this area since I last wrote
something(or at least not for a long time). In cases like this I might
put in a time at which I really dropped the project.

4:14 PM 01-Jun-99
cool, there might something like dirty rectangles, or at least there
was supposed to be something because it seems to do nothing

-patches seem to be :status bar and head/letters on it; text in the
upper left corner;Not MENU(or at least these dissapear if I comment out
V_DrawPatch–I must be pretty stupid to write a comment like this,

-a column_t is a list of post_t (which is just a group of data bytes).
We know when we have reached the end of the list when
lastpost->topdelta == 0xff (==-1 cause it’s byte)

-I wonder if I’m not adding toooo many coments to the sources. I write
them as I understand(or at least think so) things I didn’t get before,
and since this does happen after a while of stupid staring
they just seem to add up, and grOW.

-I’m so happy my chest is shaking with excitement. After understanding
how V_DrawPatch8 and V_DrawPatchFlipped8 work I made a similar
V_DrawPatchFlippedVert8 that flips the image vertically and I replaced
it with V_DrawPatch8 => it works almost right so: “I have seen the face
from Doom2 upside down”.

-now the face has no more messy pixels but it still is a little strange
(his chin is flat and the top of his head is really angled, but it’s
a clear picture). Now I wish I had put a time at the last ” – ” so
that I could tell how long it took me.

-byte is defined as unsigned char
-finally I did it the right way, now his chin is ok, just upside down
, like I wanted it. I don’t know if I’ll understand what I did there
after a month or so. The way to do it is to draw it to understand.
Well I’m going to eat now(someone promissed to help me understand
more of the math for 3d things in an hour or so, cool).It’s
7:44 PM 01-Jun-99 so bye.

6:37 PM 03-Jun-99
in R_DrawMaskedColumn by replaceing some clipping IFs I you can see
through walls(they are not transparent but you can see sprites closeby
cause they are drawn over the walls)

-I think I understand what’s with ‘screenheightarray’ and ‘mfloorclip’.
They are pointers to an array of SCREENWIDTH length. Since in Doom there
are ONLY 1 floor height and 1 ceiling height for each screen x they are
all that’s needed for vertical sprite cliping(you don’t see something
that is behind a small wall, or any wall actually).That explains the
previous note(?).
-What’s a LUT ? Is it a ‘look up table’
-well I’ve started doing something I didn’t hope to understand for
a while. I could handle assembly the tasm/masm style but I thought
there’d be a while until I got used with the DJGPP kind of asm syntax
but now having a function(R_DrawColumn8/r_draw1.c) writen in both asm
and C I’m starting to understand and… actually enjoy the syntax. In
the meantime I’m adding(as well as I can) the coresponding C for
asm lines. I didn’t finish it yet but I’ve got to go eat before it
get’s late.
end at: 8:25 PM 03-Jun-99
10:51 PM 03-Jun-99

I’ve finished reading the asm code I talked about before. I’ve also
added some C explanations. There are things I don’t understand(I still
don’t know what ‘allign’ does although I’ve seen it before a couple of
times). I also got how that doom inivisibility-like is done: in the
part of the screen where the invisible sprite was to be drawn for each
point do: (x,y)=random((x,y-1),(x,y+1)),where random(1,2) means to
randomly choose between 1 and 2. Neat!

-I’ve been trying to understand how the translucency works but now that
I think I did objects drawn with translucency(rocket explosion, some
rockets) just don’t appear(they’re a little too translucent).
-I don’t understand. I’ve copyed the original I_video.c and compiled it
(eliminating the cdcounter) and I still don’t see my plasma balls and
rocket explosions. I’m just recompiling the whole source(who knows,
maybe …). If this doesn’t work … I’m in truoble, cause it’s not
nice to feel you’re hurt or pushed back because of something you
didn’t see coming and I don’t want to lose all my coments by
recompiling the original source.
-It’s ok. Although there were no errors there was a warning(there were
a couple but one was were I thought there might be a problem) and it
turned out that I was doing something like
destination=color; when I should have done
*destination=color cause destination was a pointer.
-when I tryed to think of a way to make things transparent(a while ago)
I thought up something like this
where a is from one picture and b from the second. This way you see
both pictures and maybe(I never tryed it out) it looks like if picture
‘a’ was transparent and you can see ‘b’ through it. However in
DosDoom things are handled differently(and brilliantly I might add).
Each time you wand to draw a pixel from a transparent/translucent (is
it the same thing?)… Well I just looked in the dictionary and I
realized that my first ideea actually generated translucency because
in transparency you don’t really see the glass(or whatever) … hmmmm
but you do! Well actually they seem to be prety close … but where
was I? Each time you wand to draw a pixel from a transparent/
translucent object you have two colors col1 and col2. For the red,
green and blue components you do something like
e.g. if x==y==1 then you get the average between the two colors and
big x while small y gives a greater power to col1. In 256 color mode
this is done with a look up table(LUT?). What I don’t understand is
why when generating the LUT we have /(2*(x+y)). This might be to
compensate for the fact that before that each rgb color component of
the original palette(‘thepalette’)was shifted right by 2. Man, is this
file getting big or what ? Taking into acount that there is little
chance that anybody will ever read this thing(unless I would be just
plain rude and make them read it) maybe it would be wiser not to write
this file(cause it takes time) but somehow it helps me remember/think
that although I seem to be an isolated programmer there might be
others like me who wish to learn and/or like reading about how others
do things. Well I think I’ve done pretty much today and I need my
sleep.  Looking  forward for tomorrow!
1:42 AM 04-Jun-99

4:14 PM 04-Jun-99

-for an hour maybe I’ve been trying to do something about the square
colors you see when you go close to walls. I first tryed to average
(evenly with ‘translucencytable50’ or unevenly with ..25 and ..70)
and I got a blurry screen(beside being a LOT slower). Also it was
applied all the time. Right now I’m trying to make something like
that that only applies for big texels (that is when a texel projects
to several pixels on the scree) –texels are like pixels but in
texture space–. I don’t really expect it to look great because I’m
doing the interpolation only vertically. Well, we’ll see.
– Seems to me like I’ve done what I thought should be done but…
nothing happens… and the watch screen doesn’t seem to work right.
-HURRAY I finally cought an error (5:22). I’ve got to remember this
one for the future: DO NOT use / type division in case of fixed
point math. You might get unpredictable results(so the watch worked
after all). Well, now lets see if it works.
-Something might have happened but I really can’t notice it except
for some mess near the top of the screen when I get close to walls.
-something must be happening cause the framerate drops from around 33
to 25 when you get close to walls.
-I’m glad I didn’t try it first in assembly
-well i even tryed it in a nongeneral fashing with a switch but
still no amasing result when you go close to walls. I suspect there
just aren’t enough colors in the doom palette to make it possible
for a smooth color wipe across the texture across the screen. I think
I’m gonna try to make a micro-pattern. I’ll just try picking colors
from the texture and use them to fade the real thing.
-well the effect certanly isn’t a desirable one. I look like the
walls were reflective surfaces(they don’t reflect anything) on
which a second texture moves.
– at least I’m trying lots of new ways to make an unpleasant mess on
the screen… A smaller texture for masking might be usefull(something
like what I saw in ‘Unreal’, but I’m not gonna make it.
-now I’m back to the first try. I do a kind of interpolation between
the previous and the current pixel as we draw a column each time a
texel is on more than one vertical pixel and except unnoticeable
smoothing and about 7fps drop(it could be optimised but it isn’t
worth the bother) it’s just about the same thing as if I had done

case 0: final_col=prev_col; break;
case 1:
case 2: final_col=next_col; break;
case 3:
case 4: final_col=mix_col; break;//an average between prev and norm
default:  final_col=normal_col;
I got some pretty impressive results if it wasn’t for that continous
moving of colors on the screen, although that almost makes for the
unavailable colors. I keep thinking of a mask or something like that.
By the way I just the fps is down to about 13.
-since I saw that last effect I’ve been thinking of motion blur( that
is if I remember well to generate two frames and unite them to make
for a more realistic picture). What if I could combine the realistic
effect that I used before with the acurate image of the original doom
, in the process losing the unpleasant movement of colors(like when
your TV isn’t working right). Well I didn’t do that but each time I
drew a pixel a averaged the previous one with the current(50%) and
I got something spectacular. It’s like if you were a ghost or
something and everything seems unreal, floating. What if I used 25%?
-even with 25% you can see something through the gun.
-with only 1/16 influence of the previos frame to the current you don’t
see trails of objects/wall just the wall textures look different each
time you go near them, but the fps is great(31 unoptimised …
actually I don’t think there can be much optimisig done);
7:50 PM 04-Jun-99

11:26 AM 05-Jun-99
I love living. This morning when I woke up I got a great ideea. I
think it’s not my ideea but  at least I understood(did I?) it. What
is a ‘thinker’ that I think I have seen in Doom source and QuakeC.
Well what if it is a pointer to a function, or even better, a list
of pointers. “So what ?”, you might say. Well supose we update this
list each time something happens(in Doom). Then, at least idealy, in
my imagination, we might have a totally different kind of program.
We can jump to whatever function we need compleatly idependent of
the way the procedures/functions are ordered. In real life (if) the
makers of Doom combine(d) this with an inteligent main loop that
refreshes the screen and others(???). This would be/is very flexible.
Now back to the source.. If I leave the fuzzy efect on the wall if you
it look make a screenshot it looks great but if you play I’m not sure
you would enjoy it for a long time. What algorithm would make that
fuzzyness static, and constan each time you go near the wall ? A
friend I showed it to said it looks like LOTS of ants moving on the
wall and I should make the player hurt when you get near it. The other
options would be:
-the original: it looks the same each time you go neat the wall
(that’s good) but you also see those big squared
texels(that’s bad)
-the motion blurr: creates the feeling of acceleration,my
friend didn’t even notice it, that good
or bad? the walls don’t have squares on them
(that’s good), they look different each time
you go near them(that’s bad)
Now I really should go to the real thing.
-I must remember never to start Doom and write at the same time(yes,I’m
working under win95). I just lost a pretty long paragraph because of
a crashdown. Well, I’ll start like I did last time:
-(4:12) I think I’ll drop this subject(trying to make Doom walls look
better when you go near them) for now. Here’s what/how I’ve done until
now: First I determine how many vertical pixels a texel is spread
e.g. : if fracstep==1/3 we write three pixels until we step to the
next texel.
{ we are close to walls so we do motion blurr and throw pixels
randomly(but not too often) on the screen to recreate the true
draw the normal, fast way
For smaller texel spread not only you have an unreal feeling but also
some monsters you go near become transparent(maybe I should have
created a separate function that does only the wall mapping). I used
M_Random() for speed and eliminated(commented) the code that does the
fuzz so now we have about 33fps with very little difference when you
go near walls(maximum 3fps), so that’s ok. Translucency is great! If
the menu appers and then dissapears you see a light shadow of it on
the wall. Ok, so that isn’t very realistic but It makes for a great
visual trick. By the way, I also tryed some kind of very simple
vertical pattern, something like

switch(verticalcounter%4) /*    verticalcounter%8     */
case 0: final_col=prev_col; break;
case 1: final_col=mix_col; break;
case 2: final_col=next_col; break;
case 3: final_col=normal_col; break;
/* not this part
case 4: final_col=pixel to the left; break;
case 5: final_col=pixel to the left; break;
case 6: final_col=pixel above; break;
case 7: final_col=pixel below; break;
You could see horisontal lines of the same color… not exacly what I
wanted but if before the loop I initialized verticalcounter with a
small random number and not with 0 it didn’t look that bad. The same
thing but with the comments made a real mess on the screen but It
was cool to see how the menu dissapeared a pixel at a time.

-P_Random doesn’t look like an effective random on the screen, it seems
to clear vertical lines more than horisontal while I would expect
random to have no privileged direction. I think I might actually enjoy
some formal knowledge about generating random numbers.
-I wonder if ‘M_Random’ is a pointer to ‘M_Random()’

12:10 PM 06-Jun-99
Seems like it’s hard to give up something when I know that it still
doesn’t look right. I’ve tryed some random, but still static offseting
of each vertical line on the screen in the hope of creating a slight
fuzz that would help the motion blurr look less squared(cause it does).
I didn’t really like it. I’m still not satisfied with the pixel rain.
It loos good for a couple of seconds but then we have the original
squares. On the other hand only the motion blurr looks too different
each time you go to the same wall, so i’ll leave them both.
-plutonia.wad sure has got some nice levels, especially considering
the doom limitation for level design. I wanna make some nice levels
on a new game. I’m hoping that as a programmer I’ll get to work with
the level designers and hopefully contribute.
… dreams …

1:18 PM 06-Jun-99
I think I understand the ideea behind floor/ceiling mapping but not
the real numbers in R_DrawSpan. We are looking for constand z lines
on the floor so probably rotating corespondingly in the texture and
advancing on x,y for each next pixel we draw on the screen.
-what does dehacked.c implement ? A way to modify the wad ?
-what are tics ? They probably have something to do with syncronising
events or something ? Anyway in the main loop I replaced
if(singletics) with if(1) so the else is never done. In the game
we have 52fps(wow) but we can’t move so TryRunTicks() must do
something(the else is never true). I thought it would just make
refresh I little weirder(sometimes faster, sometimes slower).
-back to thinkers: This is the implementation from d_think.h, I like
it so much I’ve just got to put it here:
typedef  void (*actionf_v)();
typedef  void (*actionf_p1)( void* );
typedef  void (*actionf_p2)( void*, void* );

typedef union
actionf_p1    acp1;
actionf_v    acv;
actionf_p2    acp2;
} actionf_t;

// Historically, “think_t” is yet another
//  function pointer to a routine to handle
//  an actor.
typedef actionf_t  think_t;
// Doubly linked list of actors.
typedef struct thinker_s
struct thinker_s*    prev;
struct thinker_s*    next;
think_t        function;
} thinker_t;

It’s a great ideea to use pointers to functions, and it’s nice they
-what does (actionf_v)(-1) mean? actionf_v is defined as no parameters.
-those green flames in Doom might look a lot better if they were
-i DON’T get it. In D_DoomLoop i replaced singletics by 0(I’m cheating
because I only did this after seing that it was initialised by false)
and the game still works. But doesn’t that exclude the whole game but
the drawing and the sound??
-ticcmd seems to be a structure that holds information about user
imputs. So each frame/tic(?) a ticcmd is built. This allows for
coherent way to hadle imputs for playing/recoding a demo/playing one,
because for example when recording this structure is passed not only
to the engine but also to some routine that saves it in a file. Great
-doom crashes at end of map11(after text, in Plutonia.wad) with
P_SpawnMapThing: Unknown type 0 at x , y(real numbers). After seing
my guess is P_SpawnMapThing that it’s got something to do with  the
implemetation of 8 players which somebody has done(who is JC?) because
I suspect object types 1-4 and 4000-4005 are the player’s spawning
-but then what is type 0?
-had a nice crash while spawning player at object type 0
-i didn’t think anybody could make maps like(at least some) that with
the doom engine… still … I find it hard to picture how somebody
would finish the game with limited amo and health(in a limited time
period, and without knowing where each monster is).
7:23 PM 06-Jun-99
10:33 AM 07-Jun-99
this was a nice school day. The teachers are on strike so we did only
math and I’m already home. Well…I could have stayed because most
teachers still teach, but why since I don’t have to. Now onto Doom
matters: why doesn’t the watch window of Rhide work right??
-now that’s too many crashes!! I can’t fix the bug at the end of map
11 with 5 crashes a minute and no ‘watch’. A counter that should do
i++ is shown as 40065,next 63346, next 5473 and so on. That’s just too
-well, I fixed it, but in a very stupid way: if(mobj->type==0) return.
-Just found another proof that there are others with interests like me:
There are 2 versions for P_NightmareRespawn. Cool! Wish I’d get the
chance to meet them.
-my close to wall motion blurr is REALLY getting annoying.
-With some
comments and some replacing now each time you pick up something ,if
respawn is on, it reapears on the ceiling imediatly and falls down.
It’s like if it never dissapeared but a lot more fun.
-another step forward: now we have -funrespawn option that enables
what I described above. The parameter checking is in ST_InitData.
There should be a better place to put it.
-the blurr effect is now parameter based too. If no parameter is given
no blurr is applied. Synatax is the usual one “-blurr number”.
If number is 0 the whole screen is always motion blurred. I am a
little worried about those ifs in R_DrawColumn8 because that is called
really often(although the fps didn’t show it as a striking stupidity).
Only applies for 256 color mode.
8:58 PM 26-Jun-99
Since last time I wrote something I’ve been reading (more) about
bsp trees and texture mapping.
The idea behind bsp trees is something like this (as far as I
understand it):
We need to know which objects can/can’t obscure other objects(I mean
walls in case of Doom). So the the whole thing is based on: suppose we
have a room seen from above. We split it into two parts: A and B. If
the viewer is on side A no object on side B will ever obscure any
object on side A no matter what. So you first draw all objects on side
B and then all objects on side A.

-my work on DosDoom might not be over but I finally got email access
and sent a message to Mr. Chi Hoang (the man who ported the doom source
to dos/djgpp, and this isn’t the only thing he did…thanks(just look
at the features DosDoom has compared to the original)). I’m sending
this file to him in the hope that he can get it to those interested
more than I can. So bye! Write me. My email address is
I am (and probably will be for a long time) learning 3d programming and
programming in general so any documentation you can send me or any
advice you might have is welcome. I want to be a games’ programmer.
I’m looking for friends.

this file was/is written by Void lon iXaarii (that’s me)

all comments like //. or /*. in the source are mine
(although I don’t know if anybody will ever see my source)