From 625d9877ab7c15000871555a0ce22bd0a3109e89 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 27 Apr 2011 20:20:59 -0300 Subject: [PATCH] ubb-vga2.c: make frame buffer fully VGA-sized; more cleanup - ubb-vga2.c (frame, grab, session): keep all 480 lines in the frame buffer instead of duplicating them on output - ubb-vga2.c (bad): make "static" - ubb-vga2.c (session, main): removed the "single" argument - ubb-vga2.c (main): complain about timeouts only if any occurred --- ubb-vga/ubb-vga2.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ubb-vga/ubb-vga2.c b/ubb-vga/ubb-vga2.c index 93a85ca..64d7ecb 100644 --- a/ubb-vga/ubb-vga2.c +++ b/ubb-vga/ubb-vga2.c @@ -36,7 +36,7 @@ static uint8_t thres = 63; -int bad; +static int bad; /* ----- I/O pin assignment ------------------------------------------------ */ @@ -378,10 +378,8 @@ static void frame(const uint32_t *f) *pddats = HSYNC; until(line_cycles-US(0.79)); - for (p = f; p != f+240*line_words; p += line_words) { - line(p, p); + for (p = f; p != f+480*line_words; p += line_words) line(p, p+line_words); - } /* Back porch */ hdelay(14); @@ -462,23 +460,27 @@ static void grab(uint8_t *f) uint32_t pix; uint8_t r, g, b; - for (y = 0; y != 240; y++) + for (y = 0; y != 240; y++) { for (x = 0; x != 320; x++) { pix = *fb++; r = pix >> 16; g = pix >> 8; b = pix; - *f++ = pattern(r >= thres, g >= thres, b >= thres); + f[0] = f[320] = + pattern(r >= thres, g >= thres, b >= thres); + f++; } + f += 320; + } } /* ----- Command-line parsing and main loop -------------------------------- */ -static void session(int frames, int single) +static void session(int frames) { - uint32_t f[2*240*line_words]; + uint32_t f[2*240*(line_words+1)]; int i; memset(f, 0, sizeof(f)); @@ -508,7 +510,6 @@ static void usage(const char *name) int main(int argc, char *const *argv) { int frames; - int single = 1; int c; while ((c = getopt(argc, argv, "")) != EOF) @@ -529,9 +530,10 @@ int main(int argc, char *const *argv) } setup(); - session(frames, single); + session(frames); cleanup(); -printf("%d\n", bad); + if (bad) + printf("%d timeout%s\n", bad, bad == 1 ? "" : "s"); return 0; }