Annotation of 43BSDTahoe/new/X/libvs100/util.c, revision 1.1.1.1

1.1       root        1: /* $Header: util.c,v 10.4 86/11/30 16:45:52 jg Rel $ */
                      2: /* util.c              Various utilities
                      3:  *
                      4:  *     ErrorString     Interprets an error string
                      5:  *     SoundBell       Generate audible bell
                      6:  *     SetKeyClick     Control key click
                      7:  *     SetAutoRepeat   Control auto repeat
                      8:  *     SetLockLED      Control Lock LED
                      9:  *     QueryShape      Determine shapes
                     10:  *     SetVideo        Set video blanking
                     11:  *     ResolveColors   does nothing
                     12:  *     StoreColors     does nothing
                     13:  *
                     14:  */
                     15: 
                     16: /****************************************************************************
                     17:  *                                                                         *
                     18:  *  Copyright (c) 1983, 1984 by                                                    *
                     19:  *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
                     20:  *  All rights reserved.                                                   *
                     21:  *                                                                         *
                     22:  *  This software is furnished on an as-is basis and may be used and copied *
                     23:  *  only with inclusion of the above copyright notice. This software or any *
                     24:  *  other copies thereof may be provided or otherwise made available to     *
                     25:  *  others only for non-commercial purposes.  No title to or ownership of   *
                     26:  *  the software is hereby transferred.                                            *
                     27:  *                                                                         *
                     28:  *  The information in this software is  subject to change without notice   *
                     29:  *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
                     30:  *  CORPORATION.                                                           *
                     31:  *                                                                         *
                     32:  *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
                     33:  *  software on equipment which is not supplied by DIGITAL.                *
                     34:  *                                                                         *
                     35:  *                                                                         *
                     36:  ****************************************************************************/
                     37: 
                     38: #include "vs100.h"
                     39: #include "reason.h"
                     40: 
                     41: extern int sys_nerr;
                     42: extern char *sys_errlist[];
                     43: 
                     44: char *AllocateSpace();
                     45: 
                     46: struct _ErrEntry {
                     47:        int code;
                     48:        char *reason;
                     49: } errorList[NUM_ERR_CODES] = {
                     50:        {IR_ID          , IR_ID_MSG },
                     51:        {IR_CD          , IR_CD_MSG },
                     52:        {IR_DCI         , IR_DCI_MSG },
                     53:        {IR_DE          , IR_DE_MSG },
                     54:        {IR_CM          , IR_CM_MSG },
                     55:        {IR_DPM         , IR_DPM_MSG },
                     56:        {IR_MM          , IR_MM_MSG },
                     57:        {IR_PD          , IR_PD_MSG },
                     58:        {IR_AB_ACK      , IR_AB_ACK_MSG },
                     59:        {IR_STAT_ACK    , IR_STAT_ACK_MSG },
                     60:        {IR_SAVE_ACK    , IR_SAVE_ACK_MSG },
                     61:        {ERR_NYI        , ERR_NYI_MSG },
                     62:        {ERR_IFC        , ERR_IFC_MSG},
                     63:        {ERR_ICC        , ERR_ICC_MSG},
                     64:        {ERR_BE_NXM_68K , ERR_BE_NXM_68K_MSG},
                     65:        {ERR_BE_RO      , ERR_BE_RO_MSG},
                     66:        {ERR_BE_LD      , ERR_BE_LD_MSG},
                     67:        {ERR_BE_S       , ERR_BE_S_MSG},
                     68:        {ERR_AE         , ERR_AE_MSG},
                     69:        {ERR_ZD         , ERR_ZD_MSG},
                     70:        {ERR_II         , ERR_II_MSG},
                     71:        {ERR_NXM_BBA    , ERR_NXM_BBA_MSG},
                     72:        {ERR_BNI        , ERR_BNI_MSG},
                     73:        {ERR_KCQO       , ERR_KCQO_MSG},
                     74:        {ERR_DPCQO      , ERR_DPCQO_MSG},
                     75:        {ERR_MEQO       , ERR_MEQO_MSG},
                     76:        {ERR_DPEQO      , ERR_DPEQO_MSG},
                     77:        {ERR_AB_BBA     , ERR_AB_BBA_MSG},
                     78:        {ERR_KEQO       , ERR_KEQO_MSG},
                     79:        {ERR_KOR        , ERR_KOR_MSG},
                     80:        {ERR_DPOR       , ERR_DPOR_MSG},
                     81:        {ERR_KFE        , ERR_KFE_MSG},
                     82:        {ERR_DPFE       , ERR_DPFE_MSG},
                     83: 
                     84:        {ERR_ISRCM      , ERR_ISRCM_MSG},
                     85:        {ERR_ISRCBW     , ERR_ISRCBW_MSG},
                     86:        {ERR_ISRCBH     , ERR_ISRCBH_MSG},
                     87:        {ERR_ISRCC      , ERR_ISRCC_MSG},
                     88:        {ERR_ISRCBD     , ERR_ISRCBD_MSG},
                     89:        {ERR_IMSKM      , ERR_IMSKM_MSG},
                     90:        {ERR_IMSKBW     , ERR_IMSKBW_MSG},
                     91:        {ERR_IMSKBH     , ERR_IMSKBH_MSG},
                     92:        {ERR_IMSKBD     , ERR_IMSKBD_MSG},
                     93:        {ERR_IDSTM      , ERR_IDSTM_MSG},
                     94:        {ERR_IDSTBW     , ERR_IDSTBW_MSG},
                     95:        {ERR_IDSTBH     , ERR_IDSTBH_MSG},
                     96:        {ERR_IDSTBD     , ERR_IDSTBD_MSG},
                     97:        {ERR_IMAPM      , ERR_IMAPM_MSG},
                     98:        {ERR_ICLPM      , ERR_ICLPM_MSG},
                     99:        {ERR_ICLPC      , ERR_ICLPC_MSG},
                    100: 
                    101:        {ERR_SMC_ITC    , ERR_SMC_ITC_MSG},
                    102:        {ERR_SCL_CD     , ERR_SCL_CD_MSG},
                    103:        {ERR_AC_ICD     , ERR_AC_ICD_MSG},
                    104: 
                    105:        {ERR_MO_IBC     , ERR_MO_IBC_MSG},
                    106:        {ERR_MO_IOT     , ERR_MO_IOT_MSG},
                    107:        {ERR_MO_IDT     , ERR_MO_IDT_MSG},
                    108: 
                    109:        {ERR_IPC        , ERR_IPC_MSG},
                    110: 
                    111:        {ERR_DC_IPL     , ERR_DC_IPL_MSG},
                    112:        {ERR_DC_IPM     , ERR_DC_IPM_MSG},
                    113:        {ERR_DC_ICF     , ERR_DC_ICF_MSG},
                    114:        {ERR_DC_IPP     , ERR_DC_IPP_MSG},
                    115:        {ERR_DC_IPSM    , ERR_DC_IPSM_MSG},
                    116:        {ERR_DC_IPMM    , ERR_DC_IPMM_MSG},
                    117:        {ERR_DC_IPC     , ERR_DC_IPC_MSG},
                    118:        {ERR_DC_ISSRCBW , ERR_DC_ISSRCBW_MSG},
                    119:        {ERR_DC_ISSRCBH , ERR_DC_ISSRCBH_MSG},
                    120:        {ERR_DC_ISSRCBD , ERR_DC_ISSRCBD_MSG},
                    121:        {ERR_DC_ISSRCC  , ERR_DC_ISSRCC_MSG},
                    122:        {ERR_DC_IDPM    , ERR_DC_IDPM_MSG},
                    123:        {ERR_DC_DXO     , ERR_DC_DXO_MSG},
                    124:        {ERR_DC_DYO     , ERR_DC_DYO_MSG},
                    125:        {ERR_DC_CRSO    , ERR_DC_CRSO_MSG},
                    126: 
                    127:        {ERR_PT_ICSL    , ERR_PT_ICSL_MSG},
                    128:        {ERR_PT_ICSO    , ERR_PT_ICSO_MSG},
                    129:        {ERR_PT_ICSP    , ERR_PT_ICSP_MSG},
                    130:        {ERR_PT_ITSL    , ERR_PT_ITSL_MSG},
                    131:        {ERR_PT_ICI     , ERR_PT_ICI_MSG},
                    132:        {ERR_PT_TSE     , ERR_PT_TSE_MSG},
                    133:        {ERR_PT_NFP     , ERR_PT_NFP_MSG},
                    134:        {ERR_PT_ISRCFW  , ERR_PT_ISRCFW_MSG},
                    135:        {ERR_PT_ISRCFH  , ERR_PT_ISRCFH_MSG},
                    136:        {ERR_PT_ISRCFD  , ERR_PT_ISRCFD_MSG},
                    137:        {ERR_PT_IMSKFW  , ERR_PT_IMSKFW_MSG},
                    138:        {ERR_PT_IMSKFH  , ERR_PT_IMSKFH_MSG},
                    139:        {ERR_PT_IMSKFD  , ERR_PT_IMSKFD_MSG},
                    140:        {ERR_PT_CSMF    , ERR_PT_CSMF_MSG},
                    141:        {ERR_PT_ILB     , ERR_PT_ILB_MSG},
                    142:        {ERR_PT_ILE     , ERR_PT_ILE_MSG},
                    143:        {ERR_FA_ISRCB   , ERR_FA_ISRCB_MSG},
                    144:        {ERR_FA_SO      , ERR_FA_SO_MSG},
                    145:        {ERR_FA_IBMM    , ERR_FA_IBMM_MSG},
                    146: 
                    147:        {ERR_FP_ISRCB   , ERR_FP_ISRCB_MSG},
                    148:        {ERR_FP_ICF     , ERR_FP_ICF_MSG},
                    149:        {ERR_FP_DXO     , ERR_FP_DXO_MSG},
                    150:        {ERR_FP_DYO     , ERR_FP_DYO_MSG},
                    151: 
                    152:        {ERR_CPU                , ERR_CPU_MSG},
                    153:        {ERR_RHB                , ERR_RHB_MSG},
                    154:        {ERR_PR         , ERR_PR_MSG},
                    155:        {ERR_CRTC       , ERR_CRTC_MSG},
                    156:        {ERR_DPE                , ERR_DPE_MSG},
                    157:        {ERR_KE         , ERR_KE_MSG},
                    158:        {ERR_FOE                , ERR_FOE_MSG},
                    159:        {ERR_F0         , ERR_F0_MSG},
                    160:        {ERR_BSR                , ERR_BSR_MSG},
                    161:        {ERR_BCC                , ERR_BCC_MSG},
                    162:        {ERR_DPTO       , ERR_DPTO_MSG},
                    163:        {ERR_FOO                , ERR_FOO_MSG},
                    164:        {ERR_KTO                , ERR_KTO_MSG},
                    165:        {ERR_KST                , ERR_KST_MSG},
                    166:        {ERR_VR         , ERR_VR_MSG},
                    167:        {ERR_F1         , ERR_F1_MSG},
                    168:        {ERR_F2         , ERR_F2_MSG},
                    169:        {ERR_F3         , ERR_F3_MSG},
                    170:        {ERR_DPP                , ERR_DPP_MSG},
                    171:        {ERR_KP         , ERR_KP_MSG},
                    172:        {ERR_FOED       , ERR_FOED_MSG},
                    173:        {ERR_FOOD       , ERR_FOOD_MSG},
                    174:        {ERR_BCTO       , ERR_BCTO_MSG},
                    175:        {ERR_RLB                , ERR_RLB_MSG},
                    176:        {ERR_KD         , ERR_KD_MSG},
                    177:        {ERR_BVC                , ERR_BVC_MSG},
                    178: 
                    179:        {ERR_ISRCHW     , ERR_ISRCHW_MSG},
                    180:        {ERR_ISRCHH     , ERR_ISRCHH_MSG},
                    181:        {ERR_ISRCHD     , ERR_ISRCHD_MSG},
                    182:        {ERR_DC_ISSRCHW , ERR_DC_ISSRCHW_MSG},
                    183:        {ERR_DC_ISSRCHH , ERR_DC_ISSRCHH_MSG},
                    184:        {ERR_DC_ISSRCHD , ERR_DC_ISSRCHD_MSG},
                    185: 
                    186:        {ERR_LC_ICTX    , ERR_LC_ICTX_MSG},
                    187:        {ERR_LC_ICTY    , ERR_LC_ICTY_MSG},
                    188:        {ERR_LC_ICCX    , ERR_LC_ICCX_MSG},
                    189:        {ERR_LC_ICCY    , ERR_LC_ICCY_MSG},
                    190:        {ERR_LC_ICW     , ERR_LC_ICW_MSG},
                    191:        {ERR_LC_ICH     , ERR_LC_ICH_MSG},
                    192:        {ERR_PT_DXO     , ERR_PT_DXO_MSG},
                    193:        {ERR_PT_CRSO    , ERR_PT_CRSO_MSG},
                    194: };
                    195: 
                    196: /* Interpret a string corresponding to an error code.  This doesn't
                    197:  * work very well since the driver can't return enough bits for the
                    198:  * code, but we do our best */
                    199: 
                    200: char *ErrorString (error)
                    201:        int error;
                    202: {
                    203:        register int i;
                    204: 
                    205:        for (i = 0; i < NUM_ERR_CODES; i++) {
                    206:            if (errorList[i].code == error)
                    207:                return (errorList[i].reason);
                    208:        }
                    209:        if (error > 0 && error < sys_nerr)
                    210:            return (sys_errlist[error]);
                    211:        return ("Unknown error");
                    212: }
                    213: 
                    214: SoundBell (volume)
                    215:        int volume;
                    216: {
                    217:        char *buf;
                    218: 
                    219:        if ((buf = (char *) AllocateSpace(4)) == NULL)
                    220:            return;
                    221:        buf[0] = 3;
                    222:        buf[1] = 0x23;
                    223:        buf[2] = 0x87 - volume;
                    224:        buf[3] = 0xa7;
                    225:        SendToPeripheral(buf, 4, VSE_DKB);
                    226: }
                    227: 
                    228: SetKeyClick (volume)
                    229:        int volume;
                    230: {
                    231:        char *buf;
                    232: 
                    233:        if ((buf = (char *) AllocateSpace(3)) == NULL)
                    234:            return;
                    235:        if (volume) {
                    236:            buf[0] = 2;
                    237:            buf[1] = 0x1b;
                    238:            buf[2] = 0x88 - volume;
                    239:        } else {
                    240:            buf[0] = 1;
                    241:            buf[1] = 0x99;
                    242:            buf[2] = 0x99;
                    243:        }
                    244:        SendToPeripheral(buf, 3, VSE_DKB);
                    245: }
                    246: 
                    247: QueryShape (shape, width, height)
                    248:        int shape;
                    249:        short *width, *height;
                    250: {
                    251:        switch (shape) {
                    252:        case CursorShape:
                    253:            if (*width > 64)
                    254:                *width = 64;
                    255:            if (*height > 64)
                    256:                *height = 64;
                    257:            break;
                    258:        case TileShape:
                    259:            *width = *height = 16;
                    260:            break;
                    261:        }
                    262: }
                    263: 
                    264: SetAutoRepeat (onoff)
                    265:        int onoff;
                    266: {
                    267:        char *buf;
                    268: 
                    269:        if ((buf = (char *) AllocateSpace(2)) == NULL)
                    270:            return;
                    271:        buf[0] = 1;
                    272:        buf[1] = onoff ? 0xe3 : 0xe1;
                    273:        SendToPeripheral(buf, 2, VSE_DKB);
                    274: }
                    275: 
                    276: /*ARGSUSED*/
                    277: SetLockLED (onoff)
                    278:        int onoff;
                    279: {
                    280: }
                    281: 
                    282: SetVideo (onoff)
                    283:        int onoff;
                    284: {
                    285:        return (onoff - 1);
                    286: }
                    287: 
                    288: /*ARGSUSED*/
                    289: ResolveColor (red, green, blue)
                    290:        unsigned short *red, *green, *blue;
                    291: {
                    292: }
                    293: 
                    294: /*ARGSUSED*/
                    295: StoreColors (count, entries)
                    296:        int count;
                    297:        ColorDef *entries;
                    298: 
                    299: {
                    300: }

unix.superglobalmegacorp.com

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