Home » Archimedes archive » Acorn User » AU 1996-12 B.adf » Features » Arcade/c/spotlights

Arcade/c/spotlights

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1996-12 B.adf » Features
Filename: Arcade/c/spotlights
Read OK:
File size: 0E84 bytes
Load address: 0000
Exec address: 0000
File contents
/*
** Animation demo
** Matthew Bloch, July '96
*/

#define max_circles 500

#include <stdlib.h>
#include <stdio.h>

#include "DeskLib:h.Kbd"
#include "DeskLib:h.GFX"
#include "DeskLib:h.SWI"

#include "Popcorn:h.Popcorn"

/* So that rand() now works like the BASIC RND() function */

#define random(limit) (rand() % (limit+1))

struct object {
  int x,y;
  int xvel,yvel;
  int size,svel;
  int colour;
};

int main(void)
{

/* Initialise all our variables */

  int              circles = 20, start_time, end_time, frames, c;
  struct object    circle[max_circles];
  BOOL	 	   wait_for_sync = TRUE, compensate = TRUE;

/* Switch to mode 13 (with shadow memory) and remove cursors */

  SWI(2, 0, SWI_OS_Byte, 114, 0);
  GFX_Mode(13);
  SWI(0, 0, SWI_OS_RemoveCursors);

/* This call reads in the screen base and shadow addresses and also
** initialises the routine which switches the screen banks so we can
** just change animation banks by calling swap_banks(); and not care
** too much about what's going on; see the s.plotters file for more
** information.  It's not complicated, just a couple of OS_Byte calls.
*/

  Popcorn_ReadScreenDetails();

/* Initialise circles randomly (remember to seed the random no. generator) */

  SWI(0, 1, SWI_OS_ReadMonotonicTime, &c);
  srand(c);

  for (c = 0; c != max_circles; c++)
  {
    circle[c].x    = random(320); circle[c].y    = random(256);
    circle[c].xvel = random(2); circle[c].yvel = random(2);
    circle[c].size = random(100); circle[c].svel = random(2)+1;
    circle[c].colour = random(64);
  }

/* Main animation loop, exit by pressing Escape */

  SWI(0, 1, SWI_OS_ReadMonotonicTime, &start_time);
  GFX_VDU(5); /* 'cos we're going to print text over the circles */

  while (!Kbd_KeyDown(-113))
  {
    Popcorn_ClearScreen(0); /* Colour 0, i.e. black */

/* Plot circles, converting to external co-ordinates (*4) */

    for (c = 0; c != circles; c++)
    {
      GFX_GCOL(0, circle[c].colour);
      GFX_CircleFill(circle[c].x * 4, circle[c].y * 4, circle[c].size);
    }

    GFX_Move(0,1000);
    GFX_GCOL(0, 63);
    printf("Circles (1/2): %d\nWait for vsync (Q/W): %d\nSpeed compensation (A/S): %d", circles, wait_for_sync, compensate);

/* Change flags according to keypresses */

    if (Kbd_KeyDown(-49) && circles != 1) circles--;
    if (Kbd_KeyDown(-50) && circles != max_circles) circles++;
    if (Kbd_KeyDown(-17)) wait_for_sync = FALSE;
    if (Kbd_KeyDown(-34)) wait_for_sync = TRUE;
    if (Kbd_KeyDown(-66)) compensate = FALSE;
    if (Kbd_KeyDown(-82)) compensate = TRUE;

/* Wait for vsync */

    if (wait_for_sync)
      SWI(1, 0, SWI_OS_Byte, 19);
    Popcorn_SwapBanks();

/* Work out no. of animation frames have passed by (=frames) */

    do
    {
      SWI(0, 1, SWI_OS_ReadMonotonicTime, &end_time);
      frames = ( (end_time - start_time) << 1 );
    } while (frames == 0);

/* Move circles on by specified no. of frames, remembering to restart
** the timer here, since this now counts as part of the time taken for
** the next frame.
*/

    SWI(0, 1, SWI_OS_ReadMonotonicTime, &start_time);

    if (compensate)
      while (frames > 0)
      {
        for (c = 0; c != circles; c++)
        {
          circle[c].x = circle[c].x + circle[c].xvel;
          circle[c].y = circle[c].y + circle[c].yvel;
          circle[c].size = circle[c].size + circle[c].svel;
          if (circle[c].x < 0 || circle[c].x > 320)
            circle[c].xvel = -circle[c].xvel;
          if (circle[c].y < 0 || circle[c].y > 256)
            circle[c].yvel = -circle[c].yvel;
          if (circle[c].size < 0 || circle[c].size > 100)
            circle[c].svel = -circle[c].svel;
        }
        frames--;
      }

  }
  return(0);
}
00000000  2f 2a 0a 2a 2a 20 41 6e  69 6d 61 74 69 6f 6e 20  |/*.** Animation |
00000010  64 65 6d 6f 0a 2a 2a 20  4d 61 74 74 68 65 77 20  |demo.** Matthew |
00000020  42 6c 6f 63 68 2c 20 4a  75 6c 79 20 27 39 36 0a  |Bloch, July '96.|
00000030  2a 2f 0a 0a 23 64 65 66  69 6e 65 20 6d 61 78 5f  |*/..#define max_|
00000040  63 69 72 63 6c 65 73 20  35 30 30 0a 0a 23 69 6e  |circles 500..#in|
00000050  63 6c 75 64 65 20 3c 73  74 64 6c 69 62 2e 68 3e  |clude <stdlib.h>|
00000060  0a 23 69 6e 63 6c 75 64  65 20 3c 73 74 64 69 6f  |.#include <stdio|
00000070  2e 68 3e 0a 0a 23 69 6e  63 6c 75 64 65 20 22 44  |.h>..#include "D|
00000080  65 73 6b 4c 69 62 3a 68  2e 4b 62 64 22 0a 23 69  |eskLib:h.Kbd".#i|
00000090  6e 63 6c 75 64 65 20 22  44 65 73 6b 4c 69 62 3a  |nclude "DeskLib:|
000000a0  68 2e 47 46 58 22 0a 23  69 6e 63 6c 75 64 65 20  |h.GFX".#include |
000000b0  22 44 65 73 6b 4c 69 62  3a 68 2e 53 57 49 22 0a  |"DeskLib:h.SWI".|
000000c0  0a 23 69 6e 63 6c 75 64  65 20 22 50 6f 70 63 6f  |.#include "Popco|
000000d0  72 6e 3a 68 2e 50 6f 70  63 6f 72 6e 22 0a 0a 2f  |rn:h.Popcorn"../|
000000e0  2a 20 53 6f 20 74 68 61  74 20 72 61 6e 64 28 29  |* So that rand()|
000000f0  20 6e 6f 77 20 77 6f 72  6b 73 20 6c 69 6b 65 20  | now works like |
00000100  74 68 65 20 42 41 53 49  43 20 52 4e 44 28 29 20  |the BASIC RND() |
00000110  66 75 6e 63 74 69 6f 6e  20 2a 2f 0a 0a 23 64 65  |function */..#de|
00000120  66 69 6e 65 20 72 61 6e  64 6f 6d 28 6c 69 6d 69  |fine random(limi|
00000130  74 29 20 28 72 61 6e 64  28 29 20 25 20 28 6c 69  |t) (rand() % (li|
00000140  6d 69 74 2b 31 29 29 0a  0a 73 74 72 75 63 74 20  |mit+1))..struct |
00000150  6f 62 6a 65 63 74 20 7b  0a 20 20 69 6e 74 20 78  |object {.  int x|
00000160  2c 79 3b 0a 20 20 69 6e  74 20 78 76 65 6c 2c 79  |,y;.  int xvel,y|
00000170  76 65 6c 3b 0a 20 20 69  6e 74 20 73 69 7a 65 2c  |vel;.  int size,|
00000180  73 76 65 6c 3b 0a 20 20  69 6e 74 20 63 6f 6c 6f  |svel;.  int colo|
00000190  75 72 3b 0a 7d 3b 0a 0a  69 6e 74 20 6d 61 69 6e  |ur;.};..int main|
000001a0  28 76 6f 69 64 29 0a 7b  0a 0a 2f 2a 20 49 6e 69  |(void).{../* Ini|
000001b0  74 69 61 6c 69 73 65 20  61 6c 6c 20 6f 75 72 20  |tialise all our |
000001c0  76 61 72 69 61 62 6c 65  73 20 2a 2f 0a 0a 20 20  |variables */..  |
000001d0  69 6e 74 20 20 20 20 20  20 20 20 20 20 20 20 20  |int             |
000001e0  20 63 69 72 63 6c 65 73  20 3d 20 32 30 2c 20 73  | circles = 20, s|
000001f0  74 61 72 74 5f 74 69 6d  65 2c 20 65 6e 64 5f 74  |tart_time, end_t|
00000200  69 6d 65 2c 20 66 72 61  6d 65 73 2c 20 63 3b 0a  |ime, frames, c;.|
00000210  20 20 73 74 72 75 63 74  20 6f 62 6a 65 63 74 20  |  struct object |
00000220  20 20 20 63 69 72 63 6c  65 5b 6d 61 78 5f 63 69  |   circle[max_ci|
00000230  72 63 6c 65 73 5d 3b 0a  20 20 42 4f 4f 4c 09 20  |rcles];.  BOOL. |
00000240  09 20 20 20 77 61 69 74  5f 66 6f 72 5f 73 79 6e  |.   wait_for_syn|
00000250  63 20 3d 20 54 52 55 45  2c 20 63 6f 6d 70 65 6e  |c = TRUE, compen|
00000260  73 61 74 65 20 3d 20 54  52 55 45 3b 0a 0a 2f 2a  |sate = TRUE;../*|
00000270  20 53 77 69 74 63 68 20  74 6f 20 6d 6f 64 65 20  | Switch to mode |
00000280  31 33 20 28 77 69 74 68  20 73 68 61 64 6f 77 20  |13 (with shadow |
00000290  6d 65 6d 6f 72 79 29 20  61 6e 64 20 72 65 6d 6f  |memory) and remo|
000002a0  76 65 20 63 75 72 73 6f  72 73 20 2a 2f 0a 0a 20  |ve cursors */.. |
000002b0  20 53 57 49 28 32 2c 20  30 2c 20 53 57 49 5f 4f  | SWI(2, 0, SWI_O|
000002c0  53 5f 42 79 74 65 2c 20  31 31 34 2c 20 30 29 3b  |S_Byte, 114, 0);|
000002d0  0a 20 20 47 46 58 5f 4d  6f 64 65 28 31 33 29 3b  |.  GFX_Mode(13);|
000002e0  0a 20 20 53 57 49 28 30  2c 20 30 2c 20 53 57 49  |.  SWI(0, 0, SWI|
000002f0  5f 4f 53 5f 52 65 6d 6f  76 65 43 75 72 73 6f 72  |_OS_RemoveCursor|
00000300  73 29 3b 0a 0a 2f 2a 20  54 68 69 73 20 63 61 6c  |s);../* This cal|
00000310  6c 20 72 65 61 64 73 20  69 6e 20 74 68 65 20 73  |l reads in the s|
00000320  63 72 65 65 6e 20 62 61  73 65 20 61 6e 64 20 73  |creen base and s|
00000330  68 61 64 6f 77 20 61 64  64 72 65 73 73 65 73 20  |hadow addresses |
00000340  61 6e 64 20 61 6c 73 6f  0a 2a 2a 20 69 6e 69 74  |and also.** init|
00000350  69 61 6c 69 73 65 73 20  74 68 65 20 72 6f 75 74  |ialises the rout|
00000360  69 6e 65 20 77 68 69 63  68 20 73 77 69 74 63 68  |ine which switch|
00000370  65 73 20 74 68 65 20 73  63 72 65 65 6e 20 62 61  |es the screen ba|
00000380  6e 6b 73 20 73 6f 20 77  65 20 63 61 6e 0a 2a 2a  |nks so we can.**|
00000390  20 6a 75 73 74 20 63 68  61 6e 67 65 20 61 6e 69  | just change ani|
000003a0  6d 61 74 69 6f 6e 20 62  61 6e 6b 73 20 62 79 20  |mation banks by |
000003b0  63 61 6c 6c 69 6e 67 20  73 77 61 70 5f 62 61 6e  |calling swap_ban|
000003c0  6b 73 28 29 3b 20 61 6e  64 20 6e 6f 74 20 63 61  |ks(); and not ca|
000003d0  72 65 0a 2a 2a 20 74 6f  6f 20 6d 75 63 68 20 61  |re.** too much a|
000003e0  62 6f 75 74 20 77 68 61  74 27 73 20 67 6f 69 6e  |bout what's goin|
000003f0  67 20 6f 6e 3b 20 73 65  65 20 74 68 65 20 73 2e  |g on; see the s.|
00000400  70 6c 6f 74 74 65 72 73  20 66 69 6c 65 20 66 6f  |plotters file fo|
00000410  72 20 6d 6f 72 65 0a 2a  2a 20 69 6e 66 6f 72 6d  |r more.** inform|
00000420  61 74 69 6f 6e 2e 20 20  49 74 27 73 20 6e 6f 74  |ation.  It's not|
00000430  20 63 6f 6d 70 6c 69 63  61 74 65 64 2c 20 6a 75  | complicated, ju|
00000440  73 74 20 61 20 63 6f 75  70 6c 65 20 6f 66 20 4f  |st a couple of O|
00000450  53 5f 42 79 74 65 20 63  61 6c 6c 73 2e 0a 2a 2f  |S_Byte calls..*/|
00000460  0a 0a 20 20 50 6f 70 63  6f 72 6e 5f 52 65 61 64  |..  Popcorn_Read|
00000470  53 63 72 65 65 6e 44 65  74 61 69 6c 73 28 29 3b  |ScreenDetails();|
00000480  0a 0a 2f 2a 20 49 6e 69  74 69 61 6c 69 73 65 20  |../* Initialise |
00000490  63 69 72 63 6c 65 73 20  72 61 6e 64 6f 6d 6c 79  |circles randomly|
000004a0  20 28 72 65 6d 65 6d 62  65 72 20 74 6f 20 73 65  | (remember to se|
000004b0  65 64 20 74 68 65 20 72  61 6e 64 6f 6d 20 6e 6f  |ed the random no|
000004c0  2e 20 67 65 6e 65 72 61  74 6f 72 29 20 2a 2f 0a  |. generator) */.|
000004d0  0a 20 20 53 57 49 28 30  2c 20 31 2c 20 53 57 49  |.  SWI(0, 1, SWI|
000004e0  5f 4f 53 5f 52 65 61 64  4d 6f 6e 6f 74 6f 6e 69  |_OS_ReadMonotoni|
000004f0  63 54 69 6d 65 2c 20 26  63 29 3b 0a 20 20 73 72  |cTime, &c);.  sr|
00000500  61 6e 64 28 63 29 3b 0a  0a 20 20 66 6f 72 20 28  |and(c);..  for (|
00000510  63 20 3d 20 30 3b 20 63  20 21 3d 20 6d 61 78 5f  |c = 0; c != max_|
00000520  63 69 72 63 6c 65 73 3b  20 63 2b 2b 29 0a 20 20  |circles; c++).  |
00000530  7b 0a 20 20 20 20 63 69  72 63 6c 65 5b 63 5d 2e  |{.    circle[c].|
00000540  78 20 20 20 20 3d 20 72  61 6e 64 6f 6d 28 33 32  |x    = random(32|
00000550  30 29 3b 20 63 69 72 63  6c 65 5b 63 5d 2e 79 20  |0); circle[c].y |
00000560  20 20 20 3d 20 72 61 6e  64 6f 6d 28 32 35 36 29  |   = random(256)|
00000570  3b 0a 20 20 20 20 63 69  72 63 6c 65 5b 63 5d 2e  |;.    circle[c].|
00000580  78 76 65 6c 20 3d 20 72  61 6e 64 6f 6d 28 32 29  |xvel = random(2)|
00000590  3b 20 63 69 72 63 6c 65  5b 63 5d 2e 79 76 65 6c  |; circle[c].yvel|
000005a0  20 3d 20 72 61 6e 64 6f  6d 28 32 29 3b 0a 20 20  | = random(2);.  |
000005b0  20 20 63 69 72 63 6c 65  5b 63 5d 2e 73 69 7a 65  |  circle[c].size|
000005c0  20 3d 20 72 61 6e 64 6f  6d 28 31 30 30 29 3b 20  | = random(100); |
000005d0  63 69 72 63 6c 65 5b 63  5d 2e 73 76 65 6c 20 3d  |circle[c].svel =|
000005e0  20 72 61 6e 64 6f 6d 28  32 29 2b 31 3b 0a 20 20  | random(2)+1;.  |
000005f0  20 20 63 69 72 63 6c 65  5b 63 5d 2e 63 6f 6c 6f  |  circle[c].colo|
00000600  75 72 20 3d 20 72 61 6e  64 6f 6d 28 36 34 29 3b  |ur = random(64);|
00000610  0a 20 20 7d 0a 0a 2f 2a  20 4d 61 69 6e 20 61 6e  |.  }../* Main an|
00000620  69 6d 61 74 69 6f 6e 20  6c 6f 6f 70 2c 20 65 78  |imation loop, ex|
00000630  69 74 20 62 79 20 70 72  65 73 73 69 6e 67 20 45  |it by pressing E|
00000640  73 63 61 70 65 20 2a 2f  0a 0a 20 20 53 57 49 28  |scape */..  SWI(|
00000650  30 2c 20 31 2c 20 53 57  49 5f 4f 53 5f 52 65 61  |0, 1, SWI_OS_Rea|
00000660  64 4d 6f 6e 6f 74 6f 6e  69 63 54 69 6d 65 2c 20  |dMonotonicTime, |
00000670  26 73 74 61 72 74 5f 74  69 6d 65 29 3b 0a 20 20  |&start_time);.  |
00000680  47 46 58 5f 56 44 55 28  35 29 3b 20 2f 2a 20 27  |GFX_VDU(5); /* '|
00000690  63 6f 73 20 77 65 27 72  65 20 67 6f 69 6e 67 20  |cos we're going |
000006a0  74 6f 20 70 72 69 6e 74  20 74 65 78 74 20 6f 76  |to print text ov|
000006b0  65 72 20 74 68 65 20 63  69 72 63 6c 65 73 20 2a  |er the circles *|
000006c0  2f 0a 0a 20 20 77 68 69  6c 65 20 28 21 4b 62 64  |/..  while (!Kbd|
000006d0  5f 4b 65 79 44 6f 77 6e  28 2d 31 31 33 29 29 0a  |_KeyDown(-113)).|
000006e0  20 20 7b 0a 20 20 20 20  50 6f 70 63 6f 72 6e 5f  |  {.    Popcorn_|
000006f0  43 6c 65 61 72 53 63 72  65 65 6e 28 30 29 3b 20  |ClearScreen(0); |
00000700  2f 2a 20 43 6f 6c 6f 75  72 20 30 2c 20 69 2e 65  |/* Colour 0, i.e|
00000710  2e 20 62 6c 61 63 6b 20  2a 2f 0a 0a 2f 2a 20 50  |. black */../* P|
00000720  6c 6f 74 20 63 69 72 63  6c 65 73 2c 20 63 6f 6e  |lot circles, con|
00000730  76 65 72 74 69 6e 67 20  74 6f 20 65 78 74 65 72  |verting to exter|
00000740  6e 61 6c 20 63 6f 2d 6f  72 64 69 6e 61 74 65 73  |nal co-ordinates|
00000750  20 28 2a 34 29 20 2a 2f  0a 0a 20 20 20 20 66 6f  | (*4) */..    fo|
00000760  72 20 28 63 20 3d 20 30  3b 20 63 20 21 3d 20 63  |r (c = 0; c != c|
00000770  69 72 63 6c 65 73 3b 20  63 2b 2b 29 0a 20 20 20  |ircles; c++).   |
00000780  20 7b 0a 20 20 20 20 20  20 47 46 58 5f 47 43 4f  | {.      GFX_GCO|
00000790  4c 28 30 2c 20 63 69 72  63 6c 65 5b 63 5d 2e 63  |L(0, circle[c].c|
000007a0  6f 6c 6f 75 72 29 3b 0a  20 20 20 20 20 20 47 46  |olour);.      GF|
000007b0  58 5f 43 69 72 63 6c 65  46 69 6c 6c 28 63 69 72  |X_CircleFill(cir|
000007c0  63 6c 65 5b 63 5d 2e 78  20 2a 20 34 2c 20 63 69  |cle[c].x * 4, ci|
000007d0  72 63 6c 65 5b 63 5d 2e  79 20 2a 20 34 2c 20 63  |rcle[c].y * 4, c|
000007e0  69 72 63 6c 65 5b 63 5d  2e 73 69 7a 65 29 3b 0a  |ircle[c].size);.|
000007f0  20 20 20 20 7d 0a 0a 20  20 20 20 47 46 58 5f 4d  |    }..    GFX_M|
00000800  6f 76 65 28 30 2c 31 30  30 30 29 3b 0a 20 20 20  |ove(0,1000);.   |
00000810  20 47 46 58 5f 47 43 4f  4c 28 30 2c 20 36 33 29  | GFX_GCOL(0, 63)|
00000820  3b 0a 20 20 20 20 70 72  69 6e 74 66 28 22 43 69  |;.    printf("Ci|
00000830  72 63 6c 65 73 20 28 31  2f 32 29 3a 20 25 64 5c  |rcles (1/2): %d\|
00000840  6e 57 61 69 74 20 66 6f  72 20 76 73 79 6e 63 20  |nWait for vsync |
00000850  28 51 2f 57 29 3a 20 25  64 5c 6e 53 70 65 65 64  |(Q/W): %d\nSpeed|
00000860  20 63 6f 6d 70 65 6e 73  61 74 69 6f 6e 20 28 41  | compensation (A|
00000870  2f 53 29 3a 20 25 64 22  2c 20 63 69 72 63 6c 65  |/S): %d", circle|
00000880  73 2c 20 77 61 69 74 5f  66 6f 72 5f 73 79 6e 63  |s, wait_for_sync|
00000890  2c 20 63 6f 6d 70 65 6e  73 61 74 65 29 3b 0a 0a  |, compensate);..|
000008a0  2f 2a 20 43 68 61 6e 67  65 20 66 6c 61 67 73 20  |/* Change flags |
000008b0  61 63 63 6f 72 64 69 6e  67 20 74 6f 20 6b 65 79  |according to key|
000008c0  70 72 65 73 73 65 73 20  2a 2f 0a 0a 20 20 20 20  |presses */..    |
000008d0  69 66 20 28 4b 62 64 5f  4b 65 79 44 6f 77 6e 28  |if (Kbd_KeyDown(|
000008e0  2d 34 39 29 20 26 26 20  63 69 72 63 6c 65 73 20  |-49) && circles |
000008f0  21 3d 20 31 29 20 63 69  72 63 6c 65 73 2d 2d 3b  |!= 1) circles--;|
00000900  0a 20 20 20 20 69 66 20  28 4b 62 64 5f 4b 65 79  |.    if (Kbd_Key|
00000910  44 6f 77 6e 28 2d 35 30  29 20 26 26 20 63 69 72  |Down(-50) && cir|
00000920  63 6c 65 73 20 21 3d 20  6d 61 78 5f 63 69 72 63  |cles != max_circ|
00000930  6c 65 73 29 20 63 69 72  63 6c 65 73 2b 2b 3b 0a  |les) circles++;.|
00000940  20 20 20 20 69 66 20 28  4b 62 64 5f 4b 65 79 44  |    if (Kbd_KeyD|
00000950  6f 77 6e 28 2d 31 37 29  29 20 77 61 69 74 5f 66  |own(-17)) wait_f|
00000960  6f 72 5f 73 79 6e 63 20  3d 20 46 41 4c 53 45 3b  |or_sync = FALSE;|
00000970  0a 20 20 20 20 69 66 20  28 4b 62 64 5f 4b 65 79  |.    if (Kbd_Key|
00000980  44 6f 77 6e 28 2d 33 34  29 29 20 77 61 69 74 5f  |Down(-34)) wait_|
00000990  66 6f 72 5f 73 79 6e 63  20 3d 20 54 52 55 45 3b  |for_sync = TRUE;|
000009a0  0a 20 20 20 20 69 66 20  28 4b 62 64 5f 4b 65 79  |.    if (Kbd_Key|
000009b0  44 6f 77 6e 28 2d 36 36  29 29 20 63 6f 6d 70 65  |Down(-66)) compe|
000009c0  6e 73 61 74 65 20 3d 20  46 41 4c 53 45 3b 0a 20  |nsate = FALSE;. |
000009d0  20 20 20 69 66 20 28 4b  62 64 5f 4b 65 79 44 6f  |   if (Kbd_KeyDo|
000009e0  77 6e 28 2d 38 32 29 29  20 63 6f 6d 70 65 6e 73  |wn(-82)) compens|
000009f0  61 74 65 20 3d 20 54 52  55 45 3b 0a 0a 2f 2a 20  |ate = TRUE;../* |
00000a00  57 61 69 74 20 66 6f 72  20 76 73 79 6e 63 20 2a  |Wait for vsync *|
00000a10  2f 0a 0a 20 20 20 20 69  66 20 28 77 61 69 74 5f  |/..    if (wait_|
00000a20  66 6f 72 5f 73 79 6e 63  29 0a 20 20 20 20 20 20  |for_sync).      |
00000a30  53 57 49 28 31 2c 20 30  2c 20 53 57 49 5f 4f 53  |SWI(1, 0, SWI_OS|
00000a40  5f 42 79 74 65 2c 20 31  39 29 3b 0a 20 20 20 20  |_Byte, 19);.    |
00000a50  50 6f 70 63 6f 72 6e 5f  53 77 61 70 42 61 6e 6b  |Popcorn_SwapBank|
00000a60  73 28 29 3b 0a 0a 2f 2a  20 57 6f 72 6b 20 6f 75  |s();../* Work ou|
00000a70  74 20 6e 6f 2e 20 6f 66  20 61 6e 69 6d 61 74 69  |t no. of animati|
00000a80  6f 6e 20 66 72 61 6d 65  73 20 68 61 76 65 20 70  |on frames have p|
00000a90  61 73 73 65 64 20 62 79  20 28 3d 66 72 61 6d 65  |assed by (=frame|
00000aa0  73 29 20 2a 2f 0a 0a 20  20 20 20 64 6f 0a 20 20  |s) */..    do.  |
00000ab0  20 20 7b 0a 20 20 20 20  20 20 53 57 49 28 30 2c  |  {.      SWI(0,|
00000ac0  20 31 2c 20 53 57 49 5f  4f 53 5f 52 65 61 64 4d  | 1, SWI_OS_ReadM|
00000ad0  6f 6e 6f 74 6f 6e 69 63  54 69 6d 65 2c 20 26 65  |onotonicTime, &e|
00000ae0  6e 64 5f 74 69 6d 65 29  3b 0a 20 20 20 20 20 20  |nd_time);.      |
00000af0  66 72 61 6d 65 73 20 3d  20 28 20 28 65 6e 64 5f  |frames = ( (end_|
00000b00  74 69 6d 65 20 2d 20 73  74 61 72 74 5f 74 69 6d  |time - start_tim|
00000b10  65 29 20 3c 3c 20 31 20  29 3b 0a 20 20 20 20 7d  |e) << 1 );.    }|
00000b20  20 77 68 69 6c 65 20 28  66 72 61 6d 65 73 20 3d  | while (frames =|
00000b30  3d 20 30 29 3b 0a 0a 2f  2a 20 4d 6f 76 65 20 63  |= 0);../* Move c|
00000b40  69 72 63 6c 65 73 20 6f  6e 20 62 79 20 73 70 65  |ircles on by spe|
00000b50  63 69 66 69 65 64 20 6e  6f 2e 20 6f 66 20 66 72  |cified no. of fr|
00000b60  61 6d 65 73 2c 20 72 65  6d 65 6d 62 65 72 69 6e  |ames, rememberin|
00000b70  67 20 74 6f 20 72 65 73  74 61 72 74 0a 2a 2a 20  |g to restart.** |
00000b80  74 68 65 20 74 69 6d 65  72 20 68 65 72 65 2c 20  |the timer here, |
00000b90  73 69 6e 63 65 20 74 68  69 73 20 6e 6f 77 20 63  |since this now c|
00000ba0  6f 75 6e 74 73 20 61 73  20 70 61 72 74 20 6f 66  |ounts as part of|
00000bb0  20 74 68 65 20 74 69 6d  65 20 74 61 6b 65 6e 20  | the time taken |
00000bc0  66 6f 72 0a 2a 2a 20 74  68 65 20 6e 65 78 74 20  |for.** the next |
00000bd0  66 72 61 6d 65 2e 0a 2a  2f 0a 0a 20 20 20 20 53  |frame..*/..    S|
00000be0  57 49 28 30 2c 20 31 2c  20 53 57 49 5f 4f 53 5f  |WI(0, 1, SWI_OS_|
00000bf0  52 65 61 64 4d 6f 6e 6f  74 6f 6e 69 63 54 69 6d  |ReadMonotonicTim|
00000c00  65 2c 20 26 73 74 61 72  74 5f 74 69 6d 65 29 3b  |e, &start_time);|
00000c10  0a 0a 20 20 20 20 69 66  20 28 63 6f 6d 70 65 6e  |..    if (compen|
00000c20  73 61 74 65 29 0a 20 20  20 20 20 20 77 68 69 6c  |sate).      whil|
00000c30  65 20 28 66 72 61 6d 65  73 20 3e 20 30 29 0a 20  |e (frames > 0). |
00000c40  20 20 20 20 20 7b 0a 20  20 20 20 20 20 20 20 66  |     {.        f|
00000c50  6f 72 20 28 63 20 3d 20  30 3b 20 63 20 21 3d 20  |or (c = 0; c != |
00000c60  63 69 72 63 6c 65 73 3b  20 63 2b 2b 29 0a 20 20  |circles; c++).  |
00000c70  20 20 20 20 20 20 7b 0a  20 20 20 20 20 20 20 20  |      {.        |
00000c80  20 20 63 69 72 63 6c 65  5b 63 5d 2e 78 20 3d 20  |  circle[c].x = |
00000c90  63 69 72 63 6c 65 5b 63  5d 2e 78 20 2b 20 63 69  |circle[c].x + ci|
00000ca0  72 63 6c 65 5b 63 5d 2e  78 76 65 6c 3b 0a 20 20  |rcle[c].xvel;.  |
00000cb0  20 20 20 20 20 20 20 20  63 69 72 63 6c 65 5b 63  |        circle[c|
00000cc0  5d 2e 79 20 3d 20 63 69  72 63 6c 65 5b 63 5d 2e  |].y = circle[c].|
00000cd0  79 20 2b 20 63 69 72 63  6c 65 5b 63 5d 2e 79 76  |y + circle[c].yv|
00000ce0  65 6c 3b 0a 20 20 20 20  20 20 20 20 20 20 63 69  |el;.          ci|
00000cf0  72 63 6c 65 5b 63 5d 2e  73 69 7a 65 20 3d 20 63  |rcle[c].size = c|
00000d00  69 72 63 6c 65 5b 63 5d  2e 73 69 7a 65 20 2b 20  |ircle[c].size + |
00000d10  63 69 72 63 6c 65 5b 63  5d 2e 73 76 65 6c 3b 0a  |circle[c].svel;.|
00000d20  20 20 20 20 20 20 20 20  20 20 69 66 20 28 63 69  |          if (ci|
00000d30  72 63 6c 65 5b 63 5d 2e  78 20 3c 20 30 20 7c 7c  |rcle[c].x < 0 |||
00000d40  20 63 69 72 63 6c 65 5b  63 5d 2e 78 20 3e 20 33  | circle[c].x > 3|
00000d50  32 30 29 0a 20 20 20 20  20 20 20 20 20 20 20 20  |20).            |
00000d60  63 69 72 63 6c 65 5b 63  5d 2e 78 76 65 6c 20 3d  |circle[c].xvel =|
00000d70  20 2d 63 69 72 63 6c 65  5b 63 5d 2e 78 76 65 6c  | -circle[c].xvel|
00000d80  3b 0a 20 20 20 20 20 20  20 20 20 20 69 66 20 28  |;.          if (|
00000d90  63 69 72 63 6c 65 5b 63  5d 2e 79 20 3c 20 30 20  |circle[c].y < 0 |
00000da0  7c 7c 20 63 69 72 63 6c  65 5b 63 5d 2e 79 20 3e  ||| circle[c].y >|
00000db0  20 32 35 36 29 0a 20 20  20 20 20 20 20 20 20 20  | 256).          |
00000dc0  20 20 63 69 72 63 6c 65  5b 63 5d 2e 79 76 65 6c  |  circle[c].yvel|
00000dd0  20 3d 20 2d 63 69 72 63  6c 65 5b 63 5d 2e 79 76  | = -circle[c].yv|
00000de0  65 6c 3b 0a 20 20 20 20  20 20 20 20 20 20 69 66  |el;.          if|
00000df0  20 28 63 69 72 63 6c 65  5b 63 5d 2e 73 69 7a 65  | (circle[c].size|
00000e00  20 3c 20 30 20 7c 7c 20  63 69 72 63 6c 65 5b 63  | < 0 || circle[c|
00000e10  5d 2e 73 69 7a 65 20 3e  20 31 30 30 29 0a 20 20  |].size > 100).  |
00000e20  20 20 20 20 20 20 20 20  20 20 63 69 72 63 6c 65  |          circle|
00000e30  5b 63 5d 2e 73 76 65 6c  20 3d 20 2d 63 69 72 63  |[c].svel = -circ|
00000e40  6c 65 5b 63 5d 2e 73 76  65 6c 3b 0a 20 20 20 20  |le[c].svel;.    |
00000e50  20 20 20 20 7d 0a 20 20  20 20 20 20 20 20 66 72  |    }.        fr|
00000e60  61 6d 65 73 2d 2d 3b 0a  20 20 20 20 20 20 7d 0a  |ames--;.      }.|
00000e70  0a 20 20 7d 0a 20 20 72  65 74 75 72 6e 28 30 29  |.  }.  return(0)|
00000e80  3b 0a 7d 0a                                       |;.}.|
00000e84