;	Getpixel in 512*256 graphics mode.
;	 For SuperSoft C 1.2.3 compiler.
;	Prototype: int getpixel (int x,int y);


PUBLIC	getpixel


getpixel:
	lxi h,4
	dad sp
	mov e,m
	inx h
	mov a,m
	rrc
	mov a,e
	rar;		Horizontal coordinate
	lxi h,XPL2+1
	mvi m,0c0h
	jnc XPL1
	mvi m,0a0h
XPL1:	lxi h,2
	dad sp
	mov e,m;	Vertical coordinate
	mov d,a;	Horizontal coordinate
	push b
	di
	lxi h,0
	dad sp
	shld STACK
	xra a
	out 10h
	lxi sp,STACKSEG
	lxi h,PIXTAB
	mov b,a
	mov a,d
	ani 7
	mov c,a
	dad b
	mov b,m;	Masc from PIXTAB
	mov a,d
	ani 0f8h
	rrc
	rrc
	rrc
XPL2:	adi 0c0h
	mov h,a;	Real horizontal coordinate: PANEL_BASE+(0..1F)
	mov l,e;	Vertical coordinate
	mov a,m
	ana b
	lxi d,0
	jz ABANDON
	inx d
ABANDON:
	lhld STACK
	sphl
	mvi a,23h
	out 10h
	pop b
	xchg
	ei
	ret

PIXTAB:	DB 80H,40H,20H,10H,8,4,2,1
STACK:	DW	0
	DS	10
STACKSEG:
	DW	0
	END
