implemented silent mode with s command line parameter

This commit is contained in:
Luxferre
2022-08-12 12:52:45 +03:00
parent cb4c12bfe9
commit 1b0379fbac
2 changed files with 16 additions and 8 deletions
+14 -8
View File
@@ -578,9 +578,11 @@ void equi_main_loop() {
/* Equi VM entry point */
int main(int argc, char* argv[]) {
uchar instr, bc, mmode = 0;
uchar instr, bc, mmode = 0, smode = 0;
if(argc > 1 && argv[1][0] == 'm') /* enter minification mode, don't run the programs */
mmode = 1;
else if(argc > 1 && argv[1][0] == 's') /* enter silent mode, don't print the banners and prompts */
smode = 1;
/* _attempt_ to disable buffering for char input/output */
#if !defined __CC65__ && !defined __TINYC__
setvbuf(stdin, NULL, _IONBF, 0);
@@ -596,7 +598,7 @@ int main(int argc, char* argv[]) {
/* Start both execution and input buffering from the start of command buffer (-1 because we use prefix increment) */
ram.pc = ram.ibp = 65535U;
if(!mmode) { /* skip the terminal init and the greeting if in minification mode */
if(!mmode && !smode) { /* skip the terminal init and the greeting if in minification or silent mode */
/* CC65-specific terminal init */
#ifdef __CC65__
clrscr();
@@ -638,15 +640,19 @@ int main(int argc, char* argv[]) {
break; /* and exit the command mode immediately */
} else {
/* if not in II or minification mode, process EOF or Q instruction: trigger interpreter loop */
cputc(CR); /* echo CR */
cputc(LF); /* echo LF */
if(!smode) {
cputc(CR); /* echo CR */
cputc(LF); /* echo LF */
}
ram.cmdbuf[++ram.ibp] = INS_QUIT; /* end program with INS_QUIT */
ram.IM = 1; /* set the mandatory interpretation mode flag */
equi_main_loop(); /* and run the interpreter loop */
cputc(CR); /* echo CR */
cputc(LF); /* echo LF */
cputc('>');
cputc(' ');
if(!smode) {
cputc(CR); /* echo CR */
cputc(LF); /* echo LF */
cputc('>');
cputc(' ');
}
}
} else { /* append the instruction/character to the command buffer if and only if it doesn't match the above criteria and we're not in II mode */
if(!ram.II)