summaryrefslogtreecommitdiff
path: root/meme/screen.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-02-14 02:12:42 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-02-14 02:13:28 (GMT)
commitfd505de82aa73c850d7b122dc3c9f7829995ad9c (patch)
tree26c825b2c209918c758a7dee1fa7a29e1b6195bb /meme/screen.c
parent32f2b42c5055e0783ad3c076a1bdb9d6abcb5b28 (diff)
downloadmisc-fd505de82aa73c850d7b122dc3c9f7829995ad9c.zip
misc-fd505de82aa73c850d7b122dc3c9f7829995ad9c.tar.gz
misc-fd505de82aa73c850d7b122dc3c9f7829995ad9c.tar.bz2
meme/: add screen dumps with "D"; option "-d dump.bmp" to set dump name
Diffstat (limited to 'meme/screen.c')
-rw-r--r--meme/screen.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/meme/screen.c b/meme/screen.c
index c1b0f99..b9b570f 100644
--- a/meme/screen.c
+++ b/meme/screen.c
@@ -1,8 +1,8 @@
/*
* screen.c - Screen dump
*
- * Written 2015 by Werner Almesberger
- * Copyright 2015 Werner Almesberger
+ * Written 2015-2016 by Werner Almesberger
+ * Copyright 2015-2016 Werner Almesberger
*
* 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
@@ -15,19 +15,20 @@
#include <stdio.h>
#include <unistd.h>
-#include "sim.h"
+#include "SDL.h"
+
#include "screen.h"
-#define BASE_NAME "anelok-sim-"
+#define BASE_NAME "meme-"
const char *screen_dump_name = NULL;
-void dump_screen_file(const char *name)
+void dump_screen_file(SDL_Surface *s, const char *name)
{
- if (SDL_SaveBMP(surf, name)) {
+ if (SDL_SaveBMP(s, name)) {
fprintf(stderr, "SDL_SaveBMP: %s\n", SDL_GetError());
exit(1);
}
@@ -35,7 +36,7 @@ void dump_screen_file(const char *name)
}
-static void dump_screen_unique(void)
+static void dump_screen_unique(SDL_Surface *s)
{
char tmp[sizeof(BASE_NAME) + 4 + 4];
int n;
@@ -43,7 +44,7 @@ static void dump_screen_unique(void)
for (n = 0; n <= 9999; n++) {
snprintf(tmp, sizeof(tmp), BASE_NAME "%04d.bmp", n);
if (access(tmp, R_OK)) {
- dump_screen_file(tmp);
+ dump_screen_file(s, tmp);
return;
}
}
@@ -52,10 +53,10 @@ static void dump_screen_unique(void)
}
-void dump_screen(void)
+void dump_screen(SDL_Surface *s)
{
if (screen_dump_name)
- dump_screen_file(screen_dump_name);
+ dump_screen_file(s, screen_dump_name);
else
- dump_screen_unique();
+ dump_screen_unique(s);
}