home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / placesrc / pallo.asm < prev    next >
Assembly Source File  |  1995-03-13  |  23KB  |  905 lines

  1. ; COURTESY OF JMAGlC of COMPLEX (jmagic@freenet.hut.fi)
  2. ; ============================================================================
  3.  
  4.         ideal
  5.         jumps
  6.         model small
  7.  
  8. Extrn   flatman:Far
  9.  
  10.         stack 100h
  11.         codeseg
  12.         p486
  13.  
  14. rowmu    = 2
  15. y_max    = 200*2/(rowmu+1) ; 200*2/(rowmu+1)
  16. pagez    = 60
  17. veny     = (y_max/pagez)+1
  18. if veny eq 0
  19. veny = 1
  20. endif
  21. pagesh   = 200*y_max
  22. x_max    = 320
  23. x_center = 4*24 ; x_max/2
  24. y_center = (y_max)/2 ; 70*2/(rowmu+1)  ; y_max/2
  25.  
  26. ;x_scale  = 2310
  27. ;y_scale  = 2310*2/(rowmu+1)
  28.  
  29. points  = 8
  30.  
  31. include 'sintbl.dw'
  32.  
  33. xmsaddress dd 0
  34. scrnofs dd 0
  35. rotx    dw 0
  36. roty    dw 512
  37. rotz    dw 0
  38. tx      dw 0
  39. ty      dw 0
  40. tz      dw 18300 ; 10240  +256*13
  41.  
  42. holoholo        dw 0
  43.  
  44. stylero dw 0
  45.  
  46. ;============================================================================
  47. pol_l           dw 256 dup (0)  ; polygon left  edge
  48. pol_r           dw 256 dup (0)  ; polygon right edge
  49. texture_l       dw 256 dup (0)  ; polygon left  edge texture pos
  50. texture_r       dw 256 dup (0)  ; polygon right edge texture pos
  51. delta_x         dw 0            ; x2-x1
  52. delta_y         dw 0            ; y2-y1
  53.  
  54. _x1     dw 0
  55. _y1     dw 0
  56.  
  57. label _t1 word
  58. _tx1    db 0
  59. _ty1    db 0
  60.  
  61. _txd    dw 0
  62. _tyd    dw 0
  63.  
  64. fixed_low       dw 0
  65. fixed_high      dw 0
  66.  
  67. tf_addx dw 0
  68. tf_addy dw 0
  69.  
  70. tex_lo  dw 0
  71. tex_hi  dw 0
  72.  
  73. sxa     dd 0
  74. sya     dd 0
  75.  
  76. looprow dw 0
  77. loopti  dw 0
  78.  
  79. label edgemark word
  80.         db 0
  81. tbl     db 0    ; 0=left, 1=right side
  82.  
  83. stacko  dw 0    ; sp save
  84.  
  85. label   PolyCords word
  86.         dw 4*2 dup (0)
  87.  
  88. label   TextureCords byte
  89.         db   1, 1
  90.         db  64, 1
  91.         db  64, 64
  92.         db   1, 64
  93.  
  94. textureseg      dw 0
  95.  
  96. macro   line p1, p2
  97. local @@hoilaa, @@noswap, @@1, @@2, @@fryit, @@draw16loop, @@draw4loop, @@drawloop1, @@drawloop, @@piirra, @@3, @@2_1, @@2_0, @@dido, @@puis, @@null, @@bah, @@koinas
  98.         mov     [ds:tbl], 1
  99.         x1=[ds:p1*4+PolyCords]
  100.         y1=[ds:p1*4+PolyCords+2]
  101.         x2=[ds:p2*4+PolyCords]
  102.         y2=[ds:p2*4+PolyCords+2]
  103.  
  104.         tx1=[ds:p1*2+TextureCords]
  105.         ty1=[ds:p1*2+TextureCords+1]
  106.         tx2=[ds:p2*2+TextureCords]
  107.         ty2=[ds:p2*2+TextureCords+1]
  108.  
  109.         xor     ax, ax
  110.         xor     bx, bx
  111.         mov     al, tx2
  112.         mov     bl, tx1
  113.         sub     ax, bx
  114.         mov     [_txd], ax
  115.  
  116.         xor     ax, ax
  117.         xor     ebx, ebx
  118.         mov     al, ty2
  119.         mov     bl, ty1
  120.         sub     ax, bx
  121.         mov     [_tyd], ax
  122.  
  123.         mov     dl, tx1
  124.         mov     dh, ty1
  125.         mov     si, dx
  126.  
  127.         mov     dx, x1
  128.         mov     cx, y1
  129.  
  130.         mov     ax, x2
  131.         sub     ax, dx ; x1
  132.         mov     bx, y2
  133.         sub     bx, cx ; y1
  134.         jns     @@noswap
  135.         neg     ax
  136.         neg     bx
  137.         neg     [_txd]
  138.         neg     [_tyd]
  139.  
  140.         mov     dl, tx2
  141.         mov     dh, ty2
  142.         mov     si, dx
  143.  
  144.         mov     dx, x2
  145.         mov     cx, y2
  146.         dec     [ds:tbl]                ; toggle side
  147. @@noswap:
  148.         mov     [ds:_t1], si
  149.         mov     [ds:_x1], dx
  150.         mov     [ds:_y1], cx
  151.         or      bx, bx
  152.         jz      @@null
  153.         movsx   eax, ax                 ; [delta_x]
  154.         cdq
  155.         shl     eax, 16
  156.         idiv    ebx
  157.  
  158.         or      eax, eax
  159.         js      $+4
  160.         inc     eax
  161.         mov     [dword ptr ds:fixed_low], eax
  162.  
  163.         add     cx, [ds:edgemark]
  164.         lea     di, [offset pol_l+ecx*2]
  165.  
  166.         movsx   eax, [word ptr _txd]
  167.         cdq
  168.         shl     eax, 16
  169.         idiv    ebx
  170.         shr     eax, 8
  171.         mov     [tf_addx], ax
  172.  
  173.         movsx   eax, [word ptr _tyd]
  174.         cdq
  175.         shl     eax, 16
  176.         idiv    ebx
  177.         shr     eax, 8
  178.         mov     [tf_addy], ax
  179. @@koinas:
  180.         mov     ax, [word tf_addx]
  181.         xor     si, si
  182.         xor     cx, cx
  183.         mov     bp, [ds:_x1]
  184.         mov     dx, [ds:_t1]
  185.  
  186. @@drawloop:                             ; aint it sucky, eh...
  187.         add     si, [ds:fixed_low]
  188.         mov     [di], bp
  189.         adc     bp, [ds:fixed_high]
  190.         mov     [di+512*2], dx
  191.         add     cl, al ; [byte tf_addx]
  192.         adc     dl, ah ; [byte tf_addx+1]
  193.         add     ch, [byte tf_addy]
  194.         adc     dh, [byte tf_addy+1]
  195.         add     di, 2
  196.         dec     bx
  197.         jns     @@drawloop
  198.         jmp     @@puis
  199. @@null:
  200.         lea     di, [offset pol_l+ecx*2]
  201.         lea     bx, [eax+edx]
  202.         mov     [di], dx
  203.         mov     [di+256*2], bx
  204. @@puis:
  205. endm
  206.  
  207. macro   getminmax y0, y1, y2, y3
  208. local   @@1, @@2
  209.         mov     cx, 32767       ; min
  210.         xor     dx, dx          ; max
  211.  
  212. macro   testvalue
  213. local @@notless, @@notmore
  214.         cmp     ax, cx
  215.         jg      $+4
  216.         mov     cx, ax
  217.         cmp     ax, dx
  218.         jl      $+4
  219.         mov     dx, ax
  220. endm
  221.         mov     ax, y0
  222.         testvalue
  223.         mov     ax, y1
  224.         testvalue
  225.         mov     ax, y2
  226.         testvalue
  227.         mov     ax, y3
  228.         testvalue
  229.         test    cx, cx
  230.         jns     $+4
  231.         xor     cx, cx
  232.         cmp     dx, y_max
  233.         jle     $+5
  234.         mov     dx, y_max
  235. @@2:
  236. endm
  237.  
  238. dumdum  dw 0
  239.  
  240. proc    rendertexture
  241.         mov     cx, [cs:si+256*2]
  242.         sub     cx, [cs:si]
  243.         cmp     cx, 1
  244.         jl      @@puis
  245.         mov     [cs:loopti], cx
  246.  
  247.         mov     edi, ebx
  248.  
  249.         xor     eax, eax
  250.         xor     ebx, ebx
  251.         xor     ecx, ecx
  252.         xor     edx, edx
  253.  
  254.         mov     ax, [cs:si+512*2]
  255.         xchg    dl, ah
  256.  
  257.         mov     bx, [cs:si+768*2]
  258.         xchg    cl, bh
  259.         shl     eax, 16                 ; begin x
  260.         shl     edx, 16                 ; begin y
  261.         shl     ebx, 16                 ; end x
  262.         shl     ecx, 16                 ; end y
  263.         sub     ebx, eax
  264.         sub     ecx, edx
  265.         mov     eax, ebx
  266.         xor     ebx, ebx
  267.         mov     bx, [cs:loopti]
  268.         inc     bx
  269.         cdq
  270.         idiv    ebx                     ; x adder
  271.         mov     [cs:sxa], eax
  272.         mov     eax, ecx
  273.         cdq
  274.         idiv    ebx                     ; y adder
  275.         mov     [cs:sya], eax
  276.         xor     ebx, ebx
  277.         mov     bx, [word cs:si]         ; pol edge start
  278.         add     edi, ebx
  279.         xor     edx, edx
  280.         mov     bx, [cs:si+512*2]
  281.         xchg    dl, bh
  282.         mov     ebp, [cs:sya]
  283.         mov     esi, [cs:sxa]
  284.         rol     ebp, 16
  285.         rol     esi, 16
  286.         xchg    si, bp
  287.         xor     dh, dh
  288.         mov     ch, [byte cs:loopti]
  289.         shr     ch, 3
  290.         jz      @@nomolotus
  291.         shr     dh, 1
  292. @@inner1:
  293.         i=0
  294.         rept 4
  295.         adc     edx, esi
  296.         mov     al, [ds:bx]
  297.         adc     ebx, ebp
  298.         mov     bh, dl
  299.         adc     edx, esi
  300.         mov     ah, [ds:bx]
  301.         adc     ebx, ebp
  302.         mov     [es:edi+i], ax
  303.         mov     bh, dl
  304.         i=i+2
  305.         endm
  306.         adc     dh, dh
  307.         add     edi, i
  308.         shr     dh, 1
  309.         dec     ch
  310.         jnz     @@inner1
  311.         adc     dh, dh
  312.         and     [cs:loopti], 7
  313. @@nomolotus:
  314.         mov     ch, [byte cs:loopti]
  315.         shr     ch, 1
  316.         jz      @@innersingle
  317.         shr     dh, 1
  318. @@inner2:
  319.         adc     edx, esi
  320.         mov     al, [ds:bx]
  321.         adc     ebx, ebp
  322.         mov     bh, dl
  323.         adc     edx, esi
  324.         mov     ah, [ds:bx]
  325.         lea     edi, [edi+2]
  326.         adc     ebx, ebp
  327.         mov     bh, dl
  328.         mov     [es:edi-2], ax
  329.         dec     ch
  330.         jnz     @@inner2
  331.  
  332. @@innersingle:
  333.         test    [cs:loopti], 1
  334.         jz      @@PUIS
  335.         mov     al, [ds:bx]
  336.         mov     [es:edi], al
  337. @@puis:
  338.         ret
  339. endp
  340.  
  341. kunt    dw 0
  342.  
  343. proc    filltpoly4              ; fill texture mapped polygon
  344. ; line x1, y1, c1, x2, y2, c2
  345. ; parameters in POLYCORD
  346.  
  347.         push    cs
  348.         pop     ds
  349.  
  350.         mov     al, [byte ds:color]
  351.         mov     [byte ds:color+1], al
  352.  
  353.         line 0, 1
  354.         line 1, 2
  355.         line 2, 3
  356.         line 3, 0
  357.  
  358.         getminmax [ds:0*4+PolyCords+2], [ds:1*4+PolyCords+2], [ds:2*4+PolyCords+2], [ds:3*4+PolyCords+2]
  359.  
  360.         dec     dx
  361.         sub     dx, cx
  362.         js      @@nicht
  363.         mov     [ds:kunt], dx
  364.  
  365.         mov     ax, [ds:color]
  366.         mov     bx, ax
  367.         shl     eax, 16
  368.         mov     ax, bx
  369.  
  370.         lea     si, [offset pol_l+ecx*2]
  371.         shl     cx, 3                  ; \
  372.         lea     cx, [ecx+ecx*4]        ;   multiply by 8*5*5 = 200
  373.         lea     cx, [ecx+ecx*4]        ; /
  374.  
  375.         xor     ebx, ebx
  376.         mov     bx, cx
  377.         add     ebx, [cs:xmsaddress]
  378.         add     ebx, [cs:scrnofs]
  379.  
  380.         push    0
  381.         pop     es
  382.  
  383.         mov     ds, [cs:textureseg]
  384. @@w8_1:
  385.         cmp     si, offset pol_l                ; above screen?
  386.         jb      @@b
  387.         cmp     si, offset pol_l+y_max*2        ; below screen?
  388.         ja      @@b
  389.  
  390.         push    si ebx
  391.         call    rendertexture
  392.         pop     ebx si
  393. @@blorb:
  394.         inc     si
  395.         inc     si
  396. @@b:
  397.         add     ebx, 200 ; 200 wide lines
  398.         dec     [cs:kunt]
  399.         jns     @@w8_1
  400. @@nicht:
  401.         push    cs
  402.         pop     ds
  403.         ret
  404. endp
  405.  
  406. macro   fillpoly a1, a2, a3, a4
  407. local   @@tri_done, @@noco
  408.         push    cs
  409.         pop     ds
  410. ;(x3-x1)*(y2-y1)-(x2-x1)*(y3-y1)
  411.         mov     ax, [word ds:cord_x+(a3)*2]  ;x2
  412.         sub     ax, [word ds:cord_x+(a1)*2]  ;x0
  413.         mov     bx, [word ds:cord_y+(a2)*2]  ;y1
  414.         sub     bx, [word ds:cord_y+(a1)*2]  ;y0
  415.         imul    bx
  416.         mov     cx, ax
  417.         mov     ax, [word ds:cord_x+(a2)*2]  ;x1
  418.         sub     ax, [word ds:cord_x+(a1)*2]  ;x0
  419.         mov     bx, [word ds:cord_y+(a3)*2]  ;y2
  420.         sub     bx, [word ds:cord_y+(a1)*2]  ;y0
  421.         imul    bx
  422.         sub     cx, ax
  423.         jns     @@tri_done
  424.  
  425.         neg     cx
  426.         add     cx, 1700
  427.         lea     cx, [ecx+ecx*2]
  428.         shr     cx, 12
  429.         and     cx, 7
  430.         or      cx, cx
  431.         jz      $+3
  432.         inc     cx
  433.  
  434.         shl     cx, 10
  435.         add     [cs:textureseg], cx
  436.  
  437. @@noco:
  438.         mov     ax, [word cord_y+(a1)*2]
  439.         rol     eax, 16
  440.         mov     ax, [word cord_x+(a1)*2]
  441.         mov     [dword PolyCords+0*4], eax
  442.  
  443.         mov     ax, [word cord_y+(a2)*2]
  444.         rol     eax, 16
  445.         mov     ax, [word cord_x+(a2)*2]
  446.         mov     [dword PolyCords+1*4], eax
  447.  
  448.         mov     ax, [word cord_y+(a3)*2]
  449.         rol     eax, 16
  450.         mov     ax, [word cord_x+(a3)*2]
  451.         mov     [dword PolyCords+2*4], eax
  452.  
  453.         mov     ax, [word cord_y+(a4)*2]
  454.         rol     eax, 16
  455.         mov     ax, [word cord_x+(a4)*2]
  456.         mov     [dword PolyCords+3*4], eax
  457.  
  458.         call    filltpoly4
  459. @@tri_done:
  460.  
  461. endm
  462.  
  463. cord_x  dw points dup(0)
  464. cord_y  dw points dup(0)
  465. scrpage dw 0
  466.  
  467.  
  468. gg=2048+1024 ; +512+256
  469. cc=2048
  470.  
  471. label dots word
  472.         dw -cc,  cc, -cc
  473.         dw  cc,  cc, -cc
  474.         dw  cc, -cc, -cc
  475.         dw -cc, -cc, -cc
  476.         dw -cc,  cc,  cc
  477.         dw  cc,  cc,  cc
  478.         dw  cc, -cc,  cc
  479.         dw -cc, -cc,  cc
  480.  
  481. macro setborder clr
  482. ; if you
  483. endm
  484.  
  485. kolor   db 0
  486. color   dw 0
  487.  
  488. palette db 'texture_pal' , 32*3 dup (0)
  489.  
  490. ────────────────────────────────────────────────────────────────────────────
  491. ; FOLLOWING ROTATION ROUTINE IS ORIGINALLY FROM VLA'S VECTOR SOURCE!
  492. ; It's fast enough for stupid cube rotation and I'm not intending to
  493. ; release my own rotation routines before I really need to :)
  494. ────────────────────────────────────────────────────────────────────────────
  495.     ;DESTROYS: ax,dx,si,di,es,ds
  496.     ;Input: BX= X CX= Y BP= Z
  497.     ;OutPut:BX= X CX= Y BP= Z
  498. proc RotateXYZ
  499.                                             ; X-rotation
  500.                                             ; Y := cos(Xan) * y - sin(Xan) * z
  501.                                             ; Z := sin(Xan) * y + cos(Xan) * z
  502.         mov     si,[RotX]
  503.         add     si,si                       ; si = angle x
  504.         mov     ax,[Cosine+si]              ; ax = cos(angle x)
  505.         imul    cx                          ; ax = cos(angle x) * y
  506.         mov     di,dx
  507.         shl     edi,16
  508.         mov     di,ax                       ; store for later use
  509.         mov     ax,[Sine+si]                ; ax = sin(angle x)
  510.         imul    bp                          ; ax = sin(angle x) * z
  511.         shl     edx,16
  512.         mov     dx,ax
  513.         sub     edi,edx                     ; di = di-ax = cos(vx)*y - sin(vz)*z
  514.         sar     edi,8                       ; remove the (co)sin "256-factor"
  515.         push    di                          ; es = x-coordinate
  516.  
  517.         mov     ax,[sine+si]                ; ax = sin(angle x)
  518.         imul    cx                          ; ax = sin(angle x) * y
  519.         mov     di,dx
  520.         shl     edi,16
  521.         mov     di,ax
  522.         mov     ax,[cosine+si]              ; ax = cos(angle x)
  523.         imul    bp                          ; ax = cos(angle x) * z
  524.         shl     edx,16
  525.         mov     dx,ax
  526.         add     edi,edx                     ; di = di-ax = sin(vx)*y + cos(vx)*z
  527.         sar     edi,8                       ; remove the (co)sin "256-factor"
  528.  
  529.         pop     cx                          ; update y
  530.         mov     bp,di                       ; update z
  531.  
  532.                                             ; Y-rotation
  533.                                             ; X :=  cos(vy) * xc + sin(vy) * zc
  534.                                             ; Z := -sin(vy) * xc + cos(vy) * zc
  535.         mov     si,[RotY]
  536.         add     si,si                       ; si = angle y
  537.         mov     ax,[Cosine+si]              ; ax = cos(angle y)
  538.         imul    bx                          ; ax = cos(angle y) * x
  539.         mov     di,dx
  540.         shl     edi,16
  541.         mov     di,ax                       ; store for later use
  542.         mov     ax,[Sine+si]                ; ax = sin(angle y)
  543.         imul    bp                          ; ax = sin(angle y) * z
  544.         shl     edx,16
  545.         mov     dx,ax
  546.         add     edi,edx                     ; di = di+ax = cos(vy)*x + sin(vy)*z
  547.         sar     edi,8                       ; remove the (co)sin "256-factor"
  548.         push    di                          ; es = x-coordinate
  549.  
  550.         mov     ax,[Sine+si]                ; ax = sin(angle y)
  551.         neg     ax                          ; ax =-sin(angle y)
  552.         imul    bx                          ; ax =-sin(angle y) * x
  553.         mov     di,dx
  554.         shl     edi,16
  555.         mov     di,ax
  556.         mov     ax,[Cosine+si]              ; ax = cos(angle y)
  557.         imul    bp                          ; ax = cos(angle y) * z
  558.         shl     edx,16
  559.         mov     dx,ax
  560.         add     edi,edx                     ; di = di-ax = sin(vy)*x - cos(vy)*z
  561.         sar     edi,8                       ; remove the (co)sin "256-factor"
  562.  
  563.         pop     bx                          ; update x
  564.         mov     bp,di                       ; update z
  565.  
  566.                                             ; Z-rotation
  567.                                             ; X := cos(vz) * xc - sin(vz) * yc
  568.                                             ; Y := sin(vz) * xc + cos(vz) * yc
  569.         mov     si,[RotZ]
  570.         add     si,si                       ; si = angle z
  571.         mov     ax,[Cosine+si]              ; ax = cos(angle z)
  572.         imul    bx                          ; ax = cos(angle z) * x
  573.         mov     di,dx
  574.         shl     edi,16
  575.         mov     di,ax
  576.         mov     ax,[Sine+si]                ; ax = sin(angle z)
  577.         imul    cx                          ; ax = sin(angle z) * y
  578.         shl     edx,16
  579.         mov     dx,ax
  580.         sub     edi,edx                     ; di = di-ax = cos(vz)*x - sin(vz)*y
  581.         sar     edi,8                       ; remove the (co)sin "256-factor"
  582.         push    di                          ; es = x-coordinate
  583.  
  584.         mov     ax,[Sine+si]                ; ax = sin(angle z)
  585.         imul    bx                          ; ax = sin(angle z) * x
  586.         mov     di,dx
  587.         shl     edi,16
  588.         mov     di,ax
  589.         mov     ax,[Cosine+si]              ; ax = cos(angle z)
  590.         imul    cx                          ; ax = cos(angle z) * y
  591.         shl     edx,16
  592.         mov     dx,ax
  593.         add     edi,edx                     ; di = di+ax = sin(vz)*x+cos(vz)*y
  594.         sar     edi,8                       ; remove the (co)sin "256-factor"
  595.  
  596.         pop     bx                          ; update x
  597.         mov     cx,di                       ; update y
  598.  
  599.         ret
  600. ENDP
  601. ────────────────────────────────────────────────────────────────────────────
  602.  
  603. proc    rotatecord
  604.         xor     si, si
  605.         and     [RotX], 1023
  606.         and     [RotY], 1023
  607.         and     [RotZ], 1023
  608. rotcordloop1:
  609.         push    si
  610. ;BX= X CX= Y BP= Z
  611. ;BX= X CX= Y BP= Z
  612.         mov     bx, si
  613.         add     si, si
  614.         add     si, bx
  615.         mov     bx, [dots+si]
  616.         mov     cx, [dots+2+si]
  617.         mov     bp, [dots+4+si]
  618.         call    RotateXYZ
  619.         pop     si
  620.         mov     ax, [cs:tz]
  621.         sub     bp, ax
  622.         mov     ax,bx
  623.         mov     bx, (512-20)
  624.         imul    bx
  625.         idiv    bp              ;x
  626.         add     ax, x_center
  627.         mov     [cord_x+si], ax
  628.  
  629.         mov     ax,cx
  630.         mov     bx, (512*2)/(rowmu+1)
  631.         imul    bx
  632.         idiv    bp              ;y
  633.         add     ax, y_center
  634.         mov     [cord_y+si], ax
  635.         inc     si
  636.         inc     si
  637.         cmp     si, points*2
  638.         jb      rotcordloop1
  639.         ret
  640. endp
  641.  
  642. proc    draw_glenz
  643.         mov     [cs:textureseg], picseg         ; psykomössö
  644.         fillpoly 0, 4, 5, 1
  645.         mov     [cs:textureseg], picseg
  646.         fillpoly 7, 3, 2, 6
  647.         mov     [cs:textureseg], picseg
  648.         fillpoly 1, 5, 6, 2
  649.         mov     [cs:textureseg], picseg
  650.         fillpoly 3, 7, 4, 0
  651.         mov     [cs:textureseg], picseg+4       ; muija
  652.         fillpoly 0, 1, 2, 3
  653.         mov     [cs:textureseg], picseg+8       ; skull
  654.         fillpoly 5, 4, 7, 6
  655.         ret
  656. endp
  657.  
  658. macro calcofs
  659.         mov     ax, [cs:scrpage]
  660.         mov     bx, pagesh
  661.         mul     bx
  662.         shl     edx, 16
  663.         mov     dx, ax
  664.         mov     [cs:scrnofs], edx
  665. endm
  666.  
  667. proc    clearpage
  668.         calcofs
  669.         cld
  670.         push    0
  671.         pop     ds
  672.  
  673.         mov     cx, (y_max+1)*5
  674.         xor     si, si
  675.         mov     edi, [cs:scrnofs]
  676.         add     edi, [cs:xmsaddress]
  677.         xor     eax, eax
  678. @@m1:
  679.         i=0
  680.         rept 10
  681.         mov     [edi+i], eax
  682.         i=i+4
  683.         endm
  684.         add     edi, i
  685.         dec     cx
  686.         jnz     @@m1
  687.         ret
  688. endp
  689.  
  690. proc    rubbercopyscr
  691.         push    0
  692.         pop     ds
  693.         push    0a000h
  694.         pop     es
  695.  
  696.         cld
  697.         mov     esi, [cs:xmsaddress]
  698.  
  699.         mov     ebx, [cs:scrnofs]
  700.  
  701.         mov     di, 320*28-8*6
  702.  
  703.         add     [cs:scrpage], 1
  704.         cmp     [cs:scrpage], pagez
  705.         jb      @blorb1
  706.         sub     [cs:scrpage], pagez
  707. @blorb1:
  708.  
  709.         mov     cx, (y_max+1)/veny
  710. @@a:
  711.  
  712.         add     ebx, pagesh
  713.         cmp     ebx, pagez*pagesh
  714.         jb      @blorb
  715.         sub     ebx, pagez*pagesh
  716. @blorb:
  717.  
  718.         add     esi, ebx
  719.         mov     dh, veny
  720. @@b:
  721.         add     di, (80-(5*10))*4
  722.         mov     dl, 5
  723. @@c:
  724.         i=0
  725.         rept 10
  726.         mov     eax, [esi+i]
  727. ;        add     eax, 20h
  728.         stosd
  729.         i=i+4
  730.         endm
  731.         add     esi, 10*4
  732. ;        add     di, 10*4
  733.         dec     dl
  734.         jnz     @@c
  735.         dec     dh
  736.         jnz     @@b
  737.         sub     esi, ebx
  738.         dec     cx
  739.         jnz     @@a
  740.         ret
  741. endp
  742.  
  743. proc    dothetwist
  744.         calcofs
  745.         setborder 5
  746.         call    rotatecord
  747.         setborder 4
  748.         call    clearpage
  749.         setborder 1
  750.         call    draw_glenz
  751.         setborder 12
  752.         setborder 0
  753.  
  754.         mov     dx, 3dah
  755.         in      al, dx
  756.         test    al, 8
  757.         jnz     $-3
  758.         in      al, dx
  759.         test    al, 8
  760.         jz      $-3
  761.  
  762.         call    rubbercopyscr
  763.         ret
  764. endp
  765.  
  766. proc    remaptexture
  767.         mov     bx, 8
  768. @@koo:
  769.         mov     ax, picseg
  770.         mov     ds, ax
  771.  
  772.         mov     ax, picseg
  773.         mov     cx, bx
  774.         shl     cx, 10
  775.         add     ax, cx
  776.         mov     es, ax
  777.  
  778.         mov     dh, 8
  779.         sub     dh, bl
  780.         shl     dh, 5
  781.         mov     dl, dh
  782.         mov     di, dx
  783.         shl     edx, 16
  784.         mov     dx, di
  785.  
  786.         xor     di, di
  787.  
  788.         mov     cx, 256*64/4
  789. @@map:
  790.         mov     eax, [ds:di]
  791.         and     eax, 1f1f1f1fh
  792.         add     eax, edx
  793.         stosd
  794.         dec     cx
  795.         jnz     @@map
  796.         dec     bx
  797.         jnz     @@koo
  798.         ret
  799. endp
  800.  
  801. proc    fadetus
  802.         mov     ch, 7
  803. @@p1:
  804.         mov     si, offset palette
  805.         mov     dx, 3c8h
  806.         mov     al, 7
  807.         sub     al, ch
  808.         shl     al, 5
  809.         out     dx, al
  810.         inc     dx
  811.  
  812.         mov     cl, 32*3
  813. @@p2:
  814.         mov     al, ch
  815.         add     al, ch
  816.         shr     al, 2
  817.         add     al, ch
  818.         shr     al, 1
  819.         add     al, ch
  820.         add     al, ch
  821.         add     al, 7
  822.         mul     [byte cs:si]
  823.         shr     ax, 5
  824.  
  825.         out     dx, al
  826.         inc     si
  827.         dec     cl
  828.         jnz     @@p2
  829.         dec     ch
  830.         jnz     @@p1
  831.  
  832.         ret
  833. endp
  834.  
  835. doop    dw 100
  836.  
  837. proc main
  838.         mov     ax, 0
  839.         mov     bx, (pagez*pagesh/1024)
  840.         call    flatman
  841.         push    cs
  842.         pop     ds
  843.         mov     [cs:xmsaddress], eax
  844.  
  845.         call    remaptexture
  846.  
  847.         mov     ax, 13h
  848.         int     10h
  849.  
  850.         call    fadetus
  851.  
  852.         mov     dx, 3c8h
  853.         xor     al, al
  854.         out     dx, al
  855.         inc     dx
  856.         mov     al, 08
  857.         out     dx, al
  858.         mov     al, 15
  859.         out     dx, al
  860.         mov     al, 13
  861.         out     dx, al
  862.  
  863. ;        mov     [cs:stylero], 70*2
  864. ;la2:
  865. ;        call    dothetwist
  866. ;        dec     [cs:stylero]
  867. ;        jnz     la2
  868.  
  869.  
  870. l2:
  871. ;; uncomment these for "depth wobbling"
  872. ;        add     [cs:holoholo], 12
  873. ;        mov     bx, [cs:holoholo]
  874. ;        add     bx, 512
  875. ;        and     bx, 1023
  876. ;        add     bx, bx
  877. ;        mov     ax, [cs:sine+bx]
  878. ;        sal     ax, 4
  879. ;        add     ax, 18500+3700
  880. ;        mov     [cs:tz], ax
  881.  
  882.         add     [cs:rotx], 2            ; try different values,
  883.         add     [cs:roty], 1            ; large values cause distortion...
  884.         add     [cs:rotz], 5            ;
  885.         call    dothetwist
  886.         in      al, 60h
  887.         cmp     al, 1h
  888.         jnz l2
  889.  
  890. puis:
  891.         mov     ax, 1
  892.         call    flatman
  893.         mov     ax, 3
  894.         int     10h
  895.         mov     ax, 4c00h
  896.         int     21h
  897. endp
  898.  
  899. segment picseg use32
  900.         db 'texture_pic'
  901.         db 256*64*8 dup (0)
  902. ends    picseg
  903.  
  904. end main
  905.