; exported
.globl _dw_operation
.globl _dw_reset
+ .globl _dw_transaction
.globl _dw_lpr
.globl _dw_lpr_close
.area .common
+_dw_transaction:
+ pshs cc,y ; save caller
+ orcc #0x50 ; stop interrupts
+ ldy 5,s ; Y = number of bytes to send
+ beq out@ ; no byte to write - leave
+ jsr DWWrite ; send to DW
+ ldx 7,s ; X is receive buffer
+ ldy 9,s ; Y = number of bytes to receive
+ beq out@ ; no bytes to send - leave
+ jsr DWRead ; read in that many bytes
+ bcs frame@ ; C set on framing error
+ bne part@ ; Z zet on all bytes received
+out@ ldx #0 ; no error
+ puls cc,y,pc ; return
+frame@ ldx #-1 ; frame error
+ puls cc,y,pc ; return
+part@ ldx #-2 ; not all bytes received!
+ puls cc,y,pc ; return
+
_dw_reset:
; maybe reinitalise PIA here?
; and send DW_INIT request to server?