8147e7aff9b5331c0a0db55eaa2bf449514f4f96
[dos_low3d] / src / 3dgfx_s.asm
1         bits 32
2         section .text
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, 8
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         mov ecx, eax
21         mov eax, [edi + 4]      ; eax <- Y
22         imul dword [ebx + 4]
23         add ecx, eax
24         mov eax, [edi + 8]      ; eax <- Z
25         imul dword [ebx + 8]
26         add ecx, eax
27         mov eax, [edi + 12]     ; eax <- W
28         imul dword [ebx + 12]
29         add eax, ecx
30 %endmacro
31
32         MULROW
33         mov [ebp - 12], eax
34         add ebx, 16     ; next matrix row
35         MULROW
36         mov [ebp - 8], eax
37         add ebx, 16
38         MULROW
39         mov [ebp - 4], eax
40         add ebx, 16
41         MULROW
42         mov [edi + 12], eax     ; move W into place
43         ; move XYZ into place
44         mov esi, [ebp - 12]
45         movsd
46         movsd
47         movsd
48
49         pop edi
50         pop esi
51         pop ebx
52         mov esp, ebp
53         pop ebp
54         ret