home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / BASIC / PROGEN / PROSRC.ZIP / PROASM71.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-05-18  |  39.8 KB  |  1,407 lines

  1. ;-----------------------------------------------------------------------------
  2. ;
  3. ;  MYASM.ASM  IS A REPLACEMENT FOR UIASM.ASM
  4. ;
  5. ;  Copyright (C) 1989 Microsoft Corporation, All Rights Reserved
  6. ;
  7. ;  GetCopyBox   : Gets screen box info and places into string variable
  8. ;  PutCopyBox   : Puts screen box info from string variable onto screen
  9. ;  AttrBox      : Set attribute for an area of the screen
  10. ;
  11. ;DECLARE SUB getcopybox (row1%, col1%, row2%, col2%, buffer$)
  12. ;DECLARE SUB putcopybox (row%, col%, buffer$)
  13. ;DECLARE SUB attrbox (row1%, col1%, row2%, col2%, attr%)
  14. ;
  15. ;                1991 Raymond E Dixon
  16. ;                                                     
  17. ;  Colorwind    : Changes the color attributes of all characters within a box
  18. ;               : Fill with character within a box, space clears window
  19. ;
  20. ;  Drawwind     : draw a window with or without border and clear window
  21. ;
  22. ;DECLARE SUB captal (a$)         'CONVERT FIRST LETTER TO UPPER CASE
  23. ;
  24. ;  Captal a$    : converts first char to U/case and others to l/case
  25. ;               : needed for proper name format
  26. ;       From    :"rAyMoNd e DIXON"
  27. ;       To      :"Raymond E Dixon"
  28. ;
  29. ;  ClrKeyBuf    : clears keyboard buffer
  30. ;
  31. ;       "all sub work with far or near strings"
  32. ;
  33. ;   colorwind is a replacement for attrbox, allows foreground,background
  34. ;   instead of attribute plus fill char.
  35. ;        
  36. ;DECLARE SUB Colorwind (row1%, col1%, row2%, col2%,char%,fillflag%, foreground%, background%)
  37. ;
  38. ; drawwind draws a border with option to clear screen and or fill.
  39. ; char% = asc(anychar) or char value , char = 176
  40. ;
  41. ;DECLARE SUB drawwind (row1%, col1%, row2%, col2%, frame%,clear%)
  42. ;
  43. ;DECLARE SUB pnc (a$, row%, col%, foreground%, background%)
  44. ;
  45. ;  PNC string$,row%,col%,fg%,bg%         : print in color
  46. ;
  47. ;flag function allow up to 64 flags without using basic data space
  48. ; flag function from PC MAG
  49. ;
  50. ; to use :
  51. ; const endofpage = 58
  52. ;
  53. ; setflag (endofpage)
  54. ;      
  55. ;      if printedlines = getflag(endofpage) then
  56. ;          resetflag(endofpage)
  57. ;          exit print loop
  58. ;        else
  59. ;        print next line
  60. ;       end if
  61. ;
  62. ;DECLARE SUB setflag(flag%)      'SET FLAG
  63. ;DECLARE FUNCTION getflag(flag%) 'GET STATE OF FLAG
  64. ;DECLARE SUB resetflag(flag%)    'RESET FLAG
  65. ;DECLARE SUB clearall            'CLEAR ALL FLAGS
  66. ;
  67. ;DECLARE FUNCTION CPUcheck%     1 = 8086/88
  68. ;                               2 = 80286
  69. ;                               3 = 386/486
  70. ;
  71. ;DECLARE FUNCTION VIDEOcheck%   1 = MDA
  72. ;                               2 = HGC
  73. ;                               3 = CGA
  74. ;                               4 = EGA
  75. ;                               5 = VGA color
  76. ;                               6 = VGA mono
  77. ;                               7 = MCGA
  78. ;                               8 = model 30 color
  79. ;                               9 = model 30 mono
  80. ;-----------------------------------------------------------------------------
  81.  
  82. ;NOTE: For optimum speed, these routines write directly to screen memory
  83. ;      without waiting for re-trace.  If "snow" is a problem, these routines
  84. ;      will need modification.
  85.  
  86.  include dos.inc
  87.  
  88. .model medium,basic
  89.  
  90.     extrn   STRINGADDRESS:far      ;BASIC RTL entry point for string info
  91. ;returns basic far string address
  92.     
  93.     extrn   STRINGLENGTH:far       ;BASIC RTL entry point for string info
  94. ;returns basic far string length
  95.  
  96. ;-----------------------------------------------------------------------------
  97.  
  98. .data
  99. even
  100.  
  101. fillflag        db      ?            ;fillflag
  102. fill            db      ?            ;fill char
  103. attr            db      ?            ;color attribute (colorwind)
  104. x0              db      ?            ;x coord of upper-left
  105. y0              db      ?            ;y coord of upper-left
  106. x1              db      ?            ;x coord of lower-right
  107. y1              db      ?            ;y coord of lower-right
  108. bwidth          db      ?            ;box width
  109. height          db      ?            ;box height
  110. strdoff         dw      ?            ;string pointer offset
  111. strdseg         dw      ?            ;string pointer segment
  112. scrseg          dw      ?            ;screen segment
  113. movword         dw      ?            ;word count = char + attr
  114.  
  115. .code
  116.  
  117. ;---- place segment of screen memory in SCRSEG
  118.  
  119. getscrseg proc
  120.  
  121.     push    ax                      ;save value of AX
  122.     mov     ah,0Fh
  123.     int     10h                     ;INT 10H fn. 0Fh - Get Video Mode
  124.     mov     dgroup:scrseg,0B800h    ;assume COLOR screen for now
  125.     cmp     al,07h                  ;is it MONOCHROME mode?
  126.     jne     arnd1
  127.     mov     dgroup:scrseg,0B000h    ;yes, set for mono screen seg
  128. arnd1:   pop     ax                      ;restore AX
  129.     ret                             ;and exit
  130.  
  131. getscrseg endp
  132.  
  133. ; Given X and Y in AH and AL, find  the offset
  134. ; into screen memory and return in AX
  135.  
  136. getmemxy proc
  137.  
  138.     push    dx                      ;save DX
  139.     push    ax                      ;save coords
  140.     mov     dl,160
  141.     mul     dl                      ;multiply Y by 160
  142.     pop     dx                      ;put coords in DX
  143.     mov     dl,dh
  144.     mov     dh,0
  145.     add     dl,dl                   ;double X
  146.     add     ax,dx                   ;and add to mult. result for final!
  147.     pop     dx                      ;restore DX
  148.     ret
  149.  
  150. getmemxy endp
  151.  
  152. ; This is the routine that copies screen info to the string variable
  153.  
  154.     PUBLIC getcopybox
  155.  
  156. getcopybox proc far
  157.  
  158.     push    bp
  159.     mov     bp, sp
  160.     push    ds
  161.     push    ES
  162.     push    SI
  163.     push    di                      ;preserve registers
  164. getstart:
  165.     mov     bx,[bp + 14]            ;get y0
  166.     mov     ax,[bx]
  167.     mov     y0,al
  168.     mov     bx,[bp + 12]            ;...x0
  169.     mov     ax,[bx]
  170.     mov     x0,al
  171.     mov     bx,[bp + 10]            ;...y1
  172.     mov     ax,[bx]
  173.     mov     y1,al
  174.     mov     bx,[bp + 8]             ;...x1
  175.     mov     ax,[bx]
  176.     mov     x1,al
  177.     mov     bx,[bp + 6]             ;...and the destination str desc.
  178.     push    bx
  179.     call    STRINGADDRESS           ;for both near and far string support
  180.     mov     strdoff,ax
  181.     mov     strdseg,dx
  182.     dec     x0                      ;subtract 1 from
  183.     dec     y0                      ;all coordinates
  184.     dec     x1                      ;to reflect BASIC's
  185.     dec     y1                      ;screen base of 1 (not 0)
  186. getchkscr:
  187.     call    getscrseg               ;set up screen segment
  188. getsetstr:
  189.     mov     al,x1
  190.     sub     al,x0                   ;find width of box
  191.     mov     bwidth,al               ;and save
  192.     add     al,1                    ;add one to width
  193.     mov     ah,0                    ;to find # words to move
  194.     mov     movword,ax              ;MovWord = (width+1)
  195.     mov     al,y1
  196.     sub     al,y0                   ;find height of box
  197.     mov     height,al               ;and save
  198.     mov     ES,strdseg
  199.     mov     di,strdoff              ;string is the destination
  200.     mov     si,offset bwidth        ;point to width
  201.     movsb                           ;put width in string
  202.     mov     si,offset height
  203.     movsb                           ;and the height, too
  204. getmovstr:
  205.     mov     al,y0
  206.     mov     ah,x0                   ;put coords in AH and AL
  207.     call    getmemxy                ;and find offset into screen mem
  208.     mov     si,ax                   ;this will be the source
  209. getdomove:
  210.     mov     cx,movword
  211.     push    ds
  212.     mov     ds,scrseg
  213.     rep     movsw                   ;move a row into the string
  214.     pop     ds
  215.     add     SI,160
  216.     sub     si,movword              ;Add 160-(movword*2) to si
  217.     sub     si,movword              ;to point to next row
  218.     cmp     height,0                ;was that the last row?
  219.     je      getdone                 ;yes, we're done
  220.     dec     height                  ;decrement height
  221.     jmp     getdomove               ;and do another row
  222. getdone:
  223.     pop     DI
  224.     pop     SI
  225.     pop     ES
  226.     pop     ds                      ;restore registers
  227.     pop     bp
  228.     ret     10                      ;there were 5 parameters
  229.  
  230. getcopybox endp
  231.  
  232. ;-----------------------------------------------------------------------------
  233. ;This is the routine that copies the information stored
  234. ;in the string to the screen in the specified location
  235. ;-----------------------------------------------------------------------------
  236.  
  237.     PUBLIC putcopybox
  238.  
  239. putcopybox      proc    far
  240.  
  241.     push    bp
  242.     mov     bp,sp
  243.     push    ds
  244.     push    ES
  245.     push    SI
  246.     push    di                      ;preserve registers
  247. putstart:
  248.     mov     bx,[bp+10]              ;get y0
  249.     mov     ax,[bx]
  250.     mov     y0,al
  251.     mov     bx,[bp+8]               ;...x0
  252.     mov     ax,[bx]
  253.     mov     x0,al
  254.     mov     bx,[bp+6]               ;...and the destination string
  255.  
  256.     push    bx
  257.     call    STRINGADDRESS           ;for both near and far string support
  258.     mov     strdoff,ax
  259.     mov     strdseg,dx
  260.  
  261.     dec     x0                      ;subtract 1 from
  262.     dec     y0                      ;all coordinates
  263.  
  264. putchkscr:
  265.     call    getscrseg               ;set up scrseg
  266.  
  267. putsetstr:
  268.     push    ds
  269.     pop     es                      ;equate ES to DS
  270.  
  271.     mov     si,strdoff              ;point DS:SI to string mem
  272.     push    ds
  273.     mov     ds,strdseg
  274.     mov     di,offset bwidth
  275.     movsb                           ;get width
  276.     mov     di,offset height
  277.     movsb                           ;and height out of string
  278.     pop     ds
  279.  
  280.     mov     al,bwidth
  281.     add     al,1
  282.     mov     ah,0
  283.     mov     movword,ax              ;set movword to (bwidth+1)
  284.  
  285.     mov     ah,x0
  286.     mov     al,y0                   ;get coords
  287.     call    getmemxy                ;and find offset into screen mem
  288.     mov     DI,ax
  289.     mov     es,scrseg               ;ES:DI -> screen mem (UL corner)
  290. putdomove:
  291.     mov     cx, movword
  292.     push    ds
  293.     mov     ds, strdseg
  294.     rep     movsw                   ;move a row onto the screen
  295.     pop     ds
  296.     add     DI,160
  297.     sub     di,movword              ;add 160-(movword*2) to DI
  298.     sub     di,movword              ;to point to next row on screen
  299.     cmp     height,0                ;was that the last row?
  300.     je      putdone                 ;yes, we're finished
  301.     dec     height
  302.     jmp     putdomove               ;no, decrement and do again
  303. putdone:
  304.     pop     DI
  305.     pop     SI
  306.     pop     ES
  307.     pop     ds                      ;restore registers
  308.     pop     bp
  309.     ret     6                       ;pop off 3 parameters
  310. putcopybox endp
  311.  
  312. ;-----------------------------------------------------------------------------
  313. ;This is the routine that changes the attribute of the box's characters
  314. ;-----------------------------------------------------------------------------
  315.  
  316.     PUBLIC attrbox
  317.  
  318. attrbox         proc    far
  319.  
  320.     push    bp
  321.     mov     bp,sp
  322.     push    ds
  323.     push    ES
  324.     push    SI
  325.     push    di                      ;preserve registers
  326. atrstart:
  327.     mov     bx,[bp+14]              ;get y0
  328.     mov     ax,[bx]
  329.     mov     y0,al
  330.     mov     bx,[bp+12]              ;...x0
  331.     mov     ax,[bx]
  332.     mov     x0,al
  333.     mov     bx,[bp+10]              ;...y1
  334.     mov     ax,[bx]
  335.     mov     y1,al
  336.     mov     bx,[bp+8]               ;...x1
  337.     mov     ax,[bx]
  338.     mov     x1,al
  339.     mov     bx,[bp+6]               ;...and finally the new color value
  340.     mov     ax,[bx]
  341.     mov     attr,al
  342.     dec     y0                      ;subtract 1 from
  343.     dec     x0                      ;all coordinates
  344.     dec     y1                      ;to reflect BASIC's
  345.     dec     x1                      ;screen base of 1 (not 0)
  346. atrchkscr:
  347.     call    getscrseg               ;set up screen segment
  348. atrsetup:
  349.     mov     al,x1
  350.     sub     al,x0                   ;find width of box
  351.     inc     al
  352.     xor     ah,ah
  353.     mov     movword,ax              ;(width + 1 = movword)
  354.     mov     al,y1
  355.     sub     al,y0                   ;find height of box
  356.     mov     height,al               ;and save
  357. atrchgclr:
  358.     mov     al,y0
  359.     mov     ah,x0                   ;put coords in AH and AL
  360.     call    getmemxy                ;find offset into screen memory
  361.     mov     di,ax                   ;(which is our destination)
  362.     mov     ES,scrseg
  363.     mov     al,attr                 ;get the color value to store
  364. atrdoit:
  365.     mov     cx,movword
  366. atrloop:
  367.     inc     di                      ;skip the character value
  368.     stosb                           ;write new color value
  369.     loop    atrloop                 ;cx times
  370.     add     di,160                  ;add 160-(movword*2) to di
  371.     sub     di,movword
  372.     sub     di,movword
  373.     cmp     height,0                ;was that the last row?
  374.     je      atrdone                 ;yes, we be finished
  375.     dec     height                  ;no, decrement height
  376.     jmp     atrdoit
  377. atrdone:
  378.     pop     DI
  379.     pop     SI
  380.     pop     ES
  381.     pop     ds
  382.     pop     bp                      ;restore registers
  383.     ret     10                      ;pull off 5 paramters and return
  384. attrbox endp
  385.  
  386. ;-----------------------------------------------------------------------------
  387. ; This is the routine that changes the colors of the box's characters fg%,bg%
  388. ; can also fill with characers
  389. ; from here down is add to microsoft's uiasm
  390. ;
  391. ;-----------------------------------------------------------------------------
  392.  
  393.     PUBLIC colorwind
  394.  
  395. colorwind         proc    far
  396.     push    bp
  397.     mov     bp,sp
  398.     push    ds
  399.     push    ES
  400.     push    SI
  401.     push    di                      ;preserve registers
  402. colorstart:
  403.     mov     bx,[bp+20]              ;get y0
  404.     mov     ax,[bx]
  405.     mov     y0,al
  406.     mov     bx,[bp+18]              ;...x0
  407.     mov     ax,[bx]
  408.     mov     x0,al
  409.     mov     bx,[bp+16]              ;...y1
  410.     mov     ax,[bx]
  411.     mov     y1,al
  412.     mov     bx,[bp+14]              ;...x1
  413.     mov     ax,[bx]
  414.     mov     x1,al
  415.     mov     bx,[bp+12]              ;the new char value
  416.     mov     ax,[bx]
  417.     mov     fill,al
  418.     mov     bx,[bp+10]              ;the fill flag
  419.     mov     ax,[bx]
  420.     mov     fillflag,al
  421.     xor     ax,ax
  422.     mov     bx,[bp+6]           ; background color
  423.     mov     ax,[bx]             ; load color
  424.     mov     cl,04               ; shift length
  425.     shl     ax,cl               ; shift to proper position
  426.     mov     bx,[bp+8]           ; foreground color
  427.     mov     dx,[bx]             ;
  428.     and     dl,00010000b        ; leave blink attr only
  429.     mov     cl,03               ; shift length
  430.     shl     dx,cl               ; shift blink to correct position
  431.     add     ax,dx               ; this is attr
  432.     mov     dx,[bx]             ; reload forground
  433.     and     dl,00001111b        ; remove blink
  434.     add     ax,dx               ; completed attr
  435.     mov     attr,al             ; save it
  436.     cmp     byte ptr fillflag,2 ;return if not 0,1,2
  437.     jg      fillchgclr
  438.     dec     y0                  ;subtract 1 from
  439.     dec     x0                  ;all coordinates
  440.     dec     y1                  ;to reflect BASIC's
  441.     dec     x1                  ;screen base of 1 (not 0)
  442. colorchkscr:
  443.     call    getscrseg           ;set up screen segment
  444.     cmp     byte ptr fillflag,1
  445.     jg      fillchgclr          ;do char only
  446. colorsetup:
  447.     mov     al,x1
  448.     sub     al,x0               ;find width of box
  449.     inc     al
  450.     xor     ah,ah
  451.     mov     movword,ax          ;(width + 1 = movword)
  452.     mov     al,y1
  453.     sub     al,y0               ;find height of box
  454.     mov     height,al           ;and save
  455. colorchgclr:
  456.     mov     al,y0
  457.     mov     ah,x0               ;put coords in AH and AL
  458.     call    getmemxy            ;find offset into screen memory
  459.     mov     di,ax               ;which is destination
  460.     mov     ES,scrseg
  461.     mov     al,attr             ;get the color value to store
  462. colorit:
  463.     mov     cx,movword
  464. colorloop:
  465.     inc     di                  ;skip the character value
  466.     stosb                       ;write new color value
  467.     loop    colorloop           ;cx times
  468.     add     di,160              ;add 160-(movword*2) to di
  469.     sub     di,movword
  470.     sub     di,movword
  471.     cmp     height, 0           ;was that the last row?
  472.     je      colordone           ;yes, we be finished
  473.     dec     height              ;no, decrement height
  474.     jmp     colorit
  475. colordone:
  476.     cmp     byte ptr fillflag,1
  477.     je      filldone
  478. fillchgclr:
  479.     mov     al,x1
  480.     sub     al,x0               ;find width of box
  481.     inc     al
  482.     xor     ah,ah
  483.     mov     movword,ax          ;(width + 1 = movword)
  484.     mov     al,y1
  485.     sub     al,y0               ;find height of box
  486.     mov     height,al           ;and save
  487.     mov     al,y0
  488.     mov     ah,x0               ;put coords in AH and AL
  489.     call    getmemxy            ;find offset into screen memory
  490.     mov     di,ax               ;(which is our destination)
  491.     mov     ES,scrseg
  492.     mov     al,fill             ;get the color value to store
  493. filldoit:
  494.     mov     cx,movword
  495. fillloop:
  496.     stosb                       ;write new char value
  497.     inc     di                  ;skip the attrib value
  498.     loop    fillloop            ;cx times
  499.     add     di,160              ;add 160-(movword*2) to di
  500.     sub     di,movword
  501.     sub     di,movword
  502.     cmp     height,0            ;was that the last row?
  503.     je      filldone            ;yes, we be finished
  504.     dec     height              ;no, decrement height
  505.     jmp     filldoit
  506. filldone:
  507.     pop     DI
  508.     pop     SI
  509.     pop     ES
  510.     pop     ds
  511.     pop     bp                  ;restore registers
  512.     ret     16                  ;pull off 8 paramters and return
  513. colorwind endp
  514.     
  515. ;----------------------------------------------------------------------------
  516. ; print in color
  517. ;----------------------------------------------------------------------------
  518.     PUBLIC PNC
  519. ;----------------------------------------------------------------------------
  520. PNC     proc far
  521.  
  522.     push    bp
  523.     mov     bp,sp
  524.     push    ds
  525.     push    ES
  526.     push    SI
  527.     push    di                  ;preserve registers
  528. pncstart:
  529.     mov     bx,[bp+12]          ;...y1
  530.     mov     ax,[bx]
  531.     mov     y0,al
  532.     mov     bx,[bp+10]          ;...x1
  533.     mov     ax,[bx]
  534.     mov     x0,al
  535.     xor     ax,ax
  536.     mov     bx,[bp+6]           ; background color
  537.     mov     ax,[bx]             ; load color
  538.     mov     cl,04               ; shift length
  539.     shl     ax,cl               ; shift to proper position
  540.     mov     bx,[bp+8]           ; foreground color
  541.     mov     dx,[bx]             ;
  542.     and     dl,00010000b        ; leave blink attr only
  543.     mov     cl,03               ; shift length
  544.     shl     dx,cl               ; shift blink to correct position
  545.     add     ax,dx               ; this is attr
  546.     mov     dx,[bx]             ; reload forground
  547.     and     dl,00001111b        ; remove blink
  548.     add     ax,dx               ; completed attr
  549.     mov     attr,al             ; save it
  550.     mov     bx,[bp+14]          ;get the string descriptor
  551.     push    bx
  552.     call    STRINGADDRESS       ;for both near and far string support
  553.     mov     strdoff,ax
  554.     mov     strdseg,dx
  555.     mov     bx,[bp+14]          ;get the string descriptor again
  556.     push    bx                  ;save descriptor
  557.     call    STRINGLENGTH        ;for both near and far string support
  558.     mov     movword,ax          ;save string length
  559.     mov     cx,ax
  560.     jcxz    pncdone             ;ret if null string
  561.     dec     x0                  ;subtract 1 from
  562.     dec     y0                  ;all coordinates
  563. pncchkscr:
  564.     call    getscrseg           ;set up scrseg
  565. pncsetstr:
  566.     mov     ah, x0
  567.     mov     al,y0               ;get coords
  568.     call    getmemxy            ;and find offset into screen mem
  569.     mov     DI,ax
  570.     mov     es,scrseg           ;ES:DI -> screen mem (UL corner)
  571.     mov     cx,movword          ;get length of string
  572.     mov     si,strdoff          ;point SI to string offset
  573.     mov     ah,attr             ;get color attribute before seg change
  574.     mov     ds,strdseg          ;get string segment in DS:
  575. pncdomove:
  576.     mov     al,[si]             ;get char to print
  577.     stosw
  578.     inc     SI
  579.     loop    pncdomove
  580. pncdone:
  581.     pop     DI
  582.     pop     SI
  583.     pop     ES
  584.     pop     ds                  ;restore registers
  585.     pop     bp
  586.     ret     10                  ;pop off 5 parameters
  587. PNC endp
  588.  
  589. ;-----------------------------------------------------------------------------
  590.     PUBLIC Captal
  591. ;-----------------------------------------------------------------------------
  592. Blanktog        db      0
  593. leng            dw      0
  594. ;-----------------------------------------------------------------------------
  595.  
  596. Captal   PROC Far
  597.  
  598.     push    bp
  599.     mov     bp,sp
  600.     push    ds
  601.     push    ES
  602.     push    SI
  603.     push    di                  ;preserve registers
  604.     mov     bx,[bp+6]           ;descriptor to string into SI
  605.     push    bx                  ;save descriptor
  606.     call    STRINGLENGTH        ;for both near and far string support
  607.     mov     leng,ax             ;save string length
  608.     mov     cx,ax               ;put length into CX
  609.     ;or      cx,cx               ;is length 0
  610.     jcxz      Exit                ;exit
  611.     mov     bx,[bp+6]
  612.     push    bx
  613.     call    STRINGADDRESS       ;for both near and far string support
  614.     mov     cx,leng
  615.     mov     si,ax               ;address of string in SI
  616.     mov     ds,dx
  617.     mov     di,si               ;set up registers for data move
  618.     push    ds
  619.     pop     ES
  620.     mov     byte ptr Blanktog,00h   ;character is blank
  621. Next:   lodsb                        ;put character into AL
  622.     cmp     al,' '              ;is it a blank
  623.     je      Fndblnk             ;yes set switch
  624.     cmp     al,27h              ;is it a quote
  625.     jne     Noblnk              ;no, skip special
  626. Fndblnk:
  627.     mov     byte ptr Blanktog,00h   ;character is blank
  628.     jmp     Skib
  629. Noblnk:
  630.     cmp     byte ptr Blanktog,0FFh   ;is upper case or lower needed
  631.     je      Lowcase                  ;change to lower case
  632.     mov     byte ptr Blanktog,0FFh   ;reset switch
  633.     jmp     Upcase
  634. Lowcase:
  635.     cmp     al,'A'                   ;is it below "A"?
  636.     jb      Skib                     ;yes, skip
  637.     cmp     al,'Z'                   ;is it above "Z"?
  638.     ja      Skib                     ;yes, skip
  639.     or      al,20h                   ;turn on lower case bit
  640.     jmp     Skib
  641. Upcase:
  642.     cmp     al,'a'                  ;is it below "a"?
  643.     jb      Skib                    ;yes, skip it
  644.     cmp     al,'z'                  ;is it above "z"?
  645.     ja      Skib                    ;yes skip
  646.     and     al,0DFh                 ;turn off lower case bit
  647. Skib:
  648.     stosb                          ;put character back in string
  649.     Loop    Next                   ;do all char
  650. Exit:
  651.     pop     DI
  652.     pop     SI
  653.     pop     ES
  654.     pop     ds                  ;restore registers
  655.     pop     bp
  656.     
  657.     ret     2                   ;pop off 1 parameters
  658.  
  659. Captal endp
  660.  
  661. ;-----------------------------------------------------------------------------
  662. ; This is the routine that draws the box's with characters
  663. ;-----------------------------------------------------------------------------
  664. even
  665.  
  666. tlc     db      ?       ;store top left corner here
  667. trc     db      ?       ;store top right corner here
  668. brc     db      ?       ;store bottom right corner here
  669. blc     db      ?       ;store bottom left corner here
  670. vbc     db      ?       ;store vertical character here
  671. htc     db      ?       ;store horiz top character here
  672. hbc     db      ?       ;store horiz bottom character here
  673. clear   db      ?       ;store clear flag here
  674.  
  675.     PUBLIC drawwind
  676.  
  677. ;-----------------------------------------------------------------------------
  678.  
  679. drawwind  proc    far
  680.  
  681.     push    bp
  682.     mov     bp,sp
  683.     push    ds
  684.     push    ES
  685.     push    SI
  686.     push    di                  ;preserve registers
  687.     mov     bx,[bp+16]         ;get y0
  688.     mov     ax,[bx]
  689.     mov     y0,al
  690.     mov     bx,[bp+14]         ;x0
  691.     mov     ax,[bx]
  692.     mov     x0,al
  693.     mov     bx,[bp+12]         ;y1
  694.     mov     ax,[bx]
  695.     mov     y1,al
  696.     mov     bx,[bp+10]          ;x1
  697.     mov     ax,[bx]
  698.     mov     x1,al
  699.     mov     bx,[bp+6]          ;get clear flag first
  700.     mov     ax,[bx]
  701.     mov     clear,al
  702.     mov     bx,[bp+8]          ;now get frame type in al
  703.     mov     ax,[bx]
  704.     
  705. ;type 0 clears frame or entire window
  706.  
  707.     cmp     al,0 ;type 0  ,see type 4 for definition
  708.     jg      type1
  709.     mov     tlc,' '
  710.     mov     trc,' '
  711.     mov     brc,' '
  712.     mov     blc,' '
  713.     mov     vbc,' '
  714.     mov     htc,' '
  715.     mov     hbc,' '
  716.     jmp     drawstart
  717.  
  718. ;type 1 is single
  719.  
  720. type1:  cmp      al,1 ;type 1
  721.     jg      type2
  722.     mov     tlc,0dah
  723.     mov     trc,0bfh
  724.     mov     brc,0d9h
  725.     mov     blc,0c0h
  726.     mov     vbc,0b3h
  727.     mov     htc,0c4h
  728.     mov     hbc,0c4h
  729.     jmp     drawstart
  730.  
  731. ;type 2 is double
  732.  
  733. type2:
  734.     cmp     al,2 ;type 2
  735.     jg      type3
  736.     mov     tlc,0c9h
  737.     mov     trc,0bbh
  738.     mov     htc,0cdh
  739.     mov     brc,0bch
  740.     mov     blc,0c8h
  741.     mov     vbc,0bah
  742.     mov     hbc,0cdh
  743.     jmp     drawstart
  744.  
  745. ;type 3 is double top single sides
  746.  
  747. type3:
  748.     cmp     al,3 ;type 3
  749.     jg      type4
  750.     mov     tlc,0d5h
  751.     mov     trc,0b8h
  752.     mov     htc,0cdh
  753.     mov     brc,0beh
  754.     mov     blc,0d4h
  755.     mov     vbc,0b3h
  756.     mov     hbc,0cdh
  757.     jmp     drawstart
  758.  
  759. ;add next segment for each type you add and edit and remove comments
  760.  
  761. ;type 4 is solid top and bottom
  762.  
  763. type4:  ;add your type here
  764.  
  765.     ;cmp    al,4        ;add your type number here
  766.     ;jg     yourtype    ;example type5
  767.     mov     tlc,0dbh
  768.     mov     trc,0dbh
  769.     mov     brc,0dbh
  770.     mov     blc,0dbh
  771.     mov     vbc,' '
  772.     mov     htc,0dbh
  773.     mov     hbc,0dbh
  774.  
  775.     ;jmp    drawstart    ; leave all comments for last type
  776.  
  777. ;add your type before here
  778.  
  779. drawstart:
  780.  
  781.     dec     y0                  ;subtract 1 from
  782.     dec     x0                  ;all coordinates
  783.     dec     y1                  ;to reflect BASIC's
  784.     dec     x1                  ;screen base of 1 (not 0)
  785.     call    getscrseg           ;set up screen segment
  786. drawsetup:
  787.     mov     al,x1
  788.     sub     al,x0          ;find width of box
  789.     inc     al
  790.     xor     ah,ah
  791.     mov     movword,ax     ;width + 1 = movword
  792.     mov     al,y1
  793.     sub     al,y0          ;find height of box
  794.     mov     height, al      ;and save
  795. drawchgclr:
  796.     mov     al,y0
  797.     mov     ah,x0          ;put coords in AH and AL
  798.     call    getmemxy        ;find offset into screen memory
  799.     mov     di,ax          ;start pos to print
  800.     mov     es,scrseg      ; get screen seg
  801.     mov     al,tlc         ;get top left char
  802.     stosb                   ;print it
  803.     inc     DI
  804.     mov     cx,movword     ; characters to print per line
  805.     dec     cx              ; sub left and right char
  806.     dec     cx
  807.     mov     al,htc          ;get horiz top character
  808. drawtop:
  809.     stosb                   ;write new char value
  810.     inc     di              ;skip the attrib value
  811.     loop    drawtop         ;cx times
  812.     mov     al,trc          ;get top right character
  813.     stosb
  814.     inc     DI
  815. nextline:
  816.     add     di,160         ;add 160-(movword*2) to di
  817.     sub     di,movword
  818.     sub     di,movword
  819.     mov     cx,movword
  820.     dec     cx              ;adjust width count
  821.     mov     al,vbc          ;do left side
  822.     cmp     byte ptr clear,00h   ;clear if 1
  823.     je      noclear         ; don't clear window
  824. dosides:
  825.     stosb                   ;for blank window
  826.     inc     DI
  827.     mov     al,' '          ;user space char
  828.     loop    dosides
  829.     mov     al,vbc          ;side character
  830.     stosb                   ;do right side
  831.     inc     DI
  832.     dec     height          ;no, decrement height
  833.     cmp     height, 1       ;was that the last row?
  834.     jg      nextline
  835.     jmp     lastline
  836. noclear:               
  837.     stosb                  ;do left side first
  838.     dec     DI
  839. dorest:
  840.     inc     di             ;skip char
  841.     inc     di             ;skip attr
  842.     loop    dorest         ; loop width
  843.     mov     al,vbc
  844.     stosb                   ;do right side
  845.     inc     di              ;skip attr
  846.     dec     height          ;decrement height
  847.     cmp     height,1       ;was that the last row?
  848.     jg      nextline
  849. lastline:                       ;now do bottom frame
  850.     add     di,160         ;add 160-(movword*2) to di
  851.     sub     di,movword
  852.     sub     di,movword
  853.     mov     al,blc         ;get bottom left char
  854.     stosb                   ;print it
  855.     inc     DI
  856.     mov     cx,movword
  857.     dec     cx
  858.     dec     cx
  859.     mov     al,hbc          ;get horiz bottom character
  860. drawbot:
  861.     stosb                   ;write new char value
  862.     inc     di              ;skip the attrib value
  863.     loop    drawbot         ;cx times
  864.     mov     al,brc          ;get bottom right corner
  865.     stosb
  866. drawdone:
  867.     pop     DI
  868.     pop     SI
  869.     pop     ES
  870.     pop     ds
  871.     pop     bp              ;restore registers
  872.     ret     10              ;pull off 5 paramters and return
  873. drawwind endp
  874.  
  875. ;-----------------------------------------------------------------------------
  876.  
  877. ClrKeyBuf          PROC Far
  878.     
  879.     push    bp
  880.     mov     bp,sp
  881.     push    ds
  882.     push    ES
  883.     push    SI
  884.     push    di                  ;preserve registers
  885.     mov     ah,01h             ;check keyboard service
  886.     int     16h                ;call BIOS
  887. ClrKybd:
  888.     jz      Exit               ;exit if keyboard buffer is clear
  889.     mov     ah,00h             ;read keyboard service
  890.     int     16h                ;call BIOS
  891.     mov     ah,01h             ;check keyboard service
  892.     int     16h                ;call BIOS
  893.     jmp     ClrKybd            ;check for another key
  894. Exit:
  895.     pop     DI
  896.     pop     SI
  897.     pop     ES
  898.     pop     ds
  899.     pop     bp              ;restore registers
  900.     ret
  901. ClrKeyBuf endp
  902.  
  903. ;----------------------------------------------------------------------------
  904. emmname db              'EMMXXXX0'
  905. basseg  dw ?
  906. ;---------------------------------------------------------------------------
  907.  
  908.  
  909. ;       RomDate$        ROM revision date
  910.  
  911.         PUBLIC getromdate
  912.  
  913. getromdate      PROC Far
  914.     push    bp
  915.     mov     bp,sp
  916.     push    ds
  917.     push    ES
  918.     push    SI
  919.     push    di                 ;preserve registers
  920.  
  921.     mov     bx,[bp+6]
  922.     push    bx                 ;save descriptor
  923.     call    STRINGLENGTH       ;for both near and far string support
  924.     mov     cx,ax              ;put length into CX
  925.     cmp     cx,8
  926.     jl      exit               ;exit no room for date
  927.     mov     bx,[bp+6]
  928.     push    bx
  929.     call    STRINGADDRESS      ;for both near and far string support
  930.     mov     cx,8
  931.     mov     di,ax              ;address of string in DI
  932.     mov     ES,dx
  933.     mov     cx,8               ;length of move
  934.     mov     si,0FFF5h          ;offset of BIOS signature
  935.     mov     ax,0F000h;         ;segment of BIOS signature
  936.     mov     ds,ax              ;put it in DS
  937.     cld                        ;clear direction flag
  938.     rep     movsb              ;move it to parameter
  939.  
  940. Exit:
  941.     pop     DI
  942.     pop     SI
  943.     pop     ES
  944.     pop     ds                 ;restore registers
  945.     pop     bp
  946.     ret     2    
  947. getromdate endp
  948.  
  949. ;       Ram%            amount of base RAM
  950. ;       ExtRAM%         amount of Extended Memory
  951. ;       ExpRam          amount of Expanded memory
  952.  
  953.         PUBLIC getram
  954.  
  955. getram        PROC Far
  956.     push    bp
  957.     mov     bp,sp
  958.     push    ds
  959.     push    ES
  960.     push    SI
  961.     push    di                 ;preserve registers
  962.  
  963.     mov     ax,ds              ;save basic data segment
  964.     mov     basseg,ax
  965.     int     12h                ;call BIOS - conventional memory size service
  966.     mov     si,[bp+10]         ;address of parameter
  967.     mov     [si],ax            ;move ram size to parameter
  968.     push    cs
  969.     pop     ds                 ;restore DS
  970.     mov     ah,35h             ;get interrupt vector service
  971.     mov     al,67h             ;EMM vector
  972.     int     21h                ;call DOS
  973.     mov     di,0Ah             ;bump to device name
  974.     mov     si,offset emmname  ;point to EMM mgr name
  975.     mov     cx,8               ;compare length
  976.     cld                        ;clear direction flag
  977.     repz    cmpsb              ;it is correct name
  978.     jnz     NoEMM              ;no
  979.     mov     ah,42h             ;request number of pages
  980.     int     67h                ;call EMM driver
  981.     or      ah,ah              ;was call successful?
  982.     mov     ds,basseg
  983.     jnz     NoEMM              ;no expanded memory
  984.     mov     si,[bp+6]          ;point to EMM parm
  985.     mov     [si],dx            ;DX has number of 16K pages of Exp mem
  986.     jmp     GetExtMem          ;look for extended memory
  987.  
  988. NoEMM:
  989.  
  990.     mov     ds, basseg
  991.     mov     si,[bp+6]          ;point to EMM parm
  992.     mov     word ptr [si],0    ;indicate no expanded memory
  993.  
  994. GetExtMem:
  995.  
  996.     mov     si,[bp+8]          ;Extended memory parm
  997.     mov     word ptr [si],0    ;indicate no extended memory
  998.     mov     ax,0F000h
  999.     mov     ES,ax
  1000.     mov     di,0fffeh
  1001.     mov     al,byte ptr es:[di] ;get machine id
  1002.     cmp     al,0FCh             ;is this an AT?
  1003.     jne     notat               ;get number of hard disks
  1004.     mov     al,31h              ;if at get extmem from cmos
  1005.     out     70h,al              ;setup reg
  1006.     jmp     $+2                 ;delay
  1007.     in      al,71h
  1008.     xchg    al,ah
  1009.     mov     al,30h
  1010.     out     70h,al
  1011.     jmp     $+2                 ;delay
  1012.     in      al,71h
  1013.     mov     ds,basseg
  1014.     mov     SI,[bp+8]
  1015.     mov     [si],ax             ;move to parm
  1016. notat:
  1017.     pop     DI
  1018.     pop     SI
  1019.     pop     ES
  1020.     pop     ds                      ;restore registers
  1021.     pop     bp
  1022.     ret     6
  1023.  
  1024. getram endp
  1025.  
  1026. ;       LPT%            number of parallel ports
  1027.  
  1028.         PUBLIC getnumlpt
  1029.  
  1030. getnumlpt        PROC Far
  1031.     push    bp
  1032.     mov     bp,sp
  1033.     push    ds
  1034.     push    ES
  1035.     push    SI
  1036.     push    di                 ;preserve registers
  1037.     int     11h                ;call BIOS - equipment list
  1038.     and     ax,0C000h          ;clear all but number of LPT
  1039.     mov     cl,14              ;shift length
  1040.     shr     ax,cl              ;adjust it
  1041.     pop     di
  1042.     pop     si
  1043.     pop     ES
  1044.     pop     ds                      ;restore registers
  1045.     pop     bp
  1046.     ret    
  1047. getnumlpt endp
  1048.  
  1049. ;       Com%         number of serial ports
  1050.  
  1051.         PUBLIC getnumcom
  1052.  
  1053. getnumcom    PROC Far
  1054.     push    bp
  1055.     mov     bp,sp
  1056.     push    ds
  1057.     push    ES
  1058.     push    SI
  1059.     push    di                 ;preserve registers
  1060.  
  1061.     int     11h                ;call BIOS - equipment list
  1062.     and     ax,0E00h           ;clear all but number of serial ports
  1063.     mov     cl,9               ;shift length
  1064.     shr     ax,cl              ;adjust it
  1065.     
  1066.     pop     DI
  1067.     pop     SI
  1068.     pop     ES
  1069.     pop     ds                  ;restore registers
  1070.     pop     bp
  1071.     ret    
  1072. getnumcom endp
  1073.  
  1074. ;      GetNoFlop%       number of floppy drives
  1075.  
  1076.         PUBLIC getnumflop
  1077.  
  1078. getnumflop       PROC Far
  1079.     push    bp
  1080.     mov     bp,sp
  1081.     push    ds
  1082.     push    ES
  1083.     push    SI
  1084.     push    di                 ;preserve registers
  1085.  
  1086.     int     11h                ;call BIOS - equipment list
  1087.     and     ax,11000000b       ;clear all but diskette drives
  1088.     mov     cl,6               ;shift length
  1089.     shr     ax,cl              ;adjust it
  1090.     inc     ax                 ;bump it by one
  1091. nodrives:      
  1092.     pop     DI
  1093.     pop     SI
  1094.     pop     ES
  1095.     pop     ds                 ;restore registers
  1096.     pop     bp
  1097.     ret    
  1098. getnumflop endp
  1099.  
  1100. ;       Gameport%       number of game ports
  1101.  
  1102.         PUBLIC getnumgames
  1103.  
  1104. getnumgames      PROC Far
  1105.     push    bp
  1106.     mov     bp,sp
  1107.     push    ds
  1108.     push    ES
  1109.     push    SI
  1110.     push    di                 ;preserve registers
  1111.  
  1112.     int     11h                ;call BIOS - equipment list
  1113.     and     ax,1000000000000b  ;clear all but game port
  1114.     mov     cl,12              ;shift length
  1115.     shr     ax,cl              ;adjust it
  1116.  
  1117.     pop     DI
  1118.     pop     SI
  1119.     pop     ES
  1120.     pop     ds                  ;restore registers
  1121.     pop     bp
  1122.     ret    
  1123. getnumgames endp
  1124.  
  1125. ;  GetNoHard%          number of hard disks
  1126.  
  1127.         PUBLIC getnumhard
  1128.  
  1129. getnumhard      PROC Far
  1130.     push    bp
  1131.     mov     bp,sp
  1132.     push    ds
  1133.     push    ES
  1134.     push    SI
  1135.     push    di                  ;preserve registers
  1136.  
  1137.     mov     ax,40h              ;segment of disk info
  1138.     mov     es,ax               ;initialize ES
  1139.     mov     bx,75h
  1140.     mov     al,byte ptr es:[bx] ;nunber of drives
  1141.     pop     DI
  1142.     pop     SI
  1143.     pop     ES
  1144.     pop     ds                  ;restore registers
  1145.     pop     bp
  1146.     ret    
  1147.  
  1148. getnumhard endp
  1149.  
  1150. ;---------------------------------
  1151. flags   db      8 dup(0)
  1152. ;---------------------------------
  1153. ; set and get flags
  1154. ;---------------------------------
  1155.  
  1156. Clearall  PROC Far
  1157.     push    bp
  1158.     mov     bp,sp
  1159.     push    ds
  1160.     push    ES
  1161.     push    SI
  1162.     push    di                  ;preserve registers
  1163.     mov     DI,OFFSET cs:flags
  1164.     mov     cx,4
  1165.     xor     ax,ax
  1166.     rep     stosw
  1167.     pop     DI
  1168.     pop     SI
  1169.     pop     ES
  1170.     pop     ds
  1171.     pop     bp              ;restore registers
  1172.     ret
  1173.  
  1174. Clearall endp
  1175.  
  1176. ;-----------------------------------------------------------------------------
  1177.  
  1178. Resetflag  PROC Far
  1179.     
  1180.     push    bp
  1181.     mov     bp,sp
  1182.     push    ds
  1183.     push    ES
  1184.     push    SI
  1185.     push    di                  ;preserve registers
  1186.     mov     SI,[bp+6]
  1187.     CALL    doflags
  1188.     jc      exitclear
  1189.     not     al
  1190.     and     cs:[flags+bx],al
  1191. exitclear:    
  1192.     pop     DI
  1193.     pop     SI
  1194.     pop     ES
  1195.     pop     ds
  1196.     pop     bp              ;restore registers
  1197.     ret     2
  1198. Resetflag endp
  1199.  
  1200. ;-----------------------------------------------------------------------------
  1201.  
  1202. Setflag  PROC Far
  1203.     push    bp
  1204.     mov     bp,sp
  1205.     push    ds
  1206.     push    ES
  1207.     push    SI
  1208.     push    di                  ;preserve registers
  1209.     mov     SI,[bp+6]
  1210.     CALL    doflags
  1211.     jc      exitset
  1212.     or      cs:[flags+bx],al
  1213. exitset:      
  1214.     pop     DI
  1215.     pop     SI
  1216.     pop     ES
  1217.     pop     ds
  1218.     pop     bp              ;restore registers
  1219.     ret     2
  1220.  
  1221. setflag endp
  1222.  
  1223. ;-----------------------------------------------------------------------------
  1224.  
  1225. Getflag  PROC Far
  1226.     push    bp
  1227.     mov     bp,sp
  1228.     push    ds
  1229.     push    ES
  1230.     push    SI
  1231.     push    di                  ;preserve registers
  1232.     mov     SI,[bp+6]
  1233.     CALL    doflags
  1234.     test    cs:[flags+bx], al
  1235.     mov     ax,0
  1236.     jz      exitget
  1237.     dec     ax
  1238. exitget:      
  1239.     pop     DI
  1240.     pop     SI
  1241.     pop     ES
  1242.     pop     ds
  1243.     pop     bp              ;restore registers
  1244.     ret     2
  1245. Getflag endp
  1246.  
  1247. ;---------------------------------------------------------------------------
  1248.  
  1249. Doflags proc    near
  1250.     mov     ax,[SI]
  1251.     dec     ax
  1252.     cmp     ax,63
  1253.     ja      doerror
  1254.     push    ax
  1255.     mov     cx,8
  1256.     xor     dx,dx
  1257.     div     cx
  1258.     mov     bx,ax
  1259.     mov     al,1
  1260.     pop     cx
  1261.     rol     al,cl
  1262.     clc
  1263.     ret
  1264. doerror:
  1265.     stc
  1266.     ret
  1267. doflags endp
  1268.  
  1269.  
  1270.         PUBLIC  CPUcheck
  1271. CPUcheck     proc   FAR             ;Test CPU-Type (offical INTEL Method)
  1272.  
  1273.     push    bp
  1274.     mov     bp,sp
  1275.     push    ds
  1276.     push    ES
  1277.     push    SI
  1278.     push    di                 ;preserve registers
  1279.  
  1280.     xor     ax,ax              ;Push 0
  1281.     push    ax                 ;on Stack
  1282.     popf                       ;pop Flags
  1283.     pushf                      ;Push flags
  1284.     pop     ax                 ;0 in AX
  1285.     and     ax,0F000h          ;0 Bits 11-8
  1286.     cmp     ax,0F000h          ;
  1287.     je      MC_8086            ;8086
  1288.  
  1289.     mov     ax,0F000h          ;Push f000
  1290.     push    ax                 ;Stack
  1291.     popf                       ;Flags
  1292.     pushf                      ;Stack
  1293.     pop     ax                 ;AX from Stack
  1294.     and     ax,0F000h          ;0 Bits 11-8
  1295.     jz      MC_80286           ;80286
  1296.  
  1297.     mov     ax,3               ;Set AX=3 for 80386/80386SX/80486
  1298.     jp      CPUdone            ;End
  1299.  
  1300. mc_80286:
  1301.     mov     ax,2               ;Set AX=2 for 80286
  1302.     jp      CPUdone            ;end
  1303.  
  1304. mc_8086:
  1305.     mov     ax,1               ;set AX=1 for 8086/8088
  1306.  
  1307. CPUdone:
  1308.     pop     DI
  1309.     pop     SI
  1310.     pop     ES
  1311.     pop     ds
  1312.     pop     bp                 ;restore registers
  1313.  
  1314.     ret                        ;end
  1315.  
  1316. CPUcheck     endp
  1317.         
  1318.  
  1319.         PUBLIC  VIDEOcheck
  1320.  
  1321. VIDEOcheck     proc   FAR       ;Test video adapter
  1322.  
  1323.     push    bp
  1324.     mov     bp,sp
  1325.     push    ds
  1326.     push    es
  1327.     push    si
  1328.     push    di              ;preserve registers
  1329.     
  1330.     mov     ax,1A00H        ;Read display combination code
  1331.     int     10h
  1332.     cmp     al,1AH          ;Is VGA or MCGA present?
  1333.     jne     novga
  1334.     mov     ax,7            ;Set bit for MCGA adapter
  1335.     cmp     bl,0BH          ;Is it model 30 with mono?
  1336.     mov     ax,8
  1337.     je      setbits
  1338.     cmp     bl,0CH          ;Is it model 30 with color?
  1339.     mov     ax,9
  1340.     je      setbits
  1341.     mov     ax,6            ;Set bit for VGA adapter
  1342.     cmp     bl,7            ;Is it VGA mono?
  1343.     je      setbits
  1344.     cmp     bl,8            ;Is it VGA color?
  1345.     mov     ax,5
  1346.     je      setbits
  1347.  
  1348. novga:
  1349.     xor     dh,dh
  1350.     mov     ah,0B8H         ;Look for a color adapter
  1351.     call    lookforcard
  1352.     jne     nocolor
  1353.     mov     ax,3            ;Set bit for color adapter
  1354.     jmp     setbits
  1355. nocolor:
  1356.     mov     ah,0B0H         ;Look for mono adapter
  1357.     call    lookforcard
  1358.     jne     nomono
  1359.     mov     ax,1            ;Set bit for mono adapter
  1360.     jmp     setbits
  1361. nomono:
  1362.     mov     ah,12H
  1363.     mov     bl,10H          ;BIOS get EGA info function
  1364.     int     10H
  1365.     cmp     bl,10H          ;Did BL change?
  1366.     mov     ax,0
  1367.     je      setbits         ;If not, no EGA present
  1368.     mov     ax,4            ;set bit for EGA mono only
  1369.  
  1370. setbits:
  1371.  
  1372.     pop     di
  1373.     pop     si
  1374.     pop     es
  1375.     pop     ds
  1376.     pop     bp                 ;restore registers
  1377.  
  1378.     ret                        ;end
  1379.  
  1380. VIDEOcheck     endp
  1381.  
  1382. ;---------------------------------------------------------------------
  1383. ; This routine examines memory to look for a display card.
  1384. ;---------------------------------------------------------------------
  1385.  
  1386. lookforcard     proc    near
  1387.  
  1388.     xor     si,si           ;Look at offset zero
  1389.     push    ds
  1390.     xor     al,al
  1391.     mov     ds,ax           ;Load the segment register
  1392.     mov     ch,[si]         ;Store the initial value
  1393.     mov     al,55H
  1394.     mov     [si],al         ;Write pattern of ones and zeros
  1395.     jmp     delay   ;A short delay
  1396. delay:
  1397.     mov     ah,[SI]         ;Read the byte we just wrote
  1398.     mov     [si],ch         ;Restore the initial value
  1399.     pop     ds
  1400.     cmp     al,ah           ;Did it match?
  1401.     ret
  1402.  
  1403. lookforcard     endp
  1404.         
  1405. end
  1406.  
  1407.