home *** CD-ROM | disk | FTP | other *** search
/ The Equalizer BBS / equalizer-bbs-collection_2004.zip / equalizer-bbs-collection / DEMOSCENE-STUFF / REFRACT.ZIP / REFRACT.ASM < prev    next >
Assembly Source File  |  1995-11-13  |  60KB  |  2,789 lines

  1. COMMENT #
  2.  
  3.  
  4.   ┌──────────────────────────────────────────────────┐
  5.   │                                                  │▒
  6.   │              R E F R A C T I O N                 │▒
  7.   │                                                  │▒
  8.   │  A 4k intro for the PC-X competiton.             │▒
  9.   │  Made by G.O.D. /AbaddoN                         │▒
  10.   │  Copyright (C)1995. All rights reserved.         │▒
  11.   │                                                  │▒
  12.   │  Last modified: 10-31-95 05:24pm                 │▒
  13.   └──────────────────────────────────────────────────┘▒
  14.    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  15.  
  16.  
  17.  
  18.  
  19. Compiling:  TASM /m9 refract.asm
  20.             TLINK /t /x refract.obj
  21.  
  22. Note: The first respect was size optimizing, then the speed optimizing.
  23.       You can find some neglect, when you watching the code.
  24.  
  25. #
  26. .386
  27. LOCALS
  28.  
  29.  
  30. ;debug = 0
  31.  
  32.  
  33.  
  34. ; ┌───────────────────────────────┐
  35. ; │         Constants.            │▒
  36. ; └───────────────────────────────┘▒
  37. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  38.  
  39. B    EQU byte ptr        ; For an easier life.
  40. W    EQU word ptr
  41. D    EQU dword ptr
  42. O    EQU offset
  43. S    EQU small
  44. L    EQU large
  45.  
  46. CR    EQU 0dh
  47. LF    EQU 0ah
  48. EOS    EQU '$'
  49.  
  50.  
  51.  
  52. ; ┌───────────────────────────────┐
  53. ; │         Main code.            │▒
  54. ; └───────────────────────────────┘▒
  55. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  56.  
  57. code SEGMENT USE16
  58. ASSUME cs:code, ds:code, ss:code, es:code
  59.     ORG 100h
  60.  
  61. ; Last modified: 10-31-95 05:24pm
  62.  
  63. Main    PROC
  64.         mov    bx,4000h
  65.         mov    ah,4ah
  66.         int    21h
  67.         jnc    @@Enough_Mem
  68.         mov    dx,O @@NoMemStr
  69.         jmp    @@Wrt_Exit
  70.  
  71. @@Enough_Mem:
  72.         mov    dx,O @@PleaseStr
  73.         mov    ah,9
  74.         int    21h
  75.         cld
  76.         mov    ax,cs
  77.         add    ax,1000h
  78.         mov    [ChrAddr],ax    ; Where the 2nd screen will be.
  79.         add    ax,1000h
  80.         mov    [ScrAddr],ax    ; Where the charset will be.
  81.  
  82.         xor    ax,ax     ; Make a table which
  83.         xor    bx,bx     ; contains the offset address
  84.         mov    di,O ScrRowsVGA ; of the screen rows on VGA screen.
  85.         mov    cx,200
  86. @@1:
  87.         stosw
  88.         add    ax,320
  89.         loop    @@1
  90.  
  91.         call    SinGen    ; Make the sinus table
  92.  
  93.         call    MakeChars    ; Make the charset.
  94.  
  95.         xor    ax,ax
  96.         mov    es,ax
  97.  
  98. ; Setting up new keyboard routine.
  99.     IFNDEF debug
  100.         mov    [StackSegment],ss
  101.         mov    [StackPointer],sp
  102.         mov    dx,cs
  103.         shl    edx,10h
  104.         mov    dx,O KeyboardIRQ
  105.         xchg    edx,es:[24h]
  106.         mov    [Old_Kbd],edx
  107.     ENDIF
  108.  
  109. ; Setting up new timer routine.
  110.         mov    [Timer_Routine],O Timer_Blank
  111.         mov    dx,cs
  112.         shl    edx,10h
  113.         mov    dx,O TimerIRQ
  114.         xchg    edx,es:[20h]
  115.         mov    [Old_Timer],edx
  116.         mov    al,36h     ; Ticks with 10ms.
  117.         out    43h,al
  118.         mov    al,156
  119.         out    40h,al
  120.         mov    al,46
  121.         out    40h,al
  122.  
  123. ; Making the beginnig effect.
  124.         mov    di,O TitleTexts ; Select title texts.
  125.         mov    ax,600+8000h     ; Set 6 secs. waiting.
  126.         call    Mandy_Zoom
  127.  
  128. ; Making the broken screen effect.
  129.         call    BreakScr
  130.  
  131. ; Making the chess table effect.
  132.         call    Chess_Mate
  133.  
  134. ; Making the ending effect.
  135.         mov    di,O EndTexts     ; Select end texts.
  136.         mov    ax,100+8000h     ; Set 1 sec. wainting.
  137.         call    Mandy_Zoom
  138.  
  139. Abort_Code:
  140.         xor    ax,ax
  141.         mov    es,ax
  142.  
  143. ; Setting back the timer.
  144.         out    40h,al
  145.         out    40h,al
  146.         mov    edx,[Old_Timer]
  147.         mov    es:[20h],edx
  148.  
  149. ; Setting back the keyboard.
  150.     IFNDEF debug
  151.         mov    edx,[Old_Kbd]
  152.         mov    es:[24h],edx
  153.     ENDIF
  154.  
  155. ; Setting back text mode.
  156.         mov    ax,3
  157.         int    10h
  158.  
  159. ; Writing bye-string.
  160.         mov    dx,O @@EndString
  161. @@Wrt_Exit:
  162.         mov    ah,9
  163.         int    21h
  164.  
  165. ; Exit 2 DOS.
  166.         int    20h
  167.  
  168. ; The string that will be written after finishing.
  169. @@EndString    db '- REFRACTION -',CR,LF
  170.         db 'Coded by G.O.D. /AbaddoN in 1995.',EOS
  171. @@NoMemStr    db 'Not enough memory. ( 256k of base memory needed )',EOS
  172. @@PleaseStr    db 'Warming up !',EOS
  173.  
  174. Main    ENDP
  175.  
  176.  
  177.  
  178.  
  179. ; ┌───────────────────────────────────────┐
  180. ; │          Mandelbrot zoomer.           │▒
  181. ; └───────────────────────────────────────┘▒
  182. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  183.  
  184. ; Input:  ax= Delay before the first text
  185. ;         di= Offset of texts & positions & times.
  186. ; Modified regsiter(s): eax,ebx,ecx,edx,edi,esi,ebp,es
  187. ; Length: 257 bytes.
  188. ; Last modified: 10-31-95 02:09pm
  189.  
  190. Mandy_Zoom PROC NEAR
  191.  
  192.         mov    [Timer_Cnt],ax     ; Store the inputs.
  193.         mov    [MZ_TextPos],di
  194.         mov    [MZ_Cnt],1
  195.         mov    [MZ_S_bx],256
  196.         mov    [MZ_S_si],0
  197.  
  198.  
  199.         mov    ax,[ScrAddr]     ; Counting the seg.addr. of
  200.         mov    es,ax     ; the two buffer for
  201.         mov    bx,ax     ; mandelbrot.
  202.         add    bx,1000h
  203.         xor    ax,bx
  204.         mov    [MZ_XorScr],ax
  205.         mov    [MZ_ScrSeg],bx
  206.         push    ax
  207.         call    Make_Mandy
  208.         pop    ax
  209.         xor    [MZ_ScrSeg],ax
  210.  
  211.         mov    ax,13h
  212.         int    10h     ; Setting 320x200-256 mode.
  213.         mov    ax,0a000h
  214.         mov    es,ax
  215.         mov    ax,808h
  216.         xor    di,di
  217.         mov    cx,32000
  218.     rep    stosw         ; Clear the screen.
  219.  
  220.         mov    [MZ_Finish],al
  221.         mov    [MZ_Next],al
  222.  
  223.         mov    al,1fh
  224.         mov    di,320*8+94
  225.         mov    si,di
  226.         mov    cx,132
  227. @@1:
  228.         mov    es:[di],al     ; Make the frame.
  229.         mov    es:[di+320*131],al
  230.         inc    di
  231.         mov    es:[si],al
  232.         mov    es:[si+132],al
  233.         add    si,320
  234.         loop    @@1
  235.  
  236.         mov    dx,3c8h     ; Setting the colors
  237.         mov    ax,2f00h
  238.         out    dx,al
  239.         inc    dx
  240.         mov    cl,80
  241. @@2:
  242.         cmp    ah,2fh
  243.         jnz    @@3
  244.         mov    ah,0
  245.         mov    bx,1020h
  246. @@3:
  247.         mov    al,bl
  248.         out    dx,al
  249.         mov    al,bh
  250.         out    dx,al
  251.         mov    al,ah
  252.         out    dx,al
  253.         add    bx,101h
  254.         inc    ah
  255.         loop    @@2
  256.  
  257.         mov    [Timer_Routine],O Put_Mandy
  258. @@4:
  259.         mov    ebx,[MZ_Delta]     ; Count the next phase's
  260.         shl    ebx,6     ; left-upper corner &
  261.         mov    eax,@@TargetRe     ; the difference between
  262.         sub    eax,ebx     ; two dot.
  263.         mov    [MZ_StartRe],eax
  264.         mov    eax,@@TargetIm
  265.         sub    eax,ebx
  266.         mov    [MZ_StartIm],eax
  267.         shr    ebx,7
  268.         mov    [MZ_Delta],ebx
  269.         call    Make_Mandy
  270.  
  271.         mov    al,1
  272.         mov    [MZ_Next],al
  273. @@5:
  274.         cmp    [MZ_Next],al
  275.         je    @@5     ; Wait for the next phase.
  276.         cmp    [MZ_Finish],al
  277.         jne    @@4     ; Or exit at the end.
  278.         mov    ah,40h
  279. @@6:
  280.         mov    cl,80     ; Fading down the colors.
  281.         call    FadeDown
  282.         call    Raster
  283.         call    Raster
  284.         dec    ah
  285.         jnz    @@6
  286.         mov    [Timer_Routine],O Timer_Blank
  287.         ret
  288.  
  289. @@TargetRe = -15049100
  290. @@TargetIm = -43583200
  291. MZ_StartRe    dd -15049100-750000*128
  292. MZ_StartIm    dd -43583200-750000*128
  293. MZ_Delta        dd 750000
  294.  
  295. Mandy_Zoom ENDP
  296.  
  297.  
  298.  
  299.  
  300. ; ┌───────────────────────────────────────────────┐
  301. ; │          Timer routine for zooming.           │▒
  302. ; └───────────────────────────────────────────────┘▒
  303. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  304.  
  305. ; Modified regsiter(s): nothing
  306. ; Length: 179 bytes.
  307. ; Last modified: 10-17-95 10:02pm
  308.  
  309. Put_Mandy    PROC NEAR
  310.  
  311. ; Streches 256x256 square picture to 128x128.
  312. ; Input:  si= The offset of the left-upper corner in the 256x256 pic.
  313. ;         bx= The length of the edge of the part that will be zoomed.
  314. Put_Her    MACRO
  315. LOCAL P1,P2
  316.         mov    di,(320-128)/2+320*10    ; di= screen position.
  317.  
  318.         shl    bx,1    ; bx= the addition to the row.
  319.         mov    ax,si
  320.         mov    ah,0    ; ax= left sid of the square.
  321.         mov    cl,80h
  322. P1:
  323.         mov    ch,80h
  324.         push    bx si
  325.         and    si,0ff00h    ; si= the offset of the row to strech.
  326.         add    si,ax    ; si= the offset of the left-upper crn.
  327.  
  328.         mov    bp,8000h
  329.         xor    dx,dx    ; bx:dx= the addiotion to the column.
  330.         xchg    bl,dh
  331.         xchg    bh,bl
  332.         dec    bx    ; Dec. int. part 'coz of the movsb.
  333. P2:
  334.         movsb
  335.         add    bp,dx
  336.         adc    si,bx
  337.         dec    ch
  338.         jnz    P2    ; Jump if not at the end of the row.
  339.         add    di,320-128
  340.         pop    si bx
  341.         add    si,bx    ; Count the next row's address.
  342.         loop    P1    ; Loop if not at the end of the pic.
  343. ENDM
  344.  
  345.  
  346. ; It starts. (Timon of LionKing)
  347.  
  348.         pushad
  349.         push    es
  350.         mov    ax,0a000h
  351.         mov    es,ax
  352.         cmp    [Timer_Cnt],8000h
  353.         jns    @@2    ; Jump if no new text needed.
  354.         mov    si,[MZ_TextPos]
  355.         lodsw        ; Get its position.
  356.         inc    ax
  357.         jnz    @@1
  358.         mov    [MZ_Finish],1    ; Mark finish.
  359.         jmp    @@2
  360. @@1:
  361.         xchg    di,ax
  362.         mov    dx,800h+1fh-8    ; Set text colors.
  363.         call    PutTextVGA    ; Put a text.
  364.         lodsw
  365.         mov    [Timer_Cnt],ax     ; Set waiting.
  366.         mov    [MZ_TextPos],si ; Store the textpointer.
  367. @@2:
  368.         dec    [MZ_Cnt]    ; Do it every 80ms.
  369.         jne    @@4
  370.         mov    [MZ_Cnt],10
  371.  
  372.         cmp    [MZ_S_bx],128
  373.         jne    @@3    ; Jump if no new phase needed.
  374.  
  375.         cmp    [MZ_Next],1
  376.         jne    @@4    ; Jump if the next phase is not ready.
  377.         mov    ax,[MZ_XorScr]
  378.         xor    [MZ_ScrSeg],ax    ; Exchange the secondary screens.
  379.         xor    ax,ax
  380.         mov    [MZ_Next],al    ; And set up them.
  381.         mov    [MZ_S_si],ax
  382.         inc    ah
  383.         mov    [MZ_S_bx],ax
  384. @@3:
  385.         mov    bx,[MZ_S_bx]
  386.         sub    [MZ_S_bx],2
  387.         mov    si,[MZ_S_si]
  388.         add    [MZ_S_si],101h
  389.         mov    ax,[MZ_ScrSeg]
  390.         xor    ax,[MZ_XorScr]
  391.         mov    ds,ax    ; ds:si= adr.of the left-upper corner.
  392.  
  393.         Put_Her        ; Put the streched mandelbrot.
  394. @@4:
  395.         pop    es
  396.         popad
  397.         ret
  398.  
  399. MZ_Cnt    db 1        ; The counter for 80ms.
  400. MZ_S_bx    dw 256        ; The length of the edge of the square to strech.
  401. MZ_S_si    dw 0        ; The offset of the left-upper corner of the square.
  402. Put_Mandy    ENDP
  403.  
  404.  
  405.  
  406.  
  407. ; ┌────────────────────────────────────────────────┐
  408. ; │          Makes a 256x256 mandelbrot.           │▒
  409. ; └────────────────────────────────────────────────┘▒
  410. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  411.  
  412. ; Input:  MZ_ScrSeg= The segment address of the mandelbrot.
  413. ;         MZ_StartIm & MZ_StartRe= The complex value of the left-upper corner.
  414. ;         MZ_Delta= The difference between two dot.
  415. ; Modified regsiter(s): eax,ebx,ecx,edx,edi,esi,ebp,es
  416. ; Length: 149 bytes.
  417. ; Last modified: 10-17-95 10:02pm
  418.  
  419. Make_Mandy PROC NEAR
  420. MaxIter = 80    ; The number of the maximum iteration.
  421. @@FixPoint = 26    ; The number of the bit where the fix-point is.
  422.  
  423.         xor    di,di
  424.         mov    es,[MZ_ScrSeg]
  425.         mov    esi,[MZ_StartIm]
  426.  
  427.         xor    cx,cx
  428. @@1:
  429.         mov    [MZ_RowCnt],0
  430.         mov    ebx,[MZ_StartRe]
  431. @@2:
  432.         push    ebx ecx esi di
  433.         call    @@Iter    ; Do the iteration.
  434.         pop    di
  435.         mov    es:[di],cl    ; cl= the color of the dot.
  436.         inc    di
  437.  
  438.         test    cl,cl    ; Test if the color is 0.
  439.  
  440.         pop    esi ecx ebx
  441.  
  442.         jnz    @@3
  443.         inc    [MZ_RowCnt]    ; If a whole row contains 0,
  444.         jz    @@KillIt    ; fill the remained with 0 too.
  445. @@3:
  446.         add    ebx,[MZ_Delta]
  447.         dec    ch
  448.         jnz    @@2    ; Jump if not at the end of the row.
  449.         add    esi,[MZ_Delta]
  450.         loop    @@1    ; Loop if not at the end of the pic.
  451.         ret
  452. @@KillIt:
  453.         xor    cx,cx    ; Fill the remain with 0.
  454.         sub    cx,di
  455.         shr    cx,2
  456.         jmp    Fill0_2
  457.  
  458.  
  459.  
  460.  
  461. ; Counting one dot's color.
  462. ; Input:  ebx= reA
  463. ;         esi= imA
  464.  
  465. @@Iter:
  466.  
  467.         xor    edi,edi    ; edi= reZ (=0).
  468.         xor    ebp,ebp    ; ebp= imZ (=0).
  469.         mov    cl,MaxIter    ; Iteration nubmer.
  470. @@Iter_Loop:
  471.         dec    cl
  472.         jz    @@Iter_End
  473.         mov    eax,edi
  474.         imul    ebp
  475.         shrd    eax,edx,@@FixPoint-1
  476.         add    eax,esi    ; eax= 2*reZ*imZ + imA.
  477.         xchg    eax,ebp    ; ebp= imZ+ & eax=imZ.
  478.         imul    eax
  479.         shrd    eax,edx,@@FixPoint    ; eax= imZ^2.
  480.         xchg    eax,edi    ; edi= imZ^2  & eax= reZ.
  481.         imul    eax
  482.         shrd    eax,edx,@@FixPoint    ; eax= reZ^2.
  483.         mov    edx,eax    ; edx= reZ^2.
  484.         sub    eax,edi
  485.         add    eax,ebx
  486.         xchg    eax,edi    ; edi= reZ^2 - imZ^2 + reA= imZ+.
  487.         add    eax,edx    ; eax= reZ^2 + imZ^2.
  488.         cmp    eax,4 SHL @@FixPoint
  489.         jb    @@Iter_Loop
  490. @@Iter_End:
  491.         ret
  492. Make_Mandy ENDP
  493.  
  494.  
  495.  
  496. ; The title texts.
  497. TitleTexts    dw 168*320+48-1    ; The screen position of the text
  498.         db 'ABADDON',0    ; The text.
  499.         dw 500+8000h    ; The time to wait after putting it.
  500.                 ; Time=x+8000h waits x*10ms.
  501.         dw 168*320+32-1
  502.         db 'PRESENTS',0
  503.         dw 500+8000h
  504.  
  505.         dw 168*320+32-1
  506.         db ' G.O.D. ',0
  507.         dw 500+8000h
  508.  
  509.         dw 168*320+0-1
  510.         db 'PRODUCTION',0
  511.         dw 500+8000h
  512.  
  513.         dw 168*320+0-1
  514.         db '          ',0
  515.         dw 50+8000h
  516.  
  517.         dw 0ffffh    ; 0ffffh scr.pos. means the end.
  518.  
  519. ; The end texts.
  520. EndTexts        dw 168*320+16-1
  521.         db 'GREETINGS',0
  522.         dw 150+8000h
  523.  
  524.         dw 168*320-1
  525.         db '    TO    ',0
  526.         dw 150+8000h
  527.  
  528.         dw 168*320-1
  529.         db 'EVERYBODY',0
  530.         dw 150+8000h
  531.  
  532.         dw 168*320-1
  533.         db ' WHO IS  ',0
  534.         dw 150+8000h
  535.  
  536.         dw 168*320+16-1
  537.         db 'WATCHING.',0
  538.         dw 400+8000h
  539.  
  540.         dw 168*320+16-1
  541.         db 'THIS WAS ',0
  542.         dw 150+8000h
  543.  
  544.         dw 168*320-1
  545. IntroName        db 'REFRACTION',0
  546.         dw 1500+8000h
  547.  
  548.         dw 0ffffh
  549.  
  550.  
  551.  
  552.  
  553. ; ┌──────────────────────────────────────────┐
  554. ; │          Broken screen effect.           │▒
  555. ; └──────────────────────────────────────────┘▒
  556. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  557.  
  558. ; Modified regsiter(s): eax,bx,ecx,dx,edi,si,bp,es,fs
  559. ; Length: 543 bytes.
  560. ; Last modified: 10-26-95 02:17pm
  561.  
  562. BrkPntNum = 12        ; Number of vertices where the breaking line breaks.
  563.  
  564. BreakScr    PROC NEAR
  565.         mov    ax,13h
  566.         int    10h    ; Set 320x200-256 screen.
  567.  
  568.         call    ClrScr2    ; Clear the secondary screen.
  569.  
  570.         mov    bx,40*100h+45 ;43*100h+45
  571.         call    @@BrkScr_SetC    ; Set the colors.
  572.  
  573.  
  574.         mov    si,O IntroName
  575.         mov    di,320*84+0
  576.         mov    dx,1
  577.         push    dx di si
  578.         call    PutTextVGA    ; Put the text on the sec.scr.
  579.         pop    si di dx
  580.         mov    ax,0a000h
  581.         mov    es,ax
  582.         call    PutTextVGA    ; Then onto the real screen.
  583.  
  584.         mov    ax,400+8000h
  585.         call    Delay    ; Wait for 4 seconds.
  586.  
  587.         xor    cx,cx
  588.         mov    dx,140
  589.         mov    [BrkPoliXS],dx ; The breaking line is on 140 Y.
  590.         ;mov    [BrkPoliXC],70 ; The center of the light-source
  591.         ;mov    [BrkPoliYC],100 ; is at 70-100.
  592.         mov    si,O BreakingLine
  593.         mov    bp,BrkPntNum-1
  594. @@1:
  595.         lodsw        ; Draw the breaking line.
  596.         xor    bx,bx
  597.         xchg    bl,ah
  598.         add    ax,140    ; Its middle Y is 140.
  599.         push    ax bx si bp
  600.         mov    bp,O BrkStoreEdge
  601.         call    DrawEdge
  602.         pop    bp si cx dx
  603.         dec    bp
  604.         jnz    @@1
  605. COMMENT ~
  606.         xor    cx,cx    ; Break the screen.
  607. @@2:
  608.         push    cx    ; The line starts at Y=0 and
  609.         mov    bx,cx    ; finishes at T=cx.
  610.         shl    bx,2
  611.         mov    dx,W [TempArea+2][bx]    ; dx=X of the brk.l. in the
  612.                     ; cx-th. rasterrow.
  613.         sub    dx,140
  614.         mov    si,O BreakingLine-2
  615.         mov    di,O BrkLTemp
  616.         push    ds
  617.         pop    es
  618.         mov    dh,BrkPntNum
  619. @@3:
  620.         lodsw        ; Make a table for BrkPoli rout.
  621.         cmp    ah,cl    ; from a current phase of the brk.l.
  622.         jb    @@4
  623.         mov    ah,cl    ; If the vertex is below cx.
  624.         mov    al,dl
  625. @@4:
  626.         stosw
  627.         dec    dh
  628.         jnz    @@3
  629.  
  630.         mov    si,O BrkLTemp
  631.         call    @@Put_Scr    ; Make light & put the screen.
  632.  
  633.         pop    cx
  634.         add    cx,4
  635.         cmp    cx,200
  636.         jb    @@2
  637. ~
  638.         mov    ax,100+8000h
  639.         call    Delay    ; Wait for 1 sec.
  640.  
  641.  
  642.         xor    bp,bp
  643. @@5:
  644.         mov    [Timer_Cnt],4+8000h
  645.  
  646.         push    ds    ; Prepare for scrolling the two halves.
  647.         mov    ds,[ScrAddr]
  648.         push    ds
  649.         pop    es
  650.  
  651.         mov    di,320*84    ; Scroll only the middle of the screen,
  652.         mov    bx,O TempArea+84*4+2  ; where the text is.
  653.         mov    dl,28    ; It is 28 dot high.
  654. @@6:
  655.         mov    cx,cs:[bx]
  656.         sub    cx,bp
  657.         dec    cx
  658.         js    @@7
  659.         push    di
  660.         mov    si,di
  661.         inc    si
  662.     rep    movsb        ; Scroll the left side.
  663.         pop    di
  664. @@7:
  665.         mov    cx,320
  666.         sub    cx,cs:[bx]
  667.         sub    cx,bp
  668.         dec    cx
  669.         js    @@8
  670.         push    di
  671.         add    di,319
  672.         mov    si,di
  673.         dec    si
  674.         std
  675.     rep    movsb        ; Scroll the right side.
  676.         cld
  677.         pop    di
  678. @@8:
  679.         add    di,320
  680.         add    bx,4
  681.         dec    dl
  682.         jnz    @@6
  683.  
  684.         mov    si,O TempArea+2
  685.         xor    bx,bx    ; Make the highlight gap between
  686.         mov    dl,200    ; the two sides.
  687. @@9:
  688.         mov    di,cs:[si]
  689.         sub    di,bp
  690.         js    @@10
  691.         mov    B [bx+di],2
  692. @@10:
  693.         add    di,bp
  694.         add    di,bp
  695.         mov    B [bx+di+1],2
  696.         add    si,4
  697.         add    bx,320
  698.         dec    dl
  699.         jnz    @@9
  700.  
  701.         pop    ds
  702.  
  703.         cmp    bp,75
  704.         ja    @@11
  705.         mov    ax,140    ; If the gap is above 2*75 pixel,
  706.         sub    ax,bp    ; the left light is not visible.
  707.         mov    [BrkPoliXS],ax
  708.         mov    si,O BreakingLine-2
  709.         mov    ax,0c040h
  710.         call    @@BrkPoli
  711. @@11:
  712.         mov    ax,140
  713.         add    ax,bp
  714.         mov    [BrkPoliXS],ax
  715.         mov    si,O BreakingLine-2
  716.         call    @@Put_Scr    ; Make light & put the screen.
  717.  
  718.  
  719.         cmp    bp,75
  720.         jne    @@12
  721.         push    bp    ; At the gap=2*75 the light lights
  722.         mov    bx,58*100h+60    ; into our eyes.
  723.         mov    ah,40
  724.         call    @@BrkScr_SetC
  725.         pop    bp
  726. @@12:
  727.         cmp    bp,140-24
  728.         jb    @@13
  729.         push    bp    ; With 2*24 before the end the
  730.         mov    ax,bp    ; "whiting" the colors.
  731.         sub    ax,140-24-40
  732.         mov    ah,al
  733.         mov    bx,58*100h+60
  734.         call    @@BrkScr_SetC
  735.         pop    bp
  736. @@13:
  737.  
  738. @@18:
  739.         cmp    [Timer_Cnt],0
  740.         js    @@18
  741.         inc    bp
  742.         cmp    bp,140
  743.         jb    @@5
  744.  
  745.         ret
  746.  
  747. @@Put_Scr:
  748.         mov    ax,3010h
  749.         call    @@BrkPoli    ; Make the right one of the lights.
  750.         push    ds
  751.         call    Copy_Scr
  752.         push    ds
  753.         pop    es
  754.         xor    di,di    ; Clear the light from the sec.scr.
  755.         xor    si,si
  756.         mov    edx,0f0f0f0fh
  757.         mov    cx,16000
  758. @@PS1:
  759.         lodsd
  760.         and    eax,edx
  761.         stosd
  762.         loop    @@PS1
  763.         pop    ds
  764.         ret
  765.  
  766.  
  767. BrkStoreEdge:
  768.         push    bx    ; Store the X coord. of the brk.line.
  769.         shl    bx,2
  770.         mov    D [TempArea][bx],edi
  771.         pop    bx
  772.         ret
  773.  
  774.         db   0,   0
  775. BreakingLine    db  20,  20    ; The coordinates of the brk.line.
  776.         db  14,  40
  777.         db  30,  60
  778.         db  18,  80
  779.         db  25,  90
  780.         db   0, 110
  781.         db  10, 125
  782.         db  15, 140
  783.         db   5, 160
  784.         db  25, 180
  785.         db   0, 200
  786. @@Colors        db 000,000,000    ; The color table.
  787.         db 025,025,035
  788.         db 063,063,063
  789.  
  790.  
  791. @@BrkScr_SetC:
  792.         mov    dx,3c8h    ; Set the colors.
  793.         mov    al,0    ; The LS4B is the color;
  794.         out    dx,al    ; the 4-5 bit is the right light;
  795.         inc    dx    ; the 6-7 bit is the left light.
  796.         mov    bp,16*3
  797.  
  798.         mov    cx,bp
  799.         call    @@SetCol    ;00000000b
  800.  
  801.         mov    ah,bh
  802.         mov    cx,bp
  803.         call    @@SetCol    ;00010000b
  804.         mov    ah,bl
  805.         mov    di,2
  806.         call    @@BSC1
  807.                 ;00100000b
  808.                 ;00110000b
  809.         xchg    ah,bh
  810.         mov    di,4
  811.         call    @@BSC1    ;01000000b
  812.                 ;01010000b
  813.                 ;01100000b
  814.                 ;01110000b
  815.         xchg    ah,bl
  816.         mov    di,8
  817.                 ;10000000b
  818.                 ;10010000b
  819.                 ;10100000b
  820.                 ;10110000b
  821.                 ;11000000b
  822.                 ;11010000b
  823.                 ;11100000b
  824.                 ;11110000b
  825. @@BSC1:
  826.         mov    cx,bp
  827.         call    @@SetCol
  828.         dec    di
  829.         jnz    @@BSC1
  830.         ret
  831. @@SetCol:
  832.         mov    si,O @@Colors
  833.         jmp    SetBloCol
  834.  
  835.  
  836.  
  837. ; Makes the lights.
  838. ; Let's look at this:
  839. ;                     __ V1
  840. ;      Brk.line.  ___/  |
  841. ;         \   ___/      |
  842. ;       ___\_/ Light is /
  843. ; LS.__/   /V4   here  |
  844. ;   +_____/____________|
  845. ;         \V3          V2
  846. ;          \
  847.  
  848.  
  849. @@BrkPoli:
  850.         push    bp
  851.         mov    cx,BrkPntNum-1
  852. @@BP1:
  853.         push    cx si ax
  854.  
  855.         mov    bp,O BrkTemp
  856.         mov    di,O BrkTemp+4
  857.         call    @@BrkPoli2        ; Count the V4,V1 vertex.
  858.  
  859.         mov    bp,O BrkTemp+12
  860.         mov    di,O BrkTemp+8
  861.         call    @@BrkPoli2        ; Count the V2,V3 vertex.
  862.  
  863.         mov    si,O BrkTemp
  864.  
  865.         pop    ax
  866.         push    ax
  867.         mov    ah,1
  868.         mov    cx,4
  869.         call    FillPoli        ; Fill the light.
  870.  
  871.         pop    ax si cx
  872.         xor    al,ah
  873.         inc    si
  874.         inc    si
  875.         loop    @@BP1        ; Then the next one.
  876.         pop    bp
  877.         ret
  878. @@BrkPoli2:
  879.         lodsw        ; Counting an edge of a light.
  880.         xor    bx,bx
  881.         xchg    bl,ah
  882.         add    ax,[BrkPoliXS]
  883.         mov    [bp],ax    ; Store 1st vertex of the line (V3,V4).
  884.         mov    [bp+2],bx
  885.         mov    cx,ax
  886.         sub    cx,70 ;[BrkPoliXC]
  887.         mov    dx,bx
  888.         sub    dx,100 ;[BrkPoliYC]
  889. @@BP2:
  890.         add    ax,cx    ; Count the 2nd vertex (V1,V2).
  891.         add    bx,dx
  892.         cmp    ax,400
  893.         ja    @@BP3
  894.         cmp    bx,600
  895.         jb    @@BP2
  896. @@BP3:
  897.         mov    [di],ax    ; And store them.
  898.         mov    [di+2],bx
  899.         ret
  900. BreakScr    ENDP
  901.  
  902.  
  903.  
  904.  
  905. ; ┌───────────────────────────────────────────┐
  906. ; │          Sets a block of colors.          │▒
  907. ; └───────────────────────────────────────────┘▒
  908. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  909.  
  910. ; Input:  ds:si= The address of the R,G,B components of the colors.
  911. ;         cx= The number of colors to set
  912. ;         ah= The addition value to the R,G,B. (Something brightness.)
  913. ;
  914. ; Modified register(s): al, cx, si
  915. ; Length: 13 bytes.
  916. ; Last modified: 10-05-95 12:04pm
  917.  
  918. SetBloCol    PROC NEAR
  919. @@1:
  920.         lodsb
  921.         add    al,ah
  922.         cmp    al,3fh
  923.         jbe    @@2    ; Jump if the color value is right.
  924.         mov    al,3fh    ; Else set the maximum color.
  925. @@2:
  926.         out    dx,al
  927.         loop    @@1
  928.         ret
  929. SetBloCol    ENDP
  930.  
  931.  
  932.  
  933.  
  934. ; ┌────────────────────────────────────────────┐
  935. ; │          Chess is looking good.            │▒
  936. ; └────────────────────────────────────────────┘▒
  937. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  938.  
  939. ; Modified regsiter(s): eax,ebx,cx,edx,di,si,ebp,es
  940. ; Length: 488 bytes (with data).
  941. ; Last modified: 10-26-95 04:22pm
  942.  
  943. Chess_Mate PROC NEAR
  944.  
  945. ; The number of figures thoose are on the table. (6 whites & 7 blacks)
  946. FigsOn    EQU 6+7
  947.  
  948.         call    Mk_ChFigs    ; Make the figures' objects.
  949.         call    Mk_ChTable    ; Make the chess table.
  950.  
  951.         mov    ax,13h    ; Set screen to 320x200-256.
  952.         int    10h
  953.  
  954.         mov    dx,3c8h    ; Setting the colors
  955.         mov    al,0
  956.         out    dx,al
  957.         inc    dx
  958.  
  959.         mov    ch,49h    ; 0-3fh table's colors.
  960.         mov    bx,4940h
  961.         call    Ch_SetCol
  962.         mov    ch,64h    ; 40h-7fh white's colors.
  963.         mov    bx,5950h
  964.         call    Ch_SetCol
  965.         mov    ch,0    ; 80h-0bfh black's colors.
  966.         mov    bx,2921h
  967.         call    Ch_SetCol
  968.  
  969.  
  970.         mov    si,O Chess_Text1
  971.         call    Put_ManyText    ; Put the names, counry and year.
  972.  
  973.         push    cs
  974.         pop    es
  975.  
  976.         mov    di,O ChFig_Pos    ; Set up the figs' positions.
  977.         mov    si,O ChStartPos
  978.         mov    cx,FigsON*3
  979. @@1:
  980.         lodsb
  981.         cbw
  982.         shl    eax,2+10h
  983.         stosd
  984.         loop    @@1
  985.  
  986.         mov    si,O ChFig_Init ; Set up the figs' addrs&colors.
  987.         mov    di,O ChFig_Dat
  988.         mov    cx,FigsOn
  989. @@2:
  990.         movsw
  991.         lodsb
  992.         stosw
  993.         loop    @@2
  994.  
  995.                     ; Set up some other variables.
  996.         mov    [LS_Circ],00400000h    ; The ligth-circle's size.
  997.                     ; ( the bigger the less )
  998.         mov    D [Zoom_Factor-2],200*10000h ; Zooming for 3D-2D
  999.                           ; transformation.
  1000.         mov    eax,128*10000h        ; Starting rotation angles.
  1001.         mov    D [Rot_Alfa-2],eax
  1002.         mov    D [Rot_Beta-2],eax
  1003.  
  1004.         xor    eax,eax
  1005.         mov    [Eye_XAdd],eax        ; Our eye's position.
  1006.         mov    [Eye_YAdd],eax
  1007.         mov    [Eye_ZAdd],-300*10000h
  1008.  
  1009.         mov    [PO_XLight],eax    ; The light- circle's position.
  1010.         mov    [PO_ZLight],eax
  1011.  
  1012. ; ax=0 here!
  1013.         mov    di,O New_Values    ; It causes no movement at all.
  1014.         mov    cx,((9+FigsOn*3)*2)*2
  1015.     rep    stosw
  1016.  
  1017.         mov    [Timer_Routine],O Chess_Timer    ; The addr.of timing r.
  1018.  
  1019. @@3:
  1020.         call    ClrScr2        ; Clear the sec.scr.
  1021.  
  1022.         push    cs
  1023.         pop    es
  1024.         mov    [FPG_Col],al    ; eax=0 !
  1025.         mov    di,O Trans_XAdd
  1026.         mov    si,O Eye_XAdd
  1027.         movsd
  1028.         movsd
  1029.         movsd
  1030.         mov    si,O Chess_Table
  1031.         call    Put_Obj    ; Put the chess-table.
  1032.  
  1033.         push    cs    ; Sorting the figures from the fartest
  1034.         pop    es    ; to the nearest.
  1035.         mov    si,O ChFig_Pos
  1036.         mov    di,O TempArea
  1037.         mov    cx,FigsOn
  1038.         push    cx cx di
  1039.         call    Rotate    ; si=original, di=rotated, cx=number.
  1040.         pop    si cx
  1041.         add    si,8
  1042.         mov    di,O ChFig_Srt
  1043.         push    di
  1044.         xor    eax,eax
  1045. @@4:
  1046.         neg    D [si]
  1047.         movsd
  1048.         add    si,12
  1049.         stosd
  1050.         inc    ax
  1051.         loop    @@4
  1052.         pop    si cx
  1053.         call    QuickSort    ; si=rotated, cx=number.
  1054.  
  1055.         mov    bx,O ChFig_Srt+4    ; [bx]=sorted numbers of the
  1056.                     ;      figures.
  1057.         mov    cx,FigsOn
  1058. @@5:
  1059.         push    cs
  1060.         pop    es
  1061.         mov    si,[bx]    ; si=figs' number to put.
  1062.         add    bx,8
  1063.         push    bx cx
  1064.         shl    si,2
  1065.         push    si
  1066.         add    si,O ChFig_Dat
  1067.         mov    dx,[si]    ; dx=offs. of the figure's object.
  1068.         mov    al,[si+2]    ; al= color of the figure.
  1069.         mov    [FPG_Col],al
  1070.         pop    si
  1071.         mov    ax,si
  1072.         shl    si,1
  1073.         add    si,ax
  1074.         add    si,O ChFig_Pos    ; Set its position.
  1075.         mov    di,O Trans_XAdd
  1076.         lodsd
  1077.         add    eax,[Eye_XAdd]
  1078.         stosd
  1079.         lodsd
  1080.         add    eax,[Eye_YAdd]
  1081.         stosd
  1082.         lodsd
  1083.         add    eax,[Eye_ZAdd]
  1084.         stosd
  1085.         xchg    dx,si
  1086.         call    Put_Obj    ; And put it.
  1087.         pop    cx bx
  1088.         loop    @@5
  1089.  
  1090.         call    Raster
  1091.         push    ds
  1092.         call    Copy_Scr    ; Put the sec.scr to the primary scr.
  1093.         pop    ds
  1094.         cmp    [ChFinish],0
  1095.         jz    @@3    ; Jump back if not at the end.
  1096.  
  1097.         mov    si,O Chess_Text2
  1098.  
  1099. ; Puts some text to the screen.
  1100. ; Input:  si= Offset of the positions+texts.
  1101. ; Modified regsiter(s): ax,bx,cx,dx,di,si,bp,es
  1102. Put_ManyText:
  1103.         mov    ax,0a000h
  1104.         mov    es,ax
  1105.         lodsb
  1106. @@6:
  1107.         push    ax
  1108.         lodsw
  1109.         xchg    ax,di
  1110.         mov    dx,60h
  1111.         call    PutTextVGA    ; Put the text on the screen.
  1112.         pop    ax
  1113.         dec    al
  1114.         jnz    @@6
  1115.         mov    ax,400+8000h
  1116.         jmp    Delay    ; Wait for 4 seconds.
  1117.  
  1118. ; ChFinish <> 0 if this part is over.
  1119. ChFinish    db 0
  1120.  
  1121. ; Some value to make the data understandable.
  1122. CB_L =  70    ; Left-edge's position.
  1123. CB_A =  47    ; 'A' column's position.
  1124. CB_B =  35    ; etc.
  1125. CB_C =  21
  1126. CB_D =  7
  1127. CB_E = -7
  1128. CB_F = -21
  1129. CB_G = -35
  1130. CB_H = -47
  1131. CB_R = -70    ; Rigth-edge's position.
  1132. CB_U = -70    ; Upper-edge's position.
  1133. CB_1 = -47    ; '1' row's position.
  1134. CB_2 = -35    ; etc.
  1135. CB_3 = -21
  1136. CB_4 = -7
  1137. CB_5 =  7
  1138. CB_6 =  21
  1139. CB_7 =  35
  1140. CB_8 =  47
  1141. CB_D = -70    ; Down-edge's position.
  1142.  
  1143. ; The fiures's start positions.
  1144. ChStartPos db CB_7,CB_A,0   ; Black Pawn
  1145.      db CB_6,CB_B,0   ; Black Pawn
  1146.      db CB_6,CB_F,0   ; Black Pawn
  1147.      db CB_7,CB_B,0   ; Black Castle
  1148.      db CB_5,CB_E,0   ; Black Queen
  1149.      db CB_7,CB_F,0   ; Black King
  1150.  
  1151.      db CB_2,CB_A,0   ; White Pawn
  1152.      db CB_2,CB_F,0   ; White Pawn
  1153.      db CB_3,CB_G,0   ; White Pawn
  1154.      db CB_5,CB_H,0   ; White Pawn
  1155.      db CB_1,CB_B,0   ; White Bishop
  1156.      db CB_8,CB_H,0   ; White Queen
  1157.      db CB_2,CB_H,0   ; White King
  1158.  
  1159. ; The figures's object's address and color.
  1160. ChFig_Init dw O Pawn
  1161.      db 80h
  1162.      dw O Pawn
  1163.      db 80h
  1164.      dw O Pawn
  1165.      db 80h
  1166.      dw O Castle
  1167.      db 80h
  1168.      dw O Queen
  1169.      db 80h
  1170.      dw O King
  1171.      db 80h
  1172.  
  1173.      dw O Pawn
  1174.      db 40h
  1175.      dw O Pawn
  1176.      db 40h
  1177.      dw O Pawn
  1178.      db 40h
  1179.      dw O Pawn
  1180.      db 40h
  1181.      dw O Bishop
  1182.       db 40h
  1183.      dw O Queen
  1184.      db 40h
  1185.      dw O King
  1186.      db 40h
  1187.  
  1188. ; Title texts.
  1189. Chess_Text1    db 3
  1190.         dw 320*40
  1191.         db 'KERES-',0
  1192.         dw 320*72+32*3
  1193.         db 'TAMINOV',0
  1194.         dw 320*104
  1195.         db 'USSR, 1951',0
  1196. ; Finish texts.
  1197. Chess_Text2    db 2
  1198.         dw 64
  1199.         db 'BLACK',0
  1200.         dw 320*32+32
  1201.         db 'RESIGNS',0
  1202.  
  1203. Chess_Mate ENDP
  1204.  
  1205.  
  1206.  
  1207.  
  1208. ; ┌───────────────────────────────────────────┐
  1209. ; │          Chess timing routine.            │▒
  1210. ; └───────────────────────────────────────────┘▒
  1211. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1212.  
  1213. ; Length: 146 bytes + the MoveTable.
  1214. ; Last modified: 10-26-95 02:18pm
  1215.  
  1216. Chess_Timer PROC NEAR
  1217.  
  1218.         pushad
  1219.         mov    si,O Old_Values
  1220.         mov    di,O New_Values
  1221.         mov    cx,9+FigsOn*3
  1222. @@1:
  1223.         lodsd        ; Get an old variable.
  1224.         mov    ebx,[di]    ; Get its finishing value.
  1225.         add    di,8
  1226.         cmp    eax,ebx
  1227.         je    @@5    ; Jump if it is reached.
  1228.         jg    @@2
  1229.         add    eax,[di-4]    ; If less, increase it.
  1230.         cmp    eax,ebx
  1231.         jle    @@4
  1232.         jmp    @@3    ; Set the finishing value if overflow.
  1233. @@2:
  1234.         sub    eax,[di-4]    ; If greater, decrase it.
  1235.         cmp    eax,ebx
  1236.         jge    @@4
  1237. @@3:
  1238.         xchg    eax,ebx    ; In case of overflow.
  1239. @@4:
  1240.         mov    [si-4],eax    ; Write it back.
  1241. @@5:
  1242.         loop    @@1    ; Do the next one.
  1243.  
  1244.         dec    [@@Counter]
  1245.         jnz    @@Exit    ; Jump if no next phase needed.
  1246.  
  1247.         mov    si,[@@Pointer]
  1248.         lodsb        ; Set up the next phase.
  1249.         cmp    al,0ffh
  1250.         jne    @@6    ; Jump if not at the end of this part.
  1251.         mov    [ChFinish],al    ; Else mark it.
  1252.         jmp    @@Exit
  1253. @@6:
  1254.         mov    dl,al    ; Count the new delay.
  1255.         and    dx,0e0h
  1256.         shl    dx,2
  1257.         inc    dx
  1258.         mov    [@@Counter],dx
  1259.  
  1260.         and    al,1fh
  1261.         xor    edx,edx
  1262.         xchg    al,dl    ; edx= the step of modifying.
  1263.  
  1264.         lodsb
  1265.         mov    ah,0
  1266.         shl    ax,3
  1267.         add    ax,O New_Values
  1268.         xchg    ax,di    ; di= adr.of the value to change.
  1269.  
  1270.         lodsb
  1271.         cbw
  1272.         cwde
  1273.         shl    eax,18    ; eax= finishing value.
  1274.         mov    [di],eax
  1275.         shl    edx,14
  1276.         mov    [di+4],edx
  1277.  
  1278.         mov    ax,511
  1279.         and    [Rot_Alfa],ax    ; Anding the rotating angles,
  1280.         and    [Rot_Beta],ax    ; to avoid some strange effect.
  1281.  
  1282.         mov    [@@Pointer],si    ; Write back the pointer of the phases.
  1283. @@Exit:
  1284.         popad
  1285.         ret
  1286.  
  1287. ; Some value to make life easier.
  1288. Mv_BP1 = 9    ; 1st black pawn's number.
  1289. Mv_BP2 = 12    ; etc.
  1290. Mv_BP3 = 15
  1291. Mv_BC  = 18
  1292. Mv_BQ  = 21
  1293. Mv_BK  = 24
  1294. Mv_WP1 = 27
  1295. Mv_WP2 = 30
  1296. Mv_WP3 = 33
  1297. Mv_WP4 = 36
  1298. Mv_WB  = 39
  1299. Mv_WQ  = 42
  1300. Mv_WK  = 45
  1301.  
  1302. ; A counter for delaying phases.
  1303. @@Counter    dw 1
  1304. ; The pointer of phases.
  1305. @@Pointer    dw O @@MoveTable
  1306.  
  1307. ; The moving phases.
  1308. ; Format: 1st byte: bit7-5 the delay for next phase.
  1309. ;                   bit4-0 the step to reach the new values.
  1310. ;         2nd byte: the value to modify.
  1311. ;         3rd byte: the finishing value.
  1312.  
  1313.         ; 0,1, 2, 3, 4, 5,6,7,8,  9, 10, 11, 12
  1314.         ; a,b,ZF,XL,ZL,LC,X,Y,Z,f1X,f1Y,f1Z,f2X,...
  1315.         ;842421½¼            *4
  1316. @@MoveTable LABEL
  1317.       db 11100001b, 8,        -5
  1318.       db 10000001b, 8,        -5
  1319.       db 01000001b, 6,       -60
  1320.       db 01000001b, 0,       110
  1321.       db 01000001b, 6,         0
  1322.       db 11100001b, 8,       -20
  1323.  
  1324.       db 00100010b, 3,        20
  1325.       db 00100010b, 4,       -15
  1326.       db 00100010b, 3,       -15
  1327.       db 01100010b, 4,        15
  1328.       ;db 01000001b, 3,        20
  1329.       ;db 01000001b, 4,       -15
  1330.       ;db 01000001b, 3,       -15
  1331.       ;db 11100001b, 4,        15
  1332.  
  1333.       db 00000001b, Mv_WQ,   CB_7
  1334.       db 01000001b, Mv_WQ+1, CB_H
  1335.       ;db 10000001b, Mv_WQ+1, CB_H
  1336.       db 00000001b, Mv_BK,   CB_6
  1337.       db 01000001b, Mv_BK+1, CB_E
  1338.       ;db 01100001b, Mv_BK+1, CB_E
  1339.  
  1340.       db 00000001b, 0,       86
  1341.       db 00000001b, 6,       10
  1342.       db 00000001b, 4,      -18
  1343.  
  1344.       db 00000001b, Mv_WQ,   CB_7
  1345.       db 10000010b, Mv_WQ+1, CB_B
  1346.       db 01000010b, Mv_BC,   CB_L
  1347.       ;db 10000010b, Mv_BC,   CB_L
  1348.  
  1349.       db 01000001b, 0,       120
  1350.  
  1351.       db 00000010b, Mv_BQ,   CB_5
  1352.       db 01000010b, Mv_BQ+1, CB_H
  1353.       db 00000010b, Mv_WP4,  CB_4
  1354.       db 01100010b, Mv_WP4+1,CB_R
  1355.       db 01000010b, Mv_WK+1, CB_G
  1356.       db 01100100b, 5,       85
  1357.       db 0ffh
  1358.  
  1359. Chess_Timer ENDP
  1360.  
  1361.  
  1362.  
  1363.  
  1364. ; ┌────────────────────────────────────────────┐
  1365. ; │          Makes the chess figures.          │▒
  1366. ; └────────────────────────────────────────────┘▒
  1367. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1368.  
  1369. ; Modified regsiter(s): eax,ebx,cx,edx,di,si,ebp,es
  1370. ; Length: 165 bytes. ( with data )
  1371. ; Last modified: 10-26-95 04:22pm
  1372.  
  1373. Mk_ChFigs    PROC NEAR
  1374.         mov    si,O ChFig_Tab
  1375.         mov    cx,FigNum
  1376. @@1:
  1377.         lodsw        ; Get the contour's address.
  1378.         xchg    ax,bx
  1379.         lodsw        ; Get the object's room address.
  1380.         xchg    ax,di
  1381.         lodsb        ; Get the number of vertices of contour.
  1382.         mov    ah,0
  1383.         push    cx si
  1384.         xchg    ax,si
  1385.         xchg    bx,si
  1386.         call    Make_Obj    ; Make the object.
  1387.         pop    si cx
  1388.         loop    @@1    ; Do the next one.
  1389.         ret
  1390.  
  1391. FigNum EQU 5    ; The number of figures' types.
  1392. PVtx  EQU 9    ; The number of the vertices in a pawn.
  1393. BVtx  EQU 11    ; ... in a bishop, etc.
  1394. CVtx  EQU 10
  1395. QVtx  EQU 12
  1396. KVtx  EQU 15
  1397.  
  1398. ; A table for making objects. ( 1st W: contour's addr., 2nd W: object's addr.,
  1399. ;                               3rd B: the number of vertices in the contour. )
  1400. ChFig_Tab    dw O Cont_Pawn, O Pawn
  1401.     db PVtx
  1402.     dw O Cont_Bish, O Bishop
  1403.     db CVtx
  1404.     dw O Cont_Cast, O Castle
  1405.     db CVtx
  1406.     dw O Cont_Quen, O Queen
  1407.     db QVtx
  1408.     dw O Cont_King, O King
  1409.     db KVtx
  1410.  
  1411.  
  1412. ; The contours of the figures.
  1413.  
  1414. ;Cont_Pawn    db   0, 76,  -8, 76, -20, 68, -28, 56, -28, 40
  1415. ;    db -20, 28, -16, 22, -32, 16, -20,  4, -32,-40
  1416. ;    db -40,-56, -44,-56, -48,-60, -48,-72,   0,-72
  1417. Cont_Pawn    db   0, 94, -14, 89, -21, 80, -21, 70, -11, 57
  1418.     db -21, 14, -37,  6, -37,  0,   0,  0
  1419. Cont_Bish    db   0,118, -14,104, -20, 92, -20, 84, -11, 76
  1420.     db -28, 67, -11, 67, -25, 14, -36,  8, -36,  0
  1421.     db   0,  0
  1422. Cont_Cast    db   0, 97, -15, 97, -20,108, -28,108, -28, 86
  1423.     db -18, 76, -28, 15, -38, 10, -38,  0,   0,  0
  1424. Cont_Quen    db   0,159,  -3,159,  -6,156,  -6,153, -30,150
  1425.     db -12,114, -30,114, -14,105, -30, 18, -42, 12
  1426.     db -42,  0,   0,  0
  1427. Cont_King    db   0,169,  -3,169,  -3,165,  -8,165,  -8,162
  1428.     db  -3,162
  1429.     db  -3,156, -24,144, -12,114, -30,105,  -9,105
  1430.     db -30, 18, -42, 12, -42,  0,   0,  0
  1431.  
  1432. Mk_ChFigs    ENDP
  1433.  
  1434.  
  1435.  
  1436.  
  1437. ; ┌───────────────────────────────────────────────┐
  1438. ; │          Sets 64 colors for gouraud.          │▒
  1439. ; └───────────────────────────────────────────────┘▒
  1440. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1441.  
  1442. ; Input: ch,bh,bl=R,G,B compnent
  1443. ;        dx= 3c9h
  1444. ; Modified regsiter(s): ax,cl,dx,bp
  1445. ; Length: 34 bytes.
  1446. ; Last modified: 10-28-95 11:00am
  1447.  
  1448. Ch_SetCol    PROC NEAR
  1449.  
  1450.         mov    cl,0    ; cl goes from 0 to 3fh
  1451. @@1:
  1452.         mov    bp,3    ; There are 3 components for each col.
  1453. @@2:
  1454.         mov    al,cl
  1455.         mul    ch
  1456.         shr    ax,6
  1457.         cmp    al,3fh    ; Check if above the max.
  1458.         jb    @@3
  1459.         mov    al,3fh    ; If above, set the max.
  1460. @@3:
  1461.         out    dx,al
  1462.         xchg    bh,ch    ; Change for the next component.
  1463.         xchg    bl,bh
  1464.         dec    bp
  1465.         jnz    @@2    ; Do the next component.
  1466.         inc    cl
  1467.         cmp    cl,40h
  1468.         jnz    @@1    ; Do the next color.
  1469.         ret
  1470.  
  1471. Ch_SetCol    ENDP
  1472.  
  1473.  
  1474.  
  1475.  
  1476. ; ┌───────────────────────────────────────────────────┐
  1477. ; │          Makes the chess-table object.            │▒
  1478. ; └───────────────────────────────────────────────────┘▒
  1479. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1480.  
  1481. ; Modified regsiter(s): ax,ebx,cx,edx,di,ebp,es
  1482. ; Length: 98 bytes.
  1483. ; Last modified: 10-26-95 04:22pm
  1484.  
  1485. Mk_ChTable PROC NEAR
  1486. @@SqEdge= 56*10000h    ; The length of one square's edge.
  1487.  
  1488.         push    cs
  1489.         pop    es
  1490.         mov    di,O Chess_Table+2    ; di=adr.of the object.
  1491.         mov    W [di-2],81        ; It contains 81 vertices.
  1492.         mov    edx,@@SqEdge*(-4)    ; edx is the Y coordinate.
  1493.         xor    ebp,ebp        ; ebp is the Z coordinate.
  1494.         mov    cl,9        ; There are 9 vertex row.
  1495. @@1:
  1496.         mov    eax,@@SqEdge*(-4)    ; eax is the X coordinate.
  1497.         mov    ch,9        ; There are 9 vertex column.
  1498. @@2:
  1499.         stosd            ; Store X.
  1500.         mov    [di],edx        ; Store Y.
  1501.         mov    D [di+4],ebp           ; Store Z.
  1502.         add    di,8
  1503.         add    eax,@@SqEdge
  1504.         dec    ch
  1505.         jnz    @@2
  1506.         add    edx,@@SqEdge
  1507.         loop    @@1
  1508.  
  1509.         mov    ax,32        ; There are 32 square.
  1510.         stosw
  1511.         mov    ax,1
  1512.         mov    bx,ax
  1513.         mov    cl,8        ; 8 row.
  1514. @@3:
  1515.         mov    ch,4        ; 4 squre in each rows.
  1516. @@4:
  1517.         stosw            ; Store one sq.'s vertices'
  1518.         dec    ax        ; numbers.
  1519.         stosw
  1520.         add    ax,9
  1521.         stosw
  1522.         inc    ax
  1523.         stosw
  1524.         sub    ax,7
  1525.         dec    ch
  1526.         jnz    @@4        ; Next square.
  1527.         inc    ax
  1528.         add    ax,bx
  1529.         xor    bx,0fffeh
  1530.         loop    @@3        ; Next row.
  1531.         ret
  1532. Mk_ChTable ENDP
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538. ; ┌────────────────────────────────┐
  1539. ; │          Puts a text.          │▒
  1540. ; └────────────────────────────────┘▒
  1541. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1542.  
  1543. ; Input:  ds:si= Address of text to put (ASCIIZ).
  1544. ;         es:di= Screen position of text.
  1545. ;         dl= Text's color.
  1546. ;         dh= Text's background - text's color.
  1547. ; Output: ds:si= The address of the 1st byte after the text.
  1548. ;
  1549. ; Modified regsiter(s): ax,bx,cx,dx,di,si,bp
  1550. ; Length: 74 bytes.
  1551. ; Last modified: 10-28-95 11:13am
  1552.  
  1553. PutText    PROC NEAR
  1554.  
  1555. ; Entry point for putting text on VGA screen vertically.
  1556. ;PutTextVGA_Vert:
  1557. ;        mov    [@@Sub_di],0
  1558. ;        jmp    @@PutTextVGA2
  1559.  
  1560. ; Entry point for putting text on VGA screen horizontally.
  1561. PutTextVGA:
  1562.         mov    [@@Sub_di],32*320-32
  1563. @@PutTextVGA2:
  1564.         mov    bp,320-32
  1565. @@1:
  1566.         mov    [PText_Bkg],dh    ; Set text colors.
  1567.         push    fs
  1568.         mov    fs,[ChrAddr]    ; fs= Segment address of bigchars.
  1569. @@2:
  1570.         mov    bl,[si]    ; bl= The current char to put.
  1571.         inc    si
  1572.         sub    bl,20h    ; The 1st stored char is the space.
  1573.  
  1574.         jc    @@Exit    ; Jump if it's the end of the string.
  1575.         mov    bh,0
  1576.         shl    bx,10    ; bx= The offset address of the char.
  1577.  
  1578.         mov    cl,32    ; We've got 32 row in a char.
  1579. @@3:
  1580.         mov    ch,4    ; We've got 4*8 column in a char.
  1581. @@4:
  1582.         mov    dh,8
  1583. @@5:
  1584.         mov    al,fs:[bx]    ; Putting a 8 dot wide part of a row.
  1585.         inc    bx
  1586.         test    al,al
  1587.         jz    @@6
  1588.         mov    al,dl
  1589. @@6:
  1590.         add    al,[PText_Bkg]
  1591.         stosb
  1592.         dec    dh
  1593.         jnz    @@5
  1594.  
  1595.         dec    ch
  1596.         jnz    @@4    ; Next 8 dot wide part.
  1597.  
  1598.         add    di,bp    ; di= next screen row.
  1599.         loop    @@3
  1600.  
  1601.         sub    di,1234h    ; di= next char screen position.
  1602.     ORG $-2
  1603. @@Sub_di LABEL Word
  1604.     ORG $+2
  1605.         jmp    @@2    ; Next char.
  1606. @@Exit:
  1607.         pop    fs
  1608.         ret
  1609.  
  1610. PutText    ENDP
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616. ; ┌─────────────────────────────────────────┐
  1617. ; │          Filling a poligon.             │▒
  1618. ; └─────────────────────────────────────────┘▒
  1619. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1620.  
  1621. ; Input:  ds:si= The vertices of the poligon. (X1,Y1, X2,Y2, ... in words.)
  1622. ;                There must be one free space (2 words), after the coordinates.
  1623. ;         cx= The number of the vertices
  1624. ;         al= The color of the poligon
  1625. ;         ah= Putting method. ( 0-Overwrite, 1-Or, 2-Gouraud )
  1626. ;
  1627. ; Modified regsiter(s): eax,bx,ecx,edx,edi,si,bp,es
  1628. ; Length: 271 bytes.
  1629. ; Last modified: 10-28-95 11:29am
  1630.  
  1631. FillPoli    PROC NEAR
  1632.  
  1633.         mov    [FPMethod],ah
  1634.         push    ax    ; Store the color & the putting method.
  1635.         mov    eax,[si]
  1636.         mov    bx,cx
  1637.         shl    bx,2
  1638.         mov    [si+bx],eax    ; Copy the 1st vertex after the last.
  1639.         cmp    [FPMethod],2
  1640.         jne    @@2
  1641.         mov    ax,[si+4*4+4]    ; When gouraud, copy the 1 color
  1642.         mov    [si+4*4+4+4*4],ax ; after the last.
  1643. @@2:
  1644.         mov    [FPoliMin],7fffh  ; Clear the least,
  1645.         mov    [FPoliMax],8000h  ; and the greatest y coord.
  1646. @@3:
  1647.         push    cx
  1648.         lodsw        ; Get one line.
  1649.         xchg    ax,bx    ; ( Start: X=ax, Y=bx;
  1650.         lodsw        ;   End:   X=dx, Y=cx.)
  1651.         xchg    ax,bx
  1652.         mov    dx,[si]
  1653.         mov    cx,[si+2]
  1654.         mov    bp,O FPoliTemp
  1655.         cmp    cx,bx
  1656.         jl    @@4    ; Jump if the line is on the left side.
  1657.         mov    bp,O FPoliTemp+200*2
  1658. @@4:
  1659.         mov    [FPoliPnt],bp
  1660.         push    si
  1661.         mov    bp,O FillPoliEdge  ; This routine will store the edge.
  1662.         call    DrawEdge    ; Draw an edge of the poligon.
  1663.         cmp    [FPMethod],2
  1664.         jne    @@5    ; Jump if no gouraud nenned.
  1665.         pop    si
  1666.         push    si
  1667.         mov    ax,[si+16]
  1668.         mov    bx,[si-2]
  1669.         mov    dx,[si+20]
  1670.         mov    cx,[si+2]
  1671.         add    [FPoliPnt],200*2*2
  1672.         mov    bp,O FPGouraud
  1673.         call    DrawEdge    ; Draw the color on the edge.
  1674. @@5:
  1675.         pop    si
  1676.         pop    cx
  1677.         loop    @@3    ; Next edge line.
  1678.  
  1679.         mov    es,[ScrAddr]
  1680.         pop    ax    ; Get back color.
  1681.         mov    bx,[FPoliMin]    ; Poli.is between FPoliMin & FPoliMax.
  1682.         cmp    bx,7fffh
  1683.         je    @@14
  1684. @@6:
  1685.         mov    dx,320
  1686.         mov    di,[FPoliTemp][bx]    ; di= Start X coord.
  1687.         cmp    di,dx        ; Jump if beyond the right
  1688.         jge    @@13        ; edge of the screen.
  1689.         test    di,di
  1690.         jns    @@7        ; Jump if it's on the screen.
  1691.         xor    di,di        ; Else put it to the left edge.
  1692. @@7:
  1693.         mov    cx,[FPoliTemp+200*2][bx]  ; cx= End x coord.
  1694.         test    cx,cx        ; Jump if beyond the left
  1695.         js    @@13        ; edge of the screen.
  1696.         cmp    cx,dx
  1697.         jl    @@8        ; Jump if it's on the screen.
  1698.         mov    cx,dx        ; Else put it to the right edge.
  1699. @@8:
  1700.         sub    cx,di        ; cx= the length of the line.
  1701.         jle    @@13        ; Jump if len. <= 0.
  1702.         add    di,[ScrRowsVGA][bx]    ; di= screen position of line.
  1703. ;        test    ah,ah
  1704. ;        jnz    @@9        ; Jump if overwrite mode.
  1705. ;    rep    stosb        ; Put the horizontal line onto the scr.
  1706. ;        jmp    @@13
  1707. @@9:
  1708.         cmp    ah,1
  1709.         jne    @@11
  1710. @@10:
  1711.         or    B es:[di],al        ; 'OR' the horizontal line
  1712.         inc    di        ; onto the screen.
  1713.         loop    @@10
  1714.         jmp    @@13
  1715. @@11:
  1716.         push    ax        ; Draw a gourauded hrz.line.
  1717.         mov    ax,[FPGouTemp+200*2][bx]
  1718.         mov    si,[FPGouTemp][bx]
  1719.         sub    ax,si    ; ax= difference between the colors.
  1720.         shl    ax,8
  1721.         cwd
  1722.         idiv    cx
  1723.         xchg    ax,si    ; si=addition for the colors.
  1724.                 ; ( Hi8 bit fract., Lo8 bit int. )
  1725.         mov    ah,80h    ; ah= color fractational.
  1726.         add    al,[FPG_Col]    ; al= color integer.
  1727.         ror    si,8
  1728. @@12:
  1729.         stosb
  1730.         adc    ax,si
  1731.         loop    @@12
  1732.         pop    ax
  1733. @@13:
  1734.         inc    bx
  1735.         inc    bx
  1736.         cmp    bx,[FPoliMax]
  1737.         jbe    @@6    ; Next horizontal line.
  1738. @@14:
  1739.         ret
  1740. FillPoli    ENDP
  1741.  
  1742. ; This routine stores the x coordinate of the edge.
  1743. FillPoliEdge PROC NEAR
  1744.  
  1745.         cmp    bx,200
  1746.         jae    @@FPE3    ; Jump if Y coord. > 200  or  Y < 0.
  1747.         push    bx
  1748.         shl    bx,1
  1749.         cmp    bx,[FPoliMin]
  1750.         jge    @@FPE1    ; Jump if greter than the min. so far.
  1751.         mov    [FPoliMin],bx    ; Else store the new minimum.
  1752. @@FPE1:
  1753.         cmp    bx,[FPoliMax]
  1754.         jle    @@FPE2    ; Jump if less than the max. so far.
  1755.         mov    [FPoliMax],bx    ; Eles store the new maximum.
  1756. FPE_Store:
  1757. @@FPE2:
  1758.         shld    edx,edi,10h    ; dx= integer part of x coord.
  1759.         add    bx,[FPoliPnt]    ; bx= the y coord. in the edge buffer.
  1760.         mov    [bx],dx    ; Store the x coord.
  1761.         pop    bx
  1762. FPE_Exit:
  1763. @@FPE3:
  1764.         ret
  1765. FillPoliEdge ENDP
  1766.  
  1767. ; This routine stores the color of the edge for gouraud.
  1768. FPGouraud    PROC NEAR
  1769.  
  1770.         cmp    bx,200
  1771.         jae    FPE_Exit    ; Jump if Y coord. > 200  or  Y < 0.
  1772.         push    bx
  1773.         shl    bx,1
  1774.         jmp    FPE_Store
  1775. FPGouraud    ENDP
  1776.  
  1777.  
  1778.  
  1779.  
  1780. ; ┌────────────────────────────────────────────┐
  1781. ; │          Draws an 'edge line'.             │▒
  1782. ; └────────────────────────────────────────────┘▒
  1783. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1784.  
  1785. ; Draws a line. It chages the y coordinate with 1 (up or down) and gives
  1786. ; the x coordinate accords to it. It is not draw a real line.
  1787. ; You have to give the address of a routine what puts the point.
  1788. ; In this routine you must not modify the registers, except edx. You can have
  1789. ; y coordinate in bx, and x coorinate in the edi's higer 16 bits. (Huh!)
  1790. ; Input:  ax,bx= Start point's x and y coordinate
  1791. ;         dx,cx= End point's x and y coordinate
  1792. ;         bp=    The offset address of the routine, what is called every steps
  1793. ;
  1794. ; Modified regsiter(s): eax,bx,ecx,edx,edi,si
  1795. ; Length: 49 bytes.
  1796. ; Last modified: 10-28-95 01:56pm
  1797.  
  1798. DrawEdge    PROC NEAR
  1799.         mov    si,1    ; si will be the y step. ( 1 or -1.)
  1800.         sub    cx,bx    ; cx= Y difference (dY).
  1801.         jz    @@Exit    ; Jump if dY=0, 'coz no line then.
  1802.         jns    @@1    ; Jump if dY>0. Going from up to down.
  1803.         neg    si    ; Else y step is -1.
  1804.         neg    cx    ; cx=ABS(dY)
  1805. @@1:
  1806.         sub    dx,ax    ; dx= X difference (dX).
  1807.         mov    di,ax
  1808.         shl    edi,10h
  1809.         mov    di,0b000h    ; edi= start point's x in fix point.
  1810.         xchg    ax,dx
  1811.         shl    eax,10h
  1812.         cdq        ; edx:eax= dX in fix point.
  1813.         movzx    ecx,cx
  1814.         idiv    ecx    ; eax= dX/dY in fix point.
  1815.         inc    cx    ; Draw loger line by 1.
  1816. @@2:
  1817.         call    bp    ; Call the point-putter.
  1818.         add    edi,eax    ; Step X.
  1819.         add    bx,si    ; Step Y.
  1820.         loop    @@2    ; Next point.
  1821. @@Exit:
  1822.         ret
  1823. DrawEdge    ENDP
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829. ; ┌───────────────────────────────────────────┐
  1830. ; │          Fades down colors by 1.          │▒
  1831. ; └───────────────────────────────────────────┘▒
  1832. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1833.  
  1834. ; Input:  cl= The number of last color to fade. ( Starts with color 0. )
  1835. ;
  1836. ; Modified register(s): al,cx,dx,si,di
  1837. ; Length: 44 bytes.
  1838. ; Last modified: 10-02-95 04:42pm
  1839.  
  1840. FadeDown    PROC NEAR
  1841.         call    Raster    ; Waiting for a vertical retrace.
  1842. @@1:
  1843.         mov    dx,3c7h
  1844.         mov    al,cl
  1845.         out    dx,al    ; Choose color register to read.
  1846.         mov    dl,0c9h
  1847.         mov    ch,3
  1848. @@2:
  1849.         in    al,dx    ; Get one color register's R or G or B.
  1850.         sub    al,1    ; Decrement it.
  1851.         adc    al,0
  1852.         push    ax
  1853.         dec    ch
  1854.         jnz    @@2    ; Next component.
  1855.         dec    dx
  1856.         mov    al,cl
  1857.         out    dx,al    ; Choose color register to write.
  1858.         inc    dx
  1859.         pop    si    ; Popping the components.
  1860.         pop    di
  1861.         pop    ax
  1862.         out    dx,al    ; Set red component.
  1863.         xchg    ax,di
  1864.         out    dx,al    ; Set green component.
  1865.         xchg    ax,si
  1866.         out    dx,al    ; Set blue component.
  1867.         dec    cl
  1868.         cmp    cl,0ffh
  1869.         jne    @@1    ; Next color.
  1870.         ret
  1871. FadeDown    ENDP
  1872.  
  1873.  
  1874.  
  1875.  
  1876. ; ┌───────────────────────────────────────────────────┐
  1877. ; │          Clears the secopndary screen.            │▒
  1878. ; └───────────────────────────────────────────────────┘▒
  1879. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1880.  
  1881. ; Modified register(s): eax,cx,di,es
  1882. ; Length: 9 bytes.
  1883. ; Last modified: 10-02-95 04:42pm
  1884. ; The next routine must be 'Fill0'!
  1885.  
  1886. ClrScr2    PROC NEAR
  1887.         mov    es,[ScrAddr]
  1888.         mov    cx,16000
  1889. ClrScr2    ENDP
  1890.  
  1891.  
  1892.  
  1893.  
  1894. ; ┌───────────────────────────────────────────────┐
  1895. ; │          Fills an area with zeros.            │▒
  1896. ; └───────────────────────────────────────────────┘▒
  1897. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1898.  
  1899. ; Fills an area pointed by es:0 with 0 words. The length of filling is cx words.
  1900. ; Input:  es= Segment address of filling
  1901. ;         cx= Length of filling in words.
  1902. ;         df= Cleared.
  1903. ; Modified register(s): eax,cx,di
  1904. ; Length: 9 bytes.
  1905. ; Last modified: 10-02-95 04:42pm
  1906.  
  1907. Fill0    PROC NEAR
  1908.  
  1909.         xor    di,di
  1910. Fill0_2:
  1911.         xor    eax,eax
  1912.     rep    stosd
  1913.         ret
  1914. Fill0    ENDP
  1915.  
  1916.  
  1917.  
  1918.  
  1919. ; ┌───────────────────────────────────────────────┐
  1920. ; │          Waits for vertical retrace.          │▒
  1921. ; └───────────────────────────────────────────────┘▒
  1922. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1923.  
  1924. ; Modified register(s): al,dx
  1925. ; Length: 14 bytes.
  1926. ; Last modified: 08-28-95 12:27pm
  1927.  
  1928. Raster    PROC NEAR
  1929.         mov    dx,3dah
  1930. @@1:
  1931.         in    al,dx    ; Waiting for finish current vert.ret.
  1932.         test    al,8
  1933.         jnz    @@1
  1934. @@2:
  1935.         in    al,dx    ; Waiting for vertical retrace.
  1936.         test    al,8
  1937.         jz    @@2
  1938.         ret
  1939. Raster    ENDP
  1940.  
  1941.  
  1942.  
  1943.  
  1944. ; ┌───────────────────────────────────────────┐
  1945. ; │          Waits for some seconds.          │▒
  1946. ; └───────────────────────────────────────────┘▒
  1947. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1948.  
  1949. ; Input:  ax= The time for waiting (in 1/100 secs.) + 8000h
  1950. ; Modified register(s): nothing
  1951. ; Length: 11 bytes.
  1952. ; Last modified: 10-03-95 08:31pm
  1953.  
  1954. Delay    PROC NEAR
  1955.         mov    [Timer_Cnt],ax
  1956. @@Delay_Loop:
  1957.         cmp    B [Timer_Cnt+1],0
  1958.         js    @@Delay_Loop
  1959.         ret
  1960. Delay    ENDP
  1961.  
  1962.  
  1963.  
  1964. ; ┌─────────────────────────────────────────────────────────────────────┐
  1965. ; │          Copyes the secondary screen onto the real screen.          │▒
  1966. ; └─────────────────────────────────────────────────────────────────────┘▒
  1967. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1968.  
  1969. ; Modified register(s): ax, cx, di, si, ds, es
  1970. ; Length: 23 bytes.
  1971. ; Last modified: 10-07-95 05:12pm
  1972.  
  1973. Copy_Scr    PROC NEAR
  1974.         mov    ds,[ScrAddr]
  1975.         mov    ax,0a000h
  1976.         mov    es,ax
  1977.         xor    di,di
  1978.         xor    si,si
  1979.         mov    cx,16000
  1980.         call    Raster
  1981.     rep    movsd        ; Then copy the sec.scr to the real.
  1982.         ret
  1983. Copy_Scr    ENDP
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989. ; ┌────────────────────────────────────┐
  1990. ; │          Sinus generator.          │▒
  1991. ; └────────────────────────────────────┘▒
  1992. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1993.  
  1994. ; Makes a sinus-cosinus table.
  1995. ; Uses the taylor-progression of the sinus from 0 to pi/2, and copies
  1996. ; this part of the function to the others.
  1997. ; sin(x)≈x-(x^3/3!)+(x^5/5!)
  1998. ;
  1999. ; Input:  ds,es= Sinus table's segment
  2000. ; Modified register(s): eax,bx,cx,edx,di,si,bp
  2001. ; Length: 86 bytes.
  2002. ; Last modified: 08-27-95 11:10pm
  2003.  
  2004. SinGen    PROC NEAR
  2005.  
  2006.         mov    di,O SinTab+128*4
  2007.         mov    si,O SinTab+127*4
  2008.         mov    ecx,381        ; 381≈pi/2*256. (With a little
  2009.                     ; neglect.)
  2010. @@1:
  2011.         movzx    eax,cx
  2012.         mul    ecx
  2013.         mul    ecx
  2014.         div    [@@Fact3]
  2015.         mov    bp,ax        ; bp= x^3/3!
  2016.  
  2017.         mul    ecx
  2018.         mul    ecx
  2019.         div    [@@Fact5]        ; ax= x^5/5!
  2020.  
  2021.         mov    bh,cl
  2022.         mov    bl,0
  2023.         add    ax,bx
  2024.         sub    ax,bp        ; ax=sin(x)
  2025.  
  2026.         stosd            ; Store 2nd quater.
  2027.         mov    [si],eax        ; Store 1st quater.
  2028.         mov    [si+512*4],eax        ; Store 5th quater.
  2029.         neg    eax
  2030.         mov    [di+255*4],eax         ; Store 4th quater.
  2031.         mov    [si+256*4],eax     ; Store 3rd quater.
  2032.         sub    si,4
  2033.         sub    cx,3
  2034.         jnc    @@1
  2035.         ret
  2036. @@Fact3    dd 6*100h
  2037. @@Fact5    dd 20*10000h
  2038. SinGen    ENDP
  2039.  
  2040.  
  2041.  
  2042.  
  2043. ; ┌───────────────────────────────────┐
  2044. ; │          Makes charset.           │▒
  2045. ; └───────────────────────────────────┘▒
  2046. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2047.  
  2048. ; Makes the big and smoothed charset.
  2049. ; Modified register(s): ax,bx,cx,dx,di,bp,fs
  2050. ; Length: 167 bytes.
  2051. ; Last modified: 10-28-95 02:05pm
  2052.  
  2053. MakeChars    PROC NEAR
  2054.  
  2055.         mov    ax,1130h
  2056.         mov    bh,6    ; Get the 8x16 ROM charset address
  2057.         int    10h    ; to es:bp.
  2058.  
  2059.         add    bp,32*16    ; es:bp point to the space character.
  2060.  
  2061.         mov    fs,[ChrAddr]
  2062. ; Making big chars.
  2063.         xor    di,di
  2064.         mov    bx,4040h    ; We've got free space for 64 chars.
  2065. @@1:
  2066.         mov    cl,16
  2067. @@2:
  2068.         mov    al,es:[bp]
  2069.         inc    bp
  2070.         mov    ch,8
  2071. @@3:
  2072.         shl    al,1    ; Make one big dot.
  2073.         setc    dl
  2074.         mov    dh,dl
  2075.         push    dx
  2076.         shl    edx,10h
  2077.         pop    dx
  2078.         mov    fs:[di],edx
  2079.         mov    fs:[di+32],edx
  2080.         add    di,4
  2081.         dec    ch
  2082.         jnz    @@3
  2083.         add    di,32
  2084.         loop    @@2
  2085.         dec    bl
  2086.         jnz    @@1
  2087.  
  2088. ; Smoothing chars.
  2089. ; bh=40h here.
  2090.         xor    di,di
  2091.         mov    dx,303h
  2092.         mov    al,1
  2093. @@4:
  2094.         mov    cl,15
  2095. @@5:
  2096.         mov    ch,8
  2097. @@6:
  2098.         cmp    B fs:[di],al        ; Jump if dot is here.
  2099.         jne    @@10
  2100.         cmp    ch,8
  2101.         je    @@8        ; Jump at the left edge.
  2102.         cmp    B fs:[di+32*2-1],al
  2103.         jne    @@8        ; Jump if no dot at letf-below.
  2104.         cmp    B fs:[di-1],al
  2105.         je    @@7        ; Jump if dot at left.
  2106.         mov    fs:[di+32-2],dx    ; Put a 3angle at left. /.
  2107. @@7:
  2108.         cmp    B fs:[di+32*2],al
  2109.         je    @@8        ; Jump if dot at below.
  2110.         mov    fs:[di+32*2],dx    ; Put a 3angle at rght-blw. `/
  2111. @@8:
  2112.         cmp    ch,1
  2113.         je    @@10        ; Jump at the right edge.
  2114.         cmp    B fs:[di+32*2+4],al
  2115.         jne    @@10        ; Jump if no dot at right-below.
  2116.         cmp    B fs:[di+4],al
  2117.         je    @@9        ; Jump if dot at rigth.
  2118.         mov    fs:[di+32+4],dx    ; Put 3angle at right. .\
  2119. @@9:
  2120.         cmp    B fs:[di+32*4],al
  2121.         je    @@10        ; Jump if dot at below.
  2122.         mov    fs:[di+32*2+2],dx    ; Put 3angle at below. \'
  2123. @@10:
  2124.         add    di,4
  2125.         dec    ch
  2126.         jnz    @@6        ; Check next dot.
  2127.         add    di,32
  2128.         dec    cx
  2129.         jnz    @@5        ; Check next row.
  2130.         add    di,32*2
  2131.         dec    bh
  2132.         jnz    @@4        ; Check next char.
  2133.         ret
  2134. MakeChars    ENDP
  2135.  
  2136.  
  2137.  
  2138.  
  2139. ; ┌───────────────────────────────────────────────┐
  2140. ; │          Puts a gourauded object.             │▒
  2141. ; └───────────────────────────────────────────────┘▒
  2142. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2143.  
  2144. ; Input:  ds:si= Address of the object to put.
  2145. ; Modified register(s): eax,bx,cx,edx,di,si,bp,es
  2146. ; Length: 154 bytes.
  2147. ; Last modified: 10-28-95 02:47pm
  2148.  
  2149. Put_Obj    PROC NEAR
  2150.  
  2151.         push    cs
  2152.         pop    es
  2153.  
  2154.         lodsw
  2155.         mov    cx,ax    ; cx= number of vertices.
  2156.  
  2157. ; Rotating the vertices.
  2158.         mov    di,O TempArea
  2159.         push    cx di di
  2160.         call    Rotate    ; si=original, di=rotated, cx=number.
  2161.         pop    di
  2162.  
  2163. ; Sorting the poligons, by their weightpoints.
  2164.         mov    [POPoliAdr],si
  2165.         call    WPSort    ; di=adr.rotd.,si=adr.polis; to WPTemp.
  2166.         pop    si cx
  2167.  
  2168. ; Transforming the vertices from 3D to 2D.
  2169.         push    si
  2170.         mov    si,O TempArea
  2171.         call    Transform    ; si=adr.of rotated,cx=num.of vertices.
  2172.         pop    si
  2173.  
  2174.         mov    bp,[POPoliAdr]
  2175.         mov    cx,[bp]    ; cx= number of poligons.
  2176.         inc    bp
  2177.         inc    bp
  2178.         mov    bx,4
  2179. @@1:
  2180.         pusha
  2181.         mov    bx,W [WPTemp][bx]    ; bx= number of poligon to put.
  2182.         shl    bx,3
  2183.         add    bx,bp
  2184.         push    cs
  2185.         pop    es
  2186.         mov    di,O POTemp
  2187.         mov    cl,4    ; There are 4 vertices in a square. :)
  2188. @@2:
  2189.         push    si    ; Count the color of the vertex by
  2190.         mov    bp,[bx]    ; its distance from the light source
  2191.         inc    bx    ; and make the coordinates of the
  2192.         inc    bx    ; poligon on the screen.
  2193.         shl    bp,4
  2194.         add    si,bp
  2195.         lodsd
  2196.         add    ax,160    ; XCenter=160.
  2197.         stosw        ; Store its X coordinate.
  2198.         lodsd
  2199.         add    ax,100    ; YCenter=100.
  2200.         stosw        ; Store its X coordinate.
  2201.         lodsd
  2202.         sub    eax,[PO_XLight]
  2203.         imul    eax
  2204.         mov    ebp,edx
  2205.         lodsd
  2206.         sub    eax,[PO_ZLight]
  2207.         imul    eax
  2208.         add    ebp,edx
  2209.         mov    eax,[LS_Circ]
  2210.         imul    ebp
  2211.         mov    ax,2ch
  2212.         sub    ax,dx
  2213.         jnc    @@3
  2214.         xor    ax,ax
  2215. @@3:
  2216.         add    ax,13h    ; Make ambient light.
  2217.         mov    [di+16],ax
  2218.         pop    si
  2219.         dec    cl
  2220.         jnz    @@2    ; Do the next vertex.
  2221.  
  2222.         mov    si,O POTemp    ; si=adr.of the poli's coordinates.
  2223.         mov    ah,2    ; Put by gouraud.
  2224.         mov    cx,4    ; It's got 4 vertices.
  2225.         call    FillPoli    ; Put the poligon
  2226. @@4:
  2227.         popa
  2228.         add    bx,8
  2229.         loop    @@1    ; Do the next poligon.
  2230.  
  2231.         ret
  2232.  
  2233.  
  2234. Put_Obj    ENDP
  2235.  
  2236.  
  2237.  
  2238.  
  2239. ; ┌───────────────────────────────────────────────────┐
  2240. ; │          Sorting by the weightpoints.             │▒
  2241. ; └───────────────────────────────────────────────────┘▒
  2242. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2243.  
  2244. ; Input:  ds:si= Address of the object's poligons. (1st W is the num.of polis.)
  2245. ; Modified register(s): eax,ebx,cx,edx,di,si,ebp
  2246. ; Length: 52 bytes.
  2247. ; Last modified: 10-28-95 05:57pm
  2248. ; Quick Sort must be the following routine!
  2249.  
  2250. WPSort    PROC NEAR
  2251.  
  2252.         lodsw
  2253.         add    di,8
  2254.         mov    cx,ax    ; cx= number of poligons.
  2255.         mov    bx,O WPTemp
  2256.         xor    eax,eax
  2257.         push    cx bx
  2258. @@1:
  2259.         xor    edx,edx
  2260.         mov    ch,4
  2261. @@2:
  2262.         mov    bp,[si]    ; bp= number of vertex of the poligon.
  2263.         inc    si
  2264.         inc    si
  2265.         shl    bp,4
  2266.         add    edx,[di+bp]    ; edx+= Z coordinate.
  2267.         dec    ch
  2268.         jnz    @@2
  2269.         neg    edx
  2270.         mov    [bx],edx
  2271.         mov    [bx+4],eax
  2272.         inc    eax
  2273.         add    bx,8
  2274.         loop    @@1    ; Next poligon.
  2275.         pop    si cx
  2276.         ;jmp    QuickSort
  2277.  
  2278. WPSort    ENDP
  2279.  
  2280.  
  2281.  
  2282. ; ┌──────────────────────────────────┐
  2283. ; │          Quick Sort.             │▒
  2284. ; └──────────────────────────────────┘▒
  2285. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2286.  
  2287. ; Input:  ds:si= Address of the object's poligons. (1st W is the num.of polis.)
  2288. ; Modified register(s): eax,ebx,dx,di,ebp
  2289. ; Length: 116 bytes.
  2290. ; Last modified: 10-28-95 06:13pm
  2291.  
  2292. QuickSort    PROC NEAR
  2293.  
  2294.         mov    di,cx
  2295.         shl    di,3
  2296.         add    di,si
  2297.         mov    dx,8
  2298.         mov    ebx,7fffffffh
  2299.         mov    ebp,80000000h
  2300. @@QSR:
  2301.         cmp    di,si
  2302.         je    @@Exit
  2303.         mov    eax,ebx
  2304.         add    eax,ebp
  2305.         sar    eax,1
  2306.         cmp    eax,ebp
  2307.         je    @@Exit
  2308.         push    si di ebp
  2309.         call    @@Sort    ; Sort it.
  2310.         pop    ebp di
  2311.         pushad
  2312.         mov    ebp,eax
  2313.         call    @@QSR    ; Sort the first half.
  2314.         popad
  2315.         pop    di
  2316.         xchg    di,si
  2317.         mov    ebx,eax
  2318.         jmp    @@QSR    ; Sort the second half.
  2319. @@Exit:
  2320.         ret
  2321.  
  2322. @@Sort:
  2323.         sub    si,dx
  2324. @@S1:
  2325.         add    si,dx    ; si goes from the beginning.
  2326.         cmp    si,di
  2327.         jae    @@Exit
  2328.         cmp    eax,[si]
  2329.         jge    @@S1    ; si goes until the order is right.
  2330. @@S2:
  2331.         sub    di,dx    ; di goes from the end.
  2332.         cmp    di,si
  2333.         jbe    @@Exit
  2334.         cmp    eax,[di]
  2335.         jl    @@S2    ; di goes until the order is right.
  2336.         mov    ebp,[si]    ; Change the items.
  2337.         xchg    ebp,[di]
  2338.         mov    [si],ebp
  2339.         mov    ebp,[si+4]
  2340.         xchg    ebp,[di+4]
  2341.         mov    [si+4],ebp
  2342.         jmp    @@S1
  2343.  
  2344. QuickSort    ENDP
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350. ; ┌────────────────────────────────┐
  2351. ; │          Rotating.             │▒
  2352. ; └────────────────────────────────┘▒
  2353. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2354.  
  2355. ; Input:  ds:si= Address of the vertices to rotatae.
  2356. ;         ds:di= Address of the buffer for rotated coordinates.
  2357. ;         cx= Number of vertices to rotate.
  2358. ; Modified register(s): eax,ebx,cx,edx,di,si,ebp
  2359. ; Length: 158 bytes.
  2360. ; Last modified: 10-28-95 06:23pm
  2361.  
  2362. Rotate    PROC NEAR
  2363.  
  2364. @@1:
  2365.         lodsd
  2366.         add    eax,[Trans_XAdd]
  2367.         mov    [di],eax
  2368.         lodsd
  2369.         add    eax,[Trans_YAdd]
  2370.         mov    [di+4],eax
  2371.         lodsd
  2372.         add    eax,[Trans_ZAdd]
  2373.         mov    [di+8],eax
  2374.  
  2375.         mov    bp,[Rot_Alfa]
  2376.         and    bp,511
  2377.         shl    bp,2
  2378.         mov    ebx,[CosTab][bp]
  2379.         mov    ebp,[SinTab][bp]
  2380.         call    @@Rotate1    ; Rotate around the Z axis.
  2381.  
  2382.         mov    bp,[Rot_Beta]
  2383.         and    bp,511
  2384.         shl    bp,2
  2385.         mov    ebx,[CosTab][bp]
  2386.         mov    ebp,[SinTab][bp]
  2387.         call    @@Rotate1    ; Rotate around the Y axis.
  2388.  
  2389.         mov    eax,[di-8]
  2390.         add    di,4
  2391.         stosd
  2392.         loop    @@1
  2393.         ret
  2394.  
  2395. @@Rotate1:
  2396.         mov    eax,[di]
  2397.         imul    ebx    ; X= X*cos(alfa)-Y*sin(alfa).
  2398.         shld    edx,eax,10h
  2399.         push    edx
  2400.         mov    eax,[di+4]
  2401.         imul    ebp
  2402.         shld    edx,eax,10h
  2403.         pop    eax
  2404.         sub    eax,edx
  2405.         xchg    eax,[di]
  2406.         imul    ebp    ; Y= Y*cos(alfa)+X*sin(alfa).
  2407.         shld    edx,eax,10h
  2408.         push    edx
  2409.         add    di,4
  2410.         mov    eax,[di]
  2411.         imul    ebx
  2412.         shld    edx,eax,10h
  2413.         pop    eax
  2414.         add    eax,edx
  2415.         mov    [di],eax
  2416.         ret
  2417. Rotate    ENDP
  2418.  
  2419.  
  2420.  
  2421.  
  2422. ; ┌───────────────────────────────────────────────┐
  2423. ; │          Transforms from 3D to 2D.            │▒
  2424. ; └───────────────────────────────────────────────┘▒
  2425. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2426.  
  2427. ; Input:  ds:si= Address of the vertices to transform.
  2428. ;         cx= Number of vertices to transform.
  2429. ;         es=ds.
  2430. ; Modified register(s): eax,ebx,cx,edx,di,si,ebp
  2431. ; Length: 46 bytes.
  2432. ; Last modified: 10-28-95 06:28pm
  2433.  
  2434. Transform    PROC NEAR
  2435.  
  2436.         mov    di,si
  2437.         movzx    ebx,[Zoom_Factor]
  2438. @@1:
  2439.         mov    ebp,[si+8]
  2440.         add    ebp,400*10000h
  2441.         lodsd        ; Xh= X/(Z+400) * Zoom_Factor
  2442.         imul    ebx
  2443.         idiv    ebp
  2444.         stosd
  2445.         lodsd        ; Xh= X/(Z+400) * Zoom_Factor
  2446.         imul    ebx
  2447.         idiv    ebp
  2448.         stosd
  2449.         movsd
  2450.         movsd
  2451.         loop    @@1    ; Do the next vertex.
  2452.         ret
  2453. Transform    ENDP
  2454.  
  2455.  
  2456.  
  2457.  
  2458. ; ┌────────────────────────────────────────────────────┐
  2459. ; │          Makes an object from a contour.           │▒
  2460. ; └────────────────────────────────────────────────────┘▒
  2461. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2462.  
  2463. ; Input:  ds:si= Address of the vertices of the contour.
  2464. ;         cs:di= Address of the room for the object
  2465. ;         bx= Number of vertices of the contour.
  2466. ; Modified register(s): eax,cx,di,es
  2467. ; Length: 142 bytes.
  2468. ; Last modified: 10-31-95 04:52pm
  2469.  
  2470. Make_Obj    PROC NEAR
  2471. MkObj_Circ_Div=6        ; Rotating angle. Divisor of 2*PI.
  2472.  
  2473.         push    cs
  2474.         pop    es
  2475.         xor    eax,eax    ; Clear the coordinates' additions.
  2476.         mov    [Trans_XAdd],eax
  2477.         mov    [Trans_YAdd],eax
  2478.         mov    [Trans_ZAdd],eax
  2479.         mov    ax,MkObj_Circ_Div
  2480.         mov    cx,ax
  2481.         mul    bx    ; ax= number of vertices in the object.
  2482.         stosw        ; Store the number of vertices.
  2483.         xor    ax,ax
  2484.         mov    [Rot_Beta],ax    ; Clear the angle beta.
  2485. @@1:
  2486.         mov    [Rot_Alfa],ax
  2487.         push    ax bx cx si
  2488.         mov    cx,bx
  2489. @@2:
  2490.         lodsb
  2491.         cbw
  2492.         cwde
  2493.         shl    eax,0fh    ; Copy the 3 coordinates to TempArea.
  2494.         mov    D [TempArea],eax
  2495.         xor    eax,eax
  2496.         mov    D [TempArea+4],eax
  2497.         lodsb
  2498.         shl    eax,0fh
  2499.         mov    D [TempArea+8],eax
  2500.  
  2501.         push    cx si
  2502.         mov    si,O TempArea
  2503.         mov    cx,1
  2504.         call    Rotate    ; Rotata a vertex.
  2505.         sub    di,4
  2506.         pop    si cx
  2507.         loop    @@2    ; Do the next vertex.
  2508.         pop    si cx bx ax
  2509.         add    ax,512/MkObj_Circ_Div
  2510.         loop    @@1    ; Do the next phase.
  2511.  
  2512.         mov    ax,MkObj_Circ_Div
  2513.         mul    bx
  2514.         mov    bp,ax
  2515.         sub    ax,MkObj_Circ_Div
  2516.         mov    cx,ax    ; ax= number of poligons.
  2517.         stosw        ; Store the number of poligons.
  2518.         mov    si,1
  2519.         mov    cl,MkObj_Circ_Div
  2520. @@3:
  2521.         mov    ch,bl
  2522.         dec    ch
  2523. @@4:
  2524.         mov    ax,si    ; Make a poligon.
  2525.         stosw
  2526.         dec    ax
  2527.         stosw
  2528.         add    ax,bx
  2529.         cmp    ax,bp
  2530.         jb    @@5
  2531.         sub    ax,bp
  2532. @@5:
  2533.         stosw
  2534.         inc    ax
  2535.         stosw
  2536.         inc    si
  2537.         dec    ch
  2538.         jnz    @@4    ; Do the next poligon.
  2539.         inc    si
  2540.         loop    @@3    ; Do the next phase.
  2541. Timer_Blank:
  2542.         ret
  2543. Make_Obj    ENDP
  2544.  
  2545.  
  2546.  
  2547.  
  2548. ; ┌────────────────────────────────────┐
  2549. ; │          Timer interrupt.          │▒
  2550. ; └────────────────────────────────────┘▒
  2551. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2552.  
  2553. ; Decrases the 'Timer_Cnt' in every 10th ms.
  2554. ;
  2555. ; Length: 12 bytes.
  2556. ; Last modified: 08-27-95 11:17pm
  2557.  
  2558. TimerIRQ    PROC
  2559.         push    ax ds cs
  2560.         pop    ds
  2561.         dec    [Timer_Cnt]        ; Decrase counter.
  2562.         call    [Timer_Routine]    ; Calling a control routine.
  2563.         mov    al,20h        ; Send EnfOfInterrupt sign.
  2564.         out    20h,al
  2565.         pop    ds ax
  2566.         iret
  2567. TimerIRQ    ENDP
  2568.  
  2569.  
  2570.  
  2571.  
  2572. ; ┌───────────────────────────────────────┐
  2573. ; │          Keyboard interrupt.          │▒
  2574. ; └───────────────────────────────────────┘▒
  2575. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2576.  
  2577. ; Aborts the program when ESC was pressed.
  2578. ;
  2579. ; Length: 36 bytes.
  2580. ; Last modified: 08-28-95 02:50pm
  2581.  
  2582. KeyboardIRQ PROC
  2583.         push    ax
  2584.         mov    al,20h        ; Send EnfOfInterrupt sign.
  2585.         out    20h,al
  2586.  
  2587.         in    al,60h        ; Get the pressed scan-code.
  2588.         dec    al
  2589.         jz    @@1        ; Jump if it is ESC.
  2590.         pop    ax
  2591.         iret
  2592. @@1:
  2593.         push    cs        ; Set back ds.
  2594.         pop    ds
  2595.         mov    ss,[StackSegment]    ; Set back ss.
  2596.         mov    sp,[StackPointer]    ; Set back sp.
  2597.         mov    bl,40h
  2598. @@2:
  2599.         mov    cl,0ffh
  2600.         call    FadeDown
  2601.         dec    bl
  2602.         jnz    @@2
  2603.  
  2604.         jmp    Abort_Code        ; Abort the program.
  2605.  
  2606. KeyboardIRQ ENDP
  2607.  
  2608.  
  2609.  
  2610.  
  2611. ; ┌───────────────────────────────┐
  2612. ; │         Variables.            │▒
  2613. ; └───────────────────────────────┘▒
  2614. ;  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2615.  
  2616.  
  2617.  
  2618. ; General variables.
  2619.  
  2620. ALIGN 4
  2621. Old_Timer    LABEL DWord    ; The original INT8 vector.
  2622.     ORG $+4
  2623. Timer_Cnt    LABEL Word    ; Timer counter. Decrased in every 10th ms.
  2624.     ORG $+2
  2625. Timer_Routine LABEL Word    ; A definable timer routine.
  2626.     ORG $+2
  2627. Old_Kbd    LABEL DWord    ; The original INT9 vector.
  2628.     ORG $+4
  2629. StackSegment LABEL Word    ; The stored SS for aborting.
  2630.     ORG $+2
  2631. StackPointer LABEL Word    ; The stored SP for aborting.
  2632.     ORG $+2
  2633.  
  2634. ScrAddr    LABEL Word    ; Segment address of the seconday screen.
  2635.     ORG $+2
  2636. ScrOffs    LABEL Word    ; Offset address of the secondary screen.
  2637.     ORG $+2
  2638. ChrAddr    LABEL Word    ; Segment address of the big characters.
  2639.     ORG $+4
  2640.  
  2641. ScrRowsVGA LABEL Word    ; Offset of rows in a VGA screen.
  2642.     ORG $+200*2
  2643.  
  2644. SinTab    LABEL DWord    ; The sinus table.
  2645.     ORG $+128*4
  2646. CosTab    LABEL DWord    ; The cosinus table.
  2647.     ORG $+512*4
  2648. CosAdd=O CosTab - O SinTab  ; Addition to the addr.of the sintab to get the
  2649.                             ; costab's addr.
  2650.  
  2651. ; Mandelbrot zoomer's variables
  2652.  
  2653. MZ_ScrSeg    LABEL Word    ; Secondary screen's address.
  2654.     ORG $+2
  2655. MZ_XorScr    LABEL Word    ; XOR number to get the third screen's address.
  2656.     ORG $+2
  2657. MZ_Next    LABEL Byte    ; Bit0 is set, when the next Mandy-phase is ready.
  2658.     ORG $+1
  2659. MZ_Finish    LABEL Byte    ; 1, when Mandelbrot-part is over.
  2660.     ORG $+1
  2661. MZ_TextPos LABEL Word    ; Addr.for texts to put while Mandelbrot-part.
  2662.     ORG $+2
  2663. MZ_RowCnt    LABEL Byte    ; A counter to indicate, no more non-zero value
  2664.     ORG $+4    ; in the Mandelbrot.
  2665.  
  2666.  
  2667. ; Broken screen's variables.
  2668.  
  2669. BrkTemp    LABEL Word    ; A temporary area for storing poligons' vertices.
  2670.     ORG $+5*2*2
  2671. ;BrkLTemp    LABEL Word    ; A tmp.area for storing breaking line.
  2672. ;    ORG $+BrkPntNum*2
  2673. ;BrkPoliXC    LABEL Word    ; X center of the light.
  2674. ;    ORG $+2
  2675. ;BrkPoliYC    LABEL Word    ; Y center of the light.
  2676. ;    ORG $+2
  2677. BrkPoliXS    LABEL Word    ; The position of the refracted line.
  2678.     ORG $+4
  2679.  
  2680.  
  2681. ; Putting a text' variable
  2682.  
  2683. PText_Bkg    LABEL Byte    ; The background of the text.
  2684.     ORG $+4
  2685.  
  2686.  
  2687. ; Putting an object's variables
  2688.  
  2689. POPoliAdr    LABEL    Word    ; Addr.of the poligons.
  2690.     ORG $+4
  2691. POTemp    LABEL DWord    ; Tmp.area for the vertices of a poligon.
  2692.     ORG $+128
  2693.  
  2694.  
  2695. ; Filling a convex poligon's variables.
  2696.  
  2697. FPoliTemp    LABEL Word    ; The edge of the poligon of the put.
  2698.     ORG $+200*4
  2699. FPGouTemp    LABEL Word    ; The colors of the edges.
  2700.     ORG $+200*4
  2701. FPoliPnt    LABEL Word    ; The pointer to FPoliTemp.
  2702.     ORG $+2
  2703. FPoliMin    LABEL Word    ; The minimum of the Y coordinates.
  2704.     ORG $+2
  2705. FPoliMax    LABEL Word    ; The maximum of the Y coordinates.
  2706.     ORG $+2
  2707. FPMethod    LABEL Byte    ; The method of the putting.
  2708.     ORG $+1
  2709. FPG_Col    LABEL Byte    ; The color of the poligon.
  2710.     ORG $+1
  2711.  
  2712.  
  2713. ; Transfom's variables
  2714.  
  2715. Trans_XAdd LABEL DWord    ; The additiions for coordinates.
  2716.     ORG $+4
  2717. Trans_YAdd LABEL DWord
  2718.     ORG $+4
  2719. Trans_ZAdd LABEL DWord
  2720.     ORG $+4
  2721.  
  2722.  
  2723. ; Sorting by the weigthpoints' variables
  2724.  
  2725. WPTemp    LABEL DWord    ; The quick sort makes the sorting here.
  2726.     ORG $+200*8
  2727.  
  2728.  
  2729. ; Chess figures' position
  2730.  
  2731. ChFig_Dat LABEL        ; Data of the chess-figures.
  2732.     ORG $+FigsOn*4
  2733. ChFig_Srt    LABEL DWord    ; The sorted figures' positions.
  2734.     ORG $+FigsOn*20
  2735.  
  2736.  
  2737. ; Chess figures' objects
  2738.  
  2739. Chess_Table LABEL    ; The chess-table's object.
  2740.     ORG $+1232
  2741. Pawn    LABEL        ; The figres' object.
  2742.     ORG $+(4+ PVtx*12*MkObj_Circ_Div+ (PVtx-1)*8*MkObj_Circ_Div)
  2743. Bishop    LABEL
  2744.     ORG $+(4+ BVtx*12*MkObj_Circ_Div+ (BVtx-1)*8*MkObj_Circ_Div)
  2745. Castle    LABEL
  2746.     ORG $+(4+ CVtx*12*MkObj_Circ_Div+ (CVtx-1)*8*MkObj_Circ_Div)
  2747. Queen    LABEL
  2748.     ORG $+(4+ QVtx*12*MkObj_Circ_Div+ (QVtx-1)*8*MkObj_Circ_Div)
  2749. King    LABEL
  2750.     ORG $+(4+ KVtx*12*MkObj_Circ_Div+ (KVtx-1)*8*MkObj_Circ_Div)
  2751.  
  2752. ALIGN 4
  2753. Old_Values LABEL
  2754.     ORG $+2
  2755. Rot_Alfa    LABEL Word    ; The angles of rotating.
  2756.     ORG $+4
  2757. Rot_Beta    LABEL Word
  2758.     ORG $+4
  2759. Zoom_Factor LABEL Word    ; The zooming factor of trasforming.
  2760.     ORG $+2
  2761. PO_XLight    LABEL DWord    ; The light source's coordinates.
  2762.     ORG $+4
  2763. PO_ZLight    LABEL DWord
  2764.     ORG $+4
  2765. LS_Circ    LABEL DWord    ; The light circle's size.
  2766.     ORG $+4
  2767. Eye_XAdd    LABEL DWord    ; Our eye's position.
  2768.     ORG $+4
  2769. Eye_YAdd    LABEL DWord
  2770.     ORG $+4
  2771. Eye_ZAdd    LABEL DWord
  2772.     ORG $+4
  2773. ChFig_Pos LABEL DWord    ; The positions of the chess figures.
  2774.     ORG $+FigsOn*12
  2775.  
  2776. ALIGN 4
  2777. New_Values LABEL        ; The table of changed values for moving.
  2778.     ORG $+400
  2779.  
  2780.  
  2781. ; Temporary area.
  2782.  
  2783. TempArea    LABEL        ; The temporary area up to the stack.
  2784.  
  2785.  
  2786. code ENDS
  2787.  
  2788. END Main
  2789.