Home » Archimedes archive » Acorn User » AU 1997-01 B.adf » Features » Arcade/!Popcorn/c/Tidy

Arcade/!Popcorn/c/Tidy

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 1997-01 B.adf » Features
Filename: Arcade/!Popcorn/c/Tidy
Read OK:
File size: 025F 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_Tidy(struct object_table* table)
{
  register int scan_free=0, scan_full;

  while (scan_free != table->max_objects)
  {
    if (table->object[scan_free].object_id == 0)
    {
      scan_full = scan_free;
      while (scan_full != table->max_objects && table->object[scan_full].object_id == 0)
        scan_full++;
      if (scan_full == table->max_objects)
      {
        table->next_free = scan_free;
        return;
      }
      table->object[scan_free] = table->object[scan_full];
      table->object[scan_full].object_id = 0;
    }
    scan_free++;
  }
}


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 54 69 64 79 28  |id Popcorn_Tidy(|
00000030  73 74 72 75 63 74 20 6f  62 6a 65 63 74 5f 74 61  |struct object_ta|
00000040  62 6c 65 2a 20 74 61 62  6c 65 29 0a 7b 0a 20 20  |ble* table).{.  |
00000050  72 65 67 69 73 74 65 72  20 69 6e 74 20 73 63 61  |register int sca|
00000060  6e 5f 66 72 65 65 3d 30  2c 20 73 63 61 6e 5f 66  |n_free=0, scan_f|
00000070  75 6c 6c 3b 0a 0a 20 20  77 68 69 6c 65 20 28 73  |ull;..  while (s|
00000080  63 61 6e 5f 66 72 65 65  20 21 3d 20 74 61 62 6c  |can_free != tabl|
00000090  65 2d 3e 6d 61 78 5f 6f  62 6a 65 63 74 73 29 0a  |e->max_objects).|
000000a0  20 20 7b 0a 20 20 20 20  69 66 20 28 74 61 62 6c  |  {.    if (tabl|
000000b0  65 2d 3e 6f 62 6a 65 63  74 5b 73 63 61 6e 5f 66  |e->object[scan_f|
000000c0  72 65 65 5d 2e 6f 62 6a  65 63 74 5f 69 64 20 3d  |ree].object_id =|
000000d0  3d 20 30 29 0a 20 20 20  20 7b 0a 20 20 20 20 20  |= 0).    {.     |
000000e0  20 73 63 61 6e 5f 66 75  6c 6c 20 3d 20 73 63 61  | scan_full = sca|
000000f0  6e 5f 66 72 65 65 3b 0a  20 20 20 20 20 20 77 68  |n_free;.      wh|
00000100  69 6c 65 20 28 73 63 61  6e 5f 66 75 6c 6c 20 21  |ile (scan_full !|
00000110  3d 20 74 61 62 6c 65 2d  3e 6d 61 78 5f 6f 62 6a  |= table->max_obj|
00000120  65 63 74 73 20 26 26 20  74 61 62 6c 65 2d 3e 6f  |ects && table->o|
00000130  62 6a 65 63 74 5b 73 63  61 6e 5f 66 75 6c 6c 5d  |bject[scan_full]|
00000140  2e 6f 62 6a 65 63 74 5f  69 64 20 3d 3d 20 30 29  |.object_id == 0)|
00000150  0a 20 20 20 20 20 20 20  20 73 63 61 6e 5f 66 75  |.        scan_fu|
00000160  6c 6c 2b 2b 3b 0a 20 20  20 20 20 20 69 66 20 28  |ll++;.      if (|
00000170  73 63 61 6e 5f 66 75 6c  6c 20 3d 3d 20 74 61 62  |scan_full == tab|
00000180  6c 65 2d 3e 6d 61 78 5f  6f 62 6a 65 63 74 73 29  |le->max_objects)|
00000190  0a 20 20 20 20 20 20 7b  0a 20 20 20 20 20 20 20  |.      {.       |
000001a0  20 74 61 62 6c 65 2d 3e  6e 65 78 74 5f 66 72 65  | table->next_fre|
000001b0  65 20 3d 20 73 63 61 6e  5f 66 72 65 65 3b 0a 20  |e = scan_free;. |
000001c0  20 20 20 20 20 20 20 72  65 74 75 72 6e 3b 0a 20  |       return;. |
000001d0  20 20 20 20 20 7d 0a 20  20 20 20 20 20 74 61 62  |     }.      tab|
000001e0  6c 65 2d 3e 6f 62 6a 65  63 74 5b 73 63 61 6e 5f  |le->object[scan_|
000001f0  66 72 65 65 5d 20 3d 20  74 61 62 6c 65 2d 3e 6f  |free] = table->o|
00000200  62 6a 65 63 74 5b 73 63  61 6e 5f 66 75 6c 6c 5d  |bject[scan_full]|
00000210  3b 0a 20 20 20 20 20 20  74 61 62 6c 65 2d 3e 6f  |;.      table->o|
00000220  62 6a 65 63 74 5b 73 63  61 6e 5f 66 75 6c 6c 5d  |bject[scan_full]|
00000230  2e 6f 62 6a 65 63 74 5f  69 64 20 3d 20 30 3b 0a  |.object_id = 0;.|
00000240  20 20 20 20 7d 0a 20 20  20 20 73 63 61 6e 5f 66  |    }.    scan_f|
00000250  72 65 65 2b 2b 3b 0a 20  20 7d 0a 7d 0a 0a 0a     |ree++;.  }.}...|
0000025f