Files
templates/ASMOUSE.CPP
Mark Zheleznyakov be2b9502d1 init
2024-09-07 08:49:36 +03:00

131 lines
3.3 KiB
C++
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/****************************************************************************
** <20>â  ¯à®£à ¬¬  ¤¥¬®­áâà¨àã¥â, ª ª ¬®¦­® ¤®¡¨âìáï ¢§ ¨¬®¤¥©á⢨ï á ¬ë誮©,**
** ¨á¯®«ì§ãï ++ ¨ €áᥬ¡«¥à. **
****************************************************************************/
#include <conio.h>
#include <stdio.h>
#include <dos.h>
#include <iostream.h>
//ƒ«®¡ «ì­ë¥ ¯¥à¥¬¥­­ë¥, åà ­ï騥 ª®®à¤¨­ âë ¨ ¯à¨§­ ª ­ ¦ â¨ï ­  ª­®¯ªã
//¬ëè¨.
unsigned int MouseX, MouseY, MouseB;
char IfMouse ();
void ShowMouse ();
void HideMouse ();
void ReadMouse ();
void SetMouseXY (unsigned int X, unsigned int Y);
void SetMinMaxX (unsigned int Min, unsigned int Max);
void SetMinMaxY (unsigned int Min, unsigned int Max);
//<2F>â  ¯à®æ¥¤ãà  ¯à®¢¥àï¥â ¤®áâ㯭  «¨ ¬ëèì
char IfMouse ()
{
unsigned int Result;
asm mov ax, 0
asm int 0x33
asm mov Result, ax
return Result;
}
//<2F>â  ¯à®æ¥¤ãà  ¤¥« ¥â ¢¨¤¨¬ë¬ ªãàá®à ¬ëè¨
void ShowMouse ()
{
asm mov ax, 0x1
asm int 0x33
}
//<2F>â  ¯à®æ¥¤ãà  ¤¥« ¥â ­¥¢¨¤¨¬ë¬ ªãàá®à ¬ëè¨
void HideMouse ()
{
asm mov ax, 0x2
asm int 0x33
}
//<2F>â  ¯à®æ¥¤ãà  áç¨â뢠¥â ¯®«®¦¥­¨¥ ªãàá®à  ¬ëè¨ ¨ ¯à¨§­ ª ­ ¦ â¨ï
//­  ª« ¢¨èã
void ReadMouse ()
{
asm mov ax, 0x3
asm int 0x33
asm mov MouseB, bx
asm mov MouseX, cx
asm mov MouseY, dx
}
//<2F>â  ¯à®æ¥¤ãà  ãáâ ­ ¢«¨¢ ¥â ªãàá®à ¢ ¤à㣨¥ ª®®à¤¨­ âë
void SetMouseXY (unsigned int X, unsigned int Y)
{
asm mov ax, 0x4
asm mov cx, X
asm mov dx, Y
asm int 0x33
}
//<2F>â  ¯à®æ¥¤ãà  ãáâ ­ ¢«¨¢ ¥â ¬¨­¨¬ «ì­®¥ ¨ ¬ ªá¨¬ «ì­®¥ §­ ç¥­¨¥
//£à ­¨æ ¯à®¬¥¦ã⪠, ¢ ª®â®à®¬ ¬®¦¥â ¤¢¨£ âìáï ªãàá®à ¬ëè¨
//¢ £®à¨§®­â «ì­®¬ ¯®«®¦¥­¨¨.
void SetMinMaxX (unsigned int Min, unsigned int Max)
{
asm mov ax, 0x7
asm mov cx, Min
asm mov dx, Max
asm int 0x33
}
//<2F>â  ¯à®æ¥¤ãà  ãáâ ­ ¢«¨¢ ¥â ¬¨­¨¬ «ì­®¥ ¨ ¬ ªá¨¬ «ì­®¥ §­ ç¥­¨¥
//£à ­¨æ ¯à®¬¥¦ã⪠, ¢ ª®â®à®¬ ¬®¦¥â ¤¢¨£ âìáï ªãàá®à ¬ëè¨
//¢ ¢¥à⨪ «ì­®¬ ¯®«®¦¥­¨¨.
void SetMinMaxY (unsigned int Min, unsigned int Max)
{
asm mov ax, 0x8
asm mov cx, Min
asm mov dx, Max
asm int 0x33
}
//ƒ« ¢­ ï ¯®£à ¬¬  - â¥áâ¨àã¥â ¬ëèì ¨ ¯à®æ¥¤ãàë ®¯¨á ­­ë¥ ¢ëè¥.
main(){
clrscr();
IfMouse();
cout<<"Œëèì ¤®áâ㯭  ¢ á¨á⥬¥.\n";
delay(3000);
cout<<"‘¥©ç á ¯®ï¢¨âáï ªãàá®à - § ¤¥à¦ª  3 ᥪ.\n";
delay(3000);
ShowMouse();
cout<<"‘¥©ç á ªãàá®à ¨á祧­¥â - § ¤¥à¦ª  3 ᥪ.\n";
delay(3000);
HideMouse();
cout<<"—¥à¥§ 3 ᥪ ªãàá®à ¯®ï¢¨âáï ¢­®¢ì.\n";
delay(3000);
ShowMouse();
ReadMouse();
cout<<"\nŠ®®à¤¨­ âë ¬ëè¨ ­  ¬®¬¥­â #1:\n";
cout<<"•-ª®®à¤¨­ â : "<<MouseX<<"\n";
cout<<"“-ª®®à¤¨­ â  "<<MouseY<<"\n";
delay(3000);
cout<<"—¥à¥§ 3 ᥪ ¯®¬¥­ï¥¬ ª®®à¤¨­ âë ¬ëè¨ ­  å=120 ¨ ã=120\n";
delay(3000);
SetMouseXY(120,120);
ReadMouse();
cout<<"\nŠ®®à¤¨­ âë ¬ëè¨ ­  ¬®¬¥­â #2:\n";
cout<<"•-ª®®à¤¨­ â : "<<MouseX<<"\n";
cout<<"“-ª®®à¤¨­ â  "<<MouseY<<"\n";
delay(3000);
cout<<"\n<EFBFBD> ¦¬¨â¥ ª« ¢¨èã ¬ëè¨.\n";
delay(3000);
ReadMouse();
//if ((MouseB&1)==1) cout<<"\nŠ« ¢¨è  ¬ëè¨ ­ ¦ â .";
if (MouseB==1) cout<<"\nŠ« ¢¨è  ¬ëè¨ ­ ¦ â .";
else cout<<"\nŠ« ¢¨è  ¬ëè¨ ­¥ ­ ¦ â .";
delay(3000);
cout<<"\n“áâ ­®¢¨¬ £à ­¨æë ¤¢¨¦¥­¨ï ¬ëè¨ ¯® íªà ­ã:\n";
cout<<"100<X<300\n";
cout<<"0<Y<10\n";
SetMinMaxX(100,300);
SetMinMaxY(0,10);
cout<<"\n„«ï § ¢¥à襭¨ï à ¡®âë ¯à®£à ¬¬ë ­ ¦¬¨â¥ «î¡ãî ª« ¢¨èã.\n";
getch();
return 0;
}