TIM CLUT Question

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
Post Reply
Kneesnap
Curious PSXDEV User
Curious PSXDEV User
Posts: 10
Joined: Sep 22, 2017
I am a: Programmer
PlayStation Model: DTL-H1000

TIM CLUT Question

Post by Kneesnap » September 1st, 2018, 12:39 pm

I am creating a modding tool for a PSX / PC game, and the PSX image format appears similar to the TIM file format.

I'm reading from this to try and understand how this works, but it seems to leave a key bit of information out.

Specifically,
Image


After reading the index values listed, how are those indexes related to the CLUT? How do I get a color from the CLUT from those numbers?

Kneesnap
Curious PSXDEV User
Curious PSXDEV User
Posts: 10
Joined: Sep 22, 2017
I am a: Programmer
PlayStation Model: DTL-H1000

Post by Kneesnap » September 1st, 2018, 8:01 pm

Alright, after a while I figured out several things.

1. I was not reading CLUTs properly.
2. It's just a 4-bit index (0-15), which can be grabbed easily from the CLUT.

However, this raises a new final problem:

I can't seem to figure out a way to determine which CLUT to use. There are around 150 CLUT tables just in this one file I'm testing with. If I hard-code the CLUT ID, it works perfectly, so I know I've gotten everything up until this point working.

The only data I seem to have is a "clut_id" short value, which appears to be generated by taking the x, y clut coordinates and turning it into a single number. It appears to be part of LIBGPU.H:

Code: Select all

#define getClut(x, y) 	(((y)<<6)|(((x)>>4)&0x3f))
However, either I am reversing this wrong, or this isn't going to help me figure out which CLUT to use.

I feel like it would probably be best at this point to try asking what others think, as the answer is probably right in front of me, I just don't see it.

Here are some things which may help me:

1. Please come up with some statements to take a number generated by the above getClut function, so I can confirm it's not just me doing the math wrong.

2. Given the structs below, what might be used to identify which CLUT to use?

Code: Select all

struct {
	RECT			ts_vram_rect;   // See below for struct. Holds Vram coordinates, and full image dimensions.
	MR_ULONG		ts_vram_offset; // Misleading name. This is just a pointer to where the image data is.
	MR_USHORT		ts_id;           // Texture ID.
	MR_USHORT		ts_tpage_id; // Texture Page ID.
	MR_USHORT		ts_clut_id;   // This is the value I mention above, presumed to be generated by getClut.
	MR_USHORT		ts_flags;      // Texture flags. Nothing much to see here.
	MR_UBYTE		ts_u;  // Used to create texture UVs
	MR_UBYTE		ts_v; //
	MR_UBYTE		ts_w; // In-game texture width. Some images have extra parts which get cut-off in-game. The full texture width is in vram_rect.
	MR_UBYTE		ts_h;  // In-game texture height. 
}; // "TXSETUP"

struct {
	short x; // Vram X
	short y; // Vram Y
	short w; // Width
	short h; // Height
}; // "RECT" This is the RECT struct from LIBGPU.H
3. Anyone with more experience that me that has any further insight than what I may have, feel free to share any tips or suggestions which might help out.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests