📜 ⬆️ ⬇️

Analysis of the resources of the old quest Harvester '96

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

image

Palette


From wiki :
In computer graphics, the palette is a limited set of colors that allows you to display a computer’s graphic system.
From the wide color space, any N colors are selected, and their coordinates (usually: R, G, and B) are stored in a special table — the palette. Raster graphics data using a palette represent an array where numbers (indices) of colors in a palette are stored.

image
')
Push. A palette is a file or a block of data of sizes 768 bytes (256 indices of three bytes R, G, B) or 1024 bytes (4 * 256, RGB plus reserve).
Usually they put the palette separately for a group of pictures, and there may be different palettes for different parts of the game.
The picture has the maximum coordinates X, Y, the size is X * Y, the left-upper corner is zero, for each game you need to determine such things as the origin, XY values ​​of the font, whether these variables are stored somewhere in the data stream.
The font picture itself consists of a stream of bytes of indices, we read 1 byte, we take from the array of the palette:
R = buf_pal [index * 3 + 0]
G = buf_pal [index * 3 + 1]
B = buf_pal [index * 3 + 2]
where buf_pal is an array of data read from the palette file.

So far I have only met 768 byte interleaved palettes (RGB).
Sometimes colors are not RGB-RGB, but, for example, BGR-BGR.
Sometimes the image is too dark and it is necessary for each R, G, B to do a bit shift to the left by 2 (multiplication by 4).
The method of determining - on the eye, knocked down the palette, you will know immediately.

image

In Delphi, you can get the color using the RGB function (r, g, b).
In Harvester, the palette is an uncompressed file harv_cd \ GRAPHIC \ PAL \ INVHELP.PAL

Ok, quest with a palette completed. Found her and she is not hidden. Go to the search and study of the font.

Font


A font is a table with pointers to the beginning of pictures, symbol images. In old games, it can be assumed that all games used a table of 256 characters, there were no unicode sorts in my memory.
First of all, we need a clue how to look at the whole table, in the case of the subject of the game - this is Gameplay Tips, the phrases of hints at the beginning of the game are written in the file \ harv_cd \ ADJHEAD.RCS, just fine! We will drive all the codes in order from 32 to 255 in the hex editor, or just the ones we need and see, which allows us to display the standard font of the game.

image

image

Fine! At first glance, the number of umlauts is enough for one set of Russian letters, either lowercase or uppercase. Already good news.
Now you need to find where the font data is physically located and what can be done with it.
In this game, this is an easy task, font files with sonorous names HARVFNT2.CFT, HARVFONT.CFT, etc. lie in the \ harv_cd \ GRAPHIC \ FONT \ directory.

I start watching the file in the GBS program (GraphBitStream from old-games.ru). It consists of a header and a data array of a rectangular picture of letters. Very often one-bit font, in this game it is 8-bit. Each byte is a color index, and the font size is approximately 800 x 12 pixels.
It looks like this:
image

TEXTFONT.CFT font character sequence
Font width 6-8 and height ~ 12, beginning in the file with 0454h. This will be the top left corner for zero, then the line goes to the right along the X coordinate, the second line starts with 801 bytes.
image

image

In the file data stream, you need to catch something, began to spoil the file and determined the approximate dimensions of the height and width of the image of characters, wrote the same type of bytes, like EEh in groups of 10-20-30 bytes and watched what would happen in the game. I found out that the font can be drawn in 256 colors, which is very unusual. I found out that for all fonts the data starts from 0454h.
It looked like this:
image

Well, with this knowledge in mind, it is already possible to redraw existing umlauts and get Russian letters. Immediately get out the minuses. For example, each letter has a different width, and if it is not changed, the letters will not be scattered in order and you will have to do an index transcoder to insert text.

I had to study the font file header, it looked like this:
image

It turned out the following. The bottom line is:
There is a table of 256 values ​​for each letter code, which lists the widths of characters and pointers to the beginning of the data stream of a particular character. In some characters, for example, "@" was zero, that is, in the game this is an empty space. The thought came that if you set the required width and the necessary pointer to the beginning of the data in the table, you can insert the data taking into account the color of the pixel.
Great, already much better than it was.
I’ve put a graphic editor in Delphi, I’ve put a font file parser, I got a prototype:
image

And the option in which I redraw the entire font. The left mouse button is a pencil with the selected color, the right mouse button is an eraser. You can increase, you can choose a color from the palette.
image

The first experiments:
image

image

And the result:
image

Similarly, I redraw the remaining fonts, only 6 pieces.
Codes took from CP1251, font Arial.
Quest with fonts finished, the result and the tool is.
Go to the search text.

Text


The text of the dialog with the NPC is stored in the file \ harv_cd \ DIALOGUE.IDX
The file is encoded very funny. If there are codes 0Dh, 0Ah, then we skip the byte, otherwise we do xor 170, that is, we have a simple xor encoding. You can hide the resource text from prying eyes and not much to spend on decoding.
This part was spied on the forum old-games.ru
There are no difficulties with inserting text into the game, the file in cp1251 is encoded with xor and is replaced in the original.

Then there is a file DIALOG.RSP in which the questions in the dialogs are written in plain text.

Then there is some text in the harvest.exe file, like LOOK, TALK, etc. Offhand, it turns out that you cannot increase the length of a phrase without debugging an .exe file in search of a text table. The problem number one has turned out.

Then in the file HARVEST.SCR for xor'en number 170 is the script of the game.

Problem number ga w . I can’t find the text of the descriptions of items, but there it should be quite extensive.
And while he stopped at the stage of translated dialogues:

image

Test her.
image

image

image

And demo video:

Source: https://habr.com/ru/post/184986/


All Articles