home *** CD-ROM | disk | FTP | other *** search
- PAGE 60,132
- TITLE fxPC.ASM -- PCX Effects
- SUBTTL Copyright (c) Genus Microprogramming, Inc. 1988-89
-
- ; fxPC.ASM ;
- ; Copyright (c) Genus Microprogramming, Inc. 1988-89 All Rights Reserved. ;
-
- ;****************************************************************************;
- ; ;
- ; This file contains procedures for taking a display palette and changing ;
- ; it with a special effect. ;
- ; ;
- ; Procedures: fxPaletteCycle ;
- ; fxPaletteFade ;
- ; ;
- ; ;
- ; Microsoft ASM 5.x version. Programmer: Chris Howard 4/15/89 ;
- ; ;
- ;****************************************************************************;
-
- ; Include files
- INCLUDE ..\inc\pcxDefs.inc
- INCLUDE ..\inc\pcxMacs.inc
- INCLUDE ..\inc\pcxErrs.inc
-
- INCLUDE ..\inc\fxDefs.inc
- INCLUDE ..\inc\fxMacs.inc
- INCLUDE ..\inc\fxErrs.inc
-
- @SetModel
-
- @BegData
-
- EXTRN pcxFBuff : BYTE
-
- @EndData
-
- @BegCode
-
- EXTRN pcxGetDisplay : FAR
- EXTRN pcxGetDispStruc : FAR
- EXTRN pcxSetDisplayPalette : FAR
-
- EXTRN fxEffectDelay : FAR
-
- PUBLIC fxPaletteCycle
- PUBLIC fxPaletteFade
-
- ;**********
-
- ;
- ; This procedure simply sets the palette for the given display type and
- ; palette.
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
- sptype equ <[bp+10]>
- sppalseg equ <[bp+ 8]>
- sppalofs equ <[bp+ 6]>
- spparm equ 6
-
- ;Define local variables
- spret equ <[bp-2]> ;return code
- splocal equ 2 ;Total local space needed
-
- fxSetPalette PROC FAR
-
- @Entry splocal ;Set up frame and save regs
-
- mov bx,sptype ;Get the palette type
-
- @@LoadSeg ds,sppalseg ;Point to decoded palette buffer
- mov si,sppalofs
-
- cmp bx,pal1 ;Now determine the palette type
- je fxSP_pal1
-
- cmp bx,pal2
- je fxSP_pal1
-
- cmp bx,pal3
- je fxSP_pal3
-
- cmp bx,pal4
- je fxSP_pal4
-
- cmp bx,pal5
- jne fxSP_palerr ;Change je/jmp order, since not
- ; close enough
- jmp fxSP_pal5
-
- fxSP_palerr:
-
- @SetRet spret,fxERR_BADPAL ;Bad display type
- jmp fxSP_exit
-
- fxSP_pal1:
-
- mov dh,ds:[si] ;Get the background color
- ; in case we need intensity
- mov al,ds:[si][1] ;Get the palette type
-
- cmp al,4 ;Supposedly 8 palettes, but only 4
- jl fxSP_pal1det ; are supported
- sub al,4
-
- fxSP_pal1det:
-
- cmp al,0 ;Palette 0? (Red, Green, Brown)
- jne fxSP_pal11
-
- mov dl,0 ;Select palette
-
- jmp SHORT fxSP_pal1set
-
- fxSP_pal11:
-
- cmp al,1 ;Palette 1? (Lt Red, Lt Green, Yell)
- jne fxSP_pal12
-
- mov dl,0 ;Select palette
- or dh,00010000B ; (Background bit 4=hi intensity)
-
- jmp SHORT fxSP_pal1set
-
- fxSP_pal12:
-
- cmp al,2 ;Palette 2? (Cyan, Magenta, Lt Gray)
- jne fxSP_pal13
-
- mov dl,1 ;Select palette
-
- jmp SHORT fxSP_pal1set
-
- fxSP_pal13:
-
- ;Palette 3 (Lt Cyan, Lt Mag, White)
- mov dl,1 ;Select palette
- or dh,00010000B ; (Background bit 4=hi intensity)
-
- fxSP_pal1set:
-
- mov bh,1 ;Select palette function
- mov bl,dl ; and palette
- @BIOS SETCGAPAL ; and set it
-
- mov bh,0 ;Select background function
- mov bl,dh ; and background
- @BIOS SETCGAPAL ; and set it
-
- @SetRet spret,fxSUCCESS
- jmp SHORT fxSP_exit
-
- fxSP_pal2:
-
- mov bl,ds:[si] ;Get the foreground color
- mov bh,0 ;Select palette function
- @BIOS SETCGAPAL ; and set it
-
- @SetRet spret,fxSUCCESS ;If so, we are done
- jmp SHORT fxSP_exit
-
- fxSP_pal3:
-
- @@LoadSeg es,ds ;Point to palette
- mov dx,si
-
- mov al,2 ;Select palette function (all)
- @BIOS SETPAL ; and set it
-
- @SetRet spret,fxSUCCESS
- jmp SHORT fxSP_exit
-
- fxSP_pal4:
-
- mov bx,15 ;First palette reg (work back)
- @@LoadSeg es,ds ;Point to palette table
- mov di,si
- add di,2*15 ;Adjust for triples
- ; ie, palptr+(15)+(2*15) is last
- ; reg in table of 3*16 DAC's
- fxSP_pal4loop:
-
- mov dh,es:[di][bx] ;Get DAC values
- mov ch,es:[di][bx+1]
- mov cl,es:[di][bx+2]
-
- push bx ;Save palette number
- mov al,7 ;Get palette reg
- @BIOS SETPAL
-
- mov bl,bh ;Move value down
- xor bh,bh ; so BX = desired DAC reg number
-
- mov al,10H ;Now set it
- @BIOS SETPAL
- pop bx ;Retrieve palette
-
- dec di ;Point to next DAC entry
- dec di
- dec bx ; by bumping back total of 3
- jns fxSP_pal4loop ;Loop until done
-
- @SetRet spret,fxSUCCESS ;Set success code
- jmp SHORT fxSP_exit
-
- fxSP_pal5:
-
- @@LoadSeg es,ds ;Point to palette
- mov dx,si
- mov cx,256 ;Set 256 registers
- mov bx,0 ; starting at register 0
- mov al,12H ;Select update palette function
- @BIOS SETPAL ; and set
-
- @SetRet spret,fxSUCCESS
-
- fxSP_exit:
-
- @Exit spret,spparm ;Return
-
- fxSetPalette ENDP
-
- ;**********
-
- ;
- ; This procedure cycles through a set of palette registers, repeating for
- ; the given number of times, and delaying between each set.
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
- pcpalseg equ <[bp+16]> ;Palette pointer
- pcpalofs equ <[bp+14]>
- pcstart equ <[bp+12]> ;Starting palette number
- pctotal equ <[bp+10]> ;Total number to cycle
- pcrepeat equ <[bp+ 8]> ;Number of times to repeat
- pcdelay equ <[bp+ 6]> ;Time Delay
- pcparm equ 12
-
- ;Define local variables
- pcret equ <[bp- 2]> ;Return code
- pcpaltype equ <[bp- 4]> ;Palette type
- pclocal equ 4 ;Total local space needed
-
- fxPaletteCycle PROC FAR
-
- @Entry pclocal ;Set up frame and save regs
-
- @@LoadSeg ds,pcpalseg ;Point to the palette
- mov si,pcpalofs
-
- @@Data es ; and use the toolkit buffer
- mov di,OFFSET pcxFBUFF
-
- mov cx,800 ;Copy 800 bytes, regardless
- rep movsb
-
- @@Data ds ;Restore our data pointer
- mov si,OFFSET pcxFBUFF ; and point back to the new pal
-
- call pcxGetDisplay ;Get the current display type
- cmp ax,0
- jge fxPC_getstruc ;If no error, continue
-
- @SetRet pcret,ax ;Bad Display type
- jmp fxPC_exit ; so exit
-
- fxPC_getstruc:
-
- push ax ;Argument is display type
- call pcxGetDispStruc ;Get the display structure (dx:ax)
- cmp ax,0
- jae fxPC_detproc ;Successful?
-
- @SetRet pcret,pcxERR_GENERAL ;General error,
- jmp fxPC_exit ; so exit
-
- fxPC_detproc:
-
- mov di,ax ;Put returned pointer into regs
- @@LoadSeg es,dx
-
- mov bx,es:[di].dpal ;Get the palette type
- mov pcpaltype,bx ; and store
-
- cmp bx,pal3 ;EGA type palette?
- je fxPC_pal3
-
- cmp bx,pal4 ;VGA type palette (16)?
- je fxPC_pal4
-
- cmp bx,pal5 ;VGA type palette (256)?
- jne fxPC_palerr
- jmp SHORT fxPC_pal5
-
- fxPC_palerr:
-
- @SetRet pcret,fxERR_BADPAL ;No, so can't do anything
- jmp fxPC_exit
-
- fxPC_pal3:
-
- mov cx,pcrepeat ;Get the repeat count
-
- cmp cx,0 ;If zero, break out early
- jbe fxPC_pal3exit
-
- fxPC_pal3loop:
-
- push cx ;Save outer loop count
-
- mov cx,pctotal ;Get number of regs to update
-
- mov bx,pcstart ;Get the starting number
- add bx,cx ; and build a pointer out of it
- dec bx
-
- mov dl,ds:[si][bx] ;Save final register
-
- fxPC_pal3mod:
-
- mov al,ds:[si][bx-1] ;Get the previous register
- mov ds:[si][bx],al ; and store
-
- dec bx ;Bump pointer
-
- loop fxPC_pal3mod
-
- mov ds:[si][bx],dl ;And wrap last to first
-
- mov ax,pcpaltype ;Now set the palette
- push ax
- push ds
- push si
- call fxSetPalette
-
- mov ax,pcdelay ;Delay
- push ax
- call fxEffectDelay
-
- pop cx ;Restore outer loop count
-
- loop fxPC_pal3loop
-
- fxPC_pal3exit:
-
- @SetRet pcret,fxSUCCESS
- jmp SHORT fxPC_exit
-
- fxPC_pal4:
-
- fxPC_pal5:
-
- mov cx,pcrepeat ;Get the repeat count
-
- cmp cx,0 ;If zero, break out early
- jbe fxPC_pal4exit
-
- fxPC_pal4loop:
-
- push cx ;Save outer loop count
-
- mov cx,pctotal ;Get number of regs to update
- mov ax,cx ; and multiply by triples
- shl ax,1
- add cx,ax
-
- mov bx,pcstart ;Get the starting number
- dec bx
-
- mov ax,bx ;We point at triples,
- shl ax,1 ; so mult by two
- add bx,ax ; and add to get three
-
- add bx,cx ;Build a pointer out of it
-
- mov dl,ds:[si][bx] ;Save final register
- push dx
- mov dl,ds:[si][bx+1]
- push dx
- mov dl,ds:[si][bx+2]
- push dx
-
- fxPC_pal4mod:
-
- mov al,ds:[si][bx-1] ;Get the previous register
- mov ds:[si][bx+2],al ; and store
-
- dec bx ;Bump pointer
-
- loop fxPC_pal4mod
-
- pop dx ;And wrap last to first
- mov ds:[si][bx+2],dl
- pop dx
- mov ds:[si][bx+1],dl
- pop dx
- mov ds:[si][bx],dl
-
- mov ax,pcpaltype ;Now set the palette
- push ax
- push ds
- push si
- call fxSetPalette
-
- mov ax,pcdelay ;Delay
- push ax
- call fxEffectDelay
-
- pop cx ;Restore outer loop count
-
- loop fxPC_pal4loop
-
- fxPC_pal4exit:
-
- @SetRet pcret,fxSUCCESS
-
- fxPC_exit:
-
- @Exit pcret,pcparm ;Return
-
- fxPaletteCycle ENDP
-
- ;**********
-
- ;
- ; This procedure fades a given set of palette registers by the given
- ; increment, repeatedly. It then delays for the specified amount of ms.
- ;
- ;
-
- ;Define variable locations on the stack (pascal model)
- pfpalseg equ <[bp+18]> ;Palette pointer
- pfpalofs equ <[bp+16]>
- pfstart equ <[bp+14]> ;Starting palette number
- pftotal equ <[bp+12]> ;Total number to fade
- pfinc equ <[bp+10]> ;Increment value
- pfrepeat equ <[bp+ 8]> ;Repeat value
- pfdelay equ <[bp+ 6]> ;Time Delay
- pfparm equ 14
-
- ;Define local variables
- pfret equ <[bp- 2]> ;Return code
- pfpaltype equ <[bp- 4]> ;Palette type
- pflocal equ 4 ;Total local space needed
-
- fxPaletteFade PROC FAR
-
- @Entry pflocal ;Set up frame and save regs
-
- @@LoadSeg ds,pfpalseg ;Point to the palette
- mov si,pfpalofs
-
- @@Data es ; and use the toolkit buffer
- mov di,OFFSET pcxFBUFF
-
- mov cx,800 ;Copy 800 bytes, regardless
- rep movsb
-
- @@Data ds ;Restore our data pointer
- mov si,OFFSET pcxFBUFF ; and point back to the new pal
-
- call pcxGetDisplay ;Get the current display type
- cmp ax,0
- jge fxPF_getstruc ;If no error, continue
-
- @SetRet pfret,ax ;Bad Display type
- jmp fxPF_exit ; so exit
-
- fxPF_getstruc:
-
- push ax ;Argument is display type
- call pcxGetDispStruc ;Get the display structure (dx:ax)
- cmp ax,0
- jae fxPF_detproc ;Successful?
-
- @SetRet pfret,pcxERR_GENERAL ;General error,
- jmp fxPF_exit ; so exit
-
- fxPF_detproc:
-
- mov di,ax ;Put returned pointer into regs
- @@LoadSeg es,dx
-
- mov bx,es:[di].dpal ;Get the palette type
- mov pfpaltype,bx ; and store
-
- cmp bx,pal4 ;VGA type palette (16)?
- je fxPF_pal4
-
- cmp bx,pal5 ;VGA type palette (256)?
- jne fxPF_palerr
- jmp SHORT fxPF_pal5
-
- fxPF_palerr:
-
- @SetRet pfret,fxERR_BADPAL ;No, so can't do anything
- jmp fxPF_exit
-
- fxPF_pal4:
-
- fxPF_pal5:
-
- @@LoadSeg es,pfpalseg ;Point to the palette
- mov di,pfpalofs
-
- mov cx,pfrepeat ;Get the repeat count
-
- cmp cx,0 ;If zero, break out early
- jne fxPF_chktype
-
- jmp fxPF_pal4exit
-
- fxPF_chktype:
-
- cmp cx,fxFADEOUT ;Fading out?
- jne fxPF_chkin
-
- mov ax,64 ;Get the maximum repeat
- mov bx,pfinc ; and divide by the increment
- div bl
-
- xor ah,ah ;Store as the count
- mov cx,ax
-
- fxPF_chkin:
-
- cmp cx,fxFADEIN ;Fading in?
- jne fxPF_pal4loop
-
- mov cx,pftotal ;Get number of regs to update
- mov ax,cx ; and multiply by triples
- shl ax,1
- add cx,ax
-
- mov bx,pfstart ;Get the starting number
-
- mov ax,bx ;We point at triples,
- shl ax,1 ; so mult by two
- add bx,ax ; and add to get three
-
- add bx,cx ;Build a pointer out of it
-
- xor ax,ax
-
- fxPF_zero:
-
- mov ds:[si][bx],al ;Zero the register
- dec bx
- loop fxPF_zero
-
- mov ax,64 ;Get the maximum repeat
- mov bx,pfinc ; and divide by the increment
- div bl
-
- xor ah,ah ;Store as the count
- mov cx,ax
-
- fxPF_pal4loop:
-
- push cx ;Save outer loop count
-
- mov cx,pftotal ;Get number of regs to update
- mov ax,cx ; and multiply by triples
- shl ax,1
- add cx,ax
-
- mov bx,pfstart ;Get the starting number
-
- mov ax,bx ;We point at triples,
- shl ax,1 ; so mult by two
- add bx,ax ; and add to get three
-
- add bx,cx ;Build a pointer out of it
-
- fxPF_pal4mod:
-
- mov al,ds:[si][bx] ;Get the register
- mov dl,pfinc ;Get the increment
-
- cmp WORD PTR pfrepeat,fxFADEOUT ;Fading out?
- jne fxPF_pal4chkin
-
- cmp al,0 ;Already zero?
- je fxPF_pal4set
-
- sub al,dl ;If not, bump down
- jns fxPF_pal4set
-
- mov al,0
- jmp SHORT fxPF_pal4set
-
- fxPF_pal4chkin:
-
- cmp WORD PTR pfrepeat,fxFADEIN ;Fading in?
- jne fxPF_pal4norm
-
- cmp al,es:[di][bx] ;Are we at max yet?
- je fxPF_pal4set
-
- add al,dl ;If not, bump up
- cmp al,es:[di][bx]
- jbe fxPF_pal4set
-
- mov al,es:[di][bx]
- jmp SHORT fxPF_pal4set
-
- fxPF_pal4norm:
-
- add al,dl ; add from current pal value
-
- fxPF_pal4set:
-
- mov ds:[si][bx],al ; and store
-
- fxPF_pal4chkloop:
-
- dec bx ;Bump pointer
-
- loop fxPF_pal4mod
-
- mov ax,pfpaltype ;Now set the palette
- push ax
- push ds
- push si
- call fxSetPalette
-
- mov ax,pfdelay ;Delay
- push ax
- call fxEffectDelay
-
- pop cx ;Restore outer loop count
-
- loop fxPF_pal4loop
-
- fxPF_pal4exit:
-
- @SetRet pfret,fxSUCCESS
-
- fxPF_exit:
-
- @Exit pfret,pfparm ;Return
-
- fxPaletteFade ENDP
-
- @EndCode
-
- END
-
-