; extra words for VDOS... 6/14/11 ; requires DMS altutils VDOS ; ; "file" VOWCHECK - prompts to overwrite if exists, pushes 0 if ok, 1 if not ; (filename string not removed from X, used by other words) ; "file" VLOAD - loads an IPL or ABS file, if runable ABS then runs it ; "file" VSAVE - saves current system to ABS file ; "source" "dest" VCOPY - copies a file to another file in the same directory ; "file" VREAD - like USBREAD but warm-boots if file not found or other error ; "file" VWRITE - like USBWRITE but confirms overwrite, warm-boots if error ; VCLOSE - like USBCLOSE but prints a message and starts with a "V" ; "file" UFSIZE - pushes the byte-size of a file, or 0 if not valid/too big ; "usbfile" "sfsfile" UF2F - copies a USB file to a SFS file as-is ; "sfsfile" "usbfile" F2UF - copies a SFS file to a USB file as-is ; ; Could do more but can't hide everything, more examples... ; Copy ABS file to SFS binary: "ABSFILE.ABS" VREAD "SFSBINFILE" ABS2F ; Copy text file to edit file: "FILE.TXT" VREAD MALOAD "SFSFILE" SVFILE ; (text file must end with ~TERMINATE~ line, req's fed/fedutil.ipl) ; Copy edit in alt mem to usb file: "FILE.TXT" VWRITE MASAVE VCLOSE ; Basically precede things that read from MS with "USBFILE.EXT" VREAD and ; precede things that write to MS with "USBFILE.EXT" VWRITE and VCLOSE after. ; ; 6/14/11 - added -IRQ to VLOAD, changed VCMD 221 >VDR 15 >VDR VCLEAR ;select short/binary commands #1 >VDR 40 >VDR $DUP $>VCMD ;send [0x01][space][filename][cr] to VDRIVE2 &WFVDR DROP ;wait for VDRIVE2 and discard the CR #1 ;push a file-exists flag &WFVDR 103 SUB IFZ ;if next char is C &WFVDR 106 SUB IFZ ;if next char is F &WFVDR 15 SUB IFZ ;if next char is [cr] DEC ;file isn't there, decrement flag to 0 ENDIF ENDIF ENDIF VECS ;clear rest of response, go back to long commands DUP IFNZ ;save exists flag, if file exists "File exists. Overwrite? " $PRINT ;print message CHRIN 40 PCHR ;get a char, print space after it 131 SUB IFZ DEC CRLF ENDIF ;if Y pressed dec flag to 0 and print crlf ENDIF ENDIF END "Loading VLOAD" $PRINT CRLF DEFINE VLOAD ;6/13/11 ;usage: "FILE.EXT" VLOAD - loads something from USB ;if text loads as IPL, otherwise attempts to load/run ABS ;the ABS file must have a run vector in 2/3 or is not run ;clears alt mem first, not intended for overlays $TRIM $LEN IFZ $DROP ELSE ;make sure a filename is specified $DUP USBREAD USBSTAT IFNZ $DROP ELSE ;if file exists MSBIN ;read one byte to test if text or binary USBREAD ;again with dup'd string to start from beginning again IFNZ ;if the initial byte is not zero LOAD ;load the file as IPL ELSE ALTSAVE ZAM ABSLOAD CRLF ;attempt to load the ABS file 2 150 #1 A>CCOPY ;copy alt mem loc 2 to main mem loc 150 150 GET 124003 SUB IFZ ;if loc 150 = 124003 (JMP 3,I) then "Run from 77000 to return" $PRINT CRLF ;an optional reminder -IRQ 77000 RUN ;swap and execute the binary ELSE ;optional message... "No run address " $PRINT ENDIF ENDIF ENDIF ENDIF END "Loading VSAVE" $PRINT CRLF DEFINE VSAVE ;10/25/08 ;usage: "FILENAME.ABS" VSAVE - saves current system to an ABS file ;prompts to replace if the file exists. VOWCHECK ;check file and prompt to overwrite if exists IFNZ ;if file exists and overwrite not confirmed $DROP ;the filename string and exit ELSE ;otherwise try to save... USBWRITE ;opens write stream, deletes the file if it exists USBSTAT IFZ ;if no error SYSALL ;save the current system USBCLOSE ;finish writing the file ENDIF ENDIF END "Loading VCOPY" $PRINT CRLF DEFINE VCOPY ;10/25/08(B) ;copies a USB file to another file in the same directory ;Usage: "SRCFILE" "DESTFILE" VCOPY $TRIM $SWAP $TRIM ;trim spaces from names, make sure both specified ;source filename is now at the top of the X stack (swapped) #0 ;error flag $LEN IFZ INC ENDIF ;error if src file empty $SWAP ;now dest fn on top of X $LEN IFZ INC ENDIF ;error if dest file empty $CPY ;copy dest to Y because equality test eats $EQUAL IFNZ INC ENDIF ;error if src=dest (not perfect) Y>>X $SWAP ;restore dest, swap to put source on top of X stack IFNZ ;if filename error "Can't do that " $PRINT $DROP $DROP ELSE ;first stage of filename checks passed, try copy... USBREAD USBSTAT IFNZ $DROP ELSE ;redirect src file, if no error VOWCHECK ;check/confirm overwrite of dest file IFNZ ;if overwrite not confirmed $DROP "" USBREAD ;drop output fn, force input invalid ELSE ;doesn't exist or overwrite confirmed USBWRITE USBSTAT IFZ ;open write buffer, if no error... "Copying file, please wait... " $PRINT DO #0 ;loop, change 0 on stack to <>0 to stop MSBIN ;get byte from file DUP IFZ USBSTAT IFNZ SWAP INC SWAP ENDIF ENDIF ;detect eof OVER IFNZ DROP ELSE MSBOUT ENDIF ;if not eof write to output UNTIL ;end of file USBCLOSE ;close output file ENDIF ENDIF ENDIF ENDIF END "Loading VREAD" $PRINT CRLF OCTAL DEFINE VREAD ;10/25/08 $TRIM $LEN IFZ ;if filename string is empty USBREAD "USB read disabled " $PRINT ELSE "Reading USB file " $PRINT $DUP $PRINT 40 PCHR USBREAD USBSTAT IFNZ ;redirect file to MS in, if error 457 GET RUN ;get warm-boot vector and run it to warm-boot ENDIF CRLF ;if no reboot newline for formatting ENDIF END "Loading VWRITE" $PRINT CRLF OCTAL DEFINE VWRITE ;10/25/08(A) $TRIM $LEN IFZ ;if filename string is empty ask to confirm "Abandon write buffer? " $PRINT CHRIN 40 PCHR 131 SUB IFZ ;if Y pressed USBAPPEND " Done " $PRINT ;abandon and acknowledge ELSE $DROP ENDIF ;otherwise drop empty string ELSE ;filename specified VOWCHECK IFNZ ;if file exists and overwrite not confirmed 457 GET RUN ;then warm-boot HP-IPL/OS ELSE ;print message, set writes, if error warm-boot... "Writing USB file " $PRINT $DUP $PRINT 40 PCHR USBWRITE USBSTAT IFNZ 457 GET RUN ENDIF CRLF ENDIF ENDIF END "Loading VCLOSE" $PRINT CRLF DEFINE VCLOSE ;10/25/08(A) CRLF ;most MS things don't so ? on next line. Some do making this doublespace ; but that's better than DoneClosing... it's a homemade OS with pieces written ; over a period of years so not every MS thing has consistent output, no more ; than the output of all the different command-line utilities on a PC. "Closing output buffer " $PRINT USBCLOSE ;print confim message and close END "Loading UFSIZE" $PRINT CRLF DEFINE UFSIZE ;6/14/11 ;usage: "FILENAME.EXT" UFSIZE - pushes size of a USB file ;string is removed from the stack so $DUP if in a program ;if size is 0 then the specified file is not valid ;(a directory, not found, not specified, empty, too big, etc) $TRIM $LEN IFZ ;if string is empty $DROP #0 ;invalid ELSE VSYNC "SCS" $>VCMD 221 >VDR 15 >VDR VCLEAR ;select short/binary commands #1 >VDR 40 >VDR $>VCMD ;send [0x01][space][filename][cr] to VDRIVE2 (pop X) &WFVDR DROP ;wait for VDRIVE2 and discard the CR #0 ;change to 1 if [space] detected, change to -1 if [cr] detected 1st DO ;loop until one or the other... &WFVDR CASE = 40 INC = 15 DEC ENDCASE DUP UNTIL IF<0 ;if [cr] detected then invalid.. #0 ;flag invalid and exit ELSE ;size returned, parse size info... &WFVDR &WFVDR &WFVDR &WFVDR ;4 size bytes on stack, top of stack=msb &WFVDR DROP &WFVDR ;get what should be > prompt 76 SUB IFNZ ;if not then... DROP DROP DROP DROP #0 ;discard size, flag invalid (this shouldn't happen) ELSE ;dir command returned a valid size... IFNZ ;if msb not 0 then DROP DROP DROP #0 ;drop remaining, flag as invalid ELSE IFNZ ;if next to msb not 0 then DROP DROP #0 ;drop remaining, flag as invalid ELSE ;msb of 16 bit size on top, lsb next on stack 400 MUL ADD ;convert to a 16 bit byte size ;if greater than 64KB-4 bytes then still too big ;only 3 possible invalid sizes so check each one... DUP CASE = 177775 DROP #0 = 177776 DROP #0 = 177777 DROP #0 ENDCASE ;size should be valid or 0 now ENDIF ENDIF ENDIF ENDIF VECS ;go back to long/ascii commands ENDIF END ;check to see if MS2F and F2MS exist... 11/16/10 "Checking for XDOS utilities" $PRINT CRLF DEFINE TEMP 1 ;present flag "MS2F" $DEFADR IFZ DROP 0 ENDIF "F2MS" $DEFADR IFZ DROP 0 ENDIF IFZ "Not present" $PRINT CRLF CONSOLE ENDIF "TEMP" $DEFADR 4 SUB 0 PUT ;self delete END TEMP ;XDOS utilities present, continue loading "Loading UF2F" $PRINT CRLF DEFINE UF2F ;10/25/08 ;usage "USBFILE.EXT" "SFSFILENAME" UF2F - copies a USB file to a disk file ;SFS file must not exist, manually delete first to replace $TRIM $LEN IFZ $DROP $DROP ELSE ;if SFS filename specified... $SWAP $TRIM ;put USB filename on top of X stack, trim spaces $DUP UFSIZE ;get USB file size DUP IFZ ;if file not compatible then "Invalid USB file " $PRINT DROP $DROP $DROP ;remove 0 size, both filenames, exit ELSE ;valid size returned, stream to a disk file... USBREAD USBSTAT IFNZ ;open read buffer, if error DROP $DROP ;drop size and SFS filename, exit ELSE ;do the copy MS2F ;not much to it ENDIF ENDIF ENDIF END "Loading F2UF" $PRINT CRLF OCTAL DEFINE F2UF ;10/25/08 ;usage: "SFSFILENAME" "USBFILE.EXT" F2UF - copies disk file to a USB file ;uses VWRITE/VCLOSE to confirm/print messages, if not confirmed or ;USB-related error occurs will warm-boot HP-IPL/OS to cancel operation $TRIM $LEN IFZ $DROP $DROP ELSE ;if USB filename not empty $SWAP $TRIM $LEN IFZ $DROP $DROP ELSE ;if SFS filename not empty $SWAP ;put dest back on top of X stack VWRITE ;if invalid/not confirmed will warm-boot HP-IPL/OS F2MS ;copy file to MS out USBCLOSE ;finish the write (not VCLOSE to avoid message) ENDIF ENDIF END "Done" $PRINT CRLF CONSOLE ~TERMINATE~