Perfection is attained not when there's nothing to add but when there's nothing to take away
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
/*
|
||||
* NRJ (NOR and Reference Jump) OISC ANSI C emulator
|
||||
/* NRJ (NOR and Reference Jump) OISC ANSI C emulator
|
||||
* Created by Luxferre, 2022, public domain
|
||||
* Build with: cc -Os -std=c89 -o nrj nrj.c
|
||||
*/
|
||||
* Build with: cc -Os -std=c89 -o nrj nrj.c */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
@@ -49,15 +47,14 @@ void nrj_run(NRJWORD *mem, NRJWORD pc) { /* Main NRJ engine - just 12 lines of C
|
||||
}
|
||||
}
|
||||
|
||||
/* terminal helper definitions */
|
||||
struct termios tty_opts_backup, tty_opts_raw;
|
||||
struct termios tty_opts_backup, tty_opts_raw; /* terminal I/O helper definitions */
|
||||
void restore_term() {tcsetattr(0, TCSANOW, &tty_opts_backup);}
|
||||
|
||||
int main(int argc, char* argv[]) { /* emulator entry point: nrj program.bin */
|
||||
if(argc > 1) {
|
||||
NRJWORD mem[NRJSIZE]; /* NRJ memory: word 0 - input, 1 - output, 2 - I/O context, 3 - program start */
|
||||
FILE *prog = fopen(argv[1], "rb");
|
||||
if(prog) { /* load the program and prepare the terminal */
|
||||
NRJWORD mem[NRJSIZE]; /* NRJ memory: word 0 - input, 1 - output, 2 - I/O context, 3 - program start */
|
||||
fseek(prog, 0, SEEK_END);
|
||||
int flen = ftell(prog);
|
||||
fseek(prog, 0, SEEK_SET);
|
||||
@@ -68,14 +65,9 @@ int main(int argc, char* argv[]) { /* emulator entry point: nrj program.bin */
|
||||
cfmakeraw(&tty_opts_raw);
|
||||
tcsetattr(0, TCSANOW, &tty_opts_raw);
|
||||
nrj_run(mem, 3); /* now, start the engine */
|
||||
return 0; /* return the successful status to the outer OS */
|
||||
}
|
||||
else {
|
||||
printf("NRJ%u: could not open the input file %s\r\n", (unsigned int) NRJWSIZE, argv[1]);
|
||||
} /* otherwise bail out with an error */
|
||||
printf("NRJ%u: no valid program binary specified\r\n", (unsigned int) NRJWSIZE);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
printf("NRJ%u: no binary specified\r\n", (unsigned int) NRJWSIZE);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user