home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / VDH / VDHFONT.C < prev    next >
C/C++ Source or Header  |  1995-04-14  |  45KB  |  1,290 lines

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT (C) Microsoft Corporation, 1989                                 */
  4. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  5. /*                                                                           */
  6. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  7. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  8. /*    drivers. You may use this code in accordance with the IBM License      */
  9. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  10. /*    Copyright statement may not be removed.                                */
  11. /*                                                                           */
  12. /*****************************************************************************/
  13. /*****************************************************************************
  14.  *
  15.  * SOURCE FILE NAME = VDHFONT.c
  16.  *
  17.  * DESCRIPTIVE NAME = Base video device handlers - Font support
  18.  *
  19.  *
  20.  * VERSION = V2.0
  21.  *
  22.  * DATE
  23.  *
  24.  * DESCRIPTION   This source file contains VDH entry points which get/set
  25.  *               the current font.
  26.  *
  27.  * FUNCTIONS     GetCurrentFont, SetCurrentFont, SetHWFont, FindFont
  28.  *
  29.  * NOTES
  30.  *
  31.  * STRUCTURES
  32.  *
  33.  * EXTERNAL REFERENCES  SaveRegs, RestoreRegs
  34.  *                      AccessHardware, AccessFont
  35.  *
  36.  * EXTERNAL FUNCTIONS
  37.  *
  38. */
  39.  
  40.  
  41. /*
  42. **  Include files
  43. */
  44.  
  45. #define  INCL_BASE                     /* ALL of OS/2 Base                  */
  46. #define  INCL_OS2STD                   /* Needed for NULL definition in     */
  47.                                        /* OS2STD.H                          */
  48. #define INCL_NOPMAPI                   /* @95837 */
  49.  
  50. #include <os2.h>
  51. #include "vdhctl.h"                    /* Conditional compilation control   */
  52. #include "vdh.h"                       /* Type definitions                  */
  53.  
  54. #if      FONT_SUPPORT                  /*                               @S26*/
  55.                                        /* MS00                              */
  56.  
  57.  
  58. /*
  59. **  Externally defined global variables
  60. */
  61.  
  62. extern VIDEOMODE Modes[];              /* Supported modes                   */
  63. extern FONTBUFFER Fonts[];             /* Supported fonts                   */
  64. extern UCHAR READABLE;                 /* Flag to determine if hardware is
  65.                                           write-only                        */
  66. extern rcp_addr RomCP_tbl;             /* table for CP and ROM font info
  67.                                                                         @C10*/
  68. extern USHORT ROMCP_NUM;
  69.  
  70. /*****************************************************************************
  71.  *
  72.  *  SUBROUTINE NAME: GetCurrentFont
  73.  *
  74.  *  DESCRIPTIVE NAME: Get color lookup table
  75.  *
  76.  *  FUNCTION: GetCurrentFont is called by BVS to return the current
  77.  *            active video font.
  78.  *
  79.  *  ENTRY POINT: GetCurrentFont
  80.  *    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entry 267 )
  81.  *
  82.  *  INPUT: (Passed on stack)
  83.  *             FAR *Environment ( Environment buffer for the session )
  84.  *             FAR *ParmBlock
  85.  *                     USHORT Length = length of this packet
  86.  *                     USHORT Flags  = 0 - Environment buffer only
  87.  *                                     1 - Hardware also
  88.  *                     UCHAR far *FontBuffer
  89.  *                     USHORT     FontLength
  90.  *                     USHORT     PelColumns
  91.  *                     USHORT     PelRows
  92.  *             ULONG Function ( Call vector table entry = 267 )
  93.  *
  94.  *  EXIT-NORMAL: AX = 0
  95.  *               Current font is returned to caller
  96.  *
  97.  *  EXIT-ERROR: AX = ERROR_VIO_INVALID_PARMS
  98.  *
  99.  *  INTERNAL REFERENCES:
  100.  *    ROUTINES: NONE
  101.  *
  102.  *  EXTERNAL REFERENCES:
  103.  *    ROUTINES: PhysToUVirt, FreePhysToUVirt
  104.  *              AccessFont
  105.  *
  106.  ****************************************************************************/
  107.  
  108. USHORT EXPENTRY GetCurrentFont(Environment,ParmBlock,Function)
  109.  
  110.   ENVIRONMENT far *Environment;
  111.   VDH_FONT far *ParmBlock;
  112.   ULONG Function;
  113.  
  114. {
  115.  
  116.   FarAddress FontBuffer1,FontBuffer2,VideoFontBuffer;
  117.  
  118.   USHORT rc,i,PelRows,FontSize,EnvBufferPassed,hres,vres,col,row,FONT_FOUND;
  119.   ENVIRONMENT far *TempEnv;
  120.   UCHAR TempChar;                      /*         @TB21FORSAVINGROMFONTINDEX*/
  121.   SEL Selector;
  122.   UCHAR Mode,far *SourcePtr,*BasePtr;
  123.   USERFONT far *USERFont;
  124.   ROMCP_TABLE *rcp_tbl_ptr;            /*                               @C10*/
  125.  
  126.   rc = ERROR_VIO_INVALID_PARMS;
  127.   EnvBufferPassed = SEG(Environment);  /* Non-zero = TRUE                   */
  128.  
  129.   if (EnvBufferPassed)
  130.   {
  131.  
  132.     if ((Function == FnGetFont) &&     /* Valid function request            */
  133.        (ParmBlock->Length >= sizeof(VDH_FONT)) && /* Valid Length           */
  134.        (ParmBlock->Flags <= 3))
  135.     {                                  /* Valid flags                       */
  136.       rc = ERROR_VIO_MODE;             /*                               @T11*/
  137.  
  138.       if (!(Environment->ModeData.fbType & GRAPHICS) || /* Text mode?   @T11*/
  139.          (ParmBlock->Flags & GET_ROM_FONT))
  140.       {                                /* Get ROM font?                 @T11*/
  141.         rc = NO_ERROR;                 /* Parameters are OK                 */
  142.         Mode = Environment->ModeIndex;
  143.  
  144.   #if      VDHVGA                      /* Get mode from hardware, if it is  */
  145.                                        /* readable                          */
  146.  
  147.         if (ParmBlock->Flags == UPDATE_HARDWARE)
  148.         {                              /* Not for Specified Font            */
  149.  
  150.           if (!(rc = DosAllocSeg(sizeof(ENVIRONMENT), (PSEL)&Selector, 0)))
  151.           {
  152.             TempEnv = (ENVIRONMENT far *)MakeFarPTR(Selector, 0);
  153.             TempEnv->VideoEnable = 1;  /* Assume video ON               @T34*/
  154.             SaveRestoreHW(TempEnv, GET);/* Read hardware into temporary     */
  155.                                         /* ENVB                             */
  156.             Mode = (UCHAR)GetModeIndex(TempEnv);/* Get mode index + 1       */
  157.  
  158.             if (!Mode--)
  159.               rc = ERROR_VIO_MODE;
  160.  
  161.             else
  162.               SetEnvMode(Mode, Environment, TempEnv, 0);/* Update ENVB  @T70*/
  163.                                        /* end                          @TB21*/
  164.  
  165.             DosFreeSeg(Selector);      /* Deallocate the temporary ENVB     */
  166.  
  167.           }
  168.         }
  169.   #endif          /*      VDHVGA   @MS00                                    */
  170.  
  171.         PelRows = ParmBlock->PelRows;
  172.  
  173.         if (ParmBlock->Flags == UPDATE_HARDWARE)
  174.         {                              /* Not for Specified Font            */
  175.           PelRows = Environment->ModeData.vres/Environment->ModeData.row;
  176.         }
  177.  
  178.         FontSize = 256*PelRows;
  179.  
  180.         if (!rc)
  181.         {
  182.  
  183.           if ((ParmBlock->FontLength == NULL) && /* Return font size only   */
  184.              (ParmBlock->FontBuffer == NULL))
  185.           {                            /*                               @T11*/
  186.             ParmBlock->FontLength = FontSize;
  187.           }
  188.  
  189.           else
  190.             if (ParmBlock->FontLength < FontSize)
  191.             {
  192.               rc = ERROR_VIO_INVALID_PARMS;/*                          @TB38*/
  193.             }
  194.  
  195.             else
  196.             {                          /* Return complete font information  */
  197.  
  198.               if (ParmBlock->Flags == UPDATE_HARDWARE)
  199.               {                        /* Hardware font                     */
  200.                 ParmBlock->PelColumns = Modes[Mode].hres/Modes[Mode].col;
  201.                 ParmBlock->PelRows = PelRows;
  202.                 ParmBlock->FontLength = FontSize;/* in case too much        */
  203.                                        /* specified                         */
  204.  
  205.                 if (!(rc = PhysToUVirt(Fonts[0].PVB, &VideoFontBuffer,
  206.                            Fonts[0].PVBLen)))
  207.                 {                      /*                               @T53*/
  208.  
  209.                   AccessFont(VideoFontBuffer.FullAddress,
  210.                              ParmBlock->FontBuffer, ParmBlock->PelRows,
  211.                              0, (UCHAR far *)NULL, GET,
  212.                              (UCHAR)(Modes[Mode].fbType & NOT_MONO));
  213.  
  214.                   FreePhysToUVirt(VideoFontBuffer.part.Selector);
  215.  
  216.                 }                      /*                               @T53*/
  217.  
  218. /*
  219. **      PTM 2895  start of code changes
  220. **  add code to find specific fonts - first check user fonts for a
  221. **  row/column match, then current codepage then ROM fonts
  222. */
  223.  
  224.               }
  225.  
  226.               else
  227.               {
  228.                 FONT_FOUND = FALSE;
  229.  
  230. /*
  231. **  check UserFonts if they are Selectable for Row/Column match
  232. */
  233.  
  234.                 if (Environment->UserFont == USER_FONT_SELECTABLE)
  235.                 {
  236.                   USERFont = (USERFONT far *)&Environment->USERFonts;
  237.  
  238.                   for (i = 0; (FONT_FOUND == FALSE) &&
  239.                       (i < Environment->NumUSERFonts); i++)
  240.                   {
  241.  
  242.                     if ((USERFont->PelRows == ParmBlock->PelRows) &&
  243.                        (USERFont->PelColumns == ParmBlock->PelColumns))
  244.                     {
  245.                       FONT_FOUND = U_FONT;
  246.                       SourcePtr = (UCHAR far *)&USERFont->FontData;
  247.                       BasePtr = NULL;
  248.                     }
  249.  
  250.                     else
  251.                       (ULONG)USERFont = (ULONG)(&USERFont->FontData) + (ULONG)
  252.                          (USERFont->PelRows * 256);
  253.  
  254.                   }
  255.                 }
  256.  
  257. /*
  258. ** Userfont not found, check current CodePage if not ROM fonts
  259. */
  260.  
  261.                 if ((FONT_FOUND == FALSE) && (Environment->CodePageID !=
  262.                    ROM_FONT))
  263.                 {
  264.  
  265. /*                                                    @C10 START OF CHANGES */
  266.  
  267.                   rcp_tbl_ptr = RomCP_tbl.ptr;/* find codepage in ROMCP_TBL */
  268.  
  269.               /*  @B725179                                                  */
  270.  
  271.   #if      VDHEGA                      /* Make sure PelRows parm doesn't
  272.                                           exceed 14 for EGA                 */
  273.  
  274.                   if ((Environment->CodePageID == rcp_tbl_ptr->CodePageID) &&
  275.                      (ParmBlock->PelRows <= 14))
  276.                   {
  277.   #endif          /*  VDHEGA Make sure parms do not exceed 8x14 fonts       */
  278.  
  279.                     for (i = 0; i < ROMCP_NUM && !FONT_FOUND; i++)
  280.                     {
  281.  
  282.                       if ((Environment->CodePageID == rcp_tbl_ptr->CodePageID)
  283.                          && (rcp_tbl_ptr->PelRows == ParmBlock->PelRows)
  284.                          && (rcp_tbl_ptr->PelColumns == ParmBlock->PelColumns))
  285.                       {
  286.                         FONT_FOUND = C_FONT;/* codepage font found          */
  287.                         SourcePtr = rcp_tbl_ptr->FontPTR;/* check if        */
  288.                                                          /* override font   */
  289.  
  290.                         if (rcp_tbl_ptr->PelColumns == 9)
  291.                           BasePtr = rcp_tbl_ptr->BaseFontPTR;
  292.  
  293. /*                                                               @C10 END  */
  294.                         else
  295.                           BasePtr = NULL;
  296.                       }
  297.  
  298.                       else
  299.                         rcp_tbl_ptr++; /*                               @C10*/
  300.                     }
  301.                   }                    /* end to check for codepage         */
  302.  
  303.   #if      VDHEGA                      /* Make sure PelRows parm doesn't
  304.                                           exceed 14 for EGA                 */
  305.                 }
  306.   #endif                               /*  VDHEGA                           */
  307.  
  308. /*
  309. ** if codepage font not found or current codepage is ROM fonts
  310. ** try looking for a match in the ROM fonts
  311. */
  312.  
  313.                 if (FONT_FOUND == FALSE)
  314.                 {
  315.  
  316.                   for (i = ROMFont8x8; i <= ROM_FONTS && !FONT_FOUND; i++)/*
  317.                                                                         @C10*/
  318.                   {
  319.  
  320.                     if ((Fonts[i].PelRows == ParmBlock->PelRows) && /*  @C10*/
  321.                        (Fonts[i].PelColumns == ParmBlock->PelColumns))/*
  322.                                                                         @C10*/
  323.                     {
  324.                       FONT_FOUND = R_FONT;/* ROM font found                 */
  325.  
  326.                       if (!(PhysToUVirt(Fonts[i].PVB, /*      @C10,@T30,@T53*/
  327.                          &FontBuffer1, FontSize)))
  328.                       {
  329.  
  330.                         SourcePtr = FontBuffer1.FullAddress;/* check if     */
  331.                                                             /* override font*/
  332.  
  333.                         if (Fonts[i].PelColumns == 9)/*                 @C10*/
  334.                         {
  335.                           i = Fonts[i].Partner;/*                       @C10*/
  336.  
  337.                           if (!(PhysToUVirt(Fonts[i].PVB, /*  @C10,@T30,@T53*/
  338.                              &FontBuffer2, FontSize)))
  339.                           {
  340.                             BasePtr = FontBuffer2.FullAddress;
  341.                           }            /*                               @T53*/
  342.  
  343.                           else         /*                               @T53*/
  344.                             FONT_FOUND = FALSE;/*                       @T53*/
  345.                         }
  346.  
  347.                         else
  348.                           BasePtr = NULL;
  349.                       }                /*                               @T53*/
  350.  
  351.                       else             /*                               @T53*/
  352.                         FONT_FOUND = FALSE;/*                           @T53*/
  353.                     }
  354.                   }
  355.                 }                      /* end to search thru ROM fonts      */
  356.  
  357.                 if (FONT_FOUND)        /* get font in buffer                */
  358.                 {
  359.                   AccessFont(SourcePtr, ParmBlock->FontBuffer,
  360.                      ParmBlock->PelRows, ParmBlock->PelColumns, BasePtr,
  361.                      GET_ROMCP, (UCHAR)(Modes[Mode].fbType & NOT_MONO));
  362.  
  363.                   if (FONT_FOUND == R_FONT)
  364.                   {
  365.                     FreePhysToUVirt(FontBuffer1.part.Selector);
  366.                     FreePhysToUVirt(FontBuffer2.part.Selector);
  367.                   }
  368.                 }
  369.  
  370.                 else                   /* no font found, return error       */
  371.                   rc = ERROR_VIO_FONT;
  372.  
  373. /*
  374. **      PTM 2895  end of code changes
  375. */
  376.  
  377.               }
  378.             }
  379.         }
  380.       }
  381.     }
  382.   }
  383.   return (rc);
  384. }
  385.  
  386. /*****************************************************************************
  387.  *
  388.  *  SUBROUTINE NAME: SetCurrentFont
  389.  *
  390.  *  DESCRIPTIVE NAME: Set color lookup table
  391.  *
  392.  *  FUNCTION: SetCurrentFont is called by BVS to load the specified
  393.  *            video text font
  394.  *
  395.  *  ENTRY POINT: SetCurrentFont
  396.  *    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entry 268 )
  397.  *
  398.  *  INPUT: (Passed on stack)
  399.  *             FAR *Environment ( Environment buffer for the session )
  400.  *             FAR *ParmBlock
  401.  *                     USHORT Length = length of this packet
  402.  *                     USHORT Flags  = 0 - Environment buffer only
  403.  *                                     1 - Hardware also
  404.  *                     UCHAR far *FontBuffer
  405.  *                     USHORT     FontLength
  406.  *                     USHORT     PelColumns
  407.  *                     USHORT     PelRows
  408.  *             ULONG Function ( Call vector table entry = 268 )
  409.  *
  410.  *  EXIT-NORMAL: AX = 0
  411.  *               Current font is set
  412.  *
  413.  *  EXIT-ERROR: AX = ERROR_VIO_INVALID_PARMS
  414.  *
  415.  *  INTERNAL REFERENCES:
  416.  *    ROUTINES: NONE
  417.  *
  418.  *  EXTERNAL REFERENCES:
  419.  *    ROUTINES: PhysToUVirt, FreePhysToUVirt
  420.  *              AccessFont
  421.  *
  422.  ****************************************************************************/
  423.  
  424. USHORT EXPENTRY SetCurrentFont(Environment,ParmBlock,Function)
  425.  
  426.   ENVIRONMENT far *Environment;
  427.   VDH_FONT far *ParmBlock;
  428.   ULONG Function;
  429.  
  430. {
  431.   FarAddress VideoFontBuffer;
  432.   USHORT rc,rc2,i,FontLength,USERFONT_NOT_FOUND,EnvBufferPassed;
  433.   ENVIRONMENT far *TempEnv;
  434.   SEL Selector;
  435.   UCHAR Mode;
  436.   VIOMODEINFO ModeData;
  437.   USERFONT far *USERFont;              /* Pointer to an entry in the USER   */
  438.                                        /* font table                        */
  439.   ULONG NewSize;
  440.  
  441.   rc = ERROR_VIO_INVALID_PARMS;
  442.   EnvBufferPassed = SEG(Environment);  /* Non-zero = TRUE                   */
  443.  
  444. #if     VDHVGA
  445.   if ((Function == FnSetFont) &&       /* Valid function request            */
  446.      (EnvBufferPassed) &&
  447.      (Environment->SVGAMode & MODE_SVGA_ENVFLAG) &&
  448.      (ParmBlock->Flags & 4) &&
  449.      (ParmBlock->Length >= sizeof(VDH_FONT)))
  450.   {
  451.     Environment->PelRows = ParmBlock->PelRows;
  452.     Environment->PelColumns = ParmBlock->PelColumns;
  453.     return(NO_ERROR);
  454.   }
  455. #endif
  456.   if ((Function == FnSetFont) &&       /* Valid function request            */
  457.      (ParmBlock->Length >= sizeof(VDH_FONT)) && /* Valid Length             */
  458.      (ParmBlock->PelRows >= 1) &&      /* Valid rows                   @TB36*/
  459.      (ParmBlock->PelRows <= MAX_FONT_SIZE) && /* Valid rows MS08            */
  460.      (ParmBlock->PelColumns >= 1) &&   /* Valid cols                   @TB36*/
  461.      (ParmBlock->PelColumns <= 9) &&   /* Valid cols                   @TB36*/
  462.      (ParmBlock->Flags <= 1) &&        /* Valid flags                       */
  463.      (EnvBufferPassed))
  464.   {
  465.     rc = ERROR_VIO_MODE;               /* Preset invalid mode               */
  466.  
  467.     if (!(Environment->ModeData.fbType&GRAPHICS))
  468.     {                                  /* Text mode only                    */
  469.       rc = NO_ERROR;                   /* Parameters are OK                 */
  470.  
  471. /*
  472. **  Get current mode to determine if current mode is text, and also to
  473. **  verify that this font is applicable to this mode.
  474. */
  475.  
  476.       if ((ParmBlock->Flags&UPDATE_HARDWARE) && READABLE)
  477.       {
  478.  
  479.  #if      VDHVGA                      /* Read/write hardware                */
  480.                                       /*  @MS00                             */
  481.  
  482.  
  483. /*
  484. **  Allocate temporary storage to temporary environment buffer
  485. */
  486.  
  487.         if (!(rc = DosAllocSeg(sizeof(ENVIRONMENT), (PSEL)&Selector, 0)))
  488.         {
  489.           TempEnv = (ENVIRONMENT far *)MakeFarPTR(Selector, 0);
  490.  
  491.  
  492. /*
  493. **  If "foreground", get the mode directly from the hardware
  494. */
  495.  
  496.           TempEnv->VideoEnable = 1;    /* Assume video ON               @T34*/
  497.           SaveRestoreHW(TempEnv, GET); /* Read hardware                     */
  498.           Mode = (UCHAR)GetModeIndex(TempEnv);/* Get mode index + 1         */
  499.  
  500.           if (!Mode--)
  501.             rc = ERROR_VIO_MODE;
  502.  
  503. /*
  504. **  Deallocate temporary storage to temporary environment buffer
  505. */
  506.  
  507.           DosFreeSeg(Selector);
  508.         }
  509.   #endif       /*         VDHVGA @MS00                                      */
  510.       }
  511.  
  512.       else
  513.  
  514. /*
  515. **  If "background", get the mode from the environment buffer
  516. */
  517.  
  518.         Mode = Environment->ModeIndex;
  519.  
  520.       if (!rc)
  521.       {
  522.  
  523.         if (ParmBlock->FontLength < (FontLength = ParmBlock->PelRows * 256))
  524.           rc = ERROR_VIO_INVALID_PARMS;/*                              @TB38*/
  525.  
  526.         else
  527.  
  528.           if ((Modes[Mode].vres/Environment->ModeData.row !=
  529.              ParmBlock->PelRows) || (Modes[Mode].hres/Modes[Mode].col !=
  530.              ParmBlock->PelColumns))
  531.  
  532.  
  533. /*
  534. **  The specified font is not compatible with the current mode:
  535. **  Return an error but save the font for use later, in another mode
  536. */
  537.  
  538.             rc = ERROR_VIO_USER_FONT;
  539.  
  540.         if (!rc || rc == ERROR_VIO_USER_FONT)
  541.         {
  542.  
  543.  
  544. /*
  545. **  If a USER font with the same dimensions already exists in the USER font
  546. **    table, replace it with the new font.
  547. **  Otherwise, add it to the bottom of the USER font table.
  548. */
  549.  
  550.           USERFont = (USERFONT far *)&Environment->USERFonts;/* Begining of   */
  551.                                                            /* USER font table */
  552.  
  553.           for (i = 0, USERFONT_NOT_FOUND = TRUE; USERFONT_NOT_FOUND &&
  554.               (i < Environment->NumUSERFonts); i++)
  555.  
  556.             if ((USERFont->PelRows == ParmBlock->PelRows) &&
  557.                (USERFont->PelColumns == ParmBlock->PelColumns))
  558.  
  559.  
  560. /*
  561. **  A USER font of the same size is already in the USER font table
  562. */
  563.  
  564.               USERFONT_NOT_FOUND = FALSE;
  565.  
  566.             else
  567.  
  568.  
  569. /*
  570. **  Point to the next entry in the USER font table
  571. */
  572.  
  573.               (ULONG)USERFont = (ULONG)(&USERFont->FontData) + (ULONG)
  574.                                 (USERFont->PelRows * 256);
  575.  
  576.           if (USERFONT_NOT_FOUND)
  577.           {
  578.  
  579.  
  580. /*
  581. **  Add the USER font to the USER font table
  582. */
  583.  
  584.             NewSize = (ULONG)(OFFSET(USERFont->FontData) + FontLength);
  585.  
  586.  
  587. /*
  588. **  Let's limit, for now, the number of USER fonts that can be stored to the
  589. **  amount that can fit, along with the environment buffer, in 1 64k segment
  590. */
  591.  
  592.             if (NewSize > 0xFFFFL || !(rc2 = DosReallocHuge(0,(USHORT)NewSize,
  593.                 SEG(Environment))))
  594.             {
  595.               USERFont->PelColumns = ParmBlock->PelColumns;
  596.               USERFont->PelRows = ParmBlock->PelRows;
  597.               ++Environment->NumUSERFonts;
  598.             }
  599.  
  600.             else
  601.             {
  602.  
  603. /*
  604. **  For now, if the table gets filled up to 64k - size of environment buffer,
  605. **  return an error.  In the future, allocate another huge segment, or
  606. **  overwrite another entry in the table.
  607. **
  608. **  Also in the future, it would be nice to remove specified entry from the
  609. **  table ( reshuffle the entries and shrink the table )
  610. */
  611.  
  612.               rc = rc2 ? rc2 : ERROR_NOT_ENOUGH_MEMORY;
  613.             }
  614.           }
  615.  
  616.  
  617. /*
  618. **  Put the new entry in the USER font table
  619. */
  620.  
  621.           if (!rc || rc == ERROR_VIO_USER_FONT)
  622.           {
  623.  
  624.             for (i = 0; i < FontLength; i++)
  625.               ((UCHAR far *)&USERFont->FontData)[i] = ParmBlock->FontBuffer[i];
  626.  
  627.             Environment->UserFont = USER_FONT_SELECTABLE;
  628.  
  629.             if (!rc)
  630.  
  631.               if (ParmBlock->Flags&UPDATE_HARDWARE)
  632.  
  633.  
  634. /*
  635. **  Load specified font
  636. */
  637.  
  638.                 rc = SetHWFont(Environment, (UCHAR far *)&USERFont->FontData,
  639.                      (UCHAR far *)PHYSICAL_FONT_BUFFER);/*             @T53*/
  640.  
  641.               else
  642.                 Environment->ActiveFontPTR = (UCHAR far *)&USERFont->FontData;
  643.           }
  644.         }
  645.       }
  646.     }
  647.   }
  648.   return (rc);
  649. }
  650.  
  651. /*****************************************************************************
  652.  *
  653.  *  SUBROUTINE NAME: SetHWFont
  654.  *
  655.  *  DESCRIPTIVE NAME: Set the ROM, USER or CODE PAGE font
  656.  *
  657.  *  FUNCTION: SetHWFont is called to set the font to correspond with
  658.  *            the current video mode.  If a USER font is available,
  659.  *            it will be loaded.  Otherwise, if a code page is
  660.  *            available, it will be loaded.  If neither a USER font or
  661.  *            Code Page font is available, a ROM font will be loaded.
  662.  *
  663.  *  ENTRY POINT: SetHWFont
  664.  *    LINKAGE:   CALL FAR
  665.  *
  666.  *  INPUT: (Passed on stack)
  667.  *             FAR * Environment
  668.  *             FAR * USERFontBuffer (explicit source ptr)
  669.  *             FAR * DestinationBuffer (explicit target ptr)
  670.  *         (Referenced)
  671.  *             Modes[] (global data - table of supported video modes )
  672.  *             Fonts[] (global data - table of ROM font areas )
  673.  *
  674.  *  EXIT-NORMAL: An appropriate font is loaded
  675.  *
  676.  *  EFFECTS: NONE
  677.  *
  678.  *  INTERNAL REFERENCES:
  679.  *    ROUTINES: PhysToUVirt, FreePhysToUVirt
  680.  *
  681.  *  EXTERNAL REFERENCES:
  682.  *    ROUTINES: AccessFont
  683.  *
  684.  ****************************************************************************/
  685.  
  686. USHORT PASCAL near SetHWFont(Environment,USERFontBuffer,DestinationBuffer)
  687.                                                               /* @B15,@T53 */
  688.   ENVIRONMENT far *Environment;
  689.   UCHAR far *USERFontBuffer;
  690.   UCHAR far *DestinationBuffer;
  691.  
  692. {
  693.  
  694.   USHORT CellCols,CellRows,ColorMode,VideoBufferSEL,CodePageIndex,Selector,
  695.          Direction,i,rc;              /*                               @T53*/
  696.  
  697.   REGADDRESS RegAddress;
  698.   REGDATA RegData;
  699.   FarAddress ROMFontBuffer;
  700.   UCHAR ByteData;
  701.   UCHAR far *FontBuffer;
  702.   UCHAR far *Destination;
  703.   UCHAR far *BaseFontPTR;
  704.   rcp_addr rcp_tbl;                    /*                               @C10*/
  705.  
  706.   rc = NO_ERROR;                       /*                               @T53*/
  707.  
  708.   if (!(Environment->ModeData.fbType&GRAPHICS))
  709.   {                                    /* Text mode only                    */
  710. #if     VDHVGA
  711.     if ((Environment->SVGAMode & MODE_SVGA_ENVFLAG) &&                  /*            */
  712.         Environment->PelRows &&
  713.         Environment->PelColumns)
  714.     {
  715.       CellRows = Environment->PelRows;
  716.       CellCols = Environment->PelColumns;
  717.     }
  718.     else
  719. #endif
  720.     {
  721.     CellCols = Environment->ModeData.hres/Environment->ModeData.col;
  722.     CellRows = Environment->ModeData.vres/Environment->ModeData.row;
  723.     }
  724.  
  725.  
  726. /*
  727. **  Set up the Destination ptr for the font
  728. */
  729.  
  730.     if (DestinationBuffer)
  731.     {
  732.       Destination = DestinationBuffer; /* Use explicit target ptr, if       */
  733.                                        /* specified                         */
  734.     }
  735.  
  736.     else
  737.     {
  738.       rc = PhysToUVirt(Fonts[0].PVB, (FarAddress *)&Destination,
  739.            Fonts[0]. PVBLen);          /*                          @T30,@T53*/
  740.     }
  741.  
  742.  
  743. /*
  744. **  USERFontBuffer is Direction of Move, if 0:1.
  745. */
  746.  
  747.     if ((Direction = (USHORT)USERFontBuffer) == GET)
  748.     {
  749.       USERFontBuffer = NULL;
  750.     }
  751.  
  752.     else
  753.     {
  754.       Direction = SET;
  755.     }
  756.  
  757.     BaseFontPTR = (UCHAR far *)NULL;
  758.  
  759.  
  760. /*
  761. **  Set up the FontBuffer source ptr for the font
  762. */
  763.  
  764.     if (!rc && USERFontBuffer && (USERFontBuffer != (UCHAR far *)CP_FONT))
  765.     {                                  /* C10,@T53                          */
  766.  
  767.       FontBuffer = USERFontBuffer;     /* Use explicit source ptr, if       */
  768.                                        /* specified                         */
  769.  
  770.       Environment->ActiveFontPTR = USERFontBuffer;/*                    @C10*/
  771.  
  772.       if (SEG(Environment) == SEG(FontBuffer))
  773.       {                                /*                               @S31*/
  774.         CellRows = *(((USHORT *)FontBuffer)-1);/*                       @S31*/
  775.       }                                /*                               @S31*/
  776.     }
  777.  
  778.     else
  779.  
  780.       if (!rc)
  781.       {                                /*                               @T53*/
  782.                                        /* Use codepage font, if active      */
  783.  
  784.         if (Environment->ActiveFontPTR == (UCHAR far *)CP_FONT)
  785.         {                              /*                               @C10*/
  786.           rcp_tbl.ptr = RomCP_tbl.ptr; /*                               @C10*/
  787.           rcp_tbl.p.Offset = Environment->ROMFontIndex *sizeof(ROMCP_TABLE);
  788.                                        /*                               @C10*/
  789.           FontBuffer = rcp_tbl.ptr->FontPTR;/*                          @C10*/
  790.         }
  791.  
  792.         else
  793.         {
  794.  
  795.           if (!(rc = PhysToUVirt(Fonts[Environment->ROMFontIndex].PVB,
  796.              &ROMFontBuffer,Fonts[Environment->ROMFontIndex].PVBLen)))
  797.           {
  798.             FontBuffer = ROMFontBuffer.FullAddress;/* Use the ROM font as   */
  799.                                                    /* default               */
  800.           }                                        /*                   @T53*/
  801.         }
  802.  
  803.  
  804. /*
  805. **  Set up the BaseFontPTR, if this font overrides some other font
  806. */
  807.  
  808.         if (!rc && CellCols == 9)
  809.         {                              /*                               @T53*/
  810.  
  811.           if (Environment->ActiveFontPTR == (UCHAR far *)CP_FONT)/*     @C10*/
  812.           {                            /*                               @C10*/
  813.             CellRows = rcp_tbl.ptr->PelRows; /*   @MS10                     */
  814.  
  815.             if (rcp_tbl.ptr->PelColumns == 8)/*                         @C10*/
  816.               CellCols = 8;            /*                               @C10*/
  817.  
  818.             else                       /*                               @C10*/
  819.               BaseFontPTR = rcp_tbl.ptr->BaseFontPTR;/*                 @C10*/
  820.           }
  821.  
  822.           else
  823.           {                            /*                               @C10*/
  824.             CellRows = Fonts[Environment->ROMFontIndex].PelRows; /*  @MS10  */
  825.  
  826.             if (Fonts[Environment->ROMFontIndex].PelColumns == 8)/*      @C2*/
  827.               CellCols = 8;            /*                                @C2*/
  828.  
  829.             else                       /*                                @C2*/
  830.             {                          /*                                @C2*/
  831.               i = Fonts[Environment->ROMFontIndex].Partner;/*           @C10*/
  832.               rc = PhysToUVirt(Fonts[i].PVB, (FarAddress *)&BaseFontPTR, Fonts
  833.                  [i].PVBLen);          /*                          @T30,@T53*/
  834.             }
  835.           }                            /*                                @C2*/
  836.         }
  837.       }
  838.  
  839.  
  840. /*
  841. **  Move the font to its destination
  842. */
  843.  
  844.     if (!rc)
  845.     {                                  /*                               @T53*/
  846.       AccessFont(FontBuffer, Destination, CellRows, CellCols, BaseFontPTR,
  847.          Direction, (UCHAR)(Environment->ModeData.fbType&NOT_MONO));
  848.     }                                  /*                               @T53*/
  849.  
  850.  
  851. /*
  852. **  Get rid of the temporary selectors allocated by this routine
  853. */
  854.  
  855.     if (!DestinationBuffer)
  856.     {
  857.       FreePhysToUVirt((*(FarAddress *)&Destination).part.Selector);/* Free  */
  858.                                       /*  the physical font selector        */
  859.     }
  860.  
  861.     if (!USERFontBuffer)
  862.     {                                  /*                               @C10*/
  863.       FreePhysToUVirt(ROMFontBuffer.part.Selector);/* Free the base         */
  864.                                        /* selector                          */
  865.  
  866.       if (BaseFontPTR)
  867.       {
  868.         FreePhysToUVirt((*(FarAddress *)&BaseFontPTR).part.Selector);
  869.                                        /* Free the Base font selector   @T30*/
  870.       }
  871.     }
  872.  
  873.     if (!rc)
  874. #if     VDHVGA
  875.     if (!(Environment->SVGAMode & MODE_SVGA_ENVFLAG))         /*            */
  876. #endif
  877.       SetHWFontRegs(Environment, CellRows);
  878.   }
  879.   return (rc);
  880. }
  881.  
  882. /*****************************************************************************
  883.  *
  884.  *  SUBROUTINE NAME: SetHWFontRegs
  885.  *
  886.  *  DESCRIPTIVE NAME: Set the h/w regs to match the corresponding font
  887.  *
  888.  *  FUNCTION: Call by SetHWFont to adjust appropriate h/w regs.
  889.  *
  890.  *  ENTRY POINT: SetHWFontRegs
  891.  *    LINKAGE:   CALL FAR
  892.  *
  893.  *  INPUT: (Passed on stack)
  894.  *             FAR * Environment
  895.  *             USHORT CellRows (0 if not supplied)
  896.  *
  897.  *  EXIT-NORMAL: Appropriate regs are updated
  898.  *
  899.  *  EFFECTS: NONE
  900.  *
  901.  *  INTERNAL REFERENCES:
  902.  *    ROUTINES: AccessHardware
  903.  *
  904.  *  EXTERNAL REFERENCES:
  905.  *    ROUTINES: None
  906.  *
  907.  ****************************************************************************/
  908.  
  909. void PASCAL near SetHWFontRegs(Environment,CellRows)
  910.  
  911.   ENVIRONMENT far *Environment;
  912.   USHORT CellRows;
  913.  
  914. {
  915.  
  916.   USHORT ColorMode;
  917.   REGADDRESS RegAddress;
  918.   REGDATA RegData;
  919.   UCHAR ByteData;
  920.  
  921.  
  922.   if (!CellRows)
  923.     CellRows = Environment->ModeData.vres / Environment->ModeData.row;
  924.  
  925.  
  926. /*
  927. **  Adjust the registers for a number of rows different from the default
  928. */
  929.  
  930.   ColorMode = Environment->ModeData.fbType & NOT_MONO;
  931.   RegAddress.AddressPort = CRTAddressPort;
  932.   RegAddress.DataPort = CRTDataPort;
  933.   RegAddress.ColorAdjust = ColorAdjustment;
  934.   RegAddress.Flags = NONE;
  935.   RegData.DataArea = (UCHAR far *)&ByteData;
  936.   RegData.NumEntries = 1;
  937.  
  938.  
  939. /*
  940. **  Adjust the underline register
  941. */
  942.  
  943.   if (ColorMode == FALSE)
  944.   {
  945.     RegData.FirstEntry = 0x14;         /* Underline location only           */
  946.     ByteData = (UCHAR)CellRows-1;
  947.     AccessHardware(&RegAddress, BYTES, ColorMode, SET, &RegData);
  948.   }
  949.  
  950.   RegData.FirstEntry = 0x09;           /* Maximum scan line only            */
  951.   ByteData = ((UCHAR)CellRows-1);
  952.  
  953.   #if      VDHVGA                      /*    @MS00                          */
  954.  
  955.  
  956. /*
  957. **  Adjust the maximum scan line if CGA emulation
  958. */
  959.  
  960.   if (Environment->ModeData.vres == 200)
  961.     ByteData |= (Environment->Hardware.CRTCtlRegs.All
  962.                 [RegData.FirstEntry]&0xE0 );
  963.  
  964.   #endif            /*    VDHVGA         @MS00                              */
  965.  
  966.   AccessHardware(&RegAddress, BYTES, ColorMode, SET, &RegData);
  967.   RegData.FirstEntry = 0x12;           /* Vertical display enable end only  */
  968.   ByteData = (UCHAR)(CellRows *Environment->ModeData.row);
  969.  
  970.   #if      VDHVGA                /*       @MS00                             */
  971.  
  972.  
  973. /*
  974. **  Adjust the vertical display enable end if CGA emulation
  975. */
  976.  
  977.   if (Environment->ModeData.vres == 200)/* Turn 200 lines to 400 lines      */
  978.     ByteData <<= 1;
  979.  
  980.   #endif            /*     VDHVGA  @MS00                                    */
  981.  
  982.   if (!(Environment->EnvFlags & SAVEREST_VDM))            /*                */
  983.   {
  984.    ByteData--;
  985.    AccessHardware(&RegAddress, BYTES, ColorMode, SET, &RegData);
  986.   }
  987.  
  988. }
  989.  
  990. /*****************************************************************************
  991.  *
  992.  *  SUBROUTINE NAME: FindFont
  993.  *
  994.  *  DESCRIPTIVE NAME: Determine if a font is available to support
  995.  *                    the specified mode.
  996.  *
  997.  *  FUNCTION: Determine if either a ROM font or a USER font is
  998.  *            available to support the specified mode.
  999.  *
  1000.  *  ENTRY POINT: FindFont
  1001.  *    LINKAGE:   CALL FAR
  1002.  *
  1003.  *  INPUT: (Passed on stack)
  1004.  *             USHORT ModeIndex  ( Index in mode table )
  1005.  *             USHORT Rows       ( Number of text rows desired )
  1006.  *         (Referenced)
  1007.  *             Modes[] ( table of supported video modes )
  1008.  *
  1009.  *  EXIT-NORMAL: AX = FontIndex if an appropriate font is available
  1010.  *               AX = 0 if an appropriate font is not available
  1011.  *
  1012.  *  EFFECTS: NONE
  1013.  *
  1014.  *  INTERNAL REFERENCES:
  1015.  *    ROUTINES: NONE
  1016.  *
  1017.  *  EXTERNAL REFERENCES:
  1018.  *    ROUTINES: NONE
  1019.  *
  1020.  ****************************************************************************/
  1021.  
  1022. UCHAR PASCAL near FindFont(ModeIndex,Rows,Environment)/*                @B15*/
  1023.  
  1024.   USHORT ModeIndex;
  1025.   USHORT Rows;
  1026.   ENVIRONMENT far *Environment;
  1027.  
  1028. {
  1029.  
  1030.   UCHAR i,FONT_AVAILABLE;
  1031.   USHORT PelColumns,PelRows, Vres;                              /*            */
  1032.   SHORT j;                             /*                               @C10*/
  1033.   USERFONT far *USERFont;              /* Pointer to an entry in the USER   */
  1034.                                        /* font table                        */
  1035.   ROMCP_TABLE *rcp_tbl_ptr;            /*                               @C10*/
  1036.  
  1037.   FONT_AVAILABLE = FALSE;
  1038. #if     VDHVGA
  1039.   if ((Environment->SVGAMode & MODE_SVGA_ENVFLAG) &&               /*            */
  1040.      (Environment->PelRows) && (Environment->PelColumns))
  1041.   {
  1042.     Vres =      Environment->ModeData.vres;
  1043.     PelRows =   Environment->PelRows;
  1044.     PelColumns =Environment->PelColumns;
  1045.   }
  1046.   else
  1047. #endif
  1048.   {
  1049.     Vres =      Modes[ModeIndex].vres;
  1050.     PelRows =   Vres/Rows;
  1051.     PelColumns =Modes[ModeIndex].hres/Modes[ModeIndex].col;
  1052.   }
  1053.   if (Environment->UserFont == USER_FONT_SELECTABLE)
  1054.   {
  1055.     USERFont = (USERFONT far *)&Environment->USERFonts;/* Begining of USER  */
  1056.                                                        /* font table        */
  1057.  
  1058.     for (j = 0; (FONT_AVAILABLE == FALSE)/* Start of             @S26CHANGES*/
  1059.          && (j < Environment->NumUSERFonts); j++)
  1060.     {
  1061.  
  1062.       if ((USERFont->PelColumns == PelColumns) &&
  1063.          ((USERFont->PelRows == PelRows) ||                   /*        @S31*/
  1064.          (Vres/USERFont->PelRows == Rows)))                   /*            */
  1065.  
  1066.       {                                /*                               @S31*/
  1067.         FONT_AVAILABLE = TRUE;         /* Valid Mode/Font combination found */
  1068.         Environment->ActiveFontPTR = (UCHAR far *)&USERFont->FontData;
  1069.       }
  1070.  
  1071.       else
  1072.       {
  1073.         (ULONG)USERFont = (ULONG)(&USERFont->FontData) + (ULONG)
  1074.            (USERFont->PelRows * 256);   /* Next font                         */
  1075.       }
  1076.     }                                  /* End of                 @S26CHANGES*/
  1077.   }
  1078.  
  1079. /*
  1080. ** Check CodePage font table if CodePages available
  1081. */
  1082.  
  1083.   if (!FONT_AVAILABLE && (Environment->CodePageID != ROM_FONT))
  1084.   {                                    /*                                @C7*/
  1085.     rcp_tbl_ptr = RomCP_tbl.ptr;       /*                               @C10*/
  1086.  
  1087.     for (j = 0; j < ROMCP_NUM && !FONT_AVAILABLE; j++)/*                @C10*/
  1088.     {                                  /*                               @C10*/
  1089.  
  1090.       if (Environment->CodePageID == rcp_tbl_ptr->CodePageID && /*      @C10*/
  1091.          (PelRows == rcp_tbl_ptr->PelRows) && /*                        @C10*/
  1092.          (PelColumns == rcp_tbl_ptr->PelColumns))/*                     @C10*/
  1093.       {                                /*                                @C7*/
  1094.         FONT_AVAILABLE = TRUE;         /*                                @C7*/
  1095.         Environment->ROMFontIndex = (UCHAR)j;/*                         @C10*/
  1096.         Environment->ActiveFontPTR = (UCHAR far *)CP_FONT;/*             @C7*/
  1097.       }                                /*                                @C7*/
  1098.  
  1099.       else
  1100.         rcp_tbl_ptr++;                 /*                               @C10*/
  1101.  
  1102.       if ((j == (ROMCP_NUM-1)) && !FONT_AVAILABLE && (PelColumns == 9))/*
  1103.                                                                         @C10*/
  1104.       {                                /*                               @C10*/
  1105.         PelColumns = 8;                /*                               @C10*/
  1106.         j = -1;                        /*                               @C10*/
  1107.         rcp_tbl_ptr = RomCP_tbl.ptr;   /*                               @C10*/
  1108.       }                                /*                               @C10*/
  1109.     }
  1110.   }                                    /*                                @C7*/
  1111.  
  1112.   if (!FONT_AVAILABLE)
  1113.   {
  1114.  
  1115. /*
  1116. ** Check ROM font table for an appropriate mode
  1117. */
  1118.  
  1119.     for (i = ROMFont8x8; i <= ROM_FONTS; i++)/*                          @C7*/
  1120.     {
  1121.  
  1122.       if ((PelColumns == Fonts[i].PelColumns) && (PelRows == Fonts[i].PelRows))
  1123.       {
  1124.         FONT_AVAILABLE = TRUE;
  1125.         Environment->ROMFontIndex = i;
  1126.         Environment->ActiveFontPTR = (UCHAR far *)ROM_FONT;
  1127.         break;
  1128.       }
  1129.  
  1130.       if ((i == ROM_FONTS) && (PelColumns == 9))/*                   @C2,@C7*/
  1131.       {                                /*                                @C2*/
  1132.         PelColumns = 8;                /*                                @C2*/
  1133.         i = ROMFont8x8-1;              /*                                @C2*/
  1134.       }                                /*                                @C2*/
  1135.     }
  1136.   }
  1137.   return (FONT_AVAILABLE);
  1138. }
  1139.  
  1140. #endif         /*        FONT_SUPPORT @MS00                                 */
  1141.  
  1142. #if      VDHCGA                        /* Start of unique CGA support,  @S26*/
  1143.                                        /*  @MS00                            */
  1144. extern UCHAR CGAFont;                  /* CGA 8x8 font table                */
  1145.  
  1146. /*****************************************************************************
  1147.  *
  1148.  *  SUBROUTINE NAME: GetCurrentFont
  1149.  *
  1150.  *  DESCRIPTIVE NAME: Get color lookup table
  1151.  *
  1152.  *  FUNCTION: GetCurrentFont is called by BVS to return the current
  1153.  *            active video font.
  1154.  *
  1155.  *  ENTRY POINT: GetCurrentFont
  1156.  *    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entry 267 )
  1157.  *
  1158.  *  INPUT: (Passed on stack)
  1159.  *             FAR *Environment ( Environment buffer for the session )
  1160.  *             FAR *ParmBlock
  1161.  *                     USHORT Length = length of this packet
  1162.  *                     USHORT Flags  = 0 - Environment buffer only
  1163.  *                                     1 - Hardware also
  1164.  *                     UCHAR far *FontBuffer
  1165.  *                     USHORT     FontLength
  1166.  *                     USHORT     PelColumns
  1167.  *                     USHORT     PelRows
  1168.  *             ULONG Function ( Call vector table entry = 267 )
  1169.  *
  1170.  *  EXIT-NORMAL: AX = 0
  1171.  *               Current font is returned to caller
  1172.  *
  1173.  *  EXIT-ERROR: AX = ERROR_VIO_INVALID_PARMS
  1174.  *
  1175.  *  INTERNAL REFERENCES:
  1176.  *    ROUTINES: NONE
  1177.  *
  1178.  *  EXTERNAL REFERENCES:
  1179.  *    ROUTINES: PhysToUVirt, FreePhysToUVirt
  1180.  *              AccessFont
  1181.  *
  1182.  ****************************************************************************/
  1183.  
  1184. USHORT EXPENTRY GetCurrentFont(Environment,ParmBlock,Function)
  1185.  
  1186.   ENVIRONMENT far *Environment;
  1187.   VDH_FONT far *ParmBlock;
  1188.   ULONG Function;
  1189.  
  1190. {
  1191.  
  1192.   USHORT rc;
  1193.   USHORT FontSize = 0x0800;
  1194.   UCHAR register far *SourcePtr;
  1195.   UCHAR register far *DestPtr;
  1196.  
  1197.   rc = ERROR_VIO_INVALID_PARMS;
  1198.  
  1199.   if ((Function == FnGetFont) &&       /* Valid function request            */
  1200.      (ParmBlock->Length >= sizeof(VDH_FONT)) && /* Valid Length             */
  1201.      (ParmBlock->Flags <= 3))
  1202.   {                                    /* Valid flags                       */
  1203.     rc = ERROR_VIO_FONT;
  1204.  
  1205.     if ((ParmBlock->Flags&GET_ROM_FONT) && (ParmBlock->PelColumns == 8) &&
  1206.        (ParmBlock->PelRows == 8))
  1207.     {                                  /* Only 8x8 ROM font available       */
  1208.       rc = NO_ERROR;
  1209.  
  1210.       if ((ParmBlock->FontLength == NULL) && /* Return size only            */
  1211.          (ParmBlock->FontBuffer == NULL))
  1212.       {
  1213.         ParmBlock->FontLength = FontSize;
  1214.       }
  1215.  
  1216.       else
  1217.  
  1218.         if (ParmBlock->FontLength < FontSize)
  1219.         {
  1220.           rc = ERROR_VIO_INVALID_PARMS;/*                              @TB38*/
  1221.         }
  1222.  
  1223.         else
  1224.         {                              /* Return the actual font            */
  1225.           SourcePtr = &CGAFont;
  1226.           DestPtr = ParmBlock->FontBuffer;
  1227.  
  1228.           do
  1229.           {
  1230.             *DestPtr++ = *SourcePtr++;
  1231.           }
  1232.  
  1233.           while (--FontSize);
  1234.         }
  1235.     }
  1236.   }
  1237.   return (rc);
  1238. }
  1239.  
  1240. #endif           /*     VDHCGA    End of unique CGA support, @S26,MS00 */
  1241.  
  1242. #if      VDHMPA        || VDHCGA       /*                          @T68,MS00*/
  1243.  
  1244. /*****************************************************************************
  1245.  *
  1246.  *  SUBROUTINE NAME: SetCurrentFont
  1247.  *
  1248.  *  DESCRIPTIVE NAME: Set color lookup table
  1249.  *
  1250.  *  FUNCTION: SetCurrentFont is called by BVS to load the specified
  1251.  *            video text font
  1252.  *
  1253.  *  ENTRY POINT: SetCurrentFont
  1254.  *    LINKAGE:   CALL FAR ( via BVS-DDI call vector table entry 268 )
  1255.  *
  1256.  *  INPUT: (Passed on stack)
  1257.  *             FAR *Environment ( Environment buffer for the session )
  1258.  *             FAR *ParmBlock
  1259.  *                     USHORT Length = length of this packet
  1260.  *                     USHORT Flags  = 0 - Environment buffer only
  1261.  *                                     1 - Hardware also
  1262.  *                     UCHAR far *FontBuffer
  1263.  *                     USHORT     FontLength
  1264.  *                     USHORT     PelColumns
  1265.  *                     USHORT     PelRows
  1266.  *             ULONG Function ( Call vector table entry = 268 )
  1267.  *
  1268.  *  EXIT-ERROR: AX = ERROR_VIO_FONT
  1269.  *
  1270.  *  INTERNAL REFERENCES:
  1271.  *    ROUTINES: NONE
  1272.  *
  1273.  *  EXTERNAL REFERENCES:
  1274.  *    ROUTINES:
  1275.  *
  1276.  ****************************************************************************/
  1277.  
  1278. USHORT EXPENTRY SetCurrentFont(Environment,ParmBlock,Function)/*        @T68*/
  1279.  
  1280.   ENVIRONMENT far *Environment;        /*                               @T68*/
  1281.   VDH_FONT far *ParmBlock;             /*                               @T68*/
  1282.   ULONG Function;                      /*                               @T68*/
  1283.  
  1284. {                                      /*                               @T68*/
  1285.   return (ERROR_VIO_FONT);             /*                               @T68*/
  1286. }                                      /*                               @T68*/
  1287.  
  1288. #endif                                 /* VDHMPA || VDHCGA   @T68,MS00      */
  1289.  
  1290.