ADePSP
Joined: 13 Jul 2006 Posts: 58
|
Posted: Thu Sep 21, 2006 9:27 pm Post subject: rand() function in Kernel Mode [RESOLVED] |
|
|
I'm current trying to capture the PSP_CTRL_NOTE button but have found I need to run in Kernel Mode to get it... All my code compiles as before (after a few changes) apart from it doesn't recognise the rand() function anymore...
Anybody know a way to get around this...?
I tried to make my own rand() function like this but had no luck because now it doesn't recognise the time() function,
| Code: |
SceKernelUtilsMt19937Context ctx;
int RandomInit(void) {
sceKernelUtilsMt19937Init(&ctx, time(NULL));
return 0;
}
int get_random(int lo, int hi) {
u32 rand_val = sceKernelUtilsMt19937UInt(&ctx);
rand_val = lo + rand_val % (hi+1);
return (int)rand_val;
}
int rand(void) {
return get_random(0,RAND_MAX);
} |
EDIT: I managed to get it working by declaring time as t_time in the RandomInit() function...
Thanks anyway... |
|