I changed the code, but I can't understand why it is moving to the right only once ?
Code: Select all
; free codeable memory
;----------------------------------------------
gamecode
ld hl,line1 ; first display
ld (hl),"H"-27
ld hl,line2
ld (hl),"H"-27
ld hl,line3
ld (hl),"A"-27
ld hl,line4
ld (hl),"A"-27
;bkpt jr bkpt
wkey ld bc,(lastk) ; get key information
ld a,c ; copy C in A to keep C
inc a ; Test if NOKEY pressed
jr z,wkey ; NO KEY, wait for key
call erase
call right
okmove jr wkey ; stay in playloop
;---------ROUTINES-----------------------------
erase
ld hl,line1
ld (hl),0 ; erase old position
ld hl,line2
ld (hl),0
ld hl,line3
ld (hl),0
ld hl,line4
ld (hl),0
ret
right
ld hl,line1
inc hl ; move right
ld (hl),"H"-27
ld hl,line2
inc hl
ld (hl),"H"-27
ld hl,line3
inc hl
ld (hl),"A"-27
ld hl,line4
inc hl
ld (hl),"A"-27
ret
;----------------------------------------------
; the display file, Code the lines needed.
dfile
db 118,118
line1
block 32,0
ld h,d
ld l,e
db 118
line2
block 32,0
ld h,d
ld l,e
db 118
line3
block 32,0
ld h,d
ld l,e
db 118
line4
block 32,0
ld h,d
ld l,e
db 118
db #e9 ; fill unused part of the screen
vars db 128
last equ $
end