changeset 1729:7bdc60c48533

Additional Dragon changes from Phill Harvey-Smith
author boisy
date Wed, 17 Nov 2004 01:24:21 +0000
parents 843c3687eabd
children a28e465269b9
files level1/modules/boot_d64.asm level1/modules/clock.asm level1/modules/ddisk.asm level1/modules/defsfile.dragon level1/modules/drvr51.asm level1/modules/kbvdio.asm level1/modules/makefile.dragon rules.mak
diffstat 8 files changed, 207 insertions(+), 108 deletions(-) [+]
line wrap: on
line diff
--- a/level1/modules/boot_d64.asm	Wed Nov 17 01:22:14 2004 +0000
+++ b/level1/modules/boot_d64.asm	Wed Nov 17 01:24:21 2004 +0000
@@ -16,7 +16,7 @@
 * Disassembled 1900/00/00 00:05:56 by Disasm v1.5 (C) 1988 by RML
 
          ifp1
-		 use 	defsfile
+		 use 	defsfile.dragon
          endc
 
 		IFNE	DragonAlpha
--- a/level1/modules/clock.asm	Wed Nov 17 01:22:14 2004 +0000
+++ b/level1/modules/clock.asm	Wed Nov 17 01:24:21 2004 +0000
@@ -82,7 +82,7 @@
 	ldx	R$X,u		address of caller's time packet
 	ldu	#D.Time		destination address
 	ldb	<D.SysTsk	destination is in system map
-	bsr	STime.Mv	get time packet (ignore errors)
+	lbsr	STime.Mv	get time packet (ignore errors)
 	else	
 	ldx	R$X,u
 	ldd	,x
--- a/level1/modules/ddisk.asm	Wed Nov 17 01:22:14 2004 +0000
+++ b/level1/modules/ddisk.asm	Wed Nov 17 01:24:21 2004 +0000
@@ -26,13 +26,22 @@
 *	to a 3rd PIA mapped at FF24 to FF27, this PIA also has it's
 *	inturrupt lines connected to the CPU's FIRQ.
 *
+* 2004-11-15, P.Harvey-Smith.
+*	Fixed bug in inturrupt handling code that was making the 
+*	Dragon Alpha crash if a disk was accessed with no disk 
+*	in the drive. As the Alpha is using a simulated NMI disable
+* 	we have to ensure that the NMI enabling routine has completed
+*	BEFORE isuing a command to the disk controler, or if the 
+* 	inturrupt happens in the middle of the enable routine it 
+*	causes the machine to crash !
+*
          nam   DDisk
          ttl   Dragon Floppy driver
 
 * Disassembled 02/04/21 22:37:46 by Disasm v1.6 (C) 1988 by RML
 
          ifp1
-         use   defsfile
+         use   defsfile.dragon
          endc
 
 		IFNE	DragonAlpha
@@ -62,6 +71,13 @@
 SECREG		EQU		DPSECREG+IO	; Sector register
 DATAREG		EQU		DPDATAREG+IO	; Data register
 
+; Disk IO bitmasks
+
+NMIEn    	EQU		NMIEnA
+WPCEn    	EQU   	WPCEnA
+SDensEn  	EQU   	SDensEnA
+MotorOn  	EQU   	MotorOnA 
+
 		ELSE
 		
 DPPIADA		EQU		DPPIA1DA
@@ -85,13 +101,14 @@
 SECREG		EQU		DPSECREG+IO	; Sector register
 DATAREG		EQU		DPDATAREG+IO	; Data register
 
-		ENDC
+; Disk IO bitmasks
 
-; DskCmd Masks
-NMIEn    	EQU		%00100000 
-WPCEn    	EQU   	%00010000 
-MotorOn  	EQU   	%00000100 
-SDensEn  	EQU   	%00001000 
+NMIEn    	EQU		NMIEnD
+WPCEn    	EQU   	WPCEnD
+SDensEn  	EQU   	SDensEnD
+MotorOn  	EQU   	MotorOnD
+
+		ENDC
 
 * Disk Commands
 FrcInt   	EQU   	%11010000 
@@ -150,6 +167,12 @@
          lbra  Term		; Terminate device
 		 
 
+IRQPkt   fcb   $00            Normal bits (flip byte)
+         fcb   $01            Bit 1 is interrupt request flag (Mask byte)
+         fcb   10             Priority byte
+
+IRQFlag	 FCB   0
+
 * Init
 *
 * Entry:
@@ -195,6 +218,15 @@
          lda   #$7E				; $7E = JMP
          sta   >D.XSWI
 		 
+		 pshs	y
+		 leax	IRQPkt,PC		; point at IRQ definition packet
+		 leay	IRQFlag,pcr
+		 tfr	y,d
+		 leay	IRQHandler,pcr
+		 os9	F$IRQ
+		 puls	y
+		 
+		 
          ldd   #$0100			; Request a page of system ram
          pshs  u				; used to verify writes
          os9   F$SRqMem 
@@ -205,6 +237,10 @@
          clrb  
 Return   rts   
 
+IRQHandler
+		inc		$8000
+		rts
+
 * GetStat
 *
 * Entry:
@@ -242,7 +278,17 @@
 *    CC = carry set on error
 *    B  = error code
 *
-Read     lda   #$91			; Retry count
+Read     
+		pshs	a,x
+		lda   	<PD.Drv,y
+		cmpa	#1
+		bne		readxxx
+	    ldx		#$55aa
+		
+readxxx
+		 puls	a,x
+
+		 lda   #$91			; Retry count
          cmpx  #$0000		; LSN ?
          bne   L0096		; No : Just do read,
          bsr   L0096		; Yes : do read and copy disk params
@@ -328,14 +374,15 @@
          ldy   #$FFFF
          lda   #NMIEn+MotorOn	; Enable NMI, and turn motor on
          ora   >DrivSel,u		; mask in drives
-         ORB   >SideSel,U 			* Set up Side		 
-         stb   <DPCmdReg		; issue command to controler 
+         ORB   >SideSel,U 		; Set up Side		 
          
 		 IFNE	DragonAlpha		; Turn on drives & NMI
 		 lbsr	AlphaDskCtl
 		 ELSE
          sta   >DskCtl
 		 ENDC
+		 		 
+         stb   <DPCmdReg		; issue command to controler 
 		 
 		 rts  
 		 
@@ -488,7 +535,7 @@
          LDX   >CDrvTab,U 
          CMPD  #0                 	; Skip calculation of track 0
          BEQ   SeekT1 
-         CMPD  1,X               	; Has an illegal LSN been
+         CMPD  DD.TOT+1,X          	; Has an illegal LSN been
          BLO   SeekT2 
 E.Sect   COMB
          LDB   #E$Sect 
@@ -543,8 +590,8 @@
 SeekT11  STB   >SecReg 				; Write sector number to controler
          LBSR  Delay 
          CMPB  >SecReg 
-         BNE   SeekT11 
-		 
+         BNE   SeekT11  			
+
 SeekTS   LDB   <V.Trak,X   			; Entry point for SS.WTrk command
          STB   >TrkReg 
          TST   >Settle,U   			; If settle has been flagged then wait for settle
@@ -655,7 +702,9 @@
          beq   Delay3
          lda   #$F0
          sta   >D.DskTmr	;>$006F
-         bra   FDCCmdWait
+         lda   #$1
+		 sta   IRQFlag	
+		 bra   FDCCmdWait
 
 FDCCmdMotorOn    
  		 lda   #MotorOn		; Turn on motor
@@ -736,9 +785,9 @@
 ;Start drive motors
 StartMotor    
 		 pshs  x,b,a
-         lda   >D.DskTmr			; if timer = 0 then wait for motors to
-         bne   SpinUp				; spin up
-         lda   #MotorOn
+         lda   >D.DskTmr			; if timer <> 0 then skip as motor already on
+         bne   SpinUp				
+         lda   #MotorOn				; else spin up
 		 
          IFNE	DragonAlpha
 		 bsr	AlphaDskCtl
@@ -746,12 +795,13 @@
          sta   >DskCtl
 		 ENDC
 		 
-		 ldx   #$A000
+		 ldx   #$A000				; Wait a little while for motors to get up to speed
 StartMotorLoop    
 		 nop   
          nop   
          leax  -1,x
          bne   StartMotorLoop
+		 
 SpinUp   lda   #$F0					; Start external motor timer
          sta   >D.DskTmr			; external to driver
          puls  pc,x,b,a
@@ -776,86 +826,50 @@
 ; Takes byte that would be output to $FF48, reformats it and 
 ; outputs to Alpha AY-8912's IO port, which is connected to 
 ; Drive selects, motor on and enable precomp.
+; This code now expects Alpha NMI/DDEN etc codes, as defined
+; at top of this file (and dgndefs). The exception to this is
+; the drive number is still passed in the bottom 2 bits and
+; converted with a lookup table.
+; We do not need to preserve the ROM select bit as this code
+; operates in RAM only mode.
 ; Also sets NMIFlag.
 
-AlphaDskCtlB	
-		pshs	A
-		tfr		b,a
-		bsr		AlphaDskCtl
-		puls	A
-		rts
+
+DrvTab	FCB		Drive0A,Drive1A,Drive2A,Drive3A
 
 AlphaDskCtl	
-		PSHS	A,B,CC
-
-		anda	#~DDenMask	; Dragon Alpha has DDen perminently enabled
+		PSHS	x,A,B,CC
 
 		PSHS	A	
-		ANDA	#NMIMask	; mak out nmi enable bit
+		ANDA	#NMIEn		; mask out nmi enable bit
 		sta		>NMIFlag,u	; Save it for later use
 		
-		lda		,s
-		anda	#EnpMask	; Extract enp mask
-		pshs	a			; save it
-		
-		lda		1,s
-		ANDA	#DSMask		; Mask Out drive select bits
-		
-; Shift a bit in B left, a times, to convert drive number 
-; to DS bit.
-		
-		ldb		#$01
-ShiftNext
-		cmpa	#$00		; Done all shifts ?
-		beq		ShiftDone
-		lslb
-		deca
-		bra		ShiftNext
+		lda		,s			; Convert drives
+		anda	#%00000011	; mask out drive number
+		leax	DrvTab,pcr	; point at table
+		lda		a,x			; get bitmap
+		ldb		,s
+		andb	#%11111100	; mask out drive number
+		stb		,s
+		ora		,s			; recombine
+		sta		,s
 		
-ShiftDone
-		lda		1,s
-		anda	#MotorMask	; Extract motor bit
-		cmpa	#MotorMask	; Motor on ?
-		beq		MotorIsOn	; Yes leave it on.
-
-		clrb				; No zero out DS bits
-
-MotorIsOn
-		ora		,s			; Recombine with ENP bit.
-		leas	1,s			; drop off stack
-		lsla
-		lsla	
-		pshs	b
-		ora		,s
-		leas	1,s
-				
-		pshs	a			; Save motor/drive select state
-		ldb		PIADA		; get BDIR/BC1/Rom select
-		andb	#$FC		; Mask out BCDIR/BC1, so we don't change other bits
-		pshs	b			; save mask
 		
 		lda		#AYIOREG	; AY-8912 IO register
-		sta		PIADB		; Output to PIA
-		orb		#AYREGLatch	; Latch register to modify
-		stb		PIADA
+		sta		PIA2DB		; Output to PIA
+		ldb		#AYREGLatch	; Latch register to modify
+		stb		PIA2DA
 		
-		clrb
-		orb		,s			; Restore saved bits
-		stb		PIADA		; Idle AY
+		clr		PIA2DA		; Idle AY
 		
-		lda		1,s			; Fetch saved Drive Selects
-		sta		PIADB		; output to PIA
+		lda		,s+			; Fetch saved Drive Selects
+		sta		PIA2DB		; output to PIA
 		ldb		#AYWriteReg	; Write value to latched register
-		orb		,s			; Restore saved bits
-		stb		PIADA		; Set register
-		
-		clrb
-		orb		,s			; Restore saved bits
-		stb		PIADA		; Idle AY
-		
-		leas	3,s			; drop saved bytes
-		
-		PULS	A,B,CC
+		stb		PIA2DA		; Set register
+
+		clr		PIA2DA		; Idle AY
+				
+		PULS	x,A,B,CC
 		RTS
 
 		ENDC
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/level1/modules/defsfile.dragon	Wed Nov 17 01:24:21 2004 +0000
@@ -0,0 +1,2 @@
+         use   ../defsfile.dragon
+
--- a/level1/modules/drvr51.asm	Wed Nov 17 01:22:14 2004 +0000
+++ b/level1/modules/drvr51.asm	Wed Nov 17 01:24:21 2004 +0000
@@ -11,6 +11,9 @@
 *
 *          2003/09/22  Rodney Hamilton
 * Recoded fcb arrays, added labels & some comments
+*		   2004/11/15  P.Harvey-Smith.
+* Added code to turn off the drives on the Dragon Alpha.
+*
 
          nam   drvr51
          ttl   Driver for The 51 column by 24 line video display
@@ -18,7 +21,7 @@
 * Disassembled 02/07/06 21:17:23 by Disasm v1.6 (C) 1988 by RML
 
          ifp1
-         use   defsfile
+         use   defsfile.dragon
          endc
 
 tylg     set   Drivr+Objct   
@@ -156,7 +159,14 @@
          deca  
          sta   >D.DskTmr
          bne   L00CB
-         sta   >$FF48
+
+		 IFNE	DragonAlpha		; Turn off all drives
+		 lbsr	AlphaDskCtl
+		 ELSE
+         sta   >DskCtl
+		 ENDC
+
+;         sta   >$FF48
 L00CB    lbsr  L04E5
          jmp   [>D.AltIRQ]
 L00D2    pshs  x,b
@@ -1053,6 +1063,36 @@
 	fcb $12,$10,$11,$20	dc2 dle dc1 space
 	fcb $0D,$00,$1B		ENTER CLEAR esc
 
+		IFNE	DragonAlpha
+; Warning this version of AlphaDskCtl, does NOT convert DragonDos
+; $FF48 codes to alpha ones, they must be in Alpha format.
+; This is only used for timed turn off of drive motors.
+; We do not need to preserve the ROM select bit as this code
+; operates in RAM only mode.
+
+AlphaDskCtl	
+		pshs	a,b,cc
+
+		pshs	a
+		lda		#AYIOREG	; AY-8912 IO register
+		sta		PIA2DB		; Output to PIA
+		ldb		#AYREGLatch	; Latch register to modify
+		stb		PIA2DA
+		
+		CLR		PIA2DA		; Idle AY
+		
+		lda		,s+			; Fetch saved Drive Selects
+		sta		PIA2DB		; output to PIA
+		ldb		#AYWriteReg	; Write value to latched register
+		stb		PIA2DA		; Set register
+		
+		clr		PIA2DA		; Idle AY
+				
+		PULS	A,B,CC
+		RTS
+
+		ENDC
+
          emod
 eom      equ   *
          end
--- a/level1/modules/kbvdio.asm	Wed Nov 17 01:22:14 2004 +0000
+++ b/level1/modules/kbvdio.asm	Wed Nov 17 01:24:21 2004 +0000
@@ -11,6 +11,9 @@
 *
 *          2004/01/04  Rodney Hamilton
 * Recoded anonymous fcb arrays, added some comments
+*		   2004/11/15  P.Harvey-Smith.
+* Added code to turn off the drives on the Dragon Alpha.
+*
 
          nam   KBVDIO
          ttl   keyboard/video driver
@@ -18,7 +21,7 @@
 * Disassembled 02/04/21 22:37:57 by Disasm v1.6 (C) 1988 by RML
 
          ifp1
-         use   defsfile
+         use   defsfile.dragon
          endc
 
 tylg     set   Drivr+Objct   
@@ -185,12 +188,20 @@
          sta   <u003F,u
          sta   <u0040,u
          sta   <u0041,u
-L00DF    lda   >D.DskTmr
+L00DF
+		 lda   >D.DskTmr
          beq   L00ED
          deca  
          sta   >D.DskTmr
          bne   L00ED
-         sta   >$FF48
+
+		 IFNE	DragonAlpha		; Turn off all drives
+		 lbsr	AlphaDskCtl
+		 ELSE
+         sta   >DskCtl
+		 ENDC
+
+;		 sta   >$FF48
 L00ED    jmp   [>D.AltIRQ]
 L00F1    bsr   L013F
          bmi   L00DF
@@ -1204,6 +1215,40 @@
 L08E0    suba  ,s+
          bra   L08C0
 
+
+
+
+		IFNE	DragonAlpha
+
+; Warning this version of AlphaDskCtl, does NOT convert DragonDos
+; $FF48 codes to alpha ones, they must be in Alpha format.
+; This is only used for timed turn off of drive motors.
+; We do not need to preserve the ROM select bit as this code
+; operates in RAM only mode.
+
+AlphaDskCtl	
+		pshs	a,b,cc
+
+		pshs	a
+		lda		#AYIOREG	; AY-8912 IO register
+		sta		PIA2DB		; Output to PIA
+		ldb		#AYREGLatch	; Latch register to modify
+		stb		PIA2DA
+		
+		CLR		PIA2DA		; Idle AY
+		
+		lda		,s+			; Fetch saved Drive Selects
+		sta		PIA2DB		; output to PIA
+		ldb		#AYWriteReg	; Write value to latched register
+		stb		PIA2DA		; Set register
+		
+		clr		PIA2DA		; Idle AY
+				
+		PULS	A,B,CC
+		RTS
+
+		ENDC
+
          emod
 eom      equ   *
          end
--- a/level1/modules/makefile.dragon	Wed Nov 17 01:22:14 2004 +0000
+++ b/level1/modules/makefile.dragon	Wed Nov 17 01:24:21 2004 +0000
@@ -11,21 +11,21 @@
 CLOCKMESSEMU    = -aRTCMessEmu=1
 CLOCKJVEMU      = -aRTCJVEmu=1
 
-DEPENDS		= ./makefile
+DEPENDS		= ./makefile.dragon
 TPB		= $(3RDPARTY)/booters
 
-BOOTERS		= boot_1773_6ms boot_1773_30ms \
-		boot_burke boot_rampak boot_wd1002 boot_d64 boot_dalpha
+BOOTERS		= boot_d64 boot_dalpha
+
 BOOTTRACK	= rel $(BOOTERS) rel_dalpha
 KERNEL		= krn krnp2
 SYSMODS		= ioman init sysgo_dd sysgo_h0
+
 CLOCKS          = clock_60hz clock_50hz \
 		clock2_elim clock2_disto2 clock2_disto4 clock2_bnb \
                 clock2_smart clock2_harris clock2_cloud9 clock2_soft \
 		clock2_messemu clock2_jvemu clock_d64
 
 RBF		= rbf.mn \
-		rb1773.dr rb1773_scii_ff74.dr rb1773_scii_ff58.dr \
 		ddisk.dr adisk.dr \
 		ddd0_35s.dd d0_35s.dd d1_35s.dd d2_35s.dd d3_35s.dd \
 		ddd0_40d.dd d0_40d.dd d1_40d.dd d2_40d.dd \
@@ -35,7 +35,8 @@
 SCF		= scf.mn \
 		sc6551.dr vrn.dr printer.dr sio.dr sspak.dr ccio.dr \
 		co32.io co80.io \
-		nil.dd p.dd pipe.dd ssp.dd kbvdio.dr \
+		nil.dd p.dd pipe.dd ssp.dd kbvdio.dr akbvdio.dr \
+		drvr51.dr adrvr51.dr \
 		term_sio.dt term_sc6551.dt t1.dd t2_sc6551.dd t3_sc6551.dt \
 		term32.dt term80.dt term_d64.dt t1_d64.dd p1_d64.dd
 
@@ -54,18 +55,6 @@
 	$(CD) kernel; make $@
 	$(CP) kernel/$@ .
 
-boot_1773_6ms:	boot_1773.asm
-	$(AS) $< $(ASOUT)$@ $(AFLAGS) -aDNum=0 -aSTEP=0
-
-boot_1773_30ms:	boot_1773.asm
-	$(AS) $< $(ASOUT)$@ $(AFLAGS) -aDNum=0 -aSTEP=3
-
-rb1773_scii_ff74.dr:	rb1773.asm
-	$(AS) $< $(ASOUT)$@ $(AFLAGS) -aSCII=1
-
-rb1773_scii_ff58.dr:	rb1773.asm
-	$(AS) $< $(ASOUT)$@ $(AFLAGS) -aSCII=1 -aSCIIALT=1
-
 boot_d64:	boot_d64.asm
 	$(AS) $< $(ASOUT)$@ $(AFLAGS) -aDNum=0 -aSTEP=0
 
@@ -92,6 +81,8 @@
 		-aInterlv=3 -aSAS=8 -aDensity=1
 DSDD40		= -aCyls=40 -aSides=2 -aSectTrk=18 -aSectTrk0=18 \
 		-aInterlv=3 -aSAS=8 -aDensity=1
+SSDD80		= -aCyls=80 -aSides=1 -aSectTrk=18 -aSectTrk0=18 \
+		-aInterlv=3 -aSAS=8 -aDensity=1 -aD35
 DSDD80		= -aCyls=80 -aSides=2 -aSectTrk=18 -aSectTrk0=18 \
 		-aInterlv=3 -aSAS=8 -aDensity=1 -aD35
 
@@ -163,6 +154,12 @@
 rel_dalpha: rel.asm
 	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aDragon64=0 -aDragonAlpha=1
 	
+akbvdio.dr: kbvdio.asm
+	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aDragon64=0 -aDragonAlpha=1
+
+adrvr51.dr: drvr51.asm
+	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aDragon64=0 -aDragonAlpha=1
+
 
 sysgo_dd: sysgo.asm
 	$(AS) $(AFLAGS) $(ASOUT)$@ $< -aDD=1
--- a/rules.mak	Wed Nov 17 01:22:14 2004 +0000
+++ b/rules.mak	Wed Nov 17 01:24:21 2004 +0000
@@ -42,6 +42,7 @@
 OS9FORMAT	= $(OS9TOOLSDIR)/os9 format
 OS9FORMAT_SS35	= $(OS9TOOLSDIR)/os9 format -t35 -ss -dd -4
 OS9FORMAT_SS40	= $(OS9TOOLSDIR)/os9 format -t40 -ss -dd -4
+OS9FORMAT_SS80	= $(OS9TOOLSDIR)/os9 format -t80 -ss -dd -9
 OS9FORMAT_DS40	= $(OS9TOOLSDIR)/os9 format -t40 -ds -dd -4
 OS9FORMAT_DS80	= $(OS9TOOLSDIR)/os9 format -t80 -ds -dd -9
 OS9GEN		= $(OS9TOOLSDIR)/os9 gen