Changeset 534 for abuse/trunk
- Timestamp:
- Apr 22, 2011, 7:32:17 PM (12 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 1 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/clisp.h
r494 r534 10 10 11 11 #ifndef __CLISP_HPP_ 12 #ifndef SCADALISP 12 13 13 int get_lprop_number(void *sybol, int def); // returns def if symbol undefined or not number type 14 14 … … 58 58 59 59 #endif 60 #endif -
abuse/trunk/src/configuration.cpp
r512 r534 64 64 return 0; 65 65 66 #ifdef SCADALISP67 strcpy( tmp, symbol_name( k ) );68 #else69 66 strcpy( tmp, lstring_value( symbol_name( k ) ) ); 70 #endif71 67 72 68 for( char *c = tmp; *c; c++ ) -
abuse/trunk/src/imlib/image.cpp
r526 r534 690 690 int x1 = 6000, y1 = 6000, x2 = -1, y2 = -1; 691 691 692 for (int i = dirties. number_nodes(); i--; )692 for (int i = dirties.Count(); i--; ) 693 693 { 694 694 x1 = Min(x1, p->dx1); y1 = Min(y1, p->dy1); 695 695 x2 = Max(x1, p->dx1); y2 = Max(y1, p->dy1); 696 dirty_rect *tmp = (dirty_rect *)p-> next();696 dirty_rect *tmp = (dirty_rect *)p->Next(); 697 697 dirties.unlink(p); 698 698 delete p; … … 716 716 return; 717 717 718 int i = dirties. number_nodes();718 int i = dirties.Count(); 719 719 if (!i) 720 720 return; … … 722 722 for (p = (dirty_rect *)dirties.first(); i; i--, p = next) 723 723 { 724 next = (dirty_rect *)p-> next();724 next = (dirty_rect *)p->Next(); 725 725 726 726 // are the two touching? … … 815 815 return; 816 816 817 int i = dirties. number_nodes();817 int i = dirties.Count(); 818 818 if (!i) 819 819 dirties.add_front(new dirty_rect(x1, y1, x2 - 1, y2 - 1)); … … 831 831 if (x1<=p->dx1 && y1<=p->dy1 && x2>=p->dx2+1 && y2>=p->dy2+1) 832 832 { 833 dirty_rect *tmp=(dirty_rect*) p-> next();833 dirty_rect *tmp=(dirty_rect*) p->Next(); 834 834 dirties.unlink(p); 835 835 delete p; … … 867 867 return ; 868 868 } 869 p=(dirty_rect *)p-> next();870 } else p=(dirty_rect *)p-> next();869 p=(dirty_rect *)p->Next(); 870 } else p=(dirty_rect *)p->Next(); 871 871 872 872 } -
abuse/trunk/src/imlib/jwindow.h
r518 r534 48 48 void remap(filter *f); 49 49 ifield *unlink(int id); // unlinks ID from fields list and return the pointer to it 50 ifield *current() { return active; }51 50 void clear_current(); 52 51 void grab_focus(ifield *i); -
abuse/trunk/src/imlib/linked.cpp
r494 r534 17 17 #include "linked.h" 18 18 19 // 20 // take a node out of the linked list, but do not dispose of the memory 21 // 22 int linked_list::unlink(linked_node *p) 19 linked_list::linked_list() 20 : m_first(NULL), 21 m_count(0) 23 22 { 24 linked_node *q; 25 if (first()) // if there are any nodes.. 26 { 27 if (first()==p) // if they want to unlinkt the first node 28 { 29 fn->last()->set_next(fn->next()); // set the first's last's next to the first's next 30 fn->next()->set_last(fn->last()); // set the first next's last to the first last 31 if (fn->next()==fn) // if there is ony one node 32 { fn=NULL; cn=NULL; } // clear the list 33 else fn=p->next(); // else point the first pointer to the next node 34 nn--; // decrement the number of nodes in the list 35 return 1; 36 } 37 else 38 { 39 q=first()->next(); 40 while (q!=p && q!=first()) // find the node in the list 41 q=q->next(); 42 if (q!=first()) // is it in the list at all? 43 { q->last()->set_next(q->next()); // yes unlink the pointers 44 q->next()->set_last(q->last()); 45 nn--; 46 return 1; 47 } // decrement the number of nodes 48 } 49 } 50 return 0; 23 ; 51 24 } 52 25 53 54 26 // 55 // clear all the nodes in a linked list and dispose of the27 // Clear all the nodes in a linked list and dispose of the 56 28 // memory for each one by calling its destructor 57 29 // 58 30 linked_list::~linked_list() 59 31 { 60 if (fn) 61 fn->last()->set_next(NULL); // set the last nodes next to NULL 62 // so we can go until we hit NULL 63 while (fn != NULL) // repeat until we get to that node 64 { 65 cn=fn->next(); 66 delete fn; // delete the old node 67 fn=cn; 68 } 69 cn=NULL; // clear the list 70 nn=0; // set the number of nodes to 0 32 if (m_first) 33 m_first->Prev()->SetNext(NULL); // set the prev nodes next to NULL 34 // so we can go until we hit NULL 35 while (m_first != NULL) 36 { 37 linked_node *tmp = m_first->Next(); 38 delete m_first; 39 m_first = tmp; 40 } 71 41 } 72 42 73 43 // 74 // return the index of a given node in a linked list, by starting at the 75 // node and parsing backwards 44 // Take a node out of the linked list, but do not dispose of the memory 76 45 // 77 int linked_list:: node_number(linked_node *p)46 int linked_list::unlink(linked_node *p) 78 47 { 79 int x; 80 x=1; 81 while (p!=first()) 82 { x++; p=p->last(); } 83 return x; 48 if (!m_count) 49 return 0; 50 51 linked_node *q = m_first; 52 53 while (q != p) // find the node in the list 54 { 55 q = q->Next(); 56 if (q == m_first) 57 return 0; // not in the list! 58 } 59 60 q->Prev()->SetNext(q->Next()); 61 q->Next()->SetPrev(q->Prev()); 62 63 if (p == m_first) // if they want to unlink the first node 64 m_first = (m_first->Next() == m_first) ? NULL : p->Next(); 65 66 m_count--; 67 return 1; 84 68 } 85 69 70 // 71 // Add a node to the end of a linked_list 72 // 73 void linked_list::add_end(class linked_node *p) 74 { 75 if (m_first) 76 p->SetPrev(m_first->Prev()); 77 else 78 m_first = p; 79 p->SetNext(m_first); 86 80 87 // this function returns a pointer to the xth node 88 class linked_node *linked_list::get_node(int x) 89 { 90 class linked_node *p; 91 p=fn; // start tat the first node 92 while (x--!=1) p=p->next(); // go forward X-1 nodes 93 return p; 81 if (m_first != p) 82 m_first->Prev()->SetNext(p); 83 m_first->SetPrev(p); 84 85 m_count++; 94 86 } 95 87 96 97 // this function adds a node to the end of a linked_list 98 void linked_list::add_end(class linked_node *p) 99 { 100 nn++; 101 if (fn==NULL) // if there are no nodes, then this one becomes the first 102 { fn=p; 103 fn->set_next(fn); // and it poits to itself for first and last 104 fn->set_last(fn); 105 } 106 else 107 { 108 p->set_last(fn->last()); // otherwise add it in at the end 109 p->set_next(fn); 110 fn->last()->set_next(p); 111 fn->set_last(p); // the first's last pointer points to the node we just added 112 } 113 } 114 115 116 // to add a node at the fron of the list, just add it at the end and set 88 // Add a node at the front of the list: just add it at the end and set 117 89 // the first pointer to it 118 90 void linked_list::add_front(class linked_node *p) 119 91 { 120 add_end(p);121 fn=p;92 add_end(p); 93 m_first = p; 122 94 } 123 95 124 125 // insert adds a node in the list according to is sort value126 void linked_list::insert(class linked_node *p)127 {128 class linked_node *q;129 130 // if there are nodes, or it belongs at the beginin call add front131 if ((fn==NULL) || (p->compare(fn,sortby)>0))132 add_front(p);133 // else if it goes at the ned call add_end134 else if (p->compare(fn->last(),sortby)<=0)135 add_end(p);136 else // otherwise we have to find the right spot for it.137 {138 nn++;139 q=fn;140 while (q!=fn->last()) // q starts at the front141 { q=q->next();142 if (p->compare(q,sortby)>0) // repeat until we find a value greater than the one we are inserting143 { p->set_next(q);144 p->set_last(q->last()); // insert it with pointers here145 q->last()->set_next(p);146 q->set_last(p);147 q=fn->last(); // set q to the last node so we finish the loop148 }149 }150 }151 }152 153 linked_list::linked_list(linked_node *first)154 { linked_node *prev;155 fn=first; cn=first; sortby=1; nn=0;156 if (first)157 { cn=first;158 do159 {160 nn++;161 prev=cn;162 cn=cn->next();163 } while (cn && cn!=first);164 if (cn==NULL)165 {166 fn->set_last(prev);167 prev->set_next(fn);168 }169 cn=first;170 171 }172 } -
abuse/trunk/src/imlib/linked.h
r519 r534 11 11 // linked.h - linked list and linked list node classes 12 12 // written June 2, 1992 by Jonathan Clark (at home) 13 // these classes provide the basic groundwork for any future linked list14 // please derive your own linked_node subclass and define the virtual15 // function compare.16 // example compare function17 // virtual int compare(void *n1, int field)18 // { return ((classname *) n1)->data > data); }19 // should return (1 if n1 is greater than (self)) else return 020 // field is the value determined by linked_list::set_sort_field21 // this defaults to 122 13 14 #ifndef __LINKED_H__ 15 #define __LINKED_H__ 23 16 24 #ifndef linkman25 #define linkman26 17 #include <stdio.h> 27 18 #include <stdlib.h> 28 19 #include <string.h> 29 20 30 #define loop(controll,first,inside) { controll=first; \31 if (first) do { inside controll=controll->next(); } \32 while (controll!=first); }33 34 #define loopt(type,controll,first,inside) { controll=(type *)(first); \35 if (first) do { inside controll=(type *)(controll->next()); } \36 while (controll!=(type *)(first)); }37 38 39 #define loop_rev(controll,last,inside) { controll=last; \40 if (first) do { inside controll=controll->last(); } \41 while (controll!=last); }42 43 #define loopct(type,controll,first,cond,inside) { controll=(type *)first; \44 if (first && (cond)) do { inside controll=(type *)controll->next(); } \45 while (controll!=(type *)first && (cond)); }46 47 #define loop_fort(type,controll,first,x) \48 int x=0; \49 if (first) \50 for (controll=(type *)(first); \51 (!x || (controll)!=(type *)(first)); \52 controll=(type *)(controll->next()),x++)53 54 #define loop_forct(type,controll,first,cond,x) int x=0; if (first) for \55 (controll=(type *)(first); cond && (!x || controll!=(type *)(first)); \56 controll=(type *)(controll->next()),x++)57 58 21 class linked_node 59 22 { 60 class linked_node *nextp, *lastp; 23 friend class linked_list; 24 61 25 public: 62 virtual int compare(void *n1, int field) { return(0); } // default is = (equal) 63 class linked_node *next() { return nextp; } 64 class linked_node *last() { return lastp; } 65 void set_next(class linked_node *p) { nextp=p; } 66 void set_last(class linked_node *p) { lastp=p; } 67 virtual ~linked_node() { ; } 68 linked_node() { nextp=NULL; lastp=NULL; } 26 linked_node() { m_next = m_prev = NULL; } 27 virtual ~linked_node() { ; } 28 29 inline class linked_node *Next() { return m_next; } 30 inline class linked_node *Prev() { return m_prev; } 31 inline void SetNext(class linked_node *p) { m_next = p; } 32 inline void SetPrev(class linked_node *p) { m_prev = p; } 33 34 private: 35 class linked_node *m_next, *m_prev; 69 36 }; 70 37 … … 83 50 class linked_list 84 51 { 85 class linked_node *fn, *cn; // first and current nodes 86 int nn; char sortby; 87 public : 88 linked_list(linked_node *first=NULL); 89 void add_front(class linked_node *p); 90 void add_end(class linked_node *p); 91 void insert(class linked_node *p); 92 void set_sort_field(int x) { sortby=x; } // this is passed to compare 93 class linked_node *current() { return cn; } 94 class linked_node *first() { return fn; } 95 class linked_node *last() { return fn->last(); } 96 class linked_node *get_node(int x); 97 void set_current(class linked_node *p) { cn=p; } 98 void go_first() { cn=fn; } 99 void go_end() { cn=fn->last(); } 100 void go_next() { cn=cn->next(); } 101 void go_last() { cn=cn->last(); } 102 int number_nodes() { return nn; } 103 int node_number(linked_node *p); 104 int unlink(linked_node *p); 105 ~linked_list(); 52 public: 53 linked_list(); 54 ~linked_list(); 55 56 void add_front(class linked_node *p); 57 void add_end(class linked_node *p); 58 int unlink(linked_node *p); 59 60 inline class linked_node *first() { return m_first; } 61 inline class linked_node *prev() { return m_first->Prev(); } 62 inline size_t Count() { return m_count; } 63 64 private: 65 linked_node *m_first; 66 size_t m_count; 106 67 }; 107 68 108 69 #endif 109 70 110 111 -
abuse/trunk/src/imlib/palette.cpp
r524 r534 404 404 for (x=0; x<8 && !pruned; x++) 405 405 if (f->children[x]) 406 if (f->children[x]-> next()!=p->next()) // if this son is not me!406 if (f->children[x]->Next()!=p->Next()) // if this son is not me! 407 407 pruned=1; // I have a brother! stop 408 p=(quant_node *)p-> next();408 p=(quant_node *)p->Next(); 409 409 } while (p != level[lev-1].first() && !pruned); 410 410 } … … 473 473 for (x=0,i=7; i>=0; i++) 474 474 for (pn=(quant_node *)level[i].first(); 475 pn!=(quant_node *)level[i].first(); pn=(quant_node *)pn-> next())475 pn!=(quant_node *)level[i].first(); pn=(quant_node *)pn->Next()) 476 476 if (pn->is_leaf()) 477 477 p->set(x++,pn->red,pn->green,pn->blue); -
abuse/trunk/src/imlib/readwav.cpp
r524 r534 19 19 struct wav_chunk 20 20 { 21 char id[4];22 unsigned longsize;23 char type[4];24 } 21 char id[4]; 22 uint32_t size; 23 char type[4]; 24 }; 25 25 26 26 struct wav_tag 27 27 { 28 char id[4];29 unsigned longsize;30 } 28 char id[4]; 29 uint32_t size; 30 }; 31 31 32 32 33 33 struct wav_format 34 34 { 35 unsigned short fmt_tag,channels; 36 unsigned long samplesps,avg_bytesps; 37 unsigned short align; 38 } ; 39 35 uint16_t fmt_tag, channels; 36 uint32_t samplesps, avg_bytesps; 37 uint16_t align; 38 }; 40 39 41 40 struct pcm_wave 42 41 { 43 wav_format wf;44 unsigned short bitsps;45 } 42 wav_format wf; 43 uint16_t bitsps; 44 }; 46 45 47 48 49 50 void read_chunk(wav_chunk &chunk, bFILE *fp) 46 static void read_chunk(wav_chunk &chunk, bFILE *fp) 51 47 { 52 fp->read(&chunk.id,4);53 chunk.size=fp->read_uint32();54 fp->read(&chunk.type,4);48 fp->read(&chunk.id, 4); 49 chunk.size = fp->read_uint32(); 50 fp->read(&chunk.type, 4); 55 51 } 56 52 57 void read_tag(wav_tag &tag, bFILE *fp)53 static void read_tag(wav_tag &tag, bFILE *fp) 58 54 { 59 fp->read(&tag.id,4);60 tag.size=fp->read_uint32();55 fp->read(&tag.id, 4); 56 tag.size = fp->read_uint32(); 61 57 } 62 58 63 void read_wav_format(wav_format &fmt, bFILE *fp)59 static void read_pcm(pcm_wave &pcm, bFILE *fp) 64 60 { 65 fmt.fmt_tag=fp->read_uint16(); 66 fmt.channels=fp->read_uint16(); 67 fmt.samplesps=fp->read_uint32(); 68 fmt.avg_bytesps=fp->read_uint32(); 69 fmt.align=fp->read_uint16(); 61 pcm.wf.fmt_tag = fp->read_uint16(); 62 pcm.wf.channels = fp->read_uint16(); 63 pcm.wf.samplesps = fp->read_uint32(); 64 pcm.wf.avg_bytesps = fp->read_uint32(); 65 pcm.wf.align = fp->read_uint16(); 66 pcm.bitsps = fp->read_uint16(); 70 67 } 71 68 69 uint8_t *read_wav(char const *filename, int &sample_rate, int &data_size) 70 { 71 bFILE *fp = open_file(filename, "rb"); 72 if (fp->open_failure()) 73 { 74 delete fp; 75 return NULL; 76 } 72 77 73 void read_pcm(pcm_wave &pcm, bFILE *fp) 74 { 75 read_wav_format(pcm.wf,fp); 76 pcm.bitsps=fp->read_uint16(); 78 wav_chunk chunk; 79 read_chunk(chunk, fp); 80 if (memcmp(chunk.type, "WAVE", 4) != 0) 81 { 82 printf("Bad WAV file (chunk) %s\n", filename); 83 delete fp; 84 return NULL; 85 } 86 87 wav_tag tag; 88 read_tag(tag, fp); 89 if (memcmp(tag.id, "fmt ", 4) != 0) 90 { 91 printf( "fmt tag missing, bad file (%s)\n", filename); 92 delete fp; 93 return NULL; 94 } 95 96 pcm_wave pcm; 97 read_pcm(pcm, fp); 98 99 fp->seek(tag.size - 16, SEEK_CUR); // seek to offset of sample 100 101 read_tag(tag, fp); 102 103 if (memcmp(tag.id, "data", 4) != 0) 104 { 105 printf("Bad Wav file (tag), %s\n", filename); 106 delete fp; 107 return NULL; 108 } 109 110 data_size = tag.size; 111 uint8_t *ret = (uint8_t *)malloc(tag.size); 112 ERROR(ret, "Malloc error"); 113 114 sample_rate = pcm.wf.samplesps; 115 ERROR((unsigned int)fp->read(ret, tag.size) == tag.size, "Premature end of file"); 116 ERROR(pcm.bitsps == 8, "Only 8-bit samples supported"); 117 ERROR(pcm.wf.channels == 1, "Only mono samples supported"); 118 ERROR(pcm.wf.align == 1, "Bad block alignment"); 119 delete fp; 120 return ret; 77 121 } 78 122 79 80 81 void write_wav(char *filename, long sample_rate, long data_size, unsigned char *data)82 {83 bFILE *fp=open_file(filename,"wb");84 if (fp->open_failure())85 {86 printf("Unable to open %s for writing\n", filename);87 delete fp;88 exit(1);89 }90 91 /*************** Write the chunk ***************************/92 fp->write((void *)"RIFF",4);93 fp->write_uint32(data_size+36);94 fp->write((void *)"WAVE",4);95 96 97 /************** Write the tag *******************************/98 fp->write((void *)"fmt ",4);99 fp->write_uint32(16);100 101 102 /************** Write PCM ***********************************/103 fp->write_uint16(1); // format_tag104 fp->write_uint16(1); // mono recording105 fp->write_uint32(sample_rate);106 fp->write_uint32(sample_rate); // average bytes per sec107 fp->write_uint16(1); // alignment? Don't know what this does?108 fp->write_uint16(8); // 8 bits per sample109 110 /************* Write data tag ******************************/111 fp->write((void *)"data",4);112 fp->write_uint32(data_size);113 114 /************ Now write sample data ************************/115 fp->write(data,data_size);116 117 delete fp;118 }119 120 121 122 unsigned char *read_wav(char *filename, long &sample_rate, long &data_size)123 {124 unsigned char *data;125 wav_chunk chunk;126 wav_tag tag;127 pcm_wave pcm;128 129 bFILE *fp=open_file(filename,"rb");130 if (fp->open_failure())131 { delete fp; return NULL; }132 read_chunk(chunk,fp);133 if (memcmp(chunk.type,"WAVE",4)!=0)134 {135 printf("Bad WAV file (chunk) %s\n",filename);136 delete fp;137 return NULL;138 }139 140 read_tag(tag,fp);141 if (memcmp(tag.id,"fmt ",4)!=0)142 {143 printf( "fmt tag missing, bad file (%s)\n",filename);144 delete fp;145 return NULL;146 }147 148 149 read_pcm(pcm,fp);150 151 fp->seek(tag.size-16,SEEK_CUR); // seek to offset of sample152 153 read_tag(tag,fp);154 155 if (memcmp(tag.id,"data",4)!=0)156 {157 printf("Bad Wav file (tag), %s\n",filename);158 delete fp;159 return NULL;160 }161 162 data_size=tag.size;163 data=(unsigned char *)malloc(tag.size);164 ERROR(data,"Malloc error");165 166 sample_rate=pcm.wf.samplesps;167 ERROR((unsigned int)fp->read(data,tag.size)==tag.size,"Premature end of file");168 ERROR(pcm.bitsps==8,"Only 8-bit samples supported");169 ERROR(pcm.wf.channels==1,"Only mono samples supported");170 ERROR(pcm.wf.align==1,"Bad block alignment");171 delete fp;172 return data;173 }174 175 176 -
abuse/trunk/src/imlib/readwav.h
r494 r534 9 9 */ 10 10 11 #ifndef __READ_WAV_HPP_ 12 #define __READ_WAV_HPP_ 11 #ifndef __READ_WAV_H__ 12 #define __READ_WAV_H__ 13 13 14 #include "specs.h" 14 unsigned char *read_wav(char *filename, long &sample_rate, long &data_size); 15 void write_wav(char *filename, long sample_rate, long data_size, unsigned char *data); 16 15 uint8_t *read_wav(char const *filename, int &sample_rate, int &data_size); 17 16 18 17 #endif 19 18 20 21 -
abuse/trunk/src/imlib/specs.h
r529 r534 218 218 #endif 219 219 220 221 222 223 224 225 -
abuse/trunk/src/imlib/sprite.cpp
r524 r534 50 50 { sprites.add_end(sp); } 51 51 52 #define loopt(type,controll,first,inside) { controll=(type *)(first); \ 53 if (first) do { inside controll=(type *)(controll->Next()); } \ 54 while (controll!=(type *)(first)); } 55 52 56 void sprite_controller::remove_sprites() 53 57 { sprite *sp; loopt(sprite,sp,sprites.first(),sp->restore_background(); ); } … … 82 86 delete sp; 83 87 } 88 -
abuse/trunk/src/imlib/video.cpp
r524 r534 29 29 else 30 30 { 31 int count = im->m_special->dirties. number_nodes();31 int count = im->m_special->dirties.Count(); 32 32 dirty_rect *dr = (dirty_rect *)(im->m_special->dirties.first()); 33 33 while(count > 0) … … 36 36 dr->dx1, dr->dy1, dr->dx2 + 1, dr->dy2 + 1); 37 37 dirty_rect *tmp = dr; 38 dr = (dirty_rect *)(dr-> next());38 dr = (dirty_rect *)(dr->Next()); 39 39 im->m_special->dirties.unlink(tmp); 40 40 delete tmp; -
abuse/trunk/src/objects.cpp
r533 r534 27 27 #include "lisp_gc.h" 28 28 #include "profile.h" 29 30 #ifdef SCADALISP31 #define LCAR(x) CAR(x)32 #define LCDR(x) CDR(x)33 #else34 #define LCAR(x) (x)->car35 #define LCDR(x) (x)->cdr36 #endif /* SCADALISP */37 29 38 30 char **object_names; … … 538 530 current_object = o; 539 531 } else damage_fun(amount,from,hitx,hity,push_xvel,push_yvel); 540 #ifdef SCADALISP541 ENDLOCAL();542 #endif543 532 } 544 533 -
abuse/trunk/src/sdlport/sound.cpp
r494 r534 218 218 if( sound_enabled ) 219 219 { 220 longsample_speed;220 int sample_speed; 221 221 222 222 #ifdef USE_SDL_MIXER -
abuse/trunk/src/sdlport/sound.h
r494 r534 9 9 */ 10 10 11 #ifndef __SOUND_H PP_12 #define __SOUND_H PP_11 #ifndef __SOUND_H__ 12 #define __SOUND_H__ 13 13 14 14 #ifdef USE_SDL_MIXER 15 # include <SDL/SDL_mixer.h>15 # include <SDL/SDL_mixer.h> 16 16 #endif 17 17 … … 23 23 int sound_init(int argc, char **argv); 24 24 void sound_uninit(); 25 void print_sound_options(); 25 void print_sound_options(); // print the options avaible for sound 26 26 27 27 class sound_effect 28 28 { 29 long size; 30 void *data; 29 public: 30 sound_effect(char *filename); 31 void play(int volume = 127, int pitch = 128, int panpot = 128); 32 ~sound_effect(); 33 34 private: 35 void *data; 31 36 #ifdef USE_SDL_MIXER 32 Mix_Chunk* chunk;37 Mix_Chunk* chunk; 33 38 #endif 34 public : 35 sound_effect(char *filename); 36 void play(int volume=127, int pitch=128, int panpot=128); 37 ~sound_effect(); 38 } ; 39 39 int size; 40 }; 40 41 41 42 class song 42 43 { 43 char *Name; 44 unsigned char *data; 45 unsigned long song_id; 44 public: 45 char const *name() { return Name; } 46 song(char const *filename); 47 void play(unsigned char volume=127); 48 void stop(long fadeout_time=0); // time in ms 49 int playing(); 50 void set_volume(int volume); 51 ~song(); 52 53 private: 54 char *Name; 55 unsigned char *data; 56 unsigned long song_id; 46 57 #ifdef USE_SDL_MIXER 47 Mix_Music* music;48 SDL_RWops* rw;58 Mix_Music* music; 59 SDL_RWops* rw; 49 60 #endif 50 public : 51 char const *name() { return Name; } 52 song(char const *filename); 53 void play(unsigned char volume=127); 54 void stop(long fadeout_time=0); // time in ms 55 int playing(); 56 void set_volume(int volume); 57 ~song(); 58 } ; 61 }; 62 59 63 #endif 60 64 61 62 63 64 65 66 67 68 69 70
Note: See TracChangeset
for help on using the changeset viewer.