;This program is used by the Micro Menu system to "HANG" the ;Micro Decision and give a chance to exchange diskettes in ;Drive A. It will print a message, and wait for the user to ;change diskettes and press return. After pressing return, ;the program will perform a warm boot. ; aseg .z80 cr equ 0dh lf equ 0ah conout equ 2 ; bdos function number for output dconio equ 6 ; bdos function number for direct console i/o strout equ 9 ; bdos function number for string output filechk equ 17 ; bdos function number for exist check bdos equ 5 input equ 0ffh ; flag for direct console i/o direction blank equ ' ' ; ASCII blank char. esc equ 1bh ; ASCII escape character cline equ 80h ; command line address for cpm clr equ 1ah ; Clear screen ; ; org 100h ; main: ld sp,1000h call parse ; get filename and program name call exist ; check if the file exists cp 0ffh jp nz,00 ; if it exists, then go...... call wrtscn ; otherwise, print message wait: call getret ; wait for input (CR, or ESC) cp esc ; check if escape entered jp z,abort ; if so, go back to PILOT call exist ; otherwise, look for file cp 0ffh jp nz,00 ; if found, then go.... call wrong ; otherwise, wrong diskette, print msg, jp wait ; and go back to get a character abort: ld hl,(1) ; calculate address of xltab ld de,43h ; offset from bios to xltab ptr. add hl,de ld e,(hl) inc hl ld d,(hl) ex de,hl ld a,0ffh ; find free space loop: cp (hl) jr z,found ; exit if free space found inc hl ld e,(hl) inc hl ld d,(hl) inc hl add hl,de ; if not free space, find next block jr loop found: inc hl ld (hlsave),hl ; save start of free space header ld e,(hl) inc hl ld d,(hl) ld (desave),de inc hl add hl,de inc hl ld e,(hl) inc hl ld d,(hl) ld hl,(desave) add hl,de ld de,strlen xor a ; clear carry flag before subtract sbc hl,de ex de,hl ld hl,(hlsave) ld (hl),e inc hl ld (hl),d inc hl add hl,de ld (hl),0fdh inc hl ld (hl),strlen inc hl ld (hl),0 inc hl ex de,hl ld hl,pilot ld bc,strlen ldir jp 0 ; ; ; Subroutine: PARSE ; This routine moves the name of a program, and it's name on the diskette ; to a buffer area, from the console input buffer. ; parse: ld b,0 ; get ready to find names ld hl,cline ; length of data ld c,(hl) ; gets to c register ld a,b cp c ; check if blank command line jp z,error ; return to PILOT if error inc hl ; point to first character call whtspc ; skip over blanks ld de,fname ; point to buffer for file name ld a,blank move: ldi ; move a character jp po,error ; if not finished, bad command line cp (hl) ; see if next char is a blank jp nz,move ; if not, move it call whtspc ; skip over intermediate blanks ld de,name ; ready to move name ldir ; move it ret ; ; Subroutine: WHTSPC ; Looks at the characters pointed to by the HL register and increments ; past any blank spaces. For each blank passed, it decrements bc. ; whtspc: ld a,blank ; character to skip search: cp (hl) ; see if it's a blank ret nz ; exit if not blank inc hl ; point to next char dec c ; update count jp z,error ; error if out of characters jp search ; check another ; ; Subroutine: EXIST ; This routine checks for the existance of a file on the logged drive. ; if it does not exist, it will return a 0ffh value in the a register. ; exist: ld bc,20h ; build a fcb for cpm ld de,fcb+1 ld hl,fname ldir ld a,1 ; set for drive A ld de,fcb ; point to fcb ld (de),a ld c,filechk ; load bdos function number call bdos ret ; ; Subroutine: WRTSCN ; print a message on the screen asking them to change diskettes. ; wrtscn: ld de,clrscn ; clear the screen ld c,strout call bdos ld de,title ; point to header text ld c,strout ; set for string output call bdos ; and output it ld de,name ld c,strout call bdos ld de,estr ld c,strout call bdos ret ; ; getret: ld c,dconio ; get a character ld e,input call bdos cp cr ; check if CR entered jr z,ok cp esc ; check if escape entered ret z ; return if escape was entered jr getret ok: ld de,crlf ; output a cr,lf to screen ld c,strout call bdos ld a,cr ; re-init character r'cvd ret ; then return. ; ; Subroutine: GETCCP ; This routine returns with HL pointing to the beginning of the ccp. ; getccp: ld a,(7) ;MSB of bdos address sub 8 ld h,a ;starting page of ccp to h ld l,0 ;lsb of ccp addr = 0 ret ; ; Subroutine: WRONG ; Print a message indicating that they put the wrong disk in drive a, ; and give them a chance to go back to the Micro Menus. ; wrong: ld de,wrng1 ; point to 1st part of msg. ld c,strout call bdos ld de,name ; point to name of program ld c,strout call bdos ld de,wrng2 ; 2nd part of msg. ld c,strout call bdos ld de,title ld c,strout call bdos ld de,name ld c,strout call bdos ld de,estr ld c,strout call bdos ld de,wrng3 ld c,strout call bdos ret ; ; Subroutine: ERROR ; Outputs a message and returns to the Micro Menu. ; error: ld de,emsg ld c,strout call bdos jp abort ; ; clrscn: db clr,0,0,0,0 db '$' title: db cr,lf,'Insert your WORKING diskette for $' estr: db ' in Drive A, and press [RETURN].' db '$' wrng1: db cr,lf,lf,lf,'The diskette in Drive A is not a WORKING $' wrng2: db ' diskette.',lf,'$' wrng3: db cr,lf,'To return to the Micro Menus, press [ESC] . $' emsg: db cr,lf,'Invalid command line. Returning to Micro Menu. $' crlf: db cr,lf db '$' name: ds 30,'$' hlsave: ds 2 desave: ds 2 pilot: db 'A:PILOT',cr strlen equ $-pilot fname: db ' COM' ds 21,0 fcb: ds 32,0 end