INT 33h AX=0002h removes the pointer from the screen, restoring what was under it, and subtracts 1 from the visibility counter. The driver keeps tracking the mouse while it is hidden: positions and buttons from INT 33h AX=0003h stay correct and an event handler is still called.
Its main use is protecting the screen. The driver draws the pointer by saving the pixels or the character cell under it and putting them back when the pointer moves. If the program draws into that area meanwhile, the driver's "restore" puts back old contents over the new drawing, leaving a hole the shape of the pointer. So drawing code wraps itself in hide and show:
MOV AX, 0002h ; hide the pointerINT 33h; ... write to the screen: text, pixels, a scroll ...MOV AX, 0001h ; and show it againINT 33h
Because it is a counter, nested routines can each hide and show without breaking the outer one. Hiding twice needs two shows:
XOR AX, AX ; reset: hidden, counter -1INT 33hMOV AX, 0001h ; show: 0, visibleINT 33hMOV AX, 0002h ; hide: -1INT 33hMOV AX, 0002h ; hide again: -2INT 33hCALL COUNTER1 ; FEMOV AX, 0001h ; one show is not enough: -1INT 33hCALL COUNTER1 ; FFMOV AX, 0001h ; the second one shows it: 0INT 33hCALL COUNTER1 ; 00MOV AX, 0002h ; leave it hidden, as a reset wouldINT 33hCOUNTER1 PROC NEAR ; print the cursor counter: 00 shown, FF, FE... hiddenMOV AX, 002Ah ; mouse (driver 7.02+): AL = the counterINT 33hCALL PHEX2MOV DL, " "MOV AH, 02hINT 21hRETCOUNTER1 ENDPPHEX2 PROC NEAR ; print AL as two hex digits; keeps every registerPUSH AXPUSH CXPUSH DXMOV DH, AL ; keep the byteMOV CL, 4SHR AL, CL ; the high nibbleCALL HEXN1MOV AL, DHAND AL, 0Fh ; the low nibbleCALL HEXN1POP DXPOP CXPOP AXRETHEXN1:ADD AL, "0"CMP AL, "9"JBE HEXN2ADD AL, 7 ; past "9": "A".."F"HEXN2:MOV DL, ALMOV AH, 02hINT 21hRETPHEX2 ENDP
Pitfalls
Every hide needs its show; a forgotten show leaves the pointer invisible for good, and the user has no idea why. Hiding and showing for every character printed makes the pointer flicker; hide once around a whole redraw. Drivers since version 4 also offer AX=0010h, which hides the pointer only while it is inside a given rectangle, for programs that update one area often.