PGM DKMAKIPL
        REL
*
* SHOULD BE LOADED AT ABSOLUTE LOCATION #4000
*
* Writes image in form: 11*128 blocks starting record 1 track 0
*                       memory address 0
* then                  41 blocks and 6 tracks starting address #4F80
*
BASE    EQU #78     BASE ADDRESS OF CHANNEL
*
*
START   MOV AX,!#000
        MOV SS,AX
        MOV DS,AX
        MOV ES,AX
        MOV SP,!#4F0
        CALL RESET
        XOR CX,CX
        MOV BL,!0      UNIT 0
        CALL RECAL     RECALIBRATE DRIVE
        CALL WAITC
        OR AL,AL
        JE GF2
        INT            ERROR
GF2     MOV IONR,!11[B]
        MOV DX,!0                memory address
        MOV CX,DX
        INC CL                   record 1 track 0
        CALL MAKIPL
* next 41 records
        MOV IONR,!41[B]
        MOV DX,!#4F80
        MOV CX,!12               record 12 track 0
        CALL MAKIPL
* now 6 tracks
        MOV IONR,!52[B]          do whole track in one go
        MOV CL,!1                record 1
        MOV CH,CL                track counter
        MOV DX,!128*41+#4F80
*
TRKLP   PUSH CX                  save count
        PUSH DX                  and address
        CALL MAKIPL
        POP DX
        POP CX
        ADD DX,!52*128
        INC CH                   next track
        CMP CH,!6
        JLE TRKLP
* finished
        INT
*
*
IOPB    DB #T00000000   SEQ. FORMAT, EN INTS, WORD LENGTH 8
IODI    DB 0            DISKETTE INSTRUCTION
IONR    DB 52            NO. OF RECORDS
IOTA    DB 0            TRACK ADDRESS
IOSA    DB 0            SECTOR ADDRESS
IOLBA   DB 0            LOWER BUFF. ADD.
IOUBA   DB 0            UPPER BUFF. ADD.
*
* RECALIBRATE
*
RECAL   MOV AL,!RECALIN   BL SHOULD HOLD UNIT NO.
        XOR DX,DX
       MOV CX,!1       TRACK ADDRESS 0, SECTOR ADD. 1
        CALL DISKINS
        RET
*
* GENERAL DISK INSTRUCTION
*   BL   UNIT NO.
*   AL   INSTRUCTION
*   CH   TRACK ADDRESS
*   CL   SECTOR ADDRESS
*   DH   UPPER BUFFER ADDRESS
*   DL   LOWER BUFFER ADDRESS
*
DISKINS MOV IOTA,CH
        MOV IOSA,CL
        OR AL,!#T0000        8 BIT WORDS
        MOV CL,!4
        SHL BL,CL            SHIFT UNIT BITS
        OR AL,BL             OR WITH INST.
        AND AL,!#3F          CLEAR TOP 2 BITS
        MOV IODI,AL
        MOV IOLBA,DL
        MOV IOUBA,DH
        MOV AX,!IOPB
        OUT BASE+1
        PUSH AX
        POP AX
        MOV AL,AH
        OUT BASE+2           START CHANNEL
        RET
*
* MAKIPL
*
MAKIPL  MOV BL,!0        unit number
        MOV AL,!WRITEIN
        CALL DISKINS
        CALL WAITC
        OR AX,AX
        JE MAKRET
        INT                          ERROR
MAKRET  RET
*
* WAITC, WAIT FOR CHANNEL END , LOOK AT RESULT
*
WAITC   IN BASE+0
        TEST AL,!INTPEND
        JE WAITC              BUSY WAIT
        PUSH AX
        POP AX
        IN BASE+1             0 IF ERROR
       MOV AH,AL
        PUSH AX
        POP AX
       IN BASE+3             RESULT BYTE
        RET
*
* RESET CHANNEL
*
RESET   OUT BASE+7
        RET
*
*
*
RECALIN EQU 3
FORMIN  EQU 2
READIN  EQU 4
WRITEIN EQU 6
INTPEND EQU 4
*
FCH     EQU $
*
        END