|
#1
|
|||
|
|||
Объяснить код
Объясните, пожалуйста, что делает эта программа? Пожалйста, в комментариях.
Код:
#include <graphics.h> // initgraph(), ... #include <conio.h> // getch(), kbhit(), gotoxy() #include <stdio.h> // printf() #include <dos.h> // intr() #include <D:\BC31\mousedsg.dat> unsigned NewCurs[32]; int HotPointX,HotPointY; void main() { for( int i=0; i<16; i++ ) { NewCurs[i] = (~MouseDsgn1[i]); NewCurs[i+16]= MouseDsgn1[i]; } HotPointX=(char)(MouseDsgn1[16]>>8); HotPointY=(char) MouseDsgn1[16]; struct REGPACK reg; reg.r_ax=0; intr(0x33,®); if (reg.r_ax == 0) { printf("............! Press any key to exit..."); getch(); return; } else { printf("............ %d .... ....!", reg.r_bx); getch(); } int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver,&gmode,"G:\\PROGRAMS\\BC31\\BGI"); if((errorcode = graphresult()) != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to exit..."); getch(); return; } reg.r_bx=HotPointX; reg.r_cx=HotPointY; reg.r_es=FP_SEG(&NewCurs); reg.r_dx=FP_OFF(&NewCurs); reg.r_ax=9; intr(0x33,®); reg.r_ax=1; intr(0x33,®); //.... int Xp = -1,Yp = -1; while (!kbhit()) //... { reg.r_ax=3; intr(0x33,®); //... gotoxy(1,1); printf("x =%3d y =%3d", reg.r_cx, reg.r_dx); //... if (reg.r_bx == 0) // { printf(" "); } else if( reg.r_bx == 1 ) { printf(" ... .... ... ....... "); setcolor(RED); reg.r_ax=2; intr(0x33,®); // . . . line(Xp, Yp, reg.r_cx, reg.r_dx); reg.r_ax=1; intr(0x33,®); // ... } else if( reg.r_bx == 2 ) { printf(" .... .... .... .... "); setcolor(GREEN); circle(reg.r_cx,reg.r_dx,3); } else if( reg.r_bx == 3 ) { printf(" ..... .... .... .... .... "); reg.r_ax=2; intr(0x33,®); // ... ; // ... reg.r_ax=1; intr(0x33,®); // ... } else printf(" UnKnown buttons combination...%d ",reg.r_bx); Xp = reg.r_cx; Yp = reg.r_dx; }//while closegraph(); } Код:
#include <graphics.h> // initgraph(), ... #include <conio.h> // getch(), kbhit(), gotoxy() #include <stdio.h> // printf() #include <dos.h> // intr() #include <bios.h> // bioskey() #define KB_ESC 0x011B #define KB_ENTER 0x1C0D #define KB_HOME 0x4700 #define KB_END 0x4F00 #define KB_BS 0x0E08 #define KB_TAB 0x0F09 #define KB_PLUS 0x4E2B #define KB_MINUS 0x4A2D #define KB_UPARROW 0x4800 #define KB_LEFTARROW 0x4B00 #define KB_RIGHTARROW 0x4D00 #define KB_DOWNARROW 0x5000 void main() { struct REGPACK reg; int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver, &gmode, "G:\\PROGRAMS\\BC31\\BGI"); reg.r_ax=0; intr(0x33,®); if (reg.r_ax == 0) { printf("............! Press any key to exit..."); getch(); return; } else { printf("............ %d .... ....!", reg.r_bx); getch(); } int FontSize=1; while( 1 ) { int CharWidth =textwidth ("_"); // ... int CharHeight=textheight("│"); // ... reg.r_ax=3; intr(0x33,®); if( bioskey(1) ) { int key = bioskey(0); if( key == KB_ESC ){ break; } else if(key == KB_LEFTARROW ) { reg.r_cx-=CharWidth; reg.r_ax=4; intr(0x33,®);} else if(key == KB_RIGHTARROW) { reg.r_cx+=CharWidth; reg.r_ax=4; intr(0x33,®);} else if(key == KB_UPARROW) { reg.r_dx-=CharHeight; reg.r_ax=4; intr(0x33,®);} else if(key == KB_DOWNARROW) { reg.r_dx+=CharHeight; reg.r_ax=4; intr(0x33,®);} else if(key == KB_HOME) { reg.r_cx = reg.r_dx = 0; reg.r_ax=4; intr(0x33,®);} else if(key == KB_END) { reg.r_cx = getmaxx() -CharWidth; reg.r_dx = getmaxy() -CharHeight; reg.r_ax =4; intr(0x33,®); } else if(key == KB_ENTER) { reg.r_cx = 0; reg.r_dx+=CharHeight; reg.r_ax =4; intr(0x33,®);} else if(key == KB_PLUS) { if(FontSize<3) settextstyle(0,HORIZ_DIR,++FontSize);} else if(key == KB_MINUS) { if(FontSize>0) settextstyle(0,HORIZ_DIR,--FontSize);} else { reg.r_ax=2; intr(0x33,®); char* s = "*"; s[0]=(char)key; outtextxy(Xp, Yp, s); reg.r_cx += CharWidth; reg.r_ax=4; intr(0x33,®); reg.r_ax=1; intr(0x33,®); // ... } } //if(bioskey(1)) } //while closegraph(); } |