Hello! I write the program for unpacking resources LBX for MoO2, because did not see worthy clones such programmatic thing. I writing for entertainment, so only I shall complete I shall present for critics of a public.
By the current moment I understood with formats for LBX, pictures, graphic pallets, text, video, sounds, leaders. Yet I can not understand the format of fonts. The format of a font is not similar to formats of fonts DOS or Windows. There can be it raster, but it have many parameters in header. While I conduct works, hoped, that there can be someone disposes the given information.
Format of resources in MoO2
- Grig de Griz
- Posts:48
- Joined:Mon Sep 26, 2005 12:23 am
- Location:Russia
Hi de Griz,
this is interesting, I also reengeneered the format of the data files of
MOO2, and also got stuck at the fonts. Did you make any progress yet ?
By the way, I got somewhere in my "MOO2 Video player" a little bug, that
produces ugly artifacts, would you mind of posting your video decoding
algorithm ?
Hm and actually there was annother thing where I got stuck : some images
have a pallete, other do not have it, I never figured out which palette is
used in this case. From what I can tell, there seems to be some sort of
merges color palette. Did you find out something in this direction ?
And last but not least : The funky ID in the image files, some mean, with
color palette or animation ... How many IDs do you know ? Seems to be
some sort of bitshifting thing... If you are interested, I can post my work
here.
ScoTch
this is interesting, I also reengeneered the format of the data files of
MOO2, and also got stuck at the fonts. Did you make any progress yet ?
By the way, I got somewhere in my "MOO2 Video player" a little bug, that
produces ugly artifacts, would you mind of posting your video decoding
algorithm ?
Hm and actually there was annother thing where I got stuck : some images
have a pallete, other do not have it, I never figured out which palette is
used in this case. From what I can tell, there seems to be some sort of
merges color palette. Did you find out something in this direction ?
And last but not least : The funky ID in the image files, some mean, with
color palette or animation ... How many IDs do you know ? Seems to be
some sort of bitshifting thing... If you are interested, I can post my work
here.
ScoTch
- Grig de Griz
- Posts:48
- Joined:Mon Sep 26, 2005 12:23 am
- Location:Russia
I have not problems at view of picture or animate-picture. Work with pallets I too do correctly. I have written the documentation on formats, but has not made yet not exact English version. If you want to make translation from my poor English on good English, you can help me (write to my e-mail). Differently wait for an fulfilment of the english documentation.
Hi. At some time I decoded the font format; it has a RLE compression similar to the images, but using 4-bit integers instead of 8-bit.
The following code runs under linux+gcc+SDL. I think it should work in windows too, you can get the algorithm from it. Ask here if you got more questions:
Sorry for sending just code. I have a written explanation about this, but it is in spanish and I am lazy today to translate it
See you around,
trixx
The following code runs under linux+gcc+SDL. I think it should work in windows too, you can get the algorithm from it. Ask here if you got more questions:
Code: Select all
Uint16 metricstable_base = 0x059c,
metricstable_size = 0x0100,
glyphstable_base = 0x0b9c,
glyphstable_size = 0x0400,
data_base = 0x239c;
SDL_Surface* MPF_Load(SDL_RWops* f, Uint16 *pal, int font)
{
Uint8 size;
Uint32 offset, next, i;
Uint8 buffer[3001];
int glyph;
Uint32 width = 0, height = 0;
SDL_Surface *img;
Uint32 x, y, startx;
/* Create Surface */
/* get Surface Width */
for (glyph = 32; glyph < 127; glyph++)
{
SDL_RWseek (f, metricstable_base + metricstable_size * font + glyph, SEEK_SET);
SDL_RWread (f, &size, 1, 1);
width += 2 + size;
}
/* get Surface Height, measure arbitrarily from Character 42 */
SDL_RWseek (f, metricstable_base + metricstable_size * font + 42, SEEK_SET);
SDL_RWread (f, &size, 1, 1);
SDL_RWseek (f, glyphstable_base + glyphstable_size * font + 42 * 4, SEEK_SET);
SDL_RWread (f, &offset, 4, 1);
SDL_RWread (f, &next, 4, 1);
SDL_RWseek (f, offset + data_base, SEEK_SET);
SDL_RWread (f, buffer, 1, next - offset);
for (i = 0; i < next - offset; i++)
if (buffer[i] == (Uint8)0x80)
height++;
img = SDL_CreateRGBSurface (SDL_SWSURFACE, width, height, 24, 0xf80000, 0x7e000, 0x1f00, 0xff);
startx = 0;
x = 0;
for (glyph = 33; glyph < 127; glyph++)
{
y = 0;
/* Get glyph width */
SDL_RWseek (f, metricstable_base + metricstable_size * font + glyph, SEEK_SET);
SDL_RWread (f, &size, 1, 1);
/* Get glyph offset */
SDL_RWseek (f, glyphstable_base + glyphstable_size * font + glyph * 4, SEEK_SET);
SDL_RWread (f, &offset, 4, 1);
SDL_RWread (f, &next, 4, 1);
SDL_RWseek (f, offset + data_base, SEEK_SET);
SDL_RWread (f, buffer, 1, next - offset);
for (i = 0; i < next - offset; i++)
{
if (buffer[i]<0x80)
{
if (pal)
{
((Uint8 *)(img->pixels))[y * img->pitch + x * 3 + 2] = ((Uint8*)pal)[(buffer[i] - 1) * 2];
((Uint8 *)(img->pixels))[y * img->pitch + x * 3 + 1] = ((Uint8*)pal)[(buffer[i] - 1) * 2 + 1];
((Uint8 *)(img->pixels))[y * img->pitch + x * 3 + 0] = 0xff;
}
else
{
((Uint8 *)(img->pixels))[y * img->pitch + x * 3 + 2] = 0;
((Uint8 *)(img->pixels))[y * img->pitch + x * 3 + 1] = buffer[i];
((Uint8 *)(img->pixels))[y * img->pitch + x * 3 + 0] = 0xff;
}
x++;
}
else if (buffer[i] == (Uint8)0x80)
{
y++;
x = startx;
}
else
{
x += buffer[i] - 0x80;
}
}
((Uint8 *)(img->pixels))[(startx + size + 1) * 3 + 2] = 0xf8;
((Uint8 *)(img->pixels))[(startx + size + 1) * 3 + 1] = 0x1f;
((Uint8 *)(img->pixels))[(startx + size + 1) * 3 + 0] = 0xff;
startx += size + 2;
x = startx;
}
return img;
}
See you around,
trixx
- Grig de Griz
- Posts:48
- Joined:Mon Sep 26, 2005 12:23 am
- Location:Russia
- Grig de Griz
- Posts:48
- Joined:Mon Sep 26, 2005 12:23 am
- Location:Russia
The browse of unknown area of fonts's files:
That is marked "!" Equally in both files (Fonts.000.lbx and Ifonts.000.lbx).
What is it? The keyboard's driver? Header similar 16-bit DLL?
Code: Select all
---------------------------------------------------------------------
0x0000 to 0x0004 - ! 0x19 (Int)
0x0004 to 0x0008 - ! 0x32 (Int)
0x0008 to 0x0040 - Bytes...
0x0040 to 0x0184 - ! Zero. In middle which one 248 units Bytes (0x08)
0x0184 to 0x0568 - ! 248 units Integers on increase.
0x0568 to 0x059C - Bytes...
---------------------------------------------------------------------
What is it? The keyboard's driver? Header similar 16-bit DLL?
(MOO fonts seem to have characters ranging from 0 to 127 only, not 255).
Later:
It works. What there is before a offset "metricstable_base"?
Your program have bug if to read characters from 0 to 255.
The incomplete information I have about the rest of the file is (offsets in hex):
Code: Select all
0000-0071: ?
0072-016a: All bytes containing 08
-0567: Looks like a table of 4-byte offsets
0568-059b: ? apparently 16 bit values
059c-069b: metrics table, i.e., width of each character in the font
You have 5 more of this; each font file contains 6 fonts
0b9c-0f9b: offsets of each glyph; 0000 means beginning of glyph data, not of lbx resource.
There are 256 entries, but the last 128 didn't seem to make sense. Again, 5 more of this tables for the other fonts
239c-...: font data. offsets are based at this point
0x00-0x7f: color of next pixel
0x80: skip to beginning of next line
0x8n: skip n pixels
- Grig de Griz
- Posts:48
- Joined:Mon Sep 26, 2005 12:23 am
- Location:Russia
MoO2's fonts is ASCII code table (00-FF). You are right only on the English alphabet. Many characters in the European languages have values >=0x80. In particular, the characters such as ?, ?, ?, ?, and so on all have values >=0x80. For example, all codes of Russian characters >= 0x80.(MOO fonts seem to have characters ranging from 0 to 127 only, not 255).
New information about MoO2's fonts:
Code: Select all
----------------------------------------------------
Offset | Size | Description
----------------------------------------------------
0x0568 | 4 | Separator or reserved. Must be zero.
0x056C | 12 | Font's heights. Array of word.
0x0578 | 4 | Separator or reserved. Must be zero.
0x057C | 12 | Fonts glyph spacings. Array of word.
0x0588 | 4 | Separator or reserved. Must be zero.
0x058C | 12 | Fonts line spacings. Array of word.
0x0598 | 4 | Separator or reserved. Must be zero.
0x059C | ... | Further you know...
Return to “Game Modifications”
Who is online
Users browsing this forum: No registered users and 118 guests