if((gpuDataC==254 && gpuDataP>=3) ||
(gpuDataC==255 && gpuDataP>=4 && !(gpuDataP&1)))
{
- if((gpuDataM[gpuDataP] & 0xF000F000) == 0x50005000)
+ if((gpuDataM[gpuDataP] & HOST2LE32(0xF000F000)) == HOST2LE32(0x50005000))
gpuDataP=gpuDataC-1;
}
}
// byteswappings
-#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)); })
+#define SWAP16(x) __builtin_bswap16(x)
+#define SWAP32(x) __builtin_bswap32(x)
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define GETLE32_(X) LE2HOST32(*(uint32_t *)X)
#define GETLE16D(X) ({uint32_t val = GETLE32(X); (val<<16 | val >> 16);})
#define PUTLE16(X, Y) do{*((uint16_t *)X)=HOST2LE16((uint16_t)Y);}while(0)
-#define PUTLE32_(X, Y) do{*((uint32_t *)X)=HOST2LE16((uint32_t)Y);}while(0)
+#define PUTLE32_(X, Y) do{*((uint32_t *)X)=HOST2LE32((uint32_t)Y);}while(0)
#ifdef __arm__
#define GETLE32(X) (*(uint16_t *)(X)|(((uint16_t *)(X))[1]<<16))
#define PUTLE32(X, Y) do{uint16_t *p_=(uint16_t *)(X);uint32_t y_=Y;p_[0]=y_;p_[1]=y_>>16;}while(0)
// byteswappings
-#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)); })
+#define SWAP16(x) __builtin_bswap16(x)
+#define SWAP32(x) __builtin_bswap32(x)
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define GETLE32_(X) LE2HOST32(*(uint32_t *)X)
#define GETLE16D(X) ({uint32_t val = GETLE32(X); (val<<16 | val >> 16);})
#define PUTLE16(X, Y) do{*((uint16_t *)X)=HOST2LE16((uint16_t)Y);}while(0)
-#define PUTLE32_(X, Y) do{*((uint32_t *)X)=HOST2LE16((uint32_t)Y);}while(0)
+#define PUTLE32_(X, Y) do{*((uint32_t *)X)=HOST2LE32((uint32_t)Y);}while(0)
#ifdef __arm__
#define GETLE32(X) (*(uint16_t *)(X)|(((uint16_t *)(X))[1]<<16))
#define PUTLE32(X, Y) do{uint16_t *p_=(uint16_t *)(X);uint32_t y_=Y;p_[0]=y_;p_[1]=y_>>16;}while(0)
for (; list < list_end; list += 1 + len)
{
- cmd = *list >> 24;
+ cmd = GETLE32(list) >> 24;
len = cmd_lengths[cmd];
if (list + 1 + len > list_end) {
cmd = -1;
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];
+ gpu.ex_regs[cmd & 7] = GETLE32(list);
#endif
primTableJ[cmd]((void *)list);
goto breakloop;
}
- if((*list_position & 0xf000f000) == 0x50005000)
+ if((*list_position & HOST2LE32(0xf000f000)) == HOST2LE32(0x50005000))
break;
list_position++;
goto breakloop;
}
- if((*list_position & 0xf000f000) == 0x50005000)
+ if((*list_position & HOST2LE32(0xf000f000)) == HOST2LE32(0x50005000))
break;
list_position += 2;
case 0xA0: // sys -> vid
{
short *slist = (void *)list;
- u32 load_width = slist[4];
- u32 load_height = slist[5];
+ u32 load_width = LE2HOST32(slist[4]);
+ u32 load_height = LE2HOST32(slist[5]);
u32 load_size = load_width * load_height;
len += load_size / 2;
sly1=(short)(((int)sly1<<SIGNSHIFT)>>SIGNSHIFT);
}
- lc1 = gpuData[0] & 0xffffff;
+ lc1 = GETLE32(&gpuData[0]) & 0xffffff;
DrawSemiTrans = (SEMITRANSBIT(GETLE32(&gpuData[0]))) ? TRUE : FALSE;
{
int32_t sr,sb,sg,src,sbc,sgc,c;
src=XCOL1(color);sbc=XCOL2(color);sgc=XCOL3(color);
- c=GETLE32(pdest)>>16;
+ c=HIWORD(GETLE32(pdest));
sr=(XCOL1(c))-src; if(sr&0x8000) sr=0;
sb=(XCOL2(c))-sbc; if(sb&0x8000) sb=0;
sg=(XCOL3(c))-sgc; if(sg&0x8000) sg=0;
{
uint32_t ma=GETLE32(pdest);
PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask);//0x80008000;
- if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(*pdest&0xFFFF));
- if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(*pdest&0xFFFF0000));
+ if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(GETLE32(pdest)&0xFFFF));
+ if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(GETLE32(pdest)&0xFFFF0000));
return;
}
PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask);//0x80008000;
{
static int iCheat=0;
col+=iCheat;
- if(iCheat==1) iCheat=0; else iCheat=1;
+ iCheat ^= 1;
}
{
uint32_t *DSTPtr;
unsigned short LineOffset;
- uint32_t lcol=lSetMask|(((uint32_t)(col))<<16)|col;
+ uint32_t lcol = HOST2LE32(lSetMask | (((uint32_t)(col)) << 16) | col);
dx>>=1;
DSTPtr = (uint32_t *)(psxVuw + (1024*y0) + x0);
LineOffset = 512 - dx;
{
for(i=0;i<dy;i++)
{
- for(j=0;j<dx;j++) { PUTLE32(DSTPtr, lcol); DSTPtr++; }
+ for(j=0;j<dx;j++) { *DSTPtr++ = lcol; }
DSTPtr += LineOffset;
}
}
{
uint32_t *DSTPtr;
unsigned short LineOffset;
- uint32_t lcol=(((int32_t)col)<<16)|col;
+ uint32_t lcol = HOST2LE32((((uint32_t)(col)) << 16) | col);
dx>>=1;
DSTPtr = (uint32_t *)(psxVuw + (1024*y0) + x0);
LineOffset = 512 - dx;
for(i=0;i<dy;i++)
{
- for(j=0;j<dx;j++) { PUTLE32(DSTPtr, lcol); DSTPtr++; }
+ for(j=0;j<dx;j++) { *DSTPtr++ = lcol; }
DSTPtr += LineOffset;
}
}
if (is_read) {
gpu.status |= PSX_GPU_STATUS_IMG;
// XXX: wrong for width 1
- memcpy(&gpu.gp0, VRAM_MEM_XY(gpu.dma.x, gpu.dma.y), 4);
+ gpu.gp0 = LE32TOH(*(uint32_t *) VRAM_MEM_XY(gpu.dma.x, gpu.dma.y));
gpu.state.last_vram_read_frame = *gpu.state.frame_count;
}
flush_cmd_buffer();
ret = gpu.gp0;
- if (gpu.dma.h)
+ if (gpu.dma.h) {
+ ret = HTOLE32(ret);
do_vram_io(&ret, 1, 1);
+ ret = LE32TOH(ret);
+ }
log_io("gpu_read %08x\n", ret);
return ret;