doubt in graphics

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rampraveen
    New Member
    • Apr 2010
    • 37

    doubt in graphics

    Code:
    #include "stdio.h"
    #include "conio.h"
    #include "graphics.h"
    char far *vidmem=0xB8000000;
    main()
    {
    
    	int gm,gd=DETECT;
    	int r,c,i;
    	char message[]="praveen";
    	initgraph(&gd,&gm,"");
    
    	clrscr();
    	for(r=5;r<=20;r++)
    	{
    		for(c=5;c<=50;c++)
    			write2vdu('',64,r,c);
    	}
    	c=10;
    	for(i=0;i<=10;i++)
    	{
    		write2vdu(message[i],77,10,c);
    		c++;
    	}
    	getch();
    }
    write2vdu(char ch,char attr,int row,int col)
    {
    char far *v;
    v=vidmem+row*160+col*2;
    *v=ch;
    v++;
    *v=attr;
    }
    when i run this, it just show only white screen..but the author of this program says tat will show a box with some texts..any one help me to get correct output.thankyou ....
    Last edited by Banfa; Jul 16 '10, 08:33 AM. Reason: Please start putting [code]...[/code] tags round your code
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I don't have a compiler old enough to compile thbs code.

    I havent't seen far pointers in 20 years. Where did this code come from?

    Comment

    • rampraveen
      New Member
      • Apr 2010
      • 37

      #3
      Originally posted by weaknessforcats
      I don't have a compiler old enough to compile thbs code.

      I havent't seen far pointers in 20 years. Where did this code come from?
      from one c graphics book..

      Comment

      • rampraveen
        New Member
        • Apr 2010
        • 37

        #4
        am using xp and intel motherboard..an y problems wit tat..

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          I am not able to compile this code so I can't analyse it for you. Sorry.

          Comment

          • rampraveen
            New Member
            • Apr 2010
            • 37

            #6
            Originally posted by weaknessforcats
            I am not able to compile this code so I can't analyse it for you. Sorry.
            it's k..i have one doubt in tat program..tat means in that top of the prgm we are using "char far *vidmem=0XB8000 000;"
            will u tell why we are using this..?,...thk u...

            Comment

            • weaknessforcats
              Recognized Expert Expert
              • Mar 2007
              • 9214

              #7
              vidmem is used in a calculation. The 0XB8000000 must have somethibng to do with the amount of video memory.

              The fact that vidmen is a char far* means the pointer is located outside the current code segment. For this to work you need a compiler old enough to use segmented memory models which went out of existence about 1990.

              Basically, I don't believe the code is going to work using any modern computer/compiler/video driver.

              Comment

              • drhowarddrfine
                Recognized Expert Expert
                • Sep 2006
                • 7434

                #8
                Originally posted by weaknessforcats
                vidmem is used in a calculation. The 0XB8000000 must have somethibng to do with the amount of video memory.

                The fact that vidmen is a char far* means the pointer is located outside the current code segment. For this to work you need a compiler old enough to use segmented memory models which went out of existence about 1990.

                Basically, I don't believe the code is going to work using any modern computer/compiler/video driver.
                gcc will. I'm pretty sure that video address is still used though I don't know how Windows would react to it. I still see assembly code passed around using that on the assembly forums I visit. I haven't paid attention to this stuff in a few years though.

                Comment

                • newb16
                  Contributor
                  • Jul 2008
                  • 687

                  #9
                  In real mode (including emulation of it in dos box in windows), 0xB800:0000 is the starting address of display buffer of cga (ega, vga) adapter in text mode. The problem is that write2vdu expects the text mode to be on, but initgraph puts the adapter into graphics mode.

                  Comment

                  • rampraveen
                    New Member
                    • Apr 2010
                    • 37

                    #10
                    thanks friends at last i got a correct output with windows xp also........thk you for all.......

                    Comment

                    Working...