Continue to disassemble the quest. 1996
All good.
last time I stopped at that Tahoma11 introduced to the game and was satisfied.
Immediately became visible disadvantages, the font does not fit in with the style of the game.
There were new troubles:
the
-
the
- to implement a beautiful Russian font, stylized as the original, the
- to deal with the pass almost every video in dosbox.
Tools: IDA, dosbox + debugger, winhex.
Quest about fonts
First, the font. All by the same artist of the forum was painted a beautiful, stylized original Russian font.
All in the game there are six:
Since the font is 8-bit, each pixel of a character is one byte containing a color index in the palette. There is a table of the widths of each character in the header, one line of all characters in the font to form a series of (also spelled out in the title), a few rows form the top.
The size of the data block are equal (height * a row) byte, and the corresponding picture are equal (height * a row) pixels.
There was a small stupor as their shove in the game data. Your test Tahoma11 I drew pixel by pixel looking for enlarged original. The only color used is white.
By this time I had prepared a tool pixel-by-pixel rendering of each letter with the color selection, but there is a giant BUT. If the fine print you had to be redrawn by hand, the big font size 40x50 pixels was not in a reasonable time. Each letter has been used a few colors from the palette to 256 colors, what else complicates the task of hand drawing.
Had to do a data import from BMP.
The algorithm is the following. Fellow artist (Ogr 2) provided a different background for each letter, that is, there is a lead to automatically collect data about the width of each letter. Later he was to add one service line with different colors in order to count the width of each character.
So is the process.
I ran one row of bytes of the Russian font in BMP and the border between characters caught changing the color of a pixel, made the table widths.
Height is the number of rows of pixels. As we have each font is a separate file, then nothing prevents to increase height, simply by adding zeros to the end of the data block. The number of zeros equal to the number of bytes of a number. After this is fix bytes the height and voila, the new height of the finished, adjusted to the desired size.
The following paragraph is the width of each symbol must be agreed width. Shift the data alignment width.
Now we are ready to import, do the loop height, loop width and copy the bytes from the BMP directly in the data block of the game.
The result turned out great, but somehow, every action leads to consequences.
Got a problem — the total width of Russian letters was much wider than the developers and the slide transfer system has issued a here is the result:
The engine tightly Packed that the series length is 39 characters. If you pull the string of 40+ characters in a row, the game freezes, if less, it gets beyond the boundaries of the interface.
Started the way of debug.
Was thrown back of DOS header, the LE file is inserted in IDA. Bonus the developers left in the EXE file all the debug information, that is visible all the names of all functions.
Direct search of numbers 38, 39, 40 in the IDA nor to no avail. Debugging jumped in the area of functions "Talk to" and specifically I tested the "Talk to Hank", I had to trace was trace and vitrasius finally a wonderful block, the mathematics of which was the coveted number 39.
The block looked like this:
cseg01:00059D94 lea ecx, [eax-1]
cseg01:00059D97 sar edx, 1Fh
cseg01:00059D9A mov eax, ebp
cseg01:00059D9C for idiv ecx
The quotient for idiv EAX is the number 39, which is then used to transfer lines, the engine inserts each 39 characters code 0Ah, line feed.
The last two commands first I replaced the
mov al, 36
but it turned out a bug in the AH that it and the string turned out as long as eternity, all the text turned in one row, the second time I ordered already
mov ax, 36
and voila:
Later it turned out that 36 is too many and had to register 35, on this quest with strings and font is finished.
the Quest of the blanks video
Problem. A global problem. In dosbox with a large number of cycles the game runs smoothly and well, but almost all the videos are skipped immediately after the start of the show. This is unacceptable.
It was possible to reduce the number of cycles, then passes the video stopped, but the game turned into a slide show.
Process Monitor showed that the video began to read, the video was shown, but after a moment continued.
Gazing in IDA and tracing has shown that the unit decode the video went in a loop and continuously passed through a few lines:
As it turned out, during play, the game checked the buttons ESC, left and right mouse buttons. If you skip the dialogue, click and start video playback, then for some reason in the buffer remained that click, which led to interruption of the video. For-NOP-IV transitions from the mouse and leaving the output of the video just by pressing the ESC managed to win a very nasty bug of the game.
Комментарии
Отправить комментарий