1 // Rolling Thunder hacker #2: character graphics
13 // With C++ string constants, you need to use a double backslash in
14 // order to indicate a single backslash. Confusing? You bet!
15 // [It's called "escaping the escape character."]
17 #define fn1 "c:\\games\\romhac~1\\r7"
18 #define fn2 "c:\\games\\romhac~1\\r8"
22 char far *screen = (char far *) MK_FP(0xA000,0);
24 // Get a word from the current input stream
26 unsigned int GetWord(ifstream &fstr)
28 unsigned int word = 0;
31 fstr.get(ch); word = int(ch) << 8;
32 fstr.get(ch); word |= (int)ch;
37 // Get a double word from the current input stream
39 unsigned long int GetDWord(ifstream &fstr)
41 unsigned long int dword = 0;
44 for(int i=0; i<4; i++)
46 fstr.get(ch); dword <<= 8; dword |= (int)ch;
51 void plot(int x, int y, int c)
53 screen[x + y*320] = c;
56 void decode(int b1, int b2, int b3, int xx, int yy)
58 int cc = ((b1 & 0x80) >> 5) | ((b1 & 0x08) >> 2) | ((b3 & 0x80) >> 7);
60 cc = ((b1 & 0x40) >> 4) | ((b1 & 0x04) >> 1) | ((b3 & 0x40) >> 6);
62 cc = ((b1 & 0x20) >> 3) | (b1 & 0x02) | ((b3 & 0x20) >> 5);
64 cc = ((b1 & 0x10) >> 2) | ((b1 & 0x01) << 1) | ((b3 & 0x10) >> 4);
66 cc = ((b2 & 0x80) >> 5) | ((b2 & 0x08) >> 2) | ((b3 & 0x08) >> 3);
68 cc = ((b2 & 0x40) >> 4) | ((b2 & 0x04) >> 1) | ((b3 & 0x04) >> 2);
70 cc = ((b2 & 0x20) >> 3) | (b2 & 0x02) | ((b3 & 0x02) >> 1);
72 cc = ((b2 & 0x10) >> 2) | ((b2 & 0x01) << 1) | (b3 & 0x01);
81 ifstream ff, ff2; // Creates an IFSTREAM but without any file hooks
83 ff.open(fn1, ios::binary); // Open as a binary file
84 ff2.open(fn2, ios::binary); // ditto
86 if (!ff) cerr << "Could not open 'ff'";
87 if (!ff2) cerr << "Could not open 'ff2'";
89 setmode(0x13); // Set up VGA screen
91 /* for(i=0; i<256; i++)
93 pal[i*3] = (int)random(64);
94 pal[i*3+1] = (int)random(64);
95 pal[i*3+2] = (int)random(64);
105 x = i * 16; y = j * 16;
106 for(int a=0; a<8; a++)
108 ff.get(ch); int b1 = (int)ch;
109 ff.get(ch); int b2 = (int)ch;
110 ff2.get(ch); int b3 = (int)ch;
111 decode(b1, b2, b3, x, y+a);
114 for(int a=0; a<8; a++)
116 ff.get(ch); int b1 = (int)ch;
117 ff.get(ch); int b2 = (int)ch;
118 ff2.get(ch); int b3 = (int)ch;
119 decode(b1, b2, b3, x, y+a);
122 for(int a=0; a<8; a++)
124 ff.get(ch); int b1 = (int)ch;
125 ff.get(ch); int b2 = (int)ch;
126 ff2.get(ch); int b3 = (int)ch;
127 decode(b1, b2, b3, x, y+a);
130 for(int a=0; a<8; a++)
132 ff.get(ch); int b1 = (int)ch;
133 ff.get(ch); int b2 = (int)ch;
134 ff2.get(ch); int b3 = (int)ch;
135 decode(b1, b2, b3, x, y+a);
140 if (i==27) break; // Break out on ESC
142 setmode(0x03); // Reset text mode