dgcor / DGEngine

An implementation of the Diablo 1 game engine
Other
243 stars 30 forks source link

Original font sizes #3

Closed mewmew closed 7 years ago

mewmew commented 8 years ago

From the Contributing wiki page:

Font char sizes

Some CEL fonts use .bin files that say the number of pixels each char takes when drawing and another that maps each CEL frame to each ASCII char. These files are in res/level

The bigtgoldSize.bin file specifies the size for the font used in the quest's scrolling texts. These sizes are not correct and that's why the texts are truncated when displayed in game.

The first 2 bytes in this file are for line break and space size. Then comes the size for each ASCII letter (256). The tedious work to be done here is to compare the scrolling texts in the original game and make sure each char has the exact same size. One can use a hex editor to edit bigtgoldSize.bin.

For each font, there exist a dedicated array which maps from frame number to character width (note, the character width may be distinct from the frame width, which is 13 for every smaltext.cel frame, 22 for every medtexts.cel frame, and 46 for every bigtgold.cel frame).

These arrays are contained within the Diablo executable, and for version 1.09 and 1.09b, the virtual addresses of these arrays are 0x4794a4, 0x47f0f8, and 0x47a50c for smaltext.cel, medtexts.cel and bigtgold.cel, respectively.

I hope this may help resolve the font rendering issues. Let us know if anything remains unclear, in which case we'll make sure to update the notes on sanctuary.

Cheers /u

ghost commented 8 years ago

Thank you for the tip. I will update the font sizes to reflect this information.

Edit: I have updated the code with the correct mappings for the 3 fonts above. I also updated the gamefiles to use the new fonts.

mewmew commented 8 years ago

I have updated the code with the correct mappings for the 3 fonts above. I also updated the gamefiles to use the new fonts.

Great to hear!

I had a look and it seems like there are still some issues remaining related to font rendering. Whether these are caused by incorrect font character sizes, or incorrect rendering of CEL images, I am not sure.

The following notes relate to revision 40afab360a26f087b2b3e72b8c8f1794e5cb50c2.

The L character is not renedered at all in the quest log window, or the information console.

Invisible L character

The number 1 is incorrectly rendered in the character information screen (e.g. see character level 1, and base magic 10).

Incorrect rendering of number 1

ghost commented 8 years ago

These font issues are known and are because of the CEL decoding code. freeablo had them as well. They updated the cel rendering code to remove these (using your blizzconv project as reference). I looked into integrating the changes, but dropped that as the new implementation hardcodes cel names and frame numbers into the code and I don't want to do that.

CEL decoding is good enough for now to evolve on other parts of the code (level/player logic) so this decoding issue will be left on hold until the level/player code is done.

mewmew commented 8 years ago

I looked into integrating the changes, but dropped that as the new implementation hardcodes cel names and frame numbers into the code and I don't want to do that.

I know, the blizzconv code is ancient and has started to show its age. A complete rewrite is slowly taking place at https://github.com/sanctuary/formats, which generates lookup tables from the level MIN files, thus no longer relying on file name and frame number magic (see https://github.com/wheybags/freeablo/issues/213#issuecomment-223789869 for background discussion). The new implementation is currently capable of correctly decoding all CEL and CL2 images to the best of our knowledge. Take a look if you feel like it.

CEL decoding is good enough for now to evolve on other parts of the code (level/player logic) so this decoding issue will be left on hold until the level/player code is done.

Sure, sounds resonable enough. This is basically following the one-of-everything approach taken by FLARE.

From http://flarerpg.org/blog/20121218

I worked on getting "one of everything" into the game: one tile set, one hero sprite set, one weapon, one creature.

ghost commented 7 years ago

In the last commit (59f7c0c), font decoding got fixed. All letters are now decoded properly.

mewmew commented 7 years ago

Good job. Closing this issue as it has been resolved.