summaryrefslogtreecommitdiff
path: root/arm9/lib/src/OS_entropy.c
diff options
context:
space:
mode:
authorred031000 <rubenru09@aol.com>2020-05-03 19:22:26 +0100
committerred031000 <rubenru09@aol.com>2020-05-03 19:23:58 +0100
commit4f6c75ac8381a7a3c2902c97870066ee90f1d320 (patch)
treedddb158e8ec903382b383796bac8708ce8f8492f /arm9/lib/src/OS_entropy.c
parent2ee7030776461ee835dbbd44149f90ae79e7d4c5 (diff)
match OS_GetLowEntropyData
Diffstat (limited to 'arm9/lib/src/OS_entropy.c')
-rw-r--r--arm9/lib/src/OS_entropy.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/arm9/lib/src/OS_entropy.c b/arm9/lib/src/OS_entropy.c
index bfc95882..b33781cc 100644
--- a/arm9/lib/src/OS_entropy.c
+++ b/arm9/lib/src/OS_entropy.c
@@ -6,23 +6,17 @@
#include "consts.h"
#include "OS_entropy.h"
-u32 * const HW_REG_006 = (u32 *) 0x04000006;
-u32 * const HW_REG_130 = (u32 *) 0x04000130;
-u32 * const HW_REG_600 = (u32 *) 0x04000600;
-
-u32 * const OSi_TickCounter = (u32 *) 0x021D37B4;
-
ARM_FUNC void OS_GetLowEntropyData(u32 * arr)
{
- OSSystemWork* work = OS_GetSystemWork();
- u16 x = *((u16 *)HW_REG_006);
- u8 * nvramUserInfo = work->nvramUserInfo;
- u8 r5 = nvramUserInfo[0x74];
- arr[0] = (OS_GetTickLo()<<0x10) | x ;
- arr[1] = (OSi_TickCounter[0]<<0x10) ^ r5[2];
- u32 what = OSi_TickCounter[0];
- what = OSi_TickCounter[1];
- arr[2] = *((u32 *)r4) ^ what ^ *(u32 *)((u8 *)work+0x3c);
- arr[2] ^= *HW_REG_600;
- // ...
-} \ No newline at end of file
+ const OSSystemWork* work = OS_GetSystemWork();
+ const u8 * macAddress = (u8 *)((u32)(work->nvramUserInfo) + ((sizeof(NVRAMConfig) + 3) & ~3));
+ arr[0] = (u32)((GX_GetVCount() << 16) | OS_GetTickLo());
+ arr[1] = (u32)(*(u16 *)(macAddress + 4) << 16) ^ (u32)(OSi_TickCounter);
+ arr[2] = (u32)(OSi_TickCounter >> 32) ^ *(u32 *)macAddress ^ work->vblankCount;
+ arr[2] ^= reg_G3X_GXSTAT;
+ arr[3] = *(u32 *)(&work->real_time_clock[0]);
+ arr[4] = *(u32 *)(&work->real_time_clock[4]);
+ arr[5] = (((u32)work->mic_sampling_data) << 16) ^ work->mic_last_address;
+ arr[6] = (u32) ((*(u16 *)(&work->touch_panel[0]) << 16) | *(u16 *)(&work->touch_panel[2]));
+ arr[7] = (u32)((work->wm_rssi_pool << 16) | (reg_PAD_KEYINPUT | *(vu16 *)HW_BUTTON_XY_BUF));
+}