void XChar_XOR(short x,short y,struct CHAR c,unsigned char *Plane)
{
register short i=0;
register unsigned char a,b;
y += c.Yoffset; //decalage horyzontal par rapport au 'top' de la chaine
x--;
y--;
b=(x&7);
Plane += (y<<5)-(y<<1)+(x>>3); //adresse de la premiere ligne du sprite
while(i<c.hau)
{
a=*(c.map+i);
*Plane ^= a>>b; //avant la séparation du sprite entre 2 Bytes
*(Plane+1) ^= a<<(8-b); //après la séparation
Plane +=30; //une ligne au dessous
i++;
}
}
qui donne en asm:
.globl XChar_XOR XChar_XOR: link.w %a6,#0 movm.l #0x1c00,-(%sp) sub.l %a1,%a1 move.b 12(%a6),%d0 ext.w %d0 add.w 10(%a6),%d0 move.w 8(%a6),%d2 subq.w #1,%d2 subq.w #1,%d0 move.b %d2,%d5 and.b #7,%d5 move.w %d0,%d1 lsl.w #1,%d1 lsl.w #5,%d0 sub.w %d1,%d0 asr.w #3,%d2 add.w %d2,%d0 move.w %d0,%a0 move.l 28(%a6),%d1 add.l %a0,%d1 move.b 14(%a6),%d0 ext.w %d0 cmp.w %a1,%d0 jble .L27 clr.w %d3 clr.w %d2 move.w %d0,%d4 move.l %d1,%a0 .even .L28: move.b 15(%a6,%a1.w),%d3 move.b %d5,%d2 move.w %d3,%d0 asr.w %d2,%d0 eor.b %d0,(%a0) moveq.l #8,%d1 sub.w %d2,%d1 move.w %d3,%d0 lsl.w %d1,%d0 eor.b %d0,1(%a0) lea (30,%a0),%a0 addq.w #1,%a1 cmp.w %a1,%d4 jbgt .L28 .L27: movm.l (%sp)+,#0x38 unlk %a6 rts .even
sachant que:
struct CHAR //forme d'un caractère
{
char Yoffset; //decalage par rapport au 'top'
char lar; //largeur
char hau; //hauteur
unsigned char map[12];//sprite
};
))
