commit 8234f91baa46b8e89a92c696ddd5543748199ec1
parent e3d48f1cf06566eca6442c7f06b3c547eeabb98c
Author: Luxferre <lux@ferre>
Date: Tue, 16 Aug 2022 16:08:17 +0300
Figured out some CRLF differences
Diffstat:
M | equi.c | | | 35 | +++++++++++++++++++---------------- |
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/equi.c b/equi.c
@@ -16,12 +16,14 @@
#include <time.h>
#ifdef __CC65__
#include <conio.h>
+#define CRLF "\n"
#else
#include <termios.h>
#include <unistd.h>
#define cgetc() (getchar())
#define cputc(c) (putchar(c))
#pragma pack(2)
+#define CRLF "\r\n"
#endif
/* Definitions section */
@@ -150,45 +152,45 @@ enum EquiErrors {
void trapout(errcode) {
if(errcode > 0) {
if(curtask)
- fprintf(stderr, "\nError %d at 0x%x (task 0x%x, instruction %c): ", errcode, curtask->pc, curtask->id, flatram[curtask->pc]);
+ fprintf(stderr, CRLF "Error %d at 0x%x (task 0x%x, instruction %c): ", errcode, curtask->pc, curtask->id, flatram[curtask->pc]);
else
- fprintf(stderr, "\nSystem error %d: ", errcode);
+ fprintf(stderr, CRLF "System error %d: ", errcode);
switch(errcode) {
case STACK_OVERFLOW:
- cerr("Stack overflow\n");
+ cerr("Stack overflow" CRLF);
break;
case STACK_UNDERFLOW:
- cerr("Stack underflow\n");
+ cerr("Stack underflow" CRLF);
break;
case DIV_BY_ZERO:
- cerr("Division by zero\n");
+ cerr("Division by zero" CRLF);
break;
case CLT_OVERFLOW:
- cerr("Compilation lookup table full\n");
+ cerr("Compilation lookup table full" CRLF);
break;
case CMD_OVERFLOW:
- cerr("Command buffer full\n");
+ cerr("Command buffer full" CRLF);
break;
case INVALID_INSTRUCTION:
- cerr("Invalid instruction\n");
+ cerr("Invalid instruction" CRLF);
break;
case INVALID_WORD:
- cerr("Word not found in CLT\n");
+ cerr("Word not found in CLT" CRLF);
break;
case PORT_IO_ERROR:
- cerr("Port I/O error\n");
+ cerr("Port I/O error" CRLF);
break;
case PERSIST_IO_ERROR:
- cerr("Persistent storage I/O error\n");
+ cerr("Persistent storage I/O error" CRLF);
break;
case RESTRICTED_WRITE_ERROR:
- cerr("Attempt to write to a restricted RAM area\n");
+ cerr("Attempt to write to a restricted RAM area" CRLF);
break;
case OUT_OF_BOUNDS_JUMP:
- cerr("Attempt to jump outside the task context\n");
+ cerr("Attempt to jump outside the task context" CRLF);
break;
case TASK_SLOTS_FULL:
- cerr("All task slots busy and active\n");
+ cerr("All task slots busy and active" CRLF);
break;
}
if(curtask) /* if we're in a task, only terminate it */
@@ -415,7 +417,7 @@ void portIO(ushort port, ushort p2, ushort p1) {
}
break;
default:
- fprintf(stderr, "[PORTIO] Unimplemented call to port 0x%X with P1=%X and P2=%X\n", port, p1, p2);
+ fprintf(stderr, "[PORTIO] Unimplemented call to port 0x%X with P1=%X and P2=%X" CRLF, port, p1, p2);
}
pushMain(r1);
pushMain(r2);
@@ -742,7 +744,7 @@ int main(int argc, char* argv[]) {
#else /* VT100-compatible terminal init */
printf("\033c");
#endif
- printf("Welcome to Equi v" EQUI_VER " by Luxferre, 2022\r\nSystem RAM: %d bytes\r\nEqui ready\r\n\r\n> ", (int) sizeof(ram));
+ printf("Welcome to Equi v" EQUI_VER " by Luxferre, 2022" CRLF "System RAM: %d bytes" CRLF "Equi ready" CRLF CRLF "> ", (int) sizeof(ram));
}
while(1) { /* Now, we're in the command mode loop */
@@ -770,6 +772,7 @@ 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(INS_QUIT);
if(!smode) {
cputc(CR); /* echo CR */
cputc(LF); /* echo LF */