;procedure utile pour le gestion de la 3d cavaliere.

variable_3d MACRO
 Buffer_fond DW 0
 Coord_sprite DB 256*8*2 DUP(0)   ;(handle,numero,x,y,handle,numero,...)
 Handle3d DW 0
ENDM




PUT_sprite_3d MACRO Handle,numero,X,Y,Z
 MOV AX,Handle
 MOV Handle3d,AX
 PUSH numero
 PUSH X
 PUSH Y
 PUSH Z
 CALL PUT_3D
 ADD SP,8
ENDM


MASK_ALL_sprite MACRO
 CALL MASK_ALL
ENDM

_3D_ROUTINE MACRO

PUT_3d:
 LEA DI,Coord_sprite
 XOR AX,AX
 CMP CS:PageACT,AX
 JZ PUT_3DB0
  ADD DI,256*8

PUT_3DB0:
 MOV AX,DS:DI
 SHL AX,3
 MOV BX,1
 ADD DS:DI,BX
 ADD AX,2
 ADD DI,AX

 MOV AX,SP
 MOV BP,AX
 MOV AX,SS:BP+2
 SHR AX,1
 MOV CX,SS:BP+6
 MOV DX,SS:BP+4
 SUB DX,AX
 ADD CX,AX
 MOV BX,SS:BP+8
 MOV AX,Handle3D
 MOV DS:DI,AX
 MOV DS:DI+2,BX
 MOV DS:DI+4,CX
 MOV DS:DI+6,DX
 PUT_SPRITE Handle3d,BX,CX,DX,CS:ADDpage
RET

MASK_ALL:
 LEA DI,Coord_Sprite
 XOR AX,AX
 CMP CS:PAGEact,AX
 JZ MASK_ALLB0
  ADD DI,256*8

MASK_ALLB0:
 MOV CX,DS:DI
 MOV DS:DI,AX
 ADD DI,2
 CMP CX,0
 JE MASK_ALLFIN
MASK_ALLB1:
 PUSH CX
 PUSH DI
   MOV AX,DS:DI
   MOV Handle3d,AX
   MASK_SPRITE Handle3d,DS:DI+2,DS:DI+4,DS:DI+6,CS:ADDpage,Buffer_fond
  POP DI
  ADD DI,8
  POP CX
 LOOP MASK_ALLB1
MASK_ALLFIN:
RET

ENDM
