home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* AmigaEyes */
- /* */
- /* Author: Stéphane Poirier */
- /* Copyright © 1994 Stéphane Poirier. All right reserved */
- /* */
- /*****************************************************************************/
-
- #include <intuition/intuition.h>
- #include <intuition/classes.h>
- #include <intuition/classusr.h>
- #include <intuition/imageclass.h>
- #include <intuition/gadgetclass.h>
- #include <graphics/displayinfo.h>
- #include <graphics/clip.h>
- #include <graphics/view.h>
- #include <graphics/layers.h>
- #include <graphics/copper.h>
- #include <graphics/regions.h>
- #include <graphics/rastport.h>
- #include <graphics/gfxbase.h>
- #include <graphics/gfxmacros.h>
- #include <graphics/gels.h>
- #include <graphics/gfxbase.h>
- #include <clib/graphics_protos.h>
- #include <clib/exec_protos.h>
- #include <exec/memory.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
-
- #include <math.h>
- #include <mffp.h>
-
- #include "eyes.h"
-
- /*
- ** Dessin des yeux
- */
-
- #ifdef ENTRELACE
- int eyeX[37] = {-1,0,1,-2,-1,0,1,2,-3,-2,-1,0,1,2,3,-3,-2,-1,0,1,2,3,-3,-2,-1,0,1,2,3,-2,-1,0,1,2,-1,0,1};
- int eyeY[37] = {-3,-3,-3,-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,3,3,3};
- #else
- int eyeX[29] = {-1,0,1,-3,-2,-1,0,1,2,3,-4,-3,-2,-1,0,1,2,3,4,-3,-2,-1,0,1,2,3,-1,0,1};
- int eyeY[29] = {-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2};
- #endif
-
- float dcos[]= { 0.999999, 0.998027, 0.992115, 0.982287, 0.968583, 0.951057, 0.929777,
- 0.904827, 0.876307, 0.844328, 0.809017, 0.770513, 0.728969, 0.684547,
- 0.637424, 0.587785, 0.535827, 0.481754, 0.425779, 0.368125, 0.309017,
- 0.248690, 0.187381, 0.125333, 0.062790, 0.000000 };
-
- UBYTE *pixel; /* Pointeur sur le tableau de flags de la fenetre */
-
-
- struct Trace
- {
- ULONG Adr[WNDY][8]; /* Adresse des lignes d'écran */
- short Depth; /* Profondeur de l'écran */
- } Trace;
-
- struct BitMap *SBitmap; /* La structure SuperBitMap pour la fenetre */
-
- void WriteEye(struct Window *, int , int , int , int, int, int, BOOL);
- void ClearEye(struct Window *, int , int , int , int, int, int);
- BOOL TestWritePixel(int , int , int , int);
- BOOL TestClearPixel(int , int , int , int);
- BOOL FermePupilleGauche(struct Window *, int, int *);
- BOOL OuvrePupilleGauche(struct Window *, int, int *);
- BOOL FermePupilleDroite(struct Window *, int, int *);
- BOOL OuvrePupilleDroite(struct Window *, int, int *);
- void Plot(struct Window *, register SHORT, register SHORT, register int);
-
- extern struct parametres Parametres;
- extern unsigned int clockInit[];
- extern USHORT refresh;
-
- /*****************************************************************************/
-
- int EyeCloseWindow(BOOL running )
- {
- FreeMem(pixel, SIZEWNDX*SIZEWNDY); /* Libere la memoire allouée */
- return( FALSE);
- }
-
- /*****************************************************************************/
-
- void InitPlot(struct Window *EyeWnd, struct BitMap *SBitmap)
- {
- PLANEPTR plan; /* Pointeur sur un plan de bits */
- ULONG addoffset, i;
- int y;
- UWORD ligne;
-
- Trace.Depth = SBitmap->Depth; /* Profondeur de l'écran */
- ligne = WNDX >> 4; /* Calcul de l'adresse du début de chaque ligne */
- if (ligne & 1)
- ligne ++;
- ligne = ligne << 4;
-
- for(y = 0; y < WNDY; y++)
- {
- addoffset = (ligne * y) >> 3;
- for (i = 0; i < Trace.Depth; i++)
- {
- plan = SBitmap->Planes[i]; /* Adresses des plans ds la SuperBitmap */
- Trace.Adr[y][i] = (ULONG)plan + addoffset;
- }
- }
- }
-
- /*****************************************************************************/
-
- void InitEyes(struct Window *EyeWnd, struct BitMap *SBitmap)
- {
- unsigned int clock[2]; /* Horloge */
- int x;
-
- SetRast(EyeWnd->RPort,Parametres.fenetre); /* Vide la SuperBitMap */
- SetAPen(EyeWnd->RPort,Parametres.bord); /* Couleur du crayon */
-
- #ifdef ENTRELACE
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,15,15);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,14,14);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,15,15);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,14,14);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,14,15);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,14,15);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,15,14);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,15,14);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,16,14);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,16,14);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,16,15);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,16,15);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,13,15);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,13,15);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,13,13);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,13,13);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,13,14);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,13,14);
- #else
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,17,8); /* Dessine le contour des yeux */
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,17,8);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,15,7);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,15,7);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,16,7);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,16,7);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,14,8);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,14,8);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,15,8);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,15,8);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,16,8);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,16,8);
- DrawEllipse(EyeWnd->RPort,lEYE,yEYE,18,8);
- DrawEllipse(EyeWnd->RPort,rEYE,yEYE,18,8);
- #endif
-
- x = timer(clock); /* Prépare la génération de nombres aléatoires */
- srand(clock[1]);
-
- /* Allocation d'un tableau de flags représentant l'état de la SuperBitMap */
-
- if((pixel = (UBYTE *)AllocMem(SIZEWNDX*SIZEWNDY,MEMF_PUBLIC|MEMF_CLEAR)) == NULL)
- printf("erreur d'allocation mémoire\n");
-
- LockLayerRom(EyeWnd->WLayer); /* Recopie les opérations graphiques */
- SyncSBitMap(EyeWnd->WLayer); /* Dans ma SuperBitMap */
- UnlockLayerRom(EyeWnd->WLayer);
-
- }
-
- /*****************************************************************************/
- /* Routine de gestion des yeux */
- /*****************************************************************************/
-
- BOOL DrawingEyes(struct Window *EyeWnd, struct BitMap *SBitmap, int offy)
- {
- BOOL reveil = FALSE; /* Valeur de retour: y-a-t-il eu arret de la souris */
- /* puis mvt ? */
-
- static int xr, yr, xl, yl, mx, my;
- static int compteur_clin_d_oeil_gauche = 0; /* Compteurs pour clins d'oeil */
- static int compteur_clin_d_oeil_droit = 0;
- static unsigned int wait_cligne_gauche = 02; /* Delais pour clins d'oeil */
- static unsigned int wait_cligne_droit = 02;
- float dr, dl, dxl, dxr, dy, x,y;
- int tx, TempsEcoule;
- unsigned int clockVal[2];
- unsigned int xx, yy,i;
- static BOOL debut = TRUE; /* Premier passage dans la routine */
- static BOOL ferme_pupilles = FALSE; /* Pupilles fermantes = VRAI sinon FAUX */
- static BOOL ouvre_pupilles = FALSE; /* Pupilles ouvrante ... */
- static BOOL cligne_gauche = FALSE; /* Clin d'oeil gauche en cours */
- static BOOL decligne_gauche = FALSE; /* "Dé"clin d'oeil gauche en cours */
- static BOOL cligne_droit = FALSE; /* Idem oeil droit */
- static BOOL decligne_droit = FALSE;
- static BOOL pupille_fermee = FALSE; /* Pupilles fermées */
- static int rRayon = +(REYE-2); /* Rayon des ellipse pour tracer paupieres */
- static int lRayon = +(REYE-2);
-
- /* Est-ce qu'on est pas en train d'ouvrir ou fermer une pupille, ou est-ce
- ** les pupilles ne sont pas deja fermees ?
- */
- tx = timer(clockVal);
- TempsEcoule = clockVal[0] - clockInit[0];
-
- if ((!pupille_fermee) && (!ouvre_pupilles) && (!ferme_pupilles))
- {
- if (TempsEcoule > Parametres.timeout) /* Si la souris n'a pas bougé */
- ferme_pupilles = TRUE; /* durant le temps definit alors on ferme les pupilles */
-
- compteur_clin_d_oeil_gauche++; /* Incrémenter le compteur pour clin d'oeil */
-
- /* Est-on prêt à cligner de l'oeil ? et n'est-on pas en train de fermer les
- ** pupilles ?
- */
- if ((compteur_clin_d_oeil_gauche >= wait_cligne_gauche) && (!ferme_pupilles))
- cligne_gauche = TRUE;
-
- if(decligne_gauche) /* releve la paupiere */
- {
- for(i = 0; i<REYE*2; i++)
- {
- decligne_gauche = (!OuvrePupilleGauche(EyeWnd, Parametres.fond, &lRayon));
- WriteEye(EyeWnd, xl, yl, xl, yl, Parametres.pupille,
- Parametres.paupiere, decligne_gauche); /* retrace pupille */
-
- LockLayerRom(EyeWnd->WLayer); /* Copy le contenue de la SuperBitMap */
- CopySBitMap(EyeWnd->WLayer); /* Dans la BitMap du Screen */
- UnlockLayerRom(EyeWnd->WLayer);
-
- if (!decligne_gauche) break;
- }
- decligne_gauche = FALSE;
- wait_cligne_gauche = (((unsigned int)rand() >> 23) + (1 << 8))
- / refresh;
- }
-
- if(cligne_gauche)
- {
- for(i = 0; i<2*REYE; i++)
- {
- cligne_gauche = (!FermePupilleGauche(EyeWnd, Parametres.paupiere, &lRayon));
- LockLayerRom(EyeWnd->WLayer);
- CopySBitMap(EyeWnd->WLayer);
- UnlockLayerRom(EyeWnd->WLayer);
- if (!cligne_gauche) break;
- }
- decligne_gauche = TRUE;
- cligne_gauche = FALSE;
- compteur_clin_d_oeil_gauche = 0;
- }
-
- compteur_clin_d_oeil_droit++;
- if ((compteur_clin_d_oeil_droit >= wait_cligne_droit) && (!ferme_pupilles))
- cligne_droit = TRUE;
-
- if(decligne_droit)
- {
- for(i = 0; i<REYE*2; i++)
- {
- decligne_droit = (!OuvrePupilleDroite(EyeWnd, Parametres.fond, &rRayon));
- WriteEye(EyeWnd, xr, yr, xr, yr, Parametres.pupille,
- Parametres.paupiere, decligne_droit);
- LockLayerRom(EyeWnd->WLayer);
- CopySBitMap(EyeWnd->WLayer);
- UnlockLayerRom(EyeWnd->WLayer);
- if (!decligne_droit) break;
- }
- decligne_droit = FALSE;
- wait_cligne_droit = (((unsigned int)rand() >> 23) + (1 << 8))
- / refresh;
- }
-
- if(cligne_droit)
- {
- for(i = 0; i<2*REYE; i++)
- {
- cligne_droit = (!FermePupilleDroite(EyeWnd, Parametres.paupiere, &rRayon));
- LockLayerRom(EyeWnd->WLayer);
- CopySBitMap(EyeWnd->WLayer);
- UnlockLayerRom(EyeWnd->WLayer);
- if (!cligne_droit) break;
- }
- decligne_droit = TRUE;
- cligne_droit = FALSE;
- compteur_clin_d_oeil_droit = 0;
- }
- }
-
- if (ferme_pupilles)
- {
- ferme_pupilles = (!FermePupilleGauche(EyeWnd, Parametres.paupiere, &lRayon));
- ferme_pupilles = (!FermePupilleDroite(EyeWnd, Parametres.paupiere, &rRayon));
- LockLayerRom(EyeWnd->WLayer);
- CopySBitMap(EyeWnd->WLayer);
- UnlockLayerRom(EyeWnd->WLayer);
- pupille_fermee = !ferme_pupilles;
- }
-
- if (ouvre_pupilles)
- {
- ouvre_pupilles = (!OuvrePupilleGauche(EyeWnd, Parametres.fond, &lRayon));
- ouvre_pupilles = (!OuvrePupilleDroite(EyeWnd, Parametres.fond, &rRayon));
- LockLayerRom(EyeWnd->WLayer);
- CopySBitMap(EyeWnd->WLayer);
- UnlockLayerRom(EyeWnd->WLayer);
- WriteEye(EyeWnd, xl, yl, xl, yl, Parametres.pupille,
- Parametres.paupiere, ouvre_pupilles);
- WriteEye(EyeWnd, xr, yr, xr, yr, Parametres.pupille,
- Parametres.paupiere, ouvre_pupilles);
- }
-
- if ((EyeWnd->MouseX != mx + OFFX) || (EyeWnd->MouseY != my + offy))
- {
- if (TempsEcoule > 1) /* On renvoie "reveil" si 1 sec au moins */
- reveil = TRUE; /* s'est ecoulée depuis le dernier mvt. */
-
- clockInit[1] = clockVal[1];
- clockInit[0] = clockVal[0];
-
- refresh = Parametres.refresh;
-
- if((ferme_pupilles) || (pupille_fermee))
- {
- ouvre_pupilles = TRUE;
- ferme_pupilles = FALSE;
- pupille_fermee = FALSE;
- }
-
- mx = EyeWnd->MouseX - OFFX;
- my = EyeWnd->MouseY - offy;
-
- dxl = (float)mx - (float)lEYE; /* Distance de la pupille au pointeur */
- dxr = (float)mx - (float)rEYE;
- dy = (float)my - (float)yEYE;
- dl = sqrt(SQR(dxl) + SQR(dy));
- dr = sqrt(SQR(dxr) + SQR(dy));
-
- if (dl > RLIM) /* Si distance > rayon de l'oeil */
- {
- x = (float)RLIM/dl * dxl + (float)lEYE;
- #ifdef ENTRELACE
- y = (float)RLIM/dl * dy + (float)yEYE;
- #else
- y = ((float)REYE/dl * dy)/2 + (float)yEYE;
- #endif
- xx = (int)(x+0.5);
- yy = (int)(y+0.5);
- }
- else /* Sinon Pupille sous le pointeur */
- {
- xx = mx;
- yy = my;
- }
- if ((xl != xx) || (yl != yy)) /* Si la pupille est déplacée */
- { /* Alors on la redessine */
- WriteEye(EyeWnd, xx, yy, xl, yl, Parametres.pupille,
- Parametres.paupiere, ouvre_pupilles);
- if (debut == FALSE)
- ClearEye(EyeWnd, xx, yy, xl, yl, Parametres.fond, Parametres.paupiere);
- xl = xx; yl = yy;
- }
-
- if (dr > RLIM) /* Idem pupille droite */
- {
- x = (float)RLIM/dr * dxr + (float)rEYE;
- #ifdef ENTRELACE
- y = (float)RLIM/dr * dy + (float)yEYE;
- #else
- y = ((float)REYE/dr * dy)/2 + (float)yEYE;
- #endif
- xx = (int)(x+0.5);
- yy = (int)(y+0.5);
- }
- else
- {
- xx = mx;
- yy = my;
- }
- if ((xr != xx) || (yr != yy))
- {
- WriteEye(EyeWnd, xx, yy, xr, yr, Parametres.pupille,
- Parametres.paupiere, ouvre_pupilles);
- if (debut == FALSE)
- ClearEye(EyeWnd, xx, yy, xr, yr, Parametres.fond, Parametres.paupiere);
- xr = xx; yr = yy;
- }
- LockLayerRom(EyeWnd->WLayer);
- CopySBitMap(EyeWnd->WLayer);
- UnlockLayerRom(EyeWnd->WLayer);
- }
- else
- {
- if (TempsEcoule >= 1) /* Si la souris n'a pas bougé */
- {
- refresh = SLEEP; /* pendant au moins 1 sec. */
- }
-
- }
- debut = FALSE;
- return (reveil);
- }
-
- /*****************************************************************************/
- /* Dessine une pupille */
- /*****************************************************************************/
-
- void WriteEye(struct Window *EyeWnd, int x, int y,
- int xold, int yold, int c1, int c2, BOOL ouvre_pupille)
- {
- register int i, x1, y1;
- UBYTE *c;
-
- SetAPen(EyeWnd->RPort,c1);
-
- #ifdef ENTRELACE
- for (i=0; i < 37; i++) /* Chaque pupille comporte 37 pixels en version LACE */
- #else
- for (i=0; i < 29; i++) /* Chaque pupille comporte 29 pixels */
- #endif
- {
- x1 = x+eyeX[i];
- y1 = y+eyeY[i];
- c = pixel+SIZEWNDX*x1+y1;
-
- if ((*c != c2) && (*c != c1)) /* Si le point n'est pas deja affiché */
- {
- Plot(EyeWnd, x1, y1, c1);
- *c = c1;
- }
-
- }
- }
-
- /*****************************************************************************/
- /* Efface une pupille */
- /*****************************************************************************/
-
- void ClearEye(struct Window *EyeWnd, int x, int y, int xold, int yold, int c1, int c2)
- {
- register int i, x1, y1;
- UBYTE *c;
-
- SetAPen(EyeWnd->RPort,c1);
-
- #ifdef ENTRELACE
- for (i = 0; i < 37; i++) /* Chaque pupille comporte 37 pixels en version LACE */
- #else
- for (i = 0; i < 29; i++) /* Chaque pupille comporte 29 pixels */
- #endif
- {
- x1 = xold+eyeX[i];
- y1 = yold+eyeY[i];
- c = pixel+SIZEWNDX*x1+y1;
-
- if (!TestClearPixel(x1, y1, x, y))
- if (*c != c2)
- {
- Plot(EyeWnd, x1, y1, c1);
- *c = c1;
- }
-
- }
- }
-
- /*****************************************************************************/
- /* Test pour déterminer si on peut effacer un pixel */
- /*****************************************************************************/
-
- BOOL TestClearPixel(int x, int y, int xnew, int ynew)
- {
- register int i;
- BOOL ret = FALSE;
-
- #ifdef ENTRELACE
- for (i = 0; i < 37; i++) /* Chaque pupille comporte 37 pixels en version LACE */
- #else
- for (i = 0; i < 29; i++) /* Chaque pupille comporte 29 pixels */
- #endif
- {
- if ((x == xnew + eyeX[i]) && (y == ynew + eyeY[i]))
- {
- ret = TRUE;
- break;
- }
- }
- return(ret);
- }
-
- /*****************************************************************************/
-
- BOOL FermePupilleGauche(struct Window *EyeWnd, int c, int * PRayon)
- {
- SHORT i, xp, yp;
- #ifdef ENTRELACE
- static float rx = REYE-0.5;
- #else
- static float rx = 2*REYE+0.5;
- #endif
- float ry, x, y;
-
- float sgn = 1;
-
- if (*PRayon < 0)
- {
- sgn = -1;
- ry = -(*PRayon);
- }
- else
- {
- ry = *PRayon;
- }
-
- SetAPen(EyeWnd->RPort, c);
-
- for (i = 0; i <= RESOL; i++)
- {
- x = (float)rx * sgn*dcos[i];
- y = -(float)ry * sgn*dcos[RESOL-i];
-
- xp = (int)(x+0.5+lEYE);
- yp = (int)(y+0.5+yEYE);
- Plot(EyeWnd, xp, yp, c);
- *(pixel+SIZEWNDX*xp+yp) = c;
-
- xp = (int)(-x+0.5+lEYE);
- Plot(EyeWnd, xp, yp, c);
- *(pixel+SIZEWNDX*xp+yp) = c;
- }
-
- (*PRayon)--;
- #ifdef ENTRELACE
- if (*PRayon < -(REYE-2))
- #else
- if (*PRayon < -(REYE-1))
- #endif
- {
- (*PRayon)++;
- return(TRUE);
- }
- else
- return(FALSE);
- }
-
- /*****************************************************************************/
-
- BOOL OuvrePupilleGauche(struct Window *EyeWnd, int c, int *PRayon)
- {
- SHORT i, xp, yp;
- #ifdef ENTRELACE
- static float rx = REYE-0.5;
- #else
- static float rx = REYE*2+0.5;
- #endif
- float ry, x, y;
-
- float sgn = 1;
-
- if (*PRayon < 0)
- {
- sgn = -1;
- ry = -*PRayon;
- }
- else
- {
- ry = *PRayon;
- }
-
- SetAPen(EyeWnd->RPort, c);
-
- for (i = 0; i <= RESOL; i++)
- {
- x = (float)rx * sgn*dcos[i];
- y = -(float)ry * sgn*dcos[RESOL-i];
-
- xp = (int)(x+lEYE+0.5);
- yp = (int)(y+yEYE+0.5);
- Plot(EyeWnd, xp, yp, c);
- *(pixel+SIZEWNDX*xp+yp) = c;
-
- xp = (int)(-x+lEYE+0.5);
- Plot(EyeWnd, xp, yp, c);
- *(pixel+SIZEWNDX*xp+yp) = c;
- }
-
- (*PRayon)++;
- #ifdef ENTRELACE
- if (*PRayon > (REYE-2))
- #else
- if (*PRayon > (REYE-1))
- #endif
- {
- (*PRayon)--;
- return(TRUE);
- }
- else
- return(FALSE);
- }
-
- /*****************************************************************************/
-
- BOOL FermePupilleDroite(struct Window *EyeWnd, int c, int * PRayon)
- {
- SHORT i, xp, yp;
- #ifdef ENTRELACE
- static float rx = REYE-0.5;
- #else
- static float rx = REYE*2+0.5;
- #endif
- float ry, x, y;
-
- float offsetangle = 0;
- float sgn = 1;
-
- if (*PRayon < 0)
- {
- offsetangle = PI;
- sgn = -1;
- ry = -(*PRayon);
- }
- else
- {
- ry = *PRayon;
- }
-
- SetAPen(EyeWnd->RPort, c);
-
- for (i = 0; i <= RESOL; i++)
- {
- x = (float)rx * sgn*dcos[i];
- y = -(float)ry * sgn*dcos[RESOL-i];
-
- xp = (int)(x+rEYE+0.5);
- yp = (int)(y+yEYE+0.5);
- Plot(EyeWnd, xp, yp, c);
- *(pixel+SIZEWNDX*xp+yp) = c;
-
- xp = (int)(-x+rEYE+0.5);
- Plot(EyeWnd, xp, yp, c);
- *(pixel+SIZEWNDX*xp+yp) = c;
- }
-
- (*PRayon)--;
-
- #ifdef ENTRELACE
- if (*PRayon < -(REYE-2))
- #else
- if (*PRayon < -(REYE-1))
- #endif
- {
- (*PRayon)++;
- return(TRUE);
- }
- else
- return(FALSE);
- }
-
- /*****************************************************************************/
-
- BOOL OuvrePupilleDroite(struct Window *EyeWnd, int c, int *PRayon)
- {
- SHORT i, xp, yp;
- #ifdef ENTRELACE
- static float rx = REYE-0.5;
- #else
- static float rx = REYE*2+0.5;
- #endif
- float ry, x, y;
-
- float offsetangle = 0;
- float sgn = 1;
-
- if (*PRayon < 0)
- {
- offsetangle = PI;
- sgn = -1;
- ry = -*PRayon;
- }
- else
- {
- ry = *PRayon;
- }
-
- SetAPen(EyeWnd->RPort, c);
-
- for (i = 0; i <= RESOL; i++)
- {
- x = (float)rx * sgn*dcos[i];
- y = -(float)ry * sgn*dcos[RESOL-i];
-
- xp = (int)(x+rEYE+0.5);
- yp = (int)(y+yEYE+0.5);
- Plot(EyeWnd, xp, yp, c);
- *(pixel+SIZEWNDX*xp+yp) = c;
-
- xp = (int)(-x+rEYE+0.5);
- Plot(EyeWnd, xp, yp, c);
- *(pixel+SIZEWNDX*xp+yp) = c;
- }
-
- (*PRayon)++;
-
- #ifdef ENTRELACE
- if (*PRayon > (REYE-2))
- #else
- if (*PRayon > (REYE-1))
- #endif
- {
- (*PRayon)--;
- return(TRUE);
- }
- else
- return(FALSE);
- }
-
- /*****************************************************************************/
- /* Routine d'affichage d'un point */
- /*****************************************************************************/
-
- void Plot(struct Window *EyeWnd, register SHORT x, register SHORT y, register int c)
- {
- register UBYTE *adresse;
- UBYTE bit;
- register etbit, oubit;
- register ULONG addoffset, i;
-
- if ((x <= EyeWnd->Width) && (y <= EyeWnd->Height))
- {
- addoffset = x >> 3;
-
- bit = 7 - (x & 7);
- oubit = 1 << bit;
- etbit = 255 - oubit;
-
- for (i = 0; i < Trace.Depth; i++, c = c >> 1)
- {
- adresse = (UBYTE *)(Trace.Adr[y][i] + addoffset);
- if (c & 1)
- *(adresse) |= oubit;
- else
- *(adresse) &= etbit;
- }
- }
- }
-