]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - video/generic.c
Improve correctness of backtrace library.
[netwatch.git] / video / generic.c
... / ...
CommitLineData
1/* generic.c
2 * Helper functions for dealing with generic RGB888 framebuffers
3 * NetWatch system management mode administration console
4 *
5 * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
6 * This program is free software; you can redistribute and/or modify it under
7 * the terms found in the file LICENSE in the root of this source tree.
8 *
9 */
10
11#include <stdint.h>
12#include <fb.h>
13#include <crc32.h>
14
15uint32_t checksum_rect_generic32(int x, int y, int width, int height) {
16
17 /* Generic checksum_rect function for video modes with 32-bit pixels
18 * (i.e. fb->curmode.bytestride = 4).
19 */
20
21 int scanline = fb->curmode.xres * 4;
22 unsigned char * lineaddr;
23 int i;
24
25 uint32_t sum = 0;
26
27 for (i = 0; i < height; i++) {
28 lineaddr = fb->fbaddr + (i + y) * scanline + (4 * x);
29
30 sum = crc32(lineaddr, width * 4, sum);
31 }
32
33 return sum;
34}
35
36void copy_pixels_generic32(char *buf, int x, int y, int width, int height)
37{
38 int cx, cy;
39 unsigned int *ibuf = (unsigned int *)buf;
40 unsigned int *fbuf;
41 for (cy = 0; cy < height; cy++)
42 {
43 fbuf = (unsigned int *)fb->fbaddr;
44 fbuf += (cy + y) * (fb->curmode.xres) + x;
45 for (cx = 0; cx < width; cx++)
46 *(ibuf++) = *(fbuf++);
47 }
48}
This page took 0.027419 seconds and 4 git commands to generate.