Home » Archimedes archive » Acorn User » AU 1996-Xmas.adf » Features » Arcade/!Popcorn/c/LoadProto
Arcade/!Popcorn/c/LoadProto
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/LoadProto |
Read OK: | ✔ |
File size: | 14B1 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "Popcorn:h.Popcorn" os_error err_returned; os_error *err(char *msg, int line, FILE *handle) { sprintf(err_returned.errmess, "LoadPrototype: %s (line %d).", msg, line); if (handle != NULL) fclose(handle); return(&err_returned); } os_error *Popcorn_LoadPrototypes(char *proto_filename) { FILE *handle, *sprite_handle; char line[1024], filename[256], *variable = line, *value, *chk; int c, current_frame = 0, next_id = 0, frames = 0, line_num = 0, sx, sy, cx, cy; struct prototype *cp = NULL; struct { int height, width; } sprite_header; handle = fopen(proto_filename, "rb"); if (handle == NULL) { return(err("Couldn't open prototypes file", 0, NULL)); } while (!feof(handle)) { /* Get string from file, change LF terminator to zero byte */ chk = fgets(line, 1024, handle); line_num++; for(c=0; line[c]>31; c++); line[c]=0; /* Sort out 'variable' and 'value', skip spaces and things... */ if (line[0] != '#' && line[0] > 31 && chk != NULL) { c=0; while (line[c] != ' ') c++; line[c] = 0; while (line[c] != '=') c++; c++; while (line[c] == ' ') c++; value = &line[c]; if (strcmp(variable, "id") == 0) { if (current_frame != frames ) { return(err("New prototype started without finishing all the frames of previous one", line_num, handle)); } sscanf(value, "%s %d", &next_id, &frames); current_frame = 0; /* printf("%X %d frames\n", next_id, frames); */ if ( (prototype[prototype_free] = malloc(sizeof(struct prototype) + (sizeof(struct frame_data)*(frames-1)))) == NULL) { return(err("Couldn't allocate memory for prototype", line_num, handle)); } cp = prototype[prototype_free]; /* Just shorthand... */ prototype_free++; cp->id = next_id; next_id = 0; cp->handler = NULL; cp->flags.word = 0; cp->animation.frames = frames; for (c=0; c!=frames; c++) cp->animation.frame[c].sprite_anchor = NULL; } if (strcmp(variable, "handler") == 0) { cp->handler = Popcorn_FindSymbol(value); /* printf("handler: %X\n", cp->handler); */ } if (strcmp(variable, "objflags") == 0) { if (strstr(value,"std_plot")!=0) cp->flags.bits.std_plot = TRUE; if (strstr(value,"animate")!=0) cp->flags.bits.animate = TRUE; if (strstr(value,"collide")!=0) cp->flags.bits.collide = TRUE; if (strstr(value,"velocities")!=0) cp->flags.bits.velocities = TRUE; if (strstr(value,"gravity")!=0) cp->flags.bits.gravity = TRUE; if (strstr(value,"attn_every")!=0) cp->flags.bits.attn_every = TRUE; if (strstr(value,"attn_plot")!=0) cp->flags.bits.attn_plot = TRUE; if (strstr(value,"attn_timer")!=0) cp->flags.bits.attn_timer = TRUE; if (strstr(value,"attn_plotout")!=0) cp->flags.bits.attn_plotout = TRUE; if (strstr(value,"attn_gameout")!=0) cp->flags.bits.attn_gameout = TRUE; if (strstr(value,"attn_userout")!=0) cp->flags.bits.attn_userout = TRUE; if (strstr(value,"kill_timer")!=0) cp->flags.bits.kill_timer = TRUE; if (strstr(value,"kill_plotout")!=0) cp->flags.bits.kill_plotout = TRUE; if (strstr(value,"kill_gameout")!=0) cp->flags.bits.kill_gameout = TRUE; if (strstr(value,"kill_userout")!=0) cp->flags.bits.kill_userout = TRUE; if (strstr(value,"yoyo")!=0) cp->flags.bits.yoyo = TRUE; /* printf("flags: %X\n", cp->flags.word); */ } if (strcmp(variable, "frame") == 0) { if (current_frame == frames) { return(err("Too many frames", line_num, handle)); } sx = sy = cx = cy = -1; if (strstr(value, "S@") != 0) sscanf(strstr(value, "S@"), "S@%d,%d", &sx, &sy); if (strstr(value, "C@") != 0) sscanf(strstr(value, "C@"), "C@%d,%d", &cx, &cy); sscanf(value, "%s ", filename); if (sx == -1) { /* printf("trying: %s\n", filename); */ sprite_handle = fopen(filename, "rb"); if (sprite_handle == NULL) { return(err("Couldn't open sprite file", line_num, handle)); } fread(&sprite_header, 4, 2, sprite_handle); fclose(sprite_handle); sx = sprite_header.width - 1; sy = sprite_header.height - 1; } if (cx == -1) { cx = (sx+1) >> 1; cy = (sy+1) >> 1; } cp->animation.frame[current_frame].centre_x = cx; cp->animation.frame[current_frame].centre_y = cy; cp->animation.frame[current_frame].size_x = sx; cp->animation.frame[current_frame].size_y = sy; cp->animation.frame[current_frame].sprite_anchor = Popcorn_FindResource(filename); /* printf("frame %d: S@%d,%d C@%d,%d %08X %s\n", current_frame, sx, sy, cx, cy, cp->animation.frame[current_frame].sprite_anchor, filename); */ current_frame++; } } } fclose(handle); return(NULL); }
00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 6c 69 62 |#include <stdlib| 00000010 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 |.h>.#include <st| 00000020 64 69 6f 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 |dio.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 50 6f 70 63 6f 72 6e 3a 68 2e |lude "Popcorn:h.| 00000050 50 6f 70 63 6f 72 6e 22 0a 0a 6f 73 5f 65 72 72 |Popcorn"..os_err| 00000060 6f 72 20 65 72 72 5f 72 65 74 75 72 6e 65 64 3b |or err_returned;| 00000070 0a 0a 6f 73 5f 65 72 72 6f 72 20 2a 65 72 72 28 |..os_error *err(| 00000080 63 68 61 72 20 2a 6d 73 67 2c 20 69 6e 74 20 6c |char *msg, int l| 00000090 69 6e 65 2c 20 46 49 4c 45 20 2a 68 61 6e 64 6c |ine, FILE *handl| 000000a0 65 29 0a 7b 0a 20 20 73 70 72 69 6e 74 66 28 65 |e).{. sprintf(e| 000000b0 72 72 5f 72 65 74 75 72 6e 65 64 2e 65 72 72 6d |rr_returned.errm| 000000c0 65 73 73 2c 20 22 4c 6f 61 64 50 72 6f 74 6f 74 |ess, "LoadProtot| 000000d0 79 70 65 3a 20 25 73 20 28 6c 69 6e 65 20 25 64 |ype: %s (line %d| 000000e0 29 2e 22 2c 20 6d 73 67 2c 20 6c 69 6e 65 29 3b |).", msg, line);| 000000f0 0a 20 20 69 66 20 28 68 61 6e 64 6c 65 20 21 3d |. if (handle !=| 00000100 20 4e 55 4c 4c 29 20 66 63 6c 6f 73 65 28 68 61 | NULL) fclose(ha| 00000110 6e 64 6c 65 29 3b 0a 20 20 72 65 74 75 72 6e 28 |ndle);. return(| 00000120 26 65 72 72 5f 72 65 74 75 72 6e 65 64 29 3b 0a |&err_returned);.| 00000130 7d 0a 0a 6f 73 5f 65 72 72 6f 72 20 2a 50 6f 70 |}..os_error *Pop| 00000140 63 6f 72 6e 5f 4c 6f 61 64 50 72 6f 74 6f 74 79 |corn_LoadPrototy| 00000150 70 65 73 28 63 68 61 72 20 2a 70 72 6f 74 6f 5f |pes(char *proto_| 00000160 66 69 6c 65 6e 61 6d 65 29 0a 7b 0a 20 20 46 49 |filename).{. FI| 00000170 4c 45 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |LE | 00000180 20 20 2a 68 61 6e 64 6c 65 2c 20 2a 73 70 72 69 | *handle, *spri| 00000190 74 65 5f 68 61 6e 64 6c 65 3b 0a 20 20 63 68 61 |te_handle;. cha| 000001a0 72 09 09 20 20 20 20 20 20 6c 69 6e 65 5b 31 30 |r.. line[10| 000001b0 32 34 5d 2c 20 66 69 6c 65 6e 61 6d 65 5b 32 35 |24], filename[25| 000001c0 36 5d 2c 20 2a 76 61 72 69 61 62 6c 65 20 3d 20 |6], *variable = | 000001d0 6c 69 6e 65 2c 20 2a 76 61 6c 75 65 2c 0a 20 20 |line, *value,. | 000001e0 09 09 20 20 20 20 20 20 2a 63 68 6b 3b 0a 20 20 |.. *chk;. | 000001f0 69 6e 74 09 09 20 20 20 20 20 20 63 2c 20 63 75 |int.. c, cu| 00000200 72 72 65 6e 74 5f 66 72 61 6d 65 20 3d 20 30 2c |rrent_frame = 0,| 00000210 20 6e 65 78 74 5f 69 64 20 3d 20 30 2c 20 66 72 | next_id = 0, fr| 00000220 61 6d 65 73 20 3d 20 30 2c 0a 20 20 09 09 20 20 |ames = 0,. .. | 00000230 20 20 20 20 6c 69 6e 65 5f 6e 75 6d 20 3d 20 30 | line_num = 0| 00000240 2c 20 73 78 2c 20 73 79 2c 20 63 78 2c 20 63 79 |, sx, sy, cx, cy| 00000250 3b 0a 20 20 73 74 72 75 63 74 20 70 72 6f 74 6f |;. struct proto| 00000260 74 79 70 65 20 20 20 20 2a 63 70 20 3d 20 4e 55 |type *cp = NU| 00000270 4c 4c 3b 0a 20 20 73 74 72 75 63 74 0a 20 20 7b |LL;. struct. {| 00000280 0a 20 20 20 20 69 6e 74 20 68 65 69 67 68 74 2c |. int height,| 00000290 20 77 69 64 74 68 3b 0a 20 20 7d 20 73 70 72 69 | width;. } spri| 000002a0 74 65 5f 68 65 61 64 65 72 3b 0a 0a 0a 20 20 68 |te_header;... h| 000002b0 61 6e 64 6c 65 20 3d 20 66 6f 70 65 6e 28 70 72 |andle = fopen(pr| 000002c0 6f 74 6f 5f 66 69 6c 65 6e 61 6d 65 2c 20 22 72 |oto_filename, "r| 000002d0 62 22 29 3b 0a 0a 20 20 69 66 20 28 68 61 6e 64 |b");.. if (hand| 000002e0 6c 65 20 3d 3d 20 4e 55 4c 4c 29 0a 20 20 7b 0a |le == NULL). {.| 000002f0 20 20 20 20 72 65 74 75 72 6e 28 65 72 72 28 22 | return(err("| 00000300 43 6f 75 6c 64 6e 27 74 20 6f 70 65 6e 20 70 72 |Couldn't open pr| 00000310 6f 74 6f 74 79 70 65 73 20 66 69 6c 65 22 2c 20 |ototypes file", | 00000320 30 2c 20 4e 55 4c 4c 29 29 3b 0a 20 20 7d 0a 0a |0, NULL));. }..| 00000330 20 20 77 68 69 6c 65 20 28 21 66 65 6f 66 28 68 | while (!feof(h| 00000340 61 6e 64 6c 65 29 29 0a 20 20 7b 0a 0a 2f 2a 20 |andle)). {../* | 00000350 47 65 74 20 73 74 72 69 6e 67 20 66 72 6f 6d 20 |Get string from | 00000360 66 69 6c 65 2c 20 63 68 61 6e 67 65 20 4c 46 20 |file, change LF | 00000370 74 65 72 6d 69 6e 61 74 6f 72 20 74 6f 20 7a 65 |terminator to ze| 00000380 72 6f 20 62 79 74 65 20 2a 2f 0a 0a 20 20 20 20 |ro byte */.. | 00000390 63 68 6b 20 3d 20 66 67 65 74 73 28 6c 69 6e 65 |chk = fgets(line| 000003a0 2c 20 31 30 32 34 2c 20 68 61 6e 64 6c 65 29 3b |, 1024, handle);| 000003b0 0a 0a 20 20 20 20 6c 69 6e 65 5f 6e 75 6d 2b 2b |.. line_num++| 000003c0 3b 0a 20 20 20 20 66 6f 72 28 63 3d 30 3b 20 6c |;. for(c=0; l| 000003d0 69 6e 65 5b 63 5d 3e 33 31 3b 20 63 2b 2b 29 3b |ine[c]>31; c++);| 000003e0 0a 20 20 20 20 6c 69 6e 65 5b 63 5d 3d 30 3b 0a |. line[c]=0;.| 000003f0 0a 20 2f 2a 20 53 6f 72 74 20 6f 75 74 20 27 76 |. /* Sort out 'v| 00000400 61 72 69 61 62 6c 65 27 20 61 6e 64 20 27 76 61 |ariable' and 'va| 00000410 6c 75 65 27 2c 20 73 6b 69 70 20 73 70 61 63 65 |lue', skip space| 00000420 73 20 61 6e 64 20 74 68 69 6e 67 73 2e 2e 2e 20 |s and things... | 00000430 2a 2f 0a 0a 20 20 20 20 69 66 20 28 6c 69 6e 65 |*/.. if (line| 00000440 5b 30 5d 20 21 3d 20 27 23 27 20 26 26 20 6c 69 |[0] != '#' && li| 00000450 6e 65 5b 30 5d 20 3e 20 33 31 20 26 26 20 63 68 |ne[0] > 31 && ch| 00000460 6b 20 21 3d 20 4e 55 4c 4c 29 0a 20 20 20 20 7b |k != NULL). {| 00000470 0a 20 20 20 20 20 20 63 3d 30 3b 0a 20 20 20 20 |. c=0;. | 00000480 20 20 77 68 69 6c 65 20 28 6c 69 6e 65 5b 63 5d | while (line[c]| 00000490 20 21 3d 20 27 20 27 29 20 63 2b 2b 3b 0a 20 20 | != ' ') c++;. | 000004a0 20 20 20 20 6c 69 6e 65 5b 63 5d 20 3d 20 30 3b | line[c] = 0;| 000004b0 0a 20 20 20 20 20 20 77 68 69 6c 65 20 28 6c 69 |. while (li| 000004c0 6e 65 5b 63 5d 20 21 3d 20 27 3d 27 29 20 63 2b |ne[c] != '=') c+| 000004d0 2b 3b 0a 20 20 20 20 20 20 63 2b 2b 3b 0a 20 20 |+;. c++;. | 000004e0 20 20 20 20 77 68 69 6c 65 20 28 6c 69 6e 65 5b | while (line[| 000004f0 63 5d 20 3d 3d 20 27 20 27 29 20 63 2b 2b 3b 0a |c] == ' ') c++;.| 00000500 20 20 20 20 20 20 76 61 6c 75 65 20 3d 20 26 6c | value = &l| 00000510 69 6e 65 5b 63 5d 3b 0a 0a 20 20 20 20 20 20 69 |ine[c];.. i| 00000520 66 20 28 73 74 72 63 6d 70 28 76 61 72 69 61 62 |f (strcmp(variab| 00000530 6c 65 2c 20 22 69 64 22 29 20 3d 3d 20 30 29 0a |le, "id") == 0).| 00000540 20 20 20 20 20 20 7b 0a 20 20 20 20 20 20 20 20 | {. | 00000550 69 66 20 28 63 75 72 72 65 6e 74 5f 66 72 61 6d |if (current_fram| 00000560 65 20 21 3d 20 66 72 61 6d 65 73 20 29 0a 20 20 |e != frames ). | 00000570 20 20 20 20 20 20 7b 0a 20 20 20 20 20 20 20 20 | {. | 00000580 20 20 72 65 74 75 72 6e 28 65 72 72 28 22 4e 65 | return(err("Ne| 00000590 77 20 70 72 6f 74 6f 74 79 70 65 20 73 74 61 72 |w prototype star| 000005a0 74 65 64 20 77 69 74 68 6f 75 74 20 66 69 6e 69 |ted without fini| 000005b0 73 68 69 6e 67 20 61 6c 6c 20 74 68 65 20 66 72 |shing all the fr| 000005c0 61 6d 65 73 20 6f 66 20 70 72 65 76 69 6f 75 73 |ames of previous| 000005d0 20 6f 6e 65 22 2c 20 6c 69 6e 65 5f 6e 75 6d 2c | one", line_num,| 000005e0 20 68 61 6e 64 6c 65 29 29 3b 0a 20 20 20 20 20 | handle));. | 000005f0 20 20 20 7d 0a 20 20 20 20 20 20 20 20 73 73 63 | }. ssc| 00000600 61 6e 66 28 76 61 6c 75 65 2c 20 22 25 73 20 25 |anf(value, "%s %| 00000610 64 22 2c 20 26 6e 65 78 74 5f 69 64 2c 20 26 66 |d", &next_id, &f| 00000620 72 61 6d 65 73 29 3b 20 63 75 72 72 65 6e 74 5f |rames); current_| 00000630 66 72 61 6d 65 20 3d 20 30 3b 0a 0a 2f 2a 20 20 |frame = 0;../* | 00000640 20 20 20 20 20 20 20 70 72 69 6e 74 66 28 22 25 | printf("%| 00000650 58 20 25 64 20 66 72 61 6d 65 73 5c 6e 22 2c 20 |X %d frames\n", | 00000660 6e 65 78 74 5f 69 64 2c 20 66 72 61 6d 65 73 29 |next_id, frames)| 00000670 3b 20 2a 2f 0a 20 20 20 20 20 20 20 20 69 66 20 |; */. if | 00000680 28 20 28 70 72 6f 74 6f 74 79 70 65 5b 70 72 6f |( (prototype[pro| 00000690 74 6f 74 79 70 65 5f 66 72 65 65 5d 20 3d 20 6d |totype_free] = m| 000006a0 61 6c 6c 6f 63 28 73 69 7a 65 6f 66 28 73 74 72 |alloc(sizeof(str| 000006b0 75 63 74 20 70 72 6f 74 6f 74 79 70 65 29 20 2b |uct prototype) +| 000006c0 20 28 73 69 7a 65 6f 66 28 73 74 72 75 63 74 20 | (sizeof(struct | 000006d0 66 72 61 6d 65 5f 64 61 74 61 29 2a 28 66 72 61 |frame_data)*(fra| 000006e0 6d 65 73 2d 31 29 29 29 29 20 3d 3d 20 4e 55 4c |mes-1)))) == NUL| 000006f0 4c 29 0a 20 20 20 20 20 20 20 20 7b 0a 20 20 20 |L). {. | 00000700 20 20 20 20 20 20 20 72 65 74 75 72 6e 28 65 72 | return(er| 00000710 72 28 22 43 6f 75 6c 64 6e 27 74 20 61 6c 6c 6f |r("Couldn't allo| 00000720 63 61 74 65 20 6d 65 6d 6f 72 79 20 66 6f 72 20 |cate memory for | 00000730 70 72 6f 74 6f 74 79 70 65 22 2c 20 6c 69 6e 65 |prototype", line| 00000740 5f 6e 75 6d 2c 20 68 61 6e 64 6c 65 29 29 3b 0a |_num, handle));.| 00000750 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 | }. | 00000760 20 20 63 70 20 3d 20 70 72 6f 74 6f 74 79 70 65 | cp = prototype| 00000770 5b 70 72 6f 74 6f 74 79 70 65 5f 66 72 65 65 5d |[prototype_free]| 00000780 3b 20 2f 2a 20 4a 75 73 74 20 73 68 6f 72 74 68 |; /* Just shorth| 00000790 61 6e 64 2e 2e 2e 20 2a 2f 0a 20 20 20 20 20 20 |and... */. | 000007a0 20 20 70 72 6f 74 6f 74 79 70 65 5f 66 72 65 65 | prototype_free| 000007b0 2b 2b 3b 0a 20 20 20 20 20 20 20 20 63 70 2d 3e |++;. cp->| 000007c0 69 64 20 20 20 20 20 20 3d 20 6e 65 78 74 5f 69 |id = next_i| 000007d0 64 3b 20 6e 65 78 74 5f 69 64 20 3d 20 30 3b 0a |d; next_id = 0;.| 000007e0 20 20 20 20 20 20 20 20 63 70 2d 3e 68 61 6e 64 | cp->hand| 000007f0 6c 65 72 20 3d 20 4e 55 4c 4c 3b 20 63 70 2d 3e |ler = NULL; cp->| 00000800 66 6c 61 67 73 2e 77 6f 72 64 20 3d 20 30 3b 0a |flags.word = 0;.| 00000810 20 20 20 20 20 20 20 20 63 70 2d 3e 61 6e 69 6d | cp->anim| 00000820 61 74 69 6f 6e 2e 66 72 61 6d 65 73 20 3d 20 66 |ation.frames = f| 00000830 72 61 6d 65 73 3b 0a 20 20 20 20 20 20 20 20 66 |rames;. f| 00000840 6f 72 20 28 63 3d 30 3b 20 63 21 3d 66 72 61 6d |or (c=0; c!=fram| 00000850 65 73 3b 20 63 2b 2b 29 0a 20 20 20 20 20 20 20 |es; c++). | 00000860 20 20 20 63 70 2d 3e 61 6e 69 6d 61 74 69 6f 6e | cp->animation| 00000870 2e 66 72 61 6d 65 5b 63 5d 2e 73 70 72 69 74 65 |.frame[c].sprite| 00000880 5f 61 6e 63 68 6f 72 20 3d 20 4e 55 4c 4c 3b 0a |_anchor = NULL;.| 00000890 20 20 20 20 20 20 7d 0a 0a 20 20 20 20 20 20 69 | }.. i| 000008a0 66 20 28 73 74 72 63 6d 70 28 76 61 72 69 61 62 |f (strcmp(variab| 000008b0 6c 65 2c 20 22 68 61 6e 64 6c 65 72 22 29 20 3d |le, "handler") =| 000008c0 3d 20 30 29 0a 20 20 20 20 20 20 7b 0a 20 20 20 |= 0). {. | 000008d0 20 20 20 20 20 63 70 2d 3e 68 61 6e 64 6c 65 72 | cp->handler| 000008e0 20 3d 20 50 6f 70 63 6f 72 6e 5f 46 69 6e 64 53 | = Popcorn_FindS| 000008f0 79 6d 62 6f 6c 28 76 61 6c 75 65 29 3b 0a 2f 2a |ymbol(value);./*| 00000900 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 66 28 | printf(| 00000910 22 68 61 6e 64 6c 65 72 3a 20 25 58 5c 6e 22 2c |"handler: %X\n",| 00000920 20 63 70 2d 3e 68 61 6e 64 6c 65 72 29 3b 20 2a | cp->handler); *| 00000930 2f 0a 20 20 20 20 20 20 7d 0a 0a 20 20 20 20 20 |/. }.. | 00000940 20 69 66 20 28 73 74 72 63 6d 70 28 76 61 72 69 | if (strcmp(vari| 00000950 61 62 6c 65 2c 20 22 6f 62 6a 66 6c 61 67 73 22 |able, "objflags"| 00000960 29 20 3d 3d 20 30 29 0a 20 20 20 20 20 20 7b 0a |) == 0). {.| 00000970 20 20 20 20 20 20 20 20 69 66 20 28 73 74 72 73 | if (strs| 00000980 74 72 28 76 61 6c 75 65 2c 22 73 74 64 5f 70 6c |tr(value,"std_pl| 00000990 6f 74 22 29 21 3d 30 29 20 20 20 20 20 63 70 2d |ot")!=0) cp-| 000009a0 3e 66 6c 61 67 73 2e 62 69 74 73 2e 73 74 64 5f |>flags.bits.std_| 000009b0 70 6c 6f 74 20 20 20 20 20 3d 20 54 52 55 45 3b |plot = TRUE;| 000009c0 0a 20 20 20 20 20 20 20 20 69 66 20 28 73 74 72 |. if (str| 000009d0 73 74 72 28 76 61 6c 75 65 2c 22 61 6e 69 6d 61 |str(value,"anima| 000009e0 74 65 22 29 21 3d 30 29 20 20 20 20 20 20 63 70 |te")!=0) cp| 000009f0 2d 3e 66 6c 61 67 73 2e 62 69 74 73 2e 61 6e 69 |->flags.bits.ani| 00000a00 6d 61 74 65 20 20 20 20 20 20 3d 20 54 52 55 45 |mate = TRUE| 00000a10 3b 0a 20 20 20 20 20 20 20 20 69 66 20 28 73 74 |;. if (st| 00000a20 72 73 74 72 28 76 61 6c 75 65 2c 22 63 6f 6c 6c |rstr(value,"coll| 00000a30 69 64 65 22 29 21 3d 30 29 20 20 20 20 20 20 63 |ide")!=0) c| 00000a40 70 2d 3e 66 6c 61 67 73 2e 62 69 74 73 2e 63 6f |p->flags.bits.co| 00000a50 6c 6c 69 64 65 20 20 20 20 20 20 3d 20 54 52 55 |llide = TRU| 00000a60 45 3b 0a 20 20 20 20 20 20 20 20 69 66 20 28 73 |E;. if (s| 00000a70 74 72 73 74 72 28 76 61 6c 75 65 2c 22 76 65 6c |trstr(value,"vel| 00000a80 6f 63 69 74 69 65 73 22 29 21 3d 30 29 20 20 20 |ocities")!=0) | 00000a90 63 70 2d 3e 66 6c 61 67 73 2e 62 69 74 73 2e 76 |cp->flags.bits.v| 00000aa0 65 6c 6f 63 69 74 69 65 73 20 20 20 3d 20 54 52 |elocities = TR| 00000ab0 55 45 3b 0a 20 20 20 20 20 20 20 20 69 66 20 28 |UE;. if (| 00000ac0 73 74 72 73 74 72 28 76 61 6c 75 65 2c 22 67 72 |strstr(value,"gr| 00000ad0 61 76 69 74 79 22 29 21 3d 30 29 20 20 20 20 20 |avity")!=0) | 00000ae0 20 63 70 2d 3e 66 6c 61 67 73 2e 62 69 74 73 2e | cp->flags.bits.| 00000af0 67 72 61 76 69 74 79 20 20 20 20 20 20 3d 20 54 |gravity = T| 00000b00 52 55 45 3b 0a 20 20 20 20 20 20 20 20 69 66 20 |RUE;. if | 00000b10 28 73 74 72 73 74 72 28 76 61 6c 75 65 2c 22 61 |(strstr(value,"a| 00000b20 74 74 6e 5f 65 76 65 72 79 22 29 21 3d 30 29 20 |ttn_every")!=0) | 00000b30 20 20 63 70 2d 3e 66 6c 61 67 73 2e 62 69 74 73 | cp->flags.bits| 00000b40 2e 61 74 74 6e 5f 65 76 65 72 79 20 20 20 3d 20 |.attn_every = | 00000b50 54 52 55 45 3b 0a 20 20 20 20 20 20 20 20 69 66 |TRUE;. if| 00000b60 20 28 73 74 72 73 74 72 28 76 61 6c 75 65 2c 22 | (strstr(value,"| 00000b70 61 74 74 6e 5f 70 6c 6f 74 22 29 21 3d 30 29 20 |attn_plot")!=0) | 00000b80 20 20 20 63 70 2d 3e 66 6c 61 67 73 2e 62 69 74 | cp->flags.bit| 00000b90 73 2e 61 74 74 6e 5f 70 6c 6f 74 20 20 20 20 3d |s.attn_plot =| 00000ba0 20 54 52 55 45 3b 0a 20 20 20 20 20 20 20 20 69 | TRUE;. i| 00000bb0 66 20 28 73 74 72 73 74 72 28 76 61 6c 75 65 2c |f (strstr(value,| 00000bc0 22 61 74 74 6e 5f 74 69 6d 65 72 22 29 21 3d 30 |"attn_timer")!=0| 00000bd0 29 20 20 20 63 70 2d 3e 66 6c 61 67 73 2e 62 69 |) cp->flags.bi| 00000be0 74 73 2e 61 74 74 6e 5f 74 69 6d 65 72 20 20 20 |ts.attn_timer | 00000bf0 3d 20 54 52 55 45 3b 0a 20 20 20 20 20 20 20 20 |= TRUE;. | 00000c00 69 66 20 28 73 74 72 73 74 72 28 76 61 6c 75 65 |if (strstr(value| 00000c10 2c 22 61 74 74 6e 5f 70 6c 6f 74 6f 75 74 22 29 |,"attn_plotout")| 00000c20 21 3d 30 29 20 63 70 2d 3e 66 6c 61 67 73 2e 62 |!=0) cp->flags.b| 00000c30 69 74 73 2e 61 74 74 6e 5f 70 6c 6f 74 6f 75 74 |its.attn_plotout| 00000c40 20 3d 20 54 52 55 45 3b 0a 20 20 20 20 20 20 20 | = TRUE;. | 00000c50 20 69 66 20 28 73 74 72 73 74 72 28 76 61 6c 75 | if (strstr(valu| 00000c60 65 2c 22 61 74 74 6e 5f 67 61 6d 65 6f 75 74 22 |e,"attn_gameout"| 00000c70 29 21 3d 30 29 20 63 70 2d 3e 66 6c 61 67 73 2e |)!=0) cp->flags.| 00000c80 62 69 74 73 2e 61 74 74 6e 5f 67 61 6d 65 6f 75 |bits.attn_gameou| 00000c90 74 20 3d 20 54 52 55 45 3b 0a 20 20 20 20 20 20 |t = TRUE;. | 00000ca0 20 20 69 66 20 28 73 74 72 73 74 72 28 76 61 6c | if (strstr(val| 00000cb0 75 65 2c 22 61 74 74 6e 5f 75 73 65 72 6f 75 74 |ue,"attn_userout| 00000cc0 22 29 21 3d 30 29 20 63 70 2d 3e 66 6c 61 67 73 |")!=0) cp->flags| 00000cd0 2e 62 69 74 73 2e 61 74 74 6e 5f 75 73 65 72 6f |.bits.attn_usero| 00000ce0 75 74 20 3d 20 54 52 55 45 3b 0a 20 20 20 20 20 |ut = TRUE;. | 00000cf0 20 20 20 69 66 20 28 73 74 72 73 74 72 28 76 61 | if (strstr(va| 00000d00 6c 75 65 2c 22 6b 69 6c 6c 5f 74 69 6d 65 72 22 |lue,"kill_timer"| 00000d10 29 21 3d 30 29 20 20 20 63 70 2d 3e 66 6c 61 67 |)!=0) cp->flag| 00000d20 73 2e 62 69 74 73 2e 6b 69 6c 6c 5f 74 69 6d 65 |s.bits.kill_time| 00000d30 72 20 20 20 3d 20 54 52 55 45 3b 0a 20 20 20 20 |r = TRUE;. | 00000d40 20 20 20 20 69 66 20 28 73 74 72 73 74 72 28 76 | if (strstr(v| 00000d50 61 6c 75 65 2c 22 6b 69 6c 6c 5f 70 6c 6f 74 6f |alue,"kill_ploto| 00000d60 75 74 22 29 21 3d 30 29 20 63 70 2d 3e 66 6c 61 |ut")!=0) cp->fla| 00000d70 67 73 2e 62 69 74 73 2e 6b 69 6c 6c 5f 70 6c 6f |gs.bits.kill_plo| 00000d80 74 6f 75 74 20 3d 20 54 52 55 45 3b 0a 20 20 20 |tout = TRUE;. | 00000d90 20 20 20 20 20 69 66 20 28 73 74 72 73 74 72 28 | if (strstr(| 00000da0 76 61 6c 75 65 2c 22 6b 69 6c 6c 5f 67 61 6d 65 |value,"kill_game| 00000db0 6f 75 74 22 29 21 3d 30 29 20 63 70 2d 3e 66 6c |out")!=0) cp->fl| 00000dc0 61 67 73 2e 62 69 74 73 2e 6b 69 6c 6c 5f 67 61 |ags.bits.kill_ga| 00000dd0 6d 65 6f 75 74 20 3d 20 54 52 55 45 3b 0a 20 20 |meout = TRUE;. | 00000de0 20 20 20 20 20 20 69 66 20 28 73 74 72 73 74 72 | if (strstr| 00000df0 28 76 61 6c 75 65 2c 22 6b 69 6c 6c 5f 75 73 65 |(value,"kill_use| 00000e00 72 6f 75 74 22 29 21 3d 30 29 20 63 70 2d 3e 66 |rout")!=0) cp->f| 00000e10 6c 61 67 73 2e 62 69 74 73 2e 6b 69 6c 6c 5f 75 |lags.bits.kill_u| 00000e20 73 65 72 6f 75 74 20 3d 20 54 52 55 45 3b 0a 20 |serout = TRUE;. | 00000e30 20 20 20 20 20 20 20 69 66 20 28 73 74 72 73 74 | if (strst| 00000e40 72 28 76 61 6c 75 65 2c 22 79 6f 79 6f 22 29 21 |r(value,"yoyo")!| 00000e50 3d 30 29 20 20 20 20 20 20 20 20 20 63 70 2d 3e |=0) cp->| 00000e60 66 6c 61 67 73 2e 62 69 74 73 2e 79 6f 79 6f 20 |flags.bits.yoyo | 00000e70 20 20 20 20 20 20 20 20 3d 20 54 52 55 45 3b 0a | = TRUE;.| 00000e80 2f 2a 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 |/* print| 00000e90 66 28 22 66 6c 61 67 73 3a 20 25 58 5c 6e 22 2c |f("flags: %X\n",| 00000ea0 20 63 70 2d 3e 66 6c 61 67 73 2e 77 6f 72 64 29 | cp->flags.word)| 00000eb0 3b 20 2a 2f 0a 20 20 20 20 20 20 7d 0a 0a 20 20 |; */. }.. | 00000ec0 20 20 20 20 69 66 20 28 73 74 72 63 6d 70 28 76 | if (strcmp(v| 00000ed0 61 72 69 61 62 6c 65 2c 20 22 66 72 61 6d 65 22 |ariable, "frame"| 00000ee0 29 20 3d 3d 20 30 29 0a 20 20 20 20 20 20 7b 0a |) == 0). {.| 00000ef0 20 20 20 20 20 20 20 20 69 66 20 28 63 75 72 72 | if (curr| 00000f00 65 6e 74 5f 66 72 61 6d 65 20 3d 3d 20 66 72 61 |ent_frame == fra| 00000f10 6d 65 73 29 0a 20 20 20 20 20 20 20 20 7b 0a 20 |mes). {. | 00000f20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 28 | return(| 00000f30 65 72 72 28 22 54 6f 6f 20 6d 61 6e 79 20 66 72 |err("Too many fr| 00000f40 61 6d 65 73 22 2c 20 6c 69 6e 65 5f 6e 75 6d 2c |ames", line_num,| 00000f50 20 68 61 6e 64 6c 65 29 29 3b 0a 20 20 20 20 20 | handle));. | 00000f60 20 20 20 7d 0a 0a 20 20 20 20 20 20 20 20 73 78 | }.. sx| 00000f70 20 3d 20 73 79 20 3d 20 63 78 20 3d 20 63 79 20 | = sy = cx = cy | 00000f80 3d 20 2d 31 3b 0a 20 20 20 20 20 20 20 20 69 66 |= -1;. if| 00000f90 20 28 73 74 72 73 74 72 28 76 61 6c 75 65 2c 20 | (strstr(value, | 00000fa0 22 53 40 22 29 20 21 3d 20 30 29 0a 20 20 20 20 |"S@") != 0). | 00000fb0 20 20 20 20 20 20 73 73 63 61 6e 66 28 73 74 72 | sscanf(str| 00000fc0 73 74 72 28 76 61 6c 75 65 2c 20 22 53 40 22 29 |str(value, "S@")| 00000fd0 2c 20 22 53 40 25 64 2c 25 64 22 2c 20 26 73 78 |, "S@%d,%d", &sx| 00000fe0 2c 20 26 73 79 29 3b 0a 20 20 20 20 20 20 20 20 |, &sy);. | 00000ff0 69 66 20 28 73 74 72 73 74 72 28 76 61 6c 75 65 |if (strstr(value| 00001000 2c 20 22 43 40 22 29 20 21 3d 20 30 29 0a 20 20 |, "C@") != 0). | 00001010 20 20 20 20 20 20 20 20 73 73 63 61 6e 66 28 73 | sscanf(s| 00001020 74 72 73 74 72 28 76 61 6c 75 65 2c 20 22 43 40 |trstr(value, "C@| 00001030 22 29 2c 20 22 43 40 25 64 2c 25 64 22 2c 20 26 |"), "C@%d,%d", &| 00001040 63 78 2c 20 26 63 79 29 3b 0a 0a 20 20 20 20 20 |cx, &cy);.. | 00001050 20 20 20 73 73 63 61 6e 66 28 76 61 6c 75 65 2c | sscanf(value,| 00001060 20 22 25 73 20 22 2c 20 66 69 6c 65 6e 61 6d 65 | "%s ", filename| 00001070 29 3b 0a 0a 20 20 20 20 20 20 20 20 69 66 20 28 |);.. if (| 00001080 73 78 20 3d 3d 20 2d 31 29 0a 20 20 20 20 20 20 |sx == -1). | 00001090 20 20 7b 0a 2f 2a 20 20 20 20 20 20 20 20 20 20 | {./* | 000010a0 20 70 72 69 6e 74 66 28 22 74 72 79 69 6e 67 3a | printf("trying:| 000010b0 20 25 73 5c 6e 22 2c 20 66 69 6c 65 6e 61 6d 65 | %s\n", filename| 000010c0 29 3b 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 |); */. | 000010d0 73 70 72 69 74 65 5f 68 61 6e 64 6c 65 20 3d 20 |sprite_handle = | 000010e0 66 6f 70 65 6e 28 66 69 6c 65 6e 61 6d 65 2c 20 |fopen(filename, | 000010f0 22 72 62 22 29 3b 0a 20 20 20 20 20 20 20 20 20 |"rb");. | 00001100 20 69 66 20 28 73 70 72 69 74 65 5f 68 61 6e 64 | if (sprite_hand| 00001110 6c 65 20 3d 3d 20 4e 55 4c 4c 29 0a 20 20 20 20 |le == NULL). | 00001120 20 20 20 20 20 20 7b 0a 20 20 20 20 20 20 20 20 | {. | 00001130 20 20 20 20 72 65 74 75 72 6e 28 65 72 72 28 22 | return(err("| 00001140 43 6f 75 6c 64 6e 27 74 20 6f 70 65 6e 20 73 70 |Couldn't open sp| 00001150 72 69 74 65 20 66 69 6c 65 22 2c 20 6c 69 6e 65 |rite file", line| 00001160 5f 6e 75 6d 2c 20 68 61 6e 64 6c 65 29 29 3b 0a |_num, handle));.| 00001170 20 20 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 | }. | 00001180 20 20 20 20 20 20 66 72 65 61 64 28 26 73 70 72 | fread(&spr| 00001190 69 74 65 5f 68 65 61 64 65 72 2c 20 34 2c 20 32 |ite_header, 4, 2| 000011a0 2c 20 73 70 72 69 74 65 5f 68 61 6e 64 6c 65 29 |, sprite_handle)| 000011b0 3b 0a 20 20 20 20 20 20 20 20 20 20 66 63 6c 6f |;. fclo| 000011c0 73 65 28 73 70 72 69 74 65 5f 68 61 6e 64 6c 65 |se(sprite_handle| 000011d0 29 3b 0a 20 20 20 20 20 20 20 20 20 20 73 78 20 |);. sx | 000011e0 3d 20 73 70 72 69 74 65 5f 68 65 61 64 65 72 2e |= sprite_header.| 000011f0 77 69 64 74 68 20 20 2d 20 31 3b 0a 20 20 20 20 |width - 1;. | 00001200 20 20 20 20 20 20 73 79 20 3d 20 73 70 72 69 74 | sy = sprit| 00001210 65 5f 68 65 61 64 65 72 2e 68 65 69 67 68 74 20 |e_header.height | 00001220 2d 20 31 3b 0a 20 20 20 20 20 20 20 20 7d 0a 0a |- 1;. }..| 00001230 20 20 20 20 20 20 20 20 69 66 20 28 63 78 20 3d | if (cx =| 00001240 3d 20 2d 31 29 0a 20 20 20 20 20 20 20 20 7b 0a |= -1). {.| 00001250 20 20 20 20 20 20 20 20 20 20 63 78 20 3d 20 28 | cx = (| 00001260 73 78 2b 31 29 20 3e 3e 20 31 3b 20 63 79 20 3d |sx+1) >> 1; cy =| 00001270 20 28 73 79 2b 31 29 20 3e 3e 20 31 3b 0a 20 20 | (sy+1) >> 1;. | 00001280 20 20 20 20 20 20 7d 0a 0a 20 20 20 20 20 20 20 | }.. | 00001290 20 63 70 2d 3e 61 6e 69 6d 61 74 69 6f 6e 2e 66 | cp->animation.f| 000012a0 72 61 6d 65 5b 63 75 72 72 65 6e 74 5f 66 72 61 |rame[current_fra| 000012b0 6d 65 5d 2e 63 65 6e 74 72 65 5f 78 20 3d 20 63 |me].centre_x = c| 000012c0 78 3b 0a 20 20 20 20 20 20 20 20 63 70 2d 3e 61 |x;. cp->a| 000012d0 6e 69 6d 61 74 69 6f 6e 2e 66 72 61 6d 65 5b 63 |nimation.frame[c| 000012e0 75 72 72 65 6e 74 5f 66 72 61 6d 65 5d 2e 63 65 |urrent_frame].ce| 000012f0 6e 74 72 65 5f 79 20 3d 20 63 79 3b 0a 20 20 20 |ntre_y = cy;. | 00001300 20 20 20 20 20 63 70 2d 3e 61 6e 69 6d 61 74 69 | cp->animati| 00001310 6f 6e 2e 66 72 61 6d 65 5b 63 75 72 72 65 6e 74 |on.frame[current| 00001320 5f 66 72 61 6d 65 5d 2e 73 69 7a 65 5f 78 20 3d |_frame].size_x =| 00001330 20 73 78 3b 0a 20 20 20 20 20 20 20 20 63 70 2d | sx;. cp-| 00001340 3e 61 6e 69 6d 61 74 69 6f 6e 2e 66 72 61 6d 65 |>animation.frame| 00001350 5b 63 75 72 72 65 6e 74 5f 66 72 61 6d 65 5d 2e |[current_frame].| 00001360 73 69 7a 65 5f 79 20 3d 20 73 79 3b 0a 20 20 20 |size_y = sy;. | 00001370 20 20 20 20 20 63 70 2d 3e 61 6e 69 6d 61 74 69 | cp->animati| 00001380 6f 6e 2e 66 72 61 6d 65 5b 63 75 72 72 65 6e 74 |on.frame[current| 00001390 5f 66 72 61 6d 65 5d 2e 73 70 72 69 74 65 5f 61 |_frame].sprite_a| 000013a0 6e 63 68 6f 72 20 3d 20 50 6f 70 63 6f 72 6e 5f |nchor = Popcorn_| 000013b0 46 69 6e 64 52 65 73 6f 75 72 63 65 28 66 69 6c |FindResource(fil| 000013c0 65 6e 61 6d 65 29 3b 0a 0a 2f 2a 20 20 20 20 20 |ename);../* | 000013d0 20 20 20 20 70 72 69 6e 74 66 28 22 66 72 61 6d | printf("fram| 000013e0 65 20 25 64 3a 20 53 40 25 64 2c 25 64 20 43 40 |e %d: S@%d,%d C@| 000013f0 25 64 2c 25 64 20 25 30 38 58 20 25 73 5c 6e 22 |%d,%d %08X %s\n"| 00001400 2c 20 63 75 72 72 65 6e 74 5f 66 72 61 6d 65 2c |, current_frame,| 00001410 20 73 78 2c 20 73 79 2c 20 63 78 2c 20 63 79 2c | sx, sy, cx, cy,| 00001420 20 63 70 2d 3e 61 6e 69 6d 61 74 69 6f 6e 2e 66 | cp->animation.f| 00001430 72 61 6d 65 5b 63 75 72 72 65 6e 74 5f 66 72 61 |rame[current_fra| 00001440 6d 65 5d 2e 73 70 72 69 74 65 5f 61 6e 63 68 6f |me].sprite_ancho| 00001450 72 2c 20 66 69 6c 65 6e 61 6d 65 29 3b 20 2a 2f |r, filename); */| 00001460 0a 0a 20 20 20 20 20 20 20 20 63 75 72 72 65 6e |.. curren| 00001470 74 5f 66 72 61 6d 65 2b 2b 3b 0a 20 20 20 20 20 |t_frame++;. | 00001480 20 7d 0a 20 20 20 20 7d 0a 20 20 7d 0a 20 20 66 | }. }. }. f| 00001490 63 6c 6f 73 65 28 68 61 6e 64 6c 65 29 3b 0a 20 |close(handle);. | 000014a0 20 72 65 74 75 72 6e 28 4e 55 4c 4c 29 3b 0a 7d | return(NULL);.}| 000014b0 0a |.| 000014b1