BBS: Inland Empire Archive Date: 11-16-92 (03:58) Number: 266 From: RICH GELDREICH Refer#: NONE To: ALL Recvd: NO Subj: Asm Fader Conf: (2) Quik_Bas
Here is a noiseless fader written in assembly. It can fade both up and down this time: ;Some noiseless VGA DAC fading routines for QB4.5/PDS ;By Rich Geldreich 1992 ;Assembled with TASM v2.0 IDEAL MODEL SMALL DATASEG Palette 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] Start EQU [ss:bp+08] Num EQU [ss:bp+06] Parameters = 3 Push bp ;set us up a stack frame Mov bp, sp Push ds si di ;lets not get QB mad now Mov ax, @data ;get start of palette buffer Mov ds, ax Mov si, offset Palette Mov ax, Start ;get start color Mov dx, 03C7h ;get ready to start changing colors Out dx, al Inc dx Out dx, al Inc dx ;dx=03C9h Mov di, 03DAh ;di=VGA status register Mov bl, Brightness ;limit brigtness to an 8 bit value 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 Cmp ax, 256 ;if too much then exit Ja @@Done EVEN ;color alteration loop @@10: REPT 2 ;change Red & Green colors Lodsb Mul bl ;calculate (Color*brightness)\256 Mov al, ah Out dx, al ;do it ENDM Lodsb ;precalculate the last register Mul bl Mov bh, ah Xchg dx, di ;dx=status port EVEN @@20: In al, dx ;wait for horizontal retrace Test al, 1 Jz @@20 Xchg dx, di Mov al, bh Out dx, al ;let the change take affect where it's safe Loop @@10 ;'till done @@Done: Pop di si ds bp ;pop us some regs Retf Parameters*2 ;bye bye ENDP SetPalette PROC GetPalette ;Must call this routine before SetPalette! ;DECLARE SUB GetPalette () 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 The OBJ file(for those poor guys without TASM) and a small demo follows this message. --- MsgToss 2.0b * Origin: Computer Co-Op - Voorhees, NJ | Ted Hare (1:266/29)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET