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

Last change on this file since 112 was 66, checked in by Sam Hocevar, 12 years ago
  • Added the proper .h and .hpp files to _SOURCES variables. As a result, "make dist" now generates a buildable tarball.
File size: 2.3 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
12#include "seq.hpp"
13#include "macs.hpp"
14#include "lisp.hpp"
15
16int sequence::size()
17{
18  int t=0;
19  for (int i=0;i<total;i++)
20  {
21    if (cash.loaded(seq[i]))
22      t+=cash.fig(seq[i])->size();   
23  }
24  return t;
25}
26
27int sequence::cache_in()
28{
29  int i;
30  for (i=0;i<total;i++)
31  {
32    cash.note_need(seq[i]);
33  }
34  return 1;
35}
36
37sequence::sequence(char *filename, void *pict_list, void *advance_list)
38{
39  if (item_type(pict_list)==L_STRING)
40    total=1;
41  else
42    total=list_length(pict_list);
43
44  seq=(int *) jmalloc(sizeof(int)*total,"sequence ptr array");
45  if (item_type(pict_list)==L_STRING)
46    seq[0]=cash.reg_object(filename,pict_list,SPEC_CHARACTER2,1);
47  else
48  {
49    int i;
50    for (i=0;i<total;i++)
51    {
52      seq[i]=cash.reg_object(filename,lcar(pict_list),SPEC_CHARACTER2,1);
53      pict_list=lcdr(pict_list);
54    }
55  }
56}
57
58sequence::~sequence()
59{
60  jfree(seq);
61}
62
63/*sequence::sequence(char *filename, char *picts)
64{
65  char t[100],*s=picts,imname[100]; 
66  int i,j;
67  total=0; 
68
69  // first count the images
70  while (token_type(s)!=sRIGHT_PAREN)
71  {
72    if (token_type(s)==sLEFT_PAREN)
73    {
74      get_token(s,t);    // left paren
75      get_token(s,t);    // seq
76      get_token(s,t);    // name
77      i=get_number(s);     
78      total+=get_number(s)-i+1;     
79      get_token(s,t);    // right paren
80    } 
81    else
82    { get_token(s,t);
83      total++;   
84    }   
85  }
86 
87
88  s=picts; 
89  seq=(int *) jmalloc(sizeof(int)*total,"sequence ptr array");
90 
91  for (i=0;i<total;)
92  {
93    if (get_token(s,t)==sLEFT_PAREN)
94    {
95      get_token(s,t);      // left paren
96      if (strcmp(t,"seq"))
97      {
98        printf("Expected seq at %s\n",s);
99        exit(0);       
100      }
101      get_token(s,t);
102      int start,end;
103      start=get_number(s);
104      end=get_number(s);
105      for (j=start;j<=end;j++)
106      {
107        sprintf(imname,"%s%04d.pcx",t,j);
108        seq[i++]=cash.reg(filename,imname,SPEC_CHARACTER,1);
109      }           
110      get_token(s,t);      // right paren
111    }
112    else
113      seq[i++]=cash.reg(filename,t,SPEC_CHARACTER,1);
114  }
115}*/
116
117
118
119
120
Note: See TracBrowser for help on using the repository browser.