home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / CreativeComputers.iso / shareware / text / dvi_3.62 / source / dvisrc.lha / dvihgc.asm < prev    next >
Assembly Source File  |  1993-07-09  |  3KB  |  128 lines

  1.         .MODEL large
  2.         PUBLIC    _hgc_graphics
  3.  
  4. ; Set graphics mode for hercules card. From the book
  5. ; Programmer's Guide to PC&PS/2 Video Systems by Richard Wilton
  6.  
  7. ; changes by Gerhard Wilhelms:
  8. ;     converted to Turbo Assembler
  9. ;     converted for huge model caller
  10. ;     removed errors
  11. ;     automatic screen clear
  12.  
  13.         .DATA
  14.  
  15. ; These are the parameters recommended by Hercules.
  16. ; They are based on 16 pixels/character and
  17. ; 4 scan lines per character.
  18.  
  19. CRTCParms    DB    00h,35h    ; Horizontal Total:  54 characters
  20.         DB    01h,2Dh    ; Horizontal Displayed:  45 characters
  21.         DB    02h,2Eh    ; Horizontal Sync Position:  at 46th character
  22.         DB    03h,07h    ; Horizontal Sync Width:  7 character clocks
  23.  
  24.         DB    04h,5Bh    ; Vertical Total:  92 characters (368 lines)
  25.         DB    05h,02h    ; Vertical Adjust:  2 scan lines
  26.         DB    06h,57h    ; Vertical Displayed:  87 character rows (348 lines)
  27.         DB    07h,57h    ; Vertical Sync Position:  after 87th char row
  28.  
  29.         DB    09h,03h    ; Max Scan Line:  4 scan lines per char
  30.  
  31. CRTCParmsLen    EQU    9
  32.  
  33. BIOSData    DB    7    ; CRT_MODE
  34.         DW    80    ; CRT_COLS
  35.         DW    8000h    ; CRT_LEN
  36.         DW    0    ; CRT_START
  37.         DW    8 dup(0) ; CURSOR_POSN
  38.         DW    0    ; CURSOR_MODE
  39.         DB    0    ; ACTIVE_PAGE
  40. CRTCAddr    DW    3B4h    ; ADDR_6845
  41. CRTMode        DB    0Ah    ; CRT_MODE_SET (value for port 3B8h)
  42.         DB    0    ; CRT_PALETTE (unused)
  43.  
  44. BIOSDataLen    EQU    26
  45.  
  46.         .CODE
  47. _hgc_graphics    PROC    FAR
  48.  
  49.         push    bp        ; preserve caller registers
  50.         mov    bp,sp
  51.         push    si
  52.         push    di
  53.         push    ds
  54.         push    es
  55.         push    bx
  56.  
  57. ; Update Video BIOS Data Area with reasonable values
  58.  
  59.         mov    ax,40h
  60.         mov    es,ax
  61.         mov    di,49h        ; ES:DI := 0040:0049 (BIOS data area)
  62.  
  63.         mov    bx,SEG BIOSData
  64.         mov    ds,bx
  65.         mov    si,OFFSET BIOSData
  66.         mov    cx,BIOSDataLen
  67.         rep    movsb        ; update BIOS data area
  68.  
  69. ; Set Configuration Switch
  70.  
  71.         mov    dx,3BFh        ; DX := Configuration Switch port
  72.         mov    al,1        ; AL bit 1 := 0 (exclude 2nd 32K of
  73.                     ;          video buffer)
  74.                     ; AL bit 0 := 1 (allow graphics mode
  75.         out    dx,al        ;         setting via 3B8h)
  76.  
  77. ; Blank the screen to avoid interference during CRTC programming
  78.  
  79.         mov    dx,3B8h        ; DX := CRTC Mode Control Register port
  80.         xor    al,al        ; AL bit 3 := 0 (disable video signal)
  81.         out    dx,al        ; blank the screen
  82.  
  83. ; Program the CRTC
  84.  
  85.         sub    dl,4        ; DX := CRTC Address Reg port 3B4h
  86.  
  87.         mov    bx,SEG CRTCParms
  88.         mov    ds,bx
  89.         mov    si,OFFSET CRTCParms
  90.         mov    cx,CRTCParmsLen
  91.  
  92. L01:        lodsw            ; AL := CRTC register number
  93.                     ; AH := data for this register
  94.         out    dx,ax
  95.         loop    L01
  96.  
  97. ; Set graphics mode
  98.  
  99.         add    dl,4        ; DX := 3B8h (CRTC Mode Control Reg)
  100.         mov    al,CRTMode    ; AL bit 1 = 1 (enable graphics mode)
  101.                     ;    bit 3 = 1 (enable video)
  102.         out    dx,al
  103.  
  104. ; Clear screen
  105.  
  106.         mov     bx,0B000h    ; establish video addressing
  107.         mov    es,bx
  108.         xor    di,di
  109.         xor    ax,ax        ; fill pattern, blank
  110. fill_loop:    mov    cx,1000h    ; CX:=#words in each screen part
  111.         rep    stosw        ; fill buffer, increment DI by 2000h
  112.         or    di,di
  113.         jns    fill_loop    ; jump, if DI<8000h
  114.  
  115.         pop    bx
  116.         pop    es
  117.         pop    ds
  118.         pop    di        ; restore registers and exit
  119.         pop    si
  120.         mov    sp,bp
  121.         pop    bp
  122.         ret
  123.  
  124. _hgc_graphics    ENDP
  125.  
  126.  
  127.         END
  128.