EModKeen 3 thread

ModKeen mods Tiles and Sprites in all episodes of Commander Keen.
User avatar
Shadow Master
Posts: 129
Joined: Fri Oct 20, 2006 3:14 pm
Location: Santiago, Chile
Contact:

EModKeen 3 thread

Post by Shadow Master » Mon May 28, 2007 5:20 pm

I decided to start a new thread in order to clarify the difference between LModKeen/EModKeen 2.x development and EModKeen 3 development.

I've uploaded the source code (NOTE: no binaries) for the latest Alpha tree. Thanks grafix for hosting. This version is EModKeen 3 alpha 2, it features a brand-new directory tree and C++ ports of huff.c and pconio.c (now it's Multicon.cpp, my own console functions wrapper library for Win32 and ncurses).

You MUST NOT try to compile it. It simply won't. Believe me, it's intentionally broken, because I haven't had time to fulfill some parts of the new code structure, etc.

Most notably, I separated all the game data routines to approximately 6 files.

The latest source code can be downloaded here: http://shadowm.rewound.net/src/emodkeen ... en3.tar.gz

Again, I mention that it's not supposed to compile/run in your system. It's just a reference release (mostly released to ensure you know I'm still active and coding).

Have fun reading this masterpiece (no, not really)!

levellass
Posts: 2895
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass » Wed May 30, 2007 5:17 pm

Hmmmn, exceedingly confusing (To me anyway.) but potentially greatly useful, I'm rubbing my hands in anticipation.

levellass
Posts: 2895
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass » Tue Nov 06, 2007 4:00 pm

Hello, it's me again. I was just wondering whether it is possible for EModKeen to import more than the usual number of tiles into Keen? It seems that at present it simply uses the 'default' amount of bitmap, ignoring anything that comes after that, but it appears extra tiles can be inserted into Keen, and certainly it's easy to add them to levels using alteration in the GFXINFOE.CKX files for Ted5.

User avatar
Shadow Master
Posts: 129
Joined: Fri Oct 20, 2006 3:14 pm
Location: Santiago, Chile
Contact:

Post by Shadow Master » Wed Nov 07, 2007 4:35 pm

levellass wrote:Hello, it's me again. I was just wondering whether it is possible for EModKeen to import more than the usual number of tiles into Keen? It seems that at present it simply uses the 'default' amount of bitmap, ignoring anything that comes after that, but it appears extra tiles can be inserted into Keen, and certainly it's easy to add them to levels using alteration in the GFXINFOE.CKX files for Ted5.
It is?

I don't know, I would have to get my hands back at this, and try to simulate what LL did for Keen 1-3 Modkeen with Keen 4-6. It sounds interesting, but based on Ceilick's Keen 4 mod, that had the same tileset size as the original Keen 4, my best guess is that it would quickly cause OoM (Out-of-Memory) error in KEEN4E's engine.

levellass
Posts: 2895
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass » Thu Nov 08, 2007 3:40 am

Well, the main problem you'll encounter is that new tiles will have no tile information for them, they'll all be do nothing, be nothing, et cetera. This part of the problem will be very difficult to solve as it would involve expanding the tileinfo space.

Fortunately, most tiles in Keen are background or do nothing tiles, they don't *need* tile info and so can be added without any problems. For example, try opening your GFXINFOE.CK4 file and changing $04 from $0 $05 to $22 $05 ($510 background tiles expanded to $522) You'll now be able to add the first row of your foreground tiles to the background of Keen. (The colors are off due to rgb sifting.) Keen will accept these tiles, and indeed any foreground tiles into the background layer without a hitch, all with just two bytes of editing.

The real task is to find a way to add tiles to the masked and unmasked sections of Keen's graphics, and though I have made progress with this, it is slow.

The relevant parts of GFXINFOE.CKX are bytes $4-$7 and $10-$13 which store the number of unmasked and masked 16X16 tiles followed by their offsets. (Thanks Andy!)

User avatar
Shadow Master
Posts: 129
Joined: Fri Oct 20, 2006 3:14 pm
Location: Santiago, Chile
Contact:

Post by Shadow Master » Thu Nov 08, 2007 12:48 pm

levellass wrote:Well, the main problem you'll encounter is that new tiles will have no tile information for them, they'll all be do nothing, be nothing, et cetera. This part of the problem will be very difficult to solve as it would involve expanding the tileinfo space.
And that would involve CK Guy's extending Ck456Tli, and we to find a way to modify the load address of the tileinfo data, to be in an external file and not the EXE. Probably impossible.
Fortunately, most tiles in Keen are background or do nothing tiles, they don't *need* tile info and so can be added without any problems. For example, try opening your GFXINFOE.CK4 file and changing $04 from $0 $05 to $22 $05 ($510 background tiles expanded to $522) You'll now be able to add the first row of your foreground tiles to the background of Keen. (The colors are off due to rgb sifting.) Keen will accept these tiles, and indeed any foreground tiles into the background layer without a hitch, all with just two bytes of editing.

The real task is to find a way to add tiles to the masked and unmasked sections of Keen's graphics, and though I have made progress with this, it is slow.

The relevant parts of GFXINFOE.CKX are bytes $4-$7 and $10-$13 which store the number of unmasked and masked 16X16 tiles followed by their offsets. (Thanks Andy!)
I'll write down that.

User avatar
ckguy
Posts: 464
Joined: Tue Oct 14, 2003 11:20 am
Location: Providence, RI, US
Contact:

Post by ckguy » Thu Nov 08, 2007 7:39 pm

If people figure out how to have more tiles, I will very happily extend Ck456Tli.

levellass
Posts: 2895
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass » Sat Nov 10, 2007 1:36 pm

As I said, there's no pressing need as long as you just want extra background tiles, but I'll see if I can do something.

User avatar
ckguy
Posts: 464
Joined: Tue Oct 14, 2003 11:20 am
Location: Providence, RI, US
Contact:

Post by ckguy » Sat Nov 10, 2007 4:31 pm

Feature request/suggestion:

Extract the "COMMANDER" and "KEEN" images used during the opening credits. I figured out the format here last December, and then failed to publish any sort of importer/exporter.

levellass
Posts: 2895
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass » Sun Nov 11, 2007 1:32 am

I second this request; that is almost the only bit of Keen data that we cannot as yet edit. Well spotted CK Guy.

User avatar
Shadow Master
Posts: 129
Joined: Fri Oct 20, 2006 3:14 pm
Location: Santiago, Chile
Contact:

Post by Shadow Master » Mon Nov 12, 2007 6:35 pm

levellass wrote:As I said, there's no pressing need as long as you just want extra background tiles, but I'll see if I can do something.
Forgot to mention: aside from modifying the load address, it might require to make Keen allocate some extra space of memory, and copy, say, TILESET.TLI file there.

About the other requests: alright, I'll check them.

levellass
Posts: 2895
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass » Tue Nov 13, 2007 3:18 pm

That's... frankly ingenious, I would never have thought of doing that.

User avatar
Shadow Master
Posts: 129
Joined: Fri Oct 20, 2006 3:14 pm
Location: Santiago, Chile
Contact:

Post by Shadow Master » Tue Nov 13, 2007 4:00 pm

It's basically how programs which lack an external I/O manager work. They have to do all by themselves.

Although this is mostly based on my researches about the way NTLDR (Windows NT/2K/XP/2K3 loader) works, it seems to apply to DOS as well, the only difference being that NTLDR works on 32-bit protected mode as soon as possible (as soon as it prepares the memory address space, it seems), and most DOS programs such as keen run on 16-bit real mode.

The address schema also brings some important implications to the available memory and the method of allocating new blocks; fortunately, though, this is not a problem in patching Keen as it's a program that uses only one address scheme AFAIK. Problems would arise when patching DOS programs that run on 32-bit mode (DPMI) such as Duke Nukem 3D... fortunately, most of those have their source code published nowadays.

I just wish it was the same for Keen, but it would probably spoil most of the fun.

Nevertheless, if you are going to patch Keen for reading an external tileset, that would require a lot of testing to make sure everything works right; most importantly, check that border cases (the last tile and the first tile in the set) work properly.

EDIT: btw, opposite to what most people think, Keen is no emo kid. :P

User avatar
ckguy
Posts: 464
Joined: Tue Oct 14, 2003 11:20 am
Location: Providence, RI, US
Contact:

Post by ckguy » Wed Nov 14, 2007 1:48 am

Is the tileinfo in its own segment when Keen is running? Because that would make extending the number of tiles even simpler--nearly all of the code could remain intact.

levellass
Posts: 2895
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass » Wed Nov 14, 2007 5:29 pm

Almost, most of segment AW is made up of tile info, and knowing Keen 4, probably almost all of it with tile related stuff.

Post Reply