mirror of
https://github.com/ArthurFerreira2/reinette.git
synced 2024-12-22 01:29:19 +00:00
the Apple 1 Emulator
This commit is contained in:
parent
03261dc81c
commit
74302d04de
15
reinette.c
15
reinette.c
@ -1,8 +1,6 @@
|
||||
// Reinette, emulates the Apple 1 computer
|
||||
// Copyright 2018 Arthur Ferreira
|
||||
// Last modified 5th of March 2019
|
||||
// initially developped on GNU/Linux
|
||||
// compiles with gcc 6.3.0-18
|
||||
// Last modified 9th of March 2019
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <unistd.h> // for usleep()
|
||||
@ -73,11 +71,10 @@ static void reset(){
|
||||
reg.PC = readMem(0xFFFC) | (readMem(0xFFFD) << 8);
|
||||
reg.SP = 0xFF;
|
||||
reg.SR |= UNDEFINED;
|
||||
key = 0;
|
||||
keyRdy = 0;
|
||||
ope.setAcc = false;
|
||||
ope.value = 0;
|
||||
ope.address = 0;
|
||||
keyRdy = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -529,7 +526,7 @@ static void (*addressing[])(void) = {
|
||||
// PROGRAM ENTRY POINT
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i = 0, ch = 0;
|
||||
int i = 0 , ch = 0;
|
||||
uint8_t opcode = 0;
|
||||
|
||||
// ncurses initialization
|
||||
@ -552,13 +549,12 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
// keyboard controller
|
||||
if (!keyRdy){ // don't miss a keystroke
|
||||
ch = getch(); // reads from ncurses
|
||||
ch = getch(); // non blocking keybd read from ncurses
|
||||
if (ch != ERR){
|
||||
key = (uint8_t)ch; // getch() returns an int
|
||||
if (key == 0x12) reset(); // CTRL-R, reset
|
||||
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 == 0x7F) || (key == 0x08)) key = 0x5F; // DEL and BS to _
|
||||
if ((key >= 0x61) && (key <= 0x7A)) key &= 0xDF; // to upper case
|
||||
@ -566,5 +562,4 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user