Here's the challenge:
2a12 67 ld h,a ; h = a 2a13 5f ld e,a ; e = a 2a14 2e00 ld l,#00 ; l = 00 2a16 55 ld d,l ;d = 00 2a17 0e08 ld c,#08 ; c = 08 ; loop start 2a19 29 add hl,hl ; hl += hl 2a1a d21e2a jp nc,#2a1e ; jump on overflow???? 2a1d 19 add hl,de ; hl += de 2a1e 0d dec c ; c-- 2a1f c2192a jp nz,#2a19 ; jump to loop start if c is not 1 2a22 c9 ret
This code is taking the distance between two characters on screen and turning them into a destination coordinate. The return value of this function is whatever is in HL -- and will be interpreted as XXYY coordinates. Weird huh?
I can't imagine why they are perfoming an add hl, hl eight times in a row!
So, who here is smart enough with the Z80 to tell me what the mathematical significance of this peice of code is?