static int QueryParam(int fd, uint32_t uParam, const char *pszParam) { struct drm_vmw_getparam_arg Arg; int rc; Arg.value = 0; Arg.param = uParam; Arg.pad64 = 0; rc = ioctl(fd, DRM_IOCTL_VMW_GET_PARAM, &Arg); if (rc >= 0) { switch (uParam) { case DRM_VMW_PARAM_3D: printf("%30s: %#llx -- enabled: %s\n", pszParam, Arg.value, Arg.value == 0 ? "no" : Arg.value == 1 ? "yes" : "huh?"); break; case DRM_VMW_PARAM_FIFO_HW_VERSION: printf("%30s: %#llx -- major=%llu minor=%llu\n", pszParam, Arg.value, Arg.value >> 16, Arg.value & 0xffff); break; case DRM_VMW_PARAM_HW_CAPS: printf("%30s: %#llx\n", pszParam, Arg.value); DisplayFlags(g_aVmSvgaCapFlags, (uint32_t)Arg.value, 32); g_fHwCaps = Arg.value; break; case DRM_VMW_PARAM_FIFO_CAPS: printf("%30s: %#llx\n", pszParam, Arg.value); DisplayFlags(g_aVmSvgaFifoCapFlags, (uint32_t)Arg.value, 32); break; case DRM_VMW_PARAM_3D_CAP_SIZE: printf("%30s: %#llx (%lld) [bytes]\n", pszParam, Arg.value, Arg.value); g_cb3dCaps = (uint32_t)Arg.value; break; default: printf("%30s: %#llx (%lld)\n", pszParam, Arg.value, Arg.value); break; } } else
WORD RefreshRegisters(WORD maxLines, BOOL fullRefresh) { WORD count = 0; if(CurDisplay->ds_RegFlag) { RefreshRegister("D0", programD0, lastD0); RefreshRegister("D1", programD1, lastD1); RefreshRegister("D2", programD2, lastD2); RefreshRegister("D3", programD3, lastD3); count++; Newline(); maxLines--; if (!maxLines) return count; RefreshRegister("D4", programD4, lastD4); RefreshRegister("D5", programD5, lastD5); RefreshRegister("D6", programD6, lastD6); RefreshRegister("D7", programD7, lastD7); count++; Newline(); maxLines--; if (!maxLines) return count; RefreshRegister("A0", programA0, lastA0); RefreshRegister("A1", programA1, lastA1); RefreshRegister("A2", programA2, lastA2); RefreshRegister("A3", programA3, lastA3); count++; Newline(); maxLines--; if (!maxLines) return count; RefreshRegister("A4", programA4, lastA4); RefreshRegister("A5", programA5, lastA5); RefreshRegister("A6", programA6, lastA6); RefreshRegister("A7", programA7, lastA7); count++; Newline(); maxLines--; if (!maxLines) return count; RefreshRegister("PC", programPC, lastPC); ScrPlain(); ScrPrintf("SR: "); if (programSR != lastSR)ScrHighlight(); ScrPrintf("$%04X ", programSR); DisplayFlags(); ScrPlain(); ScrPrintf("STATE: "); if (programState != lastState) ScrHighlight(); ScrPrintf("%s", StateText(programState)); count++; Newline(); maxLines--; if (!maxLines) return count; } return count; }
/* the main program menu loop */ void MainLoop() { WadPtr wad; FILE *file; char input[ 120]; char *com, *out; BCINT episode, mission; for (;;) { /* get the input */ printf( "\n[? for help]> "); gets( input); if(feof(stdin)) strcpy(input, "QUIT"); printf( "\n"); /* eat the white space and get the first command word */ com = strtok( input, " "); strupr( com); /* user just hit return */ if (com == NULL) printf( "[Please enter a command or ? for help.]\n"); /* user inputting for help */ else if (!strcmp( com, "?") || !strcmp( com, "HELP") || !strcmp( com, "H")) { printf( "? or H[elp] -- to display this text\n"); printf( "A[nalyze] episode mission -- to analyze a game level's statistics\n"); printf( "D[ump] <DirEntry> [outfile] -- to dump a directory entry in hex\n"); printf( "F[lags] { <+-><24ABDEFGLMNPSTUZ>} -- to display/set the print flags\n"); printf( "L[ist] <WadFile> [outfile] -- to list the directory of a WAD file\n"); printf( "M[aster] [outfile] -- to list the master directory\n"); printf( "N[ame] [name or ''] -- to display/set the user level name\n"); printf( "P[rint] episode mission <PSfile> -- to print a game level to a PostScript file\n"); printf( "Q[uit] -- to quit\n"); printf( "R[ead] <WadFile> -- to read a new WAD patch file\n"); printf( "W[ads] -- to display the open WAD files\n"); printf( "X[tract] <DirEntry> <RawFile> -- to save (extract) one object to a raw file\n"); } /* user asked for list of open WAD files */ else if (!strcmp( com, "WADS") || !strcmp( com, "W")) { printf( "%-20s IWAD (Main ", WadFileList->filename); switch (GameVersion % 16) { case 0: printf( "Shareware"); break; case 1: printf( "Registered"); break; case 2: printf( "Commercial"); break; case 4: printf( "Ultimate"); break; } printf( " WAD file)\n"); for (wad = WadFileList->next; wad; wad = wad->next) { if (GameVersion == 2 && wad->directory[ 0].name[ 0] == 'M' && wad->directory[ 0].name[ 1] == 'A' && wad->directory[ 0].name[ 2] == 'P') printf( "%-20s PWAD (Patch WAD file for level %c%c)\n", wad->filename, wad->directory[ 0].name[ 3], wad->directory[ 0].name[ 4]); else if (GameVersion != 2 && wad->directory[ 0].name[ 0] == 'E' && wad->directory[ 0].name[ 2] == 'M') printf( "%-20s PWAD (Patch WAD file for episode %c mission %c)\n", wad->filename, wad->directory[ 0].name[ 1], wad->directory[ 0].name[ 3]); else { /* kludge */ strncpy( input, wad->directory[ 0].name, 8); input[ 8] = '\0'; printf( "%-20s PWAD (Patch WAD file for %s)\n", wad->filename, input); } } } /* user asked to quit */ else if (!strcmp( com, "QUIT") || !strcmp( com, "Q")) { if (GameVersion == 0) printf("Remember to register your copy of DOOM!\n"); else if (GameVersion == 16) printf("Remember to register your copy of Heretic!\n"); printf( "Goodbye...\n"); break; } /* user asked to display/set the print flags */ else if (!strcmp( com, "FLAGS") || !strcmp( com, "F")) { com = strtok( NULL, " "); if (com == NULL) DisplayFlags(); else while (com != NULL) { strupr( com); if (com[ 0] != '+' && com[ 0] != '-') printf( "[Flag must start with '+' or '-'.]\n"); else if (!strchr( "24ABDEFGLMNPSTUZ", com[ 1])) printf( "[Flag must be one of '24ABDEFGLMNPSTUZ'.]\n"); else if (com[ 2] != ' ' && com[ 2] != '\0') printf( "[Flag must be one character.]\n"); else SetFlag( com[ 1], com[ 0]); com = strtok( NULL, " "); } } /* user asked to display/set the user level name */ else if (!strcmp( com, "NAME") || !strcmp( com, "N")) { com = strtok( NULL, " "); if (com == NULL) if (UserLvlNm != NULL) printf( "User level name : %s\n", UserLvlNm); else printf( "[User level name is not set.]\n"); else if (! strcmp( com, "''")) { /* reset user level name */ FreeMemory( UserLvlNm); UserLvlNm = NULL; printf( "User level name reset\n"); } else { /* set user level name */ UserLvlNm = (char *) GetMemory( (strlen( com) + 1) * sizeof( char)); strcpy( UserLvlNm, com); while ((com = strtok( NULL, " ")) != NULL) { UserLvlNm = (char *) ResizeMemory( UserLvlNm, (strlen( UserLvlNm) + 1 + strlen( com)) * sizeof( char)); strcat( UserLvlNm, " "); strcat( UserLvlNm, com); } printf( "User level name set : %s\n", UserLvlNm); } } /* user asked to print a level */ else if (!strcmp( com, "PRINT") || !strcmp( com, "P")) { com = strtok( NULL, " "); if (com == NULL) { printf( "[Episode number argument missing.]\n"); continue; } episode = atoi( com); com = strtok( NULL, " "); if (com == NULL) { printf( "[Mission number argument missing.]\n"); continue; } mission = atoi( com); if (GameVersion == 2) { if (episode != 0) { printf( "[Invalid game episode number (%d).]\n", episode); continue; } if (mission < 1 || mission > 32) { printf( "[Invalid game mission number (%d).]\n", mission); continue; } } else /* GameVersion != 2 */ if (!(GameVersion == 17 && episode == 4 && mission == 1)) /* Heretic E4M1 */ { if (episode < 1 || episode > (GameVersion == 4 ? 4 : (GameVersion & 1 ? 3 : 1))) { printf( "[Invalid game episode number (%d).]\n", episode); continue; } if (mission < 1 || mission > 9) { printf( "[Invalid game mission number (%d).]\n", mission); continue; } } out = strtok( NULL, " "); if (! out) { printf( "[PostScript file name argument missing.]\n"); continue; } if (GameVersion == 2) printf( "Outputting PostScript map of level MAP%02d to \"%s\".\n", mission, out); else printf( "Outputting PostScript map of level E%dM%d to \"%s\".\n", episode, mission, out); if ((PSFile = fopen( out, "wt")) == NULL) ProgError( "error opening output file \"%s\"", out); fprintf( PSFile, "%%! DMPSMU: DooM PostScript Maps Utility, ver %s\n", DMPS_VERSION); PrintLevel( episode, mission); fprintf( PSFile, "\n%%%% End of file.\n"); fclose( PSFile); } /* user asked to analyze a level */ else if (!strcmp( com, "ANALYZE") || !strcmp( com, "A")) { com = strtok( NULL, " "); if (com == NULL) { printf( "[Episode number argument missing.]\n"); continue; } episode = atoi( com); com = strtok( NULL, " "); if (com == NULL) { printf( "[Mission number argument missing.]\n"); continue; } mission = atoi( com); if (GameVersion == 2) { if (episode != 0) { printf( "[Invalid game episode number (%d).]\n", episode); continue; } if (mission < 1 || mission > 32) { printf( "[Invalid game mission number (%d).]\n", mission); continue; } } else /* GameVersion != 2 */ if (!(GameVersion == 17 && episode == 4 && mission == 1)) /* Heretic E4M1 */ { if (episode < 1 || episode > (GameVersion == 4 ? 4 : (GameVersion & 1 ? 3 : 1))) { printf( "[Invalid game episode number (%d).]\n", episode); continue; } if (mission < 1 || mission > 9) { printf( "[Invalid game mission number (%d).]\n", mission); continue; } } AnalyzeLevel( episode, mission); } /* user ask for a listing of a WAD file */ else if (!strcmp( com, "LIST") || !strcmp( com, "L")) { com = strtok( NULL, " "); if (com == NULL) { printf( "[Wad file name argument missing.]\n"); continue; } for (wad = WadFileList; wad; wad = wad->next) if (!strcmp( com, wad->filename)) break; if (! wad) { printf( "[Wad file \"%s\" is not open.]\n", com); continue; } out = strtok( NULL, " "); if (out) { printf( "Outputting directory of \"%s\" to \"%s\".\n", wad->filename, out); if ((file = fopen( out, "wt")) == NULL) ProgError( "error opening output file \"%s\"", out); Credits( file); ListFileDirectory( file, wad); fprintf( file, "\nEnd of file.\n"); fclose( file); } else ListFileDirectory( stdout, wad); } /* user asked for the list of the master directory */ else if (!strcmp( com, "MASTER") || !strcmp( com, "M")) { out = strtok( NULL, " "); if (out) { printf( "Outputting master directory to \"%s\".\n", out); if ((file = fopen( out, "wt")) == NULL) ProgError( "error opening output file \"%s\"", out); Credits( file); ListMasterDirectory( file); fprintf( file, "\nEnd of file.\n"); fclose( file); } else ListMasterDirectory( stdout); } /* user asked to read a new patch WAD file */ else if (!strcmp( com, "READ") || !strcmp( com, "R")) { com = strtok( NULL, " "); if (com == NULL) { printf( "[Wad file name argument missing.]\n"); continue; } out = strtok( NULL, " "); if (out) *out = '\0'; out = (char *) GetMemory( (strlen( com) + 1) * sizeof( char)); strcpy( out, com); OpenPatchWad( out); CloseUnusedWadFiles(); } /* user asked to dump the contents of a WAD file entry */ else if (!strcmp( com, "DUMP") || !strcmp( com, "D")) { com = strtok( NULL, " "); if (com == NULL) { printf( "[Object name argument missing.]\n"); continue; } strupr( com); out = strtok( NULL, " "); if (out) { printf( "Outputting directory entry data to \"%s\".\n", out); if ((file = fopen( out, "wt")) == NULL) ProgError( "error opening output file \"%s\"", out); Credits( file); DumpDirectoryEntry( file, com); fprintf( file, "\nEnd of file.\n"); fclose( file); } else DumpDirectoryEntry( stdout, com); } /* user asked to extract an object to a raw binary file */ else if (!strcmp( com, "XTRACT") || !strcmp( com, "X") || !strcmp( com, "EXTRACT")) { com = strtok( NULL, " "); if (com == NULL) { printf( "[Object name argument missing.]\n"); continue; } if (strlen( com) > 8 || strchr( com, '.')) { printf( "[Invalid object name.]\n"); continue; } strupr( com); out = strtok( NULL, " "); if (! out) { printf( "[Raw file name argument missing.]\n"); continue; } for (wad = WadFileList; wad; wad = wad->next) if (!strcmp( out, wad->filename)) break; if (wad) { printf( "[You may not overwrite an opened Wad file with raw data.]\n"); continue; } printf( "Saving directory entry data to \"%s\".\n", out); if ((file = fopen( out, "wb")) == NULL) ProgError( "error opening output file \"%s\"", out); SaveEntryToRawFile( file, com); fclose( file); } /* unknown command */ else printf( "[Unknown command \"%s\"!]\n", com); } }