home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / MOUSE / MSMOUSE1.ZIP / HGC.ZIP / C.ZIP / INIT.ASM next >
Encoding:
Assembly Source File  |  1989-02-10  |  2.7 KB  |  152 lines

  1. ;  INIT.ASM - This code illustrates the recommended technique
  2. ;             for changing modes (text or graphics) on the Hercules Graphics
  3. ;             Card. Pay particular attention to the two tables - ttable, and
  4. ;             gtable - which contain the suggested 6845 values for text and
  5. ;             graphics modes.
  6. ;
  7. ;             NOTE: Be sure that the Configuration Port (03BF) is set to your
  8. ;             requirements (03BF = 1 for HALF, 03BF = 3 for FULL) before
  9. ;             attempting to set graphics mode.
  10.  
  11. DGROUP    GROUP _DATA
  12.  
  13. ;        port address
  14. index        equ        03b4h
  15. cntrl                equ        03b8h
  16.  
  17. ;        control    codes
  18. scrn_on           equ        8
  19. grph               equ        2
  20. text               equ        20h
  21.  
  22. _DATA    segment word public 'DATA'
  23.  
  24. gtable    db    35h,2dh,2eh,07h
  25.         db    5bh,02h,57h,57h
  26.         db    02h,03h,00h,00h
  27.  
  28. ttable    db    61h,50h,52h,0fh
  29.         db    19h,06h,19h,19h
  30.         db    02h,0dh,0bh,0ch
  31.  
  32.  
  33. _DATA     ENDS
  34. ;
  35. _TEXT    segment public byte 'CODE'
  36.     ASSUME CS:_TEXT, DS:DGROUP, SS:DGROUP
  37.  
  38. ;*********************************************************************
  39. ;GRAPHICS MODE - Programs the 6845 CRT controller for the 720 x 348 graphics
  40. ;mode. The active page for both writing and display is set to the default value
  41. ;of page 0.
  42. ;ON ENTRY - no parameters.
  43. ;*********************************************************************
  44.  
  45.      public  _gmode
  46. _gmode  proc near
  47.  
  48.     push    si
  49.     push    di
  50.  
  51.     mov    al,1
  52.     mov    dx, 3bfh
  53.     out    dx, al
  54.     mov    al,grph
  55.     lea    si,gtable
  56.     mov    bx,0
  57.     mov    cx,4000h
  58.     call    setmd
  59.  
  60.     pop    di
  61.     pop    si
  62.  
  63.     ret
  64.  
  65. _gmode    endp
  66.  
  67. ;**********************************************************************
  68. ;TEXT MODE - Programs the 6845 and control register to produce text mode.
  69. ;
  70. ;ON ENTRY - no parameters.
  71. ;***********************************************************************
  72.     public    _tmode
  73. _tmode proc near
  74.  
  75.     push    si
  76.     push    di
  77.  
  78.     mov    al,text
  79.     lea    si,ttable
  80.     mov    bx,720h
  81.     mov    cx,2000
  82.     call    setmd
  83.  
  84.     pop    di
  85.     pop    si
  86.  
  87.     ret
  88.  
  89. _tmode    endp
  90.  
  91. setmd    proc    near
  92.  
  93. ;     sets mode to graphics or text
  94. ;     depending on al
  95. ;     si = parameter table
  96. ;     cx = number of words to be cleared
  97. ;     bx = blank value
  98.     push    ds
  99.     push    es
  100.     push    ax
  101.     push    bx
  102.     push    cx
  103.  
  104. ;     change mode but without scrn_on
  105.     mov    dx,cntrl
  106.     out    dx,al
  107.  
  108. ;     intialize the 6845
  109.  
  110.     mov    dx,index
  111.     mov    cx,12        ;12 parameters to
  112.                 ;be output
  113.     xor    ah,ah        ;starting from
  114.                 ;reg. 0
  115. parms:    mov    al,ah
  116.     out    dx,al        ;output register
  117.                 ;number
  118.     cld
  119.  
  120.     inc    dx
  121.     lodsb
  122.     out    dx,al        ;output data
  123.  
  124.     inc    ah        ;next value
  125.     dec    dx
  126.     loop    parms
  127.  
  128.     pop    cx        ;clear the buffer
  129.     mov    ax,0b000h
  130.  
  131.     mov    es,ax
  132.     xor    di,di
  133.     pop    ax
  134.     rep    stosw
  135.  
  136. ;     scrn_on, page 0
  137.  
  138.     mov    dx,cntrl
  139.     pop    ax
  140.     add    al,scrn_on
  141.     out    dx,al
  142.  
  143.     pop    es
  144.     pop    ds
  145.  
  146.     ret
  147.  
  148. setmd    endp
  149. _TEXT    ends
  150.  
  151.       END
  152.