summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/apple.h1
-rw-r--r--src/main.c6
-rw-r--r--src/video/interface.h4
-rw-r--r--src/video/ncurses.c47
-rw-r--r--src/video/signetics.c9
5 files changed, 53 insertions, 14 deletions
diff --git a/src/apple.h b/src/apple.h
index 64542de..ea1f04e 100644
--- a/src/apple.h
+++ b/src/apple.h
@@ -2,6 +2,7 @@
#define APPLE_H
#include "cpu/core.h"
+#include <stdlib.h>
#define MEMORY_SIZE 4096
diff --git a/src/main.c b/src/main.c
index 5e7bfa2..8b07189 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,6 @@
#include "apple.h"
#include "video/interface.h"
+#include <ncurses.h>
int main() {
@@ -7,8 +8,9 @@ int main() {
AppleOn();
- TerminalPrompt();
- getch();
+ while(1) {
+ TerminalInput(getch());
+ }
TerminalClose();
diff --git a/src/video/interface.h b/src/video/interface.h
index db9bd54..49ac75c 100644
--- a/src/video/interface.h
+++ b/src/video/interface.h
@@ -5,6 +5,4 @@ void TerminalInit();
void TerminalClose();
-void TerminalInput(char n);
-
-void TerminalPrompt(); \ No newline at end of file
+void TerminalInput(char n); \ No newline at end of file
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
diff --git a/src/video/signetics.c b/src/video/signetics.c
index 944ac4d..c6dca10 100644
--- a/src/video/signetics.c
+++ b/src/video/signetics.c
@@ -1,6 +1,7 @@
// signetics.h
-// The Apple I came with its own terminal on-board, with a Signetics 2513 character ROM, and multiple shift registers acting as video memory.
-#include"cpu/core.h"
+// Signetics refers to the various Signetics brand chips which the Apple I came with, including a character ROM, and a shift-register based video memory.
+
+#include"../cpu/core.h"
#include"stdlib.h"
const byte CharacterROM[0x40] = {
@@ -10,7 +11,9 @@ const byte CharacterROM[0x40] = {
'0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , ':' , ';' , '<' , '=' , '>' , '?'
};
-byte* TerminalShiftRegister;
+const byte* TerminalShiftRegister;
+
+byte* TerminalShiftRegisterPosition;
int TerminalShiftRegisterOffset;