@@ -88,6 +88,56 @@ void ConvertIndexedSkyImage(uint* color_data, ubyte* src_indexed, int x_idx, int
8888 }
8989}
9090
91+ // this function just unpacks sky data
92+ void ConvertSkyD1 (const char * skyFileName)
93+ {
94+ FILE* fp = fopen (skyFileName, " rb" );
95+ if (!fp)
96+ {
97+ MsgError (" Unable to open '%s'\n " , skyFileName);
98+ return ;
99+ }
100+
101+ for (int skyNum = 0 ; skyNum < 12 ; skyNum++)
102+ {
103+ fseek (fp, skyNum * 48 , SEEK_SET);
104+
105+ int offsetInfo[13 ];
106+ fread (offsetInfo, 1 , sizeof (offsetInfo), fp);
107+
108+ // 12 BMPs for each sky
109+ for (int i = 0 ; i < 12 ; i++)
110+ {
111+ FILE* pNewFile = fopen (varargs (" %s_%d_%d.BMP" , skyFileName, skyNum, i), " wb" );
112+ if (!pNewFile)
113+ {
114+ MsgError (" Unable to save file!\n " );
115+ return ;
116+ }
117+
118+ // get the BMP data
119+ int bmpSize = offsetInfo[i + 1 ] - offsetInfo[i];
120+ char * data = new char [bmpSize];
121+
122+ fseek (fp, offsetInfo[i], SEEK_SET);
123+ fread (data, 1 , bmpSize, fp);
124+
125+ // write header
126+ fwrite (data, 1 , bmpSize, pNewFile);
127+
128+ // dun
129+ fclose (pNewFile);
130+
131+ delete[] data;
132+ }
133+ }
134+
135+ // LoadfileSeg("DATA\\SKY.BIN", mallocptr, gSkyNumber * 0x30, 0x34);
136+ // LoadfileSeg("DATA\\SKY.BIN", &DAT_000f8600, *texturePtr, texturePtr[0xc] - *texturePtr);
137+
138+ fclose (fp);
139+ }
140+
91141void ConvertSky (const char * skyFileName, bool saveTGA)
92142{
93143 FILE* fp = fopen (skyFileName, " rb" );
@@ -365,6 +415,13 @@ int main(int argc, char** argv)
365415 else
366416 MsgWarning (" -sky2tga must have an argument!" );
367417 }
418+ else if (!stricmp (argv[i], " -skybin2bmp" ))
419+ {
420+ if (i + 1 <= argc)
421+ ConvertSkyD1 (argv[i + 1 ]);
422+ else
423+ MsgWarning (" -skybin2bmp must have an argument!" );
424+ }
368425 else if (!stricmp (argv[i], " -bg2tim" ))
369426 {
370427 if (i + 1 <= argc)
0 commit comments