home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / MSMOUSE1.ZIP / PAS.ZIP / INITPAS.ASM next >
Encoding:
Assembly Source File  |  1989-02-10  |  3.9 KB  |  152 lines

  1. ;----------------------------------------------------------------
  2. ; INITPAS.ASM - Support code for MOUSHGCP.PAS
  3. ;
  4. ; Illustrates the recommended technique for changing
  5. ; modes (text or graphics) on the Hercules Graphics Card.
  6. ; Pay particular attention to the two tables (ttable, and
  7. ; gtable) that contain the suggested 6845 values for text
  8. ; and graphics modes.
  9. ;
  10. ; NOTE: Be sure that the Configuration Port (03BF) is set to your
  11. ; requirements (03BF = 1 for HALF, 03BF = 3 for FULL) before
  12. ; attempting to set graphics mode.
  13. ;----------------------------------------------------------------
  14. ;
  15. DGROUP  GROUP _DATA
  16. ;               port address
  17. index           equ             03b4h
  18. cntrl           equ             03b8h
  19.  
  20. ;               control codes
  21. scrn_on         equ             8
  22. grph            equ             2
  23. text            equ             20h
  24.  
  25. _DATA   segment word public 'DATA'
  26. gtable  db      35h,2dh,2eh,07h
  27.                 db      5bh,02h,57h,57h
  28.                 db      02h,03h,00h,00h
  29.  
  30. ttable  db      61h,50h,52h,0fh
  31.                 db      19h,06h,19h,19h
  32.                 db      02h,0dh,0bh,0ch
  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
  40. ; graphics mode. The active page for both writing and display is set
  41. ; to the default value of page 0.
  42. ; ON ENTRY - no parameters.
  43. ;*********************************************************************
  44.  
  45.         public  gmode
  46. gmode   proc    far
  47.  
  48.         push    si              ; Pascal requires that SI/DI not be modified
  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              ; Restore SI/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    far
  74.  
  75.         push    si              ; Pascal requires that DI/SI not be modified
  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              ; Restore DI/SI
  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 clear
  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. ;     initialize the 6845
  109.  
  110.         mov     dx,index
  111.         mov     cx,12           ;12 parameters to
  112.                                 ;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.