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
/
MBUG
/
MBUG099.ARC
/
FORMATAM.MAC
< prev
next >
Wrap
Text File
|
1979-12-31
|
19KB
|
659 lines
;This file is to Format Amstrad disks on the Microbee in the
;4 formats ie. System (either side), Data and Double sided Data format.
;
;This MAC file was FORMAT80.COM and has been disassembled
;using DASM16 and has had the necessary code added and changes
;made for multiple formats.
;
;FORMATS.COM will only format the WHOLE disk, not just
;desired tracks like FORMAT80.COM will.
;
;ver 1.3 19/3/88 Microbee data removed, Amstrad added. By AJLaughton
;ver 1.2 2/11/87 included format type on screen. By John Slater
;ver 1.1 1/11/87 removed code not needed. " " "
;ver 1.0 25/10/87
;
;
;
ASEG
.Z80
ORG 100H
L0000 EQU 0H ;WARM BOOT
L0001 EQU 1H
L0005 EQU 5H ;BDOS
L0006 EQU 6H
L0027 EQU 27H
START: ;START
LD DE,SIGN_ON
CALL MESS_OUT ;Put signon message to screen
L0106:
CALL KEYS
CP '1' ;System SS - side 0
JR NZ,S1
LD DE,TYPE1
LD (TYPE),DE
LD HL,DATA1
JR PUT_DAT
S1: CP '2' ;System SS - side 1
JR NZ,DATAS
LD DE,TYPE2
LD (TYPE),DE
LD HL,DATA2
JR PUT_DAT
DATAS: CP '3' ;Data SS
JR NZ,DATAD
LD DE,TYPE3
LD (TYPE),DE
LD HL,DATA3
JR PUT_DAT
DATAD: CP '4' ;Data DS(5.25")
JR NZ,WHAT?
LD DE,TYPE4
LD (TYPE),DE
LD HL,DATA4
PUT_DAT:
LD DE,SCRATCH ;Address of Format type scratch
LD BC,0005H ;No. of bytes of data
LDIR
JR DRIVE
WHAT?:
CP 3 ;^C
JP Z,EXIT
CP 1BH ;ESC
JP Z,EXIT
JR L0106 ;Not a known key try again
DRIVE:
LD DE,(TYPE) ;Put Format type to screen
CALL MESS_OUT
LD DE,DRV_MESS
CALL MESS_OUT ;'ENTER DRIVE' message to screen
CALL KEYS
CP 1BH
JP Z,EXIT
CP 3
JP Z,EXIT
RES 5,A
CP 'A'
JR C,DRIVE
CP 'E'
JR NC,DRIVE
PUSH AF
LD C,A
CALL L0210 ;Put Drive letter to screen
POP AF
SUB 'A'
AND 3
OR 8
LD (SCRATCH + 9),A ;Store Drive number
LD A,(SCRATCH) ;Get no. of sides to format
LD (SCRATCH + 8),A
BEGIN:
LD A,(SCRATCH + 2) ;Get total no.of trks.
LD (TRK + 1),A
DI ;Start of Formating
XOR A
OUT (9H),A ;Turn off 'bee colour board
CALL L01C8 ;Get status of FDC
CALL L01CF
XOR A
LD (SCRATCH + 7),A
L0171:
LD A,0
LD (L0289 - 1),A
LD A,(SCRATCH + 8) ;Get side no.
CP '1'
JR Z,L0183
CALL L01F2
CALL NZ,L01B4
L0183:
LD A,1
LD (L0289 - 1),A
LD A,(SCRATCH + 8)
CP '0'
JR Z,L0195
CALL L01F2
CALL NZ,L01B4
L0195:
LD A,(SCRATCH + 7)
INC A
LD (SCRATCH + 7),A
TRK: CP 28H ;Is track last track (28H for 40trk)
JR Z,FINISH ;Yes, then Finish
LD A,5BH
CALL L035F
JR L0171
FINISH:
EI
LD DE,COMP_MESS ;'FORMATTING COMPLETED'
CALL MESS_OUT ;message to screen
CALL KEYS
JP START
L01B4: ;'FORMATTING ERROR' message
LD DE,ERR_MESS ;to screen
JP MESS_OUT
L01BA:
POP HL
LD DE,PROT_MESS ;'Write Protected..'message
CALL MESS_OUT ;to screen
CALL KEYS ;
EI
JP START ;Begin again
L01C8:
LD A,0D0H
OUT (44H),A
JP L035F
L01CF:
LD A,(SCRATCH + 9)
OUT (48H),A
L01D4:
IN A,(44H)
BIT 6,A ;Check if disk is Write Protected
JP NZ,L01BA
AND 4
JR NZ,L01E6 ;Step to track 00
LD A,6BH
CALL L035F
JR L01D4
L01E6:
XOR A ;Move head to track 00
OUT (45H),A
LD HL,9C40H
L01EC: ;Delay until head reaches trk 0
DEC HL
LD A,H
OR L
JR NZ,L01EC
RET
L01F2:
XOR A
LD B,A
LD A,(SCRATCH + 7) ;Get current trk no.
CP B ;Is it track '0'?
JR C,L020C ;
LD B,A
LD A,(SCRATCH+1) ;Get end trk no.
CP B ;Are they the same?
JR C,L020C
LD A,0FFH
LD (SCRATCH + 6),A
L020C:
JP L021D
NOP
L0210:
PUSH HL
PUSH BC
PUSH AF
LD E,C
LD C,2
CALL L0005
POP AF
POP BC
POP HL
RET
L021D:
CALL L0383 ;'FORMATTING TRACK' message to screen
LD A,'0'
CALL L0AA5
JP Z,L036F
LD A,(SCRATCH + 6)
OR A
RET Z
LD A,(SCRATCH + 7)
LD L,A
LD A,(L0289 - 1) ;Get side no.
RLCA
RLCA
AND 4
LD B,A
LD A,(SCRATCH + 9) ;Get drive no.
ADD A,B
OUT (48H),A ;Set drive, side, density latch
XOR A
OUT (9H),A
LD C,48H ;Status port no.
SEC1: LD DE,(SCRATCH + 3);Get sector no. & sectors/trk
LD A,0F4H
OUT (44H),A ;Set command register
CALL L0359
LD B,20H ;Start of format data
LD A,4EH ;for 512 Bytes/sector
L0253:
IN H,(C) ;Check DRQ of the FDC
JP P,L0253 ;Not ready for data check again
OUT (47H),A ;Ready, write data
DJNZ L0253 ;
L025C:
LD B,8
LD A,0
L0260:
IN H,(C)
JP P,L0260
OUT (47H),A
DJNZ L0260
LD B,3
LD A,0F5H
L026D:
IN H,(C)
JP P,L026D
OUT (47H),A
DJNZ L026D
LD A,0FEH
L0278:
IN H,(C)
JP P,L0278
OUT (47H),A
LD A,L ;Track no.
L0280:
IN H,(C)
JP P,L0280
OUT (47H),A
LD A,0 ;Side no.
L0289:
IN H,(C)
JP P,L0289
OUT (47H),A
LD A,D ;Sector no.
L0291:
IN H,(C)
JP P,L0291
OUT (47H),A
INC D
LD A,2
L029B:
IN H,(C)
JP P,L029B
OUT (47H),A
L02A2:
NOP
LD A,0F7H
L02A5:
IN H,(C)
JP P,L02A5
OUT (47H),A
LD B,16H
LD A,4EH
L02B0:
IN H,(C)
JP P,L02B0
OUT (47H),A
DJNZ L02B0
LD B,0CH
LD A,0
L02BD:
IN H,(C)
JP P,L02BD
OUT (47H),A
DJNZ L02BD
LD B,3
LD A,0F5H
L02CA:
IN H,(C)
JP P,L02CA
OUT (47H),A
DJNZ L02CA
LD A,0FBH
L02D5:
IN H,(C)
JP P,L02D5
OUT (47H),A
LD B,0
LD A,0E5H
L02E0:
IN H,(C)
JP P,L02E0
OUT (47H),A
DJNZ L02E0
L02E9:
IN H,(C)
JP P,L02E9
OUT (47H),A
DJNZ L02E9
LD A,0F7H
L02F4:
IN H,(C)
JP P,L02F4
OUT (47H),A
LD B,1FH
LD A,4EH
L02FF:
IN H,(C)
JP P,L02FF
OUT (47H),A
DJNZ L02FF
DEC E
JP NZ,L025C ;Format next sector
LD B,0
LD A,4EH
L0310:
IN H,(C)
JP P,L0310
OUT (47H),A
DJNZ L0310
L0319:
IN H,(C)
JP P,L0319
OUT (47H),A
DJNZ L0319
L0322:
IN A,(44H)
RRCA
JP C,L0322
LD A,(L02A2)
SUB 14H
RET Z
LD A,(SCRATCH + 4)
OUT (46H),A
LD A,98H
OUT (44H),A
CALL L0359
L0339:
IN A,(44H)
BIT 0,A
JP Z,L0356
L0340:
IN A,(46H)
LD C,A
LD B,0AH
L0345:
IN A,(46H)
CP C
JR NZ,L0340
DJNZ L0345
CP 0BH
JP C,L0339
CALL L01C8
LD A,0
L0356:
AND 18H
RET
L0359:
LD A,12H
L035B:
DEC A
JR NZ,L035B
RET
L035F:
OUT (44H),A
CALL L0359
L0364:
IN A,(44H) ;test if ready
OR A
JP M,L0364
AND 1
JR NZ,L0364
RET
L036F:
LD DE,ABORT_MESS ;'Formating Aborted' message
CALL MESS_OUT ;To screen
CALL KEYS
CP 1BH
JR NZ,L037F
CALL KEYS
L037F:
EI
JP START ;Restart
L0383:
LD DE,TRK_MESS
L0398:
CALL MESS_OUT
LD A,(SCRATCH + 7)
LD HL,L0000
CALL CONVERT
LD DE,SIDE_MESS
CALL MESS_OUT
LD A,(L0289 - 1)
ADD A,'0'
LD C,2
LD E,A
CALL L0005
LD DE,L087A
JP MESS_OUT
SIGN_ON: ;Sign on message
DB 1EH,1BH,59H,0DH,0AH
DB '** ',1BH,') Amstrad --- Disk Formatter. ',1BH
DB '( ** For All AMSTRAD Disks.',0DH,0AH,0AH
DB 'This program will format Amstrad disks on the Microbee.',0DH,0AH
DB 'To Format the Disk, enter the format type (1-4)'
DB ' then enter the drive (A-D)',0DH,0AH,0DH,0AH
DB '==================================================='
DB '===========================',0DH,0AH
DB 'To abort at any point, HOLD DOWN the ESCAPE '
DB 'key until the abort message shows.',0DH,0AH
DB '==================================================='
DB '===========================',0DH,0AH,0DH,0AH
DB 09H,09H,' (1)',09H,'Amstrad System SS - Side 0 (169k)',0DH,0AH,0AH
DB 09H,09H,' (2)',09H,'Amstrad System SS - Side 1 (169k)',0DH,0AH,0AH
DB 09H,09H,' (3)',09H,'Amstrad Data SS (178k)',0DH,0AH,0AH
DB 09H,09H,' (4)',09H,'Amstrad Data DS - 5.25" (356k)',0DH,0AH,0AH,0AH
DB ' ENTER FORMAT TYPE: (1-4) - $'
TYPE:
NOP
NOP
TYPE1:
DB 1AH,09H,09H,'Disk to be ',1BH,') Amstrad System SS'
DB ' - Side 0 ',1BH,'( format.$'
TYPE2:
DB 1AH,09H,09H,'Disk to be ',1BH,') Amstrad System SS'
DB ' - Side 1 ',1BH,'( format.$'
TYPE3:
DB 1AH,09H,09H,'Disk to be ',1BH,') Amstrad Data SS'
DB ' ',1BH,'( format.$'
TYPE4:
DB 1AH,09H,09H,'Disk to be ',1BH,') Amstrad Data DS'
DB ' (5.25") ',1BH,'( format.$'
DRV_MESS:
DB 0DH,0AH,0AH
DB '================================================='
DB '=============================',0DH,0AH
DB 'To abort at any point, HOLD DOWN the ESCAPE '
DB 'key until the abort message shows.',0DH,0AH
DB '================================================='
DB '=============================',0DH,0AH,0AH,0AH,0AH
DB 'INSERT DISK to be FORMATTED then ENTER NAME OF DRIVE'
DB ': (A-D) - $'
ERR_MESS:
DB 0DH,0AH,' ** FORMATTING ERROR DETECTED (in '
DB 'the above track) **',0DH,0AH,0AH,'$'
ABORT_MESS:
DB 0DH,0AH,0AH,' ** FORMAT HAS BEEN ABORTED '
DB 'BY THE ESC KEY **',0DH,0AH,' (The track '
DB 'listed above has not yet been formatted)',0DH,0AH
DB 0AH,09H
DB ' Press any key to continue :- $'
PROT_MESS:
DB 0DH,0AH,0AH,' ** FORMAT ERROR: DISK '
DB 'IS WRITE-PROTECTED **',0DH,0AH,0AH,09H
DB ' Press any key to continue :- $'
COMP_MESS:
DB 0DH,0AH,0AH,09H,09H
DB ' ** FORMAT COMPLETED **',0DH,0AH,0AH,09H
DB ' Press any key to continue :- $'
TRK_MESS:
DB 0DH,' Formatting track '
DB 1BH,'Y$'
SIDE_MESS:
DB ', side $'
L087A:
DB '. $',0DH,' Y-Formatting track '
DB 1BH,'Y$'
KEYS: ;Get key
PUSH BC
PUSH DE
PUSH HL
LD HL,(L0001) ;Warm start entry address
LD DE,L0006 ;BDOS service req. entry address
ADD HL,DE
LD (KEY + 1),HL
KEY: CALL 0000
AND 7FH
POP HL
POP DE
POP BC
RET
CONVERT: ;Converts hex track no. to ASCII
PUSH HL
PUSH AF
LD A,H
OR A
JP NZ,L0A58
LD HL,TRK_NUM
L0A58:
POP AF
PUSH AF
RRCA
RRCA
RRCA
RRCA
AND 0FH
ADD A,'0'
CP ':'
JP C,L0A69
ADD A,7
L0A69:
LD (HL),A
INC HL
POP AF
AND 0FH
ADD A,'0'
CP ':'
JP C,L0A77
ADD A,7
L0A77:
LD (HL),A
POP HL
XOR A
CP H
RET NZ
PUSH BC
PUSH DE
LD C,9
LD DE,TRK_NUM
CALL L0005
POP DE
POP BC
RET
TRK_NUM:
NOP
NOP
DB '$'
MESS_OUT:
PUSH AF
PUSH BC
PUSH DE
PUSH HL
LD C,9
CALL L0005
POP HL
POP DE
POP BC
POP AF
RET
EXIT:
LD DE,L0AF0 ;Clear screen
CALL MESS_OUT
JP L0000 ;and exit.
L0AA5:
PUSH BC
LD B,A
LD C,A
LD A,12H
OUT (0CH),A
LD A,B
RRCA
RRCA
RRCA
RRCA
LD B,A
OUT (0DH),A
LD A,13H
OUT (0CH),A
LD A,B
OUT (0DH),A
LD A,1
OUT (0BH),A
LD A,10H
OUT (0CH),A
IN A,(0DH)
LD A,1FH
OUT (0CH),A
OUT (0DH),A
L0ACB:
IN A,(0CH)
BIT 7,A
JR Z,L0ACB
IN A,(0CH)
CPL
LD B,A
XOR A
OUT (0BH),A
LD A,10H
OUT (0CH),A
IN A,(0DH)
BIT 6,B
LD A,C
POP BC
RET
NOP
NOP
NOP
SCRATCH:
NOP ;Sides to format
NOP ;No. of tracks
NOP ;Total No. of tracks
NOP ;Sectors per track
NOP ;Skew
NOP ;Start trk no.
NOP ;Current trk no.
NOP ;Current side no.
NOP ;Drive no.
NOP
NOP
NOP
NOP
NOP
NOP
L0AF0:
DB 1AH,0DH,0AH,'$' ;Clear screen codes
NOP
NOP
DATA1: ;Amstrad System SS - Side 0
DB '0' ;Format only side 0
DB 27H ;
DB 28H ;40 Tracks
DB 09H ;9 Sectors/track
DB 41H ;Start skew at 65
NOP
NOP
DATA2: ;Amstrad System SS - Side 1
DB '1' ;Format only side 1
DB 27H ;Last track no.
DB 28H ;40 trks.
DB 09H ;9 Sectors/trk.
DB 41H ;Start skew at 65
NOP
NOP
DATA3: ;Amstrad Data SS - Side 0
DB '0' ;Format only side 0
DB 27H ;
DB 28H ;40 Trks.
DB 09 ;9 Sectors/trk.
DB 0C1H ;Start skew at C1
NOP
NOP
DATA4: ;Amstrad Data DS
DB 'B' ;Both sides
DB 27H ;
DB 28H ;40 Tracks
DB 09H ;9 Sectors/Trk.
DB 81H ;Start skew at 129
NOP
NOP
END
;9 Sectors/Trk.
DB