2018-01-28 19:00:23 +00:00
|
|
|
Standard Input/Output Functions for C02 Programs
|
|
|
|
|
|
|
|
At the beginning of the program use the directives
|
|
|
|
|
2018-07-30 00:40:31 +00:00
|
|
|
#include <stddef.h02>
|
2018-01-28 19:00:23 +00:00
|
|
|
#include <stdio.h02>
|
|
|
|
|
|
|
|
The following functions are defined:
|
|
|
|
|
2018-02-02 21:33:57 +00:00
|
|
|
c = getc(); Waits for a keypress and returns the cleaned
|
2018-01-28 19:00:23 +00:00
|
|
|
ASCII value corresponding to the pressed key.
|
|
|
|
|
2020-10-14 02:22:34 +00:00
|
|
|
Note: Aliased to getchr() from system library.
|
2018-01-28 19:00:23 +00:00
|
|
|
|
2018-02-02 21:33:57 +00:00
|
|
|
putc(c); Writes character c to the screen.
|
2018-01-28 19:00:23 +00:00
|
|
|
|
2020-10-14 02:22:34 +00:00
|
|
|
Note: Aliased to putchr() from system library.
|
2018-01-28 19:00:23 +00:00
|
|
|
|
2018-02-02 21:33:57 +00:00
|
|
|
r = gets(&s); Reads a maximum of 128 characters from keyboard
|
2018-01-28 19:00:23 +00:00
|
|
|
until the Return/Enter key is pressed, storing the
|
|
|
|
entered characters as null-terminated string s.
|
|
|
|
|
|
|
|
Allows corrections using Backspace/Delete.
|
|
|
|
|
|
|
|
Pressing the Escape/Abort key terminates entry,
|
|
|
|
leaving the string in an undefined state.
|
|
|
|
|
|
|
|
Returns number of characters entered, or 255
|
|
|
|
if entry was aborted.
|
|
|
|
|
2020-10-14 02:22:34 +00:00
|
|
|
Note: Calls getc() in a loop and uses constants
|
2018-01-28 19:00:23 +00:00
|
|
|
DELKEY, RTNKEY, and ESCKEY from the system library.
|
|
|
|
|
2018-02-02 21:33:57 +00:00
|
|
|
r = puts(&s): Writes up to 128 characters of null-terminated
|
2018-01-28 19:00:23 +00:00
|
|
|
string s to the screen.
|
|
|
|
|
|
|
|
Returns position of null terminator in string.
|
|
|
|
|
2020-10-14 02:22:34 +00:00
|
|
|
Note: Calls putsub(0, &s).
|
2018-01-28 19:00:23 +00:00
|
|
|
|
2018-02-02 21:33:57 +00:00
|
|
|
r = putsub(n, &s): Writes up to 128 characters of null-terminated
|
2018-01-28 19:00:23 +00:00
|
|
|
string s to the screen, starting at position n.
|
|
|
|
|
|
|
|
Returns position of null terminator in string.
|
|
|
|
|
2020-10-14 02:22:34 +00:00
|
|
|
Note: Calls putc() in a loop.
|
2018-01-28 19:00:23 +00:00
|
|
|
|
2018-02-02 21:33:57 +00:00
|
|
|
r = putln(&s): Writes up to 128 characters of null-terminated
|
2018-01-28 19:00:23 +00:00
|
|
|
string s to the screen and advances the cursor to
|
|
|
|
the beginning of the next line.
|
|
|
|
|
|
|
|
Returns number of characters printed.
|
|
|
|
|
2020-10-14 02:22:34 +00:00
|
|
|
Note: Calls puts(&s) followed by newlin().
|
2018-01-28 19:00:23 +00:00
|
|
|
|
|
|
|
Note: This library expects the following functions to be defined:
|
|
|
|
|
|
|
|
getkey(); Wait for and read ASCII character from keyboard
|
|
|
|
prchr(c); Print ASCII character to screen
|
|
|
|
delchr(); Backspace and delete previous character on screen
|
|
|
|
newlin(); Advance cursor to beginning of next line
|
|
|
|
setsrc(&s); Set source string pointer and initialize index
|
|
|
|
|
2020-10-14 02:22:34 +00:00
|
|
|
along with the zero page word
|
2018-01-28 19:00:23 +00:00
|
|
|
|
2020-10-14 02:22:34 +00:00
|
|
|
srcptr Source string pointer
|
2018-01-28 19:00:23 +00:00
|
|
|
|
|
|
|
and the assembler constants
|
|
|
|
|
|
|
|
DELKEY Delete/Backspace key ASCII code (usually DEL or BS)
|
|
|
|
ESCKEY Escape/Abort key ASCII code (usually ESC)
|
|
|
|
RTNKEY Return/Enter key ASCII code (usually CR)
|