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

Last change on this file since 57 was 56, checked in by Sam Hocevar, 14 years ago
  • Add licensing terms to most C / C++ files (Ref #5).
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 "parse.hpp"
15#include "lisp.hpp"
16
17int sequence::size()
18{
19  int t=0;
20  for (int i=0;i<total;i++)
21  {
22    if (cash.loaded(seq[i]))
23      t+=cash.fig(seq[i])->size();   
24  }
25  return t;
26}
27
28int sequence::cache_in()
29{
30  int i;
31  for (i=0;i<total;i++)
32  {
33    cash.note_need(seq[i]);
34  }
35  return 1;
36}
37
38sequence::sequence(char *filename, void *pict_list, void *advance_list)
39{
40  if (item_type(pict_list)==L_STRING)
41    total=1;
42  else
43    total=list_length(pict_list);
44
45  seq=(int *) jmalloc(sizeof(int)*total,"sequence ptr array");
46  if (item_type(pict_list)==L_STRING)
47    seq[0]=cash.reg_object(filename,pict_list,SPEC_CHARACTER2,1);
48  else
49  {
50    int i;
51    for (i=0;i<total;i++)
52    {
53      seq[i]=cash.reg_object(filename,lcar(pict_list),SPEC_CHARACTER2,1);
54      pict_list=lcdr(pict_list);
55    }
56  }
57}
58
59sequence::~sequence()
60{
61  jfree(seq);
62}
63
64/*sequence::sequence(char *filename, char *picts)
65{
66  char t[100],*s=picts,imname[100]; 
67  int i,j;
68  total=0; 
69
70  // first count the images
71  while (token_type(s)!=sRIGHT_PAREN)
72  {
73    if (token_type(s)==sLEFT_PAREN)
74    {
75      get_token(s,t);    // left paren
76      get_token(s,t);    // seq
77      get_token(s,t);    // name
78      i=get_number(s);     
79      total+=get_number(s)-i+1;     
80      get_token(s,t);    // right paren
81    } 
82    else
83    { get_token(s,t);
84      total++;   
85    }   
86  }
87 
88
89  s=picts; 
90  seq=(int *) jmalloc(sizeof(int)*total,"sequence ptr array");
91 
92  for (i=0;i<total;)
93  {
94    if (get_token(s,t)==sLEFT_PAREN)
95    {
96      get_token(s,t);      // left paren
97      if (strcmp(t,"seq"))
98      {
99        printf("Expected seq at %s\n",s);
100        exit(0);       
101      }
102      get_token(s,t);
103      int start,end;
104      start=get_number(s);
105      end=get_number(s);
106      for (j=start;j<=end;j++)
107      {
108        sprintf(imname,"%s%04d.pcx",t,j);
109        seq[i++]=cash.reg(filename,imname,SPEC_CHARACTER,1);
110      }           
111      get_token(s,t);      // right paren
112    }
113    else
114      seq[i++]=cash.reg(filename,t,SPEC_CHARACTER,1);
115  }
116}*/
117
118
119
120
121
Note: See TracBrowser for help on using the repository browser.