Analysis of the resources of the old quest. 96
Good everyone, I want to tell you about the color palette in the old games time 256 colors, Pro fonts and a little Delphi.
On the quest about the quest described below, I spent about 100 hours time.
The story about the path.

Of the wiki:
In computer graphics, a palette is a finite set of colors, which allows you to display graphics of the computer.
From a wide color space selects any N colors, and their coordinates are (typically R, G and B) are stored in a special table palette. The data bitmap that uses palette to represent an array, which stores the number (index) of colors in the palette.

Myself. A palette is a file or a data block size of 768 bytes (256 indices of the three bytes R, G, B) or 1024 bytes (4*256, RGB plus reserve).
Usually put the palette separately for the group of pictures, and for different parts of the game can be a different palette.
The picture has a maximum X, Y coordinates, size is equal to X * Y, left-top corner is zero, it is necessary for each game to determine such things as the origin of coordinates, the XY size of the font, does it store these variables somewhere in the data stream.
The picture of the font consists of a stream of byte indexes read 1 bytes taken from the array palette:
R = buf_pal [index * 3 + 0]
G = buf_pal [index * 3 + 1]
B = buf_pal [index * 3 + 2]
where buf_pal data array read from the file palette.
Yet I have met only the palette is 768 bytes interleaved (RGB).
Sometimes colours are not RGB, RGB, and, for example, BGR-BGR.
Sometimes the image is too dark and needs for each R, G, B to do a bitwise shift left by 2 (multiplying by 4).
Method of determination — on the eyes, downed the palette you can recognize immediately.

In Delphi to color function RGB (r,g,b).
In the game Harvester palette lies uncompressed file harv_cd\GRAPHIC\PAL\INVHELP.PAL
Well, the quest with the palette made. Found it and it is not hidden. Go to the search and study of the font.
The font is a table with pointers to beginning of pictures, images, symbols. In the old games, you can accept that all games used a table of 256 characters, there are all sorts Unicode in my memory not found.
First they need a clue how to see the entire table, in case the subject of the game is Gameplay Tips phrase tips at the beginning of the game, spelled out in the file \harv_cd\ADJHEAD.RCS is just fine! We'll drive there in a hex editor, all the codes in order from 32 to 255 or just the right look that allows you to display the standard font of the game.


Great! The number of umlauts on the first glance is enough for one set of Russian letters, either lowercase or uppercase. Already good news.
Now we need to find where the data are physically fonts and what you can do with them.
In this game, this task is easy, the font files with the sonorous names HARVFNT2.CFT, HARVFONT.CFT, etc. are in the directory \harv_cd\GRAPHIC\FONT\.
Begin to see the file in the program of GBS (GraphBitStream with old-games.ru). It consists of a header and a data array of rectangular images of the letters. Very often the font is a one-bit, in this game it 8-bit. Each byte is a color index, and the picture of the font has a size of about 800 x 12 pixels.
Looks like this:

The sequence of characters of the font TEXTFONT.CFT
Font with a width of 6-8 and a height of ~12, the beginning of the file with 0454h. This will be the upper left corner is zero, then the line is to the right of the X-coordinate, 801 byte starts the second line.

In the data flow of file need for something to cling to, began to spoil the file and determine the approximate dimensions of height and width of the image of the characters, wrote the same byte, like EEh groups of 10-20-30 bytes and watched what happens in the game. Found out that the font can draw in 256 colours, which is very unusual. Found out that all fonts starting with 0454h.
It looked something like this:

Well, given this knowledge it is already possible to redraw the existing umlauts and to Russian letters. Immediately the cons. For example, each letter has a different width if you do not change, then the letters will be scattered not in order and will have to make a transcoder indexes for text insertion.
I had to examine the header of the font file, it looked something like this:

Revealed the following. The essence is this:
There is a table of 256 values for each code letter, which lists the widths of characters and pointers to the beginning of the data stream of a particular character. Some characters, such as "@" were zero, that is, the game is empty space. The thought came that if in the table to specify the desired width and the desired pointer to the beginning of the data, you can insert the data according to the color of the pixel.
Excellent, much better than it was.
Have thrown in the Delphi image editor, have thrown a parser for font files in the prototype:

And one where I redrew the entire font. Left mouse button — the pencil with the selected color right mouse button — eraser. You can zoom, you can select a color from the palette.

First experiments:


And the result:

Similarly redrew the rest of the fonts, only 6 pieces.
Codes took CP1251, Arial.
Quest font is finished, the result and the tool is.
Go to search text.
The text dialogue with the NPC is stored in the file \harv_cd\DIALOGUE.IDX
The file is encoded very funny. If there are codes 0Dh, 0Ah, skip byte, otherwise, do xor 170, that is, have a simple xor encoding. You can hide the resource text from prying eyes and not to spend too much on decoding.
This piece was inspired on the forum old-games.ru
Difficulties with the insertion of text in the game no, the file is encoded in cp1251 XOR ohms and replaced the original.
Then there is a file DIALOG.RSP in which openly there are questions in dialogs.
Then, in the file harvest.exe there is a bit of text, like LOOK, TALK, etc. at random it turns out that to increase the length of the phrase you pick .exe file in the debugger in search of a table of text. Turned out the problem number one.
Then in the file HARVEST.SCR for XOR eny number 170 is the script of the game.
Problem number dwellVA. Can't seem to find the text descriptions of items, and there it needs to be quite extensive.
And while stopped at the stage of the dialogues translated:

Test It.



And demo videos:
Article based on information from habrahabr.ru
On the quest about the quest described below, I spent about 100 hours time.
The story about the path.

Palette
Of the wiki:
In computer graphics, a palette is a finite set of colors, which allows you to display graphics of the computer.
From a wide color space selects any N colors, and their coordinates are (typically R, G and B) are stored in a special table palette. The data bitmap that uses palette to represent an array, which stores the number (index) of colors in the palette.

Myself. A palette is a file or a data block size of 768 bytes (256 indices of the three bytes R, G, B) or 1024 bytes (4*256, RGB plus reserve).
Usually put the palette separately for the group of pictures, and for different parts of the game can be a different palette.
The picture has a maximum X, Y coordinates, size is equal to X * Y, left-top corner is zero, it is necessary for each game to determine such things as the origin of coordinates, the XY size of the font, does it store these variables somewhere in the data stream.
The picture of the font consists of a stream of byte indexes read 1 bytes taken from the array palette:
R = buf_pal [index * 3 + 0]
G = buf_pal [index * 3 + 1]
B = buf_pal [index * 3 + 2]
where buf_pal data array read from the file palette.
Yet I have met only the palette is 768 bytes interleaved (RGB).
Sometimes colours are not RGB, RGB, and, for example, BGR-BGR.
Sometimes the image is too dark and needs for each R, G, B to do a bitwise shift left by 2 (multiplying by 4).
Method of determination — on the eyes, downed the palette you can recognize immediately.

In Delphi to color function RGB (r,g,b).
In the game Harvester palette lies uncompressed file harv_cd\GRAPHIC\PAL\INVHELP.PAL
Well, the quest with the palette made. Found it and it is not hidden. Go to the search and study of the font.
Font
The font is a table with pointers to beginning of pictures, images, symbols. In the old games, you can accept that all games used a table of 256 characters, there are all sorts Unicode in my memory not found.
First they need a clue how to see the entire table, in case the subject of the game is Gameplay Tips phrase tips at the beginning of the game, spelled out in the file \harv_cd\ADJHEAD.RCS is just fine! We'll drive there in a hex editor, all the codes in order from 32 to 255 or just the right look that allows you to display the standard font of the game.


Great! The number of umlauts on the first glance is enough for one set of Russian letters, either lowercase or uppercase. Already good news.
Now we need to find where the data are physically fonts and what you can do with them.
In this game, this task is easy, the font files with the sonorous names HARVFNT2.CFT, HARVFONT.CFT, etc. are in the directory \harv_cd\GRAPHIC\FONT\.
Begin to see the file in the program of GBS (GraphBitStream with old-games.ru). It consists of a header and a data array of rectangular images of the letters. Very often the font is a one-bit, in this game it 8-bit. Each byte is a color index, and the picture of the font has a size of about 800 x 12 pixels.
Looks like this:

The sequence of characters of the font TEXTFONT.CFT
Font with a width of 6-8 and a height of ~12, the beginning of the file with 0454h. This will be the upper left corner is zero, then the line is to the right of the X-coordinate, 801 byte starts the second line.

In the data flow of file need for something to cling to, began to spoil the file and determine the approximate dimensions of height and width of the image of the characters, wrote the same byte, like EEh groups of 10-20-30 bytes and watched what happens in the game. Found out that the font can draw in 256 colours, which is very unusual. Found out that all fonts starting with 0454h.
It looked something like this:

Well, given this knowledge it is already possible to redraw the existing umlauts and to Russian letters. Immediately the cons. For example, each letter has a different width if you do not change, then the letters will be scattered not in order and will have to make a transcoder indexes for text insertion.
I had to examine the header of the font file, it looked something like this:

Revealed the following. The essence is this:
There is a table of 256 values for each code letter, which lists the widths of characters and pointers to the beginning of the data stream of a particular character. Some characters, such as "@" were zero, that is, the game is empty space. The thought came that if in the table to specify the desired width and the desired pointer to the beginning of the data, you can insert the data according to the color of the pixel.
Excellent, much better than it was.
Have thrown in the Delphi image editor, have thrown a parser for font files in the prototype:

And one where I redrew the entire font. Left mouse button — the pencil with the selected color right mouse button — eraser. You can zoom, you can select a color from the palette.

First experiments:


And the result:

Similarly redrew the rest of the fonts, only 6 pieces.
Codes took CP1251, Arial.
Quest font is finished, the result and the tool is.
Go to search text.
Text
The text dialogue with the NPC is stored in the file \harv_cd\DIALOGUE.IDX
The file is encoded very funny. If there are codes 0Dh, 0Ah, skip byte, otherwise, do xor 170, that is, have a simple xor encoding. You can hide the resource text from prying eyes and not to spend too much on decoding.
This piece was inspired on the forum old-games.ru
Difficulties with the insertion of text in the game no, the file is encoded in cp1251 XOR ohms and replaced the original.
Then there is a file DIALOG.RSP in which openly there are questions in dialogs.
Then, in the file harvest.exe there is a bit of text, like LOOK, TALK, etc. at random it turns out that to increase the length of the phrase you pick .exe file in the debugger in search of a table of text. Turned out the problem number one.
Then in the file HARVEST.SCR for XOR eny number 170 is the script of the game.
Problem number d
And while stopped at the stage of the dialogues translated:

Test It.



And demo videos:
Комментарии
Отправить комментарий