source: abuse/trunk/src/seq.cpp @ 682

Last change on this file since 682 was 555, checked in by Sam Hocevar, 8 years ago

ps3: make everything compile on the PS3. Of course, nothing links yet
because so much support is missing.

File size: 2.4 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2011 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 defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "common.h"
16
17#include "seq.h"
18#include "lisp.h"
19
20size_t sequence::MemUsage()
21{
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;
27}
28
29int sequence::cache_in()
30{
31  int i;
32  for (i=0; i<total; i++)
33  {
34    cache.note_need(seq[i]);
35  }
36  return 1;
37}
38
39sequence::sequence(char *filename, void *pict_list, void *advance_list)
40{
41  if (item_type(pict_list)==L_STRING)
42    total=1;
43  else
44    total = ((LList *)pict_list)->GetLength();
45
46  seq=(int *) malloc(sizeof(int)*total);
47  if (item_type(pict_list)==L_STRING)
48    seq[0]=cache.reg_object(filename,(LObject *)pict_list,SPEC_CHARACTER2,1);
49  else
50  {
51    int i;
52    for (i=0; i<total; i++)
53    {
54      seq[i]=cache.reg_object(filename,lcar(pict_list),SPEC_CHARACTER2,1);
55      pict_list=lcdr(pict_list);
56    }
57  }
58}
59
60sequence::~sequence()
61{
62  free(seq);
63}
64
65/*sequence::sequence(char *filename, char *picts)
66{
67  char t[100],*s=picts,imname[100];
68  int i,j;
69  total=0;
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
79      i=get_number(s);
80      total+=get_number(s)-i+1;
81      get_token(s,t);    // right paren
82    }
83    else
84    { get_token(s,t);
85      total++;
86    }
87  }
88
89
90  s=picts;
91  seq=(int *) malloc(sizeof(int)*total);
92
93  for (i=0; i<total; )
94  {
95    if (get_token(s,t)==sLEFT_PAREN)
96    {
97      get_token(s,t);      // left paren
98      if (strcmp(t,"seq"))
99      {
100    printf("Expected seq at %s\n",s);
101    exit(0);
102      }
103      get_token(s,t);
104      int start,end;
105      start=get_number(s);
106      end=get_number(s);
107      for (j=start; j<=end; j++)
108      {
109    sprintf(imname,"%s%04d.pcx",t,j);
110    seq[i++]=cache.reg(filename,imname,SPEC_CHARACTER,1);
111      }
112      get_token(s,t);      // right paren
113    }
114    else
115      seq[i++]=cache.reg(filename,t,SPEC_CHARACTER,1);
116  }
117}*/
118
119
120
121
122
Note: See TracBrowser for help on using the repository browser.