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

📄 ovdef.c

📁 汇编语言编的关于ov143b.asm的小程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  026  02-Jun-87  ovdef.c

        Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
*/

#include <stdio.h>
#include "ov.h"
#include "overr.h"
#include "menu.h"
#include "dialog.h"
#include "direct.h"

#define CFG_VERSION 2  /* <======<<<< incr when parameter file layout changes */

extern WINDOW cw;                      /* current window structure */

extern unsigned char vid_mode;         /* need to know video mode */
extern unsigned char vid_attrib;       /* we hack directly with video attrib */
extern unsigned char restricted;       /* NZ when some functions disabled */
extern unsigned char def_display;      /* NZ when define screen displayed */
extern unsigned char attribs[];        /* array of attrib's */
extern char *cantopen;                 /* common text message */

extern MENU top_file_menu[], *top_menu;

int def_color(), def_exit(), def_pag(), def_udk();
int def_set(), def_noset(), def_reset(), def_snow(), def_nosnow();

static MENU snow_menu[] = {
   { "Disable", "Disable \"snow\" checking", def_nosnow, NULL },
   { "Enable",  "Enable \"snow\" checking", def_snow, NULL },
   { NULL, NULL, NULL, NULL }
};

static MENU set_attr_menu[] = {
   { "Set", "Set color attributes to values shown", def_set, NULL },
   { "Reset", "Reset color attributes to prior values", def_reset, NULL },
   { "Quit", "Quit without changing color attributes", def_noset, NULL },
   { NULL, NULL, NULL, NULL }
};

static MENU top_def_menu[] = {
   { "Colors", "Select video display attributes", def_color, set_attr_menu },
   { "Snow", "Enable/disable video \"snow\" checking", NULL, snow_menu },
   { "Point-and-Go", "Modify Point-and-Go parameters", def_pag, NULL },
   { "UDK", "Modify User Defined Keys", def_udk, NULL },
   { "Quit", "Quit chaning Define parameters", def_exit, top_file_menu },
   { NULL, NULL, NULL, NULL }
};

static char *def_text[] =
   { "NORMAL TEXT            ", "HIGHLIGHTED TEXT       ",
     "WINDOW TEXT            ", "HIGHLIGHTED WINDOW TEXT",
     "HEADING TEXT           ", "BACKGROUND TEXT        ",
     "TAGGED FILE NAME TEXT  " };

static char *directions[] = {
     "PgUp & PgDn select the ", "type of text to be set.",
     "                       ", "\x18\x19\x1b\x1a select the colors." };

static int changed;
static int text_type;
static char *ovcfg = "OV.CFG";
static unsigned char newattr[7];
static char dirliteral[] = "Directions";
static char ent2up[] = "Enter number to update:";

/* allocate the dialog boxes and fields for def_*() routines */

static D_BOX text_box =  { 3, 2, 7, 25, NULL, NULL };
static D_BOX video_box = { 3, 30, 16, 48, NULL, NULL };
static D_BOX dir_box =   { 14, 2, 4, 25, NULL, dirliteral };
static D_BOX pag_box =   { 7, 10, 14, 61, NULL, "Set Point-and-Go Parameters" };
static D_BOX udk_box =   { 7, 10, 14, 62, NULL, "Set User-Defined-Keys" };
static D_FLD pag_fld;
static D_FLD udk_fld;

/****************************************************************************
 Following is the parameter area which holds all user specified parameters.
 This area is updated by the routines in OVDEF.C.  Be very very careful when
 modifying this area.  Make sure that routine def_write() is correct.
 ****************************************************************************/

static unsigned char cfgver = CFG_VERSION;   /* config layout version # */

unsigned char vid_snow = 1;            /* NZ if must chk for video snow */

/* Define the video display attributes.  One set for mono, one for CGA. */
/* The attributes are in the following order:                           */
/* DIS_NORM, DIS_HIGH, DIS_BOX, DIS_HIBOX, DIS_HEAD, DIS_TEXT, DIS_TAGD */

unsigned char monattr[] = { 0x07, 0x70, 0x0F, 0x70, 0x70, 0x07, 0x0F }; /*mono*/
unsigned char cgaattr[] = { 0x0B, 0x30, 0x0E, 0x30, 0x1B, 0x0A, 0x0E }; /* cga*/

/* Define the Point-and-Go parameters and the User-Defined-Keys */

PAG_ENT pag_tbl[NUM_PAG];
UDK_ENT udk_tbl[NUM_UDK];

/*****************************************************************************
                         End of parameter area
 *****************************************************************************/

char *getenv(), *strchr();
FILE *fopen(), *pathopen();

#ifdef LINT_ARGS
void dispagent(int), rdpagent(int);
void disudkent(int), rdudkent(int);
void ALTCALL rdyesno(D_BOX *, D_FLD *, unsigned char *, int);
char * ALTCALL rd_p_u_fld(D_BOX *, D_FLD *, int, int, char *);
void ALTCALL pag_or_udk(D_BOX *, void (*)(), void (*)(), int, char *);
#else
char * ALTCALL rd_p_u_fld();
void dispagent(), rdpagent();
void disudkent(), rdudkent();
void ALTCALL rdyesno(), ALTCALL pag_or_udk();
#endif

/*****************************************************************************
                               D E F I N E
 *****************************************************************************/

define() {     /* allow user to define various parameters */

   changed = FALSE;            /* nothing changed so far    */
   restricted = TRUE;          /* don't allow some commands */
   top_menu = top_def_menu;    /* make define menu THE menu */
}


/*****************************************************************************
                            D E F _ E X I T
 *****************************************************************************/

static int
def_exit() {           /* leave define screen parameters mode */

   int write;

   /* if the user changed anything, ask him if the parameters should be
      written to disk.  If he says yea, then do it. */

   if (changed) {
      write = ask("Write changed parameters to disk? (y/N): ");
      if (yes(write))
         def_write();
   }

   top_menu = top_file_menu;           /* file menu again */
   restricted = FALSE;                 /* allow everything again */
}


/*****************************************************************************
                            D E F _ C O L O R
 *****************************************************************************/

static int
def_color() {          /* define screen "colors" */

   strncpy(newattr,attribs,sizeof(newattr));   /* start with current attribs */

   def_display = TRUE;                 /* define color display is active */
   restricted = FALSE;                 /* allow the cursor keys to work  */
   top_menu = set_attr_menu;           /* so ESC doesn't leave this menu */

   def_init();                         /* actually setup the color display */

   select_t(1,text_type = DIS_NORM);   /* highlight normal text first */
   select_a(1,newattr[text_type]);     /* highlight current attr location */
}


/*****************************************************************************
                            D E F _ x S E T
 *****************************************************************************/

static int
def_set() {            /* use the currently displayed video attributes */

   changed = TRUE;                             /* assume they changed some */
   strncpy(attribs,newattr,sizeof(newattr));   /* SET the current values */
   do_set();                                   /* rest of stuff */
}

static int
def_noset() {          /* back to the prior values */

   strncpy(newattr,attribs,sizeof(newattr));   /* back to current */
   do_set();
}

static int
def_reset() {          /* reset to OverView default/config file value */

   changed = TRUE;                             /* assume some change */
   strncpy(attribs,vid_mode == 7 ? monattr : cgaattr,sizeof(newattr));
   strncpy(newattr,attribs,sizeof(newattr));   /* back to default */
   do_set();
}

static int
do_set() {
   setup_file_scr();                           /* rewrite file screen */
   update_header();                            /* to use possible new colors */
   refresh_screen(0);

   restricted = TRUE;                          /* disable cursor keys    */
   def_display = FALSE;                        /* back to normal display */
   top_menu = top_def_menu;                    /* back to define menu    */
}


/*****************************************************************************
                            D E F _ I N I T
 *****************************************************************************/

static int
def_init() {           /* initialize the define colors screen */

   int i, fg;
   register int bg;

   /* initialize the screen image */

   setvattrib(DIS_NORM);

   clr_scr();
   center_text(0,"DEFINE SCREEN COLORS");

   disp_status();                              /* status line */

   setvattrib(DIS_BOX);                        /* box to enclose text types */
   dbx_open(&text_box,0);

   for (i = DIS_NORM; i <= DIS_TAGD; i++)      /* display text types */
      select_t(0,i);

   setvattrib(DIS_BOX);                        /* box to enclose pattern */
   dbx_open(&video_box,0);

   for (fg = 0; fg < 16; fg++) {               /* display color pattern */
      dbx_goto(&video_box,fg,0);
      for (bg = 0; bg < 8; bg++) {
         vid_attrib = (bg << 4) | fg;
         disp_str(" TEXT ");
      }
   }

   setvattrib(DIS_BOX);               /* box for directions/instructions */
   dbx_open(&dir_box,0);

   for(i = 0; i < 4; i++)                      /* display the directions */
      dbx_disp(&dir_box,directions[i],i,1);

   setvattrib(DIS_NORM);       /* back to "Normal" */

}


/****************************************************************************
                          P A G _ O R _ U D K
 ***************************************************************************/

void ALTCALL
pag_or_udk(dbp,df,rf,num_ent,head)     /* define PAG or UDK entries */
D_BOX *dbp;
void (*df)();
void (*rf)();
int num_ent;
char *head;
{
   char *tmp;
   register int i;
   static D_FLD num_fld = { 13, 40, 3, 0, "   " };

   /* pop up the dialog box to use */

   setvattrib(DIS_BOX);                /* open dialog box */
   dbx_open(dbp,DBX_SAVE);

   setvattrib(DIS_HEAD);               /* display header */
   dbx_disp(dbp,head,0,0);

   setvattrib(DIS_BOX);                /* display existing entries */
   for (i = 0; i < num_ent; i++)
      (*df)(i);

   dbx_disp(dbp,ent2up,13,16);         /* entry to update msg */

   /* read entries from user */

   while (TRUE) {
      setvattrib(DIS_HIBOX);

      if (!*(tmp = dbx_rdfld(dbp,&num_fld)))   /* get # of ent to read */
         break;

      i = atoi(tmp) - 1;                       /* ascii to integer     */

      if (i >= 0 && i < num_ent) {             /* within range?        */
         (*df)(i);                             /* disp ent with HIBOX  */
         (*rf)(i);                             /* read it from user    */
         setvattrib(DIS_BOX);                  /* redisplay with BOX   */
         (*df)(i);                             /* disp ent with HIBOX  */
      }
   }

   setvattrib(DIS_NORM);       /* back to normal */

   dbx_close(dbp);             /* close the dialog box */
}


/*****************************************************************************
                              D E F _ P A G
 *****************************************************************************/

static int
def_pag() {    /* define the Point and Go parameters */

   pag_or_udk(&pag_box,dispagent,rdpagent,NUM_PAG,
              " NUM EXT  COMMAND PROTOTYPE                       PAUSE READ ");
}


/**************************************************************************
                           D I S P A G E N T
 **************************************************************************/

#define NUM_COL (1)            /* offsets within the PAG dialog box */
#define EXT_COL (5)
#define CMD_COL (10)
#define PAUSE_COL (52)
#define READ_COL (58)

static void
dispagent(ent) /* display PAG entry number ent */
int ent;
{
   int row = ent + 2;
   register PAG_ENT *pp = &pag_tbl[ent];

   dbx_goto(&pag_box,row,NUM_COL);
   out_int(ent+1,3,' ');
   dbx_goto(&pag_box,row,EXT_COL);
   out_str(pp->used ? pp->ext : "",sizeof(pp->ext)-1,' ');
   dbx_goto(&pag_box,row,CMD_COL);
   out_str(pp->used ? pp->cmd : "",sizeof(pp->cmd)-1,' ');
   dbx_disp(&pag_box,pp->used ? (pp->pause ? "Y" : "N") : " ",row,PAUSE_COL);
   dbx_disp(&pag_box,pp->used ? (pp->reload ? "Y" : "N") : " ",row,READ_COL);
}

/*****************************************************************************
                              R D P A G E N T
 ****************************************************************************/

static void
rdpagent(ent)  /* read a PAG entry from the user */
int ent;
{
   int row = ent + 2;
   register PAG_ENT *pp = &pag_tbl[ent];

   pag_fld.pos = 0;
   pag_fld.row = row;

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

   if (*rd_p_u_fld(&pag_box,&pag_fld,EXT_COL,sizeof(pp->ext)-1,pp->ext)) {

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

      /* read command prototype field */

⌨️ 快捷键说明

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