Jump to content
Jet Set Willy & Manic Miner Community

Question about a (tiny little) code optimisation in "Manic Miner"


jetsetdanny

Recommended Posts

Thanks for all your comments 🙂 .

Yes, the initial one-byte optimisation I came up with is at #904C, as described by Ian above.

I have since rewritten this code completely, gaining a few bytes. The way Matthew set the attributes for Willy and the swordfish (starting at 9052) is unnecessarily complicated and takes more bytes than a simpler solution. He does this (as per SkoolKid's disassembly) like this:

image.png

Yet it is easier and takes fewer bytes to just set the attributes by doing a series of instructions 21 LD HL,0000 and then 22 LD (0000),HL.

Until now I would never have thought I would one day judge and criticise the code Matthew Smith wrote! It sounds like blasphemy and I'm all trembling as I write these words! 😉 But the truth is that by modifying this code I gained a few bytes, which allowed me to achieve what I was looking for 🙂 .

Incidentally, this is for a project which is NOT my game, I'm merely adding some finishing touches to it. It's a fantastic game, and it should be released really soon, before the (European) summer is over...

Before the release happens, though - or, to be precise, until the end of July - I will be extremely occupied with real-world matters and may not be able to post much here or react to posts I would otherwise like to react to. Please bear with me, I will be back in August 🙂 .

Link to comment
Share on other sites

There is another aspect of the code in that vicinity which is worthy of comment. The way that Matthew hid Willy's legs underneath the Swordfish (at #9071-#9076) is not ideal. He just changed the attributes to black-on-black, but that means that they reappear during the colour-cycling when the remaining air in The Final Barrier is counting down. It's better to wipe the pixels of his feet from the screen instead, which would take about 8 or 9 bytes to replace those at #9071-76 (so two or three more bytes are needed to achieve it):

LD HL, #40F3 - point HL at the appropriate place in the pixel screen file [with Matthew's original code, HL will be pointing at #58F3 when flow of execution reaches #9071 so L already holds the correct value and therefore this command could be a LD H, #40 to save one byte. But Danny's more efficient method that he described in the post before this might mean that particular efficiency isn't available, and you might have to define both H and L]

LD DE, #???? - point DE at somewhere in the code with 32 contiguous zero bytes

CALL #8FF4

That also wipes the pixels from the character row below the one with Willy's 'ghost legs' (that part of the screen should be empty anyway so it's pointless-but-harmless).

****

For two more bytes, you can only wipe one character row of pixels (the one with Willy's legs in it), meaning that you would only have to find 16 contiguous zero bytes to point DE at. To do that, replace the CALL #8FF4 with:

LD B, #08

CALL #8FF6 - note the late entry point into the 'Draw a Sprite' routine, to ensure that only 1x2 character spaces are wiped, instead of 2x2 as usual

Edited by IRF
Link to comment
Share on other sites

  • 3 weeks later...
On 7/16/2023 at 9:51 AM, IRF said:

There is another aspect of the code in that vicinity which is worthy of comment. The way that Matthew hid Willy's legs underneath the Swordfish (at #9071-#9076) is not ideal. He just changed the attributes to black-on-black, but that means that they reappear during the colour-cycling when the remaining air in The Final Barrier is counting down.

Thanks for mentioning this, Ian!

Due to the nature of the project I've mentioned, this is not a problem there... (and I won't say any more about it right now 😉).

  

On 7/16/2023 at 7:59 AM, jetsetdanny said:

Incidentally, this is for a project which is NOT my game, I'm merely adding some finishing touches to it. It's a fantastic game, and it should be released really soon, before the (European) summer is over...

Before the release happens, though - or, to be precise, until the end of July - I will be extremely occupied with real-world matters and may not be able to post much here or react to posts I would otherwise like to react to. Please bear with me, I will be back in August 🙂data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== .

Well, I'm back 🙂 . I've just moved back to Warsaw, Poland from the United States (where I worked for the last five years) and I'm catching up with things that have been happening on the scene. I do hope I will have more time for JSW in the foreseeable future, and I definitely want to dedicate a significant portion of my spare time to it (various aspects of it: developing JSW Central, developing the JSW Central YouTube channel, assisting with other people's projects and ultimately resuming creation of my own games).

Link to comment
Share on other sites

  • 2 months later...
9 minutes ago, jetsetdanny said:

Yes 🙂 .

Have you reached the last cavern yet and seen what I meant by "Due to the nature of the project I've mentioned, this is not a problem there..."  ?

Yes.

I did slightly resent the implication in the final message that I might have cheated in order to see it. (Even though I did! 🤣) 

Edited by IRF
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.