help with unknown texture format [eastward]

Textures, recreate headers, conversions, algorithms and parsing of image files
canboy
Posts: 42
Joined: Fri Jun 26, 2020 3:24 pm

help with unknown texture format [eastward]

Post by canboy »

i'm digging around the demo version of eastward, and found out that game use bmfont, but the texture have been encrypt to sth don't have extension, not png like be mention.
so i post here for someone plz help decrypt it.
tks u so much

edit:I think all of the png for this game use the same encrypt way, with pgf header, at $4-$7 is size of the file, at $C-$F is the offset of long size - 1D... But i dunno how to write a scrypt for bms :lol:
Last edited by canboy on Fri Sep 17, 2021 12:38 pm, edited 1 time in total.
canboy
Posts: 42
Joined: Fri Jun 26, 2020 3:24 pm

Re: help with unknown texture format [eastward]

Post by canboy »

Update released file of the game :v
Its seem that still use the same index like a demo file
LinkOFF
Posts: 88
Joined: Thu Aug 11, 2016 6:52 pm

Re: help with unknown texture format [eastward]

Post by LinkOFF »

My suggestion:

Code: Select all

0x00-0x02 (string) — magic “PGF”
0x03 (byte) — number of color channels? values from 1 to 4
0x04-0x07 (uint_32) — full pgf lenght

if(0x03 == 4)
    0x08 — 0x0B — ??

0x0C — 0x0F (uint_32) — data lenght
0x10-0x13 (uint_32) — width?
0x14 — 0x17 (uint_32) — height?
0x18 (byte) — bit depth?
0x19 — 0x1F — ??
canboy
Posts: 42
Joined: Fri Jun 26, 2020 3:24 pm

Re: help with unknown texture format [eastward]

Post by canboy »

LinkOFF wrote:My suggestion:

Code: Select all

0x00-0x02 (string) — magic “PGF”
0x03 (byte) — number of color channels? values from 1 to 4
0x04-0x07 (uint_32) — full pgf lenght

if(0x03 == 4)
    0x08 — 0x0B — ??

0x0C — 0x0F (uint_32) — data lenght
0x10-0x13 (uint_32) — width?
0x14 — 0x17 (uint_32) — height?
0x18 (byte) — bit depth?
0x19 — 0x1F — ??

So...
Is there anyway to view and edit that texture?
LinkOFF
Posts: 88
Joined: Thu Aug 11, 2016 6:52 pm

Re: help with unknown texture format [eastward]

Post by LinkOFF »

canboy wrote:So...
Is there anyway to view and edit that texture?

Idk what excatly pixel format is it.
canboy
Posts: 42
Joined: Fri Jun 26, 2020 3:24 pm

Re: help with unknown texture format [eastward]

Post by canboy »

LinkOFF wrote:
canboy wrote:So...
Is there anyway to view and edit that texture?

Idk what excatly pixel format is it.

Could there anyway to Guess that format?
canboy
Posts: 42
Joined: Fri Jun 26, 2020 3:24 pm

Re: help with unknown texture format [eastward]

Post by canboy »

LinkOFF wrote:
canboy wrote:So...
Is there anyway to view and edit that texture?

Idk what excatly pixel format is it.

i found in library something like

Code: Select all

<$0C>setRGBA<$08>

is it helpful?
canboy
Posts: 42
Joined: Fri Jun 26, 2020 3:24 pm

Re: help with unknown texture format [eastward]

Post by canboy »

some another information i'm digging around
balbasar
Posts: 3
Joined: Tue Sep 21, 2021 10:24 pm

Re: help with unknown texture format [eastward]

Post by balbasar »

So those files look like compiled LuaJIT. I was able to run them through an appropriate decompiler to get legible code. Nothing that really elucidated anything about the "PGF" format. Where did you pull the files from the assets file from? I wasn't able to find those going through the g archives but I don't believe I looked very closely
canboy
Posts: 42
Joined: Fri Jun 26, 2020 3:24 pm

Re: help with unknown texture format [eastward]

Post by canboy »

balbasar wrote:So those files look like compiled LuaJIT. I was able to run them through an appropriate decompiler to get legible code. Nothing that really elucidated anything about the "PGF" format. Where did you pull the files from the assets file from? I wasn't able to find those going through the g archives but I don't believe I looked very closely

it's inside the lib.g actually
mock/gfx/asset
balbasar
Posts: 3
Joined: Tue Sep 21, 2021 10:24 pm

Re: help with unknown texture format [eastward]

Post by balbasar »

Ah I see, I found it. I wasn't using quickbms to extract the .g files and was only pulling 2 levels of files out. Now I can peruse them. I see mentions of loading the decks and atlas textures but I'll have to pore through it to try to see if there are any good hints for interpreting the data.
balbasar
Posts: 3
Joined: Tue Sep 21, 2021 10:24 pm

Re: help with unknown texture format [eastward]

Post by balbasar »

Small update:
Looking more into the files the offsets appear inconsistent therefore leading me to believe either there is some serialization/deflating that is occurring. Additionally some files have less bytes than the resolution marked in the accompanying json file (so definitely some compression or deflation).

The lua files themselves don't really go into the file parsing, rather they make use of lua-cpp bindings provided by the MOAI Framework. This framework is open source and compiled into the game binary. The author of this game forked their own version and added a MOAIImageFormatHmg class to interpret hmg (and I assume the atlas files as well since they share the starting magic bytes even though they are not .hmg terminated). I poked around a bit with ghidra but I'm no where near competent with it. I may be able to make a bit more headway with debugger so I can plod my way to where these files are loaded and how.

There may be an easier way of doing this but I have yet to find it.
Delutto
Posts: 561
Joined: Tue Oct 13, 2015 1:26 pm

Re: help with unknown texture format [eastward]

Post by Delutto »

canboy wrote:found out that game use bmfont
No, the game fonts are in the ttf.g package and are regular font files.
Last edited by Delutto on Fri Sep 24, 2021 3:52 am, edited 1 time in total.
canboy
Posts: 42
Joined: Fri Jun 26, 2020 3:24 pm

Re: help with unknown texture format [eastward]

Post by canboy »

Delutto wrote:
canboy wrote:found out that game use bmfont
No, the game fonts are in the ttf.g package and are regular font files. Both smallest files are TTF fonts and the others are OTF.

not at all
the dialog font are bitmap,store in font.g, but can switch to ttf normally
i'm just curios about how to view that font image
Delutto
Posts: 561
Joined: Tue Oct 13, 2015 1:26 pm

Re: help with unknown texture format [eastward]

Post by Delutto »

canboy wrote:not at all
the dialog font are bitmap,store in font.g, but can switch to ttf normally
i'm just curios about how to view that font image
Well, so the devs left some junk fonts behind, because there are many ttf and otf fonts files...

ttf.g
Image

font.g
Image
canboy
Posts: 42
Joined: Fri Jun 26, 2020 3:24 pm

Re: help with unknown texture format [eastward]

Post by canboy »

Delutto wrote:
canboy wrote:not at all
the dialog font are bitmap,store in font.g, but can switch to ttf normally
i'm just curios about how to view that font image
Well, so the devs left some junk fonts behind, because there are many ttf and otf fonts files...

ttf.g
Image

font.g
Image

Well we can use that ttf to translate instead of bitmap font but that font in game have some weird problem so i still prefer use the bitmap font instead
Somehow right now i could only use the ttf one.
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: help with unknown texture format [eastward]

Post by Allen »

The data is compressed, and I scanned it with quickbms to show that it uses the "LZ77EA_970" compression algorithm.

Format:

Code: Select all

char    magic[3];//PGF
byte    unkLen;
DWORD   fileSize;
byte    unkData[unkLen];
DWORD   dataSize;
DWORD   width;
DWORD   height;
byte    bpp;
byte    unk2;
byte    unkLen2;
byte    unk3;
byte    unkData2[unkLen2];
byte    datas[dataSize];

Image


If change comtype to LZ4, it Also Worked.
It should be used LZ4 compression algorithm, but they have the same algorithm for decompressing data.
canboy
Posts: 42
Joined: Fri Jun 26, 2020 3:24 pm

Re: help with unknown texture format [eastward]

Post by canboy »

Allen wrote:The data is compressed, and I scanned it with quickbms to show that it uses the "LZ77EA_970" compression algorithm.

Format:

Code: Select all

char    magic[3];//PGF
byte    unkLen;
DWORD   fileSize;
byte    unkData[unkLen];
DWORD   dataSize;
DWORD   width;
DWORD   height;
byte    bpp;
byte    unk2;
byte    unkLen2;
byte    unk3;
byte    unkData2[unkLen2];
byte    datas[dataSize];

Image


If change comtype to LZ4, it Also Worked.
It should be used LZ4 compression algorithm, but they have the same algorithm for decompressing data.

It's kinda work.
Tks bro
HydeFromT70s
Posts: 4
Joined: Mon Nov 02, 2020 1:14 pm

Re: help with unknown texture format [eastward]

Post by HydeFromT70s »

Guys, do you know exactly which file in font.g or ttf.g is responsible for in-game font and how can I edit it to add some additional characters?
cyborg77
Posts: 2
Joined: Tue Oct 05, 2021 7:07 pm

Re: help with unknown texture format [eastward]

Post by cyborg77 »

HydeFromT70s wrote:Guys, do you know exactly which file in font.g or ttf.g is responsible for in-game font and how can I edit it to add some additional characters?


...

font: CyborgSister.fnt
font/7b7429240ecf3b09c2bbf45524914d80

pixmap: CyborgSister.png
font/44543f1de71bbc95b2cc75c356c00bd5

Code: Select all

./quickbms -o -d eastward.bms font.g_extract/44543f1de71bbc95b2cc75c356c00bd5


Image


https://www.dafont.com/cyborgsister.font