I have a question:
I have this code for moving an 'I' around on the homescreen, but it doesnt work well. what is wrong with it?
Code:
...(insert header here)
Xpos .equ AppBackUpScreen
Ypos .equ Xpos+1
ld A,0
ld (Xpos),A
ld (Ypos),A
Loop:
B_CALL _GetCSC
cp 1
Call Z,Yinc
cp 2
Call Z,Xdec
cp 3
Call Z,Xinc
cp 4
Call Z,Ydec
cp 15
jp Z,Quit
ld A,(Xpos)
ld (CurCol),A
ld A,(Ypos)
ld (CurRow),A
ld HL,Itx
B_CALL _PutS
jp Loop
Xdec:
ld A,(Xpos)
cp 0
Call NZ,Adec
ld (Xpos),A
ret
Xinc:
ld A,(Xpos)
cp 15
Call NZ,Ainc
ld (Xpos),A
ret
Ydec:
ld A,(Ypos)
cp 0
Call NZ,Adec
ld (Ypos),A
ret
Yinc:
ld A,(Ypos)
cp 7
Call NZ,Ainc
ld (Ypos),A
ret
Adec:
Dec A
ret
Ainc:
Inc A
ret
Itx: ;"I text"
.db "I",0
Quit:
ret
I think that I am learning good atm, if you see those bigger codes that I write. But I think that you can optimize a bit too, can someone post optimized code with comments (please, the comments are very important for me)