Chocolate Keen (a "port" of Commander Keen 1-3)

Tools, assembly, and file formats.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

So many changes, I have to keep transferring over my saved games. I'm going to wait now, in case further improvements occur in quick succession.
NY00123
Posts: 85
Joined: Thu Sep 24, 2009 8:03 am

Post by NY00123 »

levellass wrote:So many changes, I have to keep transferring over my saved games. I'm going to wait now, in case further improvements occur in quick succession.
Assuming there are no bugs, all you need to do is replace the Chocolate Doom1 executable file. This "port" aims to be compatible with vanilla Keen1 saved game files (as well as other files like SCORES.CK1). That is one way in which it is similar to the "Chocolate Doom" source port.
If you wish, you can have a little test of saving on vanilla Keen1 and then loading it in the "port" (or vice-versa).
NY00123
Posts: 85
Joined: Thu Sep 24, 2009 8:03 am

Post by NY00123 »

Here is the last update, bringing us to what I call a Beta release of 0.6.0. At this stage, there may still be a few bugs related to accuracy, more kinds of inaccuracy that can be improved, places where the improve may be improved and/or the CPU power usage can be lowered, and more.
However, I think that it is now a feature-complete "port" of the unmodified vanilla Keen 1 v1.31, or at least of stuff actually used by it. If something is never done by unmodified vanilla Keen, there are great chances it is not ported.

A minor note about joystick support: Apart from the limitations described in the change log, I'd say that in the calibration process, there are chances that you do not need to reposition the pad/stick at all. Just leave it on the center and press on what is considered to be the "first button" twice.

*** See the first post in this thread in order to find download links for the last release.

Changelog

November 23rd, 2012 (v0.6.0):
In terms of simulating Commander Keen 1 v1.31, this should be a feature-complete release (ignoring a few potential issues).
- It is now considered a "Beta" release (rather than "Alpha"), since it has probably been relatively stable for a while.
- Basic 80-column text mode emulation is implemented! This is used for a little while when Keen 1 is loaded, as well as for the textual contents seen when quitting vanilla Keen 1.
- The command line arguments can now be shown by Chocolate Keen1 itself on ALL platforms, taking advantage of the text mode emulation. Hence, at least for now these have been removed from the README file, since any update to the arguments may easily be missed anyway...
- The command line argument -ega has been renamed to -egacga and it now does more things than changing the emulated video card's refresh rate. Among these, a larger overscan area is used on the 200-line graphics mode (as observed with an actual EGA). The text mode has also got a 200-line height in pixels (which is compatible with CGA monitors). Somehow, the fact that the observed behavior does not correspond to the EGA when configured to work with an EGA monitor has been spotted just a little before releasing this version... At least, though, things like the overscan dimensions should be similar.
By default, plain VGA behavior is emulated (combined with a VGA monitor).
- A dummy /K (or /k) argument has been added. On vanilla Keen 1 it is used to solve keyboard-related issues on some BIOS variants, while on Chocolate Keen 1 it simply adds a message on the very first few milliseconds of loading.
- Workaround for OpenGL glitches has been removed, since it can't be used now as-is with the changes between text and graphics modes. Well, almost. It is still in use when just toggling fullscreen mode, although it may not help as much as it has before.
- Vanilla-style joystick support is implemented. Note that there are VERY great chances that you wouldn't like the way it works, since it currently determines which pair of game controller buttons will be used, as well as a pair of axes. Oh, and the joystick needs to be calibrated, just like on vanilla Keen 1. The game-port way of game controllers was very problematic anyway... Ah, one more thing:
- OK, a minor bug dating back to the beginning of the game "porting" process has been fixed. What it implies now is that the controller type to use is reset to the keyboard whenever Chocolate Keen1 is loaded. This is also the behavior of vanilla Keen1. Maybe it was done on purpose due to the great issues with joysticks back then...
- Another such bug: Now after the F3 key is pressed to reconfigure the keys, the keyboard is what is used for input (if joystick has just been used). Note that this is the vanilla behavior, and the bug was that the joystick would still be in use afterwards. Truly, it hasn't had a great impact beforehand...
- The sound sample rate used internally can now be set from the command line, using the -srate argument. The current default is now 48000Hz, while before the release of the current version it has been 44100Hz.
An example for a command:
chocolate_keen1 -srate 44100
- With a few exceptions, stdint.h is used now for numeric types of specific sizes (such as uint16_t), rather than types defined by SDL (like Uint16). While there should really be no reason to abandon SDL, it is still better to avoid the usage of some stuff not directly related to SDL, if it can be done.
- Oops... the exe name is "chocolate_keen1" now, not "chocolate-keen1"! Corrected a few references mentioning the latter one.
- There are some more changes on the technical side.
Last edited by NY00123 on Fri Jul 05, 2013 9:09 pm, edited 1 time in total.
lemm
Posts: 554
Joined: Sun Jul 05, 2009 12:32 pm

Post by lemm »

Is it just me, or does keyboard button 2 refused to be redefined? After I change it to another key, the new key appears, but when I close the F3 menu and open it back up again, it has changed back to ALT.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

It's not just you (or me!) then. Uh, yay?
User avatar
doomjedi
Posts: 341
Joined: Mon Jun 11, 2007 4:30 pm
Location: Israel

Post by doomjedi »

Tried it, it's so fun. Very good and faithful Keen emulation(?).

But why is upper helmet pixel line of Keen dissapears when he is with pogo in the air?
Nospike
Posts: 160
Joined: Fri Apr 23, 2010 1:54 pm
Location: Some cool place, idk

Post by Nospike »

doomjedi wrote:Tried it, it's so fun. Very good and faithful Keen emulation(?).

But why is upper helmet pixel line of Keen dissapears when he is with pogo in the air?
Because the sprite bitmap is too low for the line to fit in. It also happens in the original Keens 1-3.
User avatar
doomjedi
Posts: 341
Joined: Mon Jun 11, 2007 4:30 pm
Location: Israel

Post by doomjedi »

Hm, interesting, never noticed that, and I've played alot of Keen 1.
Here it really stood out right away....strange...but I'm sure you're know this for sure...so it's just weird...but true, I guess.

I can check this myself rather easy :)
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Does this have the pogo-ceiling bug in it too?
NY00123
Posts: 85
Joined: Thu Sep 24, 2009 8:03 am

Post by NY00123 »

Well, I'm surprised to see some recent posts within this thread, in *these* forums!

Thanks for trying this "port"!
lemm wrote:Is it just me, or does keyboard button 2 refused to be redefined? After I change it to another key, the new key appears, but when I close the F3 menu and open it back up again, it has changed back to ALT.
Whoops. Behind the scenes it's about the whole difference between '==' and '=' in C/C++...
levellass wrote:Does this have the pogo-ceiling bug in it too?
If you refer to Keen getting into a ceiling right from below it while jumping with the pogo, possibly using the G-O-D cheat, then I recall encountering that once in Chocolate Keen1, yeah.
lemm
Posts: 554
Joined: Sun Jul 05, 2009 12:32 pm

Post by lemm »

After a little under two weeks of work, support for episode 2 has been added; hence, the project has now been renamed to "Chocolate Keen." This was a collaborative work between ny00123 and myself.

You will need Keen 2 v1.31 to play. If you are downloading the Windows binary package, simply copy chocolate_keen2.exe into an existing Keen 2 directory and play. Also note that chocolate_keen1.exe has been revised. See the first post in this thread to find download links for the last release.

Enjoy!




Changelog

April 11th, 2013 (v0.7.0):
Thanks to Lemm, Commander Keen 2 v1.31 is now supported!
- As a consequence, the project has been renamed "Chocolate Keen" (as a
substitute for the name of... "Chocolate Keen1").
- Technically, the code has been restructured so Keen 2 support can be added.
More restructuring may be done later.
- Some more changes have been applied, mainly to the code layout.
- A few timing related modifications have been applied, done for a hopefully
better accuracy among more platforms. There is still more to improve, though.
For instance, sometime after activating a Tantalus ray it may be impossible to
toggle on/off fullscreen mode for a little while.
- A buffer overflow has been fixed, where the high scores table is displayed.
Actually, it MAY still be produced - if there is a score of 1,000,000,000 or
more... however, it is apparently a problem even on vanilla Keen.
- Fixed drawing of masked tiles. (These weren't really revealed on Keen 1,
while they are much clearer on Keen 2.)
- Fixed a bug in the bridge code (again mostly noticeable on Keen 2).
- An alternative keyboard key chosen for the pogo is actually being set now.
- A few more fixes, here and there.
- There are also (very) minor edits to the changelog within the README file.
Last edited by lemm on Mon Jul 29, 2013 11:11 am, edited 1 time in total.
User avatar
doomjedi
Posts: 341
Joined: Mon Jun 11, 2007 4:30 pm
Location: Israel

Post by doomjedi »

Keep it up, guys! Great work!
NY00123
Posts: 85
Joined: Thu Sep 24, 2009 8:03 am

Post by NY00123 »

Thanks to Lemm's assistance yet again, Chocolate Keen supports the whole Invasion of the Vorticons trilogy now!
Technically, there are some more changes. See the change log for details.

To play Keen 2 or 3 you need a copy of the desired game. Version 1.31 is supported. Note that while it may get reverted later, a single unified chocolate_keen.exe file is bundled supporting all three episodes beginning with this version.

*** See the first post in this thread in order to find download links for the last release.

Changelog

May 12th, 2013 (v0.8.0):
In a similar fashion to what has recently been done for v0.7.0, support for
Commander Keen 3 v1.31 is now built-in! As a result, Chocolate Keen has full
support for the Invasion of the Vorticons trilogy.
- Even before the addition of Keen 3 support, some more code restructuring has
been added in regards to multiple episode support (and possibly more).
- An example for an experimental decision out of this restructuring:
For now a single executable is used, supporting all episodes. It is still
possible to compile one per episode. Maybe it will be the default setup again
later, similarly to the situation with the source codes for Wolfenstein 3D and
various source ports of it. For now, though, it is not the case.
- An icon is now set for the Chocolate Keen applications. Thanks to Lemm for
suggesting the chocolate bar!
- A few changes have been applied in regards to the timing yet again. As a side
note, it worths to mention that (also applying to earlier releases),
if Chocolate Keen is being run for sufficiently long (let's hope it implies,
say, 12 hours at least), then there IS the possible risk of a timing overflow
glitch occurring at some point. Not sure there's an easy way to take care of
that. Maybe such a way will be found at some point, though.
- A new command line argument has been added: "-uselastinputdevice". On vanilla
Keen 1-3, if you setup a joystick within the game (including calibration), use
it for a bit, quit the application and then restart it, keyboard input will be
forced. Since Chocolate Keen aims to act like vanilla Keen, by default it does
the same thing. With the above argument it will rather use the last selected
input device stored in the CTLPANEL file, if it is found.
- In what may seem to be a controversial decision, the (host) mouse cursor is
now LOCKED in the application's window by default, when fullscreen is toggled
on. To release, use the key combination Ctrl+F10 (also the default in DOSBox
for the same functionality). This works for a non-fullscreen window as well.
You may further (re)lock the cursor by clicking on the window or using the
key combination Ctrl+F10 (again as usually done in DOSBox).
There are a few reasons for doing this. A later point may describe one of them.
- A new "-nocursorlock" argument has been added. When passed to Chocolate Keen,
the mouse cursor will NOT be locked on startup, nor when toggling fullscreen
on/off. As usual it can be locked using the Ctrl+F10 key combo or by clicking
on the window.
- Another related argument, "-alwayshidecursor", has further been added. If one
wants the mouse cursor to not appear in the application's window even while it
is unlocked, this can be used.
- For convenience and/or a case of emergency, the keyboard combination
Ctrl+F9 (again familiar for DOSBox users) can be used for shutting down
Chocolate Keen now.
- A bit of an obscure fact: The vanilla Keen 1-3 executables do contain some
code for (possibly not-comfortable-to-use) mouse input. It might be a variation
of the code from the PC version of Dangerous Dave. While it is possible to
manually edit the CTLPANEL file to use a mouse as the input device,
keyboard input is always forced on startup as mentioned above. Now, however,
Chocolate Keen has the -uselastinputdevice argument. So, similar mouse
support has been implemented. Chances are you wouldn't like to use it every
day, though, so no special command line argument has been added for enabling
the mouse. If you want it, open the CTLPANEL file with a hex editor and set
bytes 4-5 (counting from 0) to the values of 01 00 (i.e. the Little Endian
16-bit value of 1). Afterwards, load Chocolate Keen with -uselastinputdevice.
- It should be noted that, while not commonly used by a single individual,
a secondary game controller can also be used now, again with the help
of -uselastinputdevice. A simple change of the controller type (to 3)
in the CTLPANEL file is possibly not sufficient, though, as a few
calibration-related values should be set. Furthermore, the secondary
controller's buttons can NOT be used to halt the discussion during the
encounter with the Grand Intellect in Keen 3 (which IS vanilla behavior).
- Chocolate Keen can now be compiled in a different "mode" for debugging.
Basically, using the current Makefile, when running an executable built with
something like "make DEBUG=1", the mouse cursor is NEVER locked. Furthermore,
in such a case the cursor is ALWAYS displayed, unless -alwayshidecursor is
added as an argument. The usual cursor lock toggle still works as a toggle for
using the mouse in-game at all, though.
- Fixed a bug or two in regards to joystick support.
- More bug fixes, here and there.
Last edited by NY00123 on Fri Jul 05, 2013 9:11 pm, edited 1 time in total.
NY00123
Posts: 85
Joined: Thu Sep 24, 2009 8:03 am

Post by NY00123 »

After *some* delay with releasing this, well, an update is up. This adds basic control mapping capabilities (say, for simulating keyboard actions in the game while really using a dedicated game controller). Yeah, it may be far from being, er, user-friendly. But, at least the option is there. Furthermore, in an experimental fashion SDL 2.0 can be used if desired. Note that there may be some problems with that, since SDL 2.0 is currently in the "Release Candidate" stage.

*** See the first post in this thread in order to find download links for the last release.

Changelog

June 22nd, 2013 (v0.8.2):
- The Chocolate Keen executable name (with no extension or episode number) has
been renamed chocolate-keen, i.e. a minus sign is used as a separator rather
than an underscore. This seems to be more commonly used in one environment and
also corresponds with the executable name of the Chocolate Doom source port.
- Currently experimental feature: Chocolate Keen can target SDL 2.0 now, in
addition to SDL 1.2 as before. Note that while SDL 2.0 is almost ready for an
official release, it is still in the stage of a "Release Candidate" as of now
and some problems are expected.
- While -overlay is *not* available when targeting SDL 2.0, a new -texture
argument has been added. Two more SDL 2.0 related arguments added are -renderer
(to be used with -texture) and -displaynum (currently untested).
- In the SDL 2.0 case, -texture is the default. Otherwise it is -opengl, unless
GL support is disabled in the executable, where -overlay is the default.
- DOSBox-style input mapping has been implemented, with current values saved
using Ctrl+F8. For the ones who want to take advantage of a game controller,
either out of preference or simply since there's no nearby keyboard, this
can be used to map controller buttons to emulated (102-key QWERTY layout)
keyboard keys.
- Note that while the mapper file format may be similar to the one used by the
DOSBox emulator, it is NOT identical. (!)
- Some code handling (emulated) pause key in a special manner has been removed
for now, as it often, well, hasn't done its job.
- Windowed and fullscreen resolutions are now separated: When -surface is *not*
used, these can be specified with -windowres and -fullres, respectively.
- As a consequence, these black bars known for aspect correction are no longer
shown while displaying a non-full window. Basically, when specific window
dimensions are chosen with -windowres, one can think of such imaginary bars
getting removed from the window.
- As a new default, the window resolution is (in each dimension) a specific
ratio of the desktop resolution now (imaginary bars included). Guess which...
- On a relevant note, there are chances that -surface, combined with fullscreen
and SDL 2.0, is going to fail, due to a failure to set a specific screen
resolution. In that case, "-texture -renderer software" can be used for
software rendering with nearest neighbor interpolation for scaling.
- Windows OS specific: US keyboard layout is now forced for the Chocolate Keen
application. Among other things AltGr should behave like Right Alt, rather than
Ctrl+LAlt. Thanks to Tesseract for reporting, along with helpful assistance!
NY00123
Posts: 85
Joined: Thu Sep 24, 2009 8:03 am

Post by NY00123 »

This is a notification of a "clean up" release, marked as "Alpha" again. The reason: Porting to C (from C++). Ones may think of it as "porting back", since it is almost surely the case that the game was originally written in C (along with some x86 Assembly code).

As a side effect, this has seemed to shrink the executable file size! While not the original motivation behind this (as strange as it sounds), it's nice to see it happening.

*** See the first post in this thread to find download links for the last release.

Changelog

July 5th, 2013 (v0.8.3):
- The codebase has been migrated to C (to be more specific C99). This may be
the cause of instabilities, so you have been warned. Note that it is still
possible to build an executable using a C++ compiler (as C++ code).
Furthermore, as an interesting consequence this migration has seemed to reduce
the executable file size. For instance, mingw-w64 has constructed an executable
of size 200704 bytes for v0.8.2, compared to 174592 bytes for v0.8.3.
Furthermore, the executable constructed by mingw-w64 as C++ code requires a few
additional dependencies as shared libraries (libgcc_s and libstdc++). In fact,
for that exact reason the original MinGW has been used so far. If you check the
executable as found in the v0.8.2 ZIP archive file, its size is even larger
(283648 bytes). That may be the case due to some additional code required for
C++ support as an alternative to functionalities loaded from such libraries.
- A minor fix (if not more) regarding the input mapper has been integrated.
- Some fixes regarding SDL 2.0 fullscreen handling have similarly been applied.
Furthermore, in case SDL 2.0 is used, Chocolate Keen should be ready for the
possibly of external fullscreen window resizes (tested with the Unity shell).
- So far, the game's visual contents have filled the screen with aspect
correction by default, unless "-surface" has been specified. This has changed
and software scaling is used for that now (again if "-surface" is specified).
- More generally, some changes have been applied regarding the command line
arguments and scaling. To summarize, one can say that "-scale" has been renamed
to "-scalef", "-noaspect" has been replaced with "-scalet" and a new optional
command line argument identified by "-forcecutfullscreen" has been added. For
more details, as usual one can type something like this: "chocolate-keen -?".
Post Reply