brent@rtech.UUCP (Brent Williams) (06/24/87)
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? 2. If such is not available, could someone please give information on commercial source library packages that do direct frame buffer access but also contain assembler source code? 3. Can anyone recommend a book that has all the necessary information on how to do this that is comprehensible to a C programmer with some understanding of Assembler? I already have both of Peter Norton's books, but they don't have enough information. 4. Is it really necessary to go through all the saving and restoring of video status that IBM does in the BIOS? Any other comments along this line would be helpful. I will summarize and post any replies received by mail if anyone asks. Thanks, -- -brent williams Relational Technology, Inc. 1080 Marina Village Parkway Alameda, CA 94501 {amdahl,sun,mtxinu,cpsc6a,hoptoad}!rtech!brent
cramer@kontron.UUCP (Clayton Cramer) (06/25/87)
> > 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
davidsen@steinmetz.steinmetz.UUCP (William E. Davidsen Jr) (06/26/87)
In article <957@rtech.UUCP> brent@rtech.UUCP (Brent Williams) writes: > >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 >.... lots of stuff .... >-brent williams > Relational Technology, Inc. > 1080 Marina Village Parkway > Alameda, CA 94501 > > {amdahl,sun,mtxinu,cpsc6a,hoptoad}!rtech!brent I would buy a Hercules color card. No matter how you play with the software it will either snow or be slow. You can do better with some packages, such as fansi.sys, but the solution is to go to a card which allows you to write into memory without all the b.s. Disclamer: I don't sell 'em, and don't own one. I have used several for a brief time. Some of my friends who own them are satisfied. I bought an EGA. -- bill davidsen (wedu@ge-crd.arpa) {chinet | philabs | sesimo}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me