;		Graph_lib
;
;		call from High C
;
;		1990 4  Hiroshi TODA
;

	.386p

        cseg	segment	'CODE'
	assume	cs:cseg,ds:cseg

;peekw( address, segment )

	public	peekw
	db	'peekw',5
peekw	proc	near
	mov	eax,4[esp]
	mov	fs,8[esp]
	mov	ax,fs:[eax]
	and	eax,0ffffH
	ret
peekw	endp

;pokew( address, segment, data )

	public	pokew
	db	'pokew',5
pokew	proc	near
	push	esi
	mov	esi,8[esp]
	mov	fs,12[esp]
	mov	eax,16[esp]
	mov	fs:[esi],ax
	pop	esi
	ret
pokew	endp

;xorw( address, segment, data )

	public	xorw
	db	'xorw',4
xorw	proc	near
	push	esi
	mov	esi,8[esp]
	mov	fs,12[esp]
	mov	eax,16[esp]
	xor	fs:[esi],ax
	pop	esi
	ret
xorw	endp

;peekd( address, segment )

	public	peekd
	db	'peekd',5
peekd	proc	near
	mov	eax,4[esp]
	mov	fs,8[esp]
	mov	eax,fs:[eax]
	ret
peekd	endp

;poked( address, segment, data )

	public	poked
	db	'poked',5
poked	proc	near
	push	esi
	mov	esi,8[esp]
	mov	fs,12[esp]
	mov	eax,16[esp]
	mov	fs:[esi],eax
	pop	esi
	ret
poked	endp

;xord( address, segment, data )

	public	xord
	db	'xord',4
xord	proc	near
	push	esi
	mov	esi,8[esp]
	mov	fs,12[esp]
	mov	eax,16[esp]
	xor	fs:[esi],eax
	pop	esi
	ret
xord	endp

;outfa( fa, haj )		; 垂直帰線中にhaj,fa WRITE

	public	outfa
	db	'outfa',5
outfa	proc	near
	mov	dx,0440h	; 垂直同期を読む
	mov	al,30
	out	dx,al
	mov	dx,0443h	; 0443h
	xor	ecx,ecx		; カウンター
outf01:	in	al,dx
	and	al,04h
	je	outf02
	loop	outf01
outf02:	in	al,dx
	and	al,04h
	jne	outf03
	loop	outf02
outf03:	mov	al,18		;*
	mov	dx,0440h
	out	dx,al
	mov	eax,[esp+8]
	mov	dx,0442h
	out	dx,ax
	mov	al,22		;*
	mov	dx,0440h
	out	dx,al
	mov	eax,[esp+8]
	mov	dx,0442h
	out	dx,ax
	mov	al,17		;*
	mov	dx,0440h
	out	dx,al
	mov	eax,[esp+4]
	mov	dx,0442h
	out	dx,ax
	mov	al,21		;*
	mov	dx,0440h
	out	dx,al
	mov	eax,[esp+4]
	mov	dx,0442h
	out	dx,ax
	ret
outfa	endp

;outb( address, data )  outw( address, data )  inb( address )  inw( address )

	public	outb
	db	'outb',4
outb	proc	near
	mov	edx,[esp+4]
	mov	eax,[esp+8]
	out	dx,al
	ret
outb	endp

	public	outw
	db	'outb',4
outw	proc	near
	mov	edx,[esp+4]
	mov	eax,[esp+8]
	out	dx,ax
	ret
outw	endp

	public	inb
	db	'inb',3
inb	proc	near
	mov	edx,[esp+4]
	in	al,dx
	movzx	eax,al
	ret
inb	endp

	public	inw
	db	'inw',3
inw	proc	near
	mov	edx,[esp+4]
	in	ax,dx
	movzx	eax,ax
	ret
inw	endp

        cseg	ends
	end

