Author
|
Topic: Extracting palettes from a PSX game. (Read 2 times)
|
sb iq
Guest
|
|
« on: October 28, 2006, 04:26:25 am » |
|
I know palettes can be extracted from save states for emulators for the SNES, Genesis, etc., with Tile Molester, but I don't know how it can be done with a PSX game. I'm trying to extact the palette from Tomb Raider 2 for the PlayStation. I was told I can use Peops soft GPU with epsxe to view the VRAM with F12. The plugin can also dump the VRAM into a .bmp file when I hit F8. I was also told that the palette can be extracted from this file since "VRAM is displayed in 16 bit color so the colors will be correct when viewed in that mode". I tried this out with the following settings: Plugin: P.E.Op.S. Soft Driver 1.1.17 Author: Pete Bernert and the P.E.Op.S. team Resolution/Color: - 1024x768 Fullscreen - [32 Bit] Stretch mode: 0 Dither mode: 1 Framerate: - FPS limit: on - Frame skipping: off - FPS limit: Auto Misc: - Scanlines: disabled - Game fixes: off [00000000] And when I took a screen capture of what was in the VRAM, I got this (Photobucket shrank it to 800 x 600 by the way. The original was 1024x512.): Right off the bat I recognized familiar texture shapes. They are highlighted in this picture in neon green spray paint: To extract palettes in Paint Shop Pro, I usually go to Image --> Palette --> Save Palette… I tried copying the familiar textures into a .bmp file and attempted to extract the palette from the new .bmp file, but Paint Shop Pro won’t let me. The “Save Palette†option is grayed out. I loaded the original VRAM dump into PSP and I still cannot extract the palette since that option is still grayed out. I then decided I shoud try to trace the game’s code when it loads the level with PCSXTrace in order to find where the palette is. Unfortunately, PCSXTrace cannot run Tomb Raider 2. When the level is supposed to load, it freezes up. So I cannot extract the textures by trying to trace the game's code since PCSXTrace can't even run it. I even tried pSX 1.9 and it cannot run TR2 either. Any help? I'm completely stumped.
|
|
« Last Edit: October 28, 2006, 04:42:07 am by sb iq »
|
|
|
|
Gemini
Guest
|
|
« Reply #1 on: October 28, 2006, 06:29:20 am » |
|
1) Forget about tracing for Psx games. It's useless unless you aren't just looking for a numeric value; 2) P.E.Op.S. Soft Driver color rendering sucks, so forget about that too; 3) cluts (aka playstation palettes) are stored in the framebuffer, so that stuff on the right of the vram "dump" are what you were looking for.
|
|
|
|
creaothceann
Guest
|
|
« Reply #2 on: October 28, 2006, 07:30:37 am » |
|
I was also told that the palette can be extracted from this file since "VRAM is displayed in 16 bit color so the colors will be correct when viewed in that mode".
While it's true that the colors will be correct, this doesn't mean that you can extract a palette from such graphics. After all 16-bit color depth means that there might be 65536 colors in the picture. PSP grays out that particular menu item because there is no palette in 16-bit pictures. I'd say your best bet now is reading up on cluts, and figuring out how to extract them from the VRAM dump.
|
|
|
|
DaMarsMan
Guest
|
|
« Reply #3 on: October 28, 2006, 12:55:39 pm » |
|
Yeah I agree. I think 16bit pictures or 15bit sometimes on psx have no palettes. I could be wrong about that though. However, psx can also use cluts with palettes. Even if you find it, replacing it may be quite harder. Not really too sure though.
|
|
|
|
sb iq
Guest
|
|
« Reply #4 on: October 29, 2006, 12:04:26 am » |
|
So if my understanding is correct, a Color Look-Up Table (CLUT) is different from a palette because a palette assigns one color from the color table to a single pixel, whereas a CLUT assigns different levels of red, green, and blue to a single pixel. Thus, a palette is 256 colors. But a 16-bit CLUT is 65536 colors since in 15 bits, 5 bits are associated with each color (RGB) so 2^5=32 and 32^3=32768, but 16-bit has an extra bit for another color since 16 bit is RGBA (I have heard that the PSX may be ABGR) so 32768+32768=65536 colors (thank you, wikipedia). Am I correct in this reasoning? And what is the math behind a palette only using 256 colors? Sorry, I'm really new at this. How could I figure out the hex address where the CLUT is in an epsxe savestate (or in that .bmp file that was dumped)? And would it be 196608 bytes long since 65536*3=196608? And when I find CLUT as raw data, how do I save it as a .pal file so I can load it into PSP as a palette? Btw, my questions have to do with with this topic.
|
|
« Last Edit: October 29, 2006, 12:23:27 am by sb iq »
|
|
|
|
DaMarsMan
Guest
|
|
« Reply #5 on: October 29, 2006, 12:20:56 am » |
|
You got it. 256 color palettes are used where one byte is used per pixel (8bpp). This means that the byte determines which of the 256 colors in the palette to use.
|
|
|
|
sb iq
Guest
|
|
« Reply #6 on: October 29, 2006, 12:38:16 am » |
|
Ah, I see now. Because a byte is 8 bits, and 2^8=256. fyi, after much research, it turns out the PSX version of TR2 uses 8-bit textures, not 16-bit ( http://www.romhacking.net/forum/index.php/topic,2026.0.html). So I might just be going about this the wrong way. The picture of what was in the VRAM is in 16-bit--or in other words--the .bmp snapshot is in 16-bit. However, the textures in the game itself is 8-bit . In that case, should I still be looking for a 256 color palette? How would I go about doing that if I cannot trace code? The only clue I have about the palette is that in the PC version of Tomb Raider 2, the 256 color palette begins at offset 04. And if I do find the palette or CLUT and save it as raw data, how do I convert it into a .pal file for PSP to use?
|
|
« Last Edit: October 29, 2006, 05:02:43 am by sb iq »
|
|
|
|
sb iq
Guest
|
|
« Reply #7 on: November 01, 2006, 03:20:27 am » |
|
Whenever I make a save state in epsxe, it makes a PICT Image file. I can't open it with Paint Shop Pro or Quicktime. I read that it can only be opened with a Mac. How do I open it in a Windows environment? And why exactly does epsxe make this file? From what I've read so far: -----B. 8BPP TIM Header:
-- First Header Block -- [1-4] - 10 00 00 00: ID Tag for TIM [5-8] - 09 00 00 00 or 01 00 00 00 (no CLUT): ID Tag for 8BPP [9-12] - Size of CLUT + 12 (accounting for 12 bytes before the CLUT block starts) [13-14] - Palette Org X [15-16] - Palette Org Y [17-18] - Number of colors in each CLUT (always 256) [19-20] - Number of CLUTs
-- CLUT Block (Offset: 21) -- [21-??] - CLUT Data. 256 Colors per CLUT, 512 bytes per CLUT.
-- Second Header Block (Offset: 20 + Number of CLUTs * Colors Per CLUT * 2) -- [1-4] - Size of image data + 12 (accounting for 12 bytes before image data starts) [5-6] - Image Org X [7-8] - Image Org Y [9-10] - Image Width (Multiply by 2 to get actual width) [11-12] - Image Height
-- Image Data Block (Offset: 20 + 13 + Number of CLUTs * Colors Per CLUT * 2) -- http://www.romhacking.net/docs/timgfx.txtDoes this mean if I open up the file WALL.PSX in a hex editor, look for an instance of 10 00 00 00, and add 21 to the hex address where I found 10 00 00 00, that the resulting hex address is where the CLUT begins? And I'm still stumped on something else. How do I convert the CLUT that I would rip into .pal format for Paint Shop Pro to use?
|
|
« Last Edit: November 01, 2006, 03:41:03 am by sb iq »
|
|
|
|
creaothceann
Guest
|
|
« Reply #8 on: November 01, 2006, 05:58:40 am » |
|
Whenever I make a save state in epsxe, it makes a PICT Image file.
I can't open it with Paint Shop Pro or Quicktime. I read that it can only be opened with a Mac.
How do I open it in a Windows environment?
With a HexEditor. From what I've read so far: ... http://www.romhacking.net/docs/timgfx.txtDoes this mean if I open up the file WALL.PSX in a hex editor, look for an instance of 10 00 00 00, and add 21 to the hex address where I found 10 00 00 00, that the resulting hex address is where the CLUT begins? You don't need to look for instances of data - the offsets are given (one-based, it seems ).
|
|
|
|
Gemini
Guest
|
|
« Reply #9 on: November 01, 2006, 07:15:55 am » |
|
Tomb Raider doesn't use tims at all, so forget about that doc. Make a VRAM dump, then extract all the cluts from there. Forget about PIC files in ePSXe savestates, those are just preview screenshots.
|
|
|
|
sb iq
Guest
|
|
« Reply #10 on: November 02, 2006, 07:28:46 pm » |
|
Thanks for clearing that up for me.
I still don't know where to begin in extracting the CLUT in that VRAM dump I made with Peops soft GPU plugin. I checked this place and ZD, and couldn't find any comprehensible text guides. How do I begin extracting CLUTs from that VRAM dump?
If I am lucky enough to extract the CLUT, I am still stumped on how I could use it in Paint Shop Pro. How would I convert it into a .pal file?
|
|
« Last Edit: November 02, 2006, 07:47:11 pm by sb iq »
|
|
|
|
creaothceann
Guest
|
|
« Reply #11 on: November 03, 2006, 04:41:47 am » |
|
Assuming that a CLUT contains one version of the 256-color palette for each brightness level... - If the brightness goes from normal to dark then use the brightest sub-palette.
- If the brightness goes from bright to normal to dark then use the sub-palette in the middle.
A good indicator for a non-lightened sub-palette would be that color $00 is truly black ($00 for red, green & blue). A good indicator for a non-darkened sub-palette would be that color $FF is truly white ($1F for red, green & blue, all 5 bits set).
|
|
|
|
sb iq
Guest
|
|
« Reply #12 on: November 04, 2006, 12:40:33 am » |
|
Assuming that a CLUT contains one version of the 256-color palette for each brightness level... - If the brightness goes from normal to dark then use the brightest sub-palette.
- If the brightness goes from bright to normal to dark then use the sub-palette in the middle.
A good indicator for a non-lightened sub-palette would be that color $00 is truly black ($00 for red, green & blue). A good indicator for a non-darkened sub-palette would be that color $FF is truly white ($1F for red, green & blue, all 5 bits set). So I need to look for an instance of 00 00 00 in the hex editor for the beginning of the non-lightened sub-palette and FF FF FF for the beginning of the non-darkened sub-palette? Is that what you mean? Sorry, I am unfamiliar with the use of dollar signs when it comes to computing. And does this mean that there are actually 2 256-color palletes? So the CLUT I extract will be a total of 256*3*2=1536 bytes?
|
|
|
|
creaothceann
Guest
|
|
« Reply #13 on: November 04, 2006, 04:49:06 am » |
|
$7B = 0x7B = 7Bh = 173o = 1111011b = 123d. It's all the same value. I don't like looking for instances of data, it's unreliable as hell if you don't know what you're doing. You need to find the structure of the file, and then work solely with offsets, IMO. There must be a format description of those savestates somewhere... If all fails you should take a look at the source code, if it's available. The brightest color should be $7FFF in hardware (binary: 0111111111111111b) since the PSX seems to have a 15-bit gfx system, so you can use just 2 bytes. In software this might be stored with the highest bit set; this would most likely be ignored by the hardware. 00 00 could indeed be the start of a palette, IF the palette starts with pure black. Many palettes do. There can be any number of sub-palettes, from what I know. Just look at this picture from TITLE.PHD (PC version):
|
|
|
|
sb iq
Guest
|
|
« Reply #14 on: November 04, 2006, 05:10:59 am » |
|
1) Forget about tracing for Psx games. It's useless unless you aren't just looking for a numeric value; 2) P.E.Op.S. Soft Driver color rendering sucks, so forget about that too; 3) cluts (aka playstation palettes) are stored in the framebuffer, so that stuff on the right of the vram "dump" are what you were looking for.
Hmmm. I just had the crazy idea of loading the VRAM dump into Tile Molester or Paint Shop Pro, highlighting and copying that stuff on the right, and saving it into a raw file. Would that be a good idea? Also, I tried looking for documentation on save states in the past. I could not find any. >_<
|
|
« Last Edit: November 04, 2006, 09:11:18 pm by sb iq »
|
|
|
|
|