(16 Bit..DOS ONLY) C++ using Assembly BIOS interrupts, draw rectangle

Posts 1–10 of 10 · Page 1 of 1
(16 Bit..DOS ONLY) C++ using Assembly BIOS interrupts, draw rectangle

(if you see this jason, i scrapped the old one i talked about on msn, seems like the old compiler wasn't compliant with today's standards, so i just scrapped it all)

Took me about 1 and a half hours to code.

not finished yet, still need to add fill rect..

Rectangle class is in the cpp file because i couldn't figure out how to add header files in TurboC++ DOS IDE

Pictures


Code

Code:
/* 
Coded by Patrick(Virtual Void)
May 26, 2011
thank my post /fmm
*/

#include <iostream.h>
#include <dos.h>
#define VID_SEG 0xA000
/* VID_SEG is the video segment */

void SetVideoMode13h()
{
	_AH = 0;
	_AL = 0x13; //Video mode
	geninterrupt(0x10);//generate interrupt 10h
}

void SetTextMode()
{
	_AH = 0;
	_AL = 0x03; //text mode
	geninterrupt(0x010); //generate int 10h
}

void DrawPixel(int x, int y, unsigned char Color)
{
	pokeb(VID_SEG, (y * 320) + x, Color); //320 is the screen width in 0x13 VGA mode
}

void DrawRect(int Top_Left_X,int Top_Left_Y, int Width, int Height, unsigned char Colour)
{
	DrawPixel(Top_Left_X, Top_Left_Y, Colour);

	int Bottom_Left_X = Top_Left_X;
	int Bottom_Left_Y = Top_Left_Y + Height;

	DrawPixel(Bottom_Left_X, Bottom_Left_Y, Colour);

	int Top_Right_X = Top_Left_X + Width;
	int Top_Right_Y = Top_Left_Y;

	DrawPixel(Top_Right_X, Top_Right_Y, Colour);

	int Bottom_Right_X = Top_Right_X;
	int Bottom_Right_Y = Top_Right_Y + Height;

	DrawPixel(Bottom_Right_X, Bottom_Right_Y, Colour);

	int t_x, b_x, l_y, r_y; // top x, bottom x, left y, right y, connect point

	// the equal signs show what side is drawn

	for(t_x = Top_Left_X; t_x <= Top_Right_X; t_x++) //  ======
	{                                               //   |    |
		DrawPixel(t_x, Top_Left_Y, Colour);    //    |    |
	}                                             //     |____|

	for(b_x = Bottom_Left_X; b_x <= Bottom_Right_X; b_x++) //  _____
	{                                                     //   |   |
		DrawPixel(b_x, Bottom_Left_Y, Colour);       //    |   |
	}                                                   //     =====
	
	for(l_y = Top_Left_Y; l_y <= Bottom_Left_Y; l_y++)   //   _____
	{                                                   //    =   |
		DrawPixel(Top_Left_X, l_y, Colour);        //     =   |
	}                                                 //      =___|
	
	for(r_y = Top_Right_Y; r_y <= Bottom_Left_Y; r_y++) //   _____
	{                                                  //    |   =
		DrawPixel(Top_Right_X, r_y, Colour);      //     |   =
	}                                                //      |___=

}


class Rectangle
{
	public:
	Rectangle(int Height_,int Width_,int TopLeftX_, int TopLeftY_,unsigned char color_) 
	{
		Height = Height_;
		Width = Width_;
		TopLeftX = TopLeftX_;
		TopLeftY = TopLeftY_;
		color = color_;
	}
	~Rectangle(){}
	//Rectangle attributes

	unsigned char color;

	int Height;
	int Width;

	int TopLeftX;
	int TopLeftY;

};


int main()
{
	cout << "Enter the Rect's:\nTop left X coord\nTop left Y coord\nWidth\nHeight\nColor(to 255)\nFill 1 or 0\n";
	//Just don't make anything cause a rect to be > 319,199, max res

	int tlx, tly, wid, hei;
	unsigned char col;

	cin >> tlx >> tly >> wid >> hei >> col;
	Rectangle rect(hei,wid,tlx,tly,col);

	cout << "Set Rect's attributes successfully. Press Enter for Rect\n";

	cin.ignore();
	cin.get();

	SetVideoMode13h();

	DrawRect(rect.TopLeftX,rect.TopLeftY,rect.Width,rect.Height,rect.color);

	cin.ignore();
	cin.get();
        rect.~Rectangle();
	SetTextMode();
	return 0;
}
Patrick whys your gender set to female while your name is Patrick?
Is it some kind of New-Age-cool thing? I don't get it.
Quote Originally Posted by VirtualDUDE View Post
Patrick whys your gender set to female while your name is Patrick?
Is it some kind of New-Age-cool thing? I don't get it.
He likes it.
Now please shut up or stay on topic.
Quote Originally Posted by VirtualDUDE View Post
Patrick whys your gender set to female while your name is Patrick?
Is it some kind of New-Age-cool thing? I don't get it.
used to troll that i was a girl
Quote Originally Posted by Auxilium View Post


used to troll that i was a girl
I actually know a girl called patric
Quote Originally Posted by Nathan View Post


I actually know a girl called patric
I know one called Patricia Yay..

People on the ********* think being of the female gender will bring them more attention / love / w.e from people, Which is in fact true considering people get all woozy and "Prove you are a Woman" ; Hence why I enjoy saying "Then prove you are a Man, Not just a stupid Dick".

@V.Void
Haha Cute Work.
Quote Originally Posted by Melodia View Post


I know one called Patricia Yay..

People on the ********* think being of the female gender will bring them more attention / love / w.e from people, Which is in fact true considering people get all woozy and "Prove you are a Woman" ; Hence why I enjoy saying "Then prove you are a Man, Not just a stupid Dick".

@V.Void
Haha Cute Work.
I never knew you were a woman.
Quote Originally Posted by Nathan View Post


I never knew you were a woman.
What is it supposed to change ?
Quote Originally Posted by Melodia View Post


What is it supposed to change ?
Nothing. I wasn't implying anything right?
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us