Category : Printer + Display Graphics
Archive   : CRITTER4.ZIP
Filename : CRIT_EGA.ASM

 
Output of file : CRIT_EGA.ASM contained in archive : CRITTER4.ZIP
; Module: Crit_EGA
; Version: 1.01 10-Aug-1989
;
; Language: Intel 80x86 Assembly
;
; Compilers: Microsoft Macro Assembler v5.10
; Microsoft QuickAssembler v2.01
; Borland Turbo Assembler v1.1
;
; Environ: MS-DOS, Enhanced Graphics Adapter or equivalent
;
; Purpose: This is a minimal library of EGA graphics functions for use
; with the Critters programs.
;
; Written by: Scott Robert Ladd
; 705 West Virginia
; Gunnison, CO 81230
;
; MCI ID: srl
; FidoNet: 1:104/45.2

.MODEL SMALL,C

.DATA

bitmask DW 0

.CODE

PUBLIC graphon
PUBLIC graphoff
PUBLIC plotpixel

;--------
; procedure: graphon (Set highest-resolution graphics mode on EGA)
;
; prototype: void graphon(void);
;--------

graphon PROC

mov ax,0010h
int 10h

ret

graphon ENDP


;--------
; procedure: graphoff (Set standard 80 x 25 text mode on EGA)
;
; prototype: void graphoff(void);
;--------

graphoff PROC

mov ax,0003h
int 10h

ret

graphoff ENDP


;--------
; procedure: plotpixel (Plot a Pixel)
;
; prototype: void plotpixel(int x, int y, int color);
;--------

plotpixel PROC x:WORD, y:WORD, color:WORD

mov ax,x ; divide x by 8, getting both a remainder
mov bl,8 ; in AH and a quotient in AL
div bl

mov bx,ax ; save the quotient
xor bh,bh

xor ch,ch ; clear ch
mov cl,ah ; move remainder to cl
mov ax,80h ; set AX for mask calculation
sar ax,cl ; shift bit mask

mov bitmask,ax ; store AX in bitmask

mov ax,y ; move y to AX
mov cx,80
mul cx ; multiply AX by 80

add ax,bx ; add BX (holding x div 8) to AX

mov bx,ax ; move byte offset into BX
mov ax,0A000h ; set ES to segment of EGA memory
mov es,ax

mov al,8 ; store bitmask
mov dx,03CEh
out dx,al

mov ax,bitmask
mov dx,03CFh
out dx,al

mov al,2
mov dx,03C4h
out dx,al

mov al,15
mov dx,03C5h
out dx,al

mov ch,BYTE PTR es:[bx]
mov BYTE PTR es:[bx],0

mov al,2
mov dx,03C4h
out dx,al

mov ax,color
mov dx,03C5h
out dx,al

mov BYTE PTR es:[bx],0FFh

mov al,2
mov dx,03C4h
out dx,al

mov al,15
mov dx,03C5h
out dx,al

mov al,3
mov dx,03CEh
out dx,al

mov al,0
mov dx,03CFh
out dx,al

mov al,8
mov dx,03CEh
out dx,al

mov al,0FFh
mov dx,03CFh
out dx,al

ret

plotpixel ENDP

END


  3 Responses to “Category : Printer + Display Graphics
Archive   : CRITTER4.ZIP
Filename : CRIT_EGA.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/