Hi all, Michael is right, if you I=..., then EMM386 should just do what you tell it to do. He is also right that autodetection should be careful, not "overenthousiastic". Anyway, I like the suggestion from Arkady:
> Ok. Let make another question: how to make _conditional_ inclusion of > B000 or B800 (depending of color/mono adapter(s) presence)? If I right > understand, there is currently only "not included" and "forced inclusion"? QEMM (?) had some option or driver called MONOUMB, which is pretty close to that idea. So how about the following options: - MONOUMB means "I=b000-b7ff if no mono CRTC is present" - COLORUMB could do the same for b800-bfff, but only very few people would run a 386+ (EMM386 compatible PC) on pre-CGA cards anyway - VGAUMB means "I=a000-afff, and block int 10.0 modes 0d and above, as well as int 10.4f VESA calls", which should also insist on VGA BIOS being present. Actually, VESA text modes 108..10c could be allowed as they do not touch axxx:x memory, but you would have to manipulate the mode list and the (VBE 2+) protected mode interface (int 10.4f0a) might interfere as well. The list of supported modes is returned by int 10.4f00 in VESA, but well-behaved programs would always ask int 10.4f01 for details about a mode before using it, and THERE you could fail (return AX=014f and zap the 256 byte buffer at es:di to make sure), too. Current CRTC can be detected by looking at the word at 40:63, the CRTC base I/O port. EGA can be detected by doing int 10.12.bx=ff10 (ah=12, bl=10, get EGA info) and checking if returned BH and BL are both at most 0f. If bx and f0f0 is zero, EGA BIOS is present. Finally, int 10.1a00 returns al=1a if VGA BIOS is present (get display combination: BH and BL are both display type codes, where 0 means NONE, 1 MONO, 2 CGA, 4/5 EGA, 6 PGA, 7/8 VGA, a/b/c MCGA..., but if the call is supported at all, you already know that a VGA is present). The byte at 40:10, and 30, tells you which card is active: 30 is MONO, 10 and 20 are CGA, 00 is EGA or newer. Int 10.0f returns the mode number in AL, and 88/7e/7f/56/57/41/27/20/21/ 18/19/1a/6/7/8 CAN mean b000:0 is in use (chance is pretty HIGH for 7/8). Code to detect the CRTC chip itself can be found in the MODE source code, and you may NEED that code to detect dual-head systems which have a MONO and a COLOR card active at the same time. If VGA BIOS int 10.1a00 fails to report it, that is. Function name is testCRTC. 3ba is used for mono, 3da is used for color. Technically, you can switch the CRTC port to mono and still keep the mapping at b800, but most BIOSes will not do that. The actual mapping is done by writing register 6 of EGA/VGA port 3ce/3cf: ????xx??, where xx can be 0 for "a000-bfff" (!), 1 for axxx, 2 for b000..., 3 for b800... For a fool-proof implementation, you would have to trap those accesses ;-). You would even have to trap port 3d8 writes for Hercules, because the high bit of that port being set can map b800 instead of b000, in particular for 64k-Hercules cards(?). But that would be clearly overdoing things, as there can always be post-VGA chipset functions which map graphics RAM at weird places without you being able to block them. Recommended tests: MONOUMB - 40:10 and 30 must not be 30, and if VGA is present, there must not be the value 1 in either BH or BL after int 10.1a00 ... and mode number must neither be 7 nor 8 (as returned by int 10.0f, also present at 40:49 as byte). Plus 40:63 must not be 3b4. VGAUMB - VGA BIOS must be present (int 10.12.bl=10 to test for EGA, then int 10.1a00 to test for VGA). This function should also block values outside 00..0c range for AL in int 10.00 (make int 10.00 a no-op if those values are selected I suggest) and should block int 10.4fxx calls (VESA) completely. Only if you want to do a very sound / thorough implementation, you would in addition use testCRTC and would try to allow non axxx:x VGA and VESA modes instead of only allowing 00..0c modes. Maybe you would even trap mapping port I/O calls, but that would degrade graphics performance and, as page mapping by EMM386 is "stronger" than graphics RAM mapping (except for DMA stuff, in a way), trapping I/O port access would be completely unnecessary anyway, and it would not avoid MEMORY access to axxx:x area by graphics BIOS either. Eric PS: VGAUMB would of course have to insist that CURRENT mode number, as shown by int 10.0f or 40:49, has to be in 00..0c range already. VESA modes all return pseudo-values outside that range, so checking "classic" mode number for 00..0c range is good enough. MONOUMB should also block modes 7/8 (and optionally others) for int 10.00, otherwise VGA cards being switched to a mono mode would mean trouble. The EGA/VGA 640x350 and higher mono modes are mono GRAPHICS at a000:0, so there is no need to block THOSE. Only some vendor specific mono text modes are a problem, e.g. desqview mode 21 and some 90/132 column modes etc. ... but you simply cannot enumerate all problematic modes. Maybe you just allow all 00..17 modes except 7/8 to be on the safe side, blocking 18..7f. ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Freedos-user mailing list Freedos-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freedos-user