Modernizing the Wolfenstein 3D Fizzlefade Algorithm (2017)
jacopretorius.net
jacopretorius.net
It was previously used in the commander keen series and was in great part to credit to their success because for the first time on PC a game was matching console graphical quality. It has square pixels. IIRC Carmack improved on the mode X and him and Michael started a correspondance.
Who knew such a great story was behind such a tiny mistake: nothing less than the advent of games on PC.
[0] http://archive.gamedev.net/archive/reference/articles/articl...
On the then-ubiquitous 4:3 resolution monitors.
(Made this addition because on first reading, I wondered why square pixels would occur on anything but 320x320 resolution)
2 All Commander Keen game were EGA, with some having additional CGA mode.
3 Carmack didnt improve modeX, he hired Abrash to help with optimizing Doom. As a result Doom ended up with the stupid modeY (variation of modeX) which was a wash performance wise on slow 486, while tanking performance on faster processors. https://github.com/viti95/FastDoom switching original Doom sourcecode back to mode 13h (or even better VESA 320x200) results in substantial to huge performance improvements.
A) Mode 13h has not enough ram to have 2 pages, so either you get screen flicker as you see Doom draw, or you loose 64k ram for an offscreen buffer, and the extra data transfer also takes time.
B) The core of ModeX/ModeY is disabling the chain4 mechanism and manually dispatching bytes to the 4 planes. The cost of this is some 'out' instructions, I assume 1 group per vertical slice. I don't know how doom did floors here, maybe draw them 4 times?. Even so, the cost seems not that expensive.
https://www.youtube.com/watch?v=ujXrQVyl610
8-bit accesses only, this alone tanks performance for faster VGA cards. The second problem is slow plane switching in some implementations, especially later cards didnt bother optimizing this.
When you write to VGA (ISA in general) CPU is paused for the duration of the transfer. Switching back to 13h and rendering to RAM buffer benefits from motherboard cache and lets you actually use whole bandwidth when copying to the card (rep movsd). Typical 8-Bit VGA write bw is between 700KB/s for very bad Trident up to almost 2000KB/s for ET4000. At the same time fast 386 will do >20MB/s cache writes and extremely fast VGA on overclocked ISA bus can do 7MB/s. Heretic performance is higher compared to Doom because Raven dropped modeY.
Fastdoom:
Cyrix MediaGX https://www.youtube.com/watch?v=3PAfvDsmzVY 24 vs 64 fps
and extreme case of very bad modeY handling by Rendition Verite https://www.youtube.com/watch?v=6unNuPympE4 modeY 14, 13h 60, VBE2 300 fps
The semi translucent spectres causing VGA reads were very bad on that machine, causing <5FPS if there were multiple on screen. I learned to shoot them on sight and from a distance.
Autocomplete barely existed back then, and was something performed by purpose-built TSRs that maintained their own text expansion dictionaries, rather than a thing your text editor automatically did by scanning the current file for things you might be trying to type. "r a n d o m shift - v a l u e" is a lot more to type by hand than "r n d v a l".
And even if you did have that you'd still have to deal with coding on a textmode screen that was probably 80x50 characters. Maybe 132x60 if you had a really top-of-the-line video card. Not much room for those long variable names.
(Admittedly the C code under discussion was written long after the original assembly routine was written, but by someone who'd spent a lot of time with his head in the source of these games, absorbing the idioms of early-nineties programming.)
#define FIRST_BIT (uint32_t)(0x00001)
least_significant_bit = random_value & FIRST_BIT;
if (least_significant_bit) {
how is that more readable?