home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / PCEVGAPL.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-09-06  |  3.1 KB  |  120 lines

  1. ; pcevgapl.asm
  2. ;
  3. ; 7/17/89 by Ted
  4. ;
  5. ; font plotter for EGA/VGA multi-plane display modes.
  6. ;
  7. ; Copyright (c) 1989 Oakland Group Inc.
  8. ; ALL RIGHTS RESERVED
  9. ;
  10. ;------------------------REVISION HISTORY--------------------------------------;
  11. ; 9/06/89 ted    Initialized ds in large data models; I forgot to before.
  12. ;------------------------------------------------------------------------------;
  13. include    PCDECL.MAC
  14. include    PCDATA.MAC
  15.  
  16.     GCADDR = 3CEh
  17.  
  18.     PSEG
  19. ;------------------------------------------------------------------------------;
  20. ; void DIGPRIV pc_evgaplotchar()
  21.  
  22. pubproc DIGPRIV    pc_evgaplotchar
  23.     pushm <bp, ds, es, di, si>    ; no args, so bp is not needed
  24.  
  25. IF FAR_DATA
  26.     mov ax, seg pcdatastruc_ext
  27.     mov ds, ax
  28. ENDIF
  29.  
  30. ; Get everything we need out of pcdatastruc_ext
  31.     mov si, word ptr pcdatastruc_ext.fontoffs
  32.     mov di, pcdatastruc_ext.vidaddr
  33.     mov es, pcdatastruc_ext.dispseg
  34.  
  35. ; Set up video mode registers; from Video Systems book.
  36. ; Read in color compare mode but w/don't care bits set so all 1's are read.
  37. ; Write in color-thru-planes mode. Use 'and' instruction to read-then-write.
  38.  
  39.     mov dx, GCADDR
  40.     mov ax, 0A05h        ; ah = write mode 2, read mode 1; al = mode reg no.
  41.     out dx, ax
  42.  
  43.     mov ax, 0007h        ; ah = color don't care bits; al = color don't care reg.
  44.     out dx, ax
  45.  
  46. ; Set up y and endy
  47.     mov dx, pcdatastruc_ext.starty        ; put y in dx
  48.     mov bp, dx
  49.     add bp, pcdatastruc_ext.fontlines    ; put ending y val in bp
  50.  
  51.     mov bx, word ptr pcdatastruc_ext.fgcol    ; bl = fgcol; bh = bgcol
  52.  
  53. linesloop:
  54.     push ds
  55.     mov ds, pcdatastruc_ext.fontseg
  56.     lodsb                        ; load font byte for this line; inc fontaddr
  57.     pop ds
  58.     mov ah, al                    ;  save font byte in ah
  59.  
  60. ; plot this scanline for all 'nsame' chars
  61.     push dx                        ; save y
  62.     push di                        ; save vidaddr
  63.  
  64.     mov dx, GCADDR                ; put graphics control port address in dx
  65.     mov cx, pcdatastruc_ext.nsame
  66. charloop:
  67. ;  fg
  68.     mov al, 08                    ; index of bit mask register
  69.     out dx, ax                    ; use font byte for fg mask
  70.     and es:[di], bl    ; fg
  71. ; bg
  72.     mov al, 08                    ; index of bit mask register
  73.     not ah                        ; invert font byte for bg mask
  74.     out dx, ax                    ; use inverted font byte for bg mask
  75.     and es:[di], bh    ; bg
  76.     inc di
  77.     not ah                        ; de-invert font byte
  78.     loop charloop
  79.  
  80.     pop di                        ; restore vidaddr
  81.     pop dx                        ; restore y
  82.  
  83. ;; if (++y > endy) break;
  84.     inc dx
  85.     cmp dx, bp
  86.     jae alldone
  87.  
  88. ;; vidaddr += ((y & ilmask) == 0) ? vbincr : ilsize;
  89.     test dx, pcdatastruc_ext.ilmask
  90.     jz incvidbuf
  91.     add di, pcdatastruc_ext.ilsize
  92.     jmp linesloop
  93. incvidbuf:
  94.     add di, pcdatastruc_ext.vbincr
  95.     jmp linesloop
  96.  
  97. ;---------
  98. alldone:
  99. ; Restore full bit mask
  100.     mov dx, GCADDR
  101.     mov ax, 0FF08h
  102.     out dx, ax
  103.  
  104. ; Restore color don't care register
  105.     mov ax, 0F07h        ; ah = color care bits; al = color don't care reg.
  106.     out dx, ax
  107.  
  108. ; Restore write mode 0
  109.     mov ax, 0005h
  110.     out dx, ax    ; index of mode register ; write mode 0
  111.  
  112.     popm <si, di, es, ds, bp>
  113.     ret
  114. endproc pc_evgaplotchar
  115. ;------------------------------------------------------------------------------;
  116.     ENDPS
  117.     end
  118. ;------------------------------------------------------------------------------;
  119.  
  120.