Mercurial > hg > Members > kono > nitros9-code
changeset 2723:22bdfbe8bc68 lwtools-port
Optimized dw3.asm routines for Atari and fixed crash in OP_SERPOLL mode. dwread routine now properly returns Carry or Negative set.
author | Boisy Pitre <boisy.pitre@nuance.com> |
---|---|
date | Mon, 30 Jul 2012 17:31:30 -0500 |
parents | 82b12ff069d7 |
children | 05b648103e78 |
files | level1/modules/dw3.asm level1/modules/dwread.asm level1/modules/dwwrite.asm |
diffstat | 3 files changed, 62 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- 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.DWStat @@ -280,6 +280,9 @@ lbne CkSSig ;had to lbra lbra IRQExit ;had to lbra +bad + leas 2,s ; error, cleanup stack 2 + lbra IRQExit2 ; don't reset error count on the way out ; **** IRQ ENTRY POINT IRQSvc equ * @@ -311,9 +314,8 @@ leax ,s ; point X to stack head ldy #2 ; 2 bytes to retrieve jsr DW$Read,u ; call DWRead - beq IRQSvc2 ; branch if no error - leas 2,s ; error, cleanup stack 2 - lbra IRQExit2 ; don't reset error count on the way out + bcs bad + bne bad ; process response IRQSvc2
--- a/level1/modules/dwread.asm Thu Jul 26 13:41:40 2012 -0500 +++ b/level1/modules/dwread.asm Mon Jul 30 17:31:30 2012 -0500 @@ -20,60 +20,70 @@ IFNE atari * ATARI SIO Version +TIMEOUT equ $1000 DWRead - clrb clear carry - pshs cc,a,x,y,u + clrb clear Carry & Zero CC flags + pshs cc,dp,a,x,y,u + tfr b,dp + setdp $00 tfr x,u ldx #$0000 - orcc #$50 + orcc #IntMasks * lda D.IRQENShdw * sta IRQEN * ora #%00100000 * enable the serial input interrupt - ldb SERIN read what is in the buffer - lda #SKCTL.SERMODEIN|SKCTL.KEYBRDSCAN|SKCTL.KEYDEBOUNCE - sta SKCTL - sta SKRES - + ldb SERIN read what is in the buffer + lda #SKCTL.SERMODEIN|SKCTL.KEYBRDSCAN|SKCTL.KEYDEBOUNCE + sta SKCTL + sta SKRES inloop@ - lda >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
--- 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