libdragon
Loading...
Searching...
No Matches
rdp.h
Go to the documentation of this file.
1
6#ifndef __LIBDRAGON_RDP_H
7#define __LIBDRAGON_RDP_H
8
9#include "display.h"
10#include "rdpq.h"
11#include "rdpq_attach.h"
12#include <stdbool.h>
13
15typedef struct sprite_s sprite_t;
17
24#define DP_START ((volatile uint32_t*)0xA4100000)
25
27#define DP_END ((volatile uint32_t*)0xA4100004)
28
30#define DP_CURRENT ((volatile uint32_t*)0xA4100008)
31
33#define DP_STATUS ((volatile uint32_t*)0xA410000C)
34
36#define DP_CLOCK ((volatile uint32_t*)0xA4100010)
37
39#define DP_BUSY ((volatile uint32_t*)0xA4100014)
40
42#define DP_PIPE_BUSY ((volatile uint32_t*)0xA4100018)
43
45#define DP_TMEM_BUSY ((volatile uint32_t*)0xA410001C)
46
48#define DP_STATUS_DMEM_DMA (1 << 0)
50#define DP_STATUS_FREEZE (1 << 1)
52#define DP_STATUS_FLUSH (1 << 2)
54#define DP_STATUS_GCLK_ALIVE (1 << 3)
56#define DP_STATUS_TMEM_BUSY (1 << 4)
58#define DP_STATUS_PIPE_BUSY (1 << 5)
60#define DP_STATUS_BUSY (1 << 6)
62#define DP_STATUS_BUFFER_READY (1 << 7)
64#define DP_STATUS_DMA_BUSY (1 << 8)
66#define DP_STATUS_END_VALID (1 << 9)
68#define DP_STATUS_START_VALID (1 << 10)
69
70#define DP_WSTATUS_RESET_XBUS_DMEM_DMA (1<<0)
71#define DP_WSTATUS_SET_XBUS_DMEM_DMA (1<<1)
72#define DP_WSTATUS_RESET_FREEZE (1<<2)
73#define DP_WSTATUS_SET_FREEZE (1<<3)
74#define DP_WSTATUS_RESET_FLUSH (1<<4)
75#define DP_WSTATUS_SET_FLUSH (1<<5)
76#define DP_WSTATUS_RESET_TMEM_COUNTER (1<<6)
77#define DP_WSTATUS_RESET_PIPE_COUNTER (1<<7)
78#define DP_WSTATUS_RESET_CMD_COUNTER (1<<8)
79#define DP_WSTATUS_RESET_CLOCK_COUNTER (1<<9)
80
95
106
109#ifdef __cplusplus
110extern "C" {
111#endif
112
119
134uint32_t rdp_load_texture( uint32_t texslot, uint32_t texloc, mirror_t mirror, sprite_t *sprite );
135
165uint32_t rdp_load_texture_stride( uint32_t texslot, uint32_t texloc, mirror_t mirror, sprite_t *sprite, int offset );
166
190void rdp_draw_textured_rectangle( uint32_t texslot, int tx, int ty, int bx, int by, mirror_t mirror );
191
220void rdp_draw_textured_rectangle_scaled( uint32_t texslot, int tx, int ty, int bx, int by, double x_scale, double y_scale, mirror_t mirror );
221
239void rdp_draw_sprite( uint32_t texslot, int x, int y , mirror_t mirror);
240
262void rdp_draw_sprite_scaled( uint32_t texslot, int x, int y, double x_scale, double y_scale, mirror_t mirror);
263
272void rdp_set_blend_color( uint32_t color );
273
296void rdp_draw_filled_triangle( float x1, float y1, float x2, float y2, float x3, float y3 );
297
312void rdp_set_texture_flush( flush_t flush );
313
314
315/**************************************************************************************************
316 * Deprecated functions
317 *
318 * This is the old rdp.c API which has been replaced by the new API in rdpq.h.
319 *
320 * The API is still working correctly. The implementation is based on rspq so that it can be mix
321 * and matched with existing rdpq constructs. It will emit deprecation warnings when used, trying
322 * to suggest possible replacements.
323 **************************************************************************************************/
324
326
327typedef enum
328{
329 SYNC_FULL,
330 SYNC_PIPE,
331 SYNC_LOAD,
332 SYNC_TILE
333} sync_t;
334
335__attribute__((deprecated("use rdpq_init instead")))
336void rdp_init( void );
337
338__attribute__((deprecated("use rdpq_close instead")))
339void rdp_close( void );
340
341__attribute__((deprecated("use rdpq_attach instead")))
342static inline void rdp_attach( surface_t *surface )
343{
344 rdpq_attach(surface, NULL);
345}
346
347__attribute__((deprecated("use rdpq_detach_cb instead")))
348static inline void rdp_detach_async( void (*cb)(void*), void *arg )
349{
350 rdpq_detach_cb(cb, arg);
351}
352
353__attribute__((deprecated("use rdpq_detach_wait instead")))
354void rdp_detach( void );
355
356__attribute__((deprecated("use rdpq_is_attached instead")))
357static inline bool rdp_is_attached( void )
358{
359 return rdpq_is_attached();
360}
361
362__attribute__((deprecated("use rdpq_detach_show instead")))
363static inline void rdp_detach_show( surface_t *disp )
364{
365 rdpq_detach_cb((void(*)(void*))display_show, (disp));
366}
367
368__attribute__((deprecated("use rdpq_attach instead")))
369static inline void rdp_attach_display( display_context_t disp )
370{
371 rdpq_attach(disp, NULL);
372}
373
374__attribute__((deprecated("use rdqp_detach_wait instead")))
375static inline void rdp_detach_display( void )
376{
377 rdpq_detach();
378}
379
380__attribute__((deprecated("use rdpq_set_scissor instead")))
381void rdp_set_clipping( uint32_t tx, uint32_t ty, uint32_t bx, uint32_t by );
382
383__attribute__((deprecated("default clipping is activated automatically during rdp_attach_display")))
384void rdp_set_default_clipping( void );
385
386__attribute__((deprecated("syncs are now performed automatically -- or use rdpq_sync_* functions otherwise")))
387void rdp_sync( sync_t sync );
388
389__attribute__((deprecated("use rdpq_fill_rectangle instead")))
390void rdp_draw_filled_rectangle( int tx, int ty, int bx, int by );
391
392__attribute__((deprecated("use rdpq_set_fill_color instead")))
393static inline void rdp_set_primitive_color(uint32_t color) {
394 extern void __rdpq_write8_syncchange(uint32_t cmd_id, uint32_t arg0, uint32_t arg1, uint32_t autosync);
395 __rdpq_write8_syncchange(RDPQ_CMD_SET_FILL_COLOR, 0, color, AUTOSYNC_PIPE);
396}
397
398__attribute__((deprecated("use rdpq_set_mode_fill instead")))
399void rdp_enable_primitive_fill( void );
400
401__attribute__((deprecated("use rdpq_set_mode_copy instead")))
402void rdp_enable_texture_copy( void );
403
405
406
407#ifdef __cplusplus
408}
409#endif
410
411#endif
Display Subsystem.
void display_show(surface_t *surf)
Display a buffer on the screen.
Definition display.c:340
void rdp_draw_textured_rectangle_scaled(uint32_t texslot, int tx, int ty, int bx, int by, double x_scale, double y_scale, mirror_t mirror)
Draw a textured rectangle with a scaled texture.
Definition rdp.c:228
void rdp_set_texture_flush(flush_t flush)
Set the flush strategy for texture loads.
Definition rdp.c:288
uint32_t rdp_load_texture(uint32_t texslot, uint32_t texloc, mirror_t mirror, sprite_t *sprite)
Load a sprite into RDP TMEM.
Definition rdp.c:197
void rdp_draw_sprite_scaled(uint32_t texslot, int x, int y, double x_scale, double y_scale, mirror_t mirror)
Draw a texture to the screen as a scaled sprite.
Definition rdp.c:265
mirror_t
Mirror settings for textures.
Definition rdp.h:85
void rdp_draw_textured_rectangle(uint32_t texslot, int tx, int ty, int bx, int by, mirror_t mirror)
Draw a textured rectangle.
Definition rdp.c:253
void rdp_draw_sprite(uint32_t texslot, int x, int y, mirror_t mirror)
Draw a texture to the screen as a sprite.
Definition rdp.c:259
uint32_t rdp_load_texture_stride(uint32_t texslot, uint32_t texloc, mirror_t mirror, sprite_t *sprite, int offset)
Load part of a sprite into RDP TMEM.
Definition rdp.c:208
void rdp_draw_filled_triangle(float x1, float y1, float x2, float y2, float x3, float y3)
Draw a filled triangle.
Definition rdp.c:280
flush_t
Caching strategy for loaded textures.
Definition rdp.h:100
void rdp_set_blend_color(uint32_t color)
Set the blend draw color for subsequent filled primitive operations.
Definition rdp.c:275
@ MIRROR_X
Enable texture mirroring on x axis.
Definition rdp.h:89
@ MIRROR_Y
Enable texture mirroring on y axis.
Definition rdp.h:91
@ MIRROR_XY
Enable texture mirroring on both x & y axis.
Definition rdp.h:93
@ MIRROR_DISABLED
Disable texture mirroring.
Definition rdp.h:87
@ FLUSH_STRATEGY_AUTOMATIC
Cache will be flushed on all incoming textures.
Definition rdp.h:104
@ FLUSH_STRATEGY_NONE
Textures are assumed to be pre-flushed.
Definition rdp.h:102
void rdp_enable_blend_fill(void)
Enable display of 2D filled (untextured) triangles, with possible alpha blending.
void rdpq_set_fill_color(color_t color)
Enqueue a SET_FILL_COLOR RDP command.
Definition rdpq.h:837
void rdpq_close()
Shutdown the RDPQ library.
Definition rdpq.c:487
void __rdpq_write8_syncchange(uint32_t cmd_id, uint32_t arg0, uint32_t arg1, uint32_t autosync)
Write a standard 8-byte RDP command, which changes some autosync resources
Definition rdpq.c:911
RDP Command queue.
void rdpq_detach_cb(void(*cb)(void *), void *arg)
Detach the RDP from the current surface, and call a callback when the RDP has finished drawing to it.
Definition rdpq_attach.c:123
void rdpq_attach(const surface_t *surf_color, const surface_t *surf_z)
Attach the RDP to a color surface (and optionally a Z buffer)
Definition rdpq_attach.c:76
void rdpq_detach(void)
Detach the RDP from the current surface, and restore the previous one.
Definition rdpq_attach.h:137
bool rdpq_is_attached(void)
Check if the RDP is currently attached to a surface.
Definition rdpq_attach.c:22
RDP Command queue: surface attachment API.
void rdpq_set_mode_copy(bool transparency)
Reset render mode to COPY type.
Definition rdpq_mode.c:84
#define rdpq_fill_rectangle(x0, y0, x1, y1)
Draw a filled rectangle (RDP command: FILL_RECTANGLE)
Definition rdpq_rect.h:249
Sprite structure.
Definition sprite.h:40
A surface buffer for graphics.
Definition surface.h:138