|
|
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:
7: Atari monitor and Hatari window settings.
8: */
9: const char DlgScreen_fileid[] = "Hatari dlgScreen.c : " __DATE__ " " __TIME__;
10:
11: #include "main.h"
12: #include "configuration.h"
13: #include "dialog.h"
14: #include "sdlgui.h"
15: #include "screen.h"
16: #include "screenSnapShot.h"
17: #include "resolution.h"
18: #include "video.h"
19: #include "avi_record.h"
20: #include "statusbar.h"
21: #include "clocks_timings.h"
22:
23: #define ITEMS_IN_ARRAY(a) (sizeof(a)/sizeof(a[0]))
24:
25:
26: /* The Monitor dialog: */
27: #define DLGSCRN_MONO 3
28: #define DLGSCRN_RGB 4
29: #define DLGSCRN_VGA 5
30: #define DLGSCRN_TV 6
31: #define DLGSCRN_OVERSCAN 7
32: #define DLGSCRN_USEVDIRES 9
33: #define DLGSCRN_VDI_WLESS 11
34: #define DLGSCRN_VDI_WTEXT 12
35: #define DLGSCRN_VDI_WMORE 13
36: #define DLGSCRN_VDI_HLESS 15
37: #define DLGSCRN_VDI_HTEXT 16
38: #define DLGSCRN_VDI_HMORE 17
39: #define DLGSCRN_BPP1 18
40: #define DLGSCRN_BPP2 19
41: #define DLGSCRN_BPP4 20
42: #define DLGSCRN_EXIT_MONITOR 21
43:
44: /* Strings for VDI resolution width and height */
45: static char sVdiWidth[5];
46: static char sVdiHeight[5];
47:
48: static SGOBJ monitordlg[] =
49: {
50: { SGBOX, 0, 0, 0,0, 34,18, NULL },
51:
52: { SGBOX, 0, 0, 1,1, 32,6, NULL },
53: { SGTEXT, 0, 0, 10,1, 14,1, "Atari monitor" },
54: { SGRADIOBUT, 0, 0, 4,3, 6,1, "Mono" },
55: { SGRADIOBUT, 0, 0, 12,3, 6,1, "RGB" },
56: { SGRADIOBUT, 0, 0, 19,3, 6,1, "VGA" },
57: { SGRADIOBUT, 0, 0, 26,3, 6,1, "TV" },
58: { SGCHECKBOX, 0, 0, 6,5, 22,1, "Show ST/STE borders" },
59:
60: { SGBOX, 0, 0, 1,8, 32,7, NULL },
61: { SGCHECKBOX, 0, 0, 4,9, 33,1, "Use extended VDI screen" },
62: { SGTEXT, 0, 0, 4,11, 5,1, "Size:" },
63: { SGBUTTON, 0, 0, 6,12, 1,1, "\x04" }, /* Arrow left */
64: { SGTEXT, 0, 0, 8,12, 4,1, sVdiWidth },
65: { SGBUTTON, 0, 0, 13,12, 1,1, "\x03" }, /* Arrow right */
66: { SGTEXT, 0, 0, 4,13, 1,1, "x" },
67: { SGBUTTON, 0, 0, 6,13, 1,1, "\x04" }, /* Arrow left */
68: { SGTEXT, 0, 0, 8,13, 4,1, sVdiHeight },
69: { SGBUTTON, 0, 0, 13,13, 1,1, "\x03" }, /* Arrow right */
70:
71: { SGRADIOBUT, SG_EXIT, 0, 18,11, 11,1, " 2 colors" },
72: { SGRADIOBUT, SG_EXIT, 0, 18,12, 11,1, " 4 colors" },
73: { SGRADIOBUT, SG_EXIT, 0, 18,13, 11,1, "16 colors" },
74:
75: { SGBUTTON, SG_DEFAULT, 0, 7,16, 20,1, "Back to main menu" },
76: { -1, 0, 0, 0,0, 0,0, NULL }
77: };
78:
79:
80: /* The window dialog: */
81: #define DLGSCRN_FULLSCRN 3
82: #define DLGSCRN_STATUSBAR 5
83: #define DLGSCRN_DRIVELED 6
84: #define DLGSCRN_NONE 7
85: #define DLGSCRN_SKIP0 9
86: #define DLGSCRN_SKIP1 10
87: #define DLGSCRN_SKIP2 11
88: #define DLGSCRN_SKIP3 12
89: #define DLGSCRN_SKIP4 13
90: #define DLGSCRN_KEEP_RES 15
91: #define DLGSCRN_MAX_WLESS 18
92: #define DLGSCRN_MAX_WTEXT 19
93: #define DLGSCRN_MAX_WMORE 20
94: #define DLGSCRN_MAX_HLESS 22
95: #define DLGSCRN_MAX_HTEXT 23
96: #define DLGSCRN_MAX_HMORE 24
97: #define DLGSCRN_CROP 27
98: #define DLGSCRN_CAPTURE 28
99: #define DLGSCRN_RECANIM 29
100: #define DLGSCRN_EXIT_WINDOW 30
101:
102: /* needs to match Frame skip values in windowdlg[]! */
103: static const int skip_frames[] = { 0, 1, 2, 4, AUTO_FRAMESKIP_LIMIT };
104:
105: /* Strings for doubled resolution max width and height */
106: static char sMaxWidth[5];
107: static char sMaxHeight[5];
108:
109: #define MAX_SIZE_STEP 8
110:
111: /* The window dialog: */
112: static SGOBJ windowdlg[] =
113: {
114: { SGBOX, 0, 0, 0,0, 52,20, NULL },
115:
116: { SGBOX, 0, 0, 1,1, 50,10, NULL },
117: { SGTEXT, 0, 0, 4,2, 20,1, "Hatari screen options" },
118: { SGCHECKBOX, 0, 0, 4,4, 12,1, "Fullscreen" },
119: { SGTEXT, 0, 0, 4,6, 12,1, "Indicators:" },
120: { SGRADIOBUT, 0, 0, 6,7, 11,1, "Statusbar" },
121: { SGRADIOBUT, 0, 0, 6,8, 11,1, "Drive led" },
122: { SGRADIOBUT, 0, 0, 6,9, 11,1, "None" },
123: { SGTEXT, 0, 0, 19,4, 12,1, "Frame skip:" },
124: { SGRADIOBUT, 0, 0, 21,5, 7,1, "Off" },
125: { SGRADIOBUT, 0, 0, 21,6, 7,1, "1" },
126: { SGRADIOBUT, 0, 0, 21,7, 7,1, "2" },
127: { SGRADIOBUT, 0, 0, 21,8, 7,1, "4" },
128: { SGRADIOBUT, 0, 0, 21,9, 7,1, "Auto" },
129: { SGTEXT, 0, 0, 33,2, 15,1, "Falcon/TT only:" },
130: { SGCHECKBOX, 0, 0, 33,4, 14,2, "Keep desktop" },
131: { SGTEXT, 0, 0, 35,5, 12,1, "resolution" },
132: { SGTEXT, 0, 0, 33,7, 15,1, "Max zoomed win:" },
133: { SGBUTTON, 0, 0, 35,8, 1,1, "\x04" }, /* Arrow left */
134: { SGTEXT, 0, 0, 37,8, 4,1, sMaxWidth },
135: { SGBUTTON, 0, 0, 43,8, 1,1, "\x03" }, /* Arrow right */
136: { SGTEXT, 0, 0, 33,9, 1,1, "x" },
137: { SGBUTTON, 0, 0, 35,9, 1,1, "\x04" }, /* Arrow left */
138: { SGTEXT, 0, 0, 37,9, 4,1, sMaxHeight },
139: { SGBUTTON, 0, 0, 43,9, 1,1, "\x03" }, /* Arrow right */
140:
141: { SGBOX, 0, 0, 1,12, 50,5, NULL },
142: { SGTEXT, 0, 0, 7,13, 16,1, "Screen capture" },
143: { SGCHECKBOX, 0, 0, 8,15, 16,1, "Crop statusbar" },
144: { SGBUTTON, 0, 0, 29,13, 14,1, " Screenshot " },
145: { SGBUTTON, 0, 0, 29,15, 14,1, " Record AVI " },
146:
147: { SGBUTTON, SG_DEFAULT, 0, 17,18, 20,1, "Back to main menu" },
148: { -1, 0, 0, 0,0, 0,0, NULL }
149: };
150:
151:
152: /* ---------------------------------------------------------------- */
153:
154: static int nVdiStepX, nVdiStepY; /* VDI resolution changing steps */
155:
156: /**
157: * Set width and height stepping for VDI resolution changing.
158: * Depending on the color depth we can only change the VDI resolution
159: * in certain steps:
160: * - The screen width must be dividable by 16 bytes (i.e. 128 pixels in
161: * monochrome, 32 pixels in 16 color mode), or the text mode scrolling
162: * function of TOS will fail.
163: * - The screen height must be a multiple of the character cell height
164: * (i.e. 16 pixels in monochrome, 8 pixels in color mode).
165: */
166: static void DlgMonitor_SetVdiStepping(void)
167: {
168: if (monitordlg[DLGSCRN_BPP1].state & SG_SELECTED)
169: {
170: nVdiStepX = 128;
171: nVdiStepY = 16;
172: }
173: else if (monitordlg[DLGSCRN_BPP2].state & SG_SELECTED)
174: {
175: nVdiStepX = 64;
176: nVdiStepY = 8;
177: }
178: else
179: {
180: nVdiStepX = 32;
181: nVdiStepY = 8;
182: }
183: }
184:
185:
186: /*-----------------------------------------------------------------------*/
187: /**
188: * Show and process the monitor dialog.
189: */
190: void Dialog_MonitorDlg(void)
191: {
192: int but;
193: unsigned int i;
194: MONITORTYPE mti;
195:
196: SDLGui_CenterDlg(monitordlg);
197:
198: /* Set up general monitor options in the dialog from actual values: */
199:
200: if (ConfigureParams.Screen.bAllowOverscan)
201: monitordlg[DLGSCRN_OVERSCAN].state |= SG_SELECTED;
202: else
203: monitordlg[DLGSCRN_OVERSCAN].state &= ~SG_SELECTED;
204:
205: for (i = DLGSCRN_MONO; i <= DLGSCRN_TV; i++)
206: monitordlg[i].state &= ~SG_SELECTED;
207: monitordlg[DLGSCRN_MONO+ConfigureParams.Screen.nMonitorType].state |= SG_SELECTED;
208:
209: /* Initialize VDI resolution options: */
210:
211: if (ConfigureParams.Screen.bUseExtVdiResolutions)
212: monitordlg[DLGSCRN_USEVDIRES].state |= SG_SELECTED;
213: else
214: monitordlg[DLGSCRN_USEVDIRES].state &= ~SG_SELECTED;
215: for (i=0; i<3; i++)
216: monitordlg[DLGSCRN_BPP1 + i].state &= ~SG_SELECTED;
217: monitordlg[DLGSCRN_BPP1 + ConfigureParams.Screen.nVdiColors - 16].state |= SG_SELECTED;
218: sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
219: sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
220: DlgMonitor_SetVdiStepping();
221:
222: /* The monitor dialog main loop */
223: do
224: {
225: but = SDLGui_DoDialog(monitordlg, NULL);
226: switch (but)
227: {
228: case DLGSCRN_VDI_WLESS:
229: // ConfigureParams.Screen.nVdiWidth = VDI_Limit(ConfigureParams.Screen.nVdiWidth - nVdiStepX,
230: // nVdiStepX, MIN_VDI_WIDTH, MAX_VDI_WIDTH);
231: sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
232: break;
233: case DLGSCRN_VDI_WMORE:
234: // ConfigureParams.Screen.nVdiWidth = VDI_Limit(ConfigureParams.Screen.nVdiWidth + nVdiStepX,
235: // nVdiStepX, MIN_VDI_WIDTH, MAX_VDI_WIDTH);
236: sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
237: break;
238:
239: case DLGSCRN_VDI_HLESS:
240: // ConfigureParams.Screen.nVdiHeight = VDI_Limit(ConfigureParams.Screen.nVdiHeight - nVdiStepY,
241: // nVdiStepY, MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
242: sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
243: break;
244: case DLGSCRN_VDI_HMORE:
245: // ConfigureParams.Screen.nVdiHeight = VDI_Limit(ConfigureParams.Screen.nVdiHeight + nVdiStepY,
246: // nVdiStepY, MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
247: sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
248: break;
249:
250: case DLGSCRN_BPP1:
251: case DLGSCRN_BPP2:
252: case DLGSCRN_BPP4:
253: DlgMonitor_SetVdiStepping();
254: /* Align resolution to actual conditions: */
255: // ConfigureParams.Screen.nVdiWidth = VDI_Limit(ConfigureParams.Screen.nVdiWidth, nVdiStepX,
256: // MIN_VDI_WIDTH, MAX_VDI_WIDTH);
257: // ConfigureParams.Screen.nVdiHeight = VDI_Limit(ConfigureParams.Screen.nVdiHeight, nVdiStepY,
258: // MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
259: sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
260: sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
261: break;
262: }
263: }
264: while (but != DLGSCRN_EXIT_MONITOR && but != SDLGUI_QUIT
265: && but != SDLGUI_ERROR && !bQuitProgram);
266:
267: /* Read new values from dialog: */
268:
269: // ConfigureParams.Screen.bAllowOverscan = (monitordlg[DLGSCRN_OVERSCAN].state & SG_SELECTED);
270:
271: for (mti = MONITOR_TYPE_MONO; mti <= MONITOR_TYPE_TV; mti++)
272: {
273: if (monitordlg[mti + DLGSCRN_MONO].state & SG_SELECTED)
274: {
275: ConfigureParams.Screen.nMonitorType = mti;
276: break;
277: }
278: }
279:
280: ConfigureParams.Screen.bUseExtVdiResolutions = (monitordlg[DLGSCRN_USEVDIRES].state & SG_SELECTED);
281: for (i=0; i<3; i++)
282: {
283: // if (monitordlg[DLGSCRN_BPP1 + i].state & SG_SELECTED)
284: // ConfigureParams.Screen.nVdiColors = GEMCOLOR_2 + i;
285: }
286: }
287:
288:
289: /*-----------------------------------------------------------------------*/
290: /**
291: * Show and process the window dialog.
292: */
293: void Dialog_WindowDlg(void)
294: {
295: int deskw, deskh, but, skip = 0;
296: unsigned int i;
297:
298: SDLGui_CenterDlg(windowdlg);
299:
300: /* Set up general window options in the dialog from actual values: */
301:
302: if (ConfigureParams.Screen.bFullScreen)
303: windowdlg[DLGSCRN_FULLSCRN].state |= SG_SELECTED;
304: else
305: windowdlg[DLGSCRN_FULLSCRN].state &= ~SG_SELECTED;
306:
307: // if (ConfigureParams.Screen.bKeepResolution)
308: // windowdlg[DLGSCRN_KEEP_RES].state |= SG_SELECTED;
309: // else
310: windowdlg[DLGSCRN_KEEP_RES].state &= ~SG_SELECTED;
311:
312: windowdlg[DLGSCRN_STATUSBAR].state |= SG_SELECTED;
313:
314: windowdlg[DLGSCRN_STATUSBAR].state &= ~SG_SELECTED;
315: windowdlg[DLGSCRN_DRIVELED].state &= ~SG_SELECTED;
316: windowdlg[DLGSCRN_NONE].state &= ~SG_SELECTED;
317:
318: if (ConfigureParams.Screen.bShowStatusbar)
319: windowdlg[DLGSCRN_STATUSBAR].state |= SG_SELECTED;
320: else if (ConfigureParams.Screen.bShowDriveLed)
321: windowdlg[DLGSCRN_DRIVELED].state |= SG_SELECTED;
322:
323: for (i = 0; i < ITEMS_IN_ARRAY(skip_frames); i++)
324: {
325: if (ConfigureParams.Screen.nFrameSkips >= skip_frames[i])
326: skip = i;
327: windowdlg[i+DLGSCRN_SKIP0].state &= ~SG_SELECTED;
328: }
329: windowdlg[DLGSCRN_SKIP0+skip].state |= SG_SELECTED;
330:
331: Resolution_GetDesktopSize(&deskw, &deskh);
332: sprintf(sMaxWidth, "%4i", ConfigureParams.Screen.nMaxWidth);
333: sprintf(sMaxHeight, "%4i", ConfigureParams.Screen.nMaxHeight);
334:
335: /* Initialize window capture options: */
336:
337: // if (ConfigureParams.Screen.bCrop)
338: // windowdlg[DLGSCRN_CROP].state |= SG_SELECTED;
339: // else
340: windowdlg[DLGSCRN_CROP].state &= ~SG_SELECTED;
341:
342: /* The window dialog main loop */
343: do
344: {
345: but = SDLGui_DoDialog(windowdlg, NULL);
346: switch (but)
347: {
348: case DLGSCRN_MAX_WLESS:
349: // ConfigureParams.Screen.nMaxWidth = VDI_Limit(ConfigureParams.Screen.nMaxWidth - MAX_SIZE_STEP,
350: // MAX_SIZE_STEP, MIN_VDI_WIDTH, deskw);
351: sprintf(sMaxWidth, "%4i", ConfigureParams.Screen.nMaxWidth);
352: break;
353: case DLGSCRN_MAX_WMORE:
354: // ConfigureParams.Screen.nMaxWidth = VDI_Limit(ConfigureParams.Screen.nMaxWidth + MAX_SIZE_STEP,
355: // MAX_SIZE_STEP, MIN_VDI_WIDTH, deskw);
356: sprintf(sMaxWidth, "%4i", ConfigureParams.Screen.nMaxWidth);
357: break;
358:
359: case DLGSCRN_MAX_HLESS:
360: // ConfigureParams.Screen.nMaxHeight = VDI_Limit(ConfigureParams.Screen.nMaxHeight - MAX_SIZE_STEP,
361: // MAX_SIZE_STEP, MIN_VDI_HEIGHT, deskh);
362: sprintf(sMaxHeight, "%4i", ConfigureParams.Screen.nMaxHeight);
363: break;
364: case DLGSCRN_MAX_HMORE:
365: // ConfigureParams.Screen.nMaxHeight = VDI_Limit(ConfigureParams.Screen.nMaxHeight + MAX_SIZE_STEP,
366: // MAX_SIZE_STEP, MIN_VDI_HEIGHT, deskh);
367: sprintf(sMaxHeight, "%4i", ConfigureParams.Screen.nMaxHeight);
368: break;
369:
370: case DLGSCRN_CAPTURE:
371: SDL_UpdateRect(sdlscrn, 0,0,0,0);
372: // ConfigureParams.Screen.bCrop = (windowdlg[DLGSCRN_CROP].state & SG_SELECTED);
373: ScreenSnapShot_SaveScreen();
374: break;
375:
376: case DLGSCRN_RECANIM:
377: break;
378: }
379: }
380: while (but != DLGSCRN_EXIT_WINDOW && but != SDLGUI_QUIT
381: && but != SDLGUI_ERROR && !bQuitProgram);
382:
383: /* Read new values from dialog: */
384:
385: ConfigureParams.Screen.bFullScreen = (windowdlg[DLGSCRN_FULLSCRN].state & SG_SELECTED);
386:
387: if (windowdlg[DLGSCRN_STATUSBAR].state & SG_SELECTED)
388: ConfigureParams.Screen.bShowStatusbar = true;
389: else
390: ConfigureParams.Screen.bShowStatusbar = false;
391:
392: for (i = DLGSCRN_SKIP0; i <= DLGSCRN_SKIP4; i++)
393: {
394: if (windowdlg[i].state & SG_SELECTED)
395: {
396: ConfigureParams.Screen.nFrameSkips = skip_frames[i-DLGSCRN_SKIP0];
397: break;
398: }
399: }
400:
401: // ConfigureParams.Screen.bCrop = (windowdlg[DLGSCRN_CROP].state & SG_SELECTED);
402: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.