'=========================================================================== ' Subject: ASM FADER FIX Date: 11-21-92 (00:00:00) ' Author: Rich Geldreich Code: TASM, QB, PDS ' Keys: ASM,FADER,FIX Packet: GRAPHICS.ABC '=========================================================================== ;Noiseless VGA DAC fading routines for QB4.5/PDS(works on 286's and up) ;By Rich Geldreich 1992 ;Assembled with TASM v2.0 .286 IDEAL MODEL SMALL DATASEG Palette db 768 dup (?) NewPalette db 768 dup (?) CODESEG PUBLIC GetPalette, SetPalette EVEN PROC SetPalette ;Sets the pallette retrieved by ;GetPalette to a specified brightness ;DECLARE SUB SetPalette (BYVAL Brigtness, BYVAL Start, BYVAL Num) Brightness EQU [ss:bp+10] ;0-128 Start EQU [ss:bp+08] ;0-255 Num EQU [ss:bp+06] ;1-256 Parameters = 3 Push bp ;set us up a stack frame Mov bp, sp Push es ds si di ;lets not get QB mad now Mov ax, @data ;get access to palette buffers Mov ds, ax Mov es, ax Xor ax, ax Mov al, Start ;get start color Mov dx, 03C7h ;tell the VGA some DAC values will Out dx, al ;be coming Inc dx Out dx, al Inc dx ;dh=3 Mov si, ax ;add start*3 to the palette offset Shl si, 1 Add si, ax Add si, offset Palette Mov bl, Brightness Cmp bl, 128 ;limit brightness if too high Jna @@Ok1 Mov bl, 128 @@Ok1: Mov cx, Num ;CX=# of registers to change Jcxz @@Done ;if no registers to change then exit Add ax, cx ;calculate the last register to change Sub ax, 256 ;if too many then limit Jna @@OK2 Sub cx, ax @@OK2: Mov di, offset NewPalette Mov bp, cx ;save cx for later EVEN ;color precalculation loop @@10: REPT 3 ;repeat 3 times(for Red, Green, & Blue) Lodsb ; Mul bl ;new=old*brightness Shl ax, 1 ;new=(new*2)\256 or new=new\128 Mov al, ah Stosb ENDM Loop @@10 Mov cx, bp ;multiply number of colors by 3 Shl cx, 1 Add cx, bp Mov si, offset NewPalette Mov dl, 0DAh ;wait for vertical retrace @@15: In al, dx ;wait for end of vertical retrace Test al, 8 ;(for very fast machines) Jnz @@15 @@20: In al, dx ;now wait for start of vertical Test al, 8 ;retrace Jz @@20 Mov dl, 0C9h ;dx=03C9h Rep Outsb ;output the new colors @@Done: Pop di si ds es bp Retf Parameters*2 ;bye bye ENDP SetPalette PROC GetPalette ;Must call this routine before ;DECLARE SUB GetPalette () ;SetPalette! Push es Mov ax, @data Mov es, ax Mov dx, offset Palette ;es:dx addresses palette Mov cx, 256 Xor bx, bx Mov ax, 01017h Int 010h Pop es Retf 0 ENDP GetPalette END To execute this script, save it to a file and type DEBUG < filename where "filename" is the name of this script file. E165"FADEIT.LZH" 0 E200"XcK9gVKBhoK....W/...uWJRN.G.8MIE2JIGItmH0dY8Mo2..2EEW7qk2luCj" E23D"jjztZC5Bsl1Kc.SmKO2t.OSnLBMZeYtcaMGaWGDeLkKQoJ//u//ctc6gI/M6i" E27A"M3VRO/oIGBCMElJM6eG6Y2DQ.gsqHrjTkXVV8.G8NFOMMaMZTAnAmqX2MTKh2" E2B7"Q06b61vQEM2hcy3GzWLIEAUFYXNqNa3OQhxKma.gCdivVWQwzK457fagSl0MN" E2F4"kqOjZddVEBtGBAXTDv77qiPAtd81dEnjImHFoo2MuU/cQga6Ll0StISrvXy1J" E331"XBBRgzAKI4S2YaRGyKoxa2BG1x.Pjj55cTBtv47HCIf0fKPgU./3obnn4gkX9" E36E"kLwZfnbdYiywKIehfehzZWIhQwZ8B/cq03gOOSQeY8ozyJZRSh2wQA3v.MJd4" E3AB"HUrjSG9TZzw5txbme4RNac7jUkXzSjzV6m4i5rykLbP13KkSwvuk/lgfHOS.6" E3E8"Xwd5zgeOhYdxxahgIw.U7Nzb0ZVDZ16mQV0OjOVacvCZzitF.." E100 B8 0 3C BA 65 1 33 C9 CD "!rC" BE 0 2 50 BD 93 1 55 BF 88 90 E117 "W3" DB B1 FA 8A F0 80 C1 6 32 E4 AC "<9v" 8 "