Annotation of previous_trunk/src/gui-sdl/dlgDimension.c, revision 1.1

1.1     ! root        1: /*
        !             2:   Previous - dlgDimension.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: */
        !             8: 
        !             9: const char DlgDimension_fileid[] = "Previous dlgDimension.c : " __DATE__ " " __TIME__;
        !            10: 
        !            11: #include "main.h"
        !            12: #include "configuration.h"
        !            13: #include "dialog.h"
        !            14: #include "sdlgui.h"
        !            15: #include "file.h"
        !            16: 
        !            17: 
        !            18: #define DLGND_CUSTOMIZE     5
        !            19: #define DLGND_MEMSIZE       12
        !            20: #define DLGND_BROWSE        16
        !            21: #define DLGND_NAME          17
        !            22: #define DLGND_EXIT          18
        !            23: 
        !            24: /* Variable strings */
        !            25: char dimension_memory[16] = "64 MB";
        !            26: char dimension_slot[16]   = "2:";
        !            27: 
        !            28: /* Additional functions */
        !            29: void print_nd_overview(int slot);
        !            30: void get_nd_default_values(int slot);
        !            31: 
        !            32: static SGOBJ dimensiondlg[] =
        !            33: {
        !            34:     { SGBOX,      0, 0, 0,  0, 58, 22, NULL },
        !            35:     { SGTEXT,     0, 0, 18, 1, 21, 1, "NeXTdimension options" },
        !            36:     
        !            37:     { SGBOX,      0, 0, 2,  3, 54, 8, NULL },
        !            38:     { SGTEXT,     0, 0, 3,  4, 28, 1, "NeXTdimension board at slot " },
        !            39:     { SGTEXT,     0, 0, 31, 4, 2,  1, dimension_slot },
        !            40:     { SGBUTTON,   0, 0, 35, 4, 11, 1, "Customize" },
        !            41:        
        !            42:     { SGTEXT, 0, 0, 4 ,6, 13,1, "CPU type:" },
        !            43:     { SGTEXT, 0, 0, 18,6, 13,1, "i860XR" },
        !            44:     { SGTEXT, 0, 0, 4 ,7, 13,1, "CPU clock:" },
        !            45:     { SGTEXT, 0, 0, 18,7, 13,1, "33 MHz" },
        !            46:     { SGTEXT, 0, 0, 4 ,8, 13,1, "Memory size:" },
        !            47:     { SGTEXT, 0, 0, 18,8, 13,1, dimension_memory },
        !            48:     { SGTEXT, 0, 0, 4 ,9, 13,1, "NBIC:" },
        !            49:     { SGTEXT, 0, 0, 18,9, 13,1, "present" },
        !            50: 
        !            51:     { SGBOX, 0, 0, 2,12, 54,5, NULL },
        !            52:     { SGTEXT, 0, 0, 3,13, 22,1, "ROM for NeXTdimension:" },
        !            53:     { SGBUTTON, 0, 0, 27,13, 8,1, "Browse" },
        !            54:     { SGTEXT, 0, 0, 4,15, 50,1, NULL },
        !            55:     
        !            56:     { SGBUTTON, SG_DEFAULT, 0, 24,19, 10,1, "Done" },
        !            57: 
        !            58:     { -1, 0, 0, 0,0, 0,0, NULL }
        !            59: };
        !            60: 
        !            61: 
        !            62: /* Function to set NeXTdimension memory options */
        !            63: void Dialog_NDMemDlg(int *membank);
        !            64: 
        !            65: /* Function to print system overview */
        !            66: void print_nd_overview(int n) {
        !            67:     sprintf(dimension_memory, "%i MB", Configuration_CheckDimensionMemory(ConfigureParams.Dimension.board[n].nMemoryBankSize));
        !            68: }
        !            69: 
        !            70: /* Function to get default values for each system */
        !            71: void get_nd_default_values(int n) {
        !            72:     int i;
        !            73:     
        !            74:     for (i = 0; i < 4; i++) {
        !            75:         ConfigureParams.Dimension.board[n].nMemoryBankSize[i] = 4;
        !            76:     }
        !            77: }
        !            78: 
        !            79: 
        !            80: /*-----------------------------------------------------------------------*/
        !            81: /**
        !            82:   * Show and process the "System" dialog (specific to winUAE cpu).
        !            83:   */
        !            84: bool Dialog_DimensionDlg(int n)
        !            85: {
        !            86:     int but;
        !            87:     char dlgname_ndrom[64];
        !            88:     
        !            89:     if (ConfigureParams.Dimension.board[n].bEnabled) {
        !            90:         ConfigureParams.Dimension.board[n].bEnabled = false;
        !            91:         return false;
        !            92:     }
        !            93:  
        !            94:        SDLGui_CenterDlg(dimensiondlg);
        !            95:  
        !            96:        /* Set up dialog from actual values: */
        !            97:     
        !            98:     sprintf(dimension_slot, "%i:", n*2+2);
        !            99:     
        !           100:     File_ShrinkName(dlgname_ndrom, ConfigureParams.Dimension.board[n].szRomFileName,
        !           101:                         dimensiondlg[DLGND_NAME].w);
        !           102:     dimensiondlg[DLGND_NAME].txt = dlgname_ndrom;
        !           103: 
        !           104:     /* System overview */
        !           105:     print_nd_overview(n);
        !           106:     
        !           107:        /* Draw and process the dialog: */
        !           108:     
        !           109:     do {
        !           110:         but = SDLGui_DoDialog(dimensiondlg, NULL);
        !           111:         
        !           112:         switch (but) {
        !           113:             case DLGND_BROWSE:
        !           114:                 SDLGui_FileConfSelect(dlgname_ndrom,
        !           115:                                       ConfigureParams.Dimension.board[n].szRomFileName,
        !           116:                                       dimensiondlg[DLGND_NAME].w,
        !           117:                                       false);
        !           118:                 break;
        !           119:                 
        !           120:             case DLGND_CUSTOMIZE:
        !           121:                 Dialog_NDMemDlg(ConfigureParams.Dimension.board[n].nMemoryBankSize);
        !           122:                 print_nd_overview(n);
        !           123:                 break;
        !           124:                 
        !           125:             default:
        !           126:                 break;
        !           127:         }
        !           128:     }
        !           129:     while (but != DLGND_EXIT && but != SDLGUI_QUIT
        !           130:            && but != SDLGUI_ERROR && !bQuitProgram);
        !           131:     
        !           132:     ConfigureParams.Dimension.board[n].bEnabled = true;
        !           133:     ConfigureParams.System.bNBIC = true;
        !           134:     
        !           135:     return true;
        !           136: }
        !           137: 
        !           138: 
        !           139: #define DLGNDMEM_BANK0_4MB     4
        !           140: #define DLGNDMEM_BANK0_16MB    5
        !           141: #define DLGNDMEM_BANK0_NONE    6
        !           142: 
        !           143: #define DLGNDMEM_BANK1_4MB     9
        !           144: #define DLGNDMEM_BANK1_16MB    10
        !           145: #define DLGNDMEM_BANK1_NONE    11
        !           146: 
        !           147: #define DLGNDMEM_BANK2_4MB     14
        !           148: #define DLGNDMEM_BANK2_16MB    15
        !           149: #define DLGNDMEM_BANK2_NONE    16
        !           150: 
        !           151: #define DLGNDMEM_BANK3_4MB     19
        !           152: #define DLGNDMEM_BANK3_16MB    20
        !           153: #define DLGNDMEM_BANK3_NONE    21
        !           154: 
        !           155: #define DLGNDMEM_DEFAULT       23
        !           156: #define DLGNDMEM_EXIT          24
        !           157: 
        !           158: 
        !           159: void Dialog_NDMemDraw(int *memorybank);
        !           160: void Dialog_NDMemRead(int *memorybank);
        !           161: 
        !           162: static SGOBJ ndmemdlg[] =
        !           163: {
        !           164:     { SGBOX, 0, 0, 0,0, 55,18, NULL },
        !           165:     { SGTEXT, 0, 0, 18,1, 19,1, "Custom memory setup" },
        !           166:     
        !           167:     { SGBOX, 0, 0, 2,4, 12,7, NULL },
        !           168:     { SGTEXT, 0, 0, 3,5, 14,1, "Bank0" },
        !           169:     { SGRADIOBUT, 0, 0, 4,7, 6,1, "4 MB" },
        !           170:     { SGRADIOBUT, 0, 0, 4,8, 7,1, "16 MB" },
        !           171:     { SGRADIOBUT, 0, 0, 4,9, 6,1, "none" },
        !           172:     
        !           173:     { SGBOX, 0, 0, 15,4, 12,7, NULL },
        !           174:     { SGTEXT, 0, 0, 16,5, 14,1, "Bank1" },
        !           175:     { SGRADIOBUT, 0, 0, 17,7, 6,1, "4 MB" },
        !           176:     { SGRADIOBUT, 0, 0, 17,8, 7,1, "16 MB" },
        !           177:     { SGRADIOBUT, 0, 0, 17,9, 6,1, "none" },
        !           178:     
        !           179:     { SGBOX, 0, 0, 28,4, 12,7, NULL },
        !           180:     { SGTEXT, 0, 0, 29,5, 14,1, "Bank2" },
        !           181:     { SGRADIOBUT, 0, 0, 30,7, 6,1, "4 MB" },
        !           182:     { SGRADIOBUT, 0, 0, 30,8, 7,1, "16 MB" },
        !           183:     { SGRADIOBUT, 0, 0, 30,9, 6,1, "none" },
        !           184:     
        !           185:     { SGBOX, 0, 0, 41,4, 12,7, NULL },
        !           186:     { SGTEXT, 0, 0, 42,5, 14,1, "Bank3" },
        !           187:     { SGRADIOBUT, 0, 0, 43,7, 6,1, "4 MB" },
        !           188:     { SGRADIOBUT, 0, 0, 43,8, 7,1, "16 MB" },
        !           189:     { SGRADIOBUT, 0, 0, 43,9, 6,1, "none" },
        !           190:     
        !           191:     { SGTEXT, 0, 0, 5,12, 14,1, "Bank0 must contain at least 4 MB of memory." },
        !           192:     
        !           193:     { SGBUTTON, 0, 0, 15,15, 10,1, "Defaults" },
        !           194:     { SGBUTTON, SG_DEFAULT, 0, 30,15, 10,1, "OK" },
        !           195:     { -1, 0, 0, 0,0, 0,0, NULL }
        !           196: };
        !           197: 
        !           198: 
        !           199: 
        !           200: /*-----------------------------------------------------------------------*/
        !           201: /**
        !           202:  * Show and process the "Memory Advanced" dialog.
        !           203:  */
        !           204: void Dialog_NDMemDlg(int *membank) {
        !           205:     
        !           206:     int but;
        !           207:     
        !           208:     SDLGui_CenterDlg(ndmemdlg);
        !           209:     
        !           210:     /* Set up dialog from actual values: */
        !           211:     Dialog_NDMemDraw(membank);
        !           212:     
        !           213:     /* Draw and process the dialog: */
        !           214:     do
        !           215:     {
        !           216:         but = SDLGui_DoDialog(ndmemdlg, NULL);
        !           217: 
        !           218:         switch (but) {
        !           219:             case DLGNDMEM_DEFAULT:
        !           220:                 membank[0] = membank[1] = membank[2] = membank[3] = 4;
        !           221:                 Configuration_CheckDimensionMemory(membank);
        !           222:                 Dialog_NDMemDraw(membank);
        !           223:                 break;
        !           224:             default:
        !           225:                 break;
        !           226:         }
        !           227:     }
        !           228:     while (but != DLGNDMEM_EXIT && but != SDLGUI_QUIT
        !           229:            && but != SDLGUI_ERROR && !bQuitProgram);
        !           230:     
        !           231:     
        !           232:     /* Read values from dialog: */
        !           233:     Dialog_NDMemRead(membank);
        !           234: }
        !           235: 
        !           236: 
        !           237: /* Function to set up the dialog from the actual values */
        !           238: void Dialog_NDMemDraw(int *bank) {
        !           239:     int i, j;
        !           240:     for (i = 0; i<4; i++) {
        !           241:         
        !           242:         for (j = (DLGNDMEM_BANK0_4MB+(5*i)); j <= (DLGNDMEM_BANK0_NONE+(5*i)); j++)
        !           243:         {
        !           244:             ndmemdlg[j].state &= ~SG_SELECTED;
        !           245:         }
        !           246:         
        !           247:         switch (bank[i])
        !           248:         {
        !           249:             case 0:
        !           250:                 ndmemdlg[DLGNDMEM_BANK0_NONE+(i*5)].state |= SG_SELECTED;
        !           251:                 break;
        !           252:             case 4:
        !           253:                 ndmemdlg[DLGNDMEM_BANK0_4MB+(i*5)].state |= SG_SELECTED;
        !           254:                 break;
        !           255:             case 16:
        !           256:                 ndmemdlg[DLGNDMEM_BANK0_16MB+(i*5)].state |= SG_SELECTED;
        !           257:                 break;
        !           258:                 
        !           259:             default:
        !           260:                 break;
        !           261:         }
        !           262:     }
        !           263: }
        !           264: 
        !           265: 
        !           266: /* Function to read the actual values from the dialog */
        !           267: void Dialog_NDMemRead(int *bank) {
        !           268:     int i;
        !           269:     for (i = 0; i<4; i++) {
        !           270:         if (ndmemdlg[(DLGNDMEM_BANK0_4MB)+(i*5)].state & SG_SELECTED)
        !           271:             bank[i] = 4;
        !           272:         else if (ndmemdlg[(DLGNDMEM_BANK0_16MB)+(i*5)].state & SG_SELECTED)
        !           273:             bank[i] = 16;
        !           274:         else
        !           275:             bank[i] = 0;
        !           276:     }
        !           277: }

unix.superglobalmegacorp.com

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