home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / MS_ARCAD.ZIP / ARC4_3.CHP < prev    next >
Text File  |  1993-06-15  |  5KB  |  166 lines

  1. %
  2. #EF
  3. #T15,1,Chapter 4     Animation     Pg. 4
  4. #HS,1,4,80,25,11,1
  5. #C4,R5
  6. ~Y~I
  7.                                 ~W~IBit Block Animation~Y~I
  8.  
  9. The most common form of animation used on PCs is bit block transfer (btblt),
  10. also called pixel block transfer (pixblt).
  11.  
  12. #WN
  13. Btblts are done by ~C~Igrabbing a portion of the underlying screen image, saving
  14. it in memory, drawing something at that location, restoring the underlying
  15. image,~Y~I and repeating the process in a slightly different position.
  16. Figure 4.1 shows the btblt process.
  17.  
  18. #WN
  19. %
  20. #EF
  21. #T15,1,Chapter 4     Animation     Pg. 5
  22. #HS,1,4,80,25,11,1
  23. #C1,R3
  24. ~Y~I
  25.                                    ~W~IFigure 4.1~Y~I
  26.                          The Bit Block Transfer Process
  27.  
  28.          Background Screen Image             Pixel Image
  29.  
  30.         │ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐
  31.     ────┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐       ┌────┐ ┌────┐
  32.     ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘       └────┘ └────┘
  33.     └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
  34.     ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘         │       │
  35.     └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐         └───────┘
  36.     ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
  37.     └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
  38.     ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
  39.     └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
  40.     ────┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
  41.         └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ │
  42.  
  43.  
  44. #D3
  45. #C40,R16
  46. ~W~ISave The Underlying Image To RAM~Y~I
  47. #D1
  48. #ES,15,12,31,17
  49. #C45,R18
  50. ─┼─┼─┼─┼─┼─┼─┼─┼─
  51. ─┼─┼─┼─┼─┼─┼─┼─┼─
  52. ─┼─┼─┼─┼─┼─┼─┼─┼─
  53. ─┼─┼─┼─┼─┼─┼─┼─┼─
  54. ─┼─┼─┼─┼─┼─┼─┼─┼─
  55. #D4
  56. #C23,R24
  57. ~W~ICopy The Pixel Image To The Screen~Y~I
  58. #D1
  59. #C17,R13
  60. ┌────┐ ┌────┐
  61. └────┘ └────┘
  62.  
  63.   │       │
  64.   └───────┘
  65. #D3
  66. #EL,24
  67. #C23,R24
  68. ~W~ILeave It There For A While~Y~I
  69. #D4
  70. #EL,24
  71. #C18,R24
  72. ~W~IThen Restore The Underlying Image To The Screen~Y~I
  73. #D1
  74. #ES,15,12,31,17
  75. #ES,45,17,61,22
  76. #C1,R9
  77.         │ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐
  78.     ────┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
  79.     ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
  80.     └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
  81.     ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
  82.     └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
  83.     ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
  84.     └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
  85.     ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
  86.     └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
  87.     ────┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
  88.         └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ │
  89. #EL,24
  90. #C18,R23
  91. ~W~IThen Restore The Underlying Image To The Screen~Y~I
  92. #WP
  93. %
  94. #EF
  95. #T15,1,Chapter 4     Animation     Pg. 6
  96. #HS,1,4,80,25,11,1
  97. #C4,R5
  98. ~Y~I
  99. If we want to make a ball bounce across the screen, we can use the |BGI|
  100. ~C~Igetimage()~Y~I function to save what is currently at the spot where the
  101. ball will be drawn. We then transfer a block of pixels to the screen that
  102. form a picture of a ball. In our software we will use the BGI function
  103. ~C~Iputimage()~Y~I to do this. After the user has seen this image, we erase it
  104. by restoring whatever was there before, and we start the process all over
  105. again in another spot.
  106.  
  107. #WN
  108. #C4,R14
  109. What if we want to animate a stationary image? If for instance, we have a
  110. character in our game, we may want to show him talking. To accomplish this
  111. illusion, we paint his face on the screen with his mouth closed, save the
  112. area around his mouth with ~C~Igetimage()~Y~I, use ~C~Iputimage()~Y~I to put up a picture
  113. of his mouth open, then restore the image of the mouth in a closed position.
  114. If done reasonably fast, the face will look like he's talking.
  115.  
  116. #WP
  117. %
  118. #EF
  119. #T15,1,Chapter 4     Animation     Pg. 7
  120. #HS,1,4,80,25,11,1
  121. #C4,R5
  122. ~Y~I There is a problem with this method though. In our ball example, we
  123. assumed that the background was uniform and that the background in the
  124. square that encloses the ball is the same color as the background of the
  125. screen. This enabled us to copy the ball directly into video RAM.
  126.  
  127. #WN
  128. If the background is non-uniform, or if the background in the
  129. |square around the ball| is a different color than the background color,
  130. the image won't look right. We must find a way of combining the image of
  131. the ball with the background image without changing anything but the
  132. actual image of the ball.
  133.  
  134. #WN
  135. #C4,R16
  136. One of the ways that this can be done is by using a cutout shown in
  137. Figure 4.2. The illustration shows a ball. The background in the smallest
  138. enclosing rectangle is set to the color whose numeric value is |zero|. If
  139. we combine the cutout with the screen image by bitwise or'ing the pixels,
  140. the area overlapped by the cutout background will remain as it is.
  141.  
  142. #WP
  143. %
  144. #EF
  145. #T15,1,Chapter 4     Animation     Pg. 8
  146. #HS,1,4,80,25,11,1
  147. #C4,R5
  148. ~Y~I
  149. The place in the cutout where the actual ball will go is colored white. On
  150. the PC, a white pixel has a binary value of all 1's. If we use a bitwise
  151. or, the white area in the cutout will force the spot on the screen where
  152. the ball will be drawn to turn white, as in Figure 4.2.
  153.  
  154. #WN
  155. Finally, we combine a negative image of the ball with the actual image on
  156. the spot where we have placed the cutout, as shown in Figure 4.2. We do
  157. this using a bitwise exclusive or. This preserves the area where the black
  158. enclosing rectangle of the image overlaps onto the screen image. What we
  159. wind up with is the image of a ball seamlessly integrated onto the screen
  160. image. This technique can be used to animate any figure around the screen.
  161.  
  162.  
  163. #WP
  164. #Uarc4_2.exe
  165. #QT,T,arc4_3
  166. #X