My Project
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
gx.c
Go to the documentation of this file.
1 /*
2  gx.c _ Sending GPU requests via GSP shared memory.
3 */
4 
5 #include <stdlib.h>
6 #include <3ds.h>
7 
9 
10 Result GX_RequestDma(u32* gxbuf, u32* src, u32* dst, u32 length)
11 {
12  if(!gxbuf)gxbuf=gxCmdBuf;
13 
14  u32 gxCommand[0x8];
15  gxCommand[0]=0x00; //CommandID
16  gxCommand[1]=(u32)src; //source address
17  gxCommand[2]=(u32)dst; //destination address
18  gxCommand[3]=length; //size
19  gxCommand[4]=gxCommand[5]=gxCommand[6]=gxCommand[7]=0x0;
20 
21  return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
22 }
23 
24 Result GX_SetCommandList_Last(u32* gxbuf, u32* buf0a, u32 buf0s, u8 flags)
25 {
26  if(!gxbuf)gxbuf=gxCmdBuf;
27 
28  u32 gxCommand[0x8];
29  gxCommand[0]=0x01; //CommandID
30  gxCommand[1]=(u32)buf0a; //buf0 address
31  gxCommand[2]=(u32)buf0s; //buf0 size
32  gxCommand[3]=flags&1; //written to GSP module state
33  gxCommand[4]=gxCommand[5]=gxCommand[6]=0x0;
34  gxCommand[7]=(flags>>1)&1; //when non-zero, call svcFlushProcessDataCache() with the specified buffer
35 
36  return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
37 }
38 
39 Result GX_SetMemoryFill(u32* gxbuf, u32* buf0a, u32 buf0v, u32* buf0e, u16 width0, u32* buf1a, u32 buf1v, u32* buf1e, u16 width1)
40 {
41  if(!gxbuf)gxbuf=gxCmdBuf;
42 
43  u32 gxCommand[0x8];
44  // gxCommand[0]=0x02; //CommandID
45  gxCommand[0]=0x01000102; //CommandID
46  gxCommand[1]=(u32)buf0a; //buf0 address
47  gxCommand[2]=buf0v; //buf0 value
48  gxCommand[3]=(u32)buf0e; //buf0 end addr
49  gxCommand[4]=(u32)buf1a; //buf1 address
50  gxCommand[5]=buf1v; //buf1 value
51  gxCommand[6]=(u32)buf1e; //buf1 end addr
52  gxCommand[7]=(width0)|(width1<<16);
53 
54  return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
55 }
56 
57 // Flags, for applications this is 0x1001000 for the main screen, and 0x1000 for the sub screen.
58 Result GX_SetDisplayTransfer(u32* gxbuf, u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 flags)
59 {
60  if(!gxbuf)gxbuf=gxCmdBuf;
61 
62  u32 gxCommand[0x8];
63  gxCommand[0]=0x03; //CommandID
64  gxCommand[1]=(u32)inadr;
65  gxCommand[2]=(u32)outadr;
66  gxCommand[3]=indim;
67  gxCommand[4]=outdim;
68  gxCommand[5]=flags;
69  gxCommand[6]=gxCommand[7]=0x0;
70 
71  return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
72 }
73 
74 Result GX_SetTextureCopy(u32* gxbuf, u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags)
75 {
76  if(!gxbuf)gxbuf=gxCmdBuf;
77 
78  u32 gxCommand[0x8];
79  gxCommand[0]=0x04; //CommandID
80  gxCommand[1]=(u32)inadr;
81  gxCommand[2]=(u32)outadr;
82  gxCommand[3]=size;
83  gxCommand[4]=indim;
84  gxCommand[5]=outdim;
85  gxCommand[6]=flags;
86  gxCommand[7]=0x0;
87 
88  return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
89 }
90 
91 Result GX_SetCommandList_First(u32* gxbuf, u32* buf0a, u32 buf0s, u32* buf1a, u32 buf1s, u32* buf2a, u32 buf2s)
92 {
93  if(!gxbuf)gxbuf=gxCmdBuf;
94 
95  u32 gxCommand[0x8];
96  gxCommand[0]=0x05; //CommandID
97  gxCommand[1]=(u32)buf0a; //buf0 address
98  gxCommand[2]=(u32)buf0s; //buf0 size
99  gxCommand[3]=(u32)buf1a; //buf1 address
100  gxCommand[4]=(u32)buf1s; //buf1 size
101  gxCommand[5]=(u32)buf2a; //buf2 address
102  gxCommand[6]=(u32)buf2s; //buf2 size
103  gxCommand[7]=0x0;
104 
105  return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
106 }
Result GX_SetCommandList_Last(u32 *gxbuf, u32 *buf0a, u32 buf0s, u8 flags)
Definition: gx.c:24
s32 Result
Definition: types.h:42
uint16_t u16
Definition: types.h:22
Result GX_SetMemoryFill(u32 *gxbuf, u32 *buf0a, u32 buf0v, u32 *buf0e, u16 width0, u32 *buf1a, u32 buf1v, u32 *buf1e, u16 width1)
Definition: gx.c:39
uint8_t u8
Definition: types.h:21
Result GX_SetCommandList_First(u32 *gxbuf, u32 *buf0a, u32 buf0s, u32 *buf1a, u32 buf1s, u32 *buf2a, u32 buf2s)
Definition: gx.c:91
uint32_t u32
Definition: types.h:23
Result GX_RequestDma(u32 *gxbuf, u32 *src, u32 *dst, u32 length)
Definition: gx.c:10
Result GX_SetTextureCopy(u32 *gxbuf, u32 *inadr, u32 indim, u32 *outadr, u32 outdim, u32 size, u32 flags)
Definition: gx.c:74
Result GSPGPU_SubmitGxCommand(u32 *sharedGspCmdBuf, u32 gxCommand[0x8], Handle *handle)
Definition: gsp.c:356
u32 * gxCmdBuf
Definition: gx.c:8
Result GX_SetDisplayTransfer(u32 *gxbuf, u32 *inadr, u32 indim, u32 *outadr, u32 outdim, u32 flags)
Definition: gx.c:58