⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msdsys.c

📁 Dos6.0
💻 C
📖 第 1 页 / 共 5 页
字号:
  /* Call DOS service 0Ah, pointing to the string area within chBuffer */
  /*   Normally, I would put "chBuffer" in the second parameter.       */
  /*   However, the optimizer sees the "chBuffer[1] = 0" above, then   */
  /*   sees the "i < chBuffer[1]" in the "for" loop below, and makes   */
  /*   the assumption that chBuffer[1] is left unchanged.  It issues a */
  /*   warning about the conditional expression being constant.  The   */
  /*   trick of passing the address of chBuffer[1] (minus 1, of        */
  /*   course), convices the compiler that this value may change in    */
  /*   the "bdos" call.                                                */

  bdos (0x0A, (WORD) &chBuffer[1] - 1, 0);

  /* Move the buffer area to the input string area */

  for (i = 0; (CHAR) i < chBuffer[1]; ++i)
    pchInputString[i] = chBuffer[i + 2];

  /* Add the trailing zero byte */

  pchInputString[i] = '\0';

  fReturnValue = PutString ("");

  return (fReturnValue);
}


/*********************************************************************
 * PutString - Writes a string to stdout.
 *
 * pszString - String to output.
 *
 * Returns:  TRUE if an error occured.
 *********************************************************************/

BOOL PutString (PSZ pszString)
{
  BOOL fReturnValue;  /* Return value from puts() */

  fReturnValue = puts (pszString);

  if (fReturnValue)
    return (TRUE);
  else
    return (FALSE);
}


/*********************************************************************
 * CriticalErrorHandler - Handles DOS Critical errors.
 *
 * wDevError      - AX register passed to the INT 24h interrupt.
 * wErrCode       - DI register passed to the INT 24h interrupt.
 * fpDeviceHeader - Pointer to the device header that had the error.
 *
 * Returns: Abort, retry, fail, or ignore.
 *********************************************************************/

VOID FAR CriticalErrorHandler (WORD wDevError,
                               WORD wErrCode,
                               BYTE FAR *fpDeviceHeader)
{
  fCriticalError = TRUE;
  _hardretn (_HARDERR_IGNORE);
}


/********************************************************************
 * ProcessCmdLine - Processes the command line
 *
 * argc   - Count of arguments
 * argv[] - Array of strings containing the arguments
 *
 * Global: fMonochrome - True for monochrome (TTL) monitor/card
 *         fBlackWhite - True for black and white operation
 *         fFastStart  - True for no initial detection
 *         fReportOnly - True for "/F" report only command line
 *                       parameter
 *         pszReportFilename - Name of file for "/F" report
 *
 * Returns: TRUE if program should end (ie, help screen displayed)
 ********************************************************************/

#ifdef CW_INCLUDED
BOOL ProcessCmdLine (INT argc, PSZ argv[])
{
  INT  i;                     /* Looping variable                  */
  BOOL fReturnValue = FALSE;  /* Value to return from this routine */
  WORD wWindowsType;          /* Windows type                      */
  WORD wWindowsMajor;         /* Major windows version             */
  WORD wWindowsMinor;         /* Minor windows version             */
  WORD fDosShell;             /* DOS Shell active flag             */


  WinVerDetect (&wWindowsType, &wWindowsMajor, &wWindowsMinor, &fDosShell);
  if (wWindowsType == WIN_STANDARD_MODE || wWindowsType == WIN_ENHANCED_MODE)
    ProceduralLangChk (argc, argv, FALSE);
  else
    ProceduralLangChk (argc, argv, TRUE);

  for (i = 1; i < argc && fReturnValue != TRUE; ++i)
    {
      if (argv[i][0] != '/' && argv[i][0] != '-')
        {
          CmdLineHelp();
          break;
        }

      fReturnValue = ParseCommandLine (&i, argc, argv);

    }


  {
    /* Determine if black and white mode should be used */
    if (fBlackWhite == FALSE)
      {
        VIDEO_STRUCT Video;   /* Video information strcture */

        /* Get the video information */
        VideoID ((VIDEO_STRUCT FAR *) &Video);

        if (Video.bSubsystem0 ==  0 || /* Unknown     */
            Video.bSubsystem0 ==  1 || /* MDA         */
            Video.bSubsystem0 == 80 || /* Hercules    */
            Video.bSubsystem0 == 81 || /* Hercules+   */
            Video.bDisplay0   ==  1)   /* TTL Display */
        fBlackWhite = TRUE;
      }
  }

  return (fReturnValue);
}


/********************************************************************
 * ParseCommandLine - Parses the various parameters on the MSD
 *                    command line
 ********************************************************************/

BOOL ParseCommandLine (INT *pi, INT argc, PSZ argv[])
{
  WORD u;                     /* Looping variable                  */
  BOOL fReturnValue = FALSE;  /* Value to return from this routine */


  switch (toupper(argv[*pi][1]))
    {
      case 0:
        break;

      /* "/M" Monochrome Operation */

      case MONO_CHAR:
        /* Set flags for monochrome monitor */
        fBlackWhite = TRUE;
        break;

      /* "/B" Black and White Operation */

      case BW_CHAR:
        /* Set variables for black and white operation */
        fBlackWhite = TRUE;
        break;

      /* "/I" No Initial Detection -- Fast Start */

      case NO_INITIAL_DETECT_CHAR:
        /* Set variables for fast start */
        fFastStart = TRUE;

        for (u = 0; u < MAX_REPORT_ITEM_FLAGS; ++u)
          rgfReportItemFlag[u] = FALSE;

        break;

      /* "/F filename" Report to file (does not use CW calls) */

      case REPORT_TO_FILE_CHAR:
      case 'P':
        {
          /* Check for the "PenWindows" switch */
          if (toupper(argv[*pi][1]) == 'P')
            {
              /* Turn off the Customer Info request */
              rgfReportItemFlag[IDI_CUSTOMER_INFORMATION] = FALSE;

              /* Display the title lines */
              PutString (paszMsdTitleLines[0]);
              PutString (paszMsdTitleLines[1]);
            }

          /* Set the filename for the report */
          if ((*pi + 1 < argc) && (argv[(*pi) + 1][0] != '/'))
            {
              pszReportFilename = argv[++(*pi)];

              /* Set variable for report only */
              fReportOnly = TRUE;
              fReportFlag = TRUE;
            }
          else
            {
              /* Display command line help */
              CmdLineHelp();
              fReturnValue = TRUE;
            }
          break;
        }

      /* "/S filename" Generate summary to file (does not use CW) */

      case SUMMARY_TO_FILE_CHAR:
        {
          /* Set the filename for the report */
          if ((*pi < argc) && (argv[(*pi) + 1][0] != '/'))
            {
              if (*pi + 1 == argc)
                pszReportFilename = pszCon;
              else
                pszReportFilename = argv[++(*pi)];

              /* Set variable for report only */
              fReportOnly   = TRUE;
              fReportFlag   = TRUE;
              fSummaryOnly  = TRUE;
              wReportIndent = 0;
            }
          else
            {
              /* Display command line help */
              CmdLineHelp();
              fReturnValue = TRUE;
            }
          break;
        }

      default:
        /* Display command line help */
        CmdLineHelp();
        fReturnValue = TRUE;
        break;
    }

  return (fReturnValue);
}
#else /* CW_INCLUDED */

BOOL ProcessCmdLine (INT argc, PSZ argv[])
{
  WORD wWindowsType;          /* Windows type                      */
  WORD wWindowsMajor;         /* Major windows version             */
  WORD wWindowsMinor;         /* Minor windows version             */
  WORD fDosShell;             /* DOS Shell active flag             */

  WinVerDetect (&wWindowsType, &wWindowsMajor, &wWindowsMinor, &fDosShell);
  if (wWindowsType == WIN_STANDARD_MODE || wWindowsType == WIN_ENHANCED_MODE)
    ProceduralLangChk (argc, argv, FALSE);
  else
    ProceduralLangChk (argc, argv, TRUE);

  if (argc != 1 && argv[1][0] != '/')
    {
      pszReportFilename = argv[1];

      /* Set variable for report only */
      fReportOnly = TRUE;
      fReportFlag = TRUE;

      return (FALSE);
    }

  if ((argc == 2 || argc == 3)     &&
      argv[1][0] == '/'            &&
      toupper (argv[1][1]) == 'S')
    {
      if (argc == 3)
        pszReportFilename = argv[2];
      else
        pszReportFilename = pszCon;

      /* Set variable for report only */
      fReportOnly   = TRUE;
      fReportFlag   = TRUE;
      fSummaryOnly  = TRUE;
      wReportIndent = 0;

      return (FALSE);
    }
  else
    {
      CmdLineHelp();
      return (TRUE);
    }

}
#endif /* CW_INCLUDED */


/********************************************************************
 * CmdLineHelp - Displays command line arguments on screen
 *
 * Returns: Void.
 ********************************************************************/

VOID CmdLineHelp (VOID)
{
  WORD i = 0;   /* Variable for looping though the strings */

  while (paszCommandLineHelp[i])
    PutString (paszCommandLineHelp[i++]);
}

/********************************************************************
 * SetMiscGlobals - Set some global variables (DOS version, etc).
 *
 * Returns: TRUE if an error occured
 ********************************************************************/

BOOL SetMiscGlobals (PSZ pszPath)
{
  union REGS inregs, outregs;   /* Used for calling DOS interrupts   */
  BOOL fReturnValue;            /* Return value from GetSwIntTable() */
  WORD wWindowsType;          /* Windows type                      */
  WORD wWindowsMajor;         /* Major windows version             */
  WORD wWindowsMinor;         /* Minor windows version             */
  WORD fDosShell;             /* DOS Shell active flag             */


  /* Determine the DOS version */

  inregs.h.ah = 0x30;
  inregs.h.al = 0x00;
  int86 (0x21, &inregs, &outregs);

  /* Set the global variable for the DOS version */

  wDosMajor = outregs.h.al;
  wDosMinor = outregs.h.ah;

  /* Display error message if appropriate */

  if (outregs.h.al < 3)
    {
      PutString ("Microsoft Diagnostics requires MS-DOS or PC-DOS v3.00 or later.");
      return (TRUE);
    }

  pszPathToProgram = pszPath;

  fReturnValue = GetSwIntTable();

  if (fReturnValue)
    return (fReturnValue);

  /* Set MSD's DOS critical error handling routine */

  _harderr (CriticalErrorHandler);

#if CW_INCLUDED
  /* Poll the keyboard in the CW interface */
  fPollKeyboard = TRUE;
#endif

  MemoryFence();

  /* Set the flag indiciating that Windows is running */
  WinVerDetect (&wWindowsType, &wWindowsMajor, &wWindowsMinor, &fDosShell);
  fWindowsRunning = (wWindowsType) ? TRUE : FALSE;

  return (FALSE);
}

/**********************************************************************
 * MemoryFence - Enough memory has to be free for MSD to run to get
 *               beyond this routine.
 **********************************************************************/

VOID MemoryFence (VOID)
{
  union REGS regs;
  long segment_prefix, lConv_Mem;

  int86(0x12, &regs, &regs);

  lConv_Mem = regs.x.ax * 1024L;

  segment_prefix = 0L;
  segment_prefix = segment_prefix + ((long)(_psp) * 0x10);

  /* Are there enough bytes free */
  if (lConv_Mem - segment_prefix < 340000L)
    {
      puts (pszInsufMemory);
      exit (1);
    }
}


VOID InitParm1 (PSZ pszParm1)
{
  WORD  i;
  UCHAR uchXorMask = 0x5F;


  static UCHAR szText1[] =
    {
      128, 191, 239, 232, 215, 174, 243, 249, 243, 175, 212, 154, 112,
      139, 136, 132, 194, 174, 141, 134, 148, 136, 155, 134, 140, 159,
      204, 169, 135, 142, 151, 159, 157, 128, 128, 156, 149, 132, 216,
      169, 136, 148, 155, 143, 159, 146, 180, 226, 247, 228, 184, 206,
      232, 242, 232, 233, 251, 241, 128, 227, 219, 153, 174, 175, 134,
      135, 136, 251, 197, 210, 140, 229, 207, 221, 192, 212, 192, 147,
      148, 149, 150, 151, 144, 235, 213, 194, 244, 220, 158, 159, 224,
      225, 180, 242, 234, 245, 230, 177, 249, 231, 251, 235, 186, 255,
      224, 255, 249, 219, 242, 243, 244, 159, 185, 178, 180, 249, 145,
      169, 181, 174, 170, 255, 192, 193, 194, 195, 204, 175, 137, 130,
      132, 162, 152, 203, 204, 205, 152, 222, 222, 193, 210, 133, 197,
      219, 199, 222, 242, 217, 218, 219, 176, 156, 140, 141, 237, 181,
      193,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -