movecube
	ld bc,3
	ld hl,(mcamy)
	ld de,(mcamx)
	ld a,#ef
	in a,(#fe)
	rra
        rra
	rra ;8=right
	jr c,$+3+2
        ex de,hl
	add hl,bc
        ex de,hl
	rra ;7=up
	jr c,$+4
	sbc hl,bc
	rra ;6=down
	jr c,$+3
	add hl,bc
	ld (mcamy),hl
        ld a,#f7
        in a,(#fe)
	bit 4,a ;5=left
	jr nz,$+4+2
        ex de,hl
	sbc hl,bc
        ex de,hl
	ld (mcamx),de

	 ld bc,#fbdf
	 in a,(c)
oldfbdf=$+1
	 ld b,0
	 ld (oldfbdf),a
	 sub b
	 sra a
azimuth=$+1 ;yaw ;рыскание
	add a,#40
	ld (azimuth),a

	 ld bc,#ffdf
	 in a,(c)
oldffdf=$+1
	 ld b,0
	 ld (oldffdf),a
	 sub b
	 neg
	 sra a
tangage=$+1 ;pitch
	add a,0
	 cp -#30
	 jp p,$+3+2
	 ld a,-#30
	 cp #30
	 jp m,$+3+2
	 ld a,#30
	ld (tangage),a ;тангаж

	ret

scripting
curscripttime=$+1
	ld de,0
	ld hl,(timer)
	or a
	sbc hl,de
	ret c
curscriptaddr=$+1
	ld hl,script
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld c,(hl)
	inc hl
	ld b,(hl)
	inc hl
	ld (curscripttime),bc
	ld (curscriptaddr),hl
	ex de,hl
	jp (hl)

script
	;dw initcube

;showcubetime=cubebasetime-20
	;dw showcubetime
	;dw startcube

	dw -1

