+################### transfer #####################
+
+mode_transfer:
+ move.b #0x40,(0xa1000b).l
+ move.b #0x40,(0xa10005).l
+
+ move.l (transfer_mode,pc),d0
+ tst.l d0
+ bne 0f
+ lea (txt_ready_send,pc),a0
+ bra 1f
+0:
+ lea (txt_ready_recv,pc),a0
+1:
+ move.l #13,d0
+ move.l #13,d1
+ move.l #0x8000,d2
+ jsr print
+
+wait_tl_low0:
+ move.b (0xa10005),d0
+ btst.b #4,d0
+ bne wait_tl_low0
+
+ menu_text txt_working, 13, 13, 0
+
+ lea 0xa10005,a1
+ move.l (transfer_addr,pc),a0
+ move.l (transfer_len,pc),d2
+
+ move.l (transfer_mode,pc),d0
+ tst.l d0
+ bne transfer_recv
+
+transfer_send:
+ move.b #0x4f,(0xa1000b).l
+
+tr_send_loop:
+ move.b (a0),d1
+ and.b #0x0f,d1
+
+wait_tl_low1:
+ move.b (a1),d0
+ btst.b #4,d0
+ bne wait_tl_low1
+
+ move.b d1,(a1) /* clears TH and writes data */
+
+ move.b (a0)+,d1
+ lsr.b #4,d1
+ bset.b #6,d1 /* prepare TH */
+
+wait_tl_hi1:
+ move.b (a1),d0
+ btst.b #4,d0
+ beq wait_tl_hi1
+
+ move.b d1,(a1)
+ subq.l #1,d2
+ bne tr_send_loop
+
+ move.b #0,(0xa1000b).l
+ bra return_to_main
+
+transfer_recv:
+ move.b #0,(a1) /* clear TH */
+
+tr_recv_loop:
+wait_tl_low2:
+ move.b (a1),d0
+ btst.b #4,d0
+ bne wait_tl_low2
+
+ move.b #0x40,(a1) /* set TH */
+ move.b d0,d1
+ and.b #0x0f,d1
+
+wait_tl_hi2:
+ move.b (a1),d0
+ btst.b #4,d0
+ beq wait_tl_hi2
+
+ move.b #0,(a1) /* clear TH */
+ lsl.b #4,d0
+ or.b d0,d1
+ move.b d1,(a0)+
+
+ subq.l #1,d2
+ bne tr_recv_loop
+
+ move.b #0,(0xa1000b).l
+ bra return_to_main
+