home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / crosfade / readmeor.els < prev    next >
Text File  |  1994-09-29  |  12KB  |  314 lines

  1. ╒═══════════════════════════════════════════════════════════════════════════╕
  2. │                                                                           │
  3. │  *****  Cross Fade         *****                                          │
  4. │                                                                           │
  5. │    By Esak     (September 29, 1994)                                       │
  6. ╘═══════════════════════════════════════════════════════════════════════════╛
  7.  
  8. ══════════════════════════════════════════════════════════════════════════
  9. A sad legal c**p
  10.  
  11.   I make no warranty whatsoever regarding this product. I assume no 
  12.  responsiblity for any malicious impact on you, your computer, your red 
  13.  blood cell production, or the sanity of the presidential candidate you 
  14.  supported during the last election, made by the use or misuse of this 
  15.  product.
  16. ══════════════════════════════════════════════════════════════════════════
  17.  
  18.  
  19. Hi there,
  20.  
  21.   When I knew very little programming, I was highly impressed by the cross 
  22. fading featured in the intro to _Chuck Yeager's Air Combat_. Now I know more 
  23. about graphics programing, I decided to sit down and do it. 
  24.  
  25.   Again, learn from it if you can. Rip this off if you want. You may even 
  26. include source in your own library as long as your library is a freeware as 
  27. well. I won't ask for any credit either. But if you find this useful, a 
  28. postcard would be nice, though.
  29.  
  30.  
  31. ══════════════════════════════════════════════════════════════════════════
  32. Files
  33. ══════════════════════════════════════════════════════════════════════════
  34. FADE.ASM            This module contains some palette manipulating routines. 
  35. *.OBJ               OBJ files. Compiled for large model.
  36. MODEL.INC           Include file for FADE.ASM
  37.             Change this if you would like to compile under a 
  38.             different memory model. 
  39.  
  40. CROSFADE.C          A sample program demonstrating cross fading.
  41.             Link with FADE.ASM.
  42. CROSFADE.PRJ        Project file I used to link this program.
  43. CROSFADE.EXE        The executable.
  44.  
  45. IMAGE.RAW           320*200 raw image file used by FADEDEMO
  46. PAL1.PAL            palette file used by FADEDEMO
  47. PAL2.PAL            palette file used by FADEDEMO
  48.  
  49. CROSMAKE.ZIP        This is the ZIP file containing the executable and
  50.             the source codes for the utility used to create
  51.             IMAGE.RAW, PAL1.PAL and PAL2.PAL
  52.  
  53. READMEOR.ELS        You are reading this.
  54. README.1st          You read it before.
  55.  
  56.  
  57. ═════════════════════════════════════════════════════════════════════════
  58. Okay, here is the idea behind this.
  59. ══════════════════════════════════════════════════════════════════════════
  60. (WARNING: If you don't know binary maths+hexadecimal, the following may be 
  61. confusing to you.)
  62.  
  63.  
  64. You know there is one byte located for each pixel in VGA 256 color mode(s), 
  65. right? Well, the idea is to divide this one byte for two images. So one
  66. image uses the first four bit, and the other image uses the next four bit.
  67.   So each image can use 16 colors each. Let's say the first image goes 
  68. like this (Hexadecimal):
  69.  
  70.   0 E 3 4 7 2 F
  71.  
  72.   And the second image goes like this:
  73.  
  74.   A 2 9 C D F 8
  75.  
  76.   Then when we mix those images, the screen will look like this:
  77.  
  78.   0A E2 39 4C 7D 2F F8
  79.  
  80.   Okay, that should be straight forward. But the screen will probably look 
  81. like a mess. How do we make one image stand up? 
  82.  
  83. * Now it's up to palette magic to take over the task. Let's say the palette *
  84. * data for the each image is like this:                                     *
  85.  
  86.   Palette for Image 1                 Palette for Image2
  87.  
  88.   Col 0 : Black                       Col 0: Black
  89.   Col 1 : Blue                        Col 1: Very Very Dark Red
  90.   Col 2 : Red                         Col 2: Very Dark Red
  91.   ...                                 ...
  92.   Col 15: WHite                       Col 15: Light Red
  93.  
  94. And let's say we want to hide the second image and show the first image. Then
  95. all we have to do is to set up the system palette like this: 
  96.  
  97.   Col 0 : Black
  98.   Col 1 : Black
  99.   ...
  100.   Col 15(0F): Black
  101.  
  102.   Col 16(10)-31(1F): Blue
  103.   Col 32(20)-63(2F): Red
  104.   and so on...
  105.  
  106. In other words, to hide the image stored in lower 4 bits and to show the 
  107. image stored in upper four bits, SET UP THE PALETTE so only upper four
  108. bits make any difference. (You can see that 10,15,1F are all going to look
  109. alike on the screen, right?)
  110.  
  111. Likewise, to hide the first image and show the second image stored in lower
  112. four bits:
  113.  
  114.   Col 0 (00): Black
  115.   Col 1 (01): Very Very Dark Red
  116.   Col 2 (02): Very Dark Red
  117.   ...
  118.   Col 15(0F): Light Red
  119.  
  120.   Col 16(10): Black
  121.   Col 17(11): Very Very Dark Red
  122.   Col 18(12): Very Dark Red
  123.   ...
  124.   Col 31(1F): Light Red
  125.  
  126.   ..and so on..
  127.  
  128.  
  129. So to fade from one image to another, what we need are:
  130.  
  131. -Screen that's mixture of two 16 color images
  132. -Two palettes
  133.  
  134. And we smoothly fade from one palette to another and VOILA! We got 
  135. crossfading working!
  136.  
  137.  
  138. ══════════════════════════════════════════════════════════════════════════
  139. What My Programs Do.
  140. ══════════════════════════════════════════════════════════════════════════
  141.  
  142. Okay, since I explained the idea behind crossfading, let me explain the
  143. source codes. All CROSFADE.EXE does is:
  144.  
  145.  -Load the bitmap image that's pre-mixed.
  146.  -Load the palettes that have been pre-processed as described in the
  147.   previous section.
  148.  -Fade between the two palettes.
  149.  
  150. It would be better idea to process the palettes in real time to save 
  151. memory. (loading two 16*3 byte long palettes vs. loading two 256*3 byte long 
  152. palettes.) 
  153. But I wanted to provide binary files you can take a look at.
  154.  
  155.   Those image and palette files used by CROSFADE.EXE were created using
  156. CROSMAKE.EXE, which is included in CROSMAKE.ZIP. The full content of 
  157. CROSMAKE.ZIP is:
  158.  
  159.   CROSMAKE.EXE         The executable
  160.   CROSMAKE.C           The source code
  161.   FADE1.RAW            The first 320*200 bitmap image. (Each pixel is 1 byte,
  162.                but only 16 colors are used.)
  163.   FADE1.PAL            The palette file for the first bitmap
  164.   FADE2.RAW            The second 320*200 bitmap image.
  165.   FADE2.PAL            The palette file for the second bitmap.
  166.  
  167.  
  168.  
  169.    You have your choices: You can choose to premix the images as I did, or 
  170. mix two images in real time. Once you grasp the concept, this crossfading
  171. business is very easy to program.
  172.  
  173.  
  174.  
  175. ══════════════════════════════════════════════════════════════════════════
  176. About the palette fading routine used.
  177. ══════════════════════════════════════════════════════════════════════════
  178.  
  179. I recycled the palette morphing routine included in FADECODE.ZIP, which is 
  180. another source code package I released. If you want to see some explanation
  181. for this piece of code, look for that package.
  182.  
  183.  
  184. ══════════════════════════════════════════════════════════════════════════
  185. About Graphics
  186. ══════════════════════════════════════════════════════════════════════════
  187.  
  188. In case you have question about how to create bitmap images:
  189.  
  190. I used Deluxe Paint II Animation to paint the images. (It was a quickie
  191. job with 16 colors, so they didn't turn out to be Leonardo or anything.)
  192.  
  193. Then I saved the images in PCX format. And I used a PCX utility I wrote to 
  194. extract the palette and raw format data used by CROSMAKE.EXE.
  195.  
  196.  
  197. ══════════════════════════════════════════════════════════════════════════
  198. Where to go from here.
  199. ══════════════════════════════════════════════════════════════════════════
  200.  
  201. This concept of splitting the color byte to two has a lot of potential.
  202. It should be possible to fade from the second image to third image, by
  203. simply changing upper or lower 4 bits, and then fading to the third 
  204. palette.
  205.  
  206. Also you can choose to have one image that uses 32 colors and another that
  207. uses 8 colors, instead of evenly dividing 8 bits..
  208.  
  209. Also it should be possible to animate both images while fading... It should
  210. be possible to overlap two images instead of fading... It should be possible
  211. to use transparent color for one bitmap... Oh boy, there are endless 
  212. possibilities...
  213.  
  214.  
  215.  
  216. ══════════════════════════════════════════════════════════════════════════
  217. To fellow coders
  218. ══════════════════════════════════════════════════════════════════════════
  219.  
  220. I have a very fast local bus VGA card. This toy allowed me to play _Strike
  221. Commander_ on my 486/25. The problem is that many games and demos exhibit
  222. intolerable amount of snow when they change palette.
  223.  
  224. I see strong evidences that many programmers are still sending palette data
  225. byte by byte. (out dx,al) I use this command instead.
  226.  
  227.     rep   outsb
  228.  
  229. This rep outsb command format has been around since 80286 came out. For
  230. Goodness' sake, use it!
  231.  I update 128 colors (384 bytes) at once and I get no snow on my video card.
  232. (Updating 256 color at once gave me little snow, though.)
  233.  
  234. I am getting sick and tired of seeing snow on so many games and demos (Except
  235. for some exceptions like _Zone66_.) If you don't want to use my routine for
  236. palette fading, at least use rep outsb for updating palette.
  237.  
  238.  
  239.  
  240. ══════════════════════════════════════════════════════════════════════════
  241. About me
  242. ══════════════════════════════════════════════════════════════════════════
  243. I am a second year computer engineering student attending Carnegie Mellon 
  244. University, Pittsburgh, Pennsylvania, USA.
  245.  
  246. I always hated the morons who release undocumented assembly source codes
  247. with no explanation. But unfortunately, I myself isn't that good at 
  248. explaning things. So if you have specific questions while trying to decipher 
  249. what on earth I am raving about, ask me. I will try to rephrase. I really 
  250. want people to be able to understand my source codes and use them.
  251.  
  252.  
  253. The surest and fastest way to reach me would be through the Internet.
  254.  My internet e-mail address is:
  255.   Esak+@cmu.edu
  256.  
  257.  
  258. I will do my best to reply, but don't get upset if you don't get any. Flames,
  259. outrageous requests, and questions like "I don't know C. What can I do?"
  260. etc, will most likely be ignored.
  261.  
  262.  
  263. If you don't have an internet account, or would like to send me a postcard,
  264. a Lamborghini, a chunk of fissionable material, or an alien facehugger, use
  265. the following address. (Valid for 1994-95 school year)
  266.  
  267.    1060 MOREWOOD AVE.
  268.    Box No. 1504
  269.    PITTSBURGH PA 15213
  270.    USA
  271.  
  272.  
  273. The alternate mailing address follows. It's the address of my uncle and
  274. aunt's home.
  275. Just make sure you use my real name (Hyun Yim) so they can forward the mails
  276. correctly.
  277.  
  278.    37 Blanan Drive
  279.    Chicopee, MA 01020-4803
  280.    USA
  281.  
  282.  
  283.  
  284. I used TC++3.0 and TASM 4.0. Use /m2 option when compiling with TASM.
  285.  
  286. Well, that's it for now. Watch out for my first game which will be released
  287. sometime before the end of this millenium.
  288.  
  289.  
  290. Esak 
  291.  
  292. ═════════════════════════════════════════════════════════════════════════
  293.  
  294. My friends are toys. I make them.
  295.  
  296.   - JF Sebastian, from _BladeRunner_
  297.  
  298.  
  299.  
  300. My sister and I were driving along the other day when she asked me, what
  301. would I like for my computer.
  302.     I thought long and hard about it, and came up with the following
  303. hypothesis. When a girl gets a Barbie doll, she then wants the extra 
  304. ballgown for the doll, then the hairbrush, and the car, and the house, 
  305. and the friends etc.
  306.     When a guy gets a computer, he wants the extra memory, the bigger 
  307. hard drive, the maths co-pro, the better motherboard, the latest software, 
  308. and the bigger monitor etc.
  309.     I told my sister all of this, and finished up with : "So as you can 
  310. see, computers are Barbie dolls for MEN!"
  311.     She called me a chauvinist. And hit me. Hard.
  312.  
  313.    - Grant Smith, aka DENTHOR of Asphyxia
  314.