#define SWAP16(x) ({ uint16_t y=(x); (((y)>>8 & 0xff) | ((y)<<8 & 0xff00)); })
#define SWAP32(x) ({ uint32_t y=(x); (((y)>>24 & 0xfful) | ((y)>>8 & 0xff00ul) | ((y)<<8 & 0xff0000ul) | ((y)<<24 & 0xff000000ul)); })
-#ifdef __BIG_ENDIAN__
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
// big endian config
#define HOST2LE32(x) SWAP32(x)
#define KEY_BADTEXTURES 128
#define KEY_CHECKTHISOUT 256
-#if !defined(__BIG_ENDIAN__) || defined(__x86_64__) || defined(__i386__)
-#ifndef __LITTLE_ENDIAN__
-#define __LITTLE_ENDIAN__
-#endif
-#endif
-
-#ifdef __LITTLE_ENDIAN__
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define RED(x) (x & 0xff)
#define BLUE(x) ((x>>16) & 0xff)
#define GREEN(x) ((x>>8) & 0xff)
#define COLOR(x) (x & 0xffffff)
-#elif defined __BIG_ENDIAN__
+#else
#define RED(x) ((x>>24) & 0xff)
#define BLUE(x) ((x>>8) & 0xff)
#define GREEN(x) ((x>>16) & 0xff)
unsigned long lSetMask = 0;
long lLowerpart;
+#if defined(__GNUC__) && __GNUC__ >= 6
+#pragma GCC diagnostic ignored "-Wmisleading-indentation"
+#endif
+
#include "soft.c"
#include "prim.c"
/////////////////////////////////////////////////////////////////////////////
-int renderer_init(void)
+static void set_vram(void *vram)
{
- psxVub=(void *)gpu.vram;
+ psxVub=vram;
psxVsb=(signed char *)psxVub; // different ways of accessing PSX VRAM
psxVsw=(signed short *)psxVub;
psxVul=(uint32_t *)psxVub;
psxVuw_eom=psxVuw+1024*512; // pre-calc of end of vram
+}
+
+int renderer_init(void)
+{
+ set_vram(gpu.vram);
PSXDisplay.RGB24 = FALSE; // init some stuff
PSXDisplay.Interlaced = FALSE;
return 0;
}
-extern const unsigned char cmd_lengths[256];
+void renderer_finish(void)
+{
+}
-void do_cmd_list(unsigned int *list, int list_len)
+void renderer_notify_res_change(void)
{
- unsigned int cmd, len;
+}
+
+extern const unsigned char cmd_lengths[256];
+int do_cmd_list(unsigned int *list, int list_len, int *last_cmd)
+{
+ unsigned int cmd = 0, len;
+ unsigned int *list_start = list;
unsigned int *list_end = list + list_len;
for (; list < list_end; list += 1 + len)
{
cmd = *list >> 24;
len = cmd_lengths[cmd];
+ if (list + 1 + len > list_end) {
+ cmd = -1;
+ break;
+ }
+
+#ifndef TEST
+ if (cmd == 0xa0 || cmd == 0xc0)
+ break; // image i/o, forward to upper layer
+ else if ((cmd & 0xf8) == 0xe0)
+ gpu.ex_regs[cmd & 7] = list[0];
+#endif
primTableJ[cmd]((void *)list);
{
case 0x48 ... 0x4F:
{
- u32 num_vertexes = 1;
- u32 *list_position = &(list[2]);
+ u32 num_vertexes = 2;
+ u32 *list_position = &(list[3]);
while(1)
{
- if((*list_position & 0xf000f000) == 0x50005000 || list_position >= list_end)
+ if(list_position >= list_end) {
+ cmd = -1;
+ goto breakloop;
+ }
+
+ if((*list_position & 0xf000f000) == 0x50005000)
break;
list_position++;
num_vertexes++;
}
- if(num_vertexes > 2)
- len += (num_vertexes - 2);
-
+ len += (num_vertexes - 2);
break;
}
case 0x58 ... 0x5F:
{
- u32 num_vertexes = 1;
- u32 *list_position = &(list[2]);
+ u32 num_vertexes = 2;
+ u32 *list_position = &(list[4]);
while(1)
{
- if((*list_position & 0xf000f000) == 0x50005000 || list_position >= list_end)
+ if(list_position >= list_end) {
+ cmd = -1;
+ goto breakloop;
+ }
+
+ if((*list_position & 0xf000f000) == 0x50005000)
break;
list_position += 2;
num_vertexes++;
}
- if(num_vertexes > 2)
- len += (num_vertexes - 2) * 2;
-
+ len += (num_vertexes - 2) * 2;
break;
}
#endif
}
}
+
+breakloop:
+ gpu.ex_regs[1] &= ~0x1ff;
+ gpu.ex_regs[1] |= lGPUstatusRet & 0x1ff;
+
+ *last_cmd = cmd;
+ return list - list_start;
}
void renderer_sync_ecmds(uint32_t *ecmds)
{
iUseDither = cbs->gpu_peops.iUseDither;
dwActFixes = cbs->gpu_peops.dwActFixes;
+ if (cbs->pl_set_gpu_caps)
+ cbs->pl_set_gpu_caps(0);
+ set_vram(gpu.vram);
}