Aram wrote: ↑April 16th, 2018, 9:31 pm
I'll just do the trick.
That is very interesting.
David, any idea what happens there?
Maybe the prince briefly meeting the shadow while jumping changes some kind of game state?
Or a buffer overflow, maybe?
(Level 12a of Pyramid)
Re: Auto-resurrection
Posted: April 22nd, 2018, 11:02 am
by David
(I moved your post so our discussion won't get lost in the Pyramid topic.)
Norbert wrote: ↑April 16th, 2018, 9:50 pm
That is very interesting.
David, any idea what happens there?
Maybe the prince briefly meeting the shadow while jumping changes some kind of game state?
Or a buffer overflow, maybe?
(Level 12a of Pyramid)
I tested this now.
It seems that you indeed have to visit the shadow's room. (The shadow's HP stays on screen, but the video is cropped so that's not visible.)
It also works if I merely look at the shadow's room with the H/J/U/N keys.
For easier testing I moved the starting position to the ledge below the shadow's room.
From there I can't actually go up, but pressing "U" works. But if I don't press "U" then there is no resurrection.
The gate also needs to be closed. (Well, the first half of the video is about reaching the button that closes that gate.)
This also happens in SDLPoP, so I can probably figure out what happens by debugging.
Expect a follow-up coming soon...
Re: Auto-resurrection
Posted: April 22nd, 2018, 12:51 pm
by David
David wrote: ↑April 22nd, 2018, 11:02 am
This also happens in SDLPoP, so I can probably figure out what happens by debugging.
Expect a follow-up coming soon...
Here is what I found out:
When the kid lands, all his HPs are taken; in land()
This doesn't immediately zero the kid's HP, it merely sets hitp_delta; in take_hp()
guardhp_delta is copied to hitp_delta, and hitp_delta is applied; in do_delta_hp()
This means that the loss of hit points from the hard landing is *not* effective.
Note: This HP regeneration was already mentioned in the "permadeath" topic: viewtopic.php?p=15794#p15794
Note: If you saw the shadow but the gate is open, then the kid will appear dead but he will have non-zero HP.
And the game won't display "Press Button to Continue".
Re: Auto-resurrection
Posted: April 22nd, 2018, 2:34 pm
by Norbert
Thanks for doing the analysis.
It's not clear to me what is the relevance - if any? - of the closed gate.
Maybe I overlooked something in your post.
Why won't this work?
Re: Auto-resurrection
Posted: April 28th, 2018, 1:07 pm
by David
Norbert wrote: ↑April 22nd, 2018, 2:34 pm
It's not clear to me what is the relevance - if any? - of the closed gate.
Maybe I overlooked something in your post.
The kid bumps into the gate only if it's closed.
But it does not have to be a gate, it could also be a wall, or a gate top.
The mod uses an initially open gate because it forces the player to find the close button.
The shadow regenerates the kid's HP only while the shadow is made "stuck" offscreen by being initialized in every frame.
The game keeps the shadow "stuck" while the prince's x coordinate is at least 150.
That place is near the middle of the fourth tile from the right.
This is so that the shadow won't appear until you run over the loose floors on the original level 12.
Once the prince is left from that place (in any room!), shadow_initialized becomes true (1), and do_init_shad() is never called again (until you re-enter the shadow's room), and the shadow falls into the room.
In your video, you enter a room from the left, that is when x becomes less than 150.
Re: Auto-resurrection
Posted: April 28th, 2018, 7:49 pm
by Norbert
Okay, so...
The prince needs to bump into something, apparently.
Also, he needs to be above (or below?) 150 from the left - I think.
But not 150 pixels and/or not from the left screen border, because that's not the middle of the fourth tile from the right...
And by entering from the left, x becomes less than 150, but running right apparently does not change x?
Just now I tried moving the hole in my test level further left and further right, but the prince still dies.
What are the exact conditions required for this to work?
Maybe, after 'seeing' the shadow room, the prince's horizontal position may never again be in the 0-150 range, for the trick to work?
Re: Auto-resurrection
Posted: April 29th, 2018, 3:06 pm
by David
Norbert wrote: ↑April 28th, 2018, 7:49 pm
Also, he needs to be above (or below?) 150 from the left - I think.
But not 150 pixels and/or not from the left screen border, because that's not the middle of the fourth tile from the right...
Character's x positions are measured in a special coordinate system.
You can find a drawing in Mechner's docs about PoP1, on page 7.
Basically, x = 58 is the left edge of the screen, and the screen is 140 units wide, making each tile 14 units wide.
On the DOS screen, that will mean x = (150 - 58) * 320 / 140 = 210.
Norbert wrote: ↑April 28th, 2018, 7:49 pm
And by entering from the left, x becomes less than 150, but running right apparently does not change x?
Norbert wrote: ↑April 28th, 2018, 7:49 pm
Maybe, after 'seeing' the shadow room, the prince's horizontal position may never again be in the 0-150 range, for the trick to work?