; TachyonLink Receive routine
;
; note: disables interrupts
;
TachyonLink_Receive:
	di
	ld e,0
TachyonLink_Receive_Wait:
	in a,(0)
	rra
	jr c,TachyonLink_Receive_Wait
	ld a,2
	out (0),a
	call TachyonLink_Pause
	xor a
	out (0),a
	ld b,4
	;Ready to receive
TachyonLink_Receive_Loop:
	in a,(0)
	rra
	jr c,TachyonLink_Receive_Loop
	;The clock went low...store data
	in a,(0)
	rra
	rra
	rr e
TachyonLink_Receive_Wait2:
	in a,(0)
	rra
	jr nc,TachyonLink_Receive_Wait2
	;The clock went high
	in a,(0)
	rra
	rra
	rr e
	djnz TachyonLink_Receive_Loop
	ld a,e
	ret
TachyonLink_Pause:
	ex (sp),hl
	ex (sp),hl
	push bc
	pop bc
	ret
.end

