SDLPoP; David's open-source port of PoP
Re: David's open-source port of PoP (pre-release)
Did you try one of the solutions on that page?
The simplest would be this: "or you can add the MinGW\bin directory to the system path."
~~~~
Here is the new version.
Changes:
FIXED: Pressing "K" on a skeleton crashes the game.
DONE: The game will play digi sounds (only from DAT files)
The simplest would be this: "or you can add the MinGW\bin directory to the system path."
~~~~
Here is the new version.
Changes:
FIXED: Pressing "K" on a skeleton crashes the game.
DONE: The game will play digi sounds (only from DAT files)
- Attachments
-
- PORT_PoP_v1.08.zip
- (1 MiB) Downloaded 517 times
Re: David's open-source port of PoP (pre-release)
Ah, sound effects.
I played through the game and here's what I noticed:
- For some the pitch is off, for example for the level door opening (very clear) and the prince footsteps (less noticeable).
- I had the feeling that, now and then, not enough sound effects played at the same time. For example, two opening or two closing gates should emit alternating ticks, but if I'm not mistaken they don't in the conversion.
- I think the skeleton that comes alive in level 3 has a sound effect, but I didn't hear this in the conversion. Maybe another sound effect was playing during that animation (see issue above).
- In level 5 I tried trick 35 but instead of teleporting to the left of the gate in the room to the left (8) I got teleported to the room to the right (9).
- During the intro cinematic, when Jaffar opens the palace door the game quits with a "SDL_BuildAudioCVT: " message, shortly after playing (part of?) what appears to be an incorrect sound effect, namely a gate tick.

- For some the pitch is off, for example for the level door opening (very clear) and the prince footsteps (less noticeable).
- I had the feeling that, now and then, not enough sound effects played at the same time. For example, two opening or two closing gates should emit alternating ticks, but if I'm not mistaken they don't in the conversion.
- I think the skeleton that comes alive in level 3 has a sound effect, but I didn't hear this in the conversion. Maybe another sound effect was playing during that animation (see issue above).
- In level 5 I tried trick 35 but instead of teleporting to the left of the gate in the room to the left (8) I got teleported to the room to the right (9).
- During the intro cinematic, when Jaffar opens the palace door the game quits with a "SDL_BuildAudioCVT: " message, shortly after playing (part of?) what appears to be an incorrect sound effect, namely a gate tick.
Re: David's open-source port of PoP (pre-release)
This should be the same thing I mentioned here: viewtopic.php?p=14600#p14600 (that post and the next)Norbert wrote: - For some the pitch is off, for example for the level door opening (very clear) and the prince footsteps (less noticeable).
I might add something to mimic the limited selection of sample rates of the Sound Blaster, but that's not the only difference.
The original PoP can play only one sound effect at the same time.Norbert wrote: - I had the feeling that, now and then, not enough sound effects played at the same time. For example, two opening or two closing gates should emit alternating ticks, but if I'm not mistaken they don't in the conversion.
However, a sound may interrupt another one, if the current sound is marked as interruptible (in sound_interruptible[]) and the new sound has higher priority than the current (smaller number in sound_prio_table[]).
I copied this into the conversion.
Note that if two gates are opening or closing at the same time (triggered by the same button), then they just tick at the same time.
For alternating ticks you need some difference between the gates.
An opening gate ticks in every second frame.
A closing gate ticks in every fourth frame.
I could reproduce the alternating closing sounds in the conversion in the first room of level 10.
First, press the button at the bottom. When the gates begin to close, press the button above the right gate.
Then wait until the right gate starts to close again.
However, SDL has something called "size of the audio buffer" (desired->samples).
I don't know if SDL_PauseAudio(1) waits until the whole buffer is played.
If it does then it may affect the interrupting.
Anyhow, I think it affects the checking of whether a sound ended.
Currently, my code sends an event from digi_callback() if there is no more output data.
This is usually *after* the sound has ended, but the difference is not more than the size of the buffer divided by the output frequency.
Currently it's 512 / 22050 Hz ~ 0.023 s.
Yes, it has a sound effect, and it is played for me.Norbert wrote: - I think the skeleton that comes alive in level 3 has a sound effect, but I didn't hear this in the conversion. Maybe another sound effect was playing during that animation (see issue above).
I tried it now, you're right.Norbert wrote: - In level 5 I tried trick 35 but instead of teleporting to the left of the gate in the room to the left (8) I got teleported to the room to the right (9).
I added this to my bugs.txt so I won't forget it.
And I found yet another bug while I tried that:
If you back out from the room where the guard is originally (but the screen is not switched), the kid might fall through the floor at the level door.
That also happens to me.Norbert wrote: - During the intro cinematic, when Jaffar opens the palace door the game quits with a "SDL_BuildAudioCVT: " message, shortly after playing (part of?) what appears to be an incorrect sound effect, namely a gate tick.
If you listen the original game carefully, the gate tick is there, but it's immediately followed by the other sound.
The error message means that SDL_BuildAudioCVT() did not succeed (its return value is not 1), and it gives an empty error message.
It might be related to the sample rate of that one sound. (14000 Hz)
I added a debug printout to show the return value of SDL_BuildAudioCVT(), and it's 0.
The SDL 1.2 doc says "Returns -1 if the filter could not be built or 1 if it could.".
So the documentation does not cover all cases.
However, the SDL 2.0 doc says "Returns 1 if the audio filter is prepared, 0 if no conversion is needed, or a negative error code on failure; call SDL_GetError() for more information.".
So now I modified the code to accept both 0 and 1 as success.
(But "no conversion is needed" sounds strange in this case. The sound is 14000 Hz, the output is 22050 Hz.)
Code: Select all
SDL_AudioCVT cvt;
memset(&cvt, 0, sizeof(cvt));
int result = SDL_BuildAudioCVT(&cvt,
AUDIO_U8, 1, buffer->digi.sample_rate,
digi_audiospec->format, digi_audiospec->channels, digi_audiospec->freq
);
if (result != 1 && result != 0) {
sdlperror("SDL_BuildAudioCVT");
printf("(returned %d)\n", result);
quit(1);
}
Re: David's open-source port of PoP (pre-release)
(level 5)
Repeat this: Press left and esc together, then press esc again.
The "throughfloor_opendoor" bug can be reproduced in the original game in the same way.
I think I found what is causing the bug.
check_on_floor() (in seg006.c) calls get_tile_at_char().
At that point, Char.room = 9, Char.curr_col = 9, Char.curr_row = 2. (Why?)
The tile at that position is a wall.
So the following functions are called: in_wall(), load_fram_det_col(), determine_col(), get_tile_div_mod_m7(), get_tile_div_mod().
get_tile_div_mod() is called with xpos = -14. But it uses xpos as an array index!
Accessing an out-of-range element of an array might return different values in the original game and in the conversion.
Those arrays are used for converting xpos into a tile column, and a position within the tile.
So I replaced array accesses with division and modulo.
This also fixes the original bug you wrote about.
First, I found out how to reproduce this reliably:David wrote:If you back out from the room where the guard is originally (but the screen is not switched), the kid might fall through the floor at the level door.
Repeat this: Press left and esc together, then press esc again.
The "throughfloor_opendoor" bug can be reproduced in the original game in the same way.
I think I found what is causing the bug.
check_on_floor() (in seg006.c) calls get_tile_at_char().
At that point, Char.room = 9, Char.curr_col = 9, Char.curr_row = 2. (Why?)
The tile at that position is a wall.
So the following functions are called: in_wall(), load_fram_det_col(), determine_col(), get_tile_div_mod_m7(), get_tile_div_mod().
get_tile_div_mod() is called with xpos = -14. But it uses xpos as an array index!
Accessing an out-of-range element of an array might return different values in the original game and in the conversion.
Those arrays are used for converting xpos into a tile column, and a position within the tile.
So I replaced array accesses with division and modulo.
This also fixes the original bug you wrote about.
Code: Select all
int __pascal far get_tile_div_mod(int xpos) {
// xpos might be negative if the kid is far off left.
// In this case, the array index overflows.
/* if (xpos < 0 || xpos >= 256) {
printf("get_tile_div_mod(): xpos = %d\n", xpos);
}*/
// obj_xl = tile_mod_tbl[xpos];
// return tile_div_tbl[xpos];
int x = xpos - 58;
int xl = x % 14;
int xh = x / 14;
// Integer division rounds towards zero, but we want to round down.
if (x < 0 && xl != 0) {
--xh;
}
// Modulo returns a negative number if x is negative, but we want 0 <= xl < 14.
if (xl < 0) {
xl += 14;
}
obj_xl = xl;
return xh;
}
Re: David's open-source port of PoP (pre-release)
Let's use DOSPoP.David wrote:Yes, I know that the current "name" is a bit long.
But I don't know what/which name to choose.
That is David's Open-Source Port of PoP, as you describe the conversion, and as a bonus it includes references to the Disk Operating System (DOS) and Prince of Persia (PoP).
An obvious choice, short, to the point, easy to pronounce, easy to remember, and probably the most logical choice.
A verbatim(!) Google search for 'dospop "prince of persia"' currently returns just three hits, one of which is a post about the abbreviation on this forum.
This should make it easy for anyone to find mentions of the conversion in the future.
Agreed? Anyone who thinks this name/abbreviation is a bad choice?
Re: David's open-source port of PoP (pre-release)
Or maybe SDLPoP, or something else with SDL in it, but then you need to make sure to never switch libraries. 

Re: David's open-source port of PoP (pre-release)
DOSPoP: I am still concerned about confusion with the original DOS PoP, especially if they are mentioned together.
SDLPoP: At least there is no confusion here. I don't think I will switch libraries. (Except possibly to SDL2, for the better fullscreen support. -- But that's still SDL.)
SDLPoP: At least there is no confusion here. I don't think I will switch libraries. (Except possibly to SDL2, for the better fullscreen support. -- But that's still SDL.)
Re: SDLPoP; David's open-source port of PoP (pre-release)
All right, SDLPoP.
Added it here: http://www.popot.org/get_the_games.php?game=SDLPoP
And here: http://www.princed.org/downloads/
Also added it to this thread's subject.
Near "We are currently converting the game to Windows and Linux: [...]" in the final 25th anniversary text I will add "SDLPoP: " and "PoP.NET: " in front of the URLs.
In future news entries on the Princed home page, Facebook, Twitter, and so on, I'll also use SDLPoP (in addition to a short description of what it entails).
Added it here: http://www.popot.org/get_the_games.php?game=SDLPoP
And here: http://www.princed.org/downloads/
Also added it to this thread's subject.
Near "We are currently converting the game to Windows and Linux: [...]" in the final 25th anniversary text I will add "SDLPoP: " and "PoP.NET: " in front of the URLs.
In future news entries on the Princed home page, Facebook, Twitter, and so on, I'll also use SDLPoP (in addition to a short description of what it entails).
Re: SDLPoP; David's open-source port of PoP (pre-release)
Here is the new version.
Changes:
FIXED: The game quits in the intro, when Jaffar opens the door.
FIXED: When doing the level 5 trick (backing through the gate), the kid appears in the room to the *right* instead of left.
FIXED: Level 5: If you back out from the room where the guard is originally (but the screen is not switched), the kid might fall through the floor at the level door.
Renamed the project to SDLPoP.
DONE: Added version number to the window title.
Changes:
FIXED: The game quits in the intro, when Jaffar opens the door.
FIXED: When doing the level 5 trick (backing through the gate), the kid appears in the room to the *right* instead of left.
FIXED: Level 5: If you back out from the room where the guard is originally (but the screen is not switched), the kid might fall through the floor at the level door.
Renamed the project to SDLPoP.
DONE: Added version number to the window title.
- Attachments
-
- SDLPoP_v1.09.zip
- (1 MiB) Downloaded 522 times
-
- Calif
- Posts: 553
- Joined: August 27th, 2011, 2:04 am
Re: SDLPoP; David's open-source port of PoP (pre-release)
Good choice for name "Sdl POP" because this clearly references that is open source, and free liscence???
Check my Prince in C# https://github.com/salvadorc17/Prince-Monogame
Re: SDLPoP; David's open-source port of PoP (pre-release)
Not all programs and games created with the SDL library are open-source or free software.salvadorc17 wrote:Good choice for name "Sdl POP" because this clearly references that is open source, and free liscence???
SDL 1.2 is LGPL licensed and SDL 2 uses the zlib License. Both licenses allow use with proprietary software.
An example of a proprietary program that uses it is the Steam client, and an example of a proprietary game is Don't Starve.
-
- Calif
- Posts: 553
- Joined: August 27th, 2011, 2:04 am
Re: SDLPoP; David's open-source port of PoP (pre-release)
Ok, my mistake, but this is really good work anyway for David, then sdl is for cross-platforms???
Check my Prince in C# https://github.com/salvadorc17/Prince-Monogame
Re: SDLPoP; David's open-source port of PoP (pre-release)
StaticReturn sent me some changes (in a PM) that make it possible to compile the game undex Mac OS X.
(I don't have Mac OS X, so I can't try it.)
Here is the new version.
Changes:
FIXED: Made the game compatible with Mac OS X, based on the suggestions by StaticReturn.
FIXED: Fixed most things that caused compiler warnings. (For example: overflow in implicit constant conversion.)
CHANGE: Now cheats are disabled by default unless the game is compiled in debug mode.
(I don't have Mac OS X, so I can't try it.)
Here is the new version.
Changes:
FIXED: Made the game compatible with Mac OS X, based on the suggestions by StaticReturn.
FIXED: Fixed most things that caused compiler warnings. (For example: overflow in implicit constant conversion.)
CHANGE: Now cheats are disabled by default unless the game is compiled in debug mode.
- Attachments
-
- SDLPoP_v1.10.zip
- (1 MiB) Downloaded 454 times
-
- Efendi
- Posts: 13
- Joined: September 2nd, 2014, 4:14 am
Re: SDLPoP; David's open-source port of PoP (pre-release)
Here's the OS X version of SDLPoP that should run on Mac computers that don't have SDL installed. I only have my laptop for testing, so I make no promises that it will work on your computer.
Also, you should avoid running programs from untrusted sources. I trust me, but you shouldn't until I've earned that trust. So I suggest those who want to play Prince of Persia on a Mac should download the source code and build their own binary.
Have Fun!
-SR
PS: A new Makefile for OSX
Also, you should avoid running programs from untrusted sources. I trust me, but you shouldn't until I've earned that trust. So I suggest those who want to play Prince of Persia on a Mac should download the source code and build their own binary.
Have Fun!
-SR
PS: A new Makefile for OSX
Spoiler: show
- Attachments
-
- prince.zip
- (227.98 KiB) Downloaded 478 times
Re: SDLPoP; David's open-source port of PoP (pre-release)
Now that's something that we don't hear often.StaticReturn wrote: I trust me, but you shouldn't until I've earned that trust.
I think the forum deleted the tabs from that. (But they are there if I look at the source of your post by quoting it.)StaticReturn wrote: PS: A new Makefile for OSX