From 83e5234cb6e492f7485e68ba32dd402e4634bb44 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Thu, 12 Oct 2023 13:50:31 +0200 Subject: [PATCH] - Arreglats errors ambs el viewport - Els fades van mes lentos --- source/jdraw.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/jdraw.cpp b/source/jdraw.cpp index cd6e09f..4b90493 100644 --- a/source/jdraw.cpp +++ b/source/jdraw.cpp @@ -52,6 +52,9 @@ namespace draw // Creem la superficie "screen" i la establim com a superficie destinació screen = createSurface(width, height); destination = screen; + viewport.x = viewport.y = 0; + viewport.w = width; + viewport.h = height; sel_color = transparent = 0; for (int i=0;i<256;++i) color_indices[i] = i; @@ -257,7 +260,7 @@ namespace draw surface->pixels[(viewport.x+x) + (y+viewport.y) * surface->w] = color_indices[color]; } else { // Si no es destinations, mirem que estiga dins de la surface, i sinó fora! - if (x >= 0 && y >= 0 && x < destination->w && y < destination->h) + if (x >= 0 && y >= 0 && x < surface->w && y < surface->h) surface->pixels[x + y * surface->w] = color_indices[color]; } } @@ -271,7 +274,7 @@ namespace draw return surface->pixels[(viewport.x + x) + (viewport.y + y) * surface->w]; } else { // Si no es "destination", si la coordenada està dins del rang que abarca la superficie, - if (x >= 0 && y >= 0 && x < destination->w && y < destination->h) + if (x >= 0 && y >= 0 && x < surface->w && y < surface->h) return surface->pixels[x + y * surface->w]; } @@ -404,13 +407,13 @@ namespace draw } } fading_in = false; - for (int i=0; i<256; ++i) if (incPalEntry(i, 16)) fading_in = true; + for (int i=0; i<256; ++i) if (incPalEntry(i, 8)) fading_in = true; } void fadeout() { fading_out = false; - for (int i=0; i<256; ++i) if (decPalEntry(i, 16)) fading_out = true; + for (int i=0; i<256; ++i) if (decPalEntry(i, 8)) fading_out = true; } // Refresca la pantalla