--- /dev/null
+/* Possibly the dumbest terminal program in existance... */\r
+/* Simply here to demo the MMURTL device drive interface for comms */\r
+/* Build with MakeIT.Bat, use CM32 and DASM separately:\r
+ CM32 DumbTerm.C\r
+ DASM DumbTerm.ATF\r
+*/\r
+\r
+#include <stdio.h>\r
+#include <ctype.h>\r
+#include <string.h>\r
+\r
+#include "\OSSOURCE\MDevDrv.h"\r
+#include "\OSSOURCE\MJob.h"\r
+#include "\OSSOURCE\MKbd.h"\r
+#include "\OSSOURCE\MTimer.h"\r
+#include "\OSSOURCE\MVid.h"\r
+#include "\OSSOURCE\RS232.h"\r
+\r
+#define NORMVID BRITEWHITE|BGBLUE\r
+#define CLIVID WHITE|BGBLACK\r
+\r
+unsigned long key;\r
+\r
+struct statRecC com;\r
+\r
+/*****************************************************/\r
+/*****************************************************/\r
+/*****************************************************/\r
+/*****************************************************/\r
+\r
+void main(void)\r
+\r
+{\r
+\r
+int erc, i;\r
+unsigned char b, lastb;\r
+char fOK;\r
+\r
+\r
+SetNormVid(NORMVID);\r
+ClrScr();\r
+\r
+printf(" Terminally DUMB, Dumb Terminal Program\r\n");\r
+printf(" (MMURTL Comms Device Driver demo) \r\n");\r
+\r
+/* Get the 64 byte device status block which is specific to the\r
+RS-232 device driver. The structure is defined in commdrv.h\r
+*/\r
+\r
+ erc = DeviceStat(6, &com, 64, &i);\r
+\r
+ if (erc) \r
+ {\r
+ SetNormVid(CLIVID);\r
+ ClrScr();\r
+ printf("Error on Device Stat: %d\r\n", erc);\r
+ ExitJob(erc);\r
+ }\r
+\r
+ /* set the params in the block */\r
+\r
+ com.Baudrate = 9600;\r
+ com.parity = NO_PAR;\r
+ com.databits = 8;\r
+ com.stopbits = 1;\r
+\r
+/* View other params which we could set, but should already be\r
+ defaulted with standard values when driver was initialized.\r
+*/\r
+\r
+ printf("IRQNum: %d\r\n", com.IRQNum);\r
+ printf("IOBase: %d\r\n", com.IOBase);\r
+ printf("sXBuf: %d\r\n", com.XBufSize);\r
+ printf("sRBuf: %d\r\n", com.RBufSize);\r
+ printf("RTimeO: %d\r\n", com.RTimeOut);\r
+ printf("XTimeO: %d\r\n", com.XTimeOut);\r
+\r
+/* Set the params we changed with a DeviceInit */\r
+\r
+ erc = DeviceInit(6, &com, 64);\r
+ if (erc) \r
+ {\r
+ SetNormVid(CLIVID);\r
+ ClrScr();\r
+ printf("Error on Device Init: %d\r\n", erc);\r
+ ExitJob(erc);\r
+ }\r
+\r
+ /* If device init went OK, we open the comms port */\r
+\r
+\r
+ /* device, dOpNum, dLBA, dnBlocks, pData */\r
+ erc = DeviceOp(6, CmdOpenC, 0, 0, &i);\r
+\r
+ if (erc) \r
+ {\r
+ SetNormVid(CLIVID);\r
+ ClrScr();\r
+ printf("OpenCommC ERROR: %d \r\n", erc);\r
+ ExitJob(erc);\r
+ }\r
+\r
+ printf("Communications Port Initialized.\r\n");\r
+\r
+ fOK = 1;\r
+\r
+ /* This is it... */\r
+\r
+ while (fOK) \r
+ {\r
+\r
+ if (!ReadKbd(&key, 0)) /* no wait */\r
+ {\r
+ b = key & 0x7f;\r
+\r
+ if (key & 0x3000) \r
+ { /* ALT key is down */\r
+ switch (toupper(b)) \r
+ {\r
+ case 'Q' :\r
+ /* device, dOpNum, dLBA, dnBlocks, pData */\r
+ erc = DeviceOp(6, CmdCloseC, 0, 0, &i);\r
+ SetNormVid(CLIVID);\r
+ ClrScr();\r
+ ExitJob(erc);\r
+ break;\r
+ default: break;\r
+ }\r
+ }\r
+ else \r
+ {\r
+ /* device, dOpNum, dLBA, dnBlocks, pData */\r
+ erc = DeviceOp(6, CmdWriteB, 0, 0, &b);\r
+ if (erc)\r
+ printf("WriteByteCError: %d \r\n", erc);\r
+ else \r
+ {\r
+ if (b == 0x0D) \r
+ {\r
+ b = 0x0A;\r
+ erc = DeviceOp(6, CmdWriteB, 0, 0, &b);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ /* device, dOpNum, dLBA, dnBlocks, pData */\r
+ erc = DeviceOp(6, CmdReadB, 0, 0, &b);\r
+ if (!erc) \r
+ {\r
+ TTYOut (&b, 1, NORMVID);\r
+ /* add a LF if it's not there after a CR... */\r
+ if ((lastb == 0x0D) && (b != 0x0A))\r
+ TTYOut ("\n", 1, NORMVID);\r
+ lastb = b;\r
+ }\r
+ }\r
+\r
+}\r