Voici une nouvelle version de ma routine de dessin de rectangle, qui n'est pas finie.
Quelqu'un peut la regarder pour voir si je ne fais pas fausse route, si j'utilise le bon algorithme, car il y a peut-être quelque chose de beaucoup plus simple, plus rapide et qui prend moins de place ?
(Déjà, je ne devrais pas tester à chaque fois si je fais un or, un and ou un eor/not).
ATTENTION: je sais qu'il y a des bugs potentiels, surtout avec les tst, les cmp et les sub.
De plus, je n'ai rien fait pour garder l'adresse du sommet des colonnes (je veux le faire dans a3) donc la routine plante forcément au premier rectangle.
Ah, j'avais oublié d'enlever les %. C'est chose faite.
// C Source File
// Created 05/09/2001; 13:42:36
void FastFilledRect(short x1,short y1,short x2,short y2,short mode,void *plane);
asm("xdef FastFilledRect
FastFilledRect:
movem.l d0-d7/a0/a2-a3,-(%sp)
moveq #0,d6
move.w 48(%sp),d0 | x1
move.w 50(%sp),d1 | y1
move.w 52(%sp),d2 | x2
move.w 54(%sp),d3 | y2
moveq #-16,d4 | bounds checking
cmp.w d0,d4
bge end
cmp.w d2,d4
bge end
moveq #-128,d4
cmp.w d1,d4
bge end
cmp.w d3,d4
bge end
| let's verify parameter mode
cmpi.w #3,56(%sp)
bge end
move.w d2,d4
sub.w d0,d4 | dx
sub.w d1,d3 | dy
tst.w d3
bgt.s continueFR
move.w d3,d5 | dy<0
add.w d1,d5
move.w d5,d1
neg.w d3
continueFR:
tst.w d4
bge.s calc_start_addrFR
neg.w d4
exg d0,d2
calc_start_addrFR:
move.w d0,d5
move.w d1,d6
lsl.w #5,d6
sub.w d1,d6
sub.w d1,d6
lsr.w #3,d5
add.w d5,d6
move.l 58(%sp),a0
adda.l d6,a0
| a0=address of the rectangle in memory.
move.w d2,d1
lsr.w #3,d1
sub.w d5,d1
move.w d1,d7
lea byte_1st_vals,a3
move.w d0,d6
lsl.w #3,d5
sub.w d5,d6
cmpi.w #1,d7
blt.s dx_1bFR | if 0 then it's only one byte.
bgt dx_3pbFR | if 2 or more then it's 3 bytes or more.
| 2 bytes
move.b 0(a3,d6),d5
move.b d2,d6
move.b d6,d7
lsr.b #3,d6
lsl.b #3,d6
sub.b d6,d7
lea byte_last_vals,a3
move.b 0(a3,d7),d7
|move.w 56(%sp),d4
lea 28.w,a2
move.w d0,d1
lsr.w #4,d1
lsl.w #4,d1
sub.w d0,d1
cmpi.w #7,d1
bgt _2_bytes_FR
lsl.w #8,d5
move.b d7,d5
bsr drawWFR
bra end
_2_bytesFR:
cmpi.w #1,56(%sp)
blt.s _clr2FR
bgt.s eor2FR
or2FR:
or.b d5,(a0)+
or.b d7,(a0)+
adda.l a2,a0
dbf d3,or2FR
bra end
_clr2FR:
not.b d5
not.b d7
clr2FR:
and.b d5,(a0)+
and.b d7,(a0)+
adda.l a2,a0
dbf d3,clr2FR
bra end
eor2FR:
eor.b d5,(a0)+
eor.b d7,(a0)+
adda.l a2,a0
dbf d3,eor2FR
bra end
dx_1bFR:
move.w d4,d5
neg.w d5
addq.w #7,d5
move.b 0(a3,d5),d6
move.w d0,d1
lsr.w #3,d1
lsl.w #3,d1
sub.w d1,d0
sub.w d0,d5
lsl.w d5,d6
move.w d6,d5
lea 29.w,a2
|move.w 56(%sp),d4
bsr.s drawBFR
bra end
dx_3pbFR:
move.b 0(a3,d6),d6
move.w d2,d5
move.w d5,d7
lsr.w #3,d5
lsl.w #3,d5
sub.w d5,d7
lea byte_last_vals,a3
move.b 0(a3,d7),d7
/*move.w d0,d4
move.w d2,d1
lsr.w #3,d1
lsr.w #3,d4
sub.w d4,d1
move.w d1,d0
subq.w #2,d0
neg.w d1
add.w #29,d1
move.w d1,a2*/
bsr draw3pFR
bra end
drawBFR:
cmpi.w #1,56(%sp)
blt.s _clrBFR
bgt.s eorBFR
orBFR:
or.b d5,(a0)+
adda.l a2,a0
dbf d3,orBFR
rts
_clrBFR:
not.b d5
clrBFR:
and.b d5,(a0)+
adda.l a2,a0
dbf d3,clrBFR
rts
eorBFR:
eor.b d5,(a0)+
adda.l a2,a0
dbf d3,eorBFR
rts
drawWFR:
cmpi.w #1,56(%sp)
blt.s _clrWFR
bgt.s eorWFR
orWFR:
or.w d5,(a0)+
adda.l a2,a0
dbf d3,orWFR
rts
_clrWFR:
not.w d5
clrWFR:
and.w d5,(a0)+
adda.l a2,a0
dbf d3,clrWFR
rts
eorWFR:
eor.w d5,(a0)+
adda.l a2,a0
dbf d3,eorWFR
rts
drawLFR:
cmpi.w #1,56(%sp)
blt.s _clrLFR
bgt.s eorLFR
orLFR:
or.l d5,(a0)+
adda.l a2,a0
dbf d3,orLFR
rts
_clrLFR:
not.l d5
clrLFR:
and.w d5,(a0)+
adda.l a2,a0
dbf d3,clrLFR
rts
eorLFR:
eor.w d5,(a0)+
adda.l a2,a0
dbf d3,eorLFR
rts
/*finishWFR:
addq.l #2,%sp
bra.s end*/
is_word_aligned:
move.w d0,d1
lsr.w #4,d1
lsl.w #4,d1
sub.w d0,d1
subq.w #7,d1
rts
draw3pFR:
cmpi.w #1,56(%sp)
|blt.s clr3pFR
|bgt.s eor3pFR
or3pFR:
moveq #-1,d5
_orFR:
or.b d6,(a0)+
bsr.s is_word_aligned
tst.w d1
ble.s orWL_FR
bgt drawBFR
orWL_FR:
/*move.w d2,d1
sub.w d0,d2*/
cmpi.w #32,d4
bgt.s orL_FR
cmpi.w #16,d4
bgt.s orW_FR
cmpi.w #8,d4
bgt.s orB_FR
move.w d7,d5
bsr drawBFR
bra.s end
orL_FR:
bsr.s drawLFR
bra.s _orFR
orW_FR:
bsr drawWFR
bra.s _orFR
orB_FR:
bsr drawBFR
bra.s _orFR
/*loop2FR:
move.b d5,(a0)+
dbf d0,loop2FR
or.b d7,(a0)+
adda.l a2,a0
dbf d3,_orFR
bra finish
clr3pFR:
not.b d6
not.b d7
_clr3pFR:
and.b d6,(a0)+
loopFR:
clr.b (a0)+
dbf d0,loopFR
and.b d7,(a0)+
adda.l a2,a0
dbf d3,_clr3pFR
bra.s finish
eor3pFR:
eor.b d6,(a0)+
loop3FR:
not.b (a0)+
dbf d0,loop3FR
eor.b d7,(a0)+
adda.l a2,a0
dbf d3,eor3pFR
*/
end:
movem.l (%sp)+,d0-d7/a0/a2-a3
rts
.even
")
Merci d'avance.
[edit]Edité par XDanger le 18-11-2001 à 19:43:53[/edit]
[edit]Edité par XDanger le 19-11-2001 à 07:35:27[/edit]
