unlit cube
[gba_blender] / src / polyfill.c
index 2595429..f2bb599 100644 (file)
@@ -41,6 +41,7 @@ void polyfill_flat(struct pvertex *varr, int vnum, unsigned char col)
        int32_t x, y0, y1, dx, dy, slope, fx, fy;
        short *tab, start, len;
        unsigned char *fbptr;
+       static int dbg;
 
        vlast = varr + vnum - 1;
        top = fbheight;
@@ -76,7 +77,7 @@ void polyfill_flat(struct pvertex *varr, int vnum, unsigned char col)
 
                if(line > 0) tab += line;
 
-               while(line < (y1 >> 8) && line < fbheight) {
+               while(line <= (y1 >> 8) && line < fbheight) {
                        if(line >= 0) {
                                int val = x < 0 ? 0 : x >> 8;
                                *tab++ = val < fbwidth ? val : fbwidth - 1;
@@ -87,7 +88,7 @@ void polyfill_flat(struct pvertex *varr, int vnum, unsigned char col)
        }
 
        fbptr = fb + top * fbwidth;
-       for(i=top; i<bot; i++) {
+       for(i=top; i<=bot; i++) {
                start = scantab[0][i];
                len = scantab[1][i] - start;
 
@@ -96,4 +97,6 @@ void polyfill_flat(struct pvertex *varr, int vnum, unsigned char col)
                }
                fbptr += fbwidth;
        }
+
+       dbg++;
 }