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