changeset 2626:cff23b8fc512

DriveWire routines for Atari SIO
author Boisy Pitre <boisy.pitre@nuance.com>
date Sat, 25 Feb 2012 18:21:54 -0600
parents d1ea3dc90082
children 56876a9752b9
files level1/atari/modules/dwread.asm level1/atari/modules/dwwrite.asm
diffstat 2 files changed, 124 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/level1/atari/modules/dwread.asm	Sat Feb 25 18:21:54 2012 -0600
@@ -0,0 +1,76 @@
+* DWRead
+*    Receive a response from the DriveWire server.
+*    Times out if serial port goes idle for more than 1.4 (0.7) seconds.
+*    Serial data format:  1-8-N-1
+*
+* Entry:
+*    X  = starting address where data is to be stored
+*    Y  = number of bytes expected
+*
+* Exit:
+*    CC = carry set on framing error, Z set if all bytes received
+*    X  = starting address of data received
+*    Y  = checksum
+*    U is preserved.  All accumulators are clobbered
+*
+Read                    
+          clrb                     clear carry
+          pshs      cc,a,x,y,u
+          tfr       x,u
+          ldx       #$0000
+          orcc      #$50
+*          lda       D.IRQENSHDW
+*          sta       IRQEN
+*          ora       #%00100000
+* enable the serial input interrupt
+          
+          ldb       SERIN               read what is in the buffer
+
+          lda	#$13
+          sta	SKCTL
+          sta	SKRES
+
+          lda       D.IRQENSHDW
+inloop@
+          ora       #%00100000
+          sta       IRQEN
+*          lda       1,s
+loop@
+*          ldb       #2
+*loopin@
+*          decb
+*          bne       loopin@
+*          deca
+*          beq       outtahere@
+          ldb       IRQST
+          bitb      #%00100000
+          bne       loop@
+          ldb       SERIN
+          lda       D.IRQENSHDW
+          sta       IRQEN
+* check for framing error
+          lda       SKSTAT
+          bpl       outtahere@	framing error
+          lsla
+          bpl       outtahere@	data input overrun
+          stb       ,u+
+          abx
+          leay      -1,y
+          bne       inloop@
+          stx       4,s
+          bsr       CleanUp
+          puls      cc,a,x,y,u,pc
+outtahere@
+          clr       SKRES          clear framing or data input overrun bits
+          bsr       CleanUp
+          puls      cc,a
+          stx       2,s
+          orcc      #$01
+          puls      x,y,u,pc
+          
+CleanUp   lda       #$40
+          lda	#$23
+          sta	SKCTL
+          sta	SKRES
+*          sta       AUDC4	reset POKEY
+          rts
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/level1/atari/modules/dwwrite.asm	Sat Feb 25 18:21:54 2012 -0600
@@ -0,0 +1,48 @@
+* Write
+*    Send a packet to the DriveWire server.
+*    Serial data format:  1-8-N-1
+*
+* Entry:
+*    X  = starting address of data to send
+*    Y  = number of bytes to send
+*
+* Exit:
+*    X  = address of last byte sent + 1
+*    Y  = 0
+*    All others preserved
+*
+SKSEND    equ   $23
+MSKSEND   equ   %00010000
+Write        
+          pshs      d,cc
+          orcc      #$50
+*          lda	    #SKSEND
+*          sta	    SKCTL
+*          sta	    SKRES
+          lda       D.IRQENSHDW
+byteloop@
+          ora       #%00001000
+          sta       IRQEN
+          lda       ,x+
+          sta       SEROUT
+waitloop@
+          ldb       IRQST
+          bitb      #%00001000
+          bne       waitloop@
+          lbsr      Wait
+          lda       D.IRQENSHDW
+          sta       IRQEN
+          leay      -1,y
+          bne       byteloop@
+ex@
+          clrb
+          puls      cc,d,pc
+
+Wait
+          pshs      x
+          ldx       #$100
+wait@          
+          leax      -1,x
+          bne       wait@
+          puls      x,pc
+          
\ No newline at end of file