displaybegin=$
	if NOISECLS
copyscreen
	if NOISECLS==1
copyscreen_rnd=$+2
	ld ix,#2444
	 endif
copyscreen_lphase=$+1
	ld l,scrbuf&255
copyscreen_phase=$+2
	ld de,scrtop+scrbrim
oddline=$-1
       ;if INTERLACE
	ld a,d
	xor 1
	ld (copyscreen_phase),a
	ld a,l
	xor 1
	ld (copyscreen_lphase),a
       ;endif
	ld h,scrbuf/256+scrbrim
	if NOISECLS==1
	ld b,scrhgt/2
	else
	ld bc,(scrhgt/2)*#100
	endif
copyscreen0
	if NOISECLS==1
	ld c,(ix)
	endif
	;
	 if NOISECLS==1 ;if внутри dup не компилируется
	dup scrwid/2
	ld a,(hl) ;+48
	ld (de),a ;+0 (+55)
	and c
	ld (hl),a ;+11
	inc h
	inc e
	ld a,(hl)
	ld (de),a ;+33
	inc h
	inc e     ;+41
	edup
	 else
	dup scrwid/2
	ld a,(hl) ;+23(22)
	ld (de),a ;+0 (+31)
	ld (hl),c ;+7
	inc h
	inc e
	ld a,(hl) ;+23(22)
	ld (de),a ;+0 (+31)
	inc h
	inc e
	edup
	 endif
	org $-2
       if INTERLACE
	inc l
	inc d
	inc d
       else
        ld a,l
        xor 1
        ld l,a
        ld a,d
        xor 1
        ld d,a
       endif
	 if NOISECLS==1 ;if внутри dup не компилируется
	dup scrwid/2;32
	ld a,(hl) ;+48
	ld (de),a ;+0 (+55)
	and c
	ld (hl),a ;+11
	dec h
	dec e
	ld a,(hl)
	ld (de),a ;+33
	dec h
	dec e     ;+41
	edup
	 else
	dup scrwid/2
	ld a,(hl) ;+23(22)
	ld (de),a ;+0 (+31)
	ld (hl),c ;+7
	dec h
	dec e
	ld a,(hl) ;+23(22)
	ld (de),a ;+0 (+31)
	dec h
	dec e
	edup
	 endif
	org $-2
       if INTERLACE
	inc l
	inc d
	inc d
	ld a,d
	and 6
       else
	ld a,l
        xor 1
        add a,2
        ld l,a
	ld a,d
        xor 1
        add a,2
        ld d,a
	and 6
       endif
	jp nz,dde2q
	ld a,e
	sub -32
	ld e,a
	sbc a,a
	and -8
	add a,d
	ld d,a
dde2q
	;
	 if NOISECLS==1
	inc lx
	 endif
	dec b
	jp nz,copyscreen0
	 if NOISECLS==1
        inc lx
	ld (copyscreen_rnd),ix
	 endif
	 if INTERLACE
	bit 0,l
	ld hl,scrbuf+(scrbrim*256)
	jr z,$+2+2
	ld l,255&(scrbuf+scrhgt)
	dup scrwid
	ld (hl),b
	inc h
	edup
	org $-1
	 endif
copyscreencls
	ret

	else ;~NOISECLS
copyscreen
	ld hl,((coltab&0xff00)+br0);br1)
       if INTERLACE
	ld h,l
       else
        ld a,l
        xor h
        ld h,a
       endif
	ld (copyscreenclsdata),hl
	;di
	ld ix,scrtop+31-scrbrim
copyscreen_phase=$-1
oddline=$-1
       if INTERLACE
	ld a,hx
	xor 1
	ld (copyscreen_phase),a
       endif
	ld (copyscreensp),sp
	ld l,scrbuf&#ff;+scrhgt-1
	ld c,scrhgt/(8/interlacedivisor)
copyscreen0
	inc ix
       if INTERLACE
	ld b,4
       else
	ld b,8
       endif
copyscreen1
	ld sp,ix
	ld h,scrbuf/256+scrwid-1
	dup scrwid/2
	ld d,(hl)
	dec h
	ld e,(hl)
	push de
	dec h
	edup
	org $-2
	inc l;dec l
	;дальше по прерыванию в стек пишется de
	ld (ix-scrwid),e
	ld (ix-(scrwid-1)),d
       if INTERLACE
	inc hx
       endif
	inc hx ;down ix
	djnz copyscreen1
	dec ix
	ld a,lx
	sub -32
	ld lx,a
	sbc a,a
	and -8
	add a,hx
	ld hx,a
	dec c
	jp nz,copyscreen0
copyscreensp=$+1
	ld sp,0
        ret
        
copyscreencls
	ld (copyscreenclssp),sp
copyscreenclsdata=$+1
	ld de,0
        ld bc,0
       if BACKGROUND
	ld hl,(frame_tangage)
        ld h,tsindiv2/256
        ld a,(hl)               ;sin 
       if !INTERLACE
        add a,a
       endif
        cpl ;centery
        cp -8
        jp m,$+3+3
        ld bc,0xffff
        cp 64
        jp m,$+3+2
        ld d,b
        ld e,c
       endif

	;ld d,c
	;ld e,c
	ld hl,scrbuf+scrhgt
	ld a,scrwid
copyscreencls0
	ld sp,hl
	dup scrhgt/4
	push de
	edup
	dup scrhgt/4
	push bc
	edup
	inc h
        dec a
	jp nz,copyscreencls0

copyscreenclssp=$+1
	ld sp,0
	
	;ei
	ret
	
	endif

	display "display size=",$-displaybegin
