# HG changeset patch # User Boisy Pitre # Date 1343687490 18000 # Node ID 22bdfbe8bc6812120adbdfe75e8b61f0addbb368 # Parent 82b12ff069d79f8faee510370dc3e2a65a28cc1d Optimized dw3.asm routines for Atari and fixed crash in OP_SERPOLL mode. dwread routine now properly returns Carry or Negative set. diff -r 82b12ff069d7 -r 22bdfbe8bc68 level1/modules/dw3.asm --- a/level1/modules/dw3.asm Thu Jul 26 13:41:40 2012 -0500 +++ b/level1/modules/dw3.asm Mon Jul 30 17:31:30 2012 -0500 @@ -126,7 +126,7 @@ leas 1,s ; leave one byte on stack for response ; read protocol version response, 1 byte - ldx #D.DWSrvID + leax ,s ; point X to stack head ldy #1 ; 1 byte to retrieve jsr DW$Read,u ; call DWRead beq InstIRQ ; branch if no error @@ -135,7 +135,7 @@ * install ISR InstIRQ - puls a,u + puls a,u ; a has proto version from server.. not used yet ifgt Level-1 ldx D.IRQENShdw + lda D.IRQENShdw ora #IRQEN.SERINRDY - sta >D.IRQENShdw + sta D.IRQENShdw sta IRQEN - ldd #$0000 -loop@ - subd #$0001 - beq outtahere@ +* timing loop to read a character from the serial chip + ldd #TIMEOUT +loop@ subd #$0001 + beq overrun_error@ pshs b ldb IRQST bitb #IRQST.SERINRDY puls b bne loop@ ldb SERIN - lda >D.IRQENShdw + lda D.IRQENShdw anda #^IRQEN.SERINRDY - sta >D.IRQENShdw + sta D.IRQENShdw sta IRQEN * check for framing error lda SKSTAT - bpl outtahere@ framing error + bpl framing_error@ framing error lsla - bcc outtahere@ data input overrun + bcc overrun_error@ data input overrun stb ,u+ abx leay -1,y bne inloop@ - stx 4,s -bye - sta SKRES clear framing or data input overrun bits - puls cc,a,x,y,u,pc +bye@ sta SKRES clear framing or data input overrun bits + stx 5,s + puls cc,dp,a,x,y,u,pc +framing_error@ + lda ,s + ora #Carry + sta ,s + bra outtahere@ +overrun_error@ + lda ,s + anda #^Zero + sta ,s outtahere@ - sta SKRES clear framing or data input overrun bits - puls cc,a - stx 2,s - orcc #$01 - puls x,y,u,pc + lda D.IRQENShdw + anda #^IRQEN.SERINRDY + sta D.IRQENShdw + sta IRQEN + bra bye@ ELSE IFNE BECKER diff -r 82b12ff069d7 -r 22bdfbe8bc68 level1/modules/dwwrite.asm --- a/level1/modules/dwwrite.asm Thu Jul 26 13:41:40 2012 -0500 +++ b/level1/modules/dwwrite.asm Mon Jul 30 17:31:30 2012 -0500 @@ -20,9 +20,14 @@ * Based on the hipatch source for the Atari and translated * into 6809 assembly language by Boisy G. Pitre. * +SENDDELAY equ 20 + DWWrite - andcc #^$01 ; clear carry to assume no error - pshs d,cc + andcc #^Carry ; clear carry to assume no error + pshs cc,dp,d + clra + tfr a,dp + setdp $00 ; setup pokey * lda #$28 * sta AUDCTL @@ -30,20 +35,15 @@ * lda #$A8 * sta AUDC4 * delay before send - pshs y - ldy #50 -delay@ - leay -1,y - bne delay@ - puls y - orcc #$50 ; mask interrupts + bsr somedelay + orcc #IntMasks ; mask interrupts ; set pokey to transmit data mode - lda #SKCTL.SERMODEOUT|SKCTL.KEYBRDSCAN|SKCTL.KEYDEBOUNCE - sta SKCTL - sta SKRES - lda >D.IRQENSHDW + lda #SKCTL.SERMODEOUT|SKCTL.KEYBRDSCAN|SKCTL.KEYDEBOUNCE + sta SKCTL + sta SKRES + lda D.IRQENSHDW ora #IRQEN.SEROUTNEEDED - sta >D.IRQENSHDW + sta D.IRQENSHDW sta IRQEN * bsr somedelay lda ,x+ @@ -57,10 +57,10 @@ waitloop@ bitb IRQST bne waitloop@ - ldb >D.IRQENSHDW + ldb D.IRQENSHDW andb #^IRQEN.SEROUTNEEDED stb IRQEN - ldb >D.IRQENSHDW + ldb D.IRQENSHDW stb IRQEN sta SEROUT leay -1,y @@ -69,8 +69,9 @@ lda #IRQST.SEROUTDONE wt bita IRQST ; wait until transmit complete bne wt + puls cc bsr somedelay - puls cc,d,pc + puls dp,d,pc somedelay