box in assembly to c

This is a discussion on box in assembly to c within the C Programming forums, part of the General Programming Boards category; Does anyone know how to draw a box in c? I need to draw a box asking for the coordinates. ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    14

    box in assembly to c

    Does anyone know how to draw a box in c? I need to draw a box asking for the coordinates. This code should be converted from assembly to c code? Right now I am only getting the line to be drawn when I use the code below.

    Code:
    void drawBox(int x1, int y1, int x2, int y2, int color)
    {
    	int exit1, exit2;
    
    
    	exit1 = 0;
    	exit2 = 0;
    
    
    	regin.x.dx = x1;
    	
    	while(exit1 == 0)
    	{
    		regin.x.cx = y1;
    
    		while(exit2 == 0)
    		{
    			regin.h.ah = 0x0C;
    			regin.h.al = color;
    			int86(0x10, &regin, &regout);
    
    			regin.x.cx = regin.x.cx + 1;
    
    			if(regin.x.cx >= y2)
    				exit2 = 1;
    		}
    
    		
    		regin.x.dx = regin.x.dx + 1;
    
    		if(regin.x.dx >= x2)
    			exit1 = 1;
    	}
    }

  2. #2
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    i didnt checked the whole code but the following code is merely a suggestion
    Code:
    int setpix(int color, int x,int y)
    {
    	union REGS regs;
    
    	regs.h.ah = 0x0C;  /* function 0Ch = pixel plot */
    	regs.h.al = color;
    	regs.x.cx = x;     /* x location, from 0..319  */
    	regs.x.dx = y;     /* y location, from 0..199  */
    	int86(0x10, & regs, & regs);
    	return 0;
    	}
    im assuming u want to draw the box in 13H mode so this would be perfect for u so instead of always using the interrupts use the setpix function to plot one pixel at a certain x and y c
    i one did a box so im gonna check my .c files to see if i still got it

  3. #3
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    oke i know this is sucky code but hey i did this a time ago when my programming skills werent as good as they r now
    to draw a box use this function
    Code:
    int vierkant(int size,int x,int y,int color)
    {
    	int i,beginx,eindex,eindey;
    	beginx=x;
    	for(i=0;i<size;i++){
    
    							  x=x+1;
    							  setpix(color,x,y);
    							  }
    	eindex=x;
    	for(i=0;i<eindex-beginx;i++){
    
    							  y=y-1;
    							  setpix(color,x,y);
    							  }
    	eindey=y;
    	for(i=0;i<size;i++){
    
    							  x=beginx;
    							  y=y+1;
    							  setpix(color,x,y);
    							  }
    
    	do{
    		for(i=0;i<size;i++){
    
    								  x=beginx;
    								  setpix(color,x,eindey);
    								  }
    		beginx=beginx+1;
    		}
    	while(beginx<eindex+1);
    	return 0;
    	}
    after that u can do something like this in int main()
    Code:
    for(i=0;i<120;i++){
    							vierkant(20,220-i,30+i,4);
    							delay(10);
    							}
    PS if the code for the box doesnt work PM me coz i have another "box" function but im not sure wich one is the correct one and im too lazy to compile and see wich is the right "box" function
    edit:: sry bout the indentations guess i still dont have right control over ctrl-c and ctrl-v

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    14

    graphics?

    I forgot to say that I am not supposed to use the graphics library. So I was wondering if the setpix function was in the graphics library?

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    14

    thanks

    I figured it out it seems to work great.

    Thanks,
    JW

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 01:59 PM
  2. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  3. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 07:00 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. C,C++,Perl,Java
    By brusli in forum C Programming
    Replies: 9
    Last Post: 12-31-2001, 02:35 AM

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