summaryrefslogtreecommitdiff
path: root/src/video
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
parentcbd011fe442dfb520de7b51b61e9c4ef1eacae2f (diff)
work on peripherals and display
Diffstat (limited to 'src/video')
-rw-r--r--src/video/interface.h5
-rw-r--r--src/video/ncurses.c49
-rw-r--r--src/video/signetics.c17
3 files changed, 47 insertions, 24 deletions
diff --git a/src/video/interface.h b/src/video/interface.h
index 49ac75c..5100032 100644
--- a/src/video/interface.h
+++ b/src/video/interface.h
@@ -1,8 +1,11 @@
// interface.h
// Provides the interface with which all video interactions must occur.
+// Common procedure for taking in user input.
+char UserInput();
+
void TerminalInit();
void TerminalClose();
-void TerminalInput(char n); \ No newline at end of file
+void TerminalInput(char n);
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);
+}
diff --git a/src/video/signetics.c b/src/video/signetics.c
index c6dca10..4a996d8 100644
--- a/src/video/signetics.c
+++ b/src/video/signetics.c
@@ -16,20 +16,3 @@ const byte* TerminalShiftRegister;
byte* TerminalShiftRegisterPosition;
int TerminalShiftRegisterOffset;
-
-byte ToAppleASCII(char x)
-{
- if (x < 0x20 || x >= 0x60)
- return -1;
- if (x >= 0x40)
- x -= 0x40;
- return x;
-}
-
-byte ToRegularASCII(char x)
-{
- if (x < 0x20)
- x += 0x40;
- return x;
-}
-