the Apple 1 Emulator

This commit is contained in:
ArthurFerreira2 2019-03-09 18:53:59 +01:00 committed by GitHub
parent 03261dc81c
commit 74302d04de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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[]) {
}
}
}
}
}