home *** CD-ROM | disk | FTP | other *** search
- ;unsigned short connecting_line(array_position,level,tree_array);
- ; char *tree_array;
- ; unsigned short array_position,level;
-
- EXTRN _memory_model:byte
- EXTRN _error_code:byte
- EXTRN _tree_array_size:word
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _connecting_line
- _connecting_line proc near
- push bp ;
- mov bp,sp ;
- push di ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: mov _error_code,0 ;default value
- mov dx,1 ;let dx count levels
- mov ax,[bp+4] ;get array position
- or ax,ax ;test for zero
- jz L2 ;quit if zero
- cmp ax,_tree_array_size ;in range?
- jna L2 ;jump ahead if OK
- inc _error_code ;
- jmp short L9 ;jump ahead and quit
- L2: call FigureOffset ;figure offset of element in array
- add di,13 ;point to parent field
- mov bx,es:[di] ;fetch parent pointer
- or bx,bx ;test if pts to root dir
- jz L3 ;jump if no higher levels
- inc dx ;else increment level counter
- mov ax,bx ;new offset
- jmp short L2 ;go check parent element
- L3: mov bx,[bp+6] ;level to check for in BX
- cmp bx,dx ;compare to level of subdir
- ja L8 ;quit if level is greater than
- sub dx,bx ;number levels higher must seek
- or dx,dx ;does Level match level of subdir?
- jnz L5 ;jump ahead if not
- mov ax,[bp+4] ;element position in array
- call FigureOffset ;figure offset
- add di,19 ;point to Next field
- test word ptr es:[di],0FFFFh ;is it zero?
- jz L4 ;jump if so
- mov ax,1 ;use straight char
- jmp short L0 ;quit
- L4: mov ax,2 ;use corner char
- jmp short L0 ;quit
- L5: mov ax,[bp+4] ;array position
- L6: call FigureOffset ;will climb up to specified level
- or dx,dx ;search finished?
- jz L7 ;jump if so
- dec dx ;dec level counter
- add di,13 ;point to parent field
- mov ax,es:[di] ;fetch parent pointer
- jmp short L6 ;loop up to next level
- L7: test word ptr es:[di+19],0FFFFh ;test for zero
- jz L9 ;jump if zero
- mov ax,1 ;1 = straight segment
- jmp short L0 ;quit
- L8: mov _error_code,2 ;2 = level > subdir level
- L9: sub ax,ax ;return 0
- L0: pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _connecting_line endp
- figureoffset PROC
- cmp _memory_model,2 ;data near or far?
- jb A1 ;
- les di,dword ptr[bp+8] ;ES:DI pts to array
- add di,21 ;start with array element 1
- jmp short A2 ;
- A1: push ds ;near case
- pop es ;
- mov di,[bp+8] ;
- add di,21 ;start with array element 1
- A2: dec ax ;count from zero to get offset
- mov cl,21 ;byte per element
- mul cl ;calculate offset
- add di,ax ;now ES:DI pts to element
- ret ;
- figureoffset endp
- _TEXT ENDS
- END