;-------------------------rchar routine begins--------------------------+
; NAME  RCHAR
;
; ROUTINE TO PLOT A RASTER CHARACTER 
;
; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
;         page : 151
;
; FUNCTION: This routine plots a raster character.  It uses a raster
; character table in the IBM ROM BIOS. Only ASCII codes 0 - 127 are
; supported/
;
; INPUT:  Upon entry:
;
;	ACSII code character is in AL
;	x-coordinate of upper left corner of character cell is in x0
;	y-coordinate of upper left corner of character cell is in y0
;	horizontal magnitude is in xmagn
;	vertical magnitude is in ymagn
;	color of character is in color
;
; OUTPUT:  Just to the screen.
;
; REGISTERS USED: No registers are modified.
;
; SEGMENTS REFERENCED:  Upon entry ES must point to the video RAM at
; B8000h and DS must point to the data segment used by the box-fill 
; routine.
;
; ROUTINES CALLED:  SETBOX
;
; SPECIAL NOTES: No bounds checking is performed.  Unpredictable results
; will be displayed if the horizontal or vertical magnitude is too large.
; A string of raster characters can be displayed using the GMESSOUT
; routine available on this disk.
;
; ROUTINE TO PLOT A RASTER CHARACTER
;
rchar	proc	far
;
	push	si		; save registers
	push	dx
	push	cx
	push	ax
;
; look up pattern for character
;
	cbw			; convert from byte to word
	sal	ax,1		; times 2
	sal	ax,1		; times 4
	sal	ax,1		; times 8
	add	ax,0FA6Eh+7	; char table plus pattern end
	mov	si,ax		; here is the offset
;
	mov	dx,ds		; save old DS
	mov	ax,0F000h	; point DS to ROM segment
	mov	ds,ax		; load new data segment
;
; store pattern on the stack
	mov	cx,8		; for a count of eight bytes
	std			; backward direction
;
rchar1:
	lodsb			; load
	push	ax		; push onto stack
	loop	rchar1
;
	mov	ds,dx		; restore orig data segment
;
; get the starting point
	mov	ax,x0		; get x-coord
	mov	x1,ax
	mov	ax,y0		; get y-coord
	mov	y1,ax
;
	mov	cx,8		; for a count of 8 rows
;
rchar2:
	pop	dx		; get the next row
	push	cx		; save the count
;
	mov	al,ymagn	; vertical sizing
	cbw
	dec	ax		; one less
	add	ax,y1		; add to new dot position
	mov	y2,ax
;
	mov	cx,8		; for a count of 8 dots
;
rchar3:
	push	cx		; save count
;
	mov	al,xmagn	; horiz sizing
	cbw
	dec	ax		; one less
	add	ax,x1		; add to new dot position
	mov	x2,ax
;
	test	al,80h		; check the dot
	jz	rchar4		; skip it if zero
	call	setbox		; plot it if one
;
rchar4:
	mov	ax,x2		; next column
	inc	ax		; one over from end of box
	mov	x1,ax		; into next dot posn
	rol	dl,1		; next dot from pattern
	pop	cx		; restore dot count
	loop	rchar3		; loop for next dot
;
	mov	ax,x0		; restore to first column
	mov	x1,ax		; beginning of row
	mov	ax,y2		; next row
	inc	ax		; one down from end of box
	mov	y1,ax		; into next row posn
	pop	cx		; restore row count
	loop	rchar2		; loop for next row
;
	pop	ax		; restore registers
	pop	cx
	pop	dx
	pop	si
;
	ret			; return
rchar	endp
;-------------------------rchar routine ends---------------------------+
