calculate scores
[gbajam22] / src / polyfill.c
index 18294f5..911b1d7 100644 (file)
@@ -1,6 +1,6 @@
 /*
-blender for the Gameboy Advance
-Copyright (C) 2021  John Tsiombikas <nuclear@member.fsf.org>
+gbajam22 entry for the Gameboy Advance
+Copyright (C) 2022  John Tsiombikas <nuclear@mutantstargoat.com>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -21,9 +21,9 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 static unsigned char *fb;
 static int fbwidth, fbheight;
-static short scantab[2][160] __attribute__((section(".iwram")));
+static short scantab[2][160];
 
-void polyfill_framebuffer(unsigned char *ptr, int w, int h)
+void polyfill_framebuffer(void *ptr, int w, int h)
 {
        fb = ptr;
        fbwidth = w;
@@ -34,6 +34,7 @@ void polyfill_framebuffer(unsigned char *ptr, int w, int h)
 #define VPREV(p)       ((p) == varr ? vlast : (p) - 1)
 #define VSUCC(p, side) ((side) == 0 ? VNEXT(p) : VPREV(p))
 
+ARM_IWRAM
 void polyfill_flat(struct pvertex *varr, int vnum, unsigned char col)
 {
        int i, line, top, bot;
@@ -87,6 +88,9 @@ void polyfill_flat(struct pvertex *varr, int vnum, unsigned char col)
                }
        }
 
+       if(top < 0) top = 0;
+       if(bot >= fbheight) bot = fbheight - 1;
+
        fbptr = fb + top * fbwidth;
        for(i=top; i<=bot; i++) {
                start = scantab[0][i];