.486p
LOCALS $$
_TEXT	segment byte public use16 'CODE'
_TEXT ends
DGROUP group _DATA
	assume cs:_TEXT,ds:DGROUP
_DATA	segment word public use16 'DATA'
@CharAttribute db 07
@StrBuffer db 9 dup (0)
public @CharAttribute
extrn __streams


_TEXT	segment byte public use16 'CODE'
extrn @$bnew$qui:near

beep proc near
     mov       ax,0e07h
     xor       bl,bl
     int       10h
     retn
beep endp

clrscr proc near
       mov	 ax,0b800h
       mov	 es,ax
       mov	 eax,07200720h
       xor	 di,di
       mov	 ecx,40*25
       cld
       rep	 stosd
       push	 dword ptr 0
       call	 gotoxy
       add	 sp,4
       ret
clrscr endp

gotoxy proc near
       mov bx,sp
       mov ah,02
       mov dh,Byte Ptr ss:[bx+4]
       mov dl,Byte Ptr ss:[bx+2]
       xor bx,bx
       int 10h
       ret
gotoxy endp

cputc  proc near
       mov ax,0920h
       xor bx,bx
       mov bl,@CharAttribute
       mov cx,1
       int 10h
       mov bx,sp
       mov ah,0eh
       mov al,ss:[bx+2]
       xor bx,bx
       int 10h
       ret
cputc  endp

_cputs	proc near
       mov bx,sp
       mov di,ss:[bx+2]
       mov bx,di
       mov cx,DGROUP
       xor ax,ax
       mov es,cx
       cld
       repne scasb
       sub di,bx
       push bp
       push bx
       push di
       mov ah,03
       xor bx,bx
       int 10h
       pop cx
       dec cx
       pop bp
       mov ax,1301h
       mov bl,@CharAttribute
       int 10h
       pop bp
       ret
_cputs	endp

__cputn  proc near
       push bp
       mov bp,sp
       mov ah,3
       xor bx,bx
       int 10h
       mov cx,[bp+6]
       mov ax,DGROUP
       mov es,ax
       xor bh,bh
       mov bl,@CharAttribute
       mov bp,[bp+4]
       mov ax,1301h
       int 10h
       add bp,cx
       dec bp
       mov ax,ds:[bp]
       pop bp
       ret
__cputn  endp


GetTextColor proc near
       mov al,@CharAttribute
       and ax,0fh
       ret
GetTextColor endp

GetTextBackground proc near
       mov al,@CharAttribute
       and ax,0f0h
       shr ax,4
       ret
GetTextBackground endp

SetTextColor proc near
       pop bx
       pop ax
       and ax,0fh
       mov @CharAttribute,al
       push ax
       push bx
       ret
SetTextColor endp

SetTextBackground proc near
       pop bx
       pop ax
       shl ax,4
       and ax,0f0h
       mov @CharAttribute,al
       push ax
       push bx
       ret
SetTextBackground endp

cputi proc near
       mov bx,sp
       mov ax,ss:[bx+2]
       mov di,Offset @StrBuffer
       add di,5
       mov Word Ptr [di-5],0
       mov Word Ptr [di-2],0
       mov Word Ptr [di],0
       mov Byte Ptr [di-3],0
       mov cx,10D
       xor bx,bx
       cmp ax,0
       jnl $$Greater
       neg ax
       mov bl,'-'
$$Greater:
       xor dx,dx
       div cx
       add dl,30h
       mov Byte Ptr [di],dl
       dec di
       or ax,ax
       jnz $$Greater
       or bx,bx
       jz $$G2
       mov [di],bl
       jmp $$Print
$$G2:  inc di
$$Print:
       push di
       call _cputs
       pop ax
       ret
cputi endp

cputw proc near
       mov bx,sp
       mov ax,ss:[bx+2]
       mov bx,Offset @StrBuffer
       add bx,4
       mov Word Ptr [bx-4],0
       mov Word Ptr [bx-2],0
       mov Word Ptr [bx],0
       mov cx,10D
$$Loop:
       xor dx,dx
       div cx
       cmp dl,9
       add dl,30h
       mov Byte Ptr [bx],dl
       dec bx
       or ax,ax
       jnz $$Loop
       inc bx
       push bx
       call _cputs
       pop ax
       ret
cputw endp

cputh proc near
       mov bx,sp
       mov ax,ss:[bx+2]
       mov bx,Offset @StrBuffer
       add bx,3
       mov Word Ptr [bx-3],0
       mov Word Ptr [bx-1],0
       mov Byte Ptr [bx+1],0
       mov cx,16D
$$Loop:
       xor dx,dx
       div cx
       cmp dl,9
       jg $$Hex
       add dl,30h
       jmp $$Ok
$$Hex: add dl,41h-10
$$Ok:
       mov Byte Ptr [bx],dl
       dec bx
       or ax,ax
       jnz $$Loop
       inc bx
       push bx
       call _cputs
       pop ax
       ret
cputh endp

_operator_new proc near
       jmp @$bnew$qui
_operator_new endp

_operator_newi proc near
       mov bx,sp
       mov ax,ss:[bx+2]
       shl ax,1
       push ax
       call @$bnew$qui
       pop bx
       ret
_operator_newi endp

_operator_newc proc near
       jmp @$bnew$qui
_operator_newc endp


_TEXT ends	;

public _operator_new
public _operator_newi
public _operator_newc
public cputi
public cputw
public cputh
public SetTextColor
public SetTextBackground
public GetTextColor
public GetTextBackground
public _cputs
public cputc
public __cputn
public beep
public clrscr
public gotoxy
_DATA ends

end
