;	w_font( s_rdptr, map_ptr, map_width, mod_bit, width_bit,
;	 raster_width, height, v_pos )
;
;	BUFFER*  s_rdptr	Pointer of the raster data
;	HUG_BUF* map_ptr	Pointer of the bitmap buffer
;	int	 map_width	width of bitmap buffer by bytes
;	int	 mod_bit	should be >> mod_bit for raster data
;	int	 width_bit      width of the raster data to be written
;				 - (16 - mod_bit)
;	int	 raster_width	width of the raster data in raster buffer
;				 by bytes
;	int	 height		height to be written by dots
;	int	 v_pos		vertical position
;
;				May - Dec. 1990, SHIMA
;				Feb 1992 Modification by Oh-Yeah?
;					if (mod_bit & 0xff00 != 0) do not write first-column bytes
;					of raster data

;
W_FONT_TEXT	segment	byte public 'CODE'
W_FONT_TEXT	ends
DGROUP	group	_DATA,_BSS
	assume	cs:W_FONT_TEXT,ds:DGROUP,ss:DGROUP
;	assume	cs:W_FONT_TEXT,ds:DGROUP
_DATA	segment word public 'DATA'
_DATA	ends
_BSS	segment word public 'BSS'
_BSS	ends
_DATA	segment word public 'DATA'
shift	label	word
	dw	-1
	dw	-2
	dw	-4
	dw	-8
	dw	-16
	dw	-32
	dw	-64
	dw	-128
	dw	-256
	dw	-512
	dw	-1024
	dw	-2048
	dw	-4096
	dw	-8192
	dw	-16384
	dw	-32768
	dw	0
_DATA	ends
W_FONT_TEXT	segment	byte public 'CODE'
;	?debug	L 29
_w_font	proc	far
	push	bp
	mov	bp,sp
	sub	sp,10
	push	si
	push	di

	mov	ax, word ptr [bp+8]	; ax = segment of s_ptr;
	mov	word ptr [bp-8], ax	; seg of t_rdptr = seg of s_ptr

	mov	ax, word ptr [bp+18]
	add	ax, ax
	neg	ax
	mov	word ptr [bp+18], ax

	mov	ax, word ptr [bp+14]	; di = (ulong)d_width
	mov	di, ax
	mul	word ptr [bp+24]
	add	ax, word ptr [bp+10]
	adc	dx, 0
	mov	bx, 0fh
	and	bx, ax
	mov	word ptr [bp+10], bx
	mov	cl, 4
	shr	ax, cl
	shl	dx, cl
	add	ah, dl
	add	word ptr [bp+12], ax

	xor	cx, cx
	mov	dx, word ptr [bp+20]	; dx = s_inc
	cmp	word ptr [bp+22], cx


;	Modification by Oh-Yeah? Part1 Start...
;	jnz	@4
;	jmp	@10
	jnz	@@@4
	jmp	@10
@@@4:
	cmp	byte ptr [bp+17], 0
	jz	@4
	jmp	@@4
;	Modification by Oh-Yeah? Part1 End...


@4:
;	?debug	L 40			t_rdptr = s_ptr
	les	bx, dword ptr [bp+6]
	mov	word ptr [bp-10], bx

;	?debug	L 41			r_data.byte[1] = *t_rdptr++
;	?debug	L 42			r_data.byte[0] = *t_rdptr
	mov	ax, word ptr es:[bx]
	xchg	ah, al

;	?debug	L 43			r_data.word >>= s_mod
	mov	cl, byte ptr [bp+16]
	shr	ax, cl

;	?debug	L 44			if( (t_width = s_width) < 0 )
	mov	si,word ptr [bp+18]
	or	si, si
	jle	@5

;	?debug	L 45			r_data.word &= shift[-t_width]
	and	ax, word ptr DGROUP:shift[si]
@5:
;	?debug	L 47			t_mptr = d_ptr
	les	bx, dword ptr [bp+10]
	mov	word ptr [bp-4],es
	mov	word ptr [bp-6],bx

;	?debug	L 48			*((BUFFER *)t_mptr)++ |= r_data.byte[1]
;	?debug	L 49			*t_mptr |= r_data.byte[0];
	xchg	ah, al
	or	word ptr es:[bx], ax
	or	si,si
	jnl	@7
	inc	word ptr [bp-6]

	or	cl, cl
	jnz	@5_1
	inc	word ptr [bp-10]
	add	si, 16
	jmp	short @8
@5_1:
	add	si, cx
	add	si, cx
	mov	al, 8
	sub	al, cl
	mov	cl, al
@8:
;	?debug	L 51			r_data.byte[1] = *t_rdptr++;
;	?debug	L 52			r_data.byte[0] = *t_rdptr;
	inc	word ptr [bp-10]
	les	bx, dword ptr [bp-10]
	mov	ax, word ptr es:[bx]
	xchg	ah, al

;	?debug	L 53			r_data.word = (r_data.word >> s_mod)

;	?debug	L 54			if( (t_width -= ONEBYTE) < 0 )
	add	si, 16
	or	si, si
	jle	@9

;	?debug	L 55			r_data.word &= shift[-t_width]
	and	ax, word ptr DGROUP:shift[si]
@9:
	shl	ax, cl

;	?debug	L 57			*((BUFFER *)t_mptr)++ |= r_data.byte[1]
;	?debug	L 58			*t_mptr |= r_data.byte[0];
	inc	word ptr [bp-6]
	les	bx, dword ptr [bp-6]
	xchg	ah, al
	or	word ptr es:[bx], ax
@6:
;	?debug	L 50			while ( t_width > 0 )
	or	si,si
	jl	@8
@7:
;	?debug	L 60			d_ptr += ( ulong )d_width
	dec	word ptr [bp+22]
	jz	@10
	add	word ptr [bp+6], dx
	add	word ptr [bp+10], di
	js	norm
	jmp	@4
norm:	mov	ax, word ptr [bp+10]
	mov	bx, 0fh
	and	bx, ax
	mov	word ptr [bp+10], bx
	mov	cl, 4
	shr	ax, cl
	add	word ptr [bp+12], ax

;	?debug	L 61		       	s_ptr += s_inc;
	jmp	@4
;@2:
;	?debug	L 39			while ( count )
;	sub	word ptr [bp+22], 1
;	jc	@10
;	jmp	@4
@10:
@3:
@1:
;	?debug	L 63			}
	pop	di
	pop	si
	mov	sp,bp
	pop	bp
	ret	


;	Modification by Oh-Yeah? Part2 Start...
@@4:
;	?debug	L 40			t_rdptr = s_ptr
	les	bx, dword ptr [bp+6]
	mov	word ptr [bp-10], bx

;	?debug	L 41			r_data.byte[1] = *t_rdptr++
;	?debug	L 42			r_data.byte[0] = *t_rdptr
	mov	ax, word ptr es:[bx]
	xchg	ah, al

;	?debug	L 43			r_data.word >>= s_mod
	mov	cl, byte ptr [bp+16]
	shr	ax, cl

;	?debug	L 44			if( (t_width = s_width) < 0 )
	mov	si,word ptr [bp+18]
	or	si, si
	jle	@@5

;	?debug	L 45			r_data.word &= shift[-t_width]
	and	ax, word ptr DGROUP:shift[si]
@@5:
;	?debug	L 47			t_mptr = d_ptr
	les	bx, dword ptr [bp+10]
	mov	word ptr [bp-4],es
	mov	word ptr [bp-6],bx

;	?debug	L 48			*((BUFFER *)t_mptr)++ |= r_data.byte[1]
;	?debug	L 49			*t_mptr |= r_data.byte[0];
	xchg	ah, al
;;	or	word ptr es:[bx], ax
	or	byte ptr es:[bx+1], ah
	or	si,si
	jnl	@@7
	inc	word ptr [bp-6]

	or	cl, cl
	jnz	@@5_1
	inc	word ptr [bp-10]
	add	si, 16
	jmp	short @@8
@@5_1:
	add	si, cx
	add	si, cx
	mov	al, 8
	sub	al, cl
	mov	cl, al
@@8:
;	?debug	L 51			r_data.byte[1] = *t_rdptr++;
;	?debug	L 52			r_data.byte[0] = *t_rdptr;
	inc	word ptr [bp-10]
	les	bx, dword ptr [bp-10]
	mov	ax, word ptr es:[bx]
	xchg	ah, al

;	?debug	L 53			r_data.word = (r_data.word >> s_mod)

;	?debug	L 54			if( (t_width -= ONEBYTE) < 0 )
	add	si, 16
	or	si, si
	jle	@@9

;	?debug	L 55			r_data.word &= shift[-t_width]
	and	ax, word ptr DGROUP:shift[si]
@@9:
	shl	ax, cl

;	?debug	L 57			*((BUFFER *)t_mptr)++ |= r_data.byte[1]
;	?debug	L 58			*t_mptr |= r_data.byte[0];
	inc	word ptr [bp-6]
	les	bx, dword ptr [bp-6]
	xchg	ah, al
	or	word ptr es:[bx], ax
@@6:
;	?debug	L 50			while ( t_width > 0 )
	or	si,si
	jl	@@8
@@7:
;	?debug	L 60			d_ptr += ( ulong )d_width
	dec	word ptr [bp+22]
	jz	@10
	add	word ptr [bp+6], dx
	add	word ptr [bp+10], di
	js	@norm
	jmp	@@4
@norm:	mov	ax, word ptr [bp+10]
	mov	bx, 0fh
	and	bx, ax
	mov	word ptr [bp+10], bx
	mov	cl, 4
	shr	ax, cl
	add	word ptr [bp+12], ax

;	?debug	L 61		       	s_ptr += s_inc;
	jmp	@@4
;	Modification by Oh-Yeah? Part2 End...


_w_font	endp
W_FONT_TEXT	ends
_DATA	segment word public 'DATA'
_DATA	ends
	extrn	PADA@:far
W_FONT_TEXT	segment	byte public 'CODE'
W_FONT_TEXT	ends
	public	_w_font
_shift	equ	shift
	end
