custom mouse pointer in c graphics

C Graphics Add comments

In C graphics mode when you initialize the mouse you will can see a mouse pointer which is the default one like in windows. I thought of changing it and searched the books. i found a description in yeshavant kanetkar’s book c graphics. The explanation was very nice. I created a program name mice which with i generate various mouse pointers and i save it as a header file which has codes like the following.

Mice will allow you to save mouse pointers as .h file with any valid ms-dos file name.(you can find the mice program and its partial code in future from my home page links title probably “C Snippets”.

The following code used very long variable names just for the matter of understanding… so dont worry the actual code for this seems very tiny…

The shape structure has two type of data of the mouse bitmap. one for the the foreground and other for the transparency… that is cursor mask and screen mask…

When you’re designing the cursor mask, each bit is 1 if it is displayed,
and 0 if it is not. On the screen mask, bits that are 1 are transparent.

you can assume the concept of GIF file here…

	int shape [32] =
			{
				0xffff,0xffff,0xffff,0xffff,
				0xffff,0xffff,0xffff,0xffff,
				0xff3f,0xff3f,0xffff,0xffff,
				0xffff,0xffff,0xffff,0xffff,
				0xf00f,0x8001,0x8001,0x8001,
				0x0,0x0,0x0,0x180,
				0x180,0x0,0x0,0x0,
				0x8001,0x8001,0x8001,0xf00f
			};
 
//Call the function from main as change_mouse_pointer(shape);
 
void change_mouse_pointer(int *shape)
{
	union REGS inputregister,outputregister;
	struct SREGS segmentregister;
 
	inputregister.x.ax=0;
	int86(0x33,&inputregister,&outputregister);
	inputregister.x.ax=1;
	int86(0x33,&inputregister,&outputregister);
 
	inputregister.x.ax=9;
	inputregister.x.bx=0;
	inputregister.x.cx=0;
 
	inputregister.x.dx= (unsigned) shape;
	segread(&segmentregister);
	segmentregister.es=segmentregister.ds;
	int86x(0x33,&inputregister,&outputregister,&segmentregister);
}

and when i searched the net at the time of posting this code i found one good article titled Programming the Microsoft Mouse. but at this date the page was removed. The reason is to see how many such tutorials still exists these days because people almost forgot MS-DOS… but some still had like the universities and other c programmers reference links…

and a news about geocities is that yahoo is going to stop its free web hosting service… so better save a copy of the information whatever you see in geocities… 🙁

It has been a very long time since my programming with the MS-DOS mouse… anyway if good then enjoy…

Leave a Reply

Entries RSS