<--- Turn the page     (contents page)     Turn the page --->



Animation, Kind of

Animation with out moving a pixel



Have you ever seen a water fall screen saver and wondered how they did the animation?

It is not as hard as you might think. Most waterfalls are set up with different shades of blue and then the palette is rotated rather than the pixels.

For instance. If I set the top of the waterfall to a lighter blue, every section down a little darker, and the last section dark blue, then I can rotate the palette and the waterfall comes alive.

Here is a sample code of a line drawn across the screen. I never move a pixel, I just rotate the palette.
.model tiny
.code

           xor  ax,ax                   ; set up palette buffer
           mov  cx,31                   ;
           mov  di,offset buffer        ;
Setup1:    stosw                        ; r(ed)
           stosb                        ; g(reen)
           inc  ax                      ; b(blue)
           inc  ax                      ;
           loop Setup1                  ;
           mov  cx,31                   ;
Setup2:    stosw                        ;
           stosb                        ;
           dec  ax                      ;
           dec  ax                      ;
           loop Setup2                  ;
           xor  ax,ax                   ; make sure rest of buffer
           stosw                        ;  is zero'd out
           stosw                        ;
           stosw                        ;
           stosw                        ;

           mov  ax,0013h                ; set screen mode 13h
           int  10h                     ;   (320x200x256)

Main:      mov  dx,offset Buffer        ; set DAC block
           mov  bx,01                   ;  skip color 0 (black)
           mov  cx,63                   ;  63 other 'registers'
           mov  ax,1012h                ;
           int  10h                     ;

           push es                      ; print the line
           mov  ax,0A000h               ; vga screen memory
           mov  es,ax                   ;
           mov  di,32000                ; half way down the screen
           xor  ax,ax                   ;
           mov  ax,63                   ; 64 times (63 + 1 for the zero)
PLoop1:    mov  cx,05                   ;
           rep                          ;
           stosb                        ;
           dec  ax                      ;
           jns  short PLoop1            ; jnz doesn't print the zero color
           pop  es                      ;

           mov  di,offset Buffer        ; scroll palette buffer
           mov  si,offset Buffer        ;
           lodsw                        ;
           mov  dx,ax                   ;
           lodsb                        ;
           mov  bl,al                   ;
           mov  cx,189                  ;
           rep                          ;
           movsb                        ;
           mov  ax,dx                   ;
           stosw                        ;
           mov  al,bl                   ;
           stosb                        ;

           ; might need a pause here, depending
           ;   on how fast your machine is

           mov  ah,01                   ; was a key pressed
           int  16h                     ;
           jz   short Main              ; zero flag in no pressed

           xor  ah,ah                   ; 'kill' the key
           int  16h                     ;

           mov  ax,0003h                ; set screen back to text (80x25)
           int  10h                     ;

           .exit                        ; ret to DOS

buffer     dup  192,?                   ; our palette buffer

.end
Depending on the speed of your computer and if you would like to get a better idea of what is going on, insert a 'pause' routine where specified above. ¥



<--- Turn the page     (contents page)     Turn the page --->

Page 3