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

📄 util.doc

📁 hello everybody. good lucky to you
💻 DOC
📖 第 1 页 / 共 5 页
字号:

                    The registering routines each take one parameter; a
                    symbolic name defined in graphics.h. Each registering



                                   - 3 -






                    routine returns a nonnegative value if the driver or
                    font is successfully registered.

                    The following table shows the names to be used with
                    registerbgidriver and registerbgifont. It is a complete
                    list of drivers and fonts included with Turbo C++.


---------------------------------------------------------------------------
 Driver file     registerbgidriver      Font file   registerbgifont
 (*.BGI)         symbolic name          (*.CHR)     symbolic name
---------------------------------------------------------------------------

 CGA             CGA_driver             TRIP        triplex_font
 EGAVGA          EGAVGA_driver          LITT        small_font
 HERC            Herc_driver            SANS        sansserif_font
 ATT             ATT_driver             GOTH        gothic_font
 PC3270          PC3270_driver
 IBM8514         IBM8514_driver

---------------------------------------------------------------------------


------------------  Suppose you want to convert the files for the CGA
        An example  graphics driver, the gothic font, and the triplex font
------------------  to object modules, then link them into your program.
                    Here's what you do:

                    1. Convert the binary files to object files using
                       BGIOBJ.EXE, as shown in the following separate com-
                       mand lines:

                        bgiobj  cga
                        bgiobj  trip
                        bgiobj  goth

                       This creates three files: CGA.OBJ, TRIP.OBJ, and
                       GOTH.OBJ.

                    2. You can add these object files to GRAPHICS.LIB with
                       this TLIB command line:

                          tlib  graphics  +cga  +trip  +goth

                    3. If you don't add the object files to GRAPHICS.LIB,
                       you must add the object file names CGA.OBJ,
                       TRIP.OBJ, and GOTH.OBJ to your project list (if you
                       are using Turbo C++'s integrated environment), or to



                                   - 4 -






                       the TCC command line. For example, the TCC command
                       line would look like this:

                          TCC  niftgraf graphics.lib  cga.obj  trip.obj
                       goth.obj

                    4. You register these files in your graphics program
                       like this:

 If you ever get a      /* Header file declares CGA_driver, triplex_font &
      linker error      gothic_font */
   Segment exceeds      #include <graphics.h>
 64K after linking
   in some drivers      /* Register and check for errors (one never
     and/or fonts,      knows...) */
      refer to the
following section.      if (registerbgidriver(CGA_driver) < 0) exit(1);
                        if (registerbgifont(triplex_font) < 0) exit(1);
                        if (registerbgifont(gothic_font)  < 0) exit(1);

                        /* ... */

                        initgraph(....);     /* initgraph should be called
                                                after registering */

                        /* ... */


     The /F option  =======================================================

                    This section explains what steps to take if you get the
                    linker error Segment exceeds 64K (or a similar error)
                    after linking in several driver and/or font files
                    (especially with small- and compact-model programs).

                    By default, the files created by BGIOBJ.EXE all use the
                    same segment (called _TEXT). This can cause problems if
                    your program links in many drivers and/or fonts, or
                    when you're using the small or compact memory model.

                    To solve this problem, you can convert one or more of
                    the drivers or fonts with the BGIOBJ /F option. This
                    option directs BGIOBJ to use a segment name of the form
                    filename_TEXT, so that the default segment is not
                    overburdened by all the linked-in drivers and fonts
                    (and, in small and compact model programs, all the pro-
                    gram code). For example, the following two BGIOBJ com-




                                   - 5 -






                    mand lines direct BGIOBJ to use segment names of the
                    form EGAVGA_TEXT and SANS_TEXT.

                     bgiobj  /F  egavga
                     bgiobj  /F  sans

                    When you select /F, BGIOBJ also appends F to the target
                    object file name (EGAVGAF.OBJ, SANSF.OBJ, and so
                    forth), and appends _far to the name that will be used
                    with registerfarbgidriver and registerfarbgifont. (For
                    example, EGAVGA_driver becomes EGAVGA_driver_far.)

                    For files created with /F, you must use these far
                    registering routines instead of the regular
                    registerbgidriver and registerbgifont. For example,

                     if (registerfarbgidriver(EGAVGA_driver_far) < 0)
                     exit(1);
                     if (registerfarbgifont(sansserif_font_far)  < 0)
                     exit(1);


 Advanced features  =======================================================

                    This section explains some of BGIOBJ's advanced
                    features, and the routines registerfarbgidriver and
                    registerfarbgifont. Only experienced users should use
                    these features.

                    This is the full syntax of the BGIOBJ.EXE command line:

                       BGIOBJ  [/F] source destination public-name seg-name
                    seg-class

                    This table describes each component of the BGIOBJ com-
                    mand line.


                    -------------------------------------------------------
                    Component              Description
                    -------------------------------------------------------


                    /F or -F               This option instructs BGIOBJ.EXE
                                           to use a segment name other than
                                           _TEXT (the default), and to
                                           change the public name and
                                           destination file name. (See page



                                   - 6 -






                                           5 for a detailed discussion of
                                           /F.)

                    source                 This is the driver or font file
                                           to be converted. If the file is
                                           not one of the driver/font files
                                           shipped with Turbo C++, you
                                           should specify a full file name
                                           (including extension).

                    destination            This is the name of the object
                                           file to be produced. The default
                                           destination file name is
                                           source.OBJ, or sourceF.OBJ if
                                           you use the /F option.

                    public-name            This is the name that will be
                                           used in the program in a call to
                                           registerbgidriver or
                                           registerbgifont (or their
                                           respective far versions) to link
                                           in the object module.

                                           The public name is the external
                                           name used by the linker, so it
                                           should be the name used in the
                                           program, prefixed with an
                                           underscore. If your program uses
                                           Pascal calling conventions, use
                                           only uppercase letters, and do
                                           not add an underscore.

                    seg-name               This is an optional segment
                                           name; the default is _TEXT (or
                                           filename_TEXT if /F is
                                           specified)

                    seg-class              This is an optional segment
                                           class; the default is CODE.

                    -------------------------------------------------------

                    All parameters except source are optional. However, if
                    you need to specify an optional parameter, all the
                    parameters preceding it must also be specified.






                                   - 7 -






                    If you choose to use your own public name(s), you have
                    to add declaration(s) to your program, using one of the
                    following forms:

                     void public_name(void);        /* if /F not used, */
                                                    /* default segment name
                     used */

                     extern int far public_name[];  /* if /F used, or */
                                                    /* segment name not
                     _TEXT */

                    In these declarations, public_name matches the public-
                    name you used when converting with BGIOBJ. The
                    graphics.h header file contains declarations of the
                    default driver and font public names; if you use those
                    default public names you don't have to declare them as
                    just described.

                    After these declarations, you have to register all the
                    drivers and fonts in your program. If you don't use the
                    /F option and don't change the default segment name,
                    you should register drivers and fonts through
                    registerbgidriver and registerbgifont; otherwise, use
                    registerfarbgidriver and registerfarbgifont.

                    Here is an example of a program that loads a font file
                    into memory:

                     /* Example of loading a font file into memory */

                     #include <graphics.h>
                     #include <io.h>
                     #include <fcntl.h>
                     #include <stdio.h>
                     #include <conio.h>
                     #include <stdlib.h>
                     #include <process.h>
                     #include <alloc.h>

                     main()
                     {
                        void    *gothic_fontp;    /* points to font buffer
                     in memory */
                        int      handle;          /* file handle used for
                     I/O */
                        unsigned fsize;           /* size of file (and
                     buffer) */



                                   - 8 -






                        int errorcode;
                        int graphdriver;
                        int graphmode;

                     /* open font file */
                        handle = open("GOTH.CHR", O_RDONLY|O_BINARY);
                        if (handle == -1)
                        {
                           printf("unable to open font file 'GOTH.CHR'\n");
                           exit(1);
                        }
                     /* find out size of the file */
                        fsize = filelength(handle);
                     /* allocate buffer */
                        gothic_fontp = malloc(fsize);
                        if (gothic_fontp == NULL)
                        {
                          printf("unable to allocate memory for font file
                     'GOTH.CHR'\n");
                          exit(1);
                        }
                     /* read font into memory */
                        if (read(handle, gothic_fontp, fsize) != fsize)
                        {
                           printf("unable to read font file 'GOTH.CHR'\n");
                           exit(1);
                        }
                     /* close font file */
                        close(handle);
                     /* register font */
                        if (registerfarbgifont(gothic_fontp) !=
                     GOTHIC_FONT)
                        {
                           printf("unable to register font file
                     'GOTH.CHR'\n");
                           exit(1);
                        }

⌨️ 快捷键说明

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