summaryrefslogtreecommitdiff
path: root/terminal/vt52.c
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2015-05-17 00:59:28 +0200
committerMichal Idziorek <m.i@gmx.at>2015-05-17 00:59:28 +0200
commit819a4e871058f2dc4a2e255ecbe5a2c49cc8450c (patch)
tree55849f4233682ab88bd9044575a6dbfbc244d51d /terminal/vt52.c
parent3bac6dd02d640923646b8ad988f509f47adab57f (diff)
struggling with smp and APICs and started vt52 emulation
Diffstat (limited to 'terminal/vt52.c')
-rw-r--r--terminal/vt52.c67
1 files changed, 49 insertions, 18 deletions
diff --git a/terminal/vt52.c b/terminal/vt52.c
index aa24435..1dc7289 100644
--- a/terminal/vt52.c
+++ b/terminal/vt52.c
@@ -8,10 +8,17 @@
// | | ---> Screen
// ------------
+// Interface:
+//
+// struct vt52_tty_struct; // TODO: check what is better to put in header!
+// vt52_tty vt52_init();
+// put(vt52_tty *tty, uint8_t c);
+//
+//
// REQUIREMENTS
-// * kballoc // block alloc
+// * kballoc // block wise in-kernel allocation
#include <stdint.h>
#include "kernel/kmalloc.h"
@@ -24,42 +31,66 @@
typedef struct vt52_tty_struct
{
- uint8_t x;
- uint8_t y;
- uint8_t *data; // screen data
+ uint32_t width;
+ uint32_t height;
+ uint32_t x;
+ uint32_t y;
+ uint32_t *data; // screen data
}vt52_tty;
-vt52_tty *vt52_init()
+vt52_tty vt52_init()
{
- vt52_tty *tty=kballoc(sizeof(vt52_tty));
- return tty;
-}
+ vt52_tty tty;
+ tty.data=kballoc(1);
-// User interaction
-void putKey(uint32_t code)
-{
+ tty.x=0;
+ tty.y=0;
+ tty.width=VT52_WIDTH;
+ tty.height=VT52_HEIGHT;
+
+ return tty;
}
-void refreshScreen()
+uint32_t index(vt52_tty *tty, uint32_t x, uint32_t y)
{
-
+ return tty->width*y+x;
}
-// Programm Interaction
-void put()
+void set_char(vt52_tty *tty, uint32_t x, uint32_t y, uint32_t c)
{
-
+ tty->data[index(tty,x,y)]=c;
}
-void get()
+// send one ASCII character to the terminal
+void put(vt52_tty *tty, uint8_t c)
{
-
+ set_char(tty,tty->x,tty->y,c);
+
+ if(tty->x>tty->width)
+ {
+ tty->x=0;
+ tty->y++;
+ }
+
+ //autoscroll
+ if(tty->y>=tty->height)
+ {
+ tty->y--;
+ for(uint32_t l=tty->y; l>0; l--)
+ {
+ for(uint32_t x=0;x<tty->width;x++)
+ {
+ tty->data[index(tty,x,l-1)] = tty->data[index(tty,x,l)];
+ }
+ }
+ }
}
+