SDLPoP; David's open-source port of PoP

Open-source port of PoP that runs natively on Windows, Linux, etc.
Post Reply
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

SDLPoP; David's open-source port of PoP

Post by David »

The latest version can be downloaded here.

This is the port that I already mentioned here: http://forum.princed.org/viewtopic.php?p=14975#p14975

Windows: An EXE is included with all needed DLLs.

GNU/Linux: Make sure that the development version of the "SDL" and "SDL_image" libraries are installed.
Then compile with make all and run with ./prince.

You can run the game in full screen with the command line argument "full".
Attachments
PORT_PoP.zip
(1.04 MiB) Downloaded 702 times
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: David's open-source port of PoP (pre-release)

Post by Norbert »

So much interesting code to study. :)
Already a short question, out of curiosity: in one of the text files you wrote "# stretch image to 2x, 3x (you can use fullscreen instead)"; does SDL_FULLSCREEN actually scale up the images under Windows?
Andrew
Wise Scribe
Wise Scribe
Posts: 313
Joined: July 16th, 2009, 4:39 pm

Re: David's open-source port of PoP (pre-release)

Post by Andrew »

David wrote:Windows: An EXE is included with all needed DLLs.
Zlib1.dll is missing, can be downloaded here: http://www.zlib.net

I realize these are early days yet, but some notes:
  • Any way to hide the irritating mouse cursor in full-screen mode?
  • Game seems to suffer from weird speed-ups, especially when it starts and sometimes when rooms change
  • New rooms take quite some time to be drawn, with the screen being blank in-between - perhaps some double buffering or page flipping is required?
  • Movement still seems glitchy and sometimes multiple key presses seem to be required before they are recognized
Still, this is amazing and I think deserves a huge amount of praise for the amount of effort and determination it no doubt required even to get to this point. Awesome job, David!

If only the source for the DOS version (if it is even available and not lost) had been released by Brøderbund/Ubisoft (like Id Software does regularly), we'd no doubt have a fair number of bug-fixed updated source ports by now. Oh well, no use dwelling over it...
Norbert wrote:Already a short question, out of curiosity: in one of the text files you wrote "# stretch image to 2x, 3x (you can use fullscreen instead)"; does SDL_FULLSCREEN actually scale up the images under Windows?
If I'm understanding your question correctly, yes, "prince.exe full" in this case does scale the image up instead of displaying the game as a small graphic in the middle of the screen.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: David's open-source port of PoP (pre-release)

Post by David »

There is a new version at the bottom of this post, with most of the mentioned bugs fixed.
Andrew wrote: Zlib1.dll is missing, can be downloaded here: http://www.zlib.net
Erm, yes. It's not in my PORT_PoP folder, but the game could run. Looks like something installed it.
(Actually it was GTK. It was needed for "Hu-Go!", one of the TurboGrafx-16/PC-Engine emulators I tried.)
I included it in the new version.
Andrew wrote: Any way to hide the irritating mouse cursor in full-screen mode?
I just done that, it will be hidden in the next version.
Andrew wrote: Game seems to suffer from weird speed-ups, especially when it starts and sometimes when rooms change
It seems it was caused by the "compatible timers". I disabled it now.
Andrew wrote: New rooms take quite some time to be drawn, with the screen being blank in-between - perhaps some double buffering or page flipping is required?
This is caused by that my code calls SDL_UpdateRect after each drawing, even if the target of that drawing is not the screen.
I changed this in the upcoming version, and the blanks are much shorter (barely noticeable).
Andrew wrote: Movement still seems glitchy and sometimes multiple key presses seem to be required before they are recognized
I'm not sure about this one.
Andrew wrote: Still, this is amazing and I think deserves a huge amount of praise for the amount of effort and determination it no doubt required even to get to this point. Awesome job, David!
Thanks!
Norbert wrote:Already a short question, out of curiosity: in one of the text files you wrote "# stretch image to 2x, 3x (you can use fullscreen instead)"; does SDL_FULLSCREEN actually scale up the images under Windows?
The game tries to switch to 320*200 resolution in fullscreen.
In some cases SDL uses some other resolution, for example 640*480 -- but it's always smaller than the desktop resolution.
And the smaller resolution means bigger pixels. -- Not an actual scaling, but you can see the game better.

Some other changes in the new version:
Fixed: If the mouse cursor leaves/enters the window, the game did as if the pressed keys were released.
The included EXE is now smaller because it's compiled without debugging info.
Attachments
PORT_PoP.zip
(922.11 KiB) Downloaded 655 times
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: David's open-source port of PoP (pre-release)

Post by Norbert »

David wrote:
Andrew wrote: Zlib1.dll is missing, can be downloaded here: http://www.zlib.net
Erm, yes. It's not in my PORT_PoP folder, but the game could run. Looks like something installed it.
(Actually it was GTK. It was needed for "Hu-Go!", one of the TurboGrafx-16/PC-Engine emulators I tried.)
No, you most likely got the zlib DLL before that. When I was busy with apoplexy 2.2b, I noticed that the Windows port of 2.1b wasn't immediately running in Wine because the zlib DLL was not included in the full package. After you had created the 2.2b port, I thus added the zlib DLL to the final package myself. I did the same for the 2.3 package. It was included with 1.2b, 1.9b and 2.0, so I'm guessing somewhere between December 2013 and February 2014, the DLL must have been added to your system/ or system32/ directory (or maybe syswow64/, I don't know enough about Windows). I didn't think it was worth mentioning at the time and I didn't think back about it when you mentioned SDL in the context of your port, sorry.

I have some small requests. In future packages, can you please include a (retrospective) ChangeLog file that includes dates and textual descriptions of changes made, plus preferably also version numbers (then instead of "the package of 22 July 2014", one could then say "version n" or just "n"). Please also include a readme-like file with at least some kind of contact information (you could either mention this thread/board/forum and/or an e-mail address), plus preferably also your (first) name. Finally, could you please add licensing information to the package, for example in the readme-like file, that mentions which parts of the package are free software/open source and how these files are licensed. As a side note, I'm aware there is a history of using the GPL here (usually either 2+ or 3+; for Princed projects, my software, and so on), but as I'm sure you know there's also, for example, the zlib License and various BSD licenses. All of the aforementioned things are, of course, just requests; your choices.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: David's open-source port of PoP (pre-release)

Post by Norbert »


(Later today, I'll also announce your great project on popot.org, princed.org, Facebook. [Edit: Done.])
poirot
Developer
Developer
Posts: 394
Joined: March 24th, 2003, 8:52 pm
Location: Australia
Contact:

Re: David's open-source port of PoP (pre-release)

Post by poirot »

Wow, congratulations! I'll try to compile it on Os X
htamas
Efendi
Efendi
Posts: 10
Joined: February 22nd, 2009, 7:49 pm

Re: David's open-source port of PoP (pre-release)

Post by htamas »

It's been a long time since I was last here, but I have to say: wow, congrats!
I've played through the game, and apart from a few glitches I almost forgot that I'm not playing with the original. It just feels right. When I make a jump with the expectation that I will stop right before the edge or when I enter a room knowing that a chomper won't cut me across, it never fails me. Which is great. I always liked the fact that PoP is essentially deterministic except for the guards' behaviour, and missed that kind of compatibility from freeprince. I think this is where building on the disassembly pays off.

Issues that bothered me:
You already mentioned that the feather fall duration is based on sounds which are not yet implemented, but I was still surprised when the kid died in the final jump of level 7. Fortunately there is an alternate solution there, so I just replayed the level. But I had no such luck on level 12 where I also fell down after merging with the shadow, so I had to do a Shift-L there. (Did you implement the tiles appearing in the air?) Ignoring these two bugs, the game is really well playable.
Pressing a key during the title fade-in sequence doesn't work. I think you know about this one, but I should add that it makes the usual Ctrl-R Ctrl-L shortcut of restarting from the saved game quite cumbersome.

Minor issues:
Starting a new game after winning a previous one makes all texts in the game blue instead of white.
I need to press + or - repeatedly to increase/decrease the remaining time (I can keep it pressed it in the original version).
Shift-L skips cutscenes (it shouldn't). Remaining time messages blink a lot in the last minute of game time.
I also managed to segfault the game by using random cheats on level 12, but unfortunately I can't reproduce it.

And once again: well done, thank you!
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: David's open-source port of PoP (pre-release)

Post by David »

htamas wrote: Pressing a key during the title fade-in sequence doesn't work. I think you know about this one,
Yes, it's mentioned in doc/bugs.txt as "# Can't interrupt fading of title screen.".
The problem is that in the disassembly, the procedure used for that fading does not seem to allow interruption. I possibly looked over something.
Of course, even if I can't find it in the disassembly, I will have to add it somehow.
htamas wrote: I need to press + or - repeatedly to increase/decrease the remaining time (I can keep it pressed it in the original version).
I solved this in the upcoming version by adding a call to the SDL_EnableKeyRepeat() function.
htamas wrote: Shift-L skips cutscenes (it shouldn't).
Mentioned in doc/bugs.txt as "# "Shift" of Shift-L interrupts cutscene too soon.".
If you release Shift fast enough, then you will see the cutscene, but I agree that this should not happen.
Like the first one, I don't know how is this done in the original.
htamas wrote: But I had no such luck on level 12 where I also fell down after merging with the shadow, so I had to do a Shift-L there. (Did you implement the tiles appearing in the air?)
Did you wait until the kid stops flashing? The floors appear only after that.
htamas wrote: You already mentioned that the feather fall duration is based on sounds which are not yet implemented
Here's what I'm planning:
Figure out the length of at least those sounds which are used for timing.
Then, when the game wants to play one of those, set a variable that causes check_sound_playing() to return true, and set a timer with interval = the length of that sound.
When the timer strikes, set that variable to false (and stop the timer).
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: David's open-source port of PoP (pre-release)

Post by Norbert »

I'm testing here and there, and I think it's not possible to do this trick?
http://www.youtube.com/watch?v=zYF3OMJeWms#t=372
htamas
Efendi
Efendi
Posts: 10
Joined: February 22nd, 2009, 7:49 pm

Re: David's open-source port of PoP (pre-release)

Post by htamas »

David wrote: The problem is that in the disassembly, the procedure used for that fading does not seem to allow interruption. I possibly looked over something.
Of course, even if I can't find it in the disassembly, I will have to add it somehow.
I don't have the time to check it right now, but I would assume that if the game binary allows interruption then the disassembly also has to :).
David wrote: Did you wait until the kid stops flashing? The floors appear only after that.
Looks like it was my fault, sorry for the false positive. (I usually don't wait for the flashing to stop, just have a sense of when to start then running jump. Either there is a small difference in the timing or I just fell out of my routine, probably the latter.)
David wrote: Here's what I'm planning:
Figure out the length of at least those sounds which are used for timing.
Then, when the game wants to play one of those, set a variable that causes check_sound_playing() to return true, and set a timer with interval = the length of that sound.
When the timer strikes, set that variable to false (and stop the timer).
This is an interesting question. I think we have a flaw in the original game, and you'll have to decide whether you would like to correct it or keep it as close to the original as possible. For example, if you drink a feather-fall potion, take a jump and pause the game mid-air, the sound timer continues to advance and you can influence the outcome of the game by suitably timing the pause (or kill yourself by using it inadvertently).

Also, sometimes the sound on/off switch plays an important role. Normally sounds are still used for timing if they are turned off. However, e.g. on line 587 of seg006.c, in play_seq() there is an is_sound_on check before playing the sound and therefore the sound on/off setting affects the timing of the game.

I do prefer your deterministic timing solution, but keep in mind that speedrunners are (ab)using both of the above tricks, and that the first one might be required to play some of the mods too. Anyway, counting the frames seems to be the way to go, even if you go for running the counter in pause mode as well.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: David's open-source port of PoP (pre-release)

Post by David »

htamas wrote: Starting a new game after winning a previous one makes all texts in the game blue instead of white.
I fixed it in the upcoming version.
Norbert wrote: I'm testing here and there, and I think it's not possible to do this trick?
http://www.youtube.com/watch?v=zYF3OMJeWms#t=372
I tried it now, and it seems you're right.
htamas wrote: However, e.g. on line 587 of seg006.c, in play_seq() there is an is_sound_on check before playing the sound and therefore the sound on/off setting affects the timing of the game.
That is the "end of level" sound.
It affects how much you have to wait after the kid entered the exit door.
Andrew
Wise Scribe
Wise Scribe
Posts: 313
Joined: July 16th, 2009, 4:39 pm

Re: David's open-source port of PoP (pre-release)

Post by Andrew »

At the beginning of the game when the initial scene plays where Jaffar reaches for the princess, she steps back and he throws his hands in the air and casts the spell, there seem to be gaps around animated objects (such as torch flames) during the screen flashes. Kinda looks like animated GIFs with a black non-transparent background would. Is it just on my system or do you guys see it too?

P.S. Can't seem to take a screenshot despite numerous attempts, either because my timing's off or the effect's not showing up for some reason. If no-one else is seeing this let me know and I'll try and capture a video or something.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: David's open-source port of PoP (pre-release)

Post by Norbert »

Andrew wrote:Is it just on my system or do you guys see it too?
I see it too (on Linux).
Attachments
Intro cutscene flashes.
Intro cutscene flashes.
htamas
Efendi
Efendi
Posts: 10
Joined: February 22nd, 2009, 7:49 pm

Re: David's open-source port of PoP (pre-release)

Post by htamas »

David wrote: That is the "end of level" sound.
It affects how much you have to wait after the kid entered the exit door.
Yes, I know ;). It adds up to almost two minutes of difference throughout the game, and it's counted in the game time. I learned it back in 2006 after making a 19:19 speedrun with sounds on, and probably that's why I consider it unfair :). What was new for me when I read your source code is that it's not just an unintended side effect of disabled sound, but that there is an explicit check for that.
Andrew wrote: At the beginning of the game when the initial scene plays where Jaffar reaches for the princess, she steps back and he throws his hands in the air and casts the spell, there seem to be gaps around animated objects (such as torch flames) during the screen flashes. Kinda looks like animated GIFs with a black non-transparent background would. Is it just on my system or do you guys see it too?
I can confirm. Here is a screenshot:
Image
The corresponding code path is:
... > start_game > show_title > load_intro > pv_scene > proc_cutscene_frame > draw_proom_drects > copy_screen_rect > method_1_blit_rect > ...
Post Reply