home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cl5sr386.zip / GO32 / VGA.ASM < prev    next >
Assembly Source File  |  1992-04-13  |  4KB  |  194 lines

  1. ; This is file VGA.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15.     .386p
  16.     include    segdefs.inc
  17.  
  18.     start_data16
  19.     assume    cs:DGROUP
  20.  
  21.     public    _builtin_gr_driver
  22. _builtin_gr_driver:
  23.  
  24.     dw    offset init_routine
  25.     dw    offset paging_routine
  26.     dw    1    ; set to 1 if separate read & write windows or
  27.             ; only 64K of video RAM (ie: no paging)
  28.  
  29. def_tw    dw    80    ; filled in by go32 if GO32 env. var. is set
  30. def_th    dw    25
  31. def_gw    dw    320
  32. def_gh    dw    200
  33.  
  34. ;--------------------------------------------------------------------------
  35. ; Entry: AX=mode selection
  36. ;        0=80x25 text
  37. ;        1=default text
  38. ;        2=text CX cols by DX rows
  39. ;        3=biggest text
  40. ;        4=320x200 graphics
  41. ;        5=default graphics
  42. ;        6=graphics CX width by DX height
  43. ;        7=biggest non-interlaced graphics
  44. ;        8=biggest graphics
  45. ;
  46. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  47. ;
  48. ; Exit:  CX=width (in pixels or characters)
  49. ;        DX=height
  50.  
  51. init_table    label    word
  52.     dw    offset init_0
  53.     dw    offset init_1
  54.     dw    offset init_2
  55.     dw    offset init_3
  56.     dw    offset init_4
  57.     dw    offset init_5
  58.     dw    offset init_6
  59.     dw    offset init_7
  60.     dw    offset init_8
  61.  
  62. init_routine    proc    far
  63.     cmp    ax,8
  64.     jbe    valid_req
  65.     ret
  66. valid_req:
  67.     shl    ax,1
  68.     mov    bx,ax
  69.     jmp    init_table[bx]
  70.  
  71. init_0: ; 80x25 text
  72.     mov    ax,3
  73.     int    10h
  74.     mov    cx,80
  75.     mov    dx,25
  76.     ret
  77.  
  78. init_1: ; default text
  79.     mov    cx,def_tw
  80.     mov    dx,def_th
  81.     jmp    init_2
  82.  
  83. init_2_table    label    word
  84.     dw    01h, 40, 25
  85.     dw    03h, 80, 25
  86. init_2_tend    label    word
  87.  
  88. init_2: ; CX*DX text
  89.     mov    si,offset init_2_table
  90. init_2a:
  91.     cmp    [si+2],cx
  92.     jb    init_2b
  93.     cmp    [si+4],dx
  94.     jb    init_2b
  95.     ; got a big enough one!
  96.     jmp    init_2c
  97. init_2b:
  98.     cmp    si,offset init_2_tend - 6
  99.     je    init_2c
  100.     add    si,6
  101.     jmp    init_2a
  102. init_2c:
  103.     mov    ax,[si]
  104.     push    si
  105.     int    10h
  106.     pop    si
  107.     mov    cx,[si+2]
  108.     mov    dx,[si+4]
  109.     ret
  110.  
  111. init_3: ; biggest text
  112.     mov    ax,[init_2_tend-6]
  113.     int    10h
  114.     mov    cx,[init_2_tend-4]
  115.     mov    dx,[init_2_tend-2]
  116.     ret
  117.  
  118. init_4: ; 320x200 graphics
  119.     mov    ax,13h
  120.     int    10h
  121.     mov    cx,320
  122.     mov    dx,200
  123.     ret
  124.  
  125. init_5: ; default graphics - should be 640x480 if supported
  126.     mov    cx,def_gw
  127.     mov    dx,def_gh
  128.     jmp    init_6
  129.  
  130. init_6_table    label    word
  131.     dw    13h, 320, 200
  132. init_6_tend    label    word
  133.  
  134. init_6: ; CX*DX graphics
  135.     mov    si,offset init_6_table
  136. init_6a:
  137.     cmp    [si+2],cx
  138.     jb    init_6b
  139.     cmp    [si+4],dx
  140.     jb    init_6b
  141.     ; got a big enough one!
  142.     jmp    init_6c
  143. init_6b:
  144.     cmp    si,offset init_6_tend - 6
  145.     je    init_6c
  146.     add    si,6
  147.     jmp    init_6a
  148. init_6c:
  149.     mov    ax,[si]
  150.     push    si
  151.     int    10h
  152.     pop    si
  153.     mov    cx,[si+2]
  154.     mov    dx,[si+4]
  155.     ret
  156.  
  157. init_7: ; biggest non-interlaced graphics
  158.     mov    ax,13h
  159.     int    10h
  160.     mov    cx,320
  161.     mov    dx,200
  162.     ret
  163.  
  164. init_8: ; biggest graphics
  165.     mov    ax,13h
  166.     int    10h
  167.     mov    cx,320
  168.     mov    dx,200
  169.     ret
  170.  
  171. init_routine    endp
  172.  
  173. ;--------------------------------------------------------------------------
  174. ; Entry: AH=read page
  175. ;        AL=write page
  176. ;
  177. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  178. ; This code must be relocatable and may not reference any data!
  179. ;
  180. ; Exit: VGA configured.
  181. ;       AX,BX,CX,DX,SI,DI may be trashed
  182.  
  183.     assume    ds:nothing, es:nothing
  184.  
  185. paging_routine    proc    far
  186.  
  187.     ret
  188. paging_routine    endp
  189.  
  190. ;--------------------------------------------------------------------------
  191.  
  192.     end_data16
  193.     end
  194.