Monday, January 24, 2005

Historical: Typewriter

When I was a kid, I wrote this assembly program that would play with the VGA fonts (I wrote a whole bunch of programs that messed with the VGA fonts) One particular program that comes to mind is one that shifts the lines on the VGA font one scan line upward, making it look like it was typed on a typewriter with an errant key.


SCANLINES	equ	16
SHIFT		equ	 2

.model small
.code
	org	100h
main	proc
	mov	ax,1130h	; read char vector
	mov	bh,06		; 8*16 vga/mcga
	int	10h

	mov	ah,0		; read char
	int	16h
	cbw
	push	ax
	
		
	mov	cl,4		; map of offending char
	shl	ax,cl
	add	bp,ax
	add	bp,SHIFT	
	
	mov	cx,SCANLINES-SHIFT	; save char bitmap
	push	ds
	push	es		
	pop	ds
	pop	es
	mov	si,bp		; ds:si->original map
	lea	di,charmap	; es:di->our buf
	cld
	rep	movsb	
			
	mov	ax,1100h	; set char
	mov	cx,1
	pop	dx
	mov	bh,10h		; 8*16 vga/mcga
	lea	bp,charmap
	int	10h

	mov	ax,4c00h
	int	21h
main	endp

charmap	db SCANLINES dup(0)	; init to 0 as last lines must be blank
	end	main

1 comment:

hernan said...

ha! cool! reminds me those glorious DOS days.