home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PCGAMN6.ZIP / CIAO.H < prev    next >
C/C++ Source or Header  |  1986-12-13  |  7KB  |  200 lines

  1.  
  2. /* ciao.h - declarations for all global data & functions in ciao.lib
  3. **          the module is self-initializing, vid_init is only required
  4. **          to set a particular text mode (of 7, or 2 or 3).
  5. **
  6. ** 8 sept 1986, by david c. oshel, ames, iowa
  7. */
  8.  
  9.  
  10. #include <stdio.h>  /* list of files I almost always include */
  11. #include <stdlib.h>
  12. #include <dos.h>
  13. #include <signal.h>
  14. #include <setjmp.h>
  15. #include <string.h>
  16. #include <ctype.h>
  17. #include <malloc.h>
  18.  
  19. typedef struct screenword { unsigned byte, attr; } SCW;  
  20.  
  21. extern int vid[16],        /* video registers 0..15 (see clairol() fn) */
  22.            vid_mode,       /* hardware configuration */
  23.            rasterh,        /* machine cursor high raster line */
  24.            rasterl,        /* machine cursor low  raster line */
  25.            tone,           /* no sound effects if false */
  26.            ambiguity,      /* clairol: ambiguous message levels on entry? */
  27.            Control_C_Flag; /* Typeafile exit condition flag */
  28.  
  29. /* window primitives */
  30.  
  31. extern void fullscreen(void);     /* resets 80x25 full window dimensions */
  32. extern void clreos(void);         /* ENTIRE SCREEN, from cursor */
  33. extern void clrscrn(void);        /* ENTIRE SCREEN, reset 80x25, home, clear */
  34.  
  35. extern void gotoxy(int ,int );    /* 0,0 is top left corner of window */
  36. extern void clreol(void);         /* window */
  37. extern void clrwindow(void);      /* window */
  38. extern void wink(char );          /* window character out, scroll as needed */
  39. extern void wputs(char *);        /* window string out via wink, ^ is valid */
  40. extern void scrollup(void);       /* window */
  41. extern void scrolldn(void);       /* window */
  42.  
  43. /* top left, bottom right coords: args are relative to 80x25 screen size */
  44.  
  45. extern void windowbox(int ,int ,int ,int );       /*  tx,  ty,  bx,  by */
  46. extern void setwindow(int ,int ,int ,int );       /*  tx,  ty,  bx,  by */
  47. extern void getwindow(int *,int *,int *,int *);   /* &tx, &ty, &bx, &by */
  48.  
  49. /* character primitives, active at current screen position */
  50.  
  51. extern void rptchar(char ,int );    /* char, count */
  52. extern void readscreenchar(SCW *);  /* byte and attr, see typedef, above */
  53.  
  54. /* machine cursor */
  55.  
  56. extern void setsynch(int );        /* 1 or 0, ON or OFF, synch machine cursor */
  57. extern void defcursor(void);       /* visible, synchronized, default size */
  58. extern void hidecursor(void);      /* invisible, de-synchronized */
  59. extern void setcursize(int ,int ); /* high raster, low raster */
  60.  
  61. /* machine and/or soft cursor, depending on synchronized flag */
  62.  
  63. extern int savecursor(union REGS *); /* returns synchronized flag */
  64. extern int restcursor(union REGS *); /* returns synch flag state when saved */
  65.  
  66. /* screen select, swap: contents only */
  67.  
  68. extern void setscreen(int );   /* write on selected: 1 visible, 2 hidden */
  69. extern void swapscreen(int );  /* swap hidden (2 is only valid) with visible */
  70.  
  71. /* screen save, restore: contents, cursor, window dimensions */
  72.  
  73. extern char far *savescreen(union REGS *);           /* calls _fmalloc() */
  74. extern void restorescreen(char far *,union REGS *);  /* calls _ffree()   */
  75.  
  76. /* initialize, de-initialize */
  77.  
  78. extern void vid_init(int );  /* call to set color 3, b&w 2, monochrome 7 */
  79. extern void vid_exit(void);  /* defcursor(), frees up pointer allocations */
  80.  
  81.  
  82. /* other functions */
  83.  
  84.  
  85. /* xeq( directory, program_name );
  86. **
  87. ** example: xeq("\\games", "zork /w");
  88. ** change directory, invoke program via system() call
  89. ** allows program arguments which contain the "/" switch character
  90. ** exec() and spawn() eat "/" because of "compatibility with Xenix"
  91. ** restores the original working directory on exit
  92. ** if there is one, the run time error message is from the new
  93. ** invocation of COMMAND.COM, not from C
  94. */
  95.  
  96. extern void xeq(char *,char *);
  97.  
  98.  
  99. /* typeafile( pathname, wrap, tx, ty, bx, by );
  100. **
  101. ** example: typeafile("\\games\\userman.doc", TRUE, 0,0,79,24 );
  102. ** types the file, if found, in a window box of the given dimensions
  103. ** word wrap in paragraphs if the wrap argument is TRUE
  104. ** hanging indentation in the document may cause a messy display because
  105. ** leading spaces are preserved in the middle of wrapped lines (!)
  106. ** the PgUp key allows you to scroll backwards in the file (!) -- there
  107. ** is a remote chance of stack overflow because the algorithm is recursive
  108. ** traps Control-C, Control_C_Flag = 1 if exit was via Control-C
  109. ** preserves entry screen, restores it on exit
  110. */
  111.  
  112. extern void typeafile(char *,int ,int ,int ,int ,int );
  113.  
  114.  
  115. /* clairol();
  116. **
  117. ** popout window gives users access to vid[0]..vid[3], interpreted as
  118. ** message levels Normal, Bold, Emphasis and Attention.  Users may select
  119. ** screen colors or monochrome attributes, depending on hardware.
  120. */
  121.  
  122. extern void clairol(void );
  123.  
  124.  
  125. /* wprintf( fmt, variable_length_argument_list );
  126. **
  127. ** calls wputs, recognizes ^ commands
  128. ** REQUIRES MICROSOFT C VER. 4.00
  129. */
  130.  
  131. extern void wprintf(char *,...);
  132.  
  133.  
  134. /* keyin( wait_fn );
  135. **
  136. ** wait_fn executed while awaiting keyboard input
  137. ** returns characters as positive integers from 1..255
  138. ** returns Fn keys in range 128..255 (i.e., high bit set)
  139. */
  140.  
  141. extern int keyin(void ( *)());
  142.  
  143.  
  144. /* getms( receiving_buffer_pointer, maximum_length, wait_fn, esc_fn );
  145. **
  146. ** wait_fn executed while awaiting keyboard input
  147. ** esc_fn executed if user types ESC
  148. */
  149.  
  150. extern int getms(char  *,int ,void ( *)(),void ( *)());
  151.  
  152.  
  153. /* sound */
  154.  
  155. extern void HIclack( void );      /* musical gadget declarations */
  156. extern void LOclack( void );
  157. extern void bopbleet( void );
  158. extern void blopbloop( void );
  159. extern void thurb( void );
  160. extern void setfrq( unsigned ); /* sound generation primitives declarations */ 
  161. extern void spkron( void );
  162. extern void spkroff( void );
  163. extern void note( unsigned, unsigned );
  164.  
  165. /* miscellaneous */
  166.  
  167. extern void noop(void );                     /* do nothing, convenient!    */
  168. extern void sleep(int );                     /* wait n tenths of a second  */
  169. extern void bell(void );                     /* beep: i.e., putch('\a');   */
  170.  
  171.  
  172.  
  173. /* money.h, 11/27/86, d.c.oshel
  174. */
  175.  
  176. extern int ESCflag,           /* string edit functions return ESC or MINUS */ 
  177.            MINUSflag;         /* if these booleans are non-zero */
  178.  
  179. extern char date_mask[9];     /* set_date() fills "00/00/00" to system date */
  180.  
  181. extern void set_date(void);
  182.  
  183. extern char *dlrcvt(long );         /* convert long to form 999,999,999.99- */ 
  184. extern char *crdrform(long );            /* same but with trailing Dr or Cr */
  185.  
  186. extern int getkey(void);          /* keyin(noop) with key click and ^C trap */
  187.  
  188. extern int edit_masked_numeric(char *,void (*)());  /* Bufptr, FnKeyRoutine */
  189. extern int edit_string(char *,void (*)());          /* Bufptr, FnKeyRoutine */
  190.  
  191. extern void message(int ,int ,char *,... );       /* x,y, variable arg list */
  192.  
  193.  
  194. /* keydefs.h, 12/7/86, d.c.oshel
  195. */
  196.  
  197. extern int KeyDefs(char **, char *, char *); /* options array,title,prompt */
  198.  
  199.  
  200.