Jump to content


Photo

Free space and code optimisation in "JSW"


  • Please log in to reply
261 replies to this topic

#261 Norman Sword

Norman Sword

    Advanced Member

  • Member
  • PipPipPip
  • 237 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

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


#262 IRF

IRF

    Advanced Member

  • Contributor
  • 4,276 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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users