]> 4ch.mooo.com Git - 16.git/blob - 16/tweak16/REGEDIT.CPP
cleaned up the repo from debugging watcom2 ^^
[16.git] / 16 / tweak16 / REGEDIT.CPP
1 /*\r
2         RegEdit.HPP\r
3 \r
4 */\r
5 \r
6 #include <conio.h>\r
7 #include "Screen.hpp"\r
8 #include "RegEdit.HPP"\r
9 \r
10 \r
11 RegisterEditor::RegisterEditor(istream &ins)\r
12         : RegisterTable(ins)\r
13         {\r
14         prevSel = select = 0;\r
15         }\r
16 \r
17 void RegisterEditor::printCon(int r)\r
18         {\r
19         // This gotoxy divides the registers into two columns.\r
20         gotoxy(40*(r / editHeight) +1, r % editHeight +1);\r
21         // Optionally print the left cursor.\r
22         textattr(CURSOR_COLOR);\r
23         cprintf(r==select ? "\20" : " ");\r
24         // Then put out the meat.\r
25         reg[r].printCon();\r
26         // And possibly the right cursor.\r
27         textattr(CURSOR_COLOR);\r
28         cprintf(r==select ? "\21" : " ");\r
29         // This gotoxy just puts the hardware cursor where it won't distract you.\r
30         gotoxy(40*(r / editHeight)+38, r % editHeight +1);\r
31         }\r
32 \r
33 void RegisterEditor::printAllCon()\r
34         {\r
35         for (int r = 0; r < registers; r++)\r
36                 printCon(r);\r
37         }\r
38 \r
39 int RegisterEditor::updateSelect()\r
40         {\r
41         if (select < 0)\r
42                 select = registers - 1;\r
43         else\r
44                 if (select >= registers)\r
45                         select = 0;\r
46         if (prevSel != select)\r
47                 {\r
48                 printCon(prevSel);\r
49                 prevSel = select;\r
50                 }\r
51         printCon(select);\r
52         return select;\r
53         }\r
54 \r
55 \r
56 // RegisterEditor::showBitMask() updates the bit pattern display with\r
57 //      the value of selected register.  This is TWEAK specific.\r
58 \r
59 void RegisterEditor::showBitMask()\r
60         {\r
61         gotoxy(42,editHeight-4);\r
62         textattr(BITHEADER_COLOR);\r
63         cprintf("Bit mask: 7 6 5 4 3 2 1 0");\r
64         gotoxy(51,editHeight-3);\r
65         textattr(BITPATTERN_COLOR);\r
66         unsigned char v = reg[select].getValue();\r
67         for (int e=7; e>=0; e--)\r
68                 cprintf( v&(1<<e) ? " 1" : " 0");\r
69         }\r
70 \r