Some more endianess fixes
This commit is contained in:
parent
1827c3f3b6
commit
c0a92ffe3d
|
@ -139,11 +139,11 @@ static INLINE void GPU_ligne(Screen * screen, u16 l)
|
|||
* I'm really not sure it's correct.
|
||||
*/
|
||||
if (gpu->lcd == 0) {
|
||||
unsigned long mainlcdcnt = ((unsigned long *)ARM9Mem.ARM9_REG)[0];
|
||||
u32 mainlcdcnt = ((u32 *)ARM9Mem.ARM9_REG)[0];
|
||||
int ii = l*256;
|
||||
if ((mainlcdcnt&0x10000)==0) {
|
||||
for (i=0; i<256; i++) {
|
||||
((unsigned short*)dst)[i] = ((unsigned short*)ARM9Mem.ARM9_LCD)[ii];
|
||||
((u16 *)dst)[i] = ((u16 *)ARM9Mem.ARM9_LCD)[ii];
|
||||
ii++;
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -85,7 +85,7 @@ BOOL NDS_SetROM(u8 * rom, u32 mask)
|
|||
|
||||
MMU_setRom(rom, mask);
|
||||
|
||||
NDS_header * header = (NDS_header *)MMU.CART_ROM;
|
||||
NDS_header * header = NDS_getROMHeader();
|
||||
|
||||
u32 src = header->ARM9src;
|
||||
u32 dst = header->ARM9cpy;
|
||||
|
@ -193,7 +193,51 @@ BOOL NDS_SetROM(u8 * rom, u32 mask)
|
|||
|
||||
NDS_header * NDS_getROMHeader(void)
|
||||
{
|
||||
return (NDS_header *)MMU.CART_ROM;
|
||||
NDS_header * header = malloc(sizeof(NDS_header));
|
||||
|
||||
memcpy(header->gameTile, MMU.CART_ROM, 12);
|
||||
memcpy(header->gameCode, MMU.CART_ROM + 12, 4);
|
||||
header->makerCode = T1ReadWord(MMU.CART_ROM, 16);
|
||||
header->unitCode = MMU.CART_ROM[18];
|
||||
header->deviceCode = MMU.CART_ROM[19];
|
||||
header->cardSize = MMU.CART_ROM[20];
|
||||
memcpy(header->cardInfo, MMU.CART_ROM + 21, 8);
|
||||
header->flags = MMU.CART_ROM[29];
|
||||
header->ARM9src = T1ReadLong(MMU.CART_ROM, 32);
|
||||
header->ARM9exe = T1ReadLong(MMU.CART_ROM, 36);
|
||||
header->ARM9cpy = T1ReadLong(MMU.CART_ROM, 40);
|
||||
header->ARM9binSize = T1ReadLong(MMU.CART_ROM, 44);
|
||||
header->ARM7src = T1ReadLong(MMU.CART_ROM, 48);
|
||||
header->ARM7exe = T1ReadLong(MMU.CART_ROM, 52);
|
||||
header->ARM7cpy = T1ReadLong(MMU.CART_ROM, 56);
|
||||
header->ARM7binSize = T1ReadLong(MMU.CART_ROM, 60);
|
||||
header->FNameTblOff = T1ReadLong(MMU.CART_ROM, 64);
|
||||
header->FNameTblSize = T1ReadLong(MMU.CART_ROM, 68);
|
||||
header->FATOff = T1ReadLong(MMU.CART_ROM, 72);
|
||||
header->FATSize = T1ReadLong(MMU.CART_ROM, 76);
|
||||
header->ARM9OverlayOff = T1ReadLong(MMU.CART_ROM, 80);
|
||||
header->ARM9OverlaySize = T1ReadLong(MMU.CART_ROM, 84);
|
||||
header->ARM7OverlayOff = T1ReadLong(MMU.CART_ROM, 88);
|
||||
header->ARM7OverlaySize = T1ReadLong(MMU.CART_ROM, 92);
|
||||
header->unknown2a = T1ReadLong(MMU.CART_ROM, 96);
|
||||
header->unknown2b = T1ReadLong(MMU.CART_ROM, 100);
|
||||
header->IconOff = T1ReadLong(MMU.CART_ROM, 104);
|
||||
header->CRC16 = T1ReadWord(MMU.CART_ROM, 108);
|
||||
header->ROMtimeout = T1ReadWord(MMU.CART_ROM, 110);
|
||||
header->ARM9unk = T1ReadLong(MMU.CART_ROM, 112);
|
||||
header->ARM7unk = T1ReadLong(MMU.CART_ROM, 116);
|
||||
memcpy(header->unknown3c, MMU.CART_ROM + 120, 8);
|
||||
header->ROMSize = T1ReadLong(MMU.CART_ROM, 128);
|
||||
header->HeaderSize = T1ReadLong(MMU.CART_ROM, 132);
|
||||
memcpy(header->unknown5, MMU.CART_ROM + 136, 56);
|
||||
memcpy(header->logo, MMU.CART_ROM + 192, 156);
|
||||
header->logoCRC16 = T1ReadWord(MMU.CART_ROM, 348);
|
||||
header->headerCRC16 = T1ReadWord(MMU.CART_ROM, 350);
|
||||
memcpy(header->reserved, MMU.CART_ROM + 352, 160);
|
||||
|
||||
return header;
|
||||
|
||||
//return (NDS_header *)MMU.CART_ROM;
|
||||
}
|
||||
|
||||
void NDS_setTouchPos(u16 x, u16 y)
|
||||
|
|
|
@ -55,58 +55,6 @@ extern BOOL click;
|
|||
#define reg_IPCSYNC (0x180>>1)
|
||||
#define reg_IPCFIFOCNT (0x184>>1)
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
typedef struct
|
||||
{
|
||||
u8 reserved[160];
|
||||
u16 headerCRC16;
|
||||
u16 logoCRC16;
|
||||
u8 logo[156];
|
||||
u8 unknown5[56];
|
||||
u32 HeaderSize;
|
||||
u32 ROMSize;
|
||||
u8 unknown3c[8];
|
||||
|
||||
u32 ARM7unk;
|
||||
u32 ARM9unk;
|
||||
u16 ROMtimeout;
|
||||
u16 CRC16;
|
||||
u32 IconOff;
|
||||
|
||||
u32 unknown2b;
|
||||
u32 unknown2a;
|
||||
|
||||
u32 ARM7OverlaySize;
|
||||
u32 ARM7OverlayOff;
|
||||
u32 ARM9OverlaySize;
|
||||
u32 ARM9OverlayOff;
|
||||
|
||||
u32 FATSize;
|
||||
u32 FATOff;
|
||||
|
||||
u32 FNameTblSize;
|
||||
u32 FNameTblOff;
|
||||
|
||||
u32 ARM7binSize;
|
||||
u32 ARM7cpy;
|
||||
u32 ARM7exe;
|
||||
u32 ARM7src;
|
||||
|
||||
u32 ARM9binSize;
|
||||
u32 ARM9cpy;
|
||||
u32 ARM9exe;
|
||||
u32 ARM9src;
|
||||
|
||||
u8 flags;
|
||||
u8 cardInfo[8];
|
||||
u8 cardSize;
|
||||
u8 deviceCode;
|
||||
u8 unitCode;
|
||||
u16 makerCode;
|
||||
char gameCode[4];
|
||||
char gameTile[12];
|
||||
} NDS_header;
|
||||
#else
|
||||
typedef struct
|
||||
{
|
||||
char gameTile[12];
|
||||
|
@ -157,7 +105,6 @@ typedef struct
|
|||
u16 headerCRC16;
|
||||
u8 reserved[160];
|
||||
} NDS_header;
|
||||
#endif
|
||||
|
||||
extern void debug();
|
||||
|
||||
|
@ -805,6 +752,7 @@ int NDS_LoadFirmware(const char *filename);
|
|||
if((MMU.reg_IF[1]&MMU.reg_IE[1]) && (MMU.reg_IME[1]))
|
||||
if (armcpu_irqExeption(&NDS_ARM7))
|
||||
nds.ARM7Cycle = nds.cycles;
|
||||
|
||||
}
|
||||
return nds.cycles;
|
||||
}
|
||||
|
|
|
@ -96,6 +96,25 @@ enum Mode
|
|||
SYS = 0x1F
|
||||
};
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 N : 1,
|
||||
Z : 1,
|
||||
C : 1,
|
||||
V : 1,
|
||||
Q : 1,
|
||||
RAZ : 19,
|
||||
I : 1,
|
||||
F : 1,
|
||||
T : 1,
|
||||
mode : 5;
|
||||
} bits;
|
||||
u32 val;
|
||||
} Status_Reg;
|
||||
#else
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
|
@ -113,6 +132,7 @@ typedef union
|
|||
} bits;
|
||||
u32 val;
|
||||
} Status_Reg;
|
||||
#endif
|
||||
|
||||
typedef void* armcp_t;
|
||||
|
||||
|
|
|
@ -59,8 +59,6 @@ int main(int argc, char ** argv) {
|
|||
|
||||
surface = SDL_SetVideoMode(256, 384, 32, SDL_SWSURFACE);
|
||||
|
||||
|
||||
|
||||
while(!end) {
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ static INLINE u8 T1ReadByte(u8 * mem, u32 addr)
|
|||
static INLINE u16 T1ReadWord(u8 * mem, u32 addr)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
return (mem[addr] << 8) | mem[addr + 1];
|
||||
return (mem[addr + 1] << 8) | mem[addr];
|
||||
#else
|
||||
return *((u16 *) (mem + addr));
|
||||
#endif
|
||||
|
@ -43,8 +43,8 @@ static INLINE u16 T1ReadWord(u8 * mem, u32 addr)
|
|||
static INLINE u32 T1ReadLong(u8 * mem, u32 addr)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
return (mem[addr] << 24 | mem[addr + 1] << 16 |
|
||||
mem[addr + 2] << 8 | mem[addr + 3]);
|
||||
return (mem[addr + 3] << 24 | mem[addr + 2] << 16 |
|
||||
mem[addr + 1] << 8 | mem[addr]);
|
||||
#else
|
||||
return *((u32 *) (mem + addr));
|
||||
#endif
|
||||
|
@ -53,10 +53,10 @@ static INLINE u32 T1ReadLong(u8 * mem, u32 addr)
|
|||
static INLINE u64 T1ReadQuad(u8 * mem, u32 addr)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
return (mem[addr] << 56 | mem[addr + 1] << 48 |
|
||||
mem[addr + 2] << 40 | mem[addr + 3] << 32 |
|
||||
mem[addr + 4] << 24 | mem[addr + 5] << 16 |
|
||||
mem[addr + 6] << 8 | mem[addr + 7]);
|
||||
return (mem[addr + 7] << 56 | mem[addr + 6] << 48 |
|
||||
mem[addr + 5] << 40 | mem[addr + 4] << 32 |
|
||||
mem[addr + 3] << 24 | mem[addr + 2] << 16 |
|
||||
mem[addr + 1] << 8 | mem[addr]);
|
||||
#else
|
||||
return *((u64 *) (mem + addr));
|
||||
#endif
|
||||
|
@ -70,8 +70,8 @@ static INLINE void T1WriteByte(u8 * mem, u32 addr, u8 val)
|
|||
static INLINE void T1WriteWord(u8 * mem, u32 addr, u16 val)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
mem[addr] = val >> 8;
|
||||
mem[addr + 1] = val & 0xFF;
|
||||
mem[addr + 1] = val >> 8;
|
||||
mem[addr] = val & 0xFF;
|
||||
#else
|
||||
*((u16 *) (mem + addr)) = val;
|
||||
#endif
|
||||
|
@ -80,10 +80,10 @@ static INLINE void T1WriteWord(u8 * mem, u32 addr, u16 val)
|
|||
static INLINE void T1WriteLong(u8 * mem, u32 addr, u32 val)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
mem[addr] = val >> 24;
|
||||
mem[addr + 1] = (val >> 16) & 0xFF;
|
||||
mem[addr + 2] = (val >> 8) & 0xFF;
|
||||
mem[addr + 3] = val & 0xFF;
|
||||
mem[addr + 3] = val >> 24;
|
||||
mem[addr + 2] = (val >> 16) & 0xFF;
|
||||
mem[addr + 1] = (val >> 8) & 0xFF;
|
||||
mem[addr] = val & 0xFF;
|
||||
#else
|
||||
*((u32 *) (mem + addr)) = val;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue