]> 4ch.mooo.com Git - 16.git/blob - 16/tweak16/09TO10.CPP
wwww
[16.git] / 16 / tweak16 / 09TO10.CPP
1 /*\r
2         09TO10 1.0 - convert TWEAK 0.9 files to TWEAK 1.0 files\r
3 \r
4         by Robert Schmidt of Ztiff Zox Softwear, 1992-93\r
5 \r
6         For documentation, see TWEAK.DOC.\r
7 \r
8         Most of the starting definitions was taken from the TWEAK095.CPP\r
9         file included elsewhere, so comments are removed.\r
10 */\r
11 \r
12 #ifndef __LARGE__\r
13 # ifndef __COMPACT__\r
14 #  ifndef __HUGE__\r
15 #   error A large data model is required!\r
16 #  endif\r
17 # endif\r
18 #endif\r
19 \r
20 \r
21 #include <stdio.h>\r
22 #include <dos.h>\r
23 #include <stdlib.h>\r
24 #include <fstream.h>\r
25 #include <io.h>\r
26 \r
27 #include "Register.hpp"\r
28 \r
29 \r
30 struct vgaRegisterInfo\r
31         {\r
32         char *name;\r
33         unsigned port;\r
34         unsigned char index;\r
35         };\r
36 \r
37 vgaRegisterInfo table[] =\r
38         {\r
39                 {"Misc. output",                        0x3c2,  0x00},\r
40 \r
41                 {"Horizontal total",            0x3d4,  0x00},\r
42                 {"Horizontal disp. enable",     0x3d4,  0x01},\r
43                 {"Horizontal blank start",      0x3d4,  0x02},\r
44                 {"Horizontal blank end",        0x3d4,  0x03},\r
45                 {"Horizontal retrace start",0x3d4,  0x04},\r
46                 {"Horizontal retrace end",      0x3d4,  0x05},\r
47                 {"Vertical total",                      0x3d4,  0x06},\r
48                 {"Overflow register",           0x3d4,  0x07},\r
49                 {"Preset row scan",                     0x3d4,  0x08},\r
50                 {"Max scan line/char ht.",      0x3d4,  0x09},\r
51 \r
52                 {"Vertical retrace start",      0x3d4,  0x10},\r
53                 {"Vertical retrace end",        0x3d4,  0x11},\r
54                 {"Vert. disp. enable end",      0x3d4,  0x12},\r
55                 {"Offset/Logical width",        0x3d4,  0x13},\r
56                 {"Underline location",          0x3d4,  0x14},\r
57                 {"Vertical blank start",        0x3d4,  0x15},\r
58                 {"Vertical blank end",          0x3d4,  0x16},\r
59                 {"Mode control",                        0x3d4,  0x17},\r
60 \r
61                 {"Clock mode register",         0x3c4,  0x01},\r
62                 {"Color plane write enable",0x3c4,      0x02},\r
63                 {"Character gen. select",       0x3c4,  0x03},\r
64                 {"Memory mode register",        0x3c4,  0x04},\r
65 \r
66                 {"Set/reset register",          0x3ce,  0x00},\r
67                 {"Set/reset enable",            0x3ce,  0x01},\r
68                 {"Color compare",                       0x3ce,  0x02},\r
69                 {"Data rotate & function",      0x3ce,  0x03},\r
70                 {"Mode register",                       0x3ce,  0x05},\r
71                 {"Miscellaneous register",      0x3ce,  0x06},\r
72                 {"Color don't care",            0x3ce,  0x07},\r
73                 {"Bit mask register",           0x3ce,  0x08},\r
74 \r
75                 {"Mode control",                        0x3c0,  0x10},\r
76                 {"Screen border colour",        0x3c0,  0x11},\r
77                 {"Color plane enable",          0x3c0,  0x12},\r
78                 {"Horizontal panning",          0x3c0,  0x13},\r
79                 {"Color select",                        0x3c0,  0x14}\r
80         };\r
81 \r
82 const registers = sizeof (table) / sizeof (vgaRegisterInfo);\r
83 \r
84 \r
85 class vgaRegTable\r
86         {\r
87         unsigned char value[registers];\r
88         unsigned char selectedReg;\r
89 public:\r
90         void out();\r
91         void in();\r
92         void print(unsigned char selected);\r
93         void printOne(unsigned char r, int isSelected);\r
94         unsigned char& operator [] (unsigned char n)\r
95                                         { return value[n]; }\r
96         };\r
97 \r
98 \r
99 // The main program starts here.\r
100 \r
101 main(int argc, char **argv)\r
102         {\r
103         if (argc < 3)\r
104                 {\r
105                 printf("09TO10 version 1.0\n\r"\r
106                            "by Robert Schmidt of Ztiff Zox Softwear 1993\n\r"\r
107                            "\n\r"\r
108                            "Converts TWEAK version 0.9 files to TWEAK version 1.0 files.\n\r"\r
109                            "\n\r"\r
110                            "Syntax:  09TO10 <oldfile> <newfile>\n\r"\r
111                            );\r
112                 return 0;\r
113                 }\r
114 \r
115         vgaRegTable rtab;\r
116 \r
117         char *fname = argv[1];\r
118         FILE *f;\r
119         int r;\r
120 \r
121         // Open file in selected mode.\r
122         if (!(f=fopen(fname,"rb")))\r
123                 {\r
124                 perror(fname);\r
125                 return 0;\r
126         }\r
127         // Read file:\r
128         for (r=0; r<registers; r++)\r
129                 if (fread(&(rtab[r]),1,1,f) == 0)\r
130                         {\r
131                         perror(fname);\r
132                         return 0;\r
133                         }\r
134         fclose(f);\r
135 \r
136         ofstream out(argv[2], ios::trunc|ios::binary|ios::out);\r
137         Register reg;\r
138         for (r=0; r<registers; r++)\r
139                 {\r
140                 reg.setPort(table[r].port);\r
141                 reg.setIndex(table[r].index);\r
142                 reg.setValue(rtab[r]);\r
143                 out << reg;\r
144                 }\r
145 \r
146         return 0;\r
147         }\r