home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 029.lha / Vsprite / POSTER < prev    next >
Text File  |  1987-04-02  |  4KB  |  86 lines

  1. Article 3169 of comp.sys.amiga:
  2. Path: mcdsun!fnf
  3. From: fnf@mcdsun.UUCP (Fred Fish)
  4. Newsgroups: comp.sys.amiga
  5. Subject: Re: Sun Tools on Amiga
  6. Summary: VSprite Reposting (nobody seems to have seen it the first time)
  7. Keywords: vsprite demo
  8. Message-ID: <283@mcdsun.UUCP>
  9. Date: 2 Apr 87 18:30:52 GMT
  10. Organization: Motorola Microcomputer Division, Tempe, Az.
  11. Lines: 687
  12.  
  13. NOTE:  Rob is having problems posting from his system and has
  14. asked me to post this for him, please respond to hplabs!dana!rap.
  15. ------------------------------------------------------------
  16.  
  17. A few weeks ago, a plea for help crossed the net regarding VSprites.
  18. I am posting the source to the VSprite demo that I had written for
  19. my book, the Programmers' Guide To The Amiga (SYBEX, January, 1987).
  20.  
  21. It produces 28 VSprites onscreen simultaneously, starting with one
  22. distinct sprite image (an "S!"), and using only three distinct
  23. sets of colors.  The limited number of colorsets was chosen to give
  24. the gel engine the best possible chance to be able to assign
  25. vsprites before running out of real sprites to use (especially
  26. since I restrict it to sprites 2-7 by using the line:
  27.  
  28.    g->sprRsrvd = 0xFC;    /* do not use sprites 0 or 1. */
  29.  
  30. This prevents the gel engine from trying to change the color of the 
  31. cursor.  
  32.  
  33. In the background area of the window, there are the digit sets
  34. 17 18 ... 31, each drawn in that particular color.  As the vsprites
  35. move you will notice that certain of the colors (21-23, 25-27, 29-31)
  36. get changed.  This illustrates that if you produce vsprites against
  37. a 32-color screen, the upper set of color registers, which is shared
  38. in the Amiga with the vsprites, get dynamically reassigned by the
  39. gel engine.  Therefore one should avoid drawing any background stuff
  40. using the colors that the vsprites use, unless you want the effect
  41. you see there (yuck).
  42.  
  43. Also, as the sprites move, if you follow any one of them, you
  44. will see it disappear occasionally.  This happens when there
  45. are more than (N) sprites on a single horizontal line.  N is 
  46. variable depending on the way that the colors have been assigned.
  47.  
  48. The list of vsprites to be produced is sorted (SortGList) from top
  49. to bottom as well as from left to right.  The lowest numbered
  50. available real sprite is chosen first, and the system creates
  51. copper (coprocessor) instructions that point to the first vsprite
  52. image, as well as instruction to load that first vsprite's colors
  53. into the real sprite color registers.  The hardware sprite thus used
  54. is declared unusable until a couple of lines past the bottommost
  55. line of this vsprite's display.
  56.  
  57. For each subsequent vsprite in the list, the system attempts the
  58. same kind of assignment for both image and color registers.  A
  59. preference is given to assigning to a hardware sprite that is
  60. both available, and for which its color registers have already
  61. been loaded with the colors that it wants to use.  Thus, hardware
  62. sprites 2 and 3 can occupy the same horizontal positions in any
  63. overlap position if both carry the same colors, and can have
  64. any arbitrary images.  The gel engine does not, however, compare
  65. the colors in the colorset to make the decision about possible
  66. sprite pair assignment.  Rather it compares the POINTERs to the 
  67. colorsets.  That is why you would not want to have multiple
  68. colorsets, each of which contained identical colors for your
  69. vsprites... because the POINTER values to those colorsets would
  70. be different and the system would run out of vsprites sooner.
  71.  
  72. The book goes into a similar example for simple sprites and uses
  73. a nearly identical data structure for its Bob example.  The
  74. programs are available on disk in both source and executable
  75. form.  All, including this one, are in Lattice C, though I'm
  76. working on converting all to run under either Lattice or Manx.
  77.  
  78. NOTE: THIS PROGRAM CAN BE COMPILED AND LINKED UNDER 1.1 (Lattice 3.03)
  79. BUT ONLY RUNS UNDER 1.2.  (There was a problem in release 1.1 that
  80. prevents VSprites from running).
  81.  
  82. Hope this helps.
  83.  
  84. Rob Peck    hplabs!dana!rap
  85.         USnail: DATAPATH, POBox 1828, Los Gatos, Ca. 95031-1828
  86.