less wankly

This commit is contained in:
XANTRONIX Development 2021-12-04 16:30:55 -05:00
parent 740b8d0363
commit ea96b298b3

View file

@ -499,26 +499,19 @@ static void tile_copy(cammy_image *dest,
size_t x, size_t x,
y; y;
for (y=0; y < from->height; y++) { for (y=from->y; y<from->y + from->height; y++) {
if (to->y + y > dest->height) { if (y > dest->height) {
break; break;
} }
for (x=0; x < from->width; x++) { for (x=from->x; x<from->x + from->width; x++) {
uint8_t value = tile_read((cammy_tile *)src->buf, uint8_t value = tile_read((cammy_tile *)src->buf, x, y, src->width);
from->x + x,
from->y + y,
src->width);
if (to->x + x > dest->width) { if (to->x + x > dest->width) {
break; break;
} }
tile_write((cammy_tile *)dest->buf, tile_write((cammy_tile *)dest->buf, x, y, dest->width, value);
to->x + x,
to->y + y,
dest->width,
value);
} }
} }
} }
@ -532,15 +525,15 @@ static void bitmap_copy(cammy_image *dest,
int channels_dest = depth_channels(dest->depth), int channels_dest = depth_channels(dest->depth),
channels_src = depth_channels(src->depth); channels_src = depth_channels(src->depth);
for (y=0; y < from->height; y++) { for (y=from->y; y<from->y + from->height; y++) {
if (to->y + y > dest->height) { if (y > dest->height) {
break; break;
} }
for (x=0; x < from->width; x++) { for (x=from->x; x<from->x + from->width; x++) {
uint8_t r, g, b; uint8_t r, g, b;
if (to->x + x > from->width) { if (x > from->width) {
break; break;
} }
@ -567,15 +560,15 @@ static void bitmap_copy_to_tile(cammy_image *dest,
int channels = depth_channels(src->depth); int channels = depth_channels(src->depth);
for (y=0; y < from->height; y++) { for (y=from->y; y<from->y + from->height; y++) {
if (to->y + y > dest->height) { if (y > dest->height) {
break; break;
} }
for (x=0; x < from->width; x++) { for (x=from->x; x<from->x + from->width; x++) {
uint8_t r, g, b; uint8_t r, g, b;
if (to->x + x > from->width) { if (x > from->width) {
break; break;
} }
@ -603,26 +596,23 @@ static void tile_copy_to_bitmap(cammy_image *dest,
int channels = depth_channels(dest->depth); int channels = depth_channels(dest->depth);
for (y=0; y < from->height; y++) { for (y=from->y; y<from->y + from->height; y++) {
if (to->y + y > dest->height) { if (y > dest->height) {
break; break;
} }
for (x=0; x < from->width; x++) { for (x=from->x; x<from->x + from->width; x++) {
uint8_t c; uint8_t c;
if (to->x + x > from->width) { if (x > from->width) {
break; break;
} }
c = tile_read((cammy_tile *)src->buf, c = tile_read((cammy_tile *)src->buf, x, y, from->width);
from->x + x,
from->y + y,
from->width);
bitmap_write(dest->buf, bitmap_write(dest->buf,
from->x + x, x,
from->y + y, y,
from->width, from->width,
src->palette[c].r, src->palette[c].r,
src->palette[c].g, src->palette[c].g,