[comp.sources.apple2] v001SRC030: AAF unpacker

jac@yoko.rutgers.edu (Jonathan A. Chandross) (05/02/91)

Submitted-by: Andy Tefft (art100@psuvm.psu.edu)
Posting-number: Volume 1, Source:30
Archive-name: archive/upaaf.bas
Architecture: ANY_2
Version-number: 1.00

Unpacker for AAF archives written in Basic.

Enjoy.

########################

 4  LOMEM: 16384
 5 IN$ = "X": REM  must be first string assigned
 10  TEXT : HOME
 20  PRINT "AAF Unpacker, v1.0"
 22  PRINT : PRINT "by Andy Tefft  (art100@psuvm.psu.edu)"
 24  PRINT : PRINT "This program is freeware. Do what you"
 25  PRINT "want with it, but don't blame me if you"
 26  PRINT "break it."
 28  PRINT : PRINT "Notes (list program for more):"
 30  PRINT : PRINT "1) When asked for a pathname, use"
 32  PRINT "   a full or partial pathname."
 34  PRINT : PRINT "2) Type 'PR#3' before running to use"
 36  PRINT "   80 columns."
 38  PRINT : PRINT "3) Only minimal error checking is done."
 40  PRINT : PRINT "4) Input and output volumes must both"
 42  PRINT "be online."
 44  PRINT : PRINT "Press a key to continue"
 45  GET A$
 50  REM  ARCHIVE FORMAT:
 55  REM
 60  REM  = filename : denotes output file name
 70  REM  - line     : line of output file
 80  REM  + anything : end of file ("anything" ignored")
 85  REM
 86  REM  all other lines echoed to screen
 87  REM
 90  REM  because of the difficulty of editing text files
 91  REM  on the apple //, this program prompts for output
 92  REM  file names, so you can change them if desired.
 93  REM
 94  REM  input anything routine is from an old dos 3.3
 95  REM  public-domain disk
 96  REM
 120  FOR R = 768 TO 788: READ X: POKE R,X: NEXT : REM input-anything
 130  DATA 162,0,32,117,253,160,2,138,145,105,200,169,0,145,105,200
 135  DATA  169,2,145,105,96
 140 D$ =  CHR$ (4)
 145  DIM OU$(100)
 150  PRINT D$"prefix": INPUT PR$
 160  TEXT : HOME
 165  PRINT "AAF Unpacker v1.0  Andy Tefft  11/21/90"
 170  PRINT : PRINT "Prefix: "PR$
 175  PRINT : PRINT "Enter archive pathname, ? for catalog,"
 176  PRINT "/ to change prefix, return to exit."
 180  POKE 34,7
 190  PRINT
 199  ONERR  GOTO 2000
 200  INPUT ": ";C$
 205  IF C$ = "" THEN  END
 210  IF C$ <  > "/" THEN 300
 220  PRINT : INPUT "New prefix:";P$
 230  PRINT D$"Prefix"P$
 240  GOTO 150
 300  IF C$ <  > "?" THEN 400
 310  PRINT D$"cat"
 320  GOTO 190
 400  PRINT : PRINT ">>> Opening "C$" for input."
 405  POKE 34,4:II = 1
 406  PRINT D$"verify"C$
 407 II = 0
 410  PRINT D$"open"C$
 415 IL = 0
 420  PRINT D$"read"C$
 430  CALL 768:IN$ =  MID$ (IN$,1)
 440  IF  LEFT$ (IN$,1) = "=" THEN 450
 445  PRINT IN$: GOTO 430
 450 OU$ =  MID$ (IN$,2)
 455  PRINT ">>> ";
 460  PRINT "Opening "OU$" for output."
 465  PRINT D$: REM  stop taking input from file
 470  PRINT "Press return to use this, enter a new"
 472  PRINT "pathname for output, ? for catalog"
 475  INPUT ": ";CC$
 476  IF CC$ <  > "?" THEN 480
 477  PRINT "Path to catalog, return for current dir"
 478  INPUT P$: PRINT D$"CAT"P$: GOTO 460
 480  IF CC$ <  > "" THEN OU$ = CC$
 485 OO = 1
 490  PRINT D$"open"OU$: PRINT D$"close"OU$: PRINT D$"delete"OU$
 491 OO = 0
 495  PRINT D$"read"C$
 500 OL = 0
 505 FI = 1: REM  means we've started a file
 510  CALL 768:IN$ =  MID$ (IN$,1)
 520  IF  LEFT$ (IN$,1) = "-" THEN 530
 521  IF  LEFT$ (IN$,1) = "+" THEN 1000
 525  PRINT IN$: GOTO 510
 530 OL = OL + 1
 535  VTAB  PEEK (37)
 540 OU$(OL) =  MID$ (IN$,2)
 550  IF OL < 100 GOTO 510
 560  REM   write 100 lines of output file
 570  PRINT D$"open"OU$
 580  PRINT D$"append"OU$
 590  PRINT D$"write"OU$
 600  FOR R = 1 TO 100
 610  PRINT OU$(R)
 620  NEXT
 630  PRINT D$"close"OU$
 640  GOTO 495
 1000  PRINT D$"open"OU$
 1010  PRINT D$"append"OU$
 1020  PRINT D$"write"OU$
 1030  FOR R = 1 TO OL
 1040  PRINT OU$(R): NEXT
 1050  PRINT D$"close"OU$
 1060  PRINT : PRINT ">>> Finished "OU$
 1065 FI = 0
 1070  GOTO 420
 1999  END
 2000 Y =  PEEK (222)
 2001  PRINT
 2005  IF Y = 6 THEN 2100
 2010  IF Y = 5 THEN 2020
 2015  PRINT "Error #"Y: PRINT D$"close": END
 2020  PRINT D$"close": PRINT ">>> End of file encountered."
 2030  IF FI = 1 THEN  PRINT ">>> "OU$" may be incomplete."
 2040  IF FI = 1 THEN  PRINT "(no end of file marker found)"
 2050  TEXT
 2060  END
 2100  IF OO = 1 THEN  PRINT "Volume/directory not found.": GOTO 455
 2110  IF II = 1 THEN  PRINT "Input file not found.": GOTO 175