Jump to content

Norman Sword

Member Since 08 Mar 2017
Offline Last Active Jul 18 2019 01:33 PM

Posts I've Made

In Topic: source code for JSW

18 July 2019 - 12:55 PM

I've just noticed that the two commands in the raster copy routine which you previously struck through:


  ld b,0                         ; this was set for usage in a different routine

  ld c,32                             ; this was set for usage in a different routine


are no longer struck out in posts 59 and 60.  Although the accompanying comment after the semicolon remains in place, suggesting that those commands are still not necessary (and from my interpretation of the code, they aren't needed).


Perhaps the strikethrough font 'fell off' in the process of copying and pasting?




The strike through fell off and is lying somewhere in cyberspace.

The op codes in the listings which are unwanted have been rem'ed out and also struck through again.  (just in case I paste and copy again) with that statement I am reminded that the original still has only the strike through. So I will edit that as well.

Code with the unwanted parts will still work. But since it is not needed best rem'out in addition to the strike through.  (or just deleted completely)

In Topic: source code for JSW

18 July 2019 - 12:27 PM




Every version of the raster copy routine listed under "source code for JSW"  does not use the "a" register. I subsequently added before and after the actual routine a part which modified the Block_Copy routine (which ever variant of the block copy routine as listed in each post). The raster copy routine still does not use the a register, but the modifying code before and after did use the "a" register. 


 I have done the trivial change to each modifying addition to remove the usage of the "a" register throughout the whole raster copy.  

In Topic: source code for JSW

18 July 2019 - 09:42 AM

All the raster copy posts under the heading "source code for JSW" work as stated. None use the piece of code listed back in APRIL 2017 and quoted in post #62.

Because you are reverting between differing pieces of code used over many years, I have expanded each reference to raster copy listed under "source code for JSW" to be self contained. Each and every version works and none use the "A" register.    

In Topic: source code for JSW

17 July 2019 - 09:02 PM

I have edited three posts to remove the conflict of BLOCK_MOVE32: being used with differing routines.

The routine that uses a long line of ldi's and returns without decrementing the "A" register has had its labels changed


That block move now uses the labels BLOCKX_MOVE32 and BLOCKX_MOVE31. the inclusion of the X mid label hopefully removing confusion between two very similar routines, which are mentioned sporadically over a few posts.  

In Topic: source code for JSW

17 July 2019 - 07:10 PM

since the source code for me is just a blank canvas to edit. I am not restricted to worrying about will a piece of code fit in here or there. If I delete a byte in the source code, I immediately have that byte and it can be used anywhere I want in the limits of the memory I am editing. The restrictions are removed.

Block move


ld hl,source

ld de,destination

ld bc,size



looking at this yet again, but from the no restrictions point of view. The best solution is slightly different


Shift_block32:                              ; new label to distinguish from all the other code






     jp    pe,Shift_block32



we write the code out exactly as specified in JSW but we now use one more byte on each instance and rather than LDIR we use an extra byte and call Shift_block32 or Shift_block31 ; Depending on the value being divisible by 32 or one short

This also does not use the "a" register- similar to  LDIR on its own. This method also is as close to a replacement LDIR as we can generate in code,  returning with the same parameters as would be set with LDIR.




LD HL,CHAR0  ;L869F ;$4000 
LD DE,CHAR0+1  ; 86A2 ;$4001
LD BC,$1AFF  ; 86A5 ;    
LD (HL),$00  ; 86A8 ;
LDIR   ; 86AA ;                                      call shift_block31



This is faster again (marginally) but uses the same registers as the original 


I suppose you could modify this routine  to use a similar raster copy routine as the one posted above. e.g.


;copy work and attribute screens


   ld hl, S_M_C_New_Mod          ;place to modify 

   ld (hl),$c9                              ; modify in a "ret"


    ld hl,att_work
    ld de,ATT0
    ;;;;ld b,0                         ; this was set for usage in a different routine
    ld hl,ytable
    ld bc,128   ; must be a multiple of 32  ; this is 4*32 ;- that is 4 raster lines before the attributes are written in
;loop executed 128 times on each game loop
  ld e,(hl)
  inc l
  push hl
  ld h,(hl)
  ld l,e
  ld d,h
  res 5,d
  call Shift_block32        ;executed 128 times on each game loop
  jp pe,n_raster
  exx                                  ; this code is executed 16 times on each game loop
  ;;;;ld c,32                             ; this was set for usage in a different routine
  call Shift_block32       
  inc b
  pop hl
  inc l
  jr nz,raster


 ld hl,S_M_C_New_Mod     ;place to midify

 Ld (hl),$ea                       ;opcode for Jp PE,xx


rest of code

Shift_block32:                              ; new label to distinguish from all the other code

S_M_C_New_Mod Equ $
     jp    pe,Shift_block32               ;opcode toggled between ( "ret" ) and ( "jp pe,xx" )