home *** CD-ROM | disk | FTP | other *** search
/ The Equalizer BBS / equalizer-bbs-collection_2004.zip / equalizer-bbs-collection / DEMOSCENE-STUFF / INCOMSRC.ZIP / TEXTURE.INC < prev    next >
Text File  |  1995-03-03  |  8KB  |  410 lines

  1. ;
  2. ; incompatibility version
  3. ;
  4. ;The routine to fill a 4sided polygon with Texture
  5. ;!!! Modified for Texture !!! GS = Texture segment (128x128) !!!
  6. ;(C)oded by RoByMuS / ByTeaM   at   1-20-1995
  7. ;No clipping included, so be ware !!!
  8. ;!!! 80386 required !!!
  9. ;Input DS:SI -> X/Y (word) of all points...
  10. ;      ES    -> video segment (256x256 resolution)
  11. ;      DS:BX -> 4 byte -> colors of points (0-63)
  12. ;
  13. ;Usage: Set the input datas, then call near the Gouraud routine !!!
  14. ;
  15.  
  16. assume ds:code
  17.  
  18. TextureColorAdd db 0
  19.  
  20. .386
  21. jumps
  22.  
  23. MandelTexture:
  24. call HorizontalMandelTexture
  25. retn
  26.  
  27. Texture:
  28. call HorizontalTexture
  29. retn
  30.  
  31. horizontalMandelTexture:
  32. push ds si bx
  33. mov di,offset TextureXYArea
  34. mov cx,8
  35. CopyTextureXY1_:
  36. lodsw
  37. mov cs:[di],ax
  38. add di,2
  39. loop CopyTextureXY1_
  40. mov di,offset TextureColorArea
  41. mov cx,8
  42. CopyTextureColor1_:
  43. mov al,ds:[bx]
  44. mov cs:[di],al
  45. inc bx
  46. inc di
  47. loop CopyTextureColor1_
  48. ;
  49. ;then do the job...
  50. ;
  51. mov ax,cs
  52. mov ds,ax
  53. mov bp,offset Texture2Horizline
  54. call TexturePolygon
  55. pop bx si ds
  56. retn
  57.  
  58. HorizontalTexture:
  59. ;
  60. ;First copy original datas to internal area...
  61. ;
  62. push ds si bx
  63. mov di,offset TextureXYArea
  64. mov cx,8
  65. CopyTextureXY1:
  66. lodsw
  67. mov cs:[di],ax
  68. add di,2
  69. loop CopyTextureXY1
  70. mov di,offset TextureColorArea
  71. mov cx,8
  72. CopyTextureColor1:
  73. mov al,ds:[bx]
  74. mov cs:[di],al
  75. inc bx
  76. inc di
  77. loop CopyTextureColor1
  78. ;
  79. ;then do the job...
  80. ;
  81. mov ax,cs
  82. mov ds,ax
  83. mov bp,offset TextureHorizline
  84. call TexturePolygon
  85. pop bx si ds
  86. retn
  87.  
  88. TextureXYArea dw 2*4 dup (?)
  89. TextureColorArea db 8 dup (?)
  90.  
  91. TextureLeftArea:
  92. dw ?                 ;position in TextureXYArea
  93. dw ?                 ;position in TextureColorArea
  94. dd ?                 ;current x value * 65536
  95. dd ?                 ;add it to x value...
  96. dw ?                 ;current color value * 256
  97. dw ?                 ;add it to color...
  98. ;
  99. TextureLeftAdd dw -4    ;add it to TextureXYOfs/left
  100. TextureLeftColAdd dw -2 ;add it to TextureColorOfs/left
  101. TextureLeftColCmp dw -2 ;compare TextureColorOfs/left with this
  102. TextureLeftColRep dw 6  ;replace TextureColorOfs/left with this
  103. TextureLeftOfsRep dw 3*4;replace TextureXYOfs/left with this...
  104. ;
  105. dw ?,?                  ;secondary colors...
  106. ;
  107. TextureRightArea:
  108. dw ?                 ;position in TextureXYArea
  109. dw ?                 ;position in TextureColorArea
  110. dd ?                 ;current x value * 65536
  111. dd ?                 ;add it to x value...
  112. dw ?                 ;current color value * 256
  113. dw ?                 ;add it to color...
  114. ;
  115. dw 4
  116. dw 2
  117. dw 8
  118. dw 0
  119. dw 0
  120. ;
  121. dw ?,? ;2nd color...
  122.  
  123. TextureXYOfs equ word ptr ds:[bx+0]
  124. TextureColorOfs equ word ptr ds:[bx+2]
  125. TextureDwordX equ dword ptr ds:[bx+4]
  126. TextureWordX equ word ptr ds:[bx+6]
  127. TextureXAdd equ dword ptr ds:[bx+8]
  128. TextureCol equ word ptr ds:[bx+12]
  129. TextureColAdd equ word ptr ds:[bx+14]
  130. TextureAdd equ word ptr ds:[bx+16]
  131. TextureCol_Add equ word ptr ds:[bx+18]
  132. TextureColCmp equ word ptr ds:[bx+20]
  133. TextureColRep equ word ptr ds:[bx+22]
  134. TextureOfsRep equ word ptr ds:[bx+24]
  135. TextureCol_ equ word ptr ds:[bx+26]
  136. TextureColAdd_ equ word ptr ds:[bx+28]
  137. ;
  138. TextureXYOfs2 equ word ptr ds:[bx+0+30]
  139. TextureColorOfs2 equ word ptr ds:[bx+2+30]
  140. TextureDwordX2 equ dword ptr ds:[bx+4+30]
  141. TextureWordX2 equ word ptr ds:[bx+6+30]
  142. TextureXAdd2 equ dword ptr ds:[bx+8+30]
  143. TextureCol2 equ word ptr ds:[bx+12+30]
  144. TextureColAdd2 equ word ptr ds:[bx+14+30]
  145. TextureCol_2 equ word ptr ds:[bx+26+30]
  146. TextureColAdd_2 equ word ptr ds:[bx+28+30]
  147.  
  148. TextureGlobalY dw ?
  149. TextureMaximum dw ?
  150.  
  151. TexturePolygon:
  152. ;
  153. ;Select smallest and largest Y value...
  154. ;
  155. mov si,4
  156. xor di,di                         ;minimum
  157. mov bx,di                         ;maximum
  158. mov cx,3
  159. TextureSelect:
  160. mov ax,TextureXYArea[si+2]        ;Y Coord
  161. cmp ax,TextureXYArea[di+2]
  162. jae TextureNoMinimum
  163. mov di,si
  164. TextureNoMinimum:
  165. cmp ax,TextureXYArea[bx+2]
  166. jbe TextureNoMaximum
  167. mov bx,si
  168. TextureNoMaximum:
  169. add si,4
  170. loop TextureSelect
  171. mov cx,TextureXYArea[bx+2]
  172. mov ax,TextureXYArea[di+2]
  173. mov TextureGlobalY,ax
  174. sub cx,ax
  175. add cx,2     ;Looks better...
  176. push cx
  177. mov TextureMaximum,bx
  178. mov bx,offset TextureLeftArea
  179. mov TextureXYOfs,di
  180. mov TextureXYOfs2,di
  181. shr di,1                         ;/2
  182. mov TextureColorOfs,di
  183. mov TextureColorOfs2,di
  184. call InitTexture
  185. mov bx,offset TextureRightArea
  186. call InitTexture
  187. pop cx
  188. TextureMainCik:
  189. push cx
  190. mov bx,offset offset TextureLeftArea
  191. call bp            ;do the horizontal line...
  192. call DoTexture
  193. mov bx,offset offset TextureRightArea
  194. call DoTexture
  195. inc TextureGlobalY
  196. pop cx
  197. loop TextureMainCik
  198. retn
  199.  
  200. InitTexture:
  201. mov si,TextureXYOfs
  202. mov di,TextureColorOfs
  203. movzx eax,word ptr TextureXYArea[si]
  204. movzx edx,word ptr TextureXYArea[si+2]
  205. shl eax,16
  206. mov TextureDwordX,eax
  207. movzx cx,byte ptr TextureColorArea[di]
  208. shl cx,7
  209. mov TextureCol,cx
  210. movzx cx,byte ptr TextureColorArea[di+1]
  211. shl cx,7
  212. mov TextureCol_,cx
  213. ;
  214. ;get next...
  215. ;
  216. add si,TextureAdd
  217. add di,TextureCol_Add
  218. cmp di,TextureColCmp
  219. jne NoReplaceTexture
  220. mov si,TextureOfsRep
  221. mov di,TextureColRep
  222. NoReplaceTexture:
  223. ;
  224. push edx
  225. movzx edx,word ptr TextureXYArea[si]
  226. shl edx,16
  227. sub eax,edx
  228. ;
  229. movzx edx,word ptr TextureXYArea[si+2]
  230. pop ecx
  231. sub ecx,edx
  232. jecxz DontDivTexture
  233. cdq
  234. idiv ecx       ;-X / -Y = X/Y
  235. DontDivTexture:
  236. mov TextureXAdd,eax
  237. mov ax,TextureCol
  238. mov dl,TextureColorArea[di]
  239. xor dh,dh
  240. shl dx,7
  241. sub ax,dx
  242. jecxz DontDivTexture2
  243. cwde
  244. cdq
  245. idiv ecx
  246. DontDivTexture2:
  247. mov TextureColAdd,ax
  248. ;
  249. mov ax,TextureCol_
  250. mov dl,TextureColorArea[di+1]
  251. xor dh,dh
  252. shl dx,7
  253. sub ax,dx
  254. jecxz DontDivTexture3
  255. cwde
  256. cdq
  257. idiv ecx
  258. DontDivTexture3:
  259. mov TextureColAdd_,ax
  260. ;
  261. mov TextureXYOfs,si
  262. mov TextureColorOfs,di
  263. retn
  264.  
  265. DoTexture:
  266. mov si,TextureXYOfs
  267. mov ax,TextureGlobalY
  268. cmp ax,TextureXYArea[si+2]
  269. jb NoInitTextureNeeded
  270. call InitTexture
  271. retn
  272. NoInitTextureNeeded:
  273. mov eax,TextureXAdd
  274. add TextureDwordX,eax
  275. mov ax,TextureColadd
  276. add TextureCol,ax
  277. mov ax,TextureColadd_
  278. add TextureCol_,ax
  279. retn
  280.  
  281. TextureHorizline:
  282. ;
  283. ;Now it's idle...
  284. ;
  285. push TextureCol_ TextureCol_2
  286. push TextureCol TextureCol2
  287. mov ax,TextureWordX
  288. mov cx,TextureWordX2
  289. sub cx,ax
  290. jnc TextureNoSwap
  291. neg cx
  292. mov ax,TextureCol
  293. xchg ax,TextureCol2
  294. mov TextureCol,ax
  295. mov ax,TextureCol_
  296. xchg ax,TextureCol_2
  297. mov TextureCol_,ax
  298. mov ax,TextureWordX2
  299. TextureNoSwap:
  300. mov ah,byte ptr TextureGlobalY
  301. mov di,ax
  302. mov ax,TextureCol2
  303. sub ax,TextureCol
  304. jcxz TextureNoDiv
  305. cwd
  306. idiv cx
  307. TextureNoDiv:
  308. mov Textureadd1,ax
  309. mov ax,TextureCol
  310. mov Textureval1,ax
  311. ;
  312. mov ax,TextureCol_2
  313. sub ax,TextureCol_
  314. jcxz TextureNoDiv2
  315. cwd
  316. idiv cx
  317. TextureNoDiv2:
  318. mov Textureadd2,ax
  319. mov ax,TextureCol_
  320. mov Textureval2,ax
  321. ;
  322. inc cx
  323. TextureHorizCik:
  324. mov ax,Textureval1
  325. and ax,not 7fh         ;y coord
  326. mov si,Textureval2
  327. shr si,7               ;x coord
  328. add si,ax
  329. mov al,gs:[si]
  330. add al,cs:TextureColorAdd
  331. stosb
  332. mov ax,Textureadd1
  333. add Textureval1,ax
  334. mov ax,Textureadd2
  335. add Textureval2,ax
  336. loop TextureHorizCik
  337. pop TextureCol2 TextureCol
  338. pop TextureCol_2 TextureCol_
  339. retn
  340.  
  341. Textureadd1 dw ?
  342. Textureadd2 dw ?
  343. Textureval1 dw ?
  344. Textureval2 dw ?
  345.  
  346. Texture2Horizline:
  347. ;
  348. ;Now it's idle...
  349. ;
  350. push TextureCol_ TextureCol_2
  351. push TextureCol TextureCol2
  352. mov ax,TextureWordX
  353. mov cx,TextureWordX2
  354. sub cx,ax
  355. jnc TextureNoSwap_
  356. neg cx
  357. mov ax,TextureCol
  358. xchg ax,TextureCol2
  359. mov TextureCol,ax
  360. mov ax,TextureCol_
  361. xchg ax,TextureCol_2
  362. mov TextureCol_,ax
  363. mov ax,TextureWordX2
  364. TextureNoSwap_:
  365. mov ah,byte ptr TextureGlobalY
  366. mov di,ax
  367. mov ax,TextureCol2
  368. sub ax,TextureCol
  369. jcxz TextureNoDiv_
  370. cwd
  371. idiv cx
  372. TextureNoDiv_:
  373. mov Textureadd1,ax
  374. mov ax,TextureCol
  375. mov Textureval1,ax
  376. ;
  377. mov ax,TextureCol_2
  378. sub ax,TextureCol_
  379. jcxz TextureNoDiv2_
  380. cwd
  381. idiv cx
  382. TextureNoDiv2_:
  383. mov Textureadd2,ax
  384. mov ax,TextureCol_
  385. mov Textureval2,ax
  386. ;
  387. inc cx
  388. TextureHorizCik_:
  389. mov ax,Textureval1
  390. and ax,not 7fh         ;y coord
  391. mov si,Textureval2
  392. shr si,7               ;x coord
  393. add si,ax
  394. mov al,gs:[si]
  395. test al,31
  396. jz texture_noput_
  397. mov es:[di],al
  398. texture_noput_:
  399. inc di
  400. mov ax,Textureadd1
  401. add Textureval1,ax
  402. mov ax,Textureadd2
  403. add Textureval2,ax
  404. loop TextureHorizCik_
  405. pop TextureCol2 TextureCol
  406. pop TextureCol_2 TextureCol_
  407. retn
  408.  
  409. assume ds:data1
  410.