Results 1 to 2 of 2

Thread: Replacement for the "Bar" function

  1. #1

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    The Bar function draws a filled in rectangle. It comes with BorlandC and uses the BGI graphics device drivers. I have a replacement, but it only correctly works in mode 0x13, 320x200x256color. Here is my version of the bar function:
    PHP Code:
    //These may be of use:
    typedef unsigned char  byte;
    typedef unsigned short word;

    #define SCREEN_WIDTH        320       /* width in pixels of mode 0x13 */
    #define SCREEN_HEIGHT       200       /* height in pixels of mode 0x13 */
    #define NUM_COLORS          256       /* number of colors in mode 0x13 */
    byte *xVGA=(byte *)0xA0000000L;

    //The actual function
    void rect_fill(int left,int topint rightint bottombyte color)
    {
      
    word top_offset,bottom_offset,i,temp,width;

      if (
    top>bottom)
      {
        
    temp=top;
        
    top=bottom;
        
    bottom=temp;
      }
      if (
    left>right)
      {
        
    temp=left;
        
    left=right;
        
    right=temp;
      }

      
    top_offset=(top<<8)+(top<<6)+left;
      
    bottom_offset=(bottom<<8)+(bottom<<6)+left;
      
    width=right-left+1;

      for(
    i=top_offset;i<=bottom_offset;i+=SCREEN_WIDTH)
      {
        
    memset(&xVGA[i],color,width);
      }

    This function draws a filled rectangle using mode 0x13. If you change the above variable's values, as well as the video mode, it WILL NOT correctly work in the mode you have selected.

    The problem I get with the function above is that it does NOT work correctly. It displays in incorrect places and it doesn't create a filled rectangle as big as it's supposed to be.

    I need a replacement for this function that will work in ALL video modes. Work someone please help find a function like the above.
    Designer/Programmer of the Comtech Operating System(CTOS)

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    This might not be your exact problem but I think it's something you may need to consider: the width of each line in video memory is not necessarily the same as the width of the screen, since some video cards store extra information on the end of the lines. I'm not sure if this applies to mode 13h stuff, it may be just DirectDraw surfaces, but I think it's a hardware thing more than a DirectX thing. So maybe you're writing to the wrong memory.
    Harry.

    "From one thing, know ten thousand things."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width