PGM DKMAKIPL
        REL
*
* SHOULD BE LOADED AT ABSOLUTE LOCATION #4000
*
* Writes image in form: 13*128 blocks starting record 1 track 7
*                       memory address 0
* then                  39 blocks and 1 track starting address #D280
*
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,!13[B]
        MOV DX,!0                memory address
        MOV CX,!#0701            record 1 track 7
        CALL MAKIPL
* next 39 records
        MOV IONR,!39[B]
        MOV DX,!#D280
        MOV CX,!#070E           record 14 track 7
        CALL MAKIPL
* now 1 track
        MOV IONR,!52[B]          do whole track in one go
        MOV CL,!1                record 1
        MOV CH,!8                track 8
        MOV DX,!128*39+#D280
*
        CALL MAKIPL
* 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