home *** CD-ROM | disk | FTP | other *** search
- // Written by Chris Sokol
-
- #include <bios.h>
- #include <stdio.h>
- #include "tty.h"
-
- static void Init();
- static void Run();
- static void Term();
-
- static TTY *tty;
-
- void Init()
- {
- TTYInit();
-
- tty = new TTY("COM2", 256, 256);
- tty->Baud(9600);
- tty->Bits(8);
- tty->Prty('-');
- tty->Stop(1);
-
- tty->Put('\r');
- }
-
- int main(int, char*[])
- {
- printf("TTY test started.\n");
-
- Init();
-
- Run();
-
- Term();
-
- printf("\rTTY test terminated.\n");
-
- return 0;
- }
-
- void Run()
- {
- while (1)
- if (bioskey(1))
- {
- uint k;
-
- k = bioskey(0);
-
- if (k == 0x2d00)
- break;
-
- k &= 0xff;
-
- if (!k)
- continue;
-
- tty->Put(k);
- }
- else if (tty->Avail())
- {
- uint e;
-
- e = tty->Get();
-
- if (e / 0x100 == TTYrxchar)
- printf("%c", e & 0xff);
- }
- }
-
- void Term()
- {
- delete tty;
-
- TTYTerm();
- }
-