home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / PC2BITPL.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-02-03  |  2.4 KB  |  108 lines

  1. ; pc2bitpl.asm
  2. ;
  3. ; 7/07/89 by Ted
  4. ;
  5. ; font plotter for 2 bit per pixel display modes (CGA modes 4, 5)
  6. ;
  7. ; OWL-PCA 1.2
  8. ; Copyright (c) 1989 Oakland Group Inc.
  9. ; ALL RIGHTS RESERVED
  10. ;
  11. ;------------------------REVISION HISTORY--------------------------------------;
  12. ; 9/06/89 ted    Initialized ds in large data models; I forgot to before.
  13. ; 9/06/89 ted    Moved coltab to code segment to make it more accessible.
  14. ;------------------------------------------------------------------------------;
  15. include    PCDECL.MAC
  16. include    PCDATA.MAC
  17.  
  18.     PSEG
  19.  
  20.     coltab    db    000h, 055h, 0AAh, 0FFh
  21. ;------------------------------------------------------------------------------;
  22. ; void DIGPRIV pc_2bitplotchar()
  23.  
  24. pubproc DIGPRIV    pc_2bitplotchar
  25.     pushm <bp, ds, es, di, si>    ; no args, so bp is not needed
  26.  
  27. IF FAR_DATA
  28.     mov ax, seg pcdatastruc_ext
  29.     mov ds, ax
  30. ENDIF
  31.  
  32. ;; get everything we need out of pcdatastruc_ext
  33.     mov si, word ptr pcdatastruc_ext.fontoffs
  34.     mov di, pcdatastruc_ext.vidaddr
  35.     mov es, pcdatastruc_ext.dispseg
  36.  
  37.     mov dx, pcdatastruc_ext.starty        ; put y in dx
  38.     mov bp, dx
  39.     add bp, pcdatastruc_ext.fontlines    ; put ending y val in bp
  40.  
  41. ; get fg, bg colors into ax
  42.     mov ax, word ptr pcdatastruc_ext.fgcol    ; al = fgcol; ah = bgcol
  43.     and ax, 0303h        ; mask both colors at once
  44.  
  45.     xor bh, bh
  46.     mov bl, al
  47.     mov cl, cs:coltab[bx]    ; fg
  48.     mov bl, ah
  49.     mov ch, cs:coltab[bx]    ; bg
  50. linesloop:
  51.  
  52.     mov bx, ds
  53.     mov ds, pcdatastruc_ext.fontseg
  54.     lodsb                        ; load font byte for this line; inc fontaddr
  55.     mov ds, bx
  56.  
  57. ; expand the font byte and put the colors in
  58.     xor bx, bx
  59.     mov ah, 8
  60. fontx:
  61.     shr al, 1
  62.     rcr bx, 1
  63.     sar bx, 1
  64.     dec ah
  65.     jnz fontx
  66.  
  67.     mov ax, bx
  68.     and al, cl    ; fg
  69.     and ah, cl    ; fg
  70.     not bx
  71.     and bl, ch    ; bg
  72.     and bh, ch    ; bg
  73.     or  ax, bx
  74.     xchg ah, al    ; put bytes in right order
  75.  
  76. ; plot this scanline for all 'nsame' chars
  77.     mov bx, di
  78.     push cx
  79.     mov cx, pcdatastruc_ext.nsame
  80.     rep stosw
  81.     pop  cx
  82.     mov di, bx
  83.  
  84. ;; if (++y > endy) break;
  85.     inc dx
  86.     cmp dx, bp
  87.     jae alldone
  88.  
  89. ;; vidaddr += ((y & ilmask) == 0) ? vbincr : ilsize;
  90.     test dx, pcdatastruc_ext.ilmask
  91.     jz incvidbuf
  92.     add di, pcdatastruc_ext.ilsize
  93.     jmp linesloop
  94. incvidbuf:
  95.     add di, pcdatastruc_ext.vbincr
  96.     jmp linesloop
  97.  
  98. ;---------
  99. alldone:
  100.     popm <si, di, es, ds, bp>
  101.     ret
  102. endproc pc_2bitplotchar
  103. ;------------------------------------------------------------------------------;
  104.     ENDPS
  105.     end
  106. ;------------------------------------------------------------------------------;
  107.  
  108.