render-fx: turn bopti_image_t's data array into a pointer

It used to be a flexible array member because in the old days fxconv
could only output a fixed set of bytes, so any referencing was out the
question. Nowadays fxconv can output pretty much anything. Separating
the data pointer will be useful for PythonExtra to expose it as a Python
bytes() or bytearray() object while using the gint API.
This commit is contained in:
Lephe 2024-01-29 09:49:34 +01:00
parent fd5a70e21b
commit 833025f5dd
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 16 additions and 4 deletions

1
TODO
View File

@ -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

View File

@ -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

View File

@ -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;