Removed the useless y1 and y2 parameters from the renderers' blit functions (and other places).

This commit is contained in:
OBattler
2021-09-13 23:19:10 +02:00
parent 7473a1c4b9
commit 96faa28eeb
31 changed files with 119 additions and 130 deletions

View File

@@ -244,7 +244,7 @@ const uint32_t shade[5][256] =
static struct {
int x, y, y1, y2, w, h;
int x, y, w, h;
int busy;
int buffer_in_use;
@@ -255,7 +255,7 @@ static struct {
} blit_data;
static void (*blit_func)(int x, int y, int y1, int y2, int w, int h);
static void (*blit_func)(int x, int y, int w, int h);
#ifdef ENABLE_VIDEO_LOG
@@ -279,7 +279,7 @@ video_log(const char *fmt, ...)
void
video_setblit(void(*blit)(int,int,int,int,int,int))
video_setblit(void(*blit)(int,int,int,int))
{
blit_func = blit;
}
@@ -317,7 +317,7 @@ static png_infop info_ptr;
static void
video_take_screenshot(const char *fn, int startx, int starty, int y1, int y2, int w, int h)
video_take_screenshot(const char *fn)
{
int i, x, y;
png_bytep *b_rgb = NULL;
@@ -349,25 +349,26 @@ video_take_screenshot(const char *fn, int startx, int starty, int y1, int y2, in
png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr, w, h,
png_set_IHDR(png_ptr, info_ptr, blit_data.w, blit_data.h,
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
b_rgb = (png_bytep *) malloc(sizeof(png_bytep) * h);
b_rgb = (png_bytep *) malloc(sizeof(png_bytep) * blit_data.h);
if (b_rgb == NULL) {
video_log("[video_take_screenshot] Unable to Allocate RGB Bitmap Memory");
fclose(fp);
return;
}
for (y = 0; y < h; ++y) {
for (y = 0; y < blit_data.h; ++y) {
b_rgb[y] = (png_byte *) malloc(png_get_rowbytes(png_ptr, info_ptr));
for (x = 0; x < w; ++x) {
temp = buffer32->line[starty + y][startx + x];
b_rgb[y][(x) * 3 + 0] = (temp >> 16) & 0xff;
b_rgb[y][(x) * 3 + 1] = (temp >> 8) & 0xff;
b_rgb[y][(x) * 3 + 2] = temp & 0xff;
for (x = 0; x < blit_data.w; ++x) {
if (buffer32 == NULL)
memset(&(b_rgb[y][x * 3]), 0x00, 3);
else {
temp = buffer32->line[blit_data.y + y][blit_data.x + x];
memcpy(&(b_rgb[y][x * 3]), &temp, 3);
}
}
}
@@ -378,7 +379,7 @@ video_take_screenshot(const char *fn, int startx, int starty, int y1, int y2, in
png_write_end(png_ptr, NULL);
/* cleanup heap allocation */
for (i = 0; i < h; i++)
for (i = 0; i < blit_data.h; i++)
if (b_rgb[i]) free(b_rgb[i]);
if (b_rgb) free(b_rgb);
@@ -388,7 +389,7 @@ video_take_screenshot(const char *fn, int startx, int starty, int y1, int y2, in
static void
video_screenshot(int x, int y, int y1, int y2, int w, int h)
video_screenshot(void)
{
char path[1024], fn[128];
@@ -407,7 +408,7 @@ video_screenshot(int x, int y, int y1, int y2, int w, int h)
video_log("taking screenshot to: %s\n", path);
video_take_screenshot((const char *) path, x, y, y1, y2, w, h);
video_take_screenshot((const char *) path);
png_destroy_write_struct(&png_ptr, &info_ptr);
}
@@ -417,10 +418,12 @@ video_transform_copy(uint32_t *dst, uint32_t *src, int len)
{
int i;
for (i = 0; i < len; i++) {
*dst = video_color_transform(*src);
dst++;
src++;
if ((dst != NULL) && (src != NULL)) {
for (i = 0; i < len; i++) {
*dst = video_color_transform(*src);
dst++;
src++;
}
}
}
@@ -435,8 +438,8 @@ void blit_thread(void *param)
thread_reset_event(blit_data.wake_blit_thread);
MTR_BEGIN("video", "blit_thread");
if ((video_grayscale || invert_display) && blit_data.y2 > 0) {
for (yy = blit_data.y1; yy < blit_data.y2; yy++) {
if ((video_grayscale || invert_display) && (blit_data.h > 0)) {
for (yy = 0; yy < blit_data.h; yy++) {
if (((blit_data.y + yy) >= 0) && ((blit_data.y + yy) < buffer32->h)) {
video_transform_copy(&(buffer32->line[blit_data.y + yy][blit_data.x]), &(buffer32->line[blit_data.y + yy][blit_data.x]), blit_data.w);
}
@@ -444,16 +447,13 @@ void blit_thread(void *param)
}
if (screenshots) {
if (buffer32 != NULL)
video_screenshot(blit_data.x, blit_data.y, blit_data.y1, blit_data.y2, blit_data.w, blit_data.h);
video_screenshot();
screenshots--;
video_log("screenshot taken, %i left\n", screenshots);
}
if (blit_func)
blit_func(blit_data.x, blit_data.y,
blit_data.y1, blit_data.y2,
blit_data.w, blit_data.h);
blit_func(blit_data.x, blit_data.y, blit_data.w, blit_data.h);
blit_data.busy = 0;
@@ -464,7 +464,7 @@ void blit_thread(void *param)
void
video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
video_blit_memtoscreen(int x, int y, int w, int h)
{
MTR_BEGIN("video", "video_blit_memtoscreen");
@@ -477,8 +477,6 @@ video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
blit_data.buffer_in_use = 1;
blit_data.x = x;
blit_data.y = y;
blit_data.y1 = y1;
blit_data.y2 = y2;
blit_data.w = w;
blit_data.h = h;
@@ -542,7 +540,7 @@ video_blend(int x, int y)
void
video_blit_memtoscreen_8(int x, int y, int y1, int y2, int w, int h)
video_blit_memtoscreen_8(int x, int y, int w, int h)
{
int yy, xx;
@@ -559,7 +557,7 @@ video_blit_memtoscreen_8(int x, int y, int y1, int y2, int w, int h)
}
}
video_blit_memtoscreen(x, y, y1, y2, w, h);
video_blit_memtoscreen(x, y, w, h);
}