summaryrefslogtreecommitdiff
path: root/src/video/ncurses.c
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-11-28 12:02:07 +1100
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-11-28 12:02:07 +1100
commitb4452ce8455ded6ecd4373ba30323c5c245260e8 (patch)
tree4dc718c3de1e2c26a3a0c988af33058fd1ddf421 /src/video/ncurses.c
parent2ded6baaab3946e461a7cf0b39618b31e5806c89 (diff)
terminal
Diffstat (limited to 'src/video/ncurses.c')
-rw-r--r--src/video/ncurses.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/src/video/ncurses.c b/src/video/ncurses.c
index 05653e2..76bfb26 100644
--- a/src/video/ncurses.c
+++ b/src/video/ncurses.c
@@ -15,30 +15,65 @@ void TerminalInit()
initscr();
cbreak();
noecho();
+ curs_set(0);
TerminalShiftRegister = (byte*)malloc(960);
+ TerminalShiftRegisterPosition = TerminalShiftRegister;
TerminalShiftRegisterOffset = 0;
}
void TerminalClose()
{
free(TerminalShiftRegister);
+ curs_set(0);
endwin();
}
-void TerminalInput()
+void TerminalInput(char n)
{
+ mvaddch(TermY,TermX,n);
+
+ *TerminalShiftRegisterPosition = n;
+ TerminalShiftRegisterPosition++;
+ if (TerminalShiftRegisterPosition >= (TerminalShiftRegister + 960))
+ TerminalShiftRegisterPosition = TerminalShiftRegister;
+
+
+ TermX++;
+
+ if (n == KEY_ENTER) {
+ TermY++;
+ }
+
if (TermX >= 40) {
TermX = 0;
TermY++;
}
if (TermY >= 24) {
-
+ TerminalShiftRegisterOffset += 40; // Discard first line
+ if (TerminalShiftRegisterOffset >= 960)
+ TerminalShiftRegisterOffset = TerminalShiftRegister;
+
+ byte *offset = TerminalShiftRegister + TerminalShiftRegisterOffset;
+
+ // For every position, fill with contents of the terminal shift register
+ for (int i = 0; i < 23; i++) {
+ for (int j = 0; j < 40; j++) {
+
+ if (offset >= (TerminalShiftRegister + 960))
+ offset -= 960;
+
+ mvaddch(i,j, *(offset));
+ offset++;
+ }}
+
+ TermY = 23;
+ TermX = 0;
+
+ // Clear bottom line.
+ mvwprintw(stdscr, TermY, TermX, " ");
}
-}
-void TerminalPrompt()
-{
- addch('@' | A_BLINK);
+ mvaddch(TermY, TermX, '@' | A_BLINK);
} \ No newline at end of file