GG.DAR@forsythe.stanford.edu (Aaron Reizes) (11/11/89)
How do I determine the type of video adapter installed, CGA, EGA, or VGA? So far I haven't found any easy way to be sure which I am dealing with? Thanks, Aaron Reizes reizes.forsythe.stanford.edu
fredex@cg-atla.UUCP (Fred Smith) (11/12/89)
In article <5695@lindy.Stanford.EDU> GG.DAR@forsythe.stanford.edu (Aaron Reizes) writes: >How do I determine the type of video adapter installed, >CGA, EGA, or VGA? So far I haven't found any easy way to be sure >which I am dealing with? Earlier this year there were a couple of articles in Dr. Dobbs Journal which outlined a procedure for determining not only what kind of video adapter is resident in a PC, but also whether it has a color or monochrome tube attached (except for CGA where you can't tell). Sorry, I don't recall which issues, but it was in the column by Jeff Duntemann (or the late Kent Porter). It is a simple algorithm, based on functions known to exist in the BIOS extensions implemented in each type of card. Good luck! Fred
ts@chyde.uwasa.fi (Timo Salmi LASK) (11/13/89)
In article <8019@cg-atla.UUCP> fredex@cg-atla.UUCP (Fred Smith) writes: >In article <5695@lindy.Stanford.EDU> GG.DAR@forsythe.stanford.edu (Aaron Reizes) writes: >>How do I determine the type of video adapter installed, >>CGA, EGA, or VGA? So far I haven't found any easy way to be sure >>which I am dealing with? > >Earlier this year there were a couple of articles in Dr. Dobbs Journal which >outlined a procedure for determining not only what kind of video adapter is >resident in a PC, but also whether it has a color or monochrome tube >attached (except for CGA where you can't tell). Sorry, I don't recall which True, and CGA can be tested for by the Turbo Pascal graphics detection routine included in graph.tpu. ................................................................... Prof. Timo Salmi (Site 128.214.12.3) School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun
frotz@drivax.UUCP (Frotz) (11/14/89)
fredex@cg-atla.UUCP (Fred Smith) writes: >In article <5695@lindy.Stanford.EDU> GG.DAR@forsythe.stanford.edu (Aaron Reizes) writes: >>How do I determine the type of video adapter installed, >>CGA, EGA, or VGA? So far I haven't found any easy way to be sure >>which I am dealing with? >Earlier this year there were a couple of articles in Dr. Dobbs Journal which >outlined a procedure for determining not only what kind of video adapter is >resident in a PC, but also whether it has a color or monochrome tube >attached (except for CGA where you can't tell). Sorry, I don't recall which >issues, but it was in the column by Jeff Duntemann (or the late Kent Porter). ^^^^^^^^^^^^^^ >It is a simple algorithm, based on functions known to exist in the BIOS >extensions implemented in each type of card. I have done this from Jeff Duntemann's code. However, this code will not work on some of the clone EGA/VGA or other weird cards. Iff you are using IBM and 100% compatible video cards then there will be no problem. The problem comes in when trying to correctly recognize a QuadHPG as an EGA (because it is not quite a VGA) without believing that the QuadHPG is a MDS Genius. These are but two monitors that we have in-house that have been problematic. -- Frotz
jmv@sppy00.UUCP (Jim Vickroy) (11/14/89)
In article <5695@lindy.Stanford.EDU> GG.DAR@forsythe.stanford.edu (Aaron Reizes) writes: =>How do I determine the type of video adapter installed, =>CGA, EGA, or VGA? So far I haven't found any easy way to be sure =>which I am dealing with? => I have a Microsoft C routine that identifies monitor subsystems. So far it seems pretty solid. If your interested, I'll email the source. jim -- ============================================================================== :::: ::: :: :: : : Jim Vickroy |OC| ||| || || | | Telecommunications Systems Engineering |LC| ||| || || | | Online Computer Library Center, Inc. :::: ::: :: :: : : Dublin, Ohio ------------------------------------------------------------------------------ Internet: jmv@rsch.oclc.org UUCP: {att|pyramid|killer}!osu-cis!sppy00!jmv domain: jmv@sppy00.uucp USSNAIL: 6565 Frantz Rd., Dublin, Ohio 43017-0702 ==============================================================================
davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (11/15/89)
In article <596@sppy00.UUCP>, jmv@sppy00.UUCP (Jim Vickroy) writes: | I have a Microsoft C routine that identifies monitor subsystems. So far it | seems pretty solid. If your interested, I'll email the source. Why not post it. Here if it's small, or post to comp.sources.misc if it's larger. I would like to have a copy for the sixhub archives. -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon
jamesd@qiclab.UUCP (James Deibele) (11/16/89)
In article <5695@lindy.Stanford.EDU> GG.DAR@forsythe.stanford.edu (Aaron Reizes) writes: >How do I determine the type of video adapter installed, >CGA, EGA, or VGA? So far I haven't found any easy way to be sure >which I am dealing with? The code below is swiped from the C Gazette, who charge $21 a year for 4 issues. Seems like a pretty reasonable deal to me (I have no connection with them except as a satisfied customer). The C Gazette 1341 Ocean Avenue #257 Santa Monica, CA 90401 USA (213) 473-7414 -------This is from the C Gazette, Volume 4, #1 --------- /****************** CRTTYPE.C ************************ * Identifies monitor type either by printing a * message about the CRT or by returning a unique * identification byte. Version 2.1 * * Usage: unsigned int crttype (void) * * Macros: * DRIVER -- #define it to have driver code * VERBOSE - #define it to print messages * * (c) 1989 Andrew Binstock * Use freely if authorship is acknowledged. * * Validated for Microsoft 5.1, Turbo C 2.0, Watcom 7.0 * Note: loop optimization must be disabled *******************************************************/ #include <stdio.h> #include <stdlib.h> #include <dos.h> #define MSC 1 /* set MSC to 1 for Microsoft compilation */ #if MSC #define MK_FP(seg,ofs) ((void far *) \ (((unsigned long)(seg) << 16) | (unsigned)(ofs))) #include <conio.h> #pragma loop_opt(off) /* Disable loop optimization */ #endif #define DRIVER 1 /* If != 0, run test driver */ #define VERBOSE 1 /* If != 0, print identification info to stdout */ #if VERBOSE #define say(m, i) prnt(m, i) static void prnt (char *, int); #else #define say(m, i) #endif #define MDA 0x0100 #define HERCULES 0x0200 #define CGA 0x0400 #define EGA 0x0800 #define MCGA 0x1000 #define VGA 0x2000 #define UNKNOWN 0xFF00 #define MONO 0x00 #define COLOR 0x01 #define PLUS 0x02 /* Used for identifying CGA */ #define CRTC_COLOR_INDEX_REG 0x3D4 /* Port for CRTC index register */ #define CRTC_COLOR_DATA_REG 0x3D5 /* Port for CRTC data register */ /* Used for identifying MDA */ #define CRTC_MONO_INDEX_REG 0x3B4 /* Port for CRTC index register */ #define CRTC_MONO_DATA_REG 0x3B5 /* Port for CRTC data register */ /* Used for identifying Hercules */ #define CRTC_STATUS_PORT 0x3BA /* Port for CRTC retrace status */ union REGS regs; unsigned int crttype (void) { unsigned int monitor_type = 0; unsigned char far * peeker ; unsigned char hold_a_byte; int i; regs.h.ah = 0x1A; /* Service 1A, sub-service 0 */ regs.h.al = 0x00; /* of int 10h will identify a */ int86(0x10, ®s, ®s); /* VGA or MCGA */ if (regs.h.al == 0x1A) /* true only for VGA, MCGA */ { say ("VGA found: ", -1); if (regs.h.bl != 0) say ("Currently active system is %s \n", regs.h.bl); if (regs.h.bh != 0) say ("Currently inactive system is %s \n", regs.h.bh); return (regs.h.bl < 0x0A ? VGA : MCGA); } regs.h.ah = 0x12; /* Next, test for EGA */ regs.h.bl = 0x10; int86 (0x10, ®s, ®s); if (regs.h.bl != 0x10) /* It's an EGA */ { monitor_type |= EGA; say ("EGA with %s monitor", (regs.h.bh == 0 ? 'C' : 'M'));/* Color or */ /* monochr. */ say ("and %s Kb of video RAM\n", (regs.h.bl + 1) * 64); /* RAM size */ switch (regs.h.cl) /* CL contains monitor info */ { /* found at BIOS location */ case 2: /* 0040:0088; these values */ case 3: /* are the only valid ones */ case 8: /* for an enhanced EGA. */ case 9: monitor_type |= PLUS; say ("Enhanced Display Found", -1); break; } /* Let's see if the EGA is active. Since we */ /* can't read EGA status, we have to look in */ /* the BIOS area at 0487h, bit 3: 0 = active */ peeker = MK_FP (0x0040, 0x0087); say ("EGA %s active", (*peeker & 0x08) == 0 ? 'Y' : 'N'); return (monitor_type | (regs.h.bh == 0 ? COLOR : MONO)); } /* Not VGA, MCGA, EGA, so let's try CGA, after quick test for mono */ regs.h.ah = 0x0F; /* Get the current mode */ int86 (0x10, ®s, ®s); /* if it's a 7 (mono alpha) */ if (regs.h.al != 0x07) /* go to mono test, since CGA */ { /* cannot be in mode 7 */ outp (CRTC_COLOR_INDEX_REG, 0x0F); /* Get value of reg. 15 */ hold_a_byte = inp (CRTC_COLOR_DATA_REG); /* Read and save it. */ outp (CRTC_COLOR_DATA_REG, 0x63); /* Write an unlikely value */ for (i = 0; i < 100; i++) ; /* Wait a bit... */ if (inp (CRTC_COLOR_DATA_REG) == 0x63) /* Read it back and check it*/ { /* If the same in and out, */ outp (CRTC_COLOR_DATA_REG, hold_a_byte); /* it is a CGA. */ say ("CGA found", -1); /* Say so, reset reg. 15*/ return (CGA | COLOR); /* and go home. */ } else { /* otherwise, reset reg. 15 */ outp (CRTC_COLOR_DATA_REG, hold_a_byte); /* and announce the */ say ("Unknown CGA model", -1); /* difficulty. */ return (UNKNOWN | COLOR); } } /* Let's see if a mono adapter is found */ /* Same as CGA technique but to mono port */ outp (CRTC_MONO_INDEX_REG, 0x0F); /* Announce interest in reg. 15 */ hold_a_byte = inp (CRTC_MONO_DATA_REG); /* Read and save it. */ outp (CRTC_MONO_DATA_REG, 0x63); /* Write an improbable value */ for (i = 0; i <100; i++) ; /* Wait a bit... */ if (inp (CRTC_MONO_DATA_REG) != 0x63) /* Read it back and check it; */ { /* If it's not same in and out, */ outp (CRTC_MONO_DATA_REG, hold_a_byte);/* it's not an MDA - so */ say ("Unknown monitor type", -1); /* say so, restore reg 15 and */ return (UNKNOWN | MONO); /* go home. */ } /* We have MDA if we're here. */ outp (CRTC_MONO_DATA_REG, hold_a_byte); /* Restore reg 15 from */ /* previous test */ /* So it's mono, but is it a Hercules ? */ hold_a_byte = inp (CRTC_STATUS_PORT); /* Get the setting */ hold_a_byte &= 0x80; /* Isolate bit 7 */ for ( i = 0; i < 1000; i++) /* Test bit 7, 1000 times */ { if ((inp (CRTC_STATUS_PORT) & 0x80) /* If the value changes */ != hold_a_byte) /* it'a Hercules */ { monitor_type = HERCULES; break; } } if (monitor_type != HERCULES) /* If no Hercules then it's a */ { /* plain MDA monitor. Say so */ say ("Monochrome CRT, no Hercules", -1); /* and go home. */ return (MDA | MONO); } /* What kind of Hercules is it? */ hold_a_byte = inp (CRTC_STATUS_PORT); /* Get a fresh reading */ hold_a_byte &= 0x70; /* Keep bits 4-6 */ switch (hold_a_byte) /* and test the value */ { case 0x50: say ("In Color Card found", -1); return (monitor_type | COLOR); case 0x10: say ("Graphics Plus Card found", -1); return (monitor_type | PLUS); case 0x00: say ("Regular Graphics Card found", -1); return (monitor_type | MONO); } say ("Unknown Hercules", -1); return (UNKNOWN | MONO); /* Unknown Hercules model */ } #if VERBOSE static void prnt(char * literal, int msg) { static char * display_name [] = { "Not Found", /* 00h */ "MDA with monochrome display", /* 01h */ "CGA with color display", /* 02h */ "reserved", /* 03h */ "EGA with color display", /* 04h */ "EGA with monochrome display", /* 05h */ "Professional graphics display", /* 06h */ "VGA with analog monochrome", /* 07h */ "VGA with analog color display", /* 08h */ "reserved", /* 09h */ "MCGA with digital color display", /* 0Ah */ "MCGA with analog monochrome display", /* 0Bh */ "MCGA with analog color display" /* 0Ch */ }; if (msg == -1) { puts (literal); return; } if ( msg >= 0x00 && msg <= 0x0C ) { printf (literal, display_name[msg]); return; } if ( msg == 'Y' || msg == 'N' ) { printf (literal, msg == 'Y' ? "is" : "is not"); return; } if (msg == 'C' || msg == 'M') { printf (literal, (msg == 'C' ? "color" : "monochrome")); return; } if (msg == 64 || msg == 128 || msg == 192 || msg == 256) { char p [4]; printf (literal, itoa (msg, p, 10)); return; } } #endif #ifdef DRIVER void main(void) { printf ("\nMonitor ID is %x", crttype()); } #endif -- James Deibele jamesd@qiclab BBSs: (503) 760-1473 or (503) 761-7451 TECHBooks: The Computer Book Specialists --- Voice: (503) 646-8257 12600 SW 1st Beaverton, OR 97005 --- Book reviewers wanted for computer science & electronics - contact us for more information.