.RADIX 16 SYM SET 0E00C KLV SET 0E009 STAT SET 0E006 JMP MAIN DFOR1:DB 0D,0A,"Disk Formatter V01",0D,0A DB "Drive (BCDE) ?-",0 DFOR2: DB 0D,0A,"Formatting Y/N ?-",0 DFOR3: DB 0D,"Tracks 00-80 ?-",0 DFOR4: DB 0D,"Sektors 01-16 ?-",0 DFOR5: DB 0D,"Value 128,256,512,1024 (0-3)?-",0 MAIN: LXI D,DFOR1 CALL PRINT M00: CALL KLVC SUI 42 JC M00 CPI 4 JNC M00 ADI 01 STA NDISK CALL SYM CALL D0A M01: LXI D,DFOR3 CALL PRINT CALL DESDV CPI 55 JNC M01 STA NDOR CALL D0A M02: LXI D,DFOR4 CALL PRINT CALL DESDV CPI 11 JNC M02 ORA A JZ M02 STA NSEKT CALL D0A M03: LXI D,DFOR5 CALL PRINT CALL DSV1 CPI 04 JNC M03 STA VOLUE LXI D,DFOR2 CALL PRINT M04: CALL KLVC CPI "Y" JZ TABL CPI "N" JNZ M04 CALL FDRD JMP MAIN FDRD: LXI H,END INR H MVI L,0 MVI E,0 LDA NDORS MOV D,A LXI B,00E4 LDA NDISK CALL DRSEL JC ERROR MVI B,2 MOV A,D OUT 23 MVI A,1C OUT 20 NOP NOP IN 24 IN 20 ANI 0C0 JNZ ERROR MOV A,C ;LOAD OUT 20 CHTEN: IN 24 RRC IN 23 JNC ERTR MOV M,A INX H JMP CHTEN ERTR: IN 20 ;ERR MOV C,A ANI 0DF RZ STC RET: RET FDWR: LXI H,END ;WRITE NDOR INR H MVI L,0 LDA NDORS MOV D,A MVI E,0 LXI B,00F4 LDA NDISK CALL DRSEL JC ERROR MOV A,D OUT 23 MVI A,18 OUT 20 NOP NOP IN 24 IN 20 ANI 0C0 JNZ ERROR MOV A,C OUT 20 SAVE: IN 24 RRC MOV A,M OUT 23 INX H JC SAVE CALL ERTR JMP ERROR DRSEL: PUSH B ;SET DRIVE MVI B,07 ;B: CPI 1 JZ DIS MVI B,27 ;C: CPI 2 JZ DIS MVI B,03 ;D: CPI 3 JZ DIS MVI B,23 ;E: CPI 4 JZ DIS STC RET DIS: MOV A,B OUT 25 MVI A,10 DIC: DCR A JNZ DIC IN 25 ;ZAPUSK DRIVE RLC JC DS01 IN 20 ANI 80 JZ RPAU DS01: LXI B,0FA00 IN 25 ANI 4E RAR OUT 25 ORI 8 OUT 25 DS02: IN 20 ANI 80 JZ PAUSE IN 25 RLC JNC DS02 MVI A,80 JMP RPAU PAUSE: DCR C JNZ PAUSE DCR B JNZ PAUSE XRA A RPAU: POP B RET ERROR: RNC ORA A RZ MOV B,A LXI H,DATA ERAR: MOV A,M CMP B JZ ONO ORA A JZ ERRR JNZ NEXER ONO: INX H MOV E,M INX H MOV D,M PRER: CALL D0A CALL PRINT CALL KLV RST 01 NEXER: INX H INX H INX H JMP ERAR ERRR: CALL D0A LXI D,ERR CALL PRINT MOV A,B CALL HEX CALL KLV RST 01 DATA: DB 04 DW DAT01 DB 08 DW DAT02 DB 40 DW DAT03 DB 00 DW DAT04 DAT01: DB "OUT DATA",0 DAT02: DB "BAD CRC",0 DAT03: DB "WRITE PROTECT",0 DAT04: DB "DRIVE ERROR",0 ERR: DB "ERROR HEX-",0 KLVC: CALL KLV MOV C,A CPI 03 JZ KL1 CPI 1B JZ KL1 RET KL1: POP H JMP 0 PRINT: LDAX D ORA A RZ MOV C,A CALL SYM INX D JMP PRINT DVDES: CALL DV1 MOV A,E DVA: MOV D,A DV1: MVI C,0 MVI B,8 DV2: MOV A,D RLC MOV D,A MOV A,C ADC C DAA MOV C,A DCR B JNZ DV2 JMP HEX DESDV: CALL DSV1 RLC RLC RLC MOV B,A RRC RRC ADD B MOV B,A CALL DSV1 ADD B RET DSV1: CALL KLVC SUI 30 JM DSV1 CPI 0A JP DSV1 PUSH PSW CALL SYM POP PSW RET HEXD: XCHG CALL HEXH XCHG RET HEXH: MOV A,H CALL HEX MOV A,L HEX: PUSH PSW ANI 0F0 RRC RRC RRC RRC CALL HE1 POP PSW PUSH PSW ANI 0F CALL HE1 POP PSW RET HE1: PUSH H PUSH B LXI H,DANN MVI B,0 MOV C,A DAD B MOV C,M CALL SYM POP B POP H RET DANN: DB "0123456789ABCDEF",0 CRLF: MVI C,0A CALL SYM CRD0: CALL A0D CALL HEXH PRB: MVI C,20 JMP SYM D0A: MVI C,0A CALL SYM A0D: MVI C,0D JMP SYM VERH: MVI C,0C JMP SYM NIZ: LXI D,1500 CALL SCRN LXI D,7F20 CALL CURC LXI D,1500 SCRN: PUSH D CALL VERH ;TAB PRINT MVI C,0A CALL CURS SCR1: MVI C,18 MOV D,E CALL CURS POP D RET CURC: MOV C,E CURS: MOV B,D CUS: XRA A CMP B RZ CALL SYM DCR B JMP CUS DFOR6: DB 0D,"Track-",0 DFOR7: DB " F",08,0 DFOR8: DB "V",08,0 TABL: CALL SYM CALL D0A MVI A,0 STA NSTOR STA NDORS STA NSEKS TAB0: LXI D,DFOR6 CALL PRINT LDA NDORS CALL DVA LXI D,DFOR7 CALL PRINT LDA NSTOR ;CALL HEX LXI H,END INR H MVI L,0 LXI D,504E CALL LDIR LXI D,0C00 CALL LDIR LXI D,03F6 CALL LDIR LXI D,01FC CALL LDIR LXI D,324E CALL LDIR TAB1: LXI D,0C00 CALL LDIR LXI D,03F5 CALL LDIR LXI D,01FE CALL LDIR LDA NDORS CALL LDIA LDA NSTOR CALL LDIA LDA NSEKS INR A STA NSEKS CALL LDIA LDA VOLUE CALL LDIA LXI D,01F7 CALL LDIR LXI D,164E CALL LDIR LXI D,0C00 CALL LDIR LXI D,03F5 CALL LDIR LXI D,01FB CALL LDIR LDA VOLUE LXI D,0080 CPI 0 JZ LDR LXI D,0100 CPI 01 JZ LDR LXI D,0200 CPI 02 JZ LDR LXI D,0400 CPI 03 JZ LDR LXI D,0080 LDR: MVI A,0E5 CALL LDIA DCX D MOV A,E ORA D JNZ LDR LXI D,01F7 CALL LDIR LXI D,364E CALL LDIR LDA NSEKT MOV C,A LDA NSEKS CMP C JNZ TAB1 XRA A STA NSEKS LXI D,004E CALL LDIR LXI D,004E CALL LDIR LXI D,204E CALL LDIR CALL FDWR LXI D,DFOR8 CALL PRINT CALL FDRD LDA NDOR MOV C,A LDA NDORS CMP C JZ MAIN INR A STA NDORS CALL STAT ORA A JZ TAB0 CALL KLVC JMP MAIN LDIR: MOV M,E INX H DCR D JNZ LDIR RET LDIA: MOV M,A INX H RET NDISK: DB 00 NDOR: DB 00 NSTOR: DB 00 NSEKT: DB 00 VOLUE: DB 00 NDORS: DB 00 NSEKS: DB 00 END: END