	BEGIN256 256
tsindiv2
	INCBIN "sindiv2" ;с 0 (для ROTATE_MATRIX)
	END256

        INCLUDE "rotmatrix.asm"
        INCLUDE "3dmodel.asm"
        INCLUDE "rotate.asm"
        INCLUDE "rotmodel.asm"
        INCLUDE "tmap.asm"

drawcube
tangage=$+1
        ld a,0
        ld (frame_tangage),a
azimuth=$+1
        ld a,0
        ld (frame_azimuth),a
curx=$+1
        ld a,0
        ld (frame_curx),a
;cury=$+1
;        ld a,0
;        ld (frame_cury),a
curz=$+1
        ld a,0
        ld (frame_curz),a
        
        if 1==1
        ld (clchmapsp),sp
        ld de,#c0c0
        ld hl,chmap+chmwid
        ld b,chmhgt
clchmap0
        ld sp,hl
        dup chmwid/2
        push de
        edup
        inc h
        djnz clchmap0
clchmapsp=$+1
        ld sp,0
        else
        
        ld a,(cury)
        ld h,a
        ld d,chmap/256
copytexture0
        ld l,texture&255
        ld e,chmap&255
        ld bc,64
        ldir
        inc h
        inc d
        jr nz,copytexture0        
        endif
        
        if TWOAXES==0
        ld a,15
        inc a
        ld ($-2),a
        ld ly,a ;alpha
        endif
frame_azimuth=$+1
        ld a,0
        call ROTATE_MATRIX
;не вертим камеру, просто задаём позицию объекта на экране
	ld a,0
	ld (yspaceshift),a
frame_curz=$+1
        ld a,0
	add a,#30
	ld (zspaceshift),a
	 ld (zspaceshift2),a
frame_curx=$+1
	ld a,0
	ld (xspaceshift),a
	ld a,rangeshiftjrbase+_rangeshiftsz*(rangeshiftmax-1)
	ld (rangeshiftpatch),a
        jp ROTCUBE
sortobjnext
sortobjnexthl=$+1
        ld sp,0
        ret
        
drawfaces=TRIIX

moveall
curxshift=$+1
        ld hl,950;512
        dec hl
        ld a,h
        or l
        jr z,moveall_endxshift
        ld (curxshift),hl
        jr moveall_endxshiftq
moveall_endxshift
        ;ld a,0x7e ;"ld a,(hl)"
        ;ld (curxldam),a
        ld a,52 ;"inc (hl)"
        ld (curxincm),a
moveall_endxshiftq
        ld a,l
        srl h
        rra
        srl h
        rra
        srl h
        rra
        ld c,a

	;ld a,111
	;add a,0
	;ld ($-1),a
	ld hl,curxphase
	;jr nc,$+3
curxincm=$
	nop ;/inc (hl)
curxphase=$+1
	ld hl,tsindiv2
;curxldam=$
	ld a,(hl)
	sra a
        sra a
       add a,c;32
       sub 20
;0x3a=hidden
CURXMAXX=0x80+0x3a
        sub 0x80
      cp CURXMAXX
      jr c,$+4
      ld a,CURXMAXX
        sub 0x80
	ld (curx),a

	;ld a,37
	;add a,0
	;ld ($-1),a
	ld hl,curyphase
	;jr nc,$+3
	 inc (hl)
curyphase=$+1
	ld hl,tsindiv2
	ld a,(hl)
	;add a,a
	;add a,a
	;sra a
	sra a
        sra a
        add a,#c0+#10
	ld (cury),a

	ld a,77
	add a,0
	ld ($-1),a
	ld hl,curzphase
	jr nc,$+3
	inc (hl)
curzphase=$+1
	ld hl,tsindiv2
	ld a,(hl)
	sra a
        sra a
        sra a
	ld (curz),a

	ld a,97
	add a,0
	ld ($-1),a
        ld a,0;30
        adc a,0
        ld ($-3),a
        ld (tangage),a

        ld hl,tsindiv2
        inc l
        ld ($-3),hl
        ld a,(hl)
        add a,a
        add a,0;128
	add a,0
	ld ($-1),a
        ld a,0;50 ;azimuth
        adc a,1
        ld ($-3),a
        ld (azimuth),a

	ret
