;       Static Name Aliases
;
        TITLE   vputnc
;       NAME    vputnc.C

;EQUATES

        row = 4
        col = 6
        chr = 8
        attr = 10
        times = 12
        retrace = 14

        .287
_TEXT   SEGMENT  BYTE PUBLIC 'CODE'
_TEXT   ENDS
_DATA   SEGMENT  WORD PUBLIC 'DATA'
_DATA   ENDS
CONST   SEGMENT  WORD PUBLIC 'CONST'
CONST   ENDS
_BSS    SEGMENT  WORD PUBLIC 'BSS'
_BSS    ENDS
DGROUP  GROUP   CONST,  _BSS,   _DATA
        ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
_TEXT      SEGMENT

        PUBLIC  _vputnc
_vputnc  PROC NEAR
        push    bp
        mov     bp,sp
        push    si
        push    di

;       row = 4
;       col = 6
;       chr = 8
;       attr = 10
;       times = 12
;       retrace = 14

        mov     ah,15
        int     10h
        cmp     al,7
        jne     $color
        mov     ax,0b000h
        xor     dx,dx
        jmp     short $offset
$color:
        mov     ax,0b800h
        mov     dx,[bp+retrace]            ;retrace
$offset:
        mov     es,ax

        mov     ax,160
        mov     bx,[bp+row]             ;row
        mul     bl
        mov     bx,[bp+col]             ;col
        shl     bx,1
        add     ax,bx
        mov     di,ax                 ;scr_ofs

        mov     ah,BYTE PTR [bp+attr]      ;attr
        mov     al,BYTE PTR [bp+chr]       ;chr
        mov     cx,[bp+times]              ;times

        jcxz    $cleanup
chloop:
        or      dl,dl
        jz      $stashit

        push    ax
        push    dx
        mov     dx,3dah
$WC23:
        in      al,dx
        test    al,1
        jne     $WC23
        cli

$WC25:
        in      al,dx
        test    al,1
        je      $WC25
        pop     dx
        pop     ax

$stashit:
        stosw
        sti
        loop    chloop
$cleanup:
        mov     ax,[bp+col]
        mov     bx,[bp+times]
        add     ax,bx
        pop     di
        pop     si
        mov     sp,bp
        pop     bp
        ret

_vputnc  ENDP
_TEXT   ENDS
END
