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

Last change on this file since 524 was 524, checked in by Sam Hocevar, 11 years ago

core: Get rid of mostly useless headers, move endianness handling to
common.h (and rewrite functions so that they do not need the SDL headers)
and move a few functions out of sdlport's video.cpp. These functions
were in the original video.cpp (which reappears) and shouldn't be part
of the SDL port.

File size: 2.3 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 or
8 *  Jonathan Clark.
9 */
10
11#include "config.h"
12
13#include "common.h"
14
15#include "seq.h"
16#include "lisp.h"
17
18int sequence::size()
19{
20  int t=0;
21  for (int i=0; i<total; i++)
22  {
23    if (cache.loaded(seq[i]))
24      t+=cache.fig(seq[i])->size();
25  }
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.