programmers resources
  http://www.intel-assembler.it/  (c)2017 intel-assembler.it   info@intel-assembler.it
 
Search :  
Lingua Italiana    English Language   
Index
 
just an empty assembly space
just an arrow Intel Platform
just an arrow Article & Guides
just an arrow Download Software


23/01/2009 Featured Article: How to remove Buzus Virus (permalink)




:::3061970:::
Bottone Scambio Directory Pubblicitaonline.it
Home Page | Articles & Guides | Download | Intel Platform | Contacts

Google
 


Bookmark and Share
Download 
Tell a friend



Crossfade Asm Effect

Asm source code for a crossfading effect

(by esak)

An asm fading routine which uses palette manipulation to switch between different images.
The exposed asm routines are then called from a C example program:

void setPal(void far pal);
void fill_pal(void far pal,char red,char green,char blue);
void copy_pal(void far pal,void far pal_dest);
void sub_palette(void far pal,void far pal_dest);
void fade_between_once(void far pal,void far pal_dest);

Source code is very compact.

This article is online from 2894 days and has been seen 3967 times


ΥΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΈ
³ ³
³ ***** Cross Fade ***** ³
³ ³
³ By Esak (September 29, 1994) ³
ΤΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΎ

ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
A sad legal c**p

I make no warranty whatsoever regarding this product. I assume no
responsiblity for any malicious impact on you, your computer, your red
blood cell production, or the sanity of the presidential candidate you
supported during the last election, made by the use or misuse of this
product.
ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ


Hi there,

When I knew very little programming, I was highly impressed by the cross
fading featured in the intro to _Chuck Yeager's Air Combat_. Now I know more
about graphics programing, I decided to sit down and do it.

Again, learn from it if you can. Rip this off if you want. You may even
include source in your own library as long as your library is a freeware as
well. I won't ask for any credit either. But if you find this useful, a
postcard would be nice, though.


ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
Files
ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
FADE.ASM This module contains some palette manipulating routines.
*.OBJ OBJ files. Compiled for large model.
MODEL.INC Include file for FADE.ASM
Change this if you would like to compile under a
different memory model.

CROSFADE.C A sample program demonstrating cross fading.
Link with FADE.ASM.
CROSFADE.PRJ Project file I used to link this program.
CROSFADE.EXE The executable.

IMAGE.RAW 320*200 raw image file used by FADEDEMO
PAL1.PAL palette file used by FADEDEMO
PAL2.PAL palette file used by FADEDEMO

CROSMAKE.ZIP This is the ZIP file containing the executable and
the source codes for the utility used to create
IMAGE.RAW, PAL1.PAL and PAL2.PAL

READMEOR.ELS You are reading this.
README.1st You read it before.


ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
Okay, here is the idea behind this.
ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
(WARNING: If you don't know binary maths+hexadecimal, the following may be
confusing to you.)


You know there is one byte located for each pixel in VGA 256 color mode(s),
right? Well, the idea is to divide this one byte for two images. So one
image uses the first four bit, and the other image uses the next four bit.
So each image can use 16 colors each. Let's say the first image goes
like this (Hexadecimal):

0 E 3 4 7 2 F

And the second image goes like this:

A 2 9 C D F 8

Then when we mix those images, the screen will look like this:

0A E2 39 4C 7D 2F F8

Okay, that should be straight forward. But the screen will probably look
like a mess. How do we make one image stand up?

* Now it's up to palette magic to take over the task. Let's say the palette *
* data for the each image is like this: *

Palette for Image 1 Palette for Image2

Col 0 : Black Col 0: Black
Col 1 : Blue Col 1: Very Very Dark Red
Col 2 : Red Col 2: Very Dark Red
... ...
Col 15: WHite Col 15: Light Red

And let's say we want to hide the second image and show the first image. Then
all we have to do is to set up the system palette like this:

Col 0 : Black
Col 1 : Black
...
Col 15(0F): Black

Col 16(10)-31(1F): Blue
Col 32(20)-63(2F): Red
and so on...

In other words, to hide the image stored in lower 4 bits and to show the
image stored in upper four bits, SET UP THE PALETTE so only upper four
bits make any difference. (You can see that 10,15,1F are all going to look
alike on the screen, right?)

Likewise, to hide the first image and show the second image stored in lower
four bits:

Col 0 (00): Black
Col 1 (01): Very Very Dark Red
Col 2 (02): Very Dark Red
...
Col 15(0F): Light Red

Col 16(10): Black
Col 17(11): Very Very Dark Red
Col 18(12): Very Dark Red
...
Col 31(1F): Light Red

..and so on..


So to fade from one image to another, what we need are:

-Screen that's mixture of two 16 color images
-Two palettes

And we smoothly fade from one palette to another and VOILA! We got
crossfading working!


ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
What My Programs Do.
ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ

Okay, since I explained the idea behind crossfading, let me explain the
source codes. All CROSFADE.EXE does is:

-Load the bitmap image that's pre-mixed.
-Load the palettes that have been pre-processed as described in the
previous section.
-Fade between the two palettes.

It would be better idea to process the palettes in real time to save
memory. (loading two 16*3 byte long palettes vs. loading two 256*3 byte long
palettes.)
But I wanted to provide binary files you can take a look at.

Those image and palette files used by CROSFADE.EXE were created using
CROSMAKE.EXE, which is included in CROSMAKE.ZIP. The full content of
CROSMAKE.ZIP is:

CROSMAKE.EXE The executable
CROSMAKE.C The source code
FADE1.RAW The first 320*200 bitmap image. (Each pixel is 1 byte,
but only 16 colors are used.)
FADE1.PAL The palette file for the first bitmap
FADE2.RAW The second 320*200 bitmap image.
FADE2.PAL The palette file for the second bitmap.



You have your choices: You can choose to premix the images as I did, or
mix two images in real time. Once you grasp the concept, this crossfading
business is very easy to program.



ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
About the palette fading routine used.
ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ

I recycled the palette morphing routine included in FADECODE.ZIP, which is
another source code package I released. If you want to see some explanation
for this piece of code, look for that package.


ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
About Graphics
ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ

In case you have question about how to create bitmap images:

I used Deluxe Paint II Animation to paint the images. (It was a quickie
job with 16 colors, so they didn't turn out to be Leonardo or anything.)

Then I saved the images in PCX format. And I used a PCX utility I wrote to
extract the palette and raw format data used by CROSMAKE.EXE.


ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
Where to go from here.
ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ

This concept of splitting the color byte to two has a lot of potential.
It should be possible to fade from the second image to third image, by
simply changing upper or lower 4 bits, and then fading to the third
palette.

Also you can choose to have one image that uses 32 colors and another that
uses 8 colors, instead of evenly dividing 8 bits..

Also it should be possible to animate both images while fading... It should
be possible to overlap two images instead of fading... It should be possible
to use transparent color for one bitmap... Oh boy, there are endless
possibilities...



ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
To fellow coders
ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ

I have a very fast local bus VGA card. This toy allowed me to play _Strike
Commander_ on my 486/25. The problem is that many games and demos exhibit
intolerable amount of snow when they change palette.

I see strong evidences that many programmers are still sending palette data
byte by byte. (out dx,al) I use this command instead.

rep outsb

This rep outsb command format has been around since 80286 came out. For
Goodness' sake, use it!
I update 128 colors (384 bytes) at once and I get no snow on my video card.
(Updating 256 color at once gave me little snow, though.)

I am getting sick and tired of seeing snow on so many games and demos (Except
for some exceptions like _Zone66_.) If you don't want to use my routine for
palette fading, at least use rep outsb for updating palette.



ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
About me
ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
I am a second year computer engineering student attending Carnegie Mellon
University, Pittsburgh, Pennsylvania, USA.

I always hated the morons who release undocumented assembly source codes
with no explanation. But unfortunately, I myself isn't that good at
explaning things. So if you have specific questions while trying to decipher
what on earth I am raving about, ask me. I will try to rephrase. I really
want people to be able to understand my source codes and use them.


The surest and fastest way to reach me would be through the Internet.
My internet e-mail address is:
Esak+@cmu.edu


I will do my best to reply, but don't get upset if you don't get any. Flames,
outrageous requests, and questions like "I don't know C. What can I do?"
etc, will most likely be ignored.


If you don't have an internet account, or would like to send me a postcard,
a Lamborghini, a chunk of fissionable material, or an alien facehugger, use
the following address. (Valid for 1994-95 school year)

1060 MOREWOOD AVE.
Box No. 1504
PITTSBURGH PA 15213
USA


The alternate mailing address follows. It's the address of my uncle and
aunt's home.
Just make sure you use my real name (Hyun Yim) so they can forward the mails
correctly.

37 Blanan Drive
Chicopee, MA 01020-4803
USA



I used TC++3.0 and TASM 4.0. Use /m2 option when compiling with TASM.

Well, that's it for now. Watch out for my first game which will be released
sometime before the end of this millenium.


Esak

ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ

My friends are toys. I make them.

- JF Sebastian, from _BladeRunner_



My sister and I were driving along the other day when she asked me, what
would I like for my computer.
I thought long and hard about it, and came up with the following
hypothesis. When a girl gets a Barbie doll, she then wants the extra
ballgown for the doll, then the hairbrush, and the car, and the house,
and the friends etc.
When a guy gets a computer, he wants the extra memory, the bigger
hard drive, the maths co-pro, the better motherboard, the latest software,
and the bigger monitor etc.
I told my sister all of this, and finished up with : "So as you can
see, computers are Barbie dolls for MEN!"
She called me a chauvinist. And hit me. Hard.

- Grant Smith, aka DENTHOR of Asphyxia


Top
Download 
Tell a friend
Bookmark and Share



Similar Articles

Bezier
An asm routine for drawing a Bezier curve
(by Ron Thomas)

Bresenham's Line and Circle Algorithms
design line and circle algorithm
(by Mark Feldman)

S-BUFFER FAQ
Method to implement advanced video buffering
(by Paul Nettle)

Scrolling
Basics of scrolling with many infos and pseudocode
(by Alec Thomas)

SVGA PutPixel
Programming the SVGA card in asm and C
(by ABE)

 Tags: 2d


webmaster jes
writers rguru, tech-g, aiguru, drAx

site optimized for IE/Firefox/Chrome with 1024x768 resolution

Valid HTML 4.01 Transitional


ALL TRADEMARKS ® ARE PROPERTY OF LEGITTIMATE OWNERS.
© ALL RIGHTS RESERVED.

hosting&web - www.accademia3.it

grossocactus
find rguru on
http://www.twitter.com/sicurezza3/
... send an email ...
Your name

Destination email

Message

captcha! Code