Annotation of hatari/src/gui-sdl/dlgScreen.c, revision 1.1.1.6

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.6 ! root        7: const char DlgScreen_rcsid[] = "Hatari $Id: dlgScreen.c,v 1.25 2008/11/16 10:23:44 thothy 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.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       root      147: 
1.1.1.5   root      148:        SDLGui_CenterDlg(screendlg);
1.1       root      149: 
1.1.1.5   root      150:        /* Set up general screen options in the dialog from actual values: */
1.1       root      151: 
1.1.1.6 ! root      152:        if (ConfigureParams.Screen.bFullScreen)
1.1.1.5   root      153:                screendlg[DLGSCRN_FULLSCRN].state |= SG_SELECTED;
                    154:        else
                    155:                screendlg[DLGSCRN_FULLSCRN].state &= ~SG_SELECTED;
                    156: 
1.1.1.6 ! root      157:        if (ConfigureParams.Screen.bAllowOverscan)
1.1.1.5   root      158:                screendlg[DLGSCRN_OVERSCAN].state |= SG_SELECTED;
                    159:        else
                    160:                screendlg[DLGSCRN_OVERSCAN].state &= ~SG_SELECTED;
                    161: 
1.1.1.6 ! root      162:        if (ConfigureParams.Screen.bShowStatusbar)
        !           163:                screendlg[DLGSCRN_STATUSBAR].state |= SG_SELECTED;
1.1.1.5   root      164:        else
1.1.1.6 ! root      165:                screendlg[DLGSCRN_STATUSBAR].state &= ~SG_SELECTED;
1.1.1.5   root      166: 
1.1.1.6 ! root      167:        if (ConfigureParams.Screen.bZoomLowRes)
1.1.1.5   root      168:                screendlg[DLGSCRN_ZOOMLOWRES].state |= SG_SELECTED;
                    169:        else
                    170:                screendlg[DLGSCRN_ZOOMLOWRES].state &= ~SG_SELECTED;
                    171: 
                    172:        for (i = 0; i < ITEMS_IN_ARRAY(skip_frames); i++)
                    173:        {
1.1.1.6 ! root      174:                if (ConfigureParams.Screen.nFrameSkips >= skip_frames[i])
1.1.1.5   root      175:                        skip = i;
                    176:                screendlg[i+DLGSCRN_SKIP0].state &= ~SG_SELECTED;
                    177:        }
                    178:        screendlg[DLGSCRN_SKIP0+skip].state |= SG_SELECTED;
                    179: 
                    180:        for (i = DLGSCRN_MONO; i <= DLGSCRN_TV; i++)
                    181:                screendlg[i].state &= ~SG_SELECTED;
1.1.1.6 ! root      182:        screendlg[DLGSCRN_MONO+ConfigureParams.Screen.nMonitorType].state |= SG_SELECTED;
1.1.1.5   root      183: 
                    184:        /* Initialize VDI resolution options: */
                    185: 
1.1.1.6 ! root      186:        if (ConfigureParams.Screen.bUseExtVdiResolutions)
1.1.1.5   root      187:                screendlg[DLGSCRN_USEVDIRES].state |= SG_SELECTED;
                    188:        else
                    189:                screendlg[DLGSCRN_USEVDIRES].state &= ~SG_SELECTED;
                    190:        for (i=0; i<3; i++)
                    191:                screendlg[DLGSCRN_BPP1 + i].state &= ~SG_SELECTED;
1.1.1.6 ! root      192:        screendlg[DLGSCRN_BPP1 + ConfigureParams.Screen.nVdiColors - GEMCOLOR_2].state |= SG_SELECTED;
        !           193:        sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
        !           194:        sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
1.1.1.5   root      195:        DlgScreen_SetStepping();
                    196: 
                    197:        /* Initialize screen capture options: */
                    198: 
1.1.1.6 ! root      199:        if (ConfigureParams.Screen.bCaptureChange)
1.1.1.5   root      200:                screendlg[DLGSCRN_ONCHANGE].state |= SG_SELECTED;
                    201:        else
                    202:                screendlg[DLGSCRN_ONCHANGE].state &= ~SG_SELECTED;
                    203: 
                    204:        if (ScreenSnapShot_AreWeRecording())
                    205:                screendlg[DLGSCRN_RECANIM].txt = "Stop recording";
                    206:        else
                    207:                screendlg[DLGSCRN_RECANIM].txt = "Record animation";
                    208: 
                    209:        /* The screen dialog main loop */
                    210:        do
                    211:        {
                    212:                but = SDLGui_DoDialog(screendlg, NULL);
                    213:                switch (but)
                    214:                {
                    215:                 case DLGSCRN_WIDTHLESS:
1.1.1.6 ! root      216:                        ConfigureParams.Screen.nVdiWidth = VDI_Limit(ConfigureParams.Screen.nVdiWidth - nVdiStepX,
1.1.1.5   root      217:                                                        nVdiStepX, MIN_VDI_WIDTH, MAX_VDI_WIDTH);
1.1.1.6 ! root      218:                        sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
1.1.1.5   root      219:                        break;
                    220:                 case DLGSCRN_WIDTHMORE:
1.1.1.6 ! root      221:                        ConfigureParams.Screen.nVdiWidth = VDI_Limit(ConfigureParams.Screen.nVdiWidth + nVdiStepX,
1.1.1.5   root      222:                                                        nVdiStepX, MIN_VDI_WIDTH, MAX_VDI_WIDTH);
1.1.1.6 ! root      223:                        sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
1.1.1.5   root      224:                        break;
                    225: 
                    226:                 case DLGSCRN_HEIGHTLESS:
1.1.1.6 ! root      227:                        ConfigureParams.Screen.nVdiHeight = VDI_Limit(ConfigureParams.Screen.nVdiHeight - nVdiStepY,
1.1.1.5   root      228:                                                         nVdiStepY, MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
1.1.1.6 ! root      229:                        sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
1.1.1.5   root      230:                        break;
                    231:                 case DLGSCRN_HEIGHTMORE:
1.1.1.6 ! root      232:                        ConfigureParams.Screen.nVdiHeight = VDI_Limit(ConfigureParams.Screen.nVdiHeight + nVdiStepY,
1.1.1.5   root      233:                                                         nVdiStepY, MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
1.1.1.6 ! root      234:                        sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
1.1.1.5   root      235:                        break;
                    236: 
                    237:                 case DLGSCRN_BPP1:
                    238:                 case DLGSCRN_BPP2:
                    239:                 case DLGSCRN_BPP4:
                    240:                        DlgScreen_SetStepping();
                    241:                        /* Align resolution to actual conditions: */
1.1.1.6 ! root      242:                        ConfigureParams.Screen.nVdiWidth = VDI_Limit(ConfigureParams.Screen.nVdiWidth, nVdiStepX,
1.1.1.5   root      243:                                                        MIN_VDI_WIDTH, MAX_VDI_WIDTH);
1.1.1.6 ! root      244:                        ConfigureParams.Screen.nVdiHeight = VDI_Limit(ConfigureParams.Screen.nVdiHeight, nVdiStepY,
1.1.1.5   root      245:                                                         MIN_VDI_HEIGHT, MAX_VDI_HEIGHT);
1.1.1.6 ! root      246:                        sprintf(sVdiWidth, "%4i", ConfigureParams.Screen.nVdiWidth);
        !           247:                        sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
1.1.1.5   root      248:                        break;
                    249: 
                    250:                 case DLGSCRN_CAPTURE:
                    251:                        SDL_UpdateRect(sdlscrn, 0,0,0,0);
                    252:                        ScreenSnapShot_SaveScreen();
                    253:                        break;
                    254:                 case DLGSCRN_RECANIM:
                    255:                        if (ScreenSnapShot_AreWeRecording())
                    256:                        {
                    257:                                screendlg[DLGSCRN_RECANIM].txt = "Record animation";
                    258:                                ScreenSnapShot_EndRecording();
                    259:                        }
                    260:                        else
                    261:                        {
                    262:                                screendlg[DLGSCRN_RECANIM].txt = "Stop recording";
1.1.1.6 ! root      263:                                ConfigureParams.Screen.bCaptureChange = (screendlg[DLGSCRN_ONCHANGE].state & SG_SELECTED);
        !           264:                                ScreenSnapShot_BeginRecording(ConfigureParams.Screen.bCaptureChange);
1.1.1.5   root      265:                        }
                    266:                        break;
                    267:                }
                    268:        }
                    269:        while (but != DLGSCRN_EXIT && but != SDLGUI_QUIT
                    270:                && but != SDLGUI_ERROR && !bQuitProgram);
                    271: 
                    272:        /* Read new values from dialog: */
                    273: 
1.1.1.6 ! root      274:        ConfigureParams.Screen.bFullScreen = (screendlg[DLGSCRN_FULLSCRN].state & SG_SELECTED);
        !           275:        ConfigureParams.Screen.bAllowOverscan = (screendlg[DLGSCRN_OVERSCAN].state & SG_SELECTED);
1.1.1.5   root      276: 
1.1.1.6 ! root      277:        if (screendlg[DLGSCRN_STATUSBAR].state & SG_SELECTED)
        !           278:                ConfigureParams.Screen.bShowStatusbar = TRUE;
1.1.1.5   root      279:        else
1.1.1.6 ! root      280:                ConfigureParams.Screen.bShowStatusbar = FALSE;
1.1.1.5   root      281: 
                    282:        if (screendlg[DLGSCRN_ZOOMLOWRES].state & SG_SELECTED)
1.1.1.6 ! root      283:                ConfigureParams.Screen.bZoomLowRes = TRUE;
1.1.1.5   root      284:        else
1.1.1.6 ! root      285:                ConfigureParams.Screen.bZoomLowRes = FALSE;
1.1.1.5   root      286: 
1.1.1.6 ! root      287:        ConfigureParams.Screen.bUseExtVdiResolutions = (screendlg[DLGSCRN_USEVDIRES].state & SG_SELECTED);
1.1.1.5   root      288:        for (i = DLGSCRN_SKIP0; i <= DLGSCRN_SKIP4; i++)
                    289:        {
                    290:                if (screendlg[i].state & SG_SELECTED)
                    291:                {
1.1.1.6 ! root      292:                        ConfigureParams.Screen.nFrameSkips = skip_frames[i-DLGSCRN_SKIP0];
1.1.1.5   root      293:                        break;
                    294:                }
                    295:        }
                    296:        for (i = DLGSCRN_MONO; i <= DLGSCRN_TV; i++)
                    297:        {
                    298:                if (screendlg[i].state & SG_SELECTED)
                    299:                {
1.1.1.6 ! root      300:                        ConfigureParams.Screen.nMonitorType = i - DLGSCRN_MONO;
1.1.1.5   root      301:                        break;
                    302:                }
                    303:        }
                    304:        for (i=0; i<3; i++)
                    305:        {
                    306:                if (screendlg[DLGSCRN_BPP1 + i].state & SG_SELECTED)
1.1.1.6 ! root      307:                        ConfigureParams.Screen.nVdiColors = GEMCOLOR_2 + i;
1.1.1.5   root      308:        }
1.1.1.2   root      309: 
1.1.1.6 ! root      310:        ConfigureParams.Screen.bCaptureChange = (screendlg[DLGSCRN_ONCHANGE].state & SG_SELECTED);
1.1       root      311: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.