Changeset 115 for abuse/trunk/src/particle.cpp
- Timestamp:
- Mar 16, 2008, 10:51:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/particle.cpp
r56 r115 45 45 last_anim->next=pan; 46 46 last_anim=pan; 47 } 47 } 48 48 } 49 49 … … 76 76 args=lcdr(args); 77 77 pseqs[total_pseqs]=new part_sequence(args); 78 total_pseqs++; 78 total_pseqs++; 79 79 return total_pseqs; 80 80 } … … 84 84 part_sequence::part_sequence(void *args) 85 85 { 86 char *fn=lstring_value(lcar(args)); 86 char *fn=lstring_value(lcar(args)); 87 87 bFILE *fp=open_file(fn,"rb"); 88 88 if (fp->open_failure()) … … 106 106 if (sd.entries[i]->type==SPEC_PARTICLE) tframes++; 107 107 frames=(int *)jmalloc(sizeof(int)*tframes,"part_frame id list\n"); 108 108 109 109 int on=0; 110 110 for (i=0;i<sd.total;i++) 111 if (sd.entries[i]->type==SPEC_PARTICLE) 111 if (sd.entries[i]->type==SPEC_PARTICLE) 112 112 frames[on++]=cash.reg(fn,sd.entries[i]->name,SPEC_PARTICLE,1); 113 113 … … 128 128 if (y>y2) y2=x; 129 129 data[i].x=x; 130 data[i].y=y; 131 data[i].color=fp->read_uint8(); 130 data[i].y=y; 131 data[i].color=fp->read_uint8(); 132 132 } 133 133 } … … 148 148 p=p->next; 149 149 delete d; 150 } else 150 } else 151 151 { 152 152 last=p; … … 159 159 void draw_panims(view *v) 160 160 { 161 for (part_animation *p=first_anim;p;p=p->next) 161 for (part_animation *p=first_anim;p;p=p->next) 162 162 { 163 163 cash.part(p->seq->frames[p->frame])->draw(screen,p->x-v->xoff()+v->cx1,p->y-v->yoff()+v->cy1,p->dir); … … 178 178 while (i && pon->y<cy1) { pon++; i--; } 179 179 if (!i) return ; 180 screen->lock(); 180 181 if (dir>0) 181 182 { … … 187 188 i--; 188 189 pon++; 189 } 190 } 190 191 } else 191 192 { … … 197 198 i--; 198 199 pon++; 199 } 200 } 201 202 } 203 204 205 200 } 201 } 202 screen->unlock(); 203 } 206 204 207 205 void scatter_line(int x1, int y1, int x2, int y2, int c, int s) 208 206 { 209 int16_t cx1, cy1, cx2, cy2; 210 screen->get_clip( cx1, cy1, cx2, cy2 ); 211 212 int t = abs( x2 - x1 ) > abs( y2 - y1 ) ? abs( x2 - x1 ) + 1 : abs( y2 - y1 ) + 1; 213 long xo = x1 << 16, yo = y1 << 16, dx = ( ( x2 - x1 ) << 16 ) / t, dy = ( ( y2 - y1 ) << 16 ) / t, x, y; 214 215 int xm = ( 1 << s ); 216 int ym = ( 1 << s ); 217 s = ( 15 - s ); 218 219 while( t-- ) 220 { 221 x = ( xo >> 16 ) + ( jrand() >> s ) - xm; 222 y = ( yo >> 16 ) + ( jrand() >> s ) - ym; 223 if( !( x < cx1 || y < cy1 || x > cx2 || y > cy2 ) ) 224 { 225 *(screen->scan_line( y ) + x ) = c; 226 } 227 xo += dx; 228 yo += dy; 229 } 207 int16_t cx1, cy1, cx2, cy2; 208 screen->get_clip( cx1, cy1, cx2, cy2 ); 209 210 int t = abs( x2 - x1 ) > abs( y2 - y1 ) ? abs( x2 - x1 ) + 1 : abs( y2 - y1 ) + 1; 211 long xo = x1 << 16, yo = y1 << 16, dx = ( ( x2 - x1 ) << 16 ) / t, dy = ( ( y2 - y1 ) << 16 ) / t, x, y; 212 213 int xm = ( 1 << s ); 214 int ym = ( 1 << s ); 215 s = ( 15 - s ); 216 217 screen->lock(); 218 while( t-- ) 219 { 220 x = ( xo >> 16 ) + ( jrand() >> s ) - xm; 221 y = ( yo >> 16 ) + ( jrand() >> s ) - ym; 222 if( !( x < cx1 || y < cy1 || x > cx2 || y > cy2 ) ) 223 { 224 *(screen->scan_line( y ) + x ) = c; 225 } 226 xo += dx; 227 yo += dy; 228 } 229 screen->unlock(); 230 230 } 231 231 … … 234 234 void ascatter_line(int x1, int y1, int x2, int y2, int c1, int c2, int s) 235 235 { 236 int16_t cx1, cy1, cx2, cy2; 237 screen->get_clip( cx1, cy1, cx2, cy2 ); 238 239 int t = abs( x2 - x1 ) > abs( y2 - y1 ) ? abs( x2 - x1 ) + 1 : abs( y2 - y1 ) + 1; 240 long xo = x1 << 16, yo = y1 << 16, dx = ( ( x2 - x1 ) << 16 ) / t, dy = ( ( y2 - y1 ) <<16 ) / t, x, y; 241 242 int xm = ( 1 << s ); 243 int ym = ( 1 << s ); 244 s = ( 15 - s ); 245 246 int w = screen->width(); 247 uint8_t *addr; 248 249 while( t-- ) 250 { 251 x = ( xo >> 16 ) + ( jrand() >> s ) - xm; 252 y = ( yo >> 16 ) + ( jrand() >> s ) - ym; 253 if( !( x <= cx1 || y <= cy1 || x >= cx2 || y >= cy2 ) ) 254 { 255 addr = screen->scan_line( y ) + x; 256 *addr = c1; 257 *(addr + w) = c2; 258 *(addr - w) = c2; 259 *(addr - 1) = c2; 260 *(addr + 1) = c2; 261 } 262 xo += dx; 263 yo += dy; 264 } 265 } 236 int16_t cx1, cy1, cx2, cy2; 237 screen->get_clip( cx1, cy1, cx2, cy2 ); 238 239 int t = abs( x2 - x1 ) > abs( y2 - y1 ) ? abs( x2 - x1 ) + 1 : abs( y2 - y1 ) + 1; 240 long xo = x1 << 16, yo = y1 << 16, dx = ( ( x2 - x1 ) << 16 ) / t, dy = ( ( y2 - y1 ) <<16 ) / t, x, y; 241 242 int xm = ( 1 << s ); 243 int ym = ( 1 << s ); 244 s = ( 15 - s ); 245 246 screen->lock(); 247 248 int w = screen->width(); 249 uint8_t *addr; 250 251 while( t-- ) 252 { 253 x = ( xo >> 16 ) + ( jrand() >> s ) - xm; 254 y = ( yo >> 16 ) + ( jrand() >> s ) - ym; 255 if( !( x <= cx1 || y <= cy1 || x >= cx2 || y >= cy2 ) ) 256 { 257 addr = screen->scan_line( y ) + x; 258 *addr = c1; 259 *(addr + w) = c2; 260 *(addr - w) = c2; 261 *(addr - 1) = c2; 262 *(addr + 1) = c2; 263 } 264 xo += dx; 265 yo += dy; 266 } 267 268 screen->unlock(); 269 } 270
Note: See TracChangeset
for help on using the changeset viewer.