home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 286_02 / prtgc.asm < prev    next >
Assembly Source File  |  1989-05-25  |  3KB  |  104 lines

  1.         TITLE   PRTG   of GDS
  2.         page    60,132
  3.         .SFCOND
  4. ;
  5. ; *=============================================================*
  6. ; *                                                             *
  7. ; *     prtc    append a character to the buffer                *
  8. ; *                                                             *
  9. ; *=============================================================*
  10.  
  11. IFDEF   COLOR
  12.   IFDEF HERC
  13.    .err both display type defined
  14.   ENDIF
  15. else
  16.   IFNDEF HERC
  17.     HERC equ 0
  18.   ENDIF
  19. ENDIF
  20.  
  21. smo     equ     4       ; small model offset value
  22.  
  23. DGROUP  group   _DATA
  24. _DATA   segment word public 'DATA'
  25.         assume  ds:DGROUP
  26.         extrn   _NULLPRT:word
  27.         extrn   _PBPTR:word, _PBCOUNT:word
  28.  
  29. tlen    dw      ?
  30. _DATA   ends
  31.  
  32. _TEXT   segment byte public 'CODE'
  33.         assume  cs:_TEXT,ds:DGROUP
  34.         public  _prt
  35. ;
  36. ;  prt(intarray);
  37. ;  int intarray[];
  38. ;
  39. _prt    proc    near    ;public to c
  40.         push    bp
  41.         mov     bp,sp
  42.         mov     ax,16   ; each integer is 16 bit
  43.         mov     tlen,ax
  44. pt2:    mov     bx,[bp+smo]
  45.         mov     cx,8    ; get one bit in each integer and convert to a byte
  46. pt1:    shl     word ptr ss:[bx],1
  47. IFDEF EPSON
  48.         rcl     al,1
  49. ELSE
  50.   IFDEF OKI
  51.         rcr     al,1
  52.   ELSE
  53.     .err NO PRINTER TYPE DEFINED
  54.   ENDIF
  55. ENDIF
  56.         add     bx,2
  57.         loop    pt1
  58.         xor     ah,ah
  59.         push    ax
  60.         call    _prtgc  ; output one byte
  61.         mov     sp,bp
  62.         dec     word ptr [tlen] ; until all 16 are converted
  63.         jnz     pt2
  64.         pop     bp
  65.         ret
  66. _prt    endp
  67.  
  68. ;
  69. ;  routine for appending 1 column of graphics data to the buffer
  70. ;  also insert NULLPRT of nulls to the buffer.
  71. ;  That is the difference between prtgc and prtc
  72. _prtgc  proc    near  
  73.         push    bp
  74.         mov     bp,sp
  75.         mov     bx,_PBPTR       ; load current pointer
  76.         mov     dx,[bp+smo]
  77.         mov     [bx],dl
  78.         inc     bx              ; update length count
  79.         inc     _PBCOUNT
  80. IFDEF OKI
  81.         cmp     dl,03h          ; if data = 03h (graphics command code)
  82.         jnz     pgc3
  83.         mov     [bx],dl         ; send it twice
  84.         inc     bx
  85.         inc     _PBCOUNT
  86. pgc3:
  87. ENDIF
  88.         mov     cx,_NULLPRT
  89.         test    cx,cx
  90.         jz      pgc1
  91.         mov     al,0            ; output null if NULLPRT is non-zero
  92. pgc2:   mov     [bx],al
  93.         inc     bx
  94.         inc     _PBCOUNT
  95.         loop    pgc2            ; loop NULLPRT times
  96. pgc1:   mov     word ptr _PBPTR,bx      ; save new pointer
  97.         pop     bp
  98.         ret
  99. _prtgc  endp
  100.  
  101. _TEXT   ends
  102.         end
  103.  
  104.