fix: cppcheck (21 troballes)

This commit is contained in:
2026-05-16 13:52:31 +02:00
parent a48fe51f73
commit bf7be3a7f1
13 changed files with 96 additions and 117 deletions
+19 -22
View File
@@ -3,6 +3,7 @@
// --- Includes --- // --- Includes ---
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <algorithm> // Para std::fill
#include <cstdint> // Para uint32_t, uint8_t #include <cstdint> // Para uint32_t, uint8_t
#include <cstdio> // Para NULL, fseek, fclose, fopen, fread, ftell, FILE, SEEK_END, SEEK_SET #include <cstdio> // Para NULL, fseek, fclose, fopen, fread, ftell, FILE, SEEK_END, SEEK_SET
#include <cstdlib> // Para free, malloc #include <cstdlib> // Para free, malloc
@@ -270,9 +271,7 @@ inline void JA_Init(const int freq, const SDL_AudioFormat format, const int num_
for (auto& channel : channels) { for (auto& channel : channels) {
channel.state = JA_CHANNEL_FREE; channel.state = JA_CHANNEL_FREE;
} }
for (float& i : JA_soundVolume) { std::fill(std::begin(JA_soundVolume), std::end(JA_soundVolume), 0.5F);
i = 0.5F;
}
} }
inline void JA_Quit() { inline void JA_Quit() {
@@ -673,10 +672,10 @@ inline void JA_PauseChannel(const int channel) {
} }
if (channel == -1) { if (channel == -1) {
for (auto& channel : channels) { for (auto& ch : channels) {
if (channel.state == JA_CHANNEL_PLAYING) { if (ch.state == JA_CHANNEL_PLAYING) {
channel.state = JA_CHANNEL_PAUSED; ch.state = JA_CHANNEL_PAUSED;
SDL_UnbindAudioStream(channel.stream); SDL_UnbindAudioStream(ch.stream);
} }
} }
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) { } else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
@@ -693,10 +692,10 @@ inline void JA_ResumeChannel(const int channel) {
} }
if (channel == -1) { if (channel == -1) {
for (auto& channel : channels) { for (auto& ch : channels) {
if (channel.state == JA_CHANNEL_PAUSED) { if (ch.state == JA_CHANNEL_PAUSED) {
channel.state = JA_CHANNEL_PLAYING; ch.state = JA_CHANNEL_PLAYING;
SDL_BindAudioStream(sdlAudioDevice, channel.stream); SDL_BindAudioStream(sdlAudioDevice, ch.stream);
} }
} }
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) { } else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
@@ -709,15 +708,15 @@ inline void JA_ResumeChannel(const int channel) {
inline void JA_StopChannel(const int channel) { inline void JA_StopChannel(const int channel) {
if (channel == -1) { if (channel == -1) {
for (auto& channel : channels) { for (auto& ch : channels) {
if (channel.state != JA_CHANNEL_FREE) { if (ch.state != JA_CHANNEL_FREE) {
if (channel.stream != nullptr) { if (ch.stream != nullptr) {
SDL_DestroyAudioStream(channel.stream); SDL_DestroyAudioStream(ch.stream);
} }
channel.stream = nullptr; ch.stream = nullptr;
channel.state = JA_CHANNEL_FREE; ch.state = JA_CHANNEL_FREE;
channel.pos = 0; ch.pos = 0;
channel.sound = nullptr; ch.sound = nullptr;
} }
} }
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) { } else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
@@ -748,9 +747,7 @@ inline auto JA_SetSoundVolume(float volume, const int group = -1) -> float {
const float v = SDL_clamp(volume, 0.0F, 1.0F); const float v = SDL_clamp(volume, 0.0F, 1.0F);
if (group == -1) { if (group == -1) {
for (float& i : JA_soundVolume) { std::fill(std::begin(JA_soundVolume), std::end(JA_soundVolume), v);
i = v;
}
} else if (group >= 0 && group < JA_MAX_GROUPS) { } else if (group >= 0 && group < JA_MAX_GROUPS) {
JA_soundVolume[group] = v; JA_soundVolume[group] = v;
} else { } else {
+4 -4
View File
@@ -145,11 +145,11 @@ void JD8_FillRect(int x, int y, int w, int h, Uint8 color) {
} }
} }
void JD8_Blit(JD8_Surface surface) { void JD8_Blit(const Uint8* surface) {
memcpy(screen, surface, 64000); memcpy(screen, surface, 64000);
} }
void JD8_Blit(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh) { void JD8_Blit(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh) {
int src_pointer = sx + (sy * 320); int src_pointer = sx + (sy * 320);
int dst_pointer = x + (y * 320); int dst_pointer = x + (y * 320);
for (int i = 0; i < sh; i++) { for (int i = 0; i < sh; i++) {
@@ -159,7 +159,7 @@ void JD8_Blit(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh)
} }
} }
void JD8_BlitToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh, JD8_Surface dest) { void JD8_BlitToSurface(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, JD8_Surface dest) {
int src_pointer = sx + (sy * 320); int src_pointer = sx + (sy * 320);
int dst_pointer = x + (y * 320); int dst_pointer = x + (y * 320);
for (int i = 0; i < sh; i++) { for (int i = 0; i < sh; i++) {
@@ -305,7 +305,7 @@ void JD8_FadeStartOut() {
fade_step = 0; fade_step = 0;
} }
void JD8_FadeStartToPal(JD8_Palette pal) { void JD8_FadeStartToPal(const Color* pal) {
fade_type = FadeType::ToPal; fade_type = FadeType::ToPal;
memcpy(fade_target, pal, sizeof(Color) * 256); memcpy(fade_target, pal, sizeof(Color) * 256);
fade_step = 0; fade_step = 0;
+4 -4
View File
@@ -30,11 +30,11 @@ void JD8_FillSquare(int ini, int height, Uint8 color);
// Pensat per a UI senzilla (barra de progrés del BootLoader, etc.). // Pensat per a UI senzilla (barra de progrés del BootLoader, etc.).
void JD8_FillRect(int x, int y, int w, int h, Uint8 color); void JD8_FillRect(int x, int y, int w, int h, Uint8 color);
void JD8_Blit(JD8_Surface surface); void JD8_Blit(const Uint8* surface);
void JD8_Blit(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh); void JD8_Blit(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh);
void JD8_BlitToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh, JD8_Surface dest); void JD8_BlitToSurface(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, JD8_Surface dest);
void JD8_BlitCK(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, Uint8 colorkey); void JD8_BlitCK(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, Uint8 colorkey);
@@ -69,7 +69,7 @@ void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b);
// un fade en curs per a enllaçar-lo amb un altre subsistema. // un fade en curs per a enllaçar-lo amb un altre subsistema.
// L'embolcall `scenes::PaletteFade` ho fa més idiomàtic per a escenes. // L'embolcall `scenes::PaletteFade` ho fa més idiomàtic per a escenes.
void JD8_FadeStartOut(); void JD8_FadeStartOut();
void JD8_FadeStartToPal(JD8_Palette pal); void JD8_FadeStartToPal(const Color* pal);
auto JD8_FadeTickStep() -> bool; auto JD8_FadeTickStep() -> bool;
auto JD8_FadeIsActive() -> bool; auto JD8_FadeIsActive() -> bool;
+9 -11
View File
@@ -3,6 +3,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <algorithm>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <string> #include <string>
@@ -90,11 +91,10 @@ void file_setconfigfolder(const char* foldername) {
homedir = "/tmp"; homedir = "/tmp";
} }
config_folder = std::string(homedir) + "/.config/" + foldername; config_folder = std::string(homedir) + "/.config/" + foldername;
#else
config_folder = std::string("/tmp/jailgames_config/") + foldername;
#endif #endif
if (config_folder.empty()) {
config_folder = "/tmp/jailgames_config";
}
std::error_code ec; std::error_code ec;
std::filesystem::create_directories(config_folder, ec); std::filesystem::create_directories(config_folder, ec);
// A emscripten/MEMFS create_directories pot fallar (p.ex. parent // A emscripten/MEMFS create_directories pot fallar (p.ex. parent
@@ -112,13 +112,12 @@ auto file_getconfigvalue(const char* key) -> const char* {
if (config.empty()) { if (config.empty()) {
load_config_values(); load_config_values();
} }
for (const auto& pair : config) { const auto it = std::find_if(config.begin(), config.end(), [key](const keyvalue& pair) { return pair.key == key; });
if (pair.key == key) { if (it != config.end()) {
thread_local std::string value_cache; thread_local std::string value_cache;
value_cache = pair.value; value_cache = it->value;
return value_cache.c_str(); return value_cache.c_str();
} }
}
return nullptr; return nullptr;
} }
@@ -126,13 +125,12 @@ void file_setconfigvalue(const char* key, const char* value) {
if (config.empty()) { if (config.empty()) {
load_config_values(); load_config_values();
} }
for (auto& pair : config) { const auto it = std::find_if(config.begin(), config.end(), [key](const keyvalue& pair) { return pair.key == key; });
if (pair.key == key) { if (it != config.end()) {
pair.value = value; it->value = value;
save_config_values(); save_config_values();
return; return;
} }
}
config.push_back({std::string(key), std::string(value)}); config.push_back({std::string(key), std::string(value)});
save_config_values(); save_config_values();
} }
+2 -12
View File
@@ -365,12 +365,7 @@ namespace Menu {
// body = (N-1) * ITEM_SPACING + charH — així BOTTOM_PAD és el buit real // body = (N-1) * ITEM_SPACING + charH — així BOTTOM_PAD és el buit real
// sota el text del darrer ítem, no un buit extra per sobre d'un "slot" buit. // sota el text del darrer ítem, no un buit extra per sobre d'un "slot" buit.
static auto boxHeight(const Page& page) -> int { static auto boxHeight(const Page& page) -> int {
int n = 0; const int n = static_cast<int>(std::count_if(page.items.begin(), page.items.end(), [](const auto& it) { return isVisible(it); }));
for (const auto& it : page.items) {
if (isVisible(it)) {
++n;
}
}
int body = (n == 0) ? 8 : ((n - 1) * ITEM_SPACING) + 8; int body = (n == 0) ? 8 : ((n - 1) * ITEM_SPACING) + 8;
int header = HEADER_H + (page.subtitle.empty() ? 0 : SUBTITLE_H); int header = HEADER_H + (page.subtitle.empty() ? 0 : SUBTITLE_H);
return header + body + BOTTOM_PAD; return header + body + BOTTOM_PAD;
@@ -557,12 +552,7 @@ namespace Menu {
items_y += SUBTITLE_H; items_y += SUBTITLE_H;
} }
// Compta visibles — si cap, dibuixa placeholder (caixa totalment col·lapsada però oberta) // Compta visibles — si cap, dibuixa placeholder (caixa totalment col·lapsada però oberta)
int visible_count = 0; const int visible_count = static_cast<int>(std::count_if(page.items.begin(), page.items.end(), [](const auto& it) { return isVisible(it); }));
for (const auto& it : page.items) {
if (isVisible(it)) {
++visible_count;
}
}
if (visible_count == 0) { if (visible_count == 0) {
const char* empty_text = Locale::get("menu.values.empty"); const char* empty_text = Locale::get("menu.values.empty");
int ew = font_->width(empty_text); int ew = font_->width(empty_text);
+2 -2
View File
@@ -246,7 +246,7 @@ namespace Overlay {
// Calcula amplada total interpolant cada segment per la seva anim // Calcula amplada total interpolant cada segment per la seva anim
float total_w = 0.0F; float total_w = 0.0F;
for (auto& seg : info_segments_) { for (const auto& seg : info_segments_) {
if (seg.anim > 0.0F && !seg.text.empty()) { if (seg.anim > 0.0F && !seg.text.empty()) {
int w = seg.mono_digits int w = seg.mono_digits
? font_->widthMonoDigits(seg.text.c_str(), DIGIT_CELL) ? font_->widthMonoDigits(seg.text.c_str(), DIGIT_CELL)
@@ -270,7 +270,7 @@ namespace Overlay {
// Dibuixa cada segment en la seva posició x acumulada // Dibuixa cada segment en la seva posició x acumulada
float cur_x = (SCREEN_W - total_w) / 2.0F; float cur_x = (SCREEN_W - total_w) / 2.0F;
for (auto& seg : info_segments_) { for (const auto& seg : info_segments_) {
if (seg.anim > 0.01F && !seg.text.empty()) { if (seg.anim > 0.01F && !seg.text.empty()) {
int xi = static_cast<int>(cur_x); int xi = static_cast<int>(cur_x);
int seg_w = seg.mono_digits int seg_w = seg.mono_digits
+2 -2
View File
@@ -79,7 +79,7 @@ namespace Resource {
} }
void Cache::calculateTotal() { void Cache::calculateTotal() {
auto* list = List::get(); const auto* list = List::get();
total_count_ = static_cast<int>( total_count_ = static_cast<int>(
list->getListByType(List::Type::MUSIC).size() + list->getListByType(List::Type::MUSIC).size() +
list->getListByType(List::Type::SOUND).size() + list->getListByType(List::Type::SOUND).size() +
@@ -110,7 +110,7 @@ namespace Resource {
const Uint64 start_ns = SDL_GetTicksNS(); const Uint64 start_ns = SDL_GetTicksNS();
const Uint64 budget_ns = static_cast<Uint64>(budget_ms) * 1'000'000ULL; const Uint64 budget_ns = static_cast<Uint64>(budget_ms) * 1'000'000ULL;
auto* list = List::get(); const auto* list = List::get();
while (stage_ != LoadStage::DONE) { while (stage_ != LoadStage::DONE) {
switch (stage_) { switch (stage_) {
+12 -17
View File
@@ -5,6 +5,7 @@
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <numeric>
const std::string ResourcePack::DEFAULT_ENCRYPT_KEY = "AEE_RESOURCES__2026"; const std::string ResourcePack::DEFAULT_ENCRYPT_KEY = "AEE_RESOURCES__2026";
@@ -21,11 +22,7 @@ ResourcePack::~ResourcePack() {
auto ResourcePack::calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t { auto ResourcePack::calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t {
// djb2-like hash, seed 0x12345678 (idèntic a CCAE). // djb2-like hash, seed 0x12345678 (idèntic a CCAE).
uint32_t checksum = 0x12345678; return std::accumulate(data.begin(), data.end(), uint32_t{0x12345678}, [](uint32_t acc, unsigned char b) { return ((acc << 5) + acc) + b; });
for (unsigned char b : data) {
checksum = ((checksum << 5) + checksum) + b;
}
return checksum;
} }
void ResourcePack::encryptData(std::vector<uint8_t>& data, const std::string& key) { void ResourcePack::encryptData(std::vector<uint8_t>& data, const std::string& key) {
@@ -163,20 +160,18 @@ auto ResourcePack::addDirectory(const std::string& directory) -> bool {
return false; return false;
} }
for (const auto& entry : std::filesystem::recursive_directory_iterator(directory)) { namespace fs = std::filesystem;
return std::all_of(fs::recursive_directory_iterator(directory),
fs::recursive_directory_iterator{},
[&](const fs::directory_entry& entry) {
if (!entry.is_regular_file()) { if (!entry.is_regular_file()) {
continue;
}
std::string filepath = entry.path().string();
std::string filename = std::filesystem::relative(entry.path(), directory).string();
std::ranges::replace(filename, '\\', '/');
if (!addFile(filename, filepath)) {
return false;
}
}
return true; return true;
}
std::string filepath = entry.path().string();
std::string filename = fs::relative(entry.path(), directory).string();
std::ranges::replace(filename, '\\', '/');
return addFile(filename, filepath);
});
} }
auto ResourcePack::getResource(const std::string& filename) -> std::vector<uint8_t> { auto ResourcePack::getResource(const std::string& filename) -> std::vector<uint8_t> {
+2 -3
View File
@@ -1,5 +1,6 @@
#include "game/mapa.hpp" #include "game/mapa.hpp"
#include <algorithm>
#include <cstdlib> #include <cstdlib>
#include "core/jail/jgame.hpp" #include "core/jail/jgame.hpp"
@@ -246,11 +247,9 @@ void Mapa::comprovaCaixa(Uint8 num) {
} }
// Si algun costat encara no està passat, no hi ha res que fer // Si algun costat encara no està passat, no hi ha res que fer
for (bool i : this->tombes[num].costat) { if (std::any_of(std::begin(this->tombes[num].costat), std::end(this->tombes[num].costat), [](bool c) { return !c; })) {
if (!i) {
return; return;
} }
}
// Sinó, pos la acabem d'obrir // Sinó, pos la acabem d'obrir
this->tombes[num].oberta = true; this->tombes[num].oberta = true;
+1 -1
View File
@@ -49,7 +49,7 @@ namespace {
// blit únic del wordmark "JAILGAMES" complet (231×45 al destí 43,78). // blit únic del wordmark "JAILGAMES" complet (231×45 al destí 43,78).
// IntroScene només s'activa quan use_new_logo == false, així que la // IntroScene només s'activa quan use_new_logo == false, així que la
// branca use_new_logo d'aquell helper aquí no es necessita. // branca use_new_logo d'aquell helper aquí no es necessita.
void drawWordmark(JD8_Surface gfx) { void drawWordmark(const Uint8* gfx) {
JD8_Blit(43, 78, gfx, 43, 155, 231, 45); JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
} }
+23 -23
View File
@@ -52,7 +52,7 @@ namespace {
// Branqueja segons use_new_logo perquè la mateixa sub-escena es // Branqueja segons use_new_logo perquè la mateixa sub-escena es
// reutilitza des de IntroScene (logo vell) i IntroNewLogoScene (logo // reutilitza des de IntroScene (logo vell) i IntroNewLogoScene (logo
// nou) amb arxius diferents però mateix layout de sprites. // nou) amb arxius diferents però mateix layout de sprites.
void drawWordmark(JD8_Surface gfx) { void drawWordmark(const Uint8* gfx) {
if (Options::game.use_new_logo) { if (Options::game.use_new_logo) {
// Centrat: (320 188) / 2 = 66 (IntroNewLogoScene usa la mateixa x). // Centrat: (320 188) / 2 = 66 (IntroNewLogoScene usa la mateixa x).
JD8_Blit(66, 78, gfx, 60, 158, 188, 28); JD8_Blit(66, 78, gfx, 60, 158, 188, 28);
@@ -61,7 +61,7 @@ namespace {
} }
} }
using RenderFn = void (*)(JD8_Surface, int); using RenderFn = void (*)(const Uint8*, int);
// Una fase — rang [start_i..end_i] inclusive (direcció implícita per // Una fase — rang [start_i..end_i] inclusive (direcció implícita per
// signe), funció de render, i flag d'skippable. Totes les fases actuals // signe), funció de render, i flag d'skippable. Totes les fases actuals
@@ -78,38 +78,38 @@ namespace {
// Variant 0 — Interrogant / Momia // Variant 0 — Interrogant / Momia
// ========================================================================= // =========================================================================
void v0_walk_right(JD8_Surface gfx, int i) { void v0_walk_right(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(i, 150, gfx, fr1[(i / 5) % 13], 0, 15, 15, 0); JD8_BlitCK(i, 150, gfx, fr1[(i / 5) % 13], 0, 15, 15, 0);
} }
void v0_pull_map_right(JD8_Surface gfx, int i) { void v0_pull_map_right(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(200, 150, gfx, fr3[std::min(i / 5, 10)], 30, 15, 15, 0); JD8_BlitCK(200, 150, gfx, fr3[std::min(i / 5, 10)], 30, 15, 15, 0);
} }
void v0_walk_left_to_80(JD8_Surface gfx, int i) { void v0_walk_left_to_80(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(i, 150, gfx, fr2[(i / 5) % 13], 15, 15, 15, 0); JD8_BlitCK(i, 150, gfx, fr2[(i / 5) % 13], 15, 15, 15, 0);
} }
void v0_pull_map_left(JD8_Surface gfx, int i) { void v0_pull_map_left(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(80, 150, gfx, fr4[std::min(i / 5, 10)], 45, 15, 15, 0); JD8_BlitCK(80, 150, gfx, fr4[std::min(i / 5, 10)], 45, 15, 15, 0);
} }
void v0_momia_left(JD8_Surface gfx, int i) { void v0_momia_left(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(i, 150, gfx, fr6[(i / 5) % 8], 60, 15, 15, 0); JD8_BlitCK(i, 150, gfx, fr6[(i / 5) % 8], 60, 15, 15, 0);
JD8_BlitCK(80, 150, gfx, fr4[10], 45, 15, 15, 0); JD8_BlitCK(80, 150, gfx, fr4[10], 45, 15, 15, 0);
} }
void v0_turn(JD8_Surface gfx, int /*i*/) { void v0_turn(const Uint8* gfx, int /*i*/) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(80, 150, gfx, fr1[1], 0, 15, 15, 0); JD8_BlitCK(80, 150, gfx, fr1[1], 0, 15, 15, 0);
@@ -117,28 +117,28 @@ namespace {
JD8_BlitCK(80, 133, gfx, 0, INTERROGANT, 15, 15, 0); JD8_BlitCK(80, 133, gfx, 0, INTERROGANT, 15, 15, 0);
} }
void v0_jump1(JD8_Surface gfx, int i) { void v0_jump1(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(80, 150 - ((i % 50) / 5), gfx, fr5[std::min(i / 5, 19)], 45, 15, 15, 0); JD8_BlitCK(80, 150 - ((i % 50) / 5), gfx, fr5[std::min(i / 5, 19)], 45, 15, 15, 0);
JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0); JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0);
} }
void v0_jump2(JD8_Surface gfx, int i) { void v0_jump2(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(80, 140 + ((i % 50) / 5), gfx, fr5[std::min(i / 5, 19)], 45, 15, 15, 0); JD8_BlitCK(80, 140 + ((i % 50) / 5), gfx, fr5[std::min(i / 5, 19)], 45, 15, 15, 0);
JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0); JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0);
} }
void v0_walk_final(JD8_Surface gfx, int i) { void v0_walk_final(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(i, 150, gfx, fr2[(i / 5) % 13], 15, 15, 15, 0); JD8_BlitCK(i, 150, gfx, fr2[(i / 5) % 13], 15, 15, 15, 0);
JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0); JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0);
} }
void v0_final(JD8_Surface gfx, int /*i*/) { void v0_final(const Uint8* gfx, int /*i*/) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0); JD8_BlitCK(95, 150, gfx, fr6[4], 60, 15, 15, 0);
@@ -163,21 +163,21 @@ namespace {
// Variant 1 — Creu / Pedra // Variant 1 — Creu / Pedra
// ========================================================================= // =========================================================================
void v1_walk_right(JD8_Surface gfx, int i) { void v1_walk_right(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255); JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
JD8_BlitCK(i, 150, gfx, fr1[(i / 5) % 13], 0, 15, 15, 255); JD8_BlitCK(i, 150, gfx, fr1[(i / 5) % 13], 0, 15, 15, 255);
} }
void v1_pull_map(JD8_Surface gfx, int i) { void v1_pull_map(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255); JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
JD8_BlitCK(200, 150, gfx, fr3[std::min(i / 5, 10)], 30, 15, 15, 255); JD8_BlitCK(200, 150, gfx, fr3[std::min(i / 5, 10)], 30, 15, 15, 255);
} }
void v1_interrogant(JD8_Surface gfx, int /*i*/) { void v1_interrogant(const Uint8* gfx, int /*i*/) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255); JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
@@ -185,7 +185,7 @@ namespace {
JD8_BlitCK(200, 150, gfx, fr3[10], 30, 15, 15, 255); JD8_BlitCK(200, 150, gfx, fr3[10], 30, 15, 15, 255);
} }
void v1_drop_map(JD8_Surface gfx, int i) { void v1_drop_map(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255); JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
@@ -199,7 +199,7 @@ namespace {
} }
} }
void v1_stone_fall(JD8_Surface gfx, int i) { void v1_stone_fall(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255); JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
@@ -207,14 +207,14 @@ namespace {
JD8_BlitCK(200, i * 2, gfx, fr8[0], 75, 15, 15, 255); JD8_BlitCK(200, i * 2, gfx, fr8[0], 75, 15, 15, 255);
} }
void v1_stone_break(JD8_Surface gfx, int i) { void v1_stone_break(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255); JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
JD8_BlitCK(200, 150, gfx, fr8[i / 10], 75, 15, 15, 255); JD8_BlitCK(200, 150, gfx, fr8[i / 10], 75, 15, 15, 255);
} }
void v1_final(JD8_Surface gfx, int /*i*/) { void v1_final(const Uint8* gfx, int /*i*/) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255); JD8_BlitCK(200, 155, gfx, 0, CREU, 15, 15, 255);
@@ -237,21 +237,21 @@ namespace {
// Variant 2 — Ball de carnaval // Variant 2 — Ball de carnaval
// ========================================================================= // =========================================================================
void v2_approach(JD8_Surface gfx, int i) { void v2_approach(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(i, 150, gfx, fr1[(i / 5) % 13], 0, 15, 15, 255); JD8_BlitCK(i, 150, gfx, fr1[(i / 5) % 13], 0, 15, 15, 255);
JD8_BlitCK(304 - i, 150, gfx, fr6[(i / 10) % 8], 60, 15, 15, 255); JD8_BlitCK(304 - i, 150, gfx, fr6[(i / 10) % 8], 60, 15, 15, 255);
} }
void v2_still(JD8_Surface gfx, int /*i*/) { void v2_still(const Uint8* gfx, int /*i*/) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(145, 150, gfx, fr1[1], 0, 15, 15, 255); JD8_BlitCK(145, 150, gfx, fr1[1], 0, 15, 15, 255);
JD8_BlitCK(160, 150, gfx, fr6[1], 60, 15, 15, 255); JD8_BlitCK(160, 150, gfx, fr6[1], 60, 15, 15, 255);
} }
void v2_horn(JD8_Surface gfx, int i) { void v2_horn(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(125, 150, gfx, fr11[(i / 10) % 2], 90, 15, 15, 255); JD8_BlitCK(125, 150, gfx, fr11[(i / 10) % 2], 90, 15, 15, 255);
@@ -259,7 +259,7 @@ namespace {
JD8_BlitCK(160, 150, gfx, fr6[1], 60, 15, 15, 255); JD8_BlitCK(160, 150, gfx, fr6[1], 60, 15, 15, 255);
} }
void v2_ball(JD8_Surface gfx, int i) { void v2_ball(const Uint8* gfx, int i) {
JD8_ClearScreen(0); JD8_ClearScreen(0);
drawWordmark(gfx); drawWordmark(gfx);
JD8_BlitCK(145, 150, gfx, fr9[(i / 10) % 16], 120, 15, 15, 255); JD8_BlitCK(145, 150, gfx, fr9[(i / 10) % 16], 120, 15, 15, 255);
+1 -1
View File
@@ -7,7 +7,7 @@ namespace scenes {
active_ = true; active_ = true;
} }
void PaletteFade::startFadeTo(JD8_Palette target) { void PaletteFade::startFadeTo(const Color* target) {
JD8_FadeStartToPal(target); JD8_FadeStartToPal(target);
active_ = true; active_ = true;
} }
+1 -1
View File
@@ -16,7 +16,7 @@ namespace scenes {
PaletteFade() = default; PaletteFade() = default;
void startFadeOut(); void startFadeOut();
void startFadeTo(JD8_Palette target); void startFadeTo(const Color* target);
void tick(int delta_ms); void tick(int delta_ms);