home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- * *
- * The H.C.W.P. Library contains code that addresses the need to do what *
- * may be considered low-level processing. From locating the cursor to *
- * char-by-char input, these are the routines that amount to the "ante" *
- * in a poker game. Without them you go nowhere fast. *
- * *
- * These routines are optimized for PC hardware. They are not, in many *
- * cases, portable across platform boundaries. This software is written *
- * to run on a PC, AT or what have you. IF I ever need to change platforms *
- * then I will worry about it. I don't think it will happen. *
- * *
- * Every effort has been made to write code that is OBVIOUS. Those who *
- * seek brief or "cute" code will be dis-appointed. I hope the code can *
- * jump off the screen into my, and maybe even your head. *
- * *
- * BEFORE COMPILING THIS FILE: *
- * *
- * The char_ok, del_char, inpt and check_heap routines at the end of this *
- * file and their prototypes have been commented out as I am using routines *
- * that are "a little more complex" for input, and the check_heap function *
- * is not in use unless I'm having a heap problem. *
- * *
- * To compile MAGEDEMO.C you'll need to un-comment the inpt routine and *
- * it's two friends, char_ok and del_char. You will also need to remove *
- * the same commenting code in HCWP_LIB.H. *
- * *
- * Here's a lot of work for free. If you use it PLEASE register DATAMAGE! *
- * *
- *****************************************************************************/
-
- #include <malloc.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <dos.h>
-
- typedef char SBYTE;
- typedef unsigned char BYTE;
-
- typedef short SWORD;
- typedef unsigned short WORD;
-
- typedef long SDWORD;
- typedef unsigned long DWORD;
-
- BYTE attr, /* stores attribute, see get_vs function */
- color_enable, /* 0 = no color, 1 = can diaplay color */
- ctrl_val, /* global byte, 1 of 2 */
- nrml_val, /* global byte, 2 of 2 */
- lptr, /* holds number of active printer */
- cga_sw = 0, /* 1=comand line NO direct screen writes */
- kybd_type, /* 1=103 key, 0=old style */
-
- user_enty [255], /* string to point the inpt routine at
- or, is that, at which to point? */
-
- org_str [81], /* holds original path */
-
- prompts [10] [40], /* string space for get_v_choice */
-
- c_s [3] [255], /* string space for cntrstrp
- and decoder functions */
-
- gp_str [20] [255], /* provides 20 general-purpose global strings */
-
- far * v_ram; /* pointer to video ram - set by get_vs function */
-
- SWORD char_cntr; /* holds lpt pos for various lpt routines */
-
- union REGS regs;
-
- typedef struct
- {
- BYTE ulr;
- BYTE ulc;
- BYTE lrr;
- BYTE lrc;
-
- BYTE attr;
-
- BYTE far * save;
- } window_array;
-
- /* allocate 10 windows */
-
- window_array w_a [10];
-
- /* FUNCTIONS IN HCWP_LIB */
-
- void far range_msg ();
- void far despacer (BYTE);
-
- void far get_vs ();
-
- void far cls ();
- void far clw (BYTE);
- void far c_clw (BYTE, BYTE);
-
- void far beep ();
-
- BYTE far set_window (BYTE, BYTE, BYTE ,
- BYTE, BYTE, BYTE, BYTE);
-
- void far window_border (BYTE);
- void far scroll_window (BYTE, BYTE, BYTE);
- BYTE far save_window (BYTE);
- void far repl_window (BYTE);
-
- void far _fastcall tele_out (BYTE);
-
- BYTE far s_read_char ();
- BYTE far s_read_attr ();
-
- void far _fastcall crt_out (BYTE);
- void far _fastcall c_crt_out (BYTE, BYTE);
-
- void far prnt (BYTE *);
- void far f_prnt (BYTE far *);
-
- void far clr_prnt (BYTE *, BYTE);
- void far f_clr_prnt (BYTE far *, BYTE);
-
- void far _fastcall line_out (BYTE, BYTE);
-
- DWORD far get_timer ();
- void far wait (BYTE);
-
- void far _fastcall locate (BYTE, BYTE);
- void far nrml_cursor ();
- void far no_cursor ();
- void far full_cursor ();
- void far find_cursor (BYTE *, BYTE *);
-
- void far lpt_char (BYTE);
- void far lpt_spaces (BYTE);
- void far lpt_string (BYTE *);
- void far lpt_f_string (BYTE far *);
- void far lpt_tab (WORD);
-
- void far lpt_eol ();
- void far lpt_blanks (BYTE);
-
- void far lpt_line (BYTE, BYTE);
-
- void far get_kybd_type ();
- void far _fastcall get_one (BYTE *, BYTE *);
- BYTE far check_shift ();
-
- BYTE far get_choice (BYTE);
- void far y_n ();
- void far n_y ();
-
- BYTE far get_v_choice (BYTE, BYTE, BYTE *);
-
- void far flush_kybd ();
- BYTE far check_kybd ();
-
- void far see_screen ();
-
- void far rtrim (BYTE *);
- BYTE far cntrstrp ();
-
- void far output_fail ();
- void far mem_fail ();
-
- void far write_eol (FILE *);
- void far eol_strip (BYTE *);
-
- void far show_help (BYTE * helpfile);
-
- void far set_far (BYTE far *, BYTE *, WORD);
- void far set_farst (BYTE far *, BYTE *);
-
- void far get_far (BYTE *, BYTE far *, WORD);
- void far get_farst (BYTE *, BYTE far *);
-
- BYTE far dlr_format (BYTE, BYTE);
-
- void far hard_err (BYTE, BYTE, BYTE far *);
-
- BYTE far parse_date (BYTE *, BYTE *, BYTE *,
- BYTE *, WORD *, double *);
-
- void far ipt_box (BYTE, BYTE, BYTE, BYTE,
- BYTE, BYTE, BYTE *);
-
- // BYTE far inpt (BYTE, BYTE, BYTE, BYTE,
- // BYTE, BYTE, BYTE *);
-
- // void far check_heap ();
-
- /*-------------------------------------------------------------------------*/
-
- void far range_msg ()
- {
- clw (3); beep(); locate (22, 24);
-
- prnt ("RESPONCE OUT OF RANGE - TRY AGAIN");
-
- wait (4);
- }
-
- void far despacer (BYTE cnvt_case)
- {
- BYTE c = 0, d = 0, len = strlen (c_s [0]);
-
- while (c < len)
- {
- if (c_s [0] [c] != 32)
- {
- c_s [2] [d] = c_s [0] [c];
-
- if (cnvt_case && (c_s [2] [d] > 64 && c_s [2] [d] < 91))
- c_s [2] [d] += 32;
-
- d++;
- }
-
- c++;
- }
-
- c_s [2] [d] = 0;
- }
-
- BYTE far cntrstrp ()
-
- /* combines two strings in c_s [0] and c_s [1], returns number of chars to
- space over to center strings. */
- {
- BYTE wfg = 0, addsw = 0, x, y;
-
- rtrim (c_s [0]); rtrim (c_s [1]);
-
- while (! wfg)
- {
- strcpy (c_s [2], c_s [0]);
- strcat (c_s [2], " ");
-
- if (addsw) strcat (c_s [2], " ");
-
- strcat (c_s [2], c_s [1]);
-
- x = y = strlen (c_s [2]);
-
- /* emulate BASIC's MOD function */
-
- while (y >= 2) y -= 2;
-
- if (y) addsw = 1;
- else wfg = 1;
- }
-
- return ((80 - x) / 2);
- }
-
- void far set_farst (BYTE far * target, BYTE * source)
- {
- /* sets near string into far memory */
-
- WORD register x = 0;
-
- while (source [x] && source [x] != 10 && source [x] != 13)
- target [x++] = source [x];
-
- target [x] = 0;
- }
-
- void far get_farst (BYTE * target, BYTE far * source)
- {
- /* sets far string into near memory */
-
- WORD register x = 0;
-
- while (source [x]) target [x++] = source [x];
-
- target [x] = 0;
- }
-
- void far set_far (BYTE far * target, BYTE * source, WORD count)
- {
- /* sets near BYTES into far BYTES */
-
- WORD register x;
-
- for (x = 0; x < count; x++) * (target + x) = * (source + x);
- }
-
- void far get_far (BYTE * target, BYTE far * source, WORD count)
- {
- /* sets far BYTES into near BYTES */
-
- WORD register x = 0;
-
- while (x < count) * (target + x++) = * (source + x);
- }
-
- void far _fastcall locate (BYTE row, BYTE col)
- {
- /* locates the cursor */
-
- regs.h.ah = 2; regs.h.bh = 0;
- regs.h.dh = row; regs.h.dl = col;
-
- int86 (16, ®s, ®s);
- }
-
- void far find_cursor (BYTE * row, BYTE * col)
- {
- /* finds cursor */
-
- regs.h.ah = 3;
- regs.h.al = 0;
-
- int86 (16, ®s, ®s);
-
- * row = regs.h.dh;
- * col = regs.h.dl;
- }
-
- void far nrml_cursor ()
- {
- /* sets normal cursor */
-
- regs.h.ah = 1;
- regs.h.cl = 7;
- regs.h.ch = 6;
-
- int86 (16, ®s, ®s);
- }
-
- void far full_cursor ()
- {
- /* sets fat cursor */
-
- regs.h.ah = 1;
- regs.h.cl = 7;
- regs.h.ch = 0;
-
- int86 (16, ®s, ®s);
- }
-
- void far no_cursor ()
- {
- /* turns cursor off */
-
- regs.h.ah = 1;
- regs.h.ch = 32;
- regs.h.cl = 0;
-
- int86 (16, ®s, ®s);
- }
-
- void far prnt (BYTE * target)
- {
- /* prints target string to screen */
-
- BYTE register y = 0;
-
- BYTE row, col, far * t_ram;
-
- switch (cga_sw)
- {
- case 2: _disable;
-
- case 0:
- {
- find_cursor (& row, & col);
-
- t_ram = v_ram + (row * 160) + (col * 2);
-
- while (target [y])
- {
- if (cga_sw == 2)
- {
- _asm
- {
- mov dx, 986
-
- Loop1:
-
- in al, dx
- and al, 1
- jnz Loop1
-
- Loop2:
-
- in al, dx
- and al, 1
- je Loop2
- }
-
- }
-
- * t_ram = target [y++];
-
- t_ram += 2;
- }
-
- locate (row, col + y);
-
- _enable;
-
- break;
- }
-
- case 1:
- {
- while (target [y])
- {
- regs.h.ah = 14;
- regs.h.al = target [y++];
-
- int86 (16, ®s, ®s);
- }
- }
-
- }
-
- }
-
- void far f_prnt (BYTE far * target)
- {
- /* prints FAR target string to screen */
-
- BYTE register y = 0;
-
- BYTE row, col, far * t_ram;
-
- switch (cga_sw)
- {
- case 2: _disable;
-
- case 0:
- {
- find_cursor (& row, & col);
-
- t_ram = v_ram + (row * 160) + (col * 2);
-
- while (target [y])
- {
- if (cga_sw == 2)
- {
- _asm
- {
- mov dx, 986
-
- Loop1:
-
- in al, dx
- and al, 1
- jnz Loop1
-
- Loop2:
-
- in al, dx
- and al, 1
- je Loop2
- }
-
- }
-
- * t_ram = target [y++];
-
- t_ram += 2;
- }
-
- locate (row, col + y);
-
- _enable;
-
- break;
- }
-
- case 1:
- {
- while (target [y])
- {
- regs.h.ah = 14;
- regs.h.al = target [y++];
-
- int86 (16, ®s, ®s);
- }
-
- }
-
- }
-
- }
-
- void far clr_prnt (BYTE * target, BYTE attr)
- {
- /* prints string on screen with color passed */
-
- BYTE row, col, y = 0;
-
- BYTE far * t_ram;
-
- find_cursor (& row, & col);
-
- switch (cga_sw)
- {
- case 2: _disable;
-
- case 0:
- {
- t_ram = v_ram + (row * 160) + (col * 2);
-
- while (target [y])
- {
- /* if cga in use */
-
- if (cga_sw == 2)
- {
- _asm
- {
- mov dx, 986
-
- Loop1:
-
- in al, dx
- and al, 1
- jnz Loop1
-
- Loop2:
-
- in al, dx
- and al, 1
- je Loop2
- }
-
- }
-
- * (t_ram++) = target [y++];
-
- /* if cga in use */
-
- if (cga_sw == 2)
- {
- _asm
- {
- mov dx, 986
-
- Loop3:
-
- in al, dx
- and al, 1
- jnz Loop3
-
- Loop4:
-
- in al, dx
- and al, 1
- je Loop4
- }
-
- }
-
- /* store attribute */
-
- * (t_ram++) = attr;
- }
-
- locate (row, col + y);
-
- _enable;
-
- break;
- }
-
- case 1:
- {
- regs.h.dh = row; regs.h.dl = col; regs.h.bh = 0;
-
- while (target [y])
- {
- regs.h.ah = 9;
- regs.h.al = target [y++];
- regs.h.bl = attr;
- regs.x.cx = 1;
-
- int86 (16, ®s, ®s);
-
- regs.h.ah = 2;
- regs.h.dl++;
-
- int86 (16, ®s, ®s);
- }
-
- }
-
- }
-
- }
-
- void far f_clr_prnt (BYTE far * target, BYTE attr)
- {
- /* prints FAR string on screen with color passed */
-
- BYTE row, col, y = 0;
-
- BYTE far * t_ram;
-
- find_cursor (& row, & col);
-
- switch (cga_sw)
- {
- case 2: _disable;
-
- case 0:
- {
- t_ram = v_ram + (row * 160) + (col * 2);
-
- while (target [y])
- {
- /* if cga in use */
-
- if (cga_sw == 2)
- {
- _asm
- {
- mov dx, 986
-
- Loop1:
-
- in al, dx
- and al, 1
- jnz Loop1
-
- Loop2:
-
- in al, dx
- and al, 1
- je Loop2
- }
-
- }
-
- * (t_ram++) = target [y++];
-
- /* if cga in use */
-
- if (cga_sw == 2)
- {
- _asm
- {
- mov dx, 986
-
- Loop3:
-
- in al, dx
- and al, 1
- jnz Loop3
-
- Loop4:
-
- in al, dx
- and al, 1
- je Loop4
- }
-
- }
-
- /* store attribute */
-
- * (t_ram++) = attr;
- }
-
- locate (row, col + y);
-
- _enable;
-
- break;
- }
-
- case 1:
- {
- regs.h.dh = row; regs.h.dl = col; regs.h.bh = 0;
-
- while (target [y])
- {
- regs.h.ah = 9;
- regs.h.al = target [y++];
- regs.h.bl = attr;
- regs.x.cx = 1;
-
- int86 (16, ®s, ®s);
-
- regs.h.ah = 2;
- regs.h.dl++;
-
- int86 (16, ®s, ®s);
- }
-
- }
-
- }
-
- }
-
- void far mem_fail ()
- {
- clw (3); locate (22, 25);
- prnt ("This computer's out of memory!");
- beep (); wait (4);
- }
-
- void far cls ()
- {
- /* clears entire screen to color in attr */
-
- regs.h.ah = 7; regs.h.al = 0;
- regs.h.ch = 0; regs.h.cl = 0;
- regs.h.dh = 24; regs.h.dl = 79;
- regs.h.bh = attr;
-
- int86 (16, ®s, ®s);
- }
-
- void far clw (BYTE w)
- {
- /* clears windows to their color */
-
- regs.h.ah = 7; regs.h.al = 0;
- regs.h.ch = w_a [w]. ulr;
- regs.h.cl = w_a [w] .ulc;
- regs.h.dh = w_a [w] .lrr;
- regs.h.dl = w_a [w] .lrc;
- regs.h.bh = w_a [w] .attr;
-
- int86 (16, ®s, ®s);
- }
-
- void far c_clw (BYTE w, BYTE atr)
- {
- /* clears windows to specified color */
-
- regs.h.ah = 7; regs.h.al = 0;
- regs.h.ch = w_a [w]. ulr;
- regs.h.cl = w_a [w] .ulc;
- regs.h.dh = w_a [w] .lrr;
- regs.h.dl = w_a [w] .lrc;
- regs.h.bh = atr;
-
- int86 (16, ®s, ®s);
- }
-
- void far get_vs ()
- {
- /* gets video adaptor type, color or mono */
-
- BYTE d, test;
-
- regs.h.ah = 15;
- int86 (16, & regs, & regs);
-
- if (regs.h.ah != 80) {attr = 0; return;}
-
- locate (0,0);
-
- /* test for mono */
-
- v_ram = (BYTE far *) 0xb0000000;
-
- test = * v_ram; * v_ram = 255;
-
- d = s_read_char ();
-
- if (d == 255) {attr = 7; color_enable = 0;}
-
- /* must be color */
-
- else
- {
- * v_ram = test;
-
- attr = 27; color_enable = 1;
-
- v_ram = (BYTE far *) 0xb8000000;
- }
-
- }
-
- BYTE far set_window (BYTE w, BYTE ulr, BYTE ulc, BYTE lrr,
- BYTE lrc, BYTE attr, BYTE save_it)
- {
- /* defines window */
-
- WORD size;
-
- w_a [w]. ulr = ulr;
- w_a [w]. ulc = ulc;
- w_a [w]. lrr = lrr;
- w_a [w]. lrc = lrc;
- w_a [w]. attr = attr;
-
- if (save_it)
- {
- size = ((w_a [w] .lrc - w_a [w] .ulc + 1)
- * (w_a [w] .lrr - w_a [w] .ulr + 1)) * 2;
-
- if ((w_a [w].save = _fmalloc (size) ) == NULL)
- {mem_fail(); return (1);}
-
- }
-
- else w_a [w].save = NULL;
-
- return (0);
- }
-
- void far scroll_window (BYTE w, BYTE ctrl, BYTE lines)
- {
- /* scrolls windows up/down */
-
- BYTE ud;
-
- switch (ctrl)
- {
- case 1: ud = 6; break;
-
- case 2: ud = 7;
- }
-
- regs.h.ah = ud; regs.h.al = lines;
- regs.h.ch = w_a [w] .ulr;
- regs.h.cl = w_a [w] .ulc;
- regs.h.dh = w_a [w] .lrr;
- regs.h.dl = w_a [w] .lrc;
- regs.h.bh = w_a [w] .attr;
-
- int86 (16, ®s, ®s);
- }
-
- BYTE far save_window (BYTE w)
- {
- /* saves text in windows */
-
- BYTE c, cols, d, r, rows, x;
-
- BYTE far * incr, far * v_tgt;
-
- rows = w_a [w] .lrr - w_a [w] .ulr + 1;
- cols = (w_a [w] .lrc - w_a [w] .ulc + 1) * 2;
-
- if (cga_sw != 1)
- {
- if (cga_sw == 2) _disable;
-
- for (r = 0; r < rows; r++)
- {
- v_tgt = v_ram + (((w_a [w].ulr + r) * 160)
- + (w_a [w].ulc * 2));
-
- incr = w_a [w] .save + (r * cols);
-
- for (c = x = 0; c < cols;)
- {
- /* if cga in use */
-
- if (cga_sw == 2)
- {
- _asm
- {
- mov dx, 986
-
- Loop1:
-
- in al, dx
- and al, 1
- jnz Loop1
-
- Loop2:
-
- in al, dx
- and al, 1
- je Loop2
- }
-
- }
-
- /* read char */
-
- * (incr + c++) = * (v_tgt + x++);
-
- /* if cga in use */
-
- if (cga_sw == 2)
- {
- _asm
- {
- mov dx, 986
-
- Loop3:
-
- in al, dx
- and al, 1
- jnz Loop3
-
- Loop4:
-
- in al, dx
- and al, 1
- je Loop4
- }
-
- }
-
- /* read attribute */
-
- * (incr + c++) = * (v_tgt + x++);
- }
-
- }
-
- _enable;
- }
-
- else
- {
-
- regs.h.bl = 0; regs.h.bh = 0;
-
- for (r = 0; r < rows; r++)
- {
- incr = w_a [w] .save + (r * cols);
-
- regs.h.dh = w_a [w] .ulr + r;
-
- for (d = c = 0; c < cols;)
- {
- /* locate */
-
- regs.h.ah = 2;
- regs.h.dl = w_a [w] .ulc + (d++);
-
- int86 (16, ®s, ®s);
-
- /* get char and attribute */
-
- regs.h.ah = 8;
- int86 (16, ®s, ®s);
-
- * (incr + c++) = regs.h.al;
- * (incr + c++) = regs.h.ah;
- }
-
- }
-
- }
-
- return (0);
- }
-
- void far repl_window (BYTE w)
- {
- /* replaces previously saved text into windows - WINDOW MUST BE SAVED first! */
-
- BYTE c, cols, d, r, rows, x;
-
- BYTE far * incr, far * v_tgt;
-
- rows = w_a [w] .lrr - w_a [w] .ulr + 1;
- cols = (w_a [w] .lrc - w_a [w] .ulc + 1) * 2;
-
- if (cga_sw != 1)
- {
- if (cga_sw == 2) _disable;
-
- for (r = 0; r < rows; r++)
- {
- v_tgt = v_ram + (((w_a [w].ulr + r) * 160)
- + (w_a [w].ulc * 2));
-
- incr = w_a [w] .save + (r * cols);
-
- for (c = x = 0; c < cols;)
- {
- /* if cga in use */
-
- if (cga_sw == 2)
- {
- _asm
- {
- mov dx, 986
-
- Loop1:
-
- in al, dx
- and al, 1
- jnz Loop1
-
- Loop2:
-
- in al, dx
- and al, 1
- je Loop2
- }
-
- }
-
- /* store character */
-
- * (v_tgt + x++) = * (incr + c++);
-
- /* if cga in use */
-
- if (cga_sw == 2)
- {
- _asm
- {
- mov dx, 986
-
- Loop3:
-
- in al, dx
- and al, 1
- jnz Loop3
-
- Loop4:
-
- in al, dx
- and al, 1
- je Loop4
- }
-
- }
-
- /* store attribute */
-
- * (v_tgt + x++) = * (incr + c++);
- }
-
- }
-
- _enable;
- }
-
- else
- {
- regs.h.bh = 0; regs.x.cx = 1;
-
- for (r = 0; r < rows; r++)
- {
- incr = w_a [w] .save + (r * cols);
-
- regs.h.dh = w_a [w].ulr + r;
-
- for (d = c = 0; c < cols;)
- {
- /* locate */
-
- regs.h.ah = 2;
- regs.h.dl = w_a [w] .ulc + (d++);
-
- int86 (16, ®s, ®s);
-
- /* write char and attribute */
-
- regs.h.ah = 9;
- regs.h.al = * (incr + c++);
- regs.h.bl = * (incr + c++);
-
- int86 (16, ®s, ®s);
- }
-
- }
-
- }
-
- }
-
- BYTE far s_read_char ()
- {
- /* readc char from screen */
-
- regs.h.ah = 8;
- regs.h.bh = 0;
-
- int86 (16, ®s, ®s);
-
- return (regs.h.al);
- }
-
- BYTE far s_read_attr ()
- {
- /* readc attribute from screen */
-
- regs.h.ah = 8;
- regs.h.bh = 0;
-
- int86 (16, ®s, ®s);
-
- return (regs.h.ah);
- }
-
- void far _fastcall tele_out (BYTE ch)
- {
- /* prints char, advances cursor */
-
- regs.h.ah = 14;
- regs.h.al = ch;
-
- int86 (16, ®s, ®s);
- }
-
- void far _fastcall crt_out (BYTE ch)
- {
- /* prints char, no advances cursor */
-
- regs.h.ah = 10;
- regs.h.al = ch;
- regs.h.bh = 0;
- regs.x.cx = 1;
-
- int86 (16, ®s, ®s);
- }
-
- void far _fastcall c_crt_out (BYTE ch, BYTE atr)
- {
- /* prints char, no advances cursor */
-
- regs.h.ah = 9;
- regs.h.al = ch;
- regs.h.bh = 0;
- regs.h.bl = atr;
- regs.x.cx = 1;
-
- int86 (16, ®s, ®s);
- }
-
- void far _fastcall line_out (BYTE nmbr, BYTE ch)
- {
- /* prints line of chars, no advances cursor */
-
- regs.h.ah = 10;
- regs.h.al = ch;
- regs.h.bh = 0;
- regs.x.cx = nmbr;
-
- int86 (16, ®s, ®s);
- }
-
- DWORD far get_timer ()
- {
- /* gets dos time interger */
-
- regs.h.ah = 0;
- int86 (26, ®s, ®s);
- return (regs.x.cx * 0x10000) + regs.x.dx;
- }
-
- void far wait (BYTE w)
- {
- /* clock independant wait */
-
- DWORD a, b;
-
- a = get_timer ();
- b = a + (w * 18.2);
-
- while (a < b) a = get_timer ();
- }
-
- void far lpt_char (BYTE c)
- {
- /* puts char to line printer in global flag lptr, 0 = lpt1, etc */
-
- regs.h.ah = 0;
- regs.h.al = c;
- regs.x.dx = lptr;
-
- int86(23, ®s, ®s);
-
- if (c == 12 || c == 13) char_cntr = 0;
- else char_cntr++;
- }
-
- void far lpt_spaces (BYTE no)
- {
- BYTE register d;
-
- for (d = 0; d < no; d++) lpt_char (32);
- }
-
- void far lpt_string (BYTE * t_str)
- {
- /* lprints string from memory */
-
- BYTE register d = 0;
-
- while (t_str [d]) lpt_char (t_str [d++]);
- }
-
- void far lpt_f_string (BYTE far * t_str)
- {
- /* lprints string from FAR memory */
-
- BYTE register d = 0;
-
- while (t_str [d]) lpt_char (t_str [d++]);
- }
-
- void far lpt_tab (WORD no)
- {
- WORD register d;
-
- if (no > char_cntr)
- for (d = char_cntr; d <= no; d++) lpt_char (32);
-
- char_cntr = no;
- }
-
- void far lpt_eol ()
- {
- lpt_char (10); lpt_char (13); char_cntr = 0;
- }
-
- void far lpt_blanks (BYTE howmany)
- {
- BYTE d;
-
- for (d = 0; d < howmany; d++) lpt_eol ();
- }
-
- void far lpt_line (BYTE no, BYTE c)
- {
- BYTE register d;
-
- for (d = 1; d < no; d++) lpt_char (c);
- }
-
- void far beep ()
- {
- _asm
- {
- mov ah, 2
- mov dl, 7
- int 21h
- }
-
- }
-
- void far get_kybd_type ()
- {
- /* returns 1 for 103 key, or 0 */
-
- regs.x.ax = 0x12ff;
-
- int86 (22, ®s, ®s);
-
- kybd_type = ! (regs.h.al == 0xff);
- }
-
- void far _fastcall get_one (BYTE * c_val, BYTE * n_val)
- {
- /* calls bios keyboard to get chars hit */
-
- if (kybd_type)
- {
- regs.h.ah = 16;
-
- int86 (22, ®s, ®s);
-
- * c_val = regs.h.ah;
- * n_val = regs.h.al;
-
- if (* n_val == 224) * n_val = 0;
- }
-
- else
- {
- regs.h.ah = 0;
-
- int86 (22, ®s, ®s);
-
- * c_val = regs.h.ah;
- * n_val = regs.h.al;
- }
-
- }
-
- BYTE far check_shift ()
- {
- /* check shift key */
-
- BYTE a, b;
-
- if (kybd_type) regs.h.ah = 18;
- else regs.h.ah = 2;
-
- int86 (22, ®s, ®s);
-
- a = b = regs.h.al;
-
- if (a & 1 || b & 2) return (1);
-
- return (0);
- }
-
- BYTE far get_choice (BYTE choices)
- {
- /* gets choices from kybd, max allowed is passed, returns legal choice */
-
- intake:
-
- get_one (& ctrl_val, & nrml_val);
-
- if (nrml_val < 49 || nrml_val > choices + 48) {beep (); goto intake;}
-
- return (nrml_val - 48);
- }
-
- void far y_n ()
- {
- strcpy (prompts [1], "1=YES");
- strcpy (prompts [2], "2=NO");
- }
-
- void far n_y ()
- {
- strcpy (prompts [1], "1=NO");
- strcpy (prompts [2], "2=YES");
- }
-
- BYTE far get_v_choice (BYTE choices, BYTE help_avail, BYTE * helpfile)
- {
- BYTE a, d, c, clr, ctrl_val, nrml_val, pt1,
- pt2, ret_val, wfg = 0, * where;
-
- BYTE starts [10];
-
- no_cursor();
-
- a = ((w_a [3].attr & 7) << 4);
- c = ((w_a [3].attr & 112) >> 4);
-
- clr = a + c;
-
- if (w_a [3].attr & 8) clr += 8;
-
- strcpy (c_s [0], prompts [0]);
-
- c_s [1] [0] = 0; starts [0] = 0;
-
- for (d = 1; d <= choices; d++)
- {
- starts [d] = strlen (c_s [1]);
-
- strcat (c_s [1], prompts [d]);
- strcat (c_s [1], " ");
- }
-
- a = cntrstrp ();
-
- where = strstr (c_s [2], prompts [1]);
-
- c = (where - c_s [2]) + a;
-
- for (d = 1; d <= choices; d++) starts [d] += c;
-
- clw (3); locate (22, a);
- prnt (c_s [2]);
-
- if (help_avail)
- {
- locate (23,23);
- prnt ("PRESS THE H KEY FOR ON-SCREEN HELP");
- }
-
- d = choices / 2;
-
- locate (22, starts [d]);
- clr_prnt (prompts [d], clr);
-
- while (! wfg)
- {
- get_one (& ctrl_val, & nrml_val);
-
- if (nrml_val)
- {
- switch (nrml_val)
- {
- case 13:
- {
- ret_val = d;
-
- wfg = 1;
-
- break;
- }
-
- case 'h':
- case 'H':
- {
- if (! help_avail) {beep (); continue;}
- save_window (2);
- save_window (3);
-
- show_help (helpfile);
-
- repl_window (2);
- repl_window (3);
- break;
- }
-
- default:
- {
- if (nrml_val > 48 && nrml_val < choices + 49)
- {
- ret_val = nrml_val - 48;
-
- wfg = 1;
- }
-
- else beep();
- }
-
- }
-
- continue;
- }
-
- if (ctrl_val)
- {
- switch (ctrl_val)
- {
- case 75:
- {
- locate (22, starts [d]);
- clr_prnt (prompts [d], w_a [3].attr);
-
- d -= 1;
-
- if (d < 1) d = choices;
-
- locate (22, starts [d]);
- clr_prnt (prompts [d], clr);
-
- break;
- }
-
- case 77:
- {
- locate (22, starts [d]);
- clr_prnt (prompts [d], w_a [3].attr);
-
- d += 1;
-
- if (d > choices) d = 1;
-
- locate (22, starts [d]);
- clr_prnt (prompts [d], clr);
-
- break;
- }
-
- default: beep();
- }
-
- continue;
- }
-
- }
-
- return (ret_val);
- }
-
- BYTE far check_kybd ()
- {
- /* is a char waiting? */
-
- regs.h.ah = 11;
-
- int86 (33, ®s, ®s);
-
- if (regs.h.al == 0) return (0);
- return (1);
- }
-
- void far flush_kybd ()
- {
- /* empties keyboard buffer */
-
- BYTE bool;
-
- bool = check_kybd ();
-
- while (bool)
- {
- get_one (& ctrl_val, & nrml_val);
- bool = check_kybd ();
- }
-
- }
-
- void far see_screen ()
- {
- clw(3); locate (22, 27); prnt ("Press any key to continue:");
- get_one (& ctrl_val, & nrml_val);
- }
-
- void far output_fail ()
- {
- beep (); clw (3); locate (23,19);
- prnt ("Unable to open output file!");
- wait (4);
- }
-
- void far rtrim (BYTE * str)
- {
- /* removes trailing spaces */
-
- BYTE wfg = 0;
-
- SWORD x = strlen (str);
-
- while (! wfg && x > -1)
- {
- if (str [x] && str [x] != 32) wfg = 1;
- else x--;
- }
-
- str [++x] = 0;
- }
-
- void far window_border (BYTE w)
- {
- /* borders window passed */
-
- BYTE register d;
-
- clw (w);
-
- locate (w_a [w] .ulr, w_a [w] .ulc);
- tele_out (201);
- locate (w_a [w] .ulr, w_a [w] .ulc + 1);
- line_out (w_a [w] .lrc - w_a [w] .ulc, 205);
- locate (w_a [w] .ulr, w_a [w] .lrc);
- tele_out (187);
-
- for (d = w_a [w] .ulr + 1; d < w_a [w] .lrr; d++)
- {
- locate (d, w_a [w] .ulc); tele_out (186);
- locate (d, w_a [w] .lrc); tele_out (186);
- }
-
- locate (w_a [w] .lrr, w_a [w] .ulc);
- tele_out (200);
- locate (w_a [w] .lrr, w_a [w] .ulc + 1);
- line_out (w_a [w] .lrc - w_a [w] .ulc, 205);
- locate (w_a [w] .lrr, w_a [w] .lrc);
- tele_out (188);
- }
-
- void far write_eol (FILE * target)
- {
- fputc (13, target); fputc (10, target);
- }
-
- void far eol_strip (BYTE * target)
- {
- WORD register x = 0;
-
- while (target [x] != 10 && target [x] && target [x] != 13) x++;
-
- if (target [x]) target [x] = 0;
- }
-
- void far show_help (BYTE * helpfile)
- {
- /* shows help in text file, DOES NOT save/replace window */
-
- BYTE choice, col, row, wfg = 0, x = 0, str [85];
-
- FILE * hlp;
-
- strcpy (gp_str [8], "HELPFILS\\");
- strcat (gp_str [8], helpfile);
-
- if ( (hlp = fopen (gp_str [8], "r")) == NULL)
- {
- clw(3); locate (22,28);
-
- prnt ("HELP FILE WAS NOT FOUND");
- beep(); wait (4);
-
- return;
- }
-
- strcpy (gp_str [14], prompts [1]);
- strcpy (gp_str [15], prompts [2]);
-
- strcpy (prompts [0], "MORE HELP?");
-
- y_n ();
-
- clw (2); setbuf (hlp, NULL);
-
- while (! wfg)
- {
- str [0] = 0;
-
- locate (x + 2, 5);
- fgets (str, 80, hlp);
-
- if (eof (fileno (hlp)))
- {
- wfg = 1;
-
- if (! strlen (str)) continue;
- }
-
- eol_strip (str);
- prnt (str);
-
- if (x >= 16)
- {
- choice = get_v_choice (2, 0, 0);
-
- if (choice == 2) {wfg = 2; continue;}
-
- clw (2); x = 0;
- }
-
- else x++;
- }
-
- if (wfg == 1)
- {
- clw(3); locate (22,24);
- prnt ("PRESS ANY KEY TO RESUME PROGRAM");
-
- get_one (& row, & col);
- }
-
- fclose (hlp);
-
- strcpy (prompts [1], gp_str [14]);
- strcpy (prompts [2], gp_str [15]);
- }
-
- void far hard_err (BYTE deverr, BYTE doserr, BYTE far *hdr)
- {
- /* handles hardware errors, kind of */
-
- BYTE c, choice;
-
- save_window (3); clw (3);
- beep(); locate (22, 11);
-
- strcpy (prompts [0], "A HARDWARE ERROR HAS OCCURRED!");
- strcpy (prompts [1], "1=RETRY");
- strcpy (prompts [2], "2=ABORT PROGRAM");
-
- choice = get_v_choice (2, 0, 0);
-
- switch (choice)
- {
- /* retry */
-
- case 1:
- {
- repl_window (3);
- _hardresume(_HARDERR_RETRY);
- }
-
- /* abort */
-
- case 2:
- {
- cls();
- _hardresume(_HARDERR_ABORT);
- }
-
- }
-
- }
-
-
- BYTE far dlr_format (BYTE dollar, BYTE comma)
- {
- /* formats the string in c_s [0] according to switches passed */
-
- BYTE d, x, y, decs, len, point;
-
- BYTE * where;
-
- SBYTE test;
-
- len = strlen (c_s [0]);
-
- where = strchr (c_s [0], '.');
-
- if (where == NULL) {point = len; decs = 0;}
- else
- {
- point = where - c_s [0];
-
- if (point) decs = len - point;
- else decs = 0;
- }
-
- if (dollar)
- {
- c_s [2] [0] = '$';
- c_s [2] [1] = 0;
- x = 1;
- }
-
- else {x = 0; c_s [2] [0] = 0;}
-
- if (point < 3) {strcat (c_s [2], c_s [0]); return (0);}
-
- if (comma)
- {
- test = point; d = 0;
-
- while (test - 3 > -1) test -= 3;
-
- if (test) for (; d < test;) c_s [2] [x++] = c_s [0] [d++];
-
- while (d < point)
- {
- y = d + 3;
- if (y > point) y = point;
-
- if (d) c_s [2] [x++] = ',';
-
- for (;d < y; d++) c_s [2] [x++] = c_s [0] [d];
- }
-
- if (decs) for (d = point; d < len;) c_s [2] [x++] = c_s [0] [d++];
-
- c_s [2] [x] = 0;
- }
-
- else strcat (c_s [2], c_s [0]);
-
- return (0);
- }
-
- void far ipt_box (BYTE cc, BYTE cl, BYTE max, BYTE fill,
- BYTE seed_sw, BYTE bright, BYTE * t_str)
- {
- BYTE a, atrib, b, c, d, e, f, g, h;
-
- no_cursor ();
-
- a = cl - 1; d = cl + 1; e = cc - 1;
- f = cc + max;
-
- atrib = s_read_attr ();
-
- if (color_enable && bright && ! (atrib & 8)) atrib += 8;
-
- if (color_enable && ! bright && (atrib & 8)) atrib -= 8;
-
- /* upper left corner */
-
- locate (a, e); c = s_read_char ();
-
- switch (c)
- {
- default:
- case 32: {b = 201; break;}
-
- case 203:
- case 205: {b = 203; break;}
-
- case 204:
- case 200: {b = 204; break;}
- }
-
- c_crt_out (b, atrib);
-
- /* top bar */
-
- for (g = 0; g < max; g++)
- {
- h = cc + g;
-
- locate (a, h); c = s_read_char ();
-
- switch (c)
- {
- default:
- case 32: {b = 205; break;}
-
- case 200:
- case 202:
- case 188: {b = 202; break;}
- }
-
- c_crt_out (b, atrib);
- }
-
- /* upper rt corner */
-
- locate (a, f); c = s_read_char ();
-
- switch (c)
- {
- default:
- case 32: {b = 187; break;}
-
- case 188:
- case 185: {b = 185; break;}
-
- case 203:
- case 205: {b = 203; break;}
- }
-
- c_crt_out (b, atrib);
-
- /* center line */
-
- locate (cl, e); c_crt_out (186, atrib);
-
- b = strlen (t_str);
-
- for (c = 0, g = cc; c < max; g++, c++)
- {
- locate (cl, g);
-
- if (c < b) c_crt_out (t_str [c], atrib);
- else c_crt_out (32, atrib);
- }
-
- locate (cl, f); c_crt_out (186, atrib);
-
- locate (d, e); c = s_read_char ();
-
- switch (c)
- {
- default:
- case 32: {b = 200; break;}
-
- case 204:
- case 201: {b = 204; break;}
- }
-
-
- c_crt_out (b, atrib);
-
- for (g = 0; g < max; g++)
- {
- h = cc + g;
-
- locate (d, h); c = s_read_char ();
-
- switch (c)
- {
- default:
- case 32: {b = 205; break;}
-
- case 201:
- case 203:
- case 187: {b = 203; break;}
- }
-
- c_crt_out (b, atrib);
- }
-
- locate (d, f); c = s_read_char ();
-
- switch (c)
- {
- default:
- case 32: {b = 188; break;}
-
- case 185:
- case 187: {b = 185; break;}
-
- case 205:
- case 202: {b = 202; break;}
- }
-
- c_crt_out (b, atrib);
- }
-
- BYTE far parse_date (BYTE * dte_str, BYTE * fmt, BYTE * day,
- BYTE * month, WORD * year, double * met_date)
-
- /* parses a date, format byte 1 = MM/DD/YYyy, 2 = DD/MM/YYyy
- double met_date is set to YYYYMMDD for easy comparisons */
- {
- BYTE d_str [3], m_str [3], y_str [5], met_str [9];
-
- BYTE len, m, wfg = 0;
-
- BYTE * where;
-
- double md;
-
- /* remove trailing spaces, if any */
-
- rtrim (dte_str);
-
- /* check length of date string */
-
- len = strlen (dte_str);
-
- if (len < 8) return (1);
-
- /* check for valid chars in date string */
-
- for (m = 0; m < len; m++)
- {
- if (m == 2 || m == 5) continue;
-
- if (dte_str [m] < 48 || dte_str [m] > 57) wfg = 1;
- }
-
- if (wfg) return (1);
-
- /* process chars 0 & 1 */
-
- if (* fmt == 2) where = (BYTE far *) d_str;
- else where = (BYTE far *) m_str;
-
- for (m = 0; m < 2; m++)
- {
- * (where + m) = dte_str [m];
-
- met_str [m] = dte_str [m];
- }
-
- * (where + m) = 0;
-
- if (* fmt == 2) * day = atoi (where);
- else * month = atoi (where);
-
- /* process chars 3 & 4 */
-
- if (* fmt == 2) where = m_str;
- else where = d_str;
-
- for (m = 3; m < 5; m++)
- {
- * (where + m - 3) = dte_str [m];
-
- met_str [m - 1] = dte_str [m];
- }
-
- * (where + m - 3) = 0;
-
- if (* fmt == 2) * month = atoi (m_str);
- else * day = atoi (d_str);
-
- /* process remaining chars */
-
- for (m = 6; m < len; m++)
- {
- y_str [m - 6] = dte_str [m];
-
- met_str [m - 2] = dte_str [m];
- }
-
- y_str [m - 6] = 0; met_str [m - 2] = 0;
-
- * year = atoi (y_str);
-
- if (* year < 100)
- {
- * year += 1900;
-
- itoa (* year, y_str, 10);
- }
-
- if (* day < 1 || * day > 31 || * month < 1 || * month > 12) return (1);
-
- strcpy (met_str, y_str);
- strcat (met_str, m_str);
- strcat (met_str, d_str);
-
- * met_date = atof (met_str);
-
- return (0);
- }
-
- /*
-
- void char_ok (BYTE * t_str, BYTE * chin, BYTE * ccc, BYTE cl, BYTE cc,
- BYTE max, BYTE inst, BYTE nrml_val)
- {
- // belongs to INPT routine
-
- BYTE d, x = * ccc - cc;
-
- if (inst == 0)
- {
- if (x >= max) {beep (); return;}
-
- tele_out (nrml_val);
- t_str [ x ] = nrml_val;
- * ccc += 1;
- if (x >= * chin) * chin += 1;
- return;
- }
-
- if (* chin >= max) {beep (); return;}
-
- for (d = max; d > x; d--) t_str [ d ] = t_str [ d - 1 ];
-
- t_str [ x ] = nrml_val;
-
- for (d = x; d <= * chin; ++d) tele_out (t_str [ d ]);
-
- ++ * ccc; locate (cl, * ccc); * chin += 1;
- }
-
- void del_char (BYTE * t_str, BYTE * psw, BYTE * chin, BYTE * ccc,
- BYTE cl, BYTE cc, BYTE max, BYTE fill)
- {
- // belongs to INPT routine
-
- BYTE d, x = *ccc - cc;
-
- if (t_str [ x ] == 46) * psw = 0;
-
- for (d = x; d <= max; ++d) t_str [ d ] = t_str [ d + 1 ];
-
- t_str [* chin] = fill; * chin -= 1;
-
- for (d = x; d < * chin; d++) tele_out (t_str [ d ]);
-
- tele_out (fill); locate (cl, * ccc);
- }
-
- BYTE far inpt (BYTE type, BYTE max, BYTE box_sw, BYTE seed_sw,
- BYTE spare, BYTE fill, BYTE * t_str)
- {
- // performs char input at current location
-
- BYTE cc, ccc, cl, chin = 0, cwfg, d,
- inst = 0, psw = 0, w, wfg = 0;
-
- BYTE * test;
-
- void del_char (BYTE *, BYTE *, BYTE *,
- BYTE *, BYTE, BYTE, BYTE, BYTE);
-
- void char_ok (BYTE *, BYTE *, BYTE *, BYTE, BYTE, BYTE, BYTE, BYTE);
-
- nrml_cursor ();
-
- find_cursor (& cl, & cc);
-
- if (box_sw == 1)
- {
- cc += 2;
-
- ipt_box (cc, cl, max, fill, seed_sw, 1, t_str);
- }
-
- t_str [ max + 1 ] = 0;
-
- locate (cl, cc);
-
- if (! seed_sw)
- {
- ccc = cc;
-
- for (d = 0; d <= max; d++) t_str [d] = fill;
- }
-
- else
- {
- if (! box_sw) prnt (t_str);
-
- chin = strlen (t_str);
- if (chin > max) chin = 0;
-
- ccc = cc + chin;
-
- locate (cl, ccc);
- }
-
- // detect decimal if numeric seeded input
-
- if (type == 2 && seed_sw)
- {
- test = strstr (t_str, ".");
-
- if (test == NULL) psw = 0;
- else psw = 1;
- }
-
- if (type == 1 && box_sw == 2)
- {
- if (cl <= 9) w = 11; else w = 10;
-
- save_window (w); window_border (w);
-
- locate (w_a [w].ulr + 1, 21);
- prnt ("F-KEY: 1 2 3 4 5 6 7 8 9 1");
-
- locate (w_a [w].ulr + 2, 19); tele_out (199);
- line_out (39, 196);
- locate (w_a [w].ulr + 2, 59); tele_out (182);
-
- locate (w_a [w].ulr + 3, 21);
- prnt ("ALONE \xa9 \xaa \xc0 \xd9 \xb3 \xc1 \xcb \xc6 \xd2 \xc5");
-
- locate (w_a [w].ulr + 4, 21);
- prnt ("SHFT + \xc9 \xbb \xc8 \xbc \xc4 \xc2 \xca \xb5 \xd0 \xce");
-
- locate (w_a [w].ulr + 5, 21);
- prnt ("ALT + \xd5 \xb8 \xd4 \xbe \xba \xc3 \xcc \xc7 \xd1 \xd8");
-
- locate (w_a [w].ulr + 6, 21);
- prnt ("CTRL + \xd6 \xb7 \xd3 \xbd \xcd \xb4 \xb9 \xb6 \xcf \xd7");
-
- locate (cl, cc);
- }
-
- while (! wfg)
- {
- get_one (& ctrl_val, & nrml_val); cwfg = 0;
-
- if (type == 1 && ! box_sw)
- {
- switch (ctrl_val)
- {
- // f-key
-
- case 59: nrml_val = 169; cwfg = 1; break;
- case 60: nrml_val = 170; cwfg = 1; break;
- case 61: nrml_val = 192; cwfg = 1; break;
- case 62: nrml_val = 217; cwfg = 1; break;
- case 63: nrml_val = 179; cwfg = 1; break;
- case 64: nrml_val = 193; cwfg = 1; break;
- case 65: nrml_val = 203; cwfg = 1; break;
- case 66: nrml_val = 198; cwfg = 1; break;
- case 67: nrml_val = 210; cwfg = 1; break;
- case 68: nrml_val = 197; cwfg = 1; break;
-
- // shifted f-key
-
- case 84: nrml_val = 201; cwfg = 1; break;
- case 85: nrml_val = 187; cwfg = 1; break;
- case 86: nrml_val = 200; cwfg = 1; break;
- case 87: nrml_val = 188; cwfg = 1; break;
- case 88: nrml_val = 196; cwfg = 1; break;
- case 89: nrml_val = 194; cwfg = 1; break;
- case 90: nrml_val = 202; cwfg = 1; break;
- case 91: nrml_val = 181; cwfg = 1; break;
- case 92: nrml_val = 208; cwfg = 1; break;
- case 93: nrml_val = 206; cwfg = 1; break;
-
- // alted f-key
-
- case 104: nrml_val = 213; cwfg = 1; break;
- case 105: nrml_val = 184; cwfg = 1; break;
- case 106: nrml_val = 212; cwfg = 1; break;
- case 107: nrml_val = 190; cwfg = 1; break;
- case 108: nrml_val = 186; cwfg = 1; break;
- case 109: nrml_val = 195; cwfg = 1; break;
- case 110: nrml_val = 204; cwfg = 1; break;
- case 111: nrml_val = 199; cwfg = 1; break;
- case 112: nrml_val = 209; cwfg = 1; break;
- case 113: nrml_val = 216; cwfg = 1; break;
-
- // ctrled f-key
-
- case 94: nrml_val = 214; cwfg = 1; break;
- case 95: nrml_val = 183; cwfg = 1; break;
- case 96: nrml_val = 211; cwfg = 1; break;
- case 97: nrml_val = 189; cwfg = 1; break;
- case 98: nrml_val = 205; cwfg = 1; break;
- case 99: nrml_val = 180; cwfg = 1; break;
- case 100: nrml_val = 185; cwfg = 1; break;
- case 101: nrml_val = 182; cwfg = 1; break;
- case 102: nrml_val = 207; cwfg = 1; break;
- case 103: nrml_val = 215; cwfg = 1; break;
-
- defualt: ;
- }
-
- if (cwfg)
- {
- char_ok (t_str, & chin, & ccc,
- cl, cc, max, inst, nrml_val);
- continue;
- }
-
- }
-
- if (nrml_val)
- {
- if (type == 1 && nrml_val > 31 && nrml_val < 126)
- {
- char_ok (t_str, & chin, & ccc,
- cl, cc, max, inst, nrml_val);
- continue;
- }
-
- if (type == 2 && nrml_val > 46 && nrml_val < 58)
- {
- char_ok (t_str, & chin, & ccc,
- cl, cc, max, inst, nrml_val);
- continue;
- }
-
- switch (nrml_val)
- {
- case 8 : // backspace
-
- if (chin == 0) { beep (); continue; }
-
- if (nrml_val == 8 && ccc - cc == 0)
- { beep (); continue; }
-
- --ccc; locate (cl,ccc);
- del_char (t_str, & psw,
- & chin, & ccc, cl, cc, max, fill);
- continue;
-
- case 13 : wfg = 2; continue; // return
-
- case 27 : // escape
- no_cursor (); chin = 0;
- locate (cl, cc); line_out (max, fill);
- locate (cl, cc); ccc = cc;
- nrml_cursor (); inst = 0;
-
- for (d = 0; d <= max; d++)
- t_str [d] = fill;
-
- t_str [ max + 1 ] = 0x00;
- beep (); continue;
-
- case 45 :
- if (ccc - cc > 0 || t_str [0] == 45)
- { beep (); continue; }
-
- char_ok (t_str, & chin,
- & ccc, cl, cc, max, inst,
- nrml_val);
-
- continue;
-
- case 46 :
- if (psw == 1) { beep (); continue; }
-
- char_ok (t_str, & chin,
- & ccc, cl, cc, max, inst,
- nrml_val);
- psw = 1; continue;
-
- default : beep (); continue;
- }
-
- }
-
- switch (ctrl_val)
- {
- case 71 :
- locate (cl, cc);
- ccc = cc; continue;
-
- case 75 :
- if (ccc > cc)
- {
- --ccc; locate (cl, ccc);
- continue;
- }
-
- beep (); continue;
-
- case 77 : // right arrow
-
- if ( (ccc - cc) < chin)
- {
- locate (cl, ++ccc);
- continue;
- }
-
- beep (); continue;
-
- case 79 :
- ccc = cc;
- if (chin) ccc += chin - 1;
-
- locate (cl, ccc);
- nrml_cursor (); inst = 0;
- continue;
-
- case 82 :
- if (inst == 0)
- {
- inst = 1; full_cursor ();
- continue;
- }
-
- inst = 0; nrml_cursor ();
- continue;
-
- case 83 : // delete
- if (chin == 0 || ccc - cc > max ||
- ccc - cc >= chin)
- { beep (); continue; }
-
- del_char (t_str, & psw,
- & chin, & ccc, cl, cc, max, fill);
- continue;
-
- default : beep (); continue;
- }
-
- }
-
- if (type == 1 && box_sw == 2) repl_window (w);
-
- no_cursor ();
- t_str [chin] = 0;
-
- return (chin);
- }
-
- void far check_heap ()
- {
- // handy-dandy routine for checking the heap
-
- SBYTE h;
-
- h = _heapchk ();
-
- switch (h)
- {
- case _HEAPEND:
- case _HEAPEMPTY:
- case _HEAPOK: break;
-
- case _HEAPBADBEGIN:
- case _HEAPBADNODE:
- case _HEAPBADPTR:
- case _FREEENTRY:
- case _USEDENTRY:
-
- locate (0,0); prnt ("HEAP ERROR ");
- printf ("%i",h);
- }
-
- h = _fheapchk ();
-
- switch (h)
- {
- case _HEAPEND:
- case _HEAPEMPTY:
- case _HEAPOK: break;
-
- case _HEAPBADBEGIN:
- case _HEAPBADNODE:
- case _HEAPBADPTR:
- case _FREEENTRY:
- case _USEDENTRY:
-
- locate (0,40); prnt ("FAR HEAP ERROR ");
- printf ("%i",h);
- }
-
- }
-
- */
-
-