comparison tools/lib64gfx.c @ 2324:dc79c64f158c

Constify.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 03 Sep 2019 11:54:06 +0300
parents 5abb81daadd5
children b57517a01960
comparison
equal deleted inserted replaced
2323:f367677a5b21 2324:dc79c64f158c
304 } 304 }
305 } 305 }
306 306
307 307
308 int dmC64ConvertCSDataToImage(DMImage *img, 308 int dmC64ConvertCSDataToImage(DMImage *img,
309 int xoffs, int yoffs, const Uint8 *buf, 309 const int xoffs, const int yoffs, const Uint8 *buf,
310 int width, int height, BOOL multicolor, 310 const int width, const int height, const BOOL multicolor,
311 int *colors) 311 const int *colors)
312 { 312 {
313 int yc, widthpx = width * 8; 313 int yc, widthpx = width * 8;
314 Uint8 *dp; 314 Uint8 *dpp;
315 315
316 if (img == NULL) 316 if (img == NULL)
317 return DMERR_NULLPTR; 317 return DMERR_NULLPTR;
318 318
319 if (xoffs < 0 || yoffs < 0 || 319 if (xoffs < 0 || yoffs < 0 ||
320 xoffs > img->width - widthpx || 320 xoffs > img->width - widthpx ||
321 yoffs > img->height - height) 321 yoffs > img->height - height)
322 return DMERR_INVALID_ARGS; 322 return DMERR_INVALID_ARGS;
323 323
324 dp = img->data + (yoffs * img->pitch) + xoffs; 324 dpp = img->data + (yoffs * img->pitch) + xoffs;
325 325
326 if (multicolor) 326 if (multicolor)
327 { 327 {
328 for (yc = 0; yc < height; yc++) 328 for (yc = 0; yc < height; yc++)
329 { 329 {
330 const int offs = yc * width; 330 const int offs = yc * width;
331 Uint8 *d = dp; 331 Uint8 *dp = dpp;
332 332
333 for (int xc = 0; xc < widthpx / 2; xc++) 333 for (int xc = 0; xc < widthpx / 2; xc++)
334 { 334 {
335 const int b = buf[offs + (xc / 4)]; 335 const int b = buf[offs + (xc / 4)];
336 const int v = 6 - ((xc * 2) & 6); 336 const int v = 6 - ((xc * 2) & 6);
337 const Uint8 c = colors[(b >> v) & 3]; 337 const Uint8 c = colors[(b >> v) & 3];
338 338
339 *d++ = c; 339 *dp++ = c;
340 *d++ = c; 340 *dp++ = c;
341 } 341 }
342 342
343 dp += img->pitch; 343 dpp += img->pitch;
344 } 344 }
345 } 345 }
346 else 346 else
347 { 347 {
348 for (yc = 0; yc < height; yc++) 348 for (yc = 0; yc < height; yc++)
349 { 349 {
350 const int offs = yc * width; 350 const int offs = yc * width;
351 Uint8 *d = dp; 351 Uint8 *dp = dpp;
352 352
353 for (int xc = 0; xc < widthpx; xc++) 353 for (int xc = 0; xc < widthpx; xc++)
354 { 354 {
355 const int b = buf[offs + (xc / 8)]; 355 const int b = buf[offs + (xc / 8)];
356 const int v = 7 - (xc & 7); 356 const int v = 7 - (xc & 7);
357 const Uint8 c = colors[(b >> v) & 1]; 357 const Uint8 c = colors[(b >> v) & 1];
358 358
359 *d++ = c; 359 *dp++ = c;
360 } 360 }
361 361
362 dp += img->pitch; 362 dpp += img->pitch;
363 } 363 }
364 } 364 }
365 365
366 return DMERR_OK; 366 return DMERR_OK;
367 } 367 }