重建的 Commander Keen 1-3 源代码
Reconstructed Commander Keen 1-3 Source Code

原始链接: https://pckf.com/viewtopic.php?t=18248

经过多年的努力,为庆祝《Commander Keen 1-3》游戏35周年,其完整源代码已公开发布。这包括从最早的1990年beta版本到鲜为人知的1.34版本,允许使用原始编译器(Turbo C++ 1.00/1.01和Turbo Assembler)创建逐位相同的可执行文件。 重建工作充满挑战,主要原因是需要特定的编译器版本。一个关键的障碍是精确地排列BSS段中的未初始化变量,这需要使用策略性命名的变量来影响编译器的输出。 有趣的是,此次发布揭示了《Keen》团队重用了他们之前在Softdisk公司的工作代码,特别是《The Catacomb》和《Hovertank》中发现的例程,这可能导致版权问题。证据表明,《Dangerous Dave》的代码也被利用。 现在,源代码可供爱好者探索和修改,为这款经典DOS游戏的起源提供了一个引人入胜的视角。

## Commander Keen 源代码重建与法律讨论 Commander Keen 1-3 的源代码重建版已发布 (pckf.com),引发了 Hacker News 的讨论。该项目是“匹配反编译”——它不包含原始资源,但重建了代码,并需要用户现有的游戏文件。 一个关键的争论围绕着发布反编译代码的合法性,特别是关于版权和原始权利人(如 id Software/Apogee)可能发起的删除请求。一些人认为反编译是一个法律灰色地带,而另一些人则指出版权法,认为这类似于缺乏足够创意投入的翻译。 历史背景也被提及,指出 id Software 早期代码重用的做法(可能源于他们 Softdisk 时期)以及游走在法律边缘的行为。 讨论还涉及了人们对知识产权态度的演变,从破解游戏以解放的“自由软件”精神,到目前对所有权的高度关注。 最后,用户指出该项目可能使相关项目(如 Commander Genius)受益,并与 Mister AO486 核心兼容。
相关文章

原文
It's not quite Christmas time yet, but since these are the days of Keen's 35th anniversary, I thought it was a good opportunity to finally release this to the public:

Reconstructed Commander Keen 1-3 Source Code :birthday

This package contains full source code for all versions of Keen 1-3 that I know, from the November 1990 beta version of Keen 1 to the relatively obscure Precision Software Applications release (version 1.34). Compiling the source code with the correct compiler and assembler versions and compressing the resulting executables with LZEXE or PKLITE (if necessary) generates executables that are 100% identical to the original files.

You will need Turbo C++ 1.00 (not 1.01!) and Turbo Assembler (2.0 or above) to compile exact copies of most versions of Keen 1-3 (versions 1.31 and earlier). The later special releases (the "pre-registered" Gravis version 1.32 and the PSA release version 1.34) require Borland C++ 2.0 for a fully identical copy.

---

If you have read the timeline.txt file I released along with my Reconstructed BioMenace Source Code last year, you might have noticed an entry that said "got side-tracked revisiting another old project". This is that project.

Most of the Keen 1-3 code reconstruction was done back in early 2021, before I started preparing my reconstructed Keen 4-6 source code for release. The big problem that prevented me from getting my Keen 1-3 code to compile and compress into 100% identical copies of the original executables was the fact that I didn't have access to the right compiler back then. I only had Turbo C++ 1.01, which generates slightly different code than Turbo C++ 1.00. It was impossible to get Turbo C++ 1.01 to produce the code that I needed.

Another contributing factor is that the order of the uninitialized variables in the so-called BSS segment depends on the names of the variables when using Turbo C++ 1.x to compile the code. And since some of these variables need to be accessed from within the assembly code, I couldn't simply group the variables into a struct like I did elsewhere. I had to find names that would allow the variables to appear in the correct order. So after some trial and error, I wrote a small throw-away program that generated a bunch of variables with random names and ran that list of variables through the Turbo C++ compiler. Disassembling the generated .OBJ file showed me which order these variable names would produce, so all I had left to do was to let the compiler (and the assembler) rename the variables internally. This is done in the BSSCHEAT.H and BSSCHEAT.EQU files.

A word of advice for those attempting to use a similar trick to modify the order of the variables in the BSS segment: If two names produce the same hash value for whatever hash function the compiler uses, the order of the variable declarations can have an effect on the order of the variables in the generated code. This includes "extern" declarations as well, not just the actual declaration of the variable. One way to detect hash collisions in a list of randomly generated variable names would be to reverse the order of the variables and compile the file again. If the order of certain names changes after that, those names have the same hash values and you are probably better off using only one of those names to avoid having to move (extern) declarations around to get the result you want.

---

If you check out IDLIB.C and IDLIB.ASM, you will see that I based the code in these files on The Catacomb and Hovertank. This is the code that got the team in trouble. They used the same routines they wrote for their day jobs at Softdisk in the Keen code. No matter what those old letters posted by Scott Miller said, the boys were in serious trouble.

Most of the IDLIB.C code must have come directly from the PC version of Dangerous Dave. I don't think the Dave source code has been released to the public, so you'll just have to take my word for it. But there is some extremely strong evidence showing that the id founders used Softdisk's code in their own game. Sure, it's not the code responsible for the smooth scrolling, but it is code they probably didn't have the rights to use.

---

That's all for now. Have fun messing with the code.

联系我们 contact @ memedata.com