Thread: egavga.bgi

  1. #1
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516

    egavga.bgi

    guys,i recently made a game similar to snake .... the one in which the snake or worm goes around eatin stuff and the size increases...i made it in C in the graphics mode .... so had to use the initgraph() function....the point is that .... i have to specify the location of the egavga.bgi file in that....and accordin to commonsense....if the file is not at the specified location...the exe file of the program does not work......so there is a portability issue regarding the program.....please tell me if it is possible to include the file in the program itself so that the person or the extractor does not have to manually install the file at the specified path.....any help will be appreciated
    regards......
    PING

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    If you are on windows one way would be to use the registry.

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    Did you use mode 13h?

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Borland has a function that will allow you to add EGAVGA.BGI to the BGI graphics library. I totally forget what function this is but it is found in graphics.h. Check your help file for more information. Also the readme file for Borland compilers explains this as well.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well normally, you would put the file in the same directory as the executable, or a sub-directory of where the executable is.

    Then all you have to do is figure out where your executable is.
    There's a direct win32 API call for win32 programs, but since you're using some old DOS compiler, you need to take a different approach.

    http://cboard.cprogramming.com/showt...ghlight=getenv
    This shows how to solve the problem within a Unix environment. It's mostly the same idea for DOS, but obviously some specifics need to be altered (like the field separator in the PATH environment variable).

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    From the Borland help file for DOS TC 1.01 (this function was not altered in later versions and works as shown).

    ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
    ÝinstalluserdriverÞ <GRAPHICS.H>
    ßßßßßßßßßßßßßßßßßßß
    Installs a vendor-added device driver to the BGI device driver table
    Declaration:
    int far installuserdriver(char far *name, int huge (*detect)(void));
    Remarks:
    With installuserdriver, you can add a vendor-added device driver to
    the BGI internal table.
    Argument³ What It Is/Does
    ÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
    name ³ Name of the new device driver file (filename.BGI)
    detect ³ Points to an optional autodetect function that can accompany the
    ³ new driver. This autodetect function takes no parameters and
    ³ returns an integer value.
    You can install up to 10 drivers at one time.
    There are two ways to use the vendor-supplied driver:
    1) passing the driver number directly to
    initgraph, or
    2) linking in an autodetect function.
    Passing driver number directly to initgraph
    ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
    Assume you have a new video card called the Spiffy Graphics Array
    (SpGA) and that the SpGA manufacturer provided you with a BGI device
    driver (SPGA.BGI).
    The easiest way to use this driver is to install it by calling
    installuserdriver and then passing the return value (the assigned
    driver number) directly to initgraph.
    Linking in an autodetect function
    ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
    The more general way to use this hypothetical SpGA driver is to link
    in an autodetect function that will be called by initgraph as part of
    its hardware-detection logic. (Presumably, the manufacturer of the
    SpGA gave you this autodetect function).
    When you install the driver (by calling installuserdriver), you pass
    the address of this autodetect function, along with the device
    driver's file name.
    After you install the device driver's file name and the SpGA
    autodetect function, call initgraph and let it go through its normal
    autodetection process.
    Before initgraph calls its own built-in autodetection function
    (detectgraph), it first calls the SpGA autodetect function.
    þ If the SpGA autodetect function doesn't find the SpGA hardware, it
    returns a value of -11 (grError), and initgraph proceeds with its
    normal hardware detection logic.
    (This can include calling any other vendor-supplied autodetection
    functions in the order in which they were "installed").
    þ If, however, the autodetect function determines that an SpGA is
    present, it returns a non-negative mode number.
    initgraph then:
    1) locates and loads SPGA.BGI
    2) puts the hardware into the default
    graphics mode recommended by the
    autodetect function
    3) returns control to your program.

    Return Value:
    Returns the driver number you pass to initgraph to manually select the
    newly installed driver.
    Portability:
    É DOS Ñ UNIX Ñ ANSI C Ñ C++ Only »
    º Yes ³ ³ ³ º
    ÈÍÍÍÍÍÏÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍͼ
    See Also:
    initgraph registerbgidriver
    Example:
    #include <graphics.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <conio.h>
    /* function prototypes */
    int huge detectEGA(void);
    void checkerrors(void);
    int main(void)
    {
    int gdriver, gmode;
    /* install a user written device driver */
    gdriver = installuserdriver("EGA", detectEGA);
    /* must force use of detection routine */
    gdriver = DETECT;
    /* check for any installation errors */
    checkerrors();
    /* initialize graphics and local variables */
    initgraph(&gdriver, &gmode, "");
    /* check for any initialization errors */
    checkerrors();
    /* draw a line */
    line(0, 0, getmaxx(), getmaxy());
    /* clean up */
    getch();
    closegraph();
    return 0;
    }
    /* detects EGA or VGA cards */
    int huge detectEGA(void)
    {
    int driver, mode, sugmode = 0;
    detectgraph(&driver, &mode);
    if ((driver == EGA) || (driver == VGA))
    /* return suggested video mode number */
    return sugmode;
    else
    /* return an error code */
    return grError;
    }
    /* check for and report any graphics errors */
    void checkerrors(void)
    {
    int errorcode;
    /* read result of last graphics operation */
    errorcode = graphresult();
    if (errorcode != grOk)
    {
    printf("Graphics error: %s\n", grapherrormsg(errorcode));
    printf("Press any key to halt:");
    getch();
    exit(1);
    }
    }
    The attached readme explains how to use BGIOBJ which will allow you to do what you want.

  7. #7
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    i have used turbo C to make the game .... the OS is WIN 98.....will be switchin on to linux once i get it.....very soon to be precise .... neways...thanx for all the help.....will try out wat u pple said....thanx
    regards->PING

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. egavga.bgi problem
    By sunil21 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-22-2003, 05:06 PM