X mask for CALC5 and 6

Todo sobre la creación, diseño y programación de nuevo software para
nuestro Spectrum

Moderador: Sir Cilve Sinclair

Responder
andydansby
rst 0
Mensajes: 16
Registrado: Mié Jun 28, 2017 1:11 pm

X mask for CALC5 and 6

Mensaje por andydansby » Dom Mar 06, 2022 5:45 pm

I just came across the CALC5 and CALC6 routines to calculate the screen address. I have placed in in some code and was able to successfully grab the screen address. I however, don't know how to calculate the bit mask. Can someone guide me or place up some code to allow for the bit mask for X. I greatly appreciate it.

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"
Andy
Última edición por andydansby el Mar Mar 08, 2022 10:38 am, editado 1 vez en total.

andydansby
rst 0
Mensajes: 16
Registrado: Mié Jun 28, 2017 1:11 pm

Re: X mask for CALC5 and 6

Mensaje por andydansby » Mar Mar 08, 2022 10:37 am

I did find the answer by finding the document https://wiki.speccy.org/cursos/ensambla ... de-pixeles

The relative code is

Código: Seleccionar todo

    ld a,c   ; load X position
    and $07
    ld b,a
    ;Relative_to_Mask:
    LD B, A ; We load A (pixel position) into B
    INC B   ; We increment B (for loop passes)
    XOR A   ; A = 0
    SCF ; Set Carry Flag (A=0, CF=1)
CALC5_rotate:
    RRA     ; We rotate A to the right B times
    DJNZ CALC5_rotate
    or (hl) ; OR with screen contents
    ld (hl),a   ; write to screen

Responder

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 7 invitados