petit listing qui utilise la fonction ligne(), sujet d'étude du zine accompagnant cette source
Source / Exemple :
#include <bios.h>
#include <dos.h>
#include <mem.h>
#include <conio.h>
unsigned char * ecran = (unsigned char *) 0xA0000000L;
unsigned char * virtuel = new unsigned char[64000];
void vga ()
{
_AX = 0x13;
geninterrupt(0x10);
}
void pixel(int x, int y, unsigned char index)
{
virtuel[320*y+x]=index;
}
void aff()
{
memcpy(ecran, virtuel, 64000);
}
void setecran(int index)
{
memset(virtuel,index,64000);
}
void ligne(int x1, int y1, unsigned char index, int x2, int y2)
{
int indice;
int dx,dy;
int x,y;
float m;
if(x1==x2)
x2++;
if(x1>x2)
indice=1;
else
indice=0;
if (!indice)
{
dx=x2-x1;
dy=y2-y1;
m=(float)dy/dx;
if(m<=1&&m>=-1)
{
for(x=0; x<dx; x++)
{
y=m*x+y1;
pixel(x+x1, y, index);
}
}
else
{
if(dx==1&&y2>y1)
{
for(;y1<y2;y1++)
pixel(x1,y1,index);
}
else
if(dx==1&&y2<y1)
{
for(;y1>y2;y1--)
pixel(x1,y1,index);
}
else
{
m=(float)dx/dy;
if(m>0)
{
for(y=0;y<=dy;y++)
{
x=m*y+x1;
pixel(x,y+y1,index);
}
}
else
{
for(y=0;y>dy;y--)
{
x=m*y+x1;
pixel(x,y+y1,index);
}
}
}
}
}
if (indice==1)
{
dx=x1-x2;
dy=y1-y2;
m=(float)dy/dx;
if(m<=1&&m>=-1)
{
for(x=0;x<dx;x++)
{
y=y1-m*x;
pixel(x1-x, y, index);
}
}
else
{
m=(float)dx/dy;
if(m>0)
{
for(y=0;y<dy;y++)
{
x=x1-m*y;
pixel(x,y1-y,index);
}
}
else
{
for(y=0;y>dy;y--)
{
x=x1-m*y;
pixel(x,y1-y,index);
}
}
}
}
}
void mouseinit()
{
_AX=0;
geninterrupt(0x33);
_AX=7;
_CX=0;
_DX=320;
geninterrupt(0x33);
_AX=8;
_CX=0;
_DX=200;
geninterrupt(0x33);
_AX=4;
_CX=0;
_DX=0;
geninterrupt(0x33);
}
void mouse(int *x, int *y)
{
_AX=3;
geninterrupt(0x33);
}
void main ()
{
vga();
setecran(0);
int x=0, y=0;
mouseinit();
while(!kbhit())
{
mouse(&x,&y);
setecran(0);
ligne(160,100,62,x,y);
aff();
}
}
Conclusion :
http://php.kilio.com/urazine/
Ntomega--}.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.