Detecting the Installed Display Adapter in .NET

Generate Denso QR Bar Code in .NET Detecting the Installed Display Adapter
Detecting the Installed Display Adapter
QR Code ISO/IEC18004 Decoder In Visual Studio .NET
Using Barcode Control SDK for .NET framework Control to generate, create, read, scan barcode image in .NET framework applications.
A useful example of CMP and the conditional jump instructions in action involves detecting the installed display adapter At the beginning of the 1990s, there were five different mainstream IBM display adapters in reasonably common use in PCs, from the first generation introduced with the original PC in 1981 to the VGA and MCGA introduced with the PS/2 series in 1987 Going into the twenty-first century, nearly all of those adapters except for the VGA are mostly extinct So, the code I'm about to show you is mostly a technical exercise, but if you work with older machines (and one reason to work in assembly is to create software that works quickly enough on older machines), it may be useful for sorting out what any given machine can do from a text video standpoint It isn't quite enough to know which board is installed in a given machine The way a certain board operates can change severely depending on whether a monochrome or color monitor is attached to the board The most obvious difference (and the one of most interest to the programmer) is that memory address of the video display buffer is one address for the color monitor and a different address for the monochrome monitor This schizophrenic quality of the EGA, VGA, and MCGA is so pronounced that it makes sense to consider the EGA/color monitor combination an entirely separate display adapter from the EGA/monochrome monitor combination, and ditto for the VGA (The MCGA is one of those adapters approaching extinction asymptotically) In my method, I use a separate numeric code to represent each legal adapter/monitor combination There are nine possibilities in all, summarized in Table 108 Table 108: Legal PC Display Adapter/Monitor Combinations CODE 00 01H 02H 04H 05H 07H 08H 0AH 0BH 0CH ADAPTER/MONITOR None MDA/monochrome CGA/color EGA/color EGA/monochrome VGA/monochrome VGA/color MCGA/color (digital) MCGA/monochrome MCGA/color (analog) SEGMENT OF DISPLAY BUFFER None 0B000H 0B800H 0B800H 0B000H 0B000H 0B800H 0B800H 0B000H 0B800H
Print QR Code In VS .NET
Using Barcode encoder for .NET framework Control to generate, create QR Code image in .NET framework applications.
The codes are not consecutive; note that there is no code 3, 6, or 9 I didn't make these codes up arbitrarily They are, in fact, the display adapter/ monitor combination codes returned by one of the VGA BIOS services The procedure DispID given in the following listing determines which display adapter is installed in the machine upon which DispID is running DispID then returns one of the codes listed in Table 108 I recommend that your programs define a byte-sized variable in their data segments where this code can be stored throughout the programs' duration If you detect the adapter with DispID immediately on program startup, your program can inspect the code any time it needs to make a decision as to which video features to use Given what I've told you about CMP and conditional jump instructions so far, see if you can follow the logic in DispID before we go through it blow by blow: ;--------------------------------------------------------------; DispID - Identifies the installed display adapter ; Last update 9/18/99 ; ; 1 entry point:
Reading Denso QR Bar Code In .NET
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
; ; DispID: ; Caller passes no parameters ; Routine returns a code value in AX ; The codes are these: ; 0 : Adapter is unknown; recommend aborting ; 1 : MDA (Monochrome Display Adapter) ; 2 : CGA (Color Graphics Adapter) ; ;--------------------------------------------------------------DispID: mov AH,1AH xor AL,AL int 10H cmp AL,1AH jne TryEGA mov AL,BL ret TryEGA: mov AH,12H mov BX,10H int 10H cmp BX,10H je OldBords cmp BH,0 je EGAColor mov AL,5 ret EGAColor: mov AL,4 ret OldBords: int 11H and AL,30H cmp AL,30H jne CGA mov AL,1 ret CGA: mov AL,2 ret ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; Select PS/2 Identify Adapter Service Select Get Combination Code Subservice (AL=0) Call VIDEO If AL comes back with 1AH, we have a PS/2 If not, jump down to test for the EGA Put Combination Code into AL and go home! Select EGA Alternate Function Select Get Configuration Information subservice Call VIDEO If BX comes back unchanged, EGA is *not* there Go see whether it's an MDA or CGA If BH = 0, it's an EGA/color combo otherwise it's EGA/mono Store code 5 for EGA mono and go home!
Making Bar Code In Visual Studio .NET
Using Barcode generation for VS .NET Control to generate, create bar code image in Visual Studio .NET applications.
; Store code 4 for EGA color ; and go home! ; ; ; ; ; ; ; ; Call Equipment Configuration interrupt Mask out all but bits 4 & 5 If bits 4 & 5 are both =1, it's an MDA otherwise it's a CGA Store code 1 for MDA and go home! Store code 2 for CGA and go home!
Read Barcode In .NET Framework
Using Barcode decoder for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
DispID is the most complex piece of code shown so far in this book The overall strategy is not obvious and warrants some attention IBM's standard display boards appeared in three generations The first generation consisted of the original Color Graphics Adapter (CGA) and Monochrome Display Adapter (MDA) The second generation consisted solely of the Enhanced Graphics Adapter (EGA) Finally, the third generation came in with the PS/2 in April of 1987 and provided the Video Graphics Array (VGA) and Multi-Color Graphics Array (MCGA) Although "super" successors of the VGA appeared regularly going into the 1990s, their superness was strictly on the graphics side The evolution of the PC text display pretty much ceased with the VGA and MCGA The simplest way to find out what display board is installed in a machine is to ask the machine by querying BIOS services There are BIOS services specific to each generation of display board, and by some quirk of fate all such services are well behaved, by which I mean that querying a service that doesn't exist (because an older generation of video board is installed) will not crash the system (IBM's BIOS standard is extremely downward compatible in that newer generations all contain everything the older generations do) Furthermore, if a BIOS service specific to a generation of boards is found not to exist, that tells us that the installed board is not a member of that generation or a newer generation Assuming that the target machine could have any of the standard IBM display boards in it, it makes sense to test for the presence of the newest boards first Then, through a process of elimination, we move to the older
Create QR Code JIS X 0510 In C#.NET
Using Barcode generation for .NET Control to generate, create Quick Response Code image in .NET framework applications.
and older boards The first test that DispID makes, then, is for the VGA or MCGA generation, that is, the PS/2 boards The PS/2 machines contain in their ROM BIOS a service (VIDEO Service 1AH) designed specifically to identify the installed display adapter DispID calls VIDEO service 1AH, having cleared AL to 0 via XOR As it happens, if a PS/2 BIOS is present on the bus, the 1AH service number is returned in register AL On return from the INT 10H call, we test AL for 1AH using CMP If 1AH is not found in AL, we know up front that there is no PS/2 BIOS in the system, and therefore no VGA or MCGA After the CMP instruction is the JNE TryEGA conditional branch If the CMP instruction finds that AL is not equal to 1AH, then control jumps down to the code that tests for the next older generation of video boards: the EGA If AL is equal to 1AH, then the PS/2 BIOS is present and has placed the display adapter code in BL DispID then copies BL into AL (which is where DispID returns the display code) and executes a RET instruction to pass control back to the caller Testing for the EGA is done a little differently, but the same general idea holds: We call an EGA-specific VIDEO service not present in the oldest generation of boards The key test, again, is whether a certain register comes back unchanged There is a twist, however: If BX comes back with the same value it held when the VIDEO call was made (here, 10H), then an EGA BIOS does not exist in the machine (Isn't the PC wonderful ) Here, after the CMP BX,10H instruction, we do a JE OldBords and not a JNE as we did when testing for the PS/2 generation If BX comes back in an altered state, we assume an EGA is present and that BX contains information on the display configuration If an EGA BIOS is found, a value in BH tells us whether the EGA is connected to a monochrome or color monitor (Remember, there is a different code for each) The value in BH is not the code itself, as it was with the PS/2 BIOS, so we have to do a little more testing to get the right code into AL If BH contains 0, then the attached monitor is color Any other value in BH indicates a monochrome system The following sequence of instructions from DispID takes care of loading the proper EGA-specific code into AL: cmp BH,0 je EGAColor mov AL,5 ret EGAColor: mov AL,4 ret ; If BH = 0, it's an EGA/color combo ; otherwise it's EGA/mono ; Store code 5 for EGA mono ; and go home! ; Store code 4 for EGA color ; and go home!
QR Code ISO/IEC18004 Drawer In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create QR Code ISO/IEC18004 image in ASP.NET applications.
You'll find yourself writing sequences like this a lot, when a single test decides between one of two courses of action One course here is to load the value 5 into AL, and the other course is to load 4 into AL Notice that after the appropriate MOV instruction is executed, a RET takes care of passing execution back to the caller If DispID were not a procedure, but simply a sequence coded into the main line of instructions, you would need an unconditional jump (JMP) after each MOV to continue on with instruction execution somewhere else in the program Using RET is much neater-which is yet another reason to wrap up small tasks such as display adapter identification in a procedure wrapper Finally, if neither PS/2 nor EGA are present, DispID realizes that, by default, one of the original generation of display boards is on the bus Telling MDA from CGA is not done with a BIOS call at all, because the first generation BIOS did not know which display board was present (That was a feature instituted with the EGA in 1984) Instead, there is a separate software interrupt, 11H, that returns machine configuration information
QR Code Generator In VB.NET
Using Barcode creation for Visual Studio .NET Control to generate, create QR Code ISO/IEC18004 image in .NET applications.
Barcode Maker In .NET
Using Barcode creation for .NET framework Control to generate, create barcode image in .NET framework applications.
Make Code 128 Code Set C In Visual Studio .NET
Using Barcode generation for VS .NET Control to generate, create USS Code 128 image in Visual Studio .NET applications.
Create GS1-128 In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create UCC-128 image in ASP.NET applications.
Create Bar Code In Visual C#.NET
Using Barcode creation for VS .NET Control to generate, create barcode image in .NET framework applications.
Print EAN 128 In Visual Basic .NET
Using Barcode drawer for VS .NET Control to generate, create UCC.EAN - 128 image in VS .NET applications.
Barcode Generator In VB.NET
Using Barcode creator for .NET Control to generate, create bar code image in .NET applications.