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); writepxl(x2, y, color);
} }
/******************************************************************************/ /******************************************************************************/
/* Affiche un triangle rempli entre les points spécifiés */ /* Affiche un triangle rempli entre les points spécifiés */
void trianglefilled(vertex2d *AA, vertex2d *BB, vertex2d *CC, u8 color) { void trianglefilled(vertex2d *AA, vertex2d *BB, vertex2d *CC, u8 color) {
vertex2d *A,*B,*C; vertex2d *A,*B,*C,*TEMP;
u32 a, b, y, last; u32 a, b, y, last;
int dx1, dx2, dx3, dy1, dy2, dy3 , sa, sb; int dx1, dx2, dx3, dy1, dy2, dy3 , sa, sb;
A=AA; A=AA;
B=BB; B=BB;
C=CC; C=CC;
if (AA->y > BB->y) { if (A->y > B->y)
A=BB; swapvertex(A,B);
B=AA; if (B->y > C->y)
} swapvertex(B,C);
if (BB->y > CC->y) { if (A->y > C->y)
C=BB; swapvertex(A,C);
B=CC;
}
if (AA->y > CC->y) {
C=AA;
A=CC;
}
if(A->y == C->y) { //meme ligne if(A->y == C->y) { //meme ligne
a = b = A->x; a = b = A->x;
if(B->x < a) a = B->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 */ /* Affiche un triangle entre les points spécifiés */

View File

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

View File

@ -94,8 +94,16 @@ void test2d() {
setvmode(0x84); setvmode(0x84);
fill(0x00); fill(0x00);
struct vertex2d a,b,c; 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(); randomize();
for(int i=0;i<100;i++) for(int i=0;i<3200;i++)
{ {
a.x=random(0, 800); a.x=random(0, 800);
a.y=random(0, 600); a.y=random(0, 600);
@ -105,6 +113,8 @@ void test2d() {
c.y=random(0, 600); c.y=random(0, 600);
trianglefilled(&a,&b,&c,random(0, 16)); trianglefilled(&a,&b,&c,random(0, 16));
triangle(&a,&b,&c,2); 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();
} }
} }