Mercurial > hg > Members > kono > nitros9-code
changeset 2231:27f07aa0bca0
Updated modules to use Darren Atkinson's latest changes to low level read/write routines
author | boisy |
---|---|
date | Sun, 12 Apr 2009 18:48:24 +0000 |
parents | 236cbc2d2dc8 |
children | 445fe18a92a6 |
files | level1/modules/boot_dw3.asm level1/modules/clock2_dw3.asm level1/modules/dwdefs.d level1/modules/dwread.asm level1/modules/dwwrite.asm level1/modules/rbdw3.asm |
diffstat | 6 files changed, 350 insertions(+), 460 deletions(-) [+] |
line wrap: on
line diff
--- a/level1/modules/boot_dw3.asm Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/boot_dw3.asm Sun Apr 12 18:48:24 2009 +0000 @@ -97,22 +97,20 @@ lbsr DWWrite send it to server * Get 256 bytes of sector data ldx blockloc,u - lda #255 + ldy #256 bsr DWRead read bytes from server bcs ReadEr branch if framing error - cmpd #256 - bne ReadEr2 + bne ReadEr2 * Send two byte checksum pshs y leax ,s ldy #2 lbsr DWWrite - lda #255 + ldy #1 bsr DWRead leas 2,s bcs ReadEx - cmpd #1 bne ReadEr2 ldb ,s beq ReadEx
--- a/level1/modules/clock2_dw3.asm Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/clock2_dw3.asm Sun Apr 12 18:48:24 2009 +0000 @@ -51,9 +51,8 @@ jsr 6,u puls a * Consider the following optimization -* ldx #D.Year - leax D.Year,y Note: Y = 0 after returning from XMT56K - lda #255 + ldx #D.Year + ldy #$0005 jsr 3,u UpdLeave puls x,y,u,pc
--- a/level1/modules/dwdefs.d Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/dwdefs.d Sun Apr 12 18:48:24 2009 +0000 @@ -10,6 +10,10 @@ nam dwdefs ttl DriveWire Definitions File +* Addresses +BBOUT equ $FF20 +BBIN equ $FF22 + * Opcodes OP_NOP equ $00 No-Op OP_RESET1 equ $FE Server Reset
--- a/level1/modules/dwread.asm Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/dwread.asm Sun Apr 12 18:48:24 2009 +0000 @@ -1,293 +1,244 @@ - IFNE BAUD38400 - -****************************************************************************** -* COCO 38400 BAUD BIT-BANGER RECEIVER -****************************************************************************** +******************************************************* +* +* 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 +* 4/12/2009 by Darren Atkinson * -* WAITS FOR A SPECIFIED TIMEOUT PERIOD UNTIL A START-BIT APPEARS ON THE -* BIT-BANGER INPUT. DATA RECEPTION IS INITIATED IF A START-BIT APPEARS -* BEFORE THE TIMEOUT PERIOD EXPIRES. THE SERIAL DATA FORMAT MUST BE: -* 1 START BIT, 8 DATA BITS, NO PARITY, 1..2 STOP BITS. +* 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 * -* DATA RECPEPTION TERMINATES WHEN: -* - A PERIOD OF 4 MS ELLAPSES WITHOUT A NEW START BIT -* - A FRAMING ERROR IS DETECTED. -* -* ON ENTRY: -* X = ADDRESS FOR DATA STORAGE -* A = TIMEOUT VALUE (125 = APPROX ONE SECOND) -* -* ON EXIT: -* Y = DATA CHECKSUM -* D = NUMBER OF BYTES RECEIVED -* X AND U ARE PRESERVED -* CC.CARRY IS SET ONLY IF A FRAMING ERROR WAS DETECTED -* -****************************************************************************** -BBIN EQU $FF22 ; BIT-BANGER INPUT ADDRESS -BUFBAS EQU 1 ; OFFSET TO STORAGE ADDRESS ON STACK + + + IFNE BAUD38400 +******************************************************* +* 38400 bps using 6809 code and timimg +******************************************************* + +DWRead clra ; clear Carry (no framing error) + deca ; clear Z flag, A = timeout msb ($ff) + tfr cc,b + pshs u,x,dp,b,a ; preserve registers, push timeout msb + orcc #$50 ; mask interrupts + tfr a,dp ; set direct page to $FFxx + setdp $ff + leau ,x ; U = storage ptr + ldx #0 ; initialize checksum + adda #2 ; A = $01 (serial in mask), set Carry -DWRead -RCV38K CLRB ; CLEAR CARRY FLAG (NO FRAMING ERROR) - PSHS U,X,CC ; PRESERVE REGISTERS - ORCC #$50 ; MASK INTERRUPTS - TFR D,Y ; SET Y TO INITIAL TIMEOUT COUNTER - LEAU ,X ; POINT U TO STORAGE BUFFER - LDX #0 ; INITIALIZE CHECKSUM - LDA #1 ; A = SERIAL INPUT MASK - -WAIT1 LEAY ,Y ; TEST TIMEOUT COUNTER - BEQ FINISH ; BRANCH IF TIMEOUT HAS EXPIRED -WAIT2 BITA BBIN ; CHECK FOR START BIT - BEQ BSTART ; BRANCH IF START BIT DETECTED - LEAY -1,Y ; DECREMENT TIMEOUT COUNTER - BITA BBIN ; CHECK FOR START BIT - BNE WAIT1 ; LOOP IF STILL NO START BIT +* Wait for a start bit or timeout +rx0010 bcc rxExit ; exit if timeout expired + ldb #$ff ; init timeout lsb +rx0020 bita <BBIN ; check for start bit + beq rxByte ; branch if start bit detected + subb #1 ; decrement timeout lsb + bita <BBIN + beq rxByte + bcc rx0020 ; loop until timeout lsb rolls under + bita <BBIN + beq rxByte + addb ,s ; B = timeout msb - 1 + bita <BBIN + beq rxByte + stb ,s ; store decremented timeout msb + bita <BBIN + bne rx0010 ; loop if still no start bit -BSTART LDY #BBIN ; POINT Y TO BIT BANGER INPUT REGISTER - LEAU ,U ; 4 CYCLE DELAY - LDB #$7F ; INITIALIZE B FOR SHIFT COUNTER -RDLOOP TST ,Y++ ; 9 CYCLE DELAY - LDA ,--Y ; READ DATA BIT - LSRA ; SHIFT DATA INTO CARRY - RORB ; ROTATE INTO BYTE ACCUMULATOR - BCS RDLOOP ; LOOP UNTIL 8 DATA BITS HAVE BEEN READ +* Read a byte +rxByte leay ,-y ; decrement request count + ldd #$ff80 ; A = timeout msb, B = shift counter + sta ,s ; reset timeout msb for next byte +rx0030 exg a,a + nop + lda <BBIN ; read data bit + lsra ; shift into carry + rorb ; rotate into byte accumulator + lda #$01 ; prep stop bit mask + bcc rx0030 ; loop until all 8 bits read - STB ,U+ ; STORE RECEIVED BYTE - ABX ; ACCUMULATE CHECKSUM - CLRA ; DO THE EQUIVALENT OF.. - INCA ; ..LDA #1 USING 4 CYCLES - ANDA ,Y ; CHECK FOR THE STOP BIT - LDY #128 ; SET TIMEOUT COUNTER TO 4MS - TSTA ; IF STOP BIT IS GOOD THEN.. - BNE WAIT2 ; ..GO WAIT FOR NEXT BYTE + stb ,u+ ; store received byte to memory + abx ; update checksum + ldb #$ff ; set timeout lsb for next byte + anda <BBIN ; read stop bit + beq rxExit ; exit if framing error + leay ,y ; test request count + bne rx0020 ; loop if another byte wanted + lda #$03 ; setup to return SUCCESS -FINISH INCA ; A=1 IF FRAMING ERROR, 2 OTHERWISE - ORA ,S ; SETS CARRY BIT IN CC VALUE ON.. - STA ,S ; ..STACK IF FRAMING ERROR DETECTED - LEAY ,X ; RETURN CHECKSUM IN Y - TFR U,D ; CALCULATE NUMBER.. - SUBD BUFBAS,S ; ..OF BYTES RECEIVED - PULS CC,X,U,PC ; RESTORE REGISTERS AND RETURN +* Clean up, set status and return +rxExit leas 1,s ; remove timeout msb from stack + inca ; A = status to be returned in C and Z + ora ,s ; place status information into the.. + sta ,s ; ..C and Z bits of the preserved CC + leay ,x ; return checksum in Y + puls cc,dp,x,u,pc ; restore registers and return + setdp $00 + ELSE IFNE H6309-1 -** -** Rev 3 Notes: -** -** For CoCo 1,2 or 3 -** 6809 Timing -** No Read Count in Receiver -** +******************************************************* +* 57600 (115200) bps using 6809 code and timimg +******************************************************* + +DWRead clra ; clear Carry (no framing error) + deca ; clear Z flag, A = timeout msb ($ff) + tfr cc,b + pshs u,x,dp,b,a ; preserve registers, push timeout msb + orcc #$50 ; mask interrupts + tfr a,dp ; set direct page to $FFxx + setdp $ff + leau ,x ; U = storage ptr + ldx #0 ; initialize checksum + lda #$01 ; A = serial in mask + bra rx0030 ; go wait for start bit + +* Read a byte +rxByte leau 1,u ; bump storage ptr + leay ,-y ; decrement request count + lda <BBIN ; read bit 0 + lsra ; move bit 0 into Carry + ldd #$ff20 ; A = timeout msb, B = shift counter + sta ,s ; reset timeout msb for next byte + rorb ; rotate bit 0 into byte accumulator +rx0010 lda <BBIN ; read bit (d1, d3, d5) + lsra + rorb + bita 1,s ; 5 cycle delay + bcs rx0020 ; exit loop after reading bit 5 + lda <BBIN ; read bit (d2, d4) + lsra + rorb + leau ,u + bra rx0010 + +rx0020 lda <BBIN ; read bit 6 + lsra + rorb + leay ,y ; test request count + beq rx0050 ; branch if final byte of request + lda <BBIN ; read bit 7 + lsra + rorb ; byte is now complete + stb -1,u ; store received byte to memory + abx ; update checksum + lda <BBIN ; read stop bit + anda #$01 ; mask out other bits + beq rxExit ; exit if framing error + +* Wait for a start bit or timeout +rx0030 bita <BBIN ; check for start bit + beq rxByte ; branch if start bit detected + bita <BBIN ; again + beq rxByte + ldb #$ff ; init timeout lsb +rx0040 bita <BBIN + beq rxByte + subb #1 ; decrement timeout lsb + bita <BBIN + beq rxByte + bcc rx0040 ; loop until timeout lsb rolls under + bita <BBIN + beq rxByte + addb ,s ; B = timeout msb - 1 + bita <BBIN + beq rxByte + stb ,s ; store decremented timeout msb + bita <BBIN + beq rxByte + bcs rx0030 ; loop if timeout hasn't expired + bra rxExit ; exit due to timeout + +rx0050 lda <BBIN ; read bit 7 of final byte + lsra + rorb ; byte is now complete + stb -1,u ; store received byte to memory + abx ; calculate final checksum + lda <BBIN ; read stop bit + anda #$01 ; mask out other bits + ora #$02 ; return SUCCESS if no framing error + +* Clean up, set status and return +rxExit leas 1,s ; remove timeout msb from stack + inca ; A = status to be returned in C and Z + ora ,s ; place status information into the.. + sta ,s ; ..C and Z bits of the preserved CC + leay ,x ; return checksum in Y + puls cc,dp,x,u,pc ; restore registers and return + setdp $00 -****************************************************************************** -* COCO 57600 / 115.2K BAUD BIT-BANGER RECEIVER -****************************************************************************** -* -* WAITS FOR A SPECIFIED TIMEOUT PERIOD UNTIL A START-BIT APPEARS ON THE -* BIT-BANGER INPUT. DATA RECEPTION IS INITIATED IF A START-BIT APPEARS -* BEFORE THE TIMEOUT PERIOD EXPIRES. THE SERIAL DATA FORMAT MUST BE: -* 1 START BIT, 8 DATA BITS, NO PARITY, 1..2 STOP BITS. -* -* DATA RECPEPTION TERMINATES WHEN: -* - A PERIOD OF APPROX 5.5 MS (2.75 MS) ELLAPSES WITHOUT A NEW START-BIT -* - A FRAMING ERROR IS DETECTED. -* -* ON ENTRY: -* X = START ADDRESS FOR DATA STORAGE -* A = TIMEOUT VALUE (182 = APPROX ONE SECOND @ 0.89 MHZ) -* -* ON EXIT: -* Y = DATA CHECKSUM -* D = ACTUAL NUMBER OF BYTES RECEIVED -* X AND U ARE PRESERVED -* CC.CARRY IS SET ONLY IF A FRAMING ERROR WAS DETECTED -* -****************************************************************************** -BBIN EQU $FF22 ; BIT-BANGER INPUT ADDRESS -BCTR EQU 1 ; OFFSET TO BIT LOOP COUNTER ON STACK -RCVSTA EQU 2 ; OFFSET TO CC VALUE ON THE STACK -BUFBAS EQU 4 ; OFFSET TO STORAGE ADDRESS ON STACK - -DWRead -RCV56K CLRB ; CLEAR CARRY FLAG (NO FRAMING ERROR) - PSHS U,X,DP,CC ; PRESERVE REGISTERS - STA ,--S ; STORE INITIAL TIMEOUT DURATION - LDD #$01FF ; A = SERIAL INPUT MASK, B = $FF - ORCC #$50 ; MASK INTERRUPTS - TFR B,DP ; SET DIRECT PAGE TO $FFXX - SETDP $FF ; INFORM ASSEMBLER OF NEW DP VALUE - LEAU ,X ; POINT U TO STORAGE ADDRESS - LDX #0 ; INITIALIZE CHECKSUM - BRA WAIT1 ; GO WAIT FOR A START BIT - -BSTART LEAU 1,U 5 \ 11 ; ADVANCE THE STORAGE PTR - CLR ,S 6 / ; RESET TIMEOUT MSB TO 1 + ELSE +******************************************************* +* 57600 (115200) bps using 6309 native mode +******************************************************* - LDB <BBIN 4 \ ; BIT 0 - LSRB 2 | - RORB 2 | 15 - LDA #3 2 | - STA BCTR,S 5 / - -BLOOP LDA <BBIN 4 \ ; BITS 1,3 AND 5 - LSRA 2 | 15 - RORB 2 | - DEC BCTR,S 7 / - - LDA <BBIN 4 \ ; BITS 2,4 AND 6 - LSRA 2 | - RORB 2 | 16 - LDA BCTR,S 5 | - BNE BLOOP 3 / - - LDA <BBIN 4 \ ; BIT 7 - LSRA 2 | - RORB 2 | 16 - ABX 3 | ; ACCUMULATE CHECKSUM - STB -1,U 5 / ; PUT BYTE INTO STORAGE - - LDA <BBIN 4 \ ; STOP BIT - ANDA #1 2 | 9 ; MASK OUT ALL OTHER BITS (1-7) - BEQ FINISH 3 / ; BRANCH IF FRAMING ERROR - -WAIT1 BITA <BBIN 4 \ 7 ; TWO RAPID TESTS FOR NEXT START BIT - BEQ BSTART 3 / - BITA <BBIN 4 \ - BEQ BSTART 3 | 9 - LDB #$FF 2 / ; INIT TIMEOUT LSB - -WAIT2 BITA <BBIN 4 \ - BEQ BSTART 3 | 9 - SUBB #1 2 / ; DECREMENT TIMEOUT LSB - BITA <BBIN 4 \ - BEQ BSTART 3 | 10 - BCC WAIT2 3 / ; LOOP UNTIL TIMEOUT LSB < 0 - - BITA <BBIN 4 \ - BEQ BSTART 3 | 11 - LDB ,S 4 / ; GET TIMEOUT MSB - BITA <BBIN 4 \ - BEQ BSTART 3 | 9 - SUBB #1 2 / ; DECREMENT TIMEOUT MSB - BITA <BBIN 4 \ - BEQ BSTART 3 | 11 - STB ,S 4 / ; STORE TIMEOUT MSB - BITA <BBIN 4 \ - BEQ BSTART 3 | 10 - BCC WAIT1 3 / ; LOOP IF TIMEOUT NOT EXPIRED +DWRead clrb ; clear Carry (no framing error) + decb ; clear Z flag, B = $FF + pshs u,x,dp,cc ; preserve registers + orcc #$50 ; mask interrupts +* ldmd #1 ; requires 6309 native mode + tfr b,dp ; set direct page to $FFxx + setdp $ff + leay -1,y ; adjust request count + leau ,x ; U = storage ptr + tfr 0,x ; initialize checksum + lda #$01 ; A = serial in mask + bra rx0030 ; go wait for start bit -FINISH INCA ; IF FRAMING ERROR THEN A=1 ELSE A=2 - ORA RCVSTA,S ; SET CARRY BIT IN CC VALUE ON.. - STA RCVSTA,S ; ..THE STACK ONLY IF FRAMING ERROR - LEAY ,X ; RETURN CHECKSUM IN Y - TFR U,D ; CALCULATE ACTUAL NUMBER.. - SUBD BUFBAS,S ; ..OF BYTES RECEIVED - LEAS 2,S ; POP TIMEOUT AND BIT LOOP COUNTERS - PULS CC,DP,X,U,PC ; RESTORE REGISTERS AND RETURN - SETDP $00 - - ELSE - -** Rev 4 Notes: -** -** For CoCo 2 or 3 -** 6309 Native Mode -** No Read Count in Receiver -** - -****************************************************************************** -* COCO 57600 / 115.2K BAUD BIT-BANGER RECEIVER -****************************************************************************** -* -* WAITS FOR A SPECIFIED TIMEOUT PERIOD UNTIL A START-BIT APPEARS ON THE -* BIT-BANGER INPUT. DATA RECEPTION IS INITIATED IF A START-BIT APPEARS -* BEFORE THE TIMEOUT PERIOD EXPIRES. THE SERIAL DATA FORMAT MUST BE: -* 1 START BIT, 8 DATA BITS, NO PARITY, 1..2 STOP BITS. -* -* DATA RECPEPTION TERMINATES WHEN: -* - A PERIOD OF APPROX 5.5 MS (2.75 MS) ELLAPSES WITHOUT A NEW START-BIT -* - A FRAMING ERROR IS DETECTED. -* -* ON ENTRY: -* X = START ADDRESS FOR DATA STORAGE -* A = TIMEOUT VALUE (183 = APPROX ONE SECOND @ 0.89 MHZ) -* -* ON EXIT: -* Y = DATA CHECKSUM -* D = ACTUAL NUMBER OF BYTES RECEIVED -* X AND U ARE PRESERVED -* E AND F ARE CLOBBERED -* CC.CARRY IS SET ONLY IF A FRAMING ERROR WAS DETECTED -* -****************************************************************************** -BBIN EQU $FF22 ; BIT-BANGER INPUT ADDRESS -RCVSTA EQU 0 ; OFFSET TO CC VALUE ON THE STACK -BUFBAS EQU 1 ; OFFSET TO STORAGE ADDRESS ON STACK +* Read a byte +rxByte sexw ; 4 cycle delay + ldw #$006a ; shift counter and timing flags + clra ; clear carry so next will branch +rx0010 bcc rx0020 ; branch if even bit number (15 cycles) + nop ; extra (16th) cycle +rx0020 lda <BBIN ; read bit + lsra ; move bit into carry + rorb ; rotate bit into byte accumulator + lda #0 ; prep A for 8th data bit + lsrw ; bump shift count, timing bit to carry + bne rx0010 ; loop until 7th data bit has been read + incw ; W = 1 for subtraction from Y + inca ; A = 1 for reading bit 7 + anda <BBIN ; read bit 7 + lsra ; move bit 7 into carry, A = 0 + rorb ; byte is now complete + stb ,u+ ; store received byte to memory + abx ; update checksum + subr w,y ; decrement request count + inca ; A = 1 for reading stop bit + anda <BBIN ; read stop bit + bls rxExit ; exit if completed or framing error -DWRead -RCV56K CLRB ; CLEAR CARRY FLAG (NO FRAMING ERROR) - PSHS U,X,CC ; PRESERVE REGISTERS - LDU #BBIN ; POINT U TO BIT BANGER INPUT - TFR A,F ; COPY INTITAL TIMEOUT TO F - LDD #$01FF ; A = SERIAL IN MASK, B = TIMEOUT LSB - LEAY ,X ; POINT Y TO STORAGE ADDRESS - LDX #0 ; INITIALIZE CHECKSUM - ORCC #$50 ; MASK INTERRUPTS -* LDMD #1 ; REQUIRES 6309 NATIVE MODE - BRA WAIT1 ; GO WAIT FOR A START BIT - -BSTART SEXW 4 \ ; 4-CYCLE DELAY (CLOBBERS D) - LDW #$005A 4 | 11 ; PREP SHIFT COUNTER / TIMING FLAGS - BRA BSAMP 3 / ; ENTER THE LOOP - -BLOOP BCC BSAMP 3 ; BRANCH IF A 15-CYCLE BIT - NOP 1 ; ONE MORE FOR A 16-CYCLE BIT -BSAMP LDA ,U 4 \ ; SAMPLE DATA BIT - LSRA 1 | ; SHIFT INTO CARRY - RORB 1 | 12 ; ROTATE INTO BYTE ACCUMULATOR - NOP 1 | ; DELAY CYCLE - LSRW 2 | ; BUMP THE SHIFT COUNTER / TIMING FLAGS - BNE BLOOP 3 / ; LOOP UNTIL BIT 6 HAS BEEN SAMPLED - LEAU ,U 4 ; CONSUME 4 CYCLES (16 TOTAL FOR BIT 6) +* Wait for a start bit or timeout +rx0030 clrw ; initialize timeout counter +rx0040 bita <BBIN ; check for start bit + beq rxByte ; branch if start bit detected + addw #1 ; bump timeout counter + bita <BBIN + beq rxByte + bcc rx0040 ; loop until timeout rolls over + lda #$03 ; setup to return TIMEOUT status - LDA ,U 4 \ ; BIT 7 - LSRA 1 | - RORB 1 | 15 - STB ,Y+ 5 | ; PUT BYTE INTO STORAGE - ABX 1 | ; ACCUMULATE CHECKSUM - LDD #$01FF 3 / ; A = SERIAL IN MASK, B = TIMEOUT LSB - - ANDA ,U 4 \ 7 ; STOP BIT - BEQ FINISH 3 / ; BRANCH IF FRAMING ERROR - -WAIT1 BITA ,U 4 \ 7 ; TWO RAPID TESTS FOR NEXT START BIT - BEQ BSTART 3 / -WAIT2 BITA ,U 4 \ - BEQ BSTART 3 | 9 - SUBB #1 2 / ; DECREMENT TIMEOUT LSB - BITA ,U 4 \ - BEQ BSTART 3 | 10 - BCC WAIT2 3 / ; LOOP UNTIL TIMEOUT LSB < 0 - - BITA ,U 4 \ 7 - BEQ BSTART 3 / - BITA ,U 4 \ - BEQ BSTART 3 | 10 - SUBF #1 3 / ; DECREMENT TIMEOUT MSB - BITA ,U 4 \ - BEQ BSTART 3 | 10 - BCC WAIT1 3 / ; LOOP IF TIMEOUT NOT EXPIRED - -FINISH INCA ; IF FRAMING ERROR THEN A=1 ELSE A=2 - ORA RCVSTA,S ; SET CARRY BIT IN CC VALUE ON.. - STA RCVSTA,S ; ..THE STACK ONLY IF FRAMING ERROR - TFR Y,D ; CALCULATE ACTUAL NUMBER.. - SUBD BUFBAS,S ; ..OF BYTES RECEIVED - LEAY ,X ; RETURN CHECKSUM IN Y - PULS CC,X,U,PC ; RESTORE REGISTERS AND RETURN +* Clean up, set status and return +rxExit beq rx0050 ; branch if framing error + eora #$02 ; toggle SUCCESS flag +rx0050 inca ; A = status to be returned in C and Z + ora ,s ; place status information into the.. + sta ,s ; ..C and Z bits of the preserved CC + leay ,x ; return checksum in Y + puls cc,dp,x,u,pc ; restore registers and return + setdp $00 ENDC ENDC +
--- a/level1/modules/dwwrite.asm Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/dwwrite.asm Sun Apr 12 18:48:24 2009 +0000 @@ -1,192 +1,134 @@ - IFNE BAUD38400 -** -** Rev Notes: -** -** For CoCo 1 -** 38400 bps -** 6809 Timing @ 0.89 MHz -** - -****************************************************************************** -* COCO 38400 BAUD BIT-BANGER TRANSMITTER -****************************************************************************** +******************************************************* +* +* DWWrite +* Send a packet to the DriveWire server. +* Serial data format: 1-8-N-1 +* 4/12/2009 by Darren Atkinson * -* TRNSMITS A SPECIFIED NUMBER OF DATA BYTES THROUGH THE BIT-BANGER PORT -* AT HIGH SPEED. ALL OF THE DATA IS SENT IN A SINGLE BURST, NO HANDSHAKING -* IS PROVIDED. THE TRANSMISSION FORMAT IS: -* 1 START BIT, 8 DATA BITS, NO PARITY, 1 STOP BIT. +* Entry: +* X = starting address of data to send +* Y = number of bytes to send * -* ON ENTRY: -* X = ADDRESS OF DATA TO TRANSMIT -* Y = NUMBER OF BYTES TO TRANSMIT -* -* ON EXIT: -* X = ADDRESS OF LAST BYTE TRANSMITTED + 1 -* Y = 0 -* A, B AND U ARE PRESERVED +* Exit: +* X = address of last byte sent + 1 +* Y = 0 +* All others preserved * -****************************************************************************** -BBOUT EQU $FF20 ; BIT-BANGER OUTPUT ADDRESS + + + IFNE BAUD38400 +******************************************************* +* 38400 bps using 6809 code and timimg +******************************************************* -DWWrite -XMT38K PSHS U,D,CC ; PRESERVE REGISTERS - ORCC #$50 ; MASK INTERRUPTS - LDU #BBOUT ; POINT U TO BIT BANGER OUTPUT REGISTER - FCB $8C ; SKIP NEXT INSTRUCTION - -OUTBYT STB ,--U ; TRANSMIT STOP BIT (RESTORES BUMPED U) - LEAU ,U+ ; 6 CYCLE DELAY (U UNCHANGED) - LDA #8 ; INITIALIZE LOOP COUNTER - LDB ,X+ ; GET BYTE TO TRANSMIT - LSLB ; BIT 7->CARRY .. BIT 0->B.1 .. '0'->B.0 - ROLB ; BIT 7 -> B.0 .. BIT 0->B.2 .. '0'->B.1 +DWWrite pshs u,d,cc ; preserve registers + orcc #$50 ; mask interrupts + ldu #BBOUT ; point U to bit banger out register + lda 3,u ; read PIA 1-B control register + anda #$f7 ; clear sound enable bit + sta 3,u ; disable sound output + fcb $8c ; skip next instruction -WRLOOP STB ,U++ ; TRANSMIT A BIT (BUMPING U) - TST ,--U ; 9 CYCLE DELAY (RESTORES BUMPED U) - RORB ; MOVE NEXT BIT INTO POSITION - DECA ; DECREMENT LOOP COUNTER - BNE WRLOOP ; LOOP UNTIL BIT 6 HAS BEEN TRANSMITTED +txByte stb ,--u ; send stop bit + leau ,u+ + lda #8 ; counter for start bit and 7 data bits + ldb ,x+ ; get a byte to transmit + lslb ; left rotate the byte two positions.. + rolb ; ..placing a zero (start bit) in bit 1 +tx0010 stb ,u++ ; send bit + tst ,--u + rorb ; move next bit into position + deca ; decrement loop counter + bne tx0010 ; loop until 7th data bit has been sent + leau ,u + stb ,u ; send bit 7 + lda ,u++ + ldb #$02 ; value for stop bit (MARK) + leay -1,y ; decrement byte counter + bne txByte ; loop if more to send - LEAU ,U ; 4 CYCLE DELAY - STB ,U ; TRANSMIT BIT 7 - LDA ,U++ ; 7 CYCLE DELAY (BUMPING U) - LDB #$02 ; PREPARE VALUE FOR STOP BIT - LEAY -1,Y ; DECREMENT BYTES REMAINING COUNTER - BNE OUTBYT ; LOOP IF MORE TO TRANSMIT + stb ,--u ; leave bit banger output at MARK + puls cc,d,u,pc ; restore registers and return - STB ,--U ; TRANSMIT STOP BIT - PULS CC,D,U,PC ; RESTORE REGISTERS AND RETURN ELSE IFNE H6309-1 +******************************************************* +* 57600 (115200) bps using 6809 code and timimg +******************************************************* -** -** Rev 3 Notes: -** -** For CoCo 1,2 or 3 -** 6809 Timing -** No Read Count in Receiver -** +DWWrite pshs dp,d,cc ; preserve registers + orcc #$50 ; mask interrupts + ldd #$04ff ; A = loop counter, B = $ff + tfr b,dp ; set direct page to $FFxx + setdp $ff + ldb <$ff23 ; read PIA 1-B control register + andb #$f7 ; clear sound enable bit + stb <$ff23 ; disable sound output + fcb $8c ; skip next instruction + +txByte stb <BBOUT ; send stop bit + ldb ,x+ ; get a byte to transmit + nop + lslb ; left rotate the byte two positions.. + rolb ; ..placing a zero (start bit) in bit 1 +tx0020 stb <BBOUT ; send bit (start bit, d1, d3, d5) + rorb ; move next bit into position + exg a,a + nop + stb <BBOUT ; send bit (d0, d2, d4, d6) + rorb ; move next bit into position + leau ,u + deca ; decrement loop counter + bne tx0020 ; loop until 7th data bit has been sent + + stb <BBOUT ; send bit 7 + ldd #$0402 ; A = loop counter, B = MARK value + leay ,-y ; decrement byte counter + bne txByte ; loop if more to send + + stb <BBOUT ; leave bit banger output at MARK + puls cc,d,dp,pc ; restore registers and return + setdp $00 -****************************************************************************** -* COCO 57600 / 115.2K BAUD BIT-BANGER TRANSMITTER -****************************************************************************** -* -* TRNSMITS A SPECIFIED NUMBER OF DATA BYTES THROUGH THE BIT-BANGER PORT -* AT HIGH SPEED. ALL OF THE DATA IS SENT IN A SINGLE BURST, NO HANDSHAKING -* IS PROVIDED. THE TRANSMISSION FORMAT IS: -* 1 START BIT, 8 DATA BITS, NO PARITY, 1 STOP BIT. -* -* ON ENTRY: -* X = ADDRESS OF DATA TO TRANSMIT -* Y = NUMBER OF BYTES TO TRANSMIT -* -* ON EXIT: -* X = ADDRESS OF LAST BYTE TRANSMITTED + 1 -* Y = 0 -* A, B AND U ARE PRESERVED -* -****************************************************************************** -BBOUT EQU $FF20 ; BIT-BANGER OUTPUT ADDRESS + ELSE +******************************************************* +* 57600 (115200) bps using 6309 native mode +******************************************************* -DWWrite -XMT56K PSHS U,DP,D,CC ; PRESERVE REGISTERS - LDD #$04FF ; A = LOOP COUNTER, B = $FF - ORCC #$50 ; MASK INTERRUPTS - TFR B,DP ; SET DIRECT PAGE TO $FFXX - SETDP $FF ; INFORM ASSEMBLER OF NEW DP VALUE - FCB $8C ; SKIP NEXT INSTRUCTION - -OUTBYT STB <BBOUT 4 \ ; STOP BIT - LDB ,X+ 6 | ; GET NEXT BYTE FROM STORAGE - NOP 2 | 16 ; CONSUME 2 CYCLES - LSLB 2 | ; BIT 7->CARRY .. BIT 0->B.1 ..'0'->B.0 - ROLB 2 / ; BIT 7 -> B.0 .. BIT 0->B.2 ..'0'->B.1 - -ODDBIT STB <BBOUT 4 \ ; START BIT, DATA BITS 1,3 AND 5 - RORB 2 | 16 ; MOVE NEXT BIT INTO POSITION - EXG A,A 8 | ; 8-CYCLE DELAY - NOP 2 / ; MORE DELAY - - STB <BBOUT 4 \ ; DATA BITS 0,2,4 AND 6 - RORB 2 | ; MOVE NEXT BIT INTO POSITION - LEAU ,U 4 | 15 ; 4-CYCLE DELAY - DECA 2 | ; DECREMENT LOOP COUNTER - BNE ODDBIT 3 / ; LOOP UNTIL BIT 6 HAS BEEN TRANSMITTED - - STB <BBOUT 4 \ ; DATA BIT 7 - LDD #$0402 3 | 16 ; A = LOOP COUNTER, B = STOP BIT VALUE - LEAY ,-Y 6 | ; DECREMENT BYTES REMAINING COUNT - BNE OUTBYT 3 / ; LOOP IF MORE TO TRANSMIT - - STB <BBOUT ; FINAL STOP BIT - PULS CC,D,DP,U,PC ; RESTORE REGISTERS AND RETURN - SETDP $00 - - ELSE +DWWrite pshs u,d,cc ; preserve registers + orcc #$50 ; mask interrupts +* ldmd #1 ; requires 6309 native mode + ldu #BBOUT+1 ; point U to bit banger out register +1 + aim #$f7,2,u ; disable sound output + lda #8 ; counter for start bit and 7 data bits + fcb $8c ; skip next instruction -** Rev 4 Notes: -** -** For CoCo 2 or 3 -** 6309 Native Mode -** No Read Count in Receiver -** - - -****************************************************************************** -* COCO 57600 / 115.2K BAUD BIT-BANGER TRANSMITTER -****************************************************************************** -* -* TRNSMITS A SPECIFIED NUMBER OF DATA BYTES THROUGH THE BIT-BANGER PORT -* AT HIGH SPEED. ALL OF THE DATA IS SENT IN A SINGLE BURST, NO HANDSHAKING -* IS PROVIDED. THE TRANSMISSION FORMAT IS: -* 1 START BIT, 8 DATA BITS, NO PARITY, 1 STOP BIT. -* -* ON ENTRY: -* X = ADDRESS OF DATA TO TRANSMIT -* Y = NUMBER OF BYTES TO TRANSMIT -* -* ON EXIT: -* X = ADDRESS OF LAST BYTE TRANSMITTED + 1 -* Y = 0 -* A, B, E, F AND U ARE PRESERVED -* -****************************************************************************** -BBOUT EQU $FF20 ; BIT-BANGER OUTPUT ADDRESS +txByte stb -1,u ; send stop bit +tx0010 ldb ,x+ ; get a byte to transmit + lslb ; left rotate the byte two positions.. + rolb ; ..placing a zero (start bit) in bit 1 + bra tx0030 -DWWrite -XMT56K PSHS U,D,CC ; PRESERVE REGISTERS - LDU #BBOUT ; POINT U TO BIT BANGER OUTPUT - ORCC #$50 ; MASK INTERRUPTS -* LDMD #1 ; REQUIRES 6309 NATIVE MODE - BRA XSTART ; SKIP NEXT INSTRUCTION - -OUTBYT STB ,U 4 \ ; STOP BIT -XSTART LDB ,X+ 5 | ; GET NEXT BYTE FROM STORAGE - LSLB 1 | 16 ; BIT 7->CARRY .. BIT 0->B.1 ..'0'->B.0 - ROLB 1 | ; BIT 7 -> B.0 .. BIT 0->B.2 ..'0'->B.1 - LDA #8 2 | ; BIT COUNT (START BIT, DATA BITS 0-6) - BRA BSEND 3 / ; ENTER THE LOOP +tx0020 bita #1 ; even or odd bit number ? + beq tx0040 ; branch if even (15 cycles) +tx0030 nop ; extra (16th) cycle +tx0040 stb -1,u ; send bit + rorb ; move next bit into position + deca ; decrement loop counter + bne tx0020 ; loop until 7th data bit has been sent + leau ,u+ + stb -1,u ; send bit 7 + ldd #$0802 ; A = loop counter, B = MARK value + leay -1,y ; decrement byte counter + bne txByte ; loop if more to send -XLOOP BITA #1 2 ; BIT COUNTER EVEN OR ODD? - BEQ BSEND 3 ; BRANCH IF EVEN (15-CYCLE BIT) - NOP 1 ; ONE MORE FOR A 16-CYCLE BIT -BSEND STB ,U 4 \ ; BIT OUTPUT - RORB 1 | ; ROTATE NEXT BIT INTO POSITION - NOP 1 | 10 ; DELAY CYCLE - DECA 1 | ; DECREMENT BIT COUNTER - BNE XLOOP 3 / ; LOOP UNTIL BIT 6 HAS BEEN SAMPLED - LEAU ,U++ 6 ; CONSUME 6 CYCLES (16 TOTAL FOR BIT 6) + stb -1,u ; final stop bit + puls cc,d,u,pc ; restore registers and return - STB ,U 4 \ ; BIT 7 OUTPUT - LDB #2 2 | ; PREPARE STOP BIT - NOP 1 | 15 ; DELAY CYCLE - LEAY -1,Y 5 | ; DECREMENT BYTES REMAINING COUNT - BNE OUTBYT 3 / ; LOOP IF MORE TO TRANSMIT - - STB ,U ; FINAL STOP BIT - PULS CC,D,U,PC ; RESTORE REGISTERS AND RETURN ENDC ENDC + +
--- a/level1/modules/rbdw3.asm Tue Apr 07 21:34:44 2009 +0000 +++ b/level1/modules/rbdw3.asm Sun Apr 12 18:48:24 2009 +0000 @@ -211,10 +211,9 @@ * Get 256 bytes of sector data ldx 5,s ldx PD.BUF,x get buffer pointer into X - lda #255 + ldy #$0100 jsr 3,u bcs ReadEr1 - cmpd #256 bne ReadEr1 pshs y leax ,s @@ -223,10 +222,9 @@ * Get error code byte leax ,s - lda #255 + ldy #$0001 jsr 3,u bcs ReadEr0 branch if we timed out - cmpd #0001 bne ReadEr0 puls d tfr a,b transfer byte to B (in case of error) @@ -300,12 +298,10 @@ jsr 6,u * Await acknowledgement from server on receipt of sector -* ldy #$0001 - lda #255 leax ,s + ldy #$0001 jsr 3,u read ack byte from server bcs WritEx0 - cmpd #$0001 bne WritEx0 puls d tsta