Mercurial > hg > dmlib
comparison ppl.c @ 274:31e62b1f1b6e
Add boundary checks for the scope drawing.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 10 Oct 2012 21:23:09 +0300 |
parents | 3b5493fac928 |
children | 26d714c72c0f |
comparison
equal
deleted
inserted
replaced
273:3b5493fac928 | 274:31e62b1f1b6e |
---|---|
260 if (yh < 10 || chn == NULL) | 260 if (yh < 10 || chn == NULL) |
261 return; | 261 return; |
262 | 262 |
263 int xc, ym = y0 + (y1 - y0) / 2, vol = FP_GETH(chn->chVolume); | 263 int xc, ym = y0 + (y1 - y0) / 2, vol = FP_GETH(chn->chVolume); |
264 int pitch = screen->pitch / sizeof(Uint32); | 264 int pitch = screen->pitch / sizeof(Uint32); |
265 int len = chn->chSize; | |
265 DMFixedPoint offs = chn->chPos; | 266 DMFixedPoint offs = chn->chPos; |
266 Uint32 coln = dmCol(0.0, 0.8, 0.0), colx = dmCol(1.0, 0, 0); | 267 Uint32 coln = dmCol(0.0, 0.8, 0.0), colx = dmCol(1.0, 0, 0); |
267 Uint32 *pix = screen->pixels; | 268 Uint32 *pix = screen->pixels; |
268 Sint16 *data = chn->chData; | 269 Sint16 *data = chn->chData; |
269 | 270 |
274 nchannel == engine.actChannel ? colx : col.box1); | 275 nchannel == engine.actChannel ? colx : col.box1); |
275 | 276 |
276 if (chn->chData == NULL || !chn->chPlaying) | 277 if (chn->chData == NULL || !chn->chPlaying) |
277 return; | 278 return; |
278 | 279 |
279 for (xc = x0 + 1; xc < x1 - 1; xc++) | 280 if (chn->chDirection) |
280 { | 281 { |
281 Sint16 val = ym + (data[FP_GETH(offs)] * yh * vol) / (65535 * 255); | 282 for (xc = x0 + 1; xc < x1 - 1; xc++) |
282 pix[xc + val * pitch] = coln; | 283 { |
283 if (chn->chDirection) | 284 if (FP_GETH(offs) >= len) |
285 break; | |
286 Sint16 val = ym + (data[FP_GETH(offs)] * yh * vol) / (65535 * 255); | |
287 pix[xc + val * pitch] = coln; | |
284 FP_ADD(offs, chn->chDeltaO); | 288 FP_ADD(offs, chn->chDeltaO); |
285 else | 289 } |
290 } | |
291 else | |
292 { | |
293 for (xc = x0 + 1; xc < x1 - 1; xc++) | |
294 { | |
295 if (FP_GETH(offs) < 0) | |
296 break; | |
297 Sint16 val = ym + (data[FP_GETH(offs)] * yh * vol) / (65535 * 255); | |
298 pix[xc + val * pitch] = coln; | |
286 FP_SUB(offs, chn->chDeltaO); | 299 FP_SUB(offs, chn->chDeltaO); |
300 } | |
287 } | 301 } |
288 } | 302 } |
289 | 303 |
290 | 304 |
291 void dmDisplayChannels(SDL_Surface *screen, int x0, int y0, int x1, int y1, JSSMixer *dev) | 305 void dmDisplayChannels(SDL_Surface *screen, int x0, int y0, int x1, int y1, JSSMixer *dev) |