+ jp (hl)
+
+;--------------
+;---- SEND ---- 8 bits in a
+;-------------- destr:bcdehl
+send:
+ ld c,a
+ ld b,8+1 ;bits to send
+ jr checksend
+sendloop:
+ rr c ;bit to send (in cf)
+ ld a,D0LD1H ;0: lower white
+ jr nc,sendbit
+ ld a,D0HD1L ;1: lower red
+sendbit:
+ out (7),a ;lower one (send bit)
+ ld de,TIMEOUT
+waitacksend:
+ cal checklink ;other calc must lower other whire
+ jr nz,waitacksend
+checksend:
+ ld a,D0HD1H ;ok to raise both
+ out (7),a
+ ld de,TIMEOUT
+finishsend:
+ cal checklink
+ cp %11 ;both raised (by other calc)
+ jr nz,finishsend
+ dnz sendloop ;repeat for all bits
+ .db $F6 ;or NN ;nc
+LinkFailed:
+ scf ;c=error
+ ret
+
+;--------------
+;---- RECV ---- 8 bits to a
+;-------------- destr:bcdehl
+receive:
+ halt ;&&&
+ ld de,TIMEOUT
+ cal checklink
+ jr z,receive