changeset 2714:8399491c0821 lwtools-port

Reworked sources so that serial polling for the atari works.
author Boisy Pitre <boisy.pitre@nuance.com>
date Thu, 26 Jul 2012 09:56:22 -0500
parents 37d3ee1458b6
children bb027e636315
files defs/atari.d level1/atari/modules/vtio.asm level1/modules/clock.asm level1/modules/clock2_dw3.asm level1/modules/dw3.asm level1/modules/dwread.asm level1/modules/dwwrite.asm
diffstat 7 files changed, 97 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/defs/atari.d	Wed Jul 25 11:25:34 2012 -0500
+++ b/defs/atari.d	Thu Jul 26 09:56:22 2012 -0500
@@ -112,7 +112,7 @@
 * (Yes, we are stealing an existing variable that is so old it should be
 *  removed from os9defs)
 D.IRQENShdw    equ       D.WDBtDr
-D.ATARIFLAGS   equ       D.SWPage
+D.SKCTLShdw    equ       D.SWPage
 
 * The clock interrupt is driven by the unmaskable NMI.  Therefore,
 * the rbdw3 driver uses the DWIOSEMA flag in the D.ATARIFLAGS field as
@@ -270,6 +270,8 @@
 SKCTL          equ       POKEY+$0F           ;serial port and keyboard control
 SKCTL.FORECEBREAK equ       %10000000
 SKCTL.SERMODECTRLMASK equ       %01110000
+SKCTL.SERMODEOUT equ       %00100000
+SKCTL.SERMODEIN  equ       %00010000
 SKCTL.TWOTONEMODE equ       %00001000
 SKCTL.FASTPOTSCAN equ       %00000100
 SKCTL.KEYBRDSCAN equ       %00000010
--- a/level1/atari/modules/vtio.asm	Wed Jul 25 11:25:34 2012 -0500
+++ b/level1/atari/modules/vtio.asm	Thu Jul 26 09:56:22 2012 -0500
@@ -135,15 +135,15 @@
 		bcs	initex
 		
 * set POKEY to active
-		lda	#3
+		lda	#$13
 		sta	SKCTL
 
 * tell POKEY to enable keyboard scanning
-		lda	#%11000000
+		lda	#(IRQST.BREAKDOWN|IRQST.KEYDOWN)
 		pshs	cc
 		orcc	#IntMasks
-		ora	D.IRQENSHDW
-		sta	D.IRQENSHDW
+		ora	>D.IRQENSHDW
+		sta	>D.IRQENSHDW
 		puls	cc
 		sta	IRQEN
 
@@ -463,8 +463,8 @@
 
 	
 IRQPkt	equ	*
-Pkt.Flip	fcb	%11000000		flip byte
-Pkt.Mask 	fcb	%11000000		mask byte
+Pkt.Flip	fcb	(IRQST.BREAKDOWN|IRQST.KEYDOWN)		flip byte
+Pkt.Mask	fcb	(IRQST.BREAKDOWN|IRQST.KEYDOWN)		mask byte
 		fcb 	$0A		priority
 
 	
@@ -472,7 +472,15 @@
 * IRQ routine for keyboard
 *
 IRQSvc
+* check if BREAK key pressed; if so, it's a C$QUIT char
+          ldb  IRQST
+          bitb #IRQST.BREAKDOWN
+          bne  getcode
+          lda  #C$QUIT
+          bra  noctrl@
+getcode          
 		ldb	KBCODE	get keyboard code from POKEY
+gotcode
 		pshs b
 		andb	#$7F		mask out potential CTRL key
 		leax	ATASCI,pcr
@@ -517,12 +525,12 @@
 * re-enable the keyboard interrupt
 		pshs cc
           orcc #IntMasks
-		lda	D.IRQENShdw
+		lda	>D.IRQENShdw
 		tfr	a,b
-		anda	#^%11000000
-		orb	#%11000000
+		anda	#^(IRQST.BREAKDOWN|IRQST.KEYDOWN)
+		orb	#(IRQST.BREAKDOWN|IRQST.KEYDOWN)
 		sta	IRQEN
-		stb	D.IRQENShdw
+		stb	>D.IRQENShdw
 		stb	IRQEN
 		puls cc,pc
 		
--- a/level1/modules/clock.asm	Wed Jul 25 11:25:34 2012 -0500
+++ b/level1/modules/clock.asm	Thu Jul 26 09:56:22 2012 -0500
@@ -131,9 +131,8 @@
          stb   <D.TSlice  set ticks per time slice
          stb   <D.Slice   set first time slice
          IFNE  atari
-* Atari gets its clock source from the NMI
-         leax  SvcIRQ,pcr set NMI handler
-         stx   <D.NMI    
+         leax  SvcIRQ,pcr set IRQ handler
+         stx   <D.IRQ    
          ELSE
          leax  SvcIRQ,pcr set IRQ handler
          stx   <D.IRQ    
@@ -147,11 +146,20 @@
          jsr   ,y         call init entry point of Clock2
 
 * Initialize clock hardware
-          IFNE atari
-* Atari - Tell ANTIC to assert NMI on Vertical Blank
-     	lda     #$40
-     	sta     NMIEN		enable VBlank NMI
-          rts
+          IFNE  atari
+          lda   #IRQST.TIMER1
+          pshs  cc
+	  orcc	#IntMasks
+	  ora	<D.IRQENShdw
+	  sta	<D.IRQENShdw
+	  sta   IRQEN
+          lda   #%00101001
+          sta   AUDCTL
+          clr   AUDC1
+     	  lda   #$FF
+          sta   AUDF1
+          sta   STIMER
+	  puls	cc,pc
           ELSE
          ldx   #PIA0Base  point to PIA0
          clra             no error for return...
@@ -182,8 +190,22 @@
 SvcIRQ                   
          clra            
          tfr   a,dp       set direct page to zero
-         IFNE  atari
-         sta   NMIRES     clear NMI interrupt
+         IFNE atari
+         lda   IRQST      get hw byte
+         bita  #IRQST.TIMER1
+         beq   L0032      branch if interrupt occurred
+         jmp   [>D.SvcIRQ] else service other possible IRQ
+L0032
+     	 lda   #$FF
+         sta   AUDF1
+         lda   <D.IRQENShdw
+         tfr   a,b 			A = clear interrupt, B = set interrupt
+         anda  #^IRQST.TIMER1
+         orb   #IRQST.TIMER1
+         sta   IRQEN
+         stb   IRQEN
+         stb   <D.IRQENShdw
+         sta   STIMER
          ELSE
          tst   PIA0Base+3 get hw byte
          bmi   L0032      branch if sync flag on
--- a/level1/modules/clock2_dw3.asm	Wed Jul 25 11:25:34 2012 -0500
+++ b/level1/modules/clock2_dw3.asm	Thu Jul 26 09:56:22 2012 -0500
@@ -46,10 +46,6 @@
           nop
 
 SetTime   pshs      u,y,x,d
-          IFNE      atari
-          tst       D.ATARIFLAGS
-          bmi       UpdLeave
-          ENDC
           IFGT      Level-1
           ldu       <D.DWSubAddr
           ELSE
@@ -70,10 +66,6 @@
 GetTime 
           lda       #OP_TIME        Time packet
           pshs      u,y,x,d
-          IFNE      atari
-          tst       D.ATARIFLAGS
-          bmi       UpdLeave
-          ENDC
           IFGT      Level-1
           ldu       <D.DWSubAddr
           ELSE
--- a/level1/modules/dw3.asm	Wed Jul 25 11:25:34 2012 -0500
+++ b/level1/modules/dw3.asm	Thu Jul 26 09:56:22 2012 -0500
@@ -129,9 +129,7 @@
                leax      ,s                  ; point X to stack head
                ldy       #1                  ; 1 byte to retrieve
                jsr       DW$Read,u                 ; call DWRead
-               IFNE      atari-1
                beq       InstIRQ             ; branch if no error
-               ENDC
                leas      3,s                 ; error, cleanup stack (u and 1 byte from read) 
                lbra      InitEx            	 ; don't install IRQ handler
 
--- a/level1/modules/dwread.asm	Wed Jul 25 11:25:34 2012 -0500
+++ b/level1/modules/dwread.asm	Thu Jul 26 09:56:22 2012 -0500
@@ -26,19 +26,20 @@
           tfr       x,u
           ldx       #$0000
           orcc      #$50
-*          lda       D.IRQENSHDW
+*          lda       D.IRQENShdw
 *          sta       IRQEN
 *          ora       #%00100000
 * enable the serial input interrupt
           
           ldb  SERIN               read what is in the buffer
-          lda	#$13
+          lda	#SKCTL.SERMODEIN|SKCTL.KEYBRDSCAN|SKCTL.KEYDEBOUNCE
           sta	SKCTL
           sta	SKRES
 
 inloop@
-          lda       D.IRQENSHDW
-          ora       #%00100000
+          lda       >D.IRQENShdw
+          ora       #IRQEN.SERINRDY
+          sta       >D.IRQENShdw
           sta       IRQEN
           ldd       #$0000
 loop@
@@ -46,17 +47,19 @@
           beq       outtahere@
           pshs      b
           ldb       IRQST
-          bitb      #%00100000
+          bitb      #IRQST.SERINRDY
           puls      b
           bne       loop@
           ldb       SERIN
-          lda       D.IRQENSHDW
+          lda       >D.IRQENShdw
+          anda      #^IRQEN.SERINRDY
+          sta       >D.IRQENShdw
           sta       IRQEN
 * check for framing error
           lda       SKSTAT
           bpl       outtahere@	framing error
           lsla
-          bpl       outtahere@	data input overrun
+          bcc       outtahere@	data input overrun
           stb       ,u+
           abx
           leay      -1,y
@@ -319,4 +322,4 @@
           ENDC
           ENDC
           ENDC
-          ENDC
\ No newline at end of file
+          ENDC
--- a/level1/modules/dwwrite.asm	Wed Jul 25 11:25:34 2012 -0500
+++ b/level1/modules/dwwrite.asm	Thu Jul 26 09:56:22 2012 -0500
@@ -20,57 +20,68 @@
 * Based on the hipatch source for the Atari and translated
 * into 6809 assembly language by Boisy G. Pitre.
 *
-RMSEND    equ       %11101111
-SKSEND    equ       %00100011
-MSKSEND   equ       %00010000
-IMSEND    equ       %00010000
-IMSCPL    equ       $08
 DWWrite
           andcc     #^$01               ; clear carry to assume no error
           pshs      d,cc
 ; setup pokey
-          lda       #$28
-          sta       AUDCTL
+*          lda       #$28
+*          sta       AUDCTL
 *          lda       #$A0
-          lda       #$A8
-          sta       AUDC4
-* short delay before send
-          clra
-shortdelay@
-          deca
-          bne       shortdelay@
+*          lda       #$A8
+*          sta       AUDC4
+* delay before send
+          pshs      y
+          ldy       #50
+delay@
+          leay      -1,y
+          bne       delay@
+          puls      y
           orcc      #$50                ; mask interrupts
-          lda	     #SKSEND        	; set pokey to transmit data mode
+; set pokey to transmit data mode
+          lda		#SKCTL.SERMODEOUT|SKCTL.KEYBRDSCAN|SKCTL.KEYDEBOUNCE
           sta	     SKCTL
           sta	     SKRES
-          lda       D.IRQENSHDW
-          ora       #MSKSEND
+          lda       >D.IRQENSHDW
+          ora       #IRQEN.SEROUTNEEDED
+          sta       >D.IRQENSHDW
           sta       IRQEN
+*          bsr       somedelay
           lda       ,x+
           sta       SEROUT
           leay      -1,y
           beq       ex@
 byteloop@
           lda       ,x+
-          ldb       #IMSEND
+          ldb       #IRQST.SEROUTNEEDED
 * NOTE: Potential infinite loop here!
 waitloop@
           bitb      IRQST
           bne       waitloop@
-          ldb       #RMSEND
+          ldb       >D.IRQENSHDW
+          andb      #^IRQEN.SEROUTNEEDED
           stb       IRQEN
-          ldb       D.IRQENSHDW
-          orb       #MSKSEND
+          ldb       >D.IRQENSHDW
           stb       IRQEN
           sta       SEROUT
           leay      -1,y
           bne       byteloop@
 ex@
-          lda       #IMSCPL
+          lda       #IRQST.SEROUTDONE
 wt        bita      IRQST	; wait until transmit complete
           bne       wt
+          bsr       somedelay
           puls      cc,d,pc
 
+
+somedelay
+          pshs      y
+          ldy       #20
+delay@
+          leay      -1,y
+          bne       delay@
+          puls      y,pc
+
+
           ELSE
           IFNE BECKER