; f_put2.asm
;            94/02/08 TEMITORAVIOS
;
; ax vram_ad
; bx font_ad
; cx font_data,cnt
; dx vram_data
;
;
;

f_add	equ	4	;フォントデータトップ
f_cnt	equ	8	;表示文字数
gr_xy	equ	12	;((Y x 1024)+ X) \ 2
g_stp	equ	16	;次の表示位置
d_col	equ	20	;ドットカラー
b_col	equ	24	;バックカラー

vbyts	equ	512	;1lineのバイト数 1024/2

	mov	ebp,esp
	mov	eax,[ebp+gr_xy]  ; 表示位置
	mov	esi,[ebp+f_add]  ; フォント先頭

	push	es
	mov	ecx,104h         ; VRAM セレクタ
	push	ecx
	pop	es
	mov	edi,0h           ; GRAPHIC画面
	mov	bh,[ebp+f_cnt]  ; 文字数

	align	4
moji:
	push	eax
	mov	bl,16           ; 縦16ドット
	align	4
line:
	mov	cx,[esi]
	xor	edx,edx

	test	cx,0100h
	je	b_1
	or	edx,[ebp+d_col]
	jmp	s_1
b_1:
	or	edx,[ebp+b_col]
s_1:
	shl	edx,4
	test	cx,0200h
	je	b_2
	or	edx,[ebp+d_col]
	jmp	s_2
b_2:
	or	edx,[ebp+b_col]
s_2:
	shl	edx,4
	test	cx,0400h
	je	b_3
	or	edx,[ebp+d_col]
	jmp	s_3
b_3:
	or	edx,[ebp+b_col]
s_3:
	shl	edx,4
	test	cx,0800h
	je	b_4
	or	edx,[ebp+d_col]
	jmp	s_4
b_4:
	or	edx,[ebp+b_col]
s_4:
	shl	edx,4
	test	cx,1000h
	je	b_5
	or	edx,[ebp+d_col]
	jmp	s_5
b_5:
	or	edx,[ebp+b_col]
s_5:
	shl	edx,4
	test	cx,2000h
	je	b_6
	or	edx,[ebp+d_col]
	jmp	s_6
b_6:
	or	edx,[ebp+b_col]
s_6:
	shl	edx,4
	test	cx,4000h
	je	b_7
	or	edx,[ebp+d_col]
	jmp	s_7
b_7:
	or	edx,[ebp+b_col]
s_7:
	shl	edx,4
	test	cx,8000h
	je	b_8
	or	edx,[ebp+d_col]
	jmp	s_8
b_8:
	or	edx,[ebp+b_col]
s_8:

	mov	es:[edi+eax+4],edx            ;  Vram store
	xor	edx,edx

	test	cx,0001h
	je	b_9
	or	edx,[ebp+d_col]
	jmp	s_9
b_9:
	or	edx,[ebp+b_col]
s_9:
	shl	edx,4
	test	cx,0002h
	je	b_10
	or	edx,[ebp+d_col]
	jmp	s_10
b_10:
	or	edx,[ebp+b_col]
s_10:
	shl	edx,4
	test	cx,0004h
	je	b_11
	or	edx,[ebp+d_col]
	jmp	s_11
b_11:
	or	edx,[ebp+b_col]
s_11:
	shl	edx,4
	test	cx,0008h
	je	b_12
	or	edx,[ebp+d_col]
	jmp	s_12
b_12:
	or	edx,[ebp+b_col]
s_12:
	shl	edx,4
	test	cx,0010h
	je	b_13
	or	edx,[ebp+d_col]
	jmp	s_13
b_13:
	or	edx,[ebp+b_col]
s_13:
	shl	edx,4
	test	cx,0020h
	je	b_14
	or	edx,[ebp+d_col]
	jmp	s_14
b_14:
	or	edx,[ebp+b_col]
s_14:
	shl	edx,4
	test	cx,0040h
	je	b_15
	or	edx,[ebp+d_col]
	jmp	s_15
b_15:
	or	edx,[ebp+b_col]
s_15:
	shl	edx,4
	test	cx,0080h
	je	b_16
	or	edx,[ebp+d_col]
	jmp	s_16
b_16:
	or	edx,[ebp+b_col]
s_16:
	mov	es:[edi+eax],edx      ; Vram Store

	add	eax,vbyts             ; vram_1line inc
	add	esi,2                 ; font_data inc
	dec	bl
	jne	line
	
	pop	eax
	add	eax,[ebp+g_stp]
	dec	bh
	jne	moji

	pop	es
	ret

