Código: Seleccionar todo
_CALC5:
ld bc, (_gfx_xy)
; Calculation of the upper part of the address:
LD A,B
AND 7 ; A = 00000SSSb
LD H,A ; We store it in H
LD A,B ; We retrieve again Y
RRA
RRA
RRA ; We rotate to obtain the third
AND $18 ; with an AND 00011000b -> 000TT000b
OR H ; H = H OR A = 00000SSSb OR 000TT000b
OR $40 ; We mix H with 01000000b (vram)
LD H,A ; We establish the final "H"
; Calculation of the lower part of the address:
LD A,C ; A = X coordinate
RRA
RRA
RRA ; We rotate to obtain CCCCCb
AND $1F ; A = A AND 31 = 000CCCCCb
LD L,A ; L = 000CCCCCb
LD A,B ; We retrieve again Y
RLA ; We rotate to get NNN
RLA
AND $E0 ; A = A AND 11100000b
OR L ; L = NNNCCCCC
finished:
LD L,A ; We establish the final "L"