Jump to content


Free space and code optimisation in "JSW"

262 replies to this topic

#261 Norman Sword

Norman Sword

    Advanced Member

  • Member
  • PipPipPip
  • 359 posts

Posted 13 June 2019 - 12:17 AM

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


LD (HL), C


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, 13 June 2019 - 09:42 AM.

#262 IRF


    Advanced Member

  • Contributor
  • 4,485 posts

Posted 13 June 2019 - 06:38 AM

Thanks Norman. I notice that that method overwrites the intermediate byte twice, with the same value (not that it matters).

Edited by IRF, 13 June 2019 - 08:50 AM.

#263 IRF


    Advanced Member

  • Contributor
  • 4,485 posts

Posted 01 August 2020 - 10:07 AM

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 - with a 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, 07 August 2020 - 11:28 PM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users