mirror of
https://github.com/ArthurFerreira2/reinette.git
synced 2025-01-18 07:31:37 +00:00
the Apple 1 Emulator
This commit is contained in:
parent
03261dc81c
commit
74302d04de
13
reinette.c
13
reinette.c
@ -1,8 +1,6 @@
|
|||||||
// Reinette, emulates the Apple 1 computer
|
// Reinette, emulates the Apple 1 computer
|
||||||
// Copyright 2018 Arthur Ferreira
|
// Copyright 2018 Arthur Ferreira
|
||||||
// Last modified 5th of March 2019
|
// Last modified 9th of March 2019
|
||||||
// initially developped on GNU/Linux
|
|
||||||
// compiles with gcc 6.3.0-18
|
|
||||||
|
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#include <unistd.h> // for usleep()
|
#include <unistd.h> // for usleep()
|
||||||
@ -73,11 +71,10 @@ static void reset(){
|
|||||||
reg.PC = readMem(0xFFFC) | (readMem(0xFFFD) << 8);
|
reg.PC = readMem(0xFFFC) | (readMem(0xFFFD) << 8);
|
||||||
reg.SP = 0xFF;
|
reg.SP = 0xFF;
|
||||||
reg.SR |= UNDEFINED;
|
reg.SR |= UNDEFINED;
|
||||||
key = 0;
|
|
||||||
keyRdy = 0;
|
|
||||||
ope.setAcc = false;
|
ope.setAcc = false;
|
||||||
ope.value = 0;
|
ope.value = 0;
|
||||||
ope.address = 0;
|
ope.address = 0;
|
||||||
|
keyRdy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -552,13 +549,12 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// keyboard controller
|
// keyboard controller
|
||||||
if (!keyRdy){ // don't miss a keystroke
|
ch = getch(); // non blocking keybd read from ncurses
|
||||||
ch = getch(); // reads from ncurses
|
|
||||||
if (ch != ERR){
|
if (ch != ERR){
|
||||||
key = (uint8_t)ch; // getch() returns an int
|
key = (uint8_t)ch; // getch() returns an int
|
||||||
if (key == 0x12) reset(); // CTRL-R, reset
|
if (key == 0x12) reset(); // CTRL-R, reset
|
||||||
else if (key == 0x02) BRK(); // CTRL-B, break
|
else if (key == 0x02) BRK(); // CTRL-B, break
|
||||||
else {
|
else if (!keyRdy){ // only if not already a key in wait
|
||||||
if (key == 0x0A) key = 0x0D; // LF (\n) to CR (\r)
|
if (key == 0x0A) key = 0x0D; // LF (\n) to CR (\r)
|
||||||
if ((key == 0x7F) || (key == 0x08)) key = 0x5F; // DEL and BS to _
|
if ((key == 0x7F) || (key == 0x08)) key = 0x5F; // DEL and BS to _
|
||||||
if ((key >= 0x61) && (key <= 0x7A)) key &= 0xDF; // to upper case
|
if ((key >= 0x61) && (key <= 0x7A)) key &= 0xDF; // to upper case
|
||||||
@ -567,4 +563,3 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user