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

Arcade/!Popcorn/c/ColCheck

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/!Popcorn/c/ColCheck
Read OK:
File size: 04EB bytes
Load address: 0000
Exec address: 0000
Duplicates

There is 1 duplicate copy of this file in the archive:

File contents
#include "Popcorn:h.Popcorn"

void Popcorn_CollisionCheck(struct object_table *t1,
     			    struct object_table *t2)
{
  int	 		    num1, num2;
  union object_flags	    reason_collide;

  reason_collide.word = 0;
  reason_collide.bits.collide = 1;

  if (t1->collisions == NULL || t2->collisions == NULL)
    return;

  num1 = 0;
  while (num1 != t1->collisions->entries)
  {
    if (t1 != t2)
      num2 = 0;
    else
      num2 = num1+1;
    while (num2 != t2->collisions->entries)
    {
      if (
      !(t1->collisions->collision[num1].y0 > t2->collisions->collision[num2].y1) &&
      !(t1->collisions->collision[num1].y1 < t2->collisions->collision[num2].y0) &&
      !(t1->collisions->collision[num1].x0 > t2->collisions->collision[num2].x1) &&
      !(t1->collisions->collision[num1].x1 < t2->collisions->collision[num2].x0)      )
        ( t1->collisions->collision[num1].back_ptr->handler)( (void*) t1->collisions->collision[num1].back_ptr, reason_collide, (void*) t2->collisions->collision[num2].back_ptr); /* Yuck... so I can't (void*) program! */
/*       { */
/*         printf("%X %X\n", t1->collisions->collision[num1].back_ptr, t1->collisions->collision[num1].back_ptr); */
/*       } */

      num2++;
    }
    num1++;
  }
  return;
}
00000000  23 69 6e 63 6c 75 64 65  20 22 50 6f 70 63 6f 72  |#include "Popcor|
00000010  6e 3a 68 2e 50 6f 70 63  6f 72 6e 22 0a 0a 76 6f  |n:h.Popcorn"..vo|
00000020  69 64 20 50 6f 70 63 6f  72 6e 5f 43 6f 6c 6c 69  |id Popcorn_Colli|
00000030  73 69 6f 6e 43 68 65 63  6b 28 73 74 72 75 63 74  |sionCheck(struct|
00000040  20 6f 62 6a 65 63 74 5f  74 61 62 6c 65 20 2a 74  | object_table *t|
00000050  31 2c 0a 20 20 20 20 20  09 09 09 20 20 20 20 73  |1,.     ...    s|
00000060  74 72 75 63 74 20 6f 62  6a 65 63 74 5f 74 61 62  |truct object_tab|
00000070  6c 65 20 2a 74 32 29 0a  7b 0a 20 20 69 6e 74 09  |le *t2).{.  int.|
00000080  20 09 09 20 20 20 20 6e  75 6d 31 2c 20 6e 75 6d  | ..    num1, num|
00000090  32 3b 0a 20 20 75 6e 69  6f 6e 20 6f 62 6a 65 63  |2;.  union objec|
000000a0  74 5f 66 6c 61 67 73 09  20 20 20 20 72 65 61 73  |t_flags.    reas|
000000b0  6f 6e 5f 63 6f 6c 6c 69  64 65 3b 0a 0a 20 20 72  |on_collide;..  r|
000000c0  65 61 73 6f 6e 5f 63 6f  6c 6c 69 64 65 2e 77 6f  |eason_collide.wo|
000000d0  72 64 20 3d 20 30 3b 0a  20 20 72 65 61 73 6f 6e  |rd = 0;.  reason|
000000e0  5f 63 6f 6c 6c 69 64 65  2e 62 69 74 73 2e 63 6f  |_collide.bits.co|
000000f0  6c 6c 69 64 65 20 3d 20  31 3b 0a 0a 20 20 69 66  |llide = 1;..  if|
00000100  20 28 74 31 2d 3e 63 6f  6c 6c 69 73 69 6f 6e 73  | (t1->collisions|
00000110  20 3d 3d 20 4e 55 4c 4c  20 7c 7c 20 74 32 2d 3e  | == NULL || t2->|
00000120  63 6f 6c 6c 69 73 69 6f  6e 73 20 3d 3d 20 4e 55  |collisions == NU|
00000130  4c 4c 29 0a 20 20 20 20  72 65 74 75 72 6e 3b 0a  |LL).    return;.|
00000140  0a 20 20 6e 75 6d 31 20  3d 20 30 3b 0a 20 20 77  |.  num1 = 0;.  w|
00000150  68 69 6c 65 20 28 6e 75  6d 31 20 21 3d 20 74 31  |hile (num1 != t1|
00000160  2d 3e 63 6f 6c 6c 69 73  69 6f 6e 73 2d 3e 65 6e  |->collisions->en|
00000170  74 72 69 65 73 29 0a 20  20 7b 0a 20 20 20 20 69  |tries).  {.    i|
00000180  66 20 28 74 31 20 21 3d  20 74 32 29 0a 20 20 20  |f (t1 != t2).   |
00000190  20 20 20 6e 75 6d 32 20  3d 20 30 3b 0a 20 20 20  |   num2 = 0;.   |
000001a0  20 65 6c 73 65 0a 20 20  20 20 20 20 6e 75 6d 32  | else.      num2|
000001b0  20 3d 20 6e 75 6d 31 2b  31 3b 0a 20 20 20 20 77  | = num1+1;.    w|
000001c0  68 69 6c 65 20 28 6e 75  6d 32 20 21 3d 20 74 32  |hile (num2 != t2|
000001d0  2d 3e 63 6f 6c 6c 69 73  69 6f 6e 73 2d 3e 65 6e  |->collisions->en|
000001e0  74 72 69 65 73 29 0a 20  20 20 20 7b 0a 20 20 20  |tries).    {.   |
000001f0  20 20 20 69 66 20 28 0a  20 20 20 20 20 20 21 28  |   if (.      !(|
00000200  74 31 2d 3e 63 6f 6c 6c  69 73 69 6f 6e 73 2d 3e  |t1->collisions->|
00000210  63 6f 6c 6c 69 73 69 6f  6e 5b 6e 75 6d 31 5d 2e  |collision[num1].|
00000220  79 30 20 3e 20 74 32 2d  3e 63 6f 6c 6c 69 73 69  |y0 > t2->collisi|
00000230  6f 6e 73 2d 3e 63 6f 6c  6c 69 73 69 6f 6e 5b 6e  |ons->collision[n|
00000240  75 6d 32 5d 2e 79 31 29  20 26 26 0a 20 20 20 20  |um2].y1) &&.    |
00000250  20 20 21 28 74 31 2d 3e  63 6f 6c 6c 69 73 69 6f  |  !(t1->collisio|
00000260  6e 73 2d 3e 63 6f 6c 6c  69 73 69 6f 6e 5b 6e 75  |ns->collision[nu|
00000270  6d 31 5d 2e 79 31 20 3c  20 74 32 2d 3e 63 6f 6c  |m1].y1 < t2->col|
00000280  6c 69 73 69 6f 6e 73 2d  3e 63 6f 6c 6c 69 73 69  |lisions->collisi|
00000290  6f 6e 5b 6e 75 6d 32 5d  2e 79 30 29 20 26 26 0a  |on[num2].y0) &&.|
000002a0  20 20 20 20 20 20 21 28  74 31 2d 3e 63 6f 6c 6c  |      !(t1->coll|
000002b0  69 73 69 6f 6e 73 2d 3e  63 6f 6c 6c 69 73 69 6f  |isions->collisio|
000002c0  6e 5b 6e 75 6d 31 5d 2e  78 30 20 3e 20 74 32 2d  |n[num1].x0 > t2-|
000002d0  3e 63 6f 6c 6c 69 73 69  6f 6e 73 2d 3e 63 6f 6c  |>collisions->col|
000002e0  6c 69 73 69 6f 6e 5b 6e  75 6d 32 5d 2e 78 31 29  |lision[num2].x1)|
000002f0  20 26 26 0a 20 20 20 20  20 20 21 28 74 31 2d 3e  | &&.      !(t1->|
00000300  63 6f 6c 6c 69 73 69 6f  6e 73 2d 3e 63 6f 6c 6c  |collisions->coll|
00000310  69 73 69 6f 6e 5b 6e 75  6d 31 5d 2e 78 31 20 3c  |ision[num1].x1 <|
00000320  20 74 32 2d 3e 63 6f 6c  6c 69 73 69 6f 6e 73 2d  | t2->collisions-|
00000330  3e 63 6f 6c 6c 69 73 69  6f 6e 5b 6e 75 6d 32 5d  |>collision[num2]|
00000340  2e 78 30 29 20 20 20 20  20 20 29 0a 20 20 20 20  |.x0)      ).    |
00000350  20 20 20 20 28 20 74 31  2d 3e 63 6f 6c 6c 69 73  |    ( t1->collis|
00000360  69 6f 6e 73 2d 3e 63 6f  6c 6c 69 73 69 6f 6e 5b  |ions->collision[|
00000370  6e 75 6d 31 5d 2e 62 61  63 6b 5f 70 74 72 2d 3e  |num1].back_ptr->|
00000380  68 61 6e 64 6c 65 72 29  28 20 28 76 6f 69 64 2a  |handler)( (void*|
00000390  29 20 74 31 2d 3e 63 6f  6c 6c 69 73 69 6f 6e 73  |) t1->collisions|
000003a0  2d 3e 63 6f 6c 6c 69 73  69 6f 6e 5b 6e 75 6d 31  |->collision[num1|
000003b0  5d 2e 62 61 63 6b 5f 70  74 72 2c 20 72 65 61 73  |].back_ptr, reas|
000003c0  6f 6e 5f 63 6f 6c 6c 69  64 65 2c 20 28 76 6f 69  |on_collide, (voi|
000003d0  64 2a 29 20 74 32 2d 3e  63 6f 6c 6c 69 73 69 6f  |d*) t2->collisio|
000003e0  6e 73 2d 3e 63 6f 6c 6c  69 73 69 6f 6e 5b 6e 75  |ns->collision[nu|
000003f0  6d 32 5d 2e 62 61 63 6b  5f 70 74 72 29 3b 20 2f  |m2].back_ptr); /|
00000400  2a 20 59 75 63 6b 2e 2e  2e 20 73 6f 20 49 20 63  |* Yuck... so I c|
00000410  61 6e 27 74 20 28 76 6f  69 64 2a 29 20 70 72 6f  |an't (void*) pro|
00000420  67 72 61 6d 21 20 2a 2f  0a 2f 2a 20 20 20 20 20  |gram! */./*     |
00000430  20 20 7b 20 2a 2f 0a 2f  2a 20 20 20 20 20 20 20  |  { */./*       |
00000440  20 20 70 72 69 6e 74 66  28 22 25 58 20 25 58 5c  |  printf("%X %X\|
00000450  6e 22 2c 20 74 31 2d 3e  63 6f 6c 6c 69 73 69 6f  |n", t1->collisio|
00000460  6e 73 2d 3e 63 6f 6c 6c  69 73 69 6f 6e 5b 6e 75  |ns->collision[nu|
00000470  6d 31 5d 2e 62 61 63 6b  5f 70 74 72 2c 20 74 31  |m1].back_ptr, t1|
00000480  2d 3e 63 6f 6c 6c 69 73  69 6f 6e 73 2d 3e 63 6f  |->collisions->co|
00000490  6c 6c 69 73 69 6f 6e 5b  6e 75 6d 31 5d 2e 62 61  |llision[num1].ba|
000004a0  63 6b 5f 70 74 72 29 3b  20 2a 2f 0a 2f 2a 20 20  |ck_ptr); */./*  |
000004b0  20 20 20 20 20 7d 20 2a  2f 0a 0a 20 20 20 20 20  |     } */..     |
000004c0  20 6e 75 6d 32 2b 2b 3b  0a 20 20 20 20 7d 0a 20  | num2++;.    }. |
000004d0  20 20 20 6e 75 6d 31 2b  2b 3b 0a 20 20 7d 0a 20  |   num1++;.  }. |
000004e0  20 72 65 74 75 72 6e 3b  0a 7d 0a                 | return;.}.|
000004eb