Jump to content
Jet Set Willy & Manic Miner Community

Free space and code optimisation in "JSW"


jetsetdanny

Recommended Posts

Small rewrite in the JSW game initialisation code which saves a byte:

 

87F5   LD HL,$857C     87F8   LD (HL),$30     87FA   INC HL     87FB   LD (HL),$30     87FD   INC HL     87FE   LD (HL),$30

 

LD HL, #857C

LD BC, #0330

loop:

LD (HL), C

INC HL

DJNZ loop

 

The simpler alternative is as follows

 

LD HL,#3030

LD (#857C),HL

LD (#857D),HL

 

9 bytes. Which is another byte shorter

Edited by Norman Sword
Link to comment
Share on other sites

  • 1 year later...

The start of the Move Willy(3) routine (#8FBC-#8FD0) could be simplified/shortened:

 

Within that part of the routine, Willy's Direction and Movement Flags variable (#85D0) is loaded up to A twice.  (First to check if he's moving left or right - Bit 1 - and RET to Main Loop if he isn't; then to check which way he's moving, left or right? - via Bit 0 - before deciding which path to proceed through the rest of the routine.)

 

But in between those two checks, the Rope Status Indicator (#85D6) is loaded up to A and its value tested (with a RET to Main Loop if Willy's on a rope).

 

If the test of the rope status is put first in that sequence, before the movement/direction flags are loaded up to A, then you could test Bits 1 and 0 of A in turn (reacting accordingly) via BIT instructions, thus removing the need to reload #85D0 into the Accumulator for a second time.  That should provide a modest saving of three bytes.

Edited by IRF
Link to comment
Share on other sites

  • 9 months later...

The full list of alternate (shorter) opcodes using either RRCA for RRC A and RLCA for RLC A in JSW.

The two sets of opcodes are not exactly the same in operation regarding flags. But in their context within JSW swapping to the shorter version has no impact on the code.

Besides the value at #8f14, all the other uses are in the conveyor routine.


RLC A at #9514 and #9516
RRC A at #9527 and #9529

Link to comment
Share on other sites

On 5/21/2021 at 10:32 AM, geoff said:

Inspired by this thread, I made some space optimisations in the Pyramid, only nobody seems to have noticed yet. I won't say what they are, but I will say that you don't necessarily need a disassembler to find them...

Not had chance (read: no 'free time') to look myself yet Geoff. 🙂

On 5/20/2021 at 7:56 AM, IRF said:

#8F14 is a two-byte RLC A command; I can't see any reason why it couldn't be a one-byte RLCA?

I wonder, why this happens ? Genuine question.

Is it just coding habits and the way some may write instructions "one way" and others "another way" ?

 

For instance I tend to change colours in Basic with pokes now rather than ensure all the attributes are set as its a bit quicker (and uses a bit less space) although its not as easy to read by a long margin.

 

Link to comment
Share on other sites

  • 11 months later...

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.