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 / BEEHIVE / COMMS / YAM.ARC / YAM11.C < prev    next >
Text File  |  1990-09-20  |  6KB  |  328 lines

  1. /*
  2. >>:yam11.c   01-Jun-83
  3.  * Console primitives 
  4.  * 'moment','pstat','lpstat','lprintf','getcty','putcty','sendcon'
  5.  * extracted from all other YAM modules, and placed here so that
  6.  * they may be more easily got at and altered for different
  7.  * machines    (jdw).
  8.  */
  9.  
  10. #include "yam.h"
  11.  
  12. /* following are BIOS calls */
  13. #define CONST 2            /* bios console char ready */
  14. #define CONIN 3            /* bios cons char input */
  15. #define CONOUT 4        /* bios cons char output */
  16.  
  17. /* following are BDOS calls */
  18. #define BDOS 5            /* address used to call bdos */
  19. #define SELDSK 14        /* bdos select disk 0=default disk */
  20. #define SRCH 17            /* bdos search for file pattern*/
  21. #define SRCHNXT 18        /* search for next occurrence */
  22. #define GETDEFDISK 25        /* get current disk  (0-15) */
  23. #define SETDMA 26        /* set address for read, write, etc. */
  24. #define GETALLOCP 27        /* get address of allocation vector */
  25. #define SETATTRIB 30        /* update file attributes */
  26. #define GETDPBP 31        /* get DPB address for disk */
  27. #define SETGETUSER 32        /* set or get user number */
  28. #define COMPFILSIZ 35        /* compute file size into recn and recovf */
  29. #define UFNSIZE 15        /* a:foobar12.urk\0 is 15 chars */
  30.  
  31.  
  32.  
  33. #ifdef    SORCERER
  34.  
  35.            /* a local video handler for status line */
  36.            /* also keyboard cause unmodded Sorcerer
  37.               upsets UART port */
  38.  
  39. putchar(c)
  40. char (c);
  41. {
  42.     putch(c);
  43. }
  44.  
  45.  
  46. putch(c)
  47. char c;
  48. {
  49.     int mwasav;
  50.  
  51.     mwasav = *mwalin;
  52.     switch (c)
  53.     {
  54.     case (12) : callit(17);callit(' ');callit(17);
  55.             setmem(0xf080,1856,' ');
  56.             setmem(0xf780,64,'=');
  57.             break;
  58.  
  59.       case ('\t') : callit(' ');
  60.             while (*mwacol%8)
  61.                putch(' ');
  62.             break;
  63.  
  64.       case ('\n') : callit('\r');
  65.  
  66.       default : callit (c);
  67.             if((*mwacol==63) && (mwasav==*mwalin))
  68.             putch('\n');
  69.  
  70.             if (*mwalin >= 1792)
  71.             {
  72.             movmem(0xf0c0,0xf080,1728);
  73.             setmem(0xf740,64,' ');
  74.             setmem(0xf780,64,'=');
  75.             callit(23);
  76.             }
  77.             break;
  78.     }
  79.  
  80. }
  81.  
  82. getchar()
  83. {
  84.     char c;
  85.     c = getch();
  86.     if (c) putchar(c);
  87.     return c;
  88. }
  89.  
  90.  
  91. getch()
  92. {
  93.     return (keyget());
  94. }
  95.  
  96.  
  97.  
  98.  
  99. /*
  100.  * SORCERER implements 30th line. pstat starts at lpstat + 3
  101.  * note that a call to lpstat will erase what pstat displays
  102.  */
  103.  
  104. pstat(a)
  105. char *a;
  106. {
  107.     char lin[MAXLINE];
  108.  
  109.     setmem(0xf7c0 + statpos,64 - statpos,' ');
  110.     _spr(lin,&a);
  111.     txtplot(lin,29,statpos,0);
  112.  
  113. }
  114.  
  115. /*
  116.  * Sorcerer 30th line. lpstat starts at col 1
  117.  * Rest of line is erased
  118.  */
  119.  
  120. lpstat(a,b,c)
  121. char *a, *b, *c;
  122. {
  123.     char lin[MAXLINE];
  124.  
  125.     setmem(0xf7c0,64,' ');
  126.     _spr(lin,&a);
  127.     txtplot(lin,29,0,0);
  128.     statpos = strlen(lin) + 3;
  129. }
  130.  
  131.  
  132.  
  133. char getcty()
  134. {
  135.     return keyget();
  136. }
  137. char putcty(c)
  138. char c;
  139. {
  140. #ifdef RXNONO
  141.     if(index(c, RXNONO))
  142.         return 0;
  143. #endif
  144.     putchar(c);
  145.     if(keyprs()) {
  146.         if( (c=(keyget() & KBMASK)) == XOFF)
  147.             keyget();
  148.         else
  149.             return c;
  150.     }
  151.     return FALSE;
  152. }
  153.  
  154. /*
  155.  * moment waits a moment and returns FALSE, unless a character is hit,
  156.  * in which case that character is returned
  157.  */
  158.  
  159. moment(n)
  160. int n;
  161. {
  162.     int c;
  163.     for(c=n*CLKMHZ; --c>0;)
  164.         if(keyprs())
  165.             return(keyget());
  166.     return FALSE;
  167. }
  168.  
  169.  
  170.  
  171. sendcon(c)        /* direct output to console */
  172.  
  173. char c;
  174.  
  175. {
  176.     putch(c);
  177. }
  178.  
  179. /* Any special initialisation for console hardware goes here */
  180.  
  181. init1_extra()
  182.  
  183. {
  184.     mwalin = mwa() + 0x68;
  185.     mwacol = mwa() + 0x6a;
  186.     statpos = 0;
  187. }
  188.  
  189. init2_extra()
  190.  
  191. {
  192. }
  193.  
  194. #endif        /* SORCERER */
  195.  
  196. #ifndef SORCERER
  197.  
  198. /*
  199.  * moment waits a moment and returns FALSE, unless a character is hit,
  200.  * in which case that character is returned
  201.  */
  202.  
  203. moment(n)
  204. int n;
  205.  
  206. {
  207.     int c;
  208.     for(c=n*CLKMHZ; --c>0;)
  209.         if(kbhit())
  210.             return(getchar());
  211.     return FALSE;
  212. }
  213.  
  214. pstat(a,b,c)
  215. char *a, *b, *c;
  216.  
  217. {
  218.     lprintf(a,b,c);
  219.     lprintf("\n");
  220. }
  221.  
  222. lpstat(a,b,c)
  223. char *a, *b, *c;
  224.  
  225. {
  226.     lprintf(a,b,c);
  227.     lprintf("\n");
  228. }
  229.  
  230. char getcty()
  231.  
  232. {
  233.     return bios(CONIN,0);
  234. }
  235.  
  236.  
  237. char putcty(c)
  238. char c;
  239.  
  240. {
  241. #ifdef RXNONO
  242.     if(index(c, RXNONO))
  243.         return 0;
  244. #endif /* RXNONO */
  245.  
  246.     if(View)        /* view set by list command, allows ^p */
  247.         putchar(c);
  248.     else{
  249.         sendcon(c);
  250.         if(Type)
  251.             sendline(c);    /* so remote user can see it */
  252.     }
  253.     if(bios(CONST,0)) {
  254.         if((c=(bios(CONIN,0)&KBMASK))==XOFF)
  255.             bios(CONIN,0);
  256.         else
  257.             return c;
  258.     }
  259.     return FALSE;
  260. }
  261.  
  262. #ifdef XMODEM
  263. /*
  264.  * lprintf is like regular printf but uses direct output to console
  265.  * This prevents status printouts from disrupting file transfers, etc.
  266.  */
  267.  
  268. lprintf(a,b,c,d,e,f)
  269. char *a, *b, *c, *d, *e, *f;
  270.  
  271. {
  272.     char lbuf[CMDLEN];
  273.     char *s;
  274.  
  275.     sprintf(lbuf, a,b,c,d,e,f);     /* format data into lbuf */
  276.     for(s=&lbuf; *s != '\0' ; ) {    /* now send lbuf to console directly */
  277.  
  278.         MODEMON
  279.         if (CDO){
  280.             printf("Carrier lost in lprintf function\n");
  281.             exit();            /* quit if carrier lost */
  282.         }
  283.         if(*s=='\n') {
  284.             sendcon('\r');        /* expand \n to \r\n */
  285.         }
  286.         sendcon(*s++);
  287.     }
  288. }
  289. #endif
  290.  
  291. sendcon(c)        /* direct output to console */
  292. char c;
  293.  
  294. {
  295. #ifdef XMODEM
  296.         MODEMON
  297.         if (CDO){
  298.             printf("Carrier lost in sendcon function\n");
  299.             exit();
  300.         }
  301. #endif /* XMODEM */
  302.  
  303. #ifdef CODATA
  304.         CONSOLON
  305.         while(!COREADY)
  306.             ;
  307.         outp(CODATA,c);
  308. #else
  309.         bios(CONOUT,c);
  310. #endif /* CODATA */
  311. }
  312.  
  313. /* Any special initialisation for console hardware goes here */
  314.  
  315. init1_extra()
  316.  
  317. {
  318. }
  319.  
  320. init2_extra()
  321.  
  322. {
  323. }
  324.  
  325. #endif /* !SORCERER */
  326.  
  327. /* end of YAM11.C   */
  328.