]> Shamusworld >> Repos - thunder/blob - test/temp.cpp
Fixes to makefile, file permissions.
[thunder] / test / temp.cpp
1 //
2 // Output hex dump...
3 //
4 #include <fstream.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <iomanip.h>
8 #include <stdio.h>
9 #include <conio.h>
10 #include <dos.h>
11 #include "screen.h"
12
13 #define PROM1 "RT1-1.BIN"
14 #define PROM2 "RT1-2.BIN"
15 #define PROM3 "RT1-3.BIN"
16 #define PROM4 "RT1-4.BIN"
17
18 BYTE * grom3, * spr_rom;
19
20 int main(int argc, char *argv[])
21 {
22   fstream ff1, ff2;
23   BYTE ch;
24   BYTE ccolor[256][8];
25   BYTE scolor[128][16];
26   BYTE statpal[768];
27   char file[120];
28
29   ff1.open(PROM3, ios::binary|ios::in);
30   if (ff1)
31   {
32     for(int i=0; i<256; i++) // Load pallete with PROM values
33     {
34       for(int j=0; j<8; j++)
35       {
36         ff1.get(ch);
37         ccolor[i][j] = (BYTE)ch;
38       }
39     }
40     ff1.close();
41   }
42   ff1.open(PROM4, ios::binary|ios::in);
43   if (ff1)
44   {
45     for(int i=0; i<128; i++) // Load pallete with PROM values
46     {
47       for(int j=0; j<16; j++)
48       {
49         ff1.get(ch);
50         scolor[i][j] = (BYTE)ch;
51       }
52     }
53     ff1.close();
54   }
55
56   ff1.open(PROM1, ios::binary|ios::in);
57   ff2.open(PROM2, ios::binary|ios::in);
58   if (ff1)    // If open was successful...
59   {
60     for(int i=0; i<768; i+=3)
61     {
62       ff1.get(ch);
63       statpal[i]   = (BYTE)(ch&0x0F);
64       statpal[i+1] = (BYTE)(ch>>4);
65       ff2.get(ch);
66       statpal[i+2] = (BYTE)ch;
67     }
68     // Do palette stretching here... I.e. add 0 to hinyb 0, 1 to hinyb 1, etc
69     for(int i=0; i<768; i++)
70     {
71       statpal[i] <<= 2;
72       if ((statpal[i]&0xF0) == 1)  statpal[i]++;
73       if ((statpal[i]&0xF0) == 2)  statpal[i] += 2;
74       if ((statpal[i]&0xF0) == 3)  statpal[i] += 3;
75     }
76     ff1.close();  ff2.close();
77   }
78
79   SetModeX();                     // Set up screen
80   for(int i=0; i<256; i++)        // Set up RGB colors...
81   {
82     outp(0x03C8, i);              // Tell VGA palette data is coming...
83     outp(0x03C9, statpal[i*3]);   // Send it...
84     outp(0x03C9, statpal[i*3+1]);
85     outp(0x03C9, statpal[i*3+2]);
86   }
87   extern BYTE spr_color_index;
88
89   while (!kbhit())
90   {
91     strcpy(file, "c:\\games\\romhac~1\\");
92     if (argc == 2)  strcat(file, argv[1]);
93     else            strcat(file, "r9");
94
95     ff1.open(file, ios::binary|ios::in);  // Open as a binary file
96            
97     if (!ff1) { cerr << "Could not open the file! (Maybe it doesn't exist...)";
98              return -1; }
99     for(int x=0; x<320; x+=32)
100     {
101       for(int y=0; y<224; y+=16)
102       {                                 
103         for(int j=0; j<16; j++)
104         {
105           for(int i=0; i<16; i+=2)
106           {
107             ff1.get(ch);  int lo = ch & 0x0f;  int hi = ch / 16;
108             Plot(x+i, y+j, scolor[spr_color_index][hi]);
109             Plot(x+i+1, y+j, scolor[spr_color_index][lo]);
110           }
111         }
112         for(int j=0; j<16; j++)
113         {
114           for(int i=16; i<32; i+=2)
115           {
116             ff1.get(ch);  int lo = ch & 0x0f;  int hi = ch / 16;
117             Plot(x+i, y+j, scolor[spr_color_index][hi]);
118             Plot(x+i+1, y+j, scolor[spr_color_index][lo]);
119           }
120         }
121       }
122     }
123     ff1.close();
124     int i = getch();
125     if (i==27)  break;  // Break out on ESC
126     if (i=='[')  spr_color_index--;  // Decrease...
127     if (i==']')  spr_color_index++;  // Increase...
128   }
129   SetMode(0x03);        // Reset text mode
130 }