[56] | 1 | /* |
---|
| 2 | * Abuse - dark 2D side-scrolling platform game |
---|
| 3 | * Copyright (c) 1995 Crack dot Com |
---|
[494] | 4 | * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> |
---|
[56] | 5 | * |
---|
| 6 | * This software was released into the Public Domain. As with most public |
---|
[555] | 7 | * domain software, no warranty is made or implied by Crack dot Com, by |
---|
| 8 | * Jonathan Clark, or by Sam Hocevar. |
---|
[56] | 9 | */ |
---|
| 10 | |
---|
[555] | 11 | #if defined HAVE_CONFIG_H |
---|
| 12 | # include "config.h" |
---|
| 13 | #endif |
---|
[56] | 14 | |
---|
[512] | 15 | #include "common.h" |
---|
| 16 | |
---|
[481] | 17 | #include "seq.h" |
---|
| 18 | #include "lisp.h" |
---|
[2] | 19 | |
---|
[527] | 20 | size_t sequence::MemUsage() |
---|
[2] | 21 | { |
---|
[527] | 22 | size_t t = 0; |
---|
| 23 | for (int i = 0; i < total; i++) |
---|
| 24 | if (cache.loaded(seq[i])) |
---|
| 25 | t += cache.fig(seq[i])->MemUsage(); |
---|
| 26 | return t; |
---|
[2] | 27 | } |
---|
| 28 | |
---|
| 29 | int sequence::cache_in() |
---|
| 30 | { |
---|
| 31 | int i; |
---|
[494] | 32 | for (i=0; i<total; i++) |
---|
[2] | 33 | { |
---|
[123] | 34 | cache.note_need(seq[i]); |
---|
[2] | 35 | } |
---|
| 36 | return 1; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | sequence::sequence(char *filename, void *pict_list, void *advance_list) |
---|
| 40 | { |
---|
| 41 | if (item_type(pict_list)==L_STRING) |
---|
| 42 | total=1; |
---|
| 43 | else |
---|
[492] | 44 | total = ((LList *)pict_list)->GetLength(); |
---|
[2] | 45 | |
---|
[129] | 46 | seq=(int *) malloc(sizeof(int)*total); |
---|
[2] | 47 | if (item_type(pict_list)==L_STRING) |
---|
[503] | 48 | seq[0]=cache.reg_object(filename,(LObject *)pict_list,SPEC_CHARACTER2,1); |
---|
[2] | 49 | else |
---|
| 50 | { |
---|
| 51 | int i; |
---|
[494] | 52 | for (i=0; i<total; i++) |
---|
[2] | 53 | { |
---|
[123] | 54 | seq[i]=cache.reg_object(filename,lcar(pict_list),SPEC_CHARACTER2,1); |
---|
[2] | 55 | pict_list=lcdr(pict_list); |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | sequence::~sequence() |
---|
[124] | 61 | { |
---|
[129] | 62 | free(seq); |
---|
[2] | 63 | } |
---|
| 64 | |
---|
| 65 | /*sequence::sequence(char *filename, char *picts) |
---|
| 66 | { |
---|
[124] | 67 | char t[100],*s=picts,imname[100]; |
---|
[2] | 68 | int i,j; |
---|
[124] | 69 | total=0; |
---|
[2] | 70 | |
---|
| 71 | // first count the images |
---|
| 72 | while (token_type(s)!=sRIGHT_PAREN) |
---|
| 73 | { |
---|
| 74 | if (token_type(s)==sLEFT_PAREN) |
---|
| 75 | { |
---|
| 76 | get_token(s,t); // left paren |
---|
| 77 | get_token(s,t); // seq |
---|
| 78 | get_token(s,t); // name |
---|
[124] | 79 | i=get_number(s); |
---|
| 80 | total+=get_number(s)-i+1; |
---|
[2] | 81 | get_token(s,t); // right paren |
---|
[124] | 82 | } |
---|
| 83 | else |
---|
[2] | 84 | { get_token(s,t); |
---|
[124] | 85 | total++; |
---|
| 86 | } |
---|
[2] | 87 | } |
---|
| 88 | |
---|
[124] | 89 | |
---|
| 90 | s=picts; |
---|
[129] | 91 | seq=(int *) malloc(sizeof(int)*total); |
---|
[124] | 92 | |
---|
[494] | 93 | for (i=0; i<total; ) |
---|
[2] | 94 | { |
---|
| 95 | if (get_token(s,t)==sLEFT_PAREN) |
---|
| 96 | { |
---|
| 97 | get_token(s,t); // left paren |
---|
| 98 | if (strcmp(t,"seq")) |
---|
| 99 | { |
---|
[124] | 100 | printf("Expected seq at %s\n",s); |
---|
[494] | 101 | exit(0); |
---|
[2] | 102 | } |
---|
| 103 | get_token(s,t); |
---|
| 104 | int start,end; |
---|
| 105 | start=get_number(s); |
---|
| 106 | end=get_number(s); |
---|
[494] | 107 | for (j=start; j<=end; j++) |
---|
[2] | 108 | { |
---|
[124] | 109 | sprintf(imname,"%s%04d.pcx",t,j); |
---|
| 110 | seq[i++]=cache.reg(filename,imname,SPEC_CHARACTER,1); |
---|
| 111 | } |
---|
[2] | 112 | get_token(s,t); // right paren |
---|
| 113 | } |
---|
| 114 | else |
---|
[123] | 115 | seq[i++]=cache.reg(filename,t,SPEC_CHARACTER,1); |
---|
[2] | 116 | } |
---|
| 117 | }*/ |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | |
---|