home *** CD-ROM | disk | FTP | other *** search
- /* cmdoss.cpm COMND module; OS-specific routines for CP/M-80
-
- Copyright (C) 1985 Mark E. Mallett
-
- Permission is hereby granted to distribute this file indiscriminately.
-
- Edit history
-
- When Who What
- ------ --- --------------------------------
- 84xxxx MEM Create file.
-
-
- Routines included are:
-
- CMDfob Flush terminal output buffer.
- CMDgtc Get character from terminal without echo
- CMDptc Output character to terminal (buffered)
- CMDpzs Put NUL-terminated string to terminal
- */
-
-
- #include "stdio.h" /* Standard system defs */
- #include "mem.h" /* Include my standard names */
-
-
- /* External routines */
-
-
- /* External data */
-
-
- /* Internal (public) routines */
-
-
-
- /* Internal (public) data */
-
-
- /* Local (static) data */
-
- BYTE Coline[201] = {0}; /* Output line */
- int Colpos = {0}; /* Position in output line */
-
- /*
-
- *//* CMDgtc()
-
- Get terminal input character, no echo.
-
- */
-
- CMDgtc()
-
- {
- IND int c;
-
- while ((c = CPM(6,0xffff)&0xff) == 0)
- ;
- return (c&0x7f);
- }
- /*
- *//* CMDpzs (sptr)
-
- Output a zero-terminated string to the console.
-
-
- Inputs
-
- sptr Address of the zero-terminated string
-
-
- Outputs
-
- The string (buffered) out to the terminal.
-
-
- Notes
-
- CMDfob() can be called to flush the output.
-
- */
-
- CMDpzs (sptr)
-
- BYTE *sptr; /* Address of string to output */
-
- {
- while (*sptr != NUL) /* Until end.. */
- CMDpoc (*sptr++); /* Output. */
- }
- /*
-
- *//* CMDptc(c)
-
- Output c to the terminal, buffered.
-
- */
-
- CMDptc(c)
-
- {
- Coline[Colpos++] = c; /* Store char */
- if ((c == '\n') || (Colpos == 200)) /* If read to break */
- CMDfob(); /* break */
- }
- /*
-
- *//* CMDfob()
-
- Break console output.
-
- */
-
- CMDfob()
-
- {
- if (Colpos)
- {
- write (fileno(stdout),Coline,Colpos); /* Write the line */
- Colpos = 0; /* Reset pointer */
- }
- }
-