[Question] Can i create TIM with multiple CLUT's?
-
NITROYUASH Verified
- Serious PSXDEV User
- Posts: 124
- Joined: Jan 07, 2018
- I am a: Game Designer
- PlayStation Model: SCPH-5502
- Location: Russian Federation
- Contact:
[Question] Can i create TIM with multiple CLUT's?
Hi guys. I want to create a TIM with multiple palettes (CLUT's). Is it possible?
Never seen any utilities to add more CLUT's to TIM from TIM Tool v3 or anything else.
Never seen any utilities to add more CLUT's to TIM from TIM Tool v3 or anything else.
-
LameGuy64 Verified
- Psy-Q Enthusiast
- Posts: 388
- Joined: Apr 10, 2013
- I am a: Hobbyist Game Developer
- Motto: Commercial or not, play it!
- PlayStation Model: H2000/7000
- Location: Philippines
- Contact:
So far there aren't any tools that support placing multiple CLUTs inside a single TIM. You could however create a 16-bit TIM containing multiple CLUT rows as a workaround.
Please don't forget to include my name if you share my work around. Credit where it is due.
Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.
DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.
Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.
DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.
-
NITROYUASH Verified
- Serious PSXDEV User
- Posts: 124
- Joined: Jan 07, 2018
- I am a: Game Designer
- PlayStation Model: SCPH-5502
- Location: Russian Federation
- Contact:
Do i need to add 16b CLUT's as a regular image then swap palette using something like setClut, right?
It's working only for 16-bit TIM's?
It's working only for 16-bit TIM's?
-
LameGuy64 Verified
- Psy-Q Enthusiast
- Posts: 388
- Joined: Apr 10, 2013
- I am a: Hobbyist Game Developer
- Motto: Commercial or not, play it!
- PlayStation Model: H2000/7000
- Location: Philippines
- Contact:
You store the CLUTs as a regular 16-bit TIM file (ie. a TIM containing 8 CLUTs would be 256x8 for 8-bit CLUTs or 16x8 for 4-bit CLUTs) and then use its image coordinates on setClut. To select the other CLUTs simply increment the y coordinate from the coordinates where your TIM of CLUTs is positioned to.
Remember that CLUTs are always strips of 16-bit color pixels.
Remember that CLUTs are always strips of 16-bit color pixels.
Please don't forget to include my name if you share my work around. Credit where it is due.
Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.
DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.
Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.
DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.
-
gwald Verified
- Net Yaroze Enthusiast
- Posts: 289
- Joined: Sep 18, 2013
- I am a: programmer/DBA
- PlayStation Model: Net Yaroze
- Contact:
I thought 16bit tims don't have CLUT's?
I did 4bit clut generation and clut swapping.. via brute forcing it..
Saving a single image (different colours in a clut) and timtool that image (move it to the display buffer.. not needed) and clut (keep it safe), then in code you just swap between cluts.
I'm starting to forget the details :'(
Okay I remember now, so i have sprite animation (doom trooper), each animation cell has it's own set of colours, ie green, red, purple, yellow etc etc.
In code you store the soldier's colour (Clut index to a clut array) and when rendering it, you use that.. not the TIM's clut (or it'll flash different colours).
Because I don't need each CLUT to be the same (duplicate data) I change each CLUT to be unique colours.
If that makes sense??
It was the easiest way, i'm sure there's better ways.
https://www.youtube.com/watch?v=L8nat6ZMOuc
[BBvideo=560,315]https://www.youtube.com/watch?v=L8nat6ZMOuc[/BBvideo]
I did 4bit clut generation and clut swapping.. via brute forcing it..
Saving a single image (different colours in a clut) and timtool that image (move it to the display buffer.. not needed) and clut (keep it safe), then in code you just swap between cluts.
I'm starting to forget the details :'(
Okay I remember now, so i have sprite animation (doom trooper), each animation cell has it's own set of colours, ie green, red, purple, yellow etc etc.
In code you store the soldier's colour (Clut index to a clut array) and when rendering it, you use that.. not the TIM's clut (or it'll flash different colours).
Because I don't need each CLUT to be the same (duplicate data) I change each CLUT to be unique colours.
If that makes sense??
It was the easiest way, i'm sure there's better ways.
https://www.youtube.com/watch?v=L8nat6ZMOuc
[BBvideo=560,315]https://www.youtube.com/watch?v=L8nat6ZMOuc[/BBvideo]
-
LameGuy64 Verified
- Psy-Q Enthusiast
- Posts: 388
- Joined: Apr 10, 2013
- I am a: Hobbyist Game Developer
- Motto: Commercial or not, play it!
- PlayStation Model: H2000/7000
- Location: Philippines
- Contact:
I was meaning to say having a TIM containing a bunch of CLUTs as a 16-bit texture image. A CLUT is really just a 1 pixel high 16-bit texture that is no different to a 16-bit texture image.
Technically a 16-bit TIM can contain a CLUT but its not really necessary to have a CLUT in one. Multiple CLUTs can be stored inside a single TIM as the file format treats the CLUT data like a texture image as well but all currently available TIM tools don't support it.
Technically a 16-bit TIM can contain a CLUT but its not really necessary to have a CLUT in one. Multiple CLUTs can be stored inside a single TIM as the file format treats the CLUT data like a texture image as well but all currently available TIM tools don't support it.
Please don't forget to include my name if you share my work around. Credit where it is due.
Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.
DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.
Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.
DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.
-
NITROYUASH Verified
- Serious PSXDEV User
- Posts: 124
- Joined: Jan 07, 2018
- I am a: Game Designer
- PlayStation Model: SCPH-5502
- Location: Russian Federation
- Contact:
Interesting.
But i have an idea too. What if we create CLUT inside the game code and then write result to VRAM? Can we? :)
But i have an idea too. What if we create CLUT inside the game code and then write result to VRAM? Can we? :)
-
LameGuy64 Verified
- Psy-Q Enthusiast
- Posts: 388
- Joined: Apr 10, 2013
- I am a: Hobbyist Game Developer
- Motto: Commercial or not, play it!
- PlayStation Model: H2000/7000
- Location: Philippines
- Contact:
Should be doable with this kind of struct:
Make an array out of it with 16 elements for a 16 color CLUT or 256 for a 256 color CLUT and then upload them to VRAM like this:
Code: Select all
typedef struct {
unsigned short r:5;
unsigned short g:5;
unsigned short b:5;
unsigned short i:1; // Mask bit used for transparencies
} PIX16;
Code: Select all
RECT crect;
crect.x = < desired x position of clut >;
crect.y = < desired y position of clut >;
crect.w = 256; // 16 for 16 color CLUTs
crect.h = 1;
LoadImage( &crect, clutdata );
Please don't forget to include my name if you share my work around. Credit where it is due.
Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.
DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.
Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.
DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.
-
NITROYUASH Verified
- Serious PSXDEV User
- Posts: 124
- Joined: Jan 07, 2018
- I am a: Game Designer
- PlayStation Model: SCPH-5502
- Location: Russian Federation
- Contact:
Sorry to not tested your code so long, but yesterday i wrote the code based on your example. And yes, looks like it's working. Thanks. :>
Code: Select all
// Custom Palette (CLUT) structs
typedef struct {
u_short r:5;
u_short g:5;
u_short b:5;
u_short i:1; // Mask bit used for transparencies
} CPAL;
CPAL FNT1_pal_red[256] = {
0,0,0,1, 15,0,0,0, 30,0,0,0, 45,0,0,0,
60,0,0,0, 75,0,0,0, 90,0,0,0, 105,0,0,0,
120,0,0,0, 135,0,0,0, 150,0,0,0, 165,0,0,0,
180,0,0,0, 195,0,0,0, 210,0,0,0, 225,0,0,0,
240,0,0,0, 255,0,0,0,
};
/* Record custom CLUT-Palette to VRAM.
input: Insert CLUT here
clr_list: List of colors in CLUT
X/Y: VRAM Coordinates, where the new palette will be saved */
void SetCustomCLUT(CPAL *input, short clr_list, int X, int Y) {
int i,type;
RECT rect; // Init rectangular area
if (clr_list <= 16) type = 16;
else type = 256;
// Erase junk fron unused part of output-CLUT
for (i = clr_list; i < type; i++) {
input[i].r = 0; input[i].g = 0;
input[i].b = 0; input[i].i = 0;
}
rect.x = X;
rect.y = Y;
rect.h = 1; // Always 1
rect.w = type; // CLUT size
LoadImage(&rect, (u_long*)input);
}
Code: Select all
int main(void) {
// Graphics initializer
startup_init();
SetCustomCLUT(FNT1_pal_red, 18, 700, 14);
while(1) {
PrepDisp();
FntPrint("Do something!");
Display();
}
}
-
NITROYUASH Verified
- Serious PSXDEV User
- Posts: 124
- Joined: Jan 07, 2018
- I am a: Game Designer
- PlayStation Model: SCPH-5502
- Location: Russian Federation
- Contact:
U P D:
Something else is needed here. The initialized CLUT cannot be used for any images because final colors from SetCustomCLUT() are distorted.
Something else is needed here. The initialized CLUT cannot be used for any images because final colors from SetCustomCLUT() are distorted.
► Show Spoiler
Who is online
Users browsing this forum: No registered users and 1 guest