24#define GX_WPAR_ADDRESS 0xCC008000
28#define GX_WPAR_U8 (*(volatile uint8_t*)GX_WPAR_ADDRESS)
29#define GX_WPAR_U16 (*(volatile uint16_t*)GX_WPAR_ADDRESS)
30#define GX_WPAR_U32 (*(volatile uint32_t*)GX_WPAR_ADDRESS)
31#define GX_WPAR_S8 (*(volatile int8_t*)GX_WPAR_ADDRESS)
32#define GX_WPAR_S16 (*(volatile int16_t*)GX_WPAR_ADDRESS)
33#define GX_WPAR_S32 (*(volatile int32_t*)GX_WPAR_ADDRESS)
34#define GX_WPAR_F32 (*(volatile float*)GX_WPAR_ADDRESS)
37#define GX_FIFO_MINIMUM_SIZE (64 * 1024)
38#define GX_FIFO_WATERMARK (16 * 1024)
46 GX_VTXATTR_DATA_DISABLED,
47 GX_VTXATTR_DATA_DIRECT,
48 GX_VTXATTR_DATA_INDEX8,
49 GX_VTXATTR_DATA_INDEX16
53 GX_VTXDESC_POSNORM_INDEX,
54 GX_VTXDESC_TEXCOORDMTX0,
55 GX_VTXDESC_TEXCOORDMTX1,
56 GX_VTXDESC_TEXCOORDMTX2,
57 GX_VTXDESC_TEXCOORDMTX3,
58 GX_VTXDESC_TEXCOORDMTX4,
59 GX_VTXDESC_TEXCOORDMTX5,
60 GX_VTXDESC_TEXCOORDMTX6,
61 GX_VTXDESC_TEXCOORDMTX7,
64 GX_VTXDESC_NORMAL_NBT,
78 GX_VTXATTR_POS_XY = 0,
79 GX_VTXATTR_POS_XYZ = 1,
84 GX_VTXATTR_NRM_XYZ = 0,
85 GX_VTXATTR_NRM_NBT = 1,
86 GX_VTXATTR_NRM_NBT3 = 3,
90} gx_vtxattr_component_t;
99 GX_VTXATTR_RGB565 = 0,
105} gx_vtxattr_component_format_t;
112 GX_TRIANGLE_FAN = 0xA0,
114 GX_TRIANGLE_STRIP = 0x98
121 GX_COMPARE_LESS_EQUAL,
123 GX_COMPARE_NOT_EQUAL,
124 GX_COMPARE_GREATER_EQUAL,
129 GX_PIXEL_FORMAT_RGB8_Z24,
130 GX_PIXEL_FORMAT_RGBA6_Z24,
131 GX_PIXEL_FORMAT_RGB565_Z16,
136 GX_PIXEL_FORMAT_YUV420
149 GX_CLAMP_MODE_BOTTOM,
150 GX_CLAMP_MODE_TOP_BOTTOM,
160 GX_LINE_MODE_PROGRESSIVE,
161 GX_LINE_MODE_EVEN = 2,
179#define GX_WPAR_OPCODE_LOAD_CP 0x08
180#define GX_WPAR_OPCODE_LOAD_XF 0x10
181#define GX_WPAR_OPCODE_LOAD_BP 0x61
182#define GX_WPAR_OPCODE_PRIMITIVE(type, format) (((uint8_t)type) | format)
184#define GX_XF_MEMORY_POSTEX_MTX_0 0x0000
185#define GX_XF_MEMORY_NORMAL_MTX_0 0x0400
186#define GX_XF_MEMORY_DUALTEX_MTX_0 0x0500
187#define GX_XF_MEMORY_LIGHT0 0x0600
188#define GX_XF_REGISTER_VERTEX_STATS 0x1008
189#define GX_XF_REGISTER_COLOR_COUNT 0x1009
190#define GX_XF_REGISTER_COLOR_CONTROL 0x100E
191#define GX_XF_REGISTER_DUALTEXTRANS 0x1012
192#define GX_XF_REGISTER_MTXIDX_A 0x1018
193#define GX_XF_REGISTER_MTXIDX_B 0x1019
194#define GX_XF_REGISTER_VIEWPORT 0x101A
195#define GX_XF_REGISTER_PROJECTION 0x1020
196#define GX_XF_REGISTER_TEXCOORD_COUNT 0x103F
197#define GX_XF_REGISTER_TEX0 0x1040
198#define GX_XF_REGISTER_DUALTEX0 0x1050
200#define GX_BP_REGISTERS_GENMODE (0x00 << 24)
201#define GX_BP_REGISTERS_COPY_FILTER_POS_A (0x01 << 24)
202#define GX_BP_REGISTERS_COPY_FILTER_POS_B (0x02 << 24)
203#define GX_BP_REGISTERS_COPY_FILTER_POS_C (0x03 << 24)
204#define GX_BP_REGISTERS_COPY_FILTER_POS_D (0x04 << 24)
205#define GX_BP_REGISTERS_SCISSOR_TL (0x20 << 24)
206#define GX_BP_REGISTERS_SCISSOR_BR (0x21 << 24)
207#define GX_BP_REGISTERS_SSIZE0 (0x30 << 24)
208#define GX_BP_REGISTERS_TSIZE0 (0x31 << 24)
209#define GX_BP_REGISTERS_Z_MODE (0x40 << 24)
210#define GX_BP_REGISTERS_CMODE_0 (0x41 << 24)
211#define GX_BP_REGISTERS_CMODE_1 (0x42 << 24)
212#define GX_BP_REGISTERS_PE_CONTROL (0X43 << 24)
213#define GX_BP_REGISTERS_PE_DONE (0x45 << 24)
214#define GX_BP_REGISTERS_EFB_SOURCE_TOP_LEFT (0x49 << 24)
215#define GX_BP_REGISTERS_EFB_SOURCE_WIDTH_HEIGHT (0x4A << 24)
216#define GX_BP_REGISTERS_XFB_TARGET_ADDRESS (0x4B << 24)
217#define GX_BP_REGISTERS_EFB_DESTINATION_WIDTH (0x4D << 24)
218#define GX_BP_REGISTERS_Y_SCALE (0x4E << 24)
219#define GX_BP_REGISTERS_PE_COPY_CLEAR_AR (0x4F << 24)
220#define GX_BP_REGISTERS_PE_COPY_CLEAR_GB (0x50 << 24)
221#define GX_BP_REGISTERS_PE_COPY_CLEAR_Z (0x51 << 24)
222#define GX_BP_REGISTERS_PE_COPY_EXECUTE (0x52 << 24)
223#define GX_BP_REGISTERS_COPY_FILTER_COEFF_A (0x53 << 24)
224#define GX_BP_REGISTERS_COPY_FILTER_COEFF_B (0x54 << 24)
225#define GX_BP_REGISTERS_SCISSOR_OFFSET (0x59 << 24)
226#define GX_BP_REGISTERS_TX_SETMODE0_I0 (0x80 << 24)
227#define GX_BP_REGISTERS_TX_SETMODE1_I0 (0x84 << 24)
228#define GX_BP_REGISTERS_TX_SETIMAGE0_I0 (0x88 << 24)
229#define GX_BP_REGISTERS_TX_SETIMAGE1_I0 (0x8C << 24)
230#define GX_BP_REGISTERS_TX_SETIMAGE2_I0 (0x90 << 24)
231#define GX_BP_REGISTERS_TX_SETIMAGE3_I0 (0x94 << 24)
232#define GX_BP_REGISTERS_TX_SETTLUT_0 (0x98 << 24)
233#define GX_BP_REGISTERS_TEV0_COLOR_ENV (0xC0 << 24)
234#define GX_BP_REGISTERS_TEV0_ALPHA_ENV (0xC1 << 24)
235#define GX_BP_REGISTERS_TEV_REGISTERL_0 (0xE0 << 24)
236#define GX_BP_REGISTERS_TEV_REGISTERH_0 (0xE1 << 24)
238#define GX_CP_REGISTERS_MTXIDX_A 0x30
239#define GX_CP_REGISTERS_MTXIDX_B 0x40
240#define GX_CP_REGISTER_VCD_LOW 0x50
241#define GX_CP_REGISTER_VCD_HIGH 0x60
242#define GX_CP_REGISTER_VAT_A 0x70
243#define GX_CP_REGISTER_VAT_B 0x80
244#define GX_CP_REGISTER_VAT_C 0x90
248#define GX_WPAR_CP_LOAD(address, value) \
249 GX_WPAR_U8 = GX_WPAR_OPCODE_LOAD_CP; \
250 GX_WPAR_U8 = address; \
255#define GX_WPAR_XF_LOAD(address, words) \
256 GX_WPAR_U8 = GX_WPAR_OPCODE_LOAD_XF; \
257 GX_WPAR_U16 = (words) - 1; \
258 GX_WPAR_U16 = address;
262#define GX_WPAR_BP_LOAD(value) \
263 GX_WPAR_U8 = GX_WPAR_OPCODE_LOAD_BP; \
276 uint32_t base_address;
277 uint32_t end_address;
278 uint32_t high_watermark;
279 uint32_t low_watermark;
301 GX_TEXTURE_FORMAT_I4,
302 GX_TEXTURE_FORMAT_I8,
303 GX_TEXTURE_FORMAT_IA4,
304 GX_TEXTURE_FORMAT_IA8,
305 GX_TEXTURE_FORMAT_RGB565,
306 GX_TEXTURE_FORMAT_RGB5A3,
307 GX_TEXTURE_FORMAT_RGBA8,
308 GX_TEXTURE_FORMAT_C4 = 8,
309 GX_TEXTURE_FORMAT_C8,
310 GX_TEXTURE_FORMAT_C14X2,
311 GX_TEXTURE_FORMAT_CMP = 14
312} gx_texture_format_t;
322 GX_TEXTURE_MIN_FILTER_NEAR,
323 GX_TEXTURE_MIN_FILTER_NEAR_MIP,
324 GX_TEXTURE_MIN_FILTER_NEAR_MIP_LINEAR,
325 GX_TEXTURE_MIN_FILTER_LINEAR = 4,
326 GX_TEXTURE_MIN_FILTER_LINEAR_MIP_NEAR,
327 GX_TEXTURE_MIN_FILTER_LINEAR_MIP_LINEAR,
328} gx_texture_min_filter;
419extern uint32_t
gx_efb_peak(uint32_t x, uint32_t y);
460extern void gx_vtxdesc_set(gx_vtxdesc_t desc, gx_vtxattr_data_t type);
489extern void gx_vtxfmtattr_set(uint8_t attribute_index, gx_vtxdesc_t attribute, gx_vtxattr_component_t component, gx_vtxattr_component_format_t fmt, uint8_t fraction);
501extern void gx_begin(gx_primitive_t primitive, uint8_t attribute, uint16_t count);
608extern void gx_set_copy_window(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t xfb_width);
672extern void gx_set_z_mode(
bool enable_compare, gx_compare_t compare,
bool enable_update);
739 gx_texture_wrap_t s_wrap, gx_texture_wrap_t t_wrap,
bool mipmap);
Functions for managing and rendering framebuffers.
void gx_flush()
Flushes all commands to the command processor.
Definition gx.c:736
void gx_vtxfmtattr_set(uint8_t attribute_index, gx_vtxdesc_t attribute, gx_vtxattr_component_t component, gx_vtxattr_component_format_t fmt, uint8_t fraction)
Sets the format of a vertex attribute.
Definition gx.c:859
void gx_set_copy_window(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t xfb_width)
Sets the window to of the EFB into the XFB.
Definition gx.c:991
void gx_set_render_thread(TaskHandle_t task)
Sets the current render thread for suspension.
Definition gx.c:950
void gx_fifo_set(const gx_fifo_t *fifo)
Sets the current FIFO.
Definition gx.c:699
uint32_t gx_efb_peak(uint32_t x, uint32_t y)
Grabs a pixel from the embedded frame buffer.
Definition gx.c:749
void gx_begin(gx_primitive_t primitive, uint8_t attribute, uint16_t count)
Begin drawing primatives.
Definition gx.c:929
void gx_copy_framebuffer(framebuffer_t *framebuffer, bool clear)
Copys the internal framebuffer to the external frame buffer.
Definition gx.c:1101
void gx_set_scissor_rectangle(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
Sets the scissor rectangle.
Definition gx.c:975
void gx_set_gamma(gx_gamma_t gamma)
Sets the gamma value when copying from EFB to XFB.
Definition gx.c:1001
void gx_initialize_state()
Initializes the graphics state.
Definition gx.c:565
void gx_set_pixel_format(gx_pixel_format_t pixels_format, gx_z_format_t z_format)
Sets the format of pixels in the EFB.
Definition gx.c:1075
void gx_set_z_mode(bool enable_compare, gx_compare_t compare, bool enable_update)
Determins how Z values will be treated.
Definition gx.c:1048
void gx_set_clear_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Sets the background color when copying framebuffers.
Definition gx.c:954
void gx_set_scissor_offset(int32_t x, int32_t y)
Offsets the scissor rectangle.
Definition gx.c:985
void gx_set_line_mode(gx_line_mode_t line_mode)
Sets the what lines are copied from EFB to XFB.
Definition gx.c:1005
void gx_set_clear_z(uint32_t z)
Sets the z value the frame buffer is cleared with.
Definition gx.c:959
void gx_flash_texture(gx_texture_map_t map, const gx_texture_t *texture)
Flashes a texture configuration onto the BP.
Definition gx.c:1175
void gx_enable_z_precheck(bool enable)
Enables / Disables checking Z before or after texturing.
Definition gx.c:1068
void gx_initialize_video(const video_profile_t *video_profile)
Initializes all the video settings from a video profile.
Definition gx.c:674
void gx_fifo_initialize(gx_fifo_t *fifo, void *fifo_buffer, uint32_t fifo_buffer_size)
Creates the fifo data structure.
Definition gx.c:682
void gx_vtxfmtattr_clear(uint8_t attribute_index)
Clears out a vertex attribute format.
Definition gx.c:852
void gx_vtxdesc_clear()
Clears out all vertex descriptions.
Definition gx.c:759
void gx_set_copy_filter(const uint8_t pattern[12][2], const uint8_t filter[7])
Sets the interpolation filters used when copying the frame buffer into external frame buffers of diff...
Definition gx.c:1009
void gx_set_copy_y_scale(float y_scale)
Sets the scale of the EFB to the XFB's Y.
Definition gx.c:963
void gx_initialize(const gx_fifo_t *fifo, const video_profile_t *video_profile)
Initializes the graphics.
Definition gx.c:518
void gx_draw_done()
Call to send end current drawing session. Then wait.
Definition gx.c:939
void gx_vtxdesc_set(gx_vtxdesc_t desc, gx_vtxattr_data_t type)
Sets a vertex description.
Definition gx.c:766
void gx_fifo_get(gx_fifo_t *fifo)
Gets the current FIFO.
Definition gx.c:724
void gx_set_clamp_mode(gx_clamp_mode_t mode)
Set the clamp mode when copying from EFB to XFB.
Definition gx.c:997
void gx_initialize_texture(gx_texture_t *texture, const void *data, gx_texture_format_t format, int width, int height, gx_texture_wrap_t s_wrap, gx_texture_wrap_t t_wrap, bool mipmap)
Initializes a texture object for use.
Definition gx.c:1146
void gx_set_color_update(bool update_color, bool update_alpha)
Enables updating the color when rendering into the EFB.
Definition gx.c:1056
XF definitions and function of GX.
Data format for framebuffers.
Definition framebuffer.h:28
Represents the a fifo for the Command Processor.
Definition gx.h:275
Cool little texture object. Really just a copy of the registers that will be set onto the GPU when th...
Definition gx.h:289
Manages the video output of the system.