Thread: Video Modes

  1. #1
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94

    Video Modes

    I am using Turbo C and am trying to learn how to graphics and sometime within a month or two create a small asteroids-like-game. To set the video mode in DOS (You know, CGA, VGA, SVGA)
    I use this code:

    void mode(mode_code)
    int mode_code;
    {
    union REGS r;

    r.h.al = mode_code;
    r.h.ah = 0;
    int86(0x10, &r, &r);
    }

    Ex
    mode(4);
    would put the screen in 320x200 4 color mode.

    but the problem is I can't get any of the higher modes for some reason. If I did
    mode(13); for 320x200 256 color mode or
    mode(12); for 640x480 16 color mode, It doesn't work right, and my lines or points don't show up.
    (I could also use 0x13 or 0x12 instead of 13 or 12 it doesn't make a difference)

    Please help me in setting my screen to the higher modes.
    I can use 0x00-0x06 without problems. Also maybe you can simply give me a new mode setting function that works.

    The problem may be with Turbo C since it is so old that EGA or VGA weren't out yet but I don't know.

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    VOX you're new to the forum so please read this thread...

    I have little document from one of my classes
    Accessing Linear Framebuffer Memory
    Once you have initialized the graphics hardware into a mode that supports a hardware linear framebuffer, you need to create a pointer that your application can use to write to the linear framebuffer memory. The first thing you should realize is that the linear framebuffer location reported in the ModeInfoBlock for the mode you are using is a physical memory address, and cannot be used directly from protected mode applications. Before you can use the memory you must use the services your operating system provides to map the physical memory to a linear memory address, and then map this linear address into your applications memory space. Under DPMI mapping the linear memory is done with DPMI function 0x800, and equivalent functions exist under other operating systems.
    The steps involved in mapping in a linear framebuffer region are as follows (32-bit protected mode only) :
    1. Map the physical memory address to a linear memory address (using DPMI function
      0x800 for example).
    2. Find the base address of the default DS selector for your operating environment.
    3. Subtract the base address from the linear address computed in step 1 to give you a
      near pointer (relative to DS) that you can use from within your code.
    Last edited by xErath; 11-17-2004 at 07:04 PM.

  3. #3
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94
    Thanks for the help, but that doesn't answer my question. I think. I am not that expert in C. Maybe if I knew what a hardware linear framebuffer was...

  4. #4
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    You're not an expert, but you don't have to be. If you've read what I posted them you'd realize that you need first to map the graphics memory in your main memory. And a linear buffer is simply an array.

    And try to get a recent compiler.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem With My Box
    By HaVoX in forum Tech Board
    Replies: 9
    Last Post: 10-15-2005, 07:38 AM
  2. video convert..."hack" on a genesis
    By Shadow in forum Tech Board
    Replies: 3
    Last Post: 12-06-2003, 01:30 PM
  3. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 08:39 AM
  4. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM