Home » Archimedes archive » Acorn User » AU 1997-01 B.adf » Features » Arcade/!Popcorn/c/NewTable
Arcade/!Popcorn/c/NewTable
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/NewTable |
Read OK: | ✔ |
File size: | 0296 bytes |
Load address: | 0000 |
Exec address: | 0000 |
Duplicates
There is 1 duplicate copy of this file in the archive:
- Archimedes archive » Acorn User » AU 1996-Xmas.adf » Features » Arcade/!Popcorn/c/NewTable
- Archimedes archive » Acorn User » AU 1997-01 B.adf » Features » Arcade/!Popcorn/c/NewTable
File contents
#include <stdlib.h> #include "Popcorn:h.Popcorn" struct object_table* Popcorn_NewTable(int max_objects, BOOL collisions) { int c; struct object_table *table = malloc( (sizeof(struct object_table)) + ((max_objects-1)*sizeof(struct game_object)) ); table->max_objects = max_objects; table->next_free = 0; table->grav_x = table->grav_y = 0; if (collisions) table->collisions = malloc(sizeof(struct collision_table)+sizeof(struct collision_object)*(max_objects-1)); else table->collisions = NULL; for (c=0; c<max_objects; c++) table->object[c].object_id = 0; table->header = TABLE_HEADER_WORD; return(table); }
00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 6c 69 62 |#include <stdlib| 00000010 2e 68 3e 0a 0a 23 69 6e 63 6c 75 64 65 20 22 50 |.h>..#include "P| 00000020 6f 70 63 6f 72 6e 3a 68 2e 50 6f 70 63 6f 72 6e |opcorn:h.Popcorn| 00000030 22 0a 0a 73 74 72 75 63 74 20 6f 62 6a 65 63 74 |"..struct object| 00000040 5f 74 61 62 6c 65 2a 20 50 6f 70 63 6f 72 6e 5f |_table* Popcorn_| 00000050 4e 65 77 54 61 62 6c 65 28 69 6e 74 20 6d 61 78 |NewTable(int max| 00000060 5f 6f 62 6a 65 63 74 73 2c 20 42 4f 4f 4c 20 63 |_objects, BOOL c| 00000070 6f 6c 6c 69 73 69 6f 6e 73 29 0a 7b 0a 20 20 69 |ollisions).{. i| 00000080 6e 74 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |nt | 00000090 20 20 20 63 3b 0a 20 20 73 74 72 75 63 74 20 6f | c;. struct o| 000000a0 62 6a 65 63 74 5f 74 61 62 6c 65 20 2a 74 61 62 |bject_table *tab| 000000b0 6c 65 20 3d 20 6d 61 6c 6c 6f 63 28 20 28 73 69 |le = malloc( (si| 000000c0 7a 65 6f 66 28 73 74 72 75 63 74 20 6f 62 6a 65 |zeof(struct obje| 000000d0 63 74 5f 74 61 62 6c 65 29 29 20 2b 20 28 28 6d |ct_table)) + ((m| 000000e0 61 78 5f 6f 62 6a 65 63 74 73 2d 31 29 2a 73 69 |ax_objects-1)*si| 000000f0 7a 65 6f 66 28 73 74 72 75 63 74 20 67 61 6d 65 |zeof(struct game| 00000100 5f 6f 62 6a 65 63 74 29 29 20 29 3b 0a 0a 20 20 |_object)) );.. | 00000110 74 61 62 6c 65 2d 3e 6d 61 78 5f 6f 62 6a 65 63 |table->max_objec| 00000120 74 73 20 3d 20 6d 61 78 5f 6f 62 6a 65 63 74 73 |ts = max_objects| 00000130 3b 0a 20 20 74 61 62 6c 65 2d 3e 6e 65 78 74 5f |;. table->next_| 00000140 66 72 65 65 20 3d 20 30 3b 0a 20 20 74 61 62 6c |free = 0;. tabl| 00000150 65 2d 3e 67 72 61 76 5f 78 20 3d 20 74 61 62 6c |e->grav_x = tabl| 00000160 65 2d 3e 67 72 61 76 5f 79 20 3d 20 30 3b 0a 0a |e->grav_y = 0;..| 00000170 20 20 69 66 20 28 63 6f 6c 6c 69 73 69 6f 6e 73 | if (collisions| 00000180 29 0a 20 20 20 20 74 61 62 6c 65 2d 3e 63 6f 6c |). table->col| 00000190 6c 69 73 69 6f 6e 73 20 3d 20 6d 61 6c 6c 6f 63 |lisions = malloc| 000001a0 28 73 69 7a 65 6f 66 28 73 74 72 75 63 74 20 63 |(sizeof(struct c| 000001b0 6f 6c 6c 69 73 69 6f 6e 5f 74 61 62 6c 65 29 2b |ollision_table)+| 000001c0 73 69 7a 65 6f 66 28 73 74 72 75 63 74 20 63 6f |sizeof(struct co| 000001d0 6c 6c 69 73 69 6f 6e 5f 6f 62 6a 65 63 74 29 2a |llision_object)*| 000001e0 28 6d 61 78 5f 6f 62 6a 65 63 74 73 2d 31 29 29 |(max_objects-1))| 000001f0 3b 0a 20 20 65 6c 73 65 0a 20 20 20 20 74 61 62 |;. else. tab| 00000200 6c 65 2d 3e 63 6f 6c 6c 69 73 69 6f 6e 73 20 3d |le->collisions =| 00000210 20 4e 55 4c 4c 3b 0a 0a 20 20 66 6f 72 20 28 63 | NULL;.. for (c| 00000220 3d 30 3b 20 63 3c 6d 61 78 5f 6f 62 6a 65 63 74 |=0; c<max_object| 00000230 73 3b 20 63 2b 2b 29 0a 20 20 20 20 74 61 62 6c |s; c++). tabl| 00000240 65 2d 3e 6f 62 6a 65 63 74 5b 63 5d 2e 6f 62 6a |e->object[c].obj| 00000250 65 63 74 5f 69 64 20 3d 20 30 3b 0a 0a 20 20 74 |ect_id = 0;.. t| 00000260 61 62 6c 65 2d 3e 68 65 61 64 65 72 20 3d 20 54 |able->header = T| 00000270 41 42 4c 45 5f 48 45 41 44 45 52 5f 57 4f 52 44 |ABLE_HEADER_WORD| 00000280 3b 0a 0a 20 20 72 65 74 75 72 6e 28 74 61 62 6c |;.. return(tabl| 00000290 65 29 3b 0a 7d 0a |e);.}.| 00000296