;---------------------------------------- "Loading MTBACKUP" $PRINT CRLF ; ; MTBACKUP - back up magtape to MS output ; Output is in SIMH format. ; Limitation... no single record can exceed 32K words ; 12/4/02 hacked into working again (maybe) 10/4/07 ; OCTAL DEFINE MTBACKUP DEC END ;dummy, will be replaced by call to MTBK ; ; problem - if you tell the tape to read one record it does that, ; and expects me to be there to collect it. Using DMA I have to ; know ahead of time how many words to expect, get it wrong and ; it hangs. I don't know how many words to expect... the whole ; reason I wrote a TOS, to record that vital bit of info. ; what I need is a hack that counts how many words in a ; record (it doesn't have to do anything with the data) ; so that more proper methods can be used to transfer to ; the alternate map, write to PTP etc. I just need that number! ; ; MTWC pushes word count + 1 if executed right after MTINIT ; ; 10/4/07 - first call is not be reliable, when called again from same ; tape point returns 1 less (usually), or apparently the correct count. ; This code was written on a very old sim version then never ran again ; until I needed it to compress the sim magtape file - later versions ; of the sim began inserting large inter-record 376 377 377 377 gaps ; which make the file larger and probably incompatible w/ MTRESTORE. ; CREATE MTWC * partially copied from 13181 bootrom src... DC EQU 14 * magtape data channel CC EQU 15 * magtape command channel CLA STA WCNT * clear word count LDB RDCMD * get read command JSB CMD * do it STC DC, C * start data channel LP SFC CC * check for status JMP EX * yes jump to EX SFS DC * any data? JMP *-3 * no keep checking LIB DC,C * yes get data (to nowhere) ISZ WCNT * inc count, skip if zero JMP LP * get more data EX LDA WCNT * done - get word count JSB ZSPSH,I * push count to stack JMP ZNXT,I * return to HP-IPL/OS CMD NOP OTB CC * output command LIA CC * check if rejected RAR,RAR RAR,SLA JMP *-4 * yes try again STC CC,C * no start command JMP CMD,I RDCMD OCT 1423 WCNT OCT 0 END ; DEFINE WHDR ;create SIMH magtape header record... word len on stack (leave) DUP ASL DUP 377 AND MSBOUT ;output LSbyte 400 DIV MSBOUT ;output MSbyte #0 MSWOUT ;output zero word (no records that big) END ; DEFINE MTBK ;MTBACKUP main body -IRQ ; no interrupts! MTINIT RWLP MTWAIT FILES #0 PUT DO MTINIT MTWC MTWAIT DROP BS1R MTWAIT ;10/4/07 do twice (??? !) MTINIT MTWC MTWAIT ;push number of words in next record ;10/4/07 removed DEC from MTWC calls (after calling twice) DUP IFZ CRLF "End of tape" $PRINT DROP #1 #0 MSWOUT #0 MSWOUT ;output final EOF mark 177777 MSWOUT 177777 MSWOUT ;output end of medium marker ELSE FILES DUP GET INC PUT RECORDS #0 PUT DO ;loop thru all records in file BS1R MTWAIT WHDR ;bs 1 rec, write header to out file UDMA 2 OVER MTREAD MTWAIT SDMA ;read record into alt map RECORDS DUP GET INC PUT CRLF "File " $PRINT FILES GET PNUM "Record " $PRINT RECORDS GET PNUM "Length " $PRINT DUP PNUM " Saving..." $PRINT 2 OVER OVER ADD DEC +DO INDEX IDREC #1 A>CCOPY ;alt-current copy 1 word IDREC GET MSWOUT ;output word to MS +LOOP WHDR ;write dup header #1 11 +DO 10 PCHR +LOOP " Saved" $PRINT DROP ;previous count BS1R MTWAIT FS1R MTWAIT ;added 10/4/07 MTINIT MTWC DROP MTWAIT BS1R MTWAIT ;added 10/4/07 ; just not working. MTWC gives erronous word counts... 2nd time called ; after doing BS1R (or RWLP) gives 1 less than first call, this is ; just a mess. Got it working... not sure how. Still a mess. ; but if it's a working mess - I don't care :-) but if it works at all ; on real hardware then it should put on quite a jitter-bug show. MTINIT MTWC MTWAIT ;get count of next record 10/4/07 removed DEC DUP IFZ ;if filemark MSWOUT #0 MSWOUT ;output filemark #1 ;end of file ELSE #0 ENDIF ;if not filemark leave len on stack, keep looping UNTIL ;end of file #0 ;keep looping ENDIF UNTIL ;logical end of tape END ; ; extend MTBACKUP definition around MTWC, WHDR and MTBK... "MTBK" $DEFADR DUP DEC GET ;push MTBK word address & link value "MTBACKUP" $DEFADR DEC SWAP PUT ;wrap MTBACKUP around MTBK code "MTBACKUP" $DEFADR INC SWAP PUT ;replace dummy with MTBK call ;---------------------------------------- "Loading MTRESTORE" $PRINT CRLF ; ; MTRESTORE - copies image file (SIMH format) from MS input ; to magtape volume, either adding to it or replacing ; existing contents ; OCTAL DEFINE MTRESTORE DEC END ;dummy, replaced by MTRST ; DEFINE RREC ;read SIMH record header and push word length MSBIN MSBIN 400 MUL ADD ;get byte count DUP #1 AND IFNZ INC ENDIF ;if odd add 1 ASR MSWIN DROP ;shift right (/2), get next 2 bytes (assumed 0) ;if record length > 0 then load record into alt map... DUP IFNZ 2 OVER INC +DO ;from 2 to wordlen+1 IDREC MSWIN PUT ;get 1 word into IDREC (borrowing) IDREC INDEX #1 C>ACOPY ;copy 1 word into alt map +LOOP MSWIN DROP MSWIN DROP ;read dup header, assumed correct ENDIF END ; DEFINE MTRST ;MTRESTORE main body "New Volume or Add files? (V/A) " $PRINT CHRIN CRLF CASE = 126 MTINIT RWLP MTWAIT #1 = 101 MTSCAN #1 DEFAULT #0 ENDCASE IFNZ FILES #0 PUT DO ;until logical end of tape RREC ;read record from MS input DUP IFZ ;if filemark "End of tape" $PRINT CRLF GAPMARK MTWAIT BS1R MTWAIT ;write terminating file marker DROP #1 ;drop 0 and terminate ELSE FILES DUP GET INC PUT "Transfering file " $PRINT FILES GET PNUM "wait... " $PRINT RECORDS #0 PUT DO ;until all records are written, len on stack RECORDS DUP GET INC PUT UDMA 2 SWAP MTWRITE MTWAIT ?MTERROR SDMA ;write record (drop len) RREC ;read next record or filemark DUP IFZ ;if filemark DROP GAPMARK MTWAIT ;drop 0 and write gapmark "done." $PRINT CRLF #1 ;stop looping ELSE GAP MTWAIT ;write inter-record gap #0 ;keep going, leave length on stack ENDIF UNTIL ;all records written #0 ;keep looping for more files ENDIF UNTIL ;end of tape ENDIF END ; ; extend MTRESTORE definition around MTRST... "MTRST" $DEFADR DUP DEC GET "MTRESTORE" $DEFADR DEC SWAP PUT "MTRESTORE" $DEFADR INC SWAP PUT ;---------------------------------------- "Done" $PRINT CONSOLE