mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-05-23 14:41:38 -04:00
Merge pull request #354 from Cuyler36:jaudio_NES_random
Implement & link jaudio_NES/random.c
This commit is contained in:
@@ -7,6 +7,7 @@ symbol_aligns:
|
||||
0x800190e0: 32
|
||||
0x80019380: 32
|
||||
0x8001a0c0: 32
|
||||
0x80031d80: 32
|
||||
0x80207458: 8 # align RunQueue to 0x001251d8
|
||||
0x800b9140: 32 # align gam_win_moji1_tex to 32 bytes
|
||||
0x801f71c0: 32 # align texture_buffer_data to 32 bytes
|
||||
|
||||
@@ -89,6 +89,10 @@ jaudio_NES/internal/playercall.c:
|
||||
.bss: [0x801864d0,0x80186590]
|
||||
jaudio_NES/internal/os.c:
|
||||
.text: [0x80026120, 0x80026300]
|
||||
jaudio_NES/internal/random.c:
|
||||
.text: [0x80031ce0, 0x80031d80]
|
||||
.sdata: [0x80217c38, 0x80217c40]
|
||||
.sdata2: [0x80218f60, 0x80218f70]
|
||||
Famicom/famicom.cpp:
|
||||
.text: [0x80041614, 0x80046888] # TODO: get ~J2DOrthoGraph's dtor in here somehow? 0x800468fc, also add in JUTGamePad::getPortStatus when JUTGamePad is linked?
|
||||
.rodata: [0x800aa9a8, 0x800aaa30]
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef JAUDIO_RANDOM_H
|
||||
#define JAUDIO_RANDOM_H
|
||||
|
||||
#include "types.h"
|
||||
#include "jaudio_NES/audiostruct.h"
|
||||
#include "jaudio_NES/audiowork.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern s32 GetRandom_s32(void);
|
||||
extern f32 GetRandom_sf32(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "jaudio_NES/random.h"
|
||||
|
||||
static s32 v0 = 0x0001000;
|
||||
static s32 v1 = 0x0005555;
|
||||
|
||||
#define V0_MULT (s32)0x13579BDE
|
||||
#define V1_MULT (s32)0x98765432
|
||||
|
||||
extern s32 GetRandom_s32(void) {
|
||||
s32 tmp;
|
||||
|
||||
tmp = (v1 * V1_MULT) + ((v0 * V0_MULT) >> 4);
|
||||
tmp += 1;
|
||||
v0 = v1;
|
||||
v1 = tmp;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
extern f32 GetRandom_sf32(void) {
|
||||
s32 rnd = GetRandom_s32();
|
||||
f32 rnd_float = (f32)(rnd & 0x00FFFFFF) / (f32)(0x00FFFFFF); /* map to float [0, 1] */
|
||||
|
||||
if (rnd < 0) {
|
||||
rnd_float = -rnd_float;
|
||||
}
|
||||
|
||||
return rnd_float;
|
||||
}
|
||||
Reference in New Issue
Block a user