|
|
1.1 root 1: /*
2: Hatari
3:
4: Screen Snapshot
5: */
6:
7: #include "main.h"
8: #include "misc.h"
9: #include "pcx.h"
10: #include "screen.h"
11: #include "screenSnapShot.h"
12: #include "statusBar.h"
13: #include "video.h"
14: #include "vdi.h"
15:
16: //#define ALLOW_SCREEN_GRABS /* FIXME */
17:
18: int nScreenShots=0; // Number of screen shots saved
19: BOOL bRecordingAnimation=FALSE; // Recording animation?
20: BOOL bGrabWhenChange;
21: int GrabFrameCounter,GrabFrameLatch;
22:
23: //-----------------------------------------------------------------------
24: /*
25: Check if we have pressed PrintScreen
26: */
27: void ScreenSnapShot_CheckPrintKey(void)
28: {
29: #ifdef ALLOW_SCREEN_GRABS
30: // Did press Print Screen key?
31: if (GetAsyncKeyState(VK_SNAPSHOT)&0x0001) { // Print Key pressed(not held)
32: // Save our screen
33: ScreenSnapShot_SaveScreen();
34: }
35: #endif //ALLOW_SCREEN_GRABS
36: }
37:
38: //-----------------------------------------------------------------------
39: /*
40: Save screen shot out .PCX file with filename 'grab0000.pcx','grab0001.pcx'....
41: */
42: void ScreenSnapShot_SaveScreen(void)
43: {
44: char szFileName[MAX_FILENAME_LENGTH];
45:
46: // Only do when NOT in full screen and NOT VDI resolution
47: if (!bInFullScreen && !bUseVDIRes) {
48: // Create our filename
49: sprintf(szFileName,"%s/grab%4.4d.pcx",szWorkingDir,nScreenShots);
50: nScreenShots++;
51: // And save as 1/24-bit PCX
52: if (bUseHighRes)
53: PCX_SaveScreenShot_Mono(szFileName);
54: else
55: PCX_SaveScreenShot(szFileName);
56: }
57: }
58:
59: //-----------------------------------------------------------------------
60: /*
61: Are we recording an animation?
62: */
63: BOOL ScreenSnapShot_AreWeRecording(void)
64: {
65: return(bRecordingAnimation);
66: }
67:
68: /*-----------------------------------------------------------------------*/
69: /*
70: Start recording animation
71: */
72: void ScreenSnapShot_BeginRecording(BOOL bCaptureChange, int nFramesPerSecond)
73: {
74: /* Set in globals */
75: bGrabWhenChange = bCaptureChange;
76: /* Set animation timer rate */
77: GrabFrameCounter = 0;
78: GrabFrameLatch = (int)(50.0f/(float)nFramesPerSecond);
79: /* Start animation */
80: bRecordingAnimation = TRUE;
81: /* Set status bar */
82: StatusBar_SetIcon(STATUS_ICON_SCREEN,ICONSTATE_ON);
83: /* And inform user */
84: Main_Message("Screen-Shot recording started.",PROG_NAME /*,MB_OK|MB_ICONINFORMATION*/);
85: }
86:
87: /*-----------------------------------------------------------------------*/
88: /*
89: Stop recording animation
90: */
91: void ScreenSnapShot_EndRecording()
92: {
93: /* Were we recording? */
94: if (bRecordingAnimation) {
95: /* Stop animation */
96: bRecordingAnimation = FALSE;
97: /* Turn off icon */
98: StatusBar_SetIcon(STATUS_ICON_SCREEN,ICONSTATE_OFF);
99: /* And inform user */
100: Main_Message("Screen-Shot recording stopped.",PROG_NAME /*,MB_OK|MB_ICONINFORMATION*/);
101: }
102: }
103:
104: //-----------------------------------------------------------------------
105: /*
106: Recording animation frame
107: */
108: void ScreenSnapShot_RecordFrame(BOOL bFrameChanged)
109: {
110: // As we recording? And running in a Window
111: if (bRecordingAnimation && !bInFullScreen) {
112: // Yes, but on a change basis or a timer?
113: if (bGrabWhenChange) {
114: // On change, so did change this frame?
115: if (bFrameChanged)
116: ScreenSnapShot_SaveScreen();
117: }
118: else {
119: // On timer, check for latch and save
120: GrabFrameCounter++;
121: if (GrabFrameCounter>=GrabFrameLatch) {
122: ScreenSnapShot_SaveScreen();
123: GrabFrameCounter = 0;
124: }
125: }
126: }
127: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.