]> 4ch.mooo.com Git - 16.git/blobdiff - 16/tweak16/NAMEDREG.CPP
added tweak16 for experiments
[16.git] / 16 / tweak16 / NAMEDREG.CPP
diff --git a/16/tweak16/NAMEDREG.CPP b/16/tweak16/NAMEDREG.CPP
new file mode 100755 (executable)
index 0000000..ed10527
--- /dev/null
@@ -0,0 +1,52 @@
+/*\r
+       NamedReg.CPP version 1.0\r
+       by Robert Schmidt of Ztiff Zox Softwear 1993\r
+\r
+       Defines the member functions of the NamedRegister class declared in\r
+               Register.hpp.\r
+       Defines the stream operator >> to read named register info from\r
+               an istream.  (Text mode)\r
+*/\r
+\r
+#include <conio.h>\r
+#include <iostream.h>\r
+#include <string.h>\r
+#include "Screen.hpp"\r
+#include "Register.hpp"\r
+\r
+\r
+// NamedRegister::printCon() prints the register state to the console.\r
+//     If enableFlag is zero, the value is omitted from the display, and\r
+//     its place is filled with spaces.\r
+\r
+void NamedRegister::printCon()\r
+       {\r
+       textattr(enableFlag?REGENABLE_COLOR:REGDISABLE_COLOR);\r
+       cprintf("%03hx (%02hx) %24s : %02hx", getPort(), getIndex(),\r
+               name, getValue());\r
+       }\r
+\r
+/*\r
+       This operator reads the register port number, index and name from the\r
+       input stream.  (*Not* the value!)  Used for initializing each element\r
+       in the register table used by TWEAK.\r
+*/\r
+\r
+istream& operator>> (istream &in, NamedRegister &r)\r
+       {\r
+       int i;\r
+       char *n = new char[128];\r
+\r
+       in >> hex >> i;\r
+       r.setPort(i);\r
+       in >> i >> ws;\r
+       r.setIndex((unsigned char)(i));\r
+       in.getline(n, 128);\r
+       n[in.gcount()-1] = '\0';\r
+       r.name = new char[strlen(n)+1];\r
+       strcpy(r.name, n);\r
+       delete[] n;\r
+\r
+       return in;\r
+       }\r
+\r