1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: gfx_ParticleRandom.cpp
4
5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Revision: 23207 $
14 *---------------------------------------------------------------------------*/
15
16 #include "precompiled.h"
17
18 #include <nw/gfx/gfx_ParticleRandom.h>
19
20 namespace nw
21 {
22 namespace gfx
23 {
24
25 #include <nn/hw/ARM/code32.h>
26 #include <nn/hw/ARM/VFPv2_reg.h>
27
28 //----------------------------------------
29 asm f32
NextFloatSignedOne()30 ParticleRandom::NextFloatSignedOne()
31 {
32 LDR r2, [r0, #__cpp(offsetof(ParticleRandom, m_Seed))]
33
34 LDR r3, mix1
35 LDR r1, mix2
36 MLA r1, r2, r3, r1
37
38 LDR r3, mask
39 STR r1, [r0, #0]
40 AND r2,r3,r1,LSR #16
41
42 CLZ r0, r2
43 AND r12, r1, #0x80000000
44 LSL r2, r2, r0 // 最上位が1になるまで左に出して
45 RSB r1, r0, #142 // 最上位(17)のときに126 (-1 + 127)になる
46 ADD r2, r12, r2, LSR #8
47 ADD r2, r2, r1, LSL #23 /// 指数部を設定
48 VMOV s0, r2
49
50 BX lr
51
52 mix1 DCD 0x343fd
53 mix2 DCD 0x269ec3
54 mask DCD 0x00007fff
55 }
56
57 //----------------------------------------
58 asm f32
NextFloatSignedHalf()59 ParticleRandom::NextFloatSignedHalf()
60 {
61 LDR r2, [r0, #__cpp(offsetof(ParticleRandom, m_Seed))]
62
63 LDR r3, mixh1
64 LDR r1, mixh2
65 MLA r1, r2, r3, r1
66
67 LDR r3, maskh
68 STR r1, [r0, #0]
69 AND r2,r3,r1,LSR #16
70
71 CLZ r0, r2
72 AND r12, r1, #0x80000000
73 LSL r2, r2, r0 // 最上位が1になるまで左に出して
74 RSB r1, r0, #141 // 最上位(17)のときに126 (-1 + 127)になる
75 ADD r2, r12, r2, LSR #8
76 ADD r2, r2, r1, LSL #23 /// 指数部を設定
77 VMOV s0, r2
78
79 BX lr
80
81 mixh1 DCD 0x343fd
82 mixh2 DCD 0x269ec3
83 maskh DCD 0x00007fff
84 }
85
86 #include <nn/hw/ARM/codereset.h>
87
88 } // namespace gfx
89 } // namespace nw
90