Fluffy's Prince of Persia

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

Re: Fluffy's Prince of Persia

Post by David »

FluffyQuack wrote: November 23rd, 2024, 1:59 pm Now everything should be 1:1 exact (except for the pillar reflections I haven't aligned yet, and there's 3 pixel rows being overwritten between the wharf and the screen above):
2024-11-23 12-30-18-654.png
Two windows are still at a slightly wrong place.
You can compare your level map with the ones I linked here.
FluffyQuack
Vizier
Vizier
Posts: 110
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

I spent less time on this during December than I had planned, but I got a bunch of stuff done. I've partially implemented some systems that only exist in POP2, and started implementing more and more gameplay. But not enough gameplay that a new video showcase makes sense.

Regarding gameplay: I'm implementing POP1 and POP2 gameplay into the same codebase with a lot of shared functions with slightly different behaviour depending on which game is currently active. I'm getting more and more tempted to fully merge the two games and make them behave the same way for the sake of making the codebase cleaner and easier to work with. When in doubt, I would default to POP2 behaviour as that has a coordinate system that's easier to work with and makes more sense. This would have the downside of making POP1 less accurate, but we've already got a good way of playing that on a modern system anyway. Certain stuff I will have to ensure is different between the two games, though, like how you can make loose tiles drop after knocking them 3 times in POP2, but not in POP1.

I was meant to focus exclusively on gameplay but then I randomly did a bunch of stuff related to tilesets. First of all, I went back to my POP1 code and did something I originally scrapped, which was ensuring the wall rendering in dungeon and palace tilesets are randomized the exact same way as the original.

Here are two level examples. If you compare these to the original, the decal positions on the walls and the colours should be identical. The only way it's different is that I made the colours consistent in POP1 palace. In the original game, walls that are visible in two different rooms will get different colours depending on the room you're in.
2024-12-31 17-27-08-145.png
2024-12-31 17-27-17-583.png
You'll notice a ton of stuff missing in the POP1 palace tileset. I still haven't gotten around to adding drawing of those elements. I tend to focus on whatever problem is the most interesting to me and finishing up the palace tileset has been pretty far down on my priority list.

I did more work on various tilesets in POP2, primarily ruins and temple (the following temple screenshots are older, though). Here are what some POP2 levels look like:
2024-12-21 21-07-35-002.png
2024-12-21 21-08-44-067.png
2024-12-21 21-08-51-794.png
2024-12-21 21-09-13-223.png
2024-12-21 21-09-22-935.png
2024-12-21 21-09-29-577.png
2024-12-21 21-09-37-081.png
David wrote: December 1st, 2024, 9:06 amTwo windows are still at a slightly wrong place.
You can compare your level map with the ones I linked here.
That's a good catch. I think it's only one window, though? The window next to the guard in your screenshot was off by one in my level. I don't see another window being wrong.

Here's what the level looks like right now:
2024-12-31 17-18-00-023.png
David
The Prince of Persia
The Prince of Persia
Posts: 2867
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Fluffy's Prince of Persia

Post by David »

FluffyQuack wrote: December 31st, 2024, 6:38 pm That's a good catch. I think it's only one window, though? The window next to the guard in your screenshot was off by one in my level. I don't see another window being wrong.
Sorry, maybe I wasn't clear about which other window I meant?

Here is the room from your last map:
from_map.png
from_map.png (19.48 KiB) Viewed 4599 times
And this is a screenshot of the same room:
screenshot.png
screenshot.png (10.31 KiB) Viewed 4599 times
The window (or is it a door?) in the top row is at a different place.
FluffyQuack
Vizier
Vizier
Posts: 110
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

Once again, I've put less time into this than I had wanted, so I didn't get that much done throughout January and February, but I've gotten back into the saddle now.

Right now I'm focusing on doing more gameplay-related stuff, but I've got nothing that's very exciting to show off. I'm trying to get all code related to player movement and input to be accurate to POP2.

I just finished some work on pressure plate and trobs, and now I've got gates working correctly in POP2:

Most of the code for pressure plates, trobs, and gates are identical to POP1, but I'm still going through all the code function-by-function to ensure I get the exact correct behaviour to POP2.

I've been thinking how to approach the project overall, and this is my current plan:
  • Finish implementing POP1 and POP2 and make them as exact as possible. I'm okay with small diverges and I'm very okay with bug fixes, but I want them to be as close as possible. The only big, new feature I want to implement during this step is local multiplayer. I'll also have an option for different camera systems (ie, free cam or widescreen). This step is finished when I have POP1 and POP2 playable from start to finish with all features working and bug-free. At the end of this step I'll do some code cleanups and release the source code.
  • I'll drop "pure" POP1 support and make all of the code use POP2 rules by default (with appropriate changes to ensure POP1 is fully playable). This is to make the codebase easier to deal with as right now I have branches everywhere to deal with differences between POP1 and POP2, especially due to the different coordinate systems. And as part of this, I'll make it so all gameplay systems are compatible everywhere. Ie, scythes in POP1 and POP1-style spikes in POP2. As part of this step, I'll also do some refactoring. For instance, the current collision detection code is similar to POP1/POP2 and I think that could be rewritten to be greatly simplified and easier to work with.
  • At this step I'll consider adding online multiplayer support and better modding support: a full level editor, easy systems for replacing assets, and if I'm crazy enough, a scripting system for setting up scripted events in the game.
David wrote: January 11th, 2025, 9:02 amSorry, maybe I wasn't clear about which other window I meant?

Here is the room from your last map:
from_map.png

And this is a screenshot of the same room:
screenshot.png

The window (or is it a door?) in the top row is at a different place.
Thanks for pointing that out! It's been fixed now.
FluffyQuack
Vizier
Vizier
Posts: 110
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

From one point of view, I took a huge step back with my POP2 implementation today. I can no longer control the prince as I started branching out the input code to use code that's meant for POP2, rather than use my existing input code that's written for POP1.

I have to rewrite the @GenCtrl function (similar to control() in SDL-POP) which will be a doozy as it's massive. This is how IDA decompiles the function: https://pastebin.com/raw/56RRXLDP

This is the Xbox code (I'm primarily using that as reference as IDA supports decompiling it). When the Xbox version was compiled the compiler decided to go crazy with inlining in this function, so it's a beast to parse.
FluffyQuack
Vizier
Vizier
Posts: 110
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

I've gone through most of @GenCtrl and now I've got most of the prince controls working, this time using logic that matches POP2:
User avatar
Alberto
Beylerbey
Beylerbey
Posts: 56
Joined: February 13th, 2019, 6:55 am

Re: Fluffy's Prince of Persia

Post by Alberto »

Nice! It is always great seeing progress after reworking the code.

So are you in a kind of debug mode? where the state and position of the prince is accessible for modification at any time. Cool! That is way better than what I did for my project where I had to reset the level to test again lol.
FluffyQuack
Vizier
Vizier
Posts: 110
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

Alberto wrote: March 14th, 2025, 5:31 am Nice! It is always great seeing progress after reworking the code.

So are you in a kind of debug mode? where the state and position of the prince is accessible for modification at any time. Cool! That is way better than what I did for my project where I had to reset the level to test again lol.
Yeah, I've got some features implemented for the sake of debugging. I can move the camera freely, teleport using the mouse and I've got a system for saving and loading the entire gameplay state. And, of course, I do debugging via Visual Studio all the time.

I've also got a robust system for debugging the original POP2. I decided to reverse-engineer the Xbox version of POP2, mainly because IDA can decompile the assembly and I don't have to deal with 16-bit memory addressing or code overlays, but another nice thing is that the Xemu emulator has really good debugging support for IDA. So I can step through the code line-by-line and easily look up any value in memory or CPU registers.

If I started reverse-engineering POP2 this way from the get-go (reverse-engineering Xbox version + looking up the debug symbols from the FM Towns version) then I would have been done with the project ages ago. I started off with the 16-bit DOS executable, and I'm just so insanely slow at re-writing assembly code into C.

My current method has one enormous downside, though: there is no free version of IDA that supports decompiling Xbox executables and IDA is crazy expensive. I don't want to pay for another year of IDA, so that's as a big motivator to make sure I actually finish this project this year.
FluffyQuack
Vizier
Vizier
Posts: 110
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

I figured I might as well share my current build in case anyone wanted to test the progress for themselves.

First of all, here's my first attempt at trying to re-create Prince of Persia, from way back in 2008: https://fluffyquack.com/prince/builds/2008-06-03.zip

I was working on that for a couple of weeks with a friend of mine. That's somehow 17 years ago now, which feels rather surreal. I thought I had posted about it on this forum back in 2008, but it must have been in another Prince of Persia community. We didn't get too far in the project. There's basic movement, a basic level editor (I can't remember how to access it), and there's even basic online multiplayer implemented. But no sword fighting, no traps, no gates, no enemies, and no sound. You can move using the directional keys. You can press Q to turn on aspect correct rendering. There's more debug keys to press, but I don't know what they are.

And then fast-forward to today with my current build of my new project: https://fluffyquack.com/prince/builds/2025-03-14.zip

First of all, you'll need to copy over game files from POP1 and POP2. Copy POP1 DAT files to Data\Prince\POP1 and POP2 DAT files to Data\Prince\POP2. I think my code is compatible with any DOS release of POP1 and POP2 files. I should note that my code currently expects to load both games. It'll crash if files from either game are missing.

In-game instructions:
  • Press Escape to access the menu that has a bunch of self-explanatory buttons.
  • Controls are the same as the DOS versions of POP1 and POP2.
  • IJKL for free-cam. You'll have to turn the default camera back on if you want to exit free-cam.
  • Middle-mouse button to teleport player.
  • In the menu, you can add additional human players. The additional players are controlled using Xinput controllers. The camera only follows the first player, though.
  • Shift+L to skip to the next level.
  • Page-up / page-down to switch the camera to a different level.
  • O / P to change render scale. Hold Control to change scale in integer steps.
This is very much a work-in-progress, so a ton of stuff is missing. POP1 is pretty far along, but it's still missing some substantial content: palace tileset implementation isn't done yet, there's no correct render-order/masking, no cutscenes, no music, only one palette for enemies, many sound effects are missing, and no "scripted" events (every encounter with Shadow Prince, the mouse, Jaffar, and the skeleton fight are missing). There's also a few bugs. For instance, chompers don't always activate.

POP2 is missing even more stuff. No sound, no enemies, no traps, a bunch of missing graphics, even more wonky render-order stuff, no cutscenes, no music, no color cycling and palette switching are missing, and no "scripted" events. That said, I'm happy with the progress I'm having and while I can't promise exactly when I'll have POP 1 and 2 fully implemented, I swear it'll happen sometime this year.
David
The Prince of Persia
The Prince of Persia
Posts: 2867
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Fluffy's Prince of Persia

Post by David »

FluffyQuack wrote: March 15th, 2025, 3:50 am First of all, here's my first attempt at trying to re-create Prince of Persia, from way back in 2008: https://fluffyquack.com/prince/builds/2008-06-03.zip
[...]
I thought I had posted about it on this forum back in 2008, but it must have been in another Prince of Persia community.
I have a very similar game in an archive called 2008-05-26.rar, which I downloaded on 2008-05-28.
In 2014 I reposted it here, as "Project V.zip".
It's from the PoPUW forum, according to the topic title.

The rar is identical to the file of the same name here: https://fluffyquack.com/prince/builds/

BTW, I see you posted here back in 2004: viewtopic.php?f=72&t=388&p=1841#p1841
FluffyQuack wrote: March 15th, 2025, 3:50 am You can move using the directional keys. You can press Q to turn on aspect correct rendering. There's more debug keys to press, but I don't know what they are.
I figured out some more keys (in the 2008 version) by trying every key:

Code: Select all

arrows, Shift, Ctrl: control first prince
	Ctrl: draw sword
IJKL, G, B: control second prince
	G ~ Shift
	B ~ Ctrl: draw sword
1: show first player's hitbox (while held down)
2: show both players' hitbox (while held down)
Q: toggle aspect ratio
R: first prince restarts level
C: toggle background's hitboxes
F3: crouch (both princes)
F6: add second prince (crashes the game if pressed again)
F8: act as client (toggle)
F9: act as server (toggle)
Esc: quit
right-click: teleport first prince to cursor
Enter: toggle fixed camera
FluffyQuack
Vizier
Vizier
Posts: 110
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

David wrote: March 15th, 2025, 2:35 pm I have a very similar game in an archive called 2008-05-26.rar, which I downloaded on 2008-05-28.
In 2014 I reposted it here, as "Project V.zip".
It's from the PoPUW forum, according to the topic title.

The rar is identical to the file of the same name here: https://fluffyquack.com/prince/builds/

BTW, I see you posted here back in 2004: viewtopic.php?f=72&t=388&p=1841#p1841

I figured out some more keys (in the 2008 version) by trying every key:

Code: Select all

arrows, Shift, Ctrl: control first prince
	Ctrl: draw sword
IJKL, G, B: control second prince
	G ~ Shift
	B ~ Ctrl: draw sword
1: show first player's hitbox (while held down)
2: show both players' hitbox (while held down)
Q: toggle aspect ratio
R: first prince restarts level
C: toggle background's hitboxes
F3: crouch (both princes)
F6: add second prince (crashes the game if pressed again)
F8: act as client (toggle)
F9: act as server (toggle)
Esc: quit
right-click: teleport first prince to cursor
Enter: toggle fixed camera
Yup, that's the same project! The build I posted is slightly newer, though I can't remember what changed between the two versions. There's multiple levels that can be accessed by altering the level name in the config file, but they're all simple test levels.

I feel a bit silly that we dropped the project so quickly as we had really good progress in just a few weeks, though our final result would have felt very different compared to POP since we didn't look up any source code or disassembly (my assembly knowledge now isn't amazing, but it was non-existent back then). At least I'm finally fulfilling my dream of re-creating POP1 now, with POP2 happening as well.
User avatar
Alberto
Beylerbey
Beylerbey
Posts: 56
Joined: February 13th, 2019, 6:55 am

Re: Fluffy's Prince of Persia

Post by Alberto »

FluffyQuack wrote: March 15th, 2025, 3:50 am I figured I might as well share my current build in case anyone wanted to test the progress for themselves.
I do, thank you!
FluffyQuack wrote: March 15th, 2025, 3:50 am That's somehow 17 years ago now, which feels rather surreal.
So relatable, I started stalling my project when I discovered a lot of flaws in my code that I couldn't solve and suddenly it's been years since I touched it. The worst part is that I don't want to open the files again for the fear of unreadable spaghetti nonsense lol, it has been so many years now that I may as well start fresh. Nonetheless our first projects always have a special place in our hearts.
FluffyQuack wrote: March 15th, 2025, 3:55 pm (my assembly knowledge now isn't amazing, but it was non-existent back then)
Again, I feel the same except my assembly is still non-existent lol. I'm currently learning C64 assembly and it has been surprisingly helpful not only for understanding old games, but for building a better foundation on what computers are actually doing behind the scenes.
FluffyQuack wrote: March 15th, 2025, 3:55 pm I'm finally fulfilling my dream of re-creating POP1 now, with POP2 happening as well.
Fingers crossed, I'm rooting for you.
FluffyQuack
Vizier
Vizier
Posts: 110
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

Alberto wrote: March 16th, 2025, 12:21 amAgain, I feel the same except my assembly is still non-existent lol. I'm currently learning C64 assembly and it has been surprisingly helpful not only for understanding old games, but for building a better foundation on what computers are actually doing behind the scenes.
You might already know this, but the CPUs in the C64 and Apple II are the same. If you learn C64 assembly, then you'll find the original Prince of Persia source code easy to read.
User avatar
Alberto
Beylerbey
Beylerbey
Posts: 56
Joined: February 13th, 2019, 6:55 am

Re: Fluffy's Prince of Persia

Post by Alberto »

Yeah, good old reliable 6502.

It is funny, when I first tried reading PoP's source code I couldn't understand a thing. Then I came across C64 User's guide and slowly started creating Basic programs to get my feet wet. I am now reading C64 Programmer's Reference Guide and assembly code finally clicked for me... of course understanding the basic ideas vs actually writing code are two different monsters lol.

I'm still afraid of PoP source code, but I can read it now so I feel I'm improving little by little.
FluffyQuack
Vizier
Vizier
Posts: 110
Joined: June 6th, 2004, 7:05 pm

Re: Fluffy's Prince of Persia

Post by FluffyQuack »

Updated input code to access all combat animations:


It isn't actually that many months ago since I learned you can manually turn around with sword unsheathed in POP2. And now I've learned that you can also dance by mashing the turn input. I thought that was a bug at first but, no, I tested in proper POP2 and you can turn mid-turn there.
Post Reply