diff options
Diffstat (limited to 'terminal')
| -rw-r--r-- | terminal/vt52.c | 8 | ||||
| -rw-r--r-- | terminal/vt52.h | 35 |
2 files changed, 39 insertions, 4 deletions
diff --git a/terminal/vt52.c b/terminal/vt52.c index 9ff1150..3fa4137 100644 --- a/terminal/vt52.c +++ b/terminal/vt52.c @@ -54,12 +54,13 @@ static void clear(vt52_tty *tty) } } -vt52_tty vt52_init(term_out *screen) +vt52_tty vt52_init(term_out *screen,term_in *input) { vt52_tty tty; tty.data=kballoc(1); tty.screen=screen; + tty.input=input; tty.x=0; tty.y=0; @@ -80,6 +81,11 @@ static void set_char(vt52_tty *tty, uint32_t x, uint32_t y, uint32_t c) static uint8_t escaping=0; +void vt52_kb(vt52_tty *tty, uint8_t c) +{ + vt52_put(tty,c); + tty->input->put_char(c); +} // send one ASCII character to the terminal void vt52_put(vt52_tty *tty, uint8_t c) { diff --git a/terminal/vt52.h b/terminal/vt52.h index cdc62bd..94502d1 100644 --- a/terminal/vt52.h +++ b/terminal/vt52.h @@ -4,8 +4,27 @@ #include <stdint.h> -// REQUIREMENTS -// * kballoc // block wise in-kernel allocation +// +// Emulator of a vt52 terminal +// +// 1. pass a term_out and term_in struct to vt52_init(..). +// 2. use the vt52_kb function for terminal/user input (eg. keyboard). +// 3. use the vt52_put function for input from the host/programms. +// +// +// +// ________ +// vt52_put() ------> | | ----> (term_out_struct) +// | VT52 | +// (term_in_struct)<-- |_______| <---- vt52_kb() +// +// +// OTHER REQUIREMENTS +// +// Your also need to provide some memory allocation +// +// * uint32_t kballoc(uint32_t bloks); // block wise in-kernel allocation +// typedef struct term_out_struct { @@ -15,6 +34,13 @@ typedef struct term_out_struct }term_out; +typedef struct term_in_struct +{ + + void (*put_char)(uint8_t c); + +}term_in; + typedef struct vt52_tty_struct { @@ -23,11 +49,14 @@ typedef struct vt52_tty_struct uint32_t x; uint32_t y; uint32_t *data; // screen data + term_out *screen; + term_in *input; }vt52_tty; -vt52_tty vt52_init(term_out *screen); +vt52_tty vt52_init(term_out *screen,term_in *input); void vt52_put(vt52_tty *tty, uint8_t c); +void vt52_kb(vt52_tty *tty, uint8_t c); #endif |
