Jump to content


Photo

Fixing the 'Ramps vs Walls' Bug


  • Please log in to reply
13 replies to this topic

#11 Norman Sword

Norman Sword

    Advanced Member

  • Member
  • PipPipPip
  • 125 posts

Posted 24 December 2017 - 05:56 PM

Just a note on the file I posted:

 

What is happening?

In the original JSW, the code for jumping and moving up and down ramps, are set in one overall routine that detects wall blocks and stops movement.

Within the code of the original, was two sets of movement code that treated the movement going left and the movement going right differently.

 

Moving left.

The code for moving left omitted a check for head height blocks. This permits willies head to pass through blocks moving left. This also permits willies head to pass through blocks at head height when jumping. Another routine at #8df7 detects the passage through the block at head height and immediately pushes willy downward to cell align him into/onto the block below. In most cases this works well if willy is going upwards on a jump. If willy is going downwards on a jumping arc, then the code at #8df7 will appear to move willy suddenly downward. This is the characteristic jerk as willy hits a wall and slides down it into a gap.

Moving right

This code blocks the movement of willies head through a wall tile. The result is that willy can not jump into slots cut out of walls in the same manner. Because willies body and head do not enter in a wall tile, willy will slide down walls at a normal speed, until his feet land on something. 

 

consequence.

The slight difference in the movement is why the game has cut outs in vertical walls only in left jumped to walls. The same style cut out that exist in right cut out walls normally have a platform below the cut out, on which willy can land. It also is the reason for the jerk jumping left in certain circumstances that are not replicated going right.

 

Fixs

Various fixs can be applied and each fix might cure one or other problem.

1) stop willies head passing through a block.
This fix will stop the jumps into cut outs.

 

2) allow willies head to pass through a block going right.
This fix will enable jumps left and right into cut outs. But willy will pass through so many blocks it just looks wrong.

 

3) rewrite the lot.
This introduces so many new variables, that anything can happen. My thoughts on that are GOOD LUCK.

 

DEMO 
The demo program posted above changes its set of rules depending on what is happening.
1) If willy is walking up or down a ramp then it will check for willies head/body/above head(going up)/below head (going down).
When jumping the rules are changed. When jumping upward it checks above his head, his head and also his body. If not cell aligned it will check the third cell (lower body/under foot)
2) When jumping downward  it ignores the head check and checks for his body and if free to move also checks the cell below his body (under foot). This double check for body and lower body/under foot is needed to ensure that willy is actually passing into a gap in which he can fit. (two cells high)
If the two cells are free then the code permits willies head to pass through a wall block. The code at #8df7 will detect the passage through a wall block and immediately pull willy downwards into the gap. This is what happens in the original game. The only difference in this demo is that it now happens going left or right, but willies head is blocked from passing into wall blocks when walking, walking on ramps, or even jumping upward.

 

Any modification will invariably introduce new problems. Simply because the original game appears to have been constructed around the non symmetry of code. Some of these problems are very easy to fix others are waiting to come to light.

 

ADDENDUM

Most of the labels I have in this area have been moved/change/deleted . I have had to use an unchanged version, to find the address I am referencing. 

 

Over head wall check, that push's willy downward , as written by 

 

The complete Jet Set Willy RAM disassembly 2017 11 13
© 1984 Software Projects Ltd. © 2017 Richard Dymond.
Created using SkoolKit 6.1.

 

 

Adjust Willy's attribute buffer location at 85D3 depending on his pixel y-coordinate
8DF7 LD A,($80B2)      Pick up the attribute byte of the wall tile for the current room from 80B2
8DFA CP (HL)               Is the top-left cell of Willy's sprite overlapping a wall tile?
8DFB JP Z,$8EBC        Jump if so
8DFE INC HL                Point HL at the top-right cell occupied by Willy's sprite
8DFF CP (HL)              Is the top-right cell of Willy's sprite overlapping a wall tile?
8E00 JP Z,$8EBC        Jump if so

 

The code at $8ebc will adjust his position

 

The top-left or top-right cell of Willy's sprite is overlapping a wall tile.
8EBC LD A,($85CF)     Adjust Willy's pixel y-coordinate at 85CF so that the top row of cells of his sprite is just below the wall tile
8EBF ADD A,$10
8EC1 AND $F0
8EC3 LD ($85CF),A
8EC6 CALL $8E9C      Adjust Willy's attribute buffer location at 85D3 to account for this new pixel y-coordinate
8EC9 LD A,$02           Set the airborne status indicator at 85D1 to 0x02: Willy has started falling
8ECB LD ($85D1),A
8ECE LD HL,$85D0    Reset bit 1 at 85D0: Willy is not moving left or right
8ED1 RES 1,(HL)
8ED3 RET


Edited by Norman Sword, 25 December 2017 - 01:37 PM.


#12 IRF

IRF

    Advanced Member

  • Contributor
  • 3,760 posts

Posted 24 December 2017 - 07:51 PM

Some interesting analysis, thanks Norman!

 

(I think the code you're referring to, which ejects Willy downwards from a wall tile during a jump, is at #8EBC.)

 


Any modification will invariably introduce new problems. Simply because the original game appears to have been constructed around the non symmetry of code. Some of these problems are very easy to fix others are waiting to come to light.

 

Indeed!  I only discovered today that the alternative fix which I came up with to allow Willy to jump into cut-out gaps in walls (namely to increment his horizontal movement one more time at the end of a jump, by replacing the RET at #8EB5 with a JUMP to #8FBC), has an unforeseen and critical impact on the game - because each jump takes Willy one horizontal increment further, the sequence of jumps along the conveyor in 'Under the Drive' no longer allow Willy to complete that room (and hence he can't complete the game, unless the layout of that room is changed!)


Edited by IRF, 24 December 2017 - 08:01 PM.


#13 IRF

IRF

    Advanced Member

  • Contributor
  • 3,760 posts

Posted 25 December 2017 - 09:31 PM

Another routine at #8df7 detects the passage through the block at head height and immediately pushes willy downward to cell align him into/onto the block below. In most cases this works well if willy is going upwards on a jump. If willy is going downwards on a jumping arc, then the code at #8df7 will appear to move willy suddenly downward. This is the characteristic jerk as willy hits a wall and slides down it into a gap.


I would add that when Willy is moving upwards, he has only usually moved up by one increment when the code kicks in, so the push back downwards is also only by one increment and therefore doesn't seem as stark. Whereas when he is on the way down, the code takes effect as soon as his head is aligned with the block, so the instantaneous downwards adjustment is an entire cell-row - much more noticeable.

I think it could be solved by only preventing the wall-head check when Willy is jumping AND the Jump Counter (#85D5) has reached a value of 11 (#17 in hex) i.e. one increment before the end of the jump, which occurs when #85D5 = 18 (#12).


Edited by IRF, 28 December 2017 - 08:42 PM.


#14 IRF

IRF

    Advanced Member

  • Contributor
  • 3,760 posts

Posted 10 March 2018 - 01:20 AM

Just a note on the file I posted:

What is happening?
In the original JSW, the code for jumping and moving up and down ramps, are set in one overall routine that detects wall blocks and stops movement.
Within the code of the original, was two sets of movement code that treated the movement going left and the movement going right differently.

Moving left.
The code for moving left omitted a check for head height blocks. This permits willies head to pass through blocks moving left. This also permits willies head to pass through blocks at head height when jumping. Another routine at #8df7 detects the passage through the block at head height and immediately pushes willy downward to cell align him into/onto the block below. In most cases this works well if willy is going upwards on a jump. If willy is going downwards on a jumping arc, then the code at #8df7 will appear to move willy suddenly downward. This is the characteristic jerk as willy hits a wall and slides down it into a gap.
Moving right
This code blocks the movement of willies head through a wall tile. The result is that willy can not jump into slots cut out of walls in the same manner. Because willies body and head do not enter in a wall tile, willy will slide down walls at a normal speed, until his feet land on something.

consequence.
The slight difference in the movement is why the game has cut outs in vertical walls only in left jumped to walls. The same style cut out that exist in right cut out walls normally have a platform below the cut out, on which willy can land. It also is the reason for the jerk jumping left in certain circumstances that are not replicated going right.

Fixs
Various fixs can be applied and each fix might cure one or other problem.
1) stop willies head passing through a block.
This fix will stop the jumps into cut outs.

2) allow willies head to pass through a block going right.
This fix will enable jumps left and right into cut outs. But willy will pass through so many blocks it just looks wrong.

3) rewrite the lot.
This introduces so many new variables, that anything can happen. My thoughts on that are GOOD LUCK.


Norman, I have now managed to achieve a rewrite of Willy's movement code which allows him to make jumps into 'cut outs' between underfoot and overhead wall blocks, such as the ledges in the Wine Cellar, AND which preserves the smooth arc of Willy's jumps, avoiding the sudden 'jerking downwards' as he hits a wall which you described above.

All of which is implemented in a symmetrical manner, with shared code for both leftwards and rightwards movement. ;)

Please see the file titled 'After Comprehensive Willy Movement Rewrite', attached to this post:
http://jswmm.co.uk/t...code/#entry9109

N.B. Achieving this required a redesign of the following:

- the 'Move Willy (1)' routine [deals with vertical movement - a modified version of the 'eject Willy downwards if his head enters a wall block' subroutine at #8EBC is used to eject him upwards if his feet enter a wall block!];

- the 'Move Willy (3)' routine [deals with horizontal movement, including along ramps - the changes were mostly taken from your code, as provided elsewhere in this forum, but with some minor tweaks - Willy's head can only enter a wall block if he is jumping and his Jump Counter variable holds a value of 17, one increment short of the end of the jump], and;

- the 'Draw Willy' routine [to over-ride the tendency to draw Willy downwards whilst he is standing on a ramp if he is also standing on a wall tile - I drafted my own code for this purpose, although part of it was initially based on one of your contributions].

Edited by IRF, 10 March 2018 - 08:54 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users