home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / BDSC / BDSC-1 / BDSCIO.H < prev    next >
C/C++ Source or Header  |  2000-06-30  |  5KB  |  152 lines

  1. /*
  2.     The BDS C Standard I/O header file --  v1.45    11/12/81
  3.  
  4.     This file contains global definitions, for use in all C programs
  5.     in PLACE of (yechhh) CONSTANTS. Characteristics of your system such
  6.     as video screen size, interface port numbers and masks, buffered I/O
  7.     allocations, etc., should all be configured just once within this
  8.     file. Any program which needs them should contain the preprocessor
  9.     directive:
  10.  
  11.         #include "bdscio.h"
  12.  
  13.     near the beginning. 
  14.     Go through and set all this stuff as soon as you get the package,
  15.     and most terminal-dependent sample programs should run much better.
  16. */
  17.  
  18.  
  19. /*
  20.     Some console (video) terminal characteristics:
  21.     (pre-configured for H19/Z19/H89/Z89)
  22. */
  23.  
  24. #define TWIDTH    80    /* # of columns    */
  25. #define TLENGTH    24    /* # of lines    */
  26. #define CLEARS    "\033E"    /* String to clear screen on console    */
  27. #define INTOREV    "\033p"    /* String to switch console into reverse video    */
  28. #define OUTAREV "\033q"    /* String to switch console OUT of reverse video  */
  29. #define CURSOROFF "\033x5"    /* String to turn cursor off    */
  30. #define CURSORON "\033y5"    /* String to turn cursor on    */
  31. #define ESC    '\033'    /* Standard ASCII 'escape' character    */
  32.  
  33. /*
  34.     Console serial port characteristics:
  35. */
  36.  
  37. #define CSTAT    0355    /* status port    */
  38. #define CDATA    0350    /* data port    */
  39. #define CIMASK    0x01    /* input data ready mask   */
  40. #define COMASK    0x20    /* output data ready mask  */
  41. #define CAHI    1    /* True if status active high    */
  42. #define CRESET    0    /* True if status port needs to be reset after input */
  43. #define CRESETVAL 0    /* If CRESET is true, this is the value to send    */
  44.  
  45. /*
  46.      Modem characteristics:
  47. */
  48.  
  49. #define    MSTAT    0335    /* status port    */
  50. #define MDATA    0330    /* data port    */
  51. #define MIMASK    0x01    /* input data ready mask    */
  52. #define MOMASK    0x20    /* ready to send a character mask    */
  53. #define MAHI    1    /* True if status logic active high  */
  54. #define MRESET    0    /* True if status port needs to be reset */
  55. #define MRESETVAL 0    /* If MRESET true, this is the byte to send */
  56.  
  57. /*
  58.     General purpose Symbolic constants:
  59. */
  60.  
  61. #define BASE 0        /* Base of CP/M system RAM (0 or 0x4200)  */
  62. #define NULL 0
  63. #define EOF -1        /* Physical EOF returned by low level I/O functions */
  64. #define ERROR -1    /* General "on error" return value */
  65. #define OK 0        /* General purpose "no error" return value */
  66. #define JBUFSIZE 6    /* Length of setjump/longjump buffer    */
  67. #define CPMEOF 0x1a    /* CP/M End-of-text-file marker (sometimes!)  */
  68. #define SECSIZ 128    /* Sector size for CP/M read/write calls */
  69. #define MAXLINE 135    /* Longest line of input expected from the console */
  70. #define TRUE 1        /* general purpose true truth value    */
  71. #define FALSE 0        /* general purpose false truth value     */
  72.  
  73. /*
  74.    The NSECTS symbol controls the compilation of the buffered
  75.    I/O routines within STDLIB2.C, allowing each user to set the
  76.    buffer size most convenient for his system, while keeping
  77.    the numbers totally invisible to the C source programs using
  78.    buffered I/O (via the BUFSIZ defined symbol.) For larger
  79.    NSECTS, the disk I/O is faster...but more ram is taken up.
  80.    Note that pre-1.4 versions of the library functions
  81.    were not set up to support this customizable buffer size,
  82.    and always compiled as if NSECTS were 1 in this version. To
  83.    change the buffer size allocation, follow these steps:
  84.  
  85.      1) Alter NSECTS to the desired value here in bdscio.h
  86.      2) Re-compile STDLIB1.C and STDLIB2.C
  87.      3) Use CLIB to combine STDLIB1.CRL and STDLIB2.CRL to make
  88.       a new DEFF.CRL.
  89.  
  90.    Make sure you use declare all your I/O buffers with the a
  91.    statement such as:
  92.           char buf_name[BUFSIZ];
  93.        instead of the older and now obsolete:
  94.           char buf_name[134];
  95.        (and always #include "bdscio.h" in your programs!)
  96. */
  97.  
  98. #define NSECTS 8    /* Number of sectors to buffer up in ram */
  99.  
  100. #define BUFSIZ (NSECTS * SECSIZ + 6 )    /* Don't touch this */
  101.  
  102. struct _buf {                /* Or this...        */
  103.     int _fd;
  104.     int _nleft;
  105.     char *_nextp;
  106.     char _buff[NSECTS * SECSIZ];
  107. };
  108.  
  109.  
  110.  
  111. /*
  112.     If you plan to use the high-level storage allocation functions
  113.     from the library ("alloc" and "free") then:
  114.  
  115.       1) Uncomment (enable) the "ALLOC_ON" definition, and comment out the
  116.          "ALLOC_OFF" definition from this file.
  117.  
  118.       2) Re-compile STDLIB1.C, and use CLIB to transfer "alloc"
  119.          and "free" into the DEFF.CRL library file.
  120.  
  121.       3) THIS IS IMPORTANT!!! Include the statement:
  122.  
  123.         _allocp = NULL;       /* initialize allocation pointer */
  124.  
  125.          somewhere in your "main" function PRIOR to the first use
  126.          of the "alloc" function. DON'T FORGET THIS INITIALIZATION!!
  127.  
  128.     Remember to include bdscio.h in ALL files of your C program.
  129.  
  130.     The lack of static variables is the reason for all this messiness.
  131. */
  132.  
  133. #define ALLOC_OFF 1    /* disables storage allocation if uncommented */
  134.  
  135.             /* only ONE of these two lines should be uncommented */
  136. /*
  137. #define ALLOC_ON 1    /* enables storgage allocation if uncommented */
  138. */
  139.  
  140.  
  141. #ifdef ALLOC_ON            /* if storage allocation enabled, */
  142.  
  143. struct _header  {
  144.     struct _header *_ptr;
  145.     unsigned _size;
  146.  };
  147.  
  148. struct _header _base;        /* declare this external data to  */
  149. struct _header *_allocp;    /* be used by alloc() and free()  */
  150.  
  151. #endif
  152.