home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 286_02 / hlnlmt.asm < prev    next >
Assembly Source File  |  1989-05-25  |  8KB  |  362 lines

  1. FD_SIZE equ     20
  2. oa      equ     4
  3.  
  4. DGROUP  group   _DATA
  5. _DATA   segment word public 'DATA'
  6.         assume  ds:DGROUP
  7.  
  8.         extrn   _DOTVALUE:word,_LEFTWORD:word,_RIGHTWORD:word
  9.  
  10.         extrn   wrtvec:word
  11.         extrn   _WINX1:word,_WINX2:word,_WINY1:word,_WINY2:word
  12.  
  13. vsa     dw      ?
  14. voa     dw      ?
  15. voa2    dw      ?
  16. fflag   dw      ?
  17. _DATA   ends
  18.  
  19. _TEXT   segment byte public 'CODE'
  20.         assume  cs:_TEXT,ds:DGROUP
  21.  
  22.         extrn   $calc:near, $read:near, $aread:near, $write:near
  23.  
  24.         public  _hlnlmt, _skipright
  25. ;
  26. ;  hlnlmt(x,y,boundary,fill_pattern,&leftx, &rightx);
  27. ;
  28. _hlnlmt proc    near
  29.         push    bp
  30.         mov     bp,sp
  31.         push    di
  32.         mov     fflag,0
  33.         mov     ax,[bp+oa]
  34.         mov     bx,[bp+oa+2]
  35.         mov     di,ax
  36.         and     di,0fff0h
  37.         call    $calc
  38.         mov     es,ax
  39.         mov     vsa,ax
  40.         mov     voa,bx
  41.         mov     voa2,bx
  42. IFDEF JLASER
  43.         call    $read
  44. ELSE
  45.         mov     ax,es:[bx]
  46. ENDIF
  47.         xor     ax,[bp+oa+4]
  48.         mov     cx,di          ; code for handling window
  49.         cmp     cx,_WINX1
  50.         jae     hlt510
  51.         mov     bx,_WINX1
  52.         and     bx,0fh
  53.         shl     bx,1
  54.         or      ax,_DOTVALUE[bx-2]
  55. hlt510: add     cx,15
  56.         cmp     cx,_WINX2
  57.         jbe     hlt520
  58.         mov     bx,_WINX2
  59.         and     bx,0fh
  60.         shl     bx,1
  61.         or      ax,_DOTVALUE[bx+2]
  62. hlt520: push    ax
  63.         mov     bx,[bp+oa]
  64.         and     bx,0fh
  65.         shl     bx,1
  66.         test    ax,_DOTVALUE[bx]
  67.         jz      hlt005
  68.         pop     ax
  69.         mov     ax,0ffffh
  70.         jmp     hltret          ; return
  71. hlt005: test    ax,ax
  72.         jnz     short hlt010
  73.         pop     ax
  74.         mov     ax,[bp+oa+6]
  75.         mov     bx,voa
  76.         jmp     near ptr hlt200
  77. hlt010: and     ax,_RIGHTWORD[bx+2]
  78.         jnz     short hlt020
  79.         mov     dx,_RIGHTWORD[bx+2]
  80.         jmp     short hlt100
  81. hlt020: mov     dx,_DOTVALUE[bx]
  82.         xchg    dl,dh
  83.         xchg    ah,al
  84.         mov     cx,bx
  85.         shr     cx,1
  86.         shr     ax,1
  87. hlt030: test    ax,dx
  88.         jnz     hlt040
  89.         shr     ax,1
  90.         dec     cx
  91.         jmp     hlt030
  92. hlt040: mov     dx,_RIGHTWORD[bx+2]
  93.         mov     bx,cx
  94.         shl     bx,1
  95.         and     dx,_LEFTWORD[bx]
  96.         mov     bx,[bp+oa+8]
  97.         add     cx,di
  98.         mov     [bx],cx
  99. hlt100: pop     ax
  100.         push    dx
  101.         mov     bx,[bp+oa]
  102.         and     bx,0fh
  103.         shl     bx,1
  104.         and     ax,_LEFTWORD[bx+2]
  105.         jnz     short hlt105
  106.         mov     dx,_LEFTWORD[bx+2]
  107.         jmp     hlt130
  108. hlt105: mov     dx,_DOTVALUE[bx]
  109.         xchg    ah,al
  110.         xchg    dh,dl
  111.         mov     cx,bx
  112.         shr     cx,1
  113.         shl     ax,1
  114. hlt110: test    ax,dx
  115.         jnz     hlt120
  116.         shl     ax,1
  117.         inc     cx
  118.         jmp     hlt110
  119. hlt120: mov     dx,_LEFTWORD[bx+2]
  120.         mov     bx,cx
  121.         shl     bx,1
  122.         and     dx,_RIGHTWORD[bx+2]
  123.         mov     bx,[bp+oa+10]
  124.         add     cx,di
  125.         mov     [bx],cx
  126. hlt130: pop     ax
  127.         or      dx,ax
  128.         mov     ax,[bp+oa+6]
  129.         and     ax,dx
  130.         mov     bx,voa
  131.         not     dx
  132.         mov     fflag,dx
  133.         xchg    ax,dx
  134. IFDEF JLASER
  135.         call    $aread
  136. ELSE
  137.         and     ax,es:[bx]
  138. ENDIF
  139.         or      ax,dx
  140. hlt200: 
  141. IFDEF JLASER
  142.         call    $write
  143. ELSE
  144.         mov     es:[bx],ax
  145. ENDIF
  146.         test    fflag,0080h
  147.         jz      hlt220
  148.         jmp     hltrgt2
  149. hlt220: mov     bx,voa2
  150. hlt308: sub     bx,2
  151.         mov     voa2,bx
  152. IFDEF JLASER
  153.         call    $read
  154. ELSE
  155.         mov     ax,es:[bx]
  156. ENDIF
  157.         mov     cx,di
  158.         sub     cx,16
  159.         js      hltrgt
  160.         mov     di,cx
  161.         cmp     cx,_WINX1
  162.         jb      hlt310
  163.         xor     ax,[bp+oa+4]
  164.         jnz     hlt320
  165.         mov     ax,[bp+oa+6]
  166. IFDEF JLASER
  167.         call    $write
  168. ELSE
  169.         mov     es:[bx],ax
  170. ENDIF
  171.         jmp     hlt308
  172. hlt310: mov     bx,_WINX1
  173.         and     bx,0fh
  174.         shl     bx,1
  175.         or      ax,_DOTVALUE[bx-2]
  176. hlt320: xchg    ah,al
  177.         mov     cx,16
  178. hlt330: test    ax,1
  179.         jnz     hlt340
  180.         shr     ax,1
  181.         dec     cx
  182.         jmp     hlt330
  183. hlt340: mov     bx,cx
  184.         shl     bx,1
  185.         mov     dx,_LEFTWORD[bx]
  186.         mov     bx,[bp+oa+8]
  187.         add     cx,di
  188.         mov     [bx],cx
  189.         mov     ax,[bp+oa+6]
  190.         and     ax,dx
  191.         mov     bx,voa2
  192.         not     dx
  193.         xchg    ax,dx
  194. IFDEF JLASER
  195.         call    $aread
  196. ELSE
  197.         and     ax,es:[bx]
  198. ENDIF
  199.         or      ax,dx
  200. IFDEF JLASER
  201.         call    $write
  202. ELSE
  203.         mov     es:[bx],ax
  204. ENDIF
  205.         jmp     short hltrgt3
  206. hltrgt: mov     bx,[bp+oa+8]
  207.         mov     word ptr [bx],0
  208. hltrgt3: mov     ax,voa
  209.         mov     voa2,ax
  210.         mov     di,[bp+oa]
  211. hltrgt2: test   fflag,0100h
  212.         jnz     hltret2
  213.         or      di,0fh
  214.         mov     bx,voa2
  215. hlt408: add     bx,2
  216.         mov     voa2,bx
  217. IFDEF JLASER
  218.         call    $read
  219. ELSE
  220.         mov     ax,es:[bx]
  221. ENDIF
  222.         xor     ax,[bp+oa+4]
  223.         add     di,16
  224.         cmp     di,_WINX2
  225.         ja      hlt410
  226.         test    ax,ax
  227.         jnz     hlt420
  228.         mov     ax,[bp+oa+6]
  229. IFDEF JLASER
  230.         call    $write
  231. ELSE
  232.         mov     es:[bx],ax
  233. ENDIF
  234.         jmp     hlt408
  235. hlt410: mov     bx,_WINX2
  236.         and     bx,0fh
  237.         shl     bx,1
  238.         or      ax,_DOTVALUE[bx+2]
  239. hlt420: xchg    ah,al
  240.         xor     cx,cx
  241. hlt430: test    ax,08000h
  242.         jnz     hlt440
  243.         shl     ax,1
  244.         inc     cx
  245.         jmp     hlt430
  246. hlt440: mov     bx,cx
  247.         shl     bx,1
  248.         mov     dx,_RIGHTWORD[bx]
  249.         mov     bx,[bp+oa+10]
  250.         add     cx,di
  251.         sub     cx,16
  252.         mov     [bx],cx
  253.         mov     ax,[bp+oa+6]
  254.         and     ax,dx
  255.         mov     bx,voa2
  256.         not     dx
  257.         xchg    ax,dx
  258. IFDEF JLASER
  259.         call    $aread
  260. ELSE
  261.         and     ax,es:[bx]
  262. ENDIF
  263.         or      ax,dx
  264. IFDEF JLASER
  265.         call    $write
  266. ELSE
  267.         mov     es:[bx],ax
  268. ENDIF
  269. hltret2: mov    ax,0
  270. hltret: pop     di
  271.         pop     bp
  272.         ret
  273. _hlnlmt endp
  274.  
  275. _skipright proc near
  276.         push    bp
  277.         mov     bp,sp
  278.         push    si
  279.         push    di
  280.         mov     ax,[bp+oa]
  281.         mov     bx,[bp+oa+2]
  282.         mov     di,ax
  283.         or      di,0fh
  284.         call    $calc
  285.         mov     es,ax
  286.         mov     si,bx
  287. IFDEF JLASER
  288.         call    $read
  289. ELSE
  290.         mov     ax,es:[bx]
  291. ENDIF
  292.         xor     ax,[bp+oa+4]
  293.         mov     bx,[bp+oa]
  294.         and     bx,0fh
  295.         shl     bx,1
  296.         and     ax,_LEFTWORD[bx]
  297.         cmp     di,[bp+oa+6]
  298.         jbe     skr020
  299.         mov     cx,bx
  300.         mov     bx,[bp+oa+6]
  301.         and     bx,0fh
  302.         shl     bx,1
  303.         or      ax,_DOTVALUE[bx+2]
  304.         mov     bx,cx
  305. skr020: test    ax,_DOTVALUE[bx]
  306.         jz      short skr105
  307.         mov     ax,[bp+oa]
  308.         jmp     skrret
  309. skr105: test    ax,ax
  310.         jz      short skr200
  311.         mov     dx,_DOTVALUE[bx]
  312.         xchg    ah,al
  313.         xchg    dh,dl
  314.         mov     cx,bx
  315.         shr     cx,1
  316.         inc     cx
  317.         shl     ax,1
  318. skr110: test    ax,dx
  319.         jnz     skrret2
  320.         shl     ax,1
  321.         inc     cx
  322.         jmp     skr110
  323. ;
  324. skr200: add     si,2
  325.         mov     bx,si
  326. IFDEF JLASER
  327.         call    $read
  328. ELSE
  329.         mov     ax,es:[bx]
  330. ENDIF
  331.         xor     ax,[bp+oa+4]
  332.         add     di,16
  333.         cmp     di,[bp+oa+6]
  334.         ja      skr410
  335.         test    ax,ax
  336.         jz      skr200
  337.         jmp     skr420
  338. skr410: mov     bx,[bp+oa+6]
  339.         and     bx,0fh
  340.         shl     bx,1
  341.         or      ax,_DOTVALUE[bx+2]
  342. skr420: xchg    ah,al
  343.         xor     cx,cx
  344. skr430: test    ax,08000h
  345.         jnz     skr440
  346.         shl     ax,1
  347.         inc     cx
  348.         jmp     skr430
  349. skrret2:
  350. skr440: mov     ax,cx
  351.         add     ax,di
  352.         sub     ax,16-1
  353. skrret: pop     di
  354.         pop     si
  355.         pop     bp
  356.         ret
  357. _skipright endp
  358.  
  359. _TEXT   ends
  360.         end
  361.  
  362.