Tiny3D
Loading...
Searching...
No Matches
tpx.h
Go to the documentation of this file.
1
6#ifndef TINYPX_PTX_H
7#define TINYPX_PTX_H
8
9#include <libdragon.h>
10#include <t3d/t3dmath.h>
11
12#ifdef __cplusplus
13extern "C"
14{
15#endif
16
17extern uint32_t TPX_RSP_ID;
18
19// RSP commands, must match with the commands defined in `rsp/rsp_tinypx.rspl`
20enum TPXCmd {
21 TPX_CMD_SYNC_T3D = 0x0,
22 TPX_CMD_DRAW_COLOR = 0x1,
23 TPX_CMD_MATRIX_STACK = 0x2,
24 TPX_CMD_SET_DMEM = 0x3,
25 TPX_CMD_DRAW_TEXTURE = 0x4,
26 // = 0x5,
27 // = 0x6,
28 // = 0x7,
29 // = 0x8,
30 // = 0x9,
31 // = 0xA,
32 // = 0xB,
33 // = 0xC,
34 // = 0xD,
35 // = 0xE,
36 // = 0xF,
37};
38
39typedef struct {
40 // Internal matrix stack size, must be at least 2.
41 // If set two zero, 4 will be used by default.
42 int matrixStackSize;
44
45typedef struct {
46 int8_t posA[3];
47 int8_t sizeA;
48 int8_t posB[3];
49 int8_t sizeB;
50 uint8_t colorA[4];
51 uint8_t colorB[4];
52} __attribute__((packed, aligned(16))) TPXParticle;
53
54_Static_assert(sizeof(TPXParticle) == 16, "TPXParticle size mismatch");
55
60void tpx_init(TPXInitParams params);
61
72
79void tpx_state_set_scale(float scaleX, float scaleY);
80
89void tpx_state_set_base_size(uint16_t baseSize);
90
103void tpx_state_set_tex_params(int16_t offsetX, uint16_t mirrorPoint);
104
112void tpx_particle_draw(TPXParticle *particles, uint32_t count);
113
124void tpx_particle_draw_tex(TPXParticle *particles, uint32_t count);
125
135void tpx_matrix_set(const T3DMat4FP *mat, bool doMultiply);
136
141void tpx_matrix_push(const T3DMat4FP *mat);
142
147void tpx_matrix_pop(int count);
148
161void tpx_matrix_push_pos(int count);
162
168static inline int8_t* tpx_buffer_get_pos(TPXParticle pt[], int idx) {
169 return (idx & 1) ? pt[idx/2].posB : pt[idx/2].posA;
170}
171
177static inline int8_t* tpx_buffer_get_size(TPXParticle pt[], int idx) {
178 return (idx & 1) ? &pt[idx/2].sizeB : &pt[idx/2].sizeA;
179}
180
186static inline uint32_t* tpx_buffer_get_color(TPXParticle pt[], int idx) {
187 return (idx & 1) ? (uint32_t*)&pt[idx/2].colorB : (uint32_t*)&pt[idx/2].colorA;
188}
189
195static inline uint8_t* tpx_buffer_get_rgba(TPXParticle pt[], int idx) {
196 return (idx & 1) ? pt[idx/2].colorB : pt[idx/2].colorA;
197}
198
205void tpx_buffer_swap(TPXParticle pt[], uint32_t idxA, uint32_t idxB);
206
214void tpx_buffer_copy(TPXParticle pt[], uint32_t idxDst, uint32_t idxSrc);
215
219void tpx_destroy();
220
221#ifdef __cplusplus
222}
223#endif
224
225#endif // TINYPX_PTX_H
Definition tpx.h:39
__attribute__((deprecated)) void t3d_debug_print_init()
Initializes the debug print system, make sure to have 'font.ia4.png' in your FS.
void tpx_state_set_base_size(uint16_t baseSize)
Definition tpx.c:68
void tpx_init(TPXInitParams params)
Initializes the tinyPX library.
Definition tpx.c:20
void tpx_state_set_tex_params(int16_t offsetX, uint16_t mirrorPoint)
Definition tpx.c:72
void tpx_destroy()
Definition tpx.c:152
static uint8_t * tpx_buffer_get_rgba(TPXParticle pt[], int idx)
Definition tpx.h:195
void tpx_matrix_push_pos(int count)
Definition tpx.c:125
static int8_t * tpx_buffer_get_size(TPXParticle pt[], int idx)
Definition tpx.h:177
void tpx_matrix_set(const T3DMat4FP *mat, bool doMultiply)
Definition tpx.c:112
static int8_t * tpx_buffer_get_pos(TPXParticle pt[], int idx)
Definition tpx.h:168
void tpx_matrix_pop(int count)
Definition tpx.c:120
void tpx_matrix_push(const T3DMat4FP *mat)
Definition tpx.c:116
void tpx_state_from_t3d()
Definition tpx.c:47
void tpx_buffer_copy(TPXParticle pt[], uint32_t idxDst, uint32_t idxSrc)
static uint32_t * tpx_buffer_get_color(TPXParticle pt[], int idx)
Definition tpx.h:186
void tpx_particle_draw_tex(TPXParticle *particles, uint32_t count)
Definition tpx.c:100
void tpx_state_set_scale(float scaleX, float scaleY)
Definition tpx.c:62
void tpx_buffer_swap(TPXParticle pt[], uint32_t idxA, uint32_t idxB)
Definition tpx.c:130
void tpx_particle_draw(TPXParticle *particles, uint32_t count)
Definition tpx.c:96