; ; SYSLIB Module Name: SBLINE ; Author: Richard Conn ; SYSLIB Version Number: 2.0 ; Module Version Number: 1.0 ; Module Entry Points: ; BLINE ; Module External References: ; CAPS ; ; ; BLINE -- BDOS Input Line Editor ; BLINE provides a very convenient interface to the BDOS for input ; line editor functions. It uses a buffer supplied by the user for storage ; of the input line, and it returns a pointer to the first byte of the line ; upon return. The line stored in this buffer is terminated by a binary zero. ; To use BLINE, the user need only call it, with a capitalization flag ; stored in the A Register and HL pointing to the first byte of the user- ; supplied buffer which will contain the line. This buffer is structured ; as follows: ; 1st Byte - Size (filled in by user) ; 2nd Byte - Char count (filled in by BLINE) ; 3rd to nth Byte - Characters of Line (filled in by BLINE) ; n+1st Byte - Terminating Zero ; The number of bytes allocated to the entire buffer is SIZE+3, where SIZE ; is the buffer size as supplied by the user. ; If A = 0, BLINE does not capitalize the input line characters; ; if A <> 0, BLINE capitalizes the input line characters ; before returning to the caller. ; No error codes are returned by BLINE. On return, HL points to the ; first byte of the input line and A contains a count of the number of ; characters in that line. ; ; ; EQUATES ; BDOS EQU 5 B$RDLINE EQU 10 ; READ LINE FUNCTION ; ; EXTERNAL DECLARATIONS ; EXT CAPS ; ; MAIN ROUTINE FOR BLINE ; BLINE:: JMP START ; SKIP OVER BUFFER LINEST: DS 2 ; ADDRESS OF START OF LINE BUFFER CAPFLG: DS 1 ; CAPITALIZATION FLAG (0=NO CAP) START: PUSH D ; SAVE DE, BC PUSH B STA CAPFLG ; SAVE CAPITALIZATION FLAG SHLD LINEST ; SAVE ADDRESS OF FIRST BYTE XCHG ; DE PTS TO BUFFER MVI C,B$RDLINE ; READ LINE FUNCTION IN BDOS CALL BDOS ; DO READ LINE FUNCTION LHLD LINEST ; PT TO RETURNED CHAR COUNT INX H MOV A,M ; GET IT INX H ; PT TO FIRST CHAR PUSH H ; SAVE PTR TO FIRST CHAR ADD L ; ADD CHAR COUNT MOV L,A MOV A,H ACI 0 MOV H,A ; HL PTS TO AFTER LAST CHAR MVI M,0 ; STORE ENDING ZERO POP H ; GET PTR TO FIRST CHAR LDA CAPFLG ; CAPITALIZE? ORA A ; 0=NO JZ DONE PUSH H ; SAVE PTR TO FIRST CHAR CAPLP: MOV A,M ; GET CHAR ORA A ; END OF LINE? JZ CAPDN CALL CAPS ; CAPITALIZE CHAR MOV M,A ; PUT IT BACK INX H ; PT TO NEXT JMP CAPLP CAPDN: POP H ; GET PTR TO FIRST CHAR DONE: POP B ; RESTORE REGS POP D DCX H ; PT TO CHAR COUNT MOV A,M ; GET CHAR COUNT INX H ; PT TO FIRST CHAR OF LINE RET END