Module: E:\SOURCE\TMP\MOUSE.CPP Group: 'DGROUP' CONST,CONST2,_DATA,_BSS Segment: _TEXT WORD 0000031f bytes #include #include #include #include int MouseResetDriver(int *buttons) { REGS regs; 0000 int near MouseResetDriver( int near * ): 0000 50 push ax 0001 b8 18 00 mov ax,0018H 0004 e8 00 00 call __STK 0007 58 pop ax 0008 53 push bx 0009 52 push dx 000a 56 push si 000b 55 push bp 000c 89 e5 mov bp,sp 000e 83 ec 0e sub sp,000eH 0011 89 c6 mov si,ax regs.x.ax = 0x0000; 0013 c7 46 f2 00 00 mov word ptr -0eH[bp],0000H int86(0x33, ®s,®s); 0018 8d 5e f2 lea bx,-0eH[bp] 001b 8d 56 f2 lea dx,-0eH[bp] 001e b8 33 00 mov ax,0033H 0021 e8 00 00 call int86_ if(regs.x.ax==0) return -1; //mouse not present 0024 83 7e f2 00 cmp word ptr -0eH[bp],0000H 0028 75 05 jne L1 002a b8 ff ff mov ax,0ffffH 002d eb 2c jmp L7 if(buttons) { switch(regs.x.bx) { 002f 85 f6 L1 test si,si 0031 75 0e jne L4 0033 eb 24 jmp L6 case 0x0002: *buttons = 2; break; 0035 c7 04 02 00 L2 mov word ptr [si],0002H 0039 eb 1e jmp L6 case 0x0003: *buttons = 3; break; case 0xffff: *buttons = 2; break; case 0x0000: //other than two default: *buttons = 1; } } 003b c7 04 03 00 L3 mov word ptr [si],0003H 003f eb 18 jmp L6 0041 83 7e f4 02 L4 cmp word ptr -0cH[bp],0002H 0045 72 0e jb L5 0047 76 ec jbe L2 0049 83 7e f4 03 cmp word ptr -0cH[bp],0003H 004d 76 ec jbe L3 004f 83 7e f4 ff cmp word ptr -0cH[bp],0ffffH 0053 74 e0 je L2 0055 c7 04 01 00 L5 mov word ptr [si],0001H return 0; 0059 31 c0 L6 xor ax,ax } 005b 89 ec L7 mov sp,bp 005d 5d pop bp 005e 5e pop si 005f 5a pop dx 0060 5b pop bx 0061 c3 ret int MouseShowCursor(void) { REGS regs; 0062 int near MouseShowCursor(): 0062 b8 16 00 mov ax,0016H 0065 e8 00 00 call __STK 0068 53 push bx 0069 52 push dx 006a 55 push bp 006b 89 e5 mov bp,sp 006d 83 ec 0e sub sp,000eH regs.x.ax = 0x0001; 0070 c7 46 f2 01 00 mov word ptr -0eH[bp],0001H int86(0x33, ®s,®s); return 0; //always succesfull 0075 8d 5e f2 L8 lea bx,-0eH[bp] 0078 8d 56 f2 lea dx,-0eH[bp] 007b b8 33 00 mov ax,0033H 007e e8 00 00 call int86_ } 0081 31 c0 xor ax,ax 0083 89 ec mov sp,bp 0085 5d pop bp 0086 5a pop dx 0087 5b pop bx 0088 c3 ret int MouseHideCursor(void) { REGS regs; 0089 int near MouseHideCursor(): 0089 b8 16 00 mov ax,0016H 008c e8 00 00 call __STK 008f 53 push bx 0090 52 push dx 0091 55 push bp 0092 89 e5 mov bp,sp 0094 83 ec 0e sub sp,000eH regs.x.ax = 0x0002; int86(0x33, ®s,®s); return 0; //always succesfull } 0097 c7 46 f2 02 00 mov word ptr -0eH[bp],0002H 009c eb d7 jmp L8 int MouseQueryPosition(int *column, int *row) { REGS regs; 009e int near MouseQueryPosition( int near *, int near * ): 009e 50 push ax 009f b8 18 00 mov ax,0018H 00a2 e8 00 00 call __STK 00a5 58 pop ax 00a6 53 push bx 00a7 56 push si 00a8 57 push di 00a9 55 push bp 00aa 89 e5 mov bp,sp 00ac 83 ec 0e sub sp,000eH 00af 89 c6 mov si,ax 00b1 89 d7 mov di,dx regs.x.ax = 0x0003; 00b3 c7 46 f2 03 00 mov word ptr -0eH[bp],0003H int86(0x33, ®s,®s); 00b8 8d 5e f2 lea bx,-0eH[bp] 00bb 8d 56 f2 lea dx,-0eH[bp] 00be b8 33 00 mov ax,0033H 00c1 e8 00 00 call int86_ *column = (int)regs.x.cx; 00c4 8b 46 f6 mov ax,-0aH[bp] 00c7 89 04 mov [si],ax *row = (int)regs.x.dx; return 0; 00c9 8b 46 f8 mov ax,-8H[bp] 00cc 89 05 mov [di],ax } 00ce 31 c0 xor ax,ax 00d0 89 ec mov sp,bp 00d2 5d pop bp 00d3 5f pop di 00d4 5e pop si 00d5 5b pop bx 00d6 c3 ret int MouseQueryButtonStatus(int *buttons) { REGS regs; 00d7 int near MouseQueryButtonStatus( int near * ): 00d7 50 push ax 00d8 b8 18 00 mov ax,0018H 00db e8 00 00 call __STK 00de 58 pop ax 00df 53 push bx 00e0 52 push dx 00e1 56 push si 00e2 55 push bp 00e3 89 e5 mov bp,sp 00e5 83 ec 0e sub sp,000eH 00e8 89 c6 mov si,ax regs.x.ax = 0x0003; 00ea c7 46 f2 03 00 mov word ptr -0eH[bp],0003H int86(0x33, ®s,®s); 00ef 8d 5e f2 lea bx,-0eH[bp] 00f2 8d 56 f2 lea dx,-0eH[bp] 00f5 b8 33 00 mov ax,0033H 00f8 e8 00 00 call int86_ *buttons = (int)regs.x.bx; return 0; } 00fb 8b 46 f4 mov ax,-0cH[bp] 00fe 89 04 mov [si],ax 0100 e9 56 ff jmp L6 int MouseSetPosition(int column, int row) { REGS regs; 0103 int near MouseSetPosition( int, int ): 0103 50 push ax 0104 b8 14 00 mov ax,0014H 0107 e8 00 00 call __STK 010a 58 pop ax 010b 53 push bx 010c 55 push bp 010d 89 e5 mov bp,sp 010f 83 ec 0e sub sp,000eH regs.x.ax = 0x0004; 0112 c7 46 f2 04 00 mov word ptr -0eH[bp],0004H regs.x.cx = column; 0117 89 46 f6 L9 mov -0aH[bp],ax regs.x.dx = row; 011a 89 56 f8 mov -8H[bp],dx int86(0x33, ®s,®s); return 0; 011d 8d 5e f2 lea bx,-0eH[bp] 0120 8d 56 f2 lea dx,-0eH[bp] 0123 b8 33 00 mov ax,0033H 0126 e8 00 00 call int86_ } 0129 31 c0 xor ax,ax 012b 89 ec mov sp,bp 012d 5d pop bp 012e 5b pop bx 012f c3 ret int MouseSetRange(int mincolumn, int minrow, int maxcolumn, int maxrow) { REGS regs; 0130 int near MouseSetRange( int, int, int, int ): 0130 50 push ax 0131 b8 14 00 mov ax,0014H 0134 e8 00 00 call __STK 0137 58 pop ax 0138 56 push si 0139 55 push bp 013a 89 e5 mov bp,sp 013c 83 ec 0e sub sp,000eH 013f 89 d6 mov si,dx regs.x.ax = 0x0007; 0141 c7 46 f2 07 00 mov word ptr -0eH[bp],0007H regs.x.cx = mincolumn; 0146 89 46 f6 mov -0aH[bp],ax regs.x.dx = maxcolumn; 0149 89 5e f8 mov -8H[bp],bx int86(0x33, ®s,®s); 014c 8d 5e f2 lea bx,-0eH[bp] 014f 8d 56 f2 lea dx,-0eH[bp] 0152 b8 33 00 mov ax,0033H 0155 e8 00 00 call int86_ regs.x.ax = 0x0008; 0158 c7 46 f2 08 00 mov word ptr -0eH[bp],0008H regs.x.cx = minrow; 015d 89 76 f6 mov -0aH[bp],si regs.x.dx = maxrow; 0160 89 4e f8 mov -8H[bp],cx int86(0x33, ®s,®s); return 0; 0163 8d 5e f2 lea bx,-0eH[bp] 0166 8d 56 f2 lea dx,-0eH[bp] 0169 b8 33 00 mov ax,0033H 016c e8 00 00 call int86_ } 016f 31 c0 xor ax,ax 0171 89 ec mov sp,bp 0173 5d pop bp 0174 5e pop si 0175 c3 ret int MouseSetGraphicsCursor(int hotspotcolumn, int hotspotrow, void *mask) { REGS regs; SREGS sregs; 0176 int near MouseSetGraphicsCursor( int, int, void near * ): 0176 50 push ax 0177 b8 20 00 mov ax,0020H 017a e8 00 00 call __STK 017d 58 pop ax 017e 51 push cx 017f 56 push si 0180 57 push di 0181 55 push bp 0182 89 e5 mov bp,sp 0184 83 ec 16 sub sp,0016H 0187 89 c6 mov si,ax 0189 89 d1 mov cx,dx 018b 89 df mov di,bx memset(&sregs,0,sizeof(sregs)); 018d bb 08 00 mov bx,0008H 0190 31 d2 xor dx,dx 0192 8d 46 f8 lea ax,-8H[bp] 0195 e8 00 00 call memset_ regs.x.ax = 0x0009; 0198 c7 46 ea 09 00 mov word ptr -16H[bp],0009H regs.x.bx = hotspotcolumn; 019d 89 76 ec mov -14H[bp],si regs.x.cx = hotspotrow; 01a0 89 4e ee mov -12H[bp],cx sregs.es = FP_SEG(mask); 01a3 8c 5e f8 mov -8H[bp],ds regs.x.dx = FP_OFF(mask); 01a6 89 7e f0 mov -10H[bp],di int86x(0x33,®s,®s,&sregs); return 0; 01a9 8d 4e f8 lea cx,-8H[bp] 01ac 8d 5e ea lea bx,-16H[bp] 01af 8d 56 ea lea dx,-16H[bp] 01b2 b8 33 00 mov ax,0033H 01b5 e8 00 00 call int86x_ } 01b8 31 c0 xor ax,ax 01ba 89 ec mov sp,bp 01bc 5d pop bp 01bd 5f pop di 01be 5e pop si 01bf 59 pop cx 01c0 c3 ret int MouseSetTextCursor(int andmask,int xormask) { REGS regs; 01c1 int near MouseSetTextCursor( int, int ): 01c1 50 push ax 01c2 b8 14 00 mov ax,0014H 01c5 e8 00 00 call __STK 01c8 58 pop ax 01c9 53 push bx 01ca 55 push bp 01cb 89 e5 mov bp,sp 01cd 83 ec 0e sub sp,000eH regs.x.ax = 0x000a; 01d0 c7 46 f2 0a 00 mov word ptr -0eH[bp],000aH regs.x.bx = 0x0000; //software cursor regs.x.cx = andmask; regs.x.dx = xormask; int86(0x33,®s,®s); return 0; } 01d5 c7 46 f4 00 00 mov word ptr -0cH[bp],0000H 01da e9 3a ff jmp L9 int MouseSetCallback(void __far *pf) { REGS regs; SREGS sregs; 01dd int near MouseSetCallback( void far * ): 01dd 50 push ax 01de b8 20 00 mov ax,0020H 01e1 e8 00 00 call __STK 01e4 58 pop ax 01e5 53 push bx 01e6 51 push cx 01e7 56 push si 01e8 55 push bp 01e9 89 e5 mov bp,sp 01eb 83 ec 16 sub sp,0016H 01ee 89 c1 mov cx,ax 01f0 89 d6 mov si,dx memset(&sregs,0,sizeof(sregs)); 01f2 bb 08 00 mov bx,0008H 01f5 31 d2 xor dx,dx 01f7 8d 46 f8 lea ax,-8H[bp] 01fa e8 00 00 call memset_ regs.x.ax = 0x000c; 01fd c7 46 ea 0c 00 mov word ptr -16H[bp],000cH regs.x.cx = 0x007f; 0202 c7 46 ee 7f 00 mov word ptr -12H[bp],007fH sregs.es = FP_SEG(pf); 0207 89 76 f8 mov -8H[bp],si regs.x.dx = FP_OFF(pf); 020a 89 4e f0 mov -10H[bp],cx int86x(0x33, ®s,®s,&sregs); return 0; 020d 8d 4e f8 lea cx,-8H[bp] 0210 8d 5e ea lea bx,-16H[bp] 0213 8d 56 ea lea dx,-16H[bp] 0216 b8 33 00 mov ax,0033H 0219 e8 00 00 call int86x_ } 021c 31 c0 xor ax,ax 021e 89 ec mov sp,bp 0220 5d pop bp 0221 5e pop si 0222 59 pop cx 0223 5b pop bx 0224 c3 ret int MouseUnsetCallback(void) { REGS regs; SREGS sregs; 0225 int near MouseUnsetCallback(): 0225 b8 20 00 mov ax,0020H 0228 e8 00 00 call __STK 022b 53 push bx 022c 51 push cx 022d 52 push dx 022e 55 push bp 022f 89 e5 mov bp,sp 0231 83 ec 16 sub sp,0016H memset(&sregs,0,sizeof(sregs)); 0234 bb 08 00 mov bx,0008H 0237 31 d2 xor dx,dx 0239 8d 46 f8 lea ax,-8H[bp] 023c e8 00 00 call memset_ regs.x.ax = 0x000c; 023f c7 46 ea 0c 00 mov word ptr -16H[bp],000cH regs.x.cx = 0x0000; 0244 c7 46 ee 00 00 mov word ptr -12H[bp],0000H sregs.es = 0; 0249 c7 46 f8 00 00 mov word ptr -8H[bp],0000H regs.x.dx = 0; 024e c7 46 f0 00 00 mov word ptr -10H[bp],0000H int86x(0x33, ®s,®s,&sregs); return 0; 0253 8d 4e f8 lea cx,-8H[bp] 0256 8d 5e ea lea bx,-16H[bp] 0259 8d 56 ea lea dx,-16H[bp] 025c b8 33 00 mov ax,0033H 025f e8 00 00 call int86x_ } 0262 31 c0 xor ax,ax 0264 89 ec mov sp,bp 0266 5d pop bp 0267 5a pop dx 0268 59 pop cx 0269 5b pop bx 026a c3 ret int MouseSetUpdateRegion(int mincolumn, int minrow, int maxcolumn, int maxrow) { REGS regs; 026b int near MouseSetUpdateRegion( int, int, int, int ): 026b 50 push ax 026c b8 12 00 mov ax,0012H 026f e8 00 00 call __STK 0272 58 pop ax 0273 55 push bp 0274 89 e5 mov bp,sp 0276 83 ec 0e sub sp,000eH regs.x.ax = 0x0010; 0279 c7 46 f2 10 00 mov word ptr -0eH[bp],0010H regs.x.cx = mincolumn; 027e 89 46 f6 mov -0aH[bp],ax regs.x.dx = minrow; 0281 89 56 f8 mov -8H[bp],dx regs.x.si = maxcolumn; 0284 89 5e fa mov -6H[bp],bx regs.x.di = maxrow; 0287 89 4e fc mov -4H[bp],cx int86(0x33, ®s,®s); return 0; 028a 8d 5e f2 lea bx,-0eH[bp] 028d 8d 56 f2 lea dx,-0eH[bp] 0290 b8 33 00 mov ax,0033H 0293 e8 00 00 call int86_ } volatile int buttonState; volatile int column; volatile int row; volatile int a; #pragma off(check_stack); /* void mouseProlog(void); #pragma aux mouseProlog = \ "push ds" \ "push ax" \ "mov ax,seg buttonState" \ "mov ds,ax" \ "mov ds:[buttonState],bx" \ "mov ds:[column],cx" \ "mov ds:[row],dx" \ "pop ax" \ "pop ds" \ modify []; void __far __saveregs __cdecl MyCallback(void) { mouseProlog(); } */ 0296 31 c0 xor ax,ax 0298 89 ec mov sp,bp 029a 5d pop bp 029b c3 ret void __loadds __far __saveregs MyCallback(int ax, int bx, int cx, int dx) { #pragma aux MyCallback parm [ax] [bx] [cx] [dx]; 029c void far MyCallback( int, int, int, int ): 029c 1e push ds 029d 50 push ax 029e b8 00 00 mov ax,seg L14 02a1 8e d8 mov ds,ax 02a3 58 pop ax buttonState = bx; 02a4 89 1e 00 00 mov int volatile near buttonState,bx column = cx; 02a8 89 0e 00 00 mov int volatile near column,cx row = dx; 02ac 89 16 00 00 mov int volatile near row,dx a=ax; 02b0 a3 00 00 mov int volatile near a,ax } 02b3 1f pop ds 02b4 cb retf void main(void) { 02b5 52 main_ push dx 02b6 55 push bp 02b7 89 e5 mov bp,sp 02b9 83 ec 04 sub sp,0004H if(MouseResetDriver(0)) return; 02bc 31 c0 xor ax,ax 02be e8 00 00 call int near MouseResetDriver( int near * ) 02c1 85 c0 test ax,ax 02c3 75 55 jne L13 MouseShowCursor(); 02c5 e8 00 00 call int near MouseShowCursor() MouseSetTextCursor(0x7fff,0x7f00); 02c8 ba 00 7f mov dx,7f00H 02cb b8 ff 7f mov ax,7fffH 02ce e8 00 00 call int near MouseSetTextCursor( int, int ) MouseSetCallback((void __far*)MyCallback); 02d1 b8 00 00 mov ax,offset void far MyCallback( int, int, int, int ) 02d4 ba 00 00 mov dx,seg void far MyCallback( int, int, int, int ) 02d7 e8 00 00 call int near MouseSetCallback( void far * ) while(!kbhit()) { int c,r; 02da e8 00 00 L10 call kbhit_ 02dd 85 c0 test ax,ax 02df 75 27 jne L11 MouseQueryPosition(&c,&r); 02e1 8d 56 fe lea dx,-2H[bp] 02e4 8d 46 fc lea ax,-4H[bp] 02e7 e8 00 00 call int near MouseQueryPosition( int near *, int near * ) cprintf("(%d,%d) (%d,%d) %04x \r",c,r,column,row,buttonState); 02ea a1 00 00 mov ax,int volatile near buttonState 02ed 50 push ax 02ee a1 00 00 mov ax,int volatile near row 02f1 50 push ax 02f2 a1 00 00 mov ax,int volatile near column 02f5 50 push ax 02f6 ff 76 fe push -2H[bp] 02f9 ff 76 fc push -4H[bp] 02fc b8 00 00 mov ax,offset L14 02ff 50 push ax 0300 e8 00 00 call cprintf_ 0303 83 c4 0c add sp,000cH } 0306 eb d2 jmp L10 MouseUnsetCallback(); 0308 e8 00 00 L11 call int near MouseUnsetCallback() MouseHideCursor(); 030b e8 00 00 call int near MouseHideCursor() while(kbhit()) getch(); 030e e8 00 00 L12 call kbhit_ 0311 85 c0 test ax,ax 0313 74 05 je L13 0315 e8 00 00 call getch_ 0318 eb f4 jmp L12 } 031a 89 ec L13 mov sp,bp 031c 5d pop bp 031d 5a pop dx 031e c3 ret No disassembly errors ------------------------------------------------------------ Segment: CONST WORD 0000001a bytes 0000 28 25 64 2c 25 64 29 20 L14 - (%d,%d) 0008 28 25 64 2c 25 64 29 20 - (%d,%d) 0010 25 30 34 78 20 20 20 20 - %04x 0018 0d 00 - .. No disassembly errors ------------------------------------------------------------ Segment: _BSS WORD 00000008 bytes No disassembly errors ------------------------------------------------------------