Reputation: 1688
My understanding of VGA graphics may be flawed, but it seems to have only one layer of graphics, yet the mouse cursor in MS-DOS (or at least DOSBox) appears to be independent of the graphics beneath, much like a "sprite layer" on most video game consoles of the time. Yet DOSBox's VGA mode appears to be a one-layer bitmap screen. Is the mouse on a separate layer that only it can occupy? Furthermore, is there a way for VGA to output hardware sprites?
Upvotes: 4
Views: 536
Reputation: 982
What mouse drivers generally do (at least from what I've seen in the 90s, on real hardware) is:
In text modes a cell in video memory is defined by 2 bytes: one contains the character, the other the attributes for that character (https://en.wikipedia.org/wiki/VGA_text_mode#Text_buffer).
XORing in graphic modes, with indexed colors, is possible because the palettes are arranged to obtain a high contrast, at least for the first 16 colors, inherited from EGA. When, instead, the mode allows to directly specify the intensity of the RGB channels, XORing is sufficient for the cursor to have excellent contrast.
Mouse pointer management also depends on the type of application. Typically for video games, which often use a linear framebuffer, everything is managed by software, while the mouse driver only provides the pointer coordinates. Sometimes only the delta of movement received from the driver was used because at high resolutions there was no other way to obtain precise positioning and smooth movement.
As for DOSBox, it emulates a CGA/EGA/[S]VGA card (so it never accesses the hardware's native registers), and its behavior does not change whether it is in window or full screen. When it receives focus, the native cursor of the system it runs on disappears, and only the emulated one remains visible.
Upvotes: 0
Reputation: 62
As far as I know VGA has no hardware support for a mouse cursor or sprites. With the introduction of XGA sprites became available. But VGA only supports a text cursor but no graphical cursor.
So my guess is that the mouse driver reads the 16x16 pixels (or whatever the size of the mouse pointer is) and then stores it somewhere. Then it can draw the mouse pointer into the frame buffer. When the pointer is moved a bit to the left (for example) then the driver can restore the original 16x16 pixels in the frame buffer. Then it reads 16x16 pixels from the new location and then draws the pointer again.
As long as DOS Box is in windowed mode (means not in full screen) it doesn't access the VGA registers anyway but draws on a canvas provided by the operating system. So DOS Box can use hardware sprites even if VGA doesn't support it. Because in this situation VGA is not used at all.
Upvotes: 0