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