diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-12-01 08:21:14 +1100 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-12-01 08:21:14 +1100 |
commit | 9ecaf2877f93664497110edf256fbc7825cd30f9 (patch) | |
tree | 959929f9d3b9a23a7a788d64f72fac367505e403 /src | |
parent | 88e6422ec31938fbff7b4fb9c5ddf63fc9f14a09 (diff) |
stuck at number parsing inf. loop error
Diffstat (limited to 'src')
-rw-r--r-- | src/apple.c | 49 | ||||
-rw-r--r-- | src/apple.h | 8 | ||||
-rw-r--r-- | src/main.c | 7 | ||||
-rw-r--r-- | src/video/interface.h | 6 | ||||
-rw-r--r-- | src/video/ncurses.c | 64 | ||||
-rw-r--r-- | src/video/signetics.c | 20 |
6 files changed, 59 insertions, 95 deletions
diff --git a/src/apple.c b/src/apple.c index 6c977a2..ba2cfb6 100644 --- a/src/apple.c +++ b/src/apple.c @@ -1,5 +1,6 @@ #include"apple.h" +// The Incredible Wozmon! const byte ROM[256] = { 0xd8, 0x58, 0xa0, 0x7f, 0x8c, 0x12, 0xd0, 0xa9, 0xa7, 0x8d, 0x11, 0xd0, 0x8d, 0x13, 0xd0, 0xc9, @@ -61,23 +62,6 @@ void AppleReset(){ Memory = calloc(MEMORY_SIZE, sizeof(byte)); } -/*byte ToAppleAscii(char x) -{ - if (x < 0x20 || x >= 0x60) - return -1; - if (x >= 0x40) - x -= 0x40; - return x; -} - -byte ToAscii(char x) -{ - if (x < 0x20) - x += 0x40; - return x; -}*/ - - byte GetMemory(address x){ switch(x) { @@ -108,9 +92,38 @@ void SetMemory(address x, byte y){ switch(x) { case DSP: - TerminalInput(y); + DisplayInput(y); } if (x < MEMORY_SIZE) { Memory[x] = y; } } + + + +byte UserInput() +{ + #ifdef GRAPHICAL + + #else + int c = getch(); + #endif + + switch(c) + { + case 0x08: + return BS; + case 0x0A: + return CR; + case 0x1B: + return ESC; + } + + if (c < 0x20) + return -1; + + if (c >= 0x60) + return -1; + + return c; +} diff --git a/src/apple.h b/src/apple.h index 3a5bb97..d423074 100644 --- a/src/apple.h +++ b/src/apple.h @@ -20,8 +20,10 @@ #define DSP 0xD012 #define DSP_CR 0xD013 +#define BS 0xDF +#define CR 0x8D +#define ESC 0x9B + void AppleOn(); void AppleReset(); - -//byte ToAppleAscii(char); -//byte ToAscii(char); +byte UserInput(); @@ -4,11 +4,12 @@ #include <unistd.h> int main() { - - TerminalInit(); + AppleOn(); + DisplayInit(); + while(1) { CallInstructionTable(GetMemory(PC), 0); PrintInfo(); @@ -16,7 +17,7 @@ int main() { //getch(); } - TerminalClose(); + DisplayClose(); return 0; } diff --git a/src/video/interface.h b/src/video/interface.h index 2443b62..dc074b2 100644 --- a/src/video/interface.h +++ b/src/video/interface.h @@ -13,10 +13,10 @@ byte UserInput(); void PrintInfo(); // Initialization procedure for the terminal -void TerminalInit(); +void DisplayInit(); // Exit procedure for the terminal. -void TerminalClose(); +void DisplayClose(); // Deliver an Apple ASCII character to the terminal. -void TerminalInput(byte n); +void DisplayInput(byte n); diff --git a/src/video/ncurses.c b/src/video/ncurses.c index a3ae8a4..1fbc314 100644 --- a/src/video/ncurses.c +++ b/src/video/ncurses.c @@ -4,7 +4,6 @@ #include<ncurses.h> #include"interface.h" -#include"signetics.c" #include"../apple.h" #include"../cpu/6502.h" @@ -15,49 +14,12 @@ int TermY = 0; WINDOW *AppleWindow; -byte UserInput() -{ - int c = getch(); - byte r; - - if (c == 0x08) // If c is backspace - return 0xDF; - - if (c < 0x20) { - if (c != 0x0D // CR - && c != 0x1B) // Exit - return -1; - } - //switch(c) - //{ - // Convert special characters - /*case KEY_F(1): //backspace - r = 0xDF; - break; - case KEY_F(2): //enter - r = 0x8D; - break; - case KEY_F(3): //exit, for escape. TODO: Figure out if this is Esc or not. - r = 0x9B; - break;*/ - // Convert regular characters - /*default: - if (c < 0x20 || c >= 0x60) - return -1; - - if (c >= 0x40) - r = c - 0x40; - else - r = c; - - break; - }*/ - - return c; -} +const byte* TerminalShiftRegister; +byte* TerminalShiftRegisterPosition; + +int TerminalShiftRegisterOffset; -#define FlagVisual(x, c) (getFlag(x)) ? c : '.' void PrintInfo() { @@ -89,7 +51,7 @@ void PrintInfo() -void TerminalInit() +void DisplayInit() { // ncurses initialization functions. initscr(); @@ -128,7 +90,7 @@ void TerminalInit() -void TerminalClose() +void DisplayClose() { free(TerminalShiftRegister); curs_set(1); @@ -137,11 +99,17 @@ void TerminalClose() -void TerminalInput(byte n) -{ +void DisplayInput(byte n) +{ + if (n == BS) { + return; + } + + n &= 0b01111111; + // Place character mvwaddch(AppleWindow, TermY, TermX, ' '); - mvwaddch(AppleWindow, TermY, TermX, CharacterROM(n)); + mvwaddch(AppleWindow, TermY, TermX, n); // Add character to register *TerminalShiftRegisterPosition = n; @@ -174,7 +142,7 @@ void TerminalInput(byte n) for (int j = 0; j < 40; j++) { if (offset >= (TerminalShiftRegister + 960)) offset -= TerminalShiftRegister; - mvwaddch(AppleWindow, i, j, CharacterROM(*offset) ); + mvwaddch(AppleWindow, i, j, *offset ); offset++; }} diff --git a/src/video/signetics.c b/src/video/signetics.c deleted file mode 100644 index 3dd279b..0000000 --- a/src/video/signetics.c +++ /dev/null @@ -1,20 +0,0 @@ -// signetics.c -// 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. -// Intended to be included during pre-processing into the .c of the used video library. - -const byte SigneticsROM[0x40] = { - '@' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , - 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' , '[' , '\\', ']' , '^' , '_' , - ' ' , '!' , '"' , '#' , '$' , '%' , '&' , '\'', '(' , ')' , '*' , '+' , ',' , '-' , '.' , '/' , - '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , ':' , ';' , '<' , '=' , '>' , '?' -}; - -byte CharacterROM(byte x) { - return SigneticsROM[ x & 0b01111111 ]; -} - -const byte* TerminalShiftRegister; - -byte* TerminalShiftRegisterPosition; - -int TerminalShiftRegisterOffset; |