emil@rochester.UUCP (Emil Rainero) (07/24/84)
From: Emil Rainero <emil> 2 TEXT 10 REM HUFFIN PASCAL/DOS CONVERTER CALL APPLE OCT 1981 100 HI = PEEK (115) + PEEK (116) * 256 - 2100: HIMEM: HI 110 ONERR GOTO 9000 120 DEF FN MOD(X) = (X / 256 - INT (X / 256)) * 256 130 RWTS = HI:ER = HI + 17:IOB = HI + 18:DCT = HI + 36:BUFF = HI + 40 140 TK = IOB + 4:SC = IOB + 5:HB = IOB + 9:G$ = CHR$ (7):PA = 0:DR = 0 150 POKE RWTS,169: POKE RWTS + 1, INT (IOB / 256): POKE RWTS + 2,160: POKE RWTS + 3, FN MOD(IOB): POKE RWTS + 4,32: POKE RWTS + 5,217: POKE RWTS + 6,3: POKE RWTS + 7,176: POKE RWTS + 8,1: POKE RWTS + 9,96 160 POKE RWTS + 10,173: POKE RWTS + 11, FN MOD(IOB + 13): POKE RWTS + 12, INT (IOB + 13) / 256: POKE RWTS + 13,141: POKE RWTS + 14, FN MOD(ER): POKE RWTS + 15, INT (ER / 256): POKE RWTS + 16,96 170 POKE IOB,1: POKE IOB + 3,0: POKE IOB + 6, FN MOD(DCT): POKE IOB + 7, INT (DCT / 256): POKE IOB + 8, FN MOD(BUFF) 180 POKE IOB + 10,0: POKE IOB + 11,0: POKE IOB + 12,1: POKE IOB + 13,0: POKE IOB + 14,0: POKE IOB + 15,96: POKE IOB + 16,1 190 POKE DCT,0: POKE DCT + 1,1: POKE DCT + 2,239: POKE DCT + 3,216 200 HOME : VTAB 2: HTAB 16: PRINT "HUFFIN": VTAB 5: PRINT "PASCAL TO DOS TEXT FILE CONVERSION" 210 VTAB 7: HTAB 10: PRINT "BY DANA J. SCHWARTZ": HTAB 10: PRINT "WASHINGTON APPLE PI": VTAB 10: INVERSE 220 FOR I = 1 TO 40: PRINT " ";: NEXT : VTAB 23: FOR I = 1 TO 40: PRINT " ";: NEXT 230 NORMAL : VTAB 11: POKE 34,10: POKE 35,22: ON DR > 0 GOTO 270 240 ON I GOTO 250: PRINT "SOURCE DISK: ": HTAB 8: PRINT "SLOT: ";: GET I$: PRINT I$:SS = VAL (I$): HTAB 8: PRINT "DRIVE: ";: GET I$: PRINT I$:SD = VAL (I$) 245 PRINT "TARGET DISK: ": HTAB 8: PRINT "SLOT: ";: GET I$: PRINT I$:TS = VAL (I$): HTAB 8: PRINT "DRIVE: ";: GET I$: PRINT I$:TD = VAL (I$) 250 ON SS < 1 OR SS > 7 GOTO 240: ON TS < 1 OR TS > 7 GOTO 240: ON SD < 1 OR SD > 2 GOTO 240: ON TD < 1 OR TD > 2 GOTO 240 260 SS = SS * 16: IF SS = TS * 16 AND SD = TD THEN DR = 1 270 POKE IOB + 1,SS: POKE IOB + 2,SD: IF DR = 1 THEN PRINT CHR$ (7): PRINT "INSERT WRITE PROTECTED PASCAL DISK": GOTO 290 280 ON J GOTO 300: PRINT : PRINT "WRITE PROTECT PASCAL SOURCE DISK AND INSERT IN SOURCE DRIVE": PRINT "INSERT DOS 3.3 TARGET DISK IN TARGET DRIVE" 290 ON J GOTO 300: PRINT : PRINT "(HIT " CHR$ (219);"C/R" CHR$ (221)" FOR DIRECTORY)": PRINT "FILE NAME: ";: INPUT N$: IF NOT LEN (N$) THEN GOSUB 5000: PRINT "FILENAME: ";:J = 1: INPUT N$: ON N$ = "" GOTO 470: GOTO 200 300 GOSUB 1000: IF TY < > 3 OR BT - TP < 4 THEN PRINT : INVERSE : PRINT G$"FILE EMPTY, NOT TEXT OR NOT FOUND": NORMAL :J = 0: GOTO 290 310 HOME :B1 = INT (BUFF / 256):B2 = B1 + 1:B3 = B2 + 1:B4 = B3 + 1:BK = TP + 2: GOSUB 2000 320 A$ = "": PRINT CHR$ (4)"OPEN"N$",S"TS",D"TD:D$ = CHR$ (4): PRINT D$"MONO" 330 PRINT D$"WRITE"N$ 340 FOR I = BUFF TO BUFF + 1023 350 C = PEEK (I): IF C > 16 THEN A$ = A$ + CHR$ (C): GOTO 410 360 IF C = 13 THEN PRINT A$:A$ = "":Y = FRE (0): GOTO 410 370 ON C < > 16 GOTO 400 380 I = I + 1:SP = PEEK (I): ON SP < 33 GOTO 410 390 FOR S = 1 TO SP - 32:A$ = A$ + " ": NEXT S: GOTO 410 400 IF C = 0 THEN I = BUFF + 1023 410 NEXT I 420 BK = BK + 2: ON BK = BT GOTO 450 430 IF DR = 1 THEN PRINT D$"PR#0": HOME : PRINT CHR$ (7)"INSERT PASCAL DISK AND HIT RETURN": GET I$: PRINT : HOME 440 GOSUB 2000:PA = 0: GOTO 330 450 TEXT : HOME 460 IF D$ = CHR$ (4) THEN PRINT D$"CLOSE": PRINT D$"NOMONO" 465 HOME : VTAB 4: PRINT "ANOTHER FILE ? ";: GET I$:I = 1: ON I$ = "Y" GOTO 200 470 HIMEM: HI + 2100: END : REM 1000 REM *** FIND PASCAL FILE *** 1010 BF = INT (BUFF / 256):TR = 0: FOR SE = 11 TO 4 STEP - 1: GOSUB 4000:BF = BF + 1: NEXT SE 1020 NU = PEEK (BUFF + 16):PT = BUFF + 32:LN = LEN (N$) 1030 ON PEEK (PT) < > LN GOTO 1110 1040 FOR J = 1 TO LN 1050 ON PEEK (PT + J) < > ASC ( MID$ (N$,J,1)) GOTO 1110 1060 NEXT J 1070 TP = PEEK (PT - 6) + PEEK (PT - 5) * 256 1080 BT = PEEK (PT - 4) + PEEK (PT - 3) * 256 1090 TY = PEEK (PT - 2) 1100 RETURN 1110 PT = PT + 26:NU = NU - 1: ON NU > 0 GOTO 1030 1120 TY = - 1: RETURN 2000 REM *** READ 2 PASCAL BLOCKS *** 2010 BL = BK: GOSUB 3000 2020 BF = B1:SE = S1: GOSUB 4000 2030 BF = B2:SE = S2: GOSUB 4000 2040 BL = BK + 1: GOSUB 3000 2050 BF = B3:SE = S1: GOSUB 4000 2060 BF = B4:SE = S2: GOSUB 4000 2070 IF DR = 1 THEN PRINT CHR$ (7)"INSERT DOS DISK AND HIT RETURN ": GET I$: PRINT : HOME 2080 RETURN 3000 REM *** BLK -> TR/SE *** 3010 TR = INT (BL / 8):TMP = (BL / 8 - TR) * 8 3020 S2 = 2 * (7 - TMP):S1 = S2 + 1 3030 IF NOT TMP THEN S1 = 0 3040 IF TMP = 7 THEN S2 = 15 3050 RETURN 4000 REM *** CALL RWTS *** 4010 POKE TK,TR: POKE SC,SE: POKE HB,BF: POKE ER,0: CALL RWTS 4020 IF NOT PEEK (ER) THEN RETURN 4030 IF D$ = CHR$ (4) THEN PRINT D$"PR#0": PRINT D$"NOMONO" 4040 TEXT : HOME : PRINT G$"RWTS DISK ERROR "; PEEK (ER): POP : POP : GOTO 9020 5000 REM *** PASCAL DIRECTORY *** 5010 TEXT : HOME :BF = INT (BUFF / 256):TR = 0: FOR SE = 11 TO 4 STEP - 1: GOSUB 4000:BF = BF + 1: NEXT SE 5020 V$ = "":NL = BUFF + 6: FOR I = 1 TO PEEK (NL):V$ = V$ + CHR$ ( PEEK (NL + I)): NEXT I: PRINT V$":":L$ = "":Y = FRE (0) 5030 LN = 1:NF = PEEK (BUFF + 16): IF NOT NF THEN PRINT G$;: FLASH : PRINT CHR$ (219)"NO FILES" CHR$ (221): NORMAL : PRINT : PRINT "HIT " CHR$ (219)"C/R" CHR$ (221)" TO CONTINUE ": GET I$: PRINT : HOME : RETURN 5040 FOR I = 1 TO NF:ST = BUFF + I * 26 + 6:NL = PEEK (ST): ON NOT NL GOTO 5060 5050 FOR J = 1 TO NL:L$ = L$ + CHR$ ( PEEK (ST + J)): NEXT J: PRINT " "L$:L$ = "":Y = FRE (0):LN = LN + 1 5060 IF LN > 20 OR I = NF THEN PRINT : PRINT "HIT " CHR$ (219)"C/R" CHR$ (221)" TO CONTINUE": GET I$: PRINT : PRINT V$": ";:LN = 1 5070 NEXT I: RETURN 9000 REM ERROR HANDLER 9010 IF D$ = CHR$ (4) THEN PRINT D$"PR#0": PRINT D$"NOMONO" 9020 TEXT : PRINT : PRINT GS$"ERROR "; PEEK (222);" AT LINE "; PEEK (218) + PEEK (219) * 256 9030 POKE 216,0: IF (DR = 2 OR PA = 0) AND D$ = CHR$ (4) THEN PRINT D$"CLOSE" 9040 GOTO 470 9999 REM MINOR MODS BY VAL J GOLDING