More Hex Questions

Request patches for Keens 1-3.
Post Reply
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

More Hex Questions

Post by XkyRauh »

It's Help, Story, Previews, About-ID, and Order Info time on my Keen2 mod (levels are at 5/16, I'm stuck for ideas, figured I'd take a chunk out of the paperwork)

... How exactly is the formatting defined? Flipping through the text I see 0A, 0D, and 00. I'm definitely no l337 h4xx0r... but by the looks of it:

0A is used to start a new line, much like the HTML <BR>
0D is used to swap into the "other" text color in the 2FON0000.bmp
00 is used as what... a placeholder?

This is why I need you guys! :-D

Now: I know there's a program or two that will change all this for me--but I'd like to learn why things work the way they do. Could someone step me through here and teach me what 0A, 0D, and 00 are used for in these text files?

Keen2 editing seems to be a whole lot more hexwork than Keen1--because Keen2 doesn't have a STORYTXT.ck2, FINALE.ck2, or HELPTEXT.ck2 file... it's all in the code! I'm okay at working with space constraints--what I'm more interested in is changing the layout of the text on the page! Do I NEED to have those line-breaks where they are?

If need be, I can sit down and hack out a line-by-line replacement of every little bunch of text in the game... :-) that's how I did my Keen1 mod!

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

Post by KeenRush »

Some weeks ago I made new story file to my mod with those (very useful; let you have a lot smaller or larger files in Keen 1), but I can't remember those anymore, or well, I wasn't so sure about one of them, so I can't guarantee I did it 100% correctly.
User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin »

In normal use, 0D is a carriage return, and 0A is a line feed. In DOS, to get a proper line break you need both: 0D followed by 0A. I believe this is true for Keen as well.
00 is used to mark the end of a string. While you can mess around with anything within the string, the location of the null (00) character is important: if it gets changed, the starting and ending locations of the strings will be somewhere unexpected, causing a real mess (and possibly a crash). Try it and see... :)
But you can put line breaks anywhere you want within a string.
KeenRush
Patch Maker
Posts: 1988
Joined: Sun Aug 31, 2003 2:52 pm
Location: Sand Yego
Contact:

Post by KeenRush »

Great, thanks for clearing this up! :)
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

re: line breaks

Post by XkyRauh »

I am astounded... flat out astounded. I don't remember seeing an 0D anywhere in the Keen2 "About ID..." part I was editing. Lemme go double-check.

Yeah, there's no sign of 0D anywhere in there:

Code: Select all

We are a group of software artists {0A} {00} {00} {00} {00} {00} whose goal is to bring commercial {0A} {00} {00} {00} {00} {00} {00}  quality software to the public {0A} {00} {00} {etc} ...
So how are they starting new lines? :-$ I'm really sorry for being such a nuisance about this... it's a little over my head.

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

Post by KeenRush »

Probably they just end line or something with 0A 00 00 00 00 00 in that About screen.. Maybe the format is different in help files and about screen and so on..
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

re: line length

Post by XkyRauh »

But without the 0D's in there, I can't change the length of the lines... they're practically hard-coded. For example, look at this "original" code:

Code: Select all

Word 1 Word 2 Word 3 {0A} {00} {00} {00} {00} Word 4 Word 5 Word 6
Onscreen, that would produce this:

Code: Select all

Word 1 Word 2 Word 3
Word 4 Word 5 Word 6
And that's great... but if I were to patch it to, say:

Code: Select all

Word 1 Word 2 Word 3 Word 4 {0A} {00} {00} {00} {00} Word 5 Word 6
Onscreen in the game, I'd get something like this:

Code: Select all

Word 1 Word 2 Word 3 Word 4
Word 4 Word 5 Word 6
There'd still be the Word 4 on the second line, even though the code has no such thing. This is why I posted--if I attempted to post and move the location of the 0A's, things messed up. :-( Can that be cleared up, at all?

I've already re-done the screen to accomodate for the strict format, so it's not crucial... it'sj ust something I'd like to get a better understanding of. Thanks again!

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

Post by adurdin »

My previous post was made without looking at the actual files. It appears that line breaks are marked only be 0A in this text. If you want to have the line breaks elsewhere, you can add 0As in other spots. The important thing for this is not to change any of the 00s -- or you get the effect that you mentioned in your post.

As an example, where the original has this (with * representing 0A and ~ representing 00):

Code: Select all

We are a group of software artists*~~~~~whose goal is to br
A patch could replace it with something like:

Code: Select all

Did you know?*Commander Keen is onl~~~~~y*eight years old**
Because the subroutines for printing text keep track of where to print the next character, it doesn't matter at all that you have to split the text up between the two strings.
User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin »

Note that things are different for the help and story text -- those are just text files embedded in the .exe, and use the ordinary 0D 0A newline. In these files, a tilde ~ (7E) at the beginning of a line indicates a change to red-on-grey text for that line only.
User avatar
XkyRauh
Posts: 1114
Joined: Sun Aug 31, 2003 9:14 pm
Location: San Diego, California

re: coding

Post by XkyRauh »

*gasp of understanding* That's awesome--thank you very very much, Mr. Durdin! That'll help me out a bit on my "Previews!" screen, I think.

--Xky
Post Reply