.286
.model small
.code
org 100h
;--------------------
character   equ    'G'
;--------------------
start:
		mov ax,	1130h
		mov bh, 06h
		int 10h
		mov FontSeg, es
		mov FontOffs, bp

        mov ax, 13h
        int 10h

        push 1
        push 0
        push character
        push 4
        push 2
        push FontOffs
        push FontSeg
        call OutCharXY

        mov ah, 8h
        int 21h

        mov ax, 3h
        int 10h

        int 20h
;---------------------------------------------
OutCharXY proc near 		  ;OutCharXY(X,Y,Char,Color,bg,TableOffs,TableSeg)
	push bp
	mov bp, sp
TableSeg  	equ word ptr [bp+4]
TableOffs 	equ word ptr [bp+6]
Color		equ byte ptr [bp+0Ah]
Bg	 		equ byte ptr [bp+8]
Char 		equ byte ptr [bp+12]
posY		equ	word ptr [bp+14]
posX		equ	word ptr [bp+16]
    pusha
    push es
;----------------------------
;  Character Creation
    	mov di, TableOffs
    	mov es,	TableSeg  
    	mov ah, 0
    	mov al, Char
        shl ax, 4
		add di,	ax
        mov cx,	16
		mov si,	offset face
MainLoop:
		mov bh, es:di
		push cx
		mov cx, 8
LineLoop:
		test bh, 80h
        jz	BackGround
        mov ah, Color
        mov byte ptr ds:[si], ah
		jmp LoopEnd
BackGround:
        mov ah, Bg
	    mov byte ptr ds:[si], ah
LoopEnd:
		shl bh, 1
		inc si
		loop LineLoop
		pop cx
		inc di
		loop MainLoop
; End of Character creation
;=======================================
	mov ax,	posX
	shl ax, 3
	push ax				; X position

	mov ax,	posY
	shl ax, 4
	push ax 			; Y position

	push offset face    ; Character bitmap
	push 8				; SizeX
	push 16				; SizeY
    call WriteSprite	; WriteChar

    pop es
    popa
	pop bp
	ret 14
endp
;-------------------------------------------
WriteSprite proc near         ;writesprite(x,y,char *sprt,razmx,razmy)
    push bp
    mov bp,sp
razmy equ word ptr [bp+4]
razmx equ word ptr [bp+6]
sprt  equ word ptr [bp+8]
posy  equ word ptr [bp+10]
posx  equ word ptr [bp+12]
    pusha
    push es

    mov ax, 0A000h
    mov es, ax
    mov ax, posy
    mov bx, ax
    shl ax, 8
    shl bx, 6
    add ax, bx
    add ax, posx
    mov di, ax
    mov ax, sprt
    mov si, ax
    mov cx, razmy
lup:
    push cx
    mov cx, razmx
    repe movsb
    add di, 320
    sub di,razmx
    pop cx
    loop lup

    pop es
    popa
    pop bp
ret 10
endp

face		db 128 dup (?)
FontOffs	dw ?
FontSeg		dw ?
end start
