Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!think!ames!amdahl!pyramid!voder!kontron!cramer From: cramer@kontron.UUCP (Clayton Cramer) Newsgroups: comp.sys.ibm.pc Subject: Re: Anyone have code fragment for CGA snow elimination? Message-ID: <1660@kontron.UUCP> Date: Thu, 25-Jun-87 16:39:32 EDT Article-I.D.: kontron.1660 Posted: Thu Jun 25 16:39:32 1987 Date-Received: Sat, 27-Jun-87 04:59:22 EDT References: <957@rtech.UUCP> Distribution: na Organization: Kontron Electronics, Mt. View, CA Lines: 102 > > I have been looking for a way to eliminate "snow" from a CGA adapter > during text display. I'm writing directly to the frame buffer as most > people do (the BIOS is too slow for what I'm up to). I've been looking > through the IBM PC BIOS source listing and have found the loop where they > go and wait for vertical retrace before proceeding to write the character > to the screen. I have been trying with little success to understand > the other stuff they do. They turn the video back off then back on and > reset a register or two once the I/O has completed. > > My questions, in order of utility: > > 1. Does anyone have a public-domain code fragment that clearly shows > how to write alpha text to the CGA without snow, so that I don't > have to try to wade further through mounds of assembler code that > I would rather not read? > Here's an assembler subroutine I wrote sometime back for our new product -- we've since decided to use the ROM BIOS calls in the interests of painless portability, regardless of display adapter, display, computer, etc. It's not beautiful, and it's oriented to writing characters ONE AT A TIME (for reasons that are too embarrassing to our design process to discuss), but it does successfully handle the snow problem. And for those who are wondering, the comments were written with the code -- not afterwards. ---------------------------------------------------------------------- VSTAT equ 3dah ; CGA adapter status register HRTRCE equ 1 ; horizontal retrace bit mask MONO_BUFFER equ 0b000h ; monochrome adapter buffer seg cseg segment public para 'code' public _memmapio assume cs:cseg,ds:dseg _memmapio proc far push bp mov bp,sp push ds mov ax,dseg mov ds,ax push es mov ax,[bp+12] ; get the buffer address mov es,ax mov ch,[bp+10] ; get the attribute to put mov cl,[bp+8] ; throw away high garbage mov bx,[bp+6] ; get the index into the buffer add bx,bx cmp ax,MONO_BUFFER ; is this a monochrome adapter? je mono_write ; yes, skip refresh/retrace push dx mov dx,VSTAT ; c/g adapter status register wait_horiz_refresh: in al,dx ; get the status test al,HRTRCE ; horizontal refresh started? jnz wait_horiz_refresh ; no cli wait_horiz_retrace: in al,dx ; get the status again test al,HRTRCE ; horizontal retrace started? jz wait_horiz_retrace mov es:[bx],cx ; put character into buffer sti pop dx position_cursor: mov ax,[bp+6] ; get position in display inc ax ; so cursor goes in next spot div colsperline ; convert to line and column mov dh,al ; get line number mov dl,ah ; get column number mov ah,2 ; set cursor subcode mov bh,0 ; page number (always 0) int 10h ; request set cursor bios function pop es pop ds mov sp,bp pop bp ret mono_write: mov es:[bx],cx ; put char/attributes into buffer jmp position_cursor ; position cursor _memmapio endp cseg ends dseg segment public para 'data' colsperline db 80 ; columns per line dseg ends end