home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / VOGLE / DRIVERS / IBMPC / HGCCHAR.ASM < prev    next >
Assembly Source File  |  2000-02-11  |  3KB  |  126 lines

  1.  
  2. ;
  3. ; Name:        _hgcchar
  4. ;
  5. ; Function: Display a character in Hercules 720*348 monochrome graphics mode
  6. ;
  7. ; Call:        Microsoft C:
  8. ;
  9. ;            void
  10. ;            hgcchar(c, x, y, fgd, bkgd)
  11. ;                int    c;        /* character code */
  12. ;                int    x, y;        /* upper left pixel */
  13. ;                int    fgd, bkgd;    /* fore and background
  14. ;                              pixel values */
  15. ;
  16.  
  17. ARGC        equ    word ptr [bp+6]    ; stack frame addressing
  18. ARGX        equ    word ptr [bp+8]
  19. ARGY        equ    word ptr [bp+10]
  20. ARGFGD        equ    byte ptr [bp+12]
  21. ARGBKGD        equ    byte ptr [bp+14]
  22.  
  23. VARmask        equ         [bp-8]
  24. VARtoggle    equ         [bp-10]
  25. ;VAR9bits    equ    byte ptr [bp-12]
  26.  
  27.         extrn    _chartab:word
  28.         extrn    __fontsize:word
  29.  
  30. HERC_TEXT    segment byte public 'CODE'
  31.         assume    cs:HERC_TEXT
  32.  
  33.         extrn    hgcpaddr:far
  34.  
  35.         public    _hgcchar
  36. _hgcchar    proc    far
  37.  
  38.         push    bp        ; preserve caller registers
  39.         mov    bp,sp
  40.         sub    sp,10        ; stack space for local variables
  41.         push    di
  42.         push    si
  43.         push    ds
  44.  
  45. ; calculate first pixel address
  46.  
  47.         mov    ax,ARGY        ; AX = y
  48.         mov    bx,ARGX        ; BX = x
  49.         sub    ax,__fontsize    ; Make lower left the origin by
  50.                     ; shifting up by the char size
  51.         call    hgcpaddr    ; ES:BX -> buffer
  52.                     ; CL = # bits to shift left
  53.  
  54.         xor    cl,7        ; CL = # bits to rotate right
  55.  
  56. ; set up 8 bit mask
  57.  
  58.         mov    ax,0FF00h    ; AX = 8-bit mask
  59.  
  60.             ror    ax,cl        ; AX = bit mask in proper position
  61.         mov    VARmask,ax
  62.  
  63. ; set up foreground pixel toggle mask
  64.  
  65.         mov    ah,ARGFGD    ; AH = 0 or 1 (foreground pixel value)
  66.         ror    ah,1        ; high-order bit of AH = 0 or 1
  67.         cwd            ; propagate high-order bit through DX
  68.         not    dx        ; dx = 0 if foreground = 1
  69.                     ; or = FFFh if foreground = 0
  70.         mov    ax,VARmask
  71.         not    ax
  72.         and    dx,ax        ; zero unused bits of toggle mask in DX
  73.         mov    VARtoggle,dx
  74.  
  75. ; set up character definition table addressing
  76.  
  77.         mov    ch,byte ptr __fontsize
  78.         cmp    ch,16
  79.         je    big
  80.  
  81.         mov    ax,0f000h
  82.         mov    ds,ax
  83.         mov    ax,0fa6eh
  84.         mov    si,ax
  85.         
  86.         jmp    cont1
  87. big:
  88.         mov    ax, SEG _chartab
  89.         mov    ds, ax
  90.         mov    si, OFFSET _chartab
  91. cont1:
  92.         mov    ax,ARGC
  93.         mul    ch
  94.         add    si,ax
  95.         
  96. ; mask and set pixels in the video buffer
  97.  
  98. L20:        mov    ax,VARmask
  99.         and    es:[bx],ax    ; mask character pixels in buffer
  100.  
  101.         xor    ah,ah
  102.         lodsb            ; AX = bit pattern for next pixel row
  103.  
  104.             ror    ax,cl        ; rotate pixels into position
  105.         xor    ax,VARtoggle    ; toggle pixels if foreground = 0
  106.         or    es:[bx],ax    ; store pixels in buffer
  107.         add    bx,2000h    ; increment to next portion of interleave
  108.         jns    L22
  109.         add    bx,90-8000h    ; increment to 1st portion of interleave
  110.  
  111. L22:        dec    ch
  112.         jnz    L20
  113.  
  114. Lexit:        pop    ds        ; restore caller registers and return
  115.         pop    si
  116.         pop    di
  117.         mov    sp,bp
  118.         pop    bp
  119.         ret
  120.  
  121. _hgcchar    endp
  122.  
  123. HERC_TEXT    ENDS
  124.  
  125.         END
  126.