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();
|
2017-11-26 04:30:17 +00:00
|
|
|
|
|
|
|
scrollok(stdscr, TRUE);
|
2017-11-20 14:25:09 +00:00
|
|
|
nodelay(stdscr, TRUE);
|
2017-11-26 04:30:17 +00:00
|
|
|
keypad(stdscr, TRUE);
|
2017-11-21 17:06:40 +00:00
|
|
|
|
2017-11-28 03:24:59 +00:00
|
|
|
//curs_set(FALSE);
|
2017-11-26 04:48:01 +00:00
|
|
|
|
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-28 03:24:59 +00:00
|
|
|
|
|
|
|
if (ch == 0x7F) { ch = '_'; }
|
2017-11-21 17:06:40 +00:00
|
|
|
if (ch == '\n') { ch = '\r'; }
|
2017-11-28 03:24:59 +00:00
|
|
|
if (ch >= 'a' && ch <= 'z') { ch = ch - 0x20; }
|
|
|
|
|
|
|
|
if (ch == '\r' || (ch >= 0x20 && ch <= 0x7F))
|
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-28 12:03:17 +00:00
|
|
|
if (display_buffer != 0x7F)
|
|
|
|
{
|
|
|
|
addch(display_buffer);
|
|
|
|
refresh();
|
|
|
|
}
|
2017-11-20 14:25:09 +00:00
|
|
|
}
|
|
|
|
}
|