home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Zone / VRZONE.ISO / mac / PC / REND386 / JIREND / INTSPLIT.C < prev    next >
C/C++ Source or Header  |  1993-04-11  |  3KB  |  120 lines

  1. /* Splitting-tree assembly routines (should be private to splits.c) */
  2.   
  3. /* Written by Bernie Roehl, June 1992 */
  4. /* Substantially upgraded by Dave Stampe, August '92 */
  5.   
  6. /* Copyright 1992 by Dave Stampe and Bernie Roehl.
  7.     May be freely used to write software for release into the public domain;
  8.     all commercial endeavours MUST contact Bernie Roehl and Dave Stampe
  9.     for permission to incorporate any part of this software into their
  10.     products!
  11.  */
  12.   
  13. #pragma inline
  14.   
  15. #include <dos.h>
  16.   
  17. #include "3dstruct.h"
  18. #include "splitdef.h"
  19. #include "splits.h"
  20.   
  21. int _which_side(SPLIT *s, long tx,long ty,long tz)
  22. {
  23.    int sign = -1; /* dot product: > , < , = zero */
  24.   
  25.    asm{
  26.       .386
  27.       push cx
  28.       push di
  29.       les bx,DWORD PTR s
  30.   
  31.       mov eax,DWORD PTR es:[bx].(SPLIT)nx
  32.       mov edx,DWORD PTR tx
  33.       sub edx,DWORD PTR es:[bx].(SPLIT)x
  34.       imul edx
  35.       mov ecx,eax
  36.       mov edi,edx
  37.       mov eax,DWORD PTR es:[bx].(SPLIT)ny
  38.       mov edx,DWORD PTR ty
  39.       sub edx,DWORD PTR es:[bx].(SPLIT)y
  40.       imul edx
  41.       add ecx,eax
  42.       adc edi,edx
  43.       mov eax,DWORD PTR es:[bx].(SPLIT)nz
  44.       mov edx,DWORD PTR tz
  45.       sub edx,DWORD PTR es:[bx].(SPLIT)z
  46.       imul edx
  47.       add ecx,eax
  48.       adc edi,edx
  49.       jl alldone
  50.       neg WORD PTR sign
  51.       or edi,ecx
  52.       jnz alldone
  53.       mov WORD PTR sign, di
  54.    }
  55.    alldone:
  56.    asm {
  57.       pop di
  58.       pop cx
  59.    }
  60.    return sign;
  61. }
  62.   
  63.   
  64. void *_fast_split_descent(SPLIT *tree, long x, long y, long z, char *type)
  65. {
  66.    asm {
  67.       push si
  68.       push cx
  69.       les bx,DWORD PTR tree
  70.    }
  71.    next:
  72.    asm {
  73.       or bx,bx
  74.       jz endtree
  75.       mov eax,DWORD PTR es:[bx].(SPLIT)nx
  76.       mov edx,DWORD PTR x
  77.       sub edx,DWORD PTR es:[bx].(SPLIT)x
  78.       imul edx
  79.       mov esi,eax
  80.       mov ecx,edx
  81.       mov eax,DWORD PTR es:[bx].(SPLIT)ny
  82.       mov edx,DWORD PTR y
  83.       sub edx,DWORD PTR es:[bx].(SPLIT)y
  84.       imul edx
  85.       add esi,eax
  86.       adc ecx,edx
  87.       mov eax,DWORD PTR es:[bx].(SPLIT)nz
  88.       mov edx,DWORD PTR z
  89.       sub edx,DWORD PTR es:[bx].(SPLIT)z
  90.       imul edx
  91.       add esi,eax
  92.       adc ecx,edx
  93.       jge right
  94.       mov al,BYTE PTR es:bx.(SPLIT)left_type
  95.       les bx,DWORD PTR es:bx.(SPLIT)left
  96.       cmp al,ISSPLIT
  97.       je next
  98.       jmp endtree
  99.    }
  100.    right:
  101.    asm {
  102.       mov al,BYTE PTR es:bx.(SPLIT)right_type
  103.       les bx,DWORD PTR es:bx.(SPLIT)right
  104.       cmp al,ISSPLIT
  105.       je next
  106.    }
  107.    endtree:
  108.    asm {
  109.       mov cl,al
  110.       mov ax,bx
  111.       mov dx,es
  112.       les bx,DWORD PTR type
  113.       mov es:bx,cl
  114.       pop cx
  115.       pop si
  116.    }
  117.    return; /* the return value is in DX:AX */
  118. }
  119.   
  120.