Jump to content

Blitter, Mon Ami, Dis Moi Comment Tracer Une Ligne


Azrael

Recommended Posts

Comme je ne suis pas aussi balaise que Seb, et que j'ai autre chose à faire également :P je vous propose simplement une routine 68000 d'appel de tracé de ligne au blitter. Pour les explication je vous renvois à votre cours de 4ième. Pour les explication concernant l'appel au blitter, demandez à GT, moi je n'ai rempli que les registres :P

 

Merci à Seb pour le débuggage de la division.

 

N'hésitez pas quand même à poser une question !!!

 

[ENGLISH]

As I am not as clever as Seb (known as rotation man on the dancefloors), I am just able to give you a way to order the blitter to draw a line. Remember your secondary school math lessons and ask GT for any related blitter code, I just filled the blitter register... I don't even know how to change color... shame

 

Thanks to Seb for the div debugging.

 

Anyway, feel free to ask any question :whistling:

 

; COORDONNEES DU SEGMENT;
; SEGMENT COORDINATES;
X1:        dc.w    50
Y1:        dc.w    100
X2:        dc.w    150
Y2:        dc.w    150

DeltaX:        dc.w    0
DeltaY:        dc.w    0
AbsDeltaX:    dc.w    0
AbsDeltaY:    dc.w    0
SigneDeltaX:    dc.w    0
SigneDeltaY:    dc.w    0
Prec_w:        dc.w    $FFFF
Prec_l:        dc.l    $FFFF
Prec_l_swapped:    dc.l    $FFFF0000
    
Line:    movem.l    d0-d7/a0-a6,-(a7)

    move.l    #0,A1_FSTEP
    move.l    #0,A1_STEP
    move.l    #0,A1_FPIXEL

    move.w    Y1,d0
    swap    d0
    move.w    X1,d0
    move.l    d0,A1_PIXEL

    moveq    #0,d0
    move.w    X2,d0
    sub.w    X1,d0
    move.w    #1,SigneDeltaX
    move.w    d0,DeltaX
    bpl.s    Positif_deltax
    neg.w    d0
    move.w    #-1,SigneDeltaX
Positif_deltax:
    move.w    d0,AbsDeltaX

    moveq    #0,d0
    move.w    Y2,d0
    sub.w    Y1,d0
    move.w    #1,SigneDeltaY
    move.w    d0,DeltaY
    bpl.s    Positif_deltay
    neg.w    d0
    move.w    #-1,SigneDeltaY
Positif_deltay:
    move.w    d0,AbsDeltaY
        
    tst.w    DeltaX
    bne.s    DeltaX_Pas_egal_a_zero_01
    tst.w    DeltaY
    bne.s    DeltaY_Pas_egal_a_zero_01    

    moveq    #1,d0
    swap    d0
    move.w    #1,d0
    move.l    d0,B_COUNT
    move.l    #0,A1_FINC
    jmp        Go_blit

DeltaY_Pas_egal_a_zero_01:

    moveq    #1,d0
    swap    d0
    move.w    AbsDeltaY,d0
    add.w    #1,d0
    move.l    d0,B_COUNT

    move.l    #0,A1_FINC

    moveq    #0,d0
    move.w    SigneDeltaY,d0
    swap    d0
    move.l    d0,A1_INC

    jmp        Go_blit

DeltaX_Pas_egal_a_zero_01:

    tst.w    DeltaY
    bne.s    DeltaY_Pas_egal_a_zero_02    

    moveq    #1,d0
    swap    d0
    move.w    AbsDeltaX,d0
    add.w    #1,d0
    move.l    d0,B_COUNT

    move.l    #0,A1_FINC

    moveq    #0,d0
    move.w    SigneDeltaX,d0
    move.l    d0,A1_INC

    jmp        Go_blit

DeltaY_Pas_egal_a_zero_02:

    move.w    AbsDeltaY,d0
    sub.w    AbsDeltaX,d0
    bne        AbsDeltaY_different_de_AbsDeltaX

    moveq    #1,d0
    swap    d0
    move.w    AbsDeltaX,d0
    add.w    #1,d0
    move.l    d0,B_COUNT

    move.l    #0,A1_FINC

    move.w    SigneDeltaY,d0
    swap    d0
    move.w    SigneDeltaX,d0
    move.l    d0,A1_INC
    
    jmp        Go_blit

AbsDeltaY_different_de_AbsDeltaX:
    tst.w    d0
    bpl        AbsDeltaY_inferieur_a_absdeltax

    moveq    #1,d0
    swap    d0
    move.w    AbsDeltaX,d0
    add.w    #1,d0
    move.l    d0,B_COUNT
    
    move.w    AbsDeltaY,d1
    swap    d1
    move.w    Prec_l,d1
    divu    AbsDeltaX,d1
    and.l    #$FFFF,d1

    tst.w    DeltaY
    bpl.s    DeltaY_positif_03
    neg.l    d1
    move.l    Prec_l_swapped,A1_FPIXEL
DeltaY_positif_03:

    moveq    #0,d0
    move.w    d1,d0
    swap    d0
    move.l    d0,A1_FINC

    move.w    SigneDeltaX,d1
    move.l    d1,A1_INC

    jmp        Go_blit
                
AbsDeltaY_inferieur_a_absdeltax:

    moveq    #1,d0
    swap    d0
    move.w    AbsDeltaY,d0
    add.w    #1,d0
    move.l    d0,B_COUNT

    move.w    AbsDeltaX,d1
    swap.w    d1
    move.w    Prec_l,d1
    divu    AbsDeltaY,d1
    and.l    #$FFFF,d1

    tst.w    DeltaX
    bpl.s    DeltaX_positif_04
    neg.l    d1
    move.l    Prec_l,A1_FPIXEL
DeltaX_positif_04:

    moveq    #0,d0
    move.w    d1,d0
    move.l    d0,A1_FINC

    move.w    SigneDeltaY,d1
    swap    d1
    move.l    d1,A1_INC

Go_blit:
    lea        B_SRCD,a0

    move.l    #-1,(a0)+
    move.l    #-1,(a0)+

    move.l    Adr_5,A1_BASE
    move.l    #PITCH1|PIXEL16|WID320|XADDINC,A1_FLAGS
    move.l    #UPDA1|UPDA1F|LFU_REPLACE,B_CMD    

    lea        B_CMD,a0
Wait_blitter_end_1:
    move.l    (a0),d0
    btst    #0,d0
    beq.s    Wait_blitter_end_1

Exit_line:    
    movem.l    (a7)+,d0-d7/a0-a6
    rts

 

EDIT : I have corrected the code... little fix : added 1 to AdsDeltaX and AdsDeltaY

EDIT 2 : hem... hope it works better than previously.

Link to comment
Share on other sites

; ICI ON N'AFFICHE QU'UN POINT;
; DEBROUILLEZ VOUS POUR LE FAIRE;
; HERE YOU ONLY NEED TO DISPLAY ONE POINT;
; DO IT YOURSELF;

[Français]

Au premier coup d'oeil ça m'a fait peur ! C'est en lisant le code que j'ai compris ce que tu voulais dire :D

 

[English]

This worried me at first sight ! I understood what you meant later by reading the code :D

Link to comment
Share on other sites

[Français]

:lol: Si une bonne âme pouvait me donner une routine d'affichage de point, je pense que ce serait plus rapide que de demander au Blitter de le faire, non ? Comme ça les gens n'auraient pas peur de cette routine :P

 

[English]

:lol: If a generous mind can tell me how to display a point, it would certainly be faster than asking the blitter to do so. And then people won't be affraid of that line routine.

Link to comment
Share on other sites

beau travail Azrael en tout cas

 

[english]

 

congratulations :D

Link to comment
Share on other sites

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...