fix: debogue de la fonction trianglefill

This commit is contained in:
Nicolas Hordé 2018-08-22 18:39:06 +02:00
parent c76554dd4a
commit 36185af660
3 changed files with 30 additions and 15 deletions

View File

@ -68,29 +68,24 @@ void hline(u32 x1, u32 x2, u32 y, u8 color) {
writepxl(x2, y, color);
}
/******************************************************************************/
/* Affiche un triangle rempli entre les points spécifiés */
void trianglefilled(vertex2d *AA, vertex2d *BB, vertex2d *CC, u8 color) {
vertex2d *A,*B,*C;
vertex2d *A,*B,*C,*TEMP;
u32 a, b, y, last;
int dx1, dx2, dx3, dy1, dy2, dy3 , sa, sb;
A=AA;
B=BB;
C=CC;
if (AA->y > BB->y) {
A=BB;
B=AA;
}
if (BB->y > CC->y) {
C=BB;
B=CC;
}
if (AA->y > CC->y) {
C=AA;
A=CC;
}
if (A->y > B->y)
swapvertex(A,B);
if (B->y > C->y)
swapvertex(B,C);
if (A->y > C->y)
swapvertex(A,C);
if(A->y == C->y) { //meme ligne
a = b = A->x;
if(B->x < a) a = B->x;
@ -133,6 +128,12 @@ void trianglefilled(vertex2d *AA, vertex2d *BB, vertex2d *CC, u8 color) {
}
}
void swapvertex(vertex2d* A, vertex2d* B){
vertex2d temp = *A;
*A = *B;
*B = temp;
}
/******************************************************************************/
/* Affiche un triangle entre les points spécifiés */

View File

@ -21,9 +21,13 @@ copy:
test: all copy qemu
retest: clean test
view:
(hexdump -C ./final/cos2000.img|head -c10000)
debug: debug-system
debug-boot: all copy qemu-debug
(sleep 2;cgdb -x ./debug/boot.txt)
@ -34,7 +38,7 @@ debug-system: all copy qemu-debug
(sleep 2;cgdb -x ./debug/system.txt)
qemu-debug:
(qemu-system-i386 -m 1G -fda ./final/cos2000.img -s -S &)
(killall qemu-system-i386;qemu-system-i386 -m 1G -fda ./final/cos2000.img -s -S &)
qemu:
(qemu-system-i386 -m 1G -fda ./final/cos2000.img -s)

View File

@ -94,8 +94,16 @@ void test2d() {
setvmode(0x84);
fill(0x00);
struct vertex2d a,b,c;
a.x=230;
a.y=157;
b.x=375;
b.y=29;
c.x=278;
c.y=276;
trianglefilled(&a,&b,&c,random(0, 16));
triangle(&a,&b,&c,2);
randomize();
for(int i=0;i<100;i++)
for(int i=0;i<3200;i++)
{
a.x=random(0, 800);
a.y=random(0, 600);
@ -105,6 +113,8 @@ void test2d() {
c.y=random(0, 600);
trianglefilled(&a,&b,&c,random(0, 16));
triangle(&a,&b,&c,2);
printf("\r\nA:%d,%d B:%d,%d C:%d,%d",a.x,a.y,b.x,b.y,c.x,c.y);
waitascii();
}
}