|
|
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.5 ! root 7: const char DlgScreen_rcsid[] = "Hatari $Id: dlgScreen.c,v 1.17 2008/03/01 22:37:44 eerot Exp $";
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 root 16:
17:
18: #define DLGSCRN_FULLSCRN 3
1.1.1.5 ! root 19: #define DLGSCRN_OVERSCAN 4
! 20: #define DLGSCRN_ZOOMLOWRES 5
! 21: #define DLGSCRN_8BPP 6
! 22: #define DLGSCRN_SKIP0 8
! 23: #define DLGSCRN_SKIP1 9
! 24: #define DLGSCRN_SKIP2 10
! 25: #define DLGSCRN_SKIP3 11
! 26: #define DLGSCRN_SKIP4 12
! 27: #define DLGSCRN_MONO 14
! 28: #define DLGSCRN_RGB 15
! 29: #define DLGSCRN_VGA 16
! 30: #define DLGSCRN_TV 17
! 31: #define DLGSCRN_USEVDIRES 19
! 32: #define DLGSCRN_WIDTHLESS 21
! 33: #define DLGSCRN_WIDTHTEXT 22
! 34: #define DLGSCRN_WIDTHMORE 23
! 35: #define DLGSCRN_HEIGHTLESS 25
! 36: #define DLGSCRN_HEIGHTTEXT 26
! 37: #define DLGSCRN_HEIGHTMORE 27
! 38: #define DLGSCRN_BPP1 29
! 39: #define DLGSCRN_BPP2 30
! 40: #define DLGSCRN_BPP4 31
! 41: #define DLGSCRN_ONCHANGE 34
! 42: #define DLGSCRN_FPSPOPUP 36
! 43: #define DLGSCRN_CAPTURE 37
! 44: #define DLGSCRN_RECANIM 38
! 45: #define DLGSCRN_EXIT 39
! 46:
! 47: #define ITEMS_IN_ARRAY(a) (sizeof(a)/sizeof(a[0]))
! 48:
! 49: /* needs to match Frame skip values in screendlg[]! */
! 50: static const int skip_frames[] = { 0, 1, 2, 4, 8 };
! 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" },
! 65: { SGCHECKBOX, 0, 0, 25,3, 18,1, "Zoom ST-low res." },
! 66: { SGCHECKBOX, 0, 0, 25,4, 13,1, "Force 8 bpp" },
! 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" },
! 72: { SGRADIOBUT, 0, 0, 40,6, 3,1, "8" },
! 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 },
! 80: { SGCHECKBOX, 0, 0, 2,10, 33,1, "Use extended GEM VDI resolution" },
! 81: { SGTEXT, 0, 0, 2,12, 11,1, "Resolution:" },
! 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:
! 90: { SGTEXT, 0, 0, 2,13, 12,1, "Color Depth:" },
! 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: { SGTEXT, 0, 0, 31,19, 4,1, ""/*"FPS:"*/ },
! 99: { SGTEXT/*SGPOPUP*/, 0, 0, 36,19, 3,1, ""/*"25"*/ },
! 100: { SGBUTTON, 0, 0, 6,20, 16,1, "Capture screen" },
! 101: { SGBUTTON, 0, 0, 26,20, 18,1, NULL },
1.1.1.2 root 102:
1.1.1.5 ! root 103: { SGBUTTON, SG_DEFAULT, 0, 15,23, 20,1, "Back to main menu" },
! 104: { -1, 0, 0, 0,0, 0,0, NULL }
1.1 root 105: };
106:
107:
1.1.1.5 ! root 108: static int nVdiStepX, nVdiStepY; /* VDI resolution changing steps */
! 109:
! 110:
! 111: /**
! 112: * Set width and height stepping for VDI resolution changing.
! 113: * Depending on the color depth we can only change the VDI resolution
! 114: * in certain steps:
! 115: * - The screen width must be dividable by 16 bytes (i.e. 128 pixels in
! 116: * monochrome, 32 pixels in 16 color mode), or the text mode scrolling
! 117: * function of TOS will fail.
! 118: * - The screen height must be a multiple of the character cell height
! 119: * (i.e. 16 pixels in monochrome, 8 pixels in color mode).
! 120: */
! 121: static void DlgScreen_SetStepping(void)
! 122: {
! 123: if (screendlg[DLGSCRN_BPP1].state & SG_SELECTED)
! 124: {
! 125: nVdiStepX = 128;
! 126: nVdiStepY = 16;
! 127: }
! 128: else if (screendlg[DLGSCRN_BPP2].state & SG_SELECTED)
! 129: {
! 130: nVdiStepX = 64;
! 131: nVdiStepY = 8;
! 132: }
! 133: else
! 134: {
! 135: nVdiStepX = 32;
! 136: nVdiStepY = 8;
! 137: }
! 138: }
! 139:
! 140:
1.1 root 141: /*-----------------------------------------------------------------------*/
1.1.1.5 ! root 142: /**
! 143: * Show and process the screen dialog.
! 144: */
1.1 root 145: void Dialog_ScreenDlg(void)
146: {
1.1.1.5 ! root 147: int but, skip = 0;
! 148: unsigned int i;
1.1 root 149:
1.1.1.5 ! root 150: SDLGui_CenterDlg(screendlg);
1.1 root 151:
1.1.1.5 ! root 152: /* Set up general screen options in the dialog from actual values: */
1.1 root 153:
1.1.1.5 ! root 154: if (DialogParams.Screen.bFullScreen)
! 155: screendlg[DLGSCRN_FULLSCRN].state |= SG_SELECTED;
! 156: else
! 157: screendlg[DLGSCRN_FULLSCRN].state &= ~SG_SELECTED;
! 158:
! 159: if (DialogParams.Screen.bAllowOverscan)
! 160: screendlg[DLGSCRN_OVERSCAN].state |= SG_SELECTED;
! 161: else
! 162: screendlg[DLGSCRN_OVERSCAN].state &= ~SG_SELECTED;
! 163:
! 164: if (DialogParams.Screen.nForceBpp == 8)
! 165: screendlg[DLGSCRN_8BPP].state |= SG_SELECTED;
! 166: else
! 167: screendlg[DLGSCRN_8BPP].state &= ~SG_SELECTED;
! 168:
! 169: if (DialogParams.Screen.bZoomLowRes)
! 170: screendlg[DLGSCRN_ZOOMLOWRES].state |= SG_SELECTED;
! 171: else
! 172: screendlg[DLGSCRN_ZOOMLOWRES].state &= ~SG_SELECTED;
! 173:
! 174: for (i = 0; i < ITEMS_IN_ARRAY(skip_frames); i++)
! 175: {
! 176: if (DialogParams.Screen.FrameSkips >= skip_frames[i])
! 177: skip = i;
! 178: screendlg[i+DLGSCRN_SKIP0].state &= ~SG_SELECTED;
! 179: }
! 180: screendlg[DLGSCRN_SKIP0+skip].state |= SG_SELECTED;
! 181:
! 182: for (i = DLGSCRN_MONO; i <= DLGSCRN_TV; i++)
! 183: screendlg[i].state &= ~SG_SELECTED;
! 184: screendlg[DLGSCRN_MONO+DialogParams.Screen.MonitorType].state |= SG_SELECTED;
! 185:
! 186: /* Initialize VDI resolution options: */
! 187:
! 188: if (DialogParams.Screen.bUseExtVdiResolutions)
! 189: screendlg[DLGSCRN_USEVDIRES].state |= SG_SELECTED;
! 190: else
! 191: screendlg[DLGSCRN_USEVDIRES].state &= ~SG_SELECTED;
! 192: for (i=0; i<3; i++)
! 193: screendlg[DLGSCRN_BPP1 + i].state &= ~SG_SELECTED;
! 194: screendlg[DLGSCRN_BPP1 + DialogParams.Screen.nVdiColors - GEMCOLOR_2].state |= SG_SELECTED;
! 195: sprintf(sVdiWidth, "%4i", DialogParams.Screen.nVdiWidth);
! 196: sprintf(sVdiHeight, "%4i", DialogParams.Screen.nVdiHeight);
! 197: DlgScreen_SetStepping();
! 198:
! 199: /* Initialize screen capture options: */
! 200:
! 201: if (DialogParams.Screen.bCaptureChange)
! 202: screendlg[DLGSCRN_ONCHANGE].state |= SG_SELECTED;
! 203: else
! 204: screendlg[DLGSCRN_ONCHANGE].state &= ~SG_SELECTED;
! 205:
! 206: if (ScreenSnapShot_AreWeRecording())
! 207: screendlg[DLGSCRN_RECANIM].txt = "Stop recording";
! 208: else
! 209: screendlg[DLGSCRN_RECANIM].txt = "Record animation";
! 210:
! 211: /* The screen dialog main loop */
! 212: do
! 213: {
! 214: but = SDLGui_DoDialog(screendlg, NULL);
! 215: switch (but)
! 216: {
! 217: case DLGSCRN_FPSPOPUP:
! 218: //fprintf(stderr,"Sorry, popup menus don't work yet\n");
! 219: break;
! 220:
! 221: case DLGSCRN_WIDTHLESS:
! 222: DialogParams.Screen.nVdiWidth = VDI_Limit(DialogParams.Screen.nVdiWidth - nVdiStepX,
! 223: nVdiStepX, MIN_VDI_WIDTH, MAX_VDI_WIDTH);
! 224: sprintf(sVdiWidth, "%4i", DialogParams.Screen.nVdiWidth);
! 225: break;
! 226: case DLGSCRN_WIDTHMORE:
! 227: DialogParams.Screen.nVdiWidth = VDI_Limit(DialogParams.Screen.nVdiWidth + nVdiStepX,
! 228: nVdiStepX, MIN_VDI_WIDTH, MAX_VDI_WIDTH);
! 229: sprintf(sVdiWidth, "%4i", DialogParams.Screen.nVdiWidth);
! 230: break;
! 231:
! 232: case DLGSCRN_HEIGHTLESS:
! 233: DialogParams.Screen.nVdiHeight = VDI_Limit(DialogParams.Screen.nVdiHeight - nVdiStepY,
! 234: nVdiStepY, MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
! 235: sprintf(sVdiHeight, "%4i", DialogParams.Screen.nVdiHeight);
! 236: break;
! 237: case DLGSCRN_HEIGHTMORE:
! 238: DialogParams.Screen.nVdiHeight = VDI_Limit(DialogParams.Screen.nVdiHeight + nVdiStepY,
! 239: nVdiStepY, MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
! 240: sprintf(sVdiHeight, "%4i", DialogParams.Screen.nVdiHeight);
! 241: break;
! 242:
! 243: case DLGSCRN_BPP1:
! 244: case DLGSCRN_BPP2:
! 245: case DLGSCRN_BPP4:
! 246: DlgScreen_SetStepping();
! 247: /* Align resolution to actual conditions: */
! 248: DialogParams.Screen.nVdiWidth = VDI_Limit(DialogParams.Screen.nVdiWidth, nVdiStepX,
! 249: MIN_VDI_WIDTH, MAX_VDI_WIDTH);
! 250: DialogParams.Screen.nVdiHeight = VDI_Limit(DialogParams.Screen.nVdiHeight, nVdiStepY,
! 251: MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
! 252: sprintf(sVdiWidth, "%4i", DialogParams.Screen.nVdiWidth);
! 253: sprintf(sVdiHeight, "%4i", DialogParams.Screen.nVdiHeight);
! 254: break;
! 255:
! 256: case DLGSCRN_CAPTURE:
! 257: SDL_UpdateRect(sdlscrn, 0,0,0,0);
! 258: ScreenSnapShot_SaveScreen();
! 259: break;
! 260: case DLGSCRN_RECANIM:
! 261: if (ScreenSnapShot_AreWeRecording())
! 262: {
! 263: screendlg[DLGSCRN_RECANIM].txt = "Record animation";
! 264: ScreenSnapShot_EndRecording();
! 265: }
! 266: else
! 267: {
! 268: screendlg[DLGSCRN_RECANIM].txt = "Stop recording";
! 269: DialogParams.Screen.bCaptureChange = (screendlg[DLGSCRN_ONCHANGE].state & SG_SELECTED);
! 270: ScreenSnapShot_BeginRecording(DialogParams.Screen.bCaptureChange, 25);
! 271: }
! 272: break;
! 273: }
! 274: }
! 275: while (but != DLGSCRN_EXIT && but != SDLGUI_QUIT
! 276: && but != SDLGUI_ERROR && !bQuitProgram);
! 277:
! 278: /* Read new values from dialog: */
! 279:
! 280: DialogParams.Screen.bFullScreen = (screendlg[DLGSCRN_FULLSCRN].state & SG_SELECTED);
! 281: DialogParams.Screen.bAllowOverscan = (screendlg[DLGSCRN_OVERSCAN].state & SG_SELECTED);
! 282:
! 283: if (screendlg[DLGSCRN_8BPP].state & SG_SELECTED)
! 284: DialogParams.Screen.nForceBpp = 8;
! 285: else
! 286: /* TODO: disables this setting if it's != 8 */
! 287: DialogParams.Screen.nForceBpp = 0;
! 288:
! 289: if (screendlg[DLGSCRN_ZOOMLOWRES].state & SG_SELECTED)
! 290: DialogParams.Screen.bZoomLowRes = TRUE;
! 291: else
! 292: DialogParams.Screen.bZoomLowRes = FALSE;
! 293:
! 294: DialogParams.Screen.bUseExtVdiResolutions = (screendlg[DLGSCRN_USEVDIRES].state & SG_SELECTED);
! 295: for (i = DLGSCRN_SKIP0; i <= DLGSCRN_SKIP4; i++)
! 296: {
! 297: if (screendlg[i].state & SG_SELECTED)
! 298: {
! 299: DialogParams.Screen.FrameSkips = skip_frames[i-DLGSCRN_SKIP0];
! 300: break;
! 301: }
! 302: }
! 303: for (i = DLGSCRN_MONO; i <= DLGSCRN_TV; i++)
! 304: {
! 305: if (screendlg[i].state & SG_SELECTED)
! 306: {
! 307: DialogParams.Screen.MonitorType = i - DLGSCRN_MONO;
! 308: break;
! 309: }
! 310: }
! 311: for (i=0; i<3; i++)
! 312: {
! 313: if (screendlg[DLGSCRN_BPP1 + i].state & SG_SELECTED)
! 314: DialogParams.Screen.nVdiColors = GEMCOLOR_2 + i;
! 315: }
1.1.1.2 root 316:
1.1.1.5 ! root 317: DialogParams.Screen.bCaptureChange = (screendlg[DLGSCRN_ONCHANGE].state & SG_SELECTED);
1.1 root 318: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.