Fluffy's Prince of Persia

Threads about other remakes and ports.
David
The Prince of Persia
The Prince of Persia
Posts: 2878
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Fluffy's Prince of Persia

Post by David »

FluffyQuack wrote: May 16th, 2025, 2:01 pm In related news, more debug output!!
The first screenshot has the prince and a guard back-to-back, just like the screenshot of a recent mod. :)
They are even roughly in the same place within the room.
FluffyQuack
Vizier
Vizier
Posts: 125
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

David wrote: May 17th, 2025, 12:25 pm The first screenshot has the prince and a guard back-to-back, just like the screenshot of a recent mod. :)
They are even roughly in the same place within the room.
It's a sign!!! Well, hopefully not a sign that my code should try to support original bugs to this extent...

I've gotten some more progress on the dynamic spawn system. My current plan is to finish almost everything that's needed for level 1 to play the exact same way as in the original POP2. The only exceptions being the music and the boat at the end, I'll do those later in the project.

Oh, another exception will be the colour cycling on the water. I'm still not completely sure how to handle palette stuff in my code. Either I load alternate versions of textures with different colours, or I load all textures as monochrome where the image data is palette indices and then I do the colours in shaders. Latter would be the "correct" way to do it, but it would require a huge rewrite of my graphics code.
FluffyQuack
Vizier
Vizier
Posts: 125
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

I'm still working on this here and there.

I spent hours on a bizarre problem I'm kind of annoyed I didn't figure out properly. My sword rendering was working completely fine for everything, except for the sword for guards running or jumping. I eventually figured out that the render offset from the sword frame array were correct, but the sword image index was off by one. It's so weird because everything else added up, and I could confirm the values are the same in memory when running the game on Xbox.

I ended writing this not-so-pretty hacky fix:

Code: Select all

	//"Guard run" sword frames:
	sword_tbl_pop2[88].id--; sword_tbl_pop2_shortSword[88].id--;
	sword_tbl_pop2[100].id--; sword_tbl_pop2_shortSword[100].id--;
	sword_tbl_pop2[86].id--; sword_tbl_pop2_shortSword[86].id--;
	sword_tbl_pop2[83].id--; sword_tbl_pop2_shortSword[83].id--;
	sword_tbl_pop2[80].id--; sword_tbl_pop2_shortSword[80].id--;
	sword_tbl_pop2[97].id--; sword_tbl_pop2_shortSword[97].id--;
	//"Guard start run" sword frames
	sword_tbl_pop2[77].id--; sword_tbl_pop2_shortSword[77].id--;
	sword_tbl_pop2[78].id--; sword_tbl_pop2_shortSword[78].id--;
	sword_tbl_pop2[79].id--; sword_tbl_pop2_shortSword[79].id--;
	sword_tbl_pop2[82].id--; sword_tbl_pop2_shortSword[82].id--;
	sword_tbl_pop2[85].id--; sword_tbl_pop2_shortSword[85].id--;
	sword_tbl_pop2[89].id--; sword_tbl_pop2_shortSword[89].id--;
	//"Guard running jump" sword frames
	sword_tbl_pop2[87].id--; sword_tbl_pop2_shortSword[87].id--;
	sword_tbl_pop2[92].id--; sword_tbl_pop2_shortSword[92].id--;
	sword_tbl_pop2[95].id--; sword_tbl_pop2_shortSword[95].id--;
	sword_tbl_pop2[91].id--; sword_tbl_pop2_shortSword[91].id--;
	sword_tbl_pop2[101].id--; sword_tbl_pop2_shortSword[101].id--;
	sword_tbl_pop2[98].id--; sword_tbl_pop2_shortSword[98].id--;
	sword_tbl_pop2[99].id--; sword_tbl_pop2_shortSword[99].id--;
	sword_tbl_pop2[81].id--; sword_tbl_pop2_shortSword[81].id--;
	sword_tbl_pop2[93].id--; sword_tbl_pop2_shortSword[93].id--;
	sword_tbl_pop2[96].id--; sword_tbl_pop2_shortSword[96].id--;
	sword_tbl_pop2[94].id--; sword_tbl_pop2_shortSword[94].id--;
	//"Guard end run" sword frames
	sword_tbl_pop2[90].id--; sword_tbl_pop2_shortSword[90].id--;
	sword_tbl_pop2[84].id--; sword_tbl_pop2_shortSword[84].id--;
Edit: Thinking about this, maybe this is related to a mismatch between the image IDs used by POP2 and the order I've got textures loaded in my project. Edit 2: This was caused by a sword image ID that's unused in a long sequence of used IDs, so the order images ended up being different in my project. Knowing that, I wrote a cleaner solution to the above problem.

I'm still generally trying to finish what I need for everything in level 1 to be identical. I think this is a complete list of differences right now:
  • Enemies failing the jump on the screen that's 3 screens to the left (they also fail it in DOS v1.1 and the Xbox version, but my code fails in a different way).
  • Minor render glitch in the screen where a guard jumps down.
  • Render order glitches on many ledges.
  • Falling off the level is not handled correctly.
  • Don't have the "fall into foreground" death animation yet.
  • Boat does not behave as it should.
  • No water animation/colour cycling.
  • No music.
  • A few missing sound effects.
  • The hit effect when hitting enemies looks a bit off.
  • Enemies are using the wrong palette.
  • Combat is still at 12fps.
  • Lacking brief pause when switching screens.
Once I've implemented most of the above, then I'll release a new version.
FluffyQuack
Vizier
Vizier
Posts: 125
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

I decided to implement support for "depalettizing" textures in a shader rather when loading textures. It took less work than I expected and I'm nearly done with it. Here are some work-in-progress images as it's always more fun to showcase a feature while it's broken rather than when its finished:
2025-06-24 23-28-42-723.png
2025-06-24 23-28-52-676.png
2025-06-25 17-10-24-665.png
2025-06-25 17-11-18-906.png

This is how I've got it implemented. I'm loading all palettes to the topleft portion of my "mega" texture atlas with all other color values in the texture representing palette indices. During rendering a fragment shader does the color lookup. I'm technically wasting a few megs of VRAM due to storing the texture as RGBA, but eh, no biggie.
POP-MegaTextureAtlas-indexedcolors.png
FluffyQuack
Vizier
Vizier
Posts: 125
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

Extremely obscure Prince of Persia trivia for today: In the second screen in the first level of POP2, a blue guard will spawn if you kill the blue guard that's already in that room. But did you know you could make that spawning blue guard be red if you follow extremely specific steps!?
  • Bring one red guard from first room into second room.
  • Get the attention of the blue guard and then quickly go back into the first room with the blue guard following you. Make sure to keep red guard alive.
  • Kill the blue guard.
  • Go back into the second room with the red guard following you.
  • Kill the red guard. Now a red guard spawns instead of a blue one!
And in related news, I've got that exact behaviour replicated in my project. I was puzzled when I noticed dynamic spawning enemies had no colour assigned to them, so I had to figure out exactly how it works in POP2. Which is that dynamically spawning enemies take the colour of whatever static guard was last added (and it prioritizes enemies that's already in a room, rather than enemies following you into a room).

I'm slowly getting closer to the milestone of level 1 playing, looking, and sounding the same...
Post Reply