Page	60,132
Title	SMALL -- Load EGA 8x8 font for 25 or 43 line screens.
Subttl	Thomas V. Hoffmann, January 1985

;--This program selects 80x25 alpha color mode (mode 3), loads the
;  EGA character generator with the 8x8 font, and causer BIOS to
;  recalculate the video parameters for maximum screen dimentions.
;
;  With 350-line displays, this gives 43 lines per screen.
;  With 200-line displays, this gives 25 lines per screen.
;
;  Execute:
;  MASM SMALL.ASM
;  LINK SMALL
;
stack	segment	para stack 'stack'
	dw	64 dup(0)
stack	ends

bdata	segment at 40H		; BIOS data segment
	org	63H
CRTC	dw	?		; base I/O address of CRTC
	org	87H
info	db	?		; bit 0=1 inhibits cursor emulation
bdata	ends

code	segment	para public 'code'
small	proc	far
	push	es		; push ES:0 for return to DOS
	sub	ax,ax
	push	ax
	mov	ax,bdata	; set DS to BIOS data segment
	mov	ds,ax
	assume	ds:bdata
	mov	ax,0003H	; set 80-column alpha mode
	int	10H
	mov	ax,1112H	; load 8x8 font
	mov	bl,0		;   into block 0
	int	10H		;   and recalc screen

;  This code sets the EGA CRTC cursor register directly, after
;  inhibiting the BIOS cursor emulation function. On 350-line
;  displays, this prevents BIOS from setting the cursor to lines
;  11 and 12, which are not displayed for 8 line characters.

	or	info,1		; inhibit cursor emulation
	mov	ax,0100H	; set cursor
	mov	bh,0		;   for page 0
	mov	cx,0600H	;   to last two lines
	int	10H		;   (start on 6, off on 0)
page

;  This code sets the underline location register in the CRTC to
;  the last line of the character box (line 7). BIOS incorrectly
;  sets it to line 8, which is not displayed.

	mov	dx,CRTC		; get CRTC base address
	mov	al,14H		; select underline loc register
	out	dx,al
	inc	dx		; point DX to CRTC data register
	mov	al,7		; set underline location to line 7
	out	dx,al

;  This code enables the EGA BIOS print screen routine, which
;  can handle non-standard display dimentions. In this case
;  it handles 43 lines of characters on 350-line displays.

	mov	ax,1200H	; select EGA screen print
	mov	bl,20H		;    routine
	int	10H

	ret			; return to DOS
small	endp
code	ends
	end	small		; label needed for linker [M. Papa]
