Carmageddon 2 fonts are a pain!

Been trying to understand the way C2 uses fonts for the past few days and then edit things to my liking with very minimal success, will try to outline my discoveries here.

So I’m working on a beta mod of the game that will resurrect all of the old beta/demo content of the game into the final release, one of the things is the fonts.

In the demo versions of the game, the bonus fonts are each their own images, for example below is the image that resides in DATA\64x48x8\FONTS\PIX16 for “You Wasted ‘Em”

(destroy.pix)

this image is called by the game and displayed whenever you destroy (waste) another opponent, this and a variety of other bonus text all live in the same folder within the demo and allows for great customisation of the ingame HUD and messages.

 

Enter the final version of the game and (excluding the software mode) the way the game handles these messages is now completely different, we no longer have separate images for each bonus message but instead we have font types which are used to display text that appears within the game, these bonus messages are now a part of this. In the demo versions of the game you did have fonts but they all lived in DATA\64x48x8\FONTS\PIX16 as a series of font sheets that were called upon and used as the fonts within the game, one image contains an entire font and the game would cut ’em up and use ’em correctly without you needing to fiddle at all, all well and good and the software mode in the final version of the game still uses this process albiet with lower res tiffx and not tiffrgb/pix16, hardware (glide) mode, however, does not, hardware mode uses a new system where each of the fonts the game will use are each stored in a separate folder, within this folder is a FONT.TXT file that defines the number of characters within that font, the spacing between the characters, the number of the image that the first character begins at, the font height and the width of a blank character, see below for an example of FONT.TXT from the game’s BIG_ITALIC font:

// Large timer digits and colon
133 // number of characters (ORIGINALLY: 133)
-3 // inter-character spacing (ORIGINALLY: 1)
33 // ASCII offset ( value of first character)
20 // font character height (ORIGINALLY: 24)
12 // Blank width

Now also in this folder you’ll find your PIX16/TIFFRGB folders, these folders contain each and every character associated with that font, not as one image like in demo versions of the game but each character has it’s own image, that image is then used by the game as a character, that character is defined in the game’s executable, the image just has to match the first character, for example you will see below a portion of the list of usable ASCII characters within the game’s executable:

Now, moving on to being able to display messages within the game, as previously mentioned the bonus messages in demo version of the game were images that the game loaded in to use when a certain criteria was met, these bonus messages in the final version of the game are controlled by a file within the DATA\ folder called SCROLLERS.TXT and within SCROLLERS.TXT you will find the following (please note, this is an edited version of the file but still contains the same data):

46 // # of Headup scrolly messages
// Format: Font index (THE FONT), Message string (THE FONT COLOUR AS REFERENCED
IN FONTCOL.TXT)
// N.B use underscore “_” where you want a space in the string
23,21,UNUSED // 0
23,21,UNUSED // 1
23,21,UNUSED // 2
23,21,UNUSED // 3
4, 22,GO! // 4 4, 22,GO!
4, 24,1 // 5
4, 24,2 // 6
4, 24,3 // 7
4, 24,4 // 8
4, 24,5 // 9
4, 21,SPLATTER_BONUS // 10
4, 21,PILEDRIVER_BONUS! // 11
4, 21,EXTRA_STYLE_BONUS! // 12
4, 21,BONUS_FOR_ARTISTIC_IMPRESSION // 13
4, 23,CAT_’N’_MOUSE_BONUS // 14
4, 21,WHAT_A_PUNT! // 15
4, 21,DROPPED_LIKE_A_STONE! // 16
4, 21,POLITE.PIX // 17
4, 23,2X_COMBO // 18
4, 23,3X_COMBO // 19
4, 23,4X_COMBO // 20
4, 23,5X_COMBO // 21
4, 23,6X_COMBO // 22
4, 23,7X_COMBO // 23
4, 23,8X_COMBO // 24
4, 23,9X_COMBO // 25
4, 23,10X_COMBO // 26
4, 21,”NICE_SHOT+_SIR!” // 27
4, 23,CUNNING_STUNT_BONUS // 28
4, 21,HEAD-ON_BONUS! // 29 4, 21,HEAD-ON_BONUS
4, 21,YOU_WASTED_’EM! // 30 4, 21,YOU_WASTED_’EM
4, 22,CHECKPOINT! // 31
2, 22,OUT_OF_TIME! // 32
2, 22,RACE_COMPLETED! // 33
4, 23,YOU_ARE_WASTED! // 34 4, 21,YOU_ARE_WASTED!
4, 21,BOTH_BUGGERED // 35
4, 24,GAME_OVER // 36
4, 24,UH_OH…_OUT_OF_CASH // 37
4, 24,HEH_ACE…_YOU_LOST // 38
4, 22,AMAZING…_YOU_WON! // 39
4, 21,BARBEQUE_BONUS // 40
4, 21,STITCH_THAT! // 41
4, 21,AWARD_FOR_OUTSTANDING_ACHIEVEMENT // 42
4, 24,MISSION_FAILED // 43
4, 22,MISSION_COMPLETED // 44
23,24,DEMO_TIMEOUT! // 45

There are a few things to notice here: 1) There are numbers before the bonus text (which I shall explain) and 2) there is an (assumed) unused line within this file that shows “polite.pix“.

Now this file is what controls all of the bonus messages within the game, these lines of text, much like the images that came before them are called upon by the game when a certain criteria is met but instead of the game just calling .pix images for the bonus message it now pulls the specific line required from SCROLLERS.TXT and then displays it based on the options chosen.

What are these options? You’ll notice the comments at the top of SCROLLERS.TXT, they are already present within it, although the explanations in the brackets are what I’ve added. SCROLLERS.TXT has lines of message laid out as follows:

NUMBER,NUMBER,TEXT

This first number is described in the comments as the font index, this font index can be found within the executable and makes sense, it is the font that the game will use when it displays the proceeding message, the font indexes are within the executable as show below:

Now we work our way from the bottom up and we get out indexed fonts and they are as follows:

FONT INDEX #1 = TINYFONT ( data\64x48x8\FONTS\TinyFont )
FONT INDEX #2 = BIGYELLOWTIMER ( data\64x48x8\FONTS\BigYellowTimer )
FONT INDEX #3 = MEDIUM_HEADUP ( data\64x48x8\FONTS\Medium_Headup )
FONT INDEX #4 = BIG_ITALIC ( data\64x48x8\FONTS\Big_Italic )
FONT INDEX #5 = NETPOSFONT ( data\64x48x8\FONTS\NetPosFont )

 

This all makes sense as we are firstly going to define the font we want the bonus message to use (in this case, BIG_ITALIC) but the next number is described in SCROLLERS.TXT as message string, which on it’s own is very difficult to understand but this number (as evidenced by my additional comments) actually points to another text file that resides in DATA\, that file being FontCol.TXT and what FontCol.TXT does is it lists the fonts and then lists their colours, the contents of FontCol.TXT can be found below:

// COLOURS FOR POLYGONAL FONTS
//
// Each font has four sets of RGB values in the range 0-255. These specify
// the colour for each corner of every character in that font. They are ordered as:
//
// Top/Left
// Top/Right
// Bottom/Left
// Bottom/Right
//#define kPolyfont_hand_green_15pt_unlit 0
0,255,0
0,255,0
0,140,60
0,140,60

//#define kPolyfont_hand_green_15pt_lit 1
128,255,128
128,255,128
0,255,0
0,255,0

//#define kPolyfont_hand_red_15pt_unlit 2
255,0,0
255,0,0
203,0,23
203,0,23
//#define kPolyfont_hand_red_15pt_lit 3
255,80,80
255,80,80
193,0,13
193,0,13
//#define kPolyfont_serp_red_15pt_lit 4
255,80,80
255,80,80
193,0,13
193,0,13

//#define kPolyfont_serp_red_30pt_lit 5
255,80,80
255,80,80
193,0,13
193,0,13

//#define kPolyfont_serp_green_30pt_unlit 6
0,255,0
0,255,0
0,140,60
0,140,60

//#define kPolyfont_serp_green_30pt_lit 7
128,255,128
128,255,128
0,255,0
0,255,0

//#define kPolyfont_serp_green_38pt_unlit 8
0,255,0
0,255,0
0,140,60
0,140,60

//#define kPolyfont_serp_green_38pt_lit 9
128,255,128
128,255,128
0,255,0
0,255,0

//#define kPolyfont_hand_green_10pt_unlit 10
0,255,0
0,255,0
0,140,60
0,140,60

//#define kPolyfont_hand_green_10pt_lit 11
128,255,128
128,255,128
0,255,0
0,255,0

//#define kPolyfont_ingame_tiny_yellow 12
255,144,0
255,144,0
255,248,0
255,248,0
//ORANGE-YELLOW

//#define kPolyfont_ingame_tiny_blue 13
0,128,255
0,128,255
255,255,255
255,255,255

//#define kPolyfont_ingame_tiny_red 14
255,255,255
255,255,255
255,255,255
255,255,255

//#define kPolyfont_ingame_tiny_green 15
33,223,24
33,223,24
33,223,24
33,223,24

//#define kPolyfont_ingame_big_timer 16
255,255,255
255,255,255
255,255,255
255,255,255
//YELLOW

//#define kPolyfont_ingame_medium_red 17
255,0,0
255,0,0
255,0,0
255,0,0

//#define kPolyfont_ingame_medium_blue 18
255,255,255
255,255,255
255,255,255
255,255,255

//#define kPolyfont_ingame_medium_orange 19
255,255,255
255,255,255
255,255,255
255,255,255

//#define kPolyfont_ingame_medium_green 20
0,255,0
0,255,0
255,255,255
255,255,255

//#define kPolyfont_ingame_italic_yellow 21
255,154,33
255,154,33
255,235,49
255,235,49

//#define kPolyfont_ingame_italic_green 22
0,133,0
0,133,0
0,255,0
0,255,0

//#define kPolyfont_ingame_italic_blue 23
82,101,255
82,101,255
255,255,255
255,255,255

//#define kPolyfont_ingame_italic_red 24
145,10,0
145,10,0
255,0,0
255,0,0

//#define kPolyfont_netpos 25
33,223,24
33,223,24
33,223,24
33,223,24

//#define kPolyfont_highlighter 26
255,255,255
255,255,255
255,255,255
255,255,255

Now as you may notice the comments at the top of this file make a bit more sense, it tells you the file’s purpose (to give each polygonal font a colour) and how the contents are displayed which is great (this has been edited a bit by myself, by the way,) you will also notice that each of these 27 font colours have a commented name and these names are the names that the individual fonts are given within the executable.

Now we understand the basic purpose that FontCol.TXT serves we’ll go back to SCROLLERS.TXT and now we understand that the second number in our message line points to the font’s colour we can understand it better than just staring at the words “message string” and dribbling, after this we have the text that we want to be displayed, there are a few things to note here:

1) We of course cannot use commas in our message

2) We of course cannot use underscores in our message as these have been reserved for spaces within the message

3) We are limited to what can be displayed (only one font per message and it can only be in one defined colour)

 

Moving on to another notable thing about SCROLLERS.TXT is the “polite.pix” line, polite.pix is present in the demo versions of the game and it is the image that the game would use for a “Cunning Stunt Bonus”, see that image below:

This line must be a left over from when the game was in development, at some point Stainless must have been trying to get individual images loading via SCROLLERS.TXT, a feat which is now impossible (believe me, I’ve spent days trying all sorts of methods to get SCROLLERS.TXT to display specific .pix images, ain’t possible!) but at one point it may have been, in any case we can still in theory use the new fonts to display individual images, in theory.

In practice I have run into numerous issues including: not being able to load .pix images larger than the other font characters, not being able to load .pix images with strange proportions, replacing an existing character with one of this bonus message .pix images and the game freezing for a few seconds whilst it tried (and failed) to display the image and then continuing to run as normal, to complete crashes.

 

My next step is obviously to completely cut up these bonus message images to the size of an existing font and then display them by listing the characters the image replaced in SCROLLERS.TXT in order, for example if I cut up polite.pix (the cunning stunt image) into 5 sections and replaced the BIG_ITALIC characters A, B, C, D and E with them then I would do the following on the Cunning Stunt line:

4, 21,ABCDE  //we’d of course replace the “21” and point to a completely white line in Font.Col.TXT so as not to override the pre-existing colour in the image

But as the rest of the game’s displayed messages also use BIG_ITALIC, the letters A, B, C, D and E would be unusable rendering the entire process pointless.

 

The next thing to try would be to create a new font, a feat that is also impossible if you do not want to hex edit the executable, you see the fonts are all actual files but the way they work and are used by the game is all defined in the executable, as previously shown; the five font indexes are all defined within the executable, the polygonal fonts referenced in FontCol.TXT are all defined within the executable, creating a new font would require adding it to the executable and I don’t want this mod to have to rely on a modified executable.

 

Finally I decide that maybe I should stick with the BIG_ITALIC font that I have edited and just use FontCol.TXT to do the rest but I discovered that the game had other plans, instead of SCROLLERS.TXT’s layout being as easy to explain as:

#(font index),##(font colour),XXXXX(message)

It turned out to be more complicated, yes the first number is indeed the font index BUT the second number because it references FontCol.TXT for the colour of the font and the polygonal fonts within FontCol.TXT are all defined within the executable and tied to their specific fonts it turns out that the second number also defines the font type used, so you could set your font index to 4 which is BIG_ITALIC and then you might want it the same colour as the green TINYFONT so you decide to set your second number to 15, which is seen below is the colour for the green TINYFONT:

//#define kPolyfont_ingame_tiny_green 15
33,223,24
33,223,24
33,223,24
33,223,24

The game will set your font to BIG_ITALIC as stated by the font index and then the 15th colour which is for the polygonal font TINYFONT which is green, that will override the font index and your message will be displayed in green but it will also be displayed in the TINYFONT font type, which is no good at all and this whole thing leaves us only being able to set four colours for all of the (BIG_ITALIC) ingame messages, the following:

//#define kPolyfont_ingame_italic_yellow 21
255,154,33
255,154,33
255,235,49
255,235,49

//#define kPolyfont_ingame_italic_green 22
0,133,0
0,133,0
0,255,0
0,255,0

//#define kPolyfont_ingame_italic_blue 23
82,101,255
82,101,255
255,255,255
255,255,255

//#define kPolyfont_ingame_italic_red 24
145,10,0
145,10,0
255,0,0
255,0,0

 

CONCLUSION: Without actually editing the executable itself, you’re going to have an incredibly difficult time trying to get fonts within the game unless you’re only supporting software mode.

If you want to leave any feedback or require any support, please visit the CWA Board and leave a reply on the relevant thread.