diff --git a/TODO b/TODO index d6d3e38..501e373 100644 --- a/TODO +++ b/TODO @@ -17,6 +17,7 @@ Extensions on existing code: * core: run destructors when a task-switch results in leaving the app * fs: support read-only files backed with GetBlockAddress() on fx-CG * kernel: SH4- or G-III-specific linker scripts? +* render: Properly document bopti fx. Also make it faster maybe? Future directions: * Audio playback using TSWilliamson's libsnd method diff --git a/include/gint/display-fx.h b/include/gint/display-fx.h index 7c7d7db..3835986 100644 --- a/include/gint/display-fx.h +++ b/include/gint/display-fx.h @@ -61,6 +61,12 @@ typedef enum } color_t; +/* Profiles: + 0: MONO (1 layer: color) + 1: ALPHA (2 layers: color, alpha) + 2: GRAY (2 layers: light, dark) + 3: GRAY_ALPHA (3 layers: light, dark, alpha) */ + //--- // Image rendering (bopti) //--- @@ -83,10 +89,16 @@ typedef struct uint height :12; /* Raw layer data */ - uint8_t data[]; + uint8_t *data; } GPACKED(4) bopti_image_t; +/* Number of layers in the image. */ +GINLINE static int image_layer_count(int profile) +{ + return profile + (profile <= 1); +} + #ifdef __cplusplus } #endif diff --git a/src/render-fx/bopti.c b/src/render-fx/bopti.c index 460e88c..51a7f3d 100644 --- a/src/render-fx/bopti.c +++ b/src/render-fx/bopti.c @@ -164,8 +164,7 @@ void bopti_render(bopti_image_t const *img, struct rbox *rbox, uint32_t *v1, masks(rbox->visual_x, rbox->visual_x + rbox->width - 1, vm); /* Number of layers per profile */ - static const int layer_count[] = { 1, 2, 2, 3 }; - int layers = layer_count[img->profile]; + int layers = image_layer_count(img->profile); /* For each pair of consecutive VRAM elements involved, create a mask from the intersection of the standard vram mask with the shift-mask @@ -222,7 +221,7 @@ void bopti_render_scsp(bopti_image_t const *img, struct rbox *rbox, (0xffffffff << (32 - rbox->width)) >> (rbox->visual_x & 31); /* Number of layers */ - int layers = img->profile - (img->profile >> 1) + 1; + int layers = image_layer_count(img->profile); /* Number of longwords to skip between rows of [img] */ int img_stride = ((img->width + 31) >> 5) * layers;