Store user data in $HOME
[kball.git] / src / savescrs.cpp
blob8fe66099c08e6ea3bc543af6d3fc8819e08fd2d5
1 // ------------------------------------------------------------------
2 // savescrs.cpp
3 // ------------------------------------------------------------------
4 // This saves screenshoots of the current screen
5 // ------------------------------------------------------------------
6 // By Kronoman - In loving memory of my father
7 // Copyright (c) 2004, Kronoman
8 // ------------------------------------------------------------------
10 #include "savescrs.h"
12 // ------------------------------------------------------------------
13 // This captures the screenshoot, using the file format
14 // of file extension (can be PCX, BMP, TGA)
16 // Will use [name][hex number].[extension] for the name
17 // The hex number starts counting at hex_start
18 // Will *not* overwrite files
19 // ------------------------------------------------------------------
20 void save_screenshoot(char *name, int hex_start, char *extension)
22 char fname[2048];
23 BITMAP *bmp;
24 PALETTE pal;
25 int i = 0;
27 // will try at least 4096 numbers from hex_start before giving up trying to save
28 do
30 usprintf(fname, "%s%x.%s", name, hex_start+i, extension);
31 i++;
33 while (exists(fname) && i < 4096);
35 get_palette(pal);
36 bmp = create_sub_bitmap(screen, 0, 0, SCREEN_W, SCREEN_H);
37 save_bitmap(fname, bmp, pal);
38 destroy_bitmap(bmp);