clipping bugs...
[dosdemo] / src / sdl / main.c
index 6b65796..09645aa 100644 (file)
@@ -3,6 +3,7 @@
 #include <limits.h>
 #include <SDL/SDL.h>
 #include "demo.h"
+#include "tinyfps.h"
 
 static void handle_event(SDL_Event *ev);
 static void toggle_fullscreen(void);
@@ -29,7 +30,8 @@ int main(int argc, char **argv)
        xsz = fb_width * fbscale;
        ysz = fb_height * fbscale;
 
-       if(!(fb_pixels = malloc(fb_width * fb_height * fb_bpp / CHAR_BIT))) {
+       /* allocate 1 extra row as a guard band, until we fucking fix the rasterizer */
+       if(!(fb_pixels = malloc(fb_width * (fb_height + 1) * fb_bpp / CHAR_BIT))) {
                fprintf(stderr, "failed to allocate virtual framebuffer\n");
                return 1;
        }
@@ -61,6 +63,7 @@ int main(int argc, char **argv)
 
                time_msec = SDL_GetTicks() - start_time;
                demo_draw();
+               drawFps(fb_pixels);
 
                if(SDL_MUSTLOCK(fbsurf)) {
                        SDL_LockSurface(fbsurf);
@@ -129,10 +132,10 @@ static void handle_event(SDL_Event *ev)
                break;
 
        case SDL_MOUSEBUTTONDOWN:
-               mouse_bmask |= 1 << ev->button.button;
+               mouse_bmask |= 1 << (ev->button.button - SDL_BUTTON_LEFT);
                if(0) {
        case SDL_MOUSEBUTTONUP:
-                       mouse_bmask &= ~(1 << ev->button.button);
+                       mouse_bmask &= ~(1 << (ev->button.button - SDL_BUTTON_LEFT));
                }
                mouse_x = ev->button.x / fbscale;
                mouse_y = ev->button.y / fbscale;