egavga.bgi

This is a discussion on egavga.bgi within the Game Programming forums, part of the General Programming Boards category; guys,i recently made a game similar to snake .... the one in which the snake or worm goes around eatin ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Location
    India
    Posts
    515

    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,208
    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
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    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.

    Linux: Relative Links and fopen
    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
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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
    India
    Posts
    515
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21