INT 33 Graphics Pointer Shape
Format type | Image |
---|---|
Hardware | CGA, EGA, VGA |
Colour depth | 2-bit (AND and XOR mask) |
Minimum size (pixels) | 16×16 |
Maximum size (pixels) | 16×16 |
Palette | Shared |
Plane count | 2 |
Transparent pixels? | Yes |
Hitmap pixels? | Yes |
Games |
The INT 33 Graphics Pointer Shape defines the appearance of the mouse pointer when functioning on a graphics-mode screen. DOS mouse support is enabled through the Interrupt 0x33 cpu instruction. Specifically, the mouse cursor graphics are set by sending INT 0x33 with argument AX = 0x0009[1].
Format
The graphics of the cursor are given in a pointer stored in ES:DX when executing the "Set Graphics Pointer Shape" instruction.
The data at that pointer should be 64 bytes long; two sets of 32 bytes. Each set of 32 bytes is organized as 16×16 bits, as 16 rows of 2-byte values. Since these rows are seen as UINT16LE, the two bytes to read per row should be reversed to be interpreted as a single value before they are used as bits. The actual graphics are drawn using the highest bits for the leftmost pixels, so ordered as a human-readable binary number visualisation of the Int16 value.
The first set of 32 bytes defines the "AND mask"; that is, the background will show through wherever there is a 1-bit in that data.
The second set defines the "XOR mask"; that is, after the "AND mask" has cleared out some of the background, the pixels matching the 1-bits in this data set are toggled.
In practice, this means that if the data is seen as a 2-bit graphics-planar image, where the first plane is considered the low bit, and the second plane the high bit, the resulting four values on the images have the following meaning:
- 0: Background is cleared
- 1: Background is not cleared (Transparent)
- 2: Background is cleared and inverted
- 3: Background is inverted
The effect of index 1 is clear; the background is preserved. The effect of values 0, 2 and 3 will depend on the graphics mode and the colour palette. In general, though, they will respectively be the colour at palette index 0, the colour at the very last palette index, and whatever colour happens to be on the palette at the index made from the inverted value of the overlapped background pixel.
As an example, here are the 6 mouse cursors found in the exe file of King Arthur's K.O.R.T. visualised with the above values as respectively black, fuchsia, white and red:
Sample decoding
Here you see a sample decoding of the AND and XOR masks of the sword cursor from King Arthur's KORT. In the decoded versions, 1 has been replaced by X
, and 0 by .
for better visualisation.
AND Mask
Data:
FF 8F FF 07 FF 03 FF 01 FB 80 71 C0 31 E0 11 F0 01 F8 03 FC 07 FE 03 FF 01 F8 20 F0 70 F8 F9 FF
Decoded:
8FFF X...XXXXXXXXXXXX 07FF .....XXXXXXXXXXX 03FF ......XXXXXXXXXX 01FF .......XXXXXXXXX 80FB X.......XXXXX.XX C071 XX.......XXX...X E031 XXX.......XX...X F011 XXXX.......X...X F801 XXXXX..........X FC03 XXXXXX........XX FE07 XXXXXXX......XXX FF03 XXXXXXXX......XX F801 XXXXX..........X F020 XXXX......X..... F870 XXXXX....XXX.... FFF9 XXXXXXXXXXXXX..X
XOR Mask
Data:
00 00 00 70 00 78 00 5C 00 2E 04 17 84 0B C4 05 EC 02 78 01 B0 00 68 00 D4 00 8A 07 04 00 00 00
Decoded:
0000 ................ 7000 .XXX............ 7800 .XXXX........... 5C00 .X.XXX.......... 2E00 ..X.XXX......... 1704 ...X.XXX.....X.. 0B84 ....X.XXX....X.. 05C4 .....X.XXX...X.. 02EC ......X.XXX.XX.. 0178 .......X.XXXX... 00B0 ........X.XX.... 0068 .........XX.X... 00D4 ........XX.X.X.. 078A .....XXXX...X.X. 0004 .............X.. 0000 ................
Final Image
The combined representation, with .
for the transparent areas, X
for cleared pixels, and +
for cleared and inverted pixels:
(The image contains no non-cleared inverted pixels)
.XXX............ X+++X........... X++++X.......... X+X+++X......... .X+X+++X........ ..X+X+++X...X+X. ...X+X+++X..X+X. ....X+X+++X.X+X. .....X+X+++X++X. ......X+X++++X.. .......X+X++X... ........X++X+X.. .....XXX++X+X+X. ....X++++X.X+X+X .....XXXX...X+XX .............XX.
As 2-bit image:
Hot spot
The hot spot of the cursor is given in registers BX and CX when executing the the "Set Graphics Pointer Shape" instruction.
BX gives the X coordinate of the hot spot, and CX gives the Y coordinate. This defines which pixel the cursor actually clicks on.
References
- ↑ TH INT 33H 0009H: Set Graphics Pointer Shape, techhelpmanual.com, January 18, 2020