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