2017-11-20 14:25:09 +00:00
|
|
|
#include <curses.h>
|
|
|
|
#include "inc/interface.h"
|
|
|
|
#include "inc/memory.h"
|
|
|
|
|
|
|
|
void io_init()
|
|
|
|
{
|
|
|
|
initscr();
|
|
|
|
noecho();
|
|
|
|
cbreak();
|
|
|
|
nodelay(stdscr, TRUE);
|
2017-11-21 17:06:40 +00:00
|
|
|
|
|
|
|
keyboard_control = 0x00;
|
2017-11-20 14:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void input()
|
|
|
|
{
|
|
|
|
int ch = getch();
|
2017-11-21 17:06:40 +00:00
|
|
|
if (ch == '\n') { ch = '\r'; }
|
2017-11-23 01:28:49 +00:00
|
|
|
if (ch == '\r' || ch == '.' || ch == ':' ||
|
|
|
|
(ch >= '0' && ch <= '9') ||
|
|
|
|
(ch >= 'A' && ch <= 'Z'))
|
2017-11-20 14:25:09 +00:00
|
|
|
{
|
|
|
|
keyboard_buffer = ch | 0x80;
|
|
|
|
keyboard_control = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void output()
|
|
|
|
{
|
|
|
|
// display is ready to ouptup
|
|
|
|
if (display_buffer & 0x80)
|
|
|
|
{
|
|
|
|
// outputs the buffer character
|
|
|
|
display_buffer = display_buffer & 0x7F;
|
2017-11-21 17:06:40 +00:00
|
|
|
if (display_buffer == '\r')
|
|
|
|
{
|
|
|
|
display_buffer = '\n';
|
|
|
|
}
|
2017-11-20 14:25:09 +00:00
|
|
|
addch(display_buffer);
|
|
|
|
}
|
|
|
|
}
|