Parse "Confrontation — a war chronicle" (1996-1997, Doc)

Introduction


Good all, I want to tell about the warm and tube-like strategy of childhood — Confrontation. The game was released in the 1996-98 biennium our Russian firm Doc.
Game real — time strategy about world war II. Many years later I decided to first go and write the passage, and then try to the maximum to extend the fun of the game, unpacking resources and trying to understand the game logic.

Under the cut I will describe the process of extracting the music, graphics and a little bit not make it to the map editor.
Also in the description are references to 8-bit palette of colors, pseudoangina, RLE compression, and some HEX editor. In the code I saw only the algorithm for decoding images compressed RLE.

image

The original plan was to get music on and off the fog of war, and then got a little carried away and unpacked 9 files (.ADW, .DAW .RUS).

I play and recommend full 2in1 version (Confrontation: Military news) with five cd audio tracks, that is, a full rip latest version of the game all-in-one.
If it were possible, I would buy it again, as my original disk, bought in 98g not preserved.

Music


The obvious and easiest solution is to run the game under dosbox and record all the music that I did in the first place. Playlist music.

Then thought it was wrong. It turns out that this music is not original, and passed through filters dosbox. Decided to decompress to wav state, using the original data.
Opened the file music.dat in winhex. As in music there are voices, it is assumed that there is a digital stream.
Thanks to the forum of old-games where I suggested that most often used for audio uncompressed raw data stream, just the sound of defined parameters(11025 Hz/22050 Hz as the most frequently used, 8-16 bits, mono/stereo Intel/Motorola) which were sent directly to the soundcard.

Open in hex saw the following:
image
The beginning of the file 4 bytes contain the number 20 (14h 00 00 00). Tracks in the game 20. Then the following 20 groups of 4 bytes is the offset started tunes. The last 4 bytes (33 A5 4B 01 = 01 4B A5 33h ) is equal to the size of the file music.dat, the size of each track is equal to the difference between the two offsets. Everything was nice and easy.

Offset table is easy to determine — it may be a sequentially increasing numbers, but sometimes the file table contains inconsistent offsets (E.g., table of the fonts of the game I have no mouth and I must scream). Number-the offset is in the range from 0 to the size of the file. In this case, the table goes on increasing.

In the header of each track can be traced the titles of the tracks at a fixed offset +16: Maintune, Technoish, Terrible, Requiem, Track 0, Lazy reggae, U97:Was is das, Hold, GETDOWN!, Scramble, Gone, Rainman, Guitar song, Cool Jazz, Fir plates plant, REGRET.
Experiments with pieces in the program Game Audio Player (GAP) found that music is played with the following settings — 22kHz, 8 bit, mono, unsigned. And, if you put 11кГц, the music will still play, but 2 times slower. Mono/stereo also changes the playback tempo.

Inspired by the result I started listening to all the game files... I Listened to them for three days. The sound is very similar to loading games from cassettes on the spectrum or noise analogue modem. Found out that the sounds in the game are played as 11кГц, 8 bit, mono. Also found that all the sounds in the game, the sound in the cinematics, the music is raw Nejat data pointers.
The title of each track 68 bytes, it should reject, otherwise it clicking before the music.
The result, wrote the unpacker parser music.dat.
The resulting files can be streamed GAP and convert them to any format.
The quest to extract the original music was made.

Graphics


With graphics it was a little confusing. Some of the image is RLE compressed, some are not compressed, the part in the file header are the image resolution, and might get a sequence like X Y and Y X. Some images had no titles and was the size of 32x32 pixels.
The contents of pseudoangina and RLE compression
image

First comes the header is four bytes specifying the offset to the start block data.
The last number 67 A9 07 00 equal to the length of the file, the number the end of the first block.
Then comes the second block of data specifically for the file adddata.adw is the picture of the "insert disc" for a regular campaign, and scorched the snow.
(number of files), and offset 4
04 00 00 00 — 10 00 00 00 — C3 A3 01 00 — C3 A6 01 00 — 52 40 03 00 — 8002 E001
The last number 0280h and 01E0h are numbers 640 and 480, that is the solution. Numbers form a cycle for the decoding procedure of the block with RLE compression.
Decoding algorithm:
The number is less than or equal to 7Fh (127) specifies the number of retries reaching the next byte in the example above is 7Fh (127) to repeat zero.
If the first number is greater than 80h, it means that next (X-80h) byte is just the bytes you want to copy to a new location.
The sequence 82h 01 02 means that this is number 01 and 02 without any compression.
If in place of repeat count hits zero noise.
About destiny number 80h I did not understand, it should not meet, because the difference of 80 and 80 will be zero).

The idea is you need 2 blocks of the image itself and the palette.
Beginning блока2 assumed to be zero and everything moving on the bias point from zero. That is, if you look in the hex editor, we must add the initial 24 bytes, plus 4 bytes (00 00 00 04). Total +28 bytes +1Ch

04 00 00 00 — 4 file.
10 00 00 00 + 1Ch which indicates the start of the image block 8002(640), E001(480), that is, the set cycle decoding, not longer than 640×480
C3 A3 01 00 + 1Ch indicates a palette of 256 RGB colors, 768 bytes. read More here.
C3 A6 01 00 + 1Ch indicates the image again 640x480
52 40 03 00 + 1Ch specifies the palette of the

The case remained for small, to parse the file into blocks, unpack the compressed sections and glue with a palette.
The decoded compressed image:
image

Game sprites:
image

Removed from resources of the image is dark, you need to do a bitwise left shift by 2 on each channel R, G, B.
r=r shl 2; (or multiply by 4, someone more like it)
g=g shl2;
b=b shl 2;

A little picture for relaxing. Original, no filters, true.
These pictures are drawn on the right panel, choose when the unit.
image

Video


From the video it fail, there is also raw data streams, pictures(in any format) interspersed with the sound. Took the first video of the movie.adw to 1.64 MB, stuffed in a GAP (22kHz, 8bit, mono, unsigned) — is mixed in the noise-sounds-noise-sounds, where noise is the flow of images in 320х200х256, and the sound in raw.
I suppose that if felt carefully at the file, the sound must be separated by some displacement. The video starts with the letters DLM, it is easy to find plus if you check the initial offset table in the movie.adw, they will point to the DLM.

Video:
Header 4 bytes — "DLM" + 00
The size of video + sound — 4 bytes (same as wybranym videocustom)
— Unknown 4 bytes (type E3 00 00 00 = 227, the number of offsets)
— The horizontal size, 4 bytes, 01 00 00 40 = 320
— The vertical size, 4 bytes, 00 00 00 C8 = 200
— Some delimiter 4 bytes = 04 00 00 00
— Then 227 offsets in the file by 4 bytes
— Then again, the separator 04 00 00 00
— And it seems until the end of data stream

And on this video.

a Little bit of the map editor


Picking the file CD:\DATA\MISSIONS\73\UNITS.DAT found the following
[DEUTCHE]
[TIGER]
6,80,3,50,100,0,142

Information about units on the map:
The first two numbers after the comma is the X and Y coordinates of the unit, zero starts in the upper-left corner. The maximum is 128, the map size 128x128, it seems to be fixed; integer 0-128
— The third number is the sprite rotation unit in 8 directions should be + turret rotation is also animated; integer 0-7. The tower is rotated in the direction of the sight unit.
— The fifth number is the amount of ammunition, like in percent of the maximum. 0-100.
— The last two do not understand what the numbers changed to 1, 142 2, 12, in a unit, nothing has changed. Not attack/protection, checked. (the sixth, penultimate — enemy units indicates visibility 0 not visible to the player 1, we see)
— The seventh number is XS. Looks like something to do with the patrol, from the start of the game travel to different enemy tanks. Similar to script behavior. From 0 to 255 Hz

For homes the following parameters:
[DOMES]
29,33,70,100,1

1) building Type, ranges from 0 to 35.
2,3) the X, Y Coordinates to the upper left beginning of the building, is drawn to the right and down. Values from 1 to 128.
4) the Number of "lives" of the building, in %. 0-100. Tried it and 1000%, then the building can be destroyed with 6 stars, instead of 2 for the normal great.
5) do I need to destroy a building to win the mission. 1 — a common building, for the destruction of no bonuses, 2 — the building must be destroyed to win the mission.

description of units the file units.dat
[RUSSIAN] — Russian Branch of the description of units section
[RBTANK] — Soviet T34 tank, medium tank, image
[RLTANK] — Light tank T26, image
[RGUN] Russian cannon against infantry and tanks image
[RTROOP] — Russian infantry, image
[RSAMO] Russian PT, type su100
[IS] — Russian heavy tank is
[BAT] is uncontrollable Rapid-fire gun image
[RGAUB] — Russian-controlled howitzer
[KATYA] — Katyusha
[RBTR] — machine gun armored personnel carriers, small car,
[RFURG] — truck for infantry,
[TOWER] is a tower with a machine gun,
[RZENIT] — Russian-aircraft guns against aircraft,
[CAR] — car vip
[RMZ] — Russian mobile machine with anti-aircraft guns against aircraft.

[DEUTCHE] — a branch of the description of German units, section
[DGUN] German cannon
[DLTANK] — German light tank,
[DBTANK] — German medium tank,
[TIGER] Tiger
[DBIKE] — motor-cycle
[DTROOP] — infantry,
[RFURG] — van-truck Russian, you can capture or use as your own.
[DBTR] — machine gun BTR-machine
[DSAMO] — German Fri, Ferdinand
[DGAUB] — German guided howitzer
[ART] — high-Speed, accurate gun, which can be controlled. image
[DZENIT] — anti-aircraft guns against aircraft, image
[DMZ] — Mobile antiaircraft gun anti-aircraft image
[STIG] — the German uber-tank with a powerful gun and weak armor, Shturmtigr, image

And yet, for example, if you play for the Germans, the branch descriptions Isov put under description, under the [DEUTCHE], ISA be under your control.

In the end, sketched minimod — the Friendship of peoples:
image

And insane videos:


But in the end hands to finish the editor never came, as it was not fully understood the format of the card.

forum Topic old-games, maybe someone will help! bad. The source code is available, unfortunately, Делфи7.

Walkthroughs playlists:
the Campaign for the USSR
Campaign for Germany
Additional missions — seared snow.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

The release of the new version of the module modLivestreet 0.3.0-rc

mSearch: search + filter for MODX Revolution

Emulator data from GNSS receiver NMEA