Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!ulowell!tegra!vail From: vail@tegra.UUCP (Johnathan Vail) Newsgroups: comp.sys.ibm.pc Subject: Re: Turbo-C bug Message-ID: <529@atlas.tegra.UUCP> Date: 12 Jun 89 15:30:31 GMT References: <2556@Portia.Stanford.EDU> <31rwmira01@ULKYVX.bitnet> <203@db.UUCP> Organization: Tegra, Inc., Billerica, MA Lines: 295 In-reply-to: hovanes@db.UUCP's message of 7 Jun 89 18:32:55 GMT In article <203@db.UUCP> hovanes@db.UUCP (Kenneth Hovanes) writes: I was wondering if anybody out there knew of a clean way to throw a series of graphics buffers onto the screen using assembly. I am writing an animation routine, primary in C, and would like to use assembly to toss the stuff to the screen. This is for an IBM clone. I have consulted several manuals on animation in assembly but none deal with the EGA screens. They are all concerned with the CGA screen. I have no problem doing the basic point plots in assembly, but, and this is a big but, I cannot make sense of trying to throw a graphics buffer to the EGA screen. There are four planes of color, and from what I understand each has to done by itself. Please correct me if I am wrong. By having to plot on each bit plane, one at a time, I figure the loss of speed is tremendous, even though pc's are slow anyway. If anyone has any suggestions please post them. EGA has lots of funny registers and modes. This makes it difficult to learn but provides a lot of capability. Certainly the mapping is easier than the CGA. In one mode you can write to a bit plane. In another youcan select a color and then write that color at screen locations, the EGA will write all the planes for you at once. Here are some *very* simple EGA routines that I have for some programs I am working on. The routines here will draw various colored bodes on the screen and draw some icons. Hopefully this will help. "Always Mount a Scratch Monkey" _____ | | Johnathan Vail | tegra!N1DXG@ulowell.edu |Tegra| (508) 663-7435 | N1DXG@145.110-,145.270-,444.2+,448.625- ----- title scan ; History:520,1 .286C ;______________________________________________________________________________ ; ; SCAN Display a spectrum scan ; ; WRITTEN: Johnathan Vail, N1DXG ; ; 31 Oct 1988 jv - Create from wx sources ;______________________________________________________________________________ stuff macro a,d mov dx,3CEh ; graphics 1 & 2 Address Register mov al,a out dx,al mov dx,3CFh ; data io address selcted with above mov al,d out dx,al endm ;______________________________________________________________________________ ; ; ; Paramaters to control the display format: ; pixels_per_line equ 640 num_lines equ 350 color_bar_chars equ 2 color_bar_lines equ color_bar_chars*14 color_bar_size equ 4 ; bytes per line mickey: mov bl,16 ; EGA Graphics 640x350 by 16 of 64 call set_mode mov ax,ega_seg ; Fill the screen with a color mov es,ax mov di,0 ; top_line_addr cli stuff 5,2 ; mode select register, mode 2 mov al,es:[di] stuff 8,0ffh ; Bit mask register, all bits mov al,acolor mov es:[di],al mov al,es:[di] stuff 5,1 mov cx,(color_bar_lines + num_lines)*40 cld rep stosw mov si,offset scan_icon ; display logo mov di,0 call paint_icon mov si,offset file_icon ; and file icon for future mov di,4 call paint_icon ;______________________________________________________________________________ ; mode in bl set_mode proc near push es mov ax,40h mov es,ax mov al,bl mov bl,BYTE PTR es:10h and bl,0EFh or bl,20h cmp al,7 ; Set the configuration byte jne not_a_mono or bl,30h not_a_mono: mov BYTE PTR es:10h,bl mov ah,0 int 10h pop es ret set_mode endp ;______________________________________________________________________________ ; ; EGA Graphics Routines ; ; ; Vertical line ; ; ax = x coor (from left) ; es:di = addr of y (from top) ; bl = color ; dx = distance ; ; vertical_color Entry to continue line with new color & count ; ; bl = color ; dx = distance ; vertical_line: push ax shr ax,1 ; div by 8 for byte offset of x shr ax,1 shr ax,1 add di,ax pop ax and al,7 mov cl,al mov ah,80h jz vertical_color shr ah,cl vertical_color: mov cx,dx ; loop count stuff 5,2 ; mode select register, mode 2 mov al,es:[di] stuff 8,ah ; Bit mask register mov al,bl mov es:[di],al mov al,es:[di] stuff 5,1 vline: mov es:[di],al ; al doesn't matter add di,80 ; bytes per scan line loop vline ret icon_foreground equ 0fh icon_background equ 0 ; ; Paint Icon ; ; Enter: ds:si = icon addr, es:di = screen addr (both upper left) ; paint_icon: push di mov bl,icon_background call color_bar pop di mov bh,28 icon_loop: mov cx,4 icon_line: stuff 5,2 ; mode select register, mode 2 mov al,es:[di] mov bl,[si] inc si stuff 8,bl ; Bit mask register, all bits mov al,icon_foreground mov es:[di],al mov al,es:[di] inc di loop icon_line add di,80-4 dec bh jnz icon_loop stuff 5,0 ; Set ega mode back... sti ret ;______________________________________________________________________________ ; ; bl has color, di has top left addr ; color_bar: stuff 5,2 ; mode select register, mode 2 mov al,es:[di] stuff 8,0ffh ; Bit mask register, all bits mov al,bl mov es:[di],al mov al,es:[di] stuff 5,1 mov bh,color_bar_lines byte_loop: mov cx,color_bar_size rep stosb add di,80-color_bar_size dec bh jnz byte_loop ret ; ; ICONS: ; ;______________________________________________________________________________ ; ; 14 rows by 32 bits across, 0=background, 1=foreground ; scan_icon label byte db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11110000b,11111111b,11111111b,11111111b db 11110111b,11111111b,11111111b,11111111b db 11110111b,11111100b,11111111b,11111111b db 11110000b,10001111b,01100011b,11111111b db 11111110b,10111000b,01101101b,11111111b db 11111110b,10111010b,01101101b,11111111b db 11110000b,10001101b,00101101b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11011101b,10110001b,10110110b,00111111b db 11001101b,00110100b,10110101b,11111111b db 11010101b,10110110b,11001101b,11111111b db 11010101b,10110110b,11001101b,00111111b db 11011001b,10110100b,10110101b,10111111b db 11011101b,00010001b,10110100b,01111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b db 11111111b,11111111b,11111111b,11111111b file_icon label byte db 11111111b,11111111b,11111111b,11111111b db 10000000b,00000000b,00000000b,00000001b db 10111111b,11111111b,11111111b,11111101b db 10100000b,00000000b,00000000b,01111101b db 10101111b,11111111b,11111111b,01111101b db 10101111b,11111111b,11111111b,01110001b db 10101111b,11111111b,11111111b,01110001b db 10101111b,11111111b,11111111b,01111101b db 10100000b,00000000b,00000000b,01111101b db 10111111b,11111111b,11111111b,11111101b db 10111111b,11111111b,11111111b,11111101b db 10111111b,11111110b,00111111b,11111101b db 10111111b,11111100b,00011111b,11111101b db 10111111b,11111000b,00001111b,11111101b db 10111111b,11101000b,00001111b,11111101b db 10111111b,11111000b,00001111b,11111101b db 10111111b,11111100b,00011111b,11111101b db 10111111b,11111110b,00111111b,11111101b db 10111111b,11111111b,11111111b,11111101b db 10111111b,11111111b,11111111b,11111101b db 10111111b,11111111b,01111111b,11111101b db 10111111b,11111110b,00111111b,11111101b db 10111111b,11111110b,00111111b,11111101b db 10111111b,11111110b,00111111b,11111101b db 10111111b,11111111b,01111111b,11111101b db 10111111b,11100111b,11111001b,11111101b db 10000000b,00000000b,00000000b,00000001b db 11111111b,11111111b,11111111b,11111111b