Category : BASIC Source Code
Archive   : PSETMA.ZIP
Filename : VGAPIXEL.ASM

 
Output of file : VGAPIXEL.ASM contained in archive : PSETMA.ZIP

NAME VGASetPixel

;
; Name: VGASetPixel
; Adapted for QB4 by Alan J. Fridlund
; from Programmer's Guide to PC & PS/2 Video Systems
; by Richard Wilton (Microsoft Press, 1987).
;
; Function: Set the value of a pixel in native EGA/VGA graphics modes.
; Use with VPIXADDR.ASM.
;
; *** Write Mode 2 ***
;
; Caller: Microsoft QB4:
;
; CALL VGASetPixel(o,x,y,n)
;
; int o; /* operation */
; 0 = REPLACE
; 1 = AND
; 2 = OR
; 3 = XOR
;
; int x,y; /* pixel coordinates */
;
; int n; /* pixel value */
;

VGAParams SEGMENT byte public 'CODE'
ASSUME cs:VGAParams

EXTRN PixelAddr:near

PUBLIC VGASetPixel
VGASetPixel PROC far

push bp ; preserve stack frame
mov bp,sp

mov bx,[bp+8]
mov ax,[bx] ; AX := y
mov bx,[bp+10]
mov bx,[bx] ; BX := x
call PixelAddr ; AH := bit mask
; ES:BX -> buffer
; CL := # bits to shift left

; set Graphics Controller Bit Mask register

shl ah,cl ; AH := bit mask in proper position
mov dx,3CEh ; GC address register port
mov al,8 ; AL := Bit Mask register number
out dx,ax

; set Graphics Controller Mode register

mov ax,205h ; AL := Mode register number
; AH := Write Mode 2 (bits 0,1)
; Read Mode 0 (bit 3)
out dx,ax

; set Data Rotate/Function Select register

mov si,[bp+12]
mov ax,[si]
cmp ax,0
je PixRepl
cmp ax,1
je PixAnd
cmp ax,2
je PixOr
cmp ax,3
je PixXor
jmp Term

PixRepl: mov ah, 00h ; AH := Read-Modify-Write bits
jmp RMW
PixAnd: mov ah, 08h
jmp RMW
PixOr: mov ah, 10h
jmp RMW
PixXor: mov ah, 18h

RMW: mov al,3 ; AL := Data Rotate/Function Select reg
out dx,ax

; set the pixel value

mov al,es:[bx] ; latch one byte from each bit plane
mov si,[bp+6]
mov al,[si] ; AL := pixel value
mov es:[bx],al ; update all bit planes

; restore default Graphics Controller registers

mov ax,0FF08h ; default Bit Mask
out dx,ax

mov ax,0005 ; default Mode register
out dx,ax

mov ax,0003 ; default Function Select
out dx,ax

Term: mov sp,bp ; restore stack frame and return
pop bp
ret 8

VGASetPixel ENDP

VGAParams ENDS

END 

  3 Responses to “Category : BASIC Source Code
Archive   : PSETMA.ZIP
Filename : VGAPIXEL.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/