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:
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.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 top, int right, int bottom, byte 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);
}
}
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.




Reply With Quote