Jump to content


Photo

Opening Walls in JSW64


  • Please log in to reply
9 replies to this topic

#1 IRF

IRF

    Advanced Member

  • Contributor
  • 4,264 posts

Posted 10 November 2018 - 05:35 PM

I was looking at the code which implements opening walls in the JSW64 game engine.

 

The way the existing code works, the pixel-rows disappear from top to bottom, and then the attributes of the blocks are turned from Earth to Air.  However, if you have a opening wall which is several blocks high, none of the blocks get turned to Air until the whole wall has had its pixels cleared.  So you can temporarily have an INKless wall, several blocks high, before the whole lot turns to air.

 

Having scrutinised the pertinent code, and thinking out loud, I wonder if the original intention was for each block in turn (from the top one down) to turn to Air as the eight pixel-rows of each are cleared.  A simple single POKE can be used to achieve this - and it involves reversing the conditionality of a relative jump (so a simple mistake by John Elliott when writing the code might explain the way the feature ended up, if my hunch is right that they were intended to disappear one-by-one).

 

Have a look at the two test files attached.  They illustrate the difference between the two variants of opening wall mechanics.  The opening wall in the 'unfixed' file behaves exactly the same as in the unpatched JSW64 game engine.  In the 'fixed' file, I've changed the value of address #FFD9 from #20 (JR NZ) to #28 (JR Z).

 

Willy starts off in the Off Licence.  Collecting the single item in the room causes the wall to start opening.  I've come up with a little challenge based on the different behaviour of the opening wall - only in one of this pair of files is it possible for Willy to leave the room and access The Bridge.

 

EDIT: Both files have been updated, with the addition of an extra Fire cell to prevent an (unintended) loophole.

Attached Files


Edited by IRF, 10 November 2018 - 11:41 PM.


#2 Spider

Spider

    DEC (HL)

  • Administrator
  • 3,960 posts

Posted 10 November 2018 - 08:22 PM

That's quite good. The change is very easy to see.

 

 

Regarding the small challenge: I was not able to survive the jump down after the wall had gone, despite trying!

 

I suspect the correct method may involve a quirky manoeuvre, possibly by allowing his head to pass into a solid cell :unsure:

 

However I managed to *ahem* cheat my way out ;) I don't (think) this was intended escape route as its possible in both versions ? , one extra fire cell could prevent this though. Attaching two very small .rzx's of the escape, the 'fixed version' one is slightly quicker...

 

Attached File  Unfixed_Escape.rzx   31.27KB   71 downloads Attached File  Fixed_Escape.rzx   29.65KB   67 downloads


  • IRF likes this
Changing order to chaos since 1984

#3 jetsetdanny

jetsetdanny

    Advanced Member

  • Contributor
  • 2,111 posts

Posted 10 November 2018 - 08:42 PM

An interesting technical, improvement, Ian, and very well designed examples illustrating it - congratulations! :)

 

Andy, well done on the alternative escape route!  B)

 

However, the proper solution is very simple:

 

Attached File  Fixed Opening Wall solved.rzx   29.74KB   66 downloads


Edited by jetsetdanny, 10 November 2018 - 08:42 PM.


#4 IRF

IRF

    Advanced Member

  • Contributor
  • 4,264 posts

Posted 10 November 2018 - 11:40 PM

Well done Danny on completing it the 'official' way, and well done Andy on spotting the 'loophole'!

 

I've updated the files to prevent the latter, 'unofficial' solution (with a judiciously placed additional file cell), and reuploaded to the first post in this topic.



#5 Spider

Spider

    DEC (HL)

  • Administrator
  • 3,960 posts

Posted 11 November 2018 - 09:47 AM

The solution is so obvious when I saw it. :blush: I stayed on the righthand side of the wall and then tried various tricks to jump/land safely, with a vague idea of passing his head through a cell. Come to think of it I'm not quite sure how well those kind of 'quirks' are in JSW64 / JSW128 if at all...

 

The extra fire cell is about where I would of placed it too, to prevent an 'unintended escape' :)


Edited by Spider, 11 November 2018 - 09:48 AM.

Changing order to chaos since 1984

#6 IRF

IRF

    Advanced Member

  • Contributor
  • 4,264 posts

Posted 11 November 2018 - 10:06 AM

Of course the escape route doesn't work in the 'unfixed' version, because Willy can't safely drop down one cell row at a time.

Edited by IRF, 12 November 2018 - 08:01 AM.


#7 JohnElliott

JohnElliott

    Member

  • Contributor
  • 12 posts

Posted 16 November 2018 - 04:58 PM

I was looking at the code which implements opening walls in the JSW64 game engine.

 

The way the existing code works, the pixel-rows disappear from top to bottom, and then the attributes of the blocks are turned from Earth to Air.  However, if you have a opening wall which is several blocks high, none of the blocks get turned to Air until the whole wall has had its pixels cleared.  So you can temporarily have an INKless wall, several blocks high, before the whole lot turns to air.

 

Having scrutinised the pertinent code, and thinking out loud, I wonder if the original intention was for each block in turn (from the top one down) to turn to Air as the eight pixel-rows of each are cleared.  A simple single POKE can be used to achieve this - and it involves reversing the conditionality of a relative jump (so a simple mistake by John Elliott when writing the code might explain the way the feature ended up, if my hunch is right that they were intended to disappear one-by-one).

 

IIRC, the opening-wall code is pretty much lifted from the Kong Beast rooms in Manic Miner, so that's the best place to start looking to see what the intended behaviour is.



#8 IRF

IRF

    Advanced Member

  • Contributor
  • 4,264 posts

Posted 16 November 2018 - 06:01 PM

IIRC, the opening-wall code is pretty much lifted from the Kong Beast rooms in Manic Miner, so that's the best place to start looking to see what the intended behaviour is.


It works differently in MM's Kong rooms - there are two blocks which open up in parallel, the upper block opens 'upwards' (the bottom pixel-row clears first, then the next one up, etc) whilst the lower block opens 'downwards' (from the top pixel-row downwards). Because both blocks become cleared of all pixels at the same time, they turn to Air at the same time.

In JSW64 you can have a wall of arbitrary height (in terms of the number of Earth blocks), which opens from the top pixel-row downwards. Your code clears each pixel-row in turn, and then once the entire height of the wall is cleared of pixels, the attributes of each component block of the wall turn from Earth to Air. But the latter part of the code appears to allow for the possibility of turning each wall block to Air in turn, as each block's pixels become cleared. Indeed, reversing the conditionality of a single relative jump achieves this outcome, as I discovered.

The Manic Miner code doesn't really give a precedent from which we can draw a conclusion - at no point is there a 'completely cleared' wall block that is left retaining its 'INKless Earth' status, pending the clearance of the pixels of a separate block of the wall.

****

Incidentally, I have recently discovered a previously-undocumented bug in Matthew Smith's MM code: if you insert a blank pixel-row (00 graphic byte) midway down the Earth cell bitmap, then the opening wall turns to Air prematurely, leaving a 'ghost' of some remaining uncleared pixels - which the nearby horizontal guardian (whose range is edited once the wall has fully opened so that it passes through the gap created) promptly crashes into!

Edited by IRF, 16 November 2018 - 08:27 PM.


#9 JohnElliott

JohnElliott

    Member

  • Contributor
  • 12 posts

Posted 16 November 2018 - 08:33 PM

Ah yes, I remember - because an opening wall is of arbitrary height it was easier to do it from the top or bottom than from the middle.

 

Looking at my original source, there's a comment:

;
;When all segments have slid, change cell attributes.
;

which suggests that I intended it to behave as I wrote it.



#10 IRF

IRF

    Advanced Member

  • Contributor
  • 4,264 posts

Posted 19 November 2018 - 02:42 PM

Ah yes, I remember - because an opening wall is of arbitrary height it was easier to do it from the top or bottom than from the middle.

 

Looking at my original source, there's a comment:

;
;When all segments have slid, change cell attributes.
;

which suggests that I intended it to behave as I wrote it.

 

Fair enough. :)   Although, after having come up with the code tweak that causes the alternative opening mechanism, I think I actually prefer it that way - it seems more 'natural' that the wall blocks turn to Air one at a time, and it facilitates interesting challenges such as the one which Willy encounters in the 'fixed'* test file attached to the first post in this thread.

 

I wonder if there is a spare bit in the Opening Wall Guardian definition bytes, which could be used as a flag to determine which mechanism is used when a wall opens up?  Either on an individual 'wall instance' basis, or else on a 'per room' basis (with the code change to switch between the two mechanisms implemented via a 'Room Setup' Patch).

 

 

(*In hindsight, 'Fixed' and 'Unfixed' are inaccurate descriptions, in light of John's confirmation that the existing behaviour is as he intended.  'Changed ' and 'Unchanged' would be better; or 'Series' and 'Parallel' - the blocks turn to Air either in series or in parallel.)


Edited by IRF, 19 November 2018 - 06:35 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users