summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video/ncurses.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/video/ncurses.c b/src/video/ncurses.c
index 242a3e1..8e80580 100644
--- a/src/video/ncurses.c
+++ b/src/video/ncurses.c
@@ -14,11 +14,11 @@ int TermY = 0;
WINDOW *AppleWindow;
-const byte* VRAM;
+byte* VRAM;
-byte* VRAM_Position;
+int vPosition = 0;
-int VRAM_Offset;
+int vOffset = 0;
void PrintInfo()
@@ -82,8 +82,6 @@ void DisplayInit()
// Initialize the terminal shift register variables.
VRAM = (byte*)malloc(960);
- VRAM_Position = VRAM;
- VRAM_Offset = 0;
refresh();
}
@@ -111,9 +109,9 @@ void DisplayInput(byte n)
if (n == CR) {
// Add spacing characters into VRAM
do {
- *VRAM_Position = ' ';
- VRAM_Position++;
- } while (((int)(VRAM_Position - VRAM) % 40) > 0);
+ VRAM[vPosition] = ' ';
+ vPosition++;
+ } while ((vPosition % 40) > 0);
// Set display to next line
TermX = 0;
@@ -124,8 +122,8 @@ void DisplayInput(byte n)
mvwaddch(AppleWindow, TermY, TermX, n & 0x7F);
// Add character to VRAM
- *VRAM_Position = n & 0x7f;
- VRAM_Position++;
+ VRAM[vPosition] = n & 0x7f;
+ vPosition++;
// Set display to next character/next line
TermX++;
@@ -136,31 +134,25 @@ void DisplayInput(byte n)
}
// Reset VRAM_Position if it's value is too great.
- if (VRAM_Position >= (VRAM + 960))
- VRAM_Position -= 960;
+ if (vPosition >= 960)
+ vPosition -= 960;
// If Y is past height..
if (TermY >= 24) {
//.. discard the first line..
- VRAM_Offset += 40;
- //.. verify the register offset..
- if (VRAM_Offset >= 960)
- VRAM_Offset = VRAM;
+ vOffset += 40;
- //.. and create an offset variable to cycle through memory with.
- byte *offset = VRAM + VRAM_Offset;
-
- // Then, for every cell of the screen, fill with the contents of the video memory.
+ //.. then, for every cell of the screen except the last line, fill with VRAM..
for (int i = 0; i < 23; i++) {
for (int j = 0; j < 40; j++) {
- if (offset >= (VRAM + 960))
- offset -= 960;
- mvwaddch(AppleWindow, i, j, *offset );
- offset++;
+ mvwaddch(AppleWindow, i, j, VRAM[vOffset++ % 960] );
}}
+
+ // ..and move offset up to next line.
+ vOffset += 40;
- // Set to start of final line, and clear line.
+ // Visually set to start of final line, and clear line.
TermY = 23;
TermX = 0;
mvwprintw(AppleWindow, TermY, TermX,