Files
aee/source/core/jail/jdraw8.hpp
T

79 lines
2.6 KiB
C++

#pragma once
#include <SDL3/SDL.h>
struct Color {
Uint8 r;
Uint8 g;
Uint8 b;
};
namespace Jd8 {
using Surface = Uint8*;
using Palette = Color*;
void init();
void quit();
void clearScreen(Uint8 color);
auto newSurface() -> Surface;
auto loadSurface(const char* file) -> Surface;
auto loadPalette(const char* file) -> Palette;
void setScreenPalette(Palette palette);
void fillSquare(int ini, int height, Uint8 color);
// Omple un rectangle arbitrari de la pantalla amb un color paletat.
// Pensat per a UI senzilla (barra de progrés del BootLoader, etc.).
void fillRect(int x, int y, int w, int h, Uint8 color);
void blit(const Uint8* surface);
void blit(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh);
void blitToSurface(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, Surface dest);
void blitCK(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, Uint8 colorkey);
void blitCKCut(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, Uint8 colorkey);
void blitCKScroll(int y, const Uint8* surface, int sx, int sy, int sh, Uint8 colorkey);
void blitCKToSurface(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, Surface dest, Uint8 colorkey);
// Converteix la pantalla indexada a ARGB. El Director crida aquesta
// funció al final de cada tick i després llegeix el framebuffer via
// getFramebuffer() per presentar-lo.
void flip();
// Accés al framebuffer ARGB de 320x200 actualitzat per l'última crida a
// flip(). Propietat de jdraw8 — el caller no ha de lliberar-lo.
auto getFramebuffer() -> Uint32*;
void freeSurface(Surface surface);
auto getPixel(const Uint8* surface, int x, int y) -> Uint8;
void putPixel(Surface surface, int x, int y, Uint8 pixel);
void setPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b);
// API de fade no bloquejant (màquina d'estats). `fadeStart*` inicia el
// fade; `fadeTickStep` aplica un pas i retorna `true` quan el fade ha
// acabat. Un pas correspon visualment a una iteració del fade original
// (32 passos en total). El caller és responsable de fer el Flip entre
// passos si el vol veure animat. `fadeIsActive` permet saber si hi ha
// 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.
void fadeStartOut();
void fadeStartToPal(const Color* pal);
auto fadeTickStep() -> bool;
auto fadeIsActive() -> bool;
} // namespace Jd8