Home » Archimedes archive » Acorn User » AU 1996-Xmas.adf » Features » Arcade/!Gush/c/gush

Arcade/!Gush/c/gush

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-Xmas.adf » Features
Filename: Arcade/!Gush/c/gush
Read OK:
File size: 19A0 bytes
Load address: 0000
Exec address: 0000
File contents
/* Gush demo
**
** Demonstrates the object handling features of Popcorn.  If you're getting
** started with Popcorn, print this listing out and start studying it from
** main().
*/

#include <stdlib.h>

#include "DeskLib:h.File"
#include "DeskLib:h.Gfx"
#include "DeskLib:h.Kbd"
#include "DeskLib:h.SWI"

#include "Popcorn:h.Popcorn"

#define random(n) (rand() % (n))

struct object_table		 *blue_table, *yellow_table;
void   				 *blue_sprite, *yellow_sprite;

/* ball_handler and generator_handler are two typical object handlers for
** a Popcorn object.  They contain separate little if() clauses to deal
** with each condition they could be called under.  One or many of these
** conditions could be TRUE; a handler can be called for more than one
** reason at a time.
*/

void ball_handler(struct game_object *obj, union object_flags flags, void *ref)
{
  if (flags.bits.attn_plotout) /* i.e. if ball is off the screen */
  {
    if (obj->x < 0 || obj->x > 319<<12) /* Bounce x velocity */
      obj->xv = -obj->xv;
    if (obj->y < 0 || obj->y > 255<<12) /* Bounce y velocity */
    {
      obj->yv = -obj->yv;
/*
** This next line is needed to stop jittering of objects when they hit
** the bottom of the screen.  The jittering is caused by the effects of
** gravity; well, just remove this line and see what happens...
*/
      obj->y = obj->y + obj->yv;
    }
  }

/* Delete both balls if they collide; if the handler is being called for
** a collision, 'ref' will be a pointer to the other object
*/

  if (flags.bits.collide)
  {
    Popcorn_DeleteObject(obj);
    Popcorn_DeleteObject((struct game_object*) ref);
  }
}

/* generator_handler gets called every frame, and its only purpose is to
** spew balls out, so we don't need an if (obj->flags.bits.attn_every)
** clause, since it's implicit.
*/

void generator_handler(struct game_object *obj, union object_flags *flags, void *ref)
{
  struct game_object     *ball;

  if ( (rand() & 3) == 0 ) /* This makes the spewing more erratic */
    return;

  ball = Popcorn_NewObject(obj->user_data);
  if (ball == NULL) return; /* This happens when the table is full */

/* A kludge, due to the fact that there's no way you can tell from an
** object which table it's in.  A flaw in the Popcorn design; something
** to fix for next time...
**
** Seeing as the generators' sole purpose is to spew balls out, we can
** use their position and velocity as templates for new balls.  So each
** ball takes on the x,y and xv,yv attributes of the generator it comes
** from (the velocity has a small random element added).
*/

  if (obj->user_data == blue_table)
    ball->plot_id.sprite_anchor = &blue_sprite;
  else
    ball->plot_id.sprite_anchor = &yellow_sprite;

  ball->object_id = 1;
  ball->x  = obj->x;  ball->y  = obj->y;
  ball->xv = obj->xv + (random(4096)-2048);
  ball->yv = obj->yv + (random(4096)-2048);
  ball->flags.word = 0;
  ball->flags.bits.std_plot = ball->flags.bits.velocities =
    ball->flags.bits.collide = ball->flags.bits.gravity =
    ball->flags.bits.attn_plotout = 1;
  ball->handler = (object_handler) ball_handler;
  ball->size.x = ball->size.y = 8;
  ball->plot_offset.x = ball->plot_offset.y = 4;
}

int main(void)
{
  int                   frames = 1, start_time, end_time;
  struct game_object    *temp_obj;

/* Change to mode 13 with space for two screen banks (OS_Byte 114,0) */

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

/* Initialise Popcorn sprite plotter, clear screen, and make space for
** two tables, one for blue balls, one for yellow.  Then set the gravity
** on each to a moderate value (remember 4096 Popcorn units = 1 pixel)
*/

  Popcorn_ReadScreenDetails();
  Popcorn_ClearScreen(0);
  SWI(2, 0, SWI_OS_Byte, 112, 1);
  SWI(2, 0, SWI_OS_Byte, 113, 1);
  blue_table      = Popcorn_NewTable(200, TRUE);
  yellow_table    = Popcorn_NewTable(200, TRUE);
  blue_table->grav_y = yellow_table->grav_y = 256;

/* Load blue and yellow ball sprite files */

  blue_sprite     = malloc(File_Size("<Gush$Dir>.Graphics.Blue"));
  yellow_sprite   = malloc(File_Size("<Gush$Dir>.Graphics.Yellow"));
  File_LoadTo("<Gush$Dir>.Graphics.Blue", blue_sprite, NULL);
  File_LoadTo("<Gush$Dir>.Graphics.Yellow", yellow_sprite, NULL);

/* Create 'generator' objects; these are good examples of where an object
** isn't seen, but has an important job.  The generator handler is called
** every frame to spew a ball out; the effect of this is that balls appear
** from the two corners of the screen, where the generators are.
**
** N.B. Popcorn_NewObject only finds *space* for an object in a table; the
**      actual data inside the object will be garbage.  Also that the
**      tabling routines judge an object space to be empty if the object_id
**      field = 0; so this *must* contain a non-zero value when you've
**      finished creating the object.
**
**      Last thing to remember about object co-ordinates and velocities
**      is that they are stored shifted left 12 bits; so we can move things
**      around by half-pixels.  The game windows are NOT, however.
*/

  temp_obj = Popcorn_NewObject(blue_table);
  temp_obj->object_id = 1;
  temp_obj->flags.word = 0;
  temp_obj->flags.bits.attn_every = 1;
  temp_obj->x  = temp_obj->y  = 10<<12;
  temp_obj->xv = temp_obj->yv = 4096;
  temp_obj->handler = (object_handler) generator_handler;
  temp_obj->user_data = blue_table;

  temp_obj = Popcorn_NewObject(yellow_table);
  temp_obj->object_id = 1;
  temp_obj->flags.word = 0;
  temp_obj->flags.bits.attn_every = 1;
  temp_obj->x  = 309<<12; temp_obj->y  = 10<<12;
  temp_obj->xv = -4096; temp_obj->yv = 4096;
  temp_obj->handler = (object_handler) generator_handler;
  temp_obj->user_data = yellow_table;

/* Main loop; this is similar to the 'spotlight' demo in that it uses the
** speed compensation techniques mentioned last month.  Popcorn_Process
** calls the relevant objects' handlers when they need attention; see the
** definitions above for what each handler does.
*/

  do {
    SWI(0, 1, SWI_OS_ReadMonotonicTime, &start_time);
    Popcorn_ClearScreen(0);
    Popcorn_Process(blue_table, TRUE, frames);
    Popcorn_Process(yellow_table, TRUE, frames);
    Popcorn_CollisionCheck(blue_table, yellow_table);
    do
    {
      SWI(0, 1, SWI_OS_ReadMonotonicTime, &end_time);
      frames = (end_time - start_time) >> 1;
    } while (frames == 0);
    SWI(1, 0, SWI_OS_Byte, 19);
    Popcorn_SwapBanks();
  } while (!(Kbd_KeyDown(-113) && Kbd_KeyDown(-2)));

  return(0);
}
00000000  2f 2a 20 47 75 73 68 20  64 65 6d 6f 0a 2a 2a 0a  |/* Gush demo.**.|
00000010  2a 2a 20 44 65 6d 6f 6e  73 74 72 61 74 65 73 20  |** Demonstrates |
00000020  74 68 65 20 6f 62 6a 65  63 74 20 68 61 6e 64 6c  |the object handl|
00000030  69 6e 67 20 66 65 61 74  75 72 65 73 20 6f 66 20  |ing features of |
00000040  50 6f 70 63 6f 72 6e 2e  20 20 49 66 20 79 6f 75  |Popcorn.  If you|
00000050  27 72 65 20 67 65 74 74  69 6e 67 0a 2a 2a 20 73  |'re getting.** s|
00000060  74 61 72 74 65 64 20 77  69 74 68 20 50 6f 70 63  |tarted with Popc|
00000070  6f 72 6e 2c 20 70 72 69  6e 74 20 74 68 69 73 20  |orn, print this |
00000080  6c 69 73 74 69 6e 67 20  6f 75 74 20 61 6e 64 20  |listing out and |
00000090  73 74 61 72 74 20 73 74  75 64 79 69 6e 67 20 69  |start studying i|
000000a0  74 20 66 72 6f 6d 0a 2a  2a 20 6d 61 69 6e 28 29  |t from.** main()|
000000b0  2e 0a 2a 2f 0a 0a 23 69  6e 63 6c 75 64 65 20 3c  |..*/..#include <|
000000c0  73 74 64 6c 69 62 2e 68  3e 0a 0a 23 69 6e 63 6c  |stdlib.h>..#incl|
000000d0  75 64 65 20 22 44 65 73  6b 4c 69 62 3a 68 2e 46  |ude "DeskLib:h.F|
000000e0  69 6c 65 22 0a 23 69 6e  63 6c 75 64 65 20 22 44  |ile".#include "D|
000000f0  65 73 6b 4c 69 62 3a 68  2e 47 66 78 22 0a 23 69  |eskLib:h.Gfx".#i|
00000100  6e 63 6c 75 64 65 20 22  44 65 73 6b 4c 69 62 3a  |nclude "DeskLib:|
00000110  68 2e 4b 62 64 22 0a 23  69 6e 63 6c 75 64 65 20  |h.Kbd".#include |
00000120  22 44 65 73 6b 4c 69 62  3a 68 2e 53 57 49 22 0a  |"DeskLib:h.SWI".|
00000130  0a 23 69 6e 63 6c 75 64  65 20 22 50 6f 70 63 6f  |.#include "Popco|
00000140  72 6e 3a 68 2e 50 6f 70  63 6f 72 6e 22 0a 0a 23  |rn:h.Popcorn"..#|
00000150  64 65 66 69 6e 65 20 72  61 6e 64 6f 6d 28 6e 29  |define random(n)|
00000160  20 28 72 61 6e 64 28 29  20 25 20 28 6e 29 29 0a  | (rand() % (n)).|
00000170  0a 73 74 72 75 63 74 20  6f 62 6a 65 63 74 5f 74  |.struct object_t|
00000180  61 62 6c 65 09 09 20 2a  62 6c 75 65 5f 74 61 62  |able.. *blue_tab|
00000190  6c 65 2c 20 2a 79 65 6c  6c 6f 77 5f 74 61 62 6c  |le, *yellow_tabl|
000001a0  65 3b 0a 76 6f 69 64 20  20 20 09 09 09 09 20 2a  |e;.void   .... *|
000001b0  62 6c 75 65 5f 73 70 72  69 74 65 2c 20 2a 79 65  |blue_sprite, *ye|
000001c0  6c 6c 6f 77 5f 73 70 72  69 74 65 3b 0a 0a 2f 2a  |llow_sprite;../*|
000001d0  20 62 61 6c 6c 5f 68 61  6e 64 6c 65 72 20 61 6e  | ball_handler an|
000001e0  64 20 67 65 6e 65 72 61  74 6f 72 5f 68 61 6e 64  |d generator_hand|
000001f0  6c 65 72 20 61 72 65 20  74 77 6f 20 74 79 70 69  |ler are two typi|
00000200  63 61 6c 20 6f 62 6a 65  63 74 20 68 61 6e 64 6c  |cal object handl|
00000210  65 72 73 20 66 6f 72 0a  2a 2a 20 61 20 50 6f 70  |ers for.** a Pop|
00000220  63 6f 72 6e 20 6f 62 6a  65 63 74 2e 20 20 54 68  |corn object.  Th|
00000230  65 79 20 63 6f 6e 74 61  69 6e 20 73 65 70 61 72  |ey contain separ|
00000240  61 74 65 20 6c 69 74 74  6c 65 20 69 66 28 29 20  |ate little if() |
00000250  63 6c 61 75 73 65 73 20  74 6f 20 64 65 61 6c 0a  |clauses to deal.|
00000260  2a 2a 20 77 69 74 68 20  65 61 63 68 20 63 6f 6e  |** with each con|
00000270  64 69 74 69 6f 6e 20 74  68 65 79 20 63 6f 75 6c  |dition they coul|
00000280  64 20 62 65 20 63 61 6c  6c 65 64 20 75 6e 64 65  |d be called unde|
00000290  72 2e 20 20 4f 6e 65 20  6f 72 20 6d 61 6e 79 20  |r.  One or many |
000002a0  6f 66 20 74 68 65 73 65  0a 2a 2a 20 63 6f 6e 64  |of these.** cond|
000002b0  69 74 69 6f 6e 73 20 63  6f 75 6c 64 20 62 65 20  |itions could be |
000002c0  54 52 55 45 3b 20 61 20  68 61 6e 64 6c 65 72 20  |TRUE; a handler |
000002d0  63 61 6e 20 62 65 20 63  61 6c 6c 65 64 20 66 6f  |can be called fo|
000002e0  72 20 6d 6f 72 65 20 74  68 61 6e 20 6f 6e 65 0a  |r more than one.|
000002f0  2a 2a 20 72 65 61 73 6f  6e 20 61 74 20 61 20 74  |** reason at a t|
00000300  69 6d 65 2e 0a 2a 2f 0a  0a 76 6f 69 64 20 62 61  |ime..*/..void ba|
00000310  6c 6c 5f 68 61 6e 64 6c  65 72 28 73 74 72 75 63  |ll_handler(struc|
00000320  74 20 67 61 6d 65 5f 6f  62 6a 65 63 74 20 2a 6f  |t game_object *o|
00000330  62 6a 2c 20 75 6e 69 6f  6e 20 6f 62 6a 65 63 74  |bj, union object|
00000340  5f 66 6c 61 67 73 20 66  6c 61 67 73 2c 20 76 6f  |_flags flags, vo|
00000350  69 64 20 2a 72 65 66 29  0a 7b 0a 20 20 69 66 20  |id *ref).{.  if |
00000360  28 66 6c 61 67 73 2e 62  69 74 73 2e 61 74 74 6e  |(flags.bits.attn|
00000370  5f 70 6c 6f 74 6f 75 74  29 20 2f 2a 20 69 2e 65  |_plotout) /* i.e|
00000380  2e 20 69 66 20 62 61 6c  6c 20 69 73 20 6f 66 66  |. if ball is off|
00000390  20 74 68 65 20 73 63 72  65 65 6e 20 2a 2f 0a 20  | the screen */. |
000003a0  20 7b 0a 20 20 20 20 69  66 20 28 6f 62 6a 2d 3e  | {.    if (obj->|
000003b0  78 20 3c 20 30 20 7c 7c  20 6f 62 6a 2d 3e 78 20  |x < 0 || obj->x |
000003c0  3e 20 33 31 39 3c 3c 31  32 29 20 2f 2a 20 42 6f  |> 319<<12) /* Bo|
000003d0  75 6e 63 65 20 78 20 76  65 6c 6f 63 69 74 79 20  |unce x velocity |
000003e0  2a 2f 0a 20 20 20 20 20  20 6f 62 6a 2d 3e 78 76  |*/.      obj->xv|
000003f0  20 3d 20 2d 6f 62 6a 2d  3e 78 76 3b 0a 20 20 20  | = -obj->xv;.   |
00000400  20 69 66 20 28 6f 62 6a  2d 3e 79 20 3c 20 30 20  | if (obj->y < 0 |
00000410  7c 7c 20 6f 62 6a 2d 3e  79 20 3e 20 32 35 35 3c  ||| obj->y > 255<|
00000420  3c 31 32 29 20 2f 2a 20  42 6f 75 6e 63 65 20 79  |<12) /* Bounce y|
00000430  20 76 65 6c 6f 63 69 74  79 20 2a 2f 0a 20 20 20  | velocity */.   |
00000440  20 7b 0a 20 20 20 20 20  20 6f 62 6a 2d 3e 79 76  | {.      obj->yv|
00000450  20 3d 20 2d 6f 62 6a 2d  3e 79 76 3b 0a 2f 2a 0a  | = -obj->yv;./*.|
00000460  2a 2a 20 54 68 69 73 20  6e 65 78 74 20 6c 69 6e  |** This next lin|
00000470  65 20 69 73 20 6e 65 65  64 65 64 20 74 6f 20 73  |e is needed to s|
00000480  74 6f 70 20 6a 69 74 74  65 72 69 6e 67 20 6f 66  |top jittering of|
00000490  20 6f 62 6a 65 63 74 73  20 77 68 65 6e 20 74 68  | objects when th|
000004a0  65 79 20 68 69 74 0a 2a  2a 20 74 68 65 20 62 6f  |ey hit.** the bo|
000004b0  74 74 6f 6d 20 6f 66 20  74 68 65 20 73 63 72 65  |ttom of the scre|
000004c0  65 6e 2e 20 20 54 68 65  20 6a 69 74 74 65 72 69  |en.  The jitteri|
000004d0  6e 67 20 69 73 20 63 61  75 73 65 64 20 62 79 20  |ng is caused by |
000004e0  74 68 65 20 65 66 66 65  63 74 73 20 6f 66 0a 2a  |the effects of.*|
000004f0  2a 20 67 72 61 76 69 74  79 3b 20 77 65 6c 6c 2c  |* gravity; well,|
00000500  20 6a 75 73 74 20 72 65  6d 6f 76 65 20 74 68 69  | just remove thi|
00000510  73 20 6c 69 6e 65 20 61  6e 64 20 73 65 65 20 77  |s line and see w|
00000520  68 61 74 20 68 61 70 70  65 6e 73 2e 2e 2e 0a 2a  |hat happens....*|
00000530  2f 0a 20 20 20 20 20 20  6f 62 6a 2d 3e 79 20 3d  |/.      obj->y =|
00000540  20 6f 62 6a 2d 3e 79 20  2b 20 6f 62 6a 2d 3e 79  | obj->y + obj->y|
00000550  76 3b 0a 20 20 20 20 7d  0a 20 20 7d 0a 0a 2f 2a  |v;.    }.  }../*|
00000560  20 44 65 6c 65 74 65 20  62 6f 74 68 20 62 61 6c  | Delete both bal|
00000570  6c 73 20 69 66 20 74 68  65 79 20 63 6f 6c 6c 69  |ls if they colli|
00000580  64 65 3b 20 69 66 20 74  68 65 20 68 61 6e 64 6c  |de; if the handl|
00000590  65 72 20 69 73 20 62 65  69 6e 67 20 63 61 6c 6c  |er is being call|
000005a0  65 64 20 66 6f 72 0a 2a  2a 20 61 20 63 6f 6c 6c  |ed for.** a coll|
000005b0  69 73 69 6f 6e 2c 20 27  72 65 66 27 20 77 69 6c  |ision, 'ref' wil|
000005c0  6c 20 62 65 20 61 20 70  6f 69 6e 74 65 72 20 74  |l be a pointer t|
000005d0  6f 20 74 68 65 20 6f 74  68 65 72 20 6f 62 6a 65  |o the other obje|
000005e0  63 74 0a 2a 2f 0a 0a 20  20 69 66 20 28 66 6c 61  |ct.*/..  if (fla|
000005f0  67 73 2e 62 69 74 73 2e  63 6f 6c 6c 69 64 65 29  |gs.bits.collide)|
00000600  0a 20 20 7b 0a 20 20 20  20 50 6f 70 63 6f 72 6e  |.  {.    Popcorn|
00000610  5f 44 65 6c 65 74 65 4f  62 6a 65 63 74 28 6f 62  |_DeleteObject(ob|
00000620  6a 29 3b 0a 20 20 20 20  50 6f 70 63 6f 72 6e 5f  |j);.    Popcorn_|
00000630  44 65 6c 65 74 65 4f 62  6a 65 63 74 28 28 73 74  |DeleteObject((st|
00000640  72 75 63 74 20 67 61 6d  65 5f 6f 62 6a 65 63 74  |ruct game_object|
00000650  2a 29 20 72 65 66 29 3b  0a 20 20 7d 0a 7d 0a 0a  |*) ref);.  }.}..|
00000660  2f 2a 20 67 65 6e 65 72  61 74 6f 72 5f 68 61 6e  |/* generator_han|
00000670  64 6c 65 72 20 67 65 74  73 20 63 61 6c 6c 65 64  |dler gets called|
00000680  20 65 76 65 72 79 20 66  72 61 6d 65 2c 20 61 6e  | every frame, an|
00000690  64 20 69 74 73 20 6f 6e  6c 79 20 70 75 72 70 6f  |d its only purpo|
000006a0  73 65 20 69 73 20 74 6f  0a 2a 2a 20 73 70 65 77  |se is to.** spew|
000006b0  20 62 61 6c 6c 73 20 6f  75 74 2c 20 73 6f 20 77  | balls out, so w|
000006c0  65 20 64 6f 6e 27 74 20  6e 65 65 64 20 61 6e 20  |e don't need an |
000006d0  69 66 20 28 6f 62 6a 2d  3e 66 6c 61 67 73 2e 62  |if (obj->flags.b|
000006e0  69 74 73 2e 61 74 74 6e  5f 65 76 65 72 79 29 0a  |its.attn_every).|
000006f0  2a 2a 20 63 6c 61 75 73  65 2c 20 73 69 6e 63 65  |** clause, since|
00000700  20 69 74 27 73 20 69 6d  70 6c 69 63 69 74 2e 0a  | it's implicit..|
00000710  2a 2f 0a 0a 76 6f 69 64  20 67 65 6e 65 72 61 74  |*/..void generat|
00000720  6f 72 5f 68 61 6e 64 6c  65 72 28 73 74 72 75 63  |or_handler(struc|
00000730  74 20 67 61 6d 65 5f 6f  62 6a 65 63 74 20 2a 6f  |t game_object *o|
00000740  62 6a 2c 20 75 6e 69 6f  6e 20 6f 62 6a 65 63 74  |bj, union object|
00000750  5f 66 6c 61 67 73 20 2a  66 6c 61 67 73 2c 20 76  |_flags *flags, v|
00000760  6f 69 64 20 2a 72 65 66  29 0a 7b 0a 20 20 73 74  |oid *ref).{.  st|
00000770  72 75 63 74 20 67 61 6d  65 5f 6f 62 6a 65 63 74  |ruct game_object|
00000780  20 20 20 20 20 2a 62 61  6c 6c 3b 0a 0a 20 20 69  |     *ball;..  i|
00000790  66 20 28 20 28 72 61 6e  64 28 29 20 26 20 33 29  |f ( (rand() & 3)|
000007a0  20 3d 3d 20 30 20 29 20  2f 2a 20 54 68 69 73 20  | == 0 ) /* This |
000007b0  6d 61 6b 65 73 20 74 68  65 20 73 70 65 77 69 6e  |makes the spewin|
000007c0  67 20 6d 6f 72 65 20 65  72 72 61 74 69 63 20 2a  |g more erratic *|
000007d0  2f 0a 20 20 20 20 72 65  74 75 72 6e 3b 0a 0a 20  |/.    return;.. |
000007e0  20 62 61 6c 6c 20 3d 20  50 6f 70 63 6f 72 6e 5f  | ball = Popcorn_|
000007f0  4e 65 77 4f 62 6a 65 63  74 28 6f 62 6a 2d 3e 75  |NewObject(obj->u|
00000800  73 65 72 5f 64 61 74 61  29 3b 0a 20 20 69 66 20  |ser_data);.  if |
00000810  28 62 61 6c 6c 20 3d 3d  20 4e 55 4c 4c 29 20 72  |(ball == NULL) r|
00000820  65 74 75 72 6e 3b 20 2f  2a 20 54 68 69 73 20 68  |eturn; /* This h|
00000830  61 70 70 65 6e 73 20 77  68 65 6e 20 74 68 65 20  |appens when the |
00000840  74 61 62 6c 65 20 69 73  20 66 75 6c 6c 20 2a 2f  |table is full */|
00000850  0a 0a 2f 2a 20 41 20 6b  6c 75 64 67 65 2c 20 64  |../* A kludge, d|
00000860  75 65 20 74 6f 20 74 68  65 20 66 61 63 74 20 74  |ue to the fact t|
00000870  68 61 74 20 74 68 65 72  65 27 73 20 6e 6f 20 77  |hat there's no w|
00000880  61 79 20 79 6f 75 20 63  61 6e 20 74 65 6c 6c 20  |ay you can tell |
00000890  66 72 6f 6d 20 61 6e 0a  2a 2a 20 6f 62 6a 65 63  |from an.** objec|
000008a0  74 20 77 68 69 63 68 20  74 61 62 6c 65 20 69 74  |t which table it|
000008b0  27 73 20 69 6e 2e 20 20  41 20 66 6c 61 77 20 69  |'s in.  A flaw i|
000008c0  6e 20 74 68 65 20 50 6f  70 63 6f 72 6e 20 64 65  |n the Popcorn de|
000008d0  73 69 67 6e 3b 20 73 6f  6d 65 74 68 69 6e 67 0a  |sign; something.|
000008e0  2a 2a 20 74 6f 20 66 69  78 20 66 6f 72 20 6e 65  |** to fix for ne|
000008f0  78 74 20 74 69 6d 65 2e  2e 2e 0a 2a 2a 0a 2a 2a  |xt time....**.**|
00000900  20 53 65 65 69 6e 67 20  61 73 20 74 68 65 20 67  | Seeing as the g|
00000910  65 6e 65 72 61 74 6f 72  73 27 20 73 6f 6c 65 20  |enerators' sole |
00000920  70 75 72 70 6f 73 65 20  69 73 20 74 6f 20 73 70  |purpose is to sp|
00000930  65 77 20 62 61 6c 6c 73  20 6f 75 74 2c 20 77 65  |ew balls out, we|
00000940  20 63 61 6e 0a 2a 2a 20  75 73 65 20 74 68 65 69  | can.** use thei|
00000950  72 20 70 6f 73 69 74 69  6f 6e 20 61 6e 64 20 76  |r position and v|
00000960  65 6c 6f 63 69 74 79 20  61 73 20 74 65 6d 70 6c  |elocity as templ|
00000970  61 74 65 73 20 66 6f 72  20 6e 65 77 20 62 61 6c  |ates for new bal|
00000980  6c 73 2e 20 20 53 6f 20  65 61 63 68 0a 2a 2a 20  |ls.  So each.** |
00000990  62 61 6c 6c 20 74 61 6b  65 73 20 6f 6e 20 74 68  |ball takes on th|
000009a0  65 20 78 2c 79 20 61 6e  64 20 78 76 2c 79 76 20  |e x,y and xv,yv |
000009b0  61 74 74 72 69 62 75 74  65 73 20 6f 66 20 74 68  |attributes of th|
000009c0  65 20 67 65 6e 65 72 61  74 6f 72 20 69 74 20 63  |e generator it c|
000009d0  6f 6d 65 73 0a 2a 2a 20  66 72 6f 6d 20 28 74 68  |omes.** from (th|
000009e0  65 20 76 65 6c 6f 63 69  74 79 20 68 61 73 20 61  |e velocity has a|
000009f0  20 73 6d 61 6c 6c 20 72  61 6e 64 6f 6d 20 65 6c  | small random el|
00000a00  65 6d 65 6e 74 20 61 64  64 65 64 29 2e 0a 2a 2f  |ement added)..*/|
00000a10  0a 0a 20 20 69 66 20 28  6f 62 6a 2d 3e 75 73 65  |..  if (obj->use|
00000a20  72 5f 64 61 74 61 20 3d  3d 20 62 6c 75 65 5f 74  |r_data == blue_t|
00000a30  61 62 6c 65 29 0a 20 20  20 20 62 61 6c 6c 2d 3e  |able).    ball->|
00000a40  70 6c 6f 74 5f 69 64 2e  73 70 72 69 74 65 5f 61  |plot_id.sprite_a|
00000a50  6e 63 68 6f 72 20 3d 20  26 62 6c 75 65 5f 73 70  |nchor = &blue_sp|
00000a60  72 69 74 65 3b 0a 20 20  65 6c 73 65 0a 20 20 20  |rite;.  else.   |
00000a70  20 62 61 6c 6c 2d 3e 70  6c 6f 74 5f 69 64 2e 73  | ball->plot_id.s|
00000a80  70 72 69 74 65 5f 61 6e  63 68 6f 72 20 3d 20 26  |prite_anchor = &|
00000a90  79 65 6c 6c 6f 77 5f 73  70 72 69 74 65 3b 0a 0a  |yellow_sprite;..|
00000aa0  20 20 62 61 6c 6c 2d 3e  6f 62 6a 65 63 74 5f 69  |  ball->object_i|
00000ab0  64 20 3d 20 31 3b 0a 20  20 62 61 6c 6c 2d 3e 78  |d = 1;.  ball->x|
00000ac0  20 20 3d 20 6f 62 6a 2d  3e 78 3b 20 20 62 61 6c  |  = obj->x;  bal|
00000ad0  6c 2d 3e 79 20 20 3d 20  6f 62 6a 2d 3e 79 3b 0a  |l->y  = obj->y;.|
00000ae0  20 20 62 61 6c 6c 2d 3e  78 76 20 3d 20 6f 62 6a  |  ball->xv = obj|
00000af0  2d 3e 78 76 20 2b 20 28  72 61 6e 64 6f 6d 28 34  |->xv + (random(4|
00000b00  30 39 36 29 2d 32 30 34  38 29 3b 0a 20 20 62 61  |096)-2048);.  ba|
00000b10  6c 6c 2d 3e 79 76 20 3d  20 6f 62 6a 2d 3e 79 76  |ll->yv = obj->yv|
00000b20  20 2b 20 28 72 61 6e 64  6f 6d 28 34 30 39 36 29  | + (random(4096)|
00000b30  2d 32 30 34 38 29 3b 0a  20 20 62 61 6c 6c 2d 3e  |-2048);.  ball->|
00000b40  66 6c 61 67 73 2e 77 6f  72 64 20 3d 20 30 3b 0a  |flags.word = 0;.|
00000b50  20 20 62 61 6c 6c 2d 3e  66 6c 61 67 73 2e 62 69  |  ball->flags.bi|
00000b60  74 73 2e 73 74 64 5f 70  6c 6f 74 20 3d 20 62 61  |ts.std_plot = ba|
00000b70  6c 6c 2d 3e 66 6c 61 67  73 2e 62 69 74 73 2e 76  |ll->flags.bits.v|
00000b80  65 6c 6f 63 69 74 69 65  73 20 3d 0a 20 20 20 20  |elocities =.    |
00000b90  62 61 6c 6c 2d 3e 66 6c  61 67 73 2e 62 69 74 73  |ball->flags.bits|
00000ba0  2e 63 6f 6c 6c 69 64 65  20 3d 20 62 61 6c 6c 2d  |.collide = ball-|
00000bb0  3e 66 6c 61 67 73 2e 62  69 74 73 2e 67 72 61 76  |>flags.bits.grav|
00000bc0  69 74 79 20 3d 0a 20 20  20 20 62 61 6c 6c 2d 3e  |ity =.    ball->|
00000bd0  66 6c 61 67 73 2e 62 69  74 73 2e 61 74 74 6e 5f  |flags.bits.attn_|
00000be0  70 6c 6f 74 6f 75 74 20  3d 20 31 3b 0a 20 20 62  |plotout = 1;.  b|
00000bf0  61 6c 6c 2d 3e 68 61 6e  64 6c 65 72 20 3d 20 28  |all->handler = (|
00000c00  6f 62 6a 65 63 74 5f 68  61 6e 64 6c 65 72 29 20  |object_handler) |
00000c10  62 61 6c 6c 5f 68 61 6e  64 6c 65 72 3b 0a 20 20  |ball_handler;.  |
00000c20  62 61 6c 6c 2d 3e 73 69  7a 65 2e 78 20 3d 20 62  |ball->size.x = b|
00000c30  61 6c 6c 2d 3e 73 69 7a  65 2e 79 20 3d 20 38 3b  |all->size.y = 8;|
00000c40  0a 20 20 62 61 6c 6c 2d  3e 70 6c 6f 74 5f 6f 66  |.  ball->plot_of|
00000c50  66 73 65 74 2e 78 20 3d  20 62 61 6c 6c 2d 3e 70  |fset.x = ball->p|
00000c60  6c 6f 74 5f 6f 66 66 73  65 74 2e 79 20 3d 20 34  |lot_offset.y = 4|
00000c70  3b 0a 7d 0a 0a 69 6e 74  20 6d 61 69 6e 28 76 6f  |;.}..int main(vo|
00000c80  69 64 29 0a 7b 0a 20 20  69 6e 74 20 20 20 20 20  |id).{.  int     |
00000c90  20 20 20 20 20 20 20 20  20 20 20 20 20 20 66 72  |              fr|
00000ca0  61 6d 65 73 20 3d 20 31  2c 20 73 74 61 72 74 5f  |ames = 1, start_|
00000cb0  74 69 6d 65 2c 20 65 6e  64 5f 74 69 6d 65 3b 0a  |time, end_time;.|
00000cc0  20 20 73 74 72 75 63 74  20 67 61 6d 65 5f 6f 62  |  struct game_ob|
00000cd0  6a 65 63 74 20 20 20 20  2a 74 65 6d 70 5f 6f 62  |ject    *temp_ob|
00000ce0  6a 3b 0a 0a 2f 2a 20 43  68 61 6e 67 65 20 74 6f  |j;../* Change to|
00000cf0  20 6d 6f 64 65 20 31 33  20 77 69 74 68 20 73 70  | mode 13 with sp|
00000d00  61 63 65 20 66 6f 72 20  74 77 6f 20 73 63 72 65  |ace for two scre|
00000d10  65 6e 20 62 61 6e 6b 73  20 28 4f 53 5f 42 79 74  |en banks (OS_Byt|
00000d20  65 20 31 31 34 2c 30 29  20 2a 2f 0a 0a 20 20 53  |e 114,0) */..  S|
00000d30  57 49 28 32 2c 20 30 2c  20 53 57 49 5f 4f 53 5f  |WI(2, 0, SWI_OS_|
00000d40  42 79 74 65 2c 20 31 31  34 2c 20 30 29 3b 0a 20  |Byte, 114, 0);. |
00000d50  20 47 46 58 5f 4d 6f 64  65 28 31 33 29 3b 0a 20  | GFX_Mode(13);. |
00000d60  20 53 57 49 28 30 2c 20  30 2c 20 53 57 49 5f 4f  | SWI(0, 0, SWI_O|
00000d70  53 5f 52 65 6d 6f 76 65  43 75 72 73 6f 72 73 29  |S_RemoveCursors)|
00000d80  3b 0a 20 20 53 57 49 28  32 2c 20 30 2c 20 53 57  |;.  SWI(2, 0, SW|
00000d90  49 5f 4f 53 5f 42 79 74  65 2c 20 32 32 39 2c 20  |I_OS_Byte, 229, |
00000da0  31 29 3b 0a 0a 2f 2a 20  49 6e 69 74 69 61 6c 69  |1);../* Initiali|
00000db0  73 65 20 50 6f 70 63 6f  72 6e 20 73 70 72 69 74  |se Popcorn sprit|
00000dc0  65 20 70 6c 6f 74 74 65  72 2c 20 63 6c 65 61 72  |e plotter, clear|
00000dd0  20 73 63 72 65 65 6e 2c  20 61 6e 64 20 6d 61 6b  | screen, and mak|
00000de0  65 20 73 70 61 63 65 20  66 6f 72 0a 2a 2a 20 74  |e space for.** t|
00000df0  77 6f 20 74 61 62 6c 65  73 2c 20 6f 6e 65 20 66  |wo tables, one f|
00000e00  6f 72 20 62 6c 75 65 20  62 61 6c 6c 73 2c 20 6f  |or blue balls, o|
00000e10  6e 65 20 66 6f 72 20 79  65 6c 6c 6f 77 2e 20 20  |ne for yellow.  |
00000e20  54 68 65 6e 20 73 65 74  20 74 68 65 20 67 72 61  |Then set the gra|
00000e30  76 69 74 79 0a 2a 2a 20  6f 6e 20 65 61 63 68 20  |vity.** on each |
00000e40  74 6f 20 61 20 6d 6f 64  65 72 61 74 65 20 76 61  |to a moderate va|
00000e50  6c 75 65 20 28 72 65 6d  65 6d 62 65 72 20 34 30  |lue (remember 40|
00000e60  39 36 20 50 6f 70 63 6f  72 6e 20 75 6e 69 74 73  |96 Popcorn units|
00000e70  20 3d 20 31 20 70 69 78  65 6c 29 0a 2a 2f 0a 0a  | = 1 pixel).*/..|
00000e80  20 20 50 6f 70 63 6f 72  6e 5f 52 65 61 64 53 63  |  Popcorn_ReadSc|
00000e90  72 65 65 6e 44 65 74 61  69 6c 73 28 29 3b 0a 20  |reenDetails();. |
00000ea0  20 50 6f 70 63 6f 72 6e  5f 43 6c 65 61 72 53 63  | Popcorn_ClearSc|
00000eb0  72 65 65 6e 28 30 29 3b  0a 20 20 53 57 49 28 32  |reen(0);.  SWI(2|
00000ec0  2c 20 30 2c 20 53 57 49  5f 4f 53 5f 42 79 74 65  |, 0, SWI_OS_Byte|
00000ed0  2c 20 31 31 32 2c 20 31  29 3b 0a 20 20 53 57 49  |, 112, 1);.  SWI|
00000ee0  28 32 2c 20 30 2c 20 53  57 49 5f 4f 53 5f 42 79  |(2, 0, SWI_OS_By|
00000ef0  74 65 2c 20 31 31 33 2c  20 31 29 3b 0a 20 20 62  |te, 113, 1);.  b|
00000f00  6c 75 65 5f 74 61 62 6c  65 20 20 20 20 20 20 3d  |lue_table      =|
00000f10  20 50 6f 70 63 6f 72 6e  5f 4e 65 77 54 61 62 6c  | Popcorn_NewTabl|
00000f20  65 28 32 30 30 2c 20 54  52 55 45 29 3b 0a 20 20  |e(200, TRUE);.  |
00000f30  79 65 6c 6c 6f 77 5f 74  61 62 6c 65 20 20 20 20  |yellow_table    |
00000f40  3d 20 50 6f 70 63 6f 72  6e 5f 4e 65 77 54 61 62  |= Popcorn_NewTab|
00000f50  6c 65 28 32 30 30 2c 20  54 52 55 45 29 3b 0a 20  |le(200, TRUE);. |
00000f60  20 62 6c 75 65 5f 74 61  62 6c 65 2d 3e 67 72 61  | blue_table->gra|
00000f70  76 5f 79 20 3d 20 79 65  6c 6c 6f 77 5f 74 61 62  |v_y = yellow_tab|
00000f80  6c 65 2d 3e 67 72 61 76  5f 79 20 3d 20 32 35 36  |le->grav_y = 256|
00000f90  3b 0a 0a 2f 2a 20 4c 6f  61 64 20 62 6c 75 65 20  |;../* Load blue |
00000fa0  61 6e 64 20 79 65 6c 6c  6f 77 20 62 61 6c 6c 20  |and yellow ball |
00000fb0  73 70 72 69 74 65 20 66  69 6c 65 73 20 2a 2f 0a  |sprite files */.|
00000fc0  0a 20 20 62 6c 75 65 5f  73 70 72 69 74 65 20 20  |.  blue_sprite  |
00000fd0  20 20 20 3d 20 6d 61 6c  6c 6f 63 28 46 69 6c 65  |   = malloc(File|
00000fe0  5f 53 69 7a 65 28 22 3c  47 75 73 68 24 44 69 72  |_Size("<Gush$Dir|
00000ff0  3e 2e 47 72 61 70 68 69  63 73 2e 42 6c 75 65 22  |>.Graphics.Blue"|
00001000  29 29 3b 0a 20 20 79 65  6c 6c 6f 77 5f 73 70 72  |));.  yellow_spr|
00001010  69 74 65 20 20 20 3d 20  6d 61 6c 6c 6f 63 28 46  |ite   = malloc(F|
00001020  69 6c 65 5f 53 69 7a 65  28 22 3c 47 75 73 68 24  |ile_Size("<Gush$|
00001030  44 69 72 3e 2e 47 72 61  70 68 69 63 73 2e 59 65  |Dir>.Graphics.Ye|
00001040  6c 6c 6f 77 22 29 29 3b  0a 20 20 46 69 6c 65 5f  |llow"));.  File_|
00001050  4c 6f 61 64 54 6f 28 22  3c 47 75 73 68 24 44 69  |LoadTo("<Gush$Di|
00001060  72 3e 2e 47 72 61 70 68  69 63 73 2e 42 6c 75 65  |r>.Graphics.Blue|
00001070  22 2c 20 62 6c 75 65 5f  73 70 72 69 74 65 2c 20  |", blue_sprite, |
00001080  4e 55 4c 4c 29 3b 0a 20  20 46 69 6c 65 5f 4c 6f  |NULL);.  File_Lo|
00001090  61 64 54 6f 28 22 3c 47  75 73 68 24 44 69 72 3e  |adTo("<Gush$Dir>|
000010a0  2e 47 72 61 70 68 69 63  73 2e 59 65 6c 6c 6f 77  |.Graphics.Yellow|
000010b0  22 2c 20 79 65 6c 6c 6f  77 5f 73 70 72 69 74 65  |", yellow_sprite|
000010c0  2c 20 4e 55 4c 4c 29 3b  0a 0a 2f 2a 20 43 72 65  |, NULL);../* Cre|
000010d0  61 74 65 20 27 67 65 6e  65 72 61 74 6f 72 27 20  |ate 'generator' |
000010e0  6f 62 6a 65 63 74 73 3b  20 74 68 65 73 65 20 61  |objects; these a|
000010f0  72 65 20 67 6f 6f 64 20  65 78 61 6d 70 6c 65 73  |re good examples|
00001100  20 6f 66 20 77 68 65 72  65 20 61 6e 20 6f 62 6a  | of where an obj|
00001110  65 63 74 0a 2a 2a 20 69  73 6e 27 74 20 73 65 65  |ect.** isn't see|
00001120  6e 2c 20 62 75 74 20 68  61 73 20 61 6e 20 69 6d  |n, but has an im|
00001130  70 6f 72 74 61 6e 74 20  6a 6f 62 2e 20 20 54 68  |portant job.  Th|
00001140  65 20 67 65 6e 65 72 61  74 6f 72 20 68 61 6e 64  |e generator hand|
00001150  6c 65 72 20 69 73 20 63  61 6c 6c 65 64 0a 2a 2a  |ler is called.**|
00001160  20 65 76 65 72 79 20 66  72 61 6d 65 20 74 6f 20  | every frame to |
00001170  73 70 65 77 20 61 20 62  61 6c 6c 20 6f 75 74 3b  |spew a ball out;|
00001180  20 74 68 65 20 65 66 66  65 63 74 20 6f 66 20 74  | the effect of t|
00001190  68 69 73 20 69 73 20 74  68 61 74 20 62 61 6c 6c  |his is that ball|
000011a0  73 20 61 70 70 65 61 72  0a 2a 2a 20 66 72 6f 6d  |s appear.** from|
000011b0  20 74 68 65 20 74 77 6f  20 63 6f 72 6e 65 72 73  | the two corners|
000011c0  20 6f 66 20 74 68 65 20  73 63 72 65 65 6e 2c 20  | of the screen, |
000011d0  77 68 65 72 65 20 74 68  65 20 67 65 6e 65 72 61  |where the genera|
000011e0  74 6f 72 73 20 61 72 65  2e 0a 2a 2a 0a 2a 2a 20  |tors are..**.** |
000011f0  4e 2e 42 2e 20 50 6f 70  63 6f 72 6e 5f 4e 65 77  |N.B. Popcorn_New|
00001200  4f 62 6a 65 63 74 20 6f  6e 6c 79 20 66 69 6e 64  |Object only find|
00001210  73 20 2a 73 70 61 63 65  2a 20 66 6f 72 20 61 6e  |s *space* for an|
00001220  20 6f 62 6a 65 63 74 20  69 6e 20 61 20 74 61 62  | object in a tab|
00001230  6c 65 3b 20 74 68 65 0a  2a 2a 20 20 20 20 20 20  |le; the.**      |
00001240  61 63 74 75 61 6c 20 64  61 74 61 20 69 6e 73 69  |actual data insi|
00001250  64 65 20 74 68 65 20 6f  62 6a 65 63 74 20 77 69  |de the object wi|
00001260  6c 6c 20 62 65 20 67 61  72 62 61 67 65 2e 20 20  |ll be garbage.  |
00001270  41 6c 73 6f 20 74 68 61  74 20 74 68 65 0a 2a 2a  |Also that the.**|
00001280  20 20 20 20 20 20 74 61  62 6c 69 6e 67 20 72 6f  |      tabling ro|
00001290  75 74 69 6e 65 73 20 6a  75 64 67 65 20 61 6e 20  |utines judge an |
000012a0  6f 62 6a 65 63 74 20 73  70 61 63 65 20 74 6f 20  |object space to |
000012b0  62 65 20 65 6d 70 74 79  20 69 66 20 74 68 65 20  |be empty if the |
000012c0  6f 62 6a 65 63 74 5f 69  64 0a 2a 2a 20 20 20 20  |object_id.**    |
000012d0  20 20 66 69 65 6c 64 20  3d 20 30 3b 20 73 6f 20  |  field = 0; so |
000012e0  74 68 69 73 20 2a 6d 75  73 74 2a 20 63 6f 6e 74  |this *must* cont|
000012f0  61 69 6e 20 61 20 6e 6f  6e 2d 7a 65 72 6f 20 76  |ain a non-zero v|
00001300  61 6c 75 65 20 77 68 65  6e 20 79 6f 75 27 76 65  |alue when you've|
00001310  0a 2a 2a 20 20 20 20 20  20 66 69 6e 69 73 68 65  |.**      finishe|
00001320  64 20 63 72 65 61 74 69  6e 67 20 74 68 65 20 6f  |d creating the o|
00001330  62 6a 65 63 74 2e 0a 2a  2a 0a 2a 2a 20 20 20 20  |bject..**.**    |
00001340  20 20 4c 61 73 74 20 74  68 69 6e 67 20 74 6f 20  |  Last thing to |
00001350  72 65 6d 65 6d 62 65 72  20 61 62 6f 75 74 20 6f  |remember about o|
00001360  62 6a 65 63 74 20 63 6f  2d 6f 72 64 69 6e 61 74  |bject co-ordinat|
00001370  65 73 20 61 6e 64 20 76  65 6c 6f 63 69 74 69 65  |es and velocitie|
00001380  73 0a 2a 2a 20 20 20 20  20 20 69 73 20 74 68 61  |s.**      is tha|
00001390  74 20 74 68 65 79 20 61  72 65 20 73 74 6f 72 65  |t they are store|
000013a0  64 20 73 68 69 66 74 65  64 20 6c 65 66 74 20 31  |d shifted left 1|
000013b0  32 20 62 69 74 73 3b 20  73 6f 20 77 65 20 63 61  |2 bits; so we ca|
000013c0  6e 20 6d 6f 76 65 20 74  68 69 6e 67 73 0a 2a 2a  |n move things.**|
000013d0  20 20 20 20 20 20 61 72  6f 75 6e 64 20 62 79 20  |      around by |
000013e0  68 61 6c 66 2d 70 69 78  65 6c 73 2e 20 20 54 68  |half-pixels.  Th|
000013f0  65 20 67 61 6d 65 20 77  69 6e 64 6f 77 73 20 61  |e game windows a|
00001400  72 65 20 4e 4f 54 2c 20  68 6f 77 65 76 65 72 2e  |re NOT, however.|
00001410  0a 2a 2f 0a 0a 20 20 74  65 6d 70 5f 6f 62 6a 20  |.*/..  temp_obj |
00001420  3d 20 50 6f 70 63 6f 72  6e 5f 4e 65 77 4f 62 6a  |= Popcorn_NewObj|
00001430  65 63 74 28 62 6c 75 65  5f 74 61 62 6c 65 29 3b  |ect(blue_table);|
00001440  0a 20 20 74 65 6d 70 5f  6f 62 6a 2d 3e 6f 62 6a  |.  temp_obj->obj|
00001450  65 63 74 5f 69 64 20 3d  20 31 3b 0a 20 20 74 65  |ect_id = 1;.  te|
00001460  6d 70 5f 6f 62 6a 2d 3e  66 6c 61 67 73 2e 77 6f  |mp_obj->flags.wo|
00001470  72 64 20 3d 20 30 3b 0a  20 20 74 65 6d 70 5f 6f  |rd = 0;.  temp_o|
00001480  62 6a 2d 3e 66 6c 61 67  73 2e 62 69 74 73 2e 61  |bj->flags.bits.a|
00001490  74 74 6e 5f 65 76 65 72  79 20 3d 20 31 3b 0a 20  |ttn_every = 1;. |
000014a0  20 74 65 6d 70 5f 6f 62  6a 2d 3e 78 20 20 3d 20  | temp_obj->x  = |
000014b0  74 65 6d 70 5f 6f 62 6a  2d 3e 79 20 20 3d 20 31  |temp_obj->y  = 1|
000014c0  30 3c 3c 31 32 3b 0a 20  20 74 65 6d 70 5f 6f 62  |0<<12;.  temp_ob|
000014d0  6a 2d 3e 78 76 20 3d 20  74 65 6d 70 5f 6f 62 6a  |j->xv = temp_obj|
000014e0  2d 3e 79 76 20 3d 20 34  30 39 36 3b 0a 20 20 74  |->yv = 4096;.  t|
000014f0  65 6d 70 5f 6f 62 6a 2d  3e 68 61 6e 64 6c 65 72  |emp_obj->handler|
00001500  20 3d 20 28 6f 62 6a 65  63 74 5f 68 61 6e 64 6c  | = (object_handl|
00001510  65 72 29 20 67 65 6e 65  72 61 74 6f 72 5f 68 61  |er) generator_ha|
00001520  6e 64 6c 65 72 3b 0a 20  20 74 65 6d 70 5f 6f 62  |ndler;.  temp_ob|
00001530  6a 2d 3e 75 73 65 72 5f  64 61 74 61 20 3d 20 62  |j->user_data = b|
00001540  6c 75 65 5f 74 61 62 6c  65 3b 0a 0a 20 20 74 65  |lue_table;..  te|
00001550  6d 70 5f 6f 62 6a 20 3d  20 50 6f 70 63 6f 72 6e  |mp_obj = Popcorn|
00001560  5f 4e 65 77 4f 62 6a 65  63 74 28 79 65 6c 6c 6f  |_NewObject(yello|
00001570  77 5f 74 61 62 6c 65 29  3b 0a 20 20 74 65 6d 70  |w_table);.  temp|
00001580  5f 6f 62 6a 2d 3e 6f 62  6a 65 63 74 5f 69 64 20  |_obj->object_id |
00001590  3d 20 31 3b 0a 20 20 74  65 6d 70 5f 6f 62 6a 2d  |= 1;.  temp_obj-|
000015a0  3e 66 6c 61 67 73 2e 77  6f 72 64 20 3d 20 30 3b  |>flags.word = 0;|
000015b0  0a 20 20 74 65 6d 70 5f  6f 62 6a 2d 3e 66 6c 61  |.  temp_obj->fla|
000015c0  67 73 2e 62 69 74 73 2e  61 74 74 6e 5f 65 76 65  |gs.bits.attn_eve|
000015d0  72 79 20 3d 20 31 3b 0a  20 20 74 65 6d 70 5f 6f  |ry = 1;.  temp_o|
000015e0  62 6a 2d 3e 78 20 20 3d  20 33 30 39 3c 3c 31 32  |bj->x  = 309<<12|
000015f0  3b 20 74 65 6d 70 5f 6f  62 6a 2d 3e 79 20 20 3d  |; temp_obj->y  =|
00001600  20 31 30 3c 3c 31 32 3b  0a 20 20 74 65 6d 70 5f  | 10<<12;.  temp_|
00001610  6f 62 6a 2d 3e 78 76 20  3d 20 2d 34 30 39 36 3b  |obj->xv = -4096;|
00001620  20 74 65 6d 70 5f 6f 62  6a 2d 3e 79 76 20 3d 20  | temp_obj->yv = |
00001630  34 30 39 36 3b 0a 20 20  74 65 6d 70 5f 6f 62 6a  |4096;.  temp_obj|
00001640  2d 3e 68 61 6e 64 6c 65  72 20 3d 20 28 6f 62 6a  |->handler = (obj|
00001650  65 63 74 5f 68 61 6e 64  6c 65 72 29 20 67 65 6e  |ect_handler) gen|
00001660  65 72 61 74 6f 72 5f 68  61 6e 64 6c 65 72 3b 0a  |erator_handler;.|
00001670  20 20 74 65 6d 70 5f 6f  62 6a 2d 3e 75 73 65 72  |  temp_obj->user|
00001680  5f 64 61 74 61 20 3d 20  79 65 6c 6c 6f 77 5f 74  |_data = yellow_t|
00001690  61 62 6c 65 3b 0a 0a 2f  2a 20 4d 61 69 6e 20 6c  |able;../* Main l|
000016a0  6f 6f 70 3b 20 74 68 69  73 20 69 73 20 73 69 6d  |oop; this is sim|
000016b0  69 6c 61 72 20 74 6f 20  74 68 65 20 27 73 70 6f  |ilar to the 'spo|
000016c0  74 6c 69 67 68 74 27 20  64 65 6d 6f 20 69 6e 20  |tlight' demo in |
000016d0  74 68 61 74 20 69 74 20  75 73 65 73 20 74 68 65  |that it uses the|
000016e0  0a 2a 2a 20 73 70 65 65  64 20 63 6f 6d 70 65 6e  |.** speed compen|
000016f0  73 61 74 69 6f 6e 20 74  65 63 68 6e 69 71 75 65  |sation technique|
00001700  73 20 6d 65 6e 74 69 6f  6e 65 64 20 6c 61 73 74  |s mentioned last|
00001710  20 6d 6f 6e 74 68 2e 20  20 50 6f 70 63 6f 72 6e  | month.  Popcorn|
00001720  5f 50 72 6f 63 65 73 73  0a 2a 2a 20 63 61 6c 6c  |_Process.** call|
00001730  73 20 74 68 65 20 72 65  6c 65 76 61 6e 74 20 6f  |s the relevant o|
00001740  62 6a 65 63 74 73 27 20  68 61 6e 64 6c 65 72 73  |bjects' handlers|
00001750  20 77 68 65 6e 20 74 68  65 79 20 6e 65 65 64 20  | when they need |
00001760  61 74 74 65 6e 74 69 6f  6e 3b 20 73 65 65 20 74  |attention; see t|
00001770  68 65 0a 2a 2a 20 64 65  66 69 6e 69 74 69 6f 6e  |he.** definition|
00001780  73 20 61 62 6f 76 65 20  66 6f 72 20 77 68 61 74  |s above for what|
00001790  20 65 61 63 68 20 68 61  6e 64 6c 65 72 20 64 6f  | each handler do|
000017a0  65 73 2e 0a 2a 2f 0a 0a  20 20 64 6f 20 7b 0a 20  |es..*/..  do {. |
000017b0  20 20 20 53 57 49 28 30  2c 20 31 2c 20 53 57 49  |   SWI(0, 1, SWI|
000017c0  5f 4f 53 5f 52 65 61 64  4d 6f 6e 6f 74 6f 6e 69  |_OS_ReadMonotoni|
000017d0  63 54 69 6d 65 2c 20 26  73 74 61 72 74 5f 74 69  |cTime, &start_ti|
000017e0  6d 65 29 3b 0a 20 20 20  20 50 6f 70 63 6f 72 6e  |me);.    Popcorn|
000017f0  5f 43 6c 65 61 72 53 63  72 65 65 6e 28 30 29 3b  |_ClearScreen(0);|
00001800  0a 20 20 20 20 50 6f 70  63 6f 72 6e 5f 50 72 6f  |.    Popcorn_Pro|
00001810  63 65 73 73 28 62 6c 75  65 5f 74 61 62 6c 65 2c  |cess(blue_table,|
00001820  20 54 52 55 45 2c 20 66  72 61 6d 65 73 29 3b 0a  | TRUE, frames);.|
00001830  20 20 20 20 50 6f 70 63  6f 72 6e 5f 50 72 6f 63  |    Popcorn_Proc|
00001840  65 73 73 28 79 65 6c 6c  6f 77 5f 74 61 62 6c 65  |ess(yellow_table|
00001850  2c 20 54 52 55 45 2c 20  66 72 61 6d 65 73 29 3b  |, TRUE, frames);|
00001860  0a 20 20 20 20 50 6f 70  63 6f 72 6e 5f 43 6f 6c  |.    Popcorn_Col|
00001870  6c 69 73 69 6f 6e 43 68  65 63 6b 28 62 6c 75 65  |lisionCheck(blue|
00001880  5f 74 61 62 6c 65 2c 20  79 65 6c 6c 6f 77 5f 74  |_table, yellow_t|
00001890  61 62 6c 65 29 3b 0a 20  20 20 20 64 6f 0a 20 20  |able);.    do.  |
000018a0  20 20 7b 0a 20 20 20 20  20 20 53 57 49 28 30 2c  |  {.      SWI(0,|
000018b0  20 31 2c 20 53 57 49 5f  4f 53 5f 52 65 61 64 4d  | 1, SWI_OS_ReadM|
000018c0  6f 6e 6f 74 6f 6e 69 63  54 69 6d 65 2c 20 26 65  |onotonicTime, &e|
000018d0  6e 64 5f 74 69 6d 65 29  3b 0a 20 20 20 20 20 20  |nd_time);.      |
000018e0  66 72 61 6d 65 73 20 3d  20 28 65 6e 64 5f 74 69  |frames = (end_ti|
000018f0  6d 65 20 2d 20 73 74 61  72 74 5f 74 69 6d 65 29  |me - start_time)|
00001900  20 3e 3e 20 31 3b 0a 20  20 20 20 7d 20 77 68 69  | >> 1;.    } whi|
00001910  6c 65 20 28 66 72 61 6d  65 73 20 3d 3d 20 30 29  |le (frames == 0)|
00001920  3b 0a 20 20 20 20 53 57  49 28 31 2c 20 30 2c 20  |;.    SWI(1, 0, |
00001930  53 57 49 5f 4f 53 5f 42  79 74 65 2c 20 31 39 29  |SWI_OS_Byte, 19)|
00001940  3b 0a 20 20 20 20 50 6f  70 63 6f 72 6e 5f 53 77  |;.    Popcorn_Sw|
00001950  61 70 42 61 6e 6b 73 28  29 3b 0a 20 20 7d 20 77  |apBanks();.  } w|
00001960  68 69 6c 65 20 28 21 28  4b 62 64 5f 4b 65 79 44  |hile (!(Kbd_KeyD|
00001970  6f 77 6e 28 2d 31 31 33  29 20 26 26 20 4b 62 64  |own(-113) && Kbd|
00001980  5f 4b 65 79 44 6f 77 6e  28 2d 32 29 29 29 3b 0a  |_KeyDown(-2)));.|
00001990  0a 20 20 72 65 74 75 72  6e 28 30 29 3b 0a 7d 0a  |.  return(0);.}.|
000019a0