Mercurial > hg > Members > kono > nitros9-code
changeset 1734:b992196e2ac9
Dragon updates by Phill
author | boisy |
---|---|
date | Sat, 27 Nov 2004 15:24:02 +0000 |
parents | e6e8a44ab20a |
children | 11f38ece79ef |
files | level1/makefile.dalpha level1/makefile.dragon level1/modules/boot_d64.asm level1/modules/ddisk.asm level1/modules/ddiskdesc.asm level1/modules/makefile.dragon |
diffstat | 6 files changed, 506 insertions(+), 444 deletions(-) [+] |
line wrap: on
line diff
--- a/level1/makefile.dalpha Sat Nov 27 15:23:45 2004 +0000 +++ b/level1/makefile.dalpha Sat Nov 27 15:24:02 2004 +0000 @@ -1,6 +1,6 @@ include ../rules.mak -RELEASE = nos96809l1v030204 +RELEASE = nos96809l1v030204_dalpha BOOTFILE = bootfiles/bootfile_dalpha BOOTFILE_DS80 = bootfiles/bootfile_dalpha KERNELFILE = bootfiles/kernel_dalpha
--- a/level1/makefile.dragon Sat Nov 27 15:23:45 2004 +0000 +++ b/level1/makefile.dragon Sat Nov 27 15:24:02 2004 +0000 @@ -1,10 +1,11 @@ include ../rules.mak -RELEASE = nos96809l1v030204 +RELEASE = nos96809l1v030204_dragon BOOTFILE = bootfiles/bootfile_d64 BOOTFILE_DS80 = bootfiles/bootfile_d64 KERNELFILE = bootfiles/kernel_d64 -DIRS = cmds defs sys modules bootfiles +DIRS = cmds defs sys +#modules bootfiles DDIRS = modules bootfiles # Specify which shell should be used @@ -63,7 +64,7 @@ $(DSK360K_1): $(RM) $@ - $(OS9FORMAT_SS80) -e -dr -q $@ -n"NitrOS-9/6809 Level 1 Disk 1" + $(OS9FORMAT_DS40) -e -dr -q $@ -n"NitrOS-9/6809 Level 1 Disk 1" $(OS9GEN) $@ -d -b=$(BOOTFILE) -t=$(KERNELFILE) $(MAKDIR) $@,CMDS $(MAKDIR) $@,SYS
--- a/level1/modules/boot_d64.asm Sat Nov 27 15:23:45 2004 +0000 +++ b/level1/modules/boot_d64.asm Sat Nov 27 15:24:02 2004 +0000 @@ -10,6 +10,9 @@ * See DDisk.asm for a fuller discription of how Dragon Alpha * interface works. * +* Double sided Disk code added 2004-11-25, P.Harvey-Smith. +* +* nam Boot ttl os9 system module @@ -41,11 +44,17 @@ DPSECREG EQU DPSecRegA ; Sector register DPDATAREG EQU DPDataRegA ; Data register -CMDREG EQU DPCMDREG+IO ; command/status -TRKREG EQU DPTRKREG+IO ; Track register -SECREG EQU DPSECREG+IO ; Sector register +CMDREG EQU DPCMDREG+IO ; command/status +TRKREG EQU DPTRKREG+IO ; Track register +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 @@ -70,160 +79,215 @@ SECREG EQU DPSECREG+IO ; Sector register DATAREG EQU DPDATAREG+IO ; Data register +; Disk IO bitmasks + +NMIEn EQU NMIEnD +WPCEn EQU WPCEnD +SDensEn EQU SDensEnD +MotorOn EQU MotorOnD + ENDC -tylg set Systm+Objct -atrv set ReEnt+rev -rev set $01 - mod eom,name,tylg,atrv,start,size -u0000 rmb 2 -u0002 rmb 1 -u0003 rmb 1 -u0004 rmb 1 -NMIFlag rmb 1 -size equ . -name equ * - fcs /Boot/ - fcb $00 +StepRate EQU %00000011 + +tylg set Systm+Objct +atrv set ReEnt+rev +rev set $01 + + mod eom,name,tylg,atrv,start,size +u0000 rmb 2 +BuffPtr rmb 2 +SideSel rmb 1 ; Side select mask +CurrentTrack rmb 1 ; Current track number +NMIFlag rmb 1 ; NMI enabled flag for Alpha. +size equ . + +name equ * + fcs /Boot/ + fcb $00 -start equ * - ldx #CMdReg - clra - IFNE DragonAlpha - clr NMIFlag,u - ENDC - ldb #size -L0015 pshs a - decb - bne L0015 +start equ * + ldx #$55AA + + ldx #CMdReg + clra + + IFNE DragonAlpha + clr NMIFlag,u ; Make sure NMI turned off in Dragon Alpha + ENDC + + ldb #size +L0015 pshs a ; Clear size bytes on system stack + decb + bne L0015 - tfr s,u - ldx #CMDREG - lda #$D0 - sta ,x - lbsr L0175 - lda ,x - lda >piadb - lda #$FF - sta u0004,u - leax >NMIService,pcr - stx >$010A - lda #$7E - sta >$0109 - lda #$04 - - IFNE DragonAlpha - lbsr AlphaDskCtl - ELSE - sta >DSKCTL - ENDC + tfr s,u ; Point u to data area on s stack. + + ldx #CMDREG ; Force inturrupt + lda #FrcInt + sta ,x + lbsr Delay ; Wait for command to complete + lda ,x + lda >piadb ; Clear DRQ from WD. + + lda #$FF + sta CurrentTrack,u + leax >NMIService,pcr ; Setup NMI Handler. + stx >D.XNMI+1 + lda #$7E ; $7E=JMP + sta >D.XNMI + + lda #MotorOn ; Turn on motor + IFNE DragonAlpha + lbsr AlphaDskCtl + ELSE + sta >DSKCTL + ENDC + + ldd #$C350 ; Delay while motors spin up +MotorOnDelay + nop + nop + subd #$0001 + bne MotorOnDelay + + pshs u,x,b,a + clra + clrb + ldy #$0001 + ldx <D.FMBM + ldu <D.FMBM+2 + os9 F$SchBit + bcs L009C + exg a,b ; Make bitmap into Memory pointer + ldu $04,s + std BuffPtr,u ; Save LSN0 pointer + clrb - ldd #$C350 -L0043 nop - nop - subd #$0001 - bne L0043 - pshs u,x,b,a - clra - clrb - ldy #$0001 - ldx <D.FMBM - ldu <D.FMBM+2 - os9 F$SchBit - bcs L009C - exg a,b - ldu $04,s - std u0002,u - clrb - ldx #$0000 - bsr L00BA - bcs L009C - ldd <$18,y - std ,s - os9 F$SRqMem - bcs L009C - stu $02,s - ldu $04,s - ldx $02,s - stx u0002,u - ldx <$16,y - ldd <$18,y - beq L0095 -L0083 pshs x,b,a - clrb - bsr L00BA - bcs L009A - puls x,b,a - inc u0002,u - leax $01,x - subd #$0100 - bhi L0083 -L0095 clrb - puls b,a - bra L009E -L009A leas $04,s -L009C leas $02,s -L009E puls u,x - leas Size,s - rts -L00A3 clr ,u - clr u0004,u - lda #$05 -L00A9 ldb #$43 - pshs a - lbsr L0160 - puls a - deca - bne L00A9 - ldb #$03 - lbra L0160 -L00BA lda #$91 - cmpx #$0000 - bne L00D2 - bsr L00D2 - bcs L00C9 - ldy u0002,u - clrb -L00C9 rts -L00CA bcc L00D2 - pshs x,b,a - bsr L00A3 - puls x,b,a -L00D2 pshs x,b,a - bsr L00DD - puls x,b,a - bcc L00C9 - lsra - bne L00CA -L00DD bsr L011E - bcs L00C9 - ldx u0002,u - orcc #$50 - pshs y,dp,cc - lda #$FF - tfr a,dp - lda #$34 - sta <u0003 - lda #$37 - sta <dppiacrb - lda <dppiadb - ldb #$88 - stb <dpcmdreg - ldb #$24 + ldx #$0000 ; Read LSN0 from boot disk. + bsr ReadSec + bcs L009C ; Error : give up ! + ldd <DD.BSZ,y ; Get size of boot data from LSN0 + std ,s + os9 F$SRqMem ; Request memory + bcs L009C ; Error : give up + stu $02,s + ldu $04,s + ldx $02,s + stx BuffPtr,u + ldx <DD.BT+1,y ; Get LSN of start of boot + ldd <DD.BSZ,y ; Get size of boot. + beq L0095 ; Zero size boot ?, yes : exit +; +; At this point X=start LSN of boot area, D=size of boot +; BuffPtr,u=address to load next sector, Y=pointer to LSN0 +; + +LoadBootLoop + pshs x,b,a + clrb ; We are only interested in the number of full blocks + bsr ReadSec ; Read a sector of boot + bcs L009A ; Error : exit + puls x,b,a + inc BuffPtr,u ; Increment MSB of buffpointer, point to next page to load into + leax $01,x ; Increment sector number + subd #$0100 ; Decrement number of bytes left + bhi LoadBootLoop ; Any bytes left to load ?, yes : loop again + +L0095 clrb + puls b,a + bra L009E + +L009A leas $04,s +L009C leas $02,s +L009E puls u,x + leas Size,s ; Drop stacked vars. + rts + +; +; Reset disk heads to track 0 +; + +ResetTrack0 + clr ,u + clr CurrentTrack,u ; Zero current track + lda #$05 +L00A9 ldb #StpICmnd+StepRate ; Step in + pshs a + lbsr CommandWaitReady + puls a + deca + bne L00A9 + ldb #RestCmnd ; Restore to track 0 + lbra CommandWaitReady + +; +; Read a sector off disk. +; + +ReadSec + lda #$91 ; Retry count + cmpx #$0000 ; Reading LSN0 ? + bne ReadDataWithRetry ; No, just read sector + bsr ReadDataWithRetry ; Yes read sector + bcs ReadDataExit ; And restore Y=LSN0 pointer + ldy BuffPtr,u + clrb +ReadDataExit + rts + +ReadDataRetry + bcc ReadDataWithRetry ; Retry data read if error + pshs x,b,a + bsr ResetTrack0 ; Recal drive + puls x,b,a + +ReadDataWithRetry + pshs x,b,a + bsr DoReadData ; Try reading data + puls x,b,a + bcc ReadDataExit ; No error, return to caller + lsra ; decrement retry count + bne ReadDataRetry ; retry read on error + +DoReadData + bsr SeekTrack ; Seek to correct track + bcs ReadDataExit ; Error : exit + ldx BuffPtr,u ; Set X=Data load address + orcc #$50 ; Enable FIRQ=DRQ from WD + pshs y,dp,cc + lda #$FF ; Make DP=$FF, so access to WD regs easier + tfr a,dp + lda #$34 + sta <dppia0crb ; Disable out PIA0 IRQ <u0003 + lda #$37 + sta <dppiacrb ; Enable FIRQ + lda <dppiadb + ldb #NMIEn+MotorOn ; $24 - IFNE DragonAlpha - lbsr AlphaDskCtlB - ELSE - stb <dpdskctl - ENDIF - -L00FD sync - lda <dpdatareg - ldb <dppiadb - sta ,x+ - bra L00FD + IFNE DragonAlpha + lbsr AlphaDskCtlB + ELSE + stb <dpdskctl + ENDIF + + ldb #ReadCmnd ; Issue a read command + orb >SideSel,U ; mask in side select + stb <dpcmdreg + +ReadDataWait + sync ; Read data from controler, save + lda <dpdatareg ; in memory at X + ldb <dppiadb + sta ,x+ + bra ReadDataWait ; We break out with an NMI + +; The following block of code is needed for the Dragon Alpha, because +; we currently do not know how to disable it's NMI in hardware, +; So we check a flag here, and if set we simply return from inturrupt +; as if nothing happened ! NMIService IFNE DragonAlpha @@ -236,75 +300,116 @@ DoNMI puls cc ENDC -L0106 leas $0C,s - lda #$04 +L0106 leas R$Size,s ; Drop saved Regs from stack + lda #MotorOn + + IFNE DragonAlpha + lbsr AlphaDskCtl + ELSE + sta <dpdskctl + ENDIF - IFNE DragonAlpha - bsr AlphaDskCtl - ELSE - sta <dpdskctl - ENDIF + lda #$34 ; Re-enable inturrupts + sta <dppiacrb + ldb <dpcmdreg + puls y,dp,cc + bitb #$04 + lbeq L015A +L011A comb + ldb #$F4 + rts + +; +; Seek to a track, at this point Y still points to +; in memory copy of LSN0 (if not reading LSN0 !). +; + +SeekTrack + clr ,u + tfr x,d + cmpd #$0000 ; LSN0 ? + beq SeekCalcSkip + clr ,-s ; Zero track counter + bra L012E + +L012C inc ,s +L012E subd DD.Spt,Y ; Take sectors per track from LSN + bcc L012C ; still +ve ? keep looping + addd DD.Spt,Y ; Compensate for over-loop + puls a ; retrieve track count. - lda #$34 - sta <dppiacrb - ldb <dpcmdreg - puls y,dp,cc - bitb #$04 - lbeq L015A -L011A comb - ldb #$F4 - rts -L011E clr ,u - tfr x,d - cmpd #$0000 - beq L0137 - clr ,-s - bra L012E -L012C inc ,s -L012E subd #$0012 - bcc L012C - addb #$12 - puls a -L0137 incb - stb >SECREG - ldb u0004,u - stb >TRKREG - cmpa u0004,u - beq L0158 - sta u0004,u - sta >DATAREG - ldb #$13 - bsr L0160 - pshs x - ldx #$222E -L0152 leax -$01,x - bne L0152 - puls x -L0158 clrb - rts +; At this point the A contains the track number, +; and B contains the sector number on that track. + +SeekCalcSkip + pshs b ; Save sector number + + LDB DD.Fmt,Y ; Is the media double sided ? + LSRB + BCC DiskSide0 ; skip if not + + LSRA ; Get bit 0 into CC, and devide track by 2 + BCC DiskSide0 ; Even track no so it's on side 0 + ldb #Sid2Sel ; Odd track so on side 1, flag it + bra SetSide + +DiskSide0 + clrb +SetSide + stb >SideSel,U ; Single sided, make sure sidesel set correctly + + puls b ; Get sector number + incb + stb >SECREG + ldb CurrentTrack,u + stb >TRKREG + cmpa CurrentTrack,u + beq L0158 + sta CurrentTrack,u + sta >DATAREG + ldb #SeekCmnd+3 ; Seek command+ step rate code $13 + bsr CommandWaitReady + pshs x + + ldx #$222E ; Wait for head to settle. +SettleWait + leax -$01,x + bne SettleWait + + puls x +L0158 clrb + rts + L015A bitb #$98 bne L011A clrb rts -L0160 bsr L0173 -L0162 ldb >CMDREG - bitb #$01 - bne L0162 - rts -L016A lda #$04 + +CommandWaitReady + bsr MotorOnCmdBDelay ; Turn on motor and give command to WD +CommandWait + ldb >CMDREG ; Get command status + bitb #$01 ; finished ? + bne CommandWait ; nope : continue waiting. + rts + +MotorOnCmdB + lda #MotorOn ; Turn on motor - IFNE DragonAlpha - bsr AlphaDskCtl - ELSE - sta >DSKCTL - ENDIF + IFNE DragonAlpha + bsr AlphaDskCtl + ELSE + sta >DSKCTL + ENDIF - stb >CMDREG - rts -L0173 bsr L016A -L0175 lbsr L0178 -L0178 lbsr L017B -L017B rts + stb >CMDREG ; Give command from B + rts + +MotorOnCmdBDelay + bsr MotorOnCmdB +Delay lbsr Delay2 +Delay2 lbsr Delay3 +Delay3 rts IFNE DragonAlpha @@ -312,6 +417,12 @@ ; 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 @@ -321,79 +432,44 @@ 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 - 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 + ANDA #NMIEn ; mask out nmi enable bit + sta >NMIFlag,u ; Save it for later use -ShiftDone - lda 1,s - anda #MotorMask ; Extract motor bit - cmpa #MotorMask ; Motor on ? - beq MotorOn ; Yes leave it on. - - clrb ; No zero out DS bits - -MotorOn - 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 ,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 + 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 emod
--- a/level1/modules/ddisk.asm Sat Nov 27 15:23:45 2004 +0000 +++ b/level1/modules/ddisk.asm Sat Nov 27 15:24:02 2004 +0000 @@ -35,6 +35,13 @@ * inturrupt happens in the middle of the enable routine it * causes the machine to crash ! * +* 2004-11-24, P.Harvey-Smith. +* Fixed up so that double sided disks now work, origional +* double sided code taken from Jon Bird's pages at : +* http://www.onastick.clara.net/dragon.html and modified +* for NitrOS9. +* + nam DDisk ttl Dragon Floppy driver @@ -110,29 +117,6 @@ ENDC -* Disk Commands -FrcInt EQU %11010000 -ReadCmnd EQU %10001000 -RestCmnd EQU %00000000 -SeekCmnd EQU %00010000 -StpICmnd EQU %01000000 -WritCmnd EQU %10101000 -WtTkCmnd EQU %11110000 -Sid2Sel EQU %00000010 - -* Disk Status Bits -BusyMask EQU %00000001 -LostMask EQU %00000100 -ErrMask EQU %11111000 -CRCMask EQU %00001000 -RNFMask EQU %00010000 -RTypMask EQU %00100000 -WPMask EQU %01000000 -NotRMask EQU %10000000 - -DensMask EQU %00000001 -T80Mask EQU %00000010 - tylg set Drivr+Objct atrv set ReEnt+rev rev set $00 @@ -142,17 +126,17 @@ mod eom,name,tylg,atrv,start,size - org DrvBeg - RMB MaxDrv*DrvMem -CDrvTab rmb 2 -DrivSel rmb 1 ; Saved drive mask -Settle rmb 1 ; Head settle time -SavePIA0CRB rmb 1 ; Saved copy of PIA0 control reg b -SaveACIACmd rmb 1 ; Saved copy of ACIA command reg -BuffPtr rmb 2 ; Buffer pointer -SideSel rmb 1 ; Side select. -NMIFlag rmb 1 ; Flag for Alpha, should this NMI do an RTI ? -size equ . + org DrvBeg + RMB MaxDrv*DrvMem +CDrvTab rmb 2 +DrivSel rmb 1 ; Saved drive mask +Settle rmb 1 ; Head settle time +SavePIA0CRB rmb 1 ; Saved copy of PIA0 control reg b +SaveACIACmd rmb 1 ; Saved copy of ACIA command reg +BuffPtr rmb 2 ; Buffer pointer +SideSel rmb 1 ; Side select. +NMIFlag rmb 1 ; Flag for Alpha, should this NMI do an RTI ? +size equ . fcb $FF name equ * @@ -167,11 +151,11 @@ 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 +;IRQPkt fcb $00 Normal bits (flip byte) +; fcb $01 Bit 1 is interrupt request flag (Mask byte) +; fcb 10 Priority byte -IRQFlag FCB 0 +;IRQFlag FCB 0 * Init * @@ -183,10 +167,13 @@ * CC = carry set on error * B = error code * -Init - pshs x - ldx #$55AA +DragonDebug EQU 1 +Init + IFNE DragonDebug + pshs x ; This is here so I can find disk driver in mess + ldx #$AA55 ; by setting register breakpoint to X=$AA55 ! puls x + ENDC clra sta >D.DskTmr ; Zero motor timer @@ -216,15 +203,15 @@ leax >NMIService,pcr ; Setup NMI handler stx >D.XNMI+1 lda #$7E ; $7E = JMP - sta >D.XSWI + sta >D.XNMI - pshs y - leax IRQPkt,PC ; point at IRQ definition packet - leay IRQFlag,pcr - tfr y,d - leay IRQHandler,pcr - os9 F$IRQ - puls y +; 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 @@ -237,9 +224,9 @@ clrb Return rts -IRQHandler - inc $8000 - rts +;IRQHandler +; inc $8000 +; rts * GetStat * @@ -279,20 +266,11 @@ * B = error code * 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 - bcs L008C + bne ReadDataWithRetry ; No : Just do read, + bsr ReadDataWithRetry ; Yes : do read and copy disk params + bcs ReadDataExit ldx PD.Buf,y pshs y,x ldy >CDrvTab,u @@ -303,26 +281,28 @@ bpl L0082 clrb puls pc,y,x -L008C rts +ReadDataExit + rts ; Read Retry ReadDataRetry - bcc L0096 ; Retry entry point + bcc ReadDataWithRetry ; Retry entry point pshs x,b,a lbsr ResetTrack0 ; Reset track 0 puls x,b,a -L0096 pshs x,b,a ; Normal entry point +ReadDataWithRetry + pshs x,b,a ; Normal entry point bsr DoReadData puls x,b,a - bcc L008C + bcc ReadDataExit lsra ; Check for retry bne ReadDataRetry DoReadData lbsr SeekTrack - bcs L008C + bcs ReadDataExit ldx PD.Buf,y ; Target address for data pshs y,dp,cc ldb #ReadCmnd ; Read command @@ -337,14 +317,14 @@ lbra RetReadError ; Return read error to caller ReadDataWait - sync ; Sync to inturrupts, wait for data + sync ; Sync to inturrupts, wait for data ReadDataReady - lda <DPDataReg ; Read data from FDC - ldb <DPPIADB ; Clear PIA inturrupt status - sta ,x+ ; save data in memory - bra ReadDataWait ; do next + lda <DPDataReg ; Read data from FDC + ldb <DPPIADB ; Clear PIA inturrupt status + sta ,x+ ; save data in memory + bra ReadDataWait ; do next PrepDiskRW lda #$FF ; Make DP=$FF, to make io easier @@ -386,8 +366,10 @@ rts +; +; Restore saved iO states of peripherals. +; -* Restore saved iO states of peripherals. RestoreSavedIO lda >DrivSel,u ; Deselect drives, but leave motor on ora #MotorOn @@ -442,10 +424,11 @@ bra L0124 DoWrite lbsr SeekTrack ; Seek to correct track & sector - lbcs L008C + lbcs ReadDataExit ldx PD.Buf,y ; Get data buffer in X pshs y,dp,cc ldb #WritCmnd ; Write command + WriteTrackCmd lbsr PrepDiskRW ; Prepare for disk r/w lda ,x+ ; get byte to write @@ -507,7 +490,7 @@ ldy >BuffPtr,u tfr x,u VerifyLoop - ldx ,u ; Compare every 4th word + ldx ,u ; Compare every 4th word cmpx ,y bne VerifyErrorEnd leau 8,u @@ -521,16 +504,15 @@ puls u,y,a VerifyEnd puls pc,x,b,a - +; ; Seek to a track +; SeekTrack CLR >Settle,U ; default no settle LBSR SelectDrive ; select and start correct d TSTB BNE E.Sect - clr >SideSel,u ; Make sure old sidesel cleared. - TFR X,D LDX >CDrvTab,U CMPD #0 ; Skip calculation of track 0 @@ -544,22 +526,22 @@ SeekT2 CLR ,-S ; Calculate track number SUBD PD.T0S,Y ; subtract no. of sectors in track 0 BHS SeekT4 - ADDB PD.T0S+1,Y ; if -ve we are on track 0, so add back on again + ADDD PD.T0S,Y ; if -ve we are on track 0, so add back on again BRA SeekT3 SeekT4 INC ,S SUBD DD.Spt,X ; sectors per track for rest of disk BHS SeekT4 ; repeat, until -ve, incrementing track count - ADDB DD.Spt+1,X ; re add sectors/track to get sector number on track + ADDD DD.Spt,X ; re add sectors/track to get sector number on track ; At this point the byte on the top of the stack contains the track -; number, and D contains the sector number on that track. +; number, and B contains the sector number on that track. SeekT3 PULS A ; retrieve track count LBSR SetWPC ; set write precompensation PSHS B LDB DD.Fmt,X ; Is the media double sided ? LSRB - BCC SeekT9 ; skip if not + BCC SingleSidedDisk ; skip if not LDB PD.Sid,Y ; Is the drive double sided ? DECB BNE SetupSideMask ; yes : deal with it. @@ -568,17 +550,16 @@ LDB #E$BTyp RTS -;SeekT10 LSRA ; Media & drive are double sided -; BCC SeekT9 -; BSR SetSide -SetupSideMask - BSR SetSide ; we must always do this to ensure +SetupSideMask + BSR SetSide ; Media & drive are double sided BRA SeekT9 SingleSidedDisk clr >SideSel,U ; Single sided, make sure sidesel set correctly - -SeekT1 PSHS B + BRA SeekT9 + +SeekT1 clr >SideSel,U ; make sure sidesel is always 0 if lsn0 + PSHS B SeekT9 LDB PD.Typ,Y ; Dragon and Coco disks BITB #TYP.SBO ; count sectors from 1 no BNE SeekT8 @@ -615,14 +596,19 @@ ; Set Side2 Mask ; A contains the track number on entry -SetSide PSHS A - LSRA ; Get bit 0 into carry - BCC Side1 ; Side 1 if even track no. - LDA #Sid2Sel ; Odd track no. so side 2 - BRA Side -Side1 CLRA -Side STA >SideSel,U - PULS A,PC +SetSide LSRA ; Get bit 0 into carry & devide track no by 2 + PSHS A + BCC Side0 ; Side 0 if even track no. + LDA #Sid2Sel ; Odd track no. so side 2 + BRA Side +Side0 CLRA +Side STA >SideSel,U + PULS A,PC + +; +; Select drive and start drive motors. +; On entry A=drive number. +; SelectDrive lbsr StartMotor ; Start motor @@ -649,7 +635,10 @@ SelectDriveEnd puls pc,x,b,a +; ; Analise device status return. +; + TestForError bitb #ErrMask beq TestErrorEnd @@ -666,8 +655,10 @@ TestErrorEnd clrb rts - +; ; Return error code +; + RetErrorNotReady comb ldb #E$NotRdy @@ -692,8 +683,10 @@ comb ldb #E$Read rts - +; ; Issue a command to FDC and wait till it's ready +; + FDCCommand bsr FDCCmd FDCCmdWait @@ -702,8 +695,8 @@ beq Delay3 lda #$F0 sta >D.DskTmr ;>$006F - lda #$1 - sta IRQFlag +; lda #$1 +; sta IRQFlag,pcr bra FDCCmdWait FDCCmdMotorOn @@ -738,26 +731,31 @@ * CC = carry set on error * B = error code * -SetStat ldx PD.Rgs,y ; Retrieve request +SetStat ldx PD.Rgs,y ; Retrieve request ldb R$B,x - cmpb #SS.Reset ; dispatch valid ones + + cmpb #SS.Reset ; Restore to track 0. beq ResetTrack0 - cmpb #SS.Wtrk - beq L02C2 + cmpb #SS.Wtrk ; Write (format) a track + beq DoWriteTrack comb ldb #E$UnkSvc SetStatEnd rts -; Write track -L02C2 lbsr SelectDrive ; Select drive +; +; Write (format) a track +; + +DoWriteTrack + lbsr SelectDrive ; Select drive lda R$Y+1,x - LSRA LBSR SetSide ; Set Side 2 if appropriate LDA R$U+1,X BSR SetWPC ; Set WPC by disk type -L02D5 ldx >CDrvTab,u +;L02D5 + ldx >CDrvTab,u lbsr SeekTS ; Move to correct track bcs SetStatEnd ldx PD.Rgs,y @@ -781,8 +779,10 @@ bne ResetTrack0Loop ldb #RestCmnd ; Now issue a restore bra FDCCommand +; +;Start drive motors +; -;Start drive motors StartMotor pshs x,b,a lda >D.DskTmr ; if timer <> 0 then skip as motor already on @@ -805,8 +805,10 @@ SpinUp lda #$F0 ; Start external motor timer sta >D.DskTmr ; external to driver puls pc,x,b,a +; +; Set Write Precompensation according to media type +; -; Set Write Precompensation according to media type SetWPC PSHS A,B LDB PD.DNS,Y BITB #T80Mask ; Is it 96 tpi drive
--- a/level1/modules/ddiskdesc.asm Sat Nov 27 15:23:45 2004 +0000 +++ b/level1/modules/ddiskdesc.asm Sat Nov 27 15:24:02 2004 +0000 @@ -29,7 +29,7 @@ ENDC Density set DNS.MFM Step set STP.6ms -Cyls set 35 +Cyls set 40 Sides set 1 Verify set 1 SectTrk set 18
--- a/level1/modules/makefile.dragon Sat Nov 27 15:23:45 2004 +0000 +++ b/level1/modules/makefile.dragon Sat Nov 27 15:24:02 2004 +0000 @@ -26,12 +26,11 @@ clock2_messemu clock2_jvemu clock_d64 RBF = rbf.mn \ - 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 \ - ddd0_80d.dd d0_80d.dd d1_80d.dd d2_80d.dd \ - ddd0_d64.dd d0_d64.dd d1_d64.dd d2_d64.dd d3_d64.dd - + ddisk.dr \ + ddd0_d64.dd d0_d64.dd d1_d64.dd d2_d64.dd d3_d64.dd \ + adisk.dr \ + ddd0_dalpha.dd d0_dalpha.dd d1_dalpha.dd d2_dalpha.dd d3_dalpha.dd + SCF = scf.mn \ sc6551.dr vrn.dr printer.dr sio.dr sspak.dr ccio.dr \ co32.io co80.io \ @@ -44,7 +43,7 @@ piper.dr \ pipe.dd -ALLOBJS = $(BOOTTRACK) $(KERNEL) $(SYSMODS) $(CLOCKS) $(RBF) $(SCF) $(PIPE) +ALLOBJS = $(BOOTTRACK) $(KERNEL) $(SYSMODS) $(CLOCKS) $(RBF) $(SCF) $(PIPE) all: $(ALLOBJS) @@ -76,78 +75,58 @@ # Floppy descriptors SSDD35 = -aCyls=35 -aSides=1 -aSectTrk=18 -aSectTrk0=18 \ - -aInterlv=3 -aSAS=8 -aDensity=1 + -aInterlv=2 -aSAS=8 -aDensity=1 SSDD40 = -aCyls=40 -aSides=1 -aSectTrk=18 -aSectTrk0=18 \ - -aInterlv=3 -aSAS=8 -aDensity=1 + -aInterlv=2 -aSAS=8 -aDensity=1 DSDD40 = -aCyls=40 -aSides=2 -aSectTrk=18 -aSectTrk0=18 \ - -aInterlv=3 -aSAS=8 -aDensity=1 + -aInterlv=2 -aSAS=8 -aDensity=1 SSDD80 = -aCyls=80 -aSides=1 -aSectTrk=18 -aSectTrk0=18 \ - -aInterlv=3 -aSAS=8 -aDensity=1 -aD35 + -aInterlv=2 -aSAS=8 -aDensity=1 -aD35 DSDD80 = -aCyls=80 -aSides=2 -aSectTrk=18 -aSectTrk0=18 \ - -aInterlv=3 -aSAS=8 -aDensity=1 -aD35 - -ddd0_35s.dd: rb1773desc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD35) -aDNum=0 -aDD=1 + -aInterlv=2 -aSAS=8 -aDensity=1 -aD35 -d0_35s.dd: rb1773desc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD35) -aDNum=0 - -d1_35s.dd: rb1773desc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD35) -aDNum=1 +#Dragon 64 +#Dragon 64 Drives can be double or single sided, but assume +# that /d0 and /d1 are double sided 40 track. -d2_35s.dd: rb1773desc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD35) -aDNum=2 - -d3_35s.dd: rb1773desc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD35) -aDNum=3 - -ddd0_40d.dd: rb1773desc.asm +ddd0_d64.dd: ddiskdesc.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD40) -aDNum=0 -aDD=1 -d0_40d.dd: rb1773desc.asm +d0_d64.dd: ddiskdesc.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD40) -aDNum=0 -d0_40s.dd: rb1773desc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD40) -aDNum=0 - -d1_40d.dd: rb1773desc.asm +d1_d64.dd: ddiskdesc.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD40) -aDNum=1 -d2_40d.dd: rb1773desc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD40) -aDNum=2 - -ddd0_80d.dd: rb1773desc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD80) -aDNum=0 -aDD=1 - -d0_80d.dd: rb1773desc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD80) -aDNum=0 - -d1_80d.dd: rb1773desc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD80) -aDNum=1 - -d2_80d.dd: rb1773desc.asm +d2_d64.dd: ddiskdesc.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD80) -aDNum=2 -#Dragon 64 +d3_d64.dd: ddiskdesc.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD80) -aDNum=3 + -ddd0_d64.dd: ddiskdesc.asm +#Dragon Alpha +# Internal drives on Alpha are Single Sided 80 track. + +ddd0_dalpha.dd: ddiskdesc.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD80) -aDNum=0 -aDD=1 -d0_d64.dd: ddiskdesc.asm +d0_dalpha.dd: ddiskdesc.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD80) -aDNum=0 -d1_d64.dd: ddiskdesc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD80) -aDNum=1 +d1_dalpha.dd: ddiskdesc.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD40) -aDNum=1 -d2_d64.dd: ddiskdesc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD80) -aDNum=2 +d2_dalpha.dd: ddiskdesc.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD80) -aDNum=2 -d3_d64.dd: ddiskdesc.asm - $(AS) $< $(ASOUT)$@ $(AFLAGS) $(SSDD80) -aDNum=3 +d3_dalpha.dd: ddiskdesc.asm + $(AS) $< $(ASOUT)$@ $(AFLAGS) $(DSDD80) -aDNum=3 adisk.dr: ddisk.asm $(AS) $< $(ASOUT)$@ $(AFLAGS) -aDragonAlpha=1 + rel: rel.asm $(AS) $(AFLAGS) $(ASOUT)$@ $< -aDragon64=0 @@ -170,6 +149,10 @@ sysgo_d64: sysgo_d64.asm $(AS) $(AFLAGS) $(ASOUT)$@ $< +ddisk.dr: ddisk.asm + $(AS) $(AFLAGS) $(ASOUT)$@ $< + + clean: $(CD) kernel; make $@ $(RM) $(ALLOBJS)