foo
[dos_low3d] / src / 3dgfx_s.asm
1         bits 32
2         section .text USE32
3
4         ; eax: vertex ptr, edx: matrix ptr
5         global g3d_xform_
6 g3d_xform_:
7         push ebp
8         mov ebp, esp
9         sub esp, 12
10         push ebx
11         push esi
12         push edi
13
14         mov ebx, edx    ; matrix to ebx
15         mov edi, eax    ; vertex to edi
16
17 %macro MULROW 0
18         mov eax, [edi]          ; eax <- X
19         imul dword [ebx]
20         shrd eax, edx, 16
21         mov ecx, eax
22         mov eax, [edi + 4]      ; eax <- Y
23         imul dword [ebx + 4]
24         shrd eax, edx, 16
25         add ecx, eax
26         mov eax, [edi + 8]      ; eax <- Z
27         imul dword [ebx + 8]
28         shrd eax, edx, 16
29         add ecx, eax
30         mov eax, [edi + 12]     ; eax <- W
31         imul dword [ebx + 12]
32         shrd eax, edx, 16
33         add eax, ecx
34 %endmacro
35
36         MULROW
37         mov [ebp - 12], eax
38         add ebx, 16     ; next matrix row
39         MULROW
40         mov [ebp - 8], eax
41         add ebx, 16
42         MULROW
43         mov [ebp - 4], eax
44         add ebx, 16
45         MULROW
46         mov [edi + 12], eax     ; move W into place
47         ; move XYZ into place
48         lea esi, [ebp - 12]
49         movsd
50         movsd
51         movsd
52
53         pop edi
54         pop esi
55         pop ebx
56         mov esp, ebp
57         pop ebp
58         ret
59
60 ; vi:ft=nasm ts=8 sts=8 sw=8: