Title Program Loader for the MD-1/2/3 using CP/M 2 (10_Sept_84) ; ; Copyright 1984 ; Morrow Designs, Inc ; San Leandro, Ca. .z80 aseg org 0100h ; This program allows you to batch command strings to the ; Ims facility. Additionally, you have the option to check for the ; existance of a file before the ims string is submitted which allows ; you to do validity checks. ; There are two major data structures that are used to drive this ; program. The first is a parameter block kept in page zero while the ; program is running. It consists of an ID word followed by the current ; iteration (0 to n) followed by the maximum number of iterations. ; The second data structure is a two dimensional array. The first ; dimension is set by the iteration counter. he Ims string into the IMS buffer ; Get_Base Return a Pointer to the Desired Entry ; Get_Response Get the User's Response ; -- General Parameters ; -- Program Load List ; -- Prompt Strings ; -- Error Messages page 64 ;---------------------------------------------------------------------- ; External Definitions (10_Sept_84) ;---------------------------------- ; 1) This variables are defined in the 'List' files ; External LodLst External LodLen ;---------------------------------------------------------------------- ; Equates (10_Sept_84) ;--------------------- ; ; Key filespec prompt ;-------------------- ; Null equ 0FFh ;Null Key filespec prompt ; IDs and Rev Numbers ;-------------------- ; CpmVer equ 20h ;Cpm Version Number Ccl equ 30h ;Cbios Compatibility Level Prev equ 11h ;Program revision number PID equ 'Ok' ;Program ID ; Address Definitions ;-------------------- ; Wboot equ 0 ;Address of the Start of the BIOS + 3 warmbt equ 01h ;Address of the Bios Warm boot entry Number_Drives equ 04h ;Number of Physical Drives Bdos_Entry equ 05h ;Address of the start of the BDOS IBuf equ 80h ;tail buffer location PIDadd equ 40h ;Address of the ID word LodOff equ 42h ;Current Program Load offset LodMax equ 43h ;Maximum number of load files ErrFlag equ 44h ;Error Flag ; Bdos Function Numbers ;---------------------- ; Bdos_ConOut equ 2 ;Console Output a Character Bdos_DirIO equ 6 ;Direct console control Bdos_PString equ 9 ;Print a string Bdos_GetRev equ 0Ch ;Get revision number of cpm system Bdos_SFirst equ 11h ;Search for first occurance of file x Bdos_SetDMA equ 1Ah ;Set the DMA Address InWait equ 0FFh ;Direct console input ; Offsets ;-------- ; Ccl_Offset equ 3Ch ;Offse --------------- ; CntrlC equ 3 ;Control C Code (Warm Boot) Bell equ 7 ;Bell Code Tab equ 9 ;Tab Lf equ 0Ah ;Line Feed Cr equ 0Dh ;Carriage Return PCr equ 8Dh ;Pause carriage return (see Install_Ims) ClrScr equ 1Ah ;Clear Screen Esc equ 1Bh ;Escape Bright equ '(' ;Start High Lighting Dim equ ')' ;Start Low Lighting page ;---------------------------------------------------------------------- ; Main Line of the Floppy Disk Loader for Cpm 2.2 (10_Sept_84) ;------------------------------------------------------------- ; Main_Line: ld hl,(PIDadd) ;HL:= Contents of ID word location ld de,PID ;DE:= Program ID word or a ;(Clear carry) sbc hl,de ;If (ID hasn't been written) jr z,MSkp1 call Check_Ccl ; Check CP/M rev and compatibility or a ; If (Rev levels aren't high enough) jr nz,Mdone ; Quit call Clear_Screen ; Clear the Console Screen ld de,Prmpt1 ld c,Bdos_PString call Bdos_Entry ; Print the initial prompt call Get_Response ; Get the user response or a ; If (Response eq Stop) jr nz,MDone ; Quit ld de,PID ld (PIDadd),de ; Write the ID ld a,0 ld (LodOff),a ; Reset the Load Offset ld (ErrFlag),a ; Reset the Error flag ld a,(LodLen) ld (LodMax),a ; Set Maximum number of load files MSkp1: ld a,(ErrFlag) ;see if previous copy O.K. or a jr z,CopyOk ; ld a,(LodOff) ;decrement Load Offset if Error ; dec a ; ld (LodOff),a CopyOk: call Look_for_File ;Get the user to load the next disk or a ;If (the user wants to stop) jr nz,MDone ; Quit call Install_Ims ;Install the Ims String or a ;If (There wasn't room for the Ims String) jp nz,MDone ; Quit ld a,(LodOff) inc a ld (LodOff),a ;Load Offset:= Load Offset + 1 ld b,a ld a,(LodMax) ; ------------------------------------------------------------------- ; Check the Cbios Compatibility Level (18_Jun_84) ;------------------------------------------------ ; ;Check the Cpm Version Number Check_Ccl: ld c,Bdos_GetRev ;C:= Bdos get cpm version number call Bdos_Entry ;Get version number in L ld a,l ;A:= Cpm Version 14, 22 or 31 and 0F0h ;Mask off the minor revision number cp CpmVer ;If (version ne expected version) jr nz,CclErr ; Goto Error return ;Check the Cbios Compatibility Level ld hl,(Wboot+1) ;HL:= Bios warm boot entry address ld de,Ccl_Offset ;DE:= offset to Cbios compatiblity level add hl,de ;HL:= Pointer to Cbios compatibility ld a,(hl) ;If (crnt compatibility ne Cbios Ccl) and 0F0h ; (Mask off minor revision number) cp Ccl jp nz,CclErr ; Goto Error return Cclok: ld a,0 ;A:= Successful Completion status ret ;Return CclErr: ld de,Err1 ; DE:= revision error message ld c,Bdos_PString ; C:= Print string function call Bdos_Entry ; Print Input Drive number string ld a,0FFh ; A:= error return status ret page ;---------------------------------------------------------------------- ; Clear the Console Screen (20_Jul_84) ;------------------------------------- ; 1) This Routine Simply outputs a Carriage Return followed by 50 Line ; Feeds to the Console. ; 2) NONE of the Register Pairs are altered. ; Clear_Screen: push bc push de push hl ld c,Bdos_ConOut ;C:= Bdos Console Output Function Number ld e,Cr ;E:= Carriage Return call Bdos_Entry ;Print a Carriage Return ld b,50 ;B:= Character Counter ld c,Bdos_ConOut ;C:= Bdos Console Output Function Number CsSk1: push bc ;Repeat ld e,Lf ; E:= Line Feed call Bdos_Entry ; Print the Line Feed pop bc ;-------------------------------------------------------- ; 1) This routine checks for the existance of a particular file on ; a particular disk. ; 2) If the File Name String is Null (0) then the file check is ; NOT preformed. ; Look_for_File: ld bc,Key_Offset ;Loop BC:= Offset to Prompt string call Get_Base ; HL:= Pointer Prompt string table base ld a,(hl) ; If (File Name string is Null) cp Null ld a,0 ret z ; Return (No Error) inc hl ; HL:= Source (Start of FCB) ld de,Local_Fcb ; DE:= Destination (Local FCB) ld bc,13 ; BC:= Length of Transfer ldir ; Transfer FCB for the Key File push hl ; (save pointer to prompt string) ld de,Prmpt2 ld c,Bdos_PString call Bdos_Entry ; Print 'please insert diskette.. pop de ; DE:= Pointer to prompt string ld c,Bdos_PString call Bdos_Entry ; Print title of diskette ld de,Prmpt3 ld c,Bdos_PString call Bdos_Entry ; Print 'diskette into your ' ; ld a,(Number_Drives) ; If (Number of Drives ge 2) ; cp 2 ; jr nc,LfSk1 ld de,Prmp3a ld c,Bdos_PString call Bdos_Entry ; Print 'Upper' LfSk1: ld de,Prmp3b ld c,Bdos_PString call Bdos_Entry ; Print ' disk drive' call Get_Response ; Get response from console or a ; If (response eq Stop) ret nz ; Return ld c,Bdos_SetDMA ld de,Local_Buffer call Bdos_Entry ; Set the DMA Address ld c,Bdos_SFirst ld de,Local_Fcb call Bdos_Entry ; Find Key File On Selected Drive cp 0FFh ; If (key file was found) ld a,0 ret nz ; Return (Ok) ld de,Err2 ld c,Bdos_PString call Bdos_Entry ; Print Error Message jr Look_for_File page ;---------------------------------------------------------------------- ; Put the Ims string into the IMS buffer (18_Jun_84) ;----------------- hl ;(save pointer on stack) ;Translate special characters in the Ims String ImsLp2: inc hl ;Repeat (move HL past the length byte) ld a,';' ; If (char eq Standard_Cr) cp (hl) jr nz,ImsSk2 ld (hl),Cr ; substitute Cr jr ImsSk3 ImsSk2: ld a,'|' ; Else If (char eq Pause_Cr) cp (hl) jr nz,ImsSk3 ld (hl),PCr ; substitute pause Cr ImsSk3: djnz ImsLp2 ;Until (all of buffer is processed) pop de ;DE:= pointer to start of processed buffer ;Inject the Ims string into the Ims buffer ld hl,(Wboot+1) ;Get warm boot address ld bc,Inject_Offset ;offset to inject IMS routine add hl,bc ;add offset to HL call jphl ;call (HL) ld a,0 ;If (the ims string was accepted) ret nc ; Return (no error) ld de,Err3 ;Else ld c,Bdos_PString call Bdos_Entry ; Print error (ims string won't fit) ld a,0FFh ret ; Return (ERROR) jphl: jp (hl) page ;---------------------------------------------------------------------- ; Return a Pointer to the Desired Entry (5_Feb_84) ;------------------------------------------------- ; 1) This routine uses the LodOff Value along with the Entry offset ; (passed in the BC pair) to form a pointer into the Load List. ; 2) The Load List is a two dimensional (n by 2 word) array. The First ; dimension of the array is the set by the current iteration number ; of the Loader Program (LodOff). The second dimension of the array ; allows access to the current Key file (and it prompt string) and ; the Ims Stings pointers. ; 3) Pointer offsets (passed in the BC pair): ; 0 = Key File Name ; 2 = Ims String Text ; 4) Register Usage: ; A -> General Purpose ; BC -> Pointer Offset or second dimension (0=Prompt,2=Key,4=Ims) ; DE -> used as Offset in calculating the first d nstion add hl,bc ;HL:= Pointer to Second Dimension ld e,(hl) inc hl ld d,(hl) ;(retrieve the pointer from the table) ex de,hl ;HL:= Pointer to base of desired string ret ;Return page ;---------------------------------------------------------------------- ; Get the User's Response (10_Sept_84) ;------------------------------------- ; 1) This routine prints a prompt string and then waits for a valid ; response from the console device. ; 2) A valid response is a Carriage Return to continue or a Control_C ; to stop. ; 3) Register Usage: ; AF -> Returned 0 for continue or 0FFh for Stop ; BC -> Bdos function number in the C register ; DE -> On Entry Points to the string to print ; Get_Response: ld de,Prmpt4 ld c,Bdos_PString call Bdos_Entry ;print the response prompt AskLp1º lä c,Bdos_DirIO ;Loop ld e,InWait ; (Set funct to wait for input) call Bdos_Entry ; Get a character from console and 5Fh ; (force to upper case) cp CntrlC ; If (Response eq Stop) jr nz,AskSk1 ld a,0FFh ; (Stop code) jr AskSk2 ; Break AskSk1: cp Cr ; Else If (Response eq Continue) jr nz,AskLp1 ld a,0 ; (Continue code) AskSk2: push af ;(Save the Continue/Stop Flag) ld de,CrLf ld c,Bdos_PString call Bdos_Entry ;Print Carriage Return Line Feed pop af ;A:= Response (0-Continue or 0FFh-Stop) ret ;Return page ;---------------------------------------------------------------------- ; Prompt Strings (10_Sept_84) ;---------------------------- ; Prmpt1: db Esc,Dim,Lf,Lf,Lf db ' MD-1E CP/M and NewWord Distribution Diskette' db Cr,Lf,Lf db 'Use this diskette to create a CP/M and NewWord working diskette' db Cr,Lf db 'for your MD-1E. You will need another diskette to become b Cr,Lf,Lf db ' The CP/M and NewWord distribution diskette will be' db Cr,Lf db ' called the ',esc,bright,'SOURCE',esc,dim,' diskette' db Cr,Lf,Lf db ' The other diskette will be called the ',esc,bright,'DESTINATION',esc,dim db Cr,Lf db ' diskette.' db Cr,Lf,'$' Prmpt2: db Esc, Dim, Cr,Lf db 'Please insert your ' db Esc, Bright, Cr,Lf,'$' Prmpt3: db Esc, Dim, Cr,Lf db 'diskette into your $' Prmp3a: db 'upper$' Prmp3b: db ' disk drive. $' Prmpt4: db Cr,Lf,Lf,Lf db 'To continue press ',Esc,Bright,'[RETURN] ' db '$' CrLf: db Cr,Lf,'$' page ;---------------------------------------------------------------------- ; Error Messages (18_Jun_84) ;-------------------------- ; Err1: db Cr,Lf,'Wrong Version of CP/M' db Cr,Lf,'This version of FDL Requires CP/M vers 2.2 Cbios rev ' db Ccl shr 4 + 30h,'.x$' Err2: db Cr,Lf,'ERROR: This is NOT the proper disk$' Err3: db Cr,Lf,'ERROR: There is insufficient space in the ims buffer$' page ;---------------------------------------------------------------------- ; General Parameters (5_Feb_84) ;------------------------------ ; Local_Fcb: ds 32,0 Local_Buffer: ds 128,0 end