]> Joshua Wise's Git repositories - netwatch.git/blobdiff - video/generic.c
more licensing
[netwatch.git] / video / generic.c
index 6168df20af5b459636f41a43c68443e2c78f052a..c35cd5dd14cd9fd31efaa8b34d7eaf0f867faca4 100644 (file)
@@ -1,5 +1,16 @@
+/* generic.c
+ * Helper functions for dealing with generic RGB888 framebuffers
+ * NetWatch system management mode administration console
+ *
+ * Copyright (c) 2008 Jacob Potter and Joshua Wise.  All rights reserved.
+ * This program is free software; you can redistribute and/or modify it under
+ * the terms found in the file LICENSE in the root of this source tree.
+ *
+ */
+
 #include <stdint.h>
 #include <fb.h>
+#include <crc32.h>
 
 uint32_t checksum_rect_generic32(int x, int y, int width, int height) {
 
@@ -8,17 +19,15 @@ uint32_t checksum_rect_generic32(int x, int y, int width, int height) {
         */
 
         int scanline = fb->curmode.xres * 4;
-        uint32_t * lineaddr;
-        int i, j;
+        unsigned char * lineaddr;
+        int i;
 
         uint32_t sum = 0;
 
         for (i = 0; i < height; i++) {
-                lineaddr = (uint32_t *)(fb->fbaddr + (i + y) * scanline);
+                lineaddr = fb->fbaddr + (i + y) * scanline + (4 * x);
 
-                for (j = 0; j < width; j++) {
-                        sum += lineaddr[j + x];
-                }
+                sum = crc32(lineaddr, width * 4, sum);
         }
 
         return sum;
@@ -29,11 +38,11 @@ void copy_pixels_generic32(char *buf, int x, int y, int width, int height)
        int cx, cy;
        unsigned int *ibuf = (unsigned int *)buf;
        unsigned int *fbuf;
-       for (cy = y; cy < (y + height); cy++)
+       for (cy = 0; cy < height; cy++)
        {
                fbuf = (unsigned int *)fb->fbaddr;
-               fbuf += y * (fb->curmode.xres) + x;
-               for (cx = x; cx < (x + width); cx++)
+               fbuf += (cy + y) * (fb->curmode.xres) + x;
+               for (cx = 0; cx < width; cx++)
                        *(ibuf++) = *(fbuf++);
        }
 }
This page took 0.023581 seconds and 4 git commands to generate.