]> icculus.org git repositories - divverent/darkplaces.git/blob - cpu_x86.nasm
removal of various id386 junk
[divverent/darkplaces.git] / cpu_x86.nasm
1           BITS 32
2           GLOBAL _Mod_PointInLeaf
3           GLOBAL _SV_HullPointContents
4           SECTION .text
5 _Mod_PointInLeaf
6
7 ;{
8
9         mov     eax, dword [esp+12-4] ; model
10         sub     esp, 4
11         push    ebx
12         push    esi
13
14 ;       mnode_t         *node;
15 ;       node = model->nodes;
16
17         mov     esi, dword [eax+200]
18
19 ;       if (node->contents < 0)
20
21         cmp     dword [esi], 0
22         jge     .firstvalid
23
24 ;               return (mleaf_t *)node;
25
26         mov     eax, esi
27         pop     esi
28         pop     ebx
29         add     esp, 4
30         ret     0
31 .firstvalid
32         mov     edx, dword [esp+8+8] ; p
33 .loop
34
35 ;       while (1)
36
37         mov     eax, dword [esi+36]
38         mov     cl, byte [eax+16]
39
40 ;       {
41 ;               node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct (p,node->plane->normal)) < node->plane->dist];
42
43         cmp     cl, 3
44         jb      .axisplane
45         fld     dword [eax+4]
46         fmul    dword [edx+4]
47         fld     dword [eax+8]
48         fmul    dword [edx+8]
49         fld     dword [eax]
50         fmul    dword [edx]
51         faddp   st1, st0
52         faddp   st1, st0
53         fld     dword [eax+12]
54         fcompp
55         xor     ecx, ecx
56         fnstsw  ax
57         test    ah, 65                                  ; 00000041H
58         sete    cl
59         mov     esi, dword [esi+ecx*4+40]
60
61 ;               if (node->contents < 0)
62
63         cmp     dword [esi], 0
64         jge     .loop
65
66 ;                       return (mleaf_t *)node;
67
68         mov     eax, esi
69
70 ;       }
71 ;       return NULL;    // never reached
72 ;}
73
74         pop     esi
75         pop     ebx
76         add     esp, 4
77         ret     0
78 .axisplane:
79         xor     ebx, ebx
80         mov     bl, cl
81         fld     dword [edx+ebx*4]
82         fld     dword [eax+12]
83         fcompp
84         xor     ecx, ecx
85         fnstsw  ax
86         test    ah, 65                                  ; 00000041H
87         sete    cl
88         mov     esi, dword [esi+ecx*4+40]
89
90 ;               if (node->contents < 0)
91
92         cmp     dword [esi], 0
93         jge     .loop
94
95 ;                       return (mleaf_t *)node;
96
97         mov     eax, esi
98
99 ;       }
100 ;       return NULL;    // never reached
101 ;}
102
103         pop     esi
104         pop     ebx
105         add     esp, 4
106         ret     0
107
108
109 _SV_HullPointContents
110
111 ;{
112         mov     ecx, [esp+12-4] ; num
113         sub     esp, 4
114         test    ecx, ecx
115         nop                     ; padding
116         push    ebx
117         push    esi
118         push    edi
119         push    ebp
120
121 ;       while (num >= 0)
122
123         jge     .firstvalid
124 ;       return num;
125         mov     eax, ecx
126         pop     ebp
127 ;}
128         pop     edi
129         pop     esi
130         pop     ebx
131         add     esp, 4
132         ret     0
133 .firstvalid
134         mov     eax, [esp+8+16] ; hull
135         mov     edx, [esp+16+16] ; p
136         mov     esi, [eax]
137         mov     edi, [eax+4]
138 .loop
139         mov     eax, [esi+ecx*8]
140         lea     ebx, [eax+eax*2]
141         xor     eax, eax
142         mov     al, [edi+ebx*8+16]
143         lea     ebp, [edi+ebx*8]
144
145 ;               num = hull->clipnodes[num].children[(hull->planes[hull->clipnodes[num].planenum].type < 3 ? p[hull->planes[hull->clipnodes[num].planenum].type] : DotProduct (hull->planes[hull->clipnodes[num].planenum].normal, p)) < hull->planes[hull->clipnodes[num].planenum].dist];
146
147         cmp     al, 3
148         jb      .axisplane
149         fld     dword [edx+8]
150         fmul    dword [ebp+8]
151         fld     dword [edx+4]
152         fmul    dword [ebp+4]
153         fld     dword [edx]
154         fmul    dword [ebp]
155         faddp   st1, st0
156         faddp   st1, st0
157         fstp    dword [esp-4+20]
158
159         fld     dword [ebp+12]
160         fcomp   dword [esp-4+20]
161         xor     ebx, ebx
162         fnstsw  ax
163         test    ah, 65                                  ; 00000041H
164         sete    bl
165         lea     eax, [ebx+ecx*4]
166         movsx   ecx, word [esi+eax*2+4]
167         test    ecx, ecx
168         jge     .loop
169 ;       return num;
170         mov     eax, ecx
171         pop     ebp
172 ;}
173         pop     edi
174         pop     esi
175         pop     ebx
176         add     esp, 4
177         ret     0
178
179 .axisplane
180         mov     eax, [edx+eax*4]
181         mov     [esp-4+20], eax
182
183         fld     dword [ebp+12]
184         fcomp   dword [esp-4+20]
185         xor     ebx, ebx
186         fnstsw  ax
187         test    ah, 65                                  ; 00000041H
188         sete    bl
189         lea     eax, [ebx+ecx*4]
190         movsx   ecx, word [esi+eax*2+4]
191         test    ecx, ecx
192         jge     .loop
193 ;       return num;
194         mov     eax, ecx
195         pop     ebp
196 ;}
197         pop     edi
198         pop     esi
199         pop     ebx
200         add     esp, 4
201         ret     0