d_polysa.s 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. //
  16. // d_polysa.s
  17. // x86 assembly-language polygon model drawing code
  18. //
  19. #include "asm_i386.h"
  20. #include "quakeasm.h"
  21. #include "asm_draw.h"
  22. #include "d_ifacea.h"
  23. #if id386
  24. // !!! if this is changed, it must be changed in d_polyse.c too !!!
  25. #define DPS_MAXSPANS MAXHEIGHT+1
  26. // 1 extra for spanpackage that marks end
  27. //#define SPAN_SIZE (((DPS_MAXSPANS + 1 + ((CACHE_SIZE - 1) / spanpackage_t_size)) + 1) * spanpackage_t_size)
  28. #define SPAN_SIZE (1024+1+1+1)*32
  29. .data
  30. .align 4
  31. p10_minus_p20: .single 0
  32. p01_minus_p21: .single 0
  33. temp0: .single 0
  34. temp1: .single 0
  35. Ltemp: .single 0
  36. aff8entryvec_table: .long LDraw8, LDraw7, LDraw6, LDraw5
  37. .long LDraw4, LDraw3, LDraw2, LDraw1
  38. lzistepx: .long 0
  39. .text
  40. #ifndef NeXT
  41. .extern C(D_PolysetSetEdgeTable)
  42. .extern C(D_RasterizeAliasPolySmooth)
  43. #endif
  44. //----------------------------------------------------------------------
  45. // affine triangle gradient calculation code
  46. //----------------------------------------------------------------------
  47. #define skinwidth 4+0
  48. .globl C(D_PolysetCalcGradients)
  49. C(D_PolysetCalcGradients):
  50. // p00_minus_p20 = r_p0[0] - r_p2[0];
  51. // p01_minus_p21 = r_p0[1] - r_p2[1];
  52. // p10_minus_p20 = r_p1[0] - r_p2[0];
  53. // p11_minus_p21 = r_p1[1] - r_p2[1];
  54. //
  55. // xstepdenominv = 1.0 / (p10_minus_p20 * p01_minus_p21 -
  56. // p00_minus_p20 * p11_minus_p21);
  57. //
  58. // ystepdenominv = -xstepdenominv;
  59. fildl C(r_p0)+0 // r_p0[0]
  60. fildl C(r_p2)+0 // r_p2[0] | r_p0[0]
  61. fildl C(r_p0)+4 // r_p0[1] | r_p2[0] | r_p0[0]
  62. fildl C(r_p2)+4 // r_p2[1] | r_p0[1] | r_p2[0] | r_p0[0]
  63. fildl C(r_p1)+0 // r_p1[0] | r_p2[1] | r_p0[1] | r_p2[0] | r_p0[0]
  64. fildl C(r_p1)+4 // r_p1[1] | r_p1[0] | r_p2[1] | r_p0[1] |
  65. // r_p2[0] | r_p0[0]
  66. fxch %st(3) // r_p0[1] | r_p1[0] | r_p2[1] | r_p1[1] |
  67. // r_p2[0] | r_p0[0]
  68. fsub %st(2),%st(0) // p01_minus_p21 | r_p1[0] | r_p2[1] | r_p1[1] |
  69. // r_p2[0] | r_p0[0]
  70. fxch %st(1) // r_p1[0] | p01_minus_p21 | r_p2[1] | r_p1[1] |
  71. // r_p2[0] | r_p0[0]
  72. fsub %st(4),%st(0) // p10_minus_p20 | p01_minus_p21 | r_p2[1] |
  73. // r_p1[1] | r_p2[0] | r_p0[0]
  74. fxch %st(5) // r_p0[0] | p01_minus_p21 | r_p2[1] |
  75. // r_p1[1] | r_p2[0] | p10_minus_p20
  76. fsubp %st(0),%st(4) // p01_minus_p21 | r_p2[1] | r_p1[1] |
  77. // p00_minus_p20 | p10_minus_p20
  78. fxch %st(2) // r_p1[1] | r_p2[1] | p01_minus_p21 |
  79. // p00_minus_p20 | p10_minus_p20
  80. fsubp %st(0),%st(1) // p11_minus_p21 | p01_minus_p21 |
  81. // p00_minus_p20 | p10_minus_p20
  82. fxch %st(1) // p01_minus_p21 | p11_minus_p21 |
  83. // p00_minus_p20 | p10_minus_p20
  84. flds C(d_xdenom) // d_xdenom | p01_minus_p21 | p11_minus_p21 |
  85. // p00_minus_p20 | p10_minus_p20
  86. fxch %st(4) // p10_minus_p20 | p01_minus_p21 | p11_minus_p21 |
  87. // p00_minus_p20 | d_xdenom
  88. fstps p10_minus_p20 // p01_minus_p21 | p11_minus_p21 |
  89. // p00_minus_p20 | d_xdenom
  90. fstps p01_minus_p21 // p11_minus_p21 | p00_minus_p20 | xstepdenominv
  91. fxch %st(2) // xstepdenominv | p00_minus_p20 | p11_minus_p21
  92. //// ceil () for light so positive steps are exaggerated, negative steps
  93. //// diminished, pushing us away from underflow toward overflow. Underflow is
  94. //// very visible, overflow is very unlikely, because of ambient lighting
  95. // t0 = r_p0[4] - r_p2[4];
  96. // t1 = r_p1[4] - r_p2[4];
  97. fildl C(r_p2)+16 // r_p2[4] | xstepdenominv | p00_minus_p20 |
  98. // p11_minus_p21
  99. fildl C(r_p0)+16 // r_p0[4] | r_p2[4] | xstepdenominv |
  100. // p00_minus_p20 | p11_minus_p21
  101. fildl C(r_p1)+16 // r_p1[4] | r_p0[4] | r_p2[4] | xstepdenominv |
  102. // p00_minus_p20 | p11_minus_p21
  103. fxch %st(2) // r_p2[4] | r_p0[4] | r_p1[4] | xstepdenominv |
  104. // p00_minus_p20 | p11_minus_p21
  105. fld %st(0) // r_p2[4] | r_p2[4] | r_p0[4] | r_p1[4] |
  106. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  107. fsubrp %st(0),%st(2) // r_p2[4] | t0 | r_p1[4] | xstepdenominv |
  108. // p00_minus_p20 | p11_minus_p21
  109. fsubrp %st(0),%st(2) // t0 | t1 | xstepdenominv | p00_minus_p20 |
  110. // p11_minus_p21
  111. // r_lstepx = (int)
  112. // ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
  113. // r_lstepy = (int)
  114. // ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
  115. fld %st(0) // t0 | t0 | t1 | xstepdenominv | p00_minus_p20 |
  116. // p11_minus_p21
  117. fmul %st(5),%st(0) // t0*p11_minus_p21 | t0 | t1 | xstepdenominv |
  118. // p00_minus_p20 | p11_minus_p21
  119. fxch %st(2) // t1 | t0 | t0*p11_minus_p21 | xstepdenominv |
  120. // p00_minus_p20 | p11_minus_p21
  121. fld %st(0) // t1 | t1 | t0 | t0*p11_minus_p21 |
  122. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  123. fmuls p01_minus_p21 // t1*p01_minus_p21 | t1 | t0 | t0*p11_minus_p21 |
  124. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  125. fxch %st(2) // t0 | t1 | t1*p01_minus_p21 | t0*p11_minus_p21 |
  126. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  127. fmuls p10_minus_p20 // t0*p10_minus_p20 | t1 | t1*p01_minus_p21 |
  128. // t0*p11_minus_p21 | xstepdenominv |
  129. // p00_minus_p20 | p11_minus_p21
  130. fxch %st(1) // t1 | t0*p10_minus_p20 | t1*p01_minus_p21 |
  131. // t0*p11_minus_p21 | xstepdenominv |
  132. // p00_minus_p20 | p11_minus_p21
  133. fmul %st(5),%st(0) // t1*p00_minus_p20 | t0*p10_minus_p20 |
  134. // t1*p01_minus_p21 | t0*p11_minus_p21 |
  135. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  136. fxch %st(2) // t1*p01_minus_p21 | t0*p10_minus_p20 |
  137. // t1*p00_minus_p20 | t0*p11_minus_p21 |
  138. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  139. fsubp %st(0),%st(3) // t0*p10_minus_p20 | t1*p00_minus_p20 |
  140. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  141. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  142. fsubrp %st(0),%st(1) // t1*p00_minus_p20 - t0*p10_minus_p20 |
  143. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  144. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  145. fld %st(2) // xstepdenominv |
  146. // t1*p00_minus_p20 - t0*p10_minus_p20 |
  147. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  148. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  149. fmuls float_minus_1 // ystepdenominv |
  150. // t1*p00_minus_p20 - t0*p10_minus_p20 |
  151. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  152. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  153. fxch %st(2) // t1*p01_minus_p21 - t0*p11_minus_p21 |
  154. // t1*p00_minus_p20 - t0*p10_minus_p20 |
  155. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  156. // p11_minus_p21
  157. fmul %st(3),%st(0) // (t1*p01_minus_p21 - t0*p11_minus_p21)*
  158. // xstepdenominv |
  159. // t1*p00_minus_p20 - t0*p10_minus_p20 |
  160. // | ystepdenominv | xstepdenominv |
  161. // p00_minus_p20 | p11_minus_p21
  162. fxch %st(1) // t1*p00_minus_p20 - t0*p10_minus_p20 |
  163. // (t1*p01_minus_p21 - t0*p11_minus_p21)*
  164. // xstepdenominv | ystepdenominv |
  165. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  166. fmul %st(2),%st(0) // (t1*p00_minus_p20 - t0*p10_minus_p20)*
  167. // ystepdenominv |
  168. // (t1*p01_minus_p21 - t0*p11_minus_p21)*
  169. // xstepdenominv | ystepdenominv |
  170. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  171. fldcw ceil_cw
  172. fistpl C(r_lstepy) // r_lstepx | ystepdenominv | xstepdenominv |
  173. // p00_minus_p20 | p11_minus_p21
  174. fistpl C(r_lstepx) // ystepdenominv | xstepdenominv | p00_minus_p20 |
  175. // p11_minus_p21
  176. fldcw single_cw
  177. // t0 = r_p0[2] - r_p2[2];
  178. // t1 = r_p1[2] - r_p2[2];
  179. fildl C(r_p2)+8 // r_p2[2] | ystepdenominv | xstepdenominv |
  180. // p00_minus_p20 | p11_minus_p21
  181. fildl C(r_p0)+8 // r_p0[2] | r_p2[2] | ystepdenominv |
  182. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  183. fildl C(r_p1)+8 // r_p1[2] | r_p0[2] | r_p2[2] | ystepdenominv |
  184. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  185. fxch %st(2) // r_p2[2] | r_p0[2] | r_p1[2] | ystepdenominv |
  186. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  187. fld %st(0) // r_p2[2] | r_p2[2] | r_p0[2] | r_p1[2] |
  188. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  189. // p11_minus_p21
  190. fsubrp %st(0),%st(2) // r_p2[2] | t0 | r_p1[2] | ystepdenominv |
  191. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  192. fsubrp %st(0),%st(2) // t0 | t1 | ystepdenominv | xstepdenominv |
  193. // p00_minus_p20 | p11_minus_p21
  194. // r_sstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
  195. // xstepdenominv);
  196. // r_sstepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
  197. // ystepdenominv);
  198. fld %st(0) // t0 | t0 | t1 | ystepdenominv | xstepdenominv
  199. fmul %st(6),%st(0) // t0*p11_minus_p21 | t0 | t1 | ystepdenominv |
  200. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  201. fxch %st(2) // t1 | t0 | t0*p11_minus_p21 | ystepdenominv |
  202. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  203. fld %st(0) // t1 | t1 | t0 | t0*p11_minus_p21 |
  204. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  205. // p11_minus_p21
  206. fmuls p01_minus_p21 // t1*p01_minus_p21 | t1 | t0 | t0*p11_minus_p21 |
  207. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  208. // p11_minus_p21
  209. fxch %st(2) // t0 | t1 | t1*p01_minus_p21 | t0*p11_minus_p21 |
  210. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  211. // p11_minus_p21
  212. fmuls p10_minus_p20 // t0*p10_minus_p20 | t1 | t1*p01_minus_p21 |
  213. // t0*p11_minus_p21 | ystepdenominv |
  214. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  215. fxch %st(1) // t1 | t0*p10_minus_p20 | t1*p01_minus_p21 |
  216. // t0*p11_minus_p21 | ystepdenominv |
  217. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  218. fmul %st(6),%st(0) // t1*p00_minus_p20 | t0*p10_minus_p20 |
  219. // t1*p01_minus_p21 | t0*p11_minus_p21 |
  220. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  221. // p11_minus_p21
  222. fxch %st(2) // t1*p01_minus_p21 | t0*p10_minus_p20 |
  223. // t1*p00_minus_p20 | t0*p11_minus_p21 |
  224. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  225. // p11_minus_p21
  226. fsubp %st(0),%st(3) // t0*p10_minus_p20 | t1*p00_minus_p20 |
  227. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  228. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  229. // p11_minus_p21
  230. fsubrp %st(0),%st(1) // t1*p00_minus_p20 - t0*p10_minus_p20 |
  231. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  232. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  233. // p11_minus_p21
  234. fmul %st(2),%st(0) // (t1*p00_minus_p20 - t0*p10_minus_p20)*
  235. // ystepdenominv |
  236. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  237. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  238. // p11_minus_p21
  239. fxch %st(1) // t1*p01_minus_p21 - t0*p11_minus_p21 |
  240. // (t1*p00_minus_p20 - t0*p10_minus_p20)*
  241. // ystepdenominv | ystepdenominv |
  242. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  243. fmul %st(3),%st(0) // (t1*p01_minus_p21 - t0*p11_minus_p21)*
  244. // xstepdenominv |
  245. // (t1*p00_minus_p20 - t0*p10_minus_p20)*
  246. // ystepdenominv | ystepdenominv |
  247. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  248. fxch %st(1) // (t1*p00_minus_p20 - t0*p10_minus_p20)*
  249. // ystepdenominv |
  250. // (t1*p01_minus_p21 - t0*p11_minus_p21)*
  251. // xstepdenominv | ystepdenominv |
  252. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  253. fistpl C(r_sstepy) // r_sstepx | ystepdenominv | xstepdenominv |
  254. // p00_minus_p20 | p11_minus_p21
  255. fistpl C(r_sstepx) // ystepdenominv | xstepdenominv | p00_minus_p20 |
  256. // p11_minus_p21
  257. // t0 = r_p0[3] - r_p2[3];
  258. // t1 = r_p1[3] - r_p2[3];
  259. fildl C(r_p2)+12 // r_p2[3] | ystepdenominv | xstepdenominv |
  260. // p00_minus_p20 | p11_minus_p21
  261. fildl C(r_p0)+12 // r_p0[3] | r_p2[3] | ystepdenominv |
  262. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  263. fildl C(r_p1)+12 // r_p1[3] | r_p0[3] | r_p2[3] | ystepdenominv |
  264. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  265. fxch %st(2) // r_p2[3] | r_p0[3] | r_p1[3] | ystepdenominv |
  266. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  267. fld %st(0) // r_p2[3] | r_p2[3] | r_p0[3] | r_p1[3] |
  268. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  269. // p11_minus_p21
  270. fsubrp %st(0),%st(2) // r_p2[3] | t0 | r_p1[3] | ystepdenominv |
  271. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  272. fsubrp %st(0),%st(2) // t0 | t1 | ystepdenominv | xstepdenominv |
  273. // p00_minus_p20 | p11_minus_p21
  274. // r_tstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
  275. // xstepdenominv);
  276. // r_tstepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
  277. // ystepdenominv);
  278. fld %st(0) // t0 | t0 | t1 | ystepdenominv | xstepdenominv |
  279. // p00_minus_p20 | p11_minus_p21
  280. fmul %st(6),%st(0) // t0*p11_minus_p21 | t0 | t1 | ystepdenominv |
  281. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  282. fxch %st(2) // t1 | t0 | t0*p11_minus_p21 | ystepdenominv |
  283. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  284. fld %st(0) // t1 | t1 | t0 | t0*p11_minus_p21 |
  285. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  286. // p11_minus_p21
  287. fmuls p01_minus_p21 // t1*p01_minus_p21 | t1 | t0 | t0*p11_minus_p21 |
  288. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  289. // p11_minus_p21
  290. fxch %st(2) // t0 | t1 | t1*p01_minus_p21 | t0*p11_minus_p21 |
  291. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  292. // p11_minus_p21
  293. fmuls p10_minus_p20 // t0*p10_minus_p20 | t1 | t1*p01_minus_p21 |
  294. // t0*p11_minus_p21 | ystepdenominv |
  295. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  296. fxch %st(1) // t1 | t0*p10_minus_p20 | t1*p01_minus_p21 |
  297. // t0*p11_minus_p21 | ystepdenominv |
  298. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  299. fmul %st(6),%st(0) // t1*p00_minus_p20 | t0*p10_minus_p20 |
  300. // t1*p01_minus_p21 | t0*p11_minus_p21 |
  301. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  302. // p11_minus_p21
  303. fxch %st(2) // t1*p01_minus_p21 | t0*p10_minus_p20 |
  304. // t1*p00_minus_p20 | t0*p11_minus_p21 |
  305. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  306. // p11_minus_p21
  307. fsubp %st(0),%st(3) // t0*p10_minus_p20 | t1*p00_minus_p20 |
  308. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  309. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  310. // p11_minus_p21
  311. fsubrp %st(0),%st(1) // t1*p00_minus_p20 - t0*p10_minus_p20 |
  312. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  313. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  314. // p11_minus_p21
  315. fmul %st(2),%st(0) // (t1*p00_minus_p20 - t0*p10_minus_p20)*
  316. // ystepdenominv |
  317. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  318. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  319. // p11_minus_p21
  320. fxch %st(1) // t1*p01_minus_p21 - t0*p11_minus_p21 |
  321. // (t1*p00_minus_p20 - t0*p10_minus_p20)*
  322. // ystepdenominv | ystepdenominv |
  323. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  324. fmul %st(3),%st(0) // (t1*p01_minus_p21 - t0*p11_minus_p21)*
  325. // xstepdenominv |
  326. // (t1*p00_minus_p20 - t0*p10_minus_p20)*
  327. // ystepdenominv | ystepdenominv |
  328. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  329. fxch %st(1) // (t1*p00_minus_p20 - t0*p10_minus_p20)*
  330. // ystepdenominv |
  331. // (t1*p01_minus_p21 - t0*p11_minus_p21)*
  332. // xstepdenominv | ystepdenominv |
  333. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  334. fistpl C(r_tstepy) // r_tstepx | ystepdenominv | xstepdenominv |
  335. // p00_minus_p20 | p11_minus_p21
  336. fistpl C(r_tstepx) // ystepdenominv | xstepdenominv | p00_minus_p20 |
  337. // p11_minus_p21
  338. // t0 = r_p0[5] - r_p2[5];
  339. // t1 = r_p1[5] - r_p2[5];
  340. fildl C(r_p2)+20 // r_p2[5] | ystepdenominv | xstepdenominv |
  341. // p00_minus_p20 | p11_minus_p21
  342. fildl C(r_p0)+20 // r_p0[5] | r_p2[5] | ystepdenominv |
  343. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  344. fildl C(r_p1)+20 // r_p1[5] | r_p0[5] | r_p2[5] | ystepdenominv |
  345. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  346. fxch %st(2) // r_p2[5] | r_p0[5] | r_p1[5] | ystepdenominv |
  347. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  348. fld %st(0) // r_p2[5] | r_p2[5] | r_p0[5] | r_p1[5] |
  349. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  350. // p11_minus_p21
  351. fsubrp %st(0),%st(2) // r_p2[5] | t0 | r_p1[5] | ystepdenominv |
  352. // xstepdenominv | p00_minus_p20 | p11_minus_p21
  353. fsubrp %st(0),%st(2) // t0 | t1 | ystepdenominv | xstepdenominv |
  354. // p00_minus_p20 | p11_minus_p21
  355. // r_zistepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
  356. // xstepdenominv);
  357. // r_zistepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
  358. // ystepdenominv);
  359. fld %st(0) // t0 | t0 | t1 | ystepdenominv | xstepdenominv |
  360. // p00_minus_p20 | p11_minus_p21
  361. fmulp %st(0),%st(6) // t0 | t1 | ystepdenominv | xstepdenominv |
  362. // p00_minus_p20 | t0*p11_minus_p21
  363. fxch %st(1) // t1 | t0 | ystepdenominv | xstepdenominv |
  364. // p00_minus_p20 | t0*p11_minus_p21
  365. fld %st(0) // t1 | t1 | t0 | ystepdenominv | xstepdenominv |
  366. // p00_minus_p20 | t0*p11_minus_p21
  367. fmuls p01_minus_p21 // t1*p01_minus_p21 | t1 | t0 | ystepdenominv |
  368. // xstepdenominv | p00_minus_p20 |
  369. // t0*p11_minus_p21
  370. fxch %st(2) // t0 | t1 | t1*p01_minus_p21 | ystepdenominv |
  371. // xstepdenominv | p00_minus_p20 |
  372. // t0*p11_minus_p21
  373. fmuls p10_minus_p20 // t0*p10_minus_p20 | t1 | t1*p01_minus_p21 |
  374. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  375. // t0*p11_minus_p21
  376. fxch %st(1) // t1 | t0*p10_minus_p20 | t1*p01_minus_p21 |
  377. // ystepdenominv | xstepdenominv | p00_minus_p20 |
  378. // t0*p11_minus_p21
  379. fmulp %st(0),%st(5) // t0*p10_minus_p20 | t1*p01_minus_p21 |
  380. // ystepdenominv | xstepdenominv |
  381. // t1*p00_minus_p20 | t0*p11_minus_p21
  382. fxch %st(5) // t0*p11_minus_p21 | t1*p01_minus_p21 |
  383. // ystepdenominv | xstepdenominv |
  384. // t1*p00_minus_p20 | t0*p10_minus_p20
  385. fsubrp %st(0),%st(1) // t1*p01_minus_p21 - t0*p11_minus_p21 |
  386. // ystepdenominv | xstepdenominv |
  387. // t1*p00_minus_p20 | t0*p10_minus_p20
  388. fxch %st(3) // t1*p00_minus_p20 | ystepdenominv |
  389. // xstepdenominv |
  390. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  391. // t0*p10_minus_p20
  392. fsubp %st(0),%st(4) // ystepdenominv | xstepdenominv |
  393. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  394. // t1*p00_minus_p20 - t0*p10_minus_p20
  395. fxch %st(1) // xstepdenominv | ystepdenominv |
  396. // t1*p01_minus_p21 - t0*p11_minus_p21 |
  397. // t1*p00_minus_p20 - t0*p10_minus_p20
  398. fmulp %st(0),%st(2) // ystepdenominv |
  399. // (t1*p01_minus_p21 - t0*p11_minus_p21) *
  400. // xstepdenominv |
  401. // t1*p00_minus_p20 - t0*p10_minus_p20
  402. fmulp %st(0),%st(2) // (t1*p01_minus_p21 - t0*p11_minus_p21) *
  403. // xstepdenominv |
  404. // (t1*p00_minus_p20 - t0*p10_minus_p20) *
  405. // ystepdenominv
  406. fistpl C(r_zistepx) // (t1*p00_minus_p20 - t0*p10_minus_p20) *
  407. // ystepdenominv
  408. fistpl C(r_zistepy)
  409. // a_sstepxfrac = r_sstepx << 16;
  410. // a_tstepxfrac = r_tstepx << 16;
  411. //
  412. // a_ststepxwhole = r_affinetridesc.skinwidth * (r_tstepx >> 16) +
  413. // (r_sstepx >> 16);
  414. movl C(r_sstepx),%eax
  415. movl C(r_tstepx),%edx
  416. shll $16,%eax
  417. shll $16,%edx
  418. movl %eax,C(a_sstepxfrac)
  419. movl %edx,C(a_tstepxfrac)
  420. movl C(r_sstepx),%ecx
  421. movl C(r_tstepx),%eax
  422. sarl $16,%ecx
  423. sarl $16,%eax
  424. imull skinwidth(%esp)
  425. addl %ecx,%eax
  426. movl %eax,C(a_ststepxwhole)
  427. ret
  428. //----------------------------------------------------------------------
  429. // recursive subdivision affine triangle drawing code
  430. //
  431. // not C-callable because of stdcall return
  432. //----------------------------------------------------------------------
  433. #define lp1 4+16
  434. #define lp2 8+16
  435. #define lp3 12+16
  436. .globl C(D_PolysetRecursiveTriangle)
  437. C(D_PolysetRecursiveTriangle):
  438. pushl %ebp // preserve caller stack frame pointer
  439. pushl %esi // preserve register variables
  440. pushl %edi
  441. pushl %ebx
  442. // int *temp;
  443. // int d;
  444. // int new[6];
  445. // int i;
  446. // int z;
  447. // short *zbuf;
  448. movl lp2(%esp),%esi
  449. movl lp1(%esp),%ebx
  450. movl lp3(%esp),%edi
  451. // d = lp2[0] - lp1[0];
  452. // if (d < -1 || d > 1)
  453. // goto split;
  454. movl 0(%esi),%eax
  455. movl 0(%ebx),%edx
  456. movl 4(%esi),%ebp
  457. subl %edx,%eax
  458. movl 4(%ebx),%ecx
  459. subl %ecx,%ebp
  460. incl %eax
  461. cmpl $2,%eax
  462. ja LSplit
  463. // d = lp2[1] - lp1[1];
  464. // if (d < -1 || d > 1)
  465. // goto split;
  466. movl 0(%edi),%eax
  467. incl %ebp
  468. cmpl $2,%ebp
  469. ja LSplit
  470. // d = lp3[0] - lp2[0];
  471. // if (d < -1 || d > 1)
  472. // goto split2;
  473. movl 0(%esi),%edx
  474. movl 4(%edi),%ebp
  475. subl %edx,%eax
  476. movl 4(%esi),%ecx
  477. subl %ecx,%ebp
  478. incl %eax
  479. cmpl $2,%eax
  480. ja LSplit2
  481. // d = lp3[1] - lp2[1];
  482. // if (d < -1 || d > 1)
  483. // goto split2;
  484. movl 0(%ebx),%eax
  485. incl %ebp
  486. cmpl $2,%ebp
  487. ja LSplit2
  488. // d = lp1[0] - lp3[0];
  489. // if (d < -1 || d > 1)
  490. // goto split3;
  491. movl 0(%edi),%edx
  492. movl 4(%ebx),%ebp
  493. subl %edx,%eax
  494. movl 4(%edi),%ecx
  495. subl %ecx,%ebp
  496. incl %eax
  497. incl %ebp
  498. movl %ebx,%edx
  499. cmpl $2,%eax
  500. ja LSplit3
  501. // d = lp1[1] - lp3[1];
  502. // if (d < -1 || d > 1)
  503. // {
  504. //split3:
  505. // temp = lp1;
  506. // lp3 = lp2;
  507. // lp1 = lp3;
  508. // lp2 = temp;
  509. // goto split;
  510. // }
  511. //
  512. // return; // entire tri is filled
  513. //
  514. cmpl $2,%ebp
  515. jna LDone
  516. LSplit3:
  517. movl %edi,%ebx
  518. movl %esi,%edi
  519. movl %edx,%esi
  520. jmp LSplit
  521. //split2:
  522. LSplit2:
  523. // temp = lp1;
  524. // lp1 = lp2;
  525. // lp2 = lp3;
  526. // lp3 = temp;
  527. movl %ebx,%eax
  528. movl %esi,%ebx
  529. movl %edi,%esi
  530. movl %eax,%edi
  531. //split:
  532. LSplit:
  533. subl $24,%esp // allocate space for a new vertex
  534. //// split this edge
  535. // new[0] = (lp1[0] + lp2[0]) >> 1;
  536. // new[1] = (lp1[1] + lp2[1]) >> 1;
  537. // new[2] = (lp1[2] + lp2[2]) >> 1;
  538. // new[3] = (lp1[3] + lp2[3]) >> 1;
  539. // new[5] = (lp1[5] + lp2[5]) >> 1;
  540. movl 8(%ebx),%eax
  541. movl 8(%esi),%edx
  542. movl 12(%ebx),%ecx
  543. addl %edx,%eax
  544. movl 12(%esi),%edx
  545. sarl $1,%eax
  546. addl %edx,%ecx
  547. movl %eax,8(%esp)
  548. movl 20(%ebx),%eax
  549. sarl $1,%ecx
  550. movl 20(%esi),%edx
  551. movl %ecx,12(%esp)
  552. addl %edx,%eax
  553. movl 0(%ebx),%ecx
  554. movl 0(%esi),%edx
  555. sarl $1,%eax
  556. addl %ecx,%edx
  557. movl %eax,20(%esp)
  558. movl 4(%ebx),%eax
  559. sarl $1,%edx
  560. movl 4(%esi),%ebp
  561. movl %edx,0(%esp)
  562. addl %eax,%ebp
  563. sarl $1,%ebp
  564. movl %ebp,4(%esp)
  565. //// draw the point if splitting a leading edge
  566. // if (lp2[1] > lp1[1])
  567. // goto nodraw;
  568. cmpl %eax,4(%esi)
  569. jg LNoDraw
  570. // if ((lp2[1] == lp1[1]) && (lp2[0] < lp1[0]))
  571. // goto nodraw;
  572. movl 0(%esi),%edx
  573. jnz LDraw
  574. cmpl %ecx,%edx
  575. jl LNoDraw
  576. LDraw:
  577. // z = new[5] >> 16;
  578. movl 20(%esp),%edx
  579. movl 4(%esp),%ecx
  580. sarl $16,%edx
  581. movl 0(%esp),%ebp
  582. // zbuf = zspantable[new[1]] + new[0];
  583. movl C(zspantable)(,%ecx,4),%eax
  584. // if (z >= *zbuf)
  585. // {
  586. cmpw (%eax,%ebp,2),%dx
  587. jnge LNoDraw
  588. // int pix;
  589. //
  590. // *zbuf = z;
  591. movw %dx,(%eax,%ebp,2)
  592. // pix = d_pcolormap[skintable[new[3]>>16][new[2]>>16]];
  593. movl 12(%esp),%eax
  594. sarl $16,%eax
  595. movl 8(%esp),%edx
  596. sarl $16,%edx
  597. subl %ecx,%ecx
  598. movl C(skintable)(,%eax,4),%eax
  599. movl 4(%esp),%ebp
  600. movb (%eax,%edx,),%cl
  601. movl C(d_pcolormap),%edx
  602. movb (%edx,%ecx,),%dl
  603. movl 0(%esp),%ecx
  604. // d_viewbuffer[d_scantable[new[1]] + new[0]] = pix;
  605. movl C(d_scantable)(,%ebp,4),%eax
  606. addl %eax,%ecx
  607. movl C(d_viewbuffer),%eax
  608. movb %dl,(%eax,%ecx,1)
  609. // }
  610. //
  611. //nodraw:
  612. LNoDraw:
  613. //// recursively continue
  614. // D_PolysetRecursiveTriangle (lp3, lp1, new);
  615. pushl %esp
  616. pushl %ebx
  617. pushl %edi
  618. call C(D_PolysetRecursiveTriangle)
  619. // D_PolysetRecursiveTriangle (lp3, new, lp2);
  620. movl %esp,%ebx
  621. pushl %esi
  622. pushl %ebx
  623. pushl %edi
  624. call C(D_PolysetRecursiveTriangle)
  625. addl $24,%esp
  626. LDone:
  627. popl %ebx // restore register variables
  628. popl %edi
  629. popl %esi
  630. popl %ebp // restore caller stack frame pointer
  631. ret $12
  632. //----------------------------------------------------------------------
  633. // 8-bpp horizontal span drawing code for affine polygons, with smooth
  634. // shading and no transparency
  635. //----------------------------------------------------------------------
  636. #define pspans 4+8
  637. .globl C(D_PolysetAff8Start)
  638. C(D_PolysetAff8Start):
  639. .globl C(D_PolysetDrawSpans8)
  640. C(D_PolysetDrawSpans8):
  641. pushl %esi // preserve register variables
  642. pushl %ebx
  643. movl pspans(%esp),%esi // point to the first span descriptor
  644. movl C(r_zistepx),%ecx
  645. pushl %ebp // preserve caller's stack frame
  646. pushl %edi
  647. rorl $16,%ecx // put high 16 bits of 1/z step in low word
  648. movl spanpackage_t_count(%esi),%edx
  649. movl %ecx,lzistepx
  650. LSpanLoop:
  651. // lcount = d_aspancount - pspanpackage->count;
  652. //
  653. // errorterm += erroradjustup;
  654. // if (errorterm >= 0)
  655. // {
  656. // d_aspancount += d_countextrastep;
  657. // errorterm -= erroradjustdown;
  658. // }
  659. // else
  660. // {
  661. // d_aspancount += ubasestep;
  662. // }
  663. movl C(d_aspancount),%eax
  664. subl %edx,%eax
  665. movl C(erroradjustup),%edx
  666. movl C(errorterm),%ebx
  667. addl %edx,%ebx
  668. js LNoTurnover
  669. movl C(erroradjustdown),%edx
  670. movl C(d_countextrastep),%edi
  671. subl %edx,%ebx
  672. movl C(d_aspancount),%ebp
  673. movl %ebx,C(errorterm)
  674. addl %edi,%ebp
  675. movl %ebp,C(d_aspancount)
  676. jmp LRightEdgeStepped
  677. LNoTurnover:
  678. movl C(d_aspancount),%edi
  679. movl C(ubasestep),%edx
  680. movl %ebx,C(errorterm)
  681. addl %edx,%edi
  682. movl %edi,C(d_aspancount)
  683. LRightEdgeStepped:
  684. cmpl $1,%eax
  685. jl LNextSpan
  686. jz LExactlyOneLong
  687. //
  688. // set up advancetable
  689. //
  690. movl C(a_ststepxwhole),%ecx
  691. movl C(r_affinetridesc)+atd_skinwidth,%edx
  692. movl %ecx,advancetable+4 // advance base in t
  693. addl %edx,%ecx
  694. movl %ecx,advancetable // advance extra in t
  695. movl C(a_tstepxfrac),%ecx
  696. movw C(r_lstepx),%cx
  697. movl %eax,%edx // count
  698. movl %ecx,tstep
  699. addl $7,%edx
  700. shrl $3,%edx // count of full and partial loops
  701. movl spanpackage_t_sfrac(%esi),%ebx
  702. movw %dx,%bx
  703. movl spanpackage_t_pz(%esi),%ecx
  704. negl %eax
  705. movl spanpackage_t_pdest(%esi),%edi
  706. andl $7,%eax // 0->0, 1->7, 2->6, ... , 7->1
  707. subl %eax,%edi // compensate for hardwired offsets
  708. subl %eax,%ecx
  709. subl %eax,%ecx
  710. movl spanpackage_t_tfrac(%esi),%edx
  711. movw spanpackage_t_light(%esi),%dx
  712. movl spanpackage_t_zi(%esi),%ebp
  713. rorl $16,%ebp // put high 16 bits of 1/z in low word
  714. pushl %esi
  715. movl spanpackage_t_ptex(%esi),%esi
  716. jmp aff8entryvec_table(,%eax,4)
  717. // %bx = count of full and partial loops
  718. // %ebx high word = sfrac
  719. // %ecx = pz
  720. // %dx = light
  721. // %edx high word = tfrac
  722. // %esi = ptex
  723. // %edi = pdest
  724. // %ebp = 1/z
  725. // tstep low word = C(r_lstepx)
  726. // tstep high word = C(a_tstepxfrac)
  727. // C(a_sstepxfrac) low word = 0
  728. // C(a_sstepxfrac) high word = C(a_sstepxfrac)
  729. LDrawLoop:
  730. // FIXME: do we need to clamp light? We may need at least a buffer bit to
  731. // keep it from poking into tfrac and causing problems
  732. LDraw8:
  733. cmpw (%ecx),%bp
  734. jl Lp1
  735. xorl %eax,%eax
  736. movb %dh,%ah
  737. movb (%esi),%al
  738. movw %bp,(%ecx)
  739. movb 0x12345678(%eax),%al
  740. LPatch8:
  741. movb %al,(%edi)
  742. Lp1:
  743. addl tstep,%edx
  744. sbbl %eax,%eax
  745. addl lzistepx,%ebp
  746. adcl $0,%ebp
  747. addl C(a_sstepxfrac),%ebx
  748. adcl advancetable+4(,%eax,4),%esi
  749. LDraw7:
  750. cmpw 2(%ecx),%bp
  751. jl Lp2
  752. xorl %eax,%eax
  753. movb %dh,%ah
  754. movb (%esi),%al
  755. movw %bp,2(%ecx)
  756. movb 0x12345678(%eax),%al
  757. LPatch7:
  758. movb %al,1(%edi)
  759. Lp2:
  760. addl tstep,%edx
  761. sbbl %eax,%eax
  762. addl lzistepx,%ebp
  763. adcl $0,%ebp
  764. addl C(a_sstepxfrac),%ebx
  765. adcl advancetable+4(,%eax,4),%esi
  766. LDraw6:
  767. cmpw 4(%ecx),%bp
  768. jl Lp3
  769. xorl %eax,%eax
  770. movb %dh,%ah
  771. movb (%esi),%al
  772. movw %bp,4(%ecx)
  773. movb 0x12345678(%eax),%al
  774. LPatch6:
  775. movb %al,2(%edi)
  776. Lp3:
  777. addl tstep,%edx
  778. sbbl %eax,%eax
  779. addl lzistepx,%ebp
  780. adcl $0,%ebp
  781. addl C(a_sstepxfrac),%ebx
  782. adcl advancetable+4(,%eax,4),%esi
  783. LDraw5:
  784. cmpw 6(%ecx),%bp
  785. jl Lp4
  786. xorl %eax,%eax
  787. movb %dh,%ah
  788. movb (%esi),%al
  789. movw %bp,6(%ecx)
  790. movb 0x12345678(%eax),%al
  791. LPatch5:
  792. movb %al,3(%edi)
  793. Lp4:
  794. addl tstep,%edx
  795. sbbl %eax,%eax
  796. addl lzistepx,%ebp
  797. adcl $0,%ebp
  798. addl C(a_sstepxfrac),%ebx
  799. adcl advancetable+4(,%eax,4),%esi
  800. LDraw4:
  801. cmpw 8(%ecx),%bp
  802. jl Lp5
  803. xorl %eax,%eax
  804. movb %dh,%ah
  805. movb (%esi),%al
  806. movw %bp,8(%ecx)
  807. movb 0x12345678(%eax),%al
  808. LPatch4:
  809. movb %al,4(%edi)
  810. Lp5:
  811. addl tstep,%edx
  812. sbbl %eax,%eax
  813. addl lzistepx,%ebp
  814. adcl $0,%ebp
  815. addl C(a_sstepxfrac),%ebx
  816. adcl advancetable+4(,%eax,4),%esi
  817. LDraw3:
  818. cmpw 10(%ecx),%bp
  819. jl Lp6
  820. xorl %eax,%eax
  821. movb %dh,%ah
  822. movb (%esi),%al
  823. movw %bp,10(%ecx)
  824. movb 0x12345678(%eax),%al
  825. LPatch3:
  826. movb %al,5(%edi)
  827. Lp6:
  828. addl tstep,%edx
  829. sbbl %eax,%eax
  830. addl lzistepx,%ebp
  831. adcl $0,%ebp
  832. addl C(a_sstepxfrac),%ebx
  833. adcl advancetable+4(,%eax,4),%esi
  834. LDraw2:
  835. cmpw 12(%ecx),%bp
  836. jl Lp7
  837. xorl %eax,%eax
  838. movb %dh,%ah
  839. movb (%esi),%al
  840. movw %bp,12(%ecx)
  841. movb 0x12345678(%eax),%al
  842. LPatch2:
  843. movb %al,6(%edi)
  844. Lp7:
  845. addl tstep,%edx
  846. sbbl %eax,%eax
  847. addl lzistepx,%ebp
  848. adcl $0,%ebp
  849. addl C(a_sstepxfrac),%ebx
  850. adcl advancetable+4(,%eax,4),%esi
  851. LDraw1:
  852. cmpw 14(%ecx),%bp
  853. jl Lp8
  854. xorl %eax,%eax
  855. movb %dh,%ah
  856. movb (%esi),%al
  857. movw %bp,14(%ecx)
  858. movb 0x12345678(%eax),%al
  859. LPatch1:
  860. movb %al,7(%edi)
  861. Lp8:
  862. addl tstep,%edx
  863. sbbl %eax,%eax
  864. addl lzistepx,%ebp
  865. adcl $0,%ebp
  866. addl C(a_sstepxfrac),%ebx
  867. adcl advancetable+4(,%eax,4),%esi
  868. addl $8,%edi
  869. addl $16,%ecx
  870. decw %bx
  871. jnz LDrawLoop
  872. popl %esi // restore spans pointer
  873. LNextSpan:
  874. addl $(spanpackage_t_size),%esi // point to next span
  875. LNextSpanESISet:
  876. movl spanpackage_t_count(%esi),%edx
  877. cmpl $-999999,%edx // any more spans?
  878. jnz LSpanLoop // yes
  879. popl %edi
  880. popl %ebp // restore the caller's stack frame
  881. popl %ebx // restore register variables
  882. popl %esi
  883. ret
  884. // draw a one-long span
  885. LExactlyOneLong:
  886. movl spanpackage_t_pz(%esi),%ecx
  887. movl spanpackage_t_zi(%esi),%ebp
  888. rorl $16,%ebp // put high 16 bits of 1/z in low word
  889. movl spanpackage_t_ptex(%esi),%ebx
  890. cmpw (%ecx),%bp
  891. jl LNextSpan
  892. xorl %eax,%eax
  893. movl spanpackage_t_pdest(%esi),%edi
  894. movb spanpackage_t_light+1(%esi),%ah
  895. addl $(spanpackage_t_size),%esi // point to next span
  896. movb (%ebx),%al
  897. movw %bp,(%ecx)
  898. movb 0x12345678(%eax),%al
  899. LPatch9:
  900. movb %al,(%edi)
  901. jmp LNextSpanESISet
  902. .globl C(D_PolysetAff8End)
  903. C(D_PolysetAff8End):
  904. #define pcolormap 4
  905. .globl C(D_Aff8Patch)
  906. C(D_Aff8Patch):
  907. movl pcolormap(%esp),%eax
  908. movl %eax,LPatch1-4
  909. movl %eax,LPatch2-4
  910. movl %eax,LPatch3-4
  911. movl %eax,LPatch4-4
  912. movl %eax,LPatch5-4
  913. movl %eax,LPatch6-4
  914. movl %eax,LPatch7-4
  915. movl %eax,LPatch8-4
  916. movl %eax,LPatch9-4
  917. ret
  918. //----------------------------------------------------------------------
  919. // Alias model polygon dispatching code, combined with subdivided affine
  920. // triangle drawing code
  921. //----------------------------------------------------------------------
  922. .globl C(D_PolysetDraw)
  923. C(D_PolysetDraw):
  924. // spanpackage_t spans[DPS_MAXSPANS + 1 +
  925. // ((CACHE_SIZE - 1) / sizeof(spanpackage_t)) + 1];
  926. // // one extra because of cache line pretouching
  927. //
  928. // a_spans = (spanpackage_t *)
  929. // (((long)&spans[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
  930. subl $(SPAN_SIZE),%esp
  931. movl %esp,%eax
  932. addl $(CACHE_SIZE - 1),%eax
  933. andl $(~(CACHE_SIZE - 1)),%eax
  934. movl %eax,C(a_spans)
  935. // if (r_affinetridesc.drawtype)
  936. // D_DrawSubdiv ();
  937. // else
  938. // D_DrawNonSubdiv ();
  939. movl C(r_affinetridesc)+atd_drawtype,%eax
  940. testl %eax,%eax
  941. jz C(D_DrawNonSubdiv)
  942. pushl %ebp // preserve caller stack frame pointer
  943. // lnumtriangles = r_affinetridesc.numtriangles;
  944. movl C(r_affinetridesc)+atd_numtriangles,%ebp
  945. pushl %esi // preserve register variables
  946. shll $4,%ebp
  947. pushl %ebx
  948. // ptri = r_affinetridesc.ptriangles;
  949. movl C(r_affinetridesc)+atd_ptriangles,%ebx
  950. pushl %edi
  951. // mtriangle_t *ptri;
  952. // finalvert_t *pfv, *index0, *index1, *index2;
  953. // int i;
  954. // int lnumtriangles;
  955. // int s0, s1, s2;
  956. // pfv = r_affinetridesc.pfinalverts;
  957. movl C(r_affinetridesc)+atd_pfinalverts,%edi
  958. // for (i=0 ; i<lnumtriangles ; i++)
  959. // {
  960. Llooptop:
  961. // index0 = pfv + ptri[i].vertindex[0];
  962. // index1 = pfv + ptri[i].vertindex[1];
  963. // index2 = pfv + ptri[i].vertindex[2];
  964. movl mtri_vertindex-16+0(%ebx,%ebp,),%ecx
  965. movl mtri_vertindex-16+4(%ebx,%ebp,),%esi
  966. shll $(fv_shift),%ecx
  967. movl mtri_vertindex-16+8(%ebx,%ebp,),%edx
  968. shll $(fv_shift),%esi
  969. addl %edi,%ecx
  970. shll $(fv_shift),%edx
  971. addl %edi,%esi
  972. addl %edi,%edx
  973. // if (((index0->v[1]-index1->v[1]) *
  974. // (index0->v[0]-index2->v[0]) -
  975. // (index0->v[0]-index1->v[0])*(index0->v[1]-index2->v[1])) >= 0)
  976. // {
  977. // continue;
  978. // }
  979. //
  980. // d_pcolormap = &((byte *)acolormap)[index0->v[4] & 0xFF00];
  981. fildl fv_v+4(%ecx) // i0v1
  982. fildl fv_v+4(%esi) // i1v1 | i0v1
  983. fildl fv_v+0(%ecx) // i0v0 | i1v1 | i0v1
  984. fildl fv_v+0(%edx) // i2v0 | i0v0 | i1v1 | i0v1
  985. fxch %st(2) // i1v1 | i0v0 | i2v0 | i0v1
  986. fsubr %st(3),%st(0) // i0v1-i1v1 | i0v0 | i2v0 | i0v1
  987. fildl fv_v+0(%esi) // i1v0 | i0v1-i1v1 | i0v0 | i2v0 | i0v1
  988. fxch %st(2) // i0v0 | i0v1-i1v1 | i1v0 | i2v0 | i0v1
  989. fsub %st(0),%st(3) // i0v0 | i0v1-i1v1 | i1v0 | i0v0-i2v0 | i0v1
  990. fildl fv_v+4(%edx) // i2v1 | i0v0 | i0v1-i1v1 | i1v0 | i0v0-i2v0| i0v1
  991. fxch %st(1) // i0v0 | i2v1 | i0v1-i1v1 | i1v0 | i0v0-i2v0| i0v1
  992. fsubp %st(0),%st(3) // i2v1 | i0v1-i1v1 | i0v0-i1v0 | i0v0-i2v0 | i0v1
  993. fxch %st(1) // i0v1-i1v1 | i2v1 | i0v0-i1v0 | i0v0-i2v0 | i0v1
  994. fmulp %st(0),%st(3) // i2v1 | i0v0-i1v0 | i0v1-i1v1*i0v0-i2v0 | i0v1
  995. fsubrp %st(0),%st(3) // i0v0-i1v0 | i0v1-i1v1*i0v0-i2v0 | i0v1-i2v1
  996. movl fv_v+16(%ecx),%eax
  997. andl $0xFF00,%eax
  998. fmulp %st(0),%st(2) // i0v1-i1v1*i0v0-i2v0 | i0v0-i1v0*i0v1-i2v1
  999. addl C(acolormap),%eax
  1000. fsubp %st(0),%st(1) // (i0v1-i1v1)*(i0v0-i2v0)-(i0v0-i1v0)*(i0v1-i2v1)
  1001. movl %eax,C(d_pcolormap)
  1002. fstps Ltemp
  1003. movl Ltemp,%eax
  1004. subl $0x80000001,%eax
  1005. jc Lskip
  1006. // if (ptri[i].facesfront)
  1007. // {
  1008. // D_PolysetRecursiveTriangle(index0->v, index1->v, index2->v);
  1009. movl mtri_facesfront-16(%ebx,%ebp,),%eax
  1010. testl %eax,%eax
  1011. jz Lfacesback
  1012. pushl %edx
  1013. pushl %esi
  1014. pushl %ecx
  1015. call C(D_PolysetRecursiveTriangle)
  1016. subl $16,%ebp
  1017. jnz Llooptop
  1018. jmp Ldone2
  1019. // }
  1020. // else
  1021. // {
  1022. Lfacesback:
  1023. // s0 = index0->v[2];
  1024. // s1 = index1->v[2];
  1025. // s2 = index2->v[2];
  1026. movl fv_v+8(%ecx),%eax
  1027. pushl %eax
  1028. movl fv_v+8(%esi),%eax
  1029. pushl %eax
  1030. movl fv_v+8(%edx),%eax
  1031. pushl %eax
  1032. pushl %ecx
  1033. pushl %edx
  1034. // if (index0->flags & ALIAS_ONSEAM)
  1035. // index0->v[2] += r_affinetridesc.seamfixupX16;
  1036. movl C(r_affinetridesc)+atd_seamfixupX16,%eax
  1037. testl $(ALIAS_ONSEAM),fv_flags(%ecx)
  1038. jz Lp11
  1039. addl %eax,fv_v+8(%ecx)
  1040. Lp11:
  1041. // if (index1->flags & ALIAS_ONSEAM)
  1042. // index1->v[2] += r_affinetridesc.seamfixupX16;
  1043. testl $(ALIAS_ONSEAM),fv_flags(%esi)
  1044. jz Lp12
  1045. addl %eax,fv_v+8(%esi)
  1046. Lp12:
  1047. // if (index2->flags & ALIAS_ONSEAM)
  1048. // index2->v[2] += r_affinetridesc.seamfixupX16;
  1049. testl $(ALIAS_ONSEAM),fv_flags(%edx)
  1050. jz Lp13
  1051. addl %eax,fv_v+8(%edx)
  1052. Lp13:
  1053. // D_PolysetRecursiveTriangle(index0->v, index1->v, index2->v);
  1054. pushl %edx
  1055. pushl %esi
  1056. pushl %ecx
  1057. call C(D_PolysetRecursiveTriangle)
  1058. // index0->v[2] = s0;
  1059. // index1->v[2] = s1;
  1060. // index2->v[2] = s2;
  1061. popl %edx
  1062. popl %ecx
  1063. popl %eax
  1064. movl %eax,fv_v+8(%edx)
  1065. popl %eax
  1066. movl %eax,fv_v+8(%esi)
  1067. popl %eax
  1068. movl %eax,fv_v+8(%ecx)
  1069. // }
  1070. // }
  1071. Lskip:
  1072. subl $16,%ebp
  1073. jnz Llooptop
  1074. Ldone2:
  1075. popl %edi // restore the caller's stack frame
  1076. popl %ebx
  1077. popl %esi // restore register variables
  1078. popl %ebp
  1079. addl $(SPAN_SIZE),%esp
  1080. ret
  1081. //----------------------------------------------------------------------
  1082. // Alias model triangle left-edge scanning code
  1083. //----------------------------------------------------------------------
  1084. #define height 4+16
  1085. .globl C(D_PolysetScanLeftEdge)
  1086. C(D_PolysetScanLeftEdge):
  1087. pushl %ebp // preserve caller stack frame pointer
  1088. pushl %esi // preserve register variables
  1089. pushl %edi
  1090. pushl %ebx
  1091. movl height(%esp),%eax
  1092. movl C(d_sfrac),%ecx
  1093. andl $0xFFFF,%eax
  1094. movl C(d_ptex),%ebx
  1095. orl %eax,%ecx
  1096. movl C(d_pedgespanpackage),%esi
  1097. movl C(d_tfrac),%edx
  1098. movl C(d_light),%edi
  1099. movl C(d_zi),%ebp
  1100. // %eax: scratch
  1101. // %ebx: d_ptex
  1102. // %ecx: d_sfrac in high word, count in low word
  1103. // %edx: d_tfrac
  1104. // %esi: d_pedgespanpackage, errorterm, scratch alternately
  1105. // %edi: d_light
  1106. // %ebp: d_zi
  1107. // do
  1108. // {
  1109. LScanLoop:
  1110. // d_pedgespanpackage->ptex = ptex;
  1111. // d_pedgespanpackage->pdest = d_pdest;
  1112. // d_pedgespanpackage->pz = d_pz;
  1113. // d_pedgespanpackage->count = d_aspancount;
  1114. // d_pedgespanpackage->light = d_light;
  1115. // d_pedgespanpackage->zi = d_zi;
  1116. // d_pedgespanpackage->sfrac = d_sfrac << 16;
  1117. // d_pedgespanpackage->tfrac = d_tfrac << 16;
  1118. movl %ebx,spanpackage_t_ptex(%esi)
  1119. movl C(d_pdest),%eax
  1120. movl %eax,spanpackage_t_pdest(%esi)
  1121. movl C(d_pz),%eax
  1122. movl %eax,spanpackage_t_pz(%esi)
  1123. movl C(d_aspancount),%eax
  1124. movl %eax,spanpackage_t_count(%esi)
  1125. movl %edi,spanpackage_t_light(%esi)
  1126. movl %ebp,spanpackage_t_zi(%esi)
  1127. movl %ecx,spanpackage_t_sfrac(%esi)
  1128. movl %edx,spanpackage_t_tfrac(%esi)
  1129. // pretouch the next cache line
  1130. movb spanpackage_t_size(%esi),%al
  1131. // d_pedgespanpackage++;
  1132. addl $(spanpackage_t_size),%esi
  1133. movl C(erroradjustup),%eax
  1134. movl %esi,C(d_pedgespanpackage)
  1135. // errorterm += erroradjustup;
  1136. movl C(errorterm),%esi
  1137. addl %eax,%esi
  1138. movl C(d_pdest),%eax
  1139. // if (errorterm >= 0)
  1140. // {
  1141. js LNoLeftEdgeTurnover
  1142. // errorterm -= erroradjustdown;
  1143. // d_pdest += d_pdestextrastep;
  1144. subl C(erroradjustdown),%esi
  1145. addl C(d_pdestextrastep),%eax
  1146. movl %esi,C(errorterm)
  1147. movl %eax,C(d_pdest)
  1148. // d_pz += d_pzextrastep;
  1149. // d_aspancount += d_countextrastep;
  1150. // d_ptex += d_ptexextrastep;
  1151. // d_sfrac += d_sfracextrastep;
  1152. // d_ptex += d_sfrac >> 16;
  1153. // d_sfrac &= 0xFFFF;
  1154. // d_tfrac += d_tfracextrastep;
  1155. movl C(d_pz),%eax
  1156. movl C(d_aspancount),%esi
  1157. addl C(d_pzextrastep),%eax
  1158. addl C(d_sfracextrastep),%ecx
  1159. adcl C(d_ptexextrastep),%ebx
  1160. addl C(d_countextrastep),%esi
  1161. movl %eax,C(d_pz)
  1162. movl C(d_tfracextrastep),%eax
  1163. movl %esi,C(d_aspancount)
  1164. addl %eax,%edx
  1165. // if (d_tfrac & 0x10000)
  1166. // {
  1167. jnc LSkip1
  1168. // d_ptex += r_affinetridesc.skinwidth;
  1169. // d_tfrac &= 0xFFFF;
  1170. addl C(r_affinetridesc)+atd_skinwidth,%ebx
  1171. // }
  1172. LSkip1:
  1173. // d_light += d_lightextrastep;
  1174. // d_zi += d_ziextrastep;
  1175. addl C(d_lightextrastep),%edi
  1176. addl C(d_ziextrastep),%ebp
  1177. // }
  1178. movl C(d_pedgespanpackage),%esi
  1179. decl %ecx
  1180. testl $0xFFFF,%ecx
  1181. jnz LScanLoop
  1182. popl %ebx
  1183. popl %edi
  1184. popl %esi
  1185. popl %ebp
  1186. ret
  1187. // else
  1188. // {
  1189. LNoLeftEdgeTurnover:
  1190. movl %esi,C(errorterm)
  1191. // d_pdest += d_pdestbasestep;
  1192. addl C(d_pdestbasestep),%eax
  1193. movl %eax,C(d_pdest)
  1194. // d_pz += d_pzbasestep;
  1195. // d_aspancount += ubasestep;
  1196. // d_ptex += d_ptexbasestep;
  1197. // d_sfrac += d_sfracbasestep;
  1198. // d_ptex += d_sfrac >> 16;
  1199. // d_sfrac &= 0xFFFF;
  1200. movl C(d_pz),%eax
  1201. movl C(d_aspancount),%esi
  1202. addl C(d_pzbasestep),%eax
  1203. addl C(d_sfracbasestep),%ecx
  1204. adcl C(d_ptexbasestep),%ebx
  1205. addl C(ubasestep),%esi
  1206. movl %eax,C(d_pz)
  1207. movl %esi,C(d_aspancount)
  1208. // d_tfrac += d_tfracbasestep;
  1209. movl C(d_tfracbasestep),%esi
  1210. addl %esi,%edx
  1211. // if (d_tfrac & 0x10000)
  1212. // {
  1213. jnc LSkip2
  1214. // d_ptex += r_affinetridesc.skinwidth;
  1215. // d_tfrac &= 0xFFFF;
  1216. addl C(r_affinetridesc)+atd_skinwidth,%ebx
  1217. // }
  1218. LSkip2:
  1219. // d_light += d_lightbasestep;
  1220. // d_zi += d_zibasestep;
  1221. addl C(d_lightbasestep),%edi
  1222. addl C(d_zibasestep),%ebp
  1223. // }
  1224. // } while (--height);
  1225. movl C(d_pedgespanpackage),%esi
  1226. decl %ecx
  1227. testl $0xFFFF,%ecx
  1228. jnz LScanLoop
  1229. popl %ebx
  1230. popl %edi
  1231. popl %esi
  1232. popl %ebp
  1233. ret
  1234. //----------------------------------------------------------------------
  1235. // Alias model vertex drawing code
  1236. //----------------------------------------------------------------------
  1237. #define fv 4+8
  1238. #define numverts 8+8
  1239. .globl C(D_PolysetDrawFinalVerts)
  1240. C(D_PolysetDrawFinalVerts):
  1241. pushl %ebp // preserve caller stack frame pointer
  1242. pushl %ebx
  1243. // int i, z;
  1244. // short *zbuf;
  1245. movl numverts(%esp),%ecx
  1246. movl fv(%esp),%ebx
  1247. pushl %esi // preserve register variables
  1248. pushl %edi
  1249. LFVLoop:
  1250. // for (i=0 ; i<numverts ; i++, fv++)
  1251. // {
  1252. // // valid triangle coordinates for filling can include the bottom and
  1253. // // right clip edges, due to the fill rule; these shouldn't be drawn
  1254. // if ((fv->v[0] < r_refdef.vrectright) &&
  1255. // (fv->v[1] < r_refdef.vrectbottom))
  1256. // {
  1257. movl fv_v+0(%ebx),%eax
  1258. movl C(r_refdef)+rd_vrectright,%edx
  1259. cmpl %edx,%eax
  1260. jge LNextVert
  1261. movl fv_v+4(%ebx),%esi
  1262. movl C(r_refdef)+rd_vrectbottom,%edx
  1263. cmpl %edx,%esi
  1264. jge LNextVert
  1265. // zbuf = zspantable[fv->v[1]] + fv->v[0];
  1266. movl C(zspantable)(,%esi,4),%edi
  1267. // z = fv->v[5]>>16;
  1268. movl fv_v+20(%ebx),%edx
  1269. shrl $16,%edx
  1270. // if (z >= *zbuf)
  1271. // {
  1272. // int pix;
  1273. cmpw (%edi,%eax,2),%dx
  1274. jl LNextVert
  1275. // *zbuf = z;
  1276. movw %dx,(%edi,%eax,2)
  1277. // pix = skintable[fv->v[3]>>16][fv->v[2]>>16];
  1278. movl fv_v+12(%ebx),%edi
  1279. shrl $16,%edi
  1280. movl C(skintable)(,%edi,4),%edi
  1281. movl fv_v+8(%ebx),%edx
  1282. shrl $16,%edx
  1283. movb (%edi,%edx),%dl
  1284. // pix = ((byte *)acolormap)[pix + (fv->v[4] & 0xFF00)];
  1285. movl fv_v+16(%ebx),%edi
  1286. andl $0xFF00,%edi
  1287. andl $0x00FF,%edx
  1288. addl %edx,%edi
  1289. movl C(acolormap),%edx
  1290. movb (%edx,%edi,1),%dl
  1291. // d_viewbuffer[d_scantable[fv->v[1]] + fv->v[0]] = pix;
  1292. movl C(d_scantable)(,%esi,4),%edi
  1293. movl C(d_viewbuffer),%esi
  1294. addl %eax,%edi
  1295. movb %dl,(%esi,%edi)
  1296. // }
  1297. // }
  1298. // }
  1299. LNextVert:
  1300. addl $(fv_size),%ebx
  1301. decl %ecx
  1302. jnz LFVLoop
  1303. popl %edi
  1304. popl %esi
  1305. popl %ebx
  1306. popl %ebp
  1307. ret
  1308. //----------------------------------------------------------------------
  1309. // Alias model non-subdivided polygon dispatching code
  1310. //
  1311. // not C-callable because of stack buffer cleanup
  1312. //----------------------------------------------------------------------
  1313. .globl C(D_DrawNonSubdiv)
  1314. C(D_DrawNonSubdiv):
  1315. pushl %ebp // preserve caller stack frame pointer
  1316. movl C(r_affinetridesc)+atd_numtriangles,%ebp
  1317. pushl %ebx
  1318. shll $(mtri_shift),%ebp
  1319. pushl %esi // preserve register variables
  1320. movl C(r_affinetridesc)+atd_ptriangles,%esi
  1321. pushl %edi
  1322. // mtriangle_t *ptri;
  1323. // finalvert_t *pfv, *index0, *index1, *index2;
  1324. // int i;
  1325. // int lnumtriangles;
  1326. // pfv = r_affinetridesc.pfinalverts;
  1327. // ptri = r_affinetridesc.ptriangles;
  1328. // lnumtriangles = r_affinetridesc.numtriangles;
  1329. LNDLoop:
  1330. // for (i=0 ; i<lnumtriangles ; i++, ptri++)
  1331. // {
  1332. // index0 = pfv + ptri->vertindex[0];
  1333. // index1 = pfv + ptri->vertindex[1];
  1334. // index2 = pfv + ptri->vertindex[2];
  1335. movl C(r_affinetridesc)+atd_pfinalverts,%edi
  1336. movl mtri_vertindex+0-mtri_size(%esi,%ebp,1),%ecx
  1337. shll $(fv_shift),%ecx
  1338. movl mtri_vertindex+4-mtri_size(%esi,%ebp,1),%edx
  1339. shll $(fv_shift),%edx
  1340. movl mtri_vertindex+8-mtri_size(%esi,%ebp,1),%ebx
  1341. shll $(fv_shift),%ebx
  1342. addl %edi,%ecx
  1343. addl %edi,%edx
  1344. addl %edi,%ebx
  1345. // d_xdenom = (index0->v[1]-index1->v[1]) *
  1346. // (index0->v[0]-index2->v[0]) -
  1347. // (index0->v[0]-index1->v[0])*(index0->v[1]-index2->v[1]);
  1348. movl fv_v+4(%ecx),%eax
  1349. movl fv_v+0(%ecx),%esi
  1350. subl fv_v+4(%edx),%eax
  1351. subl fv_v+0(%ebx),%esi
  1352. imull %esi,%eax
  1353. movl fv_v+0(%ecx),%esi
  1354. movl fv_v+4(%ecx),%edi
  1355. subl fv_v+0(%edx),%esi
  1356. subl fv_v+4(%ebx),%edi
  1357. imull %esi,%edi
  1358. subl %edi,%eax
  1359. // if (d_xdenom >= 0)
  1360. // {
  1361. // continue;
  1362. jns LNextTri
  1363. // }
  1364. movl %eax,C(d_xdenom)
  1365. fildl C(d_xdenom)
  1366. // r_p0[0] = index0->v[0]; // u
  1367. // r_p0[1] = index0->v[1]; // v
  1368. // r_p0[2] = index0->v[2]; // s
  1369. // r_p0[3] = index0->v[3]; // t
  1370. // r_p0[4] = index0->v[4]; // light
  1371. // r_p0[5] = index0->v[5]; // iz
  1372. movl fv_v+0(%ecx),%eax
  1373. movl fv_v+4(%ecx),%esi
  1374. movl %eax,C(r_p0)+0
  1375. movl %esi,C(r_p0)+4
  1376. movl fv_v+8(%ecx),%eax
  1377. movl fv_v+12(%ecx),%esi
  1378. movl %eax,C(r_p0)+8
  1379. movl %esi,C(r_p0)+12
  1380. movl fv_v+16(%ecx),%eax
  1381. movl fv_v+20(%ecx),%esi
  1382. movl %eax,C(r_p0)+16
  1383. movl %esi,C(r_p0)+20
  1384. fdivrs float_1
  1385. // r_p1[0] = index1->v[0];
  1386. // r_p1[1] = index1->v[1];
  1387. // r_p1[2] = index1->v[2];
  1388. // r_p1[3] = index1->v[3];
  1389. // r_p1[4] = index1->v[4];
  1390. // r_p1[5] = index1->v[5];
  1391. movl fv_v+0(%edx),%eax
  1392. movl fv_v+4(%edx),%esi
  1393. movl %eax,C(r_p1)+0
  1394. movl %esi,C(r_p1)+4
  1395. movl fv_v+8(%edx),%eax
  1396. movl fv_v+12(%edx),%esi
  1397. movl %eax,C(r_p1)+8
  1398. movl %esi,C(r_p1)+12
  1399. movl fv_v+16(%edx),%eax
  1400. movl fv_v+20(%edx),%esi
  1401. movl %eax,C(r_p1)+16
  1402. movl %esi,C(r_p1)+20
  1403. // r_p2[0] = index2->v[0];
  1404. // r_p2[1] = index2->v[1];
  1405. // r_p2[2] = index2->v[2];
  1406. // r_p2[3] = index2->v[3];
  1407. // r_p2[4] = index2->v[4];
  1408. // r_p2[5] = index2->v[5];
  1409. movl fv_v+0(%ebx),%eax
  1410. movl fv_v+4(%ebx),%esi
  1411. movl %eax,C(r_p2)+0
  1412. movl %esi,C(r_p2)+4
  1413. movl fv_v+8(%ebx),%eax
  1414. movl fv_v+12(%ebx),%esi
  1415. movl %eax,C(r_p2)+8
  1416. movl %esi,C(r_p2)+12
  1417. movl fv_v+16(%ebx),%eax
  1418. movl fv_v+20(%ebx),%esi
  1419. movl %eax,C(r_p2)+16
  1420. movl C(r_affinetridesc)+atd_ptriangles,%edi
  1421. movl %esi,C(r_p2)+20
  1422. movl mtri_facesfront-mtri_size(%edi,%ebp,1),%eax
  1423. // if (!ptri->facesfront)
  1424. // {
  1425. testl %eax,%eax
  1426. jnz LFacesFront
  1427. // if (index0->flags & ALIAS_ONSEAM)
  1428. // r_p0[2] += r_affinetridesc.seamfixupX16;
  1429. movl fv_flags(%ecx),%eax
  1430. movl fv_flags(%edx),%esi
  1431. movl fv_flags(%ebx),%edi
  1432. testl $(ALIAS_ONSEAM),%eax
  1433. movl C(r_affinetridesc)+atd_seamfixupX16,%eax
  1434. jz LOnseamDone0
  1435. addl %eax,C(r_p0)+8
  1436. LOnseamDone0:
  1437. // if (index1->flags & ALIAS_ONSEAM)
  1438. // r_p1[2] += r_affinetridesc.seamfixupX16;
  1439. testl $(ALIAS_ONSEAM),%esi
  1440. jz LOnseamDone1
  1441. addl %eax,C(r_p1)+8
  1442. LOnseamDone1:
  1443. // if (index2->flags & ALIAS_ONSEAM)
  1444. // r_p2[2] += r_affinetridesc.seamfixupX16;
  1445. testl $(ALIAS_ONSEAM),%edi
  1446. jz LOnseamDone2
  1447. addl %eax,C(r_p2)+8
  1448. LOnseamDone2:
  1449. // }
  1450. LFacesFront:
  1451. fstps C(d_xdenom)
  1452. // D_PolysetSetEdgeTable ();
  1453. // D_RasterizeAliasPolySmooth ();
  1454. call C(D_PolysetSetEdgeTable)
  1455. call C(D_RasterizeAliasPolySmooth)
  1456. LNextTri:
  1457. movl C(r_affinetridesc)+atd_ptriangles,%esi
  1458. subl $16,%ebp
  1459. jnz LNDLoop
  1460. // }
  1461. popl %edi
  1462. popl %esi
  1463. popl %ebx
  1464. popl %ebp
  1465. addl $(SPAN_SIZE),%esp
  1466. ret
  1467. #endif // id386