From eb388b90f7cc450cbc4a330edd2d99d822142b54 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 15:18:58 -0400 Subject: [PATCH] [N-Rage] fixed broken FormatMemPak in 64-bit --- Source/nragev20/PakIO.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/nragev20/PakIO.cpp b/Source/nragev20/PakIO.cpp index efc621e81..23d15aa40 100644 --- a/Source/nragev20/PakIO.cpp +++ b/Source/nragev20/PakIO.cpp @@ -800,17 +800,19 @@ inline WORD CountBlocks( const unsigned char * bMemPakBinary, LPBYTE aNoteSizes void FormatMemPak( LPBYTE aMemPak ) { - FillMemory( aMemPak, 0x100, 0xFF ); + size_t iRand, n; + FillMemory(aMemPak, 0x100, 0xFF); aMemPak[0] = 0x81; // generate a valid code( i hope i can calculate it one day) BYTE aValidCodes[] = { 0x12, 0xC5, 0x8F, 0x6F, 0xA4, 0x28, 0x5B, 0xCA }; BYTE aCode[8]; - int iRand = (( (ULONG)aMemPak / 4 + (ULONG)g_strEmuInfo.hMainWindow / 4 ) % (sizeof(aValidCodes)/8) ); - for( int n = 0; n <8; n++ ) - aCode[n] = aValidCodes[n+iRand]; + iRand = ((size_t)aMemPak / 4) + ((size_t)g_strEmuInfo.hMainWindow / 4); + iRand %= sizeof(aValidCodes) / 8; + for (n = 0; n < 8; n++) + aCode[n] = aValidCodes[n + iRand]; //----------