With the exception of the S3 911 and 924 chips, the S3 chips directly support 16-bit-per-pel drawing operations in hardware. As a result, there is little that needs to be changed in the driver code to support 16-bit-per-pel modes on the various S3 chips. This will most likely be true on most graphics chips. There are, however, two issues that can arise: byte ordering and the location of the red, green, and blue components of the pel. The S3 driver uses a 5,6,5 pel for 16 bits-per-pel. (Green gets the extra bit.) This is exactly the same mode as the XGA. If your adapter uses a different byte ordering or runs 5, 5, 6, or 5, 5, 5, the functions will have to be modified so the bit maps can be converted from one format to another, as well as changing the code to represent 16-bit color in eddf_MESS. The files that handle bit-map conversions are the following:
CONVBITM.C
CONVFUNS.C
CONVFUNS.H
CONVINT.C
CONVEXT.C
CONVERT.ASM
Of these, the bulk of the changes will be made in CONVFUNS.H, which is a package of macros for setting pels in memory bit maps. To swap the pels in CONVFUNS.H, the following macros need to be altered (the changes are in the ifdef SWAP16BPP sections):
/**********************************************************************/ /* Macro to convert to a 16 bit value in Intel format. */ /* */ /* Because XGA bit maps in system memory are stored in Motorola */ /* format, this requires swapping the low and high bytes. */ /**********************************************************************/ #ifdef SWAP16BPP #define XGA_EnsureIntel16bpp(word) (word) #else #define XGA_EnsureIntel16bpp(word) \ ((((word) & 0xFF00) >> 8) | (((word) & 0x00FF) << 8)) #endif /**********************************************************************/ /* Macro to write a 16bpp value into the internal bit map, and to */ /* increment the internal bit map pointer to the next 16bpp pel. */ /* This must be done in Motorola format (high byte, low byte). */ /**********************************************************************/ #ifdef SWAP16BPP #define XGA_SetInternal16BppPel(value) \ *((PBYTE)SPad.pbTrgPointer)++ = ((value) & 0xff); \ *((PBYTE)SPad.pbTrgPointer)++ = ((value) >> 8); #else #define XGA_SetInternal16BppPel(value) \ *((PRGB16)SPad.pbTrgPointer)++ = value; #endif
In addition, to change the R, G, and B components of the 16 bit-pel, alter the macro XGA_RGB16FromPRGB2, which is also in CONVFUNS.H. Next, alter the function ConvertExt8ToInt16, which is in CONVERT.ASM. In that function, there are several xchg al, ah instructions. Remove them. Likewise, in ConverExt24toInt16, you will see raster operation ax, 8. Remove it as well.
Finally, make a change to EDDFFAST.ASM, which holds the eddf_MESS function. In it, near the top of the file, you will see code similar to the following:
mov ax, word ptr Shadow8514Regs.Color_1 xchg ah, al mov word ptr Shadow8514Regs.Color_1, ax mov ax, word ptr Shadow8514Regs.Color_0 xchg ah, al mov word ptr Shadow8514Regs.Color_0, ax mov ax, word ptr Shadow8514Regs.Color_Comp xchg ah, al mov word ptr Shadow8514Regs.Color_Comp, ax
Disable this code. It is near the top of eddf_MESS, and immediately after the label exitMESS. It must be disabled in both places.
The modules listed above, along with EDDBCREA.C are useful to study if you are interested in the creation and conversion of bit maps in the driver.