Today I debugged SDLPoP while doing steps from various frames.
(I tested it with the left wall in the first room of level 1. Instead of a "chomp" you get a "bump".)
Here are my findings:
(Apologies if it's hard to understand, but I can't explain it simpler!)
* The size of the step is ultimately decided in dist_from_wall_forward() (seg004.c).
It calculates the difference between x-coordinates of the edge of the kid's hitbox (char_x_left/right_coll) and the obstacle's edge.
From now on, assume the kid is turned
left, so we look only at
char_x_left_coll.
Now, the position of the kid's hitbox depends on two things: (See set_char_collision() in seg006.c)
* (1) By default, it is located at the edge of the kid's image.
* The "front" edge of the kid's image is in front of the actual xpos, the distance is the "DX" value of the current frame.
(That is,
char_x_left_coll = Char.xpos - cur_frame.dx; In reality this is achieved in a bit more complicated way.)
(The
sequence and frame tables can be found here:
viewtopic.php?p=15726#p15726
You should look at them if you want to follow me. Turning is sequence 5, end-run is sequence 13.)
* (2) Some frames may specify "thin". This moves the left and right edges of the hitbox by 4 units towards the other side.
(That is,
char_x_left_coll += 4;)
The safe step works correctly if the kid starts from standing (frame 0x0F).
The attributes of frame 0x0F are: DX=0, THIN=0. Therefore,
char_x_left_coll = Char.xpos;
Now look at the frames of turning:
frame 0x32 DX=4 THIN=1 ->
char_x_left_coll = Char.xpos - 4 + 4 =
Char.xpos; No problem here.
frame 0x33 DX=3 THIN=1 ->
char_x_left_coll = Char.xpos - 3 + 4 =
Char.xpos + 1; It's *as if* the kid was one unit further right, so he will step one unit bigger.
frame 0x34 DX=1 THIN=0 ->
char_x_left_coll =
Char.xpos - 1; It's *as if* the kid was one unit further left, so he will step one unit smaller.
Remember what happened in the game?
* If I single-step with esc until I get frame 0x32 (as on my screenshot) and then press shift-right, then the kid will show frame 0x33 for a moment, and only *then* will he step forward.
And what did we get above for
frame 0x33? "
It's *as if* the kid was one unit further right, so he will step one unit bigger."
This "one unit" is enough to step into the chomper!
And the error in the other direction:
* Single-step until frame 0x33. (One frame after what you see on my screenshot.)
* Press shift-right.
According to my previous quote, this will show
frame 0x34 briefly and the kid will step only then!
* Now press shift-right again. The kid won't step through the chomper, but do a very small step instead.
And what did we get above for
frame 0x34? "
It's *as if* the kid was one unit further left, so he will step one unit smaller."
The second, "very small" step is making up for the "one unit smaller" first step.
So... are you still with me or did I lose you earlier?