Home » Archimedes archive » Acorn User » AU 1996-Xmas.adf » Features » Arcade/!Popcorn/c/LoadGroup
Arcade/!Popcorn/c/LoadGroup
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/LoadGroup |
Read OK: | ✔ |
File size: | 02F6 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/LoadGroup
- Archimedes archive » Acorn User » AU 1997-01 B.adf » Features » Arcade/!Popcorn/c/LoadGroup
File contents
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "DeskLib:h.File" #include "DeskLib:h.Str" #include "Popcorn:h.Popcorn" os_error ERROR_MEMORY = {0, "Not enough memory to load group"}; os_error *Popcorn_LoadGroup(int group) { int c = 0; os_error *err; while (c != resource_free) { if (resource[c]->group == group && resource[c]->addr == NULL) { resource[c]->addr = malloc(resource[c]->size); if (resource[c]->addr == NULL) return(&ERROR_MEMORY); err = File_LoadTo(resource[c]->file, resource[c]->addr, NULL); if (err != NULL) { return(err); } /* printf("Loading %X %s\n", resource[c]->addr, resource[c]->file); */ } c++; } return(NULL); }
00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e |#include <stdio.| 00000010 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 |h>.#include <std| 00000020 6c 69 62 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 |lib.h>.#include | 00000030 3c 73 74 72 69 6e 67 2e 68 3e 0a 0a 23 69 6e 63 |<string.h>..#inc| 00000040 6c 75 64 65 20 22 44 65 73 6b 4c 69 62 3a 68 2e |lude "DeskLib:h.| 00000050 46 69 6c 65 22 0a 23 69 6e 63 6c 75 64 65 20 22 |File".#include "| 00000060 44 65 73 6b 4c 69 62 3a 68 2e 53 74 72 22 0a 0a |DeskLib:h.Str"..| 00000070 23 69 6e 63 6c 75 64 65 20 22 50 6f 70 63 6f 72 |#include "Popcor| 00000080 6e 3a 68 2e 50 6f 70 63 6f 72 6e 22 0a 0a 6f 73 |n:h.Popcorn"..os| 00000090 5f 65 72 72 6f 72 20 45 52 52 4f 52 5f 4d 45 4d |_error ERROR_MEM| 000000a0 4f 52 59 20 3d 20 7b 30 2c 20 22 4e 6f 74 20 65 |ORY = {0, "Not e| 000000b0 6e 6f 75 67 68 20 6d 65 6d 6f 72 79 20 74 6f 20 |nough memory to | 000000c0 6c 6f 61 64 20 67 72 6f 75 70 22 7d 3b 0a 0a 6f |load group"};..o| 000000d0 73 5f 65 72 72 6f 72 20 2a 50 6f 70 63 6f 72 6e |s_error *Popcorn| 000000e0 5f 4c 6f 61 64 47 72 6f 75 70 28 69 6e 74 20 67 |_LoadGroup(int g| 000000f0 72 6f 75 70 29 0a 7b 0a 20 20 69 6e 74 20 20 20 |roup).{. int | 00000100 20 20 20 20 20 63 20 3d 20 30 3b 0a 20 20 6f 73 | c = 0;. os| 00000110 5f 65 72 72 6f 72 20 20 20 2a 65 72 72 3b 0a 0a |_error *err;..| 00000120 20 20 77 68 69 6c 65 20 28 63 20 21 3d 20 72 65 | while (c != re| 00000130 73 6f 75 72 63 65 5f 66 72 65 65 29 0a 20 20 7b |source_free). {| 00000140 0a 20 20 20 20 69 66 20 28 72 65 73 6f 75 72 63 |. if (resourc| 00000150 65 5b 63 5d 2d 3e 67 72 6f 75 70 20 3d 3d 20 67 |e[c]->group == g| 00000160 72 6f 75 70 20 26 26 20 72 65 73 6f 75 72 63 65 |roup && resource| 00000170 5b 63 5d 2d 3e 61 64 64 72 20 3d 3d 20 4e 55 4c |[c]->addr == NUL| 00000180 4c 29 0a 20 20 20 20 7b 0a 20 20 20 20 20 20 72 |L). {. r| 00000190 65 73 6f 75 72 63 65 5b 63 5d 2d 3e 61 64 64 72 |esource[c]->addr| 000001a0 20 3d 20 6d 61 6c 6c 6f 63 28 72 65 73 6f 75 72 | = malloc(resour| 000001b0 63 65 5b 63 5d 2d 3e 73 69 7a 65 29 3b 0a 20 20 |ce[c]->size);. | 000001c0 20 20 20 20 69 66 20 28 72 65 73 6f 75 72 63 65 | if (resource| 000001d0 5b 63 5d 2d 3e 61 64 64 72 20 3d 3d 20 4e 55 4c |[c]->addr == NUL| 000001e0 4c 29 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 |L). retur| 000001f0 6e 28 26 45 52 52 4f 52 5f 4d 45 4d 4f 52 59 29 |n(&ERROR_MEMORY)| 00000200 3b 0a 20 20 20 20 20 20 65 72 72 20 3d 20 46 69 |;. err = Fi| 00000210 6c 65 5f 4c 6f 61 64 54 6f 28 72 65 73 6f 75 72 |le_LoadTo(resour| 00000220 63 65 5b 63 5d 2d 3e 66 69 6c 65 2c 20 72 65 73 |ce[c]->file, res| 00000230 6f 75 72 63 65 5b 63 5d 2d 3e 61 64 64 72 2c 20 |ource[c]->addr, | 00000240 4e 55 4c 4c 29 3b 0a 20 20 20 20 20 20 69 66 20 |NULL);. if | 00000250 28 65 72 72 20 21 3d 20 4e 55 4c 4c 29 0a 20 20 |(err != NULL). | 00000260 20 20 20 20 7b 0a 20 20 20 20 20 20 20 20 72 65 | {. re| 00000270 74 75 72 6e 28 65 72 72 29 3b 0a 20 20 20 20 20 |turn(err);. | 00000280 20 7d 0a 2f 2a 20 20 20 20 20 20 20 70 72 69 6e | }./* prin| 00000290 74 66 28 22 4c 6f 61 64 69 6e 67 20 25 58 20 25 |tf("Loading %X %| 000002a0 73 5c 6e 22 2c 20 72 65 73 6f 75 72 63 65 5b 63 |s\n", resource[c| 000002b0 5d 2d 3e 61 64 64 72 2c 20 72 65 73 6f 75 72 63 |]->addr, resourc| 000002c0 65 5b 63 5d 2d 3e 66 69 6c 65 29 3b 20 2a 2f 0a |e[c]->file); */.| 000002d0 20 20 20 20 7d 0a 20 20 20 20 63 2b 2b 3b 0a 20 | }. c++;. | 000002e0 20 7d 0a 0a 20 20 72 65 74 75 72 6e 28 4e 55 4c | }.. return(NUL| 000002f0 4c 29 3b 0a 7d 0a |L);.}.| 000002f6