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