Jump to content
Jet Set Willy & Manic Miner Community

Free space and code optimisation in "JSW"


jetsetdanny

Recommended Posts

Further to my 'Guardian Class 127' fix:

Immediately after the 'Pick up the first byte of the entity specification' LD L, (IX+$00), remove the RES 7, L and replace it with a check 'Is it #FF?': EX AF, AF'; LD A, L; CP $FF. [if not, skip the next three bytes.] If so, copy 'FF' to the address that is currently pointed at by the 'DE' register pair (i.e. the first byte of the Entity Buffer entry that is currently under consideration) and then jump forward to #894A, bypassing the loops which populate the rest of the entity buffer: JR NZ $03; LD (DE), A; JR $1B; EX AF, AF'. [The purpose of the two bookending EX AF, AF' commands is to retain, in A', the value of the A register which is counting down, from a starting value of 8, the number of entities being considered. Once the loop is exited early by the presence of an 'FF' Terminator byte, the value of A' no longer needs to be retained.]

 

If the guardian specification byte under consideration isn't an 'FF' Terminator, then the existing code is resumed at #8930 (after passing through the second EX AF, AF' command to restore the 'entity counter' to A). N.B. the operand of the relative jump at #8948 would need to be changed accordingly, to ensure that it still loops back to #892B.

 

[in Z80 code: remove 'CB BD' from #892E; insert '08 7D FE FF 20 03 12 18 1B 08'; replace '20 E1' previously at #8948 with '20 D9'.]

I now believe, although I haven't tried this yet, that it might be doable in seven bytes (replacing the two-byte RES 7, L instruction at #892E, so a net total of just five bytes would need to be inserted via consolidation):

 

08 7D 12 3C 28 $00 08

 

I haven't figured out the operand of the relative jump in the above yet; but it needs to send the program straight to #894A. EDIT: Actually, it might still be #1B, although the conditionality of the relative jump is now reversed so that it's now '28 1B' rather than '18 1B'.

 

FURTHER EDIT: If the one-byte efficiency at #893E has been employed (replacing the LD BC with a LD C , then the above relative jump forwards should be 28 1A. And similarly, the relative jump backwards below should read 20DD.

 

Also, the operand of the relative jump at #8948 would need to be 'changed differently'; I think it should now read '20 DC'.

Edited by IRF
Link to comment
Share on other sites

I have just noticed that the LD BC, $0000 command at #893E can be replaced with a LD C, $00, thereby saving one byte.

 

I believe the exact same trick can be pulled off at #8950.

 

And a similar trick at #8975, replacing the LD DE, $0000 with a LD E, $00.  (The value of 'D' is retained as #50 from the preceding command at #896B.)

Edited by IRF
Link to comment
Share on other sites

Further to my 'Guardian Class 127' fix:

 

 

I now believe, although I haven't tried this yet, that it might be doable in seven bytes (replacing two at #892E, so a net total of just five bytes would need to be inserted via consolidation):

 

08 7D 12 3C 28 $00 08

 

I haven't figured out the operand of the relative jump in the above yet; but it needs to send the program straight to #894A.  EDIT: Actually, it might still be #1B, although the conditionality of the relative jump is now reversed so that it's now '28 1B' rather than '18 1B'.

 

Also, the operand of the relative jump at #8948 would need to be 'changed differently'; I think it should now read '20 DC'.

 

I've tried the above and it worked!

Link to comment
Share on other sites

Comparing the 'The game has just loaded' routines for MM and JSW (contrast the two links below), the latter seems to go about sending the program to the 'Display the title screen...' routine in a rather roundabout way.

 

Perhaps this was originally done to try to confuse potential hackers who were attempting to bypass the 'Code entry screen' security element of the game?

 

But now that the 'Code entry' routine is a bit of a 'relic', maybe the MM approach could be used in JSW?  It would only take 7 bytes to disable interrupts, set the stack pointer (in the case of JSW, to #5BFE) and then make a direct jump to #87CA.

 

http://skoolkid.github.io/manicminer/asm/8400.html

http://skoolkid.github.io/jetsetwilly/asm/8400.html

Link to comment
Share on other sites

Personally i prefer to use the cursor keys when playing any speccy game as a bit chunk of my favourite games don't have the QAOP or define keys option so my hands are virtually hardwired into gravitating towards the numbers row on the keyboard, however, the whole of the top row of the letter keys are currently used to control Willy, would modifying this in some way save any bytes? so that only Q, W and M could be used or Q, P and Space or something like that.

 

Also i think disabling the buggy automated pause routine could save something

 

Maybe deleting the [ room might save something? Unless of course you intend to furnish it and make it accessible.

 

Matthew Smith also left a load of unused graphics laying about, they're just taking up space

 

The message "AIR" at address 33873  (8451H) seems somewhat superfluous  (sorry if this has already been mentioned)

 

Oh and what about removing the WRITETYPER cheat, I don't mean to be a spoilsport here but it was only written into the code for testing purposes  :P

Edited by Metalmickey
Link to comment
Share on other sites

I have just noticed that the LD BC, $0000 command at #893E can be replaced with a LD C, $00, thereby saving one byte (because the '00' value of B is retained from earlier on in the code that populates the current room with guardians).

 

Further to the above, I've just observed that this particular efficiency is present in 'Geoff Mode', so it is 'tried and tested'!

Edited by IRF
Link to comment
Share on other sites

I'm probably missing the point here but why not just compress the entire code? I know people here are not a big fan of compression as it makes the code harder to read like with JSW2 for example but is that not because there is no decompressor available making editing a lot harder?

 

 but what if you was the one doing all the compressing?  might it be easier to edit the code then compress and decompress at will .. imagine the extra rooms and nasties you could cram in using the original JSW engine...

 

just a thought that's all

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.