tidy-fix automàtic (sense naming)

This commit is contained in:
2026-05-14 18:28:23 +02:00
parent 358e91ea30
commit b7a551c158
81 changed files with 1549 additions and 831 deletions
+43 -24
View File
@@ -42,18 +42,18 @@ void JD8_ClearScreen(Uint8 color) {
memset(screen, color, 64000);
}
JD8_Surface JD8_NewSurface() {
auto JD8_NewSurface() -> JD8_Surface {
return new Uint8[64000]{};
}
// Helper intern: deriva el basename d'una ruta per a buscar al Cache.
static std::string jd8_basename(const char* file) {
static auto jd8_basename(const char* file) -> std::string {
std::string s = file;
auto pos = s.find_last_of("/\\");
return pos == std::string::npos ? s : s.substr(pos + 1);
}
JD8_Surface JD8_LoadSurface(const char* file) {
auto JD8_LoadSurface(const char* file) -> JD8_Surface {
// Prova primer el Resource::Cache. Si l'asset és precarregat, copiem
// els 64KB des del cache (microsegons) i ens estalviem la decodificació
// GIF. Mantenim el contracte de la funció: el caller rep un buffer
@@ -70,7 +70,8 @@ JD8_Surface JD8_LoadSurface(const char* file) {
}
auto buffer = ResourceHelper::loadFile(file);
unsigned short w, h;
unsigned short w;
unsigned short h;
Uint8* pixels = LoadGif(buffer.data(), &w, &h);
if (pixels == nullptr) {
printf("Unable to load bitmap: %s\n", SDL_GetError());
@@ -82,11 +83,11 @@ JD8_Surface JD8_LoadSurface(const char* file) {
return image;
}
JD8_Palette JD8_LoadPalette(const char* file) {
auto JD8_LoadPalette(const char* file) -> JD8_Palette {
// Sempre retorna un buffer de 256 colors reservat amb `new Color[256]`
// — el caller és responsable d'alliberar-lo amb `delete[]` (o lliurar-ne
// l'ownership a `JD8_SetScreenPalette`).
JD8_Palette palette = new Color[256];
auto palette = new Color[256];
if (Resource::Cache::get() != nullptr) {
try {
@@ -106,7 +107,9 @@ JD8_Palette JD8_LoadPalette(const char* file) {
}
void JD8_SetScreenPalette(JD8_Palette palette) {
if (main_palette == palette) return;
if (main_palette == palette) {
return;
}
delete[] main_palette;
main_palette = palette;
}
@@ -126,9 +129,15 @@ void JD8_FillRect(int x, int y, int w, int h, Uint8 color) {
h += y;
y = 0;
}
if (x + w > 320) w = 320 - x;
if (y + h > 200) h = 200 - y;
if (w <= 0 || h <= 0) return;
if (x + w > 320) {
w = 320 - x;
}
if (y + h > 200) {
h = 200 - y;
}
if (w <= 0 || h <= 0) {
return;
}
for (int row = y; row < y + h; ++row) {
memset(&screen[x + (row * 320)], color, w);
}
@@ -158,47 +167,55 @@ void JD8_BlitToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int sw
}
}
void JD8_BlitCK(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh, Uint8 colorkey) {
void JD8_BlitCK(int x, int y, const JD8_Surface surface, int sx, int sy, int sw, int sh, Uint8 colorkey) {
int src_pointer = sx + (sy * 320);
int dst_pointer = x + (y * 320);
for (int j = 0; j < sh; j++) {
for (int i = 0; i < sw; i++) {
if (surface[src_pointer + i] != colorkey) screen[dst_pointer + i] = surface[src_pointer + i];
if (surface[src_pointer + i] != colorkey) {
screen[dst_pointer + i] = surface[src_pointer + i];
}
}
src_pointer += 320;
dst_pointer += 320;
}
}
void JD8_BlitCKCut(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh, Uint8 colorkey) {
void JD8_BlitCKCut(int x, int y, const JD8_Surface surface, int sx, int sy, int sw, int sh, Uint8 colorkey) {
int src_pointer = sx + (sy * 320);
int dst_pointer = x + (y * 320);
for (int j = 0; j < sh; j++) {
for (int i = 0; i < sw; i++) {
if (surface[src_pointer + i] != colorkey && (x + i >= 0) && (y + j >= 0) && (x + i < 320) && (y + j < 200)) screen[dst_pointer + i] = surface[src_pointer + i];
if (surface[src_pointer + i] != colorkey && (x + i >= 0) && (y + j >= 0) && (x + i < 320) && (y + j < 200)) {
screen[dst_pointer + i] = surface[src_pointer + i];
}
}
src_pointer += 320;
dst_pointer += 320;
}
}
void JD8_BlitCKScroll(int y, JD8_Surface surface, int sx, int sy, int sh, Uint8 colorkey) {
void JD8_BlitCKScroll(int y, const JD8_Surface surface, int sx, int sy, int sh, Uint8 colorkey) {
int dst_pointer = y * 320;
for (int j = sy; j < sy + sh; j++) {
for (int i = 0; i < 320; i++) {
int x = (i + sx) % 320;
if (surface[x + j * 320] != colorkey) screen[dst_pointer] = surface[x + j * 320];
if (surface[x + (j * 320)] != colorkey) {
screen[dst_pointer] = surface[x + (j * 320)];
}
dst_pointer++;
}
}
}
void JD8_BlitCKToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh, JD8_Surface dest, Uint8 colorkey) {
void JD8_BlitCKToSurface(int x, int y, const JD8_Surface surface, int sx, int sy, int sw, int sh, JD8_Surface dest, Uint8 colorkey) {
int src_pointer = sx + (sy * 320);
int dst_pointer = x + (y * 320);
for (int j = 0; j < sh; j++) {
for (int i = 0; i < sw; i++) {
if (surface[src_pointer + i] != colorkey) dest[dst_pointer + i] = surface[src_pointer + i];
if (surface[src_pointer + i] != colorkey) {
dest[dst_pointer + i] = surface[src_pointer + i];
}
}
src_pointer += 320;
dst_pointer += 320;
@@ -218,15 +235,15 @@ void JD8_Flip() {
}
}
Uint32* JD8_GetFramebuffer() {
auto JD8_GetFramebuffer() -> Uint32* {
return pixel_data;
}
void JD8_FreeSurface(JD8_Surface surface) {
void JD8_FreeSurface(const JD8_Surface surface) {
delete[] surface;
}
Uint8 JD8_GetPixel(JD8_Surface surface, int x, int y) {
auto JD8_GetPixel(JD8_Surface surface, int x, int y) -> Uint8 {
return surface[x + (y * 320)];
}
@@ -292,12 +309,14 @@ void JD8_FadeStartToPal(JD8_Palette pal) {
fade_step = 0;
}
bool JD8_FadeIsActive() {
auto JD8_FadeIsActive() -> bool {
return fade_type != FadeType::None;
}
bool JD8_FadeTickStep() {
if (fade_type == FadeType::None) return true;
auto JD8_FadeTickStep() -> bool {
if (fade_type == FadeType::None) {
return true;
}
apply_fade_step();
fade_step++;