1 /*
2  *	scrnshot.cc
3  *	This module contains the function ScreenShot() which is called
4  *	whenever you press shift-F1 in edit mode. It is only a wrapper
5  *	for the gifsave library.
6  *	AYM 1997-08-20
7  */
8 
9 
10 /*
11 This file is part of Yadex.
12 
13 Yadex incorporates code from DEU 5.21 that was put in the public domain in
14 1994 by Rapha�l Quinet and Brendon Wyber.
15 
16 The rest of Yadex is Copyright � 1997-2003 Andr� Majorel and others.
17 
18 This program is free software; you can redistribute it and/or modify it under
19 the terms of the GNU General Public License as published by the Free Software
20 Foundation; either version 2 of the License, or (at your option) any later
21 version.
22 
23 This program is distributed in the hope that it will be useful, but WITHOUT
24 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
25 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
26 
27 You should have received a copy of the GNU General Public License along with
28 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
29 Place, Suite 330, Boston, MA 02111-1307, USA.
30 */
31 
32 
33 #include "yadex.h"
34 #if defined Y_UNIX
35 #elif defined Y_DOS
36 #include <gifsave.h>
37 #endif
38 
39 
40 #ifdef Y_DOS
41 static int ShotGetPixel (int x, int y);
42 #endif
43 
44 
ScreenShot(void)45 void ScreenShot (void)
46 #if defined Y_UNIX
47 {
48   return;  // FIXME
49 }
50 #elif defined Y_DOS
51 {
52   int n;
53   int r;
54   int ShotWidth, ShotHeight;
55 
56   ShotWidth = ScrMaxX+1;
57   ShotHeight = ScrMaxY+1-17-12;
58 
59   LogMessage ("Writing screen shot to file yadex.gif\n");
60   r = GIF_Create ("yadex.gif", ShotWidth, ShotHeight, 16, 3);
61   if (r != GIF_OK)
62     LogMessage ("GIF_Create error %d\n", r);
63   GIF_SetColor ( 0, 0, 0, 0);  // BLACK
64   GIF_SetColor ( 1, 0, 0, 4);  // BLUE
65   GIF_SetColor ( 2, 0, 4, 0);  // GREEN
66   GIF_SetColor ( 3, 0, 4, 4);  // CYAN
67   GIF_SetColor ( 4, 4, 0, 0);  // RED
68   GIF_SetColor ( 5, 4, 0, 4);  // MAGENTA
69   GIF_SetColor ( 6, 4, 3, 0);  // BROWN
70   GIF_SetColor ( 7, 4, 4, 4);  // LIGHTGREY
71   GIF_SetColor ( 8, 2, 2, 2);  // DARKGREY
72   GIF_SetColor ( 9, 0, 0, 7);  // LIGHTBLUE
73   GIF_SetColor (10, 0, 7, 0);  // LIGHTGREEN
74   GIF_SetColor (11, 0, 7, 7);  // LIGHTCYAN
75   GIF_SetColor (12, 7, 0, 0);  // LIGHTRED
76   GIF_SetColor (13, 7, 0, 7);  // LIGHTMAGENTA
77   GIF_SetColor (14, 7, 7, 0);  // YELLOW
78   GIF_SetColor (15, 7, 7, 7);  // WHITE
79   r = GIF_CompressImage (0, 17, ShotWidth, ShotHeight, ShotGetPixel);
80   if (r != GIF_OK)
81     LogMessage ("GIF_CompressImage error %d\n", r);
82   r = GIF_Close ();
83   LogMessage ("GIF_Close returned %d\n", r);
84 }
85 
86 
87 static const char ColourCode[256] =
88 {
89    0, 0, 0, 0,15, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
90    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
91    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
92    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
93 
94    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
95    0, 0, 0, 0, 0, 0, 0, 0,  7, 0, 0, 0, 0, 0, 0, 0,
96    8, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
97   10, 0, 0, 0, 0, 0, 2, 0,  0, 0, 0, 0, 0, 0, 0, 0,
98 
99    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
100    6, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
101    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
102   12, 0, 0, 0, 0, 0, 0, 4,  0, 0, 0, 0, 0, 0, 3, 0,
103 
104    0,11, 0, 0, 0, 9, 0, 0,  0, 0, 1, 0, 0, 0, 0, 0,
105    0, 0, 0, 0, 0, 0, 0,14,  0, 0, 0, 0, 0, 0, 0, 0,
106    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
107    0, 0, 0, 0, 0, 0, 0, 0,  0, 0,13, 0, 0, 5, 0, 0
108 };
109 
110 static int ShotGetPixel (int x, int y)
111 {
112   // FIXME: I assume we're in 256 colours
113   return ColourCode[getpixel (x, y)];
114 }
115 #endif
116 
117