home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ENTERPRS
/
C64
/
GFX
/
64HDPRO.ARC
/
FORMAT.SRC
< prev
next >
Wrap
Text File
|
2000-06-30
|
11KB
|
497 lines
;BPUT"FORMAT.SRC"
;RPUT"FORMAT.SRC"
;+++++++++++++++++++++++++++++++++
;+ INITIALIZE THE HARD DISK +
;+ +
;+ INTERFACES WITH THE BIOS FOR +
;+ HARD DRIVE.... +
;+++++++++++++++++++++++++++++++++
;
READ = $7000 ;EQUATES FOR BIOS
WRITE = READ+3
RESET = READ+6
SETPRM = READ+9
RECAL = READ+12
SEEK = READ+15
TDREDY = READ+18 ;TEST DRIVE READY
SBDIAG = READ+21 ;SECTOR BUF DIAG
DRDIAG = READ+24 ;DRIVE DIAGS
CTDIAG = READ+27 ;CONTROLLER DIAGS
FBADTK = READ+30 ;FORMAT BAD TRK
FMTTRK = READ+33 ;FORMAT TRACK
FMTDRV = READ+36 ;FORMAT DRIVE
RETPRM = READ+39 ;RETURN PARMS
;INPUT - A = DRIVE NUMBER
;OUTPUT - A = # HEADS
; X = MSB #CYLS
; Y = LSB #CYLS
RDLONG = READ+42
READSB = READ+45
WRLONG = READ+48
WRITSB = READ+51
VERIFY = READ+54
DCBPTR = READ+57 ;POINTER TO DCB
* = $6000
START = * ;BEGIN FORMAT
LDA #0 ;CLEAR THE BUFFERS
TAY
CLEARBADSECTOR STA BADSECTORS,Y
STA BADSECTORS+256,Y
STA BADSECTORS+512,Y
STA BADSECTORS+768,Y
STA RDBUF,Y
STA RDBUF+256,Y
STA WRTBUF,Y
STA WRTBUF+256,Y
INY
BNE CLEARBADSECTOR
LDA #4 ;2 TIMES # SECTORS FOR BAD SECTORS
STA BADSECTORCTR
LDA #<HEADINGMSG ;CLEAR SCREEN,ETC
JSR WRITEOUTAMSG
LDA DCBPTR
STA PTR1
STA PTRX
STA DCBPTRFORGET
LDA DCBPTR+1
STA PTR2 ;ADDRESS THE DCB
STA PTRX+1
STA DCBPTRFORGET+1
LDA #0 ;SET UP FOR DRIVE 0
JSR PUTDCBDRIVE ;SET UP DRIVE 0
JSR RESET
BCC RESETISOK ;GO IF NO ERROR
LDA #<RESETERRORMSG ;ISSUE MSG
JSR WRITEOUTAMSG
BRK
RESETISOK LDA #0 ;RESTORE DRIVE 0
JSR PUTDCBDRIVE
JSR PUTDCBMSBSECTR ;SET SECTOR
JSR PUTDCBCYLLSB ;AND CYL
LDA #11 ;INTERLEAVE, TEST SHOWS 11 GOOD
JSR PUTDCBNUMSECS
LDA #<BUFFER
JSR PUTDCBLOBUFPTR
LDA #>BUFFER
JSR PUTDCBHIBUFPTR
JSR RETPRM ;GET THE PARMS
DEY ;BACK DOWN CYLINDERS BY 1
BNE SAVETHEPARMS
DEX
SAVETHEPARMS STX CYLMSB
STX NUMCYLINDERS ;SAVE
STY NUMCYLINDERS+1
STA NUMBEROFHEADS
STY CYLLSB
LDA #16 ;SET SECTOR NUMBER TO MAX
STA SECTOR
JSR CYLINDER2SECTR ;CONVERT
LDX SECNUM ;MOVE AND PRIME
LDA SECNUM+1 ;FOR SECTOR TO SAT
LDY SECNUM+2 ;CONVERSION
STX TOTALSECTORS
STA TOTALSECTORS+1
STY TOTALSECTORS+2
JSR SECTOR2SAT ;GO CONVERT
LDA SATSEC ;SAVE FOR LATER
STA LASTSATSECTOR
LDA SATBYT
STA LASTSATBYTE
LDA SATBYT+1
STA LASTSATBYTE+1
LDA SATBIT
STA LASTSATBIT
CHECKLOWLEVEL LDA #<LOWLEVELMSG ;ASK ABOUT LOLEVEL
JSR WRITEOUTAMSG
LOWLEVELANSWER JSR $FFE4
JSR $FFD2
CMP #'N' ;NO LOW LEVEL
BEQ SETUPCOUNTERS
CMP #'Y' ;DO IT?
BNE LOWLEVELANSWER
JSR FMTDRV ;LOW LEVEL IT
BCC SETUPCOUNTERS
LDA #<LOWLEVELERRMSG ;ERROR MSG
JSR WRITEOUTAMSG
BRK
SETUPCOUNTERS = *
LDA #0
STA CYLINDERCOUNTR ;CLEAR COUNTERS
STA CYLINDERCOUNTR+1
STA HEADCOUNTER
STA SECTORCOUNTER
LDX #0
FILLBUFFER TXA
STA WRTBUF,X
STA WRTBUF+256,X
INX
BNE FILLBUFFER
LDA #147
JSR $FFD2
LDA #<INTENSIVEMSG ;WHAT KIND?
JSR WRITEOUTAMSG
INTENSEANSWER JSR $FFE4 ;GET ANSWER
CMP #'N' ;NOT INTENSIVE
BEQ NOTINTENSIVE
CMP #'Y' ;YES?
BNE INTENSEANSWER
LDX #0
.BYT $2C
NOTINTENSIVE LDX #$FF
STX INTENSIVEFLAG ;SET MODE FLAG
JSR $FFD2
FORMATDRIVE LDA #5 ;CLEAR RETRY COUNTER
STA WRTRETRYCOUNTR
STA RDRETRYCOUNTER
LDA CYLINDERCOUNTR+1
JSR HEXTOASCII ;MAKE PRINTABLE
STA $041E
STX $041F
LDA CYLINDERCOUNTR
JSR HEXTOASCII
STA $0420
STX $0421
LDA #32
STA $0422
LDA HEADCOUNTER
JSR HEXTOASCII
STA $0423
STX $0424
LDA #32
STA $0425
LDA SECTORCOUNTER
JSR HEXTOASCII
STA $0426
STX $0427
JSR SETUPDCB ;SET UP DCB
LDA INTENSIVEFLAG ;CHECK FOR INTENSE FORMAT
BNE BYPASSWRITE ;BYPASS WRITE
LDA #<WRTBUF
JSR PUTDCBLOBUFPTR
LDA #>WRTBUF
JSR PUTDCBHIBUFPTR
WRITEASECTOR JSR WRITE ;GO WRITE A BLOCK
BCC BYPASSWRITE
JSR READTHESENSE ;RETRIEVE SENSE
JSR WRITEOUTSENSE
JSR RESETFORRETRY ; SET UP FOR RETRY
DEC WRTRETRYCOUNTR
BNE WRITEASECTOR
LDA #<WRITEERRORMSG ;WRITE ERROR
JSR WRITEOUTAMSG
JSR MARKBADSECTOR ;MARK AS BAD
JMP ONTONEXTSECTOR ;GO TO NEXT SECTOR
BYPASSWRITE LDA #<RDBUF
JSR PUTDCBLOBUFPTR
LDA #>RDBUF
JSR PUTDCBHIBUFPTR
READASECTOR JSR READ
BCC ISITINTENSIVE
JSR READTHESENSE ;RETRIEVE SENSE
JSR WRITEOUTSENSE
LDA #<RDERRORMSG ;READ ERROR
READRETRY PHA ;SAVE MSG NUMBER
JSR RESETFORRETRY ;SET UP FOR RETRY
PLA ;RETRIEVE MSG NUMBER
DEC RDRETRYCOUNTER ;CHECK FOR MAX NUM
BNE READASECTOR
JSR WRITEOUTAMSG
JSR MARKBADSECTOR
JMP ONTONEXTSECTOR
ISITINTENSIVE LDA INTENSIVEFLAG ;CHECK FOR INSTENSE
BNE ONTONEXTSECTOR ;BYPASS COMPARE
LDY #0 ;SET UP FOR COMPARE
COMPARESECTORS LDA WRTBUF,Y
CMP RDBUF,Y
BNE BADCOMPARE
LDA WRTBUF+256,Y
CMP RDBUF+256,Y
BEQ COMPARENEXT
BADCOMPARE LDA #<COMPAREERRMSG
BNE READRETRY
COMPARENEXT INY
BNE COMPARESECTORS
ONTONEXTSECTOR LDX SECTORCOUNTER ;CHECK SECTOR
INX
CPX #17
BNE BUMPTHEHEAD
LDX #0
BUMPTHEHEAD STX SECTORCOUNTER ;SAVE SECTOR
BNE GOTNEWADDRESS ;GO ON IF BELOW
LDX HEADCOUNTER ;BUMP TO NEXT HEAD
INX
CPX NUMBEROFHEADS ;AT MAX?
BNE SAVEHEADCOUNT
LDX #0
SAVEHEADCOUNT STX HEADCOUNTER
BNE GOTNEWADDRESS
LDA $DC0B ;GET HRS STOP CLOCK
LDA $DC09 ;GET SECONDS
JSR HEXTOASCII
STA $410
STX $411
LDA #':'
STA $412
LDA $DC08
JSR HEXTOASCII
STX $0413
STA $0414
LDA $DC0F
AND #$7F
STA $DC0F
LDA #$00
LDX #4
SETTIMETOZERO STA $DC08,X
DEX
BPL SETTIMETOZERO
LDX CYLINDERCOUNTR ;CHECK FOR END
CPX NUMCYLINDERS
BNE BUMPCYLINDERLO
LDX CYLINDERCOUNTR+1
CPX NUMCYLINDERS+1
BEQ ENDOFFORMAT
BUMPCYLINDERLO INC CYLINDERCOUNTR ;BUMP BY ONE
BEQ BUMPCYLINDERHI
GOTNEWADDRESS JMP FORMATDRIVE
BUMPCYLINDERHI INC CYLINDERCOUNTR+1
JMP FORMATDRIVE
ENDOFFORMAT LDA #<ENDOFJOBMSG
JSR WRITEOUTAMSG
BRK
;
;+++++++++++++++++++++++++++++++++
;+ SET DCB FIELD +
;+ +
;+ INPUT - A = BYTE TO PUT +
;+ X = OFFSET IN DCB +
;+++++++++++++++++++++++++++++++++
;
PUTDCBCOMMAND LDX #0 ;OFFSET 0
.BYT $2C ;BIT
PUTDCBHEAD = * ;SAME AS PUT DRIVE
PUTDCBDRIVE LDX #1 ;OFFSET 1
.BYT $2C ;BIT
PUTDCBMSBSECTR LDX #2 ;OFFSET 2
.BYT $2C ;BIT
PUTDCBCYLLSB LDX #3 ;OFFSET 3
.BYT $2C ;BIT
PUTDCBNUMSECS LDX #4 ;OFFSET 4
.BYT $2C ;BIT
PUTDCBSTEP LDX #5 ;OFFSET 5
.BYT $2C ;BIT
PUTDCBLOBUFPTR LDX #6 ;OFFSET 6
.BYT $2C ;BIT
PUTDCBHIBUFPTR LDX #7 ;OFFSET 7
PUTDCB STA PUTDCB,X
PTR1 = PUTDCB+1
PTR2 = PUTDCB+2
RTS ; SHORT AND SWEET??
;
READTHESENSE LDY #12 ;OFFSET TO SENSE
STA ERRORCODE ;SAVE ERROR CODE
LDX #0
GETALLTHESENSE LDA GETALLTHESENSE,Y
PTRX = GETALLTHESENSE+1
STA CURRENTSENSE,X ;PUT IN BUFFER
INX
INY
CPX #4
BNE GETALLTHESENSE
RTS
;
GETDCBCOMMAND LDY #0
.BYT $2C
GETDCBHEAD LDY #1
.BYT $2C
GETDCBSECTOR LDY #2
.BYT $2C
GETDCBCYLLSB LDY #3
;
GETDCBINFO LDA GETDCBINFO,Y ;Y HAS OFFSET
DCBPTRFORGET = GETDCBINFO+1
RTS
;
;
WRITEOUTHEX PHA
AND #$F0 ;HIGH NYBLE FIRST
LSR A
LSR A
LSR A
LSR A
JSR ISITATHRUF
PLA
AND #$0F
ISITATHRUF CMP #$0A
BCC ADDASCIIZERO
ADC #6 ;ADD SEVEN
ADDASCIIZERO ADC #$30
JMP $FFD2
HEXTOASCII PHA
AND #$0F ;GET LOW NYBLE
JSR BIGGERTHAN9
TAX
PLA
AND #$F0 ;NOW HI NYBLE
LSR A
LSR A
LSR A
LSR A
BIGGERTHAN9 CMP #$0A
BCC ADDAZERO
SBC #9
RTS
ADC #6 ;ADD SEVEN
ADDAZERO ADC #$30
RTS
;
WRITEOUTSENSE LDY #0
WRITEALLSENSE LDA ERRORCODE,Y ;GET ERRORCODE AND SENSE
JSR WRITEOUTHEX ;WRITE IT
LDA #32
JSR $FFD2
INY
CPY #5 ;GOT EM ALL?
BNE WRITEALLSENSE
LDA #13
JMP $FFD2
;
WRITEOUTAMSG TAX ;GET INDEX INTO TABLE
LDA MTAB,X
STA MPTR
LDA MTAB+1,X
STA MPTR+1
LDY #0
WRITEMSGLOOP LDA WRITEMSGLOOP,Y
MPTR = WRITEMSGLOOP+1
BEQ ENDOFMESSAGE
JSR $FFD2
INY
BNE WRITEMSGLOOP
ENDOFMESSAGE RTS
;
RESETFORRETRY JSR RESET
SETUPDCB LDA HEADCOUNTER ;SET HEAD NUMBER
JSR PUTDCBHEAD ;PUT HEAD # IN DCB
LDA CYLINDERCOUNTR+1 ;GET CYL #HI
ASL A ;MOVE TO HIGH BITS
ASL A
ASL A
ASL A
ASL A
ASL A
ORA SECTORCOUNTER
JSR PUTDCBMSBSECTR ;MSB CYL AND SECTOR
LDA CYLINDERCOUNTR ;LSB CYL
JSR PUTDCBCYLLSB
LDA #1 ;SET NUM BLOCKS
JMP PUTDCBNUMSECS
;
MARKBADSECTOR JSR GETDCBHEAD
AND #$0F ;CLEAR DRIVE NUMBER
JSR PUTBADSECTOR
JSR GETDCBSECTOR
JSR PUTBADSECTOR
JSR GETDCBCYLLSB
JSR PUTBADSECTOR
RTS
PUTBADSECTOR STA BADSECTORS
INC PUTBADSECTOR+1
BNE PUTBADSECEND
INC PUTBADSECTOR+2
DEC BADSECTORCTR ;BACK OFF USED SPACE
BNE PUTBADSECEND
LDA #<TOOMANYBAD ;TOO MANY BAD SECTORS
JSR WRITEOUTAMSG
PLA ;TERMINATE NOW!
PLA ;BY PULLING OFF THE RETURN
PLA ;TWICE
PLA
PUTBADSECEND RTS
;
.LIB C2SEC14.SRC
;
;+++ MESSAGE TABLE +++
MTAB = *
HEADINGMSG = *-MTAB
.WOR HEADER
RESETERRORMSG = *-MTAB
.WOR RESETE ;ERROR ON RESET
TOOMANYBAD = *-MTAB
.WOR TOOMANYBADMSG
LOWLEVELMSG = *-MTAB
.WOR LOWLVL
LOWLEVELERRMSG = *-MTAB
.WOR LOWERR ;ERROR ON LOW LEVEL
WRITEERRORMSG = *-MTAB
.WOR WRTERR ;WRITE ERROR
RDERRORMSG = *-MTAB
.WOR READER ;READ ERROR
ENDOFJOBMSG = *-MTAB
.WOR FINISH ;END OF JOB MSG
COMPAREERRMSG = *-MTAB
.WOR COMERR ;COMPARE ERROR MSG
INTENSIVEMSG = *-MTAB
.WOR HOWMSG ;WHAT KIND OF FORMAT
NUMCYLSMSG = *-MTAB
.WOR INPUTNUMCYLS ;TOTAL NUMBER OF CYLS MSG
NUMHEADSMSG = *-MTAB
.WOR INPUTNUMHEADS
REDUCEDWRTMSG = *-MTAB
.WOR INPUTREDUCED
PRECOMPMSG = *-MTAB
.WOR INPUTPRECOMP
BURSTLENMSG = *-MTAB
.WOR INPUTBURSTLEN
STEPRATEMSG = *-MTAB
.WOR INPUTSTEPRATE
;
HEADER .BYT 147,'HARD DISK FORMATER',13,13,0
RESETE .BYT 13,'E R R O R ON RESET COMMAND',13,0
LOWLVL .BYT 13,'DO LOW LEVEL FORMAT? '
.BYT '(Y OR N)',13,0
LOWERR .BYT 13,'E R R O R ON LOW LEVEL',13,0
WRTERR .BYT 13,'WRITE ERROR',13,0
TOOMANYBADMSG .BYT 13,'TOO MANY BAD SECTORS '
.BYT 'FORMAT TERMINATED!!!',13,0
READER .BYT 13,'READ ERROR',13,0
FINISH .BYT 13,'END OF FORMAT',13,0
COMERR .BYT 13,'BLOCK COMPARE ERROR',13,0
HOWMSG .BYT 13,13,'DO INTENSIVE FORMAT?'
.BYT ' <Y OR N> ',0
INPUTNUMCYLS .BYT 13,'ENTER TOTAL NUMBER OF'
.BYT ' CYLINDERS ',0
INPUTNUMHEADS .BYT 13,'ENTER NUMBER OF HEADS ',0
INPUTPRECOMP .BYT 13,'CYLINDER NUMBER '
.BYT 'FOR START PRECOMP ',0
INPUTREDUCED .BYT 13,'CYLINDER NUMBER '
.BYT 'FOR REDUCED WRITE CURRENT ',0
INPUTBURSTLEN .BYT 13,'MAX CORRECTABLE ERROR '
.BYT 'BURST LENGTH (5 - 11) ',0
INPUTSTEPRATE .BYT 13,'STEP RATE ',0
INTENSIVEFLAG .BYT 0 ;INTENSE FLAG
HEADCOUNTER .BYT 0 ;COUNT UP HEAD
CYLINDERCOUNTR .WOR 0 ;COUNT UP CYLINDERS
SECTORCOUNTER .BYT 0 ;SECTOR COUNTER
RDRETRYCOUNTER .BYT 0
WRTRETRYCOUNTR .BYT 0
BADSECTORCTR .BYT 0 ;COUNTER FOR SECTORS SECTOR
ERRORCODE .BYT 0
CURRENTSENSE .BYT 0,0,0,0
;+ STORAGE AREA
BUFFER .WOR 0
.BYT 'CALCULATED VALUES'
TOTALSECTORS .BYT 0,0,0 ;TOTAL SECTORS
LASTSATSECTOR .BYT 0 ;LAST SAT SECTOR NUMBER
LASTSATBYTE .WOR 0 ;BYTE OFFSET OF LAST SAT BYTE
LASTSATBIT .BYT 0 ;BIT OF LAST BYTE
SECTORPERCYL .WOR 0 ;NUMBER SECTORS/CYL
NUMBEROFHEADS .BYT 0 ;NUMBER HEADS
NUMCYLINDERS .WOR 0 ;NUMBER CYLINDERS
* = BUFFER+512
RDBUF = *
* = RDBUF+512
WRTBUF = *
* = WRTBUF+512
BADSECTORS = *
* = BADSECTORS+1024
.END