⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ovdef.c

📁 汇编语言编的关于ov143b.asm的小程序
💻 C
📖 第 1 页 / 共 2 页
字号:

      rd_p_u_fld(&pag_box,&pag_fld,CMD_COL,sizeof(pp->cmd)-1,pp->cmd);

      rdyesno(&pag_box,&pag_fld,&pp->pause,PAUSE_COL); /* pause after running */
      rdyesno(&pag_box,&pag_fld,&pp->reload,READ_COL); /* reread dir after    */

   } else {            /* blank ext field, no entry */

      *pp->ext = *pp->cmd = '\0';
      pp->used = pp->pause = pp->reload = 0;
   }

   changed = TRUE;             /* assume something changed */
}

#undef NUM_COL
#undef EXT_COL
#undef CMD_COL
#undef PAUSE_COL
#undef READ_COL


/*****************************************************************************
                              D E F _ U D K
 *****************************************************************************/

static int
def_udk() {    /* define the User Defined Keys */

   pag_or_udk(&udk_box,disudkent,rdudkent,NUM_UDK,
              " NUM  KEY  COMMAND PROTOTYPE                       PAUSE READ ");
}

/**************************************************************************
                           D I S U D K E N T
 **************************************************************************/

#define NUM_COL (1)            /* offsets within the UDK dialog box */
#define KEY_COL (5)
#define CMD_COL (11)
#define PAUSE_COL (53)
#define READ_COL (59)

static void
disudkent(ent) /* display UDK entry number ent */
int ent;
{
   int row = ent + 2;
   register UDK_ENT *up = &udk_tbl[ent];

   dbx_goto(&udk_box,row,NUM_COL);
   out_int(ent+1,2,' ');
   dbx_disp(&udk_box,"A-F",row,KEY_COL);
   out_int(ent+1,1+(ent >= 9),' ');
   dbx_goto(&udk_box,row,CMD_COL);
   out_str(up->used ? up->cmd : "",sizeof(up->cmd)-1,' ');
   dbx_disp(&udk_box,up->used ? (up->pause ? "Y" : "N") : " ",row,PAUSE_COL);
   dbx_disp(&udk_box,up->used ? (up->reload ? "Y" : "N") : " ",row,READ_COL);
}


/*****************************************************************************
                              R D U D K E N T
 ****************************************************************************/

static void
rdudkent(ent)  /* read a UDK entry from the user */
int ent;
{
   int row = ent + 2;
   register UDK_ENT *up = &udk_tbl[ent];

   udk_fld.pos = 0;
   udk_fld.row = row;

   /* read the CMD field for this entry, if nothing is read, blank (delete)
      this entry. */

   if (*rd_p_u_fld(&udk_box,&udk_fld,CMD_COL,sizeof(up->cmd)-1,up->cmd)) {

      up->used = 1;            /* cmd isn't blank, entry in use */

      rdyesno(&udk_box,&udk_fld,&up->pause,PAUSE_COL); /* pause after running */
      rdyesno(&udk_box,&udk_fld,&up->reload,READ_COL); /* read dir            */

   } else {            /* blank cmd field, no entry */

      *up->cmd = '\0';
      up->used = up->pause = up->reload = 0;
   }

   changed = TRUE;             /* assume something changed */
}

#undef NUM_COL
#undef KEY_COL
#undef CMD_COL
#undef PAUSE_COL
#undef READ_COL


/***************************************************************************
                          R D _ P _ U _ F L D
 ***************************************************************************/

static char * ALTCALL
rd_p_u_fld(dbp,dfp,col,len,value)      /* read 1 pag or udk field from user */
D_BOX *dbp;
register D_FLD *dfp;
int col, len;
char *value;
{
   char *tmp;

   dfp->col = col;
   dfp->len = len;
   dfp->value = value;
   if (*(tmp = dbx_rdfld(dbp,dfp)))
      strcpy(dfp->value,tmp);
   return(tmp);
}


/****************************************************************************
                               R D Y E S N O
 ****************************************************************************/

static void ALTCALL
rdyesno(dbp,dfp,ynp,col)       /* read a yes/no value into a 0/1 integer */
D_BOX *dbp;
D_FLD *dfp;
unsigned char *ynp;
int col;
{
   char yesno[2];

   *yesno = *ynp ? 'Y' : 'N';          /* convert 0/NZ to Y/N */
   yesno[1] = '\0';

   rd_p_u_fld(dbp,dfp,col,1,yesno);    /* read from user      */
   *ynp = yes(*yesno);                 /* convert Y/N to 0/1  */
}


/*****************************************************************************
                       D E F _ S N O W / N O S N O W
 *****************************************************************************/

static int
def_snow() {   /* enable video snow checking */

   vid_snow = 1;
   changed = TRUE;
}

static int
def_nosnow() { /* disable snow checking */

   vid_snow = 0;
   changed = TRUE;
}


/*****************************************************************************
                            D E F _ R E A D
 *****************************************************************************/

def_read() {   /* read parameters from configuration file */

   FILE *cfg;
   unsigned char filever = 0;

   /* try to open the CFG (configuration) file somewhere in the current
      PATH - if we don't find an existing file assume there isn't one and
      use the default values */

   if ((cfg = pathopen(ovcfg,"rb")) == NULL)   /* try to open config file */
      return;                                  /* must not be one, exit   */

   /* make sure we know how to read this form of config file */

   fread(&filever,1,1,cfg);
   if (filever != CFG_VERSION) {
      show_error(0,0,1,"Obsolete configuration file, defaults used");
      return;
   }

   /* looks okay, read parameters */

   fread(&vid_snow,1,1,cfg);                     /* read video snow flag   */
   fread(monattr,sizeof(monattr),1,cfg);         /* then mono video attr's */
   fread(cgaattr,sizeof(cgaattr),1,cfg);         /* then cga  video attr's */
   fread((char *)pag_tbl,sizeof(pag_tbl),1,cfg); /* then Point-and-Go tbl  */
   fread((char *)udk_tbl,sizeof(udk_tbl),1,cfg); /* then User-Defined-Keys */

   fclose(cfg);                                  /* done reading, close */

   /* attributes have been read, copy them to the in-use attributes */

   strncpy(attribs,vid_mode == 7 ? monattr : cgaattr,sizeof(newattr));
}


/*****************************************************************************
                            D E F _ W R I T E
 *****************************************************************************/

static int
def_write() {  /* write the updated parameters to disk */

   char *sp;
   FILE *cfg;
   register int ch;
   static char *nowrit = " - parameters not written";

   /* try to open the CFG (configuration) file somewhere in the current
      PATH - if we don't find an existing file, ask the user where he
      wants it created */

   if ((cfg = pathopen(ovcfg,"r+b")) == NULL) {
      char cfgmsg[80];

      strcpy(cfgmsg,"Can't find ");
      strcat(cfgmsg,ovcfg);
      strcat(cfgmsg,", enter target directory (ENTER = current, ESC to quit):");

      sp = prompt(NULL,cfgmsg,cw.dirbuf,strlen(cw.dirbuf),MAX_PATHLEN);

      if (strlen(sp)) {
         char cfgbuf[MAX_PATHLEN+MAX_NAMELEN+3];

         strcpy(cfgbuf,sp);                            /* build full pathname */
         if ((ch = cfgbuf[strlen(cfgbuf)-1]) != '\\' && ch != '/' && ch != ':')
            strcat(cfgbuf,"\\");
         strcat(cfgbuf,ovcfg);

         if ((cfg = fopen(cfgbuf,"w+b")) == NULL) {    /* try to open 4 WRITE */
            show_error(0,0,3,cantopen,ovcfg,nowrit);   /* give up if can't opn*/
            return;
         }

      } else                   /* user must have ESCaped out, just exit */
         return;

   } else                      /* pathopen() found it! */

      fseek(cfg,0L,SEEK_CUR);  /* was opened 4 READ, seek so we can write */

   /*** CFG file is now open, write the parameters ***/

   /* now that parms are being written, make video attrib's "permanent" */

   strncpy(vid_mode == 7 ? monattr : cgaattr,attribs,sizeof(newattr));

   fwrite(&cfgver,1,1,cfg);                /* start with config file version */
   fwrite(&vid_snow,1,1,cfg);                      /* then video snow flag   */
   fwrite(monattr,sizeof(monattr),1,cfg);          /* then mono video attr's */
   fwrite(cgaattr,sizeof(cgaattr),1,cfg);          /* then cga  video attr's */
   fwrite((char *)pag_tbl,sizeof(pag_tbl),1,cfg);  /* then Point-and-Go tbl  */
   fwrite((char *)udk_tbl,sizeof(udk_tbl),1,cfg);  /* then User-Defined-Keys */

   fclose(cfg);                                /* done, close */
}


/*****************************************************************************
                            D E F _ M O V E
 *****************************************************************************/

def_move(dir)          /* move the attribute pointer in given direction */
int dir;
{
   register unsigned int fbg, attr = newattr[text_type];

   select_a(0,attr);                   /* always deselect video attribute */

   if (dir == PGUP || dir ==PGDN)      /* maybe deselect text type */
      select_t(0,text_type);

   switch (dir) {

      case UP:                                 /* up arrow of course */

         if (fbg = attr & 15)
            attr = (attr & 0x70) | (fbg - 1);
         else
            attr = (attr & 0x70) | 15;         /* wraps to bottom */
         break;

      case DOWN:                               /* down arrow */

         if ((fbg = attr & 15) < 15)
            attr = (attr & 0x70) | (fbg + 1);
         else
            attr = attr & 0x70;                /* wraps to top */
         break;

      case LEFT:                               /* left arrow */

         if (fbg = (attr >> 4) & 7)
            attr = ((fbg - 1) << 4) | (attr & 15);
         else
            attr = 0x70 | (attr & 15);         /* wraps to right */
         break;

      case RIGHT:                              /* right arrow */

         if ((fbg = (attr >> 4) & 7) < 7)
            attr = ((fbg + 1) << 4) | (attr & 15);
         else
            attr = attr & 15;                  /* wraps to left */
         break;

      case PGUP:                               /* page up - new text type */

         if (text_type)
            --text_type;
         else
            text_type = 6;
         break;

      case PGDN:                               /* page dn - new text type */

         if (text_type < 6)
            ++text_type;
         else
            text_type = 0;
         break;
   }

   if (dir == PGUP || dir ==PGDN)              /* maybe select new text type */
      attr = newattr[text_type];               /* set attribute for new type */

   select_a(1,attr);                   /* show new attribute */
   newattr[text_type] = attr;          /* remember what it is */

   select_t(1,text_type);              /* display name in new attr */

   setvattrib(DIS_NORM);               /* stick with norm for now */
}


/*****************************************************************************
                            S E L E C T _ A
 *****************************************************************************/

static int
select_a(on_off,attr)  /* highlight the current attribute */
register int on_off, attr;
{
   vid_attrib = attr;                  /* gotta use this attribute */

   dbx_disp(&video_box,on_off ? "\x10TEXT\x11" : " TEXT ",  /* (de)select */
            (attr & 15),((attr >> 4) * 6));
}


/*****************************************************************************
                            S E L E C T _ T
 *****************************************************************************/

static int
select_t(on_off,type)  /* highlight the current text type */
register int on_off, type;
{
   vid_attrib = newattr[type];         /* gotta use this attribute */

   /* display pointer, name, pointer */

   dbx_goto(&text_box,type,0);
   disp_char(on_off ? 0x10 : ' ');
   disp_str(def_text[type]);
   disp_char(on_off ? 0x11 : ' ');
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -