summaryrefslogtreecommitdiff
path: root/src/video/ncurses.c
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-11-29 13:32:45 +1100
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-11-29 13:32:45 +1100
commit8d3aaacf14997bbac177ae37ccab4618264cf29c (patch)
tree33cbf86fae08bc1bf97d5d38f1ac2ebebf6e7cd0 /src/video/ncurses.c
parentcbd011fe442dfb520de7b51b61e9c4ef1eacae2f (diff)
work on peripherals and display
Diffstat (limited to 'src/video/ncurses.c')
-rw-r--r--src/video/ncurses.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/src/video/ncurses.c b/src/video/ncurses.c
index 76bfb26..380c57a 100644
--- a/src/video/ncurses.c
+++ b/src/video/ncurses.c
@@ -10,28 +10,64 @@
int TermX = 0;
int TermY = 0;
+WINDOW *AppleWindow;
+
+
+char UserInput()
+{
+ return getch();
+}
+
+
+
void TerminalInit()
{
initscr();
cbreak();
noecho();
curs_set(0);
+ keypad(stdscr, TRUE);
+
+ AppleWindow = newwin(24, 40, 1, 1);
+
+ // Draw the border.
+ attron(A_REVERSE);
+ move(0, 0);
+ printw(" ");
+ for (int i = 1; i <= 24; i++)
+ {
+ mvaddch(i, 0, ' ');
+ mvaddch(i, 41, ' ');
+ }
+ mvprintw(25, 0, " ~ ");
+ mvprintw(26, 0, " Alekseis Apple I ");
+ mvprintw(27, 0, " ");
+ attroff(A_REVERSE);
+
+
+ mvwaddch(AppleWindow, TermY, TermX, '@' | A_BLINK);
TerminalShiftRegister = (byte*)malloc(960);
TerminalShiftRegisterPosition = TerminalShiftRegister;
TerminalShiftRegisterOffset = 0;
+
+ refresh();
}
+
+
+
void TerminalClose()
{
free(TerminalShiftRegister);
- curs_set(0);
+ curs_set(1);
endwin();
}
+// Takes an an Apple I ASCII character.
void TerminalInput(char n)
{
- mvaddch(TermY,TermX,n);
+ mvwaddch(AppleWindow, TermY,TermX,n);
*TerminalShiftRegisterPosition = n;
TerminalShiftRegisterPosition++;
@@ -64,7 +100,7 @@ void TerminalInput(char n)
if (offset >= (TerminalShiftRegister + 960))
offset -= 960;
- mvaddch(i,j, *(offset));
+ mvwaddch(AppleWindow, i, j, *(offset));
offset++;
}}
@@ -72,8 +108,9 @@ void TerminalInput(char n)
TermX = 0;
// Clear bottom line.
- mvwprintw(stdscr, TermY, TermX, " ");
+ mvwprintw(AppleWindow, TermY, TermX, " ");
}
- mvaddch(TermY, TermX, '@' | A_BLINK);
-} \ No newline at end of file
+ mvwaddch(AppleWindow, TermY, TermX, '@' | A_BLINK);
+ wrefresh(AppleWindow);
+}