Endian fixes from FBANext for CPU cores

This commit is contained in:
Barry Harris 2011-12-23 11:08:55 +00:00
parent c0df8070c7
commit 7fe089a450
3 changed files with 36 additions and 0 deletions

View File

@ -8,6 +8,11 @@
#include <assert.h>
#include "tchar.h"
// ---------------------------------------------------------------------------
#define LSB_FIRST
// ---------------------------------------------------------------------------
#include "burn.h"
// ---------------------------------------------------------------------------
@ -19,6 +24,7 @@
// zet.cpp
#include "zet.h"
#ifdef LSB_FIRST
typedef union
{
struct { UINT8 l,h,h2,h3; } b;
@ -26,6 +32,15 @@ typedef union
UINT32 d;
} PAIR;
#define BURN_ENDIAN_SWAP_INT8(x) x
#define BURN_ENDIAN_SWAP_INT16(x) x
#define BURN_ENDIAN_SWAP_INT32(x) x
#define BURN_ENDIAN_SWAP_INT64(x) x
#else
// define the above union and BURN_ENDIAN_SWAP macros in the following platform specific header
#include "endian.h"
#endif
// ---------------------------------------------------------------------------
// Driver information

View File

@ -579,7 +579,11 @@ void program_write_dword_32be(unsigned int /*A*/, unsigned int /*V*/)
#if FAST_OP_FETCH
#ifdef LSB_FIRST
#define cpu_readop16(A) *(unsigned short *)(pSh2Ext->opbase + ((A) ^ 0x02))
#else
#define cpu_readop16(A) (*(unsigned short *)(pSh2Ext->opbase + ((A))))
#endif
#else
@ -588,7 +592,9 @@ SH2_INLINE unsigned short cpu_readop16(unsigned int A)
unsigned char * pr;
pr = pSh2Ext->MemMap[ (A >> SH2_SHIFT) + SH2_WADD * 2 ];
if ( (unsigned int)pr >= SH2_MAXHANDLER ) {
#ifdef LSB_FIRST
A ^= 2;
#endif
return *((unsigned short *)(pr + (A & SH2_PAGEM)));
}
return pSh2Ext->ReadWord[(unsigned int)pr](A);
@ -608,7 +614,9 @@ SH2_INLINE UINT8 RB(UINT32 A)
unsigned char * pr;
pr = pSh2Ext->MemMap[ A >> SH2_SHIFT ];
if ( (uintptr_t)pr >= SH2_MAXHANDLER ) {
#ifdef LSB_FIRST
A ^= 3;
#endif
return pr[A & SH2_PAGEM];
}
return pSh2Ext->ReadByte[(uintptr_t)pr](A);
@ -624,7 +632,9 @@ SH2_INLINE UINT16 RW(UINT32 A)
unsigned char * pr;
pr = pSh2Ext->MemMap[ A >> SH2_SHIFT ];
if ( (uintptr_t)pr >= SH2_MAXHANDLER ) {
#ifdef LSB_FIRST
A ^= 2;
#endif
//return (pr[A & SH2_PAGEM] << 8) | pr[(A & SH2_PAGEM) + 1];
return *((unsigned short *)(pr + (A & SH2_PAGEM)));
}
@ -637,7 +647,9 @@ SH2_INLINE UINT16 OPRW(UINT32 A)
unsigned char * pr;
pr = pSh2Ext->MemMap[ (A >> SH2_SHIFT) + SH2_WADD * 2 ];
if ( (uintptr_t)pr >= SH2_MAXHANDLER ) {
#ifdef LSB_FIRST
A ^= 2;
#endif
return *((unsigned short *)(pr + (A & SH2_PAGEM)));
}
@ -670,7 +682,9 @@ SH2_INLINE void WB(UINT32 A, UINT8 V)
unsigned char* pr;
pr = pSh2Ext->MemMap[(A >> SH2_SHIFT) + SH2_WADD];
if ((uintptr_t)pr >= SH2_MAXHANDLER) {
#ifdef LSB_FIRST
A ^= 3;
#endif
pr[A & SH2_PAGEM] = (unsigned char)V;
return;
}
@ -687,7 +701,9 @@ SH2_INLINE void WW(UINT32 A, UINT16 V)
unsigned char * pr;
pr = pSh2Ext->MemMap[(A >> SH2_SHIFT) + SH2_WADD];
if ((uintptr_t)pr >= SH2_MAXHANDLER) {
#ifdef LSB_FIRST
A ^= 2;
#endif
*((unsigned short *)(pr + (A & SH2_PAGEM))) = (unsigned short)V;
return;
}

View File

@ -8,8 +8,13 @@
typedef union
{
#ifdef LSB_FIRST
struct { UINT8 l,h,h2,h3; } b;
struct { UINT16 l,h; } w;
#else
struct { UINT8 h3,h2,h,l; } b;
struct { UINT16 h,l; } w;
#endif
UINT32 d;
} Z80_PAIR;