|
|
1.1 root 1: /*
2: Hatari - dlgScreen.c
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
6: */
1.1.1.8 ! root 7: const char DlgScreen_fileid[] = "Hatari dlgScreen.c : " __DATE__ " " __TIME__;
1.1 root 8:
9: #include "main.h"
10: #include "configuration.h"
11: #include "dialog.h"
12: #include "sdlgui.h"
13: #include "screen.h"
14: #include "screenSnapShot.h"
1.1.1.2 root 15: #include "vdi.h"
1.1.1.6 root 16: #include "video.h"
1.1 root 17:
18:
19: #define DLGSCRN_FULLSCRN 3
1.1.1.5 root 20: #define DLGSCRN_OVERSCAN 4
21: #define DLGSCRN_ZOOMLOWRES 5
1.1.1.6 root 22: #define DLGSCRN_STATUSBAR 6
1.1.1.5 root 23: #define DLGSCRN_SKIP0 8
24: #define DLGSCRN_SKIP1 9
25: #define DLGSCRN_SKIP2 10
26: #define DLGSCRN_SKIP3 11
27: #define DLGSCRN_SKIP4 12
28: #define DLGSCRN_MONO 14
29: #define DLGSCRN_RGB 15
30: #define DLGSCRN_VGA 16
31: #define DLGSCRN_TV 17
32: #define DLGSCRN_USEVDIRES 19
33: #define DLGSCRN_WIDTHLESS 21
34: #define DLGSCRN_WIDTHTEXT 22
35: #define DLGSCRN_WIDTHMORE 23
36: #define DLGSCRN_HEIGHTLESS 25
37: #define DLGSCRN_HEIGHTTEXT 26
38: #define DLGSCRN_HEIGHTMORE 27
39: #define DLGSCRN_BPP1 29
40: #define DLGSCRN_BPP2 30
41: #define DLGSCRN_BPP4 31
42: #define DLGSCRN_ONCHANGE 34
1.1.1.6 root 43: #define DLGSCRN_CAPTURE 35
44: #define DLGSCRN_RECANIM 36
45: #define DLGSCRN_EXIT 37
1.1.1.5 root 46:
47: #define ITEMS_IN_ARRAY(a) (sizeof(a)/sizeof(a[0]))
48:
49: /* needs to match Frame skip values in screendlg[]! */
1.1.1.6 root 50: static const int skip_frames[] = { 0, 1, 2, 4, AUTO_FRAMESKIP_LIMIT };
1.1.1.5 root 51:
52: /* Strings for VDI resolution width and height */
53: static char sVdiWidth[5];
54: static char sVdiHeight[5];
1.1 root 55:
56: /* The screen dialog: */
57: static SGOBJ screendlg[] =
58: {
1.1.1.5 root 59: { SGBOX, 0, 0, 0,0, 50,25, NULL },
1.1.1.2 root 60:
1.1.1.5 root 61: { SGBOX, 0, 0, 1,1, 48,7, NULL },
62: { SGTEXT, 0, 0, 18,1, 14,1, "Screen options" },
63: { SGCHECKBOX, 0, 0, 4,3, 12,1, "Fullscreen" },
64: { SGCHECKBOX, 0, 0, 4,4, 13,1, "Use borders" },
1.1.1.6 root 65: { SGCHECKBOX, 0, 0, 22,3, 18,1, "Zoom ST-low res." },
66: { SGCHECKBOX, 0, 0, 22,4, 13,1, "Statusbar" },
1.1.1.5 root 67: { SGTEXT, 0, 0, 4,6, 9,1, "Frame skip:" },
68: { SGRADIOBUT, 0, 0, 17,6, 5,1, "Off" },
69: { SGRADIOBUT, 0, 0, 24,6, 3,1, "1" },
70: { SGRADIOBUT, 0, 0, 29,6, 3,1, "2" },
71: { SGRADIOBUT, 0, 0, 35,6, 3,1, "4" },
1.1.1.6 root 72: { SGRADIOBUT, 0, 0, 40,6, 3,1, "Auto" },
1.1.1.5 root 73: { SGTEXT, 0, 0, 4,7, 8,1, "Monitor:" },
74: { SGRADIOBUT, 0, 0, 14,7, 6,1, "Mono" },
75: { SGRADIOBUT, 0, 0, 22,7, 5,1, "RGB" },
76: { SGRADIOBUT, 0, 0, 29,7, 5,1, "VGA" },
77: { SGRADIOBUT, 0, 0, 36,7, 4,1, "TV" },
78:
79: { SGBOX, 0, 0, 1,9, 48,6, NULL },
1.1.1.6 root 80: { SGCHECKBOX, 0, 0, 4,10, 33,1, "Use extended GEM VDI resolution" },
81: { SGTEXT, 0, 0, 4,12, 11,1, "Resolution:" },
1.1.1.5 root 82: { SGBUTTON, 0, 0, 18,12, 1,1, "\x04" }, /* Arrow left */
83: { SGTEXT, 0, 0, 20,12, 4,1, sVdiWidth },
84: { SGBUTTON, 0, 0, 25,12, 1,1, "\x03" }, /* Arrow right */
85: { SGTEXT, 0, 0, 28,12, 1,1, "*" },
86: { SGBUTTON, 0, 0, 31,12, 1,1, "\x04" }, /* Arrow left */
87: { SGTEXT, 0, 0, 33,12, 4,1, sVdiHeight },
88: { SGBUTTON, 0, 0, 38,12, 1,1, "\x03" }, /* Arrow right */
89:
1.1.1.6 root 90: { SGTEXT, 0, 0, 4,13, 12,1, "Color Depth:" },
1.1.1.5 root 91: { SGRADIOBUT, SG_EXIT, 0, 17,13, 7,1, "1 bpp" },
92: { SGRADIOBUT, SG_EXIT, 0, 26,13, 7,1, "2 bpp" },
93: { SGRADIOBUT, SG_EXIT, 0, 35,13, 7,1, "4 bpp" },
94:
95: { SGBOX, 0, 0, 1,16, 48,6, NULL },
96: { SGTEXT, 0, 0, 18,16, 14,1, "Screen capture" },
97: { SGCHECKBOX, 0, 0, 4,18, 39,1, "Capture only when display changes" },
98: { SGBUTTON, 0, 0, 6,20, 16,1, "Capture screen" },
99: { SGBUTTON, 0, 0, 26,20, 18,1, NULL },
1.1.1.2 root 100:
1.1.1.5 root 101: { SGBUTTON, SG_DEFAULT, 0, 15,23, 20,1, "Back to main menu" },
102: { -1, 0, 0, 0,0, 0,0, NULL }
1.1 root 103: };
104:
105:
1.1.1.5 root 106: static int nVdiStepX, nVdiStepY; /* VDI resolution changing steps */
107:
108:
109: /**
110: * Set width and height stepping for VDI resolution changing.
111: * Depending on the color depth we can only change the VDI resolution
112: * in certain steps:
113: * - The screen width must be dividable by 16 bytes (i.e. 128 pixels in
114: * monochrome, 32 pixels in 16 color mode), or the text mode scrolling
115: * function of TOS will fail.
116: * - The screen height must be a multiple of the character cell height
117: * (i.e. 16 pixels in monochrome, 8 pixels in color mode).
118: */
119: static void DlgScreen_SetStepping(void)
120: {
121: if (screendlg[DLGSCRN_BPP1].state & SG_SELECTED)
122: {
123: nVdiStepX = 128;
124: nVdiStepY = 16;
125: }
126: else if (screendlg[DLGSCRN_BPP2].state & SG_SELECTED)
127: {
128: nVdiStepX = 64;
129: nVdiStepY = 8;
130: }
131: else
132: {
133: nVdiStepX = 32;
134: nVdiStepY = 8;
135: }
136: }
137:
138:
1.1 root 139: /*-----------------------------------------------------------------------*/
1.1.1.5 root 140: /**
141: * Show and process the screen dialog.
142: */
1.1 root 143: void Dialog_ScreenDlg(void)
144: {
1.1.1.5 root 145: int but, skip = 0;
146: unsigned int i;
1.1.1.8 ! root 147: MONITORTYPE mti;
1.1 root 148:
1.1.1.5 root 149: SDLGui_CenterDlg(screendlg);
1.1 root 150:
1.1.1.5 root 151: /* Set up general screen options in the dialog from actual values: */
1.1 root 152:
1.1.1.6 root 153: if (ConfigureParams.Screen.bFullScreen)
1.1.1.5 root 154: screendlg[DLGSCRN_FULLSCRN].state |= SG_SELECTED;
155: else
156: screendlg[DLGSCRN_FULLSCRN].state &= ~SG_SELECTED;
157:
1.1.1.6 root 158: if (ConfigureParams.Screen.bAllowOverscan)
1.1.1.5 root 159: screendlg[DLGSCRN_OVERSCAN].state |= SG_SELECTED;
160: else
161: screendlg[DLGSCRN_OVERSCAN].state &= ~SG_SELECTED;
162:
1.1.1.6 root 163: if (ConfigureParams.Screen.bShowStatusbar)
164: screendlg[DLGSCRN_STATUSBAR].state |= SG_SELECTED;
1.1.1.5 root 165: else
1.1.1.6 root 166: screendlg[DLGSCRN_STATUSBAR].state &= ~SG_SELECTED;
1.1.1.5 root 167:
1.1.1.6 root 168: if (ConfigureParams.Screen.bZoomLowRes)
1.1.1.5 root 169: screendlg[DLGSCRN_ZOOMLOWRES].state |= SG_SELECTED;
170: else
171: screendlg[DLGSCRN_ZOOMLOWRES].state &= ~SG_SELECTED;
172:
173: for (i = 0; i < ITEMS_IN_ARRAY(skip_frames); i++)
174: {
1.1.1.6 root 175: if (ConfigureParams.Screen.nFrameSkips >= skip_frames[i])
1.1.1.5 root 176: skip = i;
177: screendlg[i+DLGSCRN_SKIP0].state &= ~SG_SELECTED;
178: }
179: screendlg[DLGSCRN_SKIP0+skip].state |= SG_SELECTED;
180:
181: for (i = DLGSCRN_MONO; i <= DLGSCRN_TV; i++)
182: screendlg[i].state &= ~SG_SELECTED;
1.1.1.6 root 183: screendlg[DLGSCRN_MONO+ConfigureParams.Screen.nMonitorType].state |= SG_SELECTED;
1.1.1.5 root 184:
185: /* Initialize VDI resolution options: */
186:
1.1.1.6 root 187: if (ConfigureParams.Screen.bUseExtVdiResolutions)
1.1.1.5 root 188: screendlg[DLGSCRN_USEVDIRES].state |= SG_SELECTED;
189: else
190: screendlg[DLGSCRN_USEVDIRES].state &= ~SG_SELECTED;
191: for (i=0; i<3; i++)
192: screendlg[DLGSCRN_BPP1 + i].state &= ~SG_SELECTED;
1.1.1.6 root 193: screendlg[DLGSCRN_BPP1 + ConfigureParams.Screen.nVdiColors - GEMCOLOR_2].state |= SG_SELECTED;
194: sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
195: sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
1.1.1.5 root 196: DlgScreen_SetStepping();
197:
198: /* Initialize screen capture options: */
199:
1.1.1.6 root 200: if (ConfigureParams.Screen.bCaptureChange)
1.1.1.5 root 201: screendlg[DLGSCRN_ONCHANGE].state |= SG_SELECTED;
202: else
203: screendlg[DLGSCRN_ONCHANGE].state &= ~SG_SELECTED;
204:
205: if (ScreenSnapShot_AreWeRecording())
206: screendlg[DLGSCRN_RECANIM].txt = "Stop recording";
207: else
208: screendlg[DLGSCRN_RECANIM].txt = "Record animation";
209:
210: /* The screen dialog main loop */
211: do
212: {
213: but = SDLGui_DoDialog(screendlg, NULL);
214: switch (but)
215: {
216: case DLGSCRN_WIDTHLESS:
1.1.1.6 root 217: ConfigureParams.Screen.nVdiWidth = VDI_Limit(ConfigureParams.Screen.nVdiWidth - nVdiStepX,
1.1.1.5 root 218: nVdiStepX, MIN_VDI_WIDTH, MAX_VDI_WIDTH);
1.1.1.6 root 219: sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
1.1.1.5 root 220: break;
221: case DLGSCRN_WIDTHMORE:
1.1.1.6 root 222: ConfigureParams.Screen.nVdiWidth = VDI_Limit(ConfigureParams.Screen.nVdiWidth + nVdiStepX,
1.1.1.5 root 223: nVdiStepX, MIN_VDI_WIDTH, MAX_VDI_WIDTH);
1.1.1.6 root 224: sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
1.1.1.5 root 225: break;
226:
227: case DLGSCRN_HEIGHTLESS:
1.1.1.6 root 228: ConfigureParams.Screen.nVdiHeight = VDI_Limit(ConfigureParams.Screen.nVdiHeight - nVdiStepY,
1.1.1.5 root 229: nVdiStepY, MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
1.1.1.6 root 230: sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
1.1.1.5 root 231: break;
232: case DLGSCRN_HEIGHTMORE:
1.1.1.6 root 233: ConfigureParams.Screen.nVdiHeight = VDI_Limit(ConfigureParams.Screen.nVdiHeight + nVdiStepY,
1.1.1.5 root 234: nVdiStepY, MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
1.1.1.6 root 235: sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
1.1.1.5 root 236: break;
237:
238: case DLGSCRN_BPP1:
239: case DLGSCRN_BPP2:
240: case DLGSCRN_BPP4:
241: DlgScreen_SetStepping();
242: /* Align resolution to actual conditions: */
1.1.1.6 root 243: ConfigureParams.Screen.nVdiWidth = VDI_Limit(ConfigureParams.Screen.nVdiWidth, nVdiStepX,
1.1.1.5 root 244: MIN_VDI_WIDTH, MAX_VDI_WIDTH);
1.1.1.6 root 245: ConfigureParams.Screen.nVdiHeight = VDI_Limit(ConfigureParams.Screen.nVdiHeight, nVdiStepY,
1.1.1.5 root 246: MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
1.1.1.6 root 247: sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
248: sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
1.1.1.5 root 249: break;
250:
251: case DLGSCRN_CAPTURE:
252: SDL_UpdateRect(sdlscrn, 0,0,0,0);
253: ScreenSnapShot_SaveScreen();
254: break;
255: case DLGSCRN_RECANIM:
256: if (ScreenSnapShot_AreWeRecording())
257: {
258: screendlg[DLGSCRN_RECANIM].txt = "Record animation";
259: ScreenSnapShot_EndRecording();
260: }
261: else
262: {
263: screendlg[DLGSCRN_RECANIM].txt = "Stop recording";
1.1.1.6 root 264: ConfigureParams.Screen.bCaptureChange = (screendlg[DLGSCRN_ONCHANGE].state & SG_SELECTED);
265: ScreenSnapShot_BeginRecording(ConfigureParams.Screen.bCaptureChange);
1.1.1.5 root 266: }
267: break;
268: }
269: }
270: while (but != DLGSCRN_EXIT && but != SDLGUI_QUIT
271: && but != SDLGUI_ERROR && !bQuitProgram);
272:
273: /* Read new values from dialog: */
274:
1.1.1.6 root 275: ConfigureParams.Screen.bFullScreen = (screendlg[DLGSCRN_FULLSCRN].state & SG_SELECTED);
276: ConfigureParams.Screen.bAllowOverscan = (screendlg[DLGSCRN_OVERSCAN].state & SG_SELECTED);
1.1.1.5 root 277:
1.1.1.6 root 278: if (screendlg[DLGSCRN_STATUSBAR].state & SG_SELECTED)
1.1.1.8 ! root 279: ConfigureParams.Screen.bShowStatusbar = true;
1.1.1.5 root 280: else
1.1.1.8 ! root 281: ConfigureParams.Screen.bShowStatusbar = false;
1.1.1.5 root 282:
283: if (screendlg[DLGSCRN_ZOOMLOWRES].state & SG_SELECTED)
1.1.1.8 ! root 284: ConfigureParams.Screen.bZoomLowRes = true;
1.1.1.5 root 285: else
1.1.1.8 ! root 286: ConfigureParams.Screen.bZoomLowRes = false;
1.1.1.5 root 287:
1.1.1.6 root 288: ConfigureParams.Screen.bUseExtVdiResolutions = (screendlg[DLGSCRN_USEVDIRES].state & SG_SELECTED);
1.1.1.5 root 289: for (i = DLGSCRN_SKIP0; i <= DLGSCRN_SKIP4; i++)
290: {
291: if (screendlg[i].state & SG_SELECTED)
292: {
1.1.1.6 root 293: ConfigureParams.Screen.nFrameSkips = skip_frames[i-DLGSCRN_SKIP0];
1.1.1.5 root 294: break;
295: }
296: }
1.1.1.8 ! root 297: for (mti = MONITOR_TYPE_MONO; mti <= MONITOR_TYPE_TV; mti++)
1.1.1.5 root 298: {
1.1.1.8 ! root 299: if (screendlg[mti + DLGSCRN_MONO].state & SG_SELECTED)
1.1.1.5 root 300: {
1.1.1.8 ! root 301: ConfigureParams.Screen.nMonitorType = mti;
1.1.1.5 root 302: break;
303: }
304: }
305: for (i=0; i<3; i++)
306: {
307: if (screendlg[DLGSCRN_BPP1 + i].state & SG_SELECTED)
1.1.1.6 root 308: ConfigureParams.Screen.nVdiColors = GEMCOLOR_2 + i;
1.1.1.5 root 309: }
1.1.1.2 root 310:
1.1.1.6 root 311: ConfigureParams.Screen.bCaptureChange = (screendlg[DLGSCRN_ONCHANGE].state & SG_SELECTED);
1.1 root 312: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.