char testcd( char *fn, long testsiz ) { DWORD driveletters; int i, fil, dalen; char name[32]="x:\\SUPPORT\\",driv[4]="x:\\"; strcat(name,fn); driveletters = GetLogicalDrives(); for (i=2; i<26; i++) { if (!(driveletters & (1ul<<i))) continue; driv[0] = 'A'+i; if (GetDriveType(driv) != DRIVE_CDROM) continue; name[0] = 'A'+i; fil = Bopen(name,O_RDONLY,S_IREAD); if (fil<0) continue; dalen = Bfilelength(fil); Bclose(fil); if (dalen == testsiz) { initprintf("Copy Protection: Found CDROM in drive %c:\n", driv[0]); return 0; } } wm_msgbox("Duke Nukem 3D","Copy Protection: Failed to find CDROM"); return 1; }
static void texcache_closefiles(void) { if (texcache.filehandle != -1) { Bclose(texcache.filehandle); texcache.filehandle = -1; } MAYBE_FCLOSE_AND_NULL(texcache.index); }
void convpalette(void) { int i, fil3; short danumshades; i = 0; while (Bstrncasecmp(wadata[i],"PLAYPAL",7) != 0) i++; Blseek(fil1,wadplc[i],BSEEK_SET); Bread(fil1,pal,768); for(i=0;i<768;i++) pal[i] >>= 2; i = 0; while (Bstrncasecmp(wadata[i],"COLORMAP",8) != 0) i++; Blseek(fil1,wadplc[i],BSEEK_SET); Bread(fil1,palookup,8192); if ((fil3 = Bopen("palette.dat",BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) { Bprintf("Cannot save palette.dat\n"); exit(0); } Bwrite(fil3,pal,768); danumshades = 32; Bwrite(fil3,&danumshades,2); Bwrite(fil3,palookup,8192); Bclose(fil3); }