
iotin	segment	use16
assume	cs:iotin,ds:adat

;------------------------------------------------------------------------------
setpage:	cmp	al,pag		;	VESA grafik n l 64K-nknt
		sje	pnset		;	lapoz s.
		test	uzemmod,16
		sjnz	pnset
		or	al,al
		pushad
		mov	dx,vgran
		sjns	seseap
		xor	al,al
seseap:		or	dh,dh
		cbw
		sjnz	ascet
		cmp	dl,1
		mov	pag,al
		sjbe	lappo
		mul	dl
		sjmp	lappo
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
incpage:	inc	pag		;	Kvetkez lapra  llni gyorsabb,
		pushad			;	mint a be llĄt s esetn.
		sjs	ascet
		mov	ax,vpage
		sjz	ascet
		add	ax,vgran
		sjc	ascet
lappo:		xor	bx,bx
		cmp	ax,vpages
		mov	dx,ax
		mov	vpage,ax
		sje	nella
		push	dx
		mov	vpages,ax
		call	lapoz
		pop	dx
nella:		test	own,64
		mov	bx,1
		sjz	double
		cmp	dx,vpages+2
		mov	vpages+2,dx
		sje	double
		call	lapoz
double:		popad
pnset:		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
decpage:	cmp	pag,0		;	Elz lapra visszav lt.
		pushad
		sje	ascet
		mov	ax,vpage
		sjs	ascet
		dec	pag
		sub	ax,vgran
		sjnc	lappo
ascet:		xor	ax,ax
		mov	pag,al
		sjmp	lappo
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
setcol:		and	ax,3		;	Kppontt bl zat felpĄtse,
		test	owan,64+128
		sjz	netcol
		or	al,4
netcol:		cmp	al,aktset	;	mely a grafikus kpernyre
		sje	pnset		;	trtn karkaterkiĄr shoz
		test	uzemmod,16	;	szksges: a 8 kppont szles
		sjnz	pnset		;	karakterek kpben elfordul˘
set256:		test	xmode,128
		push	ds		;	mind a 256-fle byte-hoz
		mov	aktset,al	;	tartozik 8-8 pixel, ezeket kell
		pop	es		;	majd kim solni innen.
		pushad			;	256*8=2Kb sszesen.
		cwde			;	
		sjz	seset
		test	al,2
		sjnz	seset
		xor	al,1
seset:		movzx	ecx,br setsz2[2*eax]
		mov	ecx,szinht[4*ecx]
		mov	nulegy,ecx
		mov	dl,cl
		movzx	ecx,br setsz2[2*eax+1]
		mov	ecx,szinht[4*ecx]
		mov	egynul,ecx
		mov	dh,cl
		xor	ecx,ecx
		test	mode,2
		mov	di,offset stabl
		sjnz	sethi
		mov	bx,wr setsz[2*eax]
scikl:		rol	ch,1
		mov	ax,bx
		sjnc	net1
		rol	ch,1
		mov	al,bh
		sjc	xnet1
		mov	al,dh
		sjmp	xnet1
net1:		rol	ch,1
		sjnc	xnet1
		mov	al,dl
xnet1:		rol	ch,1
		sjc	set1
		rol	ch,1
		mov	ah,bl
		sjnc	xset1
		mov	ah,dl
		sjmp	xset1
set1:		rol	ch,1
		sjc	xset1
		mov	ah,dh
xset1:		stosw
		rol	ch,1
		mov	ax,bx
		sjnc	net2
		rol	ch,1
		mov	al,bh
		sjc	xnet2
		mov	al,dh
		sjmp	xnet2
net2:		rol	ch,1
		sjnc	xnet2
		mov	al,dl
xnet2:		rol	ch,1
		sjc	set2
		rol	ch,1
		mov	ah,bl
		sjnc	xset2
		mov	ah,dl
		sjmp	xset2
set2:		rol	ch,1
		sjc	xset2
		mov	ah,dh
xset2:		inc	ch
		stosw
		sjnz	scikl
		mov	dl,bh
		mov	dh,bh
		mov	bh,bl
seveb:		mov	wr egyes,dx
		mov	wr egyes+2,dx
		mov	wr nulla,bx
		mov	wr nulla+2,bx
		popad
		ret

sethi:		movzx	bx,setsz[2*eax]		;	HICOLOR be llĄt s.
		test	mode,1
		mov	cl,setsz[2*eax+1]
		sjnz	settrue
		mov	bx,wr szinht[4*ebx]
		mov	dx,wr szinht[4*ecx]
hscikl:		mov	ax,bx
		rol	ch,3
		stosw
		sjnc	hnet1
		rol	ch,1
		mov	ax,dx
		sjc	hxnet1
		mov	ax,wr egynul
		sjmp	hxnet1
hnet1:		rol	ch,1
		sjnc	hxnet1
		mov	ax,wr nulegy
hxnet1:		stosw
		rol	ch,1
		mov	ax,dx
		sjc	hset1
		rol	ch,1
		mov	ax,bx
		sjnc	hxset1
		mov	ax,wr nulegy
		sjmp	hxset1
hset1:		rol	ch,1
		sjc	hxset1
		mov	ax,wr egynul
hxset1:		stosw
		rol	ch,1
		mov	ax,bx
		sjnc	hnet2
		rol	ch,1
		mov	ax,dx
		sjc	hxnet2
		mov	ax,wr egynul
		sjmp	hxnet2
hnet2:		rol	ch,1
		sjnc	hxnet2
		mov	ax,wr nulegy
hxnet2:		inc	ch
		stosw
		cmp	ch,64
		sjb	hscikl
		njmp	seveb

settrue:	movzx	bx,setsz[2*eax]		;	TRUECOLOR be llĄt s.
		mov	cl,setsz[2*eax+1]
		mov	al,xmode
		xor	al,1
		mov	ebx,szinht[4*ebx]
		and	ax,1
		mov	edx,szinht[4*ecx]
		xchg	ax,si
tscikl:		mov	eax,ebx
		stosd
		sub	di,si
		rol	ch,3
		sjnc	tnet1
		rol	ch,1
		mov	eax,edx
		sjc	txnet1
		mov	eax,egynul
		sjmp	txnet1
tnet1:		rol	ch,1
		sjnc	txnet1
		mov	eax,nulegy
txnet1:		stosd
		sub	di,si
		rol	ch,1
		mov	eax,edx
		sjc	tset1
		rol	ch,1
		mov	eax,ebx
		sjnc	txset1
		mov	eax,nulegy
		sjmp	txset1
tset1:		rol	ch,1
		sjc	txset1
		mov	eax,egynul
txset1:		stosd
		sub	di,si
		rol	ch,1
		mov	eax,ebx
		sjnc	tnet2
		rol	ch,1
		mov	eax,edx
		sjc	txnet2
		mov	eax,egynul
		sjmp	txnet2
tnet2:		rol	ch,1
		sjnc	txnet2
		mov	eax,nulegy
txnet2:		stosd
		inc	ch
		sub	di,si
		cmp	ch,64
		lea	di,[edi][4*esi]
		sjb	tscikl
		mov	egyes,edx
		mov	dr nulla,ebx
		popad
		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
sorrajz		proc	far		;	llapotsor vagy beviteli mez
		test	mode,4
		sjz	scsorr
		test	gwan,1
		sjnz	scres
		test	gwan,2
		sjnz	cres
scres:		and	gwan,251
		jmp	screensaver
cres:		xor	bx,bx
		mov	si,wr ablak
		mov	ax,ymax
		mov	cx,xmax
		mov	bp,bx
		and	si,3
		mov	dx,ax
		;call	opengfx
		call	enlarge
		jmp	closegfx
nhorr:		njmp	horr
hohorr:		ret
scsorr:		or	bl,bl		;	megjelenĄtse a kpernyn.
		mov	dl,uzemmod	;	BL = 0: beviteli mez, 12:
		sjns	nhorr
		test	felb,7
		mov	cx,8
		mov	ax,wr hinto
		sjz	katyo
		add	cx,cx
katyo:		or	ah,ah
		cbw
		sjz	hohorr
		or	al,al
		sjz	hohorr

		push	cx
		mov	cl,hinxxo
		cmp	cl,44
		les	di,vesacim
		sjb	cormal
		xor	bh,bh
		cmp	cl,216
		mov	bl,balsor
		sjae	cormal
taiko:		dec	bx
		sjs	cormal
		cmp	cl,balhint[bx]
		sjne	taiko
		or	brown,2
		call	prepare
		push	dx
		mov	al,hinxox
		push	ax
		mov	dx,bx
		push	di
		call	aktadat
		pop	si
		sub	di,si
		pop	bx
		mov	cx,di
		pop	dx
		sjbe	hodaiko
daiko:		xor	di,di
		cmp	bl,hhp-1
		lodsb
		sjae	odaiko
aiko:		cmp	al,asctabl[di]
		sje	dayka
		inc	di
		cmp	di,112
		sjb	aiko
		cmp	al,"["
		mov	di,90
		sje	dayka
		cmp	al,"]"
		mov	di,107
		sjne	paiko
dayka:		inc	bx
		xchg	ax,di
		mov	hint[bx-1],al
paiko:		loop	daiko
odaiko:		mov	hint[bx],bh
		inc	bx
hodaiko:	and	brown,253
		xchg	ax,bx
cormal:		cmp	al,hinto
		pop	cx
		mov	hinto,al
		sjae	normal
		or	mode,128
		or	own,16
normal:

		test	dl,16
		mov	si,xmax
		sjnz	kotty
		shr	si,3
		dec	si
		dec	si
kotty:		dec	si
		dec	si
		cmp	ax,si
		sjbe	kotl
		mov	ax,si
kotl:		cmp	al,hhp
		mov	bp,ymax
		mov	mennyit,ax
		mov	dkurz,ax
		mov	sorsze,al
		mov	si,hintx
		mov	di,hinty
		xchg	ax,dx
		sjbe	rehorr
horror:		ret
nkahorr:	njmp	kahorr
rehorr:		test	al,16
		mov	honnan,offset hint
		sjnz	nkahorr
		sub	bp,cx
		sub	bp,4
		shl	dx,3
		cmp	di,bp
		sjbe	manyo
		mov	di,bp
manyo:		mov	ax,si
		mov	hintx,ax
		add	ax,cx
		add	ax,dx
		cmp	ax,xmax
		sjb	sanyo
		dec	si
		sjnz	manyo
sanyo:		inc	cx
		inc	dx
		mov	al,3
		ncall	setcol
		inc	cx
		inc	dx
		test	tegan,8
		push	cx
		push	dx
		sjnz	ninarn
		add	dx,shintx
		add	cx,shinty
ninarn:		cmp	si,akhin
		sjne	gandarn
		cmp	di,akhin+2
		sjne	gandarn
		cmp	dx,akhin+4
		sjne	gandarn
		cmp	cx,akhin+6
		sjne	gandarn
		pop	dx
		pop	cx
		ret
gandarn:	mov	akhin,si
		mov	akhin+2,di
		mov	akhin+4,dx
		mov	akhin+6,cx
		ncall	lefed
		pop	dx
		pop	cx
		ncall	kikapcs
		push	dx
		push	si
		push	cx
		mov	bp,si
		push	di
		mov	cx,dx
		mov	bx,di
		ncall	qwonal
		pop	bx
		pop	dx
		pop	bp
		dec	dx
		pop	cx
		push	dx
		push	bp
		push	bx
		push	cx
		add	bx,dx
		ncall	qwonal
		pop	dx
		pop	bx
		pop	bp
		pop	cx

		test	tegan,8
		sjnz	neena
		push	cx
		or	oxtan,64
		push	bp
		add	bp,shintx
		push	bx
		add	bx,cx
		push	dx
		mov	cx,dx
		inc	bx
		mov	dx,shinty
		ncall	arteglap
		pop	dx
		pop	bx
		pop	bp
		pop	cx
		push	cx
		push	bp
		push	bx
		add	bx,shinty
		push	dx
		add	bp,dx
		mov	dx,cx
		mov	cx,shintx
		sub	dx,shinty
		inc	dx
		ncall	arteglap
		pop	dx
		pop	bx
		pop	bp
		and	oxtan,191
		pop	cx

neena:		dec	dx
		push	bp
		push	bx
		dec	cx
qolomp:		push	cx
		inc	bx
		push	dx
		push	bp
		push	bx
		ncall	qpont
		pop	bx
		pop	bp
		pop	dx
		push	dx
		push	bp
		push	bx
		add	bp,dx
		ncall	qpont
		pop	bx
		pop	bp
		pop	dx
		pop	cx
		loop	qolomp
		pop	ax
		pop	bp
		inc	ax
		inc	bp
		ncall	koord
		njmp	graok
kahorr:		cmp	di,bp
		mov	cl,1
		sjb	rotl
		dec	bp
		mov	di,bp
rotl:		mov	ax,si
		mov	hintx,ax
		add	ax,dx
		cmp	ax,xmax
		sjb	sotl
		dec	si
		sjnz	rotl
sotl:		ncall	lefed
		ncall	kikapcs
		mov	cx,dx
		mov	bp,si
		xchg	ax,di
		ncall	koord
		test	mode,8
		mov	si,honnan
		mov	ah,15*16
		mov	bx,offset asctabl
		sjnz	ropl
		mov	ah,15
ropl:		lodsb
		xlat
		stosw
		loop	ropl
		ncall	bekapcs
		ret
horr:		and	bx,12
		mov	di,bx
		sjz	shock
		push	ax
		push	si
		mov	si,dx
		and	si,3
		mov	al,pufabl[si]
		and	ax,3
		cmp	ax,si
		sje	shox
		and	dl,252
		or	dl,al
shox:		pop	si
		pop	ax
shock:		and	dl,19		;	 llapotsor.
		push	bx
		mov	al,felb
		mov	cx,3
		xchg	ax,bx
		push	dx
		and	bx,7
		and	al,4
		shl	bx,cl
		and	dx,16
		or	di,dx
		or	bx,ax
		shr	di,cl
		or	dx,dx
		mov	si,ax
		mov	bp,gsor
		sjz	nekra
		shr	si,1
		mov	ax,doffs[si+4]
		xor	dx,dx
		div	bp
		mov	si,dx
		shr	si,1
		mov	dx,16
		dec	si
		sjmp	xekra
nekra:		mov	si,dofpos[bx]
		mov	ax,dofpos[bx+2]
xekra:		mov	dl,dabsze[di]
		xchg	ax,di
		test	al,2
		mov	dh,bh
		sjnz	ekra
		shl	dx,cl
ekra:		test	felb,7
		mov	cx,8
		sjz	fekra
		add	cx,cx
fekra:		test	al,2
		sjz	gekra
		mov	cx,1
		inc	dx
gekra:		ncall	lefed
		ncall	kikapcs
		pop	dx
		pop	bx
		or	bl,dl
		mov	cl,3
		mov	dl,bl
		shr	bx,cl
		and	bl,cl
		;mov	ax,bx
		;or	al,2
		mov	al,2
		cmp	al,aktset	;	SzĄnbe llĄt s (ld. elbb).
		sje	soxic
		ncall	setcol
soxic:		mov	al,dpags[bx]
		cmp	al,pag
		mov	pags,al
		sje	xnpag
		ncall	setpage
xnpag:		mov	al,dabsze[bx]
		add	bx,bx
		mov	sorsze,al
		mov	di,doffs[bx]
		mov	bl,dl
		mov	poffs,di
		and	bl,7
		add	bx,bx
		mov	ax,dhossz[bx+2]
		mov	dhossz,ax
		mov	mennyit,ax
		mov	cx,ax
		mov	al,sorsze
		inc	cx
		cbw
		mov	bp,cx
		sub	bp,ax
		sjae	xoxic
		xor	cx,cx
		sjmp	xoxics
xoxic:		mov	mennyit,ax
xoxics:		mov	ax,dszcim[bx+2]
		mov	dszcim,ax
		mov	ax,dkurz[bx+2]
		add	ax,dszcim
		mov	dkurz,ax
		mov	si,ax
		mov	ax,dabpoz[bx+2]
		cmp	ax,bp
		sjbe	xoxix
		mov	ax,bp
		mov	dabpoz[bx+2],bp
xoxix:		mov	dabpoz,ax
		dec	bp
		mov	cx,ax
		sub	cx,bp
		sjbe	woxix
		sub	mennyit,cx
woxix:		add 	ax,dszcim
		mov	honnan,ax
		test	dl,16
		xchg	ax,si
		sjnz	skara
		njmp	graok

skara:		mov	es,chseg	;	Karakteres kpernyn.
		xor	dx,dx
		mov	bx,offset asctabl
		sub	ax,si
		mov	bp,dx
		mov	cx,ax
		mov	dl,sorsze
		mov	ax,bvlcol
		sjb	kurnin
		cmp	cx,dx
		sjbe	sroek
		mov	cx,dx
sroek:		mov	ah,al
		mov	bp,cx
		jcxz	kurfix
ettov:		lodsb
		xlat
		stosw
		loop	ettov
kurfix:		lodsb
		ncall	kurell
		cmp	bp,mennyit
		xlat
		sjb	kurjan
kures:		mov	al,chures
kurjan:		stosb
		mov	al,kurcol
		inc	bp
		stosb
kurnin:		mov	cx,mennyit
		sub	cx,bp
		sjbe	karvex
mastov:		lodsb
		xlat
		stosw
		loop	mastov
karvex:		mov	cx,dx
		sub	cx,mennyit
		mov	al,chures
		sjbe	karveg
		rep	stosw
karveg:		mov	al,kwan
		and	ax,3
		mov	si,ax
		mov	al,iwan
		and	al,12
		or	si,ax
		xor	dx,dx
		mov	al,3eh
		add	si,si
		mov	ah,allcol
		ncall	karvaly
		dec	ax
		mov	dl,br xmax
		dec	ax
		dec	dx
		test	mode,16
		ncall	karvaly
		mov	ah,bevcol
		sjz	magy1
		mov	al,0aeh
magy1:		test	mode,16
		mov	dx,wr sorveg[si]
		ncall	karvaly
		sjnz	magy2
		inc	ax
magy2:		inc	ax
		stc
		sbb	dl,sorsze
		ncall	karvaly
		mov	ah,stacol
		push	ax
		mov	al,"I"
		push	ds
		push	ax
		mov	ax,40h
		mov	cl,3
		mov	ds,ax
		pop	ax
		test	br ds:[17h],128
		pop	ds
		sjnz	instar
		mov	al,chures
instar:		test	mode,64
		sjz	sinstr
		ror	ah,cl
		ror	ah,1
sinstr:		mov	dl,br xmax
		sub	dx,101h
		ncall	karvaly
		pop	ax
		test	kwan,4
		mov	al,uzemmod
		mov	bx,offset scroll16
		sjnz	sihux
		mov	bx,offset xcroll16
sihux:		rol	al,cl
		and	al,7
		cmp	lass,0
		xlat	
		sje	statar
		inc	cx
		ror	ah,cl
statar:		mov	dh,1
		ncall	karvaly
		ncall	bekapcs
		ret

slcikl:		inc	laval
		sjmp	sckl
durvit:		ncall	nyurit
		sjmp	daptov
durha:		ncall	kurell
		ncall	dkub
		njmp	dfoly

graok:		test	felb,7		;	Grafikus kpernyn.
		mov	gs,charset1
		sjnz	deviga
		mov	gs,chr8set1
deviga:		movzx	edi,di
		xor	ebx,ebx
dcikl0:		push	ds
		mov	cl,orias
		mov	ax,gsor
		movzx	edx,honnan
		pop	es
		shl	bx,cl
		add	ax,di
		movzx	ebp,mennyit
		push	ax
		mov	hovair,di
		mov	laval,0
		pushf
		sjc	slcikl
sckl:		test	mode,2
		mov	cx,dkurz
		mov	di,offset vesa+16
		movzx	eax,br [edx]
		njnz	sorrhi
		or	bp,bp
		sjz	dvege0
dcikl:		cmp	di,offset vesa+512+aptuf-2*8
		movzx	si,br gs:[ebx][2*eax+1]
		sjae	durvit
daptov:		cmp	cx,dx
		lea	si,stabl[4*esi]
		sje	durha
		movsd
		movzx	si,br gs:[ebx][2*eax]
		lea	si,stabl[4*esi]
		movsd
dfoly:		inc	dx
		dec	bp
		mov	al,[edx]
		sjnz	dcikl
dvege0:		cmp	dx,cx
		movzx	cx,sorsze
		sjne	dvege1
		mov	eax,egyes
		dec	cx
		stosd
		stosd
dvege1:		sub	cx,mennyit
		sjbe	diktov
nulmas:		lea	ax,[edi][8*ecx]
		add	cx,cx
		cmp	ax,offset vesa+512+aptuf
		mov	eax,dr nulla
		sjbe	nuhet
nurrux:		mov	dx,(512-16+aptuf)/4
		ncall	nyurit
		cmp	cx,dx
		sjbe	nuhet
		sub	cx,dx
		xchg	cx,dx
		rep	stosd
		xchg	cx,dx
		sjmp	nurrux
nuhet:		rep	stosd
diktov:		mov	cl,orias
		ncall	urit
		shr	bx,cl
		popf
		sjc	liktov
iktov:		inc	bh
		cmp	bh,8
		pop	di
		njb	dcikl0
		test	felb,7
		sjz	deveg
		cmp	bh,16
		njb	dcikl0
deveg:		ncall	bekapcs
		ret
liktov:		test	laval,254
		sjnz	iktov
		ncall	incpage
		sjmp	iktov

hdurvit:	ncall	nyurit
		sjmp	hdaptov
hdurha:		ncall	kurell
		ncall	hdkub
		sjmp	hdfoly

sorrhi:		test	mode,1		;	HICOLOR megjelenĄts.
		njnz	sorrtrue
		or	bp,bp
		sjz	hdvege0
hdcikl:		cmp	di,offset vesa+512+aptuf-2*16
		movzx	si,br gs:[ebx][2*eax+1]
		sjae	hdurvit
hdaptov:	cmp	cx,dx
		lea	si,stabl[8*esi]
		sje	hdurha
hdfoly:		cmp	si,offset stabl+512
		sjae	hdnagy
		movsd
hdnavi:		movsd
		neg	bp
		movzx	si,br gs:[ebx][2*eax]
		sjs	hdaptov
		inc	dx
		dec	bp
		mov	al,[edx]
		sjnz	hdcikl
hdvege0:	cmp	dx,cx
		movzx	cx,sorsze
		sjne	hdvege1
		mov	eax,egyes
		dec	cx
		stosd
		stosd
		stosd
		stosd
hdvege1:	sub	cx,mennyit
		njbe	diktov
tulmas:		add	cx,cx
		njmp	nulmas

hdnagy:		push	ax
		cmp	si,offset stabl+1024
		mov	ax,wr nulegy
		sjae	hdngy2
		sub	si,510
hdnvi2:		stosw
		pop	ax
		movsw
		sjmp	hdnavi
hdngy2:		cmp	si,offset stabl+1536
		mov	ax,wr egynul
		sjae	hdngy3
		sub	si,1022
		sjmp	hdnvi2
hdngy3:		sub	si,1534
		mov	ax,wr egyes
		sjmp	hdnvi2

tdurvit:	ncall	nyurit
		sjmp	tdaptov
tdurha:		ncall	kurell
		ncall	tdkub
		sjmp	tdfoly
rdvege0:	stosd
		dec	di
		loop	rdvege0
		sjmp	rdvege1

sorrtrue:	or	bp,bp		;	32/24-bites TRUECOLOR.
		sjz	tdvege0
tdcikl:		cmp	di,offset vesa+512+aptuf-2*32
		movzx	si,br gs:[ebx][2*eax+1]
		sjae	tdurvit
tdaptov:	cmp	cx,dx
		lea	si,[4*esi]
		sje	tdurha
tdfoly:		test	xmode,1
		lea	si,stabl[4*esi]
		sjz	sorr24
		cmp	si,offset stabl+1024
		sjae	tdnagy
		movsd
tdnavi:		movsd
rdnavi:		movsd
		movsd
		neg	bp
		movzx	si,br gs:[ebx][2*eax]
		sjs	tdaptov
		inc	dx
		dec	bp
		mov	al,[edx]
		sjnz	tdcikl
tdvege0:	cmp	dx,cx
		movzx	cx,sorsze
		sjne	tdvege1
		dec	cx
		test	xmode,1
		push	cx
		mov	eax,egyes
		mov	cl,8
		sjz	rdvege0
		rep	stosd
rdvege1:	pop	cx
tdvege1:	sub	cx,mennyit
		sjbe	riktov
		test	xmode,1
		sjz	nmas24
		add	cx,cx
		njmp	tulmas
nmas24:		mov	eax,dr nulla
		shl	cx,3
rulmas:		cmp	di,offset vesa+512+aptuf-4
		sjae	rdurvit
rdaptov:	stosd
		dec	di
		loop	rulmas
riktov:		njmp	diktov

sorr24:		cmp	si,offset stabl+1024
		sjb	tdnavi
tdnagy:		push	eax
		cmp	si,offset stabl+2048
		mov	eax,nulegy
		sjae	tdngy2
		sub	si,1020
tdnvi2:		test	xmode,1
		stosd
		pop	eax
		sjnz	tdnavi
		dec	si
		dec	di
		movsb
		sjmp	rdnavi
rdurvit:	ncall	nyurit
		sjmp	rdaptov
tdngy2:		cmp	si,offset stabl+3072
		mov	eax,egynul
		sjae	tdngy3
		sub	si,2044
		sjmp	tdnvi2
tdngy3:		mov	eax,egyes
		sub	si,3068
		sjmp	tdnvi2
sorrajz		endp

kurell:		cmp	al,112
		sjae	nukurx
		push	ax
		mov	ax,dkurz
		sub	ax,dszcim
		cmp	ax,dhossz
		pop	ax
		sjb	nkures
nukurx:		xor	al,al
nkures:		ret

dkub:		movzx	si,br gs:[ebx][2*eax+1]		;	Kurzor 256.
		ncall	xorsi255
		lea	si,stabl[4*esi]
		movsd
		movzx	si,br gs:[ebx][2*eax]
		ncall	xorsi255
		lea	si,stabl[4*esi]
		movsd
		ret

hdkub:		sub	si,offset stabl	;	HICOLOR kurzor.
		or	al,al
		sjnz	hdkuk
		xor	si,si
hdkuk:		shr	si,3
		ncall	xorsi255
		shl	si,3
		add	si,offset stabl
		ret

tdkub:		or	al,al		;	TRUECOLOR kurzor.
		sjnz	tdkuk
		xor	si,si
tdkuk:		shr	si,2
		ncall	xorsi255
		shl	si,2
		ret

xorsi255:	push	ax
		push	cx
		mov	cx,4
xorslp:		mov	ax,si
		and	al,3
		sjz	xorol
		cmp	al,3
		sjne	nexorl
xorol:		xor	al,3
nexorl:		shrd	si,ax,2
		loop	xorslp
		pop	cx
		pop	ax
		shr	si,8
		ret

karvaly:	pushf
		push	bx
		push	cx
		mov	bl,dl
		push	dx
		xor	bh,bh
		push	bp
		mov	bp,bx
		push	di
		mov	bl,dh
		push	si
		mov	dx,1
		push	ax
		mov	si,bp
		mov	di,bx
		mov	cx,dx
		ncall	lefed
		ncall	kikapcs
		xchg	ax,bx
		ncall	koord
		xchg	ax,bx
		stosw
		pop	ax
		pop	si
		pop	di
		pop	bp
		pop	dx
		pop	cx
		pop	bx
		popf
		ret

qpont:		mov	cx,1
qwonal:		xor	al,al
		ncall	nyerit
		ncall	kvonal
		njmp	urit
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
tpu2:		mov	ax,4
		sjmp	etpu2

escrup:		mov	dl,uzemmod	;	Ablak grgetse flfel.
		mov	cx,3
		mov	bl,dl
		and	bx,cx
		cmp	ch,alass[bx]
		sje	ness2
		dec	alass[bx]
		sjnz	displ
		mov	al,lass
		mov	alass[bx],al
ness2:		mov	al,pufabl[bx]
		test	al,4
		mov	si,bx
		sjnz	tpu2
		and	ax,cx
etpu2:		rol	dl,cl
		mov	bx,ax
		and	dx,7
		mov	al,pksor[si]
		mov	di,dx
		or	al,al
		mov	cl,elept[di]
		sjnz	scotov2
		cmp	al,eltolas[si]
		sje	scoha2
scotov2:	cmp	cl,al
		sjbe	ralep2
		mov	cl,al
ralep2:		mov	al,eltolas[si]
suxi:		sub	al,elpix[di]
		sjae	raho2
hoho2:		cmp	ch,scroll[si]
		sje	scoha2
		sub	scroll[si],cl
		sjae	hohoho2
		mov	scroll[si],ch
hohoho2:	sub	pksor[si],cl
		mov	al,16
		sjae	suxi
raho2:		or	pufabl[si],32
		mov	tovabb[si],ch
		mov	tszaml[si],ch
		njmp	raho
displ:		sjmp	cispl
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
scoha:		and	pufabl[si],223
scoha2:		or	alabl[si],32
		njmp	display
eltov:		njmp	tovell

escrdn:		mov	dl,uzemmod	;	Ablak grgetse lefel.
		mov	cx,3
		mov	bl,dl
		and	bx,cx
		test	alabl[bx],1
		sjnz	eltov
		cmp	ch,alass[bx]
		sje	ness
		dec	alass[bx]
		sjnz	cispl
		mov	al,lass
		mov	alass[bx],al
ness:		mov	al,pufabl[bx]
		test	al,4
		mov	si,bx
		sjz	tpu
		mov	ax,4
		sjmp	etpu
cispl:		sjmp	rispl
tpu:		and	ax,cx
etpu:		mov	puffer,bl
		rol	dl,cl
		mov	bx,ax
		and	dx,7
		mov	al,phany[bx]
		mov	di,dx
		sub	al,kepsor
		mov	cl,elept[di]
scohugr:	sjbe	scoha
		mov	dl,al
		sub	al,pksor[si]
		sjbe	scoha
		cmp	cl,al
		sjbe	ralep
		mov	cl,al
ralep:		mov	al,eltolas[si]
		add	al,elpix[di]
		cmp	al,16
		sjb	raho
hoho:		cmp	ch,scroll[si]
		sje	scohas
		jcxz	scohax
		add	pksor[si],cl
		test	alabl[si],3
		sjz	hohox
		add	tovabb[si],cl
		sjnc	hohox
		mov	tovabb[si],-1
hohox:		sub	scroll[si],cl
		sjbe	scohax
hohoho:		mov	al,ch
raho:		or	alabl[si],32
		mov	eltolas[si],al
rispl:		ncall	display
		clc
		ret
scohax:		push	dx
		mov	scroll[si],ch
		push	si
		ncall	hohoho
		pop	si
		pop	dx
scohas:		sub	dl,pksor[si]
		sjbe	scohugr
		mov	al,fmaszk[si]
		or	alabl[si],32
		or	al,fmaszk[si+4]
		not	al
		and	br output+1,al
		clc
		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
display:	mov	bl,uzemmod
		and	wr alabl,191*(256+1)	;	Ablak megjelenĄtse.
		and	bx,31
		and	wr alabl+2,191*(256+1)
		mov	al,pags[bx+1]
		test	mode,4
		mov	pags,al
		sjnz	dsmmmm
		mov	si,bx
		push	ax
		shr	si,1
		push	bx
		and	si,-2
		mov	dx,gorsze[si+2]
		mov	cx,gepsor[si+2]
		test	bx,16
		mov	vesa+8,bh
		mov	gorsze,dx
		sjz	dnchr
		mov	dl,sorsze
		mov	cl,kepsor
		mov	dh,bh
		mov	ch,bh
		inc	dx
		add	bx,bx
		mov	bp,gsor
		push	dx
		mov	ax,poffs[bx+2]
		inc	cx
		xor	dx,dx
		inc	cx
		div	bp
		mov	si,dx
		xchg	ax,di
		pop	dx
		shr	si,1
		inc	dx
		sjmp	kefed
dsmmmm:		njmp	dsemm
dnchr:		mov	al,felb
		and	ax,7
		;sjnz	juxi
		;or	ouikon+14,672
juxi:		shl	ax,4
		or	bx,ax
		shl	bx,2
		mov	si,pofpos[bx]
		mov	di,pofpos[bx+2]
		mov	wr vesa+4,si
		mov	wr vesa+6,di
kefed:		push	wr tewan
		ncall	lefed
		pop	ax
		mov	tewan,al
		sjns	neffi
		inc	vesa+8
neffi:		pop	bx
		pop	ax

		cmp	al,pag
		sje	dnpag
		ncall	setpage
dnpag:		mov	bp,bx
		mov	dx,bx
		add	bx,bx
		mov	cx,3
		mov	di,poffs[bx+2]
		push	si
		shr	bx,cl
		mov	si,wr uzemmod
		mov	poffs,di
		mov	al,sorsze[bx+1]
		and	si,3
		push	cx
		cmp	xszel[si],1
		mov	sorsze,al
		mov	cl,al
		mov	al,hszel[si]
		sjbe	eszel
		mul	cl
		div	xszel[si]
eszel:		ncall	reszkik
		test	owan,64+128
		mov	gszel,al
		mov	gszel[si+1],al
		mov	al,kepsor[bx+1]
		sjnz	kvga
		test	uzemmod,16
		sjnz	kvga
		shr	al,1
kvga:		cmp	xmags[si],1
		mov	kepsor,al
		mov	cl,al
		mov	al,hmags[si]
		sjbe	emags
		mul	cl
		div	xmags[si]
emags:		ncall	reszkik
		test	pufabl[si],24
		mov	gmags,al
		mov	gmags[si+1],al
		sjnz	nirres
		test	gfabl[si],1
		sjz	hirres
nirres:		xor	al,al
hirres:		add	si,si
		test	uzemmod,16
		cbw
		sjnz	dilis
		add	ax,ax
		add	ax,ax
		add	ax,ax
		test	owan,64+128
		sjnz	dilis
		add	ax,ax
dilis:		add	bx,bx
		mov	valami,ax
		pop	cx
		mov	ax,gepsor[bx+2]
		and	bp,cx
		mov	gepsor,ax
		mov	bx,bp
		mov	pixel,ax
		mov	al,pufabl[bx]
		test	al,16
		pop	si
jnzdsm:		sjnz	dsemm
		mov	dh,al
		and	al,cl
		test	dh,4
		sjz	doxic
		mov	al,4
doxic:		cbw
		mov	puffer,al
		mov	si,ax
		mov	al,phany[si]
		sub	al,kepsor
		sjae	nemrovv
		mov	al,ah
nemrovv:	mov	maxsor,al
		mov	al,pksor[bx]
		cmp	bh,lass
		mov	karsor,al
		mov	ksor,al
		sjne	kermeh
		test	alabl[bx],48+128
		sjz	dsemm
kermeh:		test	alabl[bx],16
		sjz	gmehet
		ncall	kerreg
gmehet:		and	alabl[bx],207
		or	alabl[bx],64
		test	dh,8
		sjz	dnogr
		njmp	graph
dsemm:		njmp	tovell

dkara:		mov	al,kepsor	;	Karakteres kpernyn.
		mov	es,chseg
		mov	br pixel,al
		mov	ax,gsor
		cmp	ah,vesa+8
		sjz	djeska
		ncall	egerki
djeska:		add	ax,di
		push	ax
		test	dh,64
		mov	ax,betcol
		sjz	dkarn
		mov	ax,kekkar
dkarn:		mov	dx,ax
		mov	al,0c9h
		mov	cl,sorsze
		stosw
		mov	al,0cdh
		mov	bx,offset asctabl
		rep	stosw
		mov	al,0bbh
		njmp	kiind

dnogr:		add	si,si		;	Grafikus kpernyn.
		mov	ax,pseg[si+2]
		test	dl,16
		mov	pseg,ax
		sjnz	dkara
		mov	fs,ax
		mov	ah,dh
		rol	ax,2
		and	al,1
		cmp	al,aktset
		sje	cucix
		ncall	setcol
cucix:		test	owan,64+128
		mov	gs,charset2
		sjz	ceviga
		mov	gs,chr8set2
ceviga:		movzx	ebx,bx
		movzx	edi,di
		xor	eax,eax
		test	owan,64+128
		mov	bl,eltolas[bx]
		mov	edx,eax
		mov	esi,eax
		sjz	seviga
		shr	bx,1
seviga:		mov	ebp,eax
		mov	ecx,dr nulla
		shl	bx,8
cikl1:		mov	si,wr karsor
		inc	karsor
		mov	ax,sortab[2*esi]
		mov	honnan,ax
		neg	ax
		add	ax,sortab[2*esi+2]
		cmp	al,sorsze
		mov	ah,0
		sjbe	mecix
		mov	al,sorsze
mecix:		cmp	ah,vesa+8
		mov	mennyit,ax
		mov	bp,ax
		sje	cekla
		cmp	pixel,0
		sje	cekla
		test	owan,64+128
		push	bx
		push	cx
		push	si
		push	di
		push	bp
		mov	cx,16
		mov	di,wr vesa+6
		sjz	fedel
		shr	cx,1
fedel:		cmp	cx,pixel
		sjbe	fedell
		mov	cx,pixel
		sjmp	fedell
lcikl:		inc	laval
		sjmp	lckl
ngkocka:	njmp	gkocka
urvit:		ncall	nyurit
		njmp	aptov
fedell:		mov	dx,gorsze
		mov	si,wr vesa+4
		ncall	lefed
		ncall	kikapcs
		pop	bp
		pop	di
		pop	si
		pop	cx
		pop	bx
cekla:		call	begbevit
cikl2:		dec	pixel
		mov	al,sorsze
		mov	dx,honnan
		mov	xorsze,al
		sjs	ngkocka
		xor	ax,ax
		cmp	ax,valami
		mov	al,sorsze
		sjge	cikl0
		sub	al,gszel
		cmp	bp,ax
		mov	sorsze,al
		sjbe	cikl0
		mov	bp,ax
cikl0:		push	cx
		mov	ax,gsor
		mov	cl,orias+1
		inc	wr vesa+6
		shl	bx,cl
		pop	cx
		add	ax,di
		push	ds
		mov	hovair,di
		pop	es
		push	ax
		mov	laval,0
		pushf
		sjc	lcikl
lckl:		test	mode,2
		mov	di,offset vesa+16
		movzx	eax,br fs:[edx]
		njnz	disphi
		or	bp,bp
		sjz	cvege0
cikl4:		movzx	si,br gs:[ebx][2*eax+1]
		inc	dx
		cmp	di,offset vesa+512+aptuf-10
		lea	si,stabl[4*esi]
		sjae	nurvit
aptov:		movsd
		movzx	si,br gs:[ebx][2*eax]
		cmp	al,92
		lea	si,stabl[4*esi]
		movsd
		sjae	ghond
gogon:		mov	[di],cl
		inc	di
foly:		dec	bp
		mov	al,fs:[edx]
		sjnz	cikl4
cvege0:		mov	al,sorsze
		mov	bp,mennyit
		sub	ax,bp
		xchg	eax,ecx
		sjbe	ciktov
		lea	cx,[ecx][8*ecx]
		shr	cx,1
		sjnc	socik
		cmp	di,offset vesa+512+aptuf-1
		sjbe	cucik
		ncall	nyurit
cucik:		stosb
socik:		shr	cx,1
		sjnc	socik2
		cmp	di,offset vesa+512+aptuf-2
		sjbe	cucik2
		ncall	nyurit
cucik2:		stosw
socik2:		lea	dx,[edi][4*ecx]
		cmp	dx,offset vesa+512+aptuf
		sjbe	cuhet
currux:		mov	dx,(512-16+aptuf)/4
		ncall	nyurit
		cmp	cx,dx
		sjbe	cuhet
		sub	cx,dx
		xchg	cx,dx
		rep	stosd
		xchg	cx,dx
		sjmp	currux
ghond:		sjmp	gond
nurvit:		njmp	urvit
cuhet:		rep	stosd
ciktov:		mov	cl,orias+1
		ncall	urit
		shr	bx,cl
		popf
		sjc	lyktov
yktov:		inc	bh
		dec	valami
		mov	ecx,eax
		sjns	ktov
		inc	valami
ktov:		cmp	bh,8
		mov	al,xorsze
		pop	di
		mov	sorsze,al
		njb	cikl2
		test	owan,64+128
		sjnz	geviga
		cmp	bh,16
		njb	cikl2
geviga:		ncall	bekapcs
		xor	bx,bx
		njmp	cikl1
gond:		sje	gogond
		cmp	al,116
		sjb	xogon
		test	al,1
		mov	[di],cl
		njz	foly
		inc	di
xogon:		njmp	gogon
gogond:		dec	si
		movsb
		njmp	foly
lyktov:		test	laval,254
		sjnz	yktov
		ncall	incpage
		sjmp	yktov

hurvit:		ncall	nyurit
		sjmp	haptov
hnagy:		push	ax
		cmp	si,offset stabl+1024
		mov	ax,wr nulegy
		sjae	hnagy2
		sub	si,510
hnavi2:		stosw
		pop	ax
		movsw
		sjmp	hnavi
hnagy2:		cmp	si,offset stabl+1536
		mov	ax,wr egynul
		sjae	hnagy3
		sub	si,1022
		sjmp	hnavi2
hnagy3:		sub	si,1534
		mov	ax,wr egyes
		sjmp	hnavi2

disphi:		test	mode,1		;	HICOLOR megjelenĄts.
		njnz	disptrue
		or	bp,bp
		sjz	hcvege0
hcikl4:		inc	dx
		cmp	di,offset vesa+512+aptuf-2*10
		movzx	si,br gs:[ebx][2*eax+1]
		sjae	hurvit
haptov:		cmp	si,64
		lea	si,stabl[8*esi]
		sjae	hnagy
		movsd
hnavi:		movsd
		neg	bp
		movzx	si,br gs:[ebx][2*eax]
		sjs	haptov
		cmp	al,92
		sjae	hgond
hgogon:		mov	[di],cx
		add	di,2
hfoly:		dec	bp
		mov	al,fs:[edx]
		sjnz	hcikl4
hcvege0:	mov	al,sorsze
		mov	bp,mennyit
		sub	ax,bp
		xchg	eax,ecx
		njbe	ciktov
		lea	cx,[ecx][8*ecx]
		njmp	socik
hgond:		sje	hgogond
		cmp	al,116
		sjb	hgogon
		test	al,1
		mov	[di],cx
		sjz	hfoly
		add	di,2
		sjmp	hgogon
hgogond:	and	si,63
		lea	si,stabl[8*esi+6]
		movsw
		sjmp	hfoly

turvit:		ncall	nyurit
		sjmp	taptov
disp24:		cmp	si,offset stabl+1024
		sjb	tnavi
tnagy:		push	eax
		cmp	si,offset stabl+2048
		mov	eax,nulegy
		sjae	tnagy2
		sub	si,1020
tnavi2:		test	xmode,1
		stosd
		pop	eax
		sjnz	tnavi
		dec	si
		dec	di
		movsb
		sjmp	rnavi
tnagy2:		cmp	si,offset stabl+3072
		mov	eax,egynul
		sjae	tnagy3
		sub	si,2044
		sjmp	tnavi2
tnagy3:		mov	eax,egyes
		sub	si,3068
		sjmp	tnavi2

disptrue:	or	bp,bp		;	TRUECOLOR megjelenĄts.
		sjz	tcvege0
tcikl4:		inc	dx
		cmp	di,offset vesa+512+aptuf-4*10
		movzx	si,br gs:[ebx][2*eax+1]
		sjae	turvit
taptov:		add	si,si
		test	xmode,1
		lea	si,stabl[8*esi]
		sjz	disp24
		cmp	si,offset stabl+1024
		sjae	tnagy
		movsd
tnavi:		movsd
rnavi:		movsd
		movsd
		neg	bp
		movzx	si,br gs:[ebx][2*eax]
		sjs	taptov
		cmp	al,92
		sjae	tgond
tgogon:		mov	[di],ecx
		add	di,4
tfogy:		test	xmode,1
		sjnz	tfoly
		dec	di
tfoly:		dec	bp
		mov	al,fs:[edx]
		sjnz	tcikl4
tcvege0:	mov	al,sorsze
		mov	bp,mennyit
		sub	ax,bp
		xchg	eax,ecx
		njbe	ciktov
		test	xmode,1
		lea	cx,[ecx][8*ecx]
		njnz	socik2
scix:		cmp	di,offset vesa+512+aptuf-4
		sjae	summas
simos:		stosd
		dec	di
		loop	scix
		njmp	ciktov
summas:		ncall	nyurit
		sjmp	simos
tgond:		sje	tgogond
		cmp	al,116
		sjb	tgogon
		test	al,1
		mov	[di],ecx
		sjz	tfoly
		add	di,3
		test	xmode,1
		sjz	tgogon
		inc	di
		sjmp	tgogon
tgogond:	and	si,63
		shl	si,4
		test	xmode,1
		lea	si,stabl[si+12]
		sjnz	tgog
		sub	si,3
tgog:		movsd
		sjmp	tfogy

khpont:		xlat
		stosw
		sjmp	khzjvi
khzarj:		push	ax
		mov	al,"("
		stosw
		inc	bp
		pop	ax
		xlat
		stosw
		mov	al,")"
khzjvi:		inc	bp
		njmp	kikpon
khpnt:		sjmp	khpont

orkik:		test	owan,1
		sjz	ornin
		test	kwan,2
		sjz	orkel
		test	owan,2
		sjz	ornin
orkel:		test	kwan,4
		sjz	orkvi
ornin:		add	bx,36*4
		xlat
		sub	bx,36*4
		sjmp	kikpon

nkhzarj:	sjmp	khzarj
nkhpnt:		sjmp	khpnt
norkik:		sjmp	orkik

kcikl:		inc	karsor		;	Karakteres megjelenĄts.
		cmp	valami,0
		mov	si,ax
		mov	al,gszel
		sjle	nessie
		sub	sorsze,al
nessie:		mov	ax,gsor
		add	si,si
		add	ax,di
		push	ax
		mov	ax,sortab[si]
		mov	bp,ax
		neg	ax
		add	ax,sortab[si+2]
		cmp	al,sorsze
		mov	ah,ch
		sjbe	kacix
		mov	al,sorsze
kacix:		mov	si,bp
		xchg	ax,cx
		xor	bp,bp
		mov	al,0bah
		mov	ah,dh
		stosw
		mov	ah,dl
		jcxz	kvege
kcikl1:		push	ds
		mov	ds,pseg
		lodsb
		pop	ds
		test	kwan,4
		sjz	orkwa
		cmp	al,97
		sje	nkhzarj
		cmp	al,96
		sje	nkhzarj
		cmp	al,109
		sje	nkhpnt
orkwa:		cmp	al,112
		sjae	norkik
orkvi:		xlat
kikpon:		inc	bp
		stosw
kiktov:		loop	kcikl1
kvege:		mov	cl,xorsze
		mov	sorsze,cl
		sub	cx,bp
		sja	vemveg
		neg	cx
		sub	di,cx
		sub	di,cx
		sjmp	nemveg
vemveg:		mov	al,chures
		rep	stosw
nemveg:		dec	valami
		mov	al,0bah
		mov	ah,dh
		sjns	kiind
		inc	valami
kiind:		dec	br pixel
		stosw
		mov	al,sorsze
		pop	di
		mov	xorsze,al
		mov	ax,wr karsor
		sjs	gkkrvg
		njmp	kcikl
gkkrvg:		mov	al,0c8h
		mov	ah,dh
		mov	cl,sorsze
		stosw
		mov	al,0cdh
		mov	bl,uzemmod
		rep	stosw
		and	bx,3
		mov	al,0bch
		test	alabl[bx],1
		stosw
		sjz	gkkrok
		push	ax
		mov	ax,textvg-textov
		cmp	al,sorsze
		sjbe	sosox
		mov	al,sorsze
sosox:		cmp	al,1
		sjbe	sorsos
		mov	cx,ax
		inc	ax
		add	ax,ax
		add	ax,gsor
		mov	si,offset textov
		sub	di,ax
gkktov:		lodsb
		or	al,al
		mov	ah,tovcol
		sjnz	gektov
		mov	ax,es:[di]
gektov:		stosw
		loop	gkktov
sorsos:		pop	ax
gkkrok:		mov	cl,sorsze
		mov	ch,kepsor
		add	cx,101h
		test	iwan,4
		mov	bp,cx
		sjnz	ginox
		inc	bp
		inc	bp
ginox:		mov	bl,uzemmod
		add	bp,256
		test	bl,8
		mov	ah,betcolh
		mov	dx,bp
		sjz	vizsz
		mov	al,0cbh
		sub	dh,ch
		ncall	karvaly
		dec	ax
		test	bl,4
		mov	dx,bp
		sjz	minxf
		add	dh,ch
minxf:		ncall	karvaly
vizsz:		test	bl,4
		mov	dx,bp
		mov	al,0cch
		sjz	vkxkarc
		sub	dl,cl
		ncall	karvaly
		test	bl,8
		mov	dx,bp
		mov	al,0b9h
		sjz	minxv
		add	dl,cl
minxv:		ncall	karvaly
		test	bl,8
		mov	al,0ceh
		mov	dx,bp
		sjz	vkxkarc
		ncall	karvaly
vkxkarc:	mov	al,bl
		and	al,3
		cmp	al,ablak
		mov	dl,maxsor
		sje	ezzaz
		njmp	nemezaz
ezzaz:		test	iwan,8
		mov	cx,16
		sjz	xalbe
		inc	cx
		inc	cx
xalbe:		test	kwan,2
		sjz	halbe
		add	cx,24
halbe:		mov	ax,cx
		or	dl,dl
		mov	skala,ax
		sjz	nemszor
		mov	dh,ksor
		or	dh,dh
		sjnz	eloszt
		xor	ax,ax
		sjmp	nemszor
eloszt:		mul	dh
		div	dl
nemszor:	cmp	al,cl
		cbw
		sjbe	rendosz
		mov	ax,cx
rendosz:	mov	dx,gsor
		mul	dl
		mov	si,xmax
		mov	di,2
		mov	dx,1
		dec	si
		add	cx,di
		ncall	lefed
		ncall	kikapcs
		mov	di,gsor
		add	di,di
		dec	di
		add	di,di
		add	ax,di
		mov	di,rekocka
		mov	rekocka,ax
		push	ax
		mov	ax,chures
		stosw
		mov	ax,kocka
		pop	di
		stosw
		mov	dl,br xmax
		mov	dh,2
		mov	ax,fnyil
		dec	dx
		ncall	karvaly
		test	iwan,8
		mov	al,lnyil
		mov	dh,20
		sjz	hawai
		add	dh,2
hawai:		test	kwan,2
		sjz	xawai
		add	dh,24
xawai:		ncall	karvaly
		ncall	bekapcs
nemezaz:	njmp	tovell

gkara:		mov	al,kepsor
		mov	es,chseg
		mov	br pixel,al
		mov	ax,gsor
		cmp	ah,vesa+8
		sjz	gjeska
		ncall	egerki
gjeska:		add	ax,di
		test	dh,64
		push	ax
		mov	ax,betcol
		sjz	gkarn
		mov	ax,kekkar
gkarn:		mov	dx,ax
		mov	al,0c9h
		mov	cl,sorsze
		stosw
		mov	al,0cdh
		rep	stosw
		mov	al,0bbh
		sjmp	giind
gkcikl:		mov	si,gsor
		mov	al,0bah
		add	si,di
		push	si
		stosw
		mov	cl,sorsze
		mov	al,0b0h
		mov	ah,dl
		rep	stosw
		mov	al,0bah
		mov	ah,dh
giind:		stosw
		dec	br pixel
		pop	di
		sjns	gkcikl
		njmp	gkkrvg

graph:		test	dl,16
		sjnz	gkara

gkocka:		ncall	bekapcs
		mov	al,uzemmod	;	Szvegkocka grafikus kpernyn.
		and	ax,3
		cmp	al,ablak
		sjne	nemezaz
		mov	ch,ah
		mov	bx,ax
		mov	cl,maxsor
		cwd
		shl	cx,4
		mov	ax,skala
		sjz	gnemszor
		mov	dl,ksor
		shl	dx,4
		or	dl,eltolas[bx]
		or	dx,dx
		sjnz	geloszt
		mov	ax,dx
		sjmp	gnemszor
geloszt:	mul	dx
		div	cx
gnemszor:	cmp	ax,skala
		sjbe	grendosz
		mov	ax,skala
grendosz:	add	ax,skezdy
		mov	bp,skezdx
		push	ax
		mov	cx,ax
		push	bp
		xchg	ax,reky
		xchg	bp,rekx
		mov	bx,ax
		sub	ax,cx
		mov	cx,3
		sjae	gpozit
		neg	ax
gpozit:		test	taksony,128
		sjz	gomoko
		;cmp	ax,cx
gomoko:		mov	al,oxtan
		;sjb	kirak
		and	al,12
		push	bx
		cmp	al,12
		mov	al,60
		sjne	incsik
		;inc	cx
		mov	al,63
		;inc	cx
incsik:		cmp	al,actscale
		mov	newscale,al
		sje	zsazsa
		ncall	setscales
zsazsa:		pop	bx
		sub	bp,cx
		sub	bx,cx
		add	cx,cx
		mov	si,bp
		mov	dx,cx
		mov	di,bx
		add	cx,skmags
		add	dx,skszel
		ncall	lefed
		ncall	kikapcs
		xchg	cx,dx
		mov	al,-4
		ncall	teglap
kirak:		pop	bp
		mov	dx,skszel
		mov	cx,skmags
		pop	ax
		mov	bx,5
		mov	si,bp
		mov	di,ax
		sub	si,bx
		sub	di,bx
		add	bx,bx
		add	dx,bx
		add	cx,bx
		ncall	lefed
		ncall	kikapcs

		test	taksony,128
		push	ax
		njz	homoko

		add	si,xoffs
		push	cx
		xchg	ax,cx
		add	di,yoffs
		mov	cx,dx
		push	bx
		push	si
		push	di
		ncall	setscales
		pop	corny
		pop	cornx
		mov	ax,cx
		pop	bx
		or	al,3
		pop	dx
		mov	scalex,ax
		mov	ax,dx
		sub	cx,bx
		or	al,3
		mov	scaley,ax
		pop	ax
		sub	dx,bx
		push	dx
		ncall	koord
		and	xmode,247
		cmp	ch,lass
		pop	dx
		sje	pupak
		or	xmode,8
pupak:		push	ykoord
		mov	al,pag
		push	xkoord
		pushad
		ncall	buttonb
		popad
		pop	xkoord
		pop	ykoord
		ncall	setpage
		mov	al,oxtan
		and	al,3
		and	koppany,87
		cmp	al,3
		mov	swapcol,5
		sjne	svupak
		and	koppany,84
svupak:		cmp	ch,lass
		mov	al,-4
		sje	pupix
		or	koppany,8
		mov	swapcol,3
pupix:		ncall	tegcikl
		mov	actscale,-1
		njmp	ruszkik

homoko:		mov	al,oxtan
		xchg	cx,dx
		and	al,12
		cmp	al,12
		mov	al,60
		sjne	omora
		mov	al,63
omora:		cmp	al,actscale
		mov	newscale,al
		sje	homora
		push	dx
		ncall	setscales
		pop	dx
homora:		dec	bp
		pop	bx
		mov	al,-4
		dec	bp
		dec	bx
		add	dl,al
		add	cl,al
		dec	bx
		push	dx
		dec	bp
		push	cx
		dec	bx
		push	bp
		push	bx
		ncall	teglap
		pop	bx
		mov	ax,102
		test	taksony,64
		pop	bp
		xchg	ax,di
		pop	cx
		sjnz	tsint
		test	csuvas,16
		sjnz	tsint
		cmp	ch,lass
		sjne	tsint
		cmp	felb,3
		sje	tsint
		inc	di
tsint:		pop	dx
		add	di,di
		push	ds
		mov	ds,ikpuf
		mov	si,[di]
		lodsw
		cmp	cl,al
		sjb	ticsi
		cmp	dl,ah
		sjae	tnang
ticsi:		sub	di,9*2
		mov	si,[di]
		lodsw
tnang:		shr	di,1
		sub	cl,al
		pop	ds
		sjb	ruszkik
		shr	cx,1
		sub	dl,ah
		mov	ax,reky
		sjb	ruszkik
		add	bp,cx
		cmp	ax,skezdy
		sjbe	pnang
		add	bx,dx
pnang:		xchg	ax,di
		ncall	panel

ruszkik:	ncall	bekapcs
		njmp	tovell

reszkik:	and	suan,239

		test	hexan,4
		sjnz	eksan
		test	uzemmod,16
		sjnz	xeszmg
		test	felb,7
		sjz	xeszmg

eksan:		test	uzemmod,28
		sjz	reszmg
		test	suan,4
		sjz	reszmg

		test	uzemmod,16
		sjnz	xeszmg
		push	ax
		mov	al,uzemmod
		and	al,12
		cmp	al,12
		pop	ax
		sjne	reszmg

xeszmg:		xor	al,al
		or	suan,16
reszmg:		or	al,al
		sjnz	eszmg
		inc	ax
eszmg:		cmp	al,cl
		sjbe	geszmg
		xchg	ax,cx
geszmg:		ret

freszkik	proc	far
		ncall	reszkik
		ret
freszkik	endp
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
hatter		proc	far		;	Az ablakok megjelenĄtst
		call	genscales
		and	own,31
		test	mode,8		;	vgzi a h ttrben, a program
		sjnz	etmod		;	fut s val p rhuzamosan!!!
		and	owan,63
		and	kwan,253
etmod:		ncall	jenyom
		test	smode,128
		sjz	smynn
		or	mode,128
		and	smode,127
smynn:		xor	ax,ax
		mov	bx,3
swynn:		test	pufabl[bx],16
		sjz	lynn
		or	gfabl[bx],2
		and	gfabl[bx],251
lynn:		dec	bx
		sjns	swynn
gwynn:		xchg	al,orutput
		or	gwan,8
		or	br output,al
		test	mode,128
		sjnz	nginn
		njmp	nminn
nginn:		;or	huan,128
		test	huan,8
		mov	akhin,0
		sjz	dzsinn
		call	minic
dzsinn:		ncall	negpuf
		and	wr alabl,15*(256+1)
		and	wr alabl+2,15*(256+1)
		and	wr gfabl,251*(256+1)
		and	wr gfabl+2,251*(256+1)
		or	wr alabl,48*(256+1)
		or	wr alabl+2,48*(256+1)
		or	wr gfabl,2*(256+1)
		or	wr gfabl+2,2*(256+1)
		ncall	inkapcs
		push	ymax
		or	suan,2
		mov	br output,-1
		push	xmax
		ncall	raster
		mov	al,smode
		and	javas,20
		test	al,2
		sjnz	ode
		or	javas,32
ode:		call	setmode
		xor	ax,ax
		and	mode,251
		and	gwan,248
		test	ewan,1
		mov	perc,ax
		pop	bx
		mov	sperc,ax
		pop	cx
		mov	csillag,al
		sjnz	nminnn
nmynn:		njmp	nminn
nminnn:		or	bx,bx
		mov	ax,egerx
		sjz	nmbx
		mul	xmax
		div	bx
		mov	egerx,ax
		mov	ax,hintx
		mul	xmax
		div	bx
		mov	hintx,ax
nmbx:		mov	ax,egery
		jcxz	nmcx
		push	bx
		mov	bx,ymax
		cmp	bx,49
		sjne	lyaly1
		inc	bx
lyaly1:		cmp	cx,49
		sjne	lyaly2
		inc	cx
lyaly2:		mul	bx
		div	cx
		mov	egery,ax
		mov	ax,hinty
		mul	bx
		div	cx
		pop	bx
		mov	hinty,ax
		xor	cx,cx
nmcx:		test	uzemmod,16
		mov	dx,xmax
		mov	ax,7
		sjz	nemka1
		mov	dx,640
		sjmp	nemvg1
nemka1:		test	felb,7
		sjnz	nemvg1
		add	dx,dx
nemvg1:		test	huan,8
		sjz	nyegg1
		dec	dx
nyegg1:		int	33h
		test	uzemmod,16
		mov	dx,ymax
		mov	ax,8
		sjz	nemka2
		mov	cl,3
		shl	dx,cl
nemka2:		xor	cx,cx
		test	huan,8
		sjz	nyegg2
		dec	dx
nyegg2:		int	33h
		test	uzemmod,16
		mov	cl,3
		mov	ax,egerx
		mov	dx,egery
		sjz	nemvg2
		shl	dx,cl
		test	kwan,1
		sjz	khot
		inc	cx
khot:		shl	ax,cl
		sjmp	nemvg3
nemvg2:		test	felb,7
		sjnz	nemvg3
		add	ax,ax
nemvg3:		xchg	ax,cx
		mov	ax,4
		int	33h
nminn:		mov	bx,4
tgcikl:		push 	bx
		test	pfadat[bx],5
		sjnz	ntag
		mov	puffer,bl
		call	tagolas
ntag:		pop	bx
		dec	bx
		sjns	tgcikl
nxinn:		test	huan,128
		mov	ax,output
		sjnz	hatt
		or	al,al
		sjz	nhatt
hatt:		;call	genscales
		test	felb,7
		sjnz	blatt
		test	al,15
		sjz	blatt
		or	br output,16
		or	br ouikon+1,6
		or	br ouikon+8,48
		or	ouikon+14,672
blatt:		ncall	raster
		test	huan,128
		sjz	xinn
		ncall	szurkhatt
xinn:		test	mode,4
		mov	bx,3
		sjnz	xabl
alcikl:		mov	al,fmaszk[bx]
		mov	ah,fmaszk[bx+4]
		and	uzemmod,252
		test	br output,al
		sjz	nemabl
		test	uzemmod,16
		sjnz	kavlov
		test	own,16
		sjnz	pavlov
kavlov:		push	ax
		or	uzemmod,bl
		test	br output+1,al
		push	bx
		sjz	nlef
		ncall	escrdn
		sjmp	abltov
nlef:		test	br output+1,ah
		sjz	sima
		ncall	escrup
		sjmp	abltov
nhatt:		sjmp	nemhatt
sima:		mov	eltolas[bx],bh
		mov	scroll[bx],bh
		ncall	display
abltov:		pop	bx
		pop	ax
		sjnc	nemabl
pavlov:		or	ah,al
		not	ax
		and	output,ax
nemabl:		xor	ax,ax
		and	xmode,247
		mov	poffs,ax
		dec	bx
		mov	pags,al
		sjns	alcikl
xabl:		mov	al,ablak
		and	uzemmod,252
		and	al,3
		or	uzemmod,al
		test	br output,16
		sjz	nembev
		push	wr sorsze
		xor	bl,bl
		call	sorrajz
		and	br output,239
		pop	wr sorsze
nembev:		test	mode,4
		sjnz	nenehwa
		test	br output,32
		sjz	nemalp
		push	wr sorsze
		mov	bl,12
		call	sorrajz
		and	br output,223
		pop	wr sorsze
nemalp:		and	br output,15
nemhatt:	ncall	szentept
		ncall	szentkep
		mov	bl,ablak
		and	bx,3
		test	huan,32
		mov	al,alabl[bx]
		sjz	hentai
		ncall	szurkhatt
		sjmp	gevtai
nenehwa:	sjmp	nehwa
hentai:		mov	ah,al
		mov	bh,bl
		xchg	al,realabl
		xchg	bl,reablak
		and	ax,0303h
		and	bx,0303h
		cmp	al,ah
		sjne	csibla
		cmp	bl,bh
		sje	gevtai
csibla:		ncall	csikosz
gevtai:		mov	bx,255
		cmp	bh,hinto
		sje	getva
		cmp	bh,hinta
		sje	getva
		push	wr sorsze
		call	sorrajz
		pop	wr sorsze
		sjmp	tetva
getva:		mov	akhin,0
tetva:		and	mode,127
		and	huan,95
nehwa:		xor	ax,ax
		test	ewan,1
		mov	poffs,ax
		mov	pags,al
		sjz	nemeg
		test	suan,64
		sjnz	nemeg
		test	ewan,2
		sjnz	nemeg
		ncall	egerbe
		sjmp	eweg
nemeg:		ncall	egerki
eweg:		test	own,16
		sjz	heweg
		test	uzemmod,16
		sjnz	neweg
		or	mode,128
neweg:		and	own,239
heweg:		ret
hatter		endp
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
tagolas		proc	far		;	Szvegpuffer tagol sa, az
		mov	al,uzemmod	;	aktu lis mreteknek megfelelen.
		and	ax,28
		shr	ax,1
		shr	ax,1
		mov	si,ax
		mov	al,puffer
		mov	bx,ax
		test	pfadat[bx],5
		sjz	xtaghat
		ret
xtaghat:	mov	dh,al
		mov	al,sorsze[si+1]
		xchg	al,dh
tagolas		endp

taghat		proc	far
		mov	ch,al
		test	owan,64+128
		mov	al,kepsor[si+1]
		xchg	al,ch
		sjnz	tavga
		test	uzemmod,16
		sjnz	tavga
		shr	ch,1
tavga:		add	ax,ax
		xor	cl,cl
		mov	bx,ax
		xchg	al,ah
		mov	honnan,cx
		add	ax,offset sortab
		xor	si,si
		push	ax
		xor	di,di
		mov	spixl,si
		mov	es,pseg[bx+2]
		mov	bp,pvege[bx]
tcikl:		or	si,si
		mov	dl,0
		sjz	orsisi
		dec	si
		cmp	br es:[si],113
		sje	orbanc
orcikl:		inc	si
		cmp	si,bp
		sjae	orsisi
		cmp	dl,es:[si]
		sje	orcikl
		cmp	br es:[si],113
		sjne	orsisi
orbanc:		inc	si
orsisi:		mov	wr vesa[di],si
		inc	di
		inc	spixl
		inc	di
		and	di,510
		cmp	si,bp
		sjae	tagveg
		dec	dx
tcikl2:		inc	dx
tcikl2b:	cmp	si,bp
		sjae	tcikl
		cmp	dl,dh
		sjae	tcikl
		mov	al,es:[si]
		inc	si
		or	al,al
		sjz	tcikl2
		cmp	al,113
		sje	tcikl
		dec	si
		xor	cl,cl
		push	si
		dec	cx
tcikl3:		inc	cx
tcikl3b:	cmp	si,bp
		sjae	szoval
		cmp	cl,dh
		sjae	szoval
		mov	al,es:[si]
		or	al,al
		sje	szoval
		cmp	al,113
		sje	szoval
		inc	si
		test	uzemmod,16
		sjz	tcikl3
tplusz:		test	kwan,4
		sjz	tcikl3
		cmp	al,109
		sje	tplusz1
		cmp	al,97
		sje	tplusz2
		cmp	al,96
		sjne	tcikl3
tplusz2:	inc	cx
tplusz1:	inc	cx
		sjmp	tcikl3		
szoval:		add	dl,cl
		cmp	dl,dh
		pop	ax
		sjbe	tcikl2b
		mov	si,ax
		njmp	tcikl
tagveg:		push	ds
		pop	es

		mov	ax,spixl
		xor	si,si
		or	ah,ah
		sjz	tagok
		mov	ah,bh
		mov	si,ax
		mov	ax,256
		add	si,si
tagok:		shr	bx,1
		mov	dx,ax
		test	pfadat[bx],8
		pop	di
		sjnz	ntacok
		test	pfadat[bx],2
		sjz	ntacok
		njmp	vacok
ntacok:		mov	cl,ch
		mov	ch,bh
		inc	cx
		sub	cx,ax
		sja	xtacok
		test	pfadat[bx],8
		sjnz	tacok
		or	pfadat[bx],2
		mov	ch,bh
xtacok:		mov	cl,br honnan+1
		mov	br honnan,cl
		add	ax,cx
		push	ax
		xor	ax,ax
		rep	stosw
		pop	ax
tacok:		dec	ax
		mov	cx,dx
		mov	phany[bx],al
tacikl:		mov	ax,wr vesa[si]
		inc	si
		inc	si
		stosw
		and	si,510
		loop	tacikl
		inc	ch
		and	pfadat[bx],239
		add	dl,br honnan
		adc	dh,bh
		or	pfadat[bx],4
		sub	cx,dx
		sjbe	taxi
		rep	stosw

taxi:		mov	cl,phany[bx]
		mov	ch,bh
		jcxz	praxi
		add	bx,bx
		mov	ax,pvreg[bx]
		mov	si,cx
		xchg	bl,bh
		add	si,si
pracikl:	cmp	ax,sortab[bx][si]
		sjae	praxix
		dec	si
		dec	si
		loop	pracikl
praxix:		xchg	bl,bh
		shr	bx,1
praxi:		mov	dl,cl

		mov	si,3
tagabl:		mov	al,pufabl[si]
		test	al,4
		mov	ah,al
		sjz	tagren
		mov	al,4
		sjmp	tagtov
tagren:		and	al,3
tagtov:		cmp	al,bl
		sjne	taglep
		test	ah,24
		sjnz	tagsor
		mov	al,fmaszk[si]
		or	br output,al
tagsor:		mov	cl,dl
		mov	al,pkend[si]
		or	al,al
		sjz	vagsor
		sub	cl,al
		sjae	vakog
		mov	cl,bh
vakog:		mov	pksor[si],cl
		mov	pkend[si],bh
vagsor:		mov	al,phany[bx]
		mov	cx,honnan
		sub	al,ch
		sjae	pagsor
		mov	al,bh
pagsor:		cmp	al,pksor[si]
		sjbe	nagsor
		test	alabl[si],4
		sjz	magsor
nagsor:		cmp	bx,4		;	Sz˘jegyzk!!!
		mov	pksor[si],al
		sje	felsor
alsor:		and	pufabl[si],223
magsor:		test	alabl[si],8
		pushf
		and	alabl[si],240
		popf
		sjnz	taglep
		or	alabl[si],2
taglep:		dec	si
		sjns	tagabl
		ret
felsor:		test	pfadat[bx],8
		sjz	alsor
		test	uan,128
		sjnz	alsor
		push	bx
		xchg	bl,bh
		add	bx,bx
		mov	ax,sortab[bx]
		cmp	ax,sortab[bx+2]
		pop	bx
		sje	alsor
		mov	pksor[si],bh
		or	pufabl[si],32
		sjmp	magsor

vacok:		test	pfadat[bx],1
		push	si
		push	ax
		sjnz	urtorl
		add	bx,bx
		mov	ax,pnnen[bx]
		mov	si,pmeret
		shr	bx,1
		sub	si,pkmax
		cmp	ax,si
		sjae	urtorl
		mov	si,3
urcikl:		mov	al,pufabl[si]
		test	al,4
		sjz	urcic
		mov	al,4
		sjmp	urcicc
urcic:		and	al,3
urcicc:		cmp	al,bl
		sjne	urtov
		cmp	ch,pksor[si]
		sja	stacok
urtov:		dec	si
		sjns	urcikl
urtorl:		mov	si,3
torcikl:	mov	al,pufabl[si]
		test	al,4
		sjz	torcic
		mov	al,4
		sjmp	torcicc
torcic:		and	al,3
torcicc:	cmp	al,bl
		sjne	tortov
		sub	pksor[si],ch
		sjae	tortov
		mov	pksor[si],bh
tortov:		dec	si
		sjns	torcikl
		pop	ax
		xor	pfadat[bx],10
		pop	si
		njmp	tacok
stacok:		pop	ax
		pop	si
		njmp	ntacok
taghat		endp
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
egirq		proc	far		;	Kzvetlen egrmegszakĄt s.
		push	bp
		mov	bp,adat
		push	ds
		mov	ds,bp
		mov	bp,wr koppany
		and	koppany,127
		test	ewan,1
		push	si
		sjz	egro
		test	suan,64
		mov	si,ax
		sjnz	egro
		or	ax,ax
		sjz	egro
		test	bp,128
		sjnz	eleng
		test	kwan,128
		mov	bp,ax
		sjz	baleger
		and	si,2+4
		and	bp,8+16
		and	al,225
		add	si,si
		shr	bp,1
		add	si,si
		shr	bp,1
		or	ax,si
		or	ax,bp
baleger:	test	al,2+8+32
		sjz	enyom
		mov	cx,-2
		or	oxtan,128
		mov	dx,cx
enyom:		test	al,4+16+64
		sjz	eleng
		mov	cx,-2
		and	oxtan,127
		mov	dx,cx
eleng:		mov	si,emuto
		mov	empuf[si],ax
		mov	empuf[si+2],bx
		mov	empuf[si+4],cx
		mov	empuf[si+6],dx
		add	si,8
		and	si,56
		cmp	si,emelo
		mov	emuto,si
		sjne	egro
		add	si,8
		and	si,56
		mov	emelo,si
egro:		pop	si
		pop	ds
		pop	bp
		ret
egirq		endp
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
begbevit	proc	far		;	Bels ciklusokb˘l hĄva.
		or	uan,64
begbevit	endp

egbevit		proc	far		;	EgrmegszakĄt sok temezse.
		push	si
		test	gwan,8
		push	ax
		push	bx
		sjz	semegr
		test	kwan,32
		push	cx
		push	dx
		sjnz	rumegr
		sjmp	nemegr
egbev:		test	uan,64
		mov	ax,empuf[si]
		mov	bx,empuf[si+2]
		mov	cx,empuf[si+4]
		mov	dx,empuf[si+6]
		sjz	umegr
		test	al,254
		sjnz	rumegr
umegr:		mov	empuf[si],0
		add	si,8
		and	si,56
		or	ax,ax
		mov	emelo,si
		sjz	nemegr
		call	egrut
		test	kwan,32
		sjnz	remegr
nemegr:		mov	si,emelo
		cmp	si,emuto
		sjne	egbev
remegr:		;and	kwan,223
		;and	gwan,247
rumegr:		pop	dx
		pop	cx
semegr:		and	uan,191
		pop	bx
		pop	ax
		pop	si
		ret
egbevit		endp
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
egrut		proc	far		;	Az egrkezel elj r s.
		push	bp
		mov	bp,adat
		push	ds
		mov	ds,bp
		push	di
		test	ewan,1
		mov	di,cx
		sjnz	egro
rregro:		njmp	negro
egro:		or	di,dx
		push	ax
		sjs	hurut
		mov	ax,ntmousx
		sjz	hurut
		cmp	ax,xmax
		mov	ax,ntmousy
		sjae	hurut
		cmp	ax,ymax
		sjae	hurut
		or	ax,xmax
		sjz	hurut
		call	kurucz
hurut:		pop	ax
		test	al,32
		sjz	jjjole
		or	gwan,16
jjjole:		test	al,64
		sjz	jjjone
		and	gwan,239
jjjone:		or	di,di
		sjns	bacca
		test	uzemmod,16
		mov	cx,egerx
		mov	dx,egery
		sjz	yucca
		add	dx,dx
		add	cx,cx
		add	dx,dx
		add	cx,cx
		add	dx,dx
		test	kwan,1
		sjz	sicca
		add	cx,cx
		sjmp	sicca
yucca:		test	felb,7
		sjnz	bacca
sicca:		add	cx,cx
bacca:		;test	kwan,128
		;mov	bp,ax
		;sjz	jobeg
		;push	di
		;mov	di,ax
		;and	bp,2+4
		;and	di,8+16
		;add	bp,bp
		;shr	di,1
		;and	ax,225
		;add	bp,bp
		;shr	di,1
		;or	ax,bp
		;or	ax,di
		;pop	di
jobeg:		and	ax,31
		push	ax
		and	al,8+16
		sjz	lebegy
		cmp	al,8+16
		sjne	ebegy
		test	kwan,64
		sjnz	lebegy
		sjmp	aegro
ebegy:		and	kwan,191
		test	al,8
		sjz	lebegy
		or	kwan,64
lebegy:		pop	ax
		push	ax
		and	al,2+8
		cmp	al,2+8
		sje	bregro
		or	al,al
		pop	ax
		sjz	grog
		test	mode,4
		sjz	grog
		and	al,21
grog:		test	uzemmod,16
		push	wr laval
		push	wr pag
		sjz	keglac
		push	ax
		xchg	ax,cx
		mov	cl,3
		shr	dx,cl
		test	kwan,1
		sjz	bhop
		inc	cx
bhop:		shr	ax,cl
		xchg	ax,cx
		pop	ax
		sjmp	eglac
bregro:		ncall	idreakph
aegro:		pop	ax
regro:		njmp	negro
rfleng:		njmp	nfleng
keglac:		test	felb,7
		sjnz	eglac
		shr	cx,1
eglac:		cmp	cx,xmax
		sjb	egger
		mov	cx,xmax
		dec	cx
egger:		cmp	dx,ymax
		sjb	exxer
		mov	dx,ymax
		dec	dx
exxer:		cmp	cx,egerx
		sjne	gixxer
		cmp	dx,egery
		sjne	gixxer
		cmp	di,-1
		sje	nemozz
gixxer:		test	tewan,96
		sjz	neglac
		ncall	egerki
neglac:		cmp	br lenyom,131
		mov	egerx,cx
		mov	egery,dx
		sjne	nemozz
		test	al,4
		sjnz	nemozz
xemozz:		or	al,2+4+128
nemozz:		xor	di,di
		test	al,4+16
		mov	bx,di
		sjz	rfleng
		test	al,4
		sjnz	nyomom
		inc	bx
		inc	bx
nyomom:		;or	bx,bx
		push	ax
		;sjz	nyorr
		;mov	ax,lenyom
		;cmp	ax,lenyom+2
		;sje	nyeng
nyorr:		or	bx,bx
		xchg	di,lenyom[bx]
		mov	cl,4
		sjnz	zeng
		cmp	di,128
		mov	si,di
		sjae	lyeng
		push	di
		shr	di,cl
		and	si,15
		add	di,di
		add	si,si
		test	br benyom+8,12
		mov	ax,maszk[si]
		sjz	nyosd
		or	br ouikon+8,12
		and	br benyom+8,243
nyosd:		or	ouikon[di],ax
		not	ax
		and	benyom[di],ax
		pop	di
lyeng:		cmp	di,134
		sjb	nyeng
		cmp	di,138
		sjae	nyeng
		cmp	br ablx,-5
zeng:		sjne	nyeng
		push	bx
		push	ablxy
		push	vhk
		push	ablx
		push	ably
		push	lenyom
		mov	br ablx+1,-1
		push	cx
		push	dx
		mov	al,2
		push	si
		mov	cx,egerx
		push	di
		mov	dx,egery
		push	bp
		sjmp	spleng
goddz:		pop	bp
		pop	di
		pop	si
		pop	dx
		pop	cx
		cmp	br ablx,-4
		pop	lenyom
		pop	ably
		pop	ablx
		pop	bx
		pop	ax
		sjae	xeng
		cmp	bx,vhk
		sje	beng
xeng:		mov	vhk,bx
		mov	ablxy,ax
beng:		pop	bx
nyeng:		ncall	dinyeng
		test	mode,128
		pop	ax
		sjz	spleng
		or	smode,128
		or	own,16
spleng:		xor	di,di
nfleng:		test	al,2+8
		sjnz	jobany
		njmp	njbny
jobany:		or	al,al
		sjns	jojoba
		mov	br lenyom,131
jojoba:		test	uzemmod,16
		push	ax
		xchg	ax,bp
		sjnz	ahab
		push	fs
		mov	fs,ikpuf
ahab:		mov	si,wr felb
		push	cx
		xor	bx,bx
		and	si,7
		push	dx
		sjnz	aqua
		mov	bx,vikonx-ikonx
aqua:		test	uzemmod,16
		sjz	xqua
		shr	di,1
		mov	bx,kikonx-ikonx
		mov	si,4000h
xqua:		mov	ax,ikonx[bx][di]
		add	si,si
		mov	bx,ikony[bx][di]
		push	di
		sjns	demma
		cbw
		xchg	ax,bx
		mov	al,kikony[di]
		or	bx,bx
		cbw
		xchg	ax,bx
		sjz	zejb
		sjns	kjon
		add	ax,xmax
		sjns	kjon
		xor	ax,ax
kjon:		or	bx,bx
		sjz	zejb
		sjns	aya
		add	bx,ymax
		sjns	aya
		xor	bx,bx
		sjmp	aya
demma:		or	ax,ax
		sjz	zejb
		sjns	ijon1
		add	ax,ixmax[si]
ijon1:		add	ax,ixmin[si]
		or	bx,bx
zejb:		sjz	zejab
		sjns	ijon2
		add	bx,iymax[si]
ijon2:		add	bx,iymin[si]
		shr	di,1
		or	si,si
		sjnz	aya
		test	iwan,8
		sjz	aya
		cmp	di,112
		sjne	aya
		dec	bx
		dec	bx
aya:		cmp	cx,ax
		sjb	mell
		cmp	dx,bx
		sjb	mell
		sub	cx,ax
		sub	dx,bx
		or	ch,ch
		sjnz	mell
		or	dh,dh
		sjnz	mell
		or	si,si
		mov	ch,dl
		sjs	roxi1
		movzx	si,ikonszam[di]
		sjnz	roxi1
		inc	si
roxi1:		cmp	di,88
		sjb	alell
		cmp	di,116
		sjae	alell
		test	iwan,4
		sjmp	mell
alell:		test	iwan,8
mell:		sjnz	smjab
		xor	bx,bx
		test	bp,2
		sjnz	bonyom
		inc	bx
		inc	bx
bonyom:		cmp	bh,br lenyom[bx]
		sjne	smjab
		or	si,si
		sjns	gajab
		or	dx,dx
		mov	dl,kiktxt[di]
		sjnz	smjab
		or	dl,dl
zejab:		sjz	smjab
		push	ds
		mov	ds,ikpuf
		mov	si,wr ds:[0]
		mov	si,[si+8]
dxaj:		dec	dx
		sjz	daj
zaj:		lodsb
		inc	al
		sjnz	zaj
		sjmp	dxaj
daj:		dec	dx
xaj:		lodsb
		inc	dx
		inc	al
		sjnz	xaj
		cmp	cx,dx
		pop	ds
		sjae	smjab
		cmp	di,76
		sjne	jajab
		inc	di
		sjmp	jajab
smjab:		sjmp	snajab
gajab:		add	si,si
		mov	si,fs:[si]
		sjz	najab
		lodsw	fs:[si]
		cmp	cl,al
		xchg	ax,dx
		sjae	najab
		cmp	ch,dh
		sjae	najab
		dec	bh
boyop:		xor	ah,ah
		inc	bh
boxop:		lodsb	fs:[si]
		cmp	al,-16
		sjb	achat
		push	cx
		mov	cl,fs:[si]
		ncall	krahat
		sjc	krk
		inc	si
krk:		inc	al
		mov	al,cl
		pop	cx
		sjnz	hachat
		;test	csuvas,16
		;sjz	hachat
		sjmp	bozop
achat:		cmp	al,16
		sjae	boppo
		or	al,al
		sjnz	bozop
		mov	ah,dl
bozop:		add	ah,al
		cmp	ch,bh
		sjne	botor
		cmp	cl,ah
		sjb	najab
botor:		cmp	ah,dl
		sjb	boxop
		cmp	bh,dh
		sjb	boyop
snajab:		sjmp	najab
boppo:		shr	al,4
hachat:		add	ah,al
		cmp	ch,bh
		sjne	botor
		cmp	cl,ah
		sjae	botor
		xor	bh,bh
jajab:		or	bx,bx
		mov	si,di
		mov	cl,4
		mov	lenyom[bx],di
		sjnz	najab
		and	si,15
		shr	di,cl
		add	si,si
		add	di,di
		cmp	br ablx+1,-1
		mov	ax,maszk[si]
		sje	najab
		or	ouikon[di],ax
		or	benyom[di],ax
najab:		test	uzemmod,16
		pop	di
		sjz	egyab
		add	di,di
egyab:		inc	di
		inc	di
		pop	dx
		cmp	di,256
		pop	cx
		sjae	ehab
		njmp	ahab
grhalk:		njmp	grrrr
ehab:		xor	bx,bx
		test	bp,2
		sjnz	nahalk
		inc	bx
		inc	bx
nahalk:		cmp	br lenyom[bx],131
		mov	cx,128
		mov	dx,egerx
		mov	ax,egery
		sje	ehalk
		test	uzemmod,16
		sjnz	grhalk
		cmp	ax,1
		sjb	szelex
		push	ax
		sub	ax,ymax
		inc	cx
		cmp	ax,-1
		pop	ax
		sjae	szelex
		inc	cx
		cmp	dx,1
		sjae	szehalk
szelex:		pop	ax
		or	bx,bx
		push	ax
		sjz	xelex
		and	al,8+16
		cmp	al,8+16
		sjne	xelex
		cmp	cl,120
		sjb	xelex
		cmp	cl,124
		sjb	telex
		cmp	cl,128
		sjb	xelex
		cmp	cl,131
		sjb	telex
		;cmp	cl,133
		;sje	telex
		cmp	cl,138
		sjae	telex
xelex:		mov	lenyom[bx],cx
telex:		njmp	nehalk
ehalk:		inc	cx
		inc	cx
szehalk:	inc	cx
		mov	bp,skezdx
		sub	bp,4
		push	ax
		cmp	dx,bp
		mov	bp,skala
		sjb	xehalk
		sub	ax,skezdy
		add	bp,skmags
		add	ax,3
		add	bp,6
		cmp	ax,bp
		sjae	xehalk
		sub	ax,3
		sjae	xexex
		xor	ax,ax
xexex:		cmp	ax,skala
		sjbe	kexex
		mov	ax,skala
kexex:		mov	vhk,ax
		pop	ax
yelex:		sjmp	szelex
xehalk:		cmp	cx,lenyom[bx]
		pop	ax
		nje	nyehalk
		push	dx
		sub	dx,xmax
		cmp	dx,-1
		pop	dx
		sjb	yehalk
		add	cx,7
zelex:		sjmp	yelex
yehalk:		push	si
		mov	si,wr felb
		and	si,7
		push	di
		shl	si,3
		mov	di,1
		add	si,4
nyalk:		push	dx
		inc	cx
		sub	dx,dofpos[si]
		push	ax
		sjb	hualk
		sub	ax,dofpos[si+2]
		sjb	hualk
		cmp	ax,16
		sjae	hualk
		test	felb,7
		sjnz	nualk
		cmp	al,8
		sjae	hualk
nualk:		shr	dx,3
		cmp	dl,dabsze[di]
		sjae	hualk
		pop	ax
		mov	vhk,dx
		pop	dx
		pop	di
		pop	si
		sjmp	zelex
hualk:		pop	ax
		pop	dx
		sub	si,4
		dec	di
		sjns	nyalk
		xor	si,si
		push	bx
abbala:		inc	cx
		test	pufabl[si],16
		push	ax
		mov	bl,felb
		push	cx
		mov	di,wr uzemmod
		push	dx
		njnz	blabla
		and	bx,7
		and	di,12
		shl	bx,4
		or	bx,di
		or	bx,si
		shl	bx,2
		sub	ax,pofpos[bx+2]
		sjae	recsey
		cmp	ax,-3
		njb	blabla
recsey:		xchg	ax,dx
		sub	ax,pofpos[bx]
		sjae	recsex
		cmp	ax,-3
		njb	blabla
recsex:		mov	bx,gorsze
		mov	cx,gepsor
		add	bx,3
		add	cx,3
		cmp	ax,bx
		sjge	xlabla
		cmp	dx,cx
		sjge	xlabla
		or	ax,ax
		sjs	tossza
		or	dx,dx
		sjs	dossza
		test	alabl[si],1
		sjz	fossza
		test	owan,16+128
		push	si
		push	di
		mov	si,3*2
		sjz	trabla
		inc	si
		inc	si
trabla:		mov	si,wr fs:[si]
		movzx	di,br fs:[si]
		movzx	si,br fs:[si+1]
		sub	bx,di
		pop	di
		sub	cx,si
		pop	si
		cmp	ax,bx
		sjb	fossza
		cmp	dx,cx
		sjb	fossza
		mov	al,-4
tossza:		mov	dl,al
		sjmp	norzix
dossza:		mov	al,dl
norzix:		xor	bx,bx
		njmp	borzix
xlabla:		njmp	blabla
fossza:		cmp	ax,gorsze
		sjae	rossza
		cmp	dx,gepsor
		sjb	ossza
rossza:		mov	al,-3
		sjmp	tossza
ossza:		xor	cx,cx
		test	pufabl[si],8
		njnz	kapex
		test	gfabl[si],1
		njnz	soxxa
		mov	bl,gmags[si+1]
		xor	bh,bh
		shl	bx,3
		test	owan,64+128
		sjnz	sramli
		add	bx,bx
sramli:		cmp	dx,bx
		njae	soxxa
		push	ax
		mov	al,gszel[si+1]
		mov	ah,-9
		imul	ah
		add	ax,gorsze
		xchg	ax,di
		pop	ax
		cmp	ax,di
		sjb	soxxa
		push	ax
		sub	ax,di
		xor	cx,cx
		cmp	ax,9
		sjae	sonxa
		inc	cx
sonxa:		add	ax,di
		sub	ax,gorsze
		cmp	ax,-9
		sjbe	sonya
		or	cl,4
sonya:		test	owan,64+128
		mov	ax,8
		sjnz	sonja
		add	ax,ax
sonja:		cmp	dx,ax
		sjae	sopszka
		or	cl,8
sopszka:	push	dx
		neg	ax
		sub	dx,bx
		cmp	dx,ax
		pop	dx
		sjbe	kepes
		or	cl,2
kepes:		mov	ax,cx
		and	al,1+4
		cmp	al,1+4
		mov	ax,cx
		sjne	keped
		and	cl,251
keped:		and	al,2+8
		cmp	al,2+8
		sjne	kepex
		and	cl,247
kepex:		pop	ax
kapex:		mov	bl,9
		div	bl
		cmp	ch,br [esp+6]
		mov	bl,al
		mov	al,-5
		sjne	orzix
		shr	dx,3
		test	owan,64+128
		mov	bh,dl
		mov	dx,cx
		sjnz	tlabla
		shr	bh,1
		sjmp	tlabla
soxxa:		mov	bl,9
		div	bl
		mov	bl,al
orzix:		cmp	ch,br [esp+6]
		push	ax
		push	dx
		sjne	goroz
		cmp	al,-5
		mov	al,eltolas[si]
		sjae	goroz
		and	ax,15
		test	owan,64+128
		sjz	poroz
		shr	ax,1
poroz:		add	dx,ax
goroz:		pop	ax
		shr	dx,3
		shr	ax,3
		test	owan,64+128
		sjnz	xwabla
		shr	ax,1
		shr	dx,1
xwabla:		mov	bh,al
		pop	ax
		sjmp	tlabla
cwabla:		mov	bh,dl
tlabla:		cmp	al,-5
		sje	borzix
		cmp	dl,kepsor
		sja	blabla
		cmp	al,-5
		sjae	borzix
		cmp	al,sorsze
		sjae	blabla

borzix:		cmp	br [esp+6],0
		mov	br ably,dl
		mov	br ablx,al
		pop	dx
		sjne	torzix
		mov	ablxy,bx
torzix:		pop	cx
		pop	ax
		mov	vhk,si
		pop	bx
		pop	di
		pop	si
welex:		njmp	szelex
blabla:		inc	si
		pop	dx
		cmp	si,4
		pop	cx
		pop	ax
		njb	abbala
		pop	bx
		pop	di
		pop	si
behalt:		cmp	bh,br lenyom[bx]
		mov	cx,139
		sje	welex
nehalk:		cmp	br lenyom,131
nyehalk:	pushf
		test	uzemmod,16
		sjnz	pox
		popf
		pop	fs
		sjmp	poxx
pox:		popf
poxx:		pop	ax
		sjne	rjbny
		or	al,al
		sjs	rjbny
		njmp	xemozz
remmo:		njmp	goddz
rjbny:		test	al,8
		mov	dl,br lenyom+2
		mov	cx,-1
		sjz	njbny
		cmp	dl,120
		sjb	jism
		cmp	dl,124
		sjb	njbny
		cmp	dl,128
		sjb	jism
		cmp	dl,131
		sjb	njbny
		;cmp	dl,133
		;sje	njbny
		cmp	dl,138
		sjae	njbny
jism:		mov	al,8+16
		mov	dx,cx
		or	koppany,128
		call	egirq
		or	kwan,32
njbny:		and	ax,31
		cmp	br ablx+1,-1
		sje	remmo
		test	tewan,128
		xchg	ax,bp
		pop	ax
		sjnz	nemmm
		ncall	egerbe
nemmm:		cmp	al,pag
		sje	pedro
		ncall	setpage
pedro:		xor	ax,ax
		test	mode,4
		pop	wr laval
		mov	perc,ax
		mov	sperc,ax
		sjz	xegro
		test	gwan,1
		sjnz	segro
		test	gwan,2
		sjz	segro
		test	bp,30
		sjz	xegro
segro:		;mov	smodex,ax
		inc	fbalap
		or	smode,128
		or	own,126
xegro:		xchg	ax,bp
negro:		pop	di
		pop	ds
		pop	bp
		ret

grrrr:		mov	di,xmax
		dec	di
		or	ax,ax
		mov	cl,124
		sjnz	gurha
		mov	cl,118
gruah:		cmp	dx,di
		sje	silex
		inc	cx
		or	dx,dx
		sjz	silex
		cmp	cl,119
		xchg	ax,dx
		mov	cl,132
		sje	axlex
		inc	cx
axlex:		dec	ax
		mov	vhk,ax
silex:		njmp	szelex
gurha:		test	iwan,8
		mov	si,ymax
		sjnz	gruha
		dec	si
		dec	si
gruha:		dec	si
		cmp	ax,si
		sjb	seselj
		sje	gruah
		njmp	sehalk
seselj:		dec	cx
		dec	si
		dec	si
		cmp	dx,di
		sjb	grahab
		cmp	ax,si
		sja	silex
		mov	cl,117
		sje	silex
		dec	cx
		sub	al,2
		sje	silex
		mov	cl,120
		sjb	silex
		mov	cl,131
		sjmp	axlex
grahab:		mov	cx,dx
		xor	di,di
		push	bx
		xchg	ax,dx
gruhab:		push	cx
		test	pufabl[di],16
		mov	si,wr uzemmod
		push	dx
		sjnz	grulp
		and	si,28
		or	si,di
		add	si,si
		mov	ax,poffs[si+2]
		xor	dx,dx
		div	gsor
		shr	dx,1
		sub	cx,dx
		pop	dx
		push	dx
		sjb	grulp
		sub	dx,ax
		mov	bl,sorsze
		sjb	grulp
		inc	bx
		cmp	cl,bl
		mov	bh,kepsor
		sja	grulp
		inc	bh
		cmp	dl,bh
		sjbe	trulp
grulp:		inc	di
		pop	dx
		cmp	di,4
		pop	cx
		sjb	gruhab
		pop	bx
sehalk:		njmp	behalt
geret:		mov	cl,-1
garat:		mov	dl,cl
szkita:		mov	br ablx,cl
		mov	br ably,dl
		mov	ablxy,bx
		pop	dx
		pop	cx
		mov	vhk,di
		pop	bx
		lea	cx,[di+134]
		njmp	silex
trulp:		cmp	cl,bl
		sjae	geret
		cmp	dl,bh
		sjae	geret
		dec	cx
		mov	bl,cl
		sjs	geret
		dec	dx
		mov	bh,dl
		sjs	geret
		test	alabl[di],1
		mov	ah,kepsor
		sjz	nomr
		dec	ah
		cmp	dl,ah
		mov	al,sorsze
		sjb	nomr
		sub	al,textvg-textov
		sjnc	nomc
		xor	al,al
nomc:		cmp	cl,al
		sjb	nomr
		mov	cl,-4
		sjmp	garat
nomr:		xor	al,al
		test	pufabl[di],8
		sjnz	gomg
		test	gfabl[di],1
		mov	al,sorsze
		mov	ah,gmags[di+1]
		sjnz	szkita
		sub	al,gszel[di+1]
gomg:		cmp	cl,al
		sjb	szkita
		cmp	dl,ah
		sjae	szkita
		sub	cl,al
		sjne	nemb
		inc	dh
nemb:		inc	cx
		cmp	cl,gszel[di+1]
		sjb	nemj
		or	dh,4
nemj:		inc	dx
		cmp	dl,gmags[di+1]
		sjb	nema
		or	dh,2
nema:		dec	dl
		sjnz	nemf
		or	dh,8
nemf:		mov	cl,-5
		mov	dl,dh
		njmp	szkita
egrut		endp

kurucz		proc	far
		mov	ax,ntmousx
		cmp	ax,xmax
		xchg	ax,cx
		push	dx
		sjae	hurux
		jcxz	hurux
		mul	xmax
		div	cx
hurux:		xchg	ax,cx
		pop	dx
		mov	ax,ntmousy
		push	cx
		cmp	ax,ymax
		xchg	ax,cx
		sjae	huruy
		jcxz	huruy
		xchg	ax,dx
		mul	ymax
		div	cx
		xchg	ax,dx
huruy:		pop	cx
		ret
kurucz		endp

idreakph:	push	ax
		push	bx
		push	dx
		push	si
		call	fdreakf
		pop	si
		pop	dx
		pop	bx
		pop	ax
		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
jenyom:		push	ax		;	Jobb gombos magyar z˘ szvegek.
		push	bx
		mov	ax,lenyom+2
		push	di
		or	al,al
		push	es
		sjz	speng
		cmp	ax,128
		mov	es,ikpuf
		sjae	speng
		cmp	al,120
		sjb	jurta
		cmp	al,124
		sjb	peng
jurta:		cmp	al,hinta
		mov	di,wr es:[39*2]
		sje	hnyeng
		cmp	ah,hinta
		mov	bx,ax
		sjne	hnyeng
		xchg	al,hinta
		or	al,al
		mov	bl,es:[di][bx]
		sjz	hihint
		or	gwan,128
hihint:		mov	hinxxo,bl
		add	di,128
trotli:		dec	bx
		mov	al,127
		sjs	bnyeng
		sjz	nyevv
trotty:		scasb
		sjae	trotty
		sjmp	trotli
nyevv:		scasb
		mov	hint,bl
		sjb	bnyeng
		dec	di
		inc	bx
gyevv:		mov	ah,es:[di]
		scasb
		sjb	xnyeng
		inc	bx
		cmp	bl,hhp-1
		mov	hint[bx-1],ah
		sjb	gyevv
xnyeng:		mov	hint[bx],bh
		inc	bx
		or	gwan,64
		mov	hinto,bl
		mov	hinxox,bl
speng:		sjmp	peng
hnyeng:		and	gwan,63
		sjmp	peng
bnyeng:		and	gwan,63
		or	gwan,128
peng:		pop	es
		pop	di
		pop	bx
		pop	ax
		test	kwan,64
		sjnz	yoyom
		and	gwan,63
		or	gwan,128
yoyom:		;ret

majom:		push	es
		push	si
		test	owan,32+128
		push	cx
		mov	es,ikpuf
		mov	si,1*2
		push	ax
		sjz	anyo
		add	si,si
anyo:		mov	al,hinto
		test	felb,7
		mov	cx,8
		mov	si,es:[si]
		mov	vesa+6,al
		sjz	kanyo
		add	cx,cx
kanyo:		xor	ax,ax
		test	gwan,128
		sjz	gatyo
		test	gwan,64
		sjnz	patyo
		xchg	ax,wr hinto
		or	al,al
		sjz	matyo
		or	ah,ah
		sjz	matyo
patyo:		ncall	motyo
matyo:		and	gwan,127
gatyo:		test	gwan,64
		mov	al,es:[si]
		sjz	atyo
		test	uzemmod,16
		sjz	gago
		mov	al,-6
gago:		add	al,8
		add	ax,egerx
		and	gwan,63
		mov	hintx,ax
		xchg	ax,cx		
		add	al,8
		neg	ax
		test	uzemmod,16
		sjz	xanyo
		mov	ax,egery
		dec	ax
		sjns	gagyo
		inc	ax
		inc	ax
		sjmp	gagyo
banyo:		mov	al,es:[si+1]
		cbw
		add	al,8
xanyo:		add	ax,egery
		cmp	ax,2
gagyo:		mov	hinty,ax
		sjl	banyo
atyo:		pop	ax
		pop	cx
		pop	si
		pop	es
		ret

motyo:		test	uzemmod,16
		sjz	golyo
		mov	orutput,-1
		or	wr alabl,32*(1+256)
		or	wr alabl+2,32*(1+256)
		or	suan,2
		ret
golyo:		pushad
		mov	al,felb
		mov	di,wr uzemmod
		and	ax,7
		and	edi,12
		shl	ax,4
		or	di,ax
		shl	di,2
		xor	esi,esi
goro:		test	pufabl[si],16
		mov	bp,pofpos[edi][4*esi]
		mov	cx,pofpos[edi][4*esi+2]
		push	di
		mov	bx,bp
		mov	dx,cx
		push	si
		njnz	geci
		mov	si,3
		add	bx,gorsze
		add	dx,gepsor
		sub	bp,si
		sub	cx,si
		add	bx,si
		add	dx,si
		test	felb,7
		mov	di,10
		mov	si,wr vesa+6
		sjz	goci
		add	di,8
goci:		and	si,127
		shl	si,3
		inc	si
		inc	si
		add	di,hinty
		add	si,hintx
		cmp	bp,si
		sjae	ageci
		cmp	bx,hintx
		sjbe	bgeci
		cmp	cx,di
		sjae	geci
		cmp	dx,hinty
		sjbe	geci
		mov	wr vesa,si
		pop	si
		mov	wr vesa+2,di
		push	si
		mov	di,3
		mov	al,fmaszk[si]
		or	br output,al
		or	alabl[si],48
		add	bp,di
		add	bx,di
		sub	cx,di
		sub	dx,di
		test	pufabl[si],8
		mov	ah,9
		sjnz	ellen
		test	gfabl[si],1
		mov	al,sorsze
		sjnz	geci
		sub	al,gszel[si+1]
		sjbe	llen
		mul	ah
		add	bp,ax
llen:		mov	al,kepsor
		sub	al,gmags[si+1]
		cbw
		sjbe	ellen
		shl	ax,3
		test	owan,64+128
		sjnz	kllen
		add	ax,ax
kllen:		sub	dx,ax
ellen:		cmp	bp,wr vesa
ageci:		sjae	geci
		cmp	bx,hintx
bgeci:		sjbe	geci
		cmp	cx,wr vesa+2
		sjae	geci
		cmp	dx,hinty
		sjbe	geci
		and	gfabl[si],251
		or	gfabl[si],2
geci:		pop	si
		inc	si
		cmp	si,4
		pop	di
		njb	goro
		mov	eax,-1
		mov	bl,ablak
		or	br output,48
		and	bx,3
		mov	dr ouikon,eax
		mov	dr ouikon+4,eax
		mov	dr ouikon+8,eax
		mov	dr ouikon+12,eax
		mov	al,fmaszk[bx]
		or	huan,128
		or	alabl[bx],32
		or	br output,al
		popad
ninyeng:	ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
dinyeng:	or	di,di		;	DI. lenyom s vgrehajt sa:
		sjz	ninyeng		;	BX = 0: bal, 2: jobb gombbal.
		cmp	di,140
		sjae	ninyeng
		or	bx,bx
		sjz	banyek
		sub	di,116
		sjb	ninyeng
		add	di,di
		jmp	jobugr[di]
banyek:		cmp	di,64
		sjb	utasit
		cmp	di,88
		sjb	bany
		cmp	di,112
		sjb	balutas
bany:		sub	di,64
		add	di,di
		jmp	balugr[di]

utasit:		push	bx
		push	dx
		xor	bx,bx
		cmp	di,16
		push	si
		push	es
		push	di
		push	cx
		push	ds
		pop	es
		push	ds
		mov	ds,ikpuf
		mov	si,[bx]
		sjb	iguta
		sub	di,16
		cmp	di,24
		push	si
		sjb	jofes
		inc	bx
		sub	di,24
		test	es:suan,1
		lodsw
		sjz	jofes
		lodsw
jofes:		mov	al,es:fabhol[bx]
		mov	si,[si]
		cbw
		add	di,ax
		lodsb
		add	si,di
		add	si,ax
		add	si,ax
		add	si,ax
		cmp	di,ax
		lodsb
		xchg	ax,di
		pop	si
		sjae	sigux
iguta:		or	di,di
		mov	si,[si+6]
		sjnz	iggix
sigux:		pop	ds
		njmp	vacs
iggir:		lodsb
		or	al,al
		sjns	iggir
iggix:		dec	di
		sjnz	iggir
		mov	di,offset szocska
		njmp	xopon

balutas:	xchg	ax,di
		sub	ax,88
		add	al,fabhol+2
		cmp	al,balsor
		xchg	ax,di
		sjae	sbolsi
		call	prepare
		push	ax
		push	cx
		push	dx
		mov	dx,di
		push	si
		add	di,di
		push	bp
		call	dakta
		xchg	ax,dx
		sjz	demmi
		lodsb
 		or	al,al
		sjz	szemi
		add	si,cx
		lodsb
		or	al,al
		sjnz	demi
szemi:		mov	si,bp
		inc	si
demi:		xchg	dx,si
		jcxz	demmi
		lodsb
		cmp	cl,al
		xchg	dx,si
		sjne	demmi
moore:		xchg	dx,si
		lodsw
		xchg	ax,bp
		lodsb
		xchg	dx,si
		not	al
		and	ds:[bp],al
		not	al
		and	al,[si]
		inc	si
		or	ds:[bp],al
		loop	moore
demmi:		pop	bp
		pop	si
		pop	dx
		mov	al,1
		pop	cx
		call	postset
		pop	ax
		call	balsugr[di]

inormod:	or	mode,128
		or	own,16
		mov	akhin,0
		and	koppany,64
		ret

sbolsi:		sjmp	bolsi

fnuscro		proc	far
		ncall	nuscro
		ret
fnuscro		endp

nuscro:		push	bx
		mov	bx,3
lasco:		test	alabl[bx],3
		sjnz	vasco
		mov	tovabb[bx],bh
		mov	tszaml[bx],bh
vasco:		dec	bx
		sjns	lasco
		pop	bx
		ret

inskibe:	or	br orutput,16
		mov	al,128
		sjmp	csibe

scrkibe:	mov	al,16
csibe:		push	bx
		xor	bx,bx
		push	ds
		mov	ds,bx
		xor	ds:[417h],al
		pop	ds
		pop	bx
bolsi:		ret

alskibe:	xor	iwan,2
		sjmp	pfladd

balkibe:	xor	iwan,1
pfladd:		call	fpfadd
		ret

skalset:	push	bp
		mov	al,ablak
		push	bx
		and	ax,3
		mov	bp,bx
		push	ax
		xchg	ax,bx
		push	dx
		mov	al,pufabl[bx]
		and	ax,7
		test	al,4
		sjz	skall
		mov	al,4
skall:		xchg	ax,bx
		mov	al,phany[bx]
		mov	bl,kepsor
		dec	bx
		sub	al,bl
		sjae	skah
		xor	al,al
skah:		mov	bl,al
		mul	vhk
		dec	bx
		div	skala
		cmp	al,bl
		pop	dx
		sjbe	skals
		mov	al,bl
skals:		pop	bx
		push	ax
		mov	al,fmaszk[bx]
		or	alabl[bx],32
		or	br orutput,al
		or	al,fmaszk[bx+4]
		not	al
		and	br output+1,al
		or	bp,bp
		pop	ax
		sjz	joggob
		cmp	al,pksor[bx]
		mov	pksor[bx],al
		sjae	shogga
		or	pufabl[bx],32
		test	alabl[bx],1
		mov	tovabb[bx],bh
		mov	tszaml[bx],bh
		sjz	shogga
		or	alabl[bx],128
shogga:		push	bx
		mov	bl,pufabl[bx]
		and	bl,7
		test	bl,4
		sjz	shoxi
		mov	bl,4
shoxi:		mov	ah,phany[bx]
		sub	ah,kepsor
		pop	bx
		sjnc	shoxxi
		xor	ah,ah
shoxxi:		cmp	al,ah
		sjb	shogve
		and	pufabl[bx],223
shogve:		and	alabl[bx],247
shogwe:		pop	bx
		pop	bp
		ret
joggob:		sub	al,pksor[bx]
		sje	shogve
		pushf
		inc	bx
		add	bx,bx
		popf
		sja	shoggoth
		neg	al
felgor:		call	ffelfel
		sjmp	shogwe
shoggoth:	call	flele
		sjmp	shogwe

pmosztas:	or	bx,bx
		push	bx
		sjnz	mosztas
		mov	bl,uzemmod
		and	bl,224
		cmp	bl,224
		sjne	postas
		and	uzemmod,63
mostas:		call	ff12f
		pop	bx
		ret
mosztas:	test	uzemmod,224
		sjnz	mostas
		or	uzemmod,192
postas:		call	ff11f
		pop	bx
		ret

pmfelb:		or	bx,bx
		push	bx
		sjnz	mfelb
		call	fctf11
		pop	bx
		ret
mfelb:		call	fscf11
		pop	bx
		ret

pmmode:		or	bx,bx
		push	bx
		sjnz	mmode
		call	fctf12
		pop	bx
		ret
mmode:		call	fscf12
		pop	bx
		ret

paujob:		call	fpausef
		ret

bevjob:		push	bx
		mov	bl,ablak
		mov	ax,vhk
		and	bx,3
		add	bx,bx
		add	ax,dabpoz[bx+2]
		cmp	ax,dhossz[bx+2]
		sjbe	bevsem
		mov	ax,dhossz[bx+2]
		cmp	ax,dkurz[bx+2]
		sjne	beves
		;or	ax,ax
		;sjz	envalt
reves:		pop	bx
		ret
bevsem:		cmp	ax,dkurz[bx+2]
		sjne	beves
		sub	ax,dabpoz[bx+2]
		xor	bx,bx
		test	uzemmod,16
		sjz	yehoo
		inc	bx
		inc	bx
yehoo:		inc	ax
		cmp	al,dabsze[bx]
		sjae	bctjob
		dec	ax
		sjnz	reves
bctbal:		mov	al,-6
		sjmp	egyesz
bctjob:		mov	al,-7
egyesz:		mov	ah,1
		sjmp	ahesz
beves:		mov	dkurz[bx+2],ax
		pop	bx
		or	br orutput,16
		ret
neves:		sjmp	reves

ctrhom:		mov	al,-15
		sjmp	bahesz

ctrend:		mov	al,-16
		sjmp	bahesz

bpgup:		mov	al,-17
		sjmp	bahesz

bpgdn:		mov	al,-18
		sjmp	bahesz

dyhom:		mov	al,-14
		sjmp	bahesz

dyend:		mov	al,-13
		sjmp	bahesz

allhom:		mov	al,-19

bahesz:		push	bx
		sjmp	egyesz

ctrent:		push	bx

envalt:		mov	al,-3
		sjmp	egyesz

rombusz:	shr	di,1
		mov	ax,4
		sub	ax,di
		sjmp	bevisz

extodos:	mov	al,-1
		sjmp	bevisz

bevbal:		test	kwan,64
		sjz	enbal
		push	bx
		mov	bl,ablak
		mov	ax,vhk
		and	bx,3
		add	bx,bx
		add	ax,dabpoz[bx+2]
		cmp	ax,dhossz[bx+2]
		sjbe	ewing
		mov	ax,dhossz[bx+2]
		or	ax,ax
		sjz	neves
ewing:		cmp	ax,dkurz[bx+2]
		sjne	beves
		or	ax,ax
		mov	al,-2
		sjz	envalt
		sjmp	egyesz

enbal:		mov	al,113

bevisz:		push	bx		;	Egeres billentypuffer Ąr sa.
bevesz:		xor	ah,ah
ahesz:		push	ds
		cmp	al,112
		mov	bx,adat
		mov	ds,bx
		mov	bx,behany
		sje	sembvi
		cmp	bx,bhp
		sjae	sembvi
		or	ah,ah
		sjz	evesz
		or	bx,bx
		sjz	evesz
		push	bx
belep:		cmp	al,behup[bx-1]
		sje	bembvi
		dec	bx
		sjnz	belep
		pop	bx
evesz:		mov	behup[bx],al
		inc	behany
sembvi:		pop	ds
		pop	bx
		ret
bembvi:		pop	bx
		sjmp	sembvi

alljob:		push	bx
		xor	bx,bx
		test	uzemmod,16
		sjz	yahoo
		inc	bx
		inc	bx
yahoo:		mov	al,dabsze[bx+1]
		shr	al,1
		cmp	al,br vhk
		mov	al,-4
		sjae	nagyesz
		dec	ax
nagyesz:	njmp	egyesz

allbal:		push	bx
		mov	bl,ablak
		push	dx
		and	bx,3
		push	si
		mov	bl,pufabl[bx]
		push	es
		and	bl,3
		push	di
		add	bx,bx
		push	cx
		mov	di,offset szocska
		mov	cx,vhk
		push	ds
		mov	si,dszcim[bx+10]
		add	cx,dabpoz[bx+10]
		push	ds
		cmp	cx,dhossz[bx+10]
		pop	es
		sjae	wacs
		add	si,cx
		njmp	virus
wacs:		pop	ds
		njmp	vacs

janter:		push	bx
		mov	bx,vhk
		inc	bx
		push	si
		add	bx,bx
		call	fctend
		pop	si
		pop	bx
santer:		ret

joblak:		cmp	br ably,-4
		sje	janter
		sja	santer
		push	bp
		push	bx
		mov	al,sorsze
		mov	bx,vhk
		xor	ah,ah
		cmp	al,gszel[bx+1]
		mov	al,kepsor
		sja	ornagy
		test	gfabl[bx],1
		sjnz	ornagy
		mov	ah,gmags[bx+1]
		sub	al,ah
		sja	ornagy
		xchg	al,ah
ornagy:		shr	al,1
		inc	bx
		add	al,ah
		cmp	al,br ably
		mov	al,1
		sjbe	legor
		add	bx,bx
		njmp	felgor
legor:		test	alabl[bx-1],3
		sjnz	leggoth
		inc	ax
leggoth:	add	bx,bx
		njmp	shoggoth

aaltas:		shr	di,1
		push	bx
		xchg	ax,di
		push	dx
		sub	al,8
		njmp	saltas

nszablak:	njmp	szablak
nanter:		njmp	anter

bablak:		push	bx
		mov	ax,ablx
		push	dx
		mov	bx,vhk
		mov	dx,ably
		and	bx,3
		or	ah,ah
		sjnz	vablak
		or	dh,dh
		sjnz	vablak
		cmp	al,sorsze
		sjae	vablak
		cmp	dl,kepsor
		sjbe	nszablak
vablak:		cmp	al,-4
		xchg	ax,bx
		sje	nanter
		sja	baltas
		or	dl,dl
		sjz	baltas
		test	kwan,64
		sjnz	salak
		test	suan,16
		xchg	ax,bx
		sjnz	salak
		test	dl,1
		mov	al,gszel[bx+1]
		sjz	qwba
		mov	al,sorsze
		and	dl,251
		sub	al,br ablxy
		sjbe	salak
qwba:		test	dl,2
		mov	ah,gmags[bx+1]
		sjz	qwal
		mov	ah,br ablxy+1
		and	dl,247
		inc	ah
		cmp	ah,kepsor
		sja	salak
qwal:		call	frerr
		test	pufabl[bx],8
		mov	al,32
		sjnz	begga
		and	gfabl[bx],254
begga:		test	alabl[bx],1
		sjz	nyamv
		or	al,128
nyamv:		or	alabl[bx],al
		and	gfabl[bx],251
		mov	al,fmaszk[bx]
		or	gfabl[bx],2
		or	br output,al
		sjmp	salak

bxltas:		push	bx
		push	dx
		xchg	ax,bx
		sjmp	saltas

baltas:
saltas:		cmp	al,ablak
		sje	salak
		push	cx
		push	si
		xor	dx,dx
		call	fxtab
		pop	si
		pop	cx
salak:		pop	dx
		pop	bx
		ret
		push	bx
		push	dx
anter:		push	si
		mov	ax,vhk
		call	faturn
		pop	si
		sjmp	salak

nszultas:	njmp	szultas
ntljes:		njmp	tljes

szablak:	push	si
		mov	si,wr pufabl[bx]
		push	es
		and	si,7
		push	di
		test	si,4
		push	cx
		sjz	szufi
		and	si,4
szufi:		mov	cl,phany[si]
		mov	di,si
		xchg	ax,si
		xor	ch,ch
		add	dl,pksor[bx]
		xchg	al,ah
		adc	dh,ch
		add	ax,dx
		push	ds
		add	ax,ax
		add	di,di
		xchg	ax,si
		cmp	dx,cx
		push	ds
		mov	cx,sortab[si+2]
		mov	si,sortab[si]
		pop	es
		sjae	nszultas
		sub	cx,si
		sjbe	nszultas
		cmp	ax,cx
		xchg	ax,cx
		sjae	nszultas
		add	si,cx
		mov	ds,pseg[di+2]
		lodsb
		cmp	al,113
		sje	nszultas
		cmp	al,85
		mov	di,offset szocska
		sjne	csah
		jcxz	ntljes
		xor	al,al
csah:		push	si
		mov	cx,bhmax
csacs:		cmp	al,113
		sjae	nacs
		cmp	al,85
		sje	nacs
		cmp	al,91
		sjne	lesch
		pop	cx
		mov	cx,bhp-1
macs:		cmp	al,112
		sjb	zacs
		sja	tacs
		xor	al,al
zacs:		ncall	bevisz
		cmp	al,85
		sje	xacs
		lodsb
		loop	macs
tacs:		mov	al,85
		ncall	bevisz
xacs:		pop	ds
		njmp	vacs
lesch:		sub	si,2
		lodsb
		sjb	nacs
		loop	csacs
nacs:		pop	si
		mov	cx,bhmax
		dec	si
virus:		lodsb
		or	al,al
		jcxz	szwolp
		sjz	szwolp
		cmp	al,89
		sjae	szwolp
loccs:		dec	si
		sjz	szwols
		dec	si
		lodsb
		or	al,al
		sjz	szwols
		cmp	al,85
		sje	szwols
		cmp	al,89
		sjae	szwols
		loop	loccs
szwols:		lodsb
szwolp:		cmp	al,112
		sjb	szwock
		sub	al,112
		shr	al,1
		cmp	al,18*2
		sje	koponya
		cmp	al,27*2
		sjne	xwolp
koponya:	mov	ds,es:ikpuf
		mov	si,ds:[91*2]
		sjmp	xopon
tripon:		mov	ax,101*(256+1)
		stosw
		sjmp	xripon
kripon:		mov	al,81
xripon:		stosb
		sjmp	szweg
xwolp:		shr	al,1
		sjz	szwock
szwami:		cmp	bh,[si]
		sje	szwq
		cmp	br [si],113
		sjb	szwnq
szwq:		inc	si
		sjnz	szwami
szwnq:		cmp	bh,[si-1]
		sjne	szwna
		dec	si
szwna:		add	al,35
szwock:		cmp	al,108
		sje	tripon
		cmp	al,109
		sje	tripon
		cmp	al,110
		sje	kripon
		cmp	al,98
		sje	kripon
		cmp	al,92
		sje	kripon
		or	al,al
		stosb
		sjz	szweg
		cmp	al,89
		sjae	szweg

xopon:		cmp	di,offset szocska+126
		lodsb
		sjae	szweg
		or	al,al
		sjz	szweg
		cmp	al,89
		sjb	szwock
szweg:		mov	wr es:[di],128
		xor	cx,cx
		sub	di,offset szocska
		mov	ds,cx
		test	br ds:[417h],3
		pop	ds
		mov	wr besszur,cx
		mov	br besszho,1
		mov	szocskho,di
		sjnz	reweg
		test	gwan,16
		sjnz	reweg
		call	fertelm
		sjc	vacs

reweg:		mov	cx,szocskho
		jcxz	vacs
		push	cx
		mov	bl,ablak
		mov	cx,besszho
		and	bx,3
		mov	si,offset besszur
		add	bx,bx
		jcxz	nelli
		mov	ax,dkurz[bx+2]
		or	ax,ax
		sjz	nelli
		add	ax,dszcim[bx+2]
		dec	ax
		xchg	ax,bx
		mov	al,[bx]
		cmp	al,89
		sjb	celli
		cmp	al,93
		sjb	nelli
celli:		cmp	cl,1
		sja	melli
		cmp	al,besszur
		sje	nelli
melli:		mov	al,szocska
		or	al,al
		sjz	nelli
		cmp	al,98
		sjae	nelli
nell:		lodsb
		ncall	bevisz
		loop	nell		
nelli:		mov	si,offset szocska
		pop	cx
rewop:		lodsb
		ncall	bevisz
		loop	rewop
vacs:		pop	cx
		pop	di
		pop	es
		pop	si
		njmp	salak

szultas:	pop	ds
		cmp	bl,ablak
		sje	szjgyz
		ncall	bxltas
		sjmp	vacs
szjgyz:		mov	al,-12
bahia:		ncall	bahesz
		sjmp	vacs

tljes:		mov	bl,es:ablak
		and	bx,3
		add	bx,bx
		mov	di,es:dszcim[bx+2]
		mov	cx,bhmax
		mov	dx,di
xerx:		lodsb
		cmp	al,111
		sjb	xjes
		sje	xoop
		sub	al,112
		sja	xerw
xjes:		cmp	al,108
		sjb	xoop
		cmp	al,109
		mov	al,101
		sjb	xepon
		sje	xoop
xekon:		mov	al,81
		sjmp	xoop
xepon:		dec	cx
		stosb
		sjz	xxes
xoop:		cmp	al,92
		sje	xekon
		cmp	al,98
		sje	xerx
		stosb
		loop	xerx
xerw:		jcxz	xxes
		cmp	dx,di
		mov	al,bh
		sje	xoxx
		cmp	br es:[di-1],101
		sjne	xoxx
		dec	di
xoxx:		stosb
		dec	di
xxes:		sub	di,dx
		pop	ds
		xor	ax,ax
		mov	dhossz[bx+2],di
		mov	dabpoz[bx+2],ax
		mov	dkurz[bx+2],ax
		mov	al,-13
		sjmp	bahia

sorvalt:	push	ax
		push	si
		xor	hexan,8
		push	ds
		mov	ds,ikpuf
		mov	si,wr ds:[0]
		lodsw
		xchg	ax,[si]
		mov	[si-2],ax
		pop	ds
		pop	si
		pop	ax
tirsa:		ncall	felsa
		sjmp	sorsa

ikcser:		xor	suan,1
		ncall	felsa
sorsa:		mov	wr fabhol,00000h	;0ff00h/000ffh
		sjmp	alsa

felsbal:	dec	fabhol
		sjns	felsa
felsjob:	inc	fabhol
felsa:		mov	ouikon+2,-1
		mov	br ouikon+5,-1
		sjmp	kakka

alsbal:		dec	fabhol+1
		sjns	alsa
alsjob:		inc	fabhol+1
alsa:		mov	br ouikon+4,-1
		mov	ouikon+6,-1
kakka:		test	uzemmod,16
		sjz	kakkar
		or	suan,2
kakkar:		ret

balsfel:	dec	fabhol+2
		sjns	balsa
balsle:		inc	fabhol+2
balsa:		mov	br ouikon+10,-1
		mov	ouikon+12,-1
		ret

fsorvalt	proc	far
		ncall	sorvalt
		ret
fsorvalt	endp

fikcser		proc	far
		ncall	ikcser
		ret
fikcser		endp

ilenc:		call	fdelenc
		ret

incpcr:		call	priforg
		sje	iffor
		dec	kiterj+7

incscr:		call	secforg
iffor:		ret

itablo:		call	ftablo
		ret

ixsctt0:	push	bx
		xor	bl,bl
		sjmp	ixsctt

ixsctt1:	push	bx
		mov	bl,1
		sjmp	ixsctt

ixsctt2:	push	bx
		mov	bl,2
		sjmp	ixsctt

ixsctt3:	push	bx
		mov	bl,3
ixsctt:		call	fxsctt
		pop	bx
		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
szulab:		mov	al,felb
		mov	bl,uzemmod
		and	ax,7
		and	bx,12
		shl	ax,4
		push	si
		or	bx,ax
		mov	bp,-1
		shl	bx,2
		push	di
		xor	cx,cx
		lea	si,pofpos[bx]
		mov	di,3
		mov	ax,bp
		xor	dx,dx
		mov	bx,di
szuper:		push	ax
		lodsw
		sub	ax,di
		cmp	bp,ax
		sjbe	szq1
		mov	bp,ax
szq1:		add	ax,gorsze
		add	ax,di
		add	ax,di
		cmp	cx,ax
		sjae	szq2
		xchg	ax,cx
szq2:		pop	ax
		push	bp
		xchg	ax,bp
		lodsw
		sub	ax,di
		cmp	bp,ax
		sjbe	szq3
		mov	bp,ax
szq3:		add	ax,gepsor
		add	ax,di
		add	ax,di
		cmp	dx,ax
		sjae	szq4
		xchg	ax,dx
szq4:		xchg	ax,bp
		dec	bx
		pop	bp
		sjns	szuper
		pop	di
		pop	si
		sjmp	xulex2
szulal:		sja	szulab
		mov	cx,1
		sjmp	szbeva
szuleb:		cmp	si,16
		sjae	szulal
		xor	cx,cx
szbeva:		mov	bl,felb
		and	bx,7
		add	bx,bx
		or	bx,cx
		mov	cl,gabsze[bx]
		shl	bx,2
		shl	cx,3
		test	felb,7
		mov	dx,8
		mov	bp,dofpos[bx]
		mov	ax,dofpos[bx+2]
		sjz	deva
		add	dx,dx
deva:		add	cx,bp
		add	dx,ax
		test	chewan,64
		sjnz	xulex
		;test	javas,4
		;sjnz	xulex
		;test	felb,7
		;sjz	xulex
		dec	bp
		dec	ax
		inc	cx
		inc	dx
xulex2:		sjmp	xulex
szulak:		sja	szuleb
		mov	bp,skezdx
		mov	ax,reky
		mov	bx,3
		mov	cx,bp
		mov	dx,ax
		sub	bp,bx
		sub	ax,bx
		add	cx,skszel
		add	dx,skmags
		add	cx,bx
		add	dx,bx
		mov	bl,oxtan
		and	bl,12
		cmp	bl,12
		sje	xulex
		mov	ax,skezdy
		sub	dx,reky
		add	dx,ax
		sub	ax,3
		add	dx,skala
xulex:		njmp	szulex
asszur:		ret

szurkhatt:	test	mode,4		;	Szrke alapszĄn kitlts.
		sjnz	asszur
		test	uzemmod,16
		sjnz	asszur
		test	huan,64
		mov	al,63
		sjnz	asszur
		ncall	setscales
		xor	si,si
		test	huan,16
		push	ds
		sjz	brulla
		mov	scalex,si
		mov	scaley,si
brulla:		mov	di,offset stabl+768
		mov	fs,ikpuf
		mov	aktset,-1
		pop	es
szulep:		test	huan,16
		sjnz	xulla
		cmp	si,14
		mov	bl,szurja[si]
		njae	szulak
		cmp	si,10
		sjne	szuszu
		test	iwan,5
		sjz	szuszak
xulla:		xor	ax,ax
		xor	bp,bp
		xor	cx,cx
		xor	dx,dx
		sjmp	xulex
sulla:		pop	si
		sjmp	xulla
szuszu:		test	iwan,10
		sjnz	xulla
szuszak:	push	si
		mov	si,wr felb
		xor	bh,bh
		and	si,7
		push	bx
		sjnz	szuha1
		add	bx,vikonx-ikonx
szuha1:		mov	dx,ikony[bx]
		mov	cx,ikonx[bx]
		pop	bx
		add	si,si
		shr	bx,1
		or	dx,dx
		sjns	szux1
		add	dx,iymax[si]
szux1:		sjz	sulla
		or	si,si
		mov	bl,ikonszam[bx]
		sjnz	roxi2
		inc	bx
roxi2:		or	cx,cx
		sjns	szux2
		add	cx,ixmax[si]
szux2:		sjz	sulla
		add	dx,iymin[si]
		add	cx,ixmin[si]
		pop	si
		push	di
		mov	di,bx
		add	bx,bx
		mov	bx,fs:[bx]
		mov	ax,fs:[bx]
		mov	bl,szurbf[si]
		xor	bh,bh
		add	cl,al
		push	si
		adc	ch,bh
		add	dl,ah
		mov	si,wr felb
		adc	dh,bh
		and	si,7
		push	bx
		sjnz	szuha2
		add	bx,vikonx-ikonx
szuha2:		mov	ax,ikony[bx]
		mov	bp,ikonx[bx]
		add	si,si
		or	ax,ax
		pop	bx
		sjns	szuh1
		add	ax,iymax[si]
szuh1:		sjz	szux1
		or	bp,bp
		sjns	szuh2
		add	bp,ixmax[si]
szuh2:		sjz	szuh1
		add	ax,iymin[si]
		add	bp,ixmin[si]
		or	si,si
		sjnz	szuhy
		cmp	di,82
		sjne	szuhy
		dec	ax
		dec	ax
szuhy:		pop	si
		pop	di
szulex:		stosw
		xchg	ax,dx
		stosw
		xchg	ax,bp
		inc	si
		stosw
		xchg	ax,cx
		cmp	si,18
		stosw
		njb	szulep
		ncall	egerki
		test	owan,16+128
		mov	bx,1
		sjnz	szulejm
		add	bx,bx
szulejm:	mov	ax,ymax
		mov	dx,bx
		mov	di,xmax
		sub	ax,dx
		sub	di,bx
yulejm:		push	bx
		push	ax
		mov	bp,bx
xulejm:		cmp	bx,di
		mov	si,offset stabl+768
		mov	cx,18
		sjae	ulejm
		push	di
		mov	di,-1
xulhu:		lodsw
		cmp	dx,ax
		lodsw
		sjb	plejm4
		cmp	dx,ax
		lodsw
		xchg	ax,bx
		sjae	plejm2
		cmp	bp,bx
		lodsw
		sja	plejm
		cmp	bx,di
		sjae	plejm
		mov	di,bx
		mov	es,ax
		sjmp	plejm
schlejm:	cmp	bp,di
		mov	ax,es
		sja	xlejm
		cmp	bp,ax
		sjae	xlejm
		push	dx
		mov	cx,di
		mov	bx,dx
		push	ax
		sub	cx,bp
		mov	al,-4
		sjbe	svein
		ncall	kvonal
		ncall	urit
svein:		pop	bx
		pop	dx
		mov	bp,bx
		sjmp	xlejm
plejm4:		lodsw
plejm2:		lodsw
plejm:		loop	xulhu
		or	di,di
		pop	bx
		push	bx
		sjns	schlejm
xlejm:		pop	di
		sjmp	xulejm
ulejm:		push	di
		mov	bx,dx
		mov	cx,di
		push	dx
		sub	cx,bp
		mov	al,-4
		sjbe	nyuszi
		ncall	kvonal
		ncall	urit
nyuszi:		pop	dx
		pop	di
		inc	dx
		pop	ax
		cmp	dx,ax
		pop	bx
		sjb	yulejm
		test	chewan,64
		mov	si,offset stabl+768+15*8
		sjnz	vera
		;test	javas,4
		;sjnz	vera
		;test	felb,7
		;sjz	vera
tera:		lodsw
		xchg	ax,bx
		lodsw
		xchg	ax,dx
		lodsw
		dec	dx
		xchg	ax,bp
		lodsw
		dec	dx
		dec	ax
		sub	dx,bx
		xchg	ax,cx
		sjbe	vera
		sjs	vera
		sub	cx,bp
		mov	al,-2
		sjbe	vera
		sjs	vera
		ncall	nyomal
		dec	ax
		mov	di,cx
		add	bp,cx
		dec	ax
		mov	cx,1
		ncall	nyomal
		inc	ax
nyonyo:		sub	bp,di
		inc	bx
		inc	ax
		ncall	nyomal
		add	bp,di
		dec	ax
		ncall	nyomal
		dec	dx
		sjnz	nyonyo
		sub	bp,di
		dec	ax
		inc	bx
		ncall	nyomal
		inc	ax
		inc	bp
		mov	cx,di
		ncall	nyomal
		cmp	si,offset stabl+768+17*8
		sjb	tera
vera:		test	huan,16
		sjz	gera
		and	koppany,64
		and	huan,239
		sjmp	gerb
gera:		ncall	csikosz
gerb:		njmp	egerbe

nyomal:		pusha
		cmp	al,-4
		sjb	nyomos
		neg	al
		cmp	al,3
		sjne	nyomos
		mov	al,6
nyomos:		test	chewan,32
		sjz	somos
		neg	al
		add	al,8
somos:		test	chewan,128
		sjnz	csomos
		mov	al,9
csomos:		ncall	nyerit
		ncall	kvonal
		ncall	urit
		popa
		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
csikosz:	test	mode,8
		sjz	novell
		test	mode,4
		sjnz	novell
		test	uzemmod,16
		mov	al,60
		sjnz	novell
		ncall	setscales
		test	koppany,3
		mov	cx,skszel
		mov	dx,reky
		mov	bx,skezdy
		mov	bp,rekx
		sjnz	lovell
novell:		ret
lovell:		add	cx,6
		cmp	dx,bx
		push	bx
		sjb	rave
		sub	bp,3
		sja	crave
rave:		mov	dx,bx
		mov	bp,skezdx
		add	dx,skala
		sub	bp,3
		sjbe	brave
		add	dx,skmags
		add	dx,3
crave:		sub	dx,bx
		sjbe	brave
		sub	bx,3
		mov	al,-4
		sjbe	brave
		push	cx
		ncall	fedlap
		pop	cx
brave:		test	taksony,16
		mov	bl,ablak
		mov	bp,skezdx
		sjnz	rogell
		and	bx,3
		test	alabl[bx],3
		mov	al,63
		sjz	rogell
		ncall	setscales
rogell:		sub	bp,3
		pop	dx
		mov	bx,reky
		sjbe	novell
		add	dx,skala
		sub	dx,bx
		sjbe	novell
		add	bx,skmags
		mov	al,-4
		add	bx,3

fedlap:		mov	si,bp
		mov	di,bx
		xchg	cx,dx
		ncall	lefed
		ncall	kikapcs
		xchg	cx,dx
		ncall	teglap
		njmp	bekapcs
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
tovell:					;	<Tov bb> zemm˘dok kezelse.

tongrak:	mov	si,wr uzemmod	;	s grafika-kirak s is itt!!!!!
		xor	ch,ch
		mov	bx,si
		mov	cl,sorsze
		xor	dh,dh
		and	bx,3
		mov	bp,cx
		test	pufabl[bx],8
		mov	dl,kepsor
		sjnz	neggra
		mov	cl,gszel
		mov	dl,gmags
neggra:		sub	bp,cx
		test	si,16
		sjnz	tivon
		xchg	ax,cx
		add	dx,dx
		mov	ah,9
		add	dx,dx
		mul	ah
		xchg	ax,cx
		add	dx,dx
		xchg	ax,bp
		mov	ah,9
		mul	ah
		test	owan,64+128
		xchg	ax,bp
		sjnz	tivon
		add	dx,dx
tivon:		test	mode,4
		sjnz	tvvv
		test	pufabl[bx],16
tvvv:		sjnz	tovvv
		test	si,16
		sjnz	grahet
		test	pufabl[bx],8
		sjnz	tohet
grahet:		test	gfabl[bx],1
		sjnz	tovvv
tohet:		;test	gfabl[bx],4
		;sjnz	tovvv
		test	gfabl[bx],2
		sjz	tovvv
		and	si,31
		push	si
		add	si,si
		xor	bx,bx		
		test	si,32
		mov	ax,poffs[si+2]
		sjz	toposz
		push	dx
		xor	dx,dx
		div	gsor
		shr	dx,1
		inc	ax
		inc	dx
		add	bx,ax
		add	bp,dx
		pop	dx
		sjmp	topxi
toposz:		mov	di,wr felb
		and	si,30
		and	di,7
		add	si,si
		shl	di,6
		or	si,di
		add	bp,pofpos[si]
		add	bx,pofpos[si+2]
topxi:		mov	al,huan
		pop	si
		and	al,2
		and	huan,254
		shr	al,1
		and	si,3
		or	huan,al
		push	si
		mov	ax,-1
		;call	opengfx
		call	picture
		call	closegfx
		pop	bx

tovvv:		mov	al,alabl[bx]
		or	al,al
		sjs	nomore
tontov:		test	al,3
		sjz	tovvar
		mov	al,pufabl[bx]
		test	al,16
		sjnz	tovvar
		test	al,40
		sjz	tovmeg
tkikapcs:	mov	al,alabl[bx]
		and	alabl[bx],253
		or	alabl[bx],160
		test	al,1
		sjz	toppant
		mov	tovabb[bx],bh
		mov	tszaml[bx],bh
toppant:	test	pufabl[bx],32
		sjnz	toppix
xtopp:		mov	al,fmaszk[bx]
		or	br output,al
		not	al
		and	br output+1,al
toppix:		ncall	bekapcs
		clc
		ret
tovvar:		ncall	bekapcs
		stc
		ret
tkika:		sjmp	tkikapcs
nomore:		test	mode,4
		sjnz	nyomor
		test	uzemmod,16
		sjz	omorex
		and	alabl[bx],254
nyomor:		and	alabl[bx],15
		or	alabl[bx],32
		sjmp	xtopp
tovmeg:		and	eltolas[bx],15
		sjnz	tovvar
		test	al,4
		sjz	toto
		mov	al,4
		sjmp	tototo
omorex:		sjmp	nomorex
toto:		and	al,3
tototo:		cbw
		mov	cl,kepsor
		mov	si,ax
		mov	al,phany[si]
		sub	al,cl
		sjbe	tkikapcs
		cmp	al,pksor[bx]
		mov	al,gszel[bx+1]
		sjbe	tkika
		test	gfabl[bx],1
		sjnz	netto
		cmp	al,sorsze
		sjb	netto
		sub	cl,gmags[bx+1]
		sja	netto
		mov	cl,kepsor
netto:		dec	cx
		cmp	cl,tovabb[bx]
		sja	gorget
		sjb	goggo
		cmp	cl,bh
		sjbe	gorget
goggo:		push	ds
		mov	ax,40h
		mov	ds,ax
		test	br ds:[17h],16
		pop	ds
		sjnz	morepic
		xor	ax,ax
		mov	wr tovabb,ax
		mov	wr tovabb+2,ax
		mov	wr tszaml,ax
		mov	wr tszaml+2,ax
gorget:		test	alabl[bx],1
		sjz	gorgor
		or	alabl[bx],160
gorgor:		mov	al,fmaszk[bx]
		mov	ah,al
		or	output,ax
		mov	scroll[bx],-1
		njmp	toppix
nomorex:	test	alabl[bx],64
		sjnz	nomox
		sjmp	toppant22
tappancs:	test	alabl[bx],1
		sjz	topi3
toppant22:	njmp	toppant2
szippancs:	or	alabl[bx],1
		njmp	toppant4
topi3:		njmp	toppant3
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
morrak:		mov	ax,di
		mov	bp,di
		sjmp	morrax

morepic:	test	mode,4
		mov	al,gszel[bx+1]
		sjnz	szippancs
		cmp	al,sorsze
		mov	al,kepsor
		sjb	ammon
		dec	ax
		mov	tovabb[bx],al
ammon:		test	alabl[bx],64
		sjz	tappancs
		or	alabl[bx],1
		test	uzemmod,16
		sjnz	topi3
nomox:		test	owan,16+128
		mov	es,ikpuf
		mov	bp,gorsze
		mov	si,3*2
		sjz	nyeviga
		inc	si
		inc	si
nyeviga:	mov	si,wr es:[si]
		movzx	dx,br es:[si]
		movzx	cx,br es:[si+1]
		xor	di,di
		sub	bp,dx
		mov	ax,gepsor
		sjb	morrak
		sub	ax,cx
		sjb	morrak
		add	di,3
morrax:		push	di
		push	dx
		mov	si,wr uzemmod
		mov	dl,felb
		add	bp,3
		add	ax,3
		and	dx,7
		and	si,15
		shl	dx,4
		or	si,dx
		shl	si,2
		mov	di,pofpos[si+2]
		mov	si,pofpos[si]
		pop	dx
		add	di,ax
		add	si,bp
		ncall	lefed
		ncall	kikapcs
		ncall	rkoord
		add	di,poffs
		sjnc	moretov
		inc	dx
moretov:	mov	al,pags
		add	al,dl
		ncall	setpage
		test	owan,16+128
		pop	ax
		sjz	morvga
		or	ax,ax
		sjz	morvga
		inc	ax
morvga:		test	alabl[bx],128
		sjz	tkirak
		test	alabl[bx],1
		sjz	toppant4
		and	alabl[bx],254
		or	ax,ax
		sjz	nerrak
		add	al,2
nerrak:		or	alabl[bx],32
		test	xmode,64
		sjz	tkirak
		test	pufabl[bx],64
		sjz	tkirak
		or	xmode,8
tkirak:		;test	xmode,64
		;sjz	kirakat
		;test	pufabl[bx],64
		;sjz	kirakat
		;or	xmode,8
kirakat:	push	bx
		mov	si,bx
		mov	bx,poffs
		or	bl,bh
		or	bl,pags
		sjz	nekki
		ncall	vikoord
		or	javas,8
		cmp	al,5
		sjae	yekki
		push	ax
		add	al,125
		push	bx
		test	xmode,64
		push	bp
		sjz	virrak
		test	pufabl[si],64
		sjz	virrak
		or	xmode,8
virrak:		ncall	panel
		pop	bp
		test	taksony,32
		pop	bx
		sjz	brekki
		or	csuvas,128
brekki:		pop	ax
yekki:		ncall	panel
nekki:		ncall	csikosz
		pop	bx
toppant4:	and	alabl[bx],15
toppant2:	njmp	toppant
toppant3:	or	alabl[bx],32
		sjmp	toppant2
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
kikapcs:	;sjz	nekka		;	Ellenrzs ut n kikapcsolja az
		;sjc	negpuf		;	egeret, ha kell (ld.: LEFED!).

kekapcs:	sjz	nekka
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
egerki:		test	tewan,64	;	Egr kikapcsol sa (az
		sjz	negpuf		;	egrpufferban lev kpelem
		test	mode,4+128	;	visszam sol s val).
		sjnz	negpuf
		push	ax
		test	huan,8
		push	di
		push	es
		sjnz	hweki
		test	uzemmod,16
		mov	ax,efpag
		mov	di,efpos
		mov	es,chseg
		sjz	egraph
		stosw
egfeg:		pop	es
		pop	di
		pop	ax
negpuf:		and	tewan,159
nekka:		ret
hweki:		push	bx
		push	cx
		push	dx
		mov	ax,2
		push	si
		push	bp
		int	33h
		pop	bp
		pop	si
		pop	dx
		pop	cx
		pop	bx
segfeg:		sjmp	egfeg
egraph:		cmp	al,pag
		push	cx
		push	wr pag
		sje	nefpag
		ncall	setpage
nefpag:		push	si
		mov	al,mode
		xor	si,si
		push	bp
		mov	cx,epfmg
		push	ds
		mov	ah,xmode
		push	dx
		mov	dx,epfsz
		and	own,191

		;push	es
		;mov	es,ikpuf
		;mov	bp,wr es:[1*2]
		;movzx	bp,br es:[bp]
		;pop	es
		;neg	bp
		;cmp	dx,bp

		cmp	dx,-24
		mov	bp,gsor
		pushf
		test	al,2
		push	0a000h
		mov	ds,egseg
		pop	es
		sjnz	egeht
		add	bp,dx
		popf
		njne	kiger
ege256:		cmp	di,dx
		sjae	lege256
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
etov256:	add	di,bp
		sjc	elap1
ebi1:		loop	ege256
egveg:		pop	dx
		pop	ds
		pop	bp
		pop	si
		pop	ax
		pop	cx
		cmp	al,pag
		sje	segfeg
		ncall	setpage
		njmp	egfeg
elap1:		ncall	dincpage
		sjmp	ebi1
lege256:	ncall	legex
		sjmp	etov256

egeht:		and	al,1
		sjnz	egetrue
		add	dx,dx
		add	bp,dx
		popf
		njne	kiger
egehi:		cmp	di,dx
		sjae	legehi
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
etovhi:		add	di,bp
		sjc	elap2
ebi2:		loop	egehi
egvegh:		sjmp	egveg
elap2:		ncall	dincpage
		sjmp	ebi2
legehi:		ncall	legex
		sjmp	etovhi

egetrue:	popf
		push	bx
		mov	bx,dx
		add	dx,dx
		add	dx,bx
		and	ah,al
		sjz	eget24
		add	dx,bx
		pop	bx
		add	bp,dx
eget32:		mov	ax,dx
		not	ax
		shr	ax,2
egelp32:	cmp	di,-4
		movsd
		sjae	elap4
ebi4:		dec	si
		dec	ax
		sjns	egelp32
		add	di,bp
		sjc	elap3
ebi3:		loop	eget32
		sjmp	egvegh
elap3:		ncall	dincpage
		sjmp	ebi3
elap4:		ncall	dincpage
		sjmp	ebi4

eget24:		add	bp,dx
		pop	bx

kiger:		cmp	di,dx
		sjae	lkiger
		push	cx
		mov	cx,dx
		neg	cx
		shr	cx,1
		sjnc	keg1
		movsb
keg1:		shr	cx,1
		sjnc	keg2
		movsw
keg2:		shr	cx,1
		sjnc	keg3
		movsd
keg3:		shr	cx,1
		sjnc	keg4
		movsd
		movsd
keg4:		sjz	keg6
keg5:		movsd
		movsd
		movsd
		movsd
		loop	keg5
keg6:		pop	cx
kigtov:		add	di,bp
		sjc	elap5
ebi5:		loop	kiger
		sjmp	egvegh
elap5:		ncall	dincpage
		sjmp	ebi5
lkiger:		ncall	legex
		sjmp	kigtov

legex:		push	cx
		mov	cx,di
		push	di
		neg	cx
		shr	cx,1
		sjnc	leg1
		movsb
leg1:		shr	cx,1
		sjnc	leg2
		movsw
leg2:		shr	cx,1
		sjnc	leg3
		movsd
leg3:		shr	cx,1
		sjnc	leg4
		movsd
		movsd
leg4:		sjz	leg6
leg5:		movsd
		movsd
		movsd
		movsd
		loop	leg5
leg6:		pop	cx
		ncall	dincpage
		sub	cx,dx
		shr	cx,1
		sjnc	deg1
		movsb
deg1:		shr	cx,1
		sjnc	deg2
		movsw
deg2:		shr	cx,1
		sjnc	deg3
		movsd
deg3:		shr	cx,1
		sjnc	deg4
		movsd
		movsd
deg4:		sjz	deg6
deg5:		movsd
		movsd
		movsd
		movsd
		loop	deg5
deg6:		pop	cx
bexel:		ret

fegerki		proc	far
		ncall	egerki
		ret
fegerki		endp
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
xgerki:		njmp	egerki

bekapcs:	test	tewan,128	;	Rajzol s vgn vissza llĄtja az
		sjz	bexel		;	egeret, ha kell.
agerbe:		and	tewan,127
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
egerbe:		test	suan,64
		sjnz	xgerki
		test	tewan,64	;	Egr bekapcsol sa (az egr
		sjnz	begpuf		;	alatti kpelem egrpufferba
		test	ewan,1		;	m sol s val egytt).
		sjz	nemex
		test	ewan,2
		sjnz	nemex
		test	mode,4+128
		sjnz	nemex
		push	ax
		test	huan,8
		push	bp
		push	ds
		sjnz	hwebe
		test	uzemmod,16
		mov	ax,egery
		mov	bp,egerx
		mov	epufy,ax
		mov	epufx,bp
		sjz	bgraph
		push	dx
		add	bp,bp
		push	si
		mul	gsor
		add	ax,bp
		test	kwan,2
		mov	bp,4000
		sjz	kwaga
		add	bp,bp
kwaga:		cmp	ax,bp
		sjb	egjo
		xor	ax,ax
egjo:		mov	efpos,ax
		mov	ds,chseg
		xchg	ax,si
		push	cx
		lodsw
		mov	cl,4
		dec	si
		mov	ch,ah
		ror	br [si],cl
		and	ch,8
		and	br [si],247
		or	[si],ch
		pop	cx
		sjnz	ellyo
		mov	br [si],7*16
ellyo:		pop	si
		pop	dx
		pop	ds
		mov	efpag,ax
		push	ds
begfeg:		pop	ds
		pop	bp
		pop	ax
begpuf:		or	tewan,96
		ret
nemex:		njmp	negpuf
hwebe:		push	bx
		push	cx
		push	dx
		mov	ax,1
		push	si
		push	di
		int	33h
		pop	di
		pop	si
		pop	dx
		pop	cx
		pop	bx
		sjmp	begfeg
bgraph:		pushad
		and	chewan,239
		push	fs
		mov	fs,ikpuf
		cmp	br lenyom,134
		push	es
		mov	si,wr fs:[0]
		push	ax
		sjb	began
		cmp	br lenyom,138
		sjae	began
		cmp	br ablx,-5
		mov	ax,ably
		sjne	began
		and	ax,3
		sjz	began
		add	al,3
		test	chewan,8
		sjnz	began
		shl	al,2
		or	chewan,16
		add	si,ax
		sjmp	bebeyo
began:		test	tegan,4
		sjnz	beebee
		test	oxtan,128
		sjnz	beebee
		add	si,4
beebee:		test	kwan,128
		sjz	bebeyo
		add	si,8
bebeyo:		mov	esi,dr fs:[si+16]
	 	test	owan,32+128
		pop	ax
		mov	dr fs:[1*2],esi
		sjz	elvis
		shr	esi,16
elvis:		or	own,64
		test	oxtan,128
		movzx	cx,br fs:[si+1]
		movzx	dx,br fs:[si]
		push	wr pag
		sjz	koxta
		test	tegan,4
		sjnz	koxta
		test	chewan,16
		sjnz	koxta
		add	ax,nyomy
		add	bp,nyomx
koxta:		push	ax
		movzx	ax,br fs:[si+2]
		sub	bp,ax
		pop	ax
		sjae	joxta
		add	dx,bp
		sjs	nreppa
		xor	bp,bp
joxta:		sub	al,br fs:[si+3]
		mov	pag,-1
		sbb	ah,0
		sjae	roxta
		add	cx,ax
		sjs	nreppa
		xor	ax,ax
roxta:		cmp	bp,xmax
		sjae	nreppa
		cmp	ax,ymax
		sjae	nreppa
		push	ax
		add	ax,cx
		sub	ax,ymax
		sjbe	elviy
		sub	cx,ax
elviy:		mov	ax,bp
		add	ax,dx
		sub	ax,xmax
		sjbe	elvix
		sub	dx,ax
elvix:		neg	dx
		pop	ax
		;or	dx,dx
		jcxz	nreppa
		sjnz	eppa
nreppa:		njmp	reppa
eppa:		push	dx
		push	cx
		ncall	koord
		pop	cx
		mov	efpag,dx
		mov	efpos,ax
		pop	dx
		mov	epfmg,cx
		mov	epfsz,dx
		xchg	ax,si
		push	wr xmode

		;mov	bp,wr fs:[1*2]
		;movzx	bp,br fs:[bp]
		;neg	bp
		;cmp	dx,bp

		xor	di,di
		and	xmode,247
		cmp	dx,-24
		mov	al,mode
		mov	ah,xmode
		pushf
		test	al,2
		push	es
		mov	bp,gsor
		mov	es,egseg
		pop	ds
		njnz	bgeht
		add	bp,dx
		popf
		njne	ngeger
bge256:		cmp	si,dx
		sjae	lbge256
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
btov256:	add	si,bp
		sjc	blap1
bebi1:		loop	bge256
begveg:		push	ds
		pop	es
		push	adat
		pop	ds
		mov	ax,efpag
		and	oxtan,191
		;and	own,191
		cmp	al,pag
		mov	di,efpos
		sje	bgpf
		ncall	setpage
bgpf:		test	owan,32+128
		mov	si,wr fs:[1*2]
		sjz	bvga
		mov	si,wr fs:[2*2]
bvga:		ncall	epanel
		pop	wr xmode
reppa:		pop	ax
		and	own,191
		cmp	al,pag
		sje	xeppa
		ncall	setpage
xeppa:		pop	es
		pop	fs
		popad
		njmp	begfeg
blap1:		ncall	dincpage
		sjmp	bebi1
lbge256:	ncall	lbgex
		sjmp	btov256

bgeht:		and	al,1
		sjnz	bgetrue
		add	dx,dx
		add	bp,dx
		popf
		njne	ngeger
bgehi:		cmp	si,dx
		sjae	lbgehi
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
btovhi:		add	si,bp
		sjc	blap2
bebi2:		loop	bgehi
bgvegh:		njmp	begveg
blap2:		ncall	dincpage
		sjmp	bebi2
lbgehi:		ncall	lbgex
		sjmp	btovhi

bgetrue:	popf
		push	bx
		mov	bx,dx
		add	dx,dx
		add	dx,bx
		and	ah,al
		sjz	bget24
		add	dx,bx
		pop	bx
		add	bp,dx
bget32:		mov	ax,dx
		not	ax
		shr	ax,2
bgelp32:	cmp	si,-4
		movsd
		sjae	blap4
bebi4:		dec	di
		dec	ax
		sjns	bgelp32
		add	si,bp
		sjc	blap3
bebi3:		loop	bget32
		sjmp	bgvegh
blap3:		ncall	dincpage
		sjmp	bebi3
blap4:		ncall	dincpage
		sjmp	bebi4

bget24:		add	bp,dx
		pop	bx

ngeger:		cmp	si,dx
		sjae	lgeger
		push	cx
		mov	cx,dx
		neg	cx
		shr	cx,1
		sjnc	ngeg1
		movsb
ngeg1:		shr	cx,1
		sjnc	ngeg2
		movsw
ngeg2:		shr	cx,1
		sjnc	ngeg3
		movsd
ngeg3:		shr	cx,1
		sjnc	ngeg4
		movsd
		movsd
ngeg4:		sjz	ngeg6
ngeg5:		movsd
		movsd
		movsd
		movsd
		loop	ngeg5
ngeg6:		pop	cx
ngegtov:	add	si,bp
		sjc	blap5
bebi5:		loop	ngeger
		sjmp	bgvegh
blap5:		ncall	dincpage
		sjmp	bebi5
lgeger:		ncall	lbgex
		sjmp	ngegtov

lbgex:		push	cx
		mov	cx,si
		push	si
		neg	cx
		shr	cx,1
		sjnc	lbeg1
		movsb
lbeg1:		shr	cx,1
		sjnc	lbeg2
		movsw
lbeg2:		shr	cx,1
		sjnc	lbeg3
		movsd
lbeg3:		shr	cx,1
		sjnc	lbeg4
		movsd
		movsd
lbeg4:		sjz	lbeg6
lbeg5:		movsd
		movsd
		movsd
		movsd
		loop	lbeg5
lbeg6:		pop	cx
		ncall	dincpage
		sub	cx,dx
		shr	cx,1
		sjnc	dbeg1
		movsb
dbeg1:		shr	cx,1
		sjnc	dbeg2
		movsw
dbeg2:		shr	cx,1
		sjnc	dbeg3
		movsd
dbeg3:		shr	cx,1
		sjnc	dbeg4
		movsd
		movsd
dbeg4:		sjz	dbeg6
dbeg5:		movsd
		movsd
		movsd
		movsd
		loop	dbeg5
dbeg6:		pop	cx
		ret

dincpage:	push	ds
		push	adat
		pop	ds
		ncall	incpage
		pop	ds
effed:		ret

fegerbe		proc	far
		ncall	egerbe
		ret
fegerbe		endp
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
lefed:		test	tewan,32	;	Ellenrzi, hogy a kpelem
		sjz	effed		;	takarja-e az egeret.
					;	Be: SI = X-koordin ta,
					;	    DI = Y-koordin ta,
		push	ax		;	    DX = szlessg,
		push	bx		;	    CX = magass g.
					;	Ki: Z = 1 - nem,
					;	    Z = 0 - igen (AX). Ha igen:
		push	si		;	    C = 0 - rszben elfedi,
		xor	ax,ax
		push	es		;	    C = 1 - teljesen elfedi.
		mov	es,ikpuf
		push	bp
		test	uzemmod,16
		push	di
		mov	bp,egerx
		push	egery
		mov	di,1
		sjnz	xjepph
		test	owan,32+128
		mov	bx,wr es:[1*2]
		sjz	xvga
		mov	bx,wr es:[2*2]
xvga:		test	oxtan,128
		movzx	di,br es:[bx]
		movzx	bx,br es:[bx+2]
		sjz	xjeff
		test	tegan,4
		sjnz	xjeff
		test	chewan,16
		sjnz	xjeff
		add	bp,nyomx
xjeff:		sub	bp,bx
		sjae	xjepph
		add	di,bp
		xor	bp,bp
xjepph:		mov	bx,si
		sub	bx,bp
		cmp	bx,di
		sjae	xenem1
		or	ax,1+16*256
xenem1:		mov	bx,si
		add	bx,dx
		sub	bx,bp
		cmp	bx,di
		sja	xenem2
		or	ax,1+32*256
xenem2:		mov	bx,bp
		sub	bx,si
		cmp	bx,dx
		sjae	xenem3
		or	al,2+16
xenem3:		add	bp,di
		sub	bp,si
		cmp	bp,dx
		sja	xenem4
		or	al,2+32
xenem4:		pop	bp
		test	uzemmod,16
		mov	si,1
		pop	di
		sjnz	yjepph
		test	owan,32+128
		mov	bx,wr es:[1*2]
		sjz	yvga
		mov	bx,wr es:[2*2]
yvga:		test	oxtan,128
		movzx	si,br es:[bx+1]
		movzx	bx,br es:[bx+3]
		sjz	yjeff
		test	tegan,4
		sjnz	yjeff
		test	chewan,16
		sjnz	yjeff
		add	bp,nyomy
yjeff:		sub	bp,bx
		sjae	yjepph
		add	si,bp
		xor	bp,bp
yjepph:		mov	bx,di
		sub	bx,bp
		cmp	bx,si
		sjae	yenem1
		or	ah,1+64
yenem1:		mov	bx,di
		add	bx,cx
		sub	bx,bp
		cmp	bx,si
		sja	yenem2
		or	ah,1+128
yenem2:		mov	bx,bp
		sub	bx,di
		cmp	bx,cx
		sjae	yenem3
		or	ax,2*256+64
yenem3:		add	bp,si
		sub	bp,di
		cmp	bp,cx
		sja	yenem4
		or	ax,2*256+128
yenem4:		mov	bx,ax
		pop	bp
		and	bl,bh
		pop	es
		and	bl,3
		pop	si
		pop	bx
		sjz	neffed
		cmp	al,240
		sjae	newan
nbenn:		or	tewan,128
		pop	ax
		ret
newan:		test	uzemmod,16
		sjnz	nbenn
		or	tewan,128
		pop	ax
		stc
		ret
neffed:		push	ax
		and	ax,16+32+(64+128)*256
		cmp	ax,16+32+(64+128)*256
		pop	ax
		sje	nfenn
		and	ax,64+128+(16+32)*256
		cmp	ax,64+128+(16+32)*256
		sje	nfenn
		xor	ax,ax
		pop	ax
		ret
nfenn:		mov	al,128
		or	tewan,al
		dec	al
		pop	ax
		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
randomize	proc	far
		mov	ah,2ch		; A vletlengener tor kezdrtknek
		int	21h		; be llĄt sa az id lekrdezsvel
		mov	random1,cx	; (program elejn szok s).
		mov	random2,cx
		ret
randomize	endp

brandom:	xor	ah,ah

random:		push	bx		; Olyan vletlensz mot  llĄt el, mely
		push	cx		; kisebb, mint AX.
		push	dx
		mov	dx,ax
		mov	cx,16
rndcikl:	ncall	rndax
		cmp	ax,dx
		sjb	rndben
		loop	rndcikl
		mov	bx,cx
rcscikl:	mov	cx,maszk[bx]
		dec	cx
		and	ax,cx
		cmp	ax,dx
		sjb	rndben
		inc	bx
		inc	bx
		cmp	bx,30
		sjb	rcscikl
		xor	ax,ax
rndben:		pop	dx
		pop	cx
		pop	bx
		or	ax,ax
		ret

frandom		proc	far
		ncall	random
		ret
frandom		endp

rndax:		push	bx		; (l)vletlensz m-gener l˘ szubrutin:
		push	dx		; sszevissza vgez mveleteket a
		push	si		; legut˘bbi ( l)vletlensz mmal.
		push	di
		mov	ax,random2
		mov	bx,random1
		mov	si,ax
		mov	di,bx
		mov	dl,ah
		mov	ah,al
		mov	al,bh
		mov	bh,bl
		xor	bl,bl
		rcr	dl,1
		rcr	ax,cl
		rcr	bx,1
		add	bx,di
		adc	ax,si
		xor	si,cx
		sub	si,sp
		and	si,03fffh
		add	bx,[si]
		lea	si,[di][bp]
		add	si,dx
		rcr	si,cl
		and	si,03fffh
		add	ax,[si]
		xor	ax,cx
		mov	random1,bx
		mov	random2,ax
		xor	bx,ax
		mov	ax,bx
		pop	di
		pop	si
		pop	dx
		pop	bx
		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
arteglap:	mov	ax,-1
		or	own,64
		mov	pag,al
		ncall	teglap
		and	own,191
		ret
		
farteglap	proc	far		;	Tglalap rajzol sa a grafikus
		ncall	teglap		;	kpen:
		ret			;	BP = X-pozĄci˘,
farteglap	endp			;	BX = Y-pozĄci˘,
					;	CX = szlessg (kppontban!),
kteglap32:	mov	dx,32		;	DX = magass g (szintn),
kteglapp:	mov	cx,xmax		;	AL = szĄn (0...15).
		sub	cx,4
kteglap2:	mov	bp,2
kteglap0:	test	huan,64
		sjz	nektag
kteglap:	mov	al,4
teglap:		push	ax
		mov	ax,bx
		push	dx
		push	bp
		ncall	koord
		pop	bp
		pop	dx
		pop	ax
tegcikl:	push	xkoord
		pop	alkoord
ttgcikl:	push	ax
		push	cx
		push	di
		ncall	nyerit
		ncall	vonal
		ncall	gurit
		pop	ax
		mov	cx,di		;	!!!!!!!!!!!!!!!!
		sub	cx,ax
		mov	ax,gsor
		sub	ax,cx
		inc	ykoord
		add	di,ax
		sjnc	tegtov
		ncall	incpage
tegtov:		mov	ax,alkoord
		pop	cx
		mov	xkoord,ax
		dec	dx
		pop	ax
		sjnz	ttgcikl
nektag:		ret

kteglap32h:	mov	dx,32
kteglapph:	mov	cx,xmax
		sub	cx,4
kteglap2h:	mov	bp,2
kteglap0h:	test	huan,64
		sjz	nektag
kteglaph:	mov	al,4
teglaph:	ncall	kohogh
		test	csuvas,64
		sjnz	tglph
		test	javas,32+16+4
		sjz	teglap
tglph:		neg	al
		cmp	al,3
		sjne	teglap
		mov	al,6
		sjmp	teglap

kohogh:		cmp	al,-4
		sjae	kohog
		neg	al
		cmp	al,-6
		sjne	kohog
		mov	al,-3
kohog:		ret

kegponth:	ncall	kohogh
		test	csuvas,64
		sjnz	kgpnth
		test	javas,32+16+4
		sjz	kgpnt
kgpnth:		neg	al
		cmp	al,3
		sjne	kgpnt
		mov	al,6
kgpnt:		njmp	kegpont
kkponth:	mov	al,4
kponth:		mov	cx,1
kvonalh:	ncall	kohogh
		test	csuvas,64
		sjnz	kvnlh
		test	javas,32+16+4
		sjz	kvonal
kvnlh:		neg	al
		cmp	al,3
		sjne	kvonal
		mov	al,6
		sjmp	kvonal

zponth:		test	csuvas,64
		sjnz	zpont
		test	javas,32+16+4
		mov	al,-4
		sjnz	zpont
		sjmp	gpont
vponth:		test	csuvas,64
		sjnz	vpont
		test	javas,32+16+4
		mov	al,-3
		sjnz	vpont
		sjmp	gpont
sponth:		test	csuvas,64
		sjnz	spont
		test	javas,32+16+4
		mov	al,-2
		sjnz	spont
gpont:		sjmp	egpont
vvonalh:	test	csuvas,64
		sjnz	vvonal
		test	javas,32+16+4
		mov	al,-3
		sjnz	vvonal
		sjmp	vonal
svonalh:	test	csuvas,64
		sjnz	svonal
		test	javas,32+16+4
		mov	al,-2
		sjnz	svonal
		sjmp	vonal

kkpont:		mov	al,4
kpont:		mov	cx,1
kvonal:		push	ax
		mov	ax,bx
		push	bp
		ncall	koord
		pop	bp
		pop	ax
		ncall	nyerit
		sjmp	vonal

fpont:		xor	ax,ax
		sjmp	egpont
spont:		test	xmode,8
		sjnz	vpont2
spont2:		mov	al,2
		sjmp	egpont
zpont:		mov	al,4
		sjmp	egpont
vpont:		test	xmode,8
		sjnz	spont2
vpont2:		mov	al,6
		sjmp	egpont
fvonal:		xor	ax,ax
		sjmp	vonal
svonal:		test	xmode,8
		sjnz	vvonal2
svonal2:	mov	al,2
		sjmp	vonal
zvonal:		mov	al,4
		sjmp	vonal
vvonal:		test	xmode,8
		sjnz	svonal2
vvonal2:	mov	al,6
		sjmp	vonal
kegpont:	mov	al,4
egpont:		mov	cx,1
vonal:		mov	bl,mode
		and	bx,3
		cmp	al,-16
		sjae	neval
reval:		and	eax,15
		mov	eax,szinht[4*eax]
heval:		add	bx,bx
		jmp	vonugr[bx]

neval:		ncall	krahat
		and	javas,63
		or	bl,4
		inc	al
		sjz	heval
		or	javas,128
		add	bl,4
		inc	al
		mov	ah,2
		sjz	eval
		or	javas,64
		inc	al
		mov	ah,6
		sjz	eval
		and	javas,63
		sjmp	heval
eval:		test	csuvas,64
		mov	al,ah
		sjnz	gheval
		test	javas,32
		sjz	heval
gheval:		sub	bl,8
		and	javas,63
		sjmp	reval

vurv1:		ncall	gyurit
		sjmp	vapt1
vurv2:		ncall	gyurit
		sjmp	vapt2

von256:		add	xkoord,cx
		shr	cx,1
		sjnc	vonhee
		cmp	di,offset vesa+512+aptuf-1
		sja	vurv1
vapt1:		stosb
		sjmp	vonhee

vonhi:		add	xkoord,cx
vonhee:		shr	cx,1
		sjnc	vonh
		cmp	di,offset vesa+512+aptuf-2
		sja	vurv2
vapt2:		stosw
vonh:		lea	si,[edi][4*ecx]
vonht:		cmp	si,offset vesa+512+aptuf
		sja	xonat
vonat:		rep	stosd
		ret
xonat:		mov	si,(512-16+aptuf)/4
		ncall	gyurit
		cmp	cx,si
		sjbe	vonat
		sub	cx,si
		xchg	cx,si
		rep	stosd
		mov	cx,si
		sjmp	xonat

vontrue:	add	xkoord,cx
		test	xmode,1
		lea	si,[edi][4*ecx]
		sjnz	vonht
		sub	si,cx
		cmp	si,offset vesa+512+aptuf-1
		sja	xotrue
truecikl:	stosd
		dec	di
		loop	truecikl
pladre:		ret
xotrue:		mov	si,(512-16+aptuf)/3-1
		ncall	gyurit
		cmp	cx,si
		sjbe	truecikl
		sub	cx,si
sicikl:		stosd
		dec	di
		dec	si
		sjnz	sicikl
		sjmp	xotrue

shadow256:	jcxz	pladre
		ncall	csurit
dradow256:	push	dx
shanko:		xor	ah,ah
		test	csuvas,32+128
		mov	al,es:[di]
		sjnz	stown
		push	ds
		mov	bx,ax
		mov	ds,paletta
		add	bx,bx
		add	bx,ax
		mov	al,[bx]
		mov	ah,77
		inc	bx
		mul	ah
		xchg	ax,dx
		mov	al,[bx]
		mov	ah,151
		inc	bx
		mul	ah
		add	dx,ax
		mov	al,[bx]
		mov	ah,28
		pop	ds
		mul	ah
		add	ax,dx
		shr	ax,11
		test	oxtan,64
		mov	ah,al
		sjnz	noxta
		shr	ah,2
		add	al,ah
noxta:		add	al,16
 		test	own,32
		sjnz	stown
		add	al,64
stown:		stosb
		or	di,di
		sjz	shanwe
shanve:		loop	shanko
		njmp	dhadre
shanwe:		ncall	incpage
		sjmp	shanve

dradowhi:	shr	cx,1
		sjmp	drawhi

shadowhi:	jcxz	shadow256
		ncall	csurit
drawhi:		push	dx
shadhi:		test	csuvas,32+128
		mov	ax,es:[di]
		sjnz	slade
		push	cx
		mov	cl,redscr
		mov	bx,ax
		shr	ax,cl
		mov	cl,grescr
		mov	dx,bx
		shr	bx,cl
		mov	cl,bluscr
		shr	dx,cl
		mov	cl,8
		sub	cl,redsiz
		shl	al,cl
		inc	cx
		shr	al,cl
		mov	cl,8
		mov	ah,al
		sub	cl,gresiz
		shr	ah,1
		shl	bl,cl
		inc	cx
		add	al,ah
		shr	bl,cl
		mov	cl,8
		mov	bh,bl
		sub	cl,blusiz
		shr	bh,1
		shl	dl,cl
		inc	cx
		add	bl,bh
		shr	dl,cl
		shr	ah,2
		mov	dh,dl
		shr	bh,2
		shr	dh,1
		add	dl,dh
		shr	dh,2
		test	oxtan,64
		mov	cl,redscr
		sjnz	moxta
		add	al,ah
		add	bl,bh
		add	dl,dh
moxta:		xor	ah,ah
		xor	bh,bh
		shl	ax,cl
		mov	cl,grescr
		xor	dh,dh
		shl	bx,cl
		mov	cl,bluscr
		or	ax,bx
		shl	dx,cl
		pop	cx
		or	ax,dx
slade:		stosw
		or	di,di
		sjz	shadizar
zingara:	dec	cx
		njnz	shadhi
dhadre:		pop	dx
		sjmp	shadre
shadizar:	ncall	incpage
		sjmp	zingara

shadowtrue:	or	cx,cx
		njz	shadowhi
		ncall	csurit
shadow24:	test	csuvas,32+128
		mov	eax,es:[di]
		sjnz	leveller
		shr	al,1
		shr	ah,1
		mov	bx,ax
		shr	bl,1
		shr	bh,1
		add	ax,bx
		test	oxtan,64
		sjnz	fuxta
		shr	bl,2
		shr	bh,2
		add	ax,bx
fuxta:		ror	eax,16
		shr	al,1
		mov	bx,ax
		shr	bl,1
		add	al,bl
		test	oxtan,64
		sjnz	guxta
		shr	bl,2
		add	al,bl
guxta:		test	xmode,1
		sjz	shadows
		shr	ah,1
		shr	bh,2
		add	ah,bh
		test	oxtan,64
		sjnz	shadows
		shr	bh,2
		add	ah,bh
shadows:	ror	eax,16
leveller:	test	xmode,1
		stosd
		sjnz	shadow32
		dec	di
shadow32:	or	di,di
		sjz	shapve
shadve:		loop	shadow24
shadre:		test	javas,1
		sjnz	errit
		njmp	nyerit
shapve:		ncall	incpage
		sjmp	shadve

dradowtrue:	mov	ax,cx
		shr	cx,2
		test	xmode,1
		sjnz	dradow24
		mov	bx,3
		push	dx
		cwd
		div	bx
		pop	dx
		xchg	ax,cx
dradow24:	njmp	shadow24

scale256:	cmp	di,offset vesa+512+aptuf-1
		push	dx
		sjbe	sxo256
		ncall	gyurit
sxo256:		ncall	colours
		sjc	nonugr256
		test	koppany,4
		mov	ah,al
		sjnz	halef
		mov	ah,77
		mul	ah
		xchg	ax,bx
		mov	ah,151
		mul	ah
		add	bx,ax
		xchg	ax,dx
		mov	ah,28
		mul	ah
		add	ax,bx
		mov	al,ah
halef:		shr	ah,4
		shr	al,2
		pop	dx
		sub	al,ah
		add	al,16+64
		inc	xkoord
		stosb
		loop	scale256
errit:		ret

nonugr256:	pop	dx
		njmp	von256

scalehi:	cmp	di,offset vesa+512+aptuf-2
		push	dx
		sjbe	sxohi
		ncall	gyurit
sxohi:		ncall	colours
		sjc	nonugrhi
		push	cx
		mov	cl,8
		sub	cl,redsiz
		shr	ax,cl
		;cmp	cl,3
		mov	cl,redscr
		;sjb	puhir
muhir:		shl	ax,cl
		mov	cl,8
		sub	cl,gresiz
		shr	bx,cl
		;cmp	cl,3
		mov	cl,grescr
		;sjb	puhig
muhig:		shl	bx,cl
		mov	cl,8
		sub	cl,blusiz
		inc	xkoord
		shr	dx,cl
		;cmp	cl,3
		mov	cl,bluscr
		;sjb	puhib
muhib:		or	ax,bx
		shl	dx,cl
		pop	cx
		or	ax,dx
		pop	dx
		stosw
		loop	scalehi
		ret

nonugrhi:	pop	dx
		njmp	vonhi
;puhir:		and	al,254
;		sjmp	muhir
;puhig:		and	bl,254
;		sjmp	muhig
;puhib:		and	dl,254
;		sjmp	muhib

scaletrue:	cmp	di,offset vesa+512+aptuf-4
		push	dx
		sjbe	sxotrue
		ncall	gyurit
sxotrue:	ncall	colours
		sjc	nonugrtrue
		push	cx
		mov	cl,redscr
		shl	eax,cl
		mov	cl,grescr
		inc	xkoord
		shl	ebx,cl
		mov	cl,bluscr
		or	eax,ebx
		shl	edx,cl
		pop	cx
		or	eax,edx
		test	xmode,1
		pop	dx
		stosd
		sjnz	scale32
		dec	di
scale32:	loop	scaletrue
		ret

nonugrtrue:	pop	dx
		njmp	vontrue

nurnberg:	test	javas,192
		njz	nurnverz
		test	xmode,8
		sjz	nverz
		sjmp	severz

inverz:		or	si,si
		sjz	ynverz
		cmp	si,7
		sjb	severz
		cmp	si,128
		sje	ynverz
		cmp	si,129
		sje	ynverz
		cmp	si,90
		sjae	severz
ynverz:		test	xmode,8
		sjnz	nverz
		test	javas,192
		sjnz	severz
nverz:		not	bx
		not	dx
		add	bx,scaley
		add	dx,scalex
severz:		sjmp	reverz
xtukr:		not	dx
		add	dx,scalex
		sjmp	xrukr
ytukr:		not	bx
		add	bx,scaley
		sjmp	yrukr

colours:	push	si
		test	koppany,16
		mov	al,newscale
		push	es
		sjz	scale
		cmp	al,actscale
		sje	notset
scale:		ncall	setscales
notset:		mov	al,koppany
		mov	bx,ykoord
		test	al,3
		mov	dx,xkoord
		sjz	oscar
		cmp	bx,scaley
		mov	es,filepuf
		sjae	oscar
		cmp	dx,scalex
		sjae	oscar
		test	javas,8
		mov	si,aktikon
		njnz	nurnberg
nurnverz:	test	al,8
ninverz:	njnz	inverz
		cmp	si,90
		sjae	reverz
		test	xmode,8
		sjnz	ninverz
		cmp	si,13
		sjb	reverz
		cmp	si,17
		sjb	nverz
		cmp	si,88
		sjae	nverz
reverz:		test	taksony,4
		sjnz	xtukr
xrukr:		test	taksony,8
		mov	si,dx
		sjnz	ytukr
yrukr:		add	dx,dx
		add	dx,si
		mov	si,bx
		add	bx,bx
		add	bx,si
		test	al,1
		mov	si,starty
		sjz	noscx
		test	al,2
		sjnz	both
		mov	si,startx
		mov	bx,dx
noscx:		mov	ax,es:[si][bx]
		mov	dl,es:[si][bx+2]
		sjmp	noscy
oscar:		sjmp	rosca		
both:		push	dx
		mov	ax,es:[si][bx]
		mov	dl,es:[si][bx+2]
		mov	si,startx
		pop	bx
		mov	dh,es:[si][bx+2]
		mov	bx,es:[si][bx]
		add	dl,dh
		rcr	dl,1
		add	ah,bh
		rcr	ah,1
		add	al,bl
		rcr	al,1
noscy:		pop	es
		test	xmode,8
		mov	bl,ah
		pop	si
		njnz	darken
starken:	test	javas,64
		mov	ah,bl
		mov	bh,al
		mov	dh,dl
		sjnz	vilagh
		test	javas,128
		sjnz	soteth
perverz:	and	eax,255
		and	ebx,255
		and	edx,255
		ret
rosca:		test	javas,128
		mov	al,swapcol
		sjz	shavas
		mov	al,2
shavas:		test	javas,64
		pop	es
		sjz	shawas
		mov	al,6
shawas:		test	xmode,8
		pop	si
		sjz	tosca
		cmp	al,2
		sje	bax
		cmp	al,6
		sjne	babai
bax:		xor	al,4
		sjmp	tosca
babai:		test	iwan,16
		sjz	tosca
		cmp	al,5
		sjne	tosca
		;sja	tosca
		;cmp	al,4
		;sjb	tosca
		mov	al,3
tosca:		and	eax,15
		stc
		mov	eax,szinht[4*eax]
setra:		ret

vilagh:		test	xmode,8
		sjnz	steth
vlagh:		shr	ah,2
		shr	bh,2
		shr	dh,2
		add	bl,ah
		sjnc	vl1
		mov	bl,255
vl1:		add	al,bh
		sjnc	vl2
		mov	al,255
vl2:		add	dl,dh
		sjnc	perverz
		mov	dl,255
nerverz:	sjmp	perverz

soteth:		test	xmode,8
		sjnz	vlagh
steth:		shr	ah,2
		shr	bh,2
		shr	dh,2
		sub	bl,ah
		sub	al,bh
		sub	dl,dh
		shr	ah,1
		shr	bh,1
		shr	dh,1
		sub	bl,ah
		sub	al,bh
		sub	dl,dh
		sjmp	nerverz

darken:		test	iwan,16
		mov	bh,al
		mov	dh,dl
		sjz	starks
		shr	ah,3
		shr	bh,3
		shr	dh,3
		sub	bl,ah
		sub	al,bh
		sub	dl,dh
starks:		njmp	starken
ksetra:		ret		

setscales:	and	taksony,253
		and	al,63
		test	taksony,1
		sjz	askony
		or	taksony,2
askony:		test	koppany,16
		mov	newscale,al
		sjz	wales
		cmp	al,actscale
		mov	actscale,al
		sje	ksetra
		cmp	al,60
		sjbe	whales
		cmp	al,setscale
		sje	whales
wales:		ncall	enscales

whales:		cbw
		push	ds
		and	koppany,240
		cmp	al,60
		pop	es
		mov	bx,ax
		sje	csiki
		nja	sajanc
		inc	ax
		shl	bx,6
		cmp	al,60
		mov	dx,bx
		sjb	walex
		mov	al,253
walex:		mov	scaley,ax
		mov	scalex,ax
		dec	ax
		test	al,2
		mov	si,offset rgb0
		sjz	brollstok
		test	al,1
		mov	si,offset rgb2
brollstok:	mov	al,oxtan
		sjz	brostok
		test	taksony,2
		sjz	brostok
		shr	al,2
		and	al,4
		sjmp	rostok
brostok:	test	csuvas,8
		sjz	ollstok
		mov	si,offset rgbg
ollstok:	shl	al,2
rostok:		mov	ah,3
		njmp	colstok
csiki:		mov	ax,skezdx
		add	ax,xoffs
		sub	ax,3
		mov	dx,4032
		mov	cornx,ax
		mov	ax,skezdy
		add	ax,yoffs
		sub	ax,3
		mov	bx,4096
		mov	corny,ax
		mov	ax,skszel
		add	ax,6
		mov	scalex,ax
		mov	ax,skmags
		add	ax,6
		add	ax,skala
		mov	scaley,ax
		mov	al,oxtan
		mov	si,offset rgb60
		sjmp	rostok
alianz:		mov	ax,xoffs
		mov	cornx,ax
		mov	ax,yoffs
		mov	corny,ax
		mov	ax,xmax
		mov	scalex,ax
		mov	ax,ymax
		mov	scaley,ax
		mov	al,oxtan
		mov	ah,3
		shr	al,2
		sjmp	ostok
sajanc:		cmp	al,62
		mov	si,offset rgb63
		sja	alianz
		mov	si,offset rgb62
		sje	frustok
		mov	si,offset rgb61
frustok:	test	tegan,16
		mov	al,uzemmod
		mov	bx,piblak
		mov	ah,tegan
		sjnz	nukr
		and	al,12
		test	pufabl[bx],8
		sjz	nukr
		cmp	al,8
		mov	ah,2
		sje	sukr
nukr:		xor	ah,3
sukr:		mov	al,hexan
		shl	al,2
ostok:		mov	dx,5120
		mov	bx,6400
colstok:	and	ax,12+3*256
		or	al,ah
		cmp	al,12
		push	di
		sjae	colosch
		test	mode,2
		sjz	fekef
		test	mode,32
		sjnz	fekef
		test	vonan,128
		sjz	kokef
fekef:		or	al,4
kokef:		or	koppany,al
colosch:	mov	ax,bx
		add	bx,bx
		mov	di,offset rgbup
		add	ax,bx
		movsd
		mov	starty,ax
		movsd
		mov	ax,dx
		add	dx,dx
		movsd
		add	ax,dx
		movsd
		mov	startx,ax
		lodsb
		pop	di
		mov	swapcol,al
		ret

genscales	proc	far
		test	koppany,16
		mov	al,setscale
		sjnz	nscales
		ncall	enscales
nscales:	ret
genscales	endp

enscales:	test	mode,8
		push	es
		sjz	noscl
		test	uzemmod,16
		pushad
		sjnz	foscl
		and	al,63
		test	koppany,16
		push	ax
		sjnz	nemezis
		xor	ax,ax
		or	koppany,16
		mov	setscale,al
genezis:	push	ax
		ncall	whales
		ncall	genezaret
		pop	ax
		inc	ax
		cmp	al,60
		sjbe	genezis
nemezis:	pop	ax
		push	ax
		ncall	whales
		pop	ax
		cmp	al,60
		mov	actscale,al
		sjbe	foscl
		test	koppany,3
		sjz	foscl
		cmp	al,setscale
		mov	setscale,al
		sje	foscl
		ncall	genezaret
foscl:		popad
noscl:		pop	es
oscl:		ret

genezaret:	mov	al,koppany
		mov	di,startx
		test	al,3
		mov	si,scalex
		sjz	oscl
		cmp	di,starty
		mov	es,filepuf
		sjne	geczy
		dec	si
		dec	ax
		test	si,1
		sjz	deczy
		dec	ax
		inc	si
geczy:		mov	ebx,rgbleft
		test	al,1
		mov	ecx,rgbright
		push	ax
		ncall	nemezx
		pop	ax
		mov	di,starty
deczy:		test	al,2
		mov	si,scaley
		mov	ebx,rgbup
		mov	ecx,rgbdown
nemezx:		sjz	oscl
		xor	bp,bp
		or	si,si
		sjz	oscl
nemezy:		mov	dl,cl
		xor	dh,dh
		sub	dl,bl
		mov	ax,bp
		sjae	zx1
		neg	dl
zx1:		mul	dx
		div	si
		cmp	cl,bl
		sjae	sx1
		neg	al
sx1:		mov	dl,ch
		add	al,bl
		xor	dh,dh
		stosb
		sub	dl,bh
		mov	ax,bp
		sjae	zx2
		neg	dl
zx2:		mul	dx
		div	si
		cmp	ch,bh
		sjae	sx2
		neg	al
sx2:		ror	ecx,16
		add	al,bh
		mov	dl,cl
		ror	ebx,16
		xor	dh,dh
		stosb
		sub	dl,bl
		mov	ax,bp
		sjae	zx3
		neg	dl
zx3:		mul	dx
		div	si
		cmp	cl,bl
		sjae	sx3
		neg	al
sx3:		ror	ecx,16
		add	al,bl
		ror	ebx,16
		test	koppany,4
		stosb
		sjz	emezy
		dec	di
		mov	ah,28
		mov	al,es:[di]
		mul	ah
		xchg	ax,dx
		dec	di
		mov	ah,151
		mov	al,es:[di]
		mul	ah
		add	dx,ax
		dec	di
		mov	ah,77
		mov	al,es:[di]
		mul	ah
		add	ax,dx
		mov	al,ah
		stosw
		stosb
emezy:		inc	bp
		cmp	bp,si
		njb	nemezy
		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
arkord:		push	dx
		push	si
		mov	al,63
		ncall	setscales
		pop	si
		pop	dx
sirkord:	njmp	irkord

pkoord:		add	ax,yoffs
		add	bp,xoffs
		cmp	aktikon,130
		push	ax
		sjae	akkord
		cmp	br aktikon,128
		sjae	arkord
		cmp	br aktikon,5
		sjb	akkord
		cmp	br aktikon,7
		sjb	arkord
akkord:		mov	corny,ax
		mov	al,taksony
		mov	cornx,bp
		and	al,3
		push	dx
		sjz	jokor
		cmp	al,3
		sje	jokor
		and	koppany,96
jokor:		xor	ax,ax
		test	koppany,16
		mov	newscale,al
		sjz	sasha
		cmp	al,actscale
		sje	sasca
sasha:    	push	si
		push	cornx
		push	corny
		ncall	setscales
		pop	corny
		pop	cornx
      		pop	si
sasca:		cmp	gelyik,3
		mov	swapcol,5
		mov	ax,cx
		mov	di,aktikon
		sjne	ilyvo
		dec	swapcol
ilyvo:		cmp	di,13
		sjb	umi1
		cmp	di,90
		sjae	umi1
		cmp	di,15
		sjb	umi2
		cmp	di,17
		sjb	gumi
		cmp	di,88
		sjb	umi1
		cmp	al,7
		sjne	cumi
		dec	ax
cumi:		sub	corny,ax
umi2:		add	ax,ax
gumi:		pop	di
		inc	ax
		inc	di
		sub	cornx,3
		inc	di
		inc	ax
		inc	di
		sub	corny,2
		test	felb,7
		sjnz	umi
		inc	ax
		inc	di
		dec	cornx
		inc	ax
		sub	corny,2
umi:		cmp	al,14
		push	di
		sje	brumi
umi1:		dec	ax
brumi:		test	al,3
		sjz	krumi
		push	ax
		and	al,3
		cmp	al,gelyik
		pop	ax
		sjbe	grumi
		add	ax,4
grumi:		and	al,252
krumi:		or	al,gelyik
		inc	ax
		mov	scaley,ax
		dec	ax
		cmp	ax,59
		mov	ah,192
		sjbe	qwey
		mov	al,59
qwey:		mul	ah
		mov	starty,ax
		pop	ax
		dec	ax
		test	al,3
		sjz	qrumi
		push	ax
		and	al,3
		cmp	al,gelyik
		pop	ax
		sjbe	prumi
		add	ax,4
prumi:		and	al,252
qrumi:		or	al,gelyik
		inc	ax
		mov	scalex,ax
		dec	ax
		cmp	ax,59
		mov	ah,192
		sjbe	qwex
		mov	al,59
qwex:		mul	ah
		mov	startx,ax
irkord:		pop	ax
		sjmp	rkoord

rokkar:		add	ax,bp
		add	ax,bp
		mov	es,chseg
		xchg	ax,di
		ret

koord:		add	ax,yoffs	;	A koordin t k alapj n pozĄci˘t
		add	bp,xoffs	;	sz mol.

rkoord:		mov	di,corny
		;add	di,yoffs
		neg	di
		add	di,ax
		mov	ykoord,di
		mov	di,cornx
		;add	di,xoffs
		neg	di
		add	di,bp
		mov	xkoord,di
		mov	alkoord,di
		mov	di,wr mode	;	RelatĄv!!!
		mul	gsor		;	Bemenet: BP = X-pozĄci˘,
		test	uzemmod,16
		sjnz	rokkar
		and	di,3		;		 AX = Y-pozĄci˘.
		sjz	p16		;	Kimenet: DX:AX = a grafikus
		dec	di		;		 kpen belli relatĄv
		sjz	p256		;		 pozĄci˘,
		dec	di		;		 DL = ablaksorsz m,
		sjz	phi		;		 ES:DI = az els byte
ptrue:		mov	di,bp		;		 cĄme.
		add	bp,bp
		test	xmode,1
		sjz	ptrue24
		mov	di,bp
ptrue24:	add	bp,di
		xor	di,di
		sjmp	p256
p16:		push	ax
		mov	al,felb
		cmp	al,alap
		sjae	p16ap
		mov	al,alap
p16ap:		dec	al
		pop	ax
		sjz	p256
		shld	dx,ax,3
		shl	ax,3
		add	ax,bp
		adc	dx,di
		mov	di,ax
		shrd	dx,di,3
		and	ax,7
		shr	dx,3
		mov	maszk16,ax
		sjmp	p16256
phi:		add	bp,bp
p256:		add	ax,bp
		adc	dx,di
		mov	di,ax
p16256:		mov	ax,dx
		push	0a000h
		cmp	al,pag
		pop	es
		sje	ponveg
		ncall	setpage
ponveg:		mov	ax,di
		ret

fkoord		proc	far
		ncall	koord
		ret
fkoord		endp

keret		proc	far		;	Kperny keretezse.
		pushad
		mov	al,63
		ncall	setscales
		or	javas,8
		xor	bx,bx
		mov	pag,-1
		mov	cx,xmax
		mov	bp,bx
		dec	cx
		mov	al,6
		push	cx
		ncall	kvonalh
		ncall	kegponth
		ncall	urit
		pop	cx
		mov	bl,1
		push	cx
		dec 	cx
		test	owan,16+128
		mov	al,6
		njnz	keviga
		push	cx
		ncall	kvonalh
		ncall	kegponth
		ncall	sponth
		ncall	urit
		mov	bx,ymax
		mov	al,6
		dec	bx
		dec	bx
		ncall	kponth
		ncall	kegponth
		pop	cx
		ncall	svonalh
		ncall	urit
		mov	bx,ymax
		dec	bx
		ncall	kkponth
		pop	cx
		ncall	svonalh
		ncall	urit
		mov	dx,ymax
		mov	bx,2
		sub	dx,4
		mov	cx,bx
		push	dx
		mov	al,6
		push	bx
		ncall	teglaph
		mov	bp,xmax
		pop	bx
		dec	bp
		pop	dx
		dec	bp
		mov	cx,bx
		mov	mennyit,bp
kettov:		mov	al,2
		push	bx
		ncall	teglaph
		pop	bx
		push	bx
		ncall	kteglap32h
		mov	dx,ymax
		pop	bx
		mov	cx,4
		push	bx
		sub	dx,cx
		push	dx
		ncall	kteglap2h
		mov	cx,26
		pop	dx
		mov	bp,mennyit
		pop	bx
		sub	bp,cx
		ncall	kteglap0h
		mov	bx,ymax
		mov	dx,96
		sub	bx,98
		ncall	kteglapph
		popad
		and	javas,52
		ret

keviga:		ncall	kponth
		pop	cx
		dec	cx
		push	cx
		ncall	zvonal
		ncall	sponth
		ncall	urit
		mov	bx,ymax
		dec	bx
		mov	al,6
		push	bx
		dec	bx
		ncall	kponth
		pop	bx
		pop	cx
		push	cx
		push	bx
		ncall	zvonal
		ncall	sponth
		ncall	urit
		pop	bx
		mov	al,4
		ncall	kponth
		pop	cx
		inc	cx
		ncall	svonalh
		ncall	urit
		mov	al,6
		ncall	egylap
		inc	bp
		ncall	zegylap
		mov	bp,xmax
		dec	bp
		push	bp
		dec	bp
		mov	mennyit,bp
		ncall	zegylap
		pop	bp
		njmp	kettov
keret		endp

zegylap:	mov	al,4
egylap:		mov	dx,ymax
		mov	bx,2
		sub	dx,4
		push	bx
		mov	cx,1
		push	dx
		ncall	teglaph
		pop	dx
		pop	bx
nerrka:		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
kerreg:		and	alabl[bx],239
		and	xmode,247
		and	javas,52
		test	dl,16
		sjnz	nerrka
		test	pufabl[bx],16
		sjnz	nerrka
		test	xmode,64
		sjz	kleroj
		test	pufabl[bx],64
		sjz	kleroj
		or	xmode,8
kleroj:		test	csuvas,64
		pushad
		sjnz	karoj
		test	javas,32+16+4
		sjnz	karoj
		or	javas,8
karoj:		mov	bx,3
		push	di
		mov	si,wr vesa+4
		mov	di,wr vesa+6
		mov	dx,gorsze
		mov	cx,gepsor
		sub	si,bx
		sub	di,bx
		add	bx,bx
		add	dx,bx
		add	cx,bx
		ncall	lefed
		ncall	kekapcs
		sub	cx,bx
		sub	dx,bx
		pop	di
		xchg	cx,dx
		push	dr vesa+4
		ncall	button
		pop	dr vesa+4
		popad
		and	javas,52
		mov	al,pags
		ncall	setpage
nemkerr:	njmp	bekapcs
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
raster:		push	ax		;	A kpernyfrissĄts
		push	dx		;	frekvenci j hoz val˘ idzĄts.
		test	dwan,1
		mov	dx,3dah
		sjz	szink
		mov	dl,0bah
szink:		test	tewan,2
		sjnz	nemsyn
sync0:		in	al,dx
		test	al,8
		sjnz	sync0
sync:		in	al,dx
		test	al,8
		sjz	sync
nemsyn:		pop	dx
		pop	ax
nemkarr:	ret

hraster:	push	ax		;	A kpernyfrissĄts
		push	dx		;	frekvenci j hoz val˘ idzĄts.
		test	dwan,1		;	(De csak fl visszafut sra!)
		mov	dx,3dah
		sjz	hszink
		mov	dl,0bah
hszink:		test	tewan,2
		sjnz	nemsyn
hsync0:		;in	al,dx
		;test	al,8
		;sjnz	hsync0
hsync:		in	al,dx
		test	al,8
		sjz	hsync
		sjmp	nemsyn
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
button:		mov	al,63
		cmp	al,actscale
		mov	newscale,al
		sje	newsee
		push	es
		pushad
		ncall	setscales
		popad
		pop	es
newsee:
;		mov	wr vesa+2,dx	;	ES:DI pozĄci˘val megadott
;		mov	ax,gsor		;	tglalap keretezse kĄvlrl
;		add	ax,ax		;	(ń5 kppontos keret!!!).
;		add	ax,ax		;	Ha XMODE and 8 = 1, akkor a
;		add	ax,gsor		;	keret inverz lesz, azaz nem
;		add	ax,5		;	kidlled, hanem benyomott!
;		test	mode,2
;		sjz	sibsub
;		add	ax,5
;		test	mode,1
;		sjz	sibsub
;		add	ax,5
;		test	xmode,1
;		sjz	sibsub
;		add	ax,5
;sibsub:	sub	di,ax
;		sjnc	nerceg
;		ncall	decpage
;nerceg:

buttonb:
		pusha
		ncall	vikoord
		xchg	ax,bx
		sub	bp,5
		sub	ax,5
		ncall	koord
		mov	ax,xkoord
		mov	wr vesa+2,di
		mov	wr vesa+4,ax
		popa
		mov	wr vesa+6,cx
		mov	di,wr vesa+2
		add	cx,10
		mov	wr vesa+2,dx
		push	cx
		ncall	kerceg0
		pop	cx
		push	cx
		push	cx
		ncall	kerceg
		ncall	cvonal
		pop	cx
		sub	cx,4
		test	owan,16+128
		push	cx
		njnz	vgutton
		ncall	fvonal
		ncall	cerceg
		ncall	cvonal
		ncall	fpont
		pop	cx
		sub	cx,3
		push	cx
		ncall	vvonalh
		ncall	zponth
		ncall	fpont
		ncall	cerceg
		ncall	cvonal
		ncall	fpont
		mov	cx,2
		ncall	vvonalh
		ncall	urit
		mov	dx,di
		pop	cx
		sub	cx,3
		push	cx
		ncall	nyerit
		ncall	vvonalh
		ncall	urit
		mov	ax,di
		sub	ax,dx
		mov	wr vesa,ax
		ncall	nyerit
		ncall	zponth
		ncall	sponth
		ncall	fpont
		ncall	cerceg
		pop	cx
		dec	cx
		mov	dx,wr vesa+2
		dec	cx
		push	cx
picikl:		ncall	cvonal
		ncall	fpont
		mov	cx,2
		ncall	vvonalh
		ncall	urit
		add	di,wr vesa
		mov	ax,wr vesa+6
		sjnc	pictov
		ncall	incpage
pictov:		add	xkoord,ax
		ncall	nyerit
		mov	cx,2
		ncall	svonalh
		ncall	fpont
		ncall	cerceg
		dec	dx
		sjnz	picikl
		pop	cx
		push	cx
		ncall	cvonal
		ncall	fpont
		ncall	vponth
		ncall	zponth
		pop	cx
		add	cx,4
		push	cx
		ncall	svonalh
		ncall	fpont
		ncall	cerceg
		ncall	cvonal
		ncall	fpont
		ncall	zponth
		pop	cx
		inc	cx
		push	cx
		ncall	svonalh
		ncall	fpont
		ncall	cerceg
		ncall	cvonal
		pop	cx
		add	cx,3
		ncall	fvonal
		ncall	cerceg
prrceg:		pop	cx
		push	cx
		ncall	kerceg
		pop	cx
		and	xmode,247
		ncall	kerceg
		njmp	urit

kerceg0:	push	di
		ncall	nyerit
		ncall	zsvonal
		ncall	urit
		pop	bp
		mov	cx,di		;	!!!!!!!!!!!!!!!!
		sub	cx,bp
		mov	bp,gsor
		sub	bp,cx
		sjmp	zztov

vgerceg:	mov	cx,3
		sjmp	kerceg
cerceg:		mov	cx,2
kerceg:		ncall	zsvonal
		ncall	urit
zztov:		mov	ax,wr vesa+4
		add	di,bp
		mov	xkoord,ax
		sjnc	herceg
		ncall	incpage
herceg:		inc	ykoord
		njmp	nyerit
cvonal:		mov	cx,2
zsvonal:	cmp	actscale,63
		mov	al,-4
		sjne	rowal
		push	wr xmode
		and	xmode,247
		ncall	vonal
		pop	wr xmode
		ret
vgonal:		mov	cx,3
		sjmp	zsvonal

rowal:		test	mode,2
		mov	ax,cx
		sjz	rowaln
		add	ax,ax
		test	mode,1
		sjz	rowaln
		add	ax,cx
		test	xmode,1
		sjz	rowaln
		add	ax,cx
rowaln:		ncall	gurit
		add	di,ax
		sjnc	rohan
		ncall	incpage
rohan:		njmp	nyerit

vgutton:	ncall	zsvonal		;	320*200: vkonyabb keret!
		ncall	cerceg
		ncall	vgonal
		pop	cx
		dec	cx
		dec	cx
		push	cx
		ncall	fvonal
		ncall	vgerceg
		ncall	vgonal
		ncall	fpont
		ncall	urit
		pop	cx
		sub	cx,3
		test	mode,2
		push	cx
		lea	dx,[di+1]
		sjz	nehtr
		inc	dx
		test	mode,1
		sjz	nehtr
		inc	dx
		test	xmode,1
		sjz	nehtr
		inc	dx
nehtr:		ncall	nyerit
		ncall	vvonal
		ncall	urit
		mov	ax,di
		sub	ax,dx
		mov	wr vesa,ax
		ncall	nyerit
		ncall	zpont
		ncall	fpont
		ncall	vgerceg
		pop	cx
		mov	dx,wr vesa+2
		dec	cx
		push	cx
vgicikl:	ncall	vgonal
		ncall	fpont
		ncall	vpont
		ncall	urit
		add	di,wr vesa
		mov	ax,wr vesa+6
		sjnc	vgictov
		ncall	incpage
vgictov:	add	xkoord,ax
		ncall	nyerit
		ncall	spont
		ncall	fpont
		ncall	vgerceg
		dec	dx
		sjnz	vgicikl
		ncall	vgonal
		ncall	fpont
		ncall	zpont
		pop	cx
		inc	cx
		push	cx
		ncall	svonal
		ncall	fpont
		ncall	vgerceg
		ncall	vgonal
		pop	cx
		add	cx,3
		ncall	fvonal
		ncall	vgerceg
		pop	cx
		push	cx
		ncall	kerceg
		njmp	prrceg
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
inkapcs:	mov	al,iwan		;	Ikont bl k ki/be kapcsol sa.
		mov	bl,al
		and	al,1
		push	ds
		add	al,al
		and	bl,4
		add	al,al
		pop	es
		cmp	al,bl
		mov	dx,2
		sje	nemin1
		xor	iwan,4
		xor	bp,bp
		mov	si,offset icser1
		ncall	icsere
nemin1:		mov	al,iwan
		mov	bl,al
		and	al,2
		add	al,al
		and	bl,8
		add	al,al
		cmp	al,bl
		mov	dl,4
		sje	nemin2
		xor	iwan,8
		mov	bp,2
		mov	si,offset icser2
icsere:		lea	bx,pofpos[bp]
		lea	di,ipofpos[bp]
		mov	cx,96
		shr	bp,1
ilop1:		mov	ax,[di]
		xchg	ax,[bx]
		stosw
		add	bx,4
		inc	di
		inc	di
		loop	ilop1
		xor	bp,1
icserp:		lodsw
		xchg	ax,bx
		lodsw
		xchg	ax,di
		lodsb
		mov	cl,al
icsop:		mov	ax,[di]
		xchg	ax,[bx]
		stosw
		inc	bx
		inc	bx
		loop	icsop
		dec	dx
		sjnz	icserp
		lea	bx,skezdyx[bp]
		lea	di,iskezdyx[bp]
		mov	cl,6
ilop2:		mov	al,[di]
		xchg	al,[bx]
		stosb
		inc	bx
		inc	bx
		inc	di
		loop	ilop2
nemin2:		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
nyerit:		push	ax		;	Sorpuffer trlse.
		mov	ax,gsor
		mov	laval,0
		add	ax,di
		pop	ax
		sjnc	nyerix
		inc	laval
		sjmp	nyerix

nyurit:		ncall	urit
		sjmp	nyerix

gyurit:		ncall	gurit

nyerix:		mov	hovair,di
		push	ds
		mov	di,offset vesa+16
		pop	es
		ret

csurit:		add	xkoord,cx

gurit:		test	javas,2
		push	cx
		sjz	cxurit
		push	di
		mov	cx,di
		mov	di,offset vesa+16
		push	bx
		sub	cx,di
		mov	bl,mode
		sjbe	diurit
		and	bx,3
		push	wr csuvas
		or	javas,1
		add	bx,bx
		push	eax
		and	csuvas,95
		call	dronugr[bx]
		pop	eax
		pop	wr csuvas
diurit:		pop	bx
		pop	di
		pop	cx
		and	javas,254

urit:		push	cx		;	Sorpuffer kpernyre rĄtse.
cxurit:		push	si
		mov	cx,di
		mov	si,offset vesa+16
		push	0a000h
		mov	di,hovair
		sub	cx,si
		pop	es
		sjbe	nurit
		cmp	laval,0
		sjne	lavas
levas:		ncall	uricx
nurit:		pop	si
		pop	cx
		ret
lavas:		test	laval,254
		sjnz	levas
		add	cx,di
		sjc	savas
		sub	cx,di
		sjmp	levas
savas:		test	mode,3
		sjz	sav16
sne16:		push	cx
		mov	cx,di
		or	laval,2
		neg	cx
nurix:		ncall	uricx
		pop	cx
		ncall	incpage
		ncall	uricx
		sjmp	nurit
sav16:		push	ax
		mov	al,felb
		and	ax,7
		dec	ax
		pop	ax
		sjz	sne16
		push	ax
		sub	cx,di
		mov	ax,maszk16
		movzx	edi,di
		and	ax,7
		shl	edi,3
		movzx	ecx,cx
		or	di,ax
		add	ecx,edi
		pop	ax
		cmp	ecx,80000h
		sjae	lap16
		sub	ecx,edi
		shr	edi,3
		sjmp	levas
lap16:		sub	ecx,80000h
		push	cx
		mov	ecx,80000h
		or	laval,2
		sub	ecx,edi
		shr	edi,3
		sjmp	nurix

uricx:		;test	mode,3
		;sjz	urc16
nurc16:		shr	cx,1
		sjnc	uc1
		movsb
uc1:		shr	cx,1
		sjnc	uc2
		movsw
uc2:		shr	cx,1
		sjnc	uc3
		movsd
uc3:		shr	cx,1
		sjnc	uc4
		movsd
		movsd
uc4:		shr	cx,1
		sjnc	uc5
		movsd
		movsd
		movsd
		movsd
uc5:		sjz	uciv
ucip:		dec	cx
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		sjnz	ucip
uciv:		ret

;urc16:		push	ax
;		mov	al,felb
;		and	ax,7
;		dec	ax
;		pop	ax
;		sjz	nurc16
;		push	ax
;		push	bx
;		push	dx
;		push	bp
;uralk:		mov	ax,maszk16
;		mov	bx,8
;		and	ax,7
;		sub	bx,ax
;		cmp	bx,cx
;		sjbe	uruc
;		or	cx,cx
;		mov	bx,cx
;		njz	uralv
;uruc:		sub	cx,bx
;		sub	si,ax
;		push	cx
;		add	ax,bx
;		mov	cx,8
;		sub	cx,ax
;		and	ax,7
;		mov	maszk16,ax
;		mov	al,fmaszk[bx-1]
;		add	ax,ax
;		dec	ax
;		shl	ax,cl
;		pop	cx
;		xchg	ax,bp
;uralp:		mov	dx,3ceh
;		xor	al,al
;		out	dx,al
;		mov	bx,[si]
;		mov	ax,[si]
;		or	bx,[si+2]
;		and	ax,[si+2]
;		or	bx,[si+4]
;		and	ax,[si+4]
;		or	bx,[si+6]
;		and	ax,[si+6]
;		inc	dx
;		or	bl,bh
;		and	al,ah
;		not	bl
;		and	al,15
;		and	bl,15
;		out	dx,al
;		or	al,bl
;		dec	dx
;		mov	ah,al
;		mov	al,1
;		out	dx,al
;		inc	dx
;		mov	al,ah
;		out	dx,al
;		push	ax
;		dec	dx
;		mov	al,8
;		out	dx,al
;		inc	dx
;		mov	ax,bp
;		out	dx,al
;		pop	ax
;		cmp	ah,15
;		mov	bh,8
;		mov	dx,3c4h
;		sje	sipirc
;		push	cx
;kuruc:		test	ah,bh
;		mov	cx,[si]
;		mov	bl,bh
;		mov	al,2
;		sjnz	cikkim
;		out	dx,al
;		mov	al,ah
;		inc	dx
;		or	al,bh
;		test	cl,bl
;		out	dx,al
;		mov	al,0
;		sjnz	kun1
;vun1:		test	ch,bh
;		mov	cx,[si+2]
;		sjnz	kun2
;vun2:		dec	dx
;		test	cl,bl
;		sjnz	kun3
;vun3:		test	ch,bh
;		mov	cx,[si+4]
;		sjnz	kun4
;vun4:		test	cl,bl
;		sjnz	kun5
;vun5:		test	ch,bh
;		mov	cx,[si+6]
;		sjnz	kun6
;vun6:		test	cl,bl
;		mov	bl,es:[di]
;		sjnz	kun7
;vun7:		test	ch,bh
;		sjnz	kun8
;vun8:		mov	es:[di],al
;cikkim:	shr	bh,1
;		sjnz	kuruc
;		pop	cx
;		inc	di
;kurt:		add	si,8
;		sub	cx,8
;		mov	bp,-1
;		njae	uralp
;		add	cx,8
;		njmp	uralk
;sipirc:	mov	al,2
;		out	dx,al
;		inc	dx
;		mov	al,ah
;		mov	bl,es:[di]
;		out	dx,al
;		stosb
;		sjmp	kurt
;kun1:		or	al,128
;		sjmp	vun1
;kun2:		or	al,64
;		sjmp	vun2
;kun3:		or	al,32
;		sjmp	vun3
;kun4:		or	al,16
;		sjmp	vun4
;kun5:		or	al,8
;		sjmp	vun5
;kun6:		or	al,4
;		sjmp	vun6
;kun7:		or	al,2
;		sjmp	vun7
;kun8:		or	al,1
;		sjmp	vun8
;uralv:		cmp	cx,maszk16
;		pop	bp
;		pop	dx
;		pop	bx
;		pop	ax
;		sje	ujjaj
;		dec	di
;ujjaj:		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
szentept:	mov	al,felb
		and	ax,7
		test	uzemmod,16		;	Ikont bl k flpĄtse.
		push	ds
		mov	bx,offset gomby1
		sjz	grolt
		mov	al,kwan
		and	al,3
		add	al,6
grolt:		add	ax,ax
		pop	es
		inc	ax
		test	iwan,8
		mov	si,ax
		mov	di,offset balsor
		sjz	gogom
		mov	bx,offset gomby2
gogom:		mov	ah,[bx][si]
		mov	bx,2
		ncall	sorep
		xor	bx,bx
		mov	es,ikpuf
		mov	di,es:[bx]
		mov	ah,gombx1[si]
		mov	di,es:[di]
		ncall	sorep
		xor	bx,bx
		test	suan,1
		mov	di,es:[bx]
		mov	ah,gombx2[si]
		sjz	susu
		inc	di
		inc	di
susu:		inc	bx
		mov	di,es:[di+2]

sorep:		cmp	ah,24
		mov	al,fabhol[bx]
		mov	cl,es:[di]
		sjbe	sosor
		mov	ah,24
sosor:		cmp	al,cl
		push	si
		sjbe	lorok
		mov	al,cl
lorok:		mov	ch,ah
		add	ch,al
		cmp	ch,cl
		sjbe	sorok
		dec	al
		sjns	lorok
		xor	al,al
sorok:		mov	dl,cl
		mov	fabhol[bx],al
		sub	cl,al
		inc	di
		cmp	cl,ah
		mov	ch,bh
		mov	dh,bh
		sjbe	horok
		mov	cl,ah
horok:		cbw
		add	di,ax
		mov	al,fabrjz[bx]
		push	ax
		add	ax,offset ikonrajz
		test	uzemmod,16
		push	di
		sjz	gorok
		add	di,dx
		add	ax,kiktxt-ikonrajz
		add	di,dx
gorok:		xchg	ax,si
		ncall	colop
		pop	di
		pop	si
		push	ds
		mov	ds,ikpuf
		add	di,dx
		add	si,wr ds:[39*2]
		ncall	colop
		pop	ds
		pop	si
		ret

colop:		push	cx
		push	di
		jcxz	xcce
		push	cx
xcolp1:		mov	al,es:[di]
		mov	[si],al
		mov	ax,ds
		cmp	ax,adat
		sjne	nexus
		push	bp
		mov	bp,dx
		add	bp,bp
		add	bp,bp
		cmp	bl,2
		sjne	sexus
		add	bp,dx
sexus:		mov	al,es:[di][bp]
		pop	bp
		mov	[si+ikonrajz2-ikonrajz],al
nexus:		inc	di
		inc	si
		loop	xcolp1
		pop	cx
xcce:		neg	cx
		add	cx,24
		sjz	xrre
xcolp2:		mov	br [si],30
		inc	si
		loop	xcolp2
xrre:		pop	di
		pop	cx
ujjajj:		ret

szentkep:	test	mode,4			;	Ikonok megjelenĄtse.
		sjnz	ujjajj
		test	suan,2
		push	ds
		mov	di,offset ouikon
		mov	cx,8
		mov	ax,-1
		pop	es
		lea	si,[di+8]
		sjz	susuz
		and	suan,253
		test	uzemmod,16
		rep	stosw
susuz:		sjz	susua
		mov	ax,ymax
		xor	bp,bp
		mov	cx,xmax
		dec	ax
		push	es
		add	cx,cx
		dec	ax
		ncall	koord
		test	iwan,8
		mov	al,chures
		mov	bl,-2
		mov	ah,ikncol
		sjnz	gajj
		add	bl,bl
		rep	stosw
gajj:		mov	kikony+113,bl
		test	iwan,4
		mov	bl,kwan
		sjnz	kajj
		push	ax
		mov	ax,3
		and	bx,ax
		ncall	koord
		add	bl,6
		pop	ax
		test	kwan,4
		mov	dx,ax
		mov	al,216
		mov	dl,217
		sjz	sakk
		mov	al,196
		mov	dl,al
sakk:		add	bx,bx
		test	iwan,8
		mov	ch,bh
		sjz	matt
		add	bl,gomby2-gomby1
matt:		mov	cl,gomby1[bx+1]
patt:		push	di
		stosw
		xchg	ax,dx
		stosw
		pop	di
		xchg	ax,dx
		add	di,gsor
		add	di,gsor
		loop	patt
kajj:		pop	es
susua:		test	uzemmod,16
		mov	bl,ablak
		mov	al,12
		sjnz	krajj
		njmp	grajj
krajj:		xor	bh,bh
		test	al,[si]
		lea	di,[si+16]
		sjz	krax
		test	al,[di]
		sjz	krak
		or	[di],al
krak:		or	[si],al
krax:		mov	ax,17*(1+256)
		cmp	kiktxt[bx+72],18
		mov	wr kiktxt+72,ax
		mov	wr kiktxt+74,ax
		mov	kiktxt[bx+72],18
		mov	al,kwan
		sje	karaj
		or	br [si],240
karaj:		and	ax,3
		mov	bh,iwan
		add	al,6
		xor	cx,cx
		add	ax,ax
		test	kwan,1
		mov	bl,6
		sjz	karcs
		dec	bx
		dec	bx
karcs:		test	bh,8
		mov	di,offset kikonx+16
		xchg	ax,si
		pushf
		mov	ax,wr gombx1[si]
		ncall	kixep
		popf
		mov	ax,wr gombx2[si]
		pushf
		ncall	kixep
		mov	ax,wr gomby1[si]
		popf
		mov	di,offset kikony+88
		mov	bl,2
		sjz	xixi
		mov	ax,wr gomby2[si]
xixi:		test	bh,4
		ncall	kixep
		mov	cl,8
		mov	si,offset ouikon
		xor	bx,bx
kzelep:		mov	dx,[si+16]
		lodsw
		push	bx
		mov	wr [si-2],0
kzellem:	rol	dx,1
		add	ax,ax
		sjnc	nzeltov
		cmp	bl,116
		sjb	nzelt
nzeltov:	njmp	kzeltov
nzelt:		push	ax
		cmp	bl,88
		mov	al,4
		sjae	bazalt
		add	al,al
bazalt:		test	al,iwan
		pop	ax
		sjnz	nzeltov
		push	ax
		mov	al,kikonx[bx]
		or	al,al
		cbw
		sjz	zolt
		sjns	kzox
		add	ax,xmax
		sjns	kzox
		xor	ax,ax
kzox:		xchg	ax,bp
		mov	al,kikony[bx]
		or	al,al
		cbw
zolt:		sjnz	zsolt
		njmp	kzolt
zsolt:		sjns	kzoy
		add	ax,ymax
		sjns	kzoy
		xor	ax,ax
kzoy:		push	dx
		ncall	koord
		pop	dx
		push	cx
		mov	cl,kiktxt[bx]
		jcxz	czolt
		ncall	egerki
		test	dl,1
		mov	ah,ikncol
		push	si
		sjz	kzokzo
		mov	ah,ikicol
kzokzo:		test	kwan,1
		mov	bp,5
		push	ds
		sjz	bpocz
		cmp	bl,16
		sjb	bpocz
		dec	bp
		dec	bp
bpocz:		mov	ds,ikpuf
		dec	cx
		mov	si,wr ds:[0]
		mov	si,[si+8]
		sjz	czocz
		dec	si
czolp:		inc	si
		cmp	br [si],-1
		sjne	czolp
		loop	czolp
		inc	si
czocz:		push	cx
		push	si
cocz:		lodsb
		cmp	al,-1
		sje	cucz
		cmp	al,4
		mov	cx,adat
		sjae	xocz
		push	ds
		mov	ds,cx
		push	bx
		test	kwan,4
		mov	bx,offset focz
		sjz	kocz
		add	al,4
kocz:		xlat
		pop	bx
		pop	ds
xocz:		dec	bp
		stosw
		sjnz	cocz
cucz:		dec	si
		cmp	bl,88
		pop	cx
		sjb	csucs
		sub	si,cx
		cmp	si,2
		mov	cx,si
		sjae	csucs
		neg	cx
		add	cx,2
		mov	al,chures
		rep	stosw
csucs:		pop	cx
		pop	ds
		pop	si
		ncall	egerbe
czolt:		pop	cx
kzolt:		pop	ax
kzeltov:	inc	bx
		or	ax,ax
		sjnz	nzellem
		pop	bx
		add	bl,16
		loop	nzelep
		ret
nzellem:	njmp	kzellem
nzelep:		njmp	kzelep
grajj:		test	iwan,8
		mov	wr ikonszam+64,40+46*256-257
		mov	wr ikonszam+66,52+58*256-257
		mov	wr ikonszam+112,64+70*256-257
		sjz	jojja
		mov	wr ikonszam+112,76+82*256-257
jojja:		mov	al,felb
		xor	bp,bp
		and	ax,7
		mov	bx,ax
		mov	dx,ax
		sjz	julla
		inc	ax
julla:		mov	ah,al
		add	bx,bx
		add	wr ikonszam+64,ax
		add	wr ikonszam+66,ax
		add	wr ikonszam+112,ax
		mov	ax,wr gombx1[bx]
		mov	cl,ah
		cbw
		mov	ch,ah
		add	ax,81
		or	dx,dx
		sjz	jul0
		add	ax,160-81
jul0:		xor	si,si
		add	cx,cx
szep1:		mov	ikonx[si+16*2],ax
		mov	vikonx[si+16*2],ax
		inc	si
		add	ax,20
		inc	si
		or	dx,dx
		sjz	jul1
		add	ax,40-20
jul1:		cmp	si,cx
		sjb	szep1
		mov	ikonx+65*2,ax
		mov	vikonx+65*2,ax
szava1:		cmp	si,24*2
		sjae	szeve1
		mov	ikonx[si+16*2],bp
		mov	vikonx[si+16*2],bp
		inc	si
		inc	si
		sjmp	szava1
szeve1:		mov	ax,wr gombx2[bx]
		mov	cl,ah
		cbw
		mov	ch,ah
		add	ax,81
		or	dx,dx
		sjz	jul3
		add	ax,160-81
jul3:		xor	si,si
		add	cx,cx
szep2:		mov	ikonx[si+40*2],ax
		mov	vikonx[si+40*2],ax
		inc	si
		add	ax,20
		inc	si
		or	dx,dx
		sjz	jul2
		add	ax,40-20
jul2:		cmp	si,cx
		sjb	szep2
		mov	ikonx+67*2,ax
		mov	vikonx+67*2,ax
szava2:		cmp	si,24*2
		sjae	szeve2
		mov	ikonx[si+40*2],bp
		mov	vikonx[si+40*2],bp
		inc	si
		inc	si
		sjmp	szava2
szeve2:		test	iwan,8
		mov	di,offset gomby1
		sjz	szele
		mov	di,offset gomby2
szele:		mov	ax,[bx][di]
		mov	cl,ah
		cbw
		mov	ch,ah
		add	ax,16
		or	dx,dx
		sjnz	yul4
		test	iwan,8
		sjz	jul4
		sub	ax,25-16+2
yul4:		add	ax,25-16
jul4:		xor	si,si
		add	cx,cx
szep3:		mov	ikony[si+88*2],ax
		mov	vikony[si+88*2],ax
		inc	si
		add	ax,18
		inc	si
		or	dx,dx
		sjz	jul5
		add	ax,36-18
jul5:		cmp	si,cx
		sjb	szep3
		mov	ikony+113*2,ax
		mov	vikony+113*2,ax
szava3:		cmp	si,24*2
		sjae	szeve3
		mov	ikony[si+88*2],bp
		mov	vikony[si+88*2],bp
		inc	si
		inc	si
		sjmp	szava3
szeve3:
		xchg	ax,bp
		test	iwan,8
		mov	br benyom+14,al
		push	ds
		mov	cx,5
		mov	di,offset ouikon
		pop	es
		sjz	szenal
		rep	stosw
		inc	di
		stosb
		and	ouikon+14,61440
szenal:		test	iwan,4
		sjz	szenbl
		mov	br ouikon+10,al
		mov	ouikon+12,ax
		and	br ouikon+15,15
szenbl:		mov	al,uzemmod
		mov	cl,5
		shr	al,cl
		add	al,10
		mov	ikonrajz+120,al
		mov	ax,dx
		add	al,18
		mov	ikonrajz+121,al
		mov	al,mode
		and	al,3
		add	al,24
		mov	ikonrajz+122,al
		mov	cx,8
		mov	si,offset ouikon
		xor	di,di
szelep:		lodsw
		push	di
		mov	wr [si-2],0
szellem:	add	ax,ax
		njnc	szeltov
		push	ax
		xor	bx,bx
		push	cx
		or	dx,dx
		push	si
		sjnz	nellem
		mov	bx,vikonx-ikonx
nellem:		push	di
		mov	bp,ikonx[bx][di]
		mov	ax,[si+14]
		mov	si,di
		mov	bx,ikony[bx][di]
		shr	di,1
		or	bp,bp
		sjz	szenm
		or	bx,bx
szenm:		njz	szenem
		or	dx,dx
		sjnz	ellem
		test	iwan,8
		sjz	ellem
		cmp	di,112
		sjne	ellem
		dec	bx
		dec	bx
ellem:		and	si,30
		and	xmode,247
		and	iwan,239
		and	ax,maszk[si]
		mov	si,dx
		sjz	nefford
		or	xmode,8
		or	iwan,16
nefford:	add	si,si
		or	bp,bp
		sjns	xford
		add	bp,ixmax[si]
xford:		add	bp,ixmin[si]
		or	bx,bx
		push	dx
		sjns	oxford
		add	bx,iymax[si]
oxford:		push	ax
		mov	al,ikonszam[di]
		add	bx,iymin[si]
		cbw
		push	ax
		or	dx,dx
		push	bx
		sjnz	roxi3
		inc	ax
roxi3:		push	bp
		push	di
		ncall	panel
		pop	di
		xor	ah,ah
		pop	bp
		mov	al,ikonrajz[di]
		pop	bx
		or	al,al
		pop	dx
		pop	cx
		sjz	nellm
		cmp	al,50
		mov	es,ikpuf
		sjne	viszik
		;cmp	felb,4
		;sjae	sellm
		cmp	dl,70
		sjb	viszik
		cmp	dl,76
		sjb	vszikon
		cmp	dl,88
		sjae	viszik
		cmp	dl,82
		sjb	viszik
vszikon:	push	ax
		mov	si,dx
		add	si,si
		mov	si,es:[si]
		mov	al,es:[si+1]
		sub	al,5+9
		cbw
		add	bx,ax
		pop	ax
viszik:		cmp	al,48
		sjne	fuggik
		cmp	felb,4
nellm:		njae	sellm
		cmp	dl,46
		sjb	fuggik
		cmp	dl,52
		sjb	fgikon
		cmp	dl,64
		sjae	fuggik
		cmp	dl,58
		sjb	fuggik
fgikon:		push	ax
		mov	si,dx
		add	si,si
		mov	si,es:[si]
		mov	al,es:[si]
		sub	al,5+9
		cbw
		add	bp,ax
		pop	ax
fuggik:		cmp	dl,7
		push	cx
		sjne	balikon
		or	koppany,32
balikon:	cmp	dl,11
		sjne	leikon
		add	bp,5
		add	bx,15
		test	felb,7
		sjnz	leikon
		dec	bp
		sub	bx,7
		dec	bp
leikon:		jcxz	nearn
		or	csuvas,128
		or	javas,2
		cmp	dl,19
		sje	irikon
		cmp	dl,11
		sje	irikon
		inc	bp
irikon:		inc	bx
nearn:		test	felb,7
		mov	ch,ah
		push	di
		sjnz	lelek
		sub	di,120
		mov	cl,ikrahx[di]
		sjb	lelk
		sub	bp,cx
		mov	cl,ikrahy[di]
		sub	bx,cx
lelk:		cmp	al,28
		sjae	lelx
		cmp	al,10
		sjae	lelek
		sub	ax,10
lelx:		inc	ax
lelek:		push	bp
		add	ax,100
		push	bx
		ncall	panel
		pop	bx
		pop	bp
		pop	di
		xor	ah,ah
		cmp	di,112
		pop	cx
xellm:		sjae	sellm
		cmp	di,12
		mov	al,ikonrajz2[di]
		sjbe	slm
		cmp	di,72
		sjb	llm
		cmp	di,84
		sjae	ellm
slm:		or	al,al
		sjs	sellm
		sjmp	llm
ellm:		add	bx,11
		test	felb,7
		sjnz	llm
		sub	bx,5
llm:		or	al,al
		sjz	sellm
		jcxz	searn
		or	csuvas,128
		or	javas,2
searn:		add	ax,100
		test	felb,7
		sjnz	vellm
		inc	ax
vellm:		ncall	panel
sellm:		pop	dx
szenem:		pop	di
		pop	si
		pop	cx
		pop	ax
szeltov:	inc	di
		inc	di
		or	ax,ax
		sjz	xellem
		njmp	szellem
xellem:		pop	di
		add	di,32
		dec	cx
		sjz	xelep
		njmp	szelep

kixep:		mov	cl,ah
		sjz	xixep
		xor	al,al
		xor	bl,bl
xixep:		jcxz	kikken
		push	cx
kikkep:		stosb
		add	al,bl
		loop	kikkep
		pop	cx
kikken:		neg	cx
		xor	al,al
		add	cx,24
		sjz	xelep
xikkep:		rep	stosb
xelep:		ret
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
vikoord:	push	ax		;	CĄmkonverzi˘ koordin t v 
		mov	ax,di		;	(ES:DI => BP/BX).
		push	dx
		mov	dl,pag
		xor	dh,dh
		div	gsor
		test	mode,2
		mov	bp,dx
		sjz	kapanyel
		shr	bp,1
		test	mode,1
		sjz	kapanyel
		shr	bp,1
		test	xmode,1
		sjnz	kapanyel
		push	di
		xchg	ax,bp
		xchg	ax,dx
		mov	di,3
		xor	dx,dx
		div	di
		xchg	ax,bp
		pop	di
kapanyel:	sub	ax,yoffs
		pop	dx
		sjae	yoyo
		xor	ax,ax
yoyo:		sub	bp,xoffs
		xchg	ax,bx
		sjae	xoxo
		xor	bp,bp
xoxo:		pop	ax
		ret

;apanel:	add	ax,ax		;	Az AX. kpelem kirak sa cĄmre.
;		mov	fs,ikpuf
;		sjz	zasemm
;		cmp	ax,wr fs:[0]
;		xchg	ax,si
;		nja	pasemm
;		mov	si,fs:[si]
;		or	si,si
;		lodsw	fs:[si]
;zasemm:	njz	pasemm
;		movzx	dx,al
;		movzx	cx,ah
;		njmp	sipanel

apanel:		ncall	vikoord		;	Az AX. kpelem kirak sa cĄmre.

panel:		and	taksony,254
		xor	cx,cx
		cmp	ax,152
		mov	aktikon,ax
		sjae	zanel
		cmp	al,90
		sjb	lenyel
		cmp	al,140
		sjb	zanel
		test	csuvas,12
		sjnz	qanel
		cmp	al,148
		mov	cl,csuvas
		sjae	lenyal
		neg	cl
lenyal:		and	cl,3
		sjmp	qanel
lenyel:		cmp	al,5
		sjae	anyel
		cmp	al,3
		sjb	anyel
lyanel:		test	mode,2
		sjz	yanel
		or	taksony,1
yanel:		inc	cx
		sjmp	zsanel
anyel:		cmp	al,88
		sjae	lyanel
		cmp	al,13
		sjb	csuhaj
		cmp	al,19
		sjb	lyanel
csuhaj:		test	csuvas,4
		sjnz	csines
		mov	cl,csuvas
		and	cl,3
		sjmp	qanel
csines:		cmp	al,13
		sjb	ianel
		;cmp	al,19
		;sjb	lyanel
		cmp	al,19
		sjb	yanel
		cmp	al,21
		sjb	qanel
		cmp	al,29
		sjb	zanel
		cmp	al,31
		sjb	qanel
		cmp	al,39
		sjb	yanel
		cmp	al,40
		sjae	yanel
zanel:		push	ax
		mov	al,csuvas
		and	al,15
		cmp	al,2
		pop	ax
		sje	ianel
zsanel:		inc	cx		
ianel:		inc	cx
qanel:		and	csuvas,223
		add	ax,ax		;	Az AX. kpelem kirak sa,
		mov	fs,ikpuf	;	pozĄci˘ szerint:
		njz	pasemm		;	BP = X-koordin ta,
		cmp	ax,wr fs:[0]	;	BX = Y-koordin ta.
		xchg	ax,si
		nja	pasemm
		test	csuvas,16
		mov	si,fs:[si]
		sjz	szuvas
		or	csuvas,32
szuvas:		or	si,si
		mov	gelyik,cl
		lodsw	fs:[si]
		njz	pasemm
		push	si
		movzx	dx,al
		mov	cl,ah
		mov	si,bp
		mov	di,bx
		ncall	lefed
		pop	si
		ncall	kekapcs
		push	dx
		xchg	ax,bx
		ncall	pkoord
		pop	dx
		ncall	sipanel
		njmp	bekapcs
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
epanel:		lodsw	fs:[si]
		and	koppany,223
		movzx	cx,ah
		movzx	dx,al
		mov	bp,cx
		lodsw	fs:[si]
		add	bp,bp
		mov	br inmouy,ah
		mov	br inmoux,al
		test	oxtan,128
		mov	ax,epufy	;	Egrpanel kirak sa a kpre, a
		sjz	oxin1
		test	tegan,4
		sjnz	oxin1
		test	chewan,16
		sjnz	oxin1
		add	ax,nyomy
oxin1:		sub	ax,inmouy
		mov	br inmouy,ch
		sjae	toxin1
		sub	si,ax
		sub	inmouy,ax
		add	cx,ax
		sjs	sasamm
		sub	si,ax
		xor	ax,ax
toxin1:		add	ax,cx		;	hat rok ellenrzsvel.
		sub	ax,ymax
		sjbe	eplex
		sub	cx,ax
		sjbe	pasamm
eplex:		test	oxtan,128
		mov	ax,epufx
		sjz	oxin2
		test	tegan,4
		sjnz	oxin2
		test	chewan,16
		sjnz	oxin2
		add	ax,nyomx
oxin2:		sub	ax,inmoux
		mov	br inmoux,dh
		sjae	toxin2
		sub	inmoux,ax
		add	dx,ax
sasamm:		njs	pasemm
		xor	ax,ax
toxin2:		add	ax,dx
		sub	ax,xmax
		sjbe	papanel
		sub	dx,ax
pasamm:		njbe	pasemm
eplep:		add	si,bp
oplep:		push	dx
		lodsw	fs:[si]
		push	cx
		mov	cx,inmoux
		push	si
		xchg	ax,si
		jcxz	yppo
xplep:		lodsb	fs:[si]
		or	al,al
		sjz	noppo
		cmp	al,-16
		sjb	xpcik
		cmp	al,-4
		sjae	ypcik
		cmp	al,-8
		sjae	xpcik
		dec	si
		loop	filcsik
		inc	cx
filcsik:	cmp	al,-12
		sjae	ypcik
		loop	ypcik
		inc	cx
ypcik:		inc	si
xpcik:		loop	xplep
yppo:		inc	cx
		ncall	sipanel
noppo:		pop	si
		pop	cx
		pop	dx
		loop	oplep
		ret
papanel:	cmp	dh,br inmoux
		sjne	eplep
		mov	si,fs:[si]
		njmp	sipanel
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
qurit:		mov	bp,si
		xor	ax,ax
		mov	si,offset xesa+539
		mov	bx,dx
hahot:		cmp	al,-16
		mov	[si],al
		sjb	udondur
		cmp	al,-4
		sjae	timur
		not	al
		shr	al,2
		sjmp	szubotaj
timur:		dec	si
		inc	bp
		mov	[si],ax
		mov	al,ah
		sjmp	szubotaj
udondur:	cmp	al,16
		sjb	szubotaj
		shr	al,4
szubotaj:	sub	bl,al
		mov	ax,fs:[bp]
		sjbe	derit
		inc	bp
ubul:		dec	si
		or	al,al
		mov	[si],bl
		sjnz	hahot
		sub	bl,15
		sjbe	derit
		mov	br [si],15
		sjmp	ubul
derit:		mov	wr xesa+542,fs
		push	ds
		mov	wr xesa+540,bp
		pop	fs
		sjmp	qerit

nepal:		mov	cl,fs:[si]
		ncall	krahat
		sjc	krah
		inc	si
krah:		and	javas,63
		or	bl,4
		inc	al
		jcxz	pacik
		sjz	sbabax
		or	javas,128
		add	bl,4
		inc	al
		mov	ah,2
		sjz	epal
		or	javas,64
		inc	al
		mov	ah,6
		sjz	epal
		and	javas,63
sbabax:		sjmp	babax
epal:		test	csuvas,64
		mov	al,ah
		sjnz	ghabax
		test	javas,32
		sjz	babax
ghabax:		sub	bl,8
		and	javas,63
		sjmp	repal
vadax:		mov	cx,dx
		sjmp	dadax

sipanel:	mov	ax,xkoord
		or	dx,dx		;	Kpelem kirak sa a grafikus
		mov	alkoord,ax
		jcxz	pasemm		;	kpre. Paramterek:
		sjz	pasemm		;	FS:SI = a kpelem cĄme,
pacikl:		push	dx		;	ES:DI = kezdpozĄci˘ a kpen,
		push	cx		;	DX = szlessg (kppontban!),
		test	koppany,32
		push	di		;	CX = magass g (szintn).
		njnz	qurit
qerit:		ncall	nyerit
pacik:		mov	bl,mode
		lodsb	fs:[si]
		and	bx,3
		cmp	al,-16
		mov	cl,al
		sjae	nepal
		shr	cx,4
		sjz	palep
repal:		test	xmode,8
		njnz	papa
papax:		and	eax,15
		mov	eax,szinht[4*eax]
babax:		add	bx,bx
		cmp	cx,dx
		push	si
		sja	vadax
dadax:		mov	bp,cx
		call	vonugr[bx]
		pop	si
patov:		sub	dx,bp
		sja	pacik
patov2:		ncall	gurit
		mov	cx,di		;	!!!!!!!!!!!!!!!!
		pop	ax
		sub	cx,ax
		mov	ax,gsor
		sub	ax,cx
		inc	ykoord
		add	di,ax
		sjnc	paptov
		ncall	incpage
paptov:		pop	cx
		mov	ax,alkoord
		test	koppany,32
		pop	dx
		mov	xkoord,ax
		sjnz	puncsi
pancsi:		loop	pacikl
pasemm:		and	xmode,247
		and	iwan,239
		and	koppany,95
		and	csuvas,95
		and	javas,52
		mov	aktikon,0
		ret
palep:		and	ax,15
		sjz	patov2
		cmp	ax,dx
		sja	vedax
edax:		ncall	gurit
		add	xkoord,ax
		test	mode,2
		mov	bp,ax
		sjnz	pahi
panov:		add	di,ax
		sjnc	qatov
		ncall	incpage
qatov:		ncall	nyerit
		sjmp	patov
vedax:		mov	ax,dx
		sjmp	edax

papa:		and	al,15
		cmp	al,2
		sje	pax
		cmp	al,6
		sjne	papai
pax:		xor	al,4
spapax:		njmp	papax
papai:		test	iwan,16
		sjz	spapax
		cmp	al,5
		sjne	spapax
		;sja	papax
		;cmp	al,4
		;sjb	papax
		mov	al,3
		sjmp	spapax

puncsi:		lfs	si,dr xesa+540
		sjmp	pancsi
pahi:		add	ax,ax
		test	mode,1
		sjz	panov
patrue:		add	ax,bp
		test	xmode,1
		sjz	panov
patrue32:	add	ax,bp
		sjmp	panov

krahat:		cmp	al,-4
		sjae	khat
		xor	cx,cx
		cmp	al,-16
		sjb	khat
chat:		add	al,4
		inc	cx
		cmp	al,-4
		sjb	chat
		stc
khat:		ret		
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
screensaver	proc	far		;	Kpernyvd program,
		and	br output,15	;	csillagmez rajzol sa.
		xor	ax,ax
		test	uzemmod,16
		sjz	gsaver
		mov	es,chseg
		cmp	al,csillag
		sjne	vancsill
		cmp	br ymax,25
		mov	cx,2000
		mov	di,2*csillmax
		sjbe	csicikl
		add	cx,cx
csicikl:	dec	di
		mov	br csillx[di],al
		sjnz	csicikl
		rep	stosw
		inc	csillag
vancsill:	mov	al,csillmax
		ncall	brandom
		add	ax,ax
		add	ax,offset csillx
		xor	si,si
		xchg	ax,si
		mov	di,[si]
		stosw
		mov	al,br ymax
		ncall	brandom
		mul	br gsor
		mov	di,ax
		mov	al,br xmax
		ncall	brandom
		add	ax,ax
		add	di,ax
		mov	[si],di
		mov	al,2
		ncall	random
		mov	bl,15
		sjz	szmegv
		mov	bl,7
szmegv:		mov	al,3
		ncall	random
		mov	al,2eh
		sjz	csmegv
		mov	al,0fah
csmegv:		mov	ah,bl
		stosw
		ret
gsaver:		cmp	al,csillag
		sjne	gvancsill
		mov	di,4*csillmax
gcsicikl:	mov	br csillx[di-1],al
		dec	di
		sjnz	gcsicikl
		mov	cx,xmax
		mov	dx,ymax
		mov	bx,ax
		mov	bp,ax
		ncall	hraster
		ncall	teglap
		inc	csillag
gvancsill:	mov	al,csillmax
		ncall	brandom
		add	ax,ax
		add	ax,offset csillx
		xor	si,si
		xchg	ax,si
		mov	bp,[si]
		mov	bx,[si+2*csillmax]
		movzx	cx,felb
		inc	cx
		mov	dx,cx
		push	si
		ncall	hraster
		ncall	teglap
		mov	ax,xmax
		ncall	random
		mov	bp,ax
		mov	ax,ymax
		ncall	random
		mov	bx,ax
		pop	si
		mov	[si],bp
		mov	[si+2*csillmax],ax
		mov	al,felb
		inc	ax
		ncall	brandom
		inc	ax
		mov	cx,ax
		ncall	random
		inc	ax
		mov	dx,ax
		mov	al,8
		ncall	random
		inc	ax
		jmp	farteglap
screensaver	endp
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
opengfx		proc	far
		push	ax
		mov	al,256-allcolors
		push	bx
		mov	br palkzd,al
		mov	br palkzd+2,al
		mov	br palkzd+4,al
		mov	br palkzd+6,al
		mov	al,uzemmod
		and	own,191
		and	al,12
		xchg	ax,bx
		mov	al,allcolors
		sjz	onan
		shr	al,1
		cmp	bl,12
		sjne	oral
		add	br palkzd+2,al
		add	br palkzd+3,al
		shr	al,1
oral:		add	br palkzd+1,al
		add	br palkzd+3,al
onan:		test	mode,8
		pop	bx
		mov	br palnum,al
		mov	br palnum+2,al
		mov	br palnum+4,al
		mov	br palnum+6,al
		mov	br colors,al
		mov	piblak,si
		pop	ax
		sjnz	opgf
xopgf:		ret
opgf:		test	uzemmod,16
		sjnz	xopgf
		cmp	cx,12
		sjbe	xopgf
		cmp	dx,9
		sjbe	xopgf
		test	owan,64+128
		sjnz	opokk
		cmp	dx,18
		sjbe	xopgf
opokk:		pushad
		mov	bl,mode
		and	bx,3
		sjz	opci
		dec	bx
		cmp	bl,2
		sjb	opci
		test	xmode,1
		sjz	opci
		inc	bx
opci:		mov	relb,bl
		mov	grelb,bl
		mov	bl,rbyte[bx]
		mov	ax,cx
		push	dx
		mul	bx
		pop	dx
		mov	rsor,ax
		mov	ax,-1
		add	si,si
		mov	lastrow,ax
		mov	rwhere,ax
		inc	ax
		mov	rszel,cx
		mov	rcount,ax
		mov	rtabl,ax
		mov	ctabl,ax
		mov	prow,ax
		mov	row,ax
		mov	rows,ax
		cmp	ax,gfile[si]
		mov	rmags,dx
		xchg	ax,guj[si]
		sjne	xinpad
		or	ax,ax
		sjz	nunuj
		cmp	ah,32
		sjae	nunuj
		cmp	ax,gakt[si]
		sje	nunua
		ncall	megnyit
		sjc	nunuj
		mov	gakt[si],ax
		sjmp	leakt
nunuj:		mov	ax,gakt[si]
nunua:		or	ax,ax
		sjz	xuakt
		cmp	ah,32
		sjb	beakt
nuakt:		xor	ax,ax
xuakt:		mov	gfelb[si],ax
		mov	gfile[si],ax
		;mov	gakt[si],ax
		mov	graphx[si],640
		mov	graphy[si],480
		mov	gophx,640
		mov	gophy,480
xinpad:		njmp	kinpad
beakt:		ncall	megnyit
		sjc	nuakt
leakt:		mov	al,akkit
		mov	cx,rszel
		and	ax,3
		mov	bl,relb
		sjz	ehe
		dec	ax
		mov	grelb,al
		xchg	ax,bx
ehe:		mov	ax,palnum[si]
		cmp	akkit,1
		mov	colors,ax
		sjne	nehe
		mov	rtabl,3*allcolors
nehe:		mov	ax,graphy[si]
		and	bx,3
		cmp	ax,1200
		movzx	dx,grbyt[bx]
		mov	bx,graphx[si]
		sja	xennyit
		add	ax,ax
		add	cx,cx
		sjc	xennyit
		add	ax,rtabl
		sjc	xennyit
		cmp	ax,fmeret
		sjb	gennyit
xennyit:	njmp	nennyit
gennyit:	cmp	bx,1600
		mov	ctabl,ax
		sja	xennyit
		xchg	ax,bx
		mul	dx
		xchg	ax,bx
		add	ax,cx
		sjc	xennyit
		cmp	ax,fmeret
		sjae	xennyit
		mov	prow,ax
		add	ax,bx
		sjc	xennyit
		cmp	ax,fmeret
		sjae	xennyit
		mov	row,ax
		add	ax,rsor
		sjc	xennyit
		cmp	ax,fmeret
		mov	dx,rtabl
		sjae	xennyit
		mov	rows,ax
		push	si
		neg	ax
		mov	cx,ctabl
		add	ax,fmeret
		push	ds
		sub	cx,dx
		and	koppany,64
		mov	es,filepuf
		push	cx
		mov	rmeret,ax
		push	es
		xor	ax,ax
		mov	cx,fmeret
		xor	di,di
		mov	fpufs,ax
		shr	cx,1
		pop	ds
		rep	stosw
		pop	cx
		call	farread
		pop	ds
		mov	cx,rtabl
		pop	si
		sjc	nnyit
		jcxz	reicher
		push	si
		xor	dx,dx
		push	ds
		and	koppany,64
		mov	ds,filepuf
		call	farread
		pop	ds
		mov	cx,palnum[si]
		pop	si
nnyit:		njc	ennyit
		jcxz	reicher

		push	cx
		push	si
		ncall	palack
		pop	si
		pop	cx

		push	si
		test	own,32
		push	ds
		mov	ax,palkzd[si]
		sjz	palax

		mov	cx,allcolors		;	csak teszt!!!
		mov	ax,256-allcolors

		mov	di,ax
		mov	es,paletta
		add	ax,ax
		xor	si,si
		and	koppany,64
		mov	ds,filepuf
		add	di,ax
		push	cx
palazzo:	movsw
		movsb
		loop	palazzo
		pop	cx
palax:		pop	ds
		pop	si

		push	si
		ncall	malack
		;call	fco256
		pop	si

reicher:	test	mode,2
		sjnz	reichx
		push	si
		call	fco256
		pop	si
reichx:		movzx	ebx,grelb
		movzx	ecx,rszel
		mov	bl,grbyt[bx]
		movzx	eax,graphx[si]
		movzx	ebp,ctabl
		mov	edi,ecx
		xchg	eax,esi
		and	koppany,64
		mov	es,filepuf
klipsz:		mov	eax,ecx
		dec	ax
		mul	esi
		div	edi
		mul	ebx
		add	ax,prow
		mov	es:[ebp][2*ecx-2],ax
		loop	klipsz
kinpad:		popad
nopgf:		ret
ennyit:		mov	gfile[si],0
nennyit:	popad
opengfx		endp

closegfx	proc	far
		test	mode,8
		sjz	noclgf
		;test	uzemmod,16
		;sjnz	noclgf
		pusha
		mov	si,piblak
		xor	bx,bx
		add	si,si
		xchg	bx,gfile[si]
		or	bx,bx
		mov	ah,3eh
		sjz	secli
		int	21h
secli:		popa
noclgf:		ret
closegfx	endp

palack:		
		ret

malack:		
		ret

megnyit:	push	ax
		and	ah,31
		push	bx
		xchg	ax,bp
		xor	bx,bx
		mov	al,felb
memex:		cmp	cx,grx[bx]
		sja	memeh
		cmp	dx,gry[bx]
		sja	memeh
		shr	bx,1
		xchg	ax,bx
		sjmp	memev
memeh:		inc	bx
		inc	bx
		cmp	bx,2*8
		sjb	memex
memev:		shl	ax,13
		pop	bx
		or	bp,ax
		test	mode,32
		push	si
		mov	al,2
		sjnz	szurke
		test	vonan,64
		sjnz	szurke
		shr	si,1
		test	pufabl[si],128
		pushf
		add	si,si
		popf
		sjnz	szurke
		shr	si,1
		test	gfabl[si],8
		pushf
		add	si,si
		popf
		sjz	szines
szurke:		ncall	sznyiprob
		sjnc	siknyi
szines:		mov	si,3
segyb:		push	bx
		mov	bl,mode
		push	si
		and	bx,3
		shl	bx,2
		mov	ah,mitprob[bx][si]
		or	ah,ah
		stc
		sjs	snyitv
		ncall	nyiprob
snyitv:		pop	si
		pop	bx
		sjnc	siknyi
		dec	si
		sjns	segyb
		pop	si
		pop	ax
		ret

siknyi:		pop	si
		shr	si,1
		and	gfabl[si],239
		cmp	ah,8
		sjne	nossz
		or	gfabl[si],16
nossz:		mov	al,pufabl[si]
		mov	pfablo,al
		mov	al,gfabl[si]
		add	si,si
		mov	gfablo,al
		shr	bp,13
		mov	ax,file
		mov	gfelb[si],bp
		add	bp,bp
		mov	gfile[si],ax
		mov	ax,ds:grx[bp]
		mov	graphx[si],ax
		mov	gophx,ax
		mov	ax,ds:gry[bp]
		mov	graphy[si],ax
		mov	gophy,ax
		pop	ax
		;mov	gakt[si],ax
		ret

sznyiprob:	xor	ah,ah

nyiprob:	mov	akkit,ah
		push	bp
		add	ah,8
		sjmp	nyiproc
nyiski:		add	bp,8192
		cmp	bp,5*8192
		sjae	nyiski2
nyiproc:	pusha
		call	fastopen
		popa
		sjc	nyiski
nyivva:		add	sp,2
vakit:		mov	aknev,bp
		ret
nyiski2:	pop	bp
		push	bp
nyisk2:		sub	bp,8192
		sjc	nyista
		pusha
		call	fastopen
		popa
		sjc	nyisk2
		sjmp	nyivva
nyista:		pop	bp
		mov	ah,akkit
		sjmp	vakit
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
enlarge		proc	far		;	Egsz kpernyre nagyĄt s.
		and	br output,15
		test	gwan,4
		sjnz	marenl
		push	si
		and	gfabl[si],251
		push	ax
		ncall	hraster
		xor	ax,ax
		test	uzemmod,16
		push	bx
		push	cx
		push	dx
		push	bp
		sjz	geglap
		cmp	br ymax,25
		mov	cx,2000
		mov	di,ax
		mov	es,chseg
		sjbe	tehet
		add	cx,cx
tehet:		rep	stosw
		sjmp	ggg
marenl:		ret
geglap:		ncall	teglap
ggg:		pop	bp
		pop	dx
		or	huan,1
		pop	cx
		pop	bx
		or	gwan,4
		pop	ax
		pop	si
enlarge		endp

picture		proc	far		;	Kp kirajzol sa:
		or	dx,dx		;	BP/BX - bal fels sarok X/Y,
		mov	piblak,si	;	CX/DX - szlessg/magass g,
		sjz	pipic		;	SI - ablak sorsz ma,
		test	uzemmod,16	;	AX - Łj pixelsorok sz ma.
		jcxz	pipic
		sjz	grapix
		push	dx
		xchg	ax,bx
		ncall	koord
		ncall	hraster
		test	pufabl[si],64
		mov	al,0b0h
		pop	dx
		mov	ah,br betcol
		sjz	pikord
		mov	ah,br kekkar
pikord:		push	cx
		push	di
		rep	stosw
		pop	di
		add	di,gsor
		dec	dx
		pop	cx
		sjnz	pikord
		or	gfabl[si],2
		and	gfabl[si],251
		ret
pipic:		or	gfabl[si],4
pipix:		and	gfabl[si],253
		ret
grapix:		and	ah,127
		cmp	cx,xmax
		sjb	gragr
		or	ah,128
gragr:		test	xmode,128
		pushad
		mov	al,setsz
		mov	bl,setsz+2
		sjz	kfeh
		xchg	al,bl
kfeh:		test	pufabl[si],64
		push	cx
		sjz	kfehh
		xchg	al,bl
kfehh:		or	ah,ah
		push	si
		sjns	kfech
		xor	al,al
kfech:		add	si,si
		test	huan,4
		mov	vesa+8,al
		sjnz	equus
		cmp	cx,9
		sjb	equus
		test	felb,7
		mov	ax,8
		sjz	nyiax
		add	ax,ax
nyiax:		cmp	dx,ax
		mov	di,graphy[si]
		mov	si,graphx[si]
		sjb	equus
		shl	edi,16
		movzx	ebx,dx
		sjz	equus
		shl	esi,16
		movzx	ecx,cx
		sjz	equus
		mov	eax,edi
		cdq
		div	ebx
		xchg	eax,ebp
		mov	eax,esi
		cdq
		div	ecx
		cmp	eax,ebp
		sja	xquus
		sjb	yquus
equus:		xor	cx,cx
		sjmp	eqren
xquus:		xchg	eax,edi
		cdq
		div	edi
		mov	si,cx
		xchg	ax,di
		sjmp	xyren
yquus:		xchg	eax,esi
		cdq
		div	ebp
		xchg	ax,si
		mov	di,bx
xyren:		sub	cx,si
		sjae	eq1
		xor	cx,cx
eq1:		sub	bx,di
		sjae	eq2
eqren:		xor	bx,bx
eq2:		pop	si
		xor	dx,dx
		xor	bp,bp
		test	pufabl[si],8
		pop	ax
		sjz	engra
gyngy:		shr	cx,1
		mov	dx,cx
		sjmp	engy
engra:		cmp	ax,xmax
		mov	al,gszel[si+1]
		sjae	gyngy
		cmp	al,sorsze
		mov	al,gmags[si+1]
		sjb	egx1
		shr	cx,1
		mov	dx,cx
egx1:		cmp	al,kepsor
		sjb	egx2
engy:		shr	bx,1
		mov	bp,bx
egx2:		test	felb,7
		mov	ax,8
		mov	si,9
		sjz	negx
		add	ax,ax
negx:		cmp	dx,si
		sjae	kex1
		xor	dx,dx
kex1:		cmp	cx,si
		sjae	kex2
		xor	cx,cx
kex2:		cmp	bx,ax
		sjae	kex3
		xor	bx,bx
kex3:		cmp	bp,ax
		sjae	kex4
		xor	bp,bp
kex4:		cmp	ah,vesa+8
		sje	igx4
		or	dx,dx
		sjnz	igx1
		inc	dx
igx1:		or	cx,cx
		sjnz	igx2
		inc	cx
igx2:		or	bx,bx
		sjnz	igx3
		inc	bx
igx3:		or	bp,bp
		sjnz	igx4
		inc	bp
igx4:		mov	al,hexan
		and	al,3
		cmp	al,3
		sje	zsu
		mov	al,tegan
		and	al,3
		cmp	al,3
		sje	zsu
		xor	ax,ax
		cmp	dx,5
		sjb	zsu1
		inc	ax
zsu1:		cmp	cx,5
		sjb	zsu2
		inc	ax
zsu2:		cmp	bx,5
		sjb	zsu3
		inc	ax
zsu3:		cmp	bp,5
		sjb	zsu4
		inc	ax
zsu4:		dec	ax
		sjs	zsu
		sjz	zsuk
		dec	dx
		sjns	zsuk
		inc	dx
zsuk:		dec	cx
		sjns	zsa
		inc	cx
zsa:		dec	bx
		sjns	zsi
		inc	bx
zsi:		cmp	bp,5
		sjae	zsu
		dec	bp
		sjns	zsu
		inc	bp
zsu:		mov	wr vesa,dx
		mov	wr vesa+2,cx
		mov	wr vesa+4,bx
		mov	wr vesa+6,bp
		popad
		ncall	hraster
		and	taksony,243
		pusha
		test	tegan,16
		mov	cx,wr vesa
		sjnz	texa
		or	taksony,4
texa:		ncall	leglap
		popa
		and	taksony,243
		pusha
		test	tegan,16
		mov	dx,wr vesa+4
		sjnz	tegsa
		or	taksony,8
tegsa:		ncall	leglap
		popa
		and	taksony,243
		pusha
		add	bp,cx
		mov	cx,wr vesa+2
		sub	bp,cx
		ncall	leglap
		popa
		pusha
		add	bx,dx
		mov	dx,wr vesa+6
		sub	bx,dx
		ncall	leglap
		popa
		cmp	setscale,60
		push	ax
		mov	ax,wr vesa
		sjbe	hatvan
		mov	setscale,60
hatvan:		add	bp,ax
		sub	cx,ax
		mov	ax,wr vesa+4
		and	koppany,64
		add	bx,ax
		sub	dx,ax
		pop	ax
		sub	cx,wr vesa+2
		sub	dx,wr vesa+6
		test	gfabl[si],4
		mov	actscale,-1
		mov	setscale,-1
		njnz	pipix
		test	huan,1
		sjnz	yayax
		cmp	cx,2
		sjb	yayax
		cmp	dx,2
		sjb	yayax
		or	ah,ah
		sjs	yayax
		ncall	prikapcs
		dec	dx
		push	ax
		ncall	pkvonal
		push	dx
		add	bx,dx
		ncall	pkvonal
		dec	cx
walp:		dec	bx
		dec	dx
		sjz	wax
		ncall	pkpont
		add	bp,cx
		ncall	pkpont
		sub	bp,cx
		sjmp	walp
pipics2:	njmp	pipic
wax:		pop	dx
		inc	bx
		inc	bp
		pop	ax
		dec	dx
		dec	cx
		ncall	bekapcs
yayax:		or	dx,dx
		jcxz	pipics2
		sjz	pipics2
		or	ah,ah
		push	bx
		push	cx
		push	dx
		sjs	prepri
		call	closegfx
		mov	al,4
		ncall	priglap
		ncall	agerbe
prepri:		mov	di,piblak
		pop	dx
		mov	si,di
		pop	cx
		add	di,di
		pop	ax
		cmp	gfile[di],0
		sjne	soks
		cmp	cx,12
		sjbe	piclo
		cmp	dx,9
		sjbe	piclo
		test	owan,64+128
		sjnz	opoks
		cmp	dx,18
		sjbe	piclo
opoks:		call	opengfx
soks:		push	si
		add	si,si
		mov	proltx,bp
		cmp	gfile[si],0
		mov	prolty,ax
		sje	pipicl
		ncall	koord
		xor	ax,ax
		mov	wr gesdi,di
		mov	wr gesdi+2,es
sirak:		push	ax
		ncall	transform
		sjc	pipacs
		mov	si,proltx
		mov	di,prolty
		mov	dx,rszel
		mov	cx,1
		ncall	lefed
		;pushf
		;ncall	hraster
		;popf
		ncall	kekapcs
		ncall	disprow
		ncall	bekapcs
		call	begbevit
		pop	ax
		inc	prolty
		inc	ax
		cmp	ax,rmags
		sjb	sirak
pipicl:		pop	si
piclo:		call	closegfx
pipics:		njmp	pipic
pipacs:		pop	ax
		sjmp	pipicl
picture		endp

leglap:		cmp	cx,5
		mov	al,vesa+8
		sjb	priglap
		cmp	dx,5
		sjb	priglap
		or	al,al
		sjz	priglap
		push	bx
		add	bx,yoffs
		push	ax
		mov	scalex,cx
		push	dx
		cmp	al,setsz
		mov	scaley,dx
		mov	al,61
		push	bx
		sje	iglo
		inc	ax
iglo:		;test	xmode,64
		;sjnz	yglo
		;and	koppany,64
yglo:		ncall	setscales
		pop	bx
		mov	ax,bp
		pop	dx
		mov	corny,bx
		add	ax,xoffs
		test	koppany,3
		mov	cornx,ax
		pop	ax
		mov	swapcol,al
		pop	bx
		sjz	priglap
		mov	al,-4
priglap:	or	dx,dx
		jcxz	privax
		sjz	privax
		ncall	prikapcs
		push	si
		ncall	teglap
		pop	si
		njmp	bekapcs

prikapcs:	push	si
		xchg	cx,dx
		mov	di,bx
		mov	si,bp
		ncall	lefed
		pop	si
		xchg	cx,dx
		njmp	kikapcs

pkpont:		pusha
		mov	cx,1
		sjmp	oovax

pkvonal:	pusha
oovax:		xor	al,al
		ncall	kvonal
		ncall	urit
		popa
privax:		ret

disprow:	mov	es,filepuf
		mov	di,row
		mov	cx,rszel
		push	ds
		mov	ax,rsor
		and	koppany,64
		push	es
		mov	cx,ax
		les	di,gesdi
		xor	bp,bp
		add	ax,di
		mov	si,row
		pop	ds
		sjnc	laptl
		sjz	laptl
		sub	cx,ax
		shr	cx,1
		sjnc	lsp0
		movsb
lsp0:		shr	cx,1
		sjnc	lsp1
		movsw
lsp1:		mov	dx,ds
		rep	movsd
		pop	ds
		xchg	ax,cx
		ncall	incpage
		push	ds
		inc	bp
		mov	ds,dx
laptl:		shr	cx,1
		sjnc	dsp0
		movsb
dsp0:		shr	cx,1
		sjnc	dsp1
		movsw
dsp1:		shr	cx,1
		sjnc	dsp2
		movsd
dsp2:		shr	cx,1
		sjnc	dsp3
		movsd
		movsd
dsp3:		shr	cx,1
		sjnc	dsp4
		movsd
		movsd
		movsd
		movsd
dsp4:		jcxz	dspnt
dsplp:		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		movsd
		loop	dsplp
dspnt:		pop	ds
		mov	ax,gsor
		add	wr gesdi,ax
		sjc	lapaz
lapaj:		ret
lapaz:		dec	bp
		sjns	lapaj
		njmp	incpage

transform:	and	own,127
		test	mode,32
		sjnz	xszurr
		test	vonan,64
		sjnz	xszurr
		test	gfablo,8
		sjnz	xszurr
		test	pfablo,128
		sjz	xturr
xszurr:		or	own,128
xturr:		cmp	ax,rmags
		njae	rorrow
		mul	gophy
		and	gfablo,127
		div	rmags
		cmp	ax,lastrow
		njle	cukrow
		mov	lastrow,ax
		ncall	inprow
		mov	bl,relb
		njc	retrow
		and	koppany,64
		and	bx,3
		test	gfablo,16
		mov	si,gophx
		mov	es,filepuf
		sjz	sesszu
		dec	si
		mov	al,grbyt[bx]
		or	gfablo,128
		cbw
		mov	bp,prow
		mul	si
		or	bx,bx
		xchg	ax,di
		sjnz	trahi
tra256:		mov	al,es:[bp][si]
		shr	al,2
		add	al,16
		mov	es:[bp][di],al
		dec	di
		dec	si
		sjns	tra256
sesszu:		njmp	nesszu
trahi:		cmp	bl,1
		sjne	tratrue
trahix:		mov	al,es:[bp][si]
		xor	ah,ah
		test	conan,1
		push	ax
		mov	cl,8
		sjz	tred
		shr	al,1
tred:		sub	cl,redsiz
		shr	ax,cl
		mov	cl,redscr
		shl	ax,cl
		test	conan,2
		xchg	ax,dx
		pop	ax
		mov	cl,8
		push	ax
		sjz	treg
		shr	al,1
treg:		sub	cl,gresiz
		shr	ax,cl
		mov	cl,grescr
		shl	ax,cl
		mov	cl,8
		or	dx,ax
		test	conan,4
		pop	ax
		sjz	treb
		shr	al,1
treb:		sub	cl,blusiz
		shr	ax,cl
		mov	cl,bluscr
		shl	ax,cl
		or	ax,dx
		mov	es:[bp][di],ax
		dec	di
		dec	di
		dec	si
		sjns	trahix
		sjmp	nesszu
tratrue:	mov	al,es:[bp][si]
		movzx	eax,al
		test	conan,1
		mov	cl,redscr
		push	eax
		sjz	trurd
		shr	al,1
trurd:		shl	eax,cl
		test	conan,2
		xchg	eax,edx
		pop	eax
		mov	cl,grescr
		push	eax
		sjz	trurg
		shr	al,1
trurg:		shl	eax,cl
		or	edx,eax
		test	conan,4
		pop	eax
		mov	cl,bluscr
		sjz	trurb
		shr	al,1
trurb:		shl	eax,cl
		or	eax,edx
		mov	es:[bp][di],ax
		sub	di,3
		shr	eax,16
		dec	si
		mov	es:[bp][di+5],al
		sjns	tratrue
nesszu:		add	bx,bx
		test	gfablo,16
		mov	al,mode
		mov	si,ctabl
		mov	di,row
		mov	bp,prow
		sjnz	turr
		and	al,3
		test	gfablo,128
		sjnz	turr
		cmp	al,akkit
		sjne	szutty
		test	own,128
		sjnz	szurr
turr:		jmp	trugr[bx]
szurr:		jmp	grugr[bx]
szutty:		push	bp
		push	bx
		mov	bx,es:[si]
		inc	si
		mov	bp,wr akkit
		mov	eax,es:[bx]
		and	bp,3
		inc	si
		add	bp,bp
		mov	bx,es:[bx+1]
		call	ds:convert[bp]
		pop	bp
		push	bp
		call	ds:conugr[bp]
		pop	bx
		pop	bp
		cmp	si,bp
		sjb	szutty
		ret

con256:		mov	bh,al		;?????
		shr	al,2
		shl	bh,6
		mov	bl,al
		shr	al,3
		shl	bl,5
		shl	al,6
		ret
conhi:		mov	bh,al
		shr	ax,5
		shl	bh,3
		mov	bl,al
		shr	ax,6
		shl	bl,2
		shl	al,3
contrue:	ret

cg256:		ncall	togray
		shr	al,2
		add	al,16
		stosb
		ret
cghi:		test	own,128
		sjz	goggr
		ncall	ogray
		mov	bh,bl
		mov	bl,ah
goggr:		mov	cl,8
		xor	ah,ah
		sub	cl,redsiz
		shr	al,cl
		mov	cl,redscr
		shl	ax,cl
		mov	cl,8
		xchg	ax,dx
		sub	cl,gresiz
		mov	al,bl
		xor	ah,ah
		shr	al,cl
		mov	cl,grescr
		shl	ax,cl
		mov	cl,8
		or	dx,ax
		sub	cl,blusiz
		mov	al,bh
		xor	ah,ah
		shr	al,cl
		mov	cl,bluscr
		shl	ax,cl
		or	ax,dx
		stosw
		ret
cg24:		test	own,128
		sjz	toggr
		ncall	ogray
		mov	bh,bl
		mov	bl,ah
toggr:		movzx	eax,al
		mov	cl,redscr
		shl	eax,cl
		mov	cl,grescr
		xchg	eax,edx
		movzx	eax,bl
		shl	eax,cl
		mov	cl,bluscr
		or	edx,eax
		movzx	eax,bh
		shl	eax,cl
		or	eax,edx
		stosw
		shr	eax,16
		stosb
		ret
cg32:		test	own,128
		sjz	oggr
		ncall	ogray
		mov	bh,bl
		mov	bl,ah
oggr:		movzx	eax,al
		mov	cl,redscr
		shl	eax,cl
		mov	cl,grescr
		xchg	eax,edx
		movzx	eax,bl
		shl	eax,cl
		mov	cl,bluscr
		or	edx,eax
		movzx	eax,bh
		shl	eax,cl
		or	eax,edx
		stosd
		ret

t256:		mov	bx,es:[si]
		inc	si
		inc	si
		mov	al,es:[bx]
		cmp	si,bp
		stosb
		sjb	t256
		ret
thi:		mov	bx,es:[si]
		inc	si
		mov	ax,es:[bx]
		inc	si
		test	gfablo,128
		mov	bh,al
		sjnz	xmhi
		shr	ax,5
		mov	bl,al
		shr	ax,6
		and	bx,63+31*256
		and	ax,31
		test	conan,1
		mov	cl,5
		sjz	thred
		shr	al,1
thred:		sub	cl,redsiz
		sjbe	threx
		shr	ax,cl
threx:		mov	cl,redscr
		shl	ax,cl
		test	conan,2
		xchg	ax,dx
		mov	cl,6
		mov	al,bl
		sjz	threg
		shr	al,1
threg:		sub	cl,gresiz
		cbw
		sjbe	threxx
		shr	ax,cl
threxx:		mov	cl,grescr
		shl	ax,cl
		mov	cl,5
		or	dx,ax
		test	conan,4
		mov	al,bh
		sjz	threb
		shr	al,1
threb:		sub	cl,blusiz
		cbw
		sjbe	threxxx
		shr	ax,cl
threxxx:	mov	cl,bluscr
		shl	ax,cl
		or	ax,dx
xmhi:		cmp	si,bp
		stosw
		sjb	thi
		ret
t24:		mov	bx,es:[si]
		inc	si
		mov	eax,es:[bx]
		inc	si
		test	gfablo,128
		mov	bx,es:[bx+1]
		sjnz	xmtrx
		test	conan,1
		mov	cl,redscr
		movzx	eax,al
		sjz	thrurd
		shr	al,1
thrurd:		shl	eax,cl
		test	conan,2
		xchg	eax,edx
		mov	cl,grescr
		movzx	eax,bl
		sjz	thrurg
		shr	al,1
thrurg:		shl	eax,cl
		or	edx,eax
		test	conan,4
		mov	cl,bluscr
		movzx	eax,bh
		sjz	thrurb
		shr	al,1
thrurb:		shl	eax,cl
		or	eax,edx
xmtrx:		stosw
		shr	eax,16
		cmp	si,bp
		stosb
		sjb	t24
		ret
t32:		mov	bx,es:[si]
		inc	si
		mov	eax,es:[bx]
		inc	si
		test	gfablo,128
		mov	bx,es:[bx+1]
		sjnz	xmtru
		test	conan,1
		mov	cl,redscr
		movzx	eax,al
		sjz	t3rurd
		shr	al,1
t3rurd:		shl	eax,cl
		test	conan,2
		xchg	eax,edx
		mov	cl,grescr
		movzx	eax,bl
		sjz	t3rurg
		shr	al,1
t3rurg:		shl	eax,cl
		or	edx,eax
		test	conan,4
		mov	cl,bluscr
		movzx	eax,bh
		sjz	t3rurb
		shr	al,1
t3rurb:		shl	eax,cl
		or	eax,edx
xmtru:		cmp	si,bp
		stosd
		sjb	t32
		ret

t256g:		mov	bx,es:[si]
		inc	si
		mov	al,es:[bx]
		inc	si

		mov	bh,al		;?????
		shr	al,2
		mov	bl,al
		shr	al,3
		shl	bh,6
		shl	bl,5
		shl	al,6
		ncall	togray
		shr	al,2

		add	al,16
		cmp	si,bp
		stosb
		sjb	t256g
		ret
thig:		mov	bx,es:[si]
		inc	si
		mov	ax,es:[bx]
		inc	si
		mov	bh,al
		shr	ax,5
		mov	bl,al
		shr	ax,6
		shl	bh,3
		shl	bl,2
		shl	al,3
		ncall	ogray
		mov	cl,8
		mov	ch,ah
		sub	cl,blusiz
		shr	bx,cl
		mov	cl,bluscr
		shl	bx,cl
		mov	cl,8
		xor	ah,ah
		sub	cl,redsiz
		shr	al,cl
		mov	cl,redscr
		shl	ax,cl
		mov	cl,8
		or	bx,ax
		sub	cl,gresiz
		mov	al,ch
		xor	ah,ah
		shr	al,cl
		mov	cl,grescr
		shl	ax,cl
		or	ax,bx
		cmp	si,bp
		stosw
		sjb	thig
		ret
t24g:		mov	bx,es:[si]
		inc	si
		mov	al,es:[bx]
		inc	si
		mov	bx,es:[bx+1]
		ncall	ogray
		mov	bh,ah
		mov	cl,redscr
		movzx	eax,al
		shl	eax,cl
		mov	cl,grescr
		xchg	eax,edx
		movzx	eax,bh
		shl	eax,cl
		mov	cl,bluscr
		or	edx,eax
		movzx	eax,bl
		shl	eax,cl
		or	eax,edx
		stosw
		shr	eax,16
		cmp	si,bp
		stosb
		sjb	t24g
		ret
t32g:		mov	bx,es:[si]
		inc	si
		mov	al,es:[bx]
		inc	si
		mov	bx,es:[bx+1]
		ncall	ogray
		mov	bh,ah
		mov	cl,redscr
		movzx	eax,al
		shl	eax,cl
		mov	cl,grescr
		xchg	eax,edx
		movzx	eax,bh
		shl	eax,cl
		mov	cl,bluscr
		or	edx,eax
		movzx	eax,bl
		shl	eax,cl
		or	eax,edx
		cmp	si,bp
		stosd
		sjb	t32g
		ret

ogray:		ncall	togray
		test	conan,1
		sjz	vred
		shr	al,1
vred:		test	conan,2
		sjz	vgreen
		shr	ah,1
vgreen:		test	conan,4
		sjz	vblue
		shr	bl,1
vblue:		ret

togray:		mov	ah,77
		push	dx
		mul	ah
		xchg	ax,dx
		mov	ah,151
		mov	al,bl
		mul	ah
		add	dx,ax
		mov	ah,28
		mov	al,bh
		mul	ah
		xor	bh,bh
		add	ax,dx
		pop	dx
		mov	al,ah
		mov	bl,ah
		ret

inprow:		mov	bx,rwhere
		or	bx,bx
		mov	cx,rcount
		sjs	notrow
		cmp	bx,ymax
		sjae	rorrow
		sub	ax,bx
		sjb	cukrow
		cmp	ax,cx
		mov	cx,ax
		sjb	okrow
		or	ax,ax
		sjz	retrow
		add	ax,bx
notrow:		ncall	nextrows
		sjnc	inprow
retrow:		ret
rorrow:		call	farclose
		stc
		ret
okrow:		mov	es,filepuf
		push	ds
		and	koppany,64
		add	bx,bx
		mov	si,rows
		mov	ax,ctabl
		push	es
		mov	bp,fmeret
		add	bx,rtabl
		mov	di,prow
		pop	ds
		jcxz	vrow
rowan:		cmp	bx,ax
		sjae	nrow
		add	si,[bx]
		sjc	nrow
		cmp	si,bp
		sjae	nrow
		inc	bx
		inc	bx
		loop	rowan
vrow:		mov	cx,[bx]
		jcxz	nrow
		call	unpack
nrow:		pop	ds
cukrow:		clc
		ret

nextrows:	pusha
		mov	ax,rcount
		mov	es,filepuf
		and	koppany,64
		or	ax,ax
		mov	si,rwhere
		sjnz	nenex
		inc	ax
nenex:		add	ax,si
		xor	cx,cx
		mov	rwhere,ax
		add	ax,ax
		add	ax,rtabl
		xor	bp,bp
		xchg	ax,si
nelep:		cmp	si,ctabl
		mov	ax,es:[si]
		sjae	nehet
		add	ax,cx
		sjc	nehet
		cmp	ax,rmeret
		sja	nehet
		inc	si
		inc	si
		inc	bp
		xchg	ax,cx
		sjns	nelep
nehet:		or	bp,bp
		sjz	neneh
		jcxz	nenen
		push	ds
		mov	rcount,bp
		push	es
		mov	dx,rows
		pop	ds
		call	farread
		pop	ds
		sjnc	nenec
nenen:		mov	rcount,0
nenec:		popa
		ret
neneh:		xor	cx,cx
		cmp	si,ctabl
		mov	ax,4201h
		mov	bx,file
		mov	dx,es:[si]
		sjae	nenes
		int	21h
		sjnc	nenen
nenes:		ncall	rorrow
		sjmp	nenen
;------------------------------------------------------------------------------

iotin	ends
