/*-
* Copyright (c) 1998 Robert Nordier
* All rights reserved.
*
* Redistribution and use in source and binary forms are freely
* permitted provided that the above copyright notice and this
* paragraph and the following disclaimer are duplicated in all
* such forms.
*
* This software is provided "AS IS" and without any express or
* implied warranties, including, without limitation, the implied
* warranties of merchantability and fitness for a particular
* purpose.
*/
#include <btxv86.h>
#include "lib.h"
#include "rbx.h"
#include "util.h"
#include "cons.h"
void
putc(int c)
{
v86int();
}
void
xputc(int c)
{
if (ioctrl & IO_KEYBOARD)
putc(c);
sio_putc(c);
}
void
putchar(int c)
{
if (c == '\n')
xputc('\r');
xputc(c);
}
int
{
/*
* The extra comparison against zero is an attempt to work around
* what appears to be a bug in QEMU and Bochs. Both emulators
* sometimes report a key-press with scancode one and ascii zero
* when no such key is pressed in reality. As far as I can tell,
* this only happens shortly after a reboot.
*/
v86int();
}
int
{
if (OPT_CHECK(RBX_NOINTR))
return (0);
for (;;) {
if (fn)
return (0);
}
/* NOTREACHED */
}
int
{
if (OPT_CHECK(RBX_NOINTR))
return (0);
t0 = 0;
for (;;) {
if (xgetc(1))
return (1);
if (secs > 0) {
if (!t0)
return (0);
}
}
/* NOTREACHED */
}
void
{
char *s;
int c;
s = cmdstr;
for (;;) {
switch (c = xgetc(0)) {
case 0:
break;
case '\177':
case '\b':
if (s > cmdstr) {
s--;
printf("\b \b");
}
break;
case '\n':
case '\r':
*s = 0;
return;
default:
*s++ = c;
putchar(c);
break;
}
}
}
int
getchar(void)
{
return (xgetc(0));
}