source:
buchla-68k/libcio/conin.c@
d1ecb94
| Last change on this file since d1ecb94 was 8973acd, checked in by , 8 years ago | |
|---|---|
|
|
| File size: 897 bytes | |
| Rev | Line | |
|---|---|---|
| [f40a309] | 1 | /* |
| 2 | ============================================================================= | |
| 3 | conin.c -- read from the console | |
| 4 | Version 6 -- 1987-06-30 -- D.N. Lynx Crowe | |
| 5 | ============================================================================= | |
| 6 | */ | |
| 7 | ||
| [b28a12e] | 8 | #include "ram.h" |
| [f40a309] | 9 | |
| [8973acd] | 10 | uint8_t _ConBuf[258]; /* console input buffer */ |
| [7258c6a] | 11 | int16_t _CBused; |
| [f40a309] | 12 | |
| [8973acd] | 13 | int16_t _conin(io_arg arg, void *buff, int16_t len) |
| [f40a309] | 14 | { |
| [7258c6a] | 15 | int16_t nbp; |
| 16 | register int16_t l; | |
| [f40a309] | 17 | |
| [7ecfb7b] | 18 | (void)arg; |
| 19 | ||
| [f40a309] | 20 | if (_ConBuf[1] EQ 0) { |
| 21 | ||
| 22 | _ConBuf[0] = 255; | |
| 23 | _ConBuf[1] = _ConBuf[2] = 0; | |
| 24 | ||
| [8973acd] | 25 | readbuf(CON_DEV, (int8_t *)_ConBuf); |
| [f40a309] | 26 | writeln(CON_DEV, "\r\n"); |
| 27 | ||
| 28 | if (_ConBuf[2] EQ 0x1a) { | |
| 29 | ||
| 30 | _ConBuf[1] = 0; | |
| 31 | return(0); | |
| 32 | } | |
| 33 | ||
| 34 | nbp = ++_ConBuf[1]; | |
| 35 | _ConBuf[nbp++ + 1] = '\r'; | |
| 36 | _ConBuf[nbp + 1] = '\n'; | |
| 37 | _CBused = 2; | |
| 38 | } | |
| 39 | ||
| 40 | if ((l = _ConBuf[1]) > len) | |
| 41 | l = len; | |
| 42 | ||
| 43 | memcpy(buff, (_ConBuf + _CBused), l); | |
| 44 | _CBused += l; | |
| [8973acd] | 45 | _ConBuf[1] = (uint8_t)(_ConBuf[1] - l); |
| [f40a309] | 46 | return (l); |
| 47 | } | |
| [6262b5c] | 48 |
Note:
See TracBrowser
for help on using the repository browser.
![(please configure the [header_logo] section in trac.ini)](http://bob.lopatic.de/chrome/site/logo.png)