summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-02-11 14:38:44 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-02-11 14:38:44 +0000
commit6dca87e60cb54073c5a0b26b233bfc239b763d6b (patch)
treef3552877a14a43aeddd247f60eded1e512d5947f /apps/misc.c
parent11c1d28d9e69b67d425ab0b3532e69ba19a784b6 (diff)
downloadrockbox-6dca87e60cb54073c5a0b26b233bfc239b763d6b.tar.gz
rockbox-6dca87e60cb54073c5a0b26b233bfc239b763d6b.zip
iRiver: Fixed screendump() function
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5913 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/misc.c')
-rw-r--r--apps/misc.c52
1 files changed, 47 insertions, 5 deletions
diff --git a/apps/misc.c b/apps/misc.c
index e69880fb40..19d6f0d1dd 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -22,6 +22,7 @@
22#include "string.h" 22#include "string.h"
23#include "config.h" 23#include "config.h"
24#include "file.h" 24#include "file.h"
25#include "dir.h"
25#include "lcd.h" 26#include "lcd.h"
26#include "sprintf.h" 27#include "sprintf.h"
27#include "errno.h" 28#include "errno.h"
@@ -37,6 +38,7 @@
37#include "power.h" 38#include "power.h"
38#include "powermgmt.h" 39#include "powermgmt.h"
39#include "backlight.h" 40#include "backlight.h"
41#include "atoi.h"
40#ifdef HAVE_MMC 42#ifdef HAVE_MMC
41#include "ata_mmc.h" 43#include "ata_mmc.h"
42#endif 44#endif
@@ -137,8 +139,13 @@ extern unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
137static const unsigned char bmpheader[] = 139static const unsigned char bmpheader[] =
138{ 140{
139 0x42, 0x4d, 0x3e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 141 0x42, 0x4d, 0x3e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00,
140 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x40, 0x00, 142 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, LCD_WIDTH, 0x00, 0x00, 0x00, LCD_HEIGHT, 0x00,
141 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 143 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
144#if LCD_WIDTH == 160
145 0x00, 0x00, 0x00, 0x0a,
146#else
147 0x00, 0x00, 0x00, 0x04,
148#endif
142 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0x00, 0x00, 149 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0x00, 0x00,
143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xee, 0x90, 0x00, 0x00, 0x00, 150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xee, 0x90, 0x00, 0x00, 0x00,
144 0x00, 0x00 151 0x00, 0x00
@@ -150,12 +157,47 @@ void screen_dump(void)
150 int bx, by, ix, iy; 157 int bx, by, ix, iy;
151 int src_byte, src_mask, dst_mask; 158 int src_byte, src_mask, dst_mask;
152 char filename[MAX_PATH]; 159 char filename[MAX_PATH];
153 static unsigned char line_block[8][16]; 160 static unsigned char line_block[8][(LCD_WIDTH/8+3) & ~3];
161#ifdef HAVE_RTC
154 struct tm *tm = get_time(); 162 struct tm *tm = get_time();
155 163
156 snprintf(filename, MAX_PATH, "/dump %04d-%02d-%02d %02d-%02d-%02d.bmp", 164 snprintf(filename, MAX_PATH, "/dump %04d-%02d-%02d %02d-%02d-%02d.bmp",
157 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, 165 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
158 tm->tm_hour, tm->tm_min, tm->tm_sec); 166 tm->tm_hour, tm->tm_min, tm->tm_sec);
167#else
168 {
169 DIR* dir;
170 int max_dump_file = 1; /* default to dump_0001.bmp */
171 dir = opendir("/");
172 if (dir) /* found */
173 {
174 /* Search for the highest screendump filename present,
175 increment behind that. So even with "holes"
176 (deleted files), the newest will always have the
177 highest number. */
178 while(true)
179 {
180 struct dirent* entry;
181 int curr_dump_file;
182 /* walk through the directory content */
183 entry = readdir(dir);
184 if (!entry)
185 {
186 closedir(dir);
187 break; /* end of dir */
188 }
189 if (strncasecmp(entry->d_name, "dump_", 5))
190 continue; /* no screendump file */
191 curr_dump_file = atoi(&entry->d_name[5]);
192 if (curr_dump_file >= max_dump_file)
193 max_dump_file = curr_dump_file + 1;
194 }
195 }
196 snprintf(filename, MAX_PATH,
197 "/dump_%04d.bmp", max_dump_file);
198 }
199
200#endif
159 201
160 fh = creat(filename, O_WRONLY); 202 fh = creat(filename, O_WRONLY);
161 if (fh < 0) 203 if (fh < 0)
@@ -166,7 +208,7 @@ void screen_dump(void)
166 /* BMP image goes bottom up */ 208 /* BMP image goes bottom up */
167 for (by = LCD_HEIGHT/8 - 1; by >= 0; by--) 209 for (by = LCD_HEIGHT/8 - 1; by >= 0; by--)
168 { 210 {
169 memset(&line_block[0][0], 0, 8*16); 211 memset(&line_block[0][0], 0, sizeof(line_block));
170 212
171 for (bx = 0; bx < LCD_WIDTH/8; bx++) 213 for (bx = 0; bx < LCD_WIDTH/8; bx++)
172 { 214 {
@@ -185,7 +227,7 @@ void screen_dump(void)
185 } 227 }
186 } 228 }
187 229
188 write(fh, &line_block[0][0], 8*16); 230 write(fh, &line_block[0][0], sizeof(line_block));
189 } 231 }
190 close(fh); 232 close(fh);
191} 233}