RetroArch
psp1_gfx.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (C) 2014-2017 - Ali Bouhlel
3  * Copyright (C) 2011-2017 - Daniel De Matteis
4  *
5  * RetroArch is free software: you can redistribute it and/or modify it under the terms
6  * of the GNU General Public License as published by the Free Software Found-
7  * ation, either version 3 of the License, or (at your option) any later version.
8  *
9  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  * PURPOSE. See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along with RetroArch.
14  * If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef __PSP1_VIDEO_INL_H
18 #define __PSP1_VIDEO_INL_H
19 
20 #include <pspge.h>
21 #include "pspgu.h"
22 
23 typedef void (*GuCallback)(int);
24 
25 typedef struct
26 {
29  short signal_history[16];
33 
34  GuSwapBuffersCallback swapBuffersCallback;
36 } GuSettings;
37 
38 typedef struct
39 {
40  unsigned int* start;
41  unsigned int* current;
44 
45 typedef struct
46 {
49  int scissor_start[2];
50  int scissor_end[2];
52  int far_plane;
58  int sprite_mode[4];
59  unsigned int clear_color;
60  unsigned int clear_stencil;
61  unsigned int clear_depth;
63 } GuContext;
64 
65 typedef struct
66 {
69  void* frame_buffer;
70  void* disp_buffer;
71  void* depth_buffer;
73  int width;
74  int height;
75 } GuDrawBuffer;
76 
77 typedef struct
78 {
79  /* row 0 */
80 
81  unsigned char enable; /* Light enable */
82  unsigned char type; /* Light type */
83  unsigned char xpos; /* X position */
84  unsigned char ypos; /* Y position */
85 
86  /* row 1 */
87 
88  unsigned char zpos; // Z position
89  unsigned char xdir; // X direction
90  unsigned char ydir; // Y direction
91  unsigned char zdir; // Z direction
92 
93  /* row 2 */
94 
95  unsigned char ambient; // Ambient color
96  unsigned char diffuse; // Diffuse color
97  unsigned char specular; // Specular color
98  unsigned char constant; // Constant attenuation
99 
100  /* row 3 */
101 
102  unsigned char linear; // Linear attenuation
103  unsigned char quadratic;// Quadratic attenuation
104  unsigned char exponent; // Light exponent
105  unsigned char cutoff; // Light cutoff
107 
108 extern unsigned int gu_current_frame;
109 extern GuContext gu_contexts[3];
110 extern int ge_list_executed[2];
111 extern void* ge_edram_address;
112 extern GuSettings gu_settings;
113 extern GuDisplayList* gu_list;
114 extern int gu_curr_context;
115 extern int gu_init;
116 extern int gu_display_on;
117 extern int gu_call_mode;
118 extern int gu_states;
120 
121 extern unsigned int* gu_object_stack[];
122 extern int gu_object_stack_depth;
123 
125 
126 static int tbpcmd_tbl[8] = { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7 }; /* 0x30A18 */
127 static int tbwcmd_tbl[8] = { 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf }; /* 0x30A38 */
128 static int tsizecmd_tbl[8] = { 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf }; /* 0x30A58 */
129 
130 #define sendCommandi(cmd, argument) *(gu_list->current++) = (cmd << 24) | (argument & 0xffffff)
131 
132 #define sendCommandiStall(cmd, argument) \
133 { \
134  sendCommandi(cmd,argument); \
135  if (!gu_object_stack_depth && !gu_curr_context) \
136  sceGeListUpdateStallAddr(ge_list_executed[0],gu_list->current); \
137 }
138 
139 #define __sceGuCopyImage(psm, sx, sy, width, height, srcw, src, dx, dy, destw, dest) \
140  sendCommandi(178,((unsigned int)(src)) & 0xffffff); \
141  sendCommandi(179,((((unsigned int)(src)) & 0xff000000) >> 8)|(srcw)); \
142  sendCommandi(235,((sy) << 10)|(sx)); \
143  sendCommandi(180,((unsigned int)(dest)) & 0xffffff); \
144  sendCommandi(181,((((unsigned int)(dest)) & 0xff000000) >> 8)| (destw)); \
145  sendCommandi(236,((dy) << 10) | (dx)); \
146  sendCommandi(238,(((height)-1) << 10)|((width)-1)); \
147  sendCommandi(234,((psm) ^ 0x03) ? 0 : 1)
148 
149 #define __sceGuSync(mode, what) \
150  switch (mode) \
151  { \
152  case 0: return sceGeDrawSync(what); \
153  case 3: return sceGeListSync(ge_list_executed[0],what); \
154  case 4: return sceGeListSync(ge_list_executed[1],what); \
155  default: case 1: case 2: return 0; \
156  }
157 
158 #define __sceGuTexFlush() sendCommandf(203,0.0f)
159 
160 #define __sceGuTexImage(mipmap, width, height, tbw, tbp) \
161  sendCommandi(tbpcmd_tbl[(mipmap)],((unsigned int)(tbp)) & 0xffffff); \
162  sendCommandi(tbwcmd_tbl[(mipmap)],((((unsigned int)(tbp)) >> 8) & 0x0f0000)|(tbw)); \
163  sendCommandi(tsizecmd_tbl[(mipmap)],(getExp(height) << 8)|(getExp((width)))); \
164  __sceGuTexFlush()
165 
166 #define __sceGuCallList(list) \
167 { \
168  unsigned int list_addr = (unsigned int)list; \
169  if (gu_call_mode == 1) \
170  { \
171  sendCommandi(14,(list_addr >> 16) | 0x110000); \
172  sendCommandi(12,list_addr & 0xffff); \
173  sendCommandiStall(0,0); \
174  } \
175  else \
176  { \
177  sendCommandi(16,(list_addr >> 8) & 0xf0000); \
178  sendCommandiStall(10,list_addr & 0xffffff); \
179  } \
180 }
181 
182 #define __sceGuFinish_GU_DIRECT() \
183  sendCommandi(15,0); \
184  sendCommandiStall(12,0); \
185  /* go to parent list */ \
186  gu_curr_context = gu_list->parent_context; \
187  gu_list = &gu_contexts[gu_curr_context].list
188 
189 void sendCommandf(int cmd, float argument);
190 
191 void callbackSig(int id, void* arg);
192 void callbackFin(int id, void* arg);
193 void resetValues();
194 
195 #endif
unsigned char ydir
Definition: psp1_gfx.h:90
unsigned char specular
Definition: psp1_gfx.h:97
unsigned char ambient
Definition: psp1_gfx.h:95
void * disp_buffer
Definition: psp1_gfx.h:70
unsigned char xdir
Definition: psp1_gfx.h:89
int ge_list_executed[2]
unsigned int * current
Definition: psp1_gfx.h:41
int width
Definition: psp1_gfx.h:73
void * depth_buffer
Definition: psp1_gfx.h:71
unsigned char exponent
Definition: psp1_gfx.h:104
unsigned int gu_current_frame
void(* GuCallback)(int)
Definition: psp1_gfx.h:23
int ge_callback_id
Definition: psp1_gfx.h:32
GuLightSettings light_settings[4]
unsigned char diffuse
Definition: psp1_gfx.h:96
int gu_init
unsigned int * gu_object_stack[]
unsigned char zpos
Definition: psp1_gfx.h:88
GuSwapBuffersCallback swapBuffersCallback
Definition: psp1_gfx.h:34
int fragment_2x
Definition: psp1_gfx.h:54
static int tbwcmd_tbl[8]
Definition: psp1_gfx.h:127
int depth_offset
Definition: psp1_gfx.h:53
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
static int tsizecmd_tbl[8]
Definition: psp1_gfx.h:128
unsigned int clear_depth
Definition: psp1_gfx.h:61
int height
Definition: psp1_gfx.h:74
int gu_display_on
unsigned char xpos
Definition: psp1_gfx.h:83
GuContext gu_contexts[3]
GuCallback sig
Definition: psp1_gfx.h:27
unsigned char linear
Definition: psp1_gfx.h:102
int gu_states
static int tbpcmd_tbl[8]
Definition: psp1_gfx.h:126
int texture_proj_map_mode
Definition: psp1_gfx.h:56
int parent_context
Definition: psp1_gfx.h:42
ubyte cmd
Definition: wiiuse_internal.h:319
int signal_offset
Definition: psp1_gfx.h:30
unsigned char constant
Definition: psp1_gfx.h:98
unsigned char quadratic
Definition: psp1_gfx.h:103
GuCallback fin
Definition: psp1_gfx.h:28
GuDisplayList * gu_list
unsigned char type
Definition: psp1_gfx.h:82
int far_plane
Definition: psp1_gfx.h:52
void callbackFin(int id, void *arg)
Definition: psp1_gfx.h:45
int depth_width
Definition: psp1_gfx.h:72
int pixel_size
Definition: psp1_gfx.h:67
GuDisplayList list
Definition: psp1_gfx.h:47
void callbackSig(int id, void *arg)
void * frame_buffer
Definition: psp1_gfx.h:69
unsigned int * start
Definition: psp1_gfx.h:40
Definition: query.c:71
int swapBuffersBehaviour
Definition: psp1_gfx.h:35
int gu_call_mode
int scissor_enable
Definition: psp1_gfx.h:48
unsigned char zdir
Definition: psp1_gfx.h:91
GuDrawBuffer gu_draw_buffer
int gu_object_stack_depth
unsigned char ypos
Definition: psp1_gfx.h:84
int near_plane
Definition: psp1_gfx.h:51
void resetValues()
Definition: psp1_gfx.h:77
GuSettings gu_settings
Definition: psp1_gfx.h:38
int kernel_event_flag
Definition: psp1_gfx.h:31
unsigned int clear_color
Definition: psp1_gfx.h:59
int texture_map_mode
Definition: psp1_gfx.h:57
int gu_curr_context
unsigned char enable
Definition: psp1_gfx.h:81
unsigned int clear_stencil
Definition: psp1_gfx.h:60
int texture_mode
Definition: psp1_gfx.h:62
int frame_width
Definition: psp1_gfx.h:68
void * ge_edram_address
unsigned char cutoff
Definition: psp1_gfx.h:105
Definition: psp1_gfx.h:65
int texture_function
Definition: psp1_gfx.h:55
Definition: psp1_gfx.h:25
void sendCommandf(int cmd, float argument)