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

Arcade/!Gush/c/gush2

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/gush2
Read OK:
File size: 10F3 bytes
Load address: 0000
Exec address: 0000
File contents
/* Gush demo (2)
**
** Demonstrates the object handling features of Popcorn, this time with
** prototypes being used to make the code more readable, flexible etc.
*/

#include <stdlib.h>
#include <string.h>

#include "DeskLib:h.Error"
#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;

/* 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)
{
/* 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);
    return;
  }

  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;
    }
  }
}

/* This function is so much shorter because of the prototyping system */

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_NewPrototype(obj->user_data, obj->object_id, obj->x, obj->y);

  if (ball == NULL)
    return; /* This happens when the table is full */

  ball->xv = obj->xv + (random(4096)-2048);
  ball->yv = obj->yv + (random(4096)-2048);
}

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

/* Set up the address of the symbol table, load the resources, prototypes
** and the sprites.
*/

  strcpy(symbol_table_filename, "<Gush$Dir>.Data.Symbols");
  Error_CheckFatal(Popcorn_LoadResourceFile("<Gush$Dir>.Data.Resources"));
  Error_CheckFatal(Popcorn_LoadPrototypes("<Gush$Dir>.Data.Prototypes"));
  Error_CheckFatal(Popcorn_LoadGroup('LLAB'));

/* 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)
*/

  blue_table      = Popcorn_NewTable(200, TRUE);
  yellow_table    = Popcorn_NewTable(200, TRUE);
  blue_table->grav_y = yellow_table->grav_y = 256;

/* 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);

  Popcorn_ReadScreenDetails();
  Popcorn_ClearScreen(0);

/* Generator objects are now created from prototype file... easy peasy :-)
** This time their IDs are changed so that balls can be created from
** them more easily (see generator_handler above).
*/

  temp_obj = Popcorn_NewPrototype(blue_table, 'RNEG', 10<<12, 10<<12);
  temp_obj->object_id = 'EULB';
  temp_obj->xv = temp_obj->yv = 4096;
  temp_obj->user_data = blue_table;

  temp_obj = Popcorn_NewPrototype(yellow_table, 'RNEG', 309<<12, 10<<12);
  temp_obj->object_id = 'OLEY';
  temp_obj->xv = -4096; temp_obj->yv = 4096;
  temp_obj->user_data = yellow_table;

/* Main loop is unchanged */

  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 20 28 32 29  |/* Gush demo (2)|
00000010  0a 2a 2a 0a 2a 2a 20 44  65 6d 6f 6e 73 74 72 61  |.**.** Demonstra|
00000020  74 65 73 20 74 68 65 20  6f 62 6a 65 63 74 20 68  |tes the object h|
00000030  61 6e 64 6c 69 6e 67 20  66 65 61 74 75 72 65 73  |andling features|
00000040  20 6f 66 20 50 6f 70 63  6f 72 6e 2c 20 74 68 69  | of Popcorn, thi|
00000050  73 20 74 69 6d 65 20 77  69 74 68 0a 2a 2a 20 70  |s time with.** p|
00000060  72 6f 74 6f 74 79 70 65  73 20 62 65 69 6e 67 20  |rototypes being |
00000070  75 73 65 64 20 74 6f 20  6d 61 6b 65 20 74 68 65  |used to make the|
00000080  20 63 6f 64 65 20 6d 6f  72 65 20 72 65 61 64 61  | code more reada|
00000090  62 6c 65 2c 20 66 6c 65  78 69 62 6c 65 20 65 74  |ble, flexible et|
000000a0  63 2e 0a 2a 2f 0a 0a 23  69 6e 63 6c 75 64 65 20  |c..*/..#include |
000000b0  3c 73 74 64 6c 69 62 2e  68 3e 0a 23 69 6e 63 6c  |<stdlib.h>.#incl|
000000c0  75 64 65 20 3c 73 74 72  69 6e 67 2e 68 3e 0a 0a  |ude <string.h>..|
000000d0  23 69 6e 63 6c 75 64 65  20 22 44 65 73 6b 4c 69  |#include "DeskLi|
000000e0  62 3a 68 2e 45 72 72 6f  72 22 0a 23 69 6e 63 6c  |b:h.Error".#incl|
000000f0  75 64 65 20 22 44 65 73  6b 4c 69 62 3a 68 2e 46  |ude "DeskLib:h.F|
00000100  69 6c 65 22 0a 23 69 6e  63 6c 75 64 65 20 22 44  |ile".#include "D|
00000110  65 73 6b 4c 69 62 3a 68  2e 47 66 78 22 0a 23 69  |eskLib:h.Gfx".#i|
00000120  6e 63 6c 75 64 65 20 22  44 65 73 6b 4c 69 62 3a  |nclude "DeskLib:|
00000130  68 2e 4b 62 64 22 0a 23  69 6e 63 6c 75 64 65 20  |h.Kbd".#include |
00000140  22 44 65 73 6b 4c 69 62  3a 68 2e 53 57 49 22 0a  |"DeskLib:h.SWI".|
00000150  0a 23 69 6e 63 6c 75 64  65 20 22 50 6f 70 63 6f  |.#include "Popco|
00000160  72 6e 3a 68 2e 50 6f 70  63 6f 72 6e 22 0a 0a 23  |rn:h.Popcorn"..#|
00000170  64 65 66 69 6e 65 20 72  61 6e 64 6f 6d 28 6e 29  |define random(n)|
00000180  20 28 72 61 6e 64 28 29  20 25 20 28 6e 29 29 0a  | (rand() % (n)).|
00000190  0a 73 74 72 75 63 74 20  6f 62 6a 65 63 74 5f 74  |.struct object_t|
000001a0  61 62 6c 65 09 09 20 2a  62 6c 75 65 5f 74 61 62  |able.. *blue_tab|
000001b0  6c 65 2c 20 2a 79 65 6c  6c 6f 77 5f 74 61 62 6c  |le, *yellow_tabl|
000001c0  65 3b 0a 0a 2f 2a 20 62  61 6c 6c 5f 68 61 6e 64  |e;../* ball_hand|
000001d0  6c 65 72 20 61 6e 64 20  67 65 6e 65 72 61 74 6f  |ler and generato|
000001e0  72 5f 68 61 6e 64 6c 65  72 20 61 72 65 20 74 77  |r_handler are tw|
000001f0  6f 20 74 79 70 69 63 61  6c 20 6f 62 6a 65 63 74  |o typical object|
00000200  20 68 61 6e 64 6c 65 72  73 20 66 6f 72 0a 2a 2a  | handlers for.**|
00000210  20 61 20 50 6f 70 63 6f  72 6e 20 6f 62 6a 65 63  | a Popcorn objec|
00000220  74 2e 20 20 54 68 65 79  20 63 6f 6e 74 61 69 6e  |t.  They contain|
00000230  20 73 65 70 61 72 61 74  65 20 6c 69 74 74 6c 65  | separate little|
00000240  20 69 66 28 29 20 63 6c  61 75 73 65 73 20 74 6f  | if() clauses to|
00000250  20 64 65 61 6c 0a 2a 2a  20 77 69 74 68 20 65 61  | deal.** with ea|
00000260  63 68 20 63 6f 6e 64 69  74 69 6f 6e 20 74 68 65  |ch condition the|
00000270  79 20 63 6f 75 6c 64 20  62 65 20 63 61 6c 6c 65  |y could be calle|
00000280  64 20 75 6e 64 65 72 2e  20 20 4f 6e 65 20 6f 72  |d under.  One or|
00000290  20 6d 61 6e 79 20 6f 66  20 74 68 65 73 65 0a 2a  | many of these.*|
000002a0  2a 20 63 6f 6e 64 69 74  69 6f 6e 73 20 63 6f 75  |* conditions cou|
000002b0  6c 64 20 62 65 20 54 52  55 45 3b 20 61 20 68 61  |ld be TRUE; a ha|
000002c0  6e 64 6c 65 72 20 63 61  6e 20 62 65 20 63 61 6c  |ndler can be cal|
000002d0  6c 65 64 20 66 6f 72 20  6d 6f 72 65 20 74 68 61  |led for more tha|
000002e0  6e 20 6f 6e 65 0a 2a 2a  20 72 65 61 73 6f 6e 20  |n one.** reason |
000002f0  61 74 20 61 20 74 69 6d  65 2e 0a 2a 2f 0a 0a 76  |at a time..*/..v|
00000300  6f 69 64 20 62 61 6c 6c  5f 68 61 6e 64 6c 65 72  |oid ball_handler|
00000310  28 73 74 72 75 63 74 20  67 61 6d 65 5f 6f 62 6a  |(struct game_obj|
00000320  65 63 74 20 2a 6f 62 6a  2c 20 75 6e 69 6f 6e 20  |ect *obj, union |
00000330  6f 62 6a 65 63 74 5f 66  6c 61 67 73 20 66 6c 61  |object_flags fla|
00000340  67 73 2c 20 76 6f 69 64  20 2a 72 65 66 29 0a 7b  |gs, void *ref).{|
00000350  0a 2f 2a 20 44 65 6c 65  74 65 20 62 6f 74 68 20  |./* Delete both |
00000360  62 61 6c 6c 73 20 69 66  20 74 68 65 79 20 63 6f  |balls if they co|
00000370  6c 6c 69 64 65 3b 20 69  66 20 74 68 65 20 68 61  |llide; if the ha|
00000380  6e 64 6c 65 72 20 69 73  20 62 65 69 6e 67 20 63  |ndler is being c|
00000390  61 6c 6c 65 64 20 66 6f  72 0a 2a 2a 20 61 20 63  |alled for.** a c|
000003a0  6f 6c 6c 69 73 69 6f 6e  2c 20 27 72 65 66 27 20  |ollision, 'ref' |
000003b0  77 69 6c 6c 20 62 65 20  61 20 70 6f 69 6e 74 65  |will be a pointe|
000003c0  72 20 74 6f 20 74 68 65  20 6f 74 68 65 72 20 6f  |r to the other o|
000003d0  62 6a 65 63 74 0a 2a 2f  0a 0a 20 20 69 66 20 28  |bject.*/..  if (|
000003e0  66 6c 61 67 73 2e 62 69  74 73 2e 63 6f 6c 6c 69  |flags.bits.colli|
000003f0  64 65 29 0a 20 20 7b 0a  20 20 20 20 50 6f 70 63  |de).  {.    Popc|
00000400  6f 72 6e 5f 44 65 6c 65  74 65 4f 62 6a 65 63 74  |orn_DeleteObject|
00000410  28 6f 62 6a 29 3b 0a 20  20 20 20 50 6f 70 63 6f  |(obj);.    Popco|
00000420  72 6e 5f 44 65 6c 65 74  65 4f 62 6a 65 63 74 28  |rn_DeleteObject(|
00000430  28 73 74 72 75 63 74 20  67 61 6d 65 5f 6f 62 6a  |(struct game_obj|
00000440  65 63 74 2a 29 20 72 65  66 29 3b 0a 20 20 20 20  |ect*) ref);.    |
00000450  72 65 74 75 72 6e 3b 0a  20 20 7d 0a 0a 20 20 69  |return;.  }..  i|
00000460  66 20 28 66 6c 61 67 73  2e 62 69 74 73 2e 61 74  |f (flags.bits.at|
00000470  74 6e 5f 70 6c 6f 74 6f  75 74 29 20 2f 2a 20 69  |tn_plotout) /* i|
00000480  2e 65 2e 20 69 66 20 62  61 6c 6c 20 69 73 20 6f  |.e. if ball is o|
00000490  66 66 20 74 68 65 20 73  63 72 65 65 6e 20 2a 2f  |ff the screen */|
000004a0  0a 20 20 7b 0a 20 20 20  20 69 66 20 28 6f 62 6a  |.  {.    if (obj|
000004b0  2d 3e 78 20 3c 20 30 20  7c 7c 20 6f 62 6a 2d 3e  |->x < 0 || obj->|
000004c0  78 20 3e 20 33 31 39 3c  3c 31 32 29 20 2f 2a 20  |x > 319<<12) /* |
000004d0  42 6f 75 6e 63 65 20 78  20 76 65 6c 6f 63 69 74  |Bounce x velocit|
000004e0  79 20 2a 2f 0a 20 20 20  20 20 20 6f 62 6a 2d 3e  |y */.      obj->|
000004f0  78 76 20 3d 20 2d 6f 62  6a 2d 3e 78 76 3b 0a 20  |xv = -obj->xv;. |
00000500  20 20 20 69 66 20 28 6f  62 6a 2d 3e 79 20 3c 20  |   if (obj->y < |
00000510  30 20 7c 7c 20 6f 62 6a  2d 3e 79 20 3e 20 32 35  |0 || obj->y > 25|
00000520  35 3c 3c 31 32 29 20 2f  2a 20 42 6f 75 6e 63 65  |5<<12) /* Bounce|
00000530  20 79 20 76 65 6c 6f 63  69 74 79 20 2a 2f 0a 20  | y velocity */. |
00000540  20 20 20 7b 0a 20 20 20  20 20 20 6f 62 6a 2d 3e  |   {.      obj->|
00000550  79 76 20 3d 20 2d 6f 62  6a 2d 3e 79 76 3b 0a 2f  |yv = -obj->yv;./|
00000560  2a 0a 2a 2a 20 54 68 69  73 20 6e 65 78 74 20 6c  |*.** This next l|
00000570  69 6e 65 20 69 73 20 6e  65 65 64 65 64 20 74 6f  |ine is needed to|
00000580  20 73 74 6f 70 20 6a 69  74 74 65 72 69 6e 67 20  | stop jittering |
00000590  6f 66 20 6f 62 6a 65 63  74 73 20 77 68 65 6e 20  |of objects when |
000005a0  74 68 65 79 20 68 69 74  0a 2a 2a 20 74 68 65 20  |they hit.** the |
000005b0  62 6f 74 74 6f 6d 20 6f  66 20 74 68 65 20 73 63  |bottom of the sc|
000005c0  72 65 65 6e 2e 20 20 54  68 65 20 6a 69 74 74 65  |reen.  The jitte|
000005d0  72 69 6e 67 20 69 73 20  63 61 75 73 65 64 20 62  |ring is caused b|
000005e0  79 20 74 68 65 20 65 66  66 65 63 74 73 20 6f 66  |y the effects of|
000005f0  0a 2a 2a 20 67 72 61 76  69 74 79 3b 20 77 65 6c  |.** gravity; wel|
00000600  6c 2c 20 6a 75 73 74 20  72 65 6d 6f 76 65 20 74  |l, just remove t|
00000610  68 69 73 20 6c 69 6e 65  20 61 6e 64 20 73 65 65  |his line and see|
00000620  20 77 68 61 74 20 68 61  70 70 65 6e 73 2e 2e 2e  | what happens...|
00000630  0a 2a 2f 0a 20 20 20 20  20 20 6f 62 6a 2d 3e 79  |.*/.      obj->y|
00000640  20 3d 20 6f 62 6a 2d 3e  79 20 2b 20 6f 62 6a 2d  | = obj->y + obj-|
00000650  3e 79 76 3b 0a 20 20 20  20 7d 0a 20 20 7d 0a 7d  |>yv;.    }.  }.}|
00000660  0a 0a 2f 2a 20 54 68 69  73 20 66 75 6e 63 74 69  |../* This functi|
00000670  6f 6e 20 69 73 20 73 6f  20 6d 75 63 68 20 73 68  |on is so much sh|
00000680  6f 72 74 65 72 20 62 65  63 61 75 73 65 20 6f 66  |orter because of|
00000690  20 74 68 65 20 70 72 6f  74 6f 74 79 70 69 6e 67  | the prototyping|
000006a0  20 73 79 73 74 65 6d 20  2a 2f 0a 0a 76 6f 69 64  | system */..void|
000006b0  20 67 65 6e 65 72 61 74  6f 72 5f 68 61 6e 64 6c  | generator_handl|
000006c0  65 72 28 73 74 72 75 63  74 20 67 61 6d 65 5f 6f  |er(struct game_o|
000006d0  62 6a 65 63 74 20 2a 6f  62 6a 2c 20 75 6e 69 6f  |bject *obj, unio|
000006e0  6e 20 6f 62 6a 65 63 74  5f 66 6c 61 67 73 20 66  |n object_flags f|
000006f0  6c 61 67 73 2c 20 76 6f  69 64 20 2a 72 65 66 29  |lags, void *ref)|
00000700  0a 7b 0a 20 20 73 74 72  75 63 74 20 67 61 6d 65  |.{.  struct game|
00000710  5f 6f 62 6a 65 63 74 20  20 20 20 20 2a 62 61 6c  |_object     *bal|
00000720  6c 3b 0a 0a 20 20 69 66  20 28 20 28 72 61 6e 64  |l;..  if ( (rand|
00000730  28 29 20 26 20 33 29 20  3d 3d 20 30 20 29 20 2f  |() & 3) == 0 ) /|
00000740  2a 20 54 68 69 73 20 6d  61 6b 65 73 20 74 68 65  |* This makes the|
00000750  20 73 70 65 77 69 6e 67  20 6d 6f 72 65 20 65 72  | spewing more er|
00000760  72 61 74 69 63 20 2a 2f  0a 20 20 20 20 72 65 74  |ratic */.    ret|
00000770  75 72 6e 3b 0a 0a 20 20  62 61 6c 6c 20 3d 20 50  |urn;..  ball = P|
00000780  6f 70 63 6f 72 6e 5f 4e  65 77 50 72 6f 74 6f 74  |opcorn_NewProtot|
00000790  79 70 65 28 6f 62 6a 2d  3e 75 73 65 72 5f 64 61  |ype(obj->user_da|
000007a0  74 61 2c 20 6f 62 6a 2d  3e 6f 62 6a 65 63 74 5f  |ta, obj->object_|
000007b0  69 64 2c 20 6f 62 6a 2d  3e 78 2c 20 6f 62 6a 2d  |id, obj->x, obj-|
000007c0  3e 79 29 3b 0a 0a 20 20  69 66 20 28 62 61 6c 6c  |>y);..  if (ball|
000007d0  20 3d 3d 20 4e 55 4c 4c  29 0a 20 20 20 20 72 65  | == NULL).    re|
000007e0  74 75 72 6e 3b 20 2f 2a  20 54 68 69 73 20 68 61  |turn; /* This ha|
000007f0  70 70 65 6e 73 20 77 68  65 6e 20 74 68 65 20 74  |ppens when the t|
00000800  61 62 6c 65 20 69 73 20  66 75 6c 6c 20 2a 2f 0a  |able is full */.|
00000810  0a 20 20 62 61 6c 6c 2d  3e 78 76 20 3d 20 6f 62  |.  ball->xv = ob|
00000820  6a 2d 3e 78 76 20 2b 20  28 72 61 6e 64 6f 6d 28  |j->xv + (random(|
00000830  34 30 39 36 29 2d 32 30  34 38 29 3b 0a 20 20 62  |4096)-2048);.  b|
00000840  61 6c 6c 2d 3e 79 76 20  3d 20 6f 62 6a 2d 3e 79  |all->yv = obj->y|
00000850  76 20 2b 20 28 72 61 6e  64 6f 6d 28 34 30 39 36  |v + (random(4096|
00000860  29 2d 32 30 34 38 29 3b  0a 7d 0a 0a 69 6e 74 20  |)-2048);.}..int |
00000870  6d 61 69 6e 28 76 6f 69  64 29 0a 7b 0a 20 20 69  |main(void).{.  i|
00000880  6e 74 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |nt              |
00000890  20 20 20 20 20 66 72 61  6d 65 73 20 3d 20 31 2c  |     frames = 1,|
000008a0  20 73 74 61 72 74 5f 74  69 6d 65 2c 20 65 6e 64  | start_time, end|
000008b0  5f 74 69 6d 65 3b 0a 20  20 73 74 72 75 63 74 20  |_time;.  struct |
000008c0  67 61 6d 65 5f 6f 62 6a  65 63 74 20 20 20 20 2a  |game_object    *|
000008d0  74 65 6d 70 5f 6f 62 6a  3b 0a 0a 2f 2a 20 53 65  |temp_obj;../* Se|
000008e0  74 20 75 70 20 74 68 65  20 61 64 64 72 65 73 73  |t up the address|
000008f0  20 6f 66 20 74 68 65 20  73 79 6d 62 6f 6c 20 74  | of the symbol t|
00000900  61 62 6c 65 2c 20 6c 6f  61 64 20 74 68 65 20 72  |able, load the r|
00000910  65 73 6f 75 72 63 65 73  2c 20 70 72 6f 74 6f 74  |esources, protot|
00000920  79 70 65 73 0a 2a 2a 20  61 6e 64 20 74 68 65 20  |ypes.** and the |
00000930  73 70 72 69 74 65 73 2e  0a 2a 2f 0a 0a 20 20 73  |sprites..*/..  s|
00000940  74 72 63 70 79 28 73 79  6d 62 6f 6c 5f 74 61 62  |trcpy(symbol_tab|
00000950  6c 65 5f 66 69 6c 65 6e  61 6d 65 2c 20 22 3c 47  |le_filename, "<G|
00000960  75 73 68 24 44 69 72 3e  2e 44 61 74 61 2e 53 79  |ush$Dir>.Data.Sy|
00000970  6d 62 6f 6c 73 22 29 3b  0a 20 20 45 72 72 6f 72  |mbols");.  Error|
00000980  5f 43 68 65 63 6b 46 61  74 61 6c 28 50 6f 70 63  |_CheckFatal(Popc|
00000990  6f 72 6e 5f 4c 6f 61 64  52 65 73 6f 75 72 63 65  |orn_LoadResource|
000009a0  46 69 6c 65 28 22 3c 47  75 73 68 24 44 69 72 3e  |File("<Gush$Dir>|
000009b0  2e 44 61 74 61 2e 52 65  73 6f 75 72 63 65 73 22  |.Data.Resources"|
000009c0  29 29 3b 0a 20 20 45 72  72 6f 72 5f 43 68 65 63  |));.  Error_Chec|
000009d0  6b 46 61 74 61 6c 28 50  6f 70 63 6f 72 6e 5f 4c  |kFatal(Popcorn_L|
000009e0  6f 61 64 50 72 6f 74 6f  74 79 70 65 73 28 22 3c  |oadPrototypes("<|
000009f0  47 75 73 68 24 44 69 72  3e 2e 44 61 74 61 2e 50  |Gush$Dir>.Data.P|
00000a00  72 6f 74 6f 74 79 70 65  73 22 29 29 3b 0a 20 20  |rototypes"));.  |
00000a10  45 72 72 6f 72 5f 43 68  65 63 6b 46 61 74 61 6c  |Error_CheckFatal|
00000a20  28 50 6f 70 63 6f 72 6e  5f 4c 6f 61 64 47 72 6f  |(Popcorn_LoadGro|
00000a30  75 70 28 27 4c 4c 41 42  27 29 29 3b 0a 0a 2f 2a  |up('LLAB'));../*|
00000a40  20 49 6e 69 74 69 61 6c  69 73 65 20 50 6f 70 63  | Initialise Popc|
00000a50  6f 72 6e 20 73 70 72 69  74 65 20 70 6c 6f 74 74  |orn sprite plott|
00000a60  65 72 2c 20 63 6c 65 61  72 20 73 63 72 65 65 6e  |er, clear screen|
00000a70  2c 20 61 6e 64 20 6d 61  6b 65 20 73 70 61 63 65  |, and make space|
00000a80  20 66 6f 72 0a 2a 2a 20  74 77 6f 20 74 61 62 6c  | for.** two tabl|
00000a90  65 73 2c 20 6f 6e 65 20  66 6f 72 20 62 6c 75 65  |es, one for blue|
00000aa0  20 62 61 6c 6c 73 2c 20  6f 6e 65 20 66 6f 72 20  | balls, one for |
00000ab0  79 65 6c 6c 6f 77 2e 20  20 54 68 65 6e 20 73 65  |yellow.  Then se|
00000ac0  74 20 74 68 65 20 67 72  61 76 69 74 79 0a 2a 2a  |t the gravity.**|
00000ad0  20 6f 6e 20 65 61 63 68  20 74 6f 20 61 20 6d 6f  | on each to a mo|
00000ae0  64 65 72 61 74 65 20 76  61 6c 75 65 20 28 72 65  |derate value (re|
00000af0  6d 65 6d 62 65 72 20 34  30 39 36 20 50 6f 70 63  |member 4096 Popc|
00000b00  6f 72 6e 20 75 6e 69 74  73 20 3d 20 31 20 70 69  |orn units = 1 pi|
00000b10  78 65 6c 29 0a 2a 2f 0a  0a 20 20 62 6c 75 65 5f  |xel).*/..  blue_|
00000b20  74 61 62 6c 65 20 20 20  20 20 20 3d 20 50 6f 70  |table      = Pop|
00000b30  63 6f 72 6e 5f 4e 65 77  54 61 62 6c 65 28 32 30  |corn_NewTable(20|
00000b40  30 2c 20 54 52 55 45 29  3b 0a 20 20 79 65 6c 6c  |0, TRUE);.  yell|
00000b50  6f 77 5f 74 61 62 6c 65  20 20 20 20 3d 20 50 6f  |ow_table    = Po|
00000b60  70 63 6f 72 6e 5f 4e 65  77 54 61 62 6c 65 28 32  |pcorn_NewTable(2|
00000b70  30 30 2c 20 54 52 55 45  29 3b 0a 20 20 62 6c 75  |00, TRUE);.  blu|
00000b80  65 5f 74 61 62 6c 65 2d  3e 67 72 61 76 5f 79 20  |e_table->grav_y |
00000b90  3d 20 79 65 6c 6c 6f 77  5f 74 61 62 6c 65 2d 3e  |= yellow_table->|
00000ba0  67 72 61 76 5f 79 20 3d  20 32 35 36 3b 0a 0a 2f  |grav_y = 256;../|
00000bb0  2a 20 43 68 61 6e 67 65  20 74 6f 20 6d 6f 64 65  |* Change to mode|
00000bc0  20 31 33 20 77 69 74 68  20 73 70 61 63 65 20 66  | 13 with space f|
00000bd0  6f 72 20 74 77 6f 20 73  63 72 65 65 6e 20 62 61  |or two screen ba|
00000be0  6e 6b 73 20 28 4f 53 5f  42 79 74 65 20 31 31 34  |nks (OS_Byte 114|
00000bf0  2c 30 29 20 2a 2f 0a 0a  20 20 53 57 49 28 32 2c  |,0) */..  SWI(2,|
00000c00  20 30 2c 20 53 57 49 5f  4f 53 5f 42 79 74 65 2c  | 0, SWI_OS_Byte,|
00000c10  20 31 31 34 2c 20 30 29  3b 0a 20 20 47 46 58 5f  | 114, 0);.  GFX_|
00000c20  4d 6f 64 65 28 31 33 29  3b 0a 20 20 53 57 49 28  |Mode(13);.  SWI(|
00000c30  30 2c 20 30 2c 20 53 57  49 5f 4f 53 5f 52 65 6d  |0, 0, SWI_OS_Rem|
00000c40  6f 76 65 43 75 72 73 6f  72 73 29 3b 0a 20 20 53  |oveCursors);.  S|
00000c50  57 49 28 32 2c 20 30 2c  20 53 57 49 5f 4f 53 5f  |WI(2, 0, SWI_OS_|
00000c60  42 79 74 65 2c 20 32 32  39 2c 20 31 29 3b 0a 0a  |Byte, 229, 1);..|
00000c70  20 20 50 6f 70 63 6f 72  6e 5f 52 65 61 64 53 63  |  Popcorn_ReadSc|
00000c80  72 65 65 6e 44 65 74 61  69 6c 73 28 29 3b 0a 20  |reenDetails();. |
00000c90  20 50 6f 70 63 6f 72 6e  5f 43 6c 65 61 72 53 63  | Popcorn_ClearSc|
00000ca0  72 65 65 6e 28 30 29 3b  0a 0a 2f 2a 20 47 65 6e  |reen(0);../* Gen|
00000cb0  65 72 61 74 6f 72 20 6f  62 6a 65 63 74 73 20 61  |erator objects a|
00000cc0  72 65 20 6e 6f 77 20 63  72 65 61 74 65 64 20 66  |re now created f|
00000cd0  72 6f 6d 20 70 72 6f 74  6f 74 79 70 65 20 66 69  |rom prototype fi|
00000ce0  6c 65 2e 2e 2e 20 65 61  73 79 20 70 65 61 73 79  |le... easy peasy|
00000cf0  20 3a 2d 29 0a 2a 2a 20  54 68 69 73 20 74 69 6d  | :-).** This tim|
00000d00  65 20 74 68 65 69 72 20  49 44 73 20 61 72 65 20  |e their IDs are |
00000d10  63 68 61 6e 67 65 64 20  73 6f 20 74 68 61 74 20  |changed so that |
00000d20  62 61 6c 6c 73 20 63 61  6e 20 62 65 20 63 72 65  |balls can be cre|
00000d30  61 74 65 64 20 66 72 6f  6d 0a 2a 2a 20 74 68 65  |ated from.** the|
00000d40  6d 20 6d 6f 72 65 20 65  61 73 69 6c 79 20 28 73  |m more easily (s|
00000d50  65 65 20 67 65 6e 65 72  61 74 6f 72 5f 68 61 6e  |ee generator_han|
00000d60  64 6c 65 72 20 61 62 6f  76 65 29 2e 0a 2a 2f 0a  |dler above)..*/.|
00000d70  0a 20 20 74 65 6d 70 5f  6f 62 6a 20 3d 20 50 6f  |.  temp_obj = Po|
00000d80  70 63 6f 72 6e 5f 4e 65  77 50 72 6f 74 6f 74 79  |pcorn_NewPrototy|
00000d90  70 65 28 62 6c 75 65 5f  74 61 62 6c 65 2c 20 27  |pe(blue_table, '|
00000da0  52 4e 45 47 27 2c 20 31  30 3c 3c 31 32 2c 20 31  |RNEG', 10<<12, 1|
00000db0  30 3c 3c 31 32 29 3b 0a  20 20 74 65 6d 70 5f 6f  |0<<12);.  temp_o|
00000dc0  62 6a 2d 3e 6f 62 6a 65  63 74 5f 69 64 20 3d 20  |bj->object_id = |
00000dd0  27 45 55 4c 42 27 3b 0a  20 20 74 65 6d 70 5f 6f  |'EULB';.  temp_o|
00000de0  62 6a 2d 3e 78 76 20 3d  20 74 65 6d 70 5f 6f 62  |bj->xv = temp_ob|
00000df0  6a 2d 3e 79 76 20 3d 20  34 30 39 36 3b 0a 20 20  |j->yv = 4096;.  |
00000e00  74 65 6d 70 5f 6f 62 6a  2d 3e 75 73 65 72 5f 64  |temp_obj->user_d|
00000e10  61 74 61 20 3d 20 62 6c  75 65 5f 74 61 62 6c 65  |ata = blue_table|
00000e20  3b 0a 0a 20 20 74 65 6d  70 5f 6f 62 6a 20 3d 20  |;..  temp_obj = |
00000e30  50 6f 70 63 6f 72 6e 5f  4e 65 77 50 72 6f 74 6f  |Popcorn_NewProto|
00000e40  74 79 70 65 28 79 65 6c  6c 6f 77 5f 74 61 62 6c  |type(yellow_tabl|
00000e50  65 2c 20 27 52 4e 45 47  27 2c 20 33 30 39 3c 3c  |e, 'RNEG', 309<<|
00000e60  31 32 2c 20 31 30 3c 3c  31 32 29 3b 0a 20 20 74  |12, 10<<12);.  t|
00000e70  65 6d 70 5f 6f 62 6a 2d  3e 6f 62 6a 65 63 74 5f  |emp_obj->object_|
00000e80  69 64 20 3d 20 27 4f 4c  45 59 27 3b 0a 20 20 74  |id = 'OLEY';.  t|
00000e90  65 6d 70 5f 6f 62 6a 2d  3e 78 76 20 3d 20 2d 34  |emp_obj->xv = -4|
00000ea0  30 39 36 3b 20 74 65 6d  70 5f 6f 62 6a 2d 3e 79  |096; temp_obj->y|
00000eb0  76 20 3d 20 34 30 39 36  3b 0a 20 20 74 65 6d 70  |v = 4096;.  temp|
00000ec0  5f 6f 62 6a 2d 3e 75 73  65 72 5f 64 61 74 61 20  |_obj->user_data |
00000ed0  3d 20 79 65 6c 6c 6f 77  5f 74 61 62 6c 65 3b 0a  |= yellow_table;.|
00000ee0  0a 2f 2a 20 4d 61 69 6e  20 6c 6f 6f 70 20 69 73  |./* Main loop is|
00000ef0  20 75 6e 63 68 61 6e 67  65 64 20 2a 2f 0a 0a 20  | unchanged */.. |
00000f00  20 64 6f 20 7b 0a 20 20  20 20 53 57 49 28 30 2c  | do {.    SWI(0,|
00000f10  20 31 2c 20 53 57 49 5f  4f 53 5f 52 65 61 64 4d  | 1, SWI_OS_ReadM|
00000f20  6f 6e 6f 74 6f 6e 69 63  54 69 6d 65 2c 20 26 73  |onotonicTime, &s|
00000f30  74 61 72 74 5f 74 69 6d  65 29 3b 0a 20 20 20 20  |tart_time);.    |
00000f40  50 6f 70 63 6f 72 6e 5f  43 6c 65 61 72 53 63 72  |Popcorn_ClearScr|
00000f50  65 65 6e 28 30 29 3b 0a  20 20 20 20 50 6f 70 63  |een(0);.    Popc|
00000f60  6f 72 6e 5f 50 72 6f 63  65 73 73 28 62 6c 75 65  |orn_Process(blue|
00000f70  5f 74 61 62 6c 65 2c 20  54 52 55 45 2c 20 66 72  |_table, TRUE, fr|
00000f80  61 6d 65 73 29 3b 0a 20  20 20 20 50 6f 70 63 6f  |ames);.    Popco|
00000f90  72 6e 5f 50 72 6f 63 65  73 73 28 79 65 6c 6c 6f  |rn_Process(yello|
00000fa0  77 5f 74 61 62 6c 65 2c  20 54 52 55 45 2c 20 66  |w_table, TRUE, f|
00000fb0  72 61 6d 65 73 29 3b 0a  20 20 20 20 50 6f 70 63  |rames);.    Popc|
00000fc0  6f 72 6e 5f 43 6f 6c 6c  69 73 69 6f 6e 43 68 65  |orn_CollisionChe|
00000fd0  63 6b 28 62 6c 75 65 5f  74 61 62 6c 65 2c 20 79  |ck(blue_table, y|
00000fe0  65 6c 6c 6f 77 5f 74 61  62 6c 65 29 3b 0a 20 20  |ellow_table);.  |
00000ff0  20 20 64 6f 20 7b 0a 20  20 20 20 20 20 53 57 49  |  do {.      SWI|
00001000  28 30 2c 20 31 2c 20 53  57 49 5f 4f 53 5f 52 65  |(0, 1, SWI_OS_Re|
00001010  61 64 4d 6f 6e 6f 74 6f  6e 69 63 54 69 6d 65 2c  |adMonotonicTime,|
00001020  20 26 65 6e 64 5f 74 69  6d 65 29 3b 0a 20 20 20  | &end_time);.   |
00001030  20 20 20 66 72 61 6d 65  73 20 3d 20 28 65 6e 64  |   frames = (end|
00001040  5f 74 69 6d 65 20 2d 20  73 74 61 72 74 5f 74 69  |_time - start_ti|
00001050  6d 65 29 20 3e 3e 20 31  3b 0a 20 20 20 20 7d 20  |me) >> 1;.    } |
00001060  77 68 69 6c 65 20 28 66  72 61 6d 65 73 20 3d 3d  |while (frames ==|
00001070  20 30 29 3b 0a 20 20 20  20 53 57 49 28 31 2c 20  | 0);.    SWI(1, |
00001080  30 2c 20 53 57 49 5f 4f  53 5f 42 79 74 65 2c 20  |0, SWI_OS_Byte, |
00001090  31 39 29 3b 0a 20 20 20  20 50 6f 70 63 6f 72 6e  |19);.    Popcorn|
000010a0  5f 53 77 61 70 42 61 6e  6b 73 28 29 3b 0a 20 20  |_SwapBanks();.  |
000010b0  7d 20 77 68 69 6c 65 20  28 21 28 4b 62 64 5f 4b  |} while (!(Kbd_K|
000010c0  65 79 44 6f 77 6e 28 2d  31 31 33 29 20 26 26 20  |eyDown(-113) && |
000010d0  4b 62 64 5f 4b 65 79 44  6f 77 6e 28 2d 32 29 29  |Kbd_KeyDown(-2))|
000010e0  29 3b 0a 0a 20 20 72 65  74 75 72 6e 28 30 29 3b  |);..  return(0);|
000010f0  0a 7d 0a                                          |.}.|
000010f3