27 #ifndef ICB_PSX_SCRN_H 28 #define ICB_PSX_SCRN_H 30 #include "engines/icb/psx_config.h" 31 #include "engines/icb/gfx/psx_pcgpu.h" 32 #include "engines/icb/gfx/psx_pcdefines.h" 33 #include "engines/icb/gfx/psx_ot.h" 35 #include "common/util.h" 47 #define MIN_SCREEN_X (0) 48 #define MAX_SCREEN_X (SCREEN_W - 1) 49 #define MIN_SCREEN_Y (0) 50 #define MAX_SCREEN_Y (SCREEN_H - 1) 52 #define MSG_Y (SCREEN_H - 40) 54 #define MSG_W SCREEN_W 58 #define OT_LENGTH 16 // bit length of OT 60 #define OT_SIZE (1 << OT_LENGTH) 63 #define D_CACHE getScratchAddr(0) 64 #define D_CACHE_SIZE 1024 74 void SwapDoubleBuffer(
void);
75 void SwapBufferIndex(
void);
76 void DrawDisplayList(int32 buf);
77 void Init_display(int32 w, int32 h, int32 x1, int32 y1, int32 x2, int32 y2, int32 ox, int32 oy, int32 clear);
78 void RenderCycle(
void);
86 extern int32 dont_set_dispbuf;
89 extern uint32 reloadFont;
90 extern int32 global_use_otlist;
93 typedef uint8 GPUPACKET;
94 extern GPUPACKET *drawpacket;
95 extern GPUPACKET *drawpacketStart;
96 extern GPUPACKET *drawpacketEnd;
99 extern int32 globalPacketMax;
100 extern int32 packetsUsed;
104 extern int32 g_otz_shift;
105 extern int32 g_otz_offset;
108 extern int32 update_minmaxzpos;
111 extern int32 minZOTpos;
112 extern int32 maxZOTpos;
113 extern int32 minUsedZpos;
114 extern int32 maxUsedZpos;
115 extern int32 nearClip;
117 #if (_PSX_ON_PC == 0) && (_PSX == 1) 120 #define PACKETMAX 1500 122 #define PACKETSIZE sizeof(POLY_GT3) 124 #define PACKET_MAX_SIZE sizeof(DR_LOAD) 125 #define PACKETMEM (PACKETMAX * PACKETSIZE) 129 #define set3(_r0, _r1) __asm__ volatile("swl %1, 2( %0 )" : : "r"(_r0), "r"(_r1) : "memory") 131 static inline uint32 get3(
void *_r0) {
133 __asm__
volatile(
"lwl %0, 2( %1 )" :
"=r"(t) :
"r"(_r0) :
"memory");
144 #define setaddr(_p0, _p1) set3((_p0), ((uint32)(_p1)) << 8) 145 #define getaddr(_p) (get3(_p) >> 8) 147 static inline void addPrim(uint32 *ot,
void *p) {
148 uint32 tmp = get3(ot);
153 static inline void addPrims(uint32 *ot,
void *p0,
void *p1) {
154 uint32 tmp = get3(ot);
159 #endif // #if (_PSX_ON_PC == 0) && (_PSX==1) 164 static inline void mySetDrawLoad(
DR_LOAD *p,
RECT16 *r, int32 length) {
165 p->code[0] = (uint32)(0xA0 << 24);
166 p->code[1] = *((uint32 *)r);
167 p->code[2] = *((uint32 *)r + 1);
168 setlen(p, (1 + 2 + 1 + length));
169 p->p[length] = 0x01 << 24;
173 static inline void mySetDrawLoadNoFlush(
DR_LOAD *p,
RECT16 *r, int32 length) {
174 p->code[0] = (uint32)(0xA0 << 24);
175 p->code[1] = *((uint32 *)r);
176 p->code[2] = *((uint32 *)r + 1);
177 setlen(p, (1 + 2 + length));
178 p->p[length] = 0x01 << 24;
182 static inline void myAddPacket(int32 len) {
186 if (drawpacket >= drawpacketEnd) {
187 drawpacket = drawpacketStart;
192 static inline void myAddDRLOAD(
RECT16 *r, uint32 *pot, int32 length) {
193 mySetDrawLoad((
DR_LOAD *)drawpacket, r, length);
194 addPrim(pot, drawpacket);
195 myAddPacket(((5 + length) << 2));
200 static inline void myAddDRLOADNoFlush(
RECT16 *r, uint32 *pot, int32 length) {
201 mySetDrawLoadNoFlush((
DR_LOAD *)drawpacket, r, length);
202 addPrim(pot, drawpacket);
203 myAddPacket(((4 + length) << 2));
207 static inline int32 myMakeOTPosition(int32 z0) {
208 int32 z1 = (z0 >> g_otz_shift) - g_otz_offset;
210 minUsedZpos =
MIN(z0, minUsedZpos);
211 maxUsedZpos =
MAX(z0, maxUsedZpos);
213 z1 =
MAX(minZOTpos, z1);
214 z1 =
MIN(maxZOTpos, z1);
221 static inline int32 myAddPrimClip(int32 z0,
void *primitive) {
222 int32 otpos = myMakeOTPosition(z0);
226 #if (_PSX_ON_PC == 1) || (_PSX == 0) 228 addPrimZUsr(drawot + otpos, primitive, z0, OTusrData);
230 addPrim(drawot + otpos, primitive);
237 #endif // #ifndef PSX_SCRN_H
Definition: psx_scrn.h:39
T MIN(T a, T b)
Definition: util.h:59
Definition: psx_pcgpu.h:301
T MAX(T a, T b)
Definition: util.h:62
Definition: psx_pcgpu.h:280
Definition: psx_pcgpu.h:260
Definition: psx_pcgpu.h:559
Definition: psx_pcgpu.h:313