* Test vehicle for readtrack, writetrack routines ; *** EQU Tables *** cr equ 0dh ; Carriage return lf equ 0ah ; Line feed ctrlz equ 1ah ; Operator interrupt rconf equ 01h ; Dump input from console wconf equ 02h ; Write A contents to console cstaf equ 0bh ; Check con: status drive equ 04h ; Current drive number rbuff equ 0ah ; Read a console line tbuff equ 80h ; Base page default buffer bdos equ 05h ; BDOS entry point org 100h ; TPA start address begin: lxi h,0 ; Clear HL before loading dad sp ; old stack pointer shld cpmsp ; and save it. lxi sp, stak ; Set new stack lda drive ; Get current drive sta drsav ; and save it mvi c,cstaf ; Get console status call bdos ora a jz begin1 ; No input, get some. mvi c,rconf ; Ignore any if present. begin1: call ccrlf call spmsg db ' Put your message here ',0 call ccrlf jmp start ; Go to main program entry point. ; Display message to console spmsg: xthl ; Load phony RET to HL regs xra a ; Clear flags etc. add m ; Move one message character inx h ; and point to next. xthl ; restore stack to return if done. rz ; Done if 00 in A. call conout ; If not done, display it jmp spmsg ; and continue. ; Do a CR/LF to console twocr: call ccrlf ccrlf: mvi a,cr call conout mvi a,lf co: equ $ ; Allow two names conout: push b ; Display one character push d ; Push all regs push h mvi c,wconf ; Select the write function mov e,a ; and put in correct reg Š call bdos ; Do the function pop h pop d ; Pop all back. pop b ret ; Show spaces spaces: push b ; Enter with count in C mov c,a ; Save temp reg for count ora a ; Test for none jz space2 ; and quit if so. space1: mvi a, ' ' ; Load a space call conout dcr c jnz space1 ; Test countdown space2: pop b ; Clear stack ret ; Console operator interrupt opint: mvi c,cstaf ; Check for operator kill call bdos ora a ; Test if keypress rz ; Return if none. mvi c,rconf ; Was, check it. call bdos cpi ctrlz rnz done: lda drsav ; All done, check out. sta drive ; Restore current drive lhld cpmsp ; Get old stack pointer sphl ; load it, and go ret ; Input console message into buffer- cimsg: push b push d ; Push all regs push h lxi h,inbuff+1 ; Point to message start mvi m,0 ; and zero counter dcx h ; Back to length cell mvi m,80 ; and set max line xchg ; Input pointer to DE- mvi c,rbuff ; Set read buffer function call bdos ; and do it. lxi h,inbuff+1 ; Point to counter mov e,m ; and save it mvi d,0 ; Clear upper byte dad d ; and add length to start inx h ; add one more for end mvi m,0 ; and set 00 to end it. pop h pop d ; Restore them all Š pop b ret ; (Y)es or (N)o from console getyn: call spmsg ; Prompt for input db ' (Y/N)?: ',0 ; This is the prompt. call cimsg ; Read an input line call ccrlf ; and do a CR/LF lda inbuff+2 ; Use first character only. ani 5fh ; Make upper case only cpi 'Y' rz cpi 'N' jnz getyn cpi 0 ret ; Message out to console comsg: mov a,m ora a ; Test for 00 rz call conout inx h jmp comsg ; Local storage area drsav db 0 ; Current drive storage cpmsp dw 0 ; Old stack pointer inbuff ds 83 ; Line input buffer org 200h stak: equ $ start: mvi c,01 call setdrv call spmsg db ' Input track number: ',0 call cimsg call settrk call redtrk rept 18 db 00 endm trkreg equ 0e3fdh ; Morrow DJ2B track register settrk: lhld inbuff+2 ; Get track number from buffer call ascbin ; Convert to binary from ascii cpi 77 ; Test for legal range. maxtrk equ $-1 ; Set in proper max track #+1 Š jnc trkerr cpi 00h jc trkerr ; Negatives not allowed sta curtrk ; Make it current track call notbsy ; Make sure 1791 is idle lda curtrk sta trkreg ; and load track register adi 30h ; Make it ascii for possible sta asctrk ; use elsewhere. ret trkerr: call ccrlf call spmsg db ' Track number not acceptable.',0 xra a ; Set z flag ret curtrk db 1 ; CMDREG is part of SELCTDRV.LIB asctrk db 1 datreg equ 0e3ffh ; Morrow DJ2B 1791 data port cmdreg equ 0e3fch ; Morrow DJ2B 1791 command port rtkcmd equ 000e4h ; 1791 read track command redtrk: call notbsy ; Wait until 1791 is idle lxi d,datreg ; Look at 1791 data register lxi h,trkbuf ; and set up buffer area mvi c,24 ; Load number of pages maxpag equ $-1 ; to be read from track. mvi a,rtkcmd ; Load and issue track read sta cmdreg ; command for the 1791 datain: ldax d ; Load data byte mov m,a ; and store in buffer. inr l jnz datain ; Loop until all written. inr h dcr c jnz datain ret trkbuf ds 17ffh ; Room needed to read 8" track. wrtcmd equ 000f4h ; Write track command wrttrk: call notbsy ; Wait until 1791 idle lxi d,datreg ; Point to 1791 data port lxi h,trkbuf ; and to source code. mvi c,24 ; Set number of pages to be wrtpag equ $-1 ; written to disk mvi a,wrtcmd ; Get and issue a write sta cmdreg ; track command. xchg ; Swap the pointers- Š wrtlup: ldax d ; Get a data byte and dump mov m,a ; it into the 1791. Then inr e ; update the byte pointer to jnz wrtlup ; the next cell and continue inò ä »  untiì thå entirå buffeò haó dcr c ; been written to disk : one jnz wrtlup ; entire track's worth. ret notbsy: mvi c,10 ; Preset counter wait1: lxi h,cmdreg ; Point to command port of mov a,m ; 1791 and get a status byte. rar ; Test busy flag - if not up, jnc timeot ; wait for it to come up for ; short period. wait2: mov a,m ; Get status byte and test for rar ; busy flag up. Loop until it jc wait2 ; comes down again. ret ; 1791 idle, go home. timeot: dcr c ; Don't look for flag to come up jnz wait1 ; forever. If no busy flag by ret ; ten tries, is not coming up. ascbin: mov a,h ; Load the second byte ora a ; and test for entry. jz only1 ; Exit if no second number. mov a,l ; Get first entry sui 30h ; Convert from ascii and ral!ral!ral ; multiply x8 and then add add l ; to get x10. sui 30h ; Convert to binary add l sui 30h mov c,a ; Store intermediate value mov a,h ; Get second value sui 30h ; Make binary add c ; Combine for final value ret ; Return with binary in A only1: mov a,l ; Get first byte sui 30h ; Make binary ret ; and return. Š sorcdisk: call spmsg ; Ask for source drive number db ' Input source drive (a,b,c,d): ',0 call cimsg ; Get the input ani 5fh ; Then force upper case. sui 41h ; Convert to binary jz ssave ; Was A drive, is ok. cpi 00 ; Greater than A? jnc upper ; Yes, maybe ok. errdrv: call spmsg ; Print error message db ' Not legal drive: ',0 call ccrlf jmp sorcdisk upper: cpi 4 ; Less than E? jc ssave ; Yes, is legal jmp errdrv ; No, try again ssave: sta srcdrv ; Save the requested drive mov c,a ; Ready for SETDRIVE adi 41h ; Convert back to ASCII sta ascdrv ; and save if letter needed. ret srcdrv db 1 ; Binary value of source drive ascdrv db 1 ; Ascii value of source drive djdriv equ 0d31bh ; Morrow DJ2B BIOS setdrive entry djfunc equ 0e3fah ; Morrow DJ2B drive function port setdrv: mov a,c ; Save desired disk (in C on entry) ani 07h ; Make binary if not already sta curdsk ; and save it for possible use push psw call djdriv ; Bring up the drive pop psw ori 41h ; Convert to ascii value sta ascdsk ; and save for possible use ret curdsk db 1 ascdsk db 1 end