Level Exit Door Opening For Infinite

Discuss PoP1 for DOS here.
Post Reply
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Level Exit Door Opening For Infinite

Post by atrueprincefanfrom18 »

Why there is such behaviour of the level exit door?


Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Level Exit Door Opening For Infinite

Post by David »

atrueprincefanfrom18 wrote: April 3rd, 2020, 6:55 am Why there is such behaviour of the level exit door?
It's a bug in the game. PoP is not prepared to handle multiple exit doors.
See also: viewtopic.php?p=11965#p11965

Technical details:

It was fixed in SDLPoP here: https://github.com/NagyD/SDLPoP/commit/ ... 04880913c6
From this fix I can tell what caused the bug:
leveldoor_open = 0 when you start the level.
In SDLPoP before the fix (and in the original DOS game), when the first exit door fully opens, leveldoor_open is still 0, so (leveldoor_open == 0 || leveldoor_open == 2) is true, and the game goes on to stop the door (trob.type = -1). Then leveldoor_open becomes 1.
When the second exit fully opens, leveldoor_open is 1, so the condition is false and the game skips stopping the door.

By the way, the Apple II original doesn't have this bug. (I edited a level with leapop to check this.)
https://github.com/jmechner/Prince-of-P ... VER.S#L804
That version doesn't check the value of exitopen (the variable corresponding to SDLPoP's leveldoor_open), it always stops the gate when it's open enough.

What I don't know is why did the DOS version add the "if (leveldoor_open == 0 || leveldoor_open == 2)" check.
Does it do anything other than this bug?
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Level Exit Door Opening For Infinite

Post by atrueprincefanfrom18 »

David wrote: April 4th, 2020, 7:47 pm What I don't know is why did the DOS version add the "if (leveldoor_open == 0 || leveldoor_open == 2)" check.
I think maybe that's some sort of planned idea to use but which was never used or coded. Same way as there is a empty potion in the game (possible to add, but never really used in the original game).
David wrote: April 4th, 2020, 7:47 pm Does it do anything other than this bug?
Another is, you can go through another exit door, that's known by almost all.
What I was interested to find is:
1. Why did the next level didn't come? Does the level exit opening and stopping is colliding with moving on to next level? I had to manually use CTRL + A and only then I could go to Level 2...
2. What exactly happened on 0:35 in the video? The door started opening all over again!?
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
David
The Prince of Persia
The Prince of Persia
Posts: 2850
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Level Exit Door Opening For Infinite

Post by David »

atrueprincefanfrom18 wrote: April 4th, 2020, 9:11 pm 1. Why did the next level didn't come? Does the level exit opening and stopping is colliding with moving on to next level? I had to manually use CTRL + A and only then I could go to Level 2...
Probably because the game won't end the current level while a sound is playing:
https://github.com/NagyD/SDLPoP/blob/ma ... 003.c#L384
This check is intended to wait for the end level music to finish.
But in this case the level door sliding sound will play forever, so the level can't ever end.
Unless you press Ctrl+A, which stops all sounds.

Note: In SDLPoP (if I undo the fix) the sliding sound stops after the door in open enough (curr_modifier >= 43).
In the original game the sound is marked as looping, which means it will loop forever until it's explicitly stopped.
(Auto-)looping sounds are not supported in SDLPoP, so there the sound will loop only while play_sound(sound_15_leveldoor_sliding) is called.
https://github.com/NagyD/SDLPoP/blob/ma ... 007.c#L446

Also, in SDLPoP I always get a BackTable Overflow after the second exit opened too much.
I don't know why does that happen, though I should probably fix it...
UPDATE:
The error is caused by the loop which draws the moving part of the exit door: https://github.com/NagyD/SDLPoP/blob/ma ... 08.c#L1411
var_6 should be signed (short) instead of unsigned (word).
Fixed: https://github.com/NagyD/SDLPoP/commit/ ... 5055bf8798

atrueprincefanfrom18 wrote: April 4th, 2020, 9:11 pm 2. What exactly happened on 0:35 in the video? The door started opening all over again!?
A single byte stores how much is the door open.
When it's 255 and the game increases it further, it wraps around to 0.
User avatar
atrueprincefanfrom18
Site Shah
Site Shah
Posts: 1786
Joined: January 21st, 2020, 2:53 pm
Contact:

Re: Level Exit Door Opening For Infinite

Post by atrueprincefanfrom18 »

Hmm... Interesting.

Yes, the exit door sound is in loop... When you enter a level entrance door, while it's closing, press ESC to pause the game, you can hear that the door closing sound is still there and it goes on forever. I think same happens in this case...
Love to create new MODS :)

My complete list of mods until now!

My channel. Do consider subscribing it! :)
Post Reply