Duke Nukem 3D Code Review
fabiensanglard.net
fabiensanglard.net
https://github.com/fabiensanglard/chocolate_duke3D
[...] a port of the Vanilla source code with two goals in mind:
Education: Easy to read/understand and very portable.
Fidelity: The gaming experience should be similar to what ran in 1996 on our 486s.
And from the README: Aimed at education: A lot of comments and documentation has been added in order to help programmers to understand and learn.http://fabiensanglard.net/duke3d/chocolate_duke_nukem_3D.php
And that's just after reviewing their startup code!
Interestingly, I believe the code can be refactored. They have a great basis of code, but it needs a major reorganisation and a solid architectural overview and plan. It needs, in short, disciplined coding based solid OO practices.
In fact, I'd love to rip out the guts of the vcl into its own library, create a runner abstract class which you derive off of for each architecture they want to support. Better yet, they should find a good C++ IoC container and use this to plug in all their many components, including the UNO framework, which is actually very impressive.
To this end I'm strongly considering setting up a sequence diagram of the startup for the existing startup classes just to understand how they all work together. An interesting exercise at the very least :-)
And that's sensible, and very fair, given limited man-power :-) no to mention I'm doing what I'm attempting is a part time hobby!
http://wiki.openoffice.org/wiki/Documentation/DevGuide/OpenO...
Cool way to start a partnership!
I know (or think) the OP has another job/company now, but the idea of still diving into source code after leaving a technical job is a pretty cool pursuit -- especially with the intention of explaining it to the world.
I liked this vintage Carmack quote from Ken Silverman's website:
St. John: If you could just hire anybody from the 3D world, who would you hire?
Carmack: Well there's a big difference between who I consider the most talented and who I would necessarily hire, because you have to hire people that fit right. If I had to pick who I think is just the most talented, it would probably be Ken Silverman, the guy that did the BUILD engine. He does engines and tools. He's great as an editor. He writes all the code for everything, and he's just extremely talented. I think it was 3D Realms' worst decisions not to coddle him, or whatever it took, to keep him on board. I think if he was still working directly for 3D Realms, they would have a Quake-type game shipped by now, just because he's extraordinarily good. There's maybe a half dozen people that are top-notch A-level 3D programmers. I'm not going to give you a list because I'd leave somebody off and they'd be all pissed off at me.
St. John: You've already left off 90% of them by naming Ken Silverman.
Carmack: All the people doing things that people are talking about now are pretty talented. The Epic people have been working on it for a long time. They've gone through a big learning process, but they've got the issues under control and they're going to ship a product.
St. John: So you think one day Tim Sweeney might grow to be as successful as you.
Carmack: It's hard to become successful by following in footsteps. This is probably going to come out sounding demeaning, but Epic wants Unreal to be Quake. Everything they did with Unreal, they did because they wanted it to be like what Quake turned out to be. And they're going to achieve a lot of that, because they're doing a lot of things well, but you're just never as big when you're second in line.
Hook: Just like Dark Forces and Duke were both phenomenal games, they still definitely didn't have the impact of Doom simply because they just weren't first out the gate.
Carmack: Like Prey, there's a lesson to be learned, something a lot of companies don't really ever learn. You hear it from the fan base a lot. "Do it right. We'll still be here. We'll wait," and it's tempting to just let things slip. But that's really not OK. If you're doing something cutting edge, you're making fundamental decisions about your architecture, and if you let it slide for a year or two, then it's just not the right decision anymore. Even if you pile on all these extras, it's not optimal. It's not targeted at what you're doing. So I have some concerns about Prey coming out this late.
It's funny to see Carmack trash talking what Epic was doing with Unreal now, given the way history has unfolded. Tenacity, persistence, and consistency can outweigh the disadvantages of following an industry leader with a me-too product.
And for anyone else who eats this kind of thing up, David Kushner's Masters of Doom is a great read that I can't recommend highly enough.
p.s. I can definitely identify with running across popular commercial game codebases which are composed almost entirely by one source file.
Seems like he ended up quite depressed.
Still I am thankful to the world for him to exist.
If you're talking about how Epic does really well in the licencing space while Id does not, I believe that an intentional decision by Id to not compete in that space post Q3.
3D programmers for Android are probably on a combination of windows and linux. 3D programmers for iOS are no doubt coding away in Xcode. The new field of WebGL could have people coding 3d engines on Chromebooks. Etc.
There's not really any requirements for 3D development over any other development. All you need is a compiler that'll hit the platform you're developing for. Right now I'm just using vim and gcc (under Ubuntu), for Android dev, and it works great.
If you want to target consoles, you'll need the correct platform SDKs from the manufacturers. Lots of people I've worked with used VS for console dev, but I tended to stick with vim because I preferred it, and at the end of the day it's all just code going into a compiler.
http://fabiensanglard.net/duke3d/duke3d_code_review_unrolled...
For example, if you know that the iteration count is divisible by 4, you could do something like:
int unrolledN = n / 4;
for (int unrolledI = 0; unrolledI < unrolledN; unrolledI++) {
int i = unrolledI * 4;
// loop body...
i++;
// loop body...
i++;
// loop body...
i++;
// loop body...
}
This wouldn't really offer any advantage over the plain loop, though. Next you'd need to reorganize the loop body so that e.g. memory reads for all iterations would occur at the start of the unrolled loop. This kind of optimizations can offer significant performance increases because you get more control over what the CPU is doing within the loop, but they also depend greatly on the target platform. Even different x86 processors can be very different in this respect, so unrolling can become a disoptimization easily.In this case, I think he's replaced function calls with the body of those functions. For example, "displayrooms" is immediately followed by { } surrounding the contents of what "displayrooms" actually does: interpolate, animate, and so on. This means you can read just the one source file and know what's being executed, instead of having to read the source of displayrooms.c and various other source files separately.
Another common form of "unrolling" is repeating the body of a loop some number of times. See, for example, http://en.wikipedia.org/wiki/Duff%27s_device . Basically, by reducing the number of branches (and therefore potential pipeline flushes) you can decrease computation time.
Was this manually reverse-engineered or was a tool used?
.mov is acting like some kind of meta-file to point quicktime in the right direction. The only string in the file worth noting is the name of the actual video file with the .m4v extension. Maybe it's storing an IP address?
Honestly I'd rather not go through all of this, if he had used a modern standard I would of being able to scrub through the file locally.
Or if you'd rather watch outside the browser, see instructions above.
sadly does not work because they are not encoded well. So just use the following line to get the URLs and download them by hand. Substitute the page URL as needed.
curl -s http://fabiensanglard.net/duke3d/build_engine_internals.php | grep -Eo "http.\.mov"
This will fetch those:
curl -s http://fabiensanglard.net/duke3d/build_engine_internals.php | grep -Eo "http.*\.mov" |sed -e 's/\.mov/-desktop.m4v/' | xargs -n1 curl -O