SDLPoP; David's open-source port of PoP

Open-source port of PoP that runs natively on Windows, Linux, etc.
Falcury
Calif
Calif
Posts: 568
Joined: June 25th, 2009, 10:01 pm

Re: SDLPoP; David's open-source port of PoP

Post by Falcury »

I implemented support for PC speaker sounds.
See: https://github.com/NagyD/SDLPoP/pull/188

It can be tested by removing the DIGISND and MIDISND files from the data folder, so that SDLPoP will automatically fall back to the IBM_SND files.
Also, the blinking sound of the "Press button to continue" text only exists as a speaker sound, so that sound can now finally be played.
I am not 100% happy with my implementation of a square wave synthesizer, because the sound seems to hitch a tiny bit when switching from one note to another. Maybe that can be fixed later on.

Edit: I guess with the addition of support for speaker sounds, SDLPoP is more or less "feature complete"? As in, it's on par with the most commonly used configuration of the original Prince of Persia for DOS? (Although of course there are less commonly used audio and video modes that have not been implemented in SDLPoP.)
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

Falcury wrote: January 5th, 2019, 3:43 pmAlso, the blinking sound of the "Press button to continue" text only exists as a speaker sound, so that sound can now finally be played.
Neat. Makes the program even more polished.
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP; David's open-source port of PoP

Post by David »

Falcury wrote: January 5th, 2019, 3:43 pm I implemented support for PC speaker sounds.
See: https://github.com/NagyD/SDLPoP/pull/188
It works mostly well for me.
However, I have some remarks:

1.

Code: Select all

 	period_in_samples /= 2.0f; // Apparently, the frequencies in the sound files are an octave too low.
This division is indeed needed, but not for the reason that you wrote.
It's needed because we need the time between two "flips", which is the half of the period.

Code: Select all

             period
     <--------------------->
      __________            __________
     |          |          |          |
_____|          |__________|          |_____
     <---------->
  time between flips
2.

Code: Select all

 				memset(stream, square_wave_state, sizeof(short));
I don't think this is correct. memset() will fill both bytes of the current sample with the low byte of square_wave_state.
If I change the initial value of square_wave_state to 1024 then the square wave can't be heard at all. (The output will flip between 0x0000 and 0xFFFF.)
Didn't you mean something like this instead?

Code: Select all

 				*(short*)stream = square_wave_state;
3.
Some sound effects sound really different from the original game.
For example, the gate slam (res10006) at the beginning of level 1, or the breaking loose floor (res10002), or the closing level door (res10014).
What's common about these sounds is that they consist of notes with length = 1.

I think that stream should be incremented after the call to generate_square_wave().
This increment is already present in the "rest" branch of the if, so it just has to be moved outside:

Code: Select all

		size_t copy_len = (size_t)note_samples_to_emit * bytes_per_sample;
		if (note->frequency <= 0x01 /*rest*/) {
			memset(stream, digi_audiospec->silence, copy_len);
		} else {
			generate_square_wave(stream, (float)note->frequency, note_samples_to_emit);
		}
		stream += copy_len;
The aforementioned sounds play correctly after this.
Falcury
Calif
Calif
Posts: 568
Joined: June 25th, 2009, 10:01 pm

Re: SDLPoP; David's open-source port of PoP

Post by Falcury »

Thanks for the feedback, David! :) This clears things up for me, and I think you are totally right.
I added a second commit, with the changes applied. I renamed period_in_samples to half_period_in_samples (that seemed appropriate). I also updated ChangeLog.txt, which I had initially forgotten to do.
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP; David's open-source port of PoP

Post by David »

Falcury wrote: January 6th, 2019, 12:02 am I added a second commit, with the changes applied. I renamed period_in_samples to half_period_in_samples (that seemed appropriate). I also updated ChangeLog.txt, which I had initially forgotten to do.
Right, I merged it: https://github.com/NagyD/SDLPoP/commits
I also added the "stdsnd" command line parameter so you don't have to rename files to use PC Speaker mode.
(The "adlib" mode would also be easy to add, because it simply uses MIDI music with PC Speaker sound effects.)
Falcury wrote: January 5th, 2019, 3:43 pm I am not 100% happy with my implementation of a square wave synthesizer, because the sound seems to hitch a tiny bit when switching from one note to another. Maybe that can be fixed later on.
Is this still so? Fix #3 in my previous post might have fixed this, but I'm not sure.


GitHub just reminded me that my system is outdated:
For Windows XP, the last version of Firefox is 52.9 ESR. I have this version.
GitHub says (at the top of every page) that it doesn't support this browser version anymore. And indeed the Merge button doesn't work, among others.
Good thing I have Opera: GitHub doesn't complain about it, and the Merge button works there.
Falcury
Calif
Calif
Posts: 568
Joined: June 25th, 2009, 10:01 pm

Re: SDLPoP; David's open-source port of PoP

Post by Falcury »

David wrote: January 6th, 2019, 12:08 pmIs this still so? Fix #3 in my previous post might have fixed this, but I'm not sure.
Yes, I think that solved it.
It looks like fix #2 influenced only the amplitude of the wave (which makes sense, considering what you wrote), explaining why the initial value of square_wave_state needed to be changed from 1000 to a higher value, as you did in your most recent commit.

Edit:
David wrote: January 6th, 2019, 12:08 pm(The "adlib" mode would also be easy to add, because it simply uses MIDI music with PC Speaker sound effects.)
Right, good idea!
That mode has unique sound effects in version 1.3. A while back, somebody mentioned these on GitHub as a feature request:
https://github.com/NagyD/SDLPoP/issues/167
I think these sound effects use the percussion instruments of the OPL2 chip. (I briefly tried and failed to figure out how these work while implementing MIDI playback.)
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

Norbert wrote: December 26th, 2018, 8:16 pm
David wrote: December 26th, 2018, 1:09 pmDo you think I should move the last few posts about SDLPoP "in the wild" to a new topic?
Meh. Maybe if I find more in the future? :)
Well, I did run into another one.
https://www.youtube.com/watch?v=26uZkd_wke4
You can see the menu, plus use of quicksave/load throughout.
It's the original game with Pirates of Persia graphics, and a mobile/gamepad overlay.
David
The Prince of Persia
The Prince of Persia
Posts: 2877
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: SDLPoP; David's open-source port of PoP

Post by David »

Norbert wrote: January 12th, 2019, 9:09 pm https://www.youtube.com/watch?v=26uZkd_wke4
You can see the menu, plus use of quicksave/load throughout.
The menu has "WARP" instead of "SETTINGS". I wonder what it does...

I'm wondering why does the player visit every closed gate (at 0:03, 0:42, 1:09). :)
Norbert wrote: January 12th, 2019, 9:09 pm It's the original game with Pirates of Persia graphics, and a mobile/gamepad overlay.
Yeah, so the game can be played on a touchscreen.
At the very end you can see it's played on a smartphone.
Apparently the green button is shift (grab, attack), and the blue button is up (jump, parry) or maybe up+forward.

The uploader also made videos of levels 1-6: https://www.youtube.com/channel/UCRpa1i ... voA/videos

I'm wondering if this modified version is available somewhere?
Update:
Found it: https://play.google.com/store/apps/deta ... forandroid
It's the second result for "Prince of Persia" in Google Play: https://play.google.com/store/search?q= ... %22&c=apps
Now I'm wondering if the source code of this version is available somewhere?
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

David wrote: January 13th, 2019, 1:07 pmFound it: https://play.google.com/store/apps/deta ... forandroid
It's the second result for "Prince of Persia" in Google Play: https://play.google.com/store/search?q= ... %22&c=apps
Now I'm wondering if the source code of this version is available somewhere?
According to its page, this one has no ads or in-app purchases.
The permissions it takes are very broad though, including reading media and storage, plus full internet access.
This makes me think it, unfortunately, might be used as trojan software.
I don't have much faith in Google keeping crap away from Google Play.
Android phones have a bad reputation when it comes to the trustworthiness of available software.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

I see in the PoPOT stats that the SDLPoP page recently got about 50 visitors from:
http://www.inven.co.kr/board/diablo3/3991/64565
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

Norbert wrote: January 12th, 2019, 9:09 pm
Norbert wrote: December 26th, 2018, 8:16 pm
David wrote: December 26th, 2018, 1:09 pmDo you think I should move the last few posts about SDLPoP "in the wild" to a new topic?
Meh. Maybe if I find more in the future? :)
Well, I did run into another one.
Here you can see it on the Nintendo Switch homebrew screen, around 0:14.
https://www.youtube.com/watch?v=4LI9DL9yark
YURA
The Prince of Persia
The Prince of Persia
Posts: 1425
Joined: February 9th, 2017, 11:12 pm

Re: SDLPoP; David's open-source port of PoP

Post by YURA »

https://www.youtube.com/watch?v=26uZkd_wke4
You can see the menu, plus use of quicksave/load throughout.
It's the original game with Pirates of Persia graphics, and a mobile/gamepad overlay.
[/quote]

Norbert! Tell me, what is this MOD?
Looks like Pirates, but this is not the MOD?
https://www.popot.org/custom_levels.php?mod=0000047
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

YURA wrote: January 23rd, 2019, 1:31 amLooks like Pirates, but this is not the MOD?
It's the original game (no mod), but with the Pirates graphics.

(Someone added custom .DAT files to SDLPoP to create this.)
YURA
The Prince of Persia
The Prince of Persia
Posts: 1425
Joined: February 9th, 2017, 11:12 pm

Re: SDLPoP; David's open-source port of PoP

Post by YURA »

Norbert wrote: January 23rd, 2019, 1:40 am
YURA wrote: January 23rd, 2019, 1:31 amLooks like Pirates, but this is not the MOD?
It's the original game (no mod), but with the Pirates graphics.

(Someone added custom .DAT files to SDLPoP to create this.)
Thank you! Now everything fell into place.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: SDLPoP; David's open-source port of PoP

Post by Norbert »

A very minor difference between the original and SDLPoP: if the game is in upside-down mode (after drinking the flip potion) and time runs out, the original does not show the torch flames and hourglass in the princess room, while SDLPoP does. In SDLPoP, the torch flames do not move for most of that cutscene (when upside-down).
Post Reply