Home » Archimedes archive » Acorn User » AU 1996-Xmas.adf » Features » Arcade/!Popcorn/c/NewObject
Arcade/!Popcorn/c/NewObject
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/NewObject |
Read OK: | ✔ |
File size: | 0226 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/NewObject
- Archimedes archive » Acorn User » AU 1997-01 B.adf » Features » Arcade/!Popcorn/c/NewObject
File contents
#include "Popcorn:h.Popcorn" struct game_object *Popcorn_NewObject(struct object_table* table) { register int check_object; /* if (table->header != TABLE_HEADER_WORD) i.e. bad table reference */ /* system("Debug"); */ if (table->next_free < table->max_objects) { table->next_free++; return(&(table->object[(table->next_free)-1])); } for (check_object = 0; check_object < table->max_objects; check_object++) if (table->object[check_object].object_id == 0) return(&table->object[check_object]); return(NULL); }
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 73 74 |n:h.Popcorn"..st| 00000020 72 75 63 74 20 67 61 6d 65 5f 6f 62 6a 65 63 74 |ruct game_object| 00000030 20 2a 50 6f 70 63 6f 72 6e 5f 4e 65 77 4f 62 6a | *Popcorn_NewObj| 00000040 65 63 74 28 73 74 72 75 63 74 20 6f 62 6a 65 63 |ect(struct objec| 00000050 74 5f 74 61 62 6c 65 2a 20 74 61 62 6c 65 29 0a |t_table* table).| 00000060 7b 0a 20 20 72 65 67 69 73 74 65 72 20 69 6e 74 |{. register int| 00000070 20 63 68 65 63 6b 5f 6f 62 6a 65 63 74 3b 0a 0a | check_object;..| 00000080 2f 2a 20 20 20 69 66 20 28 74 61 62 6c 65 2d 3e |/* if (table->| 00000090 68 65 61 64 65 72 20 21 3d 20 54 41 42 4c 45 5f |header != TABLE_| 000000a0 48 45 41 44 45 52 5f 57 4f 52 44 29 20 69 2e 65 |HEADER_WORD) i.e| 000000b0 2e 20 62 61 64 20 74 61 62 6c 65 20 72 65 66 65 |. bad table refe| 000000c0 72 65 6e 63 65 20 2a 2f 0a 2f 2a 20 20 20 20 20 |rence */./* | 000000d0 73 79 73 74 65 6d 28 22 44 65 62 75 67 22 29 3b |system("Debug");| 000000e0 20 2a 2f 0a 0a 20 20 69 66 20 28 74 61 62 6c 65 | */.. if (table| 000000f0 2d 3e 6e 65 78 74 5f 66 72 65 65 20 3c 20 74 61 |->next_free < ta| 00000100 62 6c 65 2d 3e 6d 61 78 5f 6f 62 6a 65 63 74 73 |ble->max_objects| 00000110 29 0a 20 20 7b 0a 20 20 20 20 74 61 62 6c 65 2d |). {. table-| 00000120 3e 6e 65 78 74 5f 66 72 65 65 2b 2b 3b 0a 20 20 |>next_free++;. | 00000130 20 20 72 65 74 75 72 6e 28 26 28 74 61 62 6c 65 | return(&(table| 00000140 2d 3e 6f 62 6a 65 63 74 5b 28 74 61 62 6c 65 2d |->object[(table-| 00000150 3e 6e 65 78 74 5f 66 72 65 65 29 2d 31 5d 29 29 |>next_free)-1]))| 00000160 3b 0a 20 20 7d 0a 0a 20 20 66 6f 72 20 28 63 68 |;. }.. for (ch| 00000170 65 63 6b 5f 6f 62 6a 65 63 74 20 3d 20 30 3b 20 |eck_object = 0; | 00000180 63 68 65 63 6b 5f 6f 62 6a 65 63 74 20 3c 20 74 |check_object < t| 00000190 61 62 6c 65 2d 3e 6d 61 78 5f 6f 62 6a 65 63 74 |able->max_object| 000001a0 73 3b 20 63 68 65 63 6b 5f 6f 62 6a 65 63 74 2b |s; check_object+| 000001b0 2b 29 0a 20 20 20 20 69 66 20 28 74 61 62 6c 65 |+). if (table| 000001c0 2d 3e 6f 62 6a 65 63 74 5b 63 68 65 63 6b 5f 6f |->object[check_o| 000001d0 62 6a 65 63 74 5d 2e 6f 62 6a 65 63 74 5f 69 64 |bject].object_id| 000001e0 20 3d 3d 20 30 29 0a 20 20 20 20 20 20 72 65 74 | == 0). ret| 000001f0 75 72 6e 28 26 74 61 62 6c 65 2d 3e 6f 62 6a 65 |urn(&table->obje| 00000200 63 74 5b 63 68 65 63 6b 5f 6f 62 6a 65 63 74 5d |ct[check_object]| 00000210 29 3b 0a 0a 20 20 72 65 74 75 72 6e 28 4e 55 4c |);.. return(NUL| 00000220 4c 29 3b 0a 7d 0a |L);.}.| 00000226