changeset 2773:ce3dba57003b lwtools-port

boot_dw now uses dwinit.asm. dwinit.asm updated for Arduino
author Boisy Pitre <boisy.pitre@nuance.com>
date Wed, 23 Jan 2013 14:54:29 -0600
parents bfe3de781ddf
children 1868fbf470e7
files level1/modules/boot_dw.asm level1/modules/dwinit.asm level1/modules/dwread.asm level1/modules/dwwrite.asm
diffstat 4 files changed, 36 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/level1/modules/boot_dw.asm	Tue Jan 22 19:14:52 2013 -0600
+++ b/level1/modules/boot_dw.asm	Wed Jan 23 14:54:29 2013 -0600
@@ -58,24 +58,8 @@
 *   Exit:  Carry Clear = OK, Set = Error
 *          B = error (Carry Set)
 HWInit                   
-* Set up DDR for side B
-*               ldx       #PIA1Base           get base address of PIA
-*               ldb       3,x
-*               andb      #%11111011
-*               stb       3,x
-*               lda       #%11111010
-*               sta       2,x
-*               orb       #%00000100
-*               stb       3,x
+               use       dwinit.asm
 
-* Set up DDR for side A
-*               ldb       1,x
-*               andb      #%11111011
-*               stb       1,x                 $FF20 is now Data Direction Register
-*               lda       #%11111110          data direction bits (1=out, 0=in)
-*               sta       ,x                  tell HW
-*               orb       #%00000100          reset $FF20 to I/O register
-*               stb       1,x                 $FF20 is now Data Direction Register
 HWTerm         clrb      
                rts       
 
--- a/level1/modules/dwinit.asm	Tue Jan 22 19:14:52 2013 -0600
+++ b/level1/modules/dwinit.asm	Wed Jan 23 14:54:29 2013 -0600
@@ -4,8 +4,26 @@
 *    Initialize DriveWire for CoCo Bit Banger
 
 DWInit
-			pshs		a,x
-	ifdef PIA1Base
+               IFNE     ARDUINO
+
+* setup PIA PORTA (read)
+               clr       $FF51
+               clr       $FF50
+               lda       #$2C
+               sta       $FF51
+
+* setup PIA PORTB (write)
+               clr       $FF53
+               lda       #$FF
+               sta       $FF52
+               lda       #$2C
+               sta       $FF53
+               rts
+
+               ELSE
+
+               pshs      a,x
+               IFDEF     PIA1Base
                ldx       #PIA1Base           $FF20
                clr       1,x                 clear CD
                lda       #%11111110
@@ -13,5 +31,7 @@
                lda       #%00110100
                sta       1,x
                lda       ,x
-	endc
-               puls		a,x,pc
+               ENDC
+               puls       a,x,pc
+
+               ENDC
--- a/level1/modules/dwread.asm	Tue Jan 22 19:14:52 2013 -0600
+++ b/level1/modules/dwread.asm	Wed Jan 23 14:54:29 2013 -0600
@@ -20,20 +20,19 @@
           IFNE ARDUINO
 * Note: this is an optimistic routine. It presumes that the server will always be there, and
 * has NO timeout fallback. It is also very short and quick.
-DWRead    clra                          ; clear Carry (no framing error)
+DWRead    clra                       ; clear Carry (no framing error)
           pshs   u,x,cc              ; preserve registers
           leau   ,x
           ldx    #$0000
-loop@     tst    $FF51                  ; check for CA1 bit (1=Arduino has byte ready)
-          bpl    loop@                  ; loop if not set
-          ldb    $FF50                  ; clear CA1 bit in status register
-          stb    ,u+                    ; save off acquired byte
-          abx                           ; update checksum
+loop@     tst    $FF51               ; check for CA1 bit (1=Arduino has byte ready)
+          bpl    loop@               ; loop if not set
+          ldb    $FF50               ; clear CA1 bit in status register
+          stb    ,u+                 ; save off acquired byte
+          abx                        ; update checksum
           leay   ,-y
           bne    loop@
-
-          leay      ,x                  ; return checksum in Y
-          puls      cc,x,u,pc        ; restore registers and return
+          leay   ,x                  ; return checksum in Y
+          puls   cc,x,u,pc           ; restore registers and return
 
           ELSE
 
--- a/level1/modules/dwwrite.asm	Tue Jan 22 19:14:52 2013 -0600
+++ b/level1/modules/dwwrite.asm	Wed Jan 23 14:54:29 2013 -0600
@@ -24,10 +24,9 @@
 loop@     tst       $FF53              ; check status register
           bpl       loop@              ; until CB1 is set by Arduino, continue looping
           tst       $FF52              ; clear CB1 in status register
-          leay      -1,y                ; decrement byte counter
-          bne       txByte              ; loop if more to send
-
-          puls      a,pc                ; restore registers and return
+          leay      -1,y               ; decrement byte counter
+          bne       txByte             ; loop if more to send
+          puls      a,pc               ; restore registers and return
 
           ELSE