NagyD / PR

Princed Resources is a tool to export and import graphics and other data from and to DAT files of Prince of Persia 1 and 2.
GNU General Public License v2.0
15 stars 5 forks source link

PoP2: incorrect palette handling #1

Open bt2901 opened 6 years ago

bt2901 commented 6 years ago

This is a known issue. The details are here: http://forum.princed.org/viewtopic.php?f=70&t=4062

I wanted to export backgrounds from caverns and final, and the images came with garbled palette. I managed to fix this manually, so now I'm sharing my findings. (I used PR-1.3.1-prerelease2)

My MO was as follows: 1) find a palette file responsible for garbling (I think you just have to look for files which are too large compared to the average, or maybe this is always pals03500.pal file) 2) Split this file into several smaller files, according to my best judgement. The files contain smaller set of colors. 3) Reload the incorrect pictures, trying different palette files until the colors are correct. (I used GIMP for this: import new palette, then set colormap).

Information about palette files:

CAVERNS/pals03500.pal Consists of 320 colors (larger than 256) The first 160 colors are related to the shap03501-shap04059 (they export correctly). The last 160 colors are about the bridge scenery: shap04225 - shap04235.

FINAL/pals03500.pal Consists of 576 colors (larger than 256) First 192 colors = shap03501-shap04027 (tower) Next 96 = shap04050-shap04105 (chessboard and spider) Next 96 - unused (and empty) Next 192 - shap04125-shap04189 (crystal room and Escher rooms)

Observations:

NagyD commented 6 years ago

I wanted to export backgrounds from caverns and final, and the images came with garbled palette. (I used PR-1.3.1-prerelease2)

But this bug is already fixed in the version on GitHub. I guess I should make a new release...

NagyD commented 6 years ago

Hi @bt2901, I compiled the current source, you can find it here: http://forum.princed.org/viewtopic.php?p=23746#p23746 Please try it.

bt2901 commented 6 years ago

It doesn't seem to be working, unfortunately.

1) The previous version extracted files into ./resources/ folder by default. Now it extracts them into ./unknown/ folder and creates an unknown.xml file.

2) It extracts no .pal files (except the single palette-pop2-320cols001.pal from CAVERNS.DAT)

3) The palette of every image is wrong (either grayscale or mismatched). The only exception is several files from CAVERNS.DAT

image-full124 image-full158

I used the following command: C:\Games\pop2_resources\PR-1.3.1\src\bin>pr.exe -e CAVERNS.DAT

bt2901 commented 6 years ago

OK, that was the error on my side. I forgot about -s argument. For posterity, the command is supposed to be: C:\Games\pop2_resources\PR-1.3.1\src\bin>pr.exe -spop2.xml -e FINAL.DAT

Now it's working, thanks!

The only issue I've seen so far is about extracting FINAL.DAT. I get 14 copies of the following error message: can't load necessary palette, index=palt, value=0, error=-23

All extracted pictures are OK except the range of shap24902.bmp - shap24915.bmp (there are 14 of them as well, doesn't appear to be a coincidence)

NagyD commented 6 years ago

The only issue I've seen so far is about extracting FINAL.DAT. I get 14 copies of the following error message: can't load necessary palette, index=palt, value=0, error=-23 All extracted pictures are OK except the range of shap24902.bmp - shap24915.bmp (there are 14 of them as well, doesn't appear to be a coincidence)

These are the images of the thrown flame-ball. As the comment in pop2.xml says, these would use a palette from PRINCE.DAT. PR currently can't use a palette from a DAT with an image from another DAT. Therefore I specified an invalid palette to force PR to use a default palette. That causes the errors.

There are some further images that would use a palette from a different DAT. See the end of this post: http://forum.princed.org/viewtopic.php?p=21533#p21533