Jump to content

SA .txd files...


Yegorchic

Recommended Posts

Hello to evrybody...

 

Can somebody tell me about GTA SA .txd files. I mean, can somebody tell me, how this files coded... m... I think you understood me...

 

Sorry for my bad English...

Link to comment
Share on other sites

Well, I have code in C# for reading the TXD files... I don't have a generic format written up.. let me know if that will help and I can post it.

Link to comment
Share on other sites

Please, post this algorithm of decoding .txd it if you can.

 

---

But I know C# not well, because I learnt Delphi.

Link to comment
Share on other sites

Spookie haves released the source of ViceTXD.

I'm searching how to handle the SA IMG format with Delphi 7.

I have IMG 1.3 but I have everything tried.

Don't work confused.gif

Link to comment
Share on other sites

Doesn't seem like I can attach files here.. so fetch from here: http://aru.nd4spdworld.com/pic/rwtxd.zip

 

You need to write your own decoder for TXDDecoder.Decode() since my code has some stuff I have to rewrite properly before I can post it... no time that now. Sorry for lack of comments.. and some stuff could be done better than the approach I took in that.. especially with the code redundancies in classes that inherit RWBaseBlock.

 

If you have Delphi 2005 (I think), you can compile your app to a Delphi .NET app and access the code from those classes as a C# dll. But they are pretty small, so converting to Delphi shouldn't be a problem.

 

Good luck with whatever it is you guys are doing smile.gif.

Link to comment
Share on other sites

aru, I think I want to do tool, that you did. I wrote my IMG Reader, and now I want to make texure preview.

 

I rogramming on Delphi 7, and I don't like Delphi 8 and 2005, because I think it especially it for .NET.

 

Thank you!

Link to comment
Share on other sites

Thank you Steve-M.

 

[edit]

Link is not working confused.gif (In the post of Delfi)

[/edit]

 

[edit2]

Already downloaded it.

In july. (Forget)

 

But I have one question.

How to update the IMG Tool 1.3 (Source) code with this one confused.gif

I'm not the best @ Opening files and stuff.

 

So please someone can help me.

 

If needed I will open new topic.

[/edit2]

Edited by Jarno
Link to comment
Share on other sites

This is sructure of IMG file v2.0 (it's work in my prog.):

First 4 bytes must be "VER2"

Then you must read 3 bytes - this is count of files.

Then go files table. In Delphi I wrote that:

type

TIMG = record

StartBlock: Longword; // Start of block

BlockCount: Longword; // Size of block

Name: array[1..24] of Char; // file name

end;

 

And you must read 32 bytes for file.

 

For finding real size of block and block start you must BlockCount*2048 and StartBlock*2048.

 

And for "real file size" you must BlockCount*2.

 

I think that's all.

Link to comment
Share on other sites

I rogramming on Delphi 7, and I don't like Delphi 8 and 2005, because I think it especially it for .NET.

delphi 8 is .net only, but 2005 enables win32 development again.

 

altrough delphi 4 rules all the way wink.gif

 

Currently working on Top Down City Game, a classics top down game similar to GTA1 & GTA2: 

 

Thread Info: https://gtaforums.com/topic/911312-new-game-top-down-city/

Youtube channel: https://www.youtube.com/channel/UCxGfOh3ld7Xm-ic3KEMB6iA 

Discord: https://discord.gg/UXmDPzS - join #bridge channel 

Link to comment
Share on other sites

off topic but hey, I gotta know:

 

Dammit jarno, I have been clicking that moving X for days! Nothing has happened! Why does this dancing error graphic enthrawl me so? Please tell me what it's all about as I can tell now after many tests that it indeed does nothing! lol

 

And happy forum birthday the eleventh tounge.gif

Link to comment
Share on other sites

Dammit jarno, I have been clicking that moving X for days! Nothing has happened! Why does this dancing error graphic enthrawl me so? Please tell me what it's all about as I can tell now after many tests that it indeed does nothing! lol

To keep stupids busy I guess... wink.gif

Link to comment
Share on other sites

Dammit jarno, I have been clicking that moving X for days! Nothing has happened! Why does this dancing error graphic enthrawl me so? Please tell me what it's all about as I can tell now after many tests that it indeed does nothing! lol

Sorry but how you mean? confused.gif

 

Please can somebody take the code of IMGTool1.3 and make it compitable for SA.

Thanks in advance.

Link to comment
Share on other sites

Yegorchic, I don't know how to do that with IMG Tool 1.3

Maybe you want to do it for me please.

If needed PM me or something and I will sent source.

Link to comment
Share on other sites

Ow... I learnt, learnt and learnt aru's C code, but not understood it all... can somebody say me algorithm of .TXD files???

Link to comment
Share on other sites

Okay lets see... this might make a bit more sense than the OOP'd C# code

 

Basic chunk header format, all chunks in any txd or dff file starts like this. (see this for more info: http://www.chronetal.co.uk/gta/index.php?page=dff) Each chunk may be composed of data or more chunks. This is RWHeader in my code.

 

Header {

DWORD Type;

DWORD Size;

WORD Unknown;

WORD Version;

}

 

Type may be one of the following (defined as enum RWTypes in my code):

 

TXDStruct = 0x1,

TXDExtension = 0x3,

TXDTexture = 0x15,

TXDFile = 0x16,

 

The generic format tree is as follows,

 

TXDFile (or known as Clump normally)

-- TXDStruct (defined as RWTXDInfo in my code)

-- TXDTexture

---- TXDStruct (defined as RWTXDData)

-- TXDTexture

---- TXDStruct (defined as RWTXDData)

etc..

 

For reading purposes, just ignore any other chunks that come up. Since you have size of the chunk, you can just skip it to find the next chunk. In the tree above, you see that only TXDStruct chunks have data, TXDFile and TXDTexture just contain more chunks.

 

Now for the format of the data in RWTXDInfo:

 

RWTXDInfo {

WORD Count; // This the number of textures in the file

WORD Unknown;

}

 

and for the format of the data in TDTXDData:

 

TDTXDData {

 

DWORD Version;

DWORD FilterFlags;

BYTE TextureName[32]; // Null terminated string

BYTE AlphaName[32]; // Null terminated string

DWORD AlphaFlags;

DWORD D3DTextureFormat;

WORD Width;

WORD Height;

BYTE BitDepth;

BYTE MipMapCount;

BYTE TexCodeType;

BYTE Flags;

 

BYTE Palette[256*4]; // Only present if BitDepth == 8

 

DWORD DataSize;

BYTE Data[DataSize];

 

// If MipMapCount > 1, then the following two repeats (MipMapCount-1) times

DWORD MipMapDataSize;

BYTE MipMapData[MipMapDataSize];

 

}

 

Now Data above will contain the texture data. If D3DTextureFormat is set to a FOURCC code of "DXT3" or "DXT1", you need to DXT decode the Data block to get your 16 bpp texture data. Otherwise, just look at the BitDepth and decode the Data accordingly. If BitDepth is 8, then palette contains your 256 colour texture palette, Data is a byte array of ptrs into the palette. If BitDepth is 16, then the texture is in 565 format I think (1555 if bit0 of Flags is set -- this tells that the texture has an alpha channel). If the bitdepth is 32, then its just the normal 24bit texture with a 8bit alpha channel (if alpha present, otherwise just ignore the extra 8 bits).

 

Ideally, you should just be able to figure out the format from D3DTextureFormat, but I'm not if this was only introduced in later versions of the TXD format or if TXD Workshop writes the wrong value for it... just looking at the D3DFormat value doesn't always work!

Link to comment
Share on other sites

 

If someone compiling new MooMapper with SA DFF/TXD loaders, please give me it! At me no Delfi.

how can't people finally for once understand that altrough the txd and dff loaders are updated the moomapper still won't edit san andreas maps.

 

it is not enough, it also needs new img loader, ipl parser, binary ipl parser etc..

i updated the dff and txd loaders because i use them in GGMM and they work well there because i don't have to read map files.

 

Edited by Delfi

Currently working on Top Down City Game, a classics top down game similar to GTA1 & GTA2: 

 

Thread Info: https://gtaforums.com/topic/911312-new-game-top-down-city/

Youtube channel: https://www.youtube.com/channel/UCxGfOh3ld7Xm-ic3KEMB6iA 

Discord: https://discord.gg/UXmDPzS - join #bridge channel 

Link to comment
Share on other sites

But can you update it in the Internet, because gtaconnection, how you said, doesn't work!

No, i can't because i don't have the internet at home and have to go to library where i can't upload to FTP because stupid firewall blocks its connection ports.

 

Currently working on Top Down City Game, a classics top down game similar to GTA1 & GTA2: 

 

Thread Info: https://gtaforums.com/topic/911312-new-game-top-down-city/

Youtube channel: https://www.youtube.com/channel/UCxGfOh3ld7Xm-ic3KEMB6iA 

Discord: https://discord.gg/UXmDPzS - join #bridge channel 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.