huhhuh2000
New member
i know the pj64 help says the byte order of a rom doesnt matter, but which, in your opinion loads fastest or is best
void ByteSwapRom (void) {
DWORD count;
SendMessage( hStatusWnd, SB_SETTEXT, 0, (LPARAM)"Byte swapping image" );
switch (*((DWORD *)&ROM[0])) {
case 0x12408037:
for( count = 0 ; count < RomFileSize; count += 4 ) {
ROM[count] ^= ROM[count+2];
ROM[count + 2] ^= ROM[count];
ROM[count] ^= ROM[count+2];
ROM[count + 1] ^= ROM[count + 3];
ROM[count + 3] ^= ROM[count + 1];
ROM[count + 1] ^= ROM[count + 3];
}
break;
case 0x40123780:
for( count = 0 ; count < RomFileSize; count += 4 ) {
ROM[count] ^= ROM[count+3];
ROM[count + 3] ^= ROM[count];
ROM[count] ^= ROM[count+3];
ROM[count + 1] ^= ROM[count + 2];
ROM[count + 2] ^= ROM[count + 1];
ROM[count + 1] ^= ROM[count + 2];
}
break;
case 0x80371240:
break;
default:
DisplayError("ByteSwapRom: %X",ROM[0]);
}
}
void ByteSwapRom (void) {
DWORD count;
SendMessage( hStatusWnd, SB_SETTEXT, 0, (LPARAM)"Byte swapping image" );
switch (*((DWORD *)&ROM[0])) {
case 0x12408037:
for( count = 0 ; count < RomFileSize; count += 4 ) {
ROM[count] ^= ROM[count+2];
ROM[count + 2] ^= ROM[count];
ROM[count] ^= ROM[count+2];
ROM[count + 1] ^= ROM[count + 3];
ROM[count + 3] ^= ROM[count + 1];
ROM[count + 1] ^= ROM[count + 3];
}
MessageBox(NULL,"1","here",MB_OK);
break;
case 0x40123780:
for( count = 0 ; count < RomFileSize; count += 4 ) {
ROM[count] ^= ROM[count+3];
ROM[count + 3] ^= ROM[count];
ROM[count] ^= ROM[count+3];
ROM[count + 1] ^= ROM[count + 2];
ROM[count + 2] ^= ROM[count + 1];
ROM[count + 1] ^= ROM[count + 2];
}
MessageBox(NULL,"2","here",MB_OK);
break;
case 0x80371240:
MessageBox(NULL,"3","here",MB_OK);
break;
default:
DisplayError("ByteSwapRom: %X",ROM[0]);
}
}
AlphaWolf said:Saying "byteswapped" is a bit ambiguous, don't you think?...its either big endian (e.g. most risc CPUs), or little endian (e.g. intel CPUs). Byteswap just means you are switching from one endian to the other
I would figure though, that in the case of a dynarec engine, it would be better to match the endian-ness of the host CPU?
ShadowPrince said:Not totally correct.There are 4 DWORD formats :
Big Endian which mainframe computers using, Byteswapped, Little Endian (mostly PCs) and Wordswapped.
N64 emulators ,at least starting from uhle, disregard rom extension,and determine rom format by the first 4 bytes of the rom :
0x80371240 Big endian (z64)
0x37804012 Byteswapped (v64)
0x40123780 Little endian
0x12408037 Word swapped