mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Updated the sf2dlib and sftdlib; Added the gfx.color.hex() function; Added the New3DS CPU mode control.
As the color order of the sf2dlib changed, you have to change it in your code, or use the color.hex() function. To fix the problems, just change "0xRRGGBBAA" to "0xAABBGGRR". Also, the shader compiler changed to Picasso, so you'll need it in order to compile. https://github.com/fincs/picasso
This commit is contained in:
parent
0105970ab7
commit
b4d025d602
17 changed files with 205 additions and 131 deletions
|
|
@ -71,6 +71,10 @@ sf2d_texture *sf2d_create_texture(int width, int height, sf2d_texfmt pixel_forma
|
|||
texture->tiled = 0;
|
||||
texture->place = place;
|
||||
texture->pixel_format = pixel_format;
|
||||
texture->params = GPU_TEXTURE_MAG_FILTER(GPU_NEAREST)
|
||||
| GPU_TEXTURE_MIN_FILTER(GPU_NEAREST)
|
||||
| GPU_TEXTURE_WRAP_S(GPU_CLAMP_TO_BORDER)
|
||||
| GPU_TEXTURE_WRAP_T(GPU_CLAMP_TO_BORDER);
|
||||
texture->width = width;
|
||||
texture->height = height;
|
||||
texture->pow2_w = pow2_w;
|
||||
|
|
@ -145,7 +149,7 @@ void sf2d_bind_texture(const sf2d_texture *texture, GPU_TEXUNIT unit)
|
|||
(u32 *)osConvertVirtToPhys((u32)texture->data),
|
||||
texture->pow2_w,
|
||||
texture->pow2_h,
|
||||
GPU_TEXTURE_MAG_FILTER(GPU_NEAREST) | GPU_TEXTURE_MIN_FILTER(GPU_NEAREST),
|
||||
texture->params,
|
||||
texture->pixel_format
|
||||
);
|
||||
}
|
||||
|
|
@ -161,7 +165,7 @@ void sf2d_bind_texture_color(const sf2d_texture *texture, GPU_TEXUNIT unit, u32
|
|||
GPU_TEVOPERANDS(0, 0, 0),
|
||||
GPU_TEVOPERANDS(0, 0, 0),
|
||||
GPU_MODULATE, GPU_MODULATE,
|
||||
__builtin_bswap32(color) //RGBA8 -> ABGR8
|
||||
color
|
||||
);
|
||||
|
||||
GPU_SetTexture(
|
||||
|
|
@ -169,7 +173,7 @@ void sf2d_bind_texture_color(const sf2d_texture *texture, GPU_TEXUNIT unit, u32
|
|||
(u32 *)osConvertVirtToPhys((u32)texture->data),
|
||||
texture->pow2_w,
|
||||
texture->pow2_h,
|
||||
GPU_TEXTURE_MAG_FILTER(GPU_NEAREST) | GPU_TEXTURE_MIN_FILTER(GPU_NEAREST),
|
||||
texture->params,
|
||||
texture->pixel_format
|
||||
);
|
||||
}
|
||||
|
|
@ -198,9 +202,19 @@ void sf2d_bind_texture_parameters(const sf2d_texture *texture, GPU_TEXUNIT unit,
|
|||
);
|
||||
}
|
||||
|
||||
void sf2d_texture_set_params(sf2d_texture *texture, u32 params)
|
||||
{
|
||||
texture->params = params;
|
||||
}
|
||||
|
||||
int sf2d_texture_get_params(const sf2d_texture *texture)
|
||||
{
|
||||
return texture->params;
|
||||
}
|
||||
|
||||
static inline void sf2d_draw_texture_generic(const sf2d_texture *texture, int x, int y)
|
||||
{
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_tex));
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_tex), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
int w = texture->width;
|
||||
|
|
@ -248,7 +262,7 @@ void sf2d_draw_texture_blend(const sf2d_texture *texture, int x, int y, u32 colo
|
|||
|
||||
static inline void sf2d_draw_texture_rotate_hotspot_generic(const sf2d_texture *texture, int x, int y, float rad, float center_x, float center_y)
|
||||
{
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_tex));
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_tex), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
const float w = texture->width;
|
||||
|
|
@ -332,7 +346,7 @@ void sf2d_draw_texture_rotate_blend(const sf2d_texture *texture, int x, int y, f
|
|||
|
||||
static inline void sf2d_draw_texture_part_generic(const sf2d_texture *texture, int x, int y, int tex_x, int tex_y, int tex_w, int tex_h)
|
||||
{
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_tex));
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_tex), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
vertices[0].position = (sf2d_vector_3f){(float)x, (float)y, SF2D_DEFAULT_DEPTH};
|
||||
|
|
@ -379,7 +393,7 @@ void sf2d_draw_texture_part_blend(const sf2d_texture *texture, int x, int y, int
|
|||
|
||||
static inline void sf2d_draw_texture_scale_generic(const sf2d_texture *texture, int x, int y, float x_scale, float y_scale)
|
||||
{
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_tex));
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_tex), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
int ws = texture->width * x_scale;
|
||||
|
|
@ -427,7 +441,7 @@ void sf2d_draw_texture_scale_blend(const sf2d_texture *texture, int x, int y, fl
|
|||
|
||||
static inline void sf2d_draw_texture_part_scale_generic(const sf2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, float x_scale, float y_scale)
|
||||
{
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_tex));
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_tex), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
float u0 = tex_x/(float)texture->pow2_w;
|
||||
|
|
@ -477,7 +491,7 @@ void sf2d_draw_texture_part_scale_blend(const sf2d_texture *texture, float x, fl
|
|||
|
||||
static inline void sf2d_draw_texture_part_rotate_scale_generic(const sf2d_texture *texture, int x, int y, float rad, int tex_x, int tex_y, int tex_w, int tex_h, float x_scale, float y_scale)
|
||||
{
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_tex));
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_tex), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
int w2 = (tex_w * x_scale)/2.0f;
|
||||
|
|
@ -537,7 +551,7 @@ void sf2d_draw_texture_part_rotate_scale_blend(const sf2d_texture *texture, int
|
|||
|
||||
static inline void sf2d_draw_texture_depth_generic(const sf2d_texture *texture, int x, int y, signed short z)
|
||||
{
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_tex));
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_tex), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
int w = texture->width;
|
||||
|
|
@ -587,7 +601,7 @@ void sf2d_draw_texture_depth_blend(const sf2d_texture *texture, int x, int y, si
|
|||
|
||||
void sf2d_draw_quad_uv(const sf2d_texture *texture, float left, float top, float right, float bottom, float u0, float v0, float u1, float v1, unsigned int params)
|
||||
{
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_malloc(4 * sizeof(sf2d_vertex_pos_tex));
|
||||
sf2d_vertex_pos_tex *vertices = sf2d_pool_memalign(4 * sizeof(sf2d_vertex_pos_tex), 8);
|
||||
if (!vertices) return;
|
||||
|
||||
vertices[0].position = (sf2d_vector_3f){left, top, SF2D_DEFAULT_DEPTH};
|
||||
|
|
@ -641,9 +655,9 @@ void sf2d_set_pixel(sf2d_texture *texture, int x, int y, u32 new_color)
|
|||
if (texture->tiled) {
|
||||
u32 coarse_y = y & ~7;
|
||||
u32 offset = get_morton_offset(x, y, 4) + coarse_y * texture->pow2_w * 4;
|
||||
*(u32 *)(texture->data + offset) = __builtin_bswap32(new_color);
|
||||
*(u32 *)(texture->data + offset) = new_color;
|
||||
} else {
|
||||
((u32 *)texture->data)[x + y * texture->pow2_w] = __builtin_bswap32(new_color);
|
||||
((u32 *)texture->data)[x + y * texture->pow2_w] = new_color;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -653,9 +667,9 @@ u32 sf2d_get_pixel(sf2d_texture *texture, int x, int y)
|
|||
if (texture->tiled) {
|
||||
u32 coarse_y = y & ~7;
|
||||
u32 offset = get_morton_offset(x, y, 4) + coarse_y * texture->pow2_w * 4;
|
||||
return __builtin_bswap32(*(u32 *)(texture->data + offset));
|
||||
return *(u32 *)(texture->data + offset);
|
||||
} else {
|
||||
return __builtin_bswap32(((u32 *)texture->data)[x + y * texture->pow2_w]);
|
||||
return ((u32 *)texture->data)[x + y * texture->pow2_w];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -675,7 +689,7 @@ void sf2d_texture_tile32(sf2d_texture *texture)
|
|||
u32 dst_offset = get_morton_offset(i, j, 4) + coarse_y * texture->pow2_w * 4;
|
||||
|
||||
u32 v = ((u32 *)texture->data)[i + (texture->pow2_h - 1 - j)*texture->pow2_w];
|
||||
*(u32 *)(tmp + dst_offset) = __builtin_bswap32(v);
|
||||
*(u32 *)(tmp + dst_offset) = __builtin_bswap32(v); /* RGBA8 -> ABGR8 */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue