detect.asm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ; $Id$
  2. ; MegaZeux
  3. ;
  4. ; Copyright (C) 1996 Greg Janson
  5. ; Copyright (C) 1998 Matthew D. Williams - dbwilli@scsn.net
  6. ;
  7. ; This program is free software; you can redistribute it and/or
  8. ; modify it under the terms of the GNU General Public License as
  9. ; published by the Free Software Foundation; either version 2 of
  10. ; the License, or (at your option) any later version.
  11. ;
  12. ; This program is distributed in the hope that it will be useful,
  13. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. ; General Public License for more details.
  16. ;
  17. ; You should have received a copy of the GNU General Public License
  18. ; along with this program; if not, write to the Free Software
  19. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. ;
  21. ; DETECT.ASM- Code to detect processor and graphics card. Runs on 8088.
  22. ;
  23. Ideal
  24. include "detect.inc"
  25. p8086
  26. JUMPS
  27. include "model.inc"
  28. Codeseg
  29. NONE equ 0
  30. MDA equ 1
  31. CGA equ 2
  32. EGAMono equ 3
  33. EGAColor equ 4
  34. VGAMono equ 5
  35. VGAColor equ 6
  36. MCGAMono equ 7
  37. MCGAColor equ 8
  38. PS2_CARDS db 0,1,2,2,4,3,2,5,6,2,8,7,8
  39. i86 equ 0
  40. i186 equ 1
  41. i286 equ 2
  42. i386sx equ 3
  43. i386dx equ 4
  44. i486 equ 5
  45. ;
  46. ; Function- detect_graphics
  47. ;
  48. ; Returns graphics card type as a numeric code.
  49. ;
  50. proc detect_graphics far
  51. mov ax,1A00h ; Try calling VGA Identity Adapter function
  52. int 10h
  53. cmp al,1Ah ; Do we have PS/2 video bios ?
  54. jne @@not_PS2 ; No!
  55. cmp bl,0Ch ; bl > 0Ch => CGA hardware
  56. jg @@is_CGA ; Jump if we have CGA
  57. flipflag bh,bh
  58. flipflag ah,ah
  59. mov al,[cs:PS2_CARDS+bx] ; Load ax from PS/2 hardware table
  60. jmp short @@done ; return ax
  61. @@is_CGA:
  62. mov ax,CGA ; Have detected CGA, return id
  63. jmp short @@done
  64. @@not_PS2: ; OK We don't have PS/2 Video bios
  65. mov ah,12h ; Set alternate function service
  66. mov bx,10h ; Set to return EGA information
  67. int 10h ; call video service
  68. cmp bx,10h ; Is EGA there ?
  69. je @@simple_adapter ; Nop!
  70. mov ah,12h ; Since we have EGA bios, get details
  71. mov bl,10h
  72. int 10h
  73. or bh,bh ; Do we have colour EGA ?
  74. jz @@ega_color ; Yes
  75. mov ax,EGAMono ; Otherwise we have Mono EGA
  76. jmp short @@done
  77. @@ega_color:
  78. mov ax,EGAColor ; Have detected EGA Color, return id
  79. jmp short @@done
  80. @@simple_adapter:
  81. int 11h ; Lets try equipment determination service
  82. maskflag al,30h
  83. shr al,4
  84. flipflag ah,ah
  85. or al,al ; Do we have any graphics card at all ?
  86. jz @@done ; No ? This is a stupid machine!
  87. cmp al,3 ; Do We have a Mono adapter
  88. jne @@is_CGA ; No
  89. mov ax,MDA ; Have detected MDA, return id
  90. @@done:
  91. ret
  92. endp detect_graphics
  93. ends
  94. end