- Fix some graphical glitches on big-endian systems.
- Do some minor code cleanup.
This commit is contained in:
rogerman 2014-03-25 22:17:02 +00:00
parent db358049b9
commit 2873d83de4
4 changed files with 41 additions and 64 deletions

View File

@ -2200,10 +2200,20 @@ template<bool SKIP> static void GPU_RenderLine_DispCapture(u16 l)
case 0: // Capture screen (BG + OBJ + 3D)
{
//INFO("Capture screen (BG + OBJ + 3D)\n");
u8 *src = (u8*)(gpu->tempScanline);
#ifdef LOCAL_BE
static u16 swapSrc[256];
const size_t swapSrcSize = (gpu->dispCapCnt.capx == DISPCAPCNT::_128) ? 128 : 256;
u8 *src;
src = (u8*)(gpu->tempScanline);
for(size_t i = 0; i < swapSrcSize; i++)
{
swapSrc[i] = LE_TO_LOCAL_16(((u16 *)src)[i]);
}
CAPCOPY((u8 *)swapSrc,cap_dst,true);
#else
CAPCOPY(src,cap_dst,true);
#endif
}
break;
case 1: // Capture 3D
@ -2571,7 +2581,14 @@ void GPU_RenderLine(NDS_Screen * screen, u16 l, bool skip)
{
u8 * dst = GPU_screen + (screen->offset + l) * 512;
u8 * src = gpu->VRAMaddr + (l*512);
#ifdef LOCAL_BE
for(size_t i = 0; i < 256; i++)
{
((u16 *)dst)[i] = LE_TO_LOCAL_16(((u16 *)src)[i]);
}
#else
memcpy (dst, src, 512);
#endif
}
break;
case 3: // Display memory FIFO

View File

@ -95,20 +95,8 @@ void EMUFILE::write64le(u64* val)
void EMUFILE::write64le(u64 val)
{
#ifdef LOCAL_BE
u8 s[8];
s[0]=(u8)val;
s[1]=(u8)(val>>8);
s[2]=(u8)(val>>16);
s[3]=(u8)(val>>24);
s[4]=(u8)(val>>32);
s[5]=(u8)(val>>40);
s[6]=(u8)(val>>48);
s[7]=(u8)(val>>56);
fwrite((char*)&s,8);
#else
val = LOCAL_TO_LE_64(val);
fwrite(&val,8);
#endif
}
@ -117,11 +105,9 @@ size_t EMUFILE::read64le(u64 *Bufo)
u64 buf;
if(fread((char*)&buf,8) != 8)
return 0;
#ifndef LOCAL_BE
*Bufo=buf;
#else
*Bufo = LE_TO_LOCAL_64(buf);
#endif
return 1;
}
@ -139,16 +125,8 @@ void EMUFILE::write32le(u32* val)
void EMUFILE::write32le(u32 val)
{
#ifdef LOCAL_BE
u8 s[4];
s[0]=(u8)val;
s[1]=(u8)(val>>8);
s[2]=(u8)(val>>16);
s[3]=(u8)(val>>24);
fwrite(s,4);
#else
val = LOCAL_TO_LE_32(val);
fwrite(&val,4);
#endif
}
size_t EMUFILE::read32le(s32* Bufo) { return read32le((u32*)Bufo); }
@ -158,11 +136,9 @@ size_t EMUFILE::read32le(u32* Bufo)
u32 buf;
if(fread(&buf,4)<4)
return 0;
#ifndef LOCAL_BE
*(u32*)Bufo=buf;
#else
*(u32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24);
#endif
*Bufo = LE_TO_LOCAL_32(buf);
return 1;
}
@ -180,14 +156,8 @@ void EMUFILE::write16le(u16* val)
void EMUFILE::write16le(u16 val)
{
#ifdef LOCAL_BE
u8 s[2];
s[0]=(u8)val;
s[1]=(u8)(val>>8);
fwrite(s,2);
#else
val = LOCAL_TO_LE_16(val);
fwrite(&val,2);
#endif
}
size_t EMUFILE::read16le(s16* Bufo) { return read16le((u16*)Bufo); }
@ -197,11 +167,9 @@ size_t EMUFILE::read16le(u16* Bufo)
u32 buf;
if(fread(&buf,2)<2)
return 0;
#ifndef LOCAL_BE
*(u16*)Bufo=buf;
#else
*Bufo = LE_TO_LOCAL_16(buf);
#endif
return 1;
}

View File

@ -172,7 +172,7 @@ public:
return &(*vec)[0];
}
std::vector<u8>* get_vec() { return vec; };
std::vector<u8>* get_vec() const { return vec; };
virtual FILE *get_fp() { return NULL; }

View File

@ -79,11 +79,9 @@ int read32le(u32 *Bufo, EMUFILE *fp)
u32 buf = 0;
if(fp->_fread(&buf,4)<4)
return 0;
#ifdef LOCAL_LE
*(u32*)Bufo=buf;
#else
*(u32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24);
#endif
*Bufo = LE_TO_LOCAL_32(buf);
return 1;
}
@ -92,11 +90,9 @@ int read16le(u16 *Bufo, EMUFILE *is)
u16 buf;
if(is->_fread((char*)&buf,2) != 2)
return 0;
#ifdef LOCAL_LE
*Bufo=buf;
#else
*Bufo = LE_TO_LOCAL_16(buf);
#endif
return 1;
}
@ -105,11 +101,9 @@ int read64le(u64 *Bufo, EMUFILE *is)
u64 buf;
if(is->_fread((char*)&buf,8) != 8)
return 0;
#ifdef LOCAL_LE
*Bufo=buf;
#else
*Bufo = LE_TO_LOCAL_64(buf);
#endif
return 1;
}
@ -118,11 +112,9 @@ static int read32le(u32 *Bufo, std::istream *is)
u32 buf;
if(is->read((char*)&buf,4).gcount() != 4)
return 0;
#ifdef LOCAL_LE
*(u32*)Bufo=buf;
#else
*(u32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24);
#endif
*Bufo = LE_TO_LOCAL_32(buf);
return 1;
}