libdragon
Loading...
Searching...
No Matches
rdp.h
Go to the documentation of this file.
1
8#ifndef __LIBDRAGON_RDP_H
9#define __LIBDRAGON_RDP_H
10
11#include "display.h"
12#include "rdpq.h"
13#include "rdpq_attach.h"
14#include <stdbool.h>
15
17typedef struct sprite_s sprite_t;
19
26#define DP_START ((volatile uint32_t*)0xA4100000)
27
29#define DP_END ((volatile uint32_t*)0xA4100004)
30
32#define DP_CURRENT ((volatile uint32_t*)0xA4100008)
33
35#define DP_STATUS ((volatile uint32_t*)0xA410000C)
36
38#define DP_CLOCK ((volatile uint32_t*)0xA4100010)
39
41#define DP_BUSY ((volatile uint32_t*)0xA4100014)
42
44#define DP_PIPE_BUSY ((volatile uint32_t*)0xA4100018)
45
47#define DP_TMEM_BUSY ((volatile uint32_t*)0xA410001C)
48
50#define DP_STATUS_DMEM_DMA (1 << 0)
52#define DP_STATUS_FREEZE (1 << 1)
54#define DP_STATUS_FLUSH (1 << 2)
56#define DP_STATUS_GCLK_ALIVE (1 << 3)
58#define DP_STATUS_TMEM_BUSY (1 << 4)
60#define DP_STATUS_PIPE_BUSY (1 << 5)
62#define DP_STATUS_BUSY (1 << 6)
64#define DP_STATUS_BUFFER_READY (1 << 7)
66#define DP_STATUS_DMA_BUSY (1 << 8)
68#define DP_STATUS_END_VALID (1 << 9)
70#define DP_STATUS_START_VALID (1 << 10)
71
72#define DP_WSTATUS_RESET_XBUS_DMEM_DMA (1<<0)
73#define DP_WSTATUS_SET_XBUS_DMEM_DMA (1<<1)
74#define DP_WSTATUS_RESET_FREEZE (1<<2)
75#define DP_WSTATUS_SET_FREEZE (1<<3)
76#define DP_WSTATUS_RESET_FLUSH (1<<4)
77#define DP_WSTATUS_SET_FLUSH (1<<5)
78#define DP_WSTATUS_RESET_TMEM_COUNTER (1<<6)
79#define DP_WSTATUS_RESET_PIPE_COUNTER (1<<7)
80#define DP_WSTATUS_RESET_CMD_COUNTER (1<<8)
81#define DP_WSTATUS_RESET_CLOCK_COUNTER (1<<9)
82
97
108
111#ifdef __cplusplus
112extern "C" {
113#endif
114
121
136uint32_t rdp_load_texture( uint32_t texslot, uint32_t texloc, mirror_t mirror, sprite_t *sprite );
137
167uint32_t rdp_load_texture_stride( uint32_t texslot, uint32_t texloc, mirror_t mirror, sprite_t *sprite, int offset );
168
192void rdp_draw_textured_rectangle( uint32_t texslot, int tx, int ty, int bx, int by, mirror_t mirror );
193
222void 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 );
223
241void rdp_draw_sprite( uint32_t texslot, int x, int y , mirror_t mirror);
242
264void rdp_draw_sprite_scaled( uint32_t texslot, int x, int y, double x_scale, double y_scale, mirror_t mirror);
265
274void rdp_set_blend_color( uint32_t color );
275
298void rdp_draw_filled_triangle( float x1, float y1, float x2, float y2, float x3, float y3 );
299
314void rdp_set_texture_flush( flush_t flush );
315
316
317/**************************************************************************************************
318 * Deprecated functions
319 *
320 * This is the old rdp.c API which has been replaced by the new API in rdpq.h.
321 *
322 * The API is still working correctly. The implementation is based on rspq so that it can be mix
323 * and matched with existing rdpq constructs. It will emit deprecation warnings when used, trying
324 * to suggest possible replacements.
325 **************************************************************************************************/
326
328
329typedef enum
330{
331 SYNC_FULL,
332 SYNC_PIPE,
333 SYNC_LOAD,
334 SYNC_TILE
335} sync_t;
336
337__attribute__((deprecated("use rdpq_init instead")))
338void rdp_init( void );
339
340__attribute__((deprecated("use rdpq_close instead")))
341void rdp_close( void );
342
343__attribute__((deprecated("use rdpq_attach instead")))
344static inline void rdp_attach( surface_t *surface )
345{
346 rdpq_attach(surface, NULL);
347}
348
349__attribute__((deprecated("use rdpq_detach_cb instead")))
350static inline void rdp_detach_async( void (*cb)(void*), void *arg )
351{
352 rdpq_detach_cb(cb, arg);
353}
354
355__attribute__((deprecated("use rdpq_detach_wait instead")))
356void rdp_detach( void );
357
358__attribute__((deprecated("use rdpq_is_attached instead")))
359static inline bool rdp_is_attached( void )
360{
361 return rdpq_is_attached();
362}
363
364__attribute__((deprecated("use rdpq_detach_show instead")))
365static inline void rdp_detach_show( surface_t *disp )
366{
367 rdpq_detach_cb((void(*)(void*))display_show, (disp));
368}
369
370__attribute__((deprecated("use rdpq_attach instead")))
371static inline void rdp_attach_display( display_context_t disp )
372{
373 rdpq_attach(disp, NULL);
374}
375
376__attribute__((deprecated("use rdqp_detach_wait instead")))
377static inline void rdp_detach_display( void )
378{
379 rdpq_detach();
380}
381
382__attribute__((deprecated("use rdpq_set_scissor instead")))
383void rdp_set_clipping( uint32_t tx, uint32_t ty, uint32_t bx, uint32_t by );
384
385__attribute__((deprecated("default clipping is activated automatically during rdp_attach_display")))
386void rdp_set_default_clipping( void );
387
388__attribute__((deprecated("syncs are now performed automatically -- or use rdpq_sync_* functions otherwise")))
389void rdp_sync( sync_t sync );
390
391__attribute__((deprecated("use rdpq_fill_rectangle instead")))
392void rdp_draw_filled_rectangle( int tx, int ty, int bx, int by );
393
394__attribute__((deprecated("use rdpq_set_fill_color instead")))
395static inline void rdp_set_primitive_color(uint32_t color) {
396 extern void __rdpq_write8_syncchange(uint32_t cmd_id, uint32_t arg0, uint32_t arg1, uint32_t autosync);
397 __rdpq_write8_syncchange(RDPQ_CMD_SET_FILL_COLOR, 0, color, AUTOSYNC_PIPE);
398}
399
400__attribute__((deprecated("use rdpq_set_mode_fill instead")))
401void rdp_enable_primitive_fill( void );
402
403__attribute__((deprecated("use rdpq_set_mode_copy instead")))
404void rdp_enable_texture_copy( void );
405
407
408
409#ifdef __cplusplus
410}
411#endif
412
413#endif
Display Subsystem.
void display_show(surface_t *surf)
Display a buffer on the screen.
Definition display.c:342
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:230
void rdp_set_texture_flush(flush_t flush)
Set the flush strategy for texture loads.
Definition rdp.c:290
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:199
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:267
mirror_t
Mirror settings for textures.
Definition rdp.h:87
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:255
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:261
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:210
void rdp_draw_filled_triangle(float x1, float y1, float x2, float y2, float x3, float y3)
Draw a filled triangle.
Definition rdp.c:282
flush_t
Caching strategy for loaded textures.
Definition rdp.h:102
void rdp_set_blend_color(uint32_t color)
Set the blend draw color for subsequent filled primitive operations.
Definition rdp.c:277
@ MIRROR_X
Enable texture mirroring on x axis.
Definition rdp.h:91
@ MIRROR_Y
Enable texture mirroring on y axis.
Definition rdp.h:93
@ MIRROR_XY
Enable texture mirroring on both x & y axis.
Definition rdp.h:95
@ MIRROR_DISABLED
Disable texture mirroring.
Definition rdp.h:89
@ FLUSH_STRATEGY_AUTOMATIC
Cache will be flushed on all incoming textures.
Definition rdp.h:106
@ FLUSH_STRATEGY_NONE
Textures are assumed to be pre-flushed.
Definition rdp.h:104
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:838
void rdpq_close()
Shutdown the RDPQ library.
Definition rdpq.c:488
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:912
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:124
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:77
void rdpq_detach(void)
Detach the RDP from the current surface, and restore the previous one.
Definition rdpq_attach.h:138
bool rdpq_is_attached(void)
Check if the RDP is currently attached to a surface.
Definition rdpq_attach.c:23
RDP Command queue: surface attachment API.
void rdpq_set_mode_copy(bool transparency)
Reset render mode to COPY type.
Definition rdpq_mode.c:88
#define rdpq_fill_rectangle(x0, y0, x1, y1)
Draw a filled rectangle (RDP command: FILL_RECTANGLE)
Definition rdpq_rect.h:250
Sprite structure.
Definition sprite.h:42
A surface buffer for graphics.
Definition surface.h:140