* *----------------------------------------* * Initialize the MEDIT pointers. * *----------------------------------------* * INIT LHLD BFSTT Initialize the pointers SHLD SCHLOC * INIT0 SHLD MEMLNE SHLD MEMPNT XCHG . LXI H,SCREEN+7 SHLD SCRPNT XRA A STA CCP Initialize column counter (1) STA CLINE Initialize row counter (1) * INIT1 XRA A Initialize the screen OUT 0FEH For SOL OUT 0C8H For VDM * LXI SP,STACK Initialize the stack * *----------------------------------------* * This is the main loop of MEDIT * *----------------------------------------* * MAIN LHLD MEMLNE Get the memory address XCHG . Pointer must be in DE CALL PRVDM Put on a new screen of data * MN0 CALL CURON Put on the cursor * PUSH D Go update the information PUSH H CALL PRINFO Do it now POP H Retrieve values POP D * *----------------------------------------* * Check for input of wanted characters. * *----------------------------------------* * MN1 CALL INPUT Wait for a character ANI 7FH * *----------------------------------------* * We've got a character. Find out what * * it does (if anything) * *----------------------------------------* * LOOK LXI B,MN0 Push this on the stack as a return address PUSH B * LXI H,CHTBL Point to the lookup table * LOOK1 CMP M Is this the character? * MOV B,M Save the table character * INX H Get a jump address before acting MOV E,M INX H MOV D,M * JZ LOOK2 Finally, Yes! go to the routine * *----------------------------------------* * Not this time, check for end of table * *----------------------------------------* * MOV C,A Are we at the table end? MOV A,B ORA A MOV A,C JM CNVRT Yes, so input must be changing a memory byte * MOV A,C Get the input character back * INX H Keep looping JMP LOOK1 * *----------------------------------------* * We know the routine address, jump! * *----------------------------------------* * LOOK2 XCHG . Clean up the registers PCHL . Now, execute the routine * *----------------------------------------* * Convert the input to usable binary * * and store it in the proper place. * *----------------------------------------* * CNVRT LHLD SCRPNT * MOV B,A Save the character LDA HXASC Are we in the hex mode? ORA A MOV A,B JM CNVR3 Minus says no * *----------------------------------------* * The hex mode with "window" input. * *----------------------------------------* * CALL CKHEX Check and see if character is legal hex RC . Return now if not * CNVR2 PUSH PSW Save the character * INX H Create a "window" effect MOV A,M Move the right cursor byte left one byte DCX H MOV M,A All done * POP PSW Now, put the new byte in the others old place ORI 80H Inverse it first though * INX H Put it to the screen MOV M,A DCX H Adjust for binary conversion * CALL BINARY Convert the cursor byte for us LHLD MEMPNT MOV M,B Now, save it in mmory * LDA CURCHK Is it time to move the cursor? INR A Increment the digit counter ANI 1 If it is greater than one (i.e. two) then move it STA CURCHK JZ ADVCUR Go move it if necessary * RET . * *----------------------------------------* * ASCII mode with minus input allowed. * *----------------------------------------* * CNVR3 CPI 20H We don't want CTRL characters RC . * MOV B,A Save the character * INX H Now, check for minus input MOV A,M Get the old character ANI 7FH Clean it up CPI '-' Is it a minus? DCX H MOV A,B If so, then "window" the minus sign JZ CNVR2 * CNVR4 INX H If not, then clear the display MVI M,0A0H This does it DCX H Now, "window" nothing * CPI '-' Minus input is special JZ CNVR2 * PUSH PSW LDA CURCHK In the ASCII mode, only one letter allowed ORA A before advancing the cursor JNZ CNVR2+1 The exception is minus ("-") input, INR A then two characters are allowed STA CURCHK * JMP CNVR2+1 * *----------------------------------------* * Change ASCII to HEX and vice versa. * *----------------------------------------* * RASHX LDA HXASC Change the mode CMA . STA HXASC * LHLD MEMLNE Now, reprint the screen XCHG . * JMP PRVDM Print the new screenful of data * *----------------------------------------* * All necessary scroll routines. * *----------------------------------------* * * Scroll up one line on the screen. * RSUOL LXI B,16 Scroll forward 16 bytes MVI A,1 Do it one time JMP SCROLL * * Scroll down one line on the screen. * RSDOL LXI B,-16 Scroll backwards 16 bytes JMP RSUOL+3 * * Scroll down 7/8 of a screen * RSDS LXI B,-16 Scroll backwards 16 bytes MVI A,21 Do it 21 times JMP SCROLL * * Scroll up 7/8 of a screen. * RSUS LXI B,16 Scroll forward 16 bytes JMP RSDS+3 * *----------------------------------------* * Home the cursor on the screen. * *----------------------------------------* * RCULC CALL CURSW Erase the cursor * LXI H,SCREEN+7 Initialize the screen pointer SHLD SCRPNT XRA A Reset row/column counters STA CCP STA CLINE * LHLD MEMLNE Re-initialize the memory pointer SHLD MEMPNT * RET . * *----------------------------------------* * Put cursor at beginning of next line. * *----------------------------------------* * RCBNL CALL RCEOL Erase the cursor JMP ADVCUR * *----------------------------------------* * Move cursor to the end of the line * *----------------------------------------* * RCEOL CALL CURSW Erase the cursor LDA CLINE Get the line number LXI H,SCREEN Point to BOL 1 LXI B,80 Enter the line modulus RCE1 DCR A JM RCE2 DAD B JMP RCE1 RCE2 MOV A,L ADI 7 Put in offset MOV L,A XRA A STA CCP SHLD SCRPNT Save it for later CALL CURSW * LHLD MEMPNT Now, adjust the memory pointer MOV A,L ANI 0F0H This does it properly MOV L,A SHLD MEMPNT Save this also * CALL RCLFT Move everything down a line now * RET . * *----------------------------------------* * Insert one NOP into the file. * *----------------------------------------* * RINSRT LDA INMDE Is the insert mode on? ORA A RZ . Say bye if not * CALL CURSW Turn off the cursor LHLD BFFNS Get the end of the file address XCHG . LHLD MEMPNT Get the memory pointer * PUSH H Are we at the end of the file? PUSH D INX D LHLD FREE If the buffer end exceeds the highest DCX H available memory location, then cannot insert CALL SBTRCT MOV A,H POP D POP H ORA A JP RINS1 Everything is okay, insert the NOP * CALL CLEAR Go print the error message LXI H,BUFUL JMP SBBDER+3 * RINS1 PUSH D Save these pointers PUSH H MOV B,H Destination of block move is HL+1 MOV C,L INX B Add the one CALL MOVE Move the block * POP H Get back the pointers POP D * MVI M,0 Put the NOP in place INX D Add one to the end address * LXI H,0 Disallow use of the "RE" subcommand SHLD LSTEND * XCHG . SHLD BFFNS Save the value * JMP SBEN1 Go reprint the screen * * The error message * BUFUL ASCZ "No room for insert" * *----------------------------------------* * Delete on byte from the file. * *----------------------------------------* * RDELT LDA DEMDE Is the delete mode on? ORA A RZ . Leave if not * CALL CURSW Turn off the cursor LHLD BFFNS Get the current end of file location XCHG . * LHLD MEMPNT Is the current location the last byte of the file? XCHG . INX D PUSH H CALL BFEND Go check it out POP H DCX D JC INIT1 Exit if so XCHG . * MOV B,H BC has destination address of block move MOV C,L INX H * PUSH D Go move the block CALL MOVE POP D CALL BFBEG JNC INIT1 * XCHG . DCX H Save the new end address SHLD BFFNS * JMP SBEN1 Go reprint the screen * *----------------------------------------* * Advance the cursor one byte. * *----------------------------------------* * ADVCUR CALL RCRGT Move the cursor right one byte * LDA CCP Has it wrapped around? ORA A Check if at col 1 RNZ . Return now if not * LDA CLINE CPI 23 Is it at the bottom of the screen? JNZ RCDWN If not, then exit with the cursor-down movement JMP RSUOL Yes, scroll now * *-------------------------------------* * Position the cursor on the byte * * pointed to by HL. The cursor * * will be on the 4th line if we are * * not at the beginning of the buffer * *-------------------------------------* * POSCUR SHLD MEMPNT Save the memory pointer * MOV A,L Save the memory line value PUSH PSW It must be in the form of HHH0 ANI 0F0H so make the last nibble zero MOV L,A SHLD MEMLNE And save the value POP PSW * ANI 0FH Now, position the cursor over the proper byte STA CCP Store it in CCP LXI H,SCREEN+7 Start with cursor on top line LXI D,3 * PSCR SHLD SCRPNT Do it now DCR A JM MVDWN Exit when done DAD D JMP PSCR Keep looping * MVDWN MVI A,3 Going to put cursor on line 4 MVD1 LHLD MEMLNE Get line pointer LXI B,-16 Scroll down modulus DAD B Give it a try PUSH H Save it for later MOV B,A Save the count too XCHG . CALL BFBEG Now test if at buffer start POP H Pop this now in case JNC INIT1 Can't scroll down SHLD MEMLNE OK! Store it LHLD SCRPNT Now for the cursor MOV A,B LXI B,80 Line modulus DAD B SHLD SCRPNT Store it DCR A How many line to go? JZ INIT1 All done if zero JMP MVD1 * *----------------------------------------* * Write file to disk; return to PTDOS * *----------------------------------------* * REXIT CALL CLEAR Wipe out the screen * CALL LNGTH Calculate the file length * LXI H,SGNOFF Print the sign off message CALL LNEOUT LHLD OUTFIL CALL LNEOUT LXI H,QUESTN CALL LNEOUT * CALL INPUT Verify signing off ANI 5FH Convert to upper case CPI 'Y' JNZ INIT1 Ignore request if the answer is not "Yes" * *----------------------------------------* * Rewind the output file before writing * *----------------------------------------* * WRITE CALL OUTPUT Send out the answer for looks LDA FILEN Rewind the file pointer LXI D,0 CALL SYS DB SPAOP JMP ERROR If something is wrong, say so * *----------------------------------------* * Write the buffer out to the file. * *----------------------------------------* * LDA FILEN Get the file number * LHLD FLNGTH Get the buffer length MOV B,H Put it in BC MOV C,L * LHLD BFSTT Get the buffer start address XCHG . CALL SYS Go write it out DB WBLOP JMP ERROR Report any errors * LDA FILEN End-file the file CALL SYS DB EOFOP JMP ERROR JMP RABT1+3 Go close the file and abort * *----------------------------------------* * Abort the edit mode; retun to PTDOS * *----------------------------------------* * RABRT CALL CLEAR Wipe the screen * LXI H,ABORT Print the abort verify message CALL LNEOUT * CALL INPUT Wait for verification ANI 5FH Convert to upper case CPI 'Y' JNZ INIT1 No, he doesn't want to abort, ignore request * RABT1 CALL OUTPUT Put out the answer CALL CLOSE Go close the file * CALL SYS To a PTDOS system reset DB RETOP * *----------------------------------------* * Cursor up, down, left, right routines.* *----------------------------------------* * RCUP CALL CURSW Turn off the cursor RCUP1 LXI B,-80 Move the cursor up one line LXI D,-16 For MEMPNT adjust RCUP2 CALL LDSTOR Adjust pointers LDA CLINE Get line count DCR A Are we on line 1? STA CLINE JM RCUP3 Wrap around if so CALL ENDTST RNC . JMP RCUP1 RCUP3 LXI B,24*80 Have to wrap if so LXI D,24*16 MVI A,24 STA CLINE JMP RCUP2 * RCDWN CALL CURSW Turn off the cursor RCDW1 LXI B,80 Move the cursor down one line LXI D,16 For MEMPNT adjust RCDW2 CALL LDSTOR Adjust pointers LDA CLINE INR A STA CLINE CPI 24 On bottom line? JNC RCDW3 Wrap around if so CALL ENDTST RNC . JMP RCDW1 RCDW3 LXI B,-1920 Have to wrap if so LXI D,-384 (-16*24) MVI A,0FFH Set up for line 1 STA CLINE JMP RCDW2 * RCLFT CALL CURSW Turn off the cursor RCLF1 LXI B,-3 Move the cursor left one byte LXI D,-1 For MEMPNT adjust RCLF2 CALL LDSTOR Adjust pointers LDA CCP Get col count DCR A Are we at col 1? STA CCP JM RCLF3 CALL ENDTST RNC . JMP RCLF1 RCLF3 LXI B,16*3 Have to wrap if so LXI D,16 MVI A,16 Set at col 16 STA CCP JMP RCLF2 * RCRGT CALL CURSW Turn off the cursor RCRG1 LXI B,3 Move the cursor right one byte LXI D,1 For MEMPNT adjust RCRG2 CALL LDSTOR Adjust pointers LDA CCP Get col count INR A Bump it CPI 16 At col 16? STA CCP JZ RCRG3 Wrap around CALL ENDTST RNC . JMP RCRG1 RCRG3 LXI B,-48 Have to wrap if so LXI D,-16 MVI A,0FFH STA CCP JMP RCRG2 * LDSTOR LHLD SCRPNT Get screen pointer DAD B Add line/column modulus SHLD SCRPNT Restore pointer LHLD MEMPNT Now the memory pointer DAD D Add offset SHLD MEMPNT Save it RET . Go back * ENDTST PUSH D XCHG . CALL BFEND Over end of buffer? POP D RET . * *----------------------------------------* * RSRCH searches the buffer for a match * * of a string of data entered by the * * user. If it is an ASCII character, * * toggding to the hex mode will find * * it if the high bit is set. A Wildcard * * will match any byte in the hex mode * *----------------------------------------* * RSRCH CALL CLEAR Clear the screen MVI A,CHCR Return the cursor to column one CALL OUTPUT * LXI H,WILDB Point to wild card buffer MVI B,7FH WBZ MVI M,0 Zero it out INX H DCR B JNZ WBZ * CALL SRSET Get prompt letter CALL OUTPUT Send out the letter * MVI A,':' Now, put out the colon CALL OUTPUT CALL GETLN Get the input line * MVI A,CHCR Put out a C/R to show string acceptance CALL OUTPUT * LXI H,BUFFER Start search at beginning of buffer SHLD SCHLOC * LDA HXASC If in ASCII mode, no conversion needed ORA A JNZ RCSR0 Go start searching * *----------------------------------------* * Convert the ASCII hex in the buffer * * to binary and store it for searching. * * Put a copy in the wild card buffer * *----------------------------------------* * LXI H,LINE Point to the ASCII hex LXI D,LINE Show where to put the converted value RSR1 CALL SKPBLK Skip over blanks JZ RSR2 If last character is a C/R, then abort INR D Point DE to wild card buffer STAX D Store a copy of line DCR D Put DE back CALL BNYHEX Convert the value CPI CHCR Is the last character a C/R? MOV A,B Let's save the byte before deciding STAX D INX D Adjust the pointer also JNZ RSR1 No, we're not done yet * RSR2 MVI A,CHCR Poke in the carriage return STAX D INX D * XCHG . All done, save the last location SHLD ENDLNE JMP RCSR0 * *----------------------------------------* * RCSRCH -- continue search routine. * *----------------------------------------* * RCSRCH CALL CURSW Erase the cursor * RCSR0 LHLD ENDLNE Get the last address of string LXI D,LINE Point to the beginning PUSH D CALL SBTRCT Subtract the latter from the former... POP D MOV B,L To get the length of the string * MOV A,L If the length is zero, ORA A Send out an error message JZ STNEER * CALL SRSET Set search mode data * LHLD SCHLOC Get search address * RCSR1 PUSH D Are we at the end of the buffer? PUSH H XCHG . LHLD BFFNS Get the end address for checking CALL SBTRCT Subtract the pointer from the end address MOV A,H If the answer is zero, then all done POP H Get the pointer back in case it's not POP D ORA A If the answer is negative, then no string JM STNFER Abort if so * CALL COMPS Otherwise, go compare the strings * INX H Set up for next byte to check SHLD SCHLOC JNZ RCSR1 Loop back if the strings are unequal * DCX H Subtract for the increment above RCSR2 EQU $ Go paint the screen JMP POSCUR With the cursor over the byte * SRSET LDA HXASC Get the mode flag ORA A Check it MVI A,0FFH Move in hex stripper STA SRMOD Store it MVI A,'H' Move in prompt RZ . If it is zero its hex MVI A,7FH Must be Ascii STA SRMOD Store it MVI A,'A' Now the prompt RET * *----------------------------------------* * String search/continue error routines * *----------------------------------------* * STNEER CALL CLEAR LXI H,STGNEN String not entered error JMP SBBDER+3 * STNFER CALL CLEAR LXI H,STGNF String not found error CALL LNEOUT LXI H,CRCNT C/R to continue message CALL LNEOUT * STNF1 CALL INPUT Wait for the carriage return CPI CHCR JNZ STNF1 JMP INIT *