SDLPoP; David's open-source port of PoP

Open-source port of PoP that runs natively on Windows, Linux, etc.
DarkPrince
Efendi
Efendi
Posts: 13
Joined: January 23rd, 2016, 11:08 pm

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

Post by DarkPrince »

I've recompiled again but couldn't exactly reproduce.

That is: without your patch, the sword is not visible when entered from the right (but gets picked up by mirror self properly).

With your patch, no change currently.

I'm unsure what lead to the random blocks appearing and now not. I am sorry.
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

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

Post by David »

Falcury wrote:But I cannot seem to reproduce this...
DarkPrince wrote:I'm unsure what lead to the random blocks appearing and now not.
1. First, you must look at the room when the sword is there, so the animation can start.
2. Remember that the animation is random and fast. Only a few values will show fake tiles, so the bug will usually not appear.

I could reproduce the bug now, but it took more than 10 tries.
And I used the built-in editor to put the starting position into room 18. (The sword is removed when you leave room 18 to the right.)
In one case, I also saw that a wall pattern appeared where the sword was. This might also happen in the original game.
DarkPrince wrote:I had the impression the colors for the blocks at the bottom where a bit off. [...] Any idea what my prince drank? :)
Just for the fun, there are some versions of PoP where the colors of the screen change while slow-falling is in effect:
https://www.youtube.com/watch?feature=p ... XqnI#t=251 (PC98)
https://www.youtube.com/watch?feature=p ... 7F8#t=1614 (PC Engine)
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

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

Post by David »

Falcury wrote: It occurs due to a workaround that we needed in order to circumvent a bug in SDL 2.0.3. The bug should have been fixed in 2.0.4 (I suppose we should upgrade to the new version, and take out the workaround?)
Problem!
With SDL 2.0.4, SDLPoP crashes when I resize the window in any way. This includes entering/exiting fullscreen mode.
The crash happens in the SDL_RenderClear() call.
If I comment that out then it crashes in SDL_RenderCopy().
If I also comment that out, then there is no crash (and no display either).

Apoplexy does not crash with the same DLL.

Update:
There are two versions of SDL2.dll in the SDL2-devel-2.0.4-mingw.tar.gz archive.
SDL2-2.0.4\i686-w64-mingw32\bin\SDL2.dll --> This crashes.
SDL2-2.0.4\lib\x86\SDL2.dll --> This does not crash. But this is version 2.0.2 !
acd2001
Scholar Scribe
Scholar Scribe
Posts: 1
Joined: January 26th, 2016, 2:31 am

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

Post by acd2001 »

You must recompile sdl2 v2.04 with this patch.
I have the same problem before...

diff -Naur src/render/direct3d/SDL_render_d3d.c src/render/direct3d/SDL_render_d3d.c
--- src/render/direct3d/SDL_render_d3d.c 2016-01-02 19:56:31 +0000
+++ src/render/direct3d/SDL_render_d3d.c 2016-01-13 22:24:01 +0000
@@ -1003,6 +1003,10 @@
{
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
+
+ if (!texturedata) {
+ return 0;
+ }

if (D3D_RecreateTextureRep(data->device, &texturedata->texture, texture->format, texture->w, texture->h) < 0) {
return -1;


https://bugzilla.libsdl.org/attachment. ... ction=edit
DarkPrince
Efendi
Efendi
Posts: 13
Joined: January 23rd, 2016, 11:08 pm

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

Post by DarkPrince »

David wrote:
Falcury wrote:But I cannot seem to reproduce this...
(The sword is removed when you leave room 18 to the right.)
That gave me a nice chuckle today.

Earlier when I read it, I didn't realize what you meant. I thought the sword was supposed to be still there and the mirror self picking it up in front of you blabla ...

I played the actual dos version today and OFCOURSE the sword isn't there the second time you enter the screen. That's the whole point because he took it in the meantime.

As I said, I chuckled at myself. Has been too long and I'm just a fart becoming old :-)
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

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

Post by David »

acd2001 wrote:You must recompile sdl2 v2.04 with this patch.
Thanks for that!

So it happens only with DirectX 9. -- So it's not a problem under Linux and OS X (they use OpenGL), and under newer versions of Windows that use DirectX 11.
And only with certain texture formats. -- Maybe that's why Apoplexy is not affected?

On a related note, maybe I should put the RGB/BGR hack back, but with a run-time check that sees whether it is needed.
DarkPrince wrote: Earlier when I read it, I didn't realize what you meant. I thought the sword was supposed to be still there and the mirror self picking it up in front of you blabla ...
Oh, so *this* is what you meant when you wrote:
DarkPrince wrote: without your patch, the sword is not visible when entered from the right (but gets picked up by mirror self properly)
But at last now everything is clear. :)

Anyway, the appearing fake wall was an actual bug, so thanks for the bug report!

(Hmm... Maybe the event could be changed to work as you thought, just for fun...)
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

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

Post by David »

David wrote:On a related note, maybe I should put the RGB/BGR hack back, but with a run-time check that sees whether it is needed.
Done: https://github.com/NagyD/SDLPoP/commit/ ... 134810a751
poirot
Developer
Developer
Posts: 394
Joined: March 24th, 2003, 8:52 pm
Location: Australia
Contact:

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

Post by poirot »

David wrote:
David wrote:On a related note, maybe I should put the RGB/BGR hack back, but with a run-time check that sees whether it is needed.
Done: https://github.com/NagyD/SDLPoP/commit/ ... 134810a751
Thank you for that! The blue palace levels started to annoy me!
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

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

Post by Falcury »

David wrote:
Falcury wrote:But I cannot seem to reproduce this...
DarkPrince wrote:I'm unsure what lead to the random blocks appearing and now not.
1. First, you must look at the room when the sword is there, so the animation can start.
2. Remember that the animation is random and fast. Only a few values will show fake tiles, so the bug will usually not appear.

I could reproduce the bug now, but it took more than 10 tries.
And I used the built-in editor to put the starting position into room 18. (The sword is removed when you leave room 18 to the right.)
In one case, I also saw that a wall pattern appeared where the sword was. This might also happen in the original game.
After a number of attempts, I managed to get a second (regular) wall spot to appear, in place of the sword:

Image

I suppose this should also (rarely) happen in the original game? If so, this has to be the most obscure bug that has been found in the game so far! Nice find! :)

Something unrelated:
I am trying to experiment with implementing some basic scripting capabilities. At the moment I am trying out Lua as a scripting language, because it is relatively lightweight, easy to use and has a clean C interface.
Other options may be AngelScript, GameMonkey or Pawn. However, these all seem to be more complicated and (in the case of AngelScript and GameMonkey) we would have to mix C++ and C code.
Hopefully in the end such a scripting feature could make it easier for mod makers to define their own special events, custom potion effects, nonlinear gameplay, etc (without the need to distribute a custom executable).

Edit: Hm, libtcc also looks attractive. It can basically compile C code on the fly and run it as a script. Perhaps this is a better option than Lua.
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

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

Post by Falcury »

Here is a 'proof of concept' experimental version that shows how scripting could work.

I have used the Tiny C Compiler; it can dynamically load full-featured C code. Luckily, linking compiled C scripts back to the main program at runtime turns out to be not the most difficult part -- the main challenge could be to come up with a nice API...

I added this script as an example (filename is script.p1s):
Spoiler: show

Code: Select all

#include "pop_script.h"

void on_init_game() {
	int minutes = get_minutes_remaining();
	int ticks = get_ticks_remaining();
	printf("Script: old minutes remaining = %d, old ticks remaining = %d\n", minutes, ticks);
	set_time_remaining(999, 719);
}

void on_load_level(int level_number) {
	printf("Script: loaded level %d\n", level_number);
	if (level.start_dir == DIR_LEFT) {
		level.start_dir = DIR_RIGHT; // swap start direction
	} else level.start_dir = DIR_LEFT;
}

void on_load_room(int room) {
	int i;
	for (i = 1; i <= 30; ++i) {
		int tile = get_tile(room, i);
		// pillars are evil
		if (tile == TILE_PILLAR) set_tile(room, i, TILE_FLOOR);
	}
	play_sound(SOUND_MEET_JAFFAR); // life is dramatic
}
Once you grow tired of the script, you can of course simply delete it, rename it or modify it as you will.
Here is the pull request page on Github. Still very much a work in progress...
Attachments
SDLPoP_v1.17b1.zip
(4.84 MiB) Downloaded 60 times
User avatar
yaqxsw
Wizard Scribe
Wizard Scribe
Posts: 727
Joined: June 18th, 2012, 3:35 pm
Location: Germany

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

Post by yaqxsw »

A Problem:

1. If I use levigation, I dont hear levigation sound... what is problem :?:
2. If some save state on dosbox, dosbox will close... how solve problem :?:
3. How mix prince.exe with other prince.exe? I want, that SDLpop have 1000 minuts, special event + quicksave. How to do :?:
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

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

Post by Falcury »

yaqxsw wrote:A Problem:

1. If I use levigation, I dont hear levigation sound... what is problem :?:
2. If some save state on dosbox, dosbox will close... how solve problem :?:
Hi yaqxsw,
I don't fully understand what you mean. Are you playing the DOS version using DOSBox, or are you using SDLPoP? Could you give some more details?
yaqxsw wrote:3. How mix prince.exe with other prince.exe? I want, that SDLpop have 1000 minuts, special event + quicksave. How to do :?:
The starting time cannot be easily changed yet. But, we can add an option in SDLPoP.ini for this in the next version.
What special event are you referring to?
User avatar
yaqxsw
Wizard Scribe
Wizard Scribe
Posts: 727
Joined: June 18th, 2012, 3:35 pm
Location: Germany

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

Post by yaqxsw »

Hi yaqxsw,
I don't fully understand what you mean. Are you playing the DOS version using DOSBox, or are you using SDLPoP? Could you give some more details?
I use Apoplexy. I think, it should DOSbox.
The starting time cannot be easily changed yet. But, we can add an option in SDLPoP.ini for this in the next version.
What special event are you referring to?
There are many special event, for example winning room, skeleton awake and other... I dont want create again SDLPoP prince.exe because it would take many time
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

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

Post by David »

Falcury wrote:The starting time cannot be easily changed yet. But, we can add an option in SDLPoP.ini for this in the next version.
It's already there: start_minutes_left = default and start_ticks_left = default.
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

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

Post by Falcury »

David wrote:
Falcury wrote:The starting time cannot be easily changed yet. But, we can add an option in SDLPoP.ini for this in the next version.
It's already there: start_minutes_left = default and start_ticks_left = default.
Ah yes, I forgot. Wow, that was stupid of me.
Post Reply