use orca io, etc. [wip]

This commit is contained in:
Kelvin Sherlock 2019-01-16 18:41:40 -05:00
parent 269e2ca6cc
commit e681702045
1 changed files with 99 additions and 38 deletions

137
nscda.c
View File

@ -113,49 +113,66 @@ void Display(Word ipid, srBuff *srBuffer) {
buffer[66] = '\r'; buffer[66] = '\r';
buffer[67] = 0; buffer[67] = 0;
WriteCString(buffer); fputs(buffer, stdout);
} }
asm int ReadKey(void) { asm int ReadKey(void) {
sep #0x20 sep #0x20
loop: loop:
lda >0xe0c0000 lda >0xe0c000
bpl loop bpl loop
sta >0xe0c010 sta >0xe0c010
rep #0x20 rep #0x20
and #0x7f and #0x7f
rtl
} }
/* ORCA Console control codes */
#define CURSOR_ON 0x05
#define CURSOR_OFF 0x06
/* cursor keys */
#define LEFT 0x80
#define RIGHT 0x15
#define UP 0x0b
#define DOWN 0x0a
#define ESC 0x1b
int ReadInt(void) { int ReadInt(void) {
unsigned i = 0; unsigned i = 0;
unsigned c; unsigned c;
unsigned rv; unsigned rv;
putchar(CURSOR_ON);
while (1) { while (1) {
c = ReadChar(0); c = ReadKey();
if (c == 0x1b) {
rv = -1;
break;
}
if (c == 13) { if (c == 13) {
WriteChar(13); if (i == 0) rv = -1;
WriteChar(10); break;
if (i == 0)
return -1;
return rv;
} else if ((c == 8) || (c == 0x7f)) { } else if ((c == 8) || (c == 0x7f)) {
if (i) { if (i) {
WriteChar(8); putchar(8);
WriteChar(' '); putchar(' ');
WriteChar(8); putchar(8);
i--; i--;
rv /= 10; rv /= 10;
} }
} else if ((c >= '0') && (c <= '9')) { } else if ((c >= '0') && (c <= '9')) {
if (i < 5) { if (i < 5) {
WriteChar(c); putchar(c);
i++; i++;
rv *= 10; rv *= 10;
rv += c - '0'; rv += c - '0';
} }
else SysBeep();
} }
} }
putchar(CURSOR_OFF);
return rv;
} }
static char buffer[80]; static char buffer[80];
@ -167,7 +184,7 @@ void DisplayLinkLayer(void) {
TCPIPGetLinkLayer(&link); TCPIPGetLinkLayer(&link);
WriteChar(0x0c); //WriteChar(0x0c);
putchar(0x0c); putchar(0x0c);
printf("Link Layer:\r"); printf("Link Layer:\r");
@ -176,7 +193,7 @@ void DisplayLinkLayer(void) {
VersionString(0, link.liVersion, buffer); VersionString(0, link.liVersion, buffer);
printf(" Version: %b\r", buffer); printf(" Version: %b\r", buffer);
printf(" Flags: $%04x\r", link.liFlags); printf(" Flags: $%04x\r", link.liFlags);
fputs("\r", stdout);
lv = TCPIPGetLinkVariables(); lv = TCPIPGetLinkVariables();
printf("Link Variables\r"); printf("Link Variables\r");
printf(" Version: %d\r", lv->lvVersion); printf(" Version: %d\r", lv->lvVersion);
@ -187,8 +204,7 @@ void DisplayLinkLayer(void) {
printf(" Errors: $%08lx\r", lv->lvErrors); printf(" Errors: $%08lx\r", lv->lvErrors);
printf(" MTU: %d\r", lv->lvMTU); printf(" MTU: %d\r", lv->lvMTU);
WriteChar('\r'); ReadKey();
c = ReadChar(0);
} }
void DisplayTCP(void) { void DisplayTCP(void) {
@ -226,12 +242,46 @@ void DisplayTCP(void) {
printf("Alive Minutes: %d\r", TCPIPGetAliveMinutes()); printf("Alive Minutes: %d\r", TCPIPGetAliveMinutes());
printf("Login Count: %d\r", TCPIPGetLoginCount()); printf("Login Count: %d\r", TCPIPGetLoginCount());
WriteChar('\r'); ReadKey();
c = ReadChar(0); }
unsigned DisplayIpid(unsigned ipid) {
/* extended debug information */
Handle h;
Word size;
unsigned page = 0;
putchar(0x0c);
printf("IPID: %d\r", ipid);
h = (Handle)TCPIPGetUserRecord(ipid);
if (_toolErr) return;
if (!h) return;
size = (Word)GetHandleSize(h);
printf("Datagram count (all): %d\r",
TCPIPGetDatagramCount(ipid, protocolAll));
printf("Datagram count (icmp): %d\r",
TCPIPGetDatagramCount(ipid, protocolICMP));
printf("Datagram count (tcp): %d\r",
TCPIPGetDatagramCount(ipid, protocolTCP));
printf("Datagram count (udp): %d\r",
TCPIPGetDatagramCount(ipid, protocolUDP));
printf("User statistic 1: $%08lx\r",
TCPIPGetUserStatistic(ipid, 1));
printf("User statistic 2: $%08lx\r",
TCPIPGetUserStatistic(ipid, 2));
GetKey();
} }
unsigned DisplayMain(void) { unsigned DisplayMain(void) {
Word i;
Word count; Word count;
static srBuff srBuffer; static srBuff srBuffer;
@ -245,24 +295,24 @@ unsigned DisplayMain(void) {
redraw: redraw:
WriteChar(0x0c); putchar(0x0c);
WriteCString(Header1); fputs(Header1, stdout);
WriteCString(Header2); fputs(Header2, stdout);
line = 2; line = 2;
for (; count && ipid < 100; ipid += 2) { for (; count && ipid < 100; ipid += 2) {
TCPIPStatusTCP(i, &srBuffer); TCPIPStatusTCP(ipid, &srBuffer);
if (_toolErr) if (_toolErr)
continue; continue;
Display(i, &srBuffer); Display(ipid, &srBuffer);
--count; --count;
++line; ++line;
if (line == 24) { if (line == 24) {
WriteCString("-- more --"); fputs("-- more --", stdout);
c = ReadChar(0) & 0x7f; c = ReadKey();
if (c == 'Q' || c == 'q' || c == 0x1b) if (c == 'Q' || c == 'q' || c == 0x1b)
return 0; return 0;
goto redraw; goto redraw;
@ -270,14 +320,18 @@ redraw:
} }
while (line < 23) { while (line < 23) {
WriteChar('\r'); putchar('\r');
++line; ++line;
} }
WriteCString("Q: Quit. D: Save debug file"); fputs("Q: Quit. D: Save debug file T: TCP Status L: Link Layer status", stdout);
for (;;) { for (;;) {
c = ReadChar(0) & 0x7f; c = ReadKey();
switch (c) { switch (c) {
case 'q':
case 'Q':
case 0x1b:
return 0;
case 'D': case 'D':
case 'd': case 'd':
// debug(); // debug();
@ -293,10 +347,17 @@ redraw:
case ' ': case ' ':
goto redraw; goto redraw;
break; break;
case 'q': case 'I':
case 'Q': case 'i':
case 0x1b: /* sigh... \r is also a line feed. */
return 0; /* reverse line feed first to negate it. */
putchar(31);
putchar('\r');
putchar(29);
fputs("IPID: ", stdout);
c = ReadInt();
if ((int)c >= 0) DisplayIpid(c);
return 1;
} }
} }
} }
@ -332,18 +393,18 @@ void StopTT(void) {
} }
void StartUp(void) { void StartUp(void) {
StartTT(); //StartTT();
putchar(0x06); /* turn off cursor */ putchar(CURSOR_OFF); /* turn off cursor */
if (TCPIPStatus() == 0 || _toolErr) { if (TCPIPStatus() == 0 || _toolErr) {
WriteCString("Marinetti is not active\r"); fputs("Marinetti is not active", stdout);
ReadChar(0); ReadKey();
} else { } else {
while (DisplayMain()) /* */ while (DisplayMain()) /* */
; ;
} }
StopTT(); //StopTT();
} }
void ShutDown(void) {} void ShutDown(void) {}