home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / ANIVGA.ZIP / ANIVGA.DOC < prev    next >
Text File  |  1992-08-28  |  173KB  |  3,558 lines

  1.        ░░░░░░▄ ░░░▄ ░░▄ ░░░░░░▄                ░░▄ ░░▄  ░░░░▄  ░░░░░░▄
  2.        ░░█▀░░█ ░░░░▄░░█   ░░█▀▀                ░░█ ░░█ ░░█▀▀▀  ░░█▀░░█
  3.        ░░░░░░█ ░░█░░░░█   ░░█      ░░░░░░▄     ░░█ ░░█ ░░█░░░▄ ░░░░░░█
  4.        ░░█▀░░█ ░░█ ░░░█   ░░█       ▀▀▀▀▀▀      ░█ ░█▀ ░░█ ░░█ ░░█▀░░█
  5.        ░░█ ░░█ ░░█  ░░█ ░░░░░░▄                  ░░█▀   ░░░░█▀ ░░█ ░░█
  6.         ▀▀  ▀▀  ▀▀   ▀▀  ▀▀▀▀▀▀                   ▀▀     ▀▀▀▀   ▀▀  ▀▀
  7.  
  8.  
  9.                          ░░░░░▄  ░░░░░░▄  ░░░░▄
  10.                          ░░█▀░░▄ ░░█▀░░█ ░░█▀░░▄
  11.                          ░░█ ░░█ ░░█ ░░█ ░░█  ▀▀
  12.                          ░░█ ░░█ ░░█ ░░█ ░░█ ░░▄
  13.                      ░░▄ ░░░░░█▀ ░░░░░░█  ░░░░█▀
  14.                       ▀▀  ▀▀▀▀▀   ▀▀▀▀▀▀   ▀▀▀▀
  15.  
  16.                         (English documentation)
  17.  
  18.             ┌─────────────────────────────────────────────┐
  19.             │                   ANIVGA                    │
  20.             │      a sprite-unit for TurboPascal V6.0     │
  21.             │              by Kai Rohrbacher              │
  22.             │                 Version 1.1                 │
  23.             └─────────────────────────────────────────────┘
  24.  
  25.  
  26. Purpose : Animation of sprites on a VGA's 320x200x256 mode and
  27.           TurboPascal V6.0
  28. Author  : Kai Rohrbacher
  29.           Germany
  30.           Internet: S_ROHRBACHER@IRAVCL.IRA.UKA.DE
  31.           Bitnet  : UKB8@DKAUNI2.BITNET
  32.           FIDO    : 2:241/7521.7
  33. Language: TurboPascal V6.0
  34. Date    : September 1992
  35.  
  36. ---------------------------------------------------------------------
  37. Always remember: "I know my English spelling is bad, but if I used my
  38.                   own language you probably couldn't read it at all."
  39.                                                      -- Nico de Vries
  40. ---------------------------------------------------------------------
  41.  
  42. 0. Table of contents
  43. ────────────────────
  44.  
  45.   1. Prélude: Legal Notices
  46.   2. What is ANIVGA?
  47.   3. Features and Restrictions of ANIVGA
  48.   4. "HELLO WORLD" - A First Example
  49.   5. How ANIVGA works
  50.   6. Tips, tricks and techniques
  51.   7. Credits
  52.   8. ANIVGA Reference Manual
  53.  
  54.  
  55. 1. Prélude: Legal Notices
  56. ─────────────────────────
  57.  
  58. Okay, the boring stuff first...
  59.  
  60. The author hereby disclaims all warranties relating to this software,
  61. whether expressed or implied, including without limitation any implied
  62. warranties of merchantability or fitness for a particular purpose.
  63. I will not be liable for any special, incidental, consequential, indirect
  64. or similar damages due to loss of data/damage to hardware or any other
  65. reason, even if I have been advised of the possibility of such damages.
  66.  
  67. This programming toolkit is released as "freeware" by the author.
  68. It is however copyrighted and all rights and ownership are kept with the
  69. author. You may use it, copy it and give it to everybody as long as no
  70. modifications are made  -- but don't try to sell it (or part of it)!
  71.  
  72. Nevertheless, all programs you realize with this software package may be
  73. distributed/sold freely - the only thing I ask you for is to mention the use
  74. of this toolkit in your program and to send me a copy of your program, al-
  75. though a small donation would be *much* appreciated, for the reasons told in
  76. the file README.2ND (which I hope, you have read thoroughly!).
  77.  
  78.  
  79. 2. What is ANIVGA?
  80. ──────────────────
  81.  
  82. ANIVGA is a powerful toolkit for the animation of sprites on any IBM (or com-
  83. patible) with a VGA card installed.
  84. It consists of one (big) TurboPascal V6.0-unit to be used by your applications
  85. and some utilities to simplify its use:
  86.  
  87. README.1ST   - as it tells you: a text file you should read first
  88. README.2ND   - yes, *exactly* what you are thinking right now...
  89. ANIVGA.DOC   - the manual, you are reading it!
  90. FAQ.TXT      - some frequently asked questions
  91.  
  92. ANIVGA.PAS   - the source code of the animation unit
  93. MAKES.EXE    - a spritemaker program (requires a mouse and a Super-VGA-card!)
  94. GRAB.EXE     - a TSR-program to grab sprites from other graphics (req. mouse)
  95. UNLIB.EXE    - a utility to break apart a library of sprites back into
  96.                its individual sprite files
  97. DUMP_SPR.EXE - a "sprite dumper" which disassembles a (binary) sprite file
  98.                into a (recompilable) ASCII-text
  99. EXAMPLE?.PAS - a few _simple_ demo programs
  100. *.COD, *.PAL - some sprites and palettes, which belong to the demo programs
  101. SVGA256.BGI  - a BGI driver, only used for MAKES.EXE
  102.  
  103. TRANSLAT.EXE - a utility to generate a version of ANIVGA.PAS with English
  104.                comments
  105. ANIVGA.DIC   - dictionary needed for the translation
  106. *.*          - documentation, sources, ...
  107.  
  108. -> Copy these files into your TurboPascal-directory and compile ANIVGA.PAS to
  109.    implement ANIVGA on your system - that's all.
  110.  
  111.  
  112. 3. Features and Restrictions of ANIVGA
  113. ──────────────────────────────────────
  114.  
  115. Some of ANIVGA's features are:
  116.  
  117.  - flickerfree animation by a "page-flipping" algorithm and using the
  118.    display enable signal
  119.  - sprite movement in any increments you want
  120.  - arbitrary background image for the animation
  121.  - full use of the VGA's 256-color mode
  122.  - several sprite display methods available:
  123.    - sprites can be written normally (covering underlying figures)
  124.    - sprites can be declared to be transparent with regard to the background
  125.      or other sprites pixel by pixel
  126.    - sprites can change their color depending on the underlying background
  127.      image (-> shadow function)
  128.  - display methods can be different for each sprite
  129.  - pixel precise hit-detection routine built in
  130.  - correct clipping of sprites at the screen boundaries
  131.  - up to 32767 different sprites
  132.  - up to 500 sprites may be simultaneously active
  133.  - maximal size of each sprite = 64k
  134.  - maximal size of all loaded sprites only restricted by available memory
  135.  - works with virtual coordinates in the range -16000..+16000
  136.  - thus simple creation of horizontal/vertical "scrolling" games
  137.  - scrolling background image, too
  138.  - several supporting routines to: drawing lines (with built in clipping-
  139.    algorithm), points and graphic-text (incl. clipping), automatic heap
  140.    management for loading of sprites, sprite libraries, background images,
  141.    processor-speed adjustment, palette handling,...
  142.  
  143. What ANIVGA does _not_ support:
  144.  - EMS or XMS memory  (to slow)
  145.  - resolutions other than 320x200x256  (compatibility question)
  146.  
  147.  
  148. 4. "HELLO WORLD" - A First Example
  149. ──────────────────────────────────
  150.  
  151. ANIVGA uses a non-standard 320x200x256 graphic mode, different from the BIOS-
  152. mode $13, but there should be no problems with all truly compatible VGA cards.
  153. To see if ANIVGA is compatible with your system and to get a first impression
  154. of its ease of use, compile the following _simple_ program (you can find it on
  155. disk as file "EXAMPLE1.PAS"):
  156.  
  157. (Remember to copy and compile ANIVGA.PAS in your TurboPascal-Unit-directory
  158.  first!)
  159.  
  160. PROGRAM Example1;
  161. USES ANIVGA,CRT;
  162. CONST LoadNumber=42; {why not 42? - A hello to all Douglas Adam fans!}
  163.       SpriteName='FLOWER.COD'; {Path and name of the sprite to load}
  164.       Sprite1=0;
  165.       Sprite2=5;
  166.       ch:CHAR=#0; {sets ch to that value everytime the program starts}
  167. VAR collide:BOOLEAN;
  168.  
  169. BEGIN
  170.  IF loadSprite(SpriteName,LoadNumber)=0
  171.   THEN BEGIN
  172.         CloseRoutines;
  173.         WRITELN('Error: '+GetErrorMessage); halt(1)
  174.        END;
  175.  
  176.  InitGraph;
  177.  
  178.  Color:=66;
  179.  BackgroundLine(0,0,XMAX,0); BackgroundLine(XMAX,0,XMAX,YMAX);
  180.  BackgroundLine(XMAX,YMAX,0,YMAX); BackgroundLine(0,YMAX,0,0);
  181.  BackgroundOutTextXY(100,70,'Hello world!');
  182.  
  183.  SpriteN[Sprite1]:=LoadNumber;
  184.  SpriteX[Sprite1]:=0; SpriteY[Sprite1]:=0;
  185.  
  186.  SpriteN[Sprite2]:=LoadNumber;
  187.  SpriteX[Sprite2]:=XMAX SHR 1; SpriteY[Sprite2]:=YMAX SHR 1;
  188.  
  189.  Animate;
  190.  REPEAT
  191.   collide:=Hitdetect(Sprite1,Sprite2);
  192.   if collide THEN BEGIN Sound(1000); Delay(5); NoSound END;
  193.   if KeyPressed
  194.    THEN BEGIN
  195.          WHILE KeyPressed do ch:=UpCase(ReadKey);
  196.          CASE ch OF
  197.           'I':DEC(SpriteY[0]);
  198.           'J':DEC(SpriteX[0]);
  199.           'K':INC(SpriteX[0]);
  200.           'M':INC(SpriteY[0]);
  201.           'E':dec(StartVirtualY,10);  {change position of whole scene with}
  202.           'S':dec(StartVirtualX,10);  {E,S,D,X}
  203.           'D':inc(StartVirtualX,10);
  204.           'X':inc(StartVirtualY,10);
  205.          END;
  206.          IF POS(ch,'IJKMESDX')>0 THEN Animate;
  207.         END;
  208.  
  209.  UNTIL (ch='Q') OR (ch=#27);
  210.  
  211.  CloseRoutines;
  212. END.
  213.  
  214. (Don't worry if you do not understand the whole program at once - it should
  215.  only give you a first impression of ANIVGA's capabilities)
  216. If you run this program (make sure that the sprite file FLOWER.COD can be
  217. found by the program!) you should see a graphic consisting of two flowers, a
  218. rectangle showing the screen boundaries and the words "Hello world" near the
  219. middle of the screen.
  220. You can move the top left flower by using the keys "I","J","K","M".
  221. If you hit the other flower with the first one, the program will beep.
  222. Try out what happens if you move across the two words in the middle:
  223. obviously, the two leafs of the sprite behave somehow different: the black
  224. parts of left leaf are "transparent" in that the writing shines through it,
  225. while the black parts of the right leaf are "covering black".
  226. But the writing (which is written in the background image) won't be destroyed.
  227. As soon as you leave them, the words will be alright again.
  228. Move the sprite to the very left screen boundary - and move it even more to
  229. the left: you'll get the impression that it moves off the screen until it is
  230. totally offscreen.
  231. Hmmmm - how do we get it back? Sure, "K" will do, but press "S" instead: this
  232. will "pan" the whole screen 10 pixels to the left (think of that as if you
  233. could control an imaginary camera to slide to the left), "X" pans into the
  234. other direction (note the restriction of the program to non-scrolling back-
  235. ground at this point: the big rectangle and the words "Hello world" won't
  236. move because they are part of the so-called "static" background image).
  237. ("E" and "X" will behave similarily, but for the y-direction.)
  238. Now -using the "I","J","K" and "M" keys- bring back your sprite to the 2nd one
  239. and let them collide. Press "A" a few times to scroll them both offscreen.
  240. As you'll notice, the program will not stop beeping: it indicates that the two
  241. sprites collide, even if they are not visible to you!
  242. Okay, that should be enough for a first impression, so hit "Q" (or ESC) to
  243. quit the program, if you've finished wondering... :-)
  244.  
  245. There are a few more EXAMPLE programs included. They share a common thing:
  246. they are as small and simple as possible, because they shall only show you
  247. some basic techniques!
  248.  
  249. Run EXAMPLE2.PAS for a demonstration of "scrolling" background; the program is
  250. much the same as EXAMPLE1, but uses four different "tiles" to build the back-
  251. ground image. As before, you can use "I,J,K,M" to move your sprite along, but
  252. this time, you may scroll the whole scene (incl. the background!) with the
  253. "E,S,D,X" keys, too ("Q" quits, as before).
  254.  
  255. EXAMPLE3.PAS shows (an extremely) simple use of the "Display_SHADOW" mode to
  256. display a graphical object and demonstrates the difference to mode
  257. "Display_SHADOWEXACT": first, a sprite is used for its own shadow zone, simply
  258. by redrawing it with a little horizontal and vertical offset, using mode
  259. "Display_SHADOW".
  260. Although this is a nice trick with many sprites (you don't have to design
  261. extra shadow sprites this way), it doesn't always work: note that there is one
  262. area in the flower which differs from what we would expect as shadow: this is
  263. because ANIVGA assumes that everything between the left- and rightmost point
  264. of a sprite belongs to the sprite's interior and will be drawn accordingly.
  265. To circumvent this, one would have to draw one (or even several) especially
  266. designed "shadow zone" sprites for the flower, or use Display_SHADOWEXACT
  267. instead: just press the space bar to toggle to that mode.
  268. Pressing "P" draws 1000 randomly distributed points so you can better see the
  269. shadowing effect for single points.
  270. Finally, "C" copies part of the screen into memory (with GetImage() ) and
  271. pastes it somewhere else (with PutImage() ) while clipping off at the screen
  272. boundaries and is merely there to give a short demonstration of how to use
  273. these routines.
  274.  
  275. EXAMPLE4.PAS is an example how to use "sprite cycles": there are six images in
  276. the sprite (library) file HANTEL.LIB which become "glued" together to form one
  277. sprite cycle.
  278. App. one hundred copies of this sprite are then animated on the screen with
  279. maximum animation speed and again, you can scroll the whole screen area with
  280. the keys "E","S","D","X". When you do, you will note that as more and more of
  281. the sprites gets scrolled offscreen, the remaining sprites will rotate faster.
  282. Pressing the space bar will toggle between fastest animation (no time limit)
  283. and an animation rate of 200ms per frame.
  284. You can play around with this value to find out an "optimal" time for your PC
  285. and this program:
  286.  
  287.  very small: program will show the same symptoms as mentioned above (being
  288.              faster for every sprite offscreen)
  289.      .
  290.      .
  291.      .
  292.  very big  : program will slow down even when all sprites are onscreen
  293.  
  294. Somewhere between lies a value where the animation doesn't get slowed down
  295. when all sprites are onscreen (=max. work for ANIVGA), but stays at the same
  296. speed for all other cases (=less work for ANIVGA).
  297.  
  298. EXAMPLE5.PAS and EXAMPLE6.PAS are two programs to demonstrate how you can
  299. build a background image by using tiles: a 2x2 (8x4 respectively) COD-file
  300. will be loaded and pasted repetively into the virtual screen.
  301. EXAMPLE6.PAS also shows how you may tie sprites and text output to an absolute
  302. screen position in scrolling background modes!
  303.  
  304. EXAMPLE7.PAS shows you the same old demo image of the former examples, but
  305. this time using another palette, loaded from disk.
  306.  
  307. EXAMPLE8.PAS shows you all opening sequences available by the routine
  308. "FadeIn()". Press a key A..Y (without Q) to view a method, ESC will quit.
  309.  
  310.  
  311. 5. How ANIVGA works
  312. ───────────────────
  313.  
  314. (It would be _impossible_ trying to cope every detail of ANIVGA, but I'm sure
  315.  you will get the basic ideas of ANIVGA very soon.)
  316.  
  317. As already mentioned, the program uses a "tweaked" VGA-graphic mode: the VGA
  318. is programmed in a way to give 4 graphic pages at a resolution of 320x200
  319. pixels in 256 colors numbered 0..3.
  320. Page 0 and 1 are used for the display, page 2 holds the "normal" background
  321. image and page 3 can contain so-called "tiles" which can be used to build a
  322. huge background image in "scrolling" background mode.
  323. The basic idea of the "page flipping" scheme used is that: do everything (era-
  324. sing the old graphic page, draw sprites/lines/pixels/text) on a graphic page
  325. invisible to the user while showing him a completed page on the screen.
  326. Then, if finished, "flip" the page, thus making the new, completed page
  327. visible and the old page to the invisible one. Now start creating the next
  328. image on this new invisible page - and so on.
  329. "Erasing" the old image means: overdraw it completely with the background
  330. image stored in page 2 (or 3), so one could write in pseudo code:
  331.  
  332.    ...
  333.   REPEAT
  334.    show page 0 to user;
  335.    fill (invisible) page 1 with contents of page 2;
  336.    draw new sprites and all other stuff on page 1;
  337.    show page 1 to user;
  338.    fill (invisible) page 0 with contents of page 2;
  339.    draw new sprites and all other stuff on page 0;
  340.   UNTIL DOOMSDAY
  341.    ...
  342.  
  343. You as the programmer doesn't have to think much about this mechanism, the
  344. routines keep track of the page flipping automatically: the global variable
  345. "PAGE" always holds the number of the page which is invisible (and thus:
  346. the page to be drawn on). Therefore, we say that PAGE holds the "actual page"
  347. number and 1-PAGE is the page visible to the user.
  348. Most of the procedures and functions of the animation package adjust them-
  349. selves to the appropriate page; there are only a few situations where you have
  350. to be aware of this mechanism, mostly when drawing pixels or to create special
  351. effects.
  352.  
  353. The whole package is "table driven". That means, the interface to the user
  354. consists of some tables in which you specify your sprites to be drawn:
  355. You store into this tables which sprites to draw ("SpriteN[]") and their
  356. coordinates (in "SpriteX[]" and "SpriteY[]").
  357. After this, a call of the main routine "Animate()" gives back control to the
  358. animation routines, which update the graphic screen accordingly:
  359.  
  360. ...
  361. REPEAT
  362.  update SpriteN[]-table:
  363.    deactivate sprite i by storing a "0" into SpriteN[i]   or
  364.    activate a sprite k by storing k in an unused SpriteN[]-entry   or
  365.    let all the other SpriteN[]-entries as they were last cycle
  366.  FOR ALL SpriteN[i]<>0 DO
  367.    IF SpriteN[i] should change its coordinates
  368.      THEN update (SpriteX[i],SpriteY[i]) accordingly
  369.  call Animate() to draw image and display it
  370. UNTIL end-of-computer-life
  371. ...
  372.  
  373. You should notice that there are two kinds of "sprite numbers" which should
  374. not be mixed up: one is a spriteLOAD number and represents a handle to the
  375. (physical) sprite data, while the other (normally termed "sprite number") is
  376. a logical number to address this sprite data.
  377. In the pseudo code given above, "k" is the spriteLOAD number (it is a number
  378. given at load time) and the index "i" in SpriteN[i] is the sprite number.
  379. Note that "k" is a unique value: you can think of it as a NAME of the sprite
  380. data loaded (e.g. you could name the FLOWER.COD - data as "123" when loading
  381. it: there can't be another sprite with the same LOAD-number). On the other
  382. hand, there could be a hundred flowers on the screen: just choose hundred
  383. different sprite-table entries (=sprite numbers), e.g. SpriteN[100]..
  384. SpriteN[199] and store "123" in each of them!
  385. Whenever you are unsure if you (or I) are speaking of a "sprite number" or a
  386. "spriteLOAD number", remember that:
  387.  
  388.  ■ A sprite number can hold values in the range 0..NMAX and is an index of
  389.    the tables SpriteX[], SpriteY[] and SpriteN[].
  390.  ■ A spriteLOAD number can hold values between 0..LoadMax and is assigned
  391.    as a "name" to the sprites' physical loaded data; a "0" as load number is
  392.    reserved for "inactivate sprite" (in other words, it is the *content* of
  393.    an entry in SpriteN[])
  394.  
  395. Example: SpriteN[42]:=0
  396.                  │    └ spriteLOAD number
  397.                  └ sprite number
  398.  
  399. The world ANIVGA knows is 32000 pixels wide and high, numbered -16000..+16000
  400. on each axis. Because your graphic screen consists of only 320 by 200 points,
  401. (ranging from 0..XMAX and 0..YMAX in the x- and y-axis, respectively; (0,0) is
  402.  the upper left corner, (XMAX,YMAX) the lower right one) you can only see a
  403. small part of this world, but ANIVGA does not distinguish between the visible
  404. and invisible parts of the world. If, for example, two sprites collide, the
  405. routine "HitDetect()" will find out, even if this collision occurs offscreen.
  406. Thus you can think of your graphic display being a "camera" to the real world:
  407. your actions can take place everythere in this virtual world, but you see only
  408. the part displayed by your camera; if you wish to see another part of your
  409. world, you have to move this imaginary camera to that place.
  410. In ANIVGA, you can do this by changing the values "StartVirtualX" and
  411. "StartVirtualY" which hold the upper left corner of the visual window. As an
  412. example, let (StartVirtualX,StartVirtualY) be (1000,500): then on your screen
  413. you will see the part of the world which ranges from coordinates (1000..1319)
  414. and (500..699) in X- and Y-directions, respectively.
  415.  
  416.  
  417. 6. Tips, tricks and techniques
  418. ──────────────────────────────
  419.  
  420. There would be a lot of things to say and most of them will be mentioned in
  421. the following "Reference Manual". Nevertheless, it seems reasonable to repeat
  422. them in a more concentrated form here, although this happens to make this
  423. chapter a real topsyturvydom...
  424.  
  425. a) The ERROR-concept: if an error occurs in one of ANIVGA's routines, the
  426.    global variable ERROR will be set accordingly. This gives you the freedom
  427.    either to check this variable each time you called a routine - or ignore it
  428.    for improved speed.
  429.    As a rule of thumb, you should always check this variable while your pro-
  430.    gram is still in the testing phase - and "comment out" these sections when
  431.    you are through with debugging. (Conditional defines are great for that
  432.    job!)
  433.    Note that there are some routines that do not set ERROR at all (like
  434.    Screen, GetPixel, PageGetPixel, PagePutPixel), either because in some
  435.    special cases, "nice" tricks can be played with "faulty" parameters or
  436.    because of severe speed improvements! For example, if you are going to read
  437.    a 5000 pixel area from the screen with PageGetPixel(), it would be crazy to
  438.    check 5000 times whether the "page" given to read from is valid or not.
  439.  
  440. b) Pixel-drawing routines: basically spoken, there are three sorts of graphic
  441.    data objects in ANIVGA: sprites, pixels and background images.
  442.    Because of ANIVGA's working scheme, all routines handling pixels (PutPixel,
  443.    PagePutPixel, Line, PutImage,...) must be used in a special form:
  444.    - If you use them to "draw" into the background page, this can only be done
  445.      when using background mode STATIC (because in mode SCROLLING, the back-
  446.      ground is stored in a compressed "tiling" format one can't access
  447.      directly).
  448.    - Drawing into the background page in mode STATIC is fine (that's the main
  449.      advantage of this mode compared with mode SCROLLING), and the best time
  450.      to do it is _before_ calling Animate(), because changes to the background
  451.      image will then be visible with the call to this routine.
  452.    - Drawing "on the monitor screen" will be visible exactly for one animation
  453.      cycle, that is: until the next call to Animate(). For this reason, you
  454.      must do this changes _after_ calling Animate() and at the _visible_ page
  455.      1-PAGE (not the _actual_ page PAGE itself).
  456.  
  457.      It is not that difficult as it may sound at first glance; for example:
  458.      ...
  459.      REPEAT
  460.       read_user_inputs; compute_necessary_actions;
  461.        do_all_changes_to_the_background_image;
  462.        do_all_changes_to_the_sprites;
  463.        Animate();
  464.        do_all_changes_to_the_visible_screen;{e.g.: Line(0,0,XMAX,YMAX,1-PAGE)}
  465.      UNTIL user_wants_to_end_application
  466.      ...
  467.  
  468.      This way, after having called Animate(), the changes to the background
  469.      (and your sprites) will be visible (because Animate() has generated an
  470.      appropriate picture) and your changes to this image with the pixel-
  471.      drawing routines will be visible "at once".
  472.      That image will then stay visible until the next call to Animate().
  473.      (Simply spoken, you let Animate() generate and display a picture and then
  474.       do some changes to the picture while it is diplayed)
  475.    - Because of unavoidable memory restrictions, ANIVGA can't store pixels
  476.      drawn offscreen: if ANIVGA sees that points/lines lie outside the visible
  477.      screen, it just does nothing at all; in other words, you can't draw a
  478.      line outside the screen and "scroll it in" five minutes later! (You would
  479.      have to define the line as a sprite instead, because sprites are the only
  480.      objects stored independently).
  481.  
  482. c) Coordinates: Throughout all routines, ANIVGA works with _virtual_ coordi-
  483.    nates (that is values in the range xε[-16000..+16000], yε[-16000..+16000]),
  484.    but sometimes you will have to address _absolute_ coordinates (in the range
  485.    xε[0..XMAX], yε[0..YMAX]), so you have to transform virtual coordinates
  486.    into absolute coordinates (or vice versa), which is _very_ easy:
  487.  
  488.    virtual coordinates -> absolute coordinates:
  489.       Xabsolute := Xvirtual - StartVirtualX
  490.       Yabsolute := Yvirtual - StartVirtualY
  491.  
  492.    absolute coordinates -> virtual coordinates:
  493.       Xvirtual  := Xabsolute + StartVirtualX
  494.       Yvirtual  := Yabsolute + StartVirtualY
  495.  
  496. d) Background / valid pages: Many routines expect a graphic page number as
  497.    parameter. As mentioned under b), BACKGNDPAGE is valid only when you use
  498.    background mode STATIC. Nevertheless, you could draw to this page even when
  499.    you are using background mode SCROLLING without getting an error
  500.    "Err_InvalidPageNumber" (although you are _strongly_ discouraged to do
  501.    so)!
  502.    That's because you can play some tricks on ANIVGA this way, provided that
  503.    you do know _exactly_ what you (and ANIVGA) are doing, but this "feature"
  504.    will probably be cut off in future versions of this program.
  505.    (Note that this doesn't mean that you can't switch between STATIC and
  506.     SCROLLING backgrounds during runtime! - It only says that you can't use
  507.     the two background pages _in parallel_ (=at the same time)!)
  508.  
  509. e) Display objects at the same abolute screen position:
  510.    Let us assume you want to display a score at the upper right corner of the
  511.    screen; that's not hard when using STATIC background: just define your
  512.    score as a sprite and choose an appropriate coordinate pair.
  513.    In SCROLLING mode, your score would scroll away, too, so you must tie it to
  514.    absolute screen coordinates, as said in c), but there is a simple rule
  515.    which can be derived from the equation
  516.  
  517.       absolute_coordinate := virtual_coordinate - StartVirtual_value
  518.  
  519.    To ensure that the absolute (=screen) coordinate stays the same, you have
  520.    to balance out changes done to the StartVirtual-variables like this: when-
  521.    ever you increase/decrease StartVirtualX|Y by some amount delta, increase/
  522.    decrease your score-coordinates by the same amount delta!
  523.    (This results in: new_coord := virtual_coord±delta - (StartVirtual±delta)
  524.     = virtual_coord - StartVirtual = old_coord    as wanted)
  525.  
  526. f) Displaying scores: another way to display a score without defining it as a
  527.    sprite would be to simply draw it to the screen with the pixeldrawing rou-
  528.    tines or OutTextXY():
  529.     ■ draw it to the visible page (1-PAGE) each time after having called
  530.       ANIMATE()
  531.     ■ draw it to the background page BACKGNDPAGE
  532.    The last method is applicable only in background mode STATIC and you have
  533.    to restore the background image in the used area manually, but has the ad-
  534.    vantage that you must redraw your score only when it really changed (in-
  535.    stead of every animation cycle as with the first method). One way to
  536.    accomplish that would be to use the GetImage() and PutImage() routines:
  537.    ...
  538.    build background image;
  539.    use GetImage() to get a copy of the background area which will be overdrawn
  540.    by the score;
  541.    ...
  542.    main_loop:
  543.     IF new score has to be displayed
  544.       THEN BEGIN
  545.             use PutImage() to restore old background area underneath the score
  546.             use OutTextXY() to write new score into the background image
  547.            END
  548.    ...
  549.  
  550. g) Speed: It is hard to predict the speed of animations, because that is
  551.    merely determined by the speed of your VGA card, not your computer's CPU
  552.    clock rate! E.g., a program runs faster on my old AT (8MHz) than on a fast
  553.    (25 MHz) 80386 machine - only because of a better VGA card installed in
  554.    the AT!
  555.    Stated otherwise, if you use a computer with "enough" CPU-power, you won't
  556.    have to think much about "should I use STATIC background instead of SCROL-
  557.    LING for improved speed?", because it won't matter much anyway!
  558.    The break even point, where the VGA-card's bottle neck becomes the limiting
  559.    factor depends largely on your application (and your VGA-card, of course),
  560.    but as a rule of thumb, clock speeds faster than 12MHz won't improve your
  561.    program speeds *linearly* any further:
  562.  
  563.         animation  ^            ______
  564.         speed      │     ___----
  565.                    │    /
  566.                    │  /
  567.                    │/
  568.                    ┼─────┬───────────>  clock rate
  569.                          break-
  570.                          even point
  571.  
  572.    Note that your programs will still profit from faster CPU's, but that is
  573.    due to faster computation of all routines not limited by accessing the
  574.    video RAM; even on the fastest clones, the IBM-bus-clock-rate is not faster
  575.    than 10MHz  -- and this limits accessing the VGA card: sad, but true...
  576.  
  577. h) DMA access: Quite a long time, I tried to speed up animation rates by using
  578.    the DMA-chip in parallel to the CPU: while the CPU is running your program,
  579.    the DMA should move around memory.
  580.    Unfortunately, I had to find out that most computers don't like DMA memory-
  581.    to-memory transfers at all and those who do don't work when addresses used
  582.    reference the video RAM area. One of you (TNX Mike!) meant that's due to
  583.    the fact that most VGA cards do not decode the necessary DMA signals.
  584.    [comment: @!%&#*!@$ ]
  585.  
  586. i) Speedup things: Naturally, STATIC background is faster than SCROLLING
  587.    backgrounds, but you can speed up SCROLLING backgrounds, too: make sure
  588.    that StartVirtualX always is a multiple of 4 (that is, StartVirtualX
  589.    MOD 4 = 0), because then, ANIVGA can (and will) use the VGA's write mode 1
  590.    which is a lot faster than normal write mode 0.
  591.    Another idea is to shrink NMAX: if you don't need more than 100 sprites
  592.    (say), then change that constant and recompile ANIVGA!
  593.  
  594. j) GRAB: If GRAB won't pop up, then save the picture to disk (it's wise to do
  595.    that anyway), run a graphic viewer to merely display the picture and
  596.    capture then.
  597.  
  598.  
  599. 7. Credits
  600. ──────────
  601.  
  602. Honour to whom honour is due! I would like to thank some people on this way:
  603.  
  604. - Ken Pottebaum for his TSR-unit TSRUNIT.ZIP, providing the routines necessary
  605.   to write the Grabsprite-Utility
  606. - John Bridges for his SVGA256.BGI driver (out of his SuperVGA-driver package
  607.   SVGABGI3.ZIP) used in the sprite maker
  608.   (The above mentioned programs are available at the SIMTEL20-servers)
  609. - Bernd Klawonn (?) for his principle of using table-driven graphics in the
  610.   first graphics toolkit I ever saw - long, long ago in the "good'ol-AppleII-
  611.   days" (~1985)
  612.  
  613.  
  614. 8. ANIVGA Reference Manual
  615. ──────────────────────────
  616.  
  617. This reference manual lists all routines, variables, constants and a lot of
  618. informational stuff concerning ANIVGA in alphabetic order.
  619. Don't get frightened about the amount of informations given; in normal appli-
  620. cations you will need only a few of them!
  621. (Start with looking at the example *.PAS files and play around with them
  622.  - you'll learn a whole lot more by first using them as templates than by
  623.  reading manuals!)
  624.  
  625.  
  626. ABSOLUTE COORDINATES - information
  627. ──────────────────────────────────
  628.  
  629. See       : coordinates
  630.  
  631.  
  632. ActualColors - variable
  633. ───────────────────────
  634.  
  635. Function   : Supplies the actually used palette
  636.  
  637. Declaration: VAR ActualColors:Palette;
  638.  
  639. Description: This variable holds the values of the actual graphic colors.
  640.              You can use it to change the palette, but must issue a call to
  641.              SetPalette() to make your changes visible.
  642.              E.g., to make color 5 to "mere green", you would code:
  643.               ActualColors[5].red  :=0;
  644.               ActualColors[5].green:=63;
  645.               ActualColors[5].blue :=0;
  646.               SetPalette(ActualColors,TRUE);  {or ...,FALSE}
  647.  
  648. Note       : -Whenever you change palette values by using the routine
  649.               SetPalette(), ANIVGA reflects the changes in ActualColors, that
  650.               is, as long as you don't work around ANIVGA's SetPalette()-
  651.               routine by directly tempering with the VGA's palette registers,
  652.               ActualColors always holds the actual palette (so you won't need
  653.               GetPalette() )
  654.  
  655. See also   : Palette, SetPalette, GetPalette
  656.  
  657.  
  658. Animate - procedure
  659. ───────────────────
  660.  
  661. Function   : Performs a complete animation cycle
  662.  
  663. Declaration: PROCEDURE Animate FAR;
  664.  
  665. Description: A call to Animate() clears the invisible graphic page by copying
  666.              the contents of the background image into the actual drawing
  667.              page (specified by variable PAGE).
  668.              Then all active sprites (SpriteN[i]<>0) in the visible window
  669.              (determined by StartVirtualX and StartVirtualY) are drawn in the
  670.              style and at the coordinates given by the user.
  671.              After that, the routine waits for the display enable signal to
  672.              reprogram the VGA adapter to flip the display pages, making the
  673.              completed image visible and changes PAGE to point to the new,
  674.              invisible graphic page.
  675.              Finally, the procedure looks how much time passed since the last
  676.              animation cycle and if this time is less than that set by
  677.              SetCycleTime(), the program waits accordingly.
  678.  
  679. Note       : This procedure is the kernel routine which has to be called
  680.              everytime when you have set all data for a new animation frame.
  681.  
  682. See also   : PAGE, SetCycleTime, StartVirtualX, StartVirtualY
  683.  
  684.  
  685. ANIVGAVersion - constant
  686. ────────────────────────
  687.  
  688. Function   : Holds version number of ANIVGA-unit
  689.  
  690. Declaration: CONST ANIVGAVersion=11;
  691.  
  692. Description: Starting with V1.1, all versions of ANIVGA will define this
  693.              constant, holding the version number of the unit.
  694.  
  695. Note       : This constant is new with version 1.1; if for some case you need
  696.              a homogenous scheme for version 1.0, too, then you must add the
  697.              definition "ANIVGAVersion=10" to somewhere in the constant decla-
  698.              ration part in the interface section of ANIVGA V1.0 and recompile
  699.              that unit!
  700.  
  701. See also   : -
  702.  
  703.  
  704. BackGndPage - constant
  705. ──────────────────────
  706.  
  707. Function   : Holds the page number of the backround page
  708.  
  709. Declaration: CONST BACKGNDPAGE=2;
  710.  
  711. Description: When using background mode STATIC, BackGndPage specifies the page
  712.              number of the background image for the animations to be used.
  713.  
  714. Note (!)   : Use of this constant only makes sense when using background mode
  715.              STATIC!
  716.  
  717. See also   : ScrollPage, Background
  718.  
  719.  
  720. Background - information
  721. ────────────────────────
  722.  
  723. The term "background" specifies a graphic image in front of which all anima-
  724. tions take place.
  725. There are two sorts of background in ANIVGA: SCROLLING background and STATIC
  726. background, which you choose with SetBackgroundMode().
  727.  
  728. As its name states, a STATIC background cannot be scrolled: it consists of a
  729. 320x200 pixels picture.
  730. This background picture is stored in the graphic page numbered BACKGNDPAGE.
  731. At the very start of every animation cycle, the routine Animate copies that
  732. picture into the actual drawing page, thus erasing old stuff on that page and
  733. building the basis for the new image.
  734. As a normal bitmap picture, it is 320x200=64000 bytes in size. If you use the
  735. GRAB-Utility or the WritePage()-Routine to save an image, a three byte header
  736. is put ahead of the information, thus extending the size to 64003 bytes.
  737.  
  738. The second background sort is called SCROLLING: like ANIVGA's virtual coor-
  739. dinates, you can define a huge background image and scroll over it.
  740. Unfortunately, it is impossible to hold a complete background picture in
  741. memory: you would need 32000*32000=1024000000 bytes RAM (!) to do that.
  742. Instead, ANIVGA uses a "tiling" mechanism: tiles are small pictures (16x16
  743. pixels) which can be combined freely to build the background image.
  744. You can use up to 256 different tiles and "pin" them on an background area of
  745. up to MaxTiles (=10000) tiles; everything outside of this background area will
  746. be assigned to tile no. 0 automatically.
  747. For example, let us assume that you use only scrolling in the y-coordinate
  748. axis, 16 screens in total: thus, your x-coordinates reach from 0 to 319 and
  749. your y-coordinates from 0..(16*200-1)=5119, which gives an area of 320*5120
  750. =1638400 pixels.
  751. This is equivalent to (320/16)*(5120/16)=20*320=6400 tiles (remember: each
  752. tile consists of 16x16 pixels!).
  753. So you would define the scroll range for the background area needed with
  754. SetBackgroundScrollRange(0,0,319,5119) and start "painting" your background:
  755. You could design up to 256 different tiles and use them to assemble your
  756. background image (=those 6400 tiles).
  757. Most often, only a few are needed, because the background image isn't that
  758. dramatically different all over the place. For simplicity, let's assume that
  759. you need only 20 different tiles, numbered 0..19 respectively in the following
  760. order to build your background image:
  761.  
  762.   (0,0)                                                         (319,0)
  763.     ┌────────┬────────┬────────┐         ┌────────┬────────┬────────┐
  764.     │        │        │        │         │        │        │        │
  765.     │   0    │   1    │   2    │   ...   │   13   │   14   │   15   │
  766.     │        │        │        │         │        │        │        │
  767.     ├────────┼────────┼────────┤         ├────────┼────────┼────────┤
  768.         .        .        .                  .        .        .
  769.         .        .        .                  .        .        .
  770.         .        .        .                  .        .        .
  771.     ├────────┼────────┼────────┤         ├────────┼────────┼────────┤
  772.     │        │        │        │         │        │        │        │
  773.     │   0    │   1    │   2    │   ...   │   13   │   14   │   15   │
  774.     │        │        │        │         │        │        │        │
  775.     └────────┴────────┴────────┘         └────────┴────────┴────────┘
  776.   (0,5119)                                                      (319,5119)
  777.  
  778. Now all you have to do is to tell ANIVGA that layout with the PutTile command:
  779.  
  780.  {assuming SetBackgroundScrollRange(0,0,319,5119) has been set}
  781.  number:=0;
  782.  y:=0; {better: y:=BackY1}
  783.  REPEAT  (things would become easier if Pascal would know a STEP-command...)
  784.   x:=0; {better: x:=BackX1}
  785.   REPEAT
  786.    PutTile(x,y,number);
  787.    number:=(number+1) MOD 16;
  788.    inc(x,16);
  789.   UNTIL x>319; {better: x>BackX2}
  790.   inc(y,16);
  791.  UNTIL y>5119; {better: y>BackY2}
  792.  
  793. That's it! (It is better to use the (global defined) "Back..."-variables, set
  794. by the former SetBackgroundScrollRange()-call, because ANIVGA has to adjust
  795. values on multiples of 16, see SetBackgroundScrollRange()/Back?? for more
  796. details).
  797.  
  798. So then, why should one use STATIC backgrounds after all when there is such a
  799. powerful instrument like SCROLLING backgrounds?
  800. There are two simple answers: speed and simplicity! - First, SCROLLING back-
  801. grounds take a lot of work to compute, which slows down animations (unless you
  802. have a fast machine, because then the VGA's memory access time becomes the
  803. limiting factor). Second, it is easy to do some "tricks" on static back-
  804. grounds:
  805. draw a line in the static background page and >zap!< starting with the next
  806. animation cycle, it will be visible for all times. Stated otherwise, when
  807. using scrolling background, you cannot use drawings to the background image,
  808. because it simply doesn't exist explicitly, you are restricted solely to
  809. "tiles" and "sprites"! (On the other hand, you can play nice tricks on scrol-
  810. ling background by changing single tiles...)
  811. So consider carefully what mode you are going to use for your application!
  812.  
  813. See also   : BACKGNDPAGE, BACKGNDADR, WritePage, LoadPage,
  814.              WriteBackgroundPage, LoadBackgroundPage, SetBackgroundMode,
  815.              LoadTile, Tile
  816.  
  817.  
  818. BackgroundGetPixel - function
  819. ─────────────────────────────
  820.  
  821. Function   : Reads a background pixel's color
  822.  
  823. Declaration: FUNCTION BackgroundGetPixel(x,y:INTEGER):BYTE; FAR;
  824.  
  825. Description: This routine will return the color value of the specified point
  826.              with virtual coordinates (x,y) in the background image.
  827.              If the corresponding absolute coordinates lie outside the screen,
  828.              zero (= black) will be returned.
  829.  
  830. Note       : Use of this routine works only when using background mode STATIC!
  831.              It might look strange to use virtual coordinates then, although
  832.              the background is said to be static (= non-scrollable) and hence
  833.              restricted to absolute coordinates anyway, but it is often con-
  834.              venient to use an uniform notation and it is easy to convert co-
  835.              ordinates accordingly (see "coordinates" for more about that).
  836.  
  837. See also   : coordinates, GetPixel, PageGetPixel
  838.  
  839.  
  840. BackgroundLine - procedure
  841. ──────────────────────────
  842.  
  843. Function   : Draws a line on the background page
  844.  
  845. Declaration: PROCEDURE BackgroundLine(x1,y1,x2,y2:INTEGER); FAR;
  846.  
  847. Description: To draw a line on the background page (thus alterating the back-
  848.              ground), you can use this procedure. Like the similiar Line()-
  849.              routine, it uses virtual coordinates, too.
  850.              If necessary, the line will be clipped down to its visible part
  851.              (using a special Sutherland-Cohen algorithm).
  852.  
  853. Note       : Use of this routine only makes sense when using background mode
  854.              STATIC!
  855.  
  856. See also   : Line, coordinates
  857.  
  858.  
  859. BackGroundMode - variable
  860. ─────────────────────────
  861.  
  862. Function   : Holds the actual choosen background mode
  863.  
  864. Declaration: VAR BackgroundMode:BYTE;
  865.  
  866. Description: Using SetBackgroundMode(), you can select one of the possible
  867.              background modes STATIC or SCROLLING. BackGroundMode stores this
  868.              value.
  869.  
  870. Note (!)   : Only read this value, never change it directly!
  871.  
  872. See also   : Background, SetBackgroundMode
  873.     
  874.  
  875. BackgroundOutTextXY - procedure
  876. ───────────────────────────────
  877.  
  878. Function   : Writes a textstring to the background page BACKGNDPAGE
  879.  
  880. Declaration: PROCEDURE BackgroundOutTextXY(x,y:INTEGER; s:STRING); FAR;
  881.  
  882. Description: This routine is exactly the same like OutTextXY() (see there), but
  883.              it writes the string into the background page (so it will be visi-
  884.              ble permanently).
  885.  
  886. Note       : Use of the routine only makes sense if STATIC is used as
  887.              background mode. With SCROLLING backgrounds, use OutTextXY()
  888.              instead.
  889.  
  890. See also   : GraphtextColor, GraphtextOrientation, GraphtextBackground,
  891.              OutTextXY, background
  892.  
  893.  
  894. BackgroundPutPixel - procedure
  895. ──────────────────────────────
  896.  
  897. Function   : Plots a point into the background page
  898.  
  899. Declaration: PROCEDURE BackgroundPutPixel(x,y:INTEGER; color:BYTE); FAR;
  900.  
  901. Description: (x,y) specify the virtual coordinates of the point to be drawn in
  902.              color "color". If this point lies onscreen (i.e.: its _absolute_
  903.              coordinates are between (0,0)..(319,199)), it will be drawn on the
  904.              background page BACKGNDPAGE (and become visible starting with the
  905.              next animation cycle).
  906.  
  907. Note (!)   : - Use of this routine makes sense only when using background mode
  908.                STATIC!
  909.              - This routine works with virtual coordinates! - Although this
  910.                seems silly at first glance (because in STATIC mode, background
  911.                coordinates are always restricted to (0,0)..(319,199)), it
  912.                appears to be handy in many situations. If you actually want to
  913.                address points absolute coordinates (a,b), you can call this
  914.                routine with coordinates (a+StartVirtualX,b+StartVirtualY)
  915.                instead.
  916.              - Because of ANIVGA's working scheme, you probably want to call
  917.                this routine _before_ calling Animate(), so that changes of the
  918.                point will be visible as soon as possible.
  919.  
  920. See also   : PutPixel, PagePutPixel, background, coordinates, How ANIVGA works
  921.  
  922.  
  923. BACKX1, BACKX2, BACKY1, BACKY2 - variables
  924. ──────────────────────────────────────────
  925.  
  926. Function   : Hold the background image boundaries in background mode SCROLLING
  927.  
  928. Declaration: BackX1,BackY1,BackX2,BackY2:INTEGER;
  929.  
  930. Description: When background mode SCROLLING is to be used, you have to define
  931.              a scrolling area (with SetBackgroundScrollRange()). Due to inter-
  932.              nal management restrictions of ANIVGA, the boundaries of this area
  933.              must fall on coordinates which are multiples of 16 ("on a grid
  934.              with mesh 16").
  935.              If the values you supply don't fulfill this restriction, ANIVGA
  936.              adjusts them automatically to do so and stores them to these
  937.              variables for further use.
  938.  
  939. Note       : The only reason these variables are visible to you are that it
  940.              could be necessary for you to notice adjustments ANIVGA did;
  941.              so: only read this values, never change them directly!
  942.              (Look at "background" for an example).
  943.  
  944. See also   : background
  945.  
  946.  
  947. CloseRoutines - procedure
  948. ─────────────────────────
  949.  
  950. Function   : Terminates ANIVGA
  951.  
  952. Declaration: PROCEDURE CloseRoutines; FAR;
  953.  
  954. Description: Calling this routine switches back from ANIVGA's special graphic
  955.              mode into the graphic or text mode previously set.
  956.  
  957. Note       : This should always be the last call to a routine of ANIVGA in your
  958.              programs.
  959.  
  960. See also   : InitGraph
  961.  
  962.  
  963. COLLISION-DETECTION, CONCAVE, CONVEX - information
  964. ──────────────────────────────────────────────────
  965.  
  966. A graphical figure can be classified by its outline into one of two groups,
  967. called "concave" or "convex" figures.
  968. To motivate this mathematical notion >eh, don't get frustrated...<, regard
  969. your sprite only given by its "outmost" points, which connected together shape
  970. the figures boundaries.
  971. The figure is called "convex" :<=> every pair of arbitrarily choosen points
  972. on this boundary build a line which is totally inside (or at least on the
  973. boundary of) the figure:
  974.   ┌──────┐ This rectangle is "convex", because whenever you choose two points
  975.   │      │ on its boundaries and connect them, the resulting line lies com-
  976.   └──────┘ pletely inside (or on the boundary) of the rectangle itself.
  977.  
  978.   ┌──────┐ On the other hand, this figure would be "concave", because if you
  979.   └─┐  ┌─┘ choose the top-right and bottom-right corner (say) and connect them,
  980.   ┌─┘  └─┐ then the middle part of the resulting vertical line lies outside the
  981.   └──────┘ figure.
  982.  
  983. That is (in a very lax form) the _mathematical_ definition of these terms, but
  984. ANIVGA completely deals with either horizontal or vertical lines, so that an
  985. extension of these terms can be made:
  986.  
  987. A sprite is called "horizontal concave" ("vertical concave"), if a horizontal
  988. (vertical) line connecting two points of the sprite's boundary can be found
  989. so that parts of this line lies outside the sprite; if the sprite is not hori-
  990. zontal (vertical concave), it is "horizontal convex" ("vertical convex").
  991.  
  992. In that sense, the second of the figures above is "vertical concave", but
  993. "horizontal convex"!
  994. (Notice that figures which are concave in the pure _mathematical_ sense are
  995.  sometimes treated as convex by this definition, as this cross:)
  996.     ┌─┐     (If you use either a horizontal or vertical "scan line" sweeping
  997.   ┌─┘ └─┐    throughout the cross, there will be never more than one part of
  998.   └─┐ ┌─┘    the "scan line" which belongs to the figure; you can use this
  999.     └─┘      principle as a second definition for horizontal/vertical convex)
  1000.  
  1001. This terminology comes in handy when describing some mechanisms of ANIVGA: a
  1002. sprite is drawn LINEwise. For this, every point between the leftmost and right-
  1003. most point of a sprite's line is considered to be an _inner_ point of the
  1004. sprite, thus ANIVGA assumes a horizontal convexity! If your sprite isn't, like
  1005. this one...
  1006.   ┌─────┐  ...and the points between the two "legs" of this sprite shall still
  1007.   │ ┌─┐ │  be treated as "transparent" (assuming they have been defined with
  1008.   │ │ │ │  color "black" (=0)), you must use display mode "Display_NORMAL",
  1009.   │ │ │ │  because the "Display_FAST" mode would treat them as belonging to the
  1010.   └─┘ └─┘  sprite itself and draw them as "covering" black.
  1011.  
  1012. (To state it otherwise: whenever your sprite is (at least) horizontal convex
  1013.  and you don't need the feature of transparent parts inside the sprite, you
  1014.  can use the "Display_FAST" mode without any loss of accuracy in the sprite
  1015.  display)
  1016.  
  1017. Tip: the spritemaker program MAKES allows to display a sprite's horizontal
  1018. boundaries, which makes it easier for the beginner to decide about that
  1019. figure's convexity. But whenever you are unsure, you still can use mode
  1020. "Display_NORMAL" for drawing it.
  1021.  
  1022. ---
  1023.  
  1024. Things get a bit more tough when deciding if two sprites collide or not (which
  1025. is an important task): in difference to many sprite toolkits, ANIVGA doesn't
  1026. use a "mask" approach, which makes sprites big and collision detection slow.
  1027. Instead, ANIVGA uses a sprite's outline to decide whether two sprites collide.
  1028. For that, it computes for every line (column) of the overlap region of the
  1029. sprites' surrounding rectangles, whether the sprites overlap horizontally
  1030. (vertically) and says "collision!" only if there are intersections in both
  1031. directions. In pseudo code:
  1032.  
  1033. IF smallest_box_around(sprite1) doesn't intersect smallest_box_around(sprite2)
  1034.  THEN no_collision
  1035.  ELSE BEGIN
  1036.        compute the lines and columns for which the 2 sprite rectangles overlap
  1037.        FOR every such line compare -with the help of the sprite boundaries- if
  1038.         the corresponding lines overlap
  1039.        FOR every such column do the same check
  1040.        ONLY_IF there is an intersection in at least one line AND one column
  1041.         THEN collision!
  1042.         ELSE no_collision
  1043.       END
  1044.  
  1045. If you think a byte (=8 bits...) about this algorithm, you'll see that it can
  1046. lead to misdetection, in that the algorithm says "collision!", although there
  1047. is none (but it still guarantees that if there _is_ a collision, the alg. will
  1048. detect it) as in the following example:
  1049.           ┌─────┐
  1050.           └───┐ │
  1051.    ┌────────┐ │ │
  1052.    │ ┌────┐ │ │ │
  1053.    │ │ ┌─┐│ │ │ │  <─ In this line there is a "horizontal collision" (that is,
  1054.    └─┘ │ │└─┘ │ │     the two sprites overlap in their horizontal dimension)
  1055.        │ └────┘ │  
  1056.        └────────┘  ┌─ In this column there is a "vertical collision"
  1057.            ^───────┘
  1058.  
  1059. To state things without a proof here, such an (unavoidable) misdetection is
  1060. only possible, if at least one of the two sprites is neither horizontal nor
  1061. vertical convex!!!
  1062.  
  1063. Even then, it takes special constellations (as the one above) to produce such
  1064. an error, so that in praxis, it is very unlikely for such an error to occur.
  1065.  
  1066.  
  1067. Color - variable
  1068. ────────────────
  1069.  
  1070. Function   : Determines the actual drawing color
  1071.  
  1072. Declaration: VAR Color:BYTE;
  1073.  
  1074. Description: Various drawing routines use this global variable to determine
  1075.              which color should be used.
  1076.  
  1077. Note       : ANIVGA uses the standard color table of the 256-color mode $13.
  1078.  
  1079. See also   : -
  1080.  
  1081.  
  1082. ColorTable - type
  1083. ─────────────────
  1084.  
  1085. Function   : Supply a data type for self-defined "Shadow Tables"
  1086.  
  1087. Declaration: TYPE ColorTable=ARRAY[0..255] OF BYTE;
  1088.  
  1089. Description: If you want to use a different color look-up-table for your
  1090.              sprites in display mode Display_SHADOW or Display_SHADOWEXACT
  1091.              than can be achieved with SetShadowTab(), you must build a table
  1092.              like this.
  1093.              Each entry gives the color which should be used to replace the
  1094.              original color with that index, i.e.: if c is of type ColorTable
  1095.              and c[5]=9, this means that every point of your sprite which is to
  1096.              be drawn over a pixel with color 5 should replace that pixel with
  1097.              color 9.
  1098.              You can find an example how to activate such a "home-brew" table
  1099.              at "ShadowTab".
  1100.  
  1101. Note       : -
  1102.  
  1103. See also   : ShadowTab, SetShadowTab, Display modes, Palette
  1104.  
  1105.  
  1106. COORDINATES - information
  1107. ─────────────────────────
  1108.  
  1109. ANIVGA has to deal with two kinds of coordinates: "virtual" and "absolute" ones.
  1110. An absolute coordinate lies in the range 0..319, 0..199 for the x and y values,
  1111. respectively. It names a unique point on your graphic screen.
  1112. However, ANIVGA doesn't restrict animations to take place on the visible
  1113. graphic screen: its routines deal with coordinates in the range -16000..+16000
  1114. in each direction, called "virtual coordinates".
  1115. The picture you view while ANIVGA's routines are running is a window of that
  1116. virtual screen, 320 points wide and 200 points high.
  1117. Naturally, the graphic hardware only knows absolute coordinates and thus,
  1118. ANIVGA has to transform virtual in absolute coordinates. It does this with the
  1119. help of the two variables StartVirtualX and StartVirtualY which together speci-
  1120. fy the starting point of the upper left corner of your actual screen window;
  1121. e.g. if (StartVirtualX,StartVirtualY) was (1000,2000) then you would look at
  1122. the part of ANIVGA's world which consists of the 320x200 region with the coor-
  1123. dinates xε(1000..1319) and yε(2000..2199).
  1124. Note that there is one severe restriction, though: because it is absolutely
  1125. impossible to hold a complete "virtual" screen bitmap for ANIVGA's world in
  1126. memory (it would need app. 1GB RAM!), all drawing commands only take place on
  1127. the visible screen.
  1128. This means that you can't draw lines, points or any other objects which are
  1129. _not_ sprites outside the visible window that become visible, when you scroll
  1130. your window over to that part of the virtual screen. For example, if you draw
  1131. a point somewhere outside your visible window (say at (-10000,1234) while your
  1132. visible window starts at (500,900)) and pan to that region afterwards (by set-
  1133. ting (StartVirtualX,StartVirtualY)=(-10100,1200) or something like that), you
  1134. won't see that point: it is stored nowhere.
  1135. (The only way to circumvent this is to define the point as a sprite and set its
  1136.  coordinates (SpriteX[],SpriteY[]) to (-10000,1234), because sprites are the
  1137.  only objects which the system stores!).
  1138.  
  1139. More general:
  1140. Because there is _no_ complete virtual screen, all information drawn outside
  1141. the coordinate range visible at the moment will be lost and all information
  1142. read in from these "offscreen" pixel positions will be zero (= black).
  1143. For that reason it may seem strange for some routines that were restricted in
  1144. their use to the "real" (= absolute coordinate) screen region to use virtual
  1145. coordinates inspite (e.g.: GetImage, BackGroundGetPixel,...), but this was done
  1146. intentionally, because it leaves room for further improvements: if it should be
  1147. possible some day to store a complete virtual screen image, there will be no
  1148. changes necessary in ANIVGA's syntax.
  1149. Meanwhile, it is simple to transform absolute and virtual coordinates into each
  1150. other whenever necessary, using the following equivalence:
  1151.  
  1152.   virtual X-coordinates - StartVirtualX = absolute X-coordinates
  1153.   virtual Y-coordinates - StartVirtualY = absolute Y-coordinates
  1154.  
  1155. As a result: virtual coordinates lie in the range -16000..+16000, the start of
  1156. the visible part is defined in StartVirtualX and StartVirtualY and only sprites
  1157. can be "scrolled in" into the visible screen, while all other objects are
  1158. "lost".
  1159.  
  1160.  
  1161. DefaultColors - constant
  1162. ────────────────────────
  1163.  
  1164. Function   : Supplies the default RGB-colors of mode $13 to the user
  1165.  
  1166. Declaration: CONST DefaultColors:Palette=
  1167.              (
  1168.               (red:  0; green:  0; blue:  0),
  1169.                [...stuff deleted...]
  1170.               (red: 63; green: 63; blue: 63)
  1171.              );
  1172.  
  1173. Description: ANIVGA and its accompanying utility programs are based on the
  1174.              Bios' default color palette. That ain't necessary, though (and
  1175.              you *can* set different palettes), but it makes things a bit
  1176.              easier!
  1177.              DefaultColors is a listing of these default colors.
  1178.  
  1179. Note       : Consider the table as *read only*! When you use SetPalette(),
  1180.              ANIVGA will not temper this table (thus you can use it to restore
  1181.              the original palette values again).
  1182.  
  1183. See also   : Palette, SetPalette, GetPalette
  1184.  
  1185.  
  1186. Display modes - information
  1187. ───────────────────────────
  1188.  
  1189. ANIVGA is able to display a sprite in several "modes". This describes how the
  1190. sprite's data should be handled when drawing the sprite to the screen. Up to
  1191. now, there are four modes:
  1192.  - Display_NORMAL  
  1193.  - Display_FAST
  1194.  - Display_SHADOW
  1195.  - Display_SHADOWEXACT
  1196. This mode is linked to a sprite's physical data by creation of the sprite with
  1197. the spritemaker program (and defaults to Display_NORMAL), but can be altered
  1198. once the sprite is loaded into memory with the procedure SetModeByte().
  1199.  
  1200. Note that the display mode information is part of the _physical_ sprites (that
  1201. is, the memory image of the bytes loaded at the beginning), not the _logical_
  1202. sprites (the "handles" in the SpriteN-array to this physical data). For that
  1203. reason, a change of the display mode of a sprite with spriteLOAD number 123
  1204. (say) will affect _all_ sprites of type 123 (= all entries in SpriteN[] with
  1205. value 123). This is intended, because the display mode is a piece of informa-
  1206. tion reflecting the sprite's physical structure!
  1207. (For the case that you disagree: of course you are free to load the same sprite
  1208.  with a different load number into memory a second time and assign another
  1209.  display mode to this copy!)
  1210.  
  1211. In mode "Display_NORMAL" you can think of a sprite as a picture with holes at
  1212. the places where its pixels have color 0: when displayed, all the parts of the
  1213. sprite with color<>0 will cover (paint over) the screens original pixels, but
  1214. the pieces with color=0 will act like "window panes": the original contents of
  1215. the screen remain visible there.
  1216. This mode is useful for all kinds of sprites which have such opaque holes in-
  1217. side themselves: cars/planes/houses or other objects with window panes, but
  1218. also all "concave" sprites. Note that black, COVERING parts must be realized
  1219. with a dark color<>0, for example color 16.
  1220.  
  1221. "Display_FAST" is a bit (but not that dramtically) faster than the last method,
  1222. because it doesn't know of a special color: all sprite data is treated equally
  1223. and stored to the screen at once. For that, all parts of the sprite are
  1224. covering. (But note that a sprite consists only of the points "inside" and on
  1225. its boundaries: all the points "outside" the sprite doesn't matter).
  1226. You will use this mode whenever you have sprites which meet the following re-
  1227. quirements: they are "convex" and don't have any transparent parts inside them-
  1228. selves.
  1229.  
  1230. "Display_SHADOW" is a tribute to the fact that one often needs some kind of
  1231. shadowing to give the impression of an freefloating object or other pseudo
  1232. 3D-effects. In this mode, the sprite's real colors are insignificant, only its
  1233. boundaries and the actual contents of the screen where the sprite shall be
  1234. drawn are important. The color of every sprite point is determined by the color
  1235. of the appropriate screen point. The color of these points are translated by
  1236. the lookup table ShadowTab into darker ones.
  1237. If you want to give a sprite a shadow zone, then you must divide your sprite
  1238. into two ones: one building the sprite itself and a second one to realize only
  1239. that shadow area, and compose them with appropriate coordinates.
  1240.  
  1241. "Display_SHADOWEXACT" behaves quite similiar to "Display_SHADOW", but shadowing
  1242. will only take place at the sprite's pixels with color <>0, that is: color 0
  1243. is again used as "transparent", this time even for shadows! To state it other-
  1244. wise: Display_SHADOWEXACT is for displaying shadows what Display_NORMAL is for
  1245. displaying sprites (and Display_SHADOW relates to Display_FAST in that sense):
  1246. exactly for the same reason, Display_SHADOWEXACT is slower than Display_SHADOW!
  1247. Normally, you will use Display_SHADOW when you are using Display_FAST, too: If
  1248. your sprites are "convex" and don't have any transparent parts inside them-
  1249. selves.
  1250. (If you are still not sure about the difference between these two combinations
  1251.   a) Display_FAST   & Display_SHADOW
  1252.   b) Display_NORMAL & Display_SHADOWEXACT
  1253.  then EXAMPLE3.PAS is a good place to try out!)
  1254.  
  1255. Technically spoken, there are short code areas in ANIVGA's routines reserved in
  1256. which the right piece of code to transfer/interpret the sprite's data become
  1257. copied, when not already there. For optimal performance it is wise to group the
  1258. entries in SpriteN[] such that adjacent sprite entries share the same display
  1259. method.
  1260.  
  1261. See also   : convex, concave
  1262.  
  1263.  
  1264. DUMP_SPR - utility
  1265. ──────────────────
  1266.  
  1267. (This is surely a tool for all those hackers among us...)
  1268. If you want to take a closer look at a sprite's data, you don't have to fiddle
  1269. around with DEBUG or the like, just use this sprite dumper: it takes a (binary)
  1270. sprite file (*.COD or *.LIB) and disassembles it into readable ASCII-text.
  1271. You can redirect the output to a file or printer, e.g.:
  1272.  
  1273.  DUMP_SPR mysprite.cod >mysprite.txt
  1274.  
  1275. would dump the sprite file "mysprite.cod" to the ASCII-text file "mysprite.txt"
  1276. for further usage.
  1277. Note that DUMP_SPR creates a format which will be understood by assemblers like
  1278. MASM or TASM so that you can reassemble the files to get a binary sprite file
  1279. once again!
  1280. To do so, you would have to enter the following commands (replace MASM by TASM
  1281. if you use Borland's assembler):
  1282.   MASM mysprite.TXT;                 -> gives you mysprite.OBJ
  1283.   LINK mysprite.OBJ;                 -> gives you mysprite.EXE
  1284.   EXE2BIN mysprite.EXE mysprite.COD  -> gives you mysprite.COD
  1285.  
  1286.  
  1287. ERROR - variable
  1288. ────────────────
  1289.  
  1290. Function   : Holds the code of the last error which occured
  1291.  
  1292. Declaration: VAR ERROR:BYTE
  1293.  
  1294. Description: If an error occurs while executing one of its routines, ANIVGA
  1295.              terminates that routine and sets ERROR accordingly to reflect that
  1296.              error.
  1297.              You can use GetErrorMessage() anytime to get more information,
  1298.              which error occured.
  1299.              It is your responsibility to check if such an error occured and
  1300.              react in an appropriate way.
  1301.              For the possible values and their descriptions returned by
  1302.              GetErrorMessage, see there.
  1303.              
  1304. Note (!)   : - After processing an error, you have to reset the variable back
  1305.                to Err_None yourself
  1306.              - In respect of future extensions, you should treat every value
  1307.                <> Err_None as an error
  1308.              - The most frequented routine Animate() doesn't produce any
  1309.                errors, neither do several other procedures. As a basic rule,
  1310.                all routines which have to do with file I/O have to be checked.
  1311.              - ERROR is initialized with Err_None
  1312.  
  1313. See also   : GetErrorMessage, InitRoutines
  1314.  
  1315.  
  1316. FadeIn - procedure
  1317. ──────────────────
  1318.  
  1319. Function   : Fade in a graphic page onto the actually visible page.
  1320.  
  1321. Declaration:  PROCEDURE FadeIn(pa,ti,style:WORD); FAR;
  1322.  
  1323. Description: If you need an interesting opening sequence for your program, then
  1324.              FadeIn() is what you need: there are a lot of different routines
  1325.              available to copy one image to the actually displayed graphic page
  1326.              (1-PAGE): supply the page which shall be displayed "pa" (most
  1327.              often, this will be BACKGNDPAGE), "ti" is the time (in millise-
  1328.              conds) the fade should last (approximately), "style" defines the
  1329.              algorithm to be used and must be one of:
  1330.               Fade_Squares,
  1331.               Fade_Circles,
  1332.               Fade_Moiree1 .. Fade_Moiree14,
  1333.               Fade_SweepInFromTop,    Fade_SweepInFromBottom,
  1334.               Fade_SweepInFromLeft,   Fade_SweepInFromRight,
  1335.               Fade_ScrollInFromTop,   Fade_ScrollInFromBottom,
  1336.               Fade_ScrollInFromLeft,  Fade_ScrollInFromRight
  1337.  
  1338. Note       : - The easiest way to use this routine is the following:
  1339.                a) initialize the graphic mode via InitGraph(),
  1340.                b) load the background page BACKGNDPAGE with your normal
  1341.                   animation background,
  1342.                c) (if you want:) fill the visible page 1-PAGE with whatever
  1343.                   you want (initially, it is completely black)
  1344.                d) call FadeIn(BACKGNDPAGE,2000,Fade_???);
  1345.                   (about 2000..4000 milliseconds are good values)
  1346.                e) continue with your normal program
  1347.              - Naturally, ANIVGA can't make your PC faster than it is: the
  1348.                time value you supply is a _lower bound_!
  1349.              - FadeIn() will use the "normal" MSDos-timer values for its
  1350.                operation; as this timer has resolution of about 55msec, it
  1351.                is quite inaccurate (..for a computer, I mean..), but as we
  1352.                are talking about thousands of milliseconds here, that won't
  1353.                matter! (Besides that, this timer won't interfere with the
  1354.                one used for the animation rate, set by SetCycleTime()!)
  1355.  
  1356. See also   : -
  1357.  
  1358.  
  1359. FillBackground - procedure
  1360. ──────────────────────────
  1361.  
  1362. Function   : Fills the background page with the specified color.
  1363.  
  1364. Declaration: PROCEDURE FillBackground(color:BYTE); FAR;
  1365.  
  1366. Description: The given value is written into the whole graphic page BACKGNDPAGE
  1367.              and thus defines the picture before all animations take place to
  1368.              have one color.
  1369.  
  1370. Note       : Use of this routine only makes sense when using background mode
  1371.              STATIC!
  1372.  
  1373. See also   : Background, BACKGNDPAGE, BACKGNDADR, GetBackgroundFromPage,
  1374.              LoadBackgroundPage
  1375.  
  1376.  
  1377. FillPage - procedure
  1378. ────────────────────
  1379.  
  1380. Function   : Fills a graphic page completely with a given color
  1381.  
  1382. Declaration: PROCEDURE FillPage(pa,color:Byte); FAR;
  1383.  
  1384. Description: If you want to paint a complete page uniformly with one color,
  1385.              then this will be the fastest method to do it: specify the graphic
  1386.              page (0,1 or BACKGNDPAGE (=2)) in "pa" and the color to be used in
  1387.              "color".
  1388.  
  1389. Note       : - Although possible, you are strongly discouraged to use this pro-
  1390.                cedure in background mode SCROLLING (i.e.: pa=SCROLLPAGE (=3) as
  1391.                page number), because the background is treated completely dif-
  1392.                ferent!
  1393.              - Remember also that changes to one of the drawing pages (0 or 1)
  1394.                have to be applied _after_ calling Animate and will be visible
  1395.                for exactly one animation cycle, whereas changes to the back-
  1396.                ground page remain permanent (and are best done _before_ calling
  1397.                Animate, although that's not peremptory).
  1398.              - This routine is great to produce "flashing" screens: apply it to
  1399.                1-PAGE (the visible page).
  1400.              - Possible ERROR-values returned are Err_InvalidPageNumber
  1401.  
  1402. See also   : background, How ANIVGA works, LoadPage, LoadBackgroundPage,
  1403.              GetBackgroundFromPage
  1404.  
  1405.  
  1406. FontOrient, FontHeight, FontWidth - type/constants
  1407. ──────────────────────────────────────────────────
  1408.  
  1409. Function   : Supply some additional data about the internal font
  1410.  
  1411. Declaration: TYPE  FontOrient=(horizontal,vertical);
  1412.              CONST FontHeight=6;
  1413.                    FontWidth=6;
  1414.  
  1415. Description: The internal font used for displaying graphic text (OutTextXY(),
  1416.              BackgroundOutTextXY()) can be displayed either horizontally or
  1417.              vertically; use of the TYPE FontOrient simplifies that.
  1418.              To compute the width/height of a text, the constants FontHeight
  1419.              and FontWidth can be used, which specify the size of one letter.
  1420.  
  1421. Note       : -
  1422.  
  1423. See also   : OutTextXY, BackgroundOutTextXY
  1424.  
  1425.  
  1426. FreeImageMem - procedure
  1427. ────────────────────────
  1428.  
  1429. Function   : Releases the memory allocated by a GetImage()-call
  1430.  
  1431. Declaration: PROCEDURE FreeImageMem(p:POINTER); FAR;
  1432.  
  1433. Description: If you use GetImage(), ANIVGA allocates the memory needed and
  1434.              returns a pointer to that area, which you can use with PutImage()
  1435.              as often as you desire. If you don't need that clipped image any
  1436.              longer, you should release its memory so that it can be used by
  1437.              other routines again. To do that, just call FreeImageMem() with
  1438.              the pointer GetImage() returned to you.
  1439.  
  1440. Note       : It is this reason -releasing memory- why you shouldn't make an
  1441.              "anonymous" GetImage() / PutImage() combination like
  1442.               PutImage(x,y,GetImage(x1,y1,x2,y2,1-PAGE),1-PAGE): you don't get
  1443.              a handle which could be used to free the occupied memory!
  1444.              Of course, you could use "Mark()" and "Release()", but a simple
  1445.              additional pointer variable ("p") is better style:
  1446.               p:=GetImage(x1,y1,x2,y2,1-PAGE);
  1447.               PutImage(x,y,p,1-PAGE);
  1448.               FreeImageMem(p)
  1449.  
  1450. See also   : GetImage, PutImage
  1451.  
  1452.  
  1453. GetBackgroundFromPage - procedure
  1454. ─────────────────────────────────
  1455.  
  1456. Function   : Take over one of the drawing pages as background image
  1457.  
  1458. Declaration: PROCEDURE GetBackgroundFromPage(pa:Byte); FAR;
  1459.  
  1460. Description: Specify the graphic page (0 or 1) from which the image should be
  1461.              "captured" and the routine will copy its contents into the back-
  1462.              ground page BACKGNDPAGE (=2) as new background image.
  1463.  
  1464. Note       : - Use of the routine only makes sense if STATIC is used as
  1465.                background mode.
  1466.              - Possible ERROR-values returned are Err_InvalidPageNumber
  1467.  
  1468. See also   : LoadBackgroundPage
  1469.  
  1470.  
  1471. GetErrorMessage - function
  1472. ──────────────────────────
  1473.  
  1474. Function   : Returns a description of the last error occured
  1475.  
  1476. Declaration: FUNCTION GetErrorMessage:STRING; FAR;
  1477.  
  1478. Description: Although you can use the ERROR variable directly to evaluate any
  1479.              error and inform the user about it, it is often more comfortable
  1480.              to let ANIVGA do that: GetErrorMessage will give you a string
  1481.              describing the last error which occured in words.
  1482.              The possible string contents and the corresponding ERROR values
  1483.              are:
  1484.  
  1485.               Err_None: 'No Error'
  1486.                No error occured during the routine; this is the variable's
  1487.                initial value
  1488.  
  1489.               Err_NotEnoughMemory: 'Not enough memory available on heap'
  1490.                The program couldn't load sprites or other data to the heap
  1491.  
  1492.               Err_FileIO: 'I/O-error with file'
  1493.                There was an error reading the file; either the file doesn't
  1494.                exist at the path given or it is damaged
  1495.  
  1496.               Err_InvalidSpriteNumber: 'Invalid sprite number used'
  1497.                This error occurs if you try to load a sprite with a sprite
  1498.                loadnumber not in the valid range 1..LoadMAX
  1499.  
  1500.               Err_NoSprite: 'No (or corrupted) sprite file'
  1501.                While attempting to interpret the data just read in, ANIVGA
  1502.                found the data not to be in the expected format; either because
  1503.                you used a wrong data file or it is damaged
  1504.  
  1505.               Err_InvalidPageNumber: 'Invalid page number used'
  1506.                There are four graphic pages, numbered 0..3. Page 0 & 1 are
  1507.                used for the animation itself, page 2 ("BACKGNDPAGE") holds the
  1508.                static background image and page 3 ("SCROLLPAGE") is reserved
  1509.                for the scrollable background information
  1510.  
  1511.               Err_NoVGA: 'No VGA-card found'
  1512.                The animation package needs a VGA (or compatible) graphic card
  1513.                but couldn't find one
  1514.  
  1515.               Err_NoPicture: 'No (or corrupted) picture file'
  1516.                The background picture file ANIVGA should load has not the ex-
  1517.                pected size/format or a DOS-error occured while attempting to
  1518.                access the data
  1519.  
  1520.               Err_InvalidPercentage: 'Percentage value must be 0..100'
  1521.                If you set the colortable for the shadowing effects of sprite
  1522.                display mode Display_SHADOW or Display_SHADOWEXACT, you must use
  1523.                a percentage value giving the remaining brightness of the colors
  1524.                in the shadow areas, which must be in the range 0..100%, of
  1525.                course
  1526.  
  1527.               Err_NoTile: 'No (or corrupted) tile/sprite file'
  1528.                There was an error loading the specified sprite file(s) and
  1529.                interpreting them as background tiles. Most often this occurs
  1530.                because the sprite doesn't meet the requirement to be a multiple
  1531.                of 16 points in its x- and y-directions!
  1532.  
  1533.               Err_InvalidTileNumber: 'Invalid tile number used'
  1534.                There may be only 256 background tiles, numbered 0..255
  1535.  
  1536.               Err_InvalidCoordinates: 'Invalid coordinates used'
  1537.                The virtual background coordinates you use must lie in the range
  1538.                (BackX1,BackY1)..(BackX2,BackY2), which has been specified with
  1539.                SetBackgroundScrollRange()
  1540.  
  1541.               Err_BackgroundToBig: 'Background to big for tile-buffer'
  1542.                ANIVGA's tile buffer can hold no more than MaxTiles (=10000)
  1543.                tiles, that is an area of 10000*16*16 pixels². Check the area
  1544.                you specified in your SetBackgroundScrollRange()-call!
  1545.  
  1546.               Err_InvalidMode: 'Only STATIC or SCROLLING allowed here'
  1547.                The only background modes ANIVGA knows are STATIC and SCROLLING
  1548.  
  1549.               Err_InvalidSpriteLoadNumber: 'Invalid spriteload number used'
  1550.                spriteLOADNumbers must lie in the range 0..LoadMAX; when you
  1551.                get this error, you probably confounded a spriteLOADnumber with
  1552.                a spritenumber
  1553.  
  1554.               Err_NoPalette: 'No (or corrupted) palette file'
  1555.                You tried to load a palette file which didn't meet the require-
  1556.                ments: a palette file must be of size 3..768 bytes and a
  1557.                multiple of 3
  1558.  
  1559.               Err_PaletteWontFit: 'Attempt to write beyond palette end'
  1560.                While attempting to read in and store the palette file into the
  1561.                actual color table, ANIVGA noticed that it would have to write
  1562.                beyond the end of that table; decrease your "number" parameter!
  1563.  
  1564.               Err_InvalidFade: 'Invalid fade style used'
  1565.                You tried to use a fade style not supported by the unit: look
  1566.                at routine "FadeIn()" for allowed styles.
  1567.  
  1568.               (else): 'Unknown error'
  1569.                If ERROR has none of the above values, this string will be
  1570.                returned; this should never happen, though.
  1571.  
  1572. Note       : Calling GetErrorMessage won't set back the ERROR variable either;
  1573.              you must do that explicitly!
  1574.  
  1575. See also   : ERROR
  1576.  
  1577.  
  1578. GetImage - function
  1579. ───────────────────
  1580.  
  1581. Function   : Makes a copy of the specified screen region
  1582.  
  1583. Declaration: FUNCTION GetImage(x1,y1,x2,y2:INTEGER;pa:BYTE):POINTER; FAR;
  1584.  
  1585. Description: - This function works much the same as its equivalent in Turbo-
  1586.                Pascal: (x1,y1) and (x2,y2) define the upper left and lower right
  1587.                corners of the screen part to save, but now these coordinates are
  1588.                _virtual coordinates_, the routine reserves the memory needed to
  1589.                hold the copy itself and you can specify the graphic page, from
  1590.                which the image is to be taken (pa=0,1 or BACKGNDPAGE (=2) ).
  1591.              - As result you get a pointer to the start of the saved image,
  1592.                which can be used with PutImage().
  1593.              - If there is not enough memory available or the specified part of
  1594.                the screen lies completely outside the visible screen, NIL is
  1595.                returned.
  1596.              - Besides that, there are 5 global variables which are set accor-
  1597.                dingly:
  1598.                was_cut:BOOLEAN = TRUE/FALSE, if the image had to be _partially_
  1599.                        clipped (if the specified image is totally offscreen,
  1600.                        was_cut stays at FALSE!)
  1601.                left_cut, right_cut, top_cut, bottom_cut:WORD  hold the size how
  1602.                        much had to be clipped off at the boundaries; these
  1603.                        values are only set when was_cut=TRUE
  1604.                (If you wonder about this odd definitions: GetImage was intended
  1605.                 to work only with the visible screen (that is: with _absolute_
  1606.                 coordinates): together with its counterpart PutImage(), you can
  1607.                 copy a part of the screen to another part or page. In that case,
  1608.                 you do not have to fiddle around with clipping: just issue a
  1609.                 GetImage() and use PutImage() to paste this block elsewhere.
  1610.                 But there may be some applications, when you cut out part of
  1611.                 the screen and think you got the complete graphic figure you
  1612.                 wanted, although (because of the use of virtual coordinates and
  1613.                 your figure being partially offscreen) you got only part of it.
  1614.                 Checking "was_cut" informs you about such a partial clipping.
  1615.                 If your figure is completely offscreen, that is a special case:
  1616.                 it depends on your application whether this should be treated
  1617.                 as being okay or not; if you need special treatment (as with
  1618.                 partial clipping), you still can check for this with something
  1619.                 like:
  1620.                 ...
  1621.                 image_ptr:=GetImage(x1,y1,x2,y2,1-PAGE); {1-PAGE=visible page!}
  1622.                 IF ERROR<>Err_None
  1623.                  THEN ... {probably not enough memory}
  1624.                  ELSE IF (was_cut) OR (image_ptr=NIL)
  1625.                        THEN ... {partial or total clipping occured}
  1626.                        ELSE ... {no clipping at all}
  1627.                )
  1628.              - possible ERROR-values returned are: Err_NotEnoughMemory and
  1629.                Err_InvalidPageNumber
  1630.  
  1631. Note       : - As already mentioned, GetImage() only works on screen regions in
  1632.                the _absolute_ coordinate range 0..319, 0..199, but expects
  1633.                _virtual_ coordinates!
  1634.              - To release the memory allocated by a GetImage() call, you must
  1635.                use FreeImageMem(); TurboPascal's "Dispose()" won't work.
  1636.  
  1637. See also   : PutImage, FreeImageMem, coordinates
  1638.  
  1639.  
  1640. GetModeByte - function
  1641. ──────────────────────
  1642.  
  1643. Function   : Returns the actual display method set for a sprite
  1644.  
  1645. Declaration: FUNCTION GetModeByte(Sp:WORD):BYTE; FAR;
  1646.  
  1647. Description: "Sp" specifies the spriteLOADnumber of the sprite from which the
  1648.              user wants to know the display mode. The function will return one
  1649.              of the valid modes Display_NORMAL, Display_FAST, Display_SHADOW
  1650.              or Display_SHADOWEXACT.
  1651.  
  1652. Note       : - Again, spriteLOADnumbers are used!
  1653.              - If the LOADnumber given doesn't exist (because no sprite has
  1654.                been loaded with that number), the routine will return
  1655.                Display_UNKNOWN instead.
  1656.  
  1657. See also   : Display modes, SetModeByte
  1658.  
  1659.  
  1660. GetPalette - procedure
  1661. ──────────────────────
  1662.  
  1663. Function   : Reads out the actually set color palette directly from the VGA
  1664.  
  1665. Declaration: PROCEDURE GetPalette(VAR pal:Palette); FAR;
  1666.  
  1667. Description: "pal" specifies the variable in which to store the actual palette.
  1668.  
  1669. Note (!)   : - This procedure has been added for completeness, merely: As long
  1670.                as you make all palette changes by using SetPalette(), you can
  1671.                use the variable "ActualColors[]" instead!
  1672.              - You must be in graphic mode already or you will get rubbish!
  1673.                To state in otherwise: call this routine _after_ having called
  1674.                InitGraph() and _before_ calling CloseRoutines()!
  1675.  
  1676. See also   : SetPalette, Palette, ActualColors
  1677.  
  1678.  
  1679. GetPixel - function
  1680. ───────────────────
  1681.  
  1682. Function   : Reads a pixel's color
  1683.  
  1684. Declaration: FUNCTION GetPixel(x,y:INTEGER):BYTE; FAR;
  1685.  
  1686. Description: Returns the color value of the specified pixel with the virtual
  1687.              coordinates (x,y) on graphic page PAGE. If (x,y) lies offscreen
  1688.              (to be precise: the computed absolute coordinates lie offscreen),
  1689.              then zero (= black) is returned.
  1690.  
  1691. Note       : Be aware that PAGE is the invisible page, not the one you are
  1692.              looking at!
  1693.  
  1694. See also   : coordinates, PAGE, PageGetPixel, PutPixel
  1695.  
  1696.  
  1697. GRAB - utility
  1698. ──────────────
  1699.  
  1700. GRAB allows you to "steal" graphics from other applications and convert them
  1701. into sprite files (*.COD) or background images (*.PIC) for use with ANIVGA.
  1702. This program is a terminate-and-stay-resident (TSR) utility that has to be run
  1703. before starting those applications from which you want to capture graphic
  1704. images.
  1705. It requires a mouse to be installed and a VGA card - note that an EGA won't do!
  1706. Pressing the hotkey CTRL-ALT-G will popup a frame which you can move and resize
  1707. to select the part of the graphic sreen you want to save (if you are not in a
  1708. graphic mode or in a graphic mode unknown to GRAB you'll here a beep instead).
  1709. Note that if you are in a "MSDos critical" situation, GRAB can't pop up.
  1710. Use the mouse to move the box, hold down the left mouse button and drag the
  1711. mouse to resize the box (in "sprite mode" only). The space bar will toggle
  1712. between "sprite mode" and "background mode", pressing the right button will
  1713. store the framed graphic to disk (either as sprite or background image, what-
  1714. ever program mode you are actually in).
  1715. Press ESC (or both mouse buttons simultaneously) anytime to escape from GRAB
  1716. back to your application.
  1717. By default, GRAB starts in sprite capture mode, thus generating sprite files
  1718. (starting with the file name GRAB_000.COD with increasing numbers for the next
  1719. sprites). To get a background image, toggle into screen capture mode by pres-
  1720. sing the space bar (a second press will switch back to sprite capture mode
  1721. again), select the screen region wanted and press the right mouse button to
  1722. get that part of the screen in the file GRAB_000.PIC (or whatever number is
  1723. actual then).
  1724. In both modes, GRAB also dumps the actually set palette to disk, having the
  1725. same number as the COD/PIC file, but with the ending ".PAL" and a (P)icture
  1726. or (S)prite replacing the underscore, e.g. "GRABS000.PAL" for the first
  1727. sprite saved.
  1728. Naturally, you can't resize your frame in the screen capture mode: it stays at
  1729. its initial size of 320x200 points.
  1730. Note that there is the a restriction for a sprite's size: a sprite may be
  1731. 152x152 points in max., if you need bigger sprites then just save the sprite
  1732. as a PIC file and convert it afterwards, using MAKES.
  1733.  
  1734. There is only one possible command line parameter when installing GRAB:
  1735. "BIOS": Supplying "BIOS" tells GRAB to use the video bios interrupt INT10h to
  1736. access all video data. This should work on almost every VGA, but is extremely
  1737. slow.
  1738. Otherwise, GRAB defaults to its internal, fast access routines. Note that some
  1739. applications directly reprogram the VGA hardware so that GRAB must fail on
  1740. them (both in default and BIOS mode)!
  1741.  
  1742. Notes      :
  1743.  o It may happen that you can't popup GRAB in some applications; if you have
  1744.    some commercial screen capture utility, you can use that (most often, they
  1745.    are more "radical" in their behaviour, using undocumented Dos-funtions and
  1746.    the like).
  1747.    Then, use an appropriate viewer program and capture the graphic from their
  1748.    display!
  1749.    (Sorry, I know there are much situations where GRAB _should_ popup, but
  1750.     does not - I'm not content with that, either, but I didn't write the TSR-
  1751.     unit, but only use it; _if_ I should find the time, I'll write a more
  1752.     suitable TSR-unit on my own)
  1753.  o Especially if you save a screen as a PIC file, it will take quite a long
  1754.    time until GRAB finishes its operation - be patient!
  1755.  
  1756. See also   : MAKES, Palette
  1757.  
  1758.  
  1759. GraphTextBackground, GraphTextColor, GraphTextOrientation - variables
  1760. ─────────────────────────────────────────────────────────────────────
  1761.  
  1762. Function   : Determine how the OutTextXY()-procedures work
  1763.  
  1764. Declaration:  TYPE  FontChar=ARRAY[0..5] OF BYTE;
  1765.                     Font=ARRAY[0..255] OF Fontchar;
  1766.                     FontOrient=(horizontal,vertical);
  1767.               CONST GraphTextOrientation:FontOrient=horizontal;
  1768.                     GraphTextColor:BYTE=white;
  1769.                     GraphTextBackground:BYTE=white;
  1770.                     FontHeight=6;
  1771.                     FontWidth=6;
  1772.  
  1773. Description: Whenever text is to be written to the graphic screen, ANIVGA
  1774.              consults some global variables. GraphTextColor is simply the color
  1775.              in which the text should be drawn, GraphTextBackground specifies
  1776.              the color for the pixels in between the letters with one special
  1777.              value: if GraphTextBackground=GraphTextcolor, then only the pixels
  1778.              belonging to the letters will be drawn with all others remaining
  1779.              unchanged.
  1780.              Finally, GraphTextOrientation tells ANIVGA in which direction the
  1781.              text should be written with two values being possible: HORIZONTAL
  1782.              (default) for left-to-right text and VERTICAL for top-to-bottom
  1783.              style text.
  1784.  
  1785. Note       : Default color for the text is "white/white" = "white and don't
  1786.              change pixel values between letters".
  1787.  
  1788. See also   : OutTextXY, BackgroundOutTextXY
  1789.  
  1790.  
  1791. HitDetect - function
  1792. ────────────────────
  1793.  
  1794. Function   : Checks whether two sprites collide or not
  1795.  
  1796. Declaration: FUNCTION Hitdetect(s1,s2:INTEGER):BOOLEAN; FAR;
  1797.  
  1798. Description: Call this routine with the sprite numbers of the two sprites to be
  1799.              checked for collision; the function will return TRUE/FALSE when
  1800.              the sprites collide/do not collide, respectively.
  1801.  
  1802. Note (!)   : - Collision detection is independent of whether the sprites are
  1803.                visible or offscreen: ANIVGA uses the corrdinates of the two
  1804.                sprites given (in SpriteX/Y) and internal data to check.
  1805.              - For this it is possible to check for collisions _before_ drawing
  1806.                an image (with Animate) and thus make necessary sprite updates
  1807.                at once!
  1808.              - Inactive sprites cannot collide:
  1809.                (SpriteN[s1] or SpriteN[s2]=0) -> FALSE
  1810.              - A sprite can't collide with itself: (s1=s2 -> FALSE)
  1811.  
  1812. See also   : Collision-detection
  1813.  
  1814.  
  1815. InitGraph - procedure
  1816. ─────────────────────
  1817.  
  1818. Function   : Initialises the VGA card for the use with ANIVGA
  1819.  
  1820. Declaration: PROCEDURE InitGraph; FAR;
  1821.  
  1822. Description: ANIVGA uses a special graphic mode, which supports 4 graphic pages
  1823.              in the resoultion 320x200 pixels and 256 colors. Because this mode
  1824.              is not known by the VGA's BIOS, ANIVGA has to reprogram the VGA.
  1825.              You should use this command only once to switch into graphic mode.
  1826.  
  1827. Note       : InitGraph automatically switches to the invisible graphic page
  1828.              1-PAGE.
  1829.  
  1830. See also   : Screen, CloseRoutines
  1831.  
  1832.  
  1833. InitRoutines - procedure
  1834. ────────────────────────
  1835.  
  1836. Function   : Resets all necessary internal variables of ANIVGA to initial values
  1837.  
  1838. Declaration: PROCEDURE InitRoutines FAR;
  1839.  
  1840. Description: At program start, some variables have to be set and a few system
  1841.              checks are necessary.
  1842.              Among these are:
  1843.              - SpriteN[] and SpriteAd[] become cleared (= set to 0)
  1844.              - Page (the actual drwaing page) is set to 0
  1845.              - PageAdr is set to the segment address of the drawing page PAGE
  1846.              - BackgroundMode is set to STATIC, i.e.: non-scrollable background
  1847.              - BackGndAdr is set to the segment address of the background image
  1848.              - StartVirtualX/Y are set to (0,0), making the normal screen coor-
  1849.                dinates identical to the virtual screen coordinates
  1850.              - the old graphic/text mode which was active at program start is
  1851.                stored for restoring it at the program end
  1852.              - the system is checked if a VGA card is present and the global
  1853.                variable ERROR is set accordingly
  1854.              - CycleTime is set to 0, which says that there should be no time-
  1855.                control mechanism for the animation rate
  1856.              - if the machine is not at least an AT, the time mechanism is
  1857.                switched off completely
  1858.              - COLOR is set to 15 (= white)
  1859.  
  1860.              The first thing you should do in your programs is to look at the
  1861.              ERROR variable: if it was set to something different from Err_None
  1862.              (by the implicit, automatical call of InitRoutines) then your pro-
  1863.              gram should not proceed further.
  1864.  
  1865. Note       : - This routine is called automatically at the very beginning of
  1866.                every program which uses ANIVGA. For that, there is normally no
  1867.                need to call this routine explicitly.
  1868.              - Possible ERROR-values returned are: Err_None and Err_NoVGA
  1869.              - Note that this is the _only_ routine that definitely sets the
  1870.                variable ERROR, either to Err_None or Err_NoVGA. Because it is
  1871.                called at the beginning of every program, it is thus assured
  1872.                that your application always has a defined value for ERROR!
  1873.  
  1874. See also   : ERROR
  1875.  
  1876.  
  1877. Line - procedure
  1878. ────────────────
  1879.  
  1880. Function   : Draw a line between the two points specified
  1881.  
  1882. Declaration: PROCEDURE Line(x1,y1,x2,y2:INTEGER; pa:BYTE); FAR;
  1883.  
  1884. Description: Calling this routine will draw a line between the two points
  1885.              (x1,y1) and (x2,y2) on graphic page "pa" and in the color COLOR.
  1886.              The routine uses virtual coordinates and clips the line down to
  1887.              its visible part.
  1888.              "pa" must be one of the values 0, 1 or BACKGNDPAGE (=2).
  1889.  
  1890. Note       : - As with all point-setting procedures of ANIVGA, you have to re-
  1891.                member ANIVGA's working scheme: the first thing ANIVGA does when
  1892.                Animate becomes executed is to copy the background image to the
  1893.                actual drawing page PAGE, erasing everything on that image.
  1894.                For this reason, a line drawn on the visible page 1-PAGE will be
  1895.                visible exactly one animation cycle.
  1896.              - Possible ERROR-values returned are: Err_InvalidPageNumber
  1897.  
  1898. See also   : PutPixel, BackGroundLine, coordinates
  1899.  
  1900.  
  1901. LoadBackgroundPage - procedure
  1902. ──────────────────────────────
  1903.  
  1904. Function   : Loads a background image from disk
  1905.  
  1906. Declaration: PROCEDURE LoadBackgroundpage(name:String) FAR;
  1907.  
  1908. Description: This routine loads a bitmap image stored in file "name" into the
  1909.              graphic page used for the background image (BACKGNDPAGE).
  1910.  
  1911. Note (!)   : - This routine must be called *after* the graphic mode has been
  1912.                initialized (with InitGraph())!
  1913.              - You can create such images either with the WritePage()- and
  1914.                WriteBackgroundPage()-routines of ANIVGA or the GRAB-Utility.
  1915.              - Calling this routine is equivalent to use the routine LoadPage()
  1916.                with BACKGNDPAGE as second argument.
  1917.              - Possible ERROR-values returned are: Err_FileIO and Err_NoPicture
  1918.  
  1919. See also   : Background, LoadPage, FillBackground, GetBackgroundFromPage,
  1920.              InitGraph
  1921.  
  1922.  
  1923. LoadMAX - constant
  1924. ──────────────────
  1925.  
  1926. Function   : Specifies the maximum number of different sprites
  1927.  
  1928. Declaration: CONST LoadMAX=1000;
  1929.  
  1930. Description: For each physical sprite, ANIVGA uses an internal pointer to its
  1931.              data. There are LoadMAX pointers, thus there may be up to LoadMAX
  1932.              different spriteLOADnumbers (= different sprites).
  1933.  
  1934. Note       : Don't mix this constant up with NMAX!
  1935.  
  1936. See also   : NMAX, SPRITE, SpriteLOADnumbers, Spritenumbers
  1937.  
  1938.  
  1939. LoadPage - procedure
  1940. ────────────────────
  1941.  
  1942. Function   : Loads a graphic page from disk
  1943.  
  1944. Declaration: PROCEDURE LoadPage(name:STRING; pa:BYTE); FAR;
  1945.  
  1946. Description: "name" is the MSDOS-path to the graphic image to load, pa the
  1947.              destination page (0,1 or BACKGNDPAGE (=2)).
  1948.  
  1949. Note       : - The graphic mode must have been initialized (vià InitGraph)
  1950.                already!
  1951.              - You can generate disk files of graphic pages with the help of
  1952.                the WritePage()-routine or with the GRAB-utility program.
  1953.              - Don't use this routine to load an image into the SCROLLPAGE,
  1954.                i.e.: in background mode SCROLLING!
  1955.              - Possible ERROR-values returned are: Err_InvalidPageNumber,
  1956.                Err_FileIO and Err_NoPicture
  1957.  
  1958. See also   : GRAB, WritePage, background, InitGraph
  1959.  
  1960.  
  1961. LoadPalette - function
  1962. ──────────────────────
  1963.  
  1964. Function   : Loads a palette into memory
  1965.  
  1966. Declaration: FUNCTION LoadPalette(name:String; number:BYTE;
  1967.                                   VAR pal:Palette):WORD;
  1968. Description: "name" is the MSDOS-name of the palette file (*.PAL) to load,
  1969.              "number" is the index of the first loaded color in the desti-
  1970.              nation array "pal". For example,
  1971.               LoadPalette('C:\ANIVGA\TEST.PAL',0,my_pal)
  1972.              would load the named palette file into my_pal and the first color
  1973.              of this file would be stored in my_pal[0], the second in
  1974.              my_pal[1] and so on. (This call - "number" set to 0 - will be
  1975.              the form you'll need in 99% of all cases!)
  1976.              The routine will read in the complete file and return the number
  1977.              of colors read as result.
  1978.              All other colors in "pal" before "number" or after the end of the
  1979.              specified pal-file will stay untouched!
  1980.  
  1981. Note       : - As the routine reads in the complete file, you must take care
  1982.                not to write beyond the end of "pal"! Especially, if you load
  1983.                a complete 256-color palette (size: 3*256=768 bytes), you must
  1984.                start at color index 0 (that is: number=0) or you'll get an
  1985.                "Err_PaletteWontFit"-Error! Most often however, you will use
  1986.                this routine as in the example above.
  1987.              - Other possible errors are: Err_FileIO and Err_NoPalette
  1988.              - You can call this routine only after having called InitGraph()!
  1989.              - You can directly load into ActualColors, that is the sequence:
  1990.                 Dummy:=LoadPalette(pal_name,0,ActualColors);
  1991.                 SetPalette(ActualColors);
  1992.                is valid!
  1993.  
  1994. See also   : palettes, SetPalette, GetPalette
  1995.  
  1996.  
  1997. LoadSprite - function
  1998. ─────────────────────
  1999.  
  2000. Function   : Loads one (or more) sprites into memory
  2001.  
  2002. Declaration: FUNCTION LoadSprite(name:String; number:WORD):WORD; FAR;
  2003.  
  2004. Description: "name" is the MSDOS-name of the sprite file to load, which can be
  2005.              either a single sprite file (*.COD) or a complete sprite library
  2006.              (*.LIB): the function will detect automatically, which format is
  2007.              used while loading the data.
  2008.              "number" is the spriteLOADnumber, the first loaded sprite will be
  2009.              assigned to. If the file contains more than one sprite, they will
  2010.              get consecutive LOADnumbers.
  2011.              The value returned by the function is the numbers of sprites read
  2012.              in (i.e.: 0 means "no sprite read", so you should check ERROR in
  2013.              that case).
  2014.  
  2015. Note       : - Unlike LoadTile(), LoadSprite() loads data into conventional
  2016.                memory. For that, you don't have to be in graphic mode to load
  2017.                data from disk!
  2018.              - Possible ERROR-values returned are: Err_FileIO, Err_NoSprite,
  2019.                Err_NotEnoughMemory and Err_InvalidSpriteNumber
  2020.  
  2021. See also   : sprite format, MAKES
  2022.  
  2023.  
  2024. LoadTile - function
  2025. ───────────────────
  2026.  
  2027. Function   : Loads one or more tiles from disk
  2028.  
  2029. Declaration: FUNCTION LoadTile(name:STRING; number:BYTE):WORD; FAR;
  2030.  
  2031. Description: This routine loads the background tile file "name" into the
  2032.              graphic memory area reserved for tiles (the SCROLLPAGE).
  2033.              The starting number for the first tile of the file is "number",
  2034.              if there are more than one tile in the named file, they will be
  2035.              loaded to (with increasing numbers).
  2036.              The function returns the number of tiles read in.
  2037.  
  2038. Note (!)   : - This routine must be called *after* the graphic mode has been
  2039.                initialized (with InitGraph)!
  2040.                What the function actually does is reading in a sprite and con-
  2041.                verting it into an internal tile format: if the sprite read in
  2042.                doesn't have the proper size of a tile (16x16 pixels), you nor-
  2043.                mally will get an appropriate error (Err_NoTile), with one (use-
  2044.                ful) exception: if the sprite can be "cut" into tiles (that is,
  2045.                its width and height are multiples of 16 pixels each), then
  2046.                LoadTile() will do so with the following numbering scheme: from
  2047.                left to right and from top to bottom.
  2048.                For example, a sprite with (width,height)=(3*16,2*16) points
  2049.                would be numbered as: (assuming that "number" = 0)
  2050.                ┌────────┬────────┬────────┐
  2051.                │        │        │        │
  2052.                │   0    │   1    │   2    │
  2053.                │        │        │        │
  2054.                ├────────┼────────┼────────┤
  2055.                │        │        │        │
  2056.                │   3    │   4    │   5    │
  2057.                │        │        │        │
  2058.                └────────┴────────┴────────┘
  2059.                Besides, LOADTILE can load a sprite library, too (they will be
  2060.                loaded in the sequence in which they appear in the library).
  2061.              - Possible ERROR-values returned are: Err_NotEnoughMemory,
  2062.                Err_FileIO, Err_NoTile and Err_InvalidTileNumber
  2063.  
  2064. See also   : Background, LOADSPRITE, TILE
  2065.  
  2066.  
  2067. MAKES - utility
  2068. ───────────────
  2069.  
  2070. The design of sprites, background pictures and tiles is much to tedious to be
  2071. carried out manually. For this reason, there are two utility programs to
  2072. simplify that task. The first one is a resident program named "GRAB" to
  2073. capture graphics from other applications and convert them into sprites, the
  2074. second is MAKES, a spritemaker program.
  2075. To use it, you must have a mouse installed and a Super-VGA card.
  2076.  
  2077. -> MAKES uses a "tweaked" 640x400x256 graphic mode, only available at Super-
  2078.    VGA-cards! If you don't have one (or one which chip-set isn't supported by
  2079.    the supplied BGI-driver), you won't be able to run MAKES!
  2080.    Let me cite from Jordan Hargrave's docs:
  2081.  
  2082.    >Card types supported: (SuperVGA drivers)
  2083.    >Ahead, ATI, Chips & Tech, Everex, Genoa, Paradise, Oak, Trident (both 8800
  2084.    >and 8900), Tseng (both 3000 and 4000 chipsets) and Video7.
  2085.    >These drivers will also work on video cards with VESA capability.
  2086.    >
  2087.    >I have not tested these drivers on all these card types, so I can not
  2088.    >guarantee perfect operation with your card.  I have tested them extensively
  2089.    >on Trident, Tseng and ATI cards, and have had no problems. (Trident 8800
  2090.    >cards occasionally have problems, especially older models)
  2091.    
  2092.    If you can't run MAKES, then please drop me a note specifying which brand of
  2093.    VGA card you have and which chip-set it uses!
  2094.  
  2095. There are no parameters or such things, just start it!
  2096. The screen is divided in several areas:
  2097.  - the so-called "work area" in the upper left region, in which you paint your
  2098.    sprite
  2099.  - the palette area to the right of it, where you choose colors for painting
  2100.    or define new colors
  2101.  - the info bar right beneath the work area, which informs you about the
  2102.    cursor position and some other actually set data
  2103.  - the icon field, supplying 18 different functions: 8 "tools" and 10 pure
  2104.    functions
  2105.  - 10 function boxes at the very screen bottom, which can also be accessed by
  2106.    pressing the appropriate function key (ever seen the Norton Commander?)
  2107.  
  2108. (Note that a lot of the icons/function boxes have two functions, where the
  2109.  second one can be reached by holding down the shift-key while pressing/
  2110.  clicking at the icon - this will be described later on, but you can always
  2111.  press F1 in MAKES for a short summary.)
  2112.  
  2113.  
  2114. Now let's take a small tout through MAKES!
  2115.  
  2116. -> I propose that you print out this part of the documentation and then start
  2117.    MAKES.EXE for the following description!!!
  2118.  
  2119. Huh - where to begin? Okay, look at the work area's boundary: it has small
  2120. marks on it, indicating 8 pixel intervals. Move the mouse cursor somewhere into
  2121. the workarea: right beneath the work area, your PC will display the mouse
  2122. cursor's position and what color is currently set at that point. Now move around
  2123. and convince yourself about the marks' values. Press the left mouse button a
  2124. few times: each time, a white pixel will be drawn at the cursor position,
  2125. because "pixel" is the selected tool and "white" the actually set drawing color.
  2126. Nothing whopping, eh? - Now press "+" a few times: wow! You zoom into the work
  2127. area as much as you wish (well, I limited it to a factor 30, but if _that_ is
  2128. not enough you should consider selling your PC for a seeing-eye dog, anyway!).
  2129. Use "-" to zoom out, down to value 1: for easier pointing, the cursor will
  2130. change to a small crosshair pointer when zooming is at factor 1.
  2131. -> Note that as the screen you look at has resolution 640x400, while ANIVGA's
  2132.    has 320x200, zoom=2 (the default value) will give you normal 1:1 aspect
  2133.    ratio!
  2134. You don't like monochrome pictures? Ok, then click (with the left mouse button)
  2135. at another color in the palette area: this changes the drawing color to the
  2136. color you clicked at.
  2137. Repeat choosing a color, but this time press the _right_ mouse button: a menu
  2138. will pop up and let you change the RGB-values of that color; this way, you may
  2139. alter the palette for your sprites!
  2140. -> Note that RGB-values reach from 0 to 63. If you want to copy another color's
  2141.    values, then just click at this color; e.g. if you want to have color 222
  2142.    hold the same color as 111 (for example as a template), then click with the
  2143.    _right_ button at color 222 and then with the _left_ button at color 111
  2144. Now choose another drawing tool, let's say lines: click at this icon and move
  2145. back into the work area. Choose a starting point and click at it (release the
  2146. mouse button!): now you started a line: move around the mouse to route your
  2147. line; if you are content with it, then press the left button again. If you
  2148. decide to cancel the line drawing instead, then press the right button instead.
  2149. -> This "philosophy" will be used for all tools: press the left button to
  2150.    start/advance/complete an action, press the right button any time to cancel
  2151.    what you are doing - so get used to it!
  2152. Now repeat the process of drawing a line, but hold down "shift" while you are
  2153. clicking at the starting point: this tells the object "to be aligned" which
  2154. in the context of lines means that you are drawing a horizontal, vertical or
  2155. diagonal line! In the same way, you can align rectangles to become squares and
  2156. ellipses to circles. Try it! Choose these icons and draw the according objects,
  2157. aligned and not aligned (if you choose the lower rectangle/ellipse icon, your
  2158. objects will be filled out with the actual drawing color).
  2159. -> You may select another color even if you are in midst of drawing an object;
  2160.    move out of the work area, click at the color you wish - as soon as you
  2161.    move back into the work area, your object will change!
  2162. Let's try the filling tool (the left, bottommost one): it will fill all points
  2163. it can reach from the pixel you clicked at having the same color, e.g. if you
  2164. click at a white pixel, it will color all white pixels neighboured to that
  2165. pixel and so on. Note that as long as you don't press the left button a second
  2166. time, this coloring doesn't rest, that is if you move around the mouse after
  2167. having clicked the first time, MAKES will restart its fill algorithm starting
  2168. at the new pixel your mouse points at! This behaviour is a bit confusing in
  2169. the beginning but comes in very handy when you get used to it.
  2170. -> If you really get stuck - especially on slow machines - then just press the
  2171.    right mouse button for two or three seconds to cancel the action and start
  2172.    over again.
  2173. The last tool to be mentioned is the copy tool (the icon with the scissors):
  2174. you can span a (dotted) rectangular area which you want to copy the same way
  2175. you would draw a rectangle, but after pressing the mouse button a second time,
  2176. a copy of this area will be visible at your cursor which you can place where-
  2177. ever you want to. (Note that color 0 inside this copy will be treated as trans-
  2178. parent, which makes it easier to overlay objects at the screen!)
  2179.  
  2180. These 8 icons (the 4 leftmost in the upper and lower row) make up the available
  2181. _tools_, the resting 10 icons are "function buttons", that is: their linked
  2182. action will take place at once (respectively: after asking you necessary para-
  2183. meters).
  2184. I'll first name them, starting in the upper row at the 5th icon, in clockwise
  2185. order:
  2186. a) change color
  2187. b) rotate work area left
  2188. c) rotate work area right
  2189. d) mirror work area horizontally
  2190. e) go/move to the upper-left
  2191. f) display boundaries
  2192. g) mirror work area vertically
  2193. h) rotate work area down
  2194. i) rotate work area up
  2195. j) blink color
  2196.  
  2197. a)
  2198.  You can replace pixels of a specific color by another color with this tool:
  2199.  the program will ask you for the colors, which you can select by either
  2200.  clicking in the palette area or by clicking at pixels in the work area itself.
  2201.  
  2202. b), c), h), i)
  2203.  Clicking at one of these buttons will move the contents of the work area in
  2204.  the according direction, but what "falls out" at one side of the work area
  2205.  will show up on the opposite side again. If you hold down "shift" while
  2206.  clicking, the image will rotate by one pixel, without shift, it will rotate
  2207.  by 1/4 of the actual screen width.
  2208.  
  2209. d), g)
  2210.  I guess these two mirror options should be quite clear; note that as
  2211.  they mirror a small image in the upper left corner to the "far away" right/
  2212.  bottom region of the work area, you'll often need a tool to "pull back" the
  2213.  graphic contents to the upper left corner: that is exactly the task of the
  2214.  e) icon: it will move the graphic contents to the top and left as much as
  2215.  possible.
  2216.  
  2217. e)
  2218.  As mentioned above, this tool will move the work area contents to the left
  2219.  (and top), until column 0 (row 0) holds a non-zero colored pixel.
  2220.  If you hold down "shift" while clicking at this icon, there is another
  2221.  functionality: then, MAKES scrolls back the visible part of the workarea
  2222.  back to the upper left region of the picture (0,0), that is: this is a short-
  2223.  cut for pressing the left- and up-arrow keys a few times (see below for more
  2224.  about this).
  2225.  
  2226. f)
  2227.  If you want to know/see the boundaries of your sprite, then click at this
  2228.  icon: the leftmost and rightmost (upmost & bottommost) pixel of each row
  2229.  (column) will blink and a popup window will inform you about the sprite's
  2230.  size numerically.
  2231.  If you hold down "shift" while clicking this icon, MAKES will also blink all
  2232.  transparent areas inside the sprite, which may be useful if you don't know
  2233.  whether you must use display mode Display_SHADOW <-> Display_SHADOWEXACT and
  2234.  Display_FAST <-> Display_NORMAL; in all other cases you can forget about this
  2235.  option.
  2236. -> Note that sprites are always stored as the smallest rectangle which
  2237.    surrounds them and starts at the upper left corner (0,0): if you don't have
  2238.    special reasons to do otherwise, your sprites should start in the upper left
  2239.    corner.
  2240.    If for example you realize a sprite consisting of one single point at
  2241.    coordinates (a,b), the smallest surrounding box with (0,0) as upper left
  2242.    corner would be
  2243.    (0,0)      (a,0)      of size (a+1)*(b+1) pixels (=bytes)!!!
  2244.      ┌──────────┐
  2245.      │          │
  2246.      │          │
  2247.      │          │
  2248.      └──────────▀   <─ this is your 1 point
  2249.    (0,b)      (a,b)
  2250.    (In addition to that, the right edge of this box will be rounded up so that
  2251.     the width of the sprite will be a multiple of 4)
  2252.    To determine what areas belong to your sprite and which don't, the program
  2253.    assumes color 0 to specify no-sprite-areas and all other colors to be part
  2254.    of your sprite (roughly spoken).
  2255.  
  2256. j)
  2257.  If for some reason you must know of all pixels of a specific color (e.g. to
  2258.  distinguish two very similiar colors), you can use this function: the program
  2259.  will ask you to select the color, what you can do by either clicking at a
  2260.  work area pixel with that color or at a color in the palette area.
  2261.  
  2262. Okay, now that we are through with the icons, let's have a look at the keys:
  2263. you already know that "+" and "-" zoom in and out the workarea. But if zoom>1
  2264. then only a part of the complete workarea (320x200 pixels) will be visible!
  2265. To work on the "offscreen" regions, you can scroll the work area by using the
  2266. cursor keys: pressing one of the arrow keys will scroll by 1/4 screen into the
  2267. corresponding direction; if you hold down "shift" while pressing an arrow key,
  2268. it will scroll by one pixel instead. The absolute coordinate value of the
  2269. upper left corner you are looking at will be displayed by the two "offset:"
  2270. messages, e.g. "offset X: 40" means that there are 40 columns (0..39) to the
  2271. left of the visible window of the work area, which you may scroll in by
  2272. pressing the left arrow key. (Consider the work area as a view-finder of an
  2273. imaginary camera which you may slide into each direction).
  2274. A short-cut to return to the work area's origin (0,0) is available, too: press
  2275. shift and click at the "go/move to upper left" icon.
  2276.  
  2277. The function keys do what they tell you:
  2278.  F1 = a short summary of the functionality not visible at first sight
  2279.  F2 = save the work area's contents to disk as a sprite file
  2280.  F3 = load a previously saved sprite into the work area; if you press "shift"
  2281.       while activating this icon (or Shift-F3), then the work area won't be
  2282.       erased before loading the sprite: this way, you may overlay several
  2283.       sprites on the screen
  2284.  F4 = save the actually set palette to disk. Note that if you are using the
  2285.       BIOS' default palette, the program won't store it to disk (as you don't
  2286.       need)
  2287.  F5 = load a previously saved palette. This function is especially necessary
  2288.       when you used GRAB to capture a sprite from an application using a
  2289.       different palette. (See below for more about palette handling)
  2290.  F6 = save the work area's contents to disk, this time as a background picture
  2291.  F7 = load a previously saved background picture; the same notes apply as said
  2292.       to loading sprites (F3)
  2293.  F8 = clear screen. This will erase the work area and let you start all over
  2294.       again. Note that it won't reset the palette to the BIOS' default! If you
  2295.       want that, you have to press Shift-F9, too!
  2296.  F9 = map the workarea colors onto another palette. This feature asks you for
  2297.       a palette, loads that and then uses a minimum square algorithm to exchange
  2298.       each's pixel color by the one from the specified palette which comes as
  2299.       close as possible to the original color. (See below for more about that)
  2300.       Shift-F9 works the same, but maps to the BIOS' default palette instead
  2301.       of asking you for a palette file.
  2302.  F10= quit the program
  2303.  
  2304.  
  2305. Note       :
  2306. o Palettes:
  2307.  Note that if you load/save a sprite or picture file, MAKES won't load/save
  2308.  the according palette automatically, you have to do that manually. This has
  2309.  been done intentionally, however: never forget that you may design a hundred
  2310.  sprites with a hundred different palettes, but when it all comes down to
  2311.  display these sprites simultaneously in your programs, only *one* palette may
  2312.  be active! For that reason, you must mix all those palettes to the one you are
  2313.  going to use. 
  2314.  Normally, that won't be that dramatic, as 240 free color shades (it is *very*
  2315.  wise not to change the first 16 EGA-compatible colors) seem enough to me, but
  2316.  perhaps you want to include a formerly designed sprite A, using palette B,
  2317.  into a new program where you use palette C! Before you start mixing a new
  2318.  palette D for this old and your new sprites together, you should try mapping
  2319.  old sprite A's colors to palette C: To accomplish that, load sprite A (using
  2320.  F3), then load its old palette B (using F5); now press "map palette to
  2321.  palette" (F9) and tell the program to map onto palette C: if the result looks
  2322.  good enough, then save sprite A (perhaps using a different name) and use
  2323.  palette C for all items in your program, else you have to find a compromise
  2324.  between palettes B and C (I'm actually working on a program which will auto-
  2325.  matize that job, but for now, you are on your own!).
  2326.  
  2327.  To state it clear: there is a conceptional difference between EXCHANGING a
  2328.  color (using the "change color" icon) and CHANGING a color itself (by altering
  2329.  the RGB values of one or multiple colors):
  2330.  - exchanging colors doesn't change the palette, it merely uses another color
  2331.    of that palette
  2332.  - changing palette colors doesn't change the pixels' color number, but the
  2333.    color's RGB value
  2334.  In other words: if you exchange colors, then you don't have to save the color
  2335.  palette again, as it didn't change, but the sprite, because its data changed.
  2336.  On the other hand, if you changed palette colors, then you'll have to save the
  2337.  palette, but not the sprite, as the pixel data didn't change.
  2338.  (If you didn't get that: just always save both and forget about it...)
  2339.  
  2340. o Mouse problems:
  2341.  I noticed that sometimes, the program hangs when initializing the mouse driver
  2342.  (when it calls "INT 33h" with AX=0), what you see in that the starting count-
  2343.  down doesn't get below 7. I don't have _any_ idea why this happens and hope
  2344.  it won't show up on other systems. Note that this is (at least what I noticed)
  2345.  a spurious error: cancel the program, restart it once more and it will work!
  2346.  Besides that, when quitting the program, MAKES sometimes reports a senseless
  2347.  runtime error - it is a spurious, not reproducable error I couldn't track
  2348.  down, either (perhaps TP doesn't like my TSR / QEMM installation, I dunno)!?
  2349.  
  2350. o Memory:
  2351.  You should have at least 256K free RAM if you start MAKES, or it won't work.
  2352.  
  2353. o Sprite size:
  2354.  If MAKES tells you that it can't save the workarea as a sprite, because it
  2355.  is "to big" - well, then you'll have to shrink your sprite! Sorry, but I
  2356.  wanted MAKES to handle CODs and PICs at the same time, but 320x200 pixels
  2357.  (the size of a picture) is to much for a COD, as the additional data stored
  2358.  along with the sprite would make it larger than 64K! (Cut off a few rows or
  2359.  columns until it works.)
  2360.  Note also that MAKES has to store sprites with widths being a multiple of 4!
  2361.  That is: it doesn't matter, whether the max. used x-coordinate is for example
  2362.  316, 317, 318 or 319, because for all those 4 widths (0..316=317 pixels,
  2363.  0..317=318, 0..318=319, 0..319=320), MAKES would have to store them with
  2364.  the "rounded up" width of 320 pixels!
  2365.  (In other words: although ANIVGA itself can handle sprites up to 32000 pixels
  2366.   in each axis and 64K max. size, MAKES restricts you to sprites of x-size at
  2367.   most 320 pixels and y-sizes of at most 200 pixels)
  2368.  
  2369. o COD <-> PIC:
  2370.  Yes, you read right: MAKES doesn't care whether you are working on a sprite
  2371.  or a picture graphic: just paint it and store it into the format you want
  2372.  (subject to what I said above concerning the 64K limit)! Oh yes, that way
  2373.  you may convert a sprite into a background picture (and vice versa) if you
  2374.  have reason to do so!
  2375.  
  2376. o Tips:
  2377.  
  2378.  The best way to design a sprite is to start in midst of a cleared work area.
  2379.  If you need more room, rotate your sprite in the appropriate direction.
  2380.  If you think you're done, use the rotate boxes again (or the "move to upper-
  2381.  left" icon) to align your sprite with the upper left corner. Then click on
  2382.  the "display boundaries" box to compare the sprite's size with what you
  2383.  expected. To wide (high)? Then there is a pixel with color <> 0 to the right
  2384.  (beneath) your sprite! Look at the max. column (row) MAKES told you and kill
  2385.  that pixel! (To see it more clearly, just hold down "shift" while clicking
  2386.  at the "display boundaries" icon).
  2387.  
  2388.  If you are unsure whether you can use display mode Display_FAST or need
  2389.  Display_NORMAL (same applies for Display_SHADOWEXACT and Display_SHADOW),
  2390.  then hold down "shift", click at the "display boundaries" icon and look at
  2391.  the picture: if the blinking parts "spread" out of the parts you think your
  2392.  sprite should be made of, then you should use Display_NORMAL
  2393.  (Display_SHADOWEXACT, respectively), if all the blinking areas are inside your
  2394.  sprite, you can (and should) use Display_FAST (Display_SHADOW).
  2395.  
  2396. See also   : sprite format, GRAB, Display modes
  2397.  
  2398.  
  2399. MaxTiles - constant
  2400. ───────────────────
  2401.  
  2402. Function   : Holds the maximum number of tiles to build the background image
  2403.  
  2404. Declaration: CONST MaxTiles=10000;
  2405.  
  2406. Description: In background mode SCROLLING, you may use up to MaxTiles tiles
  2407.              to build your graphic image.
  2408.  
  2409. Note       : -
  2410.  
  2411. See also   : Background
  2412.  
  2413.  
  2414. NextSprite - variables
  2415. ──────────────────────
  2416.  
  2417. Function   : Holds the "successors" of sprites for sprite cycles
  2418.  
  2419. Declaration: VAR NextSprite: ARRAY [0..LoadMAX] OF WORD
  2420.  
  2421. Description: To realize a sprite cycle, you must tell ANIVGA which sprites
  2422.              should be drawn one after another. It is this information
  2423.              NextSprite holds! For example, let us assume that you wanted to
  2424.              make the sprite(loadnumber)s 43, 177 and 111 a sprite cycle, i.e.:
  2425.              whenever you set a sprite (to be precise: a SpriteN[]-entry) to
  2426.              one of these three numbers, ANIVGA should cycle between the three
  2427.              sprite-images in the sequence 43->177->111->43->177->111->...
  2428.              You would then set NextSprite[43]:=177; NextSprite[177]:=111 and
  2429.              NextSprite[111]:=43  (don't forget this final value!) to do so.
  2430.  
  2431. Note (!)   : - Most often, you will have the situation that some sprite(load)-
  2432.                numbers with consecutive numbers should make up a cycle. In that
  2433.                case it is more convenient to use the SetSpriteCycle()-procedure
  2434.                to do the job for you
  2435.              - Again, note that the routine deals with spriteLOADnumbers! That
  2436.                is intentionally, because a sprite cycle is related to the
  2437.                _physical_ existent sprite data, or simply spoken: if you make
  2438.                5 pictures to form a flickering torch and you are going to use
  2439.                10 torches in your animation then each of them should loop
  2440.                through this 5-picture-cycle, shouldn't it?
  2441.              - NextSprite[] is initially set "to point to itself", that is:
  2442.                NextSprite[i]=i for all possible i's. If you had to break off
  2443.                a sprite cycle (though I can't think what this should be good
  2444.                for...), you must restore this data, e.g.: if you wanted to
  2445.                break the sprite cycle above, you would have to set
  2446.                NextSprite[43]:=43; NextSprite[177]:=177; NextSprite[111]:=43;
  2447.              - As this is a global variable, ANIVGA can't check whether your
  2448.                settings make sense or not; thus, it remains your responsibi-
  2449.                lity to use proper values!
  2450.  
  2451. See also   :   SetSpriteCycle, Sprite cycles
  2452.  
  2453.  
  2454. NMAX - constant
  2455. ───────────────
  2456.  
  2457. Function   : Determines the maximum of sprites to be active at the same time
  2458.              (minus 1)
  2459.  
  2460. Declaration: CONST NMAX=499
  2461.  
  2462. Description: This constant sets the size of the internal tables - and thus the
  2463.              valid sprite numbers: the indices of the tables SpriteX, SpriteY
  2464.              and SpriteN must lie in the range 0..NMAX.
  2465.              To state it otherwise, there may be up to NMAX+1 sprites creeping
  2466.              around your screen at the same time...
  2467.  
  2468. Note       : Don't confound that constant with LoadMAX
  2469.  
  2470. See also   : LoadMAX
  2471.  
  2472.  
  2473. OutTextXY - procedure
  2474. ─────────────────────
  2475.  
  2476. Function   : Writes a textstring to the graphic screen
  2477.  
  2478. Declaration: PROCEDURE OutTextXY(x,y:INTEGER; pa:BYTE; s:STRING); FAR;
  2479.  
  2480. Description: ANIVGA has a built-in font, each character consisting of 6x6
  2481.              pixels: very ugly, but hey, we want to make animations, not text!
  2482.              To write the string "s" to the graphic screen, you must specify
  2483.              the upper left starting corner of the text in (x,y):
  2484.                  (x,y) -> ▄──────────┐ , where (x,y) are virtual coordinates!
  2485.                           │          │
  2486.                           │          │
  2487.                           │          │
  2488.                           └──────────┘
  2489.              The text will be drawn in color GRAPHTEXTCOLOR and with the orien-
  2490.              tation GRAPHTEXTORIENTATION ("VERTICAL" or "HORIZONTAL").
  2491.              A third global variable, GRAPHTEXTBACKGROUND, specifies the color
  2492.              which will be used for the background area "beneath" the text
  2493.              letters; if GRAPHTEXTCOLOR=GRAPHTEXTBACKGROUND then the text will
  2494.              be drawn like TurboPascal's routine does: only the pixels be-
  2495.              longing to the letters will be drawn, all others remain unchanged.
  2496.              "pa" specifies the graphic page to be drawn on and must be one of
  2497.              the drawing pages (0 or 1) or the BACKGNDPAGE (=2) for background
  2498.              mode STATIC.
  2499.  
  2500. Note       : - In 99% of all cases, you will output text to the visible
  2501.                screen, that is: "OutTextXY(someX,someY,1-PAGE,'foobar')"
  2502.              - Any text drawn to the working pages 0 or 1 will stay onscreen
  2503.                only for one animation cycle. If you want it permanent, then
  2504.                use BackGroundOutTextXY() in mode STATIC or replace any call
  2505.                to Animate() by the sequence
  2506.                 Animate();
  2507.                 OutTextXY(someX,someY,1-PAGE,my_text)
  2508.                which works in both modes STATIC & SCROLLING. (As always, if
  2509.                you are in mode SCROLLING and use absolute coordinates, the
  2510.                text will scroll with your graphic image, while if you use
  2511.                relative coordinates (relative to StartVirtualX|Y of course),
  2512.                then the text will stay at a definite physical monitor position.
  2513.                For example,
  2514.                 OutTextXY(StartVirtualX,StartVirtualY,1-PAGE,'Hi!')
  2515.                will tie the text to the upper left screen position)
  2516.              - Better fonts could have been developped, but they would all
  2517.                depend on special assumptions about the text- and/or background
  2518.                color(s).
  2519.                This font was intented for short and simple text strings and to
  2520.                be as small as possible.
  2521.                Nevertheless, using a bigger cell (say: 10x10) and several
  2522.                colors (for antialiasing effects) can result in very impressive
  2523.                fonts - and work, too...
  2524.              - Possible ERROR-values returned are: Err_InvalidPageNumber
  2525.  
  2526. See also   : GraphtextColor, GraphtextOrientation, GraphtextBackground,
  2527.              BackgroundOutTextXY
  2528.  
  2529.  
  2530. PAGE - variable
  2531. ───────────────
  2532.  
  2533. Function   : Holds the number of the actual drawing page
  2534.  
  2535. Declaration: VAR PAGE:WORD
  2536.  
  2537. Description: ANIVGA uses a page flipping approach. Basically this means that it
  2538.              alternates between using page 0 and page 1 for its display.
  2539.              Although this mechanism should be transparent for the user, ANIVGA
  2540.              provides you with the page number of the actual drawing page in
  2541.              "PAGE". Note that this number specifies always the invisible page:
  2542.              when PAGE=0, then the actual _displayed_ page is page 1 and vice
  2543.              versa (ANIVGA always works on the invisible page!).
  2544.  
  2545. Note (!)   : Only _read_ this value, never assign a new value to it!
  2546.  
  2547.  
  2548. PAGEADR - variable
  2549. ──────────────────
  2550.  
  2551. Function   : Holds the segment address of the actual drawing page PAGE
  2552.  
  2553. Declaration: VAR PAGEADR:WORD
  2554.  
  2555. Description: As already mentioned, there are four graphic pages, numbered from
  2556.              0 to 3. The start addresses of these four pages are used by ANIVGA
  2557.              and normally the user should not need to reference them, but with
  2558.              PAGEADR at least the address of the actual (invisble) graphic page
  2559.              PAGE is available in PAGEADR.
  2560.  
  2561. Note (!)   : Only use this variable to _read_ its value, never change it!
  2562.              Although this 16-bit-value represents only the segment part of the
  2563.              complete address, it is the whole address: the address is norma-
  2564.              lized in such a way that the offset part is always zero.
  2565.  
  2566. See also   : PAGE
  2567.  
  2568.  
  2569. PageGetPixel - function
  2570. ───────────────────────
  2571.  
  2572. Function   : Returns the color value of the specified point
  2573.  
  2574. Declaration: FUNCTION PageGetPixel(x,y:INTEGER; pa:BYTE):BYTE; FAR;
  2575.  
  2576. Description: If the point at the virtual coordinates (x,y) and graphic page
  2577.              "pa" lies on the screen (i.e.: in the range (0,0)..(319,199) in
  2578.              absolute coordinates), this routine will return its color, if it
  2579.              is offscreen, the function returns zero.
  2580.              "pa" should be one of the values 0, 1 or BACKGNDPAGE (=2).
  2581.  
  2582. Note       : - If you want to read a pixels' color from the _visible_ page, you
  2583.                have to remember that it is the opposite of the _actual_ page
  2584.                (that is, you have to use "1-PAGE" as page number).
  2585.              - Although only values of 0,1 and BACKGNDPAGE (=2) make sense as
  2586.                "pa" values, the routine doesn't check that (for improved speed)
  2587.              - For that, the routine _doesn't_ return Err_InvalidPagenumber or
  2588.                something similiar in ERROR!
  2589.  
  2590. See also   : Background, Coordinates, GetPixel
  2591.  
  2592.  
  2593. PagePutPixel - procedure
  2594. ────────────────────────
  2595.  
  2596. Function   : Plots a point at a specified page
  2597.  
  2598. Declaration: PROCEDURE PagePutPixel(x,y:INTEGER; color,pa:BYTE); FAR;
  2599.  
  2600. Description: This routine is very similiar to PutPixel(), but it lets you
  2601.              specify explicitly on which graphic page the point shall be drawn.
  2602.              (x,y) specify the virtual coordinates of the point to be drawn in
  2603.              color "color". If this point lies onscreen (i.e.: its absolute
  2604.              coordinates are between (0,0)..(319,199)), it will be drawn on the
  2605.              specified page "pa", which must have one of the values 0, 1 or
  2606.              BACKGNDPAGE (=2). The latter only makes sense if STATIC is used as
  2607.              background mode.
  2608.  
  2609. Note       : - Don't forget that this routine works with virtual coordinates.
  2610.              - Note also that the point is _not_ drawn automatically on the
  2611.                background page if pa=0 or pa=1, thus it will be visible exactly
  2612.                one animation cycle (and be overdrawn by the background image
  2613.                then).
  2614.              - Because of ANIVGA's working scheme, you probably want to use
  2615.                this routine AFTER calling Animate() (else, your point would be
  2616.                overdrawn by the background image immediately) if pa=1-PAGE.
  2617.                If you want to draw the point at the _visible_ page, remember
  2618.                that it is the "opposite" of the _actual_ drawing page, i.e.:
  2619.                you have to use "1-PAGE" for "pa".
  2620.              - For improved speed, the routine _doesn't_ check the "pa"
  2621.                variable to have a valid value, so there will be no report to
  2622.                ERROR (Err_InvalidPageNumber or the like) available!
  2623.                It remains your responsibility to assure a proper value for pa!
  2624.  
  2625. See also   : BackgroundPutPixel, PutPixel, coordinates, How ANIVGA works
  2626.  
  2627.  
  2628. Palette, PaletteEntry, PalettePtr - type
  2629. ────────────────────────────────────────
  2630.  
  2631. Function   : Supplies user with proper internal data types
  2632.  
  2633. Declaration: TYPE PaletteEntry=RECORD red,green,blue:BYTE END;
  2634.                   Palette=ARRAY[0..255] OF PaletteEntry;
  2635.                   PalettePtr=^Palette;
  2636.  
  2637. Description: Drawing colors with the EGA/VGA is quite an interesting thing!
  2638.              You probably heard that "mode $13 gives you 256 out of 262144
  2639.              colors". The key to this is the palette (or, to be precise:
  2640.              the color-look-up-table "CLUT").
  2641.              Every color (in the range 0..255) is used as a pointer into the
  2642.              CLUT; the corresponding entry consists of three bytes, which
  2643.              stand for the red/green/blue intensity of that color (in that
  2644.              order!). These three "bytes" (only the values 0..63 are valid for
  2645.              each of them) together form an "PaletteEntry". Because we have
  2646.              256 colors, a complete CLUT is made of 256 such entries: such a
  2647.              table will be called a "Palette" in ANIVGA!
  2648.  
  2649. Note       : ANIVGA initially assumes the default colors of mode $13.
  2650.              When you change the palette and you are using one of the display
  2651.              modes Display_SHADOW or Display_SHADOWEXACT, ANIVGA must know
  2652.              this, as it must recompute its ShadowTab. "SetPalette()" takes
  2653.              care of this, so you shouldn't change palettes by other means
  2654.              than "SetPalette()" until you are absolutely sure what you are
  2655.              doing!
  2656.  
  2657.              FYI: Note also that the 256 color modes are something special:
  2658.              in all other graphic modes (the EGA's 640x350x16 for example),
  2659.              there is a second, intermediate indirection level.
  2660.              There, the color value is used as an index into a table, giving
  2661.              a value between 0..63. This value is used again as an index into
  2662.              a second table which holds the triples ("PaletteEntries")
  2663.              mentioned above. The first table is called the palette, the second
  2664.              is the CLUT. In the 256 color modes, only the CLUT is used, but
  2665.              few of us ever heard of CLUTs! Because there is no way to confuse
  2666.              things in ANIVGA, I decided to use the term "palette"!
  2667.  
  2668. See also   : SetShadowTab, ShadowTab, DefaultColors, SetPalette, GetPalette
  2669.  
  2670.  
  2671. Palette (*.PAL) files - information
  2672. ───────────────────────────────────
  2673.  
  2674. Palette files generated by GRAB and MAKES make it possible to use different
  2675. colors than the BIOS default values, just by issuing a LoadPalette()-call.
  2676. Their internal format is the simplest possible: each color consists of three
  2677. bytes, specifying the RGB-values (in that order), where each value can reach
  2678. from 0 (darkest) to 63 (brightest), e.g.: a bright red would be coded as
  2679. (63,0,0).
  2680. LoadPalette() reads in a complete palette - equally, if it is 3*16 bytes in
  2681. size or the max. 3*256 bytes for a complete 256 color palette, but it is wise
  2682. to use complete 256 color palettes, because otherwise you soon get confused,
  2683. - don't say I didn't warn you!
  2684.  
  2685. See also   : LoadPalette(), Palette
  2686.  
  2687.  
  2688. PutImage - procedure
  2689. ────────────────────
  2690.  
  2691. Function   : Pastes a formerly copied image to the screen
  2692.  
  2693. Declaration: PROCEDURE PutImage(x,y:INTEGER; p:POINTER; pa:WORD); FAR;
  2694.  
  2695. Description: PutImage() is the counterpart of GetImage(): use GetImage() to
  2696.              copy part of the screen and PutImage to paste it somewhere. (x,y)
  2697.              is the upper left corner of the destination (in _virtual_ coordi-
  2698.              nates), "p" is the pointer given by GetImage() and "pa" is the
  2699.              number of the graphic page (0, 1 or BACKGNDPAGE (=2)) of the des-
  2700.              tination.
  2701.              If p equals NIL, the routine does nothing at all; this is useful
  2702.              because you can PutImage() directly on the result of a GetImage()
  2703.              call without further checking for clippings, although you should
  2704.              be careful by doing so: you don't get a "handle" this way which
  2705.              you could use to free up the occupied memory again!
  2706.              (See FreeImageMem() for more about that)
  2707.  
  2708. Note       : - Like GetImage(), this routine also works only when the _virtual_
  2709.                coordinates translate into _absolute_ coordinates in the range
  2710.                of 0..319, 0..199, that is: they must lie on the visible part of
  2711.                the screen, everything else is clipped off.
  2712.              - Possible ERROR-values returned are: Err_InvaliPageNumber
  2713.  
  2714. See also   : GetImage, FreeImageMem, coordinates
  2715.  
  2716.  
  2717. PutPixel - procedure
  2718. ────────────────────
  2719.  
  2720. Function   : Plots a point
  2721.  
  2722. Declaration: PROCEDURE PutPixel(x,y:INTEGER; color:BYTE); FAR;
  2723.  
  2724. Description: (x,y) specify the virtual coordinates of the point to be drawn in
  2725.              color "color". If this point lies onscreen (i.e.: its absolute
  2726.              coordinates are between (0,0)..(319,199)), it will be drawn on the
  2727.              visible page 1-PAGE.
  2728.  
  2729. Note       : This routine is not the same as TurboPascal's one: it works with
  2730.              virtual coordinates! Note also that the point is _not_ drawn on
  2731.              the background page, thus it will be visible for exactly one ani-
  2732.              mation cycle (and be overdrawn by the background image then).
  2733.              Because of ANIVGA's working scheme, you probably want to use this
  2734.              routine AFTER calling Animate() (your point will then be visible
  2735.              until the next call to Animate()).
  2736.  
  2737. See also   : BackgroundPutPixel, PagePutPixel, coordinates, How ANIVGA works
  2738.  
  2739.  
  2740. PutTile - procedute
  2741. ───────────────────
  2742.  
  2743. Function   : "Pastes" a tile into the background image
  2744.  
  2745. Declaration: PROCEDURE PutTile(x,y:INTEGER; TileNr:BYTE); FAR;
  2746.  
  2747. Description: After you have defined a background scrolling area, you can use to
  2748.              PutTile() to arrange them as wanted to build your background image.
  2749.              (x,y) is the virtual coordinate where you want the tile "TileNr"
  2750.              to be placed.
  2751.              (x,y) will be changed to be a multiple on 16 in each direction
  2752.              and must then lie in the range (BackX1,BackY1)..(BackX2,BackY2).
  2753.  
  2754. Note       : - Of course, this routine only makes sense when you use background
  2755.                mode SCROLLING!
  2756.              - (x,y) will be drawn to the upper left to fall on the grid.
  2757.              - Possible ERROR-values returned are: Err_InvalidCoordinates
  2758.  
  2759. See also   : background, tile, SetBackgroundScrollRange, coordinate, BackX1,
  2760.              BackX2, BackY1, BackY2
  2761.  
  2762.  
  2763. Screen - procedure
  2764. ──────────────────
  2765.  
  2766. Function   : Chooses the display page.
  2767.  
  2768. Declaration: PROCEDURE Screen(pa:BYTE) FAR;
  2769.  
  2770. Description: Call Screen() with a value between 0 and 3 which tells the routine
  2771.              to which graphic page it should switch. This is done by repro-
  2772.              gramming the VGA start address registers. For a flickerfree dis-
  2773.              play, this switching is synchronized to the display enable signal.
  2774.  
  2775. Note (!)   : - You should not use this routine if you are not absolutely sure
  2776.                what you are doing! Be aware that ANIVGA relies on the fact that
  2777.                the actual drawing page is PAGE and its segment address is in
  2778.                PAGEADR while the actually visible page is 1-PAGE!
  2779.              - Although it makes little sense to apply this routine to graphic
  2780.                pages other than 0 or 1, it is possible to set "pa" to 2 (=BACK-
  2781.                GNDPAGE) or 3 (=SCROLLPAGE).
  2782.  
  2783. See also   : PAGE, PAGEADR, InitGraph
  2784.  
  2785.  
  2786. ScrollPage - constant
  2787. ─────────────────────
  2788.  
  2789. Function   : Holds the page number of the backround page
  2790.  
  2791. Declaration: CONST SCROLLPAGE=3;
  2792.  
  2793. Description: When using background mode SCROLLING, BackGndPage specifies the
  2794.              page number of the tile buffer used to build up the background
  2795.              image for animations.
  2796.  
  2797. Note (!)   : Use of this constant only makes sense when using background mode
  2798.              SCROLLING!
  2799.  
  2800. See also   : BackGndPage, Background
  2801.  
  2802.  
  2803. SetBackgroundMode - procedure
  2804. ─────────────────────────────
  2805.  
  2806. Function   : Chooses one of the possible background modes of ANIVGA
  2807.  
  2808. Declaration: PROCEDURE SetBackgroundMode(mode:BYTE); FAR;
  2809.  
  2810. Description: ANIVGA has two possible ways of handling background you can choose
  2811.              of: "STATIC" or "SCROLLING" backgrounds with several advantages
  2812.              and disadvantages, each (see background). Specify the mode you
  2813.              want to use in the "mode" variable.
  2814.  
  2815. Note       : - Default value set by ANIVGA is STATIC.
  2816.              - Possible ERROR-values returned are: Err_InvalidMode
  2817.  
  2818. See also   : background
  2819.  
  2820.  
  2821. SetBackgroundScrollRange - procedure
  2822. ────────────────────────────────────
  2823.  
  2824. Function   : Specifies the scrollable background area in mode SCROLLING
  2825.  
  2826. Declaration: PROCEDURE SetBackgroundScrollRange(x1,y1,x2,y2:INTEGER) FAR;
  2827.  
  2828. Description: (x1,y1) is the upper left corner of the background scroll area,
  2829.              (x2,y2) the lower right corner (all virtual coordinates).
  2830.              ANIVGA will round the points given to fit on a grid with mesh 16,
  2831.              that is, x1,y1,x2,y2 will be changed to be all multiples of 16.
  2832.              These new values will be stored in the (global) variables BackX1,
  2833.              BackY1, BackX2, BackY2 for further use.
  2834.              Besides that, XTiles and YTiles will hold the width and height of
  2835.              the choosen background area in tiles.
  2836.  
  2837. Note       : - You can read the Back??-variables for your information, but
  2838.                don't change them!
  2839.              - Of course, this routine only makes sense when you are going to
  2840.                use SCROLLING as background mode.
  2841.              - The upper left corner (x1,y1) will be drawn to the upper left,
  2842.                the lower right corner (x2,y2) to the lower right to fall on the
  2843.                grid.
  2844.              - Don't forget that the tile memory is limited; you can't select
  2845.                an area bigger than MaxTiles (=10000) tiles, that is more than
  2846.                2560000 pixels².
  2847.              - Possible ERROR-values returned are: Err_InvalidCoordinates and
  2848.                Err_BackgroundToBig
  2849.  
  2850. See also   : background, tiles, PutTile
  2851.  
  2852.  
  2853. SetCycleTime - procedure
  2854. ────────────────────────
  2855.  
  2856. Function   : Defines the maximum animation speed
  2857.  
  2858. Declaration: PROCEDURE SetCycleTime(milliseconds:WORD); FAR;
  2859.  
  2860. Description: There are lots of PC-compatible machines with a broad range of
  2861.              clock rates, wait states and different speeds of their graphic
  2862.              cards. With this routine you can set the time an animation cycle
  2863.              has to last at least: at the very end of Animate, the routine
  2864.              checks whether at least "milliseconds" milliseconds have been past
  2865.              since the last call to this routine and waits if necessary.
  2866.              If you give 0 milliseconds as an argument or your machine is not
  2867.              (at least) an AT class machine, there will be no such time control
  2868.              mechanism and the animation will always take part at the maximal
  2869.              speed on the specific machine (this is also the default value).
  2870.  
  2871.              For example: "SetCycleTime(100);" would restrict the animation
  2872.              rate even on the fastest 80586 machines to at most 1sec/100msec
  2873.              = ten frames per second.
  2874.  
  2875. Note (!)   : - Because there is no such high precision timer on PC/XT computers
  2876.                as required, SetCycleTime() is ignored on these machines.
  2877.                Anyway, this should be not to hard because these computers are
  2878.                normally that slow that they would not have been slowed down
  2879.                either.
  2880.              - The accuracy of this timing mechanism is better than 1 milli-
  2881.                second.
  2882.  
  2883.  
  2884. SetModeByte - procedure
  2885. ───────────────────────
  2886.  
  2887. Function   : Specifies the way a sprite will be displayed
  2888.  
  2889. Declaration: PROCEDURE SetModeByte(Sp:WORD; M:BYTE); FAR;
  2890.  
  2891. Description: This routine assigns one of the possible display methods "M"
  2892.              (Display_NORMAL, Display_FAST, Display_SHADOW,
  2893.               Display_SHADOWEXACT)
  2894.              to the specified spriteLOADnumber "Sp".
  2895.  
  2896. Note       : - Because this kind of information is stored directly inside the
  2897.                sprite data, the sprite must have been loaded already for this
  2898.                routine to work.
  2899.              - For the same reason, the routine works on spriteLOADnumbers,
  2900.                not sprite numbers (>gee, again!<): a display method set for one
  2901.                spriteLOADnumber will affect all sprites with that LOADnumber!
  2902.                Most often, that is okay (e.g.: if you use the sprite of a foot-
  2903.                ball player ten times, it is quite normal to use the same dis-
  2904.                play mode for all ten players!), if you really must use a sprite
  2905.                with two different display methods at the same time, you can use
  2906.                the following trick: load the sprite's data a second time into
  2907.                memory, using a different spriteLOADnumber. For this new copy,
  2908.                you can use another display mode.
  2909.              - Possible ERROR-values returned are: Err_InvalidSpriteNumber and
  2910.                Err_InvalidMode
  2911.  
  2912. See also   : SpriteLoadNumber, SpriteNumber, Display methods, GetModeByte
  2913.  
  2914.  
  2915. SetOffscreenTile - procedure
  2916. ────────────────────────────
  2917.  
  2918. Function   : Defines the tile to be used outside the specified scroll range
  2919.  
  2920. Declaration: PROCEDURE SetOffscreenTile(TileNr:BYTE); FAR;
  2921.  
  2922. Description: When you use background mode SCROLLING and have set up a scroll
  2923.              range (via SetBackgroundScrollRange() ), all tiles _within_ that
  2924.              region are specified by your settings done with PutTile().
  2925.              However, ANIVGA must know what to draw when it has to display
  2926.              areas _outside_ that "window": you can choose that tile with
  2927.              SetOffscreenTile().
  2928.              Example: You set your scrollable background range by issuing
  2929.              SetBackgroundScrollRange(-500,-500,1000,1000) and used PutTile()
  2930.              to define that tiles 0..10 (say) should be used inside that
  2931.              window (-500,-500,1000,1000) in some specific order. If you want
  2932.              that everything outside the window should be painted with tile
  2933.              6 (say), you would tell ANIVGA so by calling SetOffscreenTile(6)
  2934.  
  2935. Note       : - The default value set by ANIVGA is 0
  2936.              - Of course, using this procedure only makes sense when using
  2937.                background mode SCROLLING!
  2938.  
  2939. See also   : SetBackgroundScrollRange, PutTile, Background
  2940.  
  2941.  
  2942. SetPalette - procedure
  2943. ──────────────────────
  2944.  
  2945. Function   : Changes the VGA's color values
  2946.  
  2947. Declaration: PROCEDURE SetPalette(pal:Palette; update:BOOLEAN); FAR;
  2948.  
  2949. Description: You can use this procedure to change the color values of the VGA's
  2950.              256 colors by supplying an appropriate palette.
  2951.              "update" tells the procedure whether it should recompute its
  2952.              internal "ShadowTab" or not; if you use one of the two display
  2953.              modes Display_SHADOW or Display_SHADOWEXACT you must set this
  2954.              value to TRUE or the shadow areas will show "wrong" colors
  2955.              (namely the old ones *before* changing the palette). If you don't
  2956.              use shadowing (or change colors in a way so that using the old
  2957.              shadow is okay), you can use FALSE and save some time.
  2958.  
  2959. Note       : - SetPalette automatically updates "ActualColors" to reflect the
  2960.                changes made; although you don't have to use the variable
  2961.                "ActualColors" as first parameter of this procedure, you are
  2962.                recommended to do so, that is
  2963.                 a) make your color changes to ActualColors[]
  2964.                 b) call SetPalette(ActualColors,TRUE|FALSE)
  2965.                This way, you will save some time and the memory requirements
  2966.                for an additional palette
  2967.              - If you messed up things, use "SetPalette(DefaultColors,TRUE)" to
  2968.                return to the default values.
  2969.              - You must be in graphic mode already or strange things may happen
  2970.                (at least, you won't get the colors you intented...)
  2971.                To state in otherwise: call this routine _after_ having called
  2972.                InitGraph() and _before_ calling CloseRoutines()!
  2973.  
  2974. See also   : GetPalette, Palette, LoadPalette, ActualColors
  2975.  
  2976.  
  2977. SetShadowTab - procedure
  2978. ────────────────────────
  2979.  
  2980. Function   : Set the amount of shadowing in display modes Display_SHADOW and
  2981.              or Display_SHADOWEXACT
  2982.  
  2983. Declaration: PROCEDURE SetShadowTab(brightness:BYTE); FAR;
  2984.  
  2985. Description: Whenever a sprite is drawn in Display_SHADOW / Display_SHADOWEXACT
  2986.              mode, ANIVGA must know how much darker these shadow areas should
  2987.              be, compared with the brightness of the original (not-shadowed)
  2988.              colors.
  2989.              This data is held in the table ShadowTab and is set by default to
  2990.              70% of the colors original brightness. However, you can use this
  2991.              routine to provide more or less darker shadow areas: "brightness"
  2992.              is the percentage of the colors original brightness which shall
  2993.              remain, e.g.: brightness=0 would mean every shadow is completely
  2994.              black, brightness=100 is the original color as shadow (not darken-
  2995.              ed at all), brightness=40 will darken every color by 100-40=60%,
  2996.              etc.
  2997.  
  2998. Note (!)   : - SetShadowTab() bases its computation on the actually displayed
  2999.                colors, held in the table "ActualColors"
  3000.              - This routine takes app. 1s on an 8MHz AT. This can be quite a
  3001.                "long" time when you are in midst of a smooth animation sequence
  3002.                -or doesn't bother you at all (e.g., in the very beginning of
  3003.                your program) - this depends on your applications!
  3004.              - The argument will be only approximated: the algorithm computes
  3005.                the 256 color values needed precisely and matches them as close
  3006.                as possible to the 256 colors actually set.
  3007.                Note that the palette registers of the VGA card *won't* be
  3008.                changed at all! ANIVGA still works with the default VGA palette
  3009.                of the BIOS (or whatever values you set); what it does is
  3010.                solely creating an internal color look-up-table!
  3011.              - Possible ERROR-values returned are: Err_InvalidPercentage
  3012.  
  3013. See also   : ShadowTab, ActualColors, Display modes, SetModeByte
  3014.  
  3015.  
  3016. SetSpriteCycle - procedure
  3017. ──────────────────────────
  3018.  
  3019. Function   : Links spriteLOADnumbers together to form a sprite cycle
  3020.  
  3021. Declaration: PROCEDURE SetSpriteCycle(nr,len:WORD); FAR;
  3022.  
  3023. Description: "nr" is the first spriteLOADnumber to be included in the sprite
  3024.              cycle and "len" entries (i.e.: from "nr" to "nr+len-1") should be
  3025.              tied together.
  3026.              The routine will then set the according NextSprite[] entries to
  3027.              build this cycle: nr -> nr+1 -> nr+2 -> ... -> nr+len-1 -> nr
  3028.  
  3029. Note       : - The routine uses spriteLOADnumbers, _not_ sprite numbers!
  3030.              - If you want to link sprite(loadnumber)s which do not have conse-
  3031.                cutive (load)numbers, you must do that by setting NextSprite[]
  3032.                accordingly.
  3033.  
  3034. See also   : Sprite cycles, NextSprite
  3035.  
  3036.  
  3037. ShadowTab - "procedure"
  3038. ───────────────────────
  3039.  
  3040. Function   : Table for translating sprite colors into others
  3041.  
  3042. Declaration: PROCEDURE ShadowTab; FAR;
  3043.  
  3044. Description: If the display mode "Display_SHADOW" is set for a physical
  3045.              sprite, its colors will depend not on the values stored in the
  3046.              sprite itself, but on the values found on the screen at the place
  3047.              where the sprite shall be drawn: every pixel of the sprite will
  3048.              become darkened by substituting its corresponding color against
  3049.              the color stored in this color table. (Mode "Display_SHADOWEXACT"
  3050.              behaves the same, but shadowing will take place only at points
  3051.              with sprite color <>0 - that's the whole difference).
  3052.              At startup, this table is set to make shadows be approximately
  3053.              70% the brightness of the original colors, but you can adjust
  3054.              this with the routine SetShadowTab() if this value is not sui-
  3055.              table for your application.
  3056.              You can even supply a completely different color table (for
  3057.              special effects?).
  3058.              To do so, define an array "[0..255] of byte" (you should use the
  3059.              predefined TYPE ColorTable for this), containing for each color
  3060.              of the standard palette its substitute (e.g. setting array
  3061.              element [8]:=13 would mean: "replace every pixel in the shadow
  3062.              area with color 8 against a pixel with color 13") and overwrite
  3063.              the original color table by issuing the command
  3064.              "MOVE(my_array,@ShadowTab^,256)"
  3065.  
  3066. Note       : - Although this table is declared as a procedure, it really is
  3067.                data, not code; so don't call it!
  3068.              - There can be only _one_ color table and it is only active in
  3069.                display modes "Display_SHADOW" or "Display_SHADOWEXACT".
  3070.  
  3071. See also   : SetShadowTab, Display modes, SetModeByte
  3072.  
  3073.  
  3074. SPRITE, Spritenumbers, Spriteloadnumbers - information
  3075. ──────────────────────────────────────────────────────
  3076.  
  3077. A sprite is the basic data element used in ANIVGA. Technically spoken, it is
  3078. nothing more then a two-dimensional array of bytes which becomes copied to the
  3079. screen positions needed, but it is far more comprehensive to think about it as
  3080. a photograph of a figure which can be pasted to the screen whereever you want.
  3081. To distinguish between different sprites, we use natural numbers, but whenever
  3082. we talk about "sprites", we are somehow inaccurate:
  3083. You should notice that there are two kinds of "sprite numbers" which should
  3084. not be mixed up: one is a spriteLOAD number and represents a handle to the
  3085. (physical) sprite data, while the other (normally termed "sprite number") is
  3086. a logical number to address the sprite data.
  3087. Yet, most often it is clear from the context, which meaning is intended:
  3088. For a simple example: if you are going to animate a soccer team, you would
  3089. need 11 sprites for the player - but they all have the same shape. This means,
  3090. you only have to load one sprite (-> you need 1 spriteLOAD number), but need
  3091. 11 copies of that image to move around the screen (-> you need 11 sprite
  3092. numbers).
  3093. (See section "How ANIVGA works" for more about that)
  3094. You can design sprites with the help of the spritemaker-tool MAKES, by using
  3095. GRAB to capture and convert graphic screens from other graphic applications
  3096. or write your own tools for that (it's really not that difficult you think
  3097. it is...).
  3098.  
  3099. See also   : sprite format, How ANIVGA works
  3100.  
  3101.  
  3102. SPRITE CYCLES - information
  3103. ───────────────────────────
  3104.  
  3105. Often, you don't want to have a single picture as sprite, but a sequence of
  3106. them which should loop forever. For example, let's assume that you use a torch
  3107. as an animation object in your application and you want it to have a flicker-
  3108. ing flame.
  3109. You would start to draw 5 (say) pictures, which -repeatedly displayed one
  3110. after another- would make the impression of your flickering torch. But within
  3111. your application, you still want to handle these five different images as one
  3112. single object - namely the sprite "torch".
  3113. To do so, you can use a capability of ANIVGA, called a "sprite cycle": load
  3114. the five images as (physical) sprites and tie their loadnumbers together to
  3115. form that sequence!
  3116. The easiest way to do that would be to load the images with consecutive
  3117. numbers and use the SetSpriteCycle() procedure to form the sprite cycle (see
  3118. there).
  3119. Note that we are talking about linking spriteLOADnumbers here: when you have
  3120. built such a cycle for your torch and you want to use 10 torches in your
  3121. program, you surely want that each of them behaves the same, that is: they all
  3122. should show a flickering flame by using that sprite cycle.
  3123. For this reason, ANIVGA uses spriteLOADnumbers, so that every instantiation of
  3124. a spriteLOADnumber (i.e.: a SpriteN[]-entry) belonging to a cycle will lead to
  3125. a sprite cycle for this sprite! (Tip: in out torches example, it would be wise
  3126. to use different starting values for the 10 torches, so that they do not
  3127. flicker "in phase")
  3128. A small detail at last: if you defined a sprite cycle to be a->b->c->a->...,
  3129. and initialized a SpriteN[]-entry to "a", then the first sprite displayed at
  3130. the screen will be "b" instead of "a" - why?
  3131. Well, ANIVGA handles sprite cycles in the Animate() routine and thus has two
  3132. possibilities to update the SpriteN[]-table (by issuing a "SpriteN[] :=
  3133. NextSprite[SpriteN[]]" command): _before_ drawing the sprites or _afterwards_.
  3134. But when it does _after_ drawing the sprites, the sprites displayed on your
  3135. screen (=the old SpriteN[] values before doing the above command) are incon-
  3136. sistent to the according numbers actually held in the SpriteN[]-table!
  3137. This could lead to problems (e.g.: when you do a HitDetect() after calling
  3138. Animate()). Although this could be circumvented by a special grouping of sub-
  3139. routine calls, it is far more convenient to update the SpriteN[]-table
  3140. _before_ drawing the sprites.
  3141. The only drawback with this method is the one stated in the beginning: not the
  3142. SpriteN[]-entry supplied by you will be drawn, but its "successor"
  3143. NextSprite[SpriteN[]]!
  3144. However, most often that won't be that bad and *if* it would, you still could
  3145. compensate for it by using the sprite's predecessor (in the above example, you
  3146. would use "c", as it is the predecessor of "a", to display "a").
  3147.  
  3148.  
  3149. SPRITE FORMAT - information
  3150. ───────────────────────────
  3151.  
  3152. As already said, a sprite is nothing more then a two-dimensional array of
  3153. bytes which becomes copied to the screen positions needed.
  3154. For quick animations, the data should be stored in a format which causes few
  3155. and simple transformation steps when accessing the data, but it is hard to
  3156. keep up with that principle, because the graphic mode used is "planed".
  3157. This means that points are _not_ stored sequentially into the graphics memory,
  3158. but in a rather strange way: every 4 points use the same address, but lie in
  3159. different "bitplanes". To cut it short: clipping and drawing sprites is hell
  3160. therefore (and surely one reason why there are so less tools for this mode)
  3161. and ANIVGA uses a very special format to store a sprite (= *.COD-files):
  3162.  
  3163.       0..1   DW offset to Plane_0_Data (points with x-coord. MOD 4=0)
  3164.       2..3   DW offset to Plane_1_Data (points with x-coord. MOD 4=1)
  3165.       4..5   DW offset to Plane_2_Data (points with x-coord. MOD 4=2)
  3166.       6..7   DW offset to Plane_3_Data (points with x-coord. MOD 4=3)
  3167.       8..9   DW sprite width (DIV 4), rounded up if not dividable by 4
  3168.       10..11 DW sprite height in lines
  3169.       12..15 DB 1,2,4,8      ; constants (translate-table)
  3170.       16..17 DW SpriteLength ; length of this sprite file
  3171.       18..37 DW 10 dup(?)    ; reserved area for future use
  3172.       38..39 DB 'K','R'      ; code for "this is a sprite file"
  3173.       40     DB 1            ; version
  3174.       41     DB 0            ; default display mode (0=Display_NORMAL)
  3175.       42..43 DW offset pointer to left boundary table
  3176.       44..45 DW offset pointer to right boundary table
  3177.       46..47 DW offset pointer to top boundary table
  3178.       48..49 DW offset pointer to bottom boundary table
  3179.       50..SpriteLength-1: boundary- and plane data tables
  3180.  
  3181. (If you should wonder why all pointers are only 16 bit long: the maximal size
  3182.  of one sprite is 64k, so offset pointers are sufficient.
  3183.  Another trick is that ANIVGA loads sprites at segment boundaries; for that,
  3184.  you don't have to distinguish between "relative offsets" and "offset poin-
  3185.  ters": if normalized segment addresses (=offset part is ε [0..15]) are used
  3186.  to address sprites, the offset part is always 0, so the two terms are
  3187.  identical!)
  3188.  
  3189. The Plane_?_Data tables consist of the points of the sprite (1 pixel = 1 byte);
  3190. if the sprite width is 12 pixels (say), then each table would hold 12/4=3 bytes
  3191. for each of the sprite's rows:
  3192. Plane_0_Data = color of pixels 0,4,8 of 1. sprite row
  3193.                color of pixels 0,4,8 of 2. sprite row
  3194.                ...
  3195. Plane_1_Data = ditto, for pixels 1,5,9
  3196. Plane_2_Data = ditto, for pixels 2,6,10
  3197. Plane_3_Data = ditto, for pixels 3,7,11
  3198.  
  3199. The boundary tables hold the outermost positions of the sprite:
  3200.  The left/top/right/bottom boundary table holds the leftmost/topmost/
  3201.  rightmost/bottomost pixel of each row/column/row/column (or 16000/16000/
  3202.  -16000/-16000 if none exists), respectively:
  3203. left boundary table = leftmost pixel coordinate of 1. sprite row  (or 16000)
  3204.                       leftmost pixel coordinate of 2. sprite row  (or 16000)
  3205.                       ...
  3206. Note that each entry in the boundary tables consists of a signed integer!
  3207.  
  3208. Note also that sprites are always stored as the smallest, the figure including
  3209. box (rounded up in the x-direction to the next multiple of 4), but that the
  3210. values of the "superfluous points" stored in the plane tables doesn't matter
  3211. at all (no difference which display mode is used for the sprite!), because
  3212. ANIVGA uses only the bytes of the areas which belong to the _real_ sprite-
  3213. figure (ANIVGA determines these parts by assuming the sprite to be "horizontal
  3214. convex" and uses the boundary tables to compute them).
  3215. (Don't worry if you do not understand these technical details now --hopefully,
  3216.  you won't need them at all).
  3217.  
  3218. See also   : MAKES, Display modes, convex, sprite library
  3219.  
  3220.  
  3221. SPRITE LIBRARY - information
  3222. ────────────────────────────
  3223.  
  3224. Sprite files can be combined to sprite libraries. The main advantage of this
  3225. is that you can reduce the number of files needed for your programs drama-
  3226. tically:
  3227. A normal program will use approximately 20..40 different sprites, so that you
  3228. would have 20..40 files only for your sprites!
  3229. But ANIVGA's routine to load sprites "loadSprite()" is flexible enough to dis-
  3230. tinguish whether the file to be loaded contains one or more sprites and loads
  3231. them all.
  3232. To construct such a "sprite library" (suggested filename extension: .LIB), you
  3233. just use MSDos' COPY-command with the binary option "/B" to glue the binaries
  3234. together; for example:
  3235.  
  3236.  COPY /B sprite1.cod+d:\sprites\sprite2.cod+testspr.cod A:\mylib.lib
  3237.  
  3238. would concatenate the three sprites "sprite1.cod", "d:\sprites\sprite2.cod"
  3239. and "testspr.cod" and build the sprite library "A:\mylib.lib".
  3240.  
  3241. Note       : You can reverse this process with the UNLIB-utility.
  3242.  
  3243. See also   : UNLIB, sprite format, loadSprite
  3244.  
  3245.  
  3246. SpriteAd - variable
  3247. ───────────────────
  3248.  
  3249. Function   : Store the pointers to the sprites' data
  3250.  
  3251. Declaration: VAR SPRITEAD:ARRAY[0..LoadMAX] OF WORD;
  3252.  
  3253. Description: Whenever you load a (physical) sprite with LOADnumber xxx, ANIVGA
  3254.              stores the sprite's data somewhere in RAM and maintains a pointer
  3255.              which points to the beginning of this data as a handle to access
  3256.              the data: this handle is stored in SpriteAd[xxx] and reflects the
  3257.              segment part of the starting address of the data.
  3258.  
  3259. Note       : Don't change that data directly unless you are absolutely sure
  3260.              what you are doing!
  3261.  
  3262. See also   : LoadSprite, SPRITE, Sprite Format
  3263.  
  3264.  
  3265. SPRITEN, SPRITEX, SPRITEY - tables
  3266. ──────────────────────────────────
  3267.  
  3268. Function   : Hold the values of all sprites to be drawn in the next animation
  3269.              cycle.
  3270.  
  3271. Declaration: VAR SpriteN:ARRAY[0..NMAX] of Integer  (SpriteX/Y dto.)
  3272.  
  3273. Description: ANIVGA is based on tables: in SpriteN[] you must declare, which
  3274.              sprites shall be drawn in the next animation step. To do that,
  3275.              store the spriteLOAD number of the sprites into the SpriteN[]-
  3276.              entries; a zero indicates that the according sprite is inactive
  3277.              and should not be displayed.
  3278.              For every active sprite (SpriteN[i]<>0), a pair of virtual coor-
  3279.              dinates in the range -16000..+16000 must be specified in the
  3280.              SpriteX[i] and SpriteY[i] entries to determine the sprites' po-
  3281.              sition on the (virtual) screen.
  3282.              These coordinates will be transformed internally into real coor-
  3283.              dinates to decide whether the sprite is onscreen and has to be
  3284.              displayed or not.
  3285.  
  3286. Note       : If you have less sprites than are allowed by the system (that is:
  3287.              less than NMAX+1), your decision what table entries you use are
  3288.              arbitrary; if for example you have only two sprites, it won't
  3289.              matter, if you use SpriteN[0] for the first one and SpriteN[1]
  3290.              for the other or vice versa, or SpriteN[123] and SpriteN[310] or
  3291.              whatever valid indices you can think of - except in one point:
  3292.              the sprites are drawn in reverse order, that means SpriteN[NMAX]
  3293.              is drawn first, then SpriteN[NMAX-1] ... SpriteN[0].
  3294.              For that, if two (or more) sprites overlap each other, the one
  3295.              with the smallest index is drawn topmost and covers the other(s).
  3296.  
  3297.              For performance reasons you should observe another rule: if you
  3298.              use different display methods for different sprites then try to
  3299.              group your sprites in such a way, that sprites with the same dis-
  3300.              play method have continous indices. As an example: if the sprites
  3301.              with (load)number 1 use one method and the ones with number 2
  3302.              another, then the sequence SpriteN[]=(...2,2,2,2,2,...,1,1,1...)
  3303.              would be better than (...2,2,1,2,...,1,2,...,1,2,...).
  3304.              This is due to the fact that whenever ANIVGA has to draw a sprite
  3305.              with a display method other than the active one, it must inter-
  3306.              nally switch from one method to the other which costs some time.
  3307.  
  3308. See also   : SetModeByte
  3309.  
  3310.  
  3311. StartVirtualX, StartVirtualY - variables
  3312. ────────────────────────────────────────
  3313.  
  3314. Function   : Specify the upper left corner of the visible world
  3315.  
  3316. Declaration: CONST StartVirtualX:INTEGER=0;
  3317.                    StartVirtualY:INTEGER=0;
  3318.  
  3319. Description: When working with virtual coordinates, your screen displays only
  3320.              a very small window (320x200 points) of this "virtual screen"
  3321.              (32000x32000 points). To tell ANIVGA which part of this virtual
  3322.              screen is to be displayed, you specify the upper left corner of
  3323.              the visible part in (StartVirtualX,StartVirtualY).
  3324.              For example, setting (StartVirtualX,StartVirtualY) to (100,1000)
  3325.              would define that the part of the virtual screen having x-coordi-
  3326.              nates ε [100..100+XMAX] and y-coordinates ε [1000..1000+YMAX] to
  3327.              be displayed.
  3328.  
  3329. Note       : Setting these variables doesn't affect the HitDetect-function: if
  3330.              two sprites collide outside the visible area, it will be detec-
  3331.              ted, still.
  3332.  
  3333. See also   : coordinates
  3334.  
  3335.  
  3336. Table - TYPE
  3337. ────────────
  3338.  
  3339. Function   : Supply a data type for the animation variables
  3340.  
  3341. Declaration: TYPE Table=ARRAY[0..NMAX] OF INTEGER;
  3342.  
  3343. Description: A lot of variables in ANIVGA have to be of type "one entry for
  3344.              each sprite" and "Table" is the appropriate form for that.
  3345.  
  3346. Note       : -
  3347.  
  3348. See also   : SpriteX, SpriteY, SpriteN
  3349.  
  3350.  
  3351. Tile - information
  3352. ──────────────────
  3353.  
  3354. "Tiles" are graphic images, 16 pixels wide and high. They are used to define a
  3355. scrollable background image when you use SCROLLING as background mode.
  3356. Due to memory limitations, it is impossible to hold a complete background
  3357. image in memory (because virtual coordinates range 32000 pixels in x/y-direc-
  3358. tions, one would need app. 977 MB (!) RAM for that).
  3359. Instead, you may define up to 256 different tiles and then combine them to
  3360. form the graphic background, which may consist of up to MaxTiles (=10000)
  3361. tiles (using the 256 different tiles).
  3362. (A simple example for that can be found by "Background").
  3363. ANIVGA stores tiles in a slightly different format then sprites internally,
  3364. but you don't have to bother your head about that: on disk, tiles have the
  3365. same format as sprites, so you can use all the utility programs to create/edit
  3366. sprites also to create/edit tiles! The only restriction you have to care about
  3367. is, that a tile has the definite size of 16 pixels in each direction (but see
  3368. the LoadTile()-function for some simplifications about even that).
  3369.  
  3370. See also   : Background, LoadTile
  3371.  
  3372.  
  3373. TRANSLAT - utility
  3374. ──────────────────
  3375.  
  3376. I hate doing work twice - that's why I have bought a PC! And it is the reason
  3377. why... a) I invented TRANSLAT
  3378.        b) I'll just *cite* a few words from my own docs to TRANSLAT here:
  3379.  
  3380. >TRANSLATE is a (quite dumb) translation program. It reads in a Pascal source
  3381. >file, filters out all comments and tries to translate them into another
  3382. >language by using a database "dictionary". It then writes out a new Pascal
  3383. >file with the translated comments in it.
  3384. >TRANSLATE is thought for all those programmers among us, whose native tongue
  3385. >isn't English but who realized that this is the only universal language to
  3386. >publish programs. I think most of us don't have problems to write program
  3387. >docs and other accompanying texts in English. The problem lies within the
  3388. >program sources: the comments of a program should serve two purposes: help
  3389. >YOU, the author, to remember the thoughts you had when writing these lines
  3390. >of code and second, help OTHERS to understand your program.
  3391. >As being quite close to the thinking process in the human brain, I'm sure
  3392. >that most of us are not willing to write down their program comments other
  3393. >than in their native language! But when it comes to publish the program
  3394. >sources, you'd better have them in English, as this is the only universally
  3395. >understood language.
  3396. >
  3397. >Now you could maintain a second version of the program, identical to your
  3398. >original, but with all comments translated to English -- but >uaaah!< if you
  3399. >ever had to manage the consistency of two program versions of an evolving
  3400. >project, you _surely_ know that this is like putting the plagues back into
  3401. >Pandora's box!
  3402. >So why not setting up a database for your comments and then run a program
  3403. >which translates these comments? Well, TRANSLATE is exactly that program!
  3404.  
  3405. Creating such dictionaries doesn't have to concern you (not until you would
  3406. like to use it for your own sources; if so then drop me a note) -- just use
  3407. it:
  3408.        TRANSLAT ANIVGA.PAS ANIVGA.NEW ANIVGA.DIC
  3409.  
  3410. ...will create an English version of ANIVGA, named ANIVGA.NEW!
  3411. (It takes quite a long time (~1h) for this, so if you have a multitasking en-
  3412.  vironment, then run it in the background!)
  3413. If everything worked and ANIVGA.NEW compiles ok, then you can use ANIVGA.NEW
  3414. to replace the German version ANIVGA.PAS (and delete TRANSLAT.EXE and
  3415. ANIVGA.DIC).
  3416.  
  3417. Note       : - You can use _the same_ dictionary to translate ANIVGA V1.0, too
  3418.              - I didn't publish the complete TRANSLAT-package til now; con-
  3419.                sider the version included a "working α-version": it is just
  3420.                intended for the above command line. You are free to experi-
  3421.                ment with it, but if you ruin your system, don't say I didn't
  3422.                warn you! B-p
  3423.  
  3424.  
  3425. UNLIB - utility
  3426. ───────────────
  3427.  
  3428. Sometimes, you will want to reverse the process of building a sprite library,
  3429. that is: you want to split a sprite library into the sprite files of which it
  3430. consists.
  3431. To do that, call UNLIB with the name of the sprite library to split. UNLIB
  3432. will then create the files UNLIB000.COD, UNLIB001.COD, UNLIB002.COD,...  which
  3433. represent the sprite files wanted.
  3434. Note here that UNLIB cannot restore the original filenames you used (there is
  3435. no such entry in a sprite's header). For that, it is a good idea to write down
  3436. the names and sequence of the sprite files used in building a sprite library.
  3437. (If you didn't, you still can load every extracted sprite with MAKES, look at
  3438.  it and give it the right name then)
  3439.  
  3440. See also   : sprite library, MAKES, sprite format
  3441.  
  3442.  
  3443. VIRTUAL COORDINATES - information
  3444. ─────────────────────────────────
  3445.  
  3446. See        : coordinates
  3447.  
  3448.  
  3449. WriteBackgroundPage - procedure
  3450. ───────────────────────────────
  3451.  
  3452. Function   : Saves the background image to disk
  3453.  
  3454. Declaration: PROCEDURE WriteBackgroundPage(name:STRING); FAR;
  3455.  
  3456. Description: This is merely a shortcut of the WritePage()-procedure (see
  3457.              there), i.e. WritePage(name; BACKGNDPAGE) would do an equivalent
  3458.              job.
  3459.  
  3460. Note       : Possible ERROR-values returned are Err_FileIO
  3461.  
  3462. See also   : WritePage
  3463.  
  3464.  
  3465. WritePage - procedure
  3466. ─────────────────────
  3467.  
  3468. Function   : Saves a graphic page to disk
  3469.  
  3470. Declaration: PROCEDURE WritePage(name:STRING; pa:BYTE); FAR;
  3471.  
  3472. Description: To save an image of one of the drawing pages (0 or 1) or the
  3473.              backgroundpage BACKGNDPAGE (=2), specify the approriate page
  3474.              number in "pa" and a valid MSDOS-path/name where to store the
  3475.              data in "name".
  3476.  
  3477. Note       : - Make sure that your disk has enough space to hold the data: one
  3478.                page is stored as 64003 bytes!
  3479.              - You can't use this procedure for saving the background page
  3480.                "pa"=SCROLLPAGE in background mode SCROLLING!
  3481.              - Possible ERROR-values returned are: Err_InvalidPageNumber and
  3482.                Err_FileIO
  3483.  
  3484. See also   : WriteBackgroundPage, LoadPage
  3485.  
  3486.  
  3487. XMAX - constant
  3488. ───────────────
  3489.  
  3490. Function   : Specifies the maximal absolute x-coordinate
  3491.  
  3492. Declaration: CONST XMAX=319
  3493.  
  3494. Description: XMAX is the biggest _absolute_ coordinate in the x-direction
  3495.              which can be used: all x-coordinates must lie in the range
  3496.              0..XMAX.
  3497.  
  3498. Note       : Probably, you will never use this constant at all, because nearly
  3499.              everything in ANIVGA's user interface works with _virtual_ coor-
  3500.              dinates, but who can tell...
  3501.  
  3502. See also   : YMAX, coordinates
  3503.  
  3504.  
  3505. XTiles - variable
  3506. ─────────────────
  3507.  
  3508. Function   : Holds the width of the scrollable background image in tiles
  3509.  
  3510. Declaration: VAR XTiles:INTEGER;
  3511.  
  3512. Description: When using background mode SCROLLING, you have to specify the
  3513.              size of your scrolling background area (with the
  3514.              SetBackgroundScrollRange()-procedure). ANIVGA adjusts these
  3515.              values slightly and computes the size of the resulting background
  3516.              image in tiles.
  3517.          The width of this area (in tiles) is then stored in XTiles.
  3518.  
  3519. Notes       : Don't change this variable directly!
  3520.  
  3521. See also   : YTiles, Background, SetBackgroundScrollRange
  3522.  
  3523.  
  3524. YMAX - constant
  3525. ───────────────
  3526.  
  3527. Function   : Specifies the maximal absolute y-coordinate
  3528.  
  3529. Declaration: CONST YMAX=199
  3530.  
  3531. Description: YMAX is the biggest _absolute_ y-coordinate which may be used,
  3532.              that is, every y-coordinate must lie in the range 0..YMAX.
  3533.  
  3534. Note       : Probably, you will never use this constant at all, because nearly
  3535.              everything in ANIVGA's user interface works with _virtual_ coor-
  3536.              dinates, but who can tell...
  3537.  
  3538. See also   : XMAX, coordinates
  3539.  
  3540.  
  3541. YTiles - variable
  3542. ─────────────────
  3543.  
  3544. Function   : Holds the height of the scrollable background image in tiles
  3545.  
  3546. Declaration: VAR YTiles:INTEGER;
  3547.  
  3548. Description: When using background mode SCROLLING, you have to specify the
  3549.              size of your scrolling background area (with the
  3550.              SetBackgroundScrollRange()-procedure). ANIVGA adjusts these
  3551.              values slightly and computes the size of the resulting background
  3552.              image in tiles.
  3553.              The height of this area (in tiles) is then stored in YTiles.
  3554.  
  3555. Notes       : Don't change this variable directly!
  3556.  
  3557. See also   : XTiles, Background, SetBackgroundScrollRange
  3558.