
Doomsday / JHexen
==================
Windows/OpenGL port of the Doom engine and Hexen v1.1
by Jaakko Kernen.


TO-DO LIST
-----------
Legend: -- not done, ++ done


++ Check_voice() of WinAllegro is probably malfunctioning. I'm guessing this
	is the reason why the rising lava pool of demo2 (and other sounds meant 
	to be repeated) play only once. The best solution is to wait for the new,
	unified Allegro. I think I'd better send some mail to the Allegro list 
	about this.
  *** SOLVED: I modified WinAllegro's DirectSound driver so that it checks if 
	the	voice is playing or not, and if it isn't, directsound_get_position() 
	returns -1 -- exactly like Allegro expects. I'd better tell Stefan about
	this...

++ MIDI music. If I manage to find the MUS format somewhere I'll write a 
	converter to MIDI. If the conversion is fast enough to be done at runtime 
	that's the way to go. Otherwise I'll have to do it like GLDoom did: write 
	a separate,	temporary MIDI file.
  *** SOLVED: A runtime MUS player. Pretty Cool.

++ CD music. This is the third option in music playing (the other two being
	'no music' and 'midi'). Should be quite straightforward since can be done
	with MCI.
  *** DONE: Some additional testing might be good, though.

++ Remove the music handles from the I_* music routines.

++ Investigate the weird crashes that happened a while ago when exiting game
	from the demo. (If they can be repeated.) It's probably just Windows...
  *** Shouldn't happen any more now that Allegro's not around.

++ Pause key doesn't work. This is a WinAllegro bug.
  *** Actually it's a DirectInput bug. Sheesh. Let's use P for pause.

++ Joystick input. I don't understand how *anyone* could play these games with
	a joystick (apart from total beginners). Implementing this is surely a 
	piece of cake, though.
  *** And all the menus, too.

++ Fix cheat codes.
  *** SOLVED: Never were broken. :-)

++ Check the aspect ratio. Remember that the original version used 320x200.
	Should be implemented by scaling Z coordinates when rendering (x 1.2 in 
	screen resolutions with aspect of 1).
  *** SOLVED: Scaling the modelview matrix.

++ The failure of demo2 may be because of the new restrictions in looking and
	down. The mage's magic stick is dependent of aiming, you see.
  *** SOLVED: View pitch change speed is 5 again, and the limits are the 
	original ones, except for the upper limit, which is 110. This could break
	demos that look very much up, but it's unlikely.

++ Render only visible subsectors. Use 2D clipping ranges, full 360 degree 
	coverage.

++ Black fog in the distance? Investigate how the original engine did it. Come
	up with a better fog implementation than now.
  *** SOLVED: 2D lighting based on 2D distance. Closely resembles the original.

++ Minimize OpenGL state changes. What are display lists? Make sure this has
	an good impact on performance.
  *** SOLVED: Rendering lists. Now it's quite efficient.

++ See if the billboarding could be improved by making the sprites always yaw
	to the eye position, not the Z axis.
  *** SOLVED: Looks brilliant.

++ Correct rendering of polyobjs.

++ Patch origin coordinates are ignored in one-patch textures?
  *** I suppose so, unless it's a masked texture. No problems, though, so I'm
	going to forget about this.

++ Confirm that unpegged lower textures are rendered correctly.
  *** SOLVED: Now they are aligned with a corresponding middle texture.

++ Remove all obsolete code (e.g. the old low-level video routines, old data 
	arrays in memory, calls to functions that are now unneeded).
  *** The old rendering/seg/bsp/plane/sprite stuff is now gone. I guess there
	might be some useless code left but that'd require a bit more thorough
	examination.

++ See that objects hanging from the ceiling are positioned correctly (there
	may be need to lower them by 4, for example).
  *** SOLVED: Now sprites are only in the floor/ceiling when forced (not enough
	room).

++ Check out Palettized Textures. Should save quite a bit of texture memory...
  *** Would be nice, but it seems my TNT doesn't support them. I now know how
	to use the OpenGL extensions, so that's not a problem, either.    

++ OPTIMIZE everything you see. Check the algorithms. Looks at things 
	differently. A profiler would be a great help. I'm not even mentioning the
	impact an optimizing compiler would have (hopefully it'd be enormous...).
  Footnote: an optimizing compiler does have quite an effect. No more rendering
    slowdowns even in the most complex areas (read "castle of grief").
  *** I think the algorithms are quite fast. The compiler can take care of the
	rest. I should profile the renderer, though, to see if there are some 
	abnormally slow portions of code.

++ Check that patch->topoffset and patch->leftoffset are (not?) used in 
	rendering vissprites (this might explain the exploding-bottles-in-the-
	ground bug).
  *** Obsolete.
  
++ Remove seamlines of split up textures, if possible. Try half pixel shifts.
  *** SOLVED: Texture clamping plus one pixel to the left for the right 
	portion. The software renderer didn't show it correctly, but honestly:
	who cares?

++ Fix automap scrolling. Currently snapping to 320x200 pixels.
  *** Very smooth, now.

++ Automap background. Use a 256 x 256 portion of the default background 
	picture. Zooming also enabled. Do the math with the texture matrix.
  *** No zoom/scroll. I've had it with it. Now it's just there.

++ Are there extended flats? Their size would be 128x128, names beginning with
	X_. I remember seeing them in the end of the flat lumps.
  *** This is wrong information. The 'extended' flats are 8192 bytes long, and
	I don't see that they are any different from the normal flats.

++ Are there translucent middle textures, like windows? I don't think so, but
	it's worth a look.
  *** No, there aren't. I'm pretty certain of this -- I haven't checked, tho.

++ Make sure that 1024 clip nodes is enough (probably way too much, though).
	Pick a small amount that doesn't overflow. The ranges are merged pretty 
	well as they are added. I bet something like 128 ranges would be 
	sufficient.
  *** It's now 128. If it overflows during playtesting (when I get that	far) 
	I'll raise it to 256.

++ Fix keyboard input. It should register ALL keypresses, not just the ones 
	that are down/up in the beginning of a frame. I'll probably have to bypass
	WinAllegro's DirectInput keyboard handler, and write one of my own.
  *** DONE: Introducing Jake Tools Keyboard Handler! Just the bare bones 
	functionality. Pause doesn't work, but it's a DirectInput bug (Hmph!).

++ Make sure the music is shut down properly (BEFORE deleting the music data).
	Probably it's OK, but doesn't hurt to check.
  *** Now music is stopped (sound shutdown) first when quitting. This should be
	the best solution.

++ Lighting problems could be reduced by splitting long subsector edges. 
  *** The 'problems' really aren't that bad. You don't even notice them unless
	you specifically look for them. And the splitting would increase polycount.

++ Sky hemispheres. Finding the maximum performance and best visuals may be a
	bit difficult. Also remember the 'ceilings in the sky' problem. On the 
	average, though, this just means taking the current ceiling triangles and
	making a sky out of them. On the whole there'll only be fillrate problems
	with overdraw. Hopefully that can be kept to a minimum.

++ Try to find a solution for the improper BSP ordering when standing on a 
	partition line. Move off the line?
  *** Doesn't really make any difference. There are some inaccuracies with the
	automap, but that's of little concern. I guess the clipper could be more
	flexible when it comes to combining two *nearly* connected wall segments.

++ Make sure the large flats (size > 4096) are implemented correctly. Currently
	the large size is just ignored.
  *** SOLVED: I can't see any difference, and an X_* flat is used in Winnowing
	Hall, in the hidden room with the emerald key.

++ Make a graphical console. It'll be used for the startup, debug and other 
	info messages, and as a message log. The user can write commands in the
	console as well. (So it's a Quake-style console.) How about CON_Responder
	and CON_Drawer? During startup, the Hexen title picture would be nice. And
	the background is dimmed by at least .6 when the console is down. There's
	probably a nice flat I can use for doing the dimming interestingly. And the
	text size could be adjusted (by default something like 8x10 physical pixels
	in 640x480). I could have a weird, slight scale/rotate thing going on with 
	the console background (or not).
  *** Needs a bit more work.

++ Get rid of lookspring with mlook, please!
  *** SOLVED: Lookspring disabled if mouse look used in real play. In demos the
	lookspring works normally.

++ Be sure to change the default WAD from D:\Games\Hexen\Hexen.wad to just 
	Hexen.wad.

++ The finale.

++ Finish up with the console. The up scrolling should have a limit (count the
	lines), no commands are yet interpreted (use defaults) and the text is 
	acting awkwardly when the console is very small. Shift+keys aren't working.
  *** The console is in much better shape now. There are one or two little 
    things left, though. More cvars and ccmds are needed.

++ Graphics options menu. Mipmap types, sky hemisphere columns, etc.

++ Mana in the status bar (and in full screen).

++ Move the near clip distance as far as possible. This means walls shouldn't 
	disappear when standing right in front of them.
  *** It's quite OK.

++ Investigate what role pixel formats play in the horrible slowdowns.
  *** SOLVED: A new TNT driver fixed this. Did it? Well, an old Graphics 
   Blaster driver did.

++ Startup messages in a special startup screen (a la glDoom).
  *** Just needs a new text renderer.

++ Think about networking with DirectPlay. If only I could test it somehow...
	Well, I *can* test serial, modem and internet, too, I guess. Plug the 
	Monster somewhere, get a test machine #2?
  *** Networking is pretty much done with.
 
++ Previous commands in console with up arrow? Only if the console is made a 
	bit more useful...
  *** Done. Very handy.

++ See why the sky renderer has problems with large detail levels (>7).
  *** OpenGL driver bug. Problems with long triangle strips?

++ Fix sky rendering when two sky sectors are next to each other and the other
	one is lower. Use hexmiss and deadlock for testing.
  *** Done. There might be situations where the algorithm falls apart, but 
    deadlock and hexmiss work alright.

++ The current method of drawing the startup text is horrendously slow. The 
	correct approach would be to prepare a font texture (using a GDI font) and
	then write a function that prints text using the texture. This would be 
	lightning fast (more so than in the console), plus it'd allow scaling and 
	other nice features.
  *** Done. Startup is now much faster. Scaling is not officially supported, 
    though (no min or mag filters).

++ 'Visual cracking' fix to be based on the distance. Bigger changes far away
	where they are needed. Try to still reduce the cracking problem in map08.
	It's the fog that makes the cracks so easy to notice.
  *** Currently only done for ceilings and floors. Helps.

++ Screen shots (-ravpic and F1).

++ Dynamical light maps around luminous objects (no halos, though). Looks real
	good.

++ Fullscreen mana out of item usage icons' way (the winged skull!).

++ Key repeat. Has nothing to do with jtKey. The key event handler maintains a
	list of pressed-down keys (based on the keyup/down events). When a key has
	been kept down for some number of tics, the handler starts resending the
	key at certain intervals (ev_keyrepeat?).

++ Status bar downscaling. With high resolutions it's stupid to have a *huge*
	status bar. 
  *** 20 levels. I guess level 1 is a bit silly, though.

++ Voodoo has a problem with the small viewport. It seems SwapBuffers does 
	literally just what it says. The view borders are drawn only to the back 
	buffer. When swapping happens the front buffer becomes the back buffer. 
	When swapping is done again, there aren't any view borders. An ugly flicker
	will ensue. This means the view borders must be drawn twice.
  *** borderupd (border_update) controls continuous border updating.

++ Replace the texture coordinate normalization with texture matrices. No need
	to divide everything with texw and texh.
  *** No... and some OpenGL drivers might even have problems with texture 
	matrices. Wouldn't even be a performance gain.

++ Colored dynamic lights. Analyze the sprites to see which RGB factors to use.
  *** Looks real good.

++ Console command: quit.

++ Compiler optimizations + demos == problems. Global optimizations again?
  *** That was a bit tricky to fix. There also was a real bug from the original
	Hexen. Turning was being incorrectly packed into the demo file. It was 
	right-shifted, and evidently that's not so smart with signed values. Now
	it has a simple division and it works brilliantly. The rest of the problems
	were solved by disabling global optimizations for a couple of files.

++ Dynlights very often flicker up/down when seen for the first time. What's 
	causing this?
  *** You should *set* values before using them!

++ Why aren't the old savegames working? MSVC?
  *** Byte alignment problems. Now it's working like a dream.

++ The 'fade away' menu shouldn't be shown after viewing the info screens.

++ Mouselook activation key/mousebutton. Requires lookspring and other things. 
	Check out how Quake did it.
  *** Lookspring is enough. It's quite nice now.

++ Item hotkey config.

++ Change resolution at runtime (graphics submenu).

++ Check what little things could be wrong in jtSound. There are difficulties
	with Aureal and NT. Try to make it fully DX3 compatible. Hint: crash when
	a sound is played. Get rid of DSBLOCK_ENTIREBUFFER?
  *** That fixed the NT problem. But only now it's DX3 compatible.

++ Rewrite jtJoy to be DX3 compatible (like WinAllegro).
  *** Done. It's now done using the Multimedia System.

++ Mouse backstep button. (Daniel E. Cobos)

++ Option to only reverse mouse look. (Jan Pear)

++ Dynlights 'pop' visible in ceilings?
  *** The color of the dynlights was incorrectly chosen.

++ Enhance the breakup fix (dx and dy can be precalculated). Also put a limit
	on the magnitude of the fix. I don't want it to become an error.
  *** Done. It's a bit of a hack, but it works...

++ Default resolution in hexen.cfg.
  *** After a few hassles, it works.

++ The (+) key also does not enlarge the screen size even though the (-)
	key reduces it? (Ric B. Green)
  *** Right as it should be.

++ Hide mouse AFTER network init! (Marc Torres)

++ Make load/save menu centre automatically on the slot from/to which the game 
	was loaded/saved, as in Hexen II. (Dehumaniser)

++ Echo picked up items and puzzle/game messages to the console, so that you 
	can always view what you did later. (Dehumaniser)

++ Sprite color translation tables.
  *** ...are working perfectly.

++ 'Sky with no textures' option. (Igor V. Spiridonov)
  *** simplesky cvar.

++ In game WAD loading. A console command.
  *** Works now fully, it seems. You can even load the hexdd.wad without 
	problems. Then you can reset and load something else. Nice.

++ Check out numpad enter.

++ Do a scrupulous examination of the savegame writing (and reading) code. 
	There might be some byte alignment problems still left.
  *** No. It seems archiveNum may be wrong with the mobj targets.

++ Reset lookdir when starting a new level.

++ Demo buffer size as a parameter (not hardcoded 0x20000 bytes).
  *** Demo buffer resized on the fly.

++ Z_CheckHeap still complains about consecutive free blocks in the memory
	zone in some cases (with caldera) when reseting. Why is this such a bad 
	thing?
  *** Fixed the problem in W_UpdateCache(). Now the excess cache lumps are just
	freed.

++ Playstate not refreshed completely when NOT using the config file to load 
	the main wad???
  *** Fixed with the revised WAD system.

-- Spectator mode for playing demos!

-- Fix in-game timedemo.

-- Porkelator bug: mobjs with the same TID as the one who gets morphed vanish?

++ Quake-style key bindings: bind anything to a key: controls, ccmds, macros...

++ Break the executable into DLLs so some of them can be replaced (in mods).
	Might be a pretty hard thing to do... I have to investigate how Quake2 does
	it. It only has one DLL that contains the game logic (the exe has only the
	main engine core).
  *** Engine / Game. That's the split I'm using, and it's a good one IMHO.


--------
Graphics
--------

-- Status bar needn't to be rendered every frame, especially with the view
	borders visible. This isn't of paramount importance, though...

++ Tune SetVertexCol(). It should be as close as possible to the original. The
	torch effect shouldn't change the brightness depth so much (more stable, 
	please). I also seem to remember that the orientation of a wall affects it
	lighting (something like north-south walls being lighter?). Check if the 
	original wall lighting calculations include this.
  *** It's now close enough for me.

-- Find out why the hell are the psprites sometimes drawn in the wrong Y 
	position just after popping up or hiding the status bar. I suspect this has
	something to do with viewheight not being in sync with the actual viewport
	height.

++ Exponential fog might provide better results than linear, but is there any
	performance costs involved? This must be tested on the final, optimized 
	engine. Currently I'll stick with the linear fog. Anyway, it should be 
	thicker.
  *** Exp fog doesn't look good. The fog is now perfect (linear, darker, 
	thicker).

++ With non-square pixel aspect ratios (I guess) the viewport isn't positioned
	correctly when it's not full screen.
  *** This was because the window client area was too small. Now it's fine.

-- Support for multitexturing (especially helpful with the sky).

++ Some sprites could align fully with the view plane, not just yaw. Naturally
	monsters and trees and suchlike couldn't. Fireballs and other projectiles
	must do this!

-- Masked textures *should* be sorted with sprites. This requires some changes
	in the rendering architecture.

++ No huge (48) dynlights for very small luminous objects.
  *** Very good.

++ Ice shards/chunks partially transparent.

++ Ice shards, too much dynamic lights.
  *** The new colored lights fix this pretty nicely. If it still bothers 
	somebody, just think 'powerful magic...'

++ Translucent projectiles (some). Additive blending.
  *** sprblend.

-- MD2 models (as replacements for sprites).

++ Halos, using Z buffer?

++ Waving water?
  *** Ain't gonna do it.

++ Roof chandeliers and blastradius must be fullbright.

++ simplesky: normal quads.

-- mapcolors: to make the coloring like it used to be.

++ simplesky 2: no sky mask (no glColorMask called).

-- Fog sky layer one translucent? (Augusto Herrmann)

++ Clip flat dynlights to texture edges. No need to redraw the whole floor/
	ceiling for each light.
  *** The clipper should be fast enough, need to profile it yet, though.

++ Get rid of pushattrib in dynlight renderer.

++ Console variable for maximum number of dynamic lights.

-- Smooth alpha changes with MF_(ALT)SHADOW. Other smoothed out fx? (Ssabre)

++ Adjust dynamic lights and make them faster.

++ Dynamic lights to light up mobjs, too.

++ Align partially to view plane? (with Afrits)

++ Maxdl to drop lights based on distance.

++ Cvar to controls dlblend 1 'boldness' (color).

++ Spirit-weapon: ghosts luminous?

++ Vars and ccmd to modify the fog parameters (niceness, start, end, mode, 
	color, density).

-- Fade out disappearing flares in an Unreal-ish fashion.

-- Shadows, with subsector edge clipping?

-- Reflecting water (?) and ice (maybe...).

++ Paletted textures, again. I can test it with the Voodoo.


-----
Sound
-----

++ Make a sound code debug mode.
  *** Done, and already gotten rid of. :-)

++ Monster Sound MX300 sucks. Check out music, too.

++ Why are the sounds sometimes played WAY too quietly?
  *** I hope this is now fixed. It seemed that certain sounds weren't updated
	at all (all that originated from the listener), and this caused problems
	how?

++ CD playing code scrub-through.

-- Make i_mus.c use midi streams instead of commands.


----------
Networking
----------

++ Integrate jtNet inside the game so that there's a multiplayer menu. Might
	require new menu controls? Would allow in-game deathmatch lauching, and
	whatever.

++ Rehaul the network code: client/server system. This requires some planning.
	There might not even be a problem... I'd just need to send all the packets
	to the server who'd in turn send them to the other players. Both the server
	and the clients would do full simulation of game events, just like now: 
	only the ticcmds would be transmitted. Each client would only have to 
	converse with the host. The host *would* need to send all the ticcmds of
	all the players in the game *to each player*. Example: there are 10 
	players. The client sends one message to the host. The host sends back
	nine (9). The host in this case would be more like a router. If I ventured
	into the realm of total host control, the whole ticcmd system would have to
	be changed on the client side (!).

++ Player names (already it jtNet). (Dehumaniser)

++ Pick the color of your clothes'. (Dehumaniser) 

-- Reduce the size of ticcmd_t and doomdata_t. For example, chatchar can be 
	taken out. Also, try to merge some of the doomdata info bytes together.


--------
Gameplay
--------

++ Adjust aiming for true 3D. Demo considerations? Auto-aiming should take care
	of that, though. Only works in not-demo mode, of course.

++ Map cheat to show unseen places with different color. And fix mode 2. (SSabre)

++ Mousewheel support (e.g. to cycle weapons or artifacts). (SSabre)

++ Unite all controls into one array (keyboard, mouse, joystick). Requires 
	changes in the way they are checked for activity.
  *** I don't think this is practical, or useful.

-- Make "wings of wrath" carry over between hub changes? (SSabre)

++ Controls to change weapon to previous or next. This combined with the new
	united control mechanism should be nice.
  *** Done.

++ Look angle should change the behavior of Flechettes with the fighter (i.e.
	throw them up or down, not just out). (Ssabre)
  *** Don't like it, compromises too much. It wouldn't work in demos, anyway.

++ Hypostyle: Wyvern getting stuck?
  *** I don't think so...

-- Skill 6: super difficulty. (Ssabre)

-- Flying like in Quake: pressing forward makes you fly in the direction you're
	looking (not in demos).

++ Crosshair(s).

++ 'Choose and use' for the inventory.

++ Keylook speed change.


-------
Console
-------

++ Cheat in console.

++ Make an option to print a copy of everything that's shown in the console to
	a logfile.
  *** There's now the cvar 'consoleDump'.

++ More cvars and ccmds.

++ Real console commands for cheats (god, clip, etc.)

++ Script status queries in console.

++ Cvar for console alpha (and to lock the background on what it is when it
	loads... I really like that one) (SSabre)

++ Fade when going up (like Quake). (Ssabre)

++ Word completion with tab.

++ Ccmd 'Clear' to clear the text buffer.

-- Ccmd 'status', which lists together map, location, time, connection (if any)
	status and player name.

++ Ccmd 'suicide'.

-- There is a bug with drawing the text when the console is opened for the
	first time. It seems like a jumble of characters (they're on top of each 
	other?).


-----------
Performance
-----------

-- Profile the renderer to see whether everything is consistently fast.

-- Profile dynlights to see why they are so slow. It's the searching through
	all the subsectors, I'd imagine... *MAKE IT FASTER*.


-----------
Experiments
-----------

-- Replace FixedMul and FixedDiv2 with true inline C code and let the compiler 
	optimize it. Might affect performance? Not good? Well, the inline code is
	also preventing optimization...
