1/* 2Copyright (C) 1996-1997 Id Software, Inc. 3 4This program is free software; you can redistribute it and/or 5modify it under the terms of the GNU General Public License 6as published by the Free Software Foundation; either version 2 7of the License, or (at your option) any later version. 8 9This program is distributed in the hope that it will be useful, 10but WITHOUT ANY WARRANTY; without even the implied warranty of 11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 13See the GNU General Public License for more details. 14 15You should have received a copy of the GNU General Public License 16along with this program; if not, write to the Free Software 17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19*/ 20// 21// r_aliasa.s 22// x86 assembly-language Alias model transform and project code. 23// 24 25#include "asm_i386.h" 26#include "quakeasm.h" 27#include "asm_draw.h" 28#include "d_ifacea.h" 29 30#if id386 31 32 .data 33Ltemp0: .long 0 34Ltemp1: .long 0 35 36 .text 37 38#define pfv0 8+4 39#define pfv1 8+8 40#define out 8+12 41 42.globl C(R_Alias_clip_bottom) 43C(R_Alias_clip_bottom): 44 pushl %esi 45 pushl %edi 46 47 movl pfv0(%esp),%esi 48 movl pfv1(%esp),%edi 49 50 movl C(r_refdef)+rd_aliasvrectbottom,%eax 51 52LDoForwardOrBackward: 53 54 movl fv_v+4(%esi),%edx 55 movl fv_v+4(%edi),%ecx 56 57 cmpl %ecx,%edx 58 jl LDoForward 59 60 movl fv_v+4(%esi),%ecx 61 movl fv_v+4(%edi),%edx 62 movl pfv0(%esp),%edi 63 movl pfv1(%esp),%esi 64 65LDoForward: 66 67 subl %edx,%ecx 68 subl %edx,%eax 69 movl %ecx,Ltemp1 70 movl %eax,Ltemp0 71 fildl Ltemp1 72 fildl Ltemp0 73 movl out(%esp),%edx 74 movl $2,%eax 75 76 fdivp %st(0),%st(1) // scale 77 78LDo3Forward: 79 fildl fv_v+0(%esi) // fv0v0 | scale 80 fildl fv_v+0(%edi) // fv1v0 | fv0v0 | scale 81 fildl fv_v+4(%esi) // fv0v1 | fv1v0 | fv0v0 | scale 82 fildl fv_v+4(%edi) // fv1v1 | fv0v1 | fv1v0 | fv0v0 | scale 83 fildl fv_v+8(%esi) // fv0v2 | fv1v1 | fv0v1 | fv1v0 | fv0v0 | scale 84 fildl fv_v+8(%edi) // fv1v2 | fv0v2 | fv1v1 | fv0v1 | fv1v0 | fv0v0 | 85 // scale 86 fxch %st(5) // fv0v0 | fv0v2 | fv1v1 | fv0v1 | fv1v0 | fv1v2 | 87 // scale 88 fsubr %st(0),%st(4) // fv0v0 | fv0v2 | fv1v1 | fv0v1 | fv1v0-fv0v0 | 89 // fv1v2 | scale 90 fxch %st(3) // fv0v1 | fv0v2 | fv1v1 | fv0v0 | fv1v0-fv0v0 | 91 // fv1v2 | scale 92 fsubr %st(0),%st(2) // fv0v1 | fv0v2 | fv1v1-fv0v1 | fv0v0 | 93 // fv1v0-fv0v0 | fv1v2 | scale 94 fxch %st(1) // fv0v2 | fv0v1 | fv1v1-fv0v1 | fv0v0 | 95 // fv1v0-fv0v0 | fv1v2 | scale 96 fsubr %st(0),%st(5) // fv0v2 | fv0v1 | fv1v1-fv0v1 | fv0v0 | 97 // fv1v0-fv0v0 | fv1v2-fv0v2 | scale 98 fxch %st(6) // scale | fv0v1 | fv1v1-fv0v1 | fv0v0 | 99 // fv1v0-fv0v0 | fv1v2-fv0v2 | fv0v2 100 fmul %st(0),%st(4) // scale | fv0v1 | fv1v1-fv0v1 | fv0v0 | 101 // (fv1v0-fv0v0)*scale | fv1v2-fv0v2 | fv0v2 102 addl $12,%edi 103 fmul %st(0),%st(2) // scale | fv0v1 | (fv1v1-fv0v1)*scale | fv0v0 | 104 // (fv1v0-fv0v0)*scale | fv1v2-fv0v2 | fv0v2 105 addl $12,%esi 106 addl $12,%edx 107 fmul %st(0),%st(5) // scale | fv0v1 | (fv1v1-fv0v1)*scale | fv0v0 | 108 // (fv1v0-fv0v0)*scale | (fv1v2-fv0v2)*scale | 109 // fv0v2 110 fxch %st(3) // fv0v0 | fv0v1 | (fv1v1-fv0v1)*scale | scale | 111 // (fv1v0-fv0v0)*scale | (fv1v2-fv0v2)*scale | 112 // fv0v2 113 faddp %st(0),%st(4) // fv0v1 | (fv1v1-fv0v1)*scale | scale | 114 // fv0v0+(fv1v0-fv0v0)*scale | 115 // (fv1v2-fv0v2)*scale | fv0v2 116 faddp %st(0),%st(1) // fv0v1+(fv1v1-fv0v1)*scale | scale | 117 // fv0v0+(fv1v0-fv0v0)*scale | 118 // (fv1v2-fv0v2)*scale | fv0v2 119 fxch %st(4) // fv0v2 | scale | fv0v0+(fv1v0-fv0v0)*scale | 120 // (fv1v2-fv0v2)*scale | fv0v1+(fv1v1-fv0v1)*scale 121 faddp %st(0),%st(3) // scale | fv0v0+(fv1v0-fv0v0)*scale | 122 // fv0v2+(fv1v2-fv0v2)*scale | 123 // fv0v1+(fv1v1-fv0v1)*scale 124 fxch %st(1) // fv0v0+(fv1v0-fv0v0)*scale | scale | 125 // fv0v2+(fv1v2-fv0v2)*scale | 126 // fv0v1+(fv1v1-fv0v1)*scale 127 fadds float_point5 128 fxch %st(3) // fv0v1+(fv1v1-fv0v1)*scale | scale | 129 // fv0v2+(fv1v2-fv0v2)*scale | 130 // fv0v0+(fv1v0-fv0v0)*scale 131 fadds float_point5 132 fxch %st(2) // fv0v2+(fv1v2-fv0v2)*scale | scale | 133 // fv0v1+(fv1v1-fv0v1)*scale | 134 // fv0v0+(fv1v0-fv0v0)*scale 135 fadds float_point5 136 fxch %st(3) // fv0v0+(fv1v0-fv0v0)*scale | scale | 137 // fv0v1+(fv1v1-fv0v1)*scale | 138 // fv0v2+(fv1v2-fv0v2)*scale 139 fistpl fv_v+0-12(%edx) // scale | fv0v1+(fv1v1-fv0v1)*scale | 140 // fv0v2+(fv1v2-fv0v2)*scale 141 fxch %st(1) // fv0v1+(fv1v1-fv0v1)*scale | scale | 142 // fv0v2+(fv1v2-fv0v2)*scale | scale 143 fistpl fv_v+4-12(%edx) // scale | fv0v2+(fv1v2-fv0v2)*scale 144 fxch %st(1) // fv0v2+(fv1v2-fv0v2)*sc | scale 145 fistpl fv_v+8-12(%edx) // scale 146 147 decl %eax 148 jnz LDo3Forward 149 150 fstp %st(0) 151 152 popl %edi 153 popl %esi 154 155 ret 156 157 158.globl C(R_Alias_clip_top) 159C(R_Alias_clip_top): 160 pushl %esi 161 pushl %edi 162 163 movl pfv0(%esp),%esi 164 movl pfv1(%esp),%edi 165 166 movl C(r_refdef)+rd_aliasvrect+4,%eax 167 jmp LDoForwardOrBackward 168 169 170 171.globl C(R_Alias_clip_right) 172C(R_Alias_clip_right): 173 pushl %esi 174 pushl %edi 175 176 movl pfv0(%esp),%esi 177 movl pfv1(%esp),%edi 178 179 movl C(r_refdef)+rd_aliasvrectright,%eax 180 181LRightLeftEntry: 182 183 184 movl fv_v+4(%esi),%edx 185 movl fv_v+4(%edi),%ecx 186 187 cmpl %ecx,%edx 188 movl fv_v+0(%esi),%edx 189 190 movl fv_v+0(%edi),%ecx 191 jl LDoForward2 192 193 movl fv_v+0(%esi),%ecx 194 movl fv_v+0(%edi),%edx 195 movl pfv0(%esp),%edi 196 movl pfv1(%esp),%esi 197 198LDoForward2: 199 200 jmp LDoForward 201 202 203.globl C(R_Alias_clip_left) 204C(R_Alias_clip_left): 205 pushl %esi 206 pushl %edi 207 208 movl pfv0(%esp),%esi 209 movl pfv1(%esp),%edi 210 211 movl C(r_refdef)+rd_aliasvrect+0,%eax 212 jmp LRightLeftEntry 213 214 215#endif // id386 216 217