TED5 Replacement - KEDfW (Keen Editor for Windows)

Utilities for editing Keen:Galaxy and Keen:Dreams levels.
User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin » Tue Aug 17, 2004 12:15 pm

Boeing747 wrote:Thanks! The (unfinished) keen file format doc is better to understand.
I'll make a module with Type declarations.
But one question:
PlaneOffsets(0 to 2) As Integer is the same as:

Code: Select all

Type PlaneOffsets
  PlaneOffS1 As Integer
  PlaneOffS2 As Integer
  PlaneOffS3 As Integer
End Type
?
That's right -- but not that the plane offsets are 32-bit words (Long in VB), not 16-bit words (Integer in VB).
How can I make this bug similar in VB6?
...
But VB6 doesn't see this String as an 0 to 7 array.
You don't need to worry about it -- see below.
What are those "ABC-Words" in gamemaps?
and in this TED5 file, i could not see any junkbytes.
The bug is a buffer overflow: the C code actually tells the program to start writing bytes out, beginning with "T" in "TED5v1.0", and stopping when it reaches a byte equal to &H0 (null). This could be almost anywhere later in memory, so you could get zero or many junk bytes. But it doesn't matter a bit -- you should write "TED5v1.0" at the beginning of the file when saving GameMaps, and you should read it just to be sure that it's a valid file, but to work out where the map data is you need to read the maphead information from the maphead file or the (unlzexed) .exe file.
Public Type GAMEMAPS_HEAD
Signature As String * 8 ' Always set to "TED5v1.0"
Junk() As Byte ' ???
End Type
So remove the "Junk() As Byte" and you've got what you need there.

User avatar
Boeing747
Posts: 76
Joined: Fri Apr 16, 2004 11:24 am
Location: Germany
Contact:

Post by Boeing747 » Wed Aug 18, 2004 10:14 am

Thanks I'm worry about the C source of TED5 for the compression methods. I know the syntax of C bot not at all. If I have troubles I
post them here.

In wich sourcemodule of TED5 is the charmack and RLE compression?
I'm searching... ... ... ... Found something in JHUFF.C, JHUFF.H
theres no Charmackize or RLe, only Huffmanize?!
Umm, I'd only found the TED5 ROTT source. Not CK! :(
I'm sorry that I'm so stupid for this.

Suggestion 2: Could we split this topic into 2 parts? KMO | KEDfW?

User avatar
Frenkel
Posts: 37
Joined: Sun Feb 15, 2004 10:18 am
Location: Netherlands
Contact:

Post by Frenkel » Wed Aug 18, 2004 12:27 pm

Boeing747 wrote:Umm, I'd only found the TED5 ROTT source. Not CK! :(
I'm sorry that I'm so stupid for this.
That's the only version of TED5 that they released, so you got the right one.

User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin » Wed Aug 18, 2004 12:41 pm

Boeing747 wrote:Thanks I'm worry about the C source of TED5 for the compression methods. I know the syntax of C bot not at all. If I have troubles I
post them here.
Don't worry, the TED5 source has both C and Assembly versions of them :-b
In wich sourcemodule of TED5 is the charmack and RLE compression?
I'm searching... ... ... ... Found something in JHUFF.C, JHUFF.H
theres no Charmackize or RLe, only Huffmanize?!
Umm, I'd only found the TED5 ROTT source. Not CK! :(
I'm sorry that I'm so stupid for this.
No, it's all there in JHUFF.C -- Huffman, Carmack, and RLE.
Suggestion 2: Could we split this topic into 2 parts? KMO | KEDfW?
Done way back. And it's been moved now to the TED5 forum.

User avatar
Boeing747
Posts: 76
Joined: Fri Apr 16, 2004 11:24 am
Location: Germany
Contact:

Post by Boeing747 » Wed Aug 18, 2004 7:00 pm

Too bad. I can't take these jhuff.c und jhuff.h listings :´(.
HELP!

User avatar
Boeing747
Posts: 76
Joined: Fri Apr 16, 2004 11:24 am
Location: Germany
Contact:

Post by Boeing747 » Sat Aug 21, 2004 1:51 pm

Andy i'm at the end of my knowlege. If you have time:
- Please make me a *.bas for encode and decode charmack and rle (not faked)
- Please make maphead, gamemaps load and save in the *.bas
Name for *.bas could be: "modGameMaps.bas"

All my tests won't work. Thanks :´(
Please look into http://www.plsplayer.de/kedfw/kedfwsrc.rar .
Thanks

User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin » Sat Aug 21, 2004 9:59 pm

I'm sorry, Boeing747, I don't have time to do that at the moment, unfortunately.

User avatar
Boeing747
Posts: 76
Joined: Fri Apr 16, 2004 11:24 am
Location: Germany
Contact:

Post by Boeing747 » Sat Aug 21, 2004 10:10 pm

Hm I have time. I'm young i can wait ;o).
I MUST wait. I'd tryed everything - no results.

In that time: Anyone could translate this C code to VB6
(FileAcces, not String), PLEASE Image:

Code: Select all

/*
==================
=
= CarmackCompress
=
= Compress a string of words
=
==================
*/

#define NEARTAG	0xa7
#define FARTAG	0xa8

long CarmackCompress (unsigned far *source,long length,
	unsigned far *dest)
{
	unsigned	ch,chhigh;
	unsigned	far *instart, far *inptr, far *inscan,
				far *stopscan, far *outptr;
	unsigned	far *bestscan, beststring;
	unsigned	dist,maxstring,string,outlength;
	unsigned	nearrepeats,farrepeats;
	unsigned	dups,count;
	unsigned	newwords;

//
// this compression method produces a stream of words
// If the words high byte is NEARTAG or FARTAG, the low byte is a word
// copy count from the a position specified by either the next byte
// or the next word, respectively.  A copy count of 0 means to insert the
// next byte as the low byte of the tag into the output
//


//
// set up
//
	instart = inptr = source;
	outptr = dest;

	outlength = 0;
	length = (length+1)/2;

	nearrepeats = farrepeats = dups = 0;
	count = 10;
	newwords = 0;
//
// compress
//
	do
	{
		ch = *inptr;

//
// scan from start for patterns that match current data
//
		beststring = 0;
		for (inscan = instart; inscan<inptr; inscan++)
		{
			if (*inscan != ch)
				continue;

			maxstring = inptr-inscan;
			if (maxstring > length)
				maxstring = length;
			if (maxstring > 255)
				maxstring = 255;

			string = 1;
			while (*(inscan+string) == *(inptr+string) && string<maxstring)
				string++;

			if (string >= beststring)
			{
				beststring = string;
				bestscan = inscan;
			}
		}

		if (beststring > 1 && inptr-bestscan <= 255)
		{
		// near string
			*outptr++ = beststring + (NEARTAG*256);
			*((unsigned char far *)outptr)++ = inptr-bestscan;
			outlength += 3;
			nearrepeats++;
			inptr += beststring;
			length -= beststring;
		}
		else if (beststring > 2)
		{
		// far string
			*outptr++ = beststring + (FARTAG*256);
			*outptr++ = bestscan-instart;
			outlength += 4;
			farrepeats++;
			inptr += beststring;
			length -= beststring;
		}
		else							// no compression
		{
			chhigh = ch>>8;
			if (chhigh == NEARTAG || chhigh == FARTAG)
			{
			// special case of encountering a
			// tag word in the data stream
			// send a length of 0, and follow it with the real low byte
				*outptr++ = ch & 0xff00;
				*((unsigned char far *)outptr)++ = ch&0xff;
				outlength += 3;
				dups++;
			}
			else
			{
				*outptr++ = ch;
				outlength += 2;
			}
			inptr++;
			length--;
			newwords++;
		}

		if (!--count)
		{
			static char cc[2]="-";
			cc[0]^='+'^'-';
			print(cc);
			sx--;

			count = 10;

		 if (keydown[1])
		 {
		  while(keydown[1]);
		  return 0;
		 }
		}
		if (length<0)
			Quit ("Length < 0!");
	} while (length);
	#if 0
	printf ("%u near patterns\n",nearrepeats);
	printf ("%u far patterns\n",farrepeats);
	printf ("%u new words\n",newwords);
	printf ("%u dups\n\n",dups);
	#endif
	return outlength;
}
And a small question? how can I get VB's INTEGER UNSIGNED?
Edit: Unsigned Integers is okay: If it's < 0 then add 65536.
Last edited by Boeing747 on Thu Aug 26, 2004 12:17 am, edited 1 time in total.

User avatar
Boeing747
Posts: 76
Joined: Fri Apr 16, 2004 11:24 am
Location: Germany
Contact:

Post by Boeing747 » Wed Aug 25, 2004 11:01 pm

Lasted source of kedfw: http://www.plsplayer.de/kedfw/src/kedfw.zip
I'll add a Projectmanager!

Here is the first created gamemapsfile for ck.
Please look at this file with your HEXEDITOR.
My question: Is this file compatible to TED5v1.0
when it is Carmack-compressed?
http://www.plsplayer.de/kedfw/1stgamemaps.zip

There is a new source of KEDfW (BETA 0.06) available:
www.plsplayer.de/kedfw/src/006.zip

SupFanat
Posts: 29
Joined: Thu Mar 04, 2004 8:33 pm

Post by SupFanat » Sun Nov 21, 2004 2:58 pm

All these links don't work! :( :( :( :(

User avatar
grafix
Posts: 199
Joined: Fri Oct 29, 2004 8:38 am

Post by grafix » Mon Nov 22, 2004 7:38 am

I'll get round to uploading the files to my server after school. About 7 1/2 hours till I get home from school, so... wait.

User avatar
DasBrot
Posts: 49
Joined: Wed Dec 29, 2004 12:01 pm
Location: Germany

Hello?

Post by DasBrot » Thu Feb 17, 2005 1:46 pm

Is anyone still working on this editor?

KeenRush
Patch Maker
Posts: 1988
Joined: Sun Aug 31, 2003 2:52 pm
Location: Sand Yego
Contact:

Post by KeenRush » Thu Feb 17, 2005 1:51 pm

Not on this.

User avatar
grafix
Posts: 199
Joined: Fri Oct 29, 2004 8:38 am

Post by grafix » Sat Feb 19, 2005 10:42 am

Unless Boeing appears again (sounds unlikely - last time I heard he was doing work experience for a steel manufacturer) there won't be any work done on this. I might incorporate some of it into modCore 4-6, when I get around to it.

User avatar
DasBrot
Posts: 49
Joined: Wed Dec 29, 2004 12:01 pm
Location: Germany

*DasBrots Keen4 mod dies dreadful*

Post by DasBrot » Sat Feb 19, 2005 2:19 pm

Hmm, ok. I will start my work on keen1 mods...

Post Reply